Add support for publishing individual records#47
Add support for publishing individual records#47nvelozsavino wants to merge 7 commits intoThingSet:mainfrom
Conversation
martinjaeger
left a comment
There was a problem hiding this comment.
Thanks for the contribution. That's a useful update.
Got two small remarks.
src/thingset_txt.c
Outdated
| if (len_value <= 0) { | ||
| return 0; | ||
| } | ||
| len+=len_value; |
There was a problem hiding this comment.
Please add two spaces for consistent code format:
| len+=len_value; | |
| len += len_value; |
| if (len >= buf_size - 1) { | ||
| return 0; | ||
| } |
There was a problem hiding this comment.
I think this check is not necessary as the maximum available size was already provided to ts_json_serialize_value before. So if no error occurred, the data will always fit into the buffer.
martinjaeger
left a comment
There was a problem hiding this comment.
Thanks for the update. Looks good from function point of view. There are only some small style issues left and the unit test has to be enabled.
In order to actually execute the new unit test, it has to be added to zephyr/tests/src/main.c (for Zephyr) and test/main.cpp for PlatformIO.
Can you please make the coding style consistent with the rest of the code (especially regarding spaces). The style is following the Libre Solar style.
src/thingset_txt.c
Outdated
| return snprintf(buf, size, "%" PRIu8 ",", *((uint8_t *)data)); | ||
| case TS_T_INT8: | ||
| return snprintf(buf, size, "%" PRIi8 ",", *((int8_t *)data)); | ||
| case TS_T_BOOL: |
There was a problem hiding this comment.
TS_T_BOOL is already covered. See line 135.
|
|
||
| // TXT STATEMTENT DATA /////////////////////////////////////////////////////// | ||
|
|
||
| TS_GROUP(ID_TXT,"TXT",TS_NO_CALLBACK,ID_ROOT), |
There was a problem hiding this comment.
| TS_GROUP(ID_TXT,"TXT",TS_NO_CALLBACK,ID_ROOT), | |
| TS_GROUP(ID_TXT, "TXT", TS_NO_CALLBACK, ID_ROOT), |
|
|
||
|
|
| {"TXT/rBoolFalse","false"}, | ||
| }; | ||
|
|
||
| for (size_t i=0;i<ARRAY_SIZE(tests);i++){ |
There was a problem hiding this comment.
| for (size_t i=0;i<ARRAY_SIZE(tests);i++){ | |
| for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { |
|
The unit tests are failing. |
|
Unit tests are still failing because you added new data items which would have to be considered in the tests that discover all data objects. Not sure if adding new data items is really needed or if we can just test with the existing ones. |
|
BTW: You can easily run the unit tests in your local Zephyr environment with the commands explained here: https://github.com/ThingSet/thingset-device-library/blob/main/zephyr/tests/README.md |
145c21f to
0e93f34
Compare
calling ts_txt_statement on an ts_object pointing a simple item now adds to the buffer the item with the format #
Ex:
#/foo/rBar 23