Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wolkabout/wolkconnect-c
C99 Connector library which provides easy connectivity to WolkAbout IoT Platform.
https://github.com/wolkabout/wolkconnect-c
c99 client-library connectivity dfu fota iot iot-platform wolkabout wolkconnect
Last synced: about 2 months ago
JSON representation
C99 Connector library which provides easy connectivity to WolkAbout IoT Platform.
- Host: GitHub
- URL: https://github.com/wolkabout/wolkconnect-c
- Owner: Wolkabout
- License: apache-2.0
- Created: 2017-09-11T11:04:01.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-08-18T06:20:41.000Z (over 2 years ago)
- Last Synced: 2024-03-27T05:59:29.198Z (9 months ago)
- Topics: c99, client-library, connectivity, dfu, fota, iot, iot-platform, wolkabout, wolkconnect
- Language: C
- Homepage: https://demo.wolkabout.com
- Size: 1.21 MB
- Stars: 3
- Watchers: 5
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
```
██╗ ██╗ ██████╗ ██╗ ██╗ ██╗ ██████╗ ██████╗ ███╗ ██╗███╗ ██╗███████╗ ██████╗████████╗
██║ ██║██╔═══██╗██║ ██║ ██╔╝██╔════╝██╔═══██╗████╗ ██║████╗ ██║██╔════╝██╔════╝╚══██╔══╝
██║ █╗ ██║██║ ██║██║ █████╔╝ ██║ ██║ ██║██╔██╗ ██║██╔██╗ ██║█████╗ ██║ ██║
██║███╗██║██║ ██║██║ ██╔═██╗ ██║ ██║ ██║██║╚██╗██║██║╚██╗██║██╔══╝ ██║ ██║
╚███╔███╔╝╚██████╔╝███████╗██║ ██╗╚██████╗╚██████╔╝██║ ╚████║██║ ╚████║███████╗╚██████╗ ██║
╚══╝╚══╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═╝
██████╗
██╔════╝
█████╗██║
╚════╝██║
╚██████╗
╚═════╝
```
[![CMake](https://github.com/Wolkabout/WolkConnect-C/actions/workflows/cmake.yml/badge.svg?branch=development)](https://github.com/Wolkabout/WolkConnect-C/actions/workflows/cmake.yml)
-----
WolkAbout C99 Connector library for connecting devices to WolkAbout IoT platform instance.WolkConnect-C is transportation layer agnostic which means it is up to the user of the library to open socket to WolkAbout IoT platform,
configure SSL if desired, and forward read/write implementation to WolkConnect-C Connector.
WolkConnect-C Connector is not thread safe, and is written with cooperative scheduling in mind.
This allows WolkConnect-C Connector to work on wide variety of systems, bare metal to OS based ones.Given examples are intended to be run on Debian based system.
Prerequisite
------
Following tools/libraries are required in order to build WolkConnect-C Connector* libz-dev & wget
* gcc & g++
* cmake - version 2.8 or later
* libssl-dev
* clang-format
* ruby
* ceedling
* valgrindFormer can be installed on Debian based system from terminal by invoking
`sudo apt-get install libz-dev wget gcc g++ cmake libssl-dev clang-format ruby valgrind`
`gem install ceedling`
When dependencies are installed, Unix Makefiles build system can be generated by invoking `./configure`
Generated build system is located inside `build` directory.
WolkConnect-C Connector library, and example are built from `build` directory by invoking `make all` in terminal.
Library application is built to `out/lib` directory, and example application is built to `out/bin` directory.
Example Usage
-------------
**Initialize WolkConnect-C Connector**Create a device on WolkAbout IoT platform using `Simple example` device type.
This device type fits [simple example](https://github.com/Wolkabout/WolkConnect-C/blob/master/examples/simple/main.c) and demonstrates the periodic sending of a temperature_value sensor reading.```c
/* WolkAbout Platform device connection parameters */
static const char* device_key = "device_key";
static const char* device_password = "some_password";
static const char* hostname = "insert_host";
static int portno = 80; // TODO: insert port
static char certs[] = "../ca.crt";/* Sample in-memory persistence storage - size 1MB */
static uint8_t persistence_storage[1024*1024];/* WolkConnect-C Connector context */
static wolk_ctx_t wolk;//...
//...
//...wolk_init(&wolk, /* Context */
send_buffer, /* See send_func_t */
receive_buffer, /* See recv_func_t */
device_key, device_password, /* Device key and password provided by WolkAbout IoT Platform upon device creation */
PUSH, /* Device outbound mode - see outbound_mode_t */
NULL, /* Feeds handler - see feed_handler_t */
NULL, /* Parameters handler - see parameter_handler_t */
NULL); /* Details synchronization handler - see details_synchronization_handler_t */wolk_init_in_memory_persistence(&wolk, /* Context */
persistence_storage, /* Address to start of the memory which will be used by persistence mechanism */
sizeof(persistence_storage), /* Size of memory in bytes */
false); /* If storage is full overwrite the oldest item when pushing */wolk_connect(&wolk);
```
Considering that WolkConnect C Connector is transportation layer agnostic, it is up to the user of it to open connection to
WolkAbout IoT Platform, optionally setup TLS, and forward read/write callbacks WolkConnect-C Connector in initialization
step.See `send_func_t` and `send_func_t` in `sources/wolk_connector.h`
**Establishing connection with WolkAbout IoT platform:**
```c
wolk_connect(&wolk);
```
**Adding feed example:**
```c
wolk_numeric_feeds_t feed = {0};
feed.value = 23;
wolk_add_numeric_feed(&wolk, "T", &feed, 1)
```
**Data publish strategy:**Data is pushed to WolkAbout IoT platform on demand by calling
```c
wolk_publish(&wolk);
```**Cooperative scheduling:**
Function `wolk_process(wolk_ctx_t *ctx)` is non-blocking in order to comply with cooperative scheduling,
and it must be called periodically.```c
wolk_process(&wolk, 1);
```**Disconnecting from the platform:**
```c
wolk_disconnect(&wolk);
```**Data persistence:**
WolkConnect-C provides mechanism for persisting data in situations where readings can not be sent to WolkAbout IoT platform.
Default implementation can work with in-memory or memory mapped storage.Persisted readings are sent to WolkAbout IoT platform, in batches, on publish function call.
In cases when provided persistence implementation is suboptimal, one can use custom persistence by providing custom implementation.
```c
wolk_init_custom_persistence(&wolk,
persistence_push_impl,
persistence_peek_impl, persistence_pop_impl,
persistence_is_empty_impl);
```For more info on persistence mechanism see `sources/persistence/persistence.h` and `sources/persistence/in_memory_persistence.h` files.
**Additional functionality**
WolkConnect-C library has integrated additional features which can perform full WolkAbout IoT platform potential. Read more about full feature set example [HERE](https://github.com/Wolkabout/WolkConnect-C/tree/master/examples/full_feature_set).