Skip to content

Commit

Permalink
Development (#76)
Browse files Browse the repository at this point in the history
* Fixed include paths

* implement make install

* remove build dir

* replace build with out dir

* replace build with out dir

* rename makro

* include pahomqtt path for include dir, and *.h files for install

* rpi remark

* add valgrind;fix tests

* test are not part of the all;update readme with valgrind

* allow installing mqtt dep

* Install include files independently

* first copy PAHO_MQTT_HEADER_FILES

* separate install includes

* example build selection

* run build on aciton with sudo to install dep

* missing valgrind for actions

* Changed folder structure

* Initial scattering/file changes

* Permission changes; Defining types;

* Attribute model

* Parameter model

* Feed model

* Model for incoming feed values

* Updated reading not to include manifest

* Added new handles to wolk object

* Added pipeline for parser to be implemented; Implemented serialization of simple messages

* Revised permissions

* Temporary simple example, for testing capabilities of new software

* all

* disable pahoc installation at /usr/lib

* init char array

* rename MANIFEST_ITEM_REFERENCE_SIZE into REFERENCE_SIZE

* first_reading into readings

* clear readings, clear recieved char array, form DT payloads

* rename defines, remove manifest, intorduce wolk_readings_t,  wolk_add_numeric_feed

* change for type int to size_t;intorduce reading data type

* separate parsing based on the message type

* implement remove feed and register bulk

* implement multiple attribute registration;outbound message init

* receive feeds, paramters and time

* Implement details_synchronization;

* introduce feed_registration_t, wolk_init_feed;remove reading term; remove lastwill from disconnect;implement examples

* reading to feed

* remove readings.h and .c

* remove unused

* adding header to files;add unit to format at cmake;init word into initialize;cover feed serialization tests

* implement parameter_value_handler, wolk_init_parameter and wolk_set_value_parameter;

* md5 from PCSXALL repo

* insert new topic; subs to p2d; remove fw verison

* implement wolk_init_attribute; implement md5 checksum comparison

* format; remove local var for topic

* test fix including md5.h

* file list struct;

* delete files;abort;receive files with multiple chunks

* url download

* url download error mngt

* update exmaples with defualt values

* stop if defined chunk size is out of the range

* fm implementation;remove version;new topics

* fix compiler warnings

* update readmes

* add NL at the eol;

* Feat/build doc with actions (#79)

* add Doxygen Action

* add deployment gh-pages

* doc deploy

* remove Unexpected input(s) for action gh-pages

* docs path

* remove workign dir

* remove pub dir

* run doxygen

* only run

* create nojekyll

* run Doxyfile

* force branch

* new way

Signed-off-by: srdjanStankovic <srdjanrstankovic@gmail.com>

* deploy

* runs on

* remove

* comment doxyfile-path:

* work dir

* doc to docs

* update comments

Co-authored-by: srdjanStankovic <srdjanrstankovic@gmail.com>

* Feat/build doc with actions (#80)

* add Doxygen Action

* add deployment gh-pages

* doc deploy

* remove Unexpected input(s) for action gh-pages

* docs path

* remove workign dir

* remove pub dir

* run doxygen

* only run

* create nojekyll

* run Doxyfile

* force branch

* new way

Signed-off-by: srdjanStankovic <srdjanrstankovic@gmail.com>

* deploy

* runs on

* remove

* comment doxyfile-path:

* work dir

* doc to docs

* update comments

* add dependency between jobs

* add working dir

* publish dir update

* deploy at the same time

* remove doxygen from apt install

Co-authored-by: srdjanStankovic <srdjanrstankovic@gmail.com>

* change host name input

* remove ca.crt file;fix FIRMWARE_UPDATE_CHECK_TIME neutral value

* create out dir

Co-authored-by: srdjanStankovic <srdjanrstankovic@gmail.com>
Co-authored-by: srdjastankovic <srdjan.stankovic@wolkabout.com>
Co-authored-by: LazarBozic94 <lazar.bozic@wolkabout.com>
  • Loading branch information
4 people authored May 23, 2022
1 parent 4cbc7a5 commit 8560d00
Show file tree
Hide file tree
Showing 102 changed files with 4,417 additions and 4,419 deletions.
28 changes: 23 additions & 5 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2

- name: Install dependencies
run: sudo apt update && sudo apt-get install -y libz-dev wget gcc g++ cmake libssl-dev clang-format ruby
run: sudo apt update && sudo apt-get install -y libz-dev wget gcc g++ cmake libssl-dev clang-format ruby valgrind doxygen

- name: Install Unit Test toolset
run: sudo gem install ceedling
Expand All @@ -30,14 +30,32 @@ jobs:
run: ./configure

- name: Build
working-directory: ${{github.workspace}}/build
working-directory: ${{github.workspace}}/out
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: make all -j$(nproc)
# Execute the out. You can specify a specific target with "--target <NAME>"
run: sudo make all -j$(nproc)

- name: Test
working-directory: ${{github.workspace}}/build
working-directory: ${{github.workspace}}/out
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: make tests

# Build the Doxygen documentation
- name: Doxygen Action
uses: mattnotmitt/doxygen-action@v1.1.0
with:
doxyfile-path: ./Doxyfile
working-directory: .

# Deploy the HTML documentation to GitHub Pages
- name: GH Pages Deployment
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/html/
enable_jekyll: false
allow_empty_commit: false
force_orphan: true
publish_branch: gh-pages
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ release
cmake-build-release
build
cmake-build-debug
.vscode

# Out directory
out
Expand Down
39 changes: 30 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,23 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic \
-Wcast-qual \
-Wstrict-prototypes \
-Wmissing-prototypes \
-Wconversion \
-fsanitize=address \
-static-libasan")
-Wconversion")

set(LIBRARY_NAME "WolkConnector-C")

include_directories("sources")
file(GLOB_RECURSE HEADER_FILES "sources/*.h")
file(GLOB_RECURSE SOURCE_FILES "sources/*.c")

include_directories("examples")
file(GLOB_RECURSE SIMPLE_HEADER_FILES "examples/simple/*.h")
file(GLOB_RECURSE SIMPLE_SOURCE_FILES "examples/simple/*.c")
file(GLOB_RECURSE PULL_HEADER_FILES "examples/pull/*.h")
file(GLOB_RECURSE PULL_SOURCE_FILES "examples/pull/*.c")
file(GLOB_RECURSE REGISTER_FEED_AND_ATTRIBUTE_HEADER_FILES "examples/register_feed_and_attribute/*.h")
file(GLOB_RECURSE REGISTER_FEED_AND_ATTRIBUTE_SOURCE_FILES "examples/register_feed_and_attribute/*.c")
file(GLOB_RECURSE FULL_EXAMPLE_HEADER_FILES "examples/full_feature_set/*.h")
file(GLOB_RECURSE FULL_EXAMPLE_SOURCE_FILES "examples/full_feature_set/*.c")
file(GLOB_RECURSE TESTS_SOURCE_FILES "tests/test/*.c")

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/lib")
Expand All @@ -68,9 +70,10 @@ link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})

#Dependencies
add_subdirectory(dependencies)
include_directories(dependencies/pahomqttembeddedc/MQTTPacket/src)

add_library(${LIBRARY_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
target_include_directories(${LIBRARY_NAME} PUBLIC sources)
target_include_directories(${LIBRARY_NAME} PUBLIC dependencies/pahomqttembeddedc/MQTTPacket/src)
target_link_libraries(${LIBRARY_NAME} paho-embed-mqtt3c ssl crypto)
set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS "-Wl,-rpath,./")

Expand All @@ -81,22 +84,40 @@ add_custom_target(format ALL
COMMAND "clang-format" -i -sort-includes -style=file
${HEADER_FILES} ${SOURCE_FILES}
${FULL_EXAMPLE_HEADER_FILES} ${FULL_EXAMPLE_SOURCE_FILES}
${PULL_HEADER_FILES} ${PULL_SOURCE_FILES}
${REGISTER_FEED_AND_ATTRIBUTE_HEADER_FILES} ${REGISTER_FEED_AND_ATTRIBUTE_SOURCE_FILES}
${SIMPLE_HEADER_FILES} ${SIMPLE_SOURCE_FILES}
${TESTS_SOURCE_FILES}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "[Formatting source code]"
VERBATIM)

# Run Unit tests
set(TEST_FILES "${CMAKE_SOURCE_DIR}/tests")
set(TEST_FILES "${CMAKE_CURRENT_LIST_DIR}/tests")

add_custom_target(tests ALL
add_custom_target(tests
WORKING_DIRECTORY "${TEST_FILES}"
DEPENDS pahomqttembeddedc
COMMAND ceedling clean
COMMAND ceedling test:all
COMMENT "[Run Unit tests]"
VERBATIM)

file(GLOB_RECURSE PAHO_MQTT_HEADER_FILES "dependencies/pahomqttembeddedc/MQTTPacket/src/*.h")
#install library at /usr/lib
install(DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} DESTINATION /usr
FILES_MATCHING
PATTERN "*so*")
#install headers at /usr/include
install(FILES ${PAHO_MQTT_HEADER_FILES} DESTINATION /usr/include)
install(FILES ${HEADER_FILES} DESTINATION /usr/include)
install(CODE "MESSAGE(\"Installed WolkConnector-C\")")

# Examples
add_subdirectory(examples/simple)
add_subdirectory(examples/full_feature_set)
OPTION(BUILD_EXAMPLES "Build the library examples" ON)
if (${BUILD_EXAMPLES})
add_subdirectory(examples/simple)
add_subdirectory(examples/pull)
add_subdirectory(examples/register_feed_and_attribute)
add_subdirectory(examples/full_feature_set)
endif()
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
╚██████╗
╚═════╝
```
[![Build Status](https://travis-ci.com/Wolkabout/WolkConnect-C.svg?branch=master)](https://travis-ci.com/Wolkabout/WolkConnect-C)
[![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.

Expand All @@ -24,9 +24,6 @@ This allows WolkConnect-C Connector to work on wide variety of systems, bare met

Given examples are intended to be run on Debian based system.

Supported protocol(s):
* WOLKABOUT PROTOCOL

Prerequisite
------
Following tools/libraries are required in order to build WolkConnect-C Connector
Expand All @@ -38,18 +35,19 @@ Following tools/libraries are required in order to build WolkConnect-C Connector
* clang-format
* ruby
* ceedling
* valgrind

Former 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`
`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 generated by invoking `./configure`
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` in terminal.
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.

Expand All @@ -58,7 +56,7 @@ 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 sensor reading.
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 */
Expand All @@ -81,19 +79,18 @@ static wolk_ctx_t wolk;
wolk_init(&wolk, /* Context */
send_buffer, /* See send_func_t */
receive_buffer, /* See recv_func_t */
NULL, /* Actuation handler - see actuation_handler_t */
ACTUATOR_STATE_READY, /* Actuator status provider - see actuator_status_provider_t */
NULL, /* Configuration handler - see configuration_handler_t */
NULL, /* Configuration provider - see configuration_provider_t */
device_key, device_password, /* Device key and password provided by WolkAbout IoT Platform upon device creation */
PROTOCOL_WOLKABOUT, /* Protocol specified for device */
NULL, /* Array of actuator references */
NULL); /* Number of actuator references */
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 */
true); /* If storage is full overwrite oldest item when pushing */
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
Expand All @@ -105,24 +102,26 @@ See `send_func_t` and `send_func_t` in `sources/wolk_connector.h`
```c
wolk_connect(&wolk);
```
**Adding sensor readings:**
**Adding feed example:**
```c
wolk_add_numeric_sensor_reading(&wolk, "T", 23.4, 0);
wolk_numeric_feeds_t feed = {0};
feed.value = 23;
wolk_add_numeric_feed(&wolk, "T", &feed, 1)
```
**Data publish strategy:**
Sensor reading is pushed to WolkAbout IoT platform on demand by calling
Data is pushed to WolkAbout IoT platform on demand by calling
```c
wolk_publish(&wolk);
```

**Cooperative scheduling:**

Fuction `wolk_process(wolk_ctx_t *ctx)` is non-blocking in order to comply with cooperative scheduling,
and it must to be called periodically.
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, 5);
wolk_process(&wolk, 1);
```
**Disconnecting from the platform:**
Expand All @@ -146,7 +145,7 @@ wolk_init_custom_persistence(&wolk,
persistence_is_empty_impl);
```
For more info on persistence mechanism see `sources/persistence.h` and `sources/in_memory_persistence.h` files.
For more info on persistence mechanism see `sources/persistence/persistence.h` and `sources/persistence/in_memory_persistence.h` files.
**Additional functionality**
Expand Down
4 changes: 2 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
mkdir -p build
mkdir -p out

cd build || exit
cd out || exit
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
9 changes: 4 additions & 5 deletions dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ include(ExternalProject)
set(PAHO_MQTT_EMBEDDED_C_VERSION "1.1.0")

if(NOT DEFINED CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_BINARY_DIR}/build")
set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_BINARY_DIR}/out")
endif(NOT DEFINED CMAKE_PREFIX_PATH)
include_directories(SYSTEM "${CMAKE_PREFIX_PATH}/include")

ExternalProject_Add(pahomqttembeddedc
SOURCE_DIR "${CMAKE_SOURCE_DIR}/dependencies/pahomqttembeddedc"
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/pahomqttembeddedc"
GIT_REPOSITORY "https://github.com/eclipse/paho.mqtt.embedded-c"
GIT_TAG "v${PAHO_MQTT_EMBEDDED_C_VERSION}"
UPDATE_COMMAND ""
INSTALL_COMMAND ""
CMAKE_ARGS -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} -DCMAKE_INSTALL_PREFIX=${CMAKE_PREFIX_PATH} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_INSTALL_RPATH='.'
)
CMAKE_ARGS -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} -DCMAKE_INSTALL_PREFIX=${CMAKE_PREFIX_PATH} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_INSTALL_RPATH='.' INSTALL_COMMAND ""
)
6 changes: 3 additions & 3 deletions docs/templates/WolkConnect-Functional-Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Sensor readings like GPS and accelerometers that hold more than one single infor
####Alarms


Alarms are derived from some data on the device and are used to indicate the state of a condition, eg. high-temperature alarm which emerged as a result of exceeding a threshold value on the device. Alarm value can either be on or off.
Alarms are derived from some data on the device and are used to indicate the state of a condition, eg. high-temperature_value alarm which emerged as a result of exceeding a threshold value on the device. Alarm value can either be on or off.

Like sensor readings, alarm messages are stored on the device before being published to WolkAbout IoT Platform. Alarms can also have a UTC timestamp to denote when the alarm occurred, but if the timestamp is omitted then WolkAbout IoT Platform will assign a timestamp when it receives the alarm message.

Expand Down Expand Up @@ -141,7 +141,7 @@ To summarize, when the actuation command is issued from WolkAbout IoT Platform,
####Configuration


Configuration is the dynamical modification of the device properties from WolkAbout IoT Platform with the goal to change device behavior, eg. measurement heartbeat, sensors delivery reduction, enabling/disabling device interfaces, increase/decrease device logging level, etc.
Configuration is the dynamical modification of the device properties from WolkAbout IoT Platform with the goal to change device behavior, eg. measurement heartbeat_value, sensors delivery reduction, enabling/disabling device interfaces, increase/decrease device logging level, etc.

Configuration requires the same way of handling messages as actuations do. When a configuration command is issued from WolkAbout IoT Platform, it will be passed to the configuration handler that will attempt to execute the command. Then the configuration status provider will report back to WolkAbout IoT Platform with the current values of the configuration parameters, with the addition that configuration parameters are always sent as a whole, even when only one value changes.

Expand Down Expand Up @@ -179,5 +179,5 @@ This firmware handler will specify the following parameters:

To see how to utilize WolkConnect library APIs, visit one of the following files and look up detailed information in the Example Usage section:

- [Simple example README.md](https://github.com/Wolkabout/WolkConnect-C/blob/master/README.md) - demonstrates the sending of a temperature sensor reading
- [Simple example README.md](https://github.com/Wolkabout/WolkConnect-C/blob/master/README.md) - demonstrates the sending of a temperature_value sensor reading
- [Full feature set example README.md](https://github.com/Wolkabout/WolkConnect-C/blob/master/examples/full_feature_set/README.md) - demonstrates full WolkAbout IoT Platform potential
2 changes: 1 addition & 1 deletion examples/full_feature_set/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
# limitations under the License.
#

add_executable(full-feature-set main.c sensor_readings.c file_management_implementation.c firmware_update_implementation.h firmware_update_implementation.c)
add_executable(full-feature-set main.c file_management_implementation.c file_management_implementation.h firmware_update_implementation.h firmware_update_implementation.c)

target_link_libraries(full-feature-set WolkConnector-C pthread)
Loading

0 comments on commit 8560d00

Please sign in to comment.