Closed martinjaeger closed 2 years ago
Data nodes are now called data objects (as it was already the case in a very early version of the protocol) in order to avoid confusion with IoT devices, which are also often called "nodes" Leaf nodes containing actual data (like Bat_V) are called data items.
Why not also adapt type names to new nomenclature?
Data nodes are now called data objects (as it was already the case in a very early version of the protocol) in order to avoid confusion with IoT devices, which are also often called "nodes" Leaf nodes containing actual data (like Bat_V) are called data items.
Why not also adapt type names to new nomenclature?
- struct ts_data_nodes -> struct ts_data_objects
- node -> data_object
- endpoint -> data_item
Good point. I was planning to do that, but thought it might be better to wait with this find & replace action until your remaining changes are included aswell, as such changes make rebasing very difficult. Or do you think I should add it to this PR right away?
such changes make rebasing very difficult. Or do you think I should add it to this PR right away?
I was a general remark. Please wait, I will update PR #10 today or tomorrow.
Please also update zephyr/tests/src/main.c to changed and new tests.
LGTM
Thanks for the reviews. I'm currently working on a few more updates to match v0.4 spec which I'm going to add to this PR. Will be ready for final review probably by end of today.
Quick summary of the new commits:
subset
(previously called pubsub
channel) of all data items. These should be used for such purposes now. They do not contain the first ThingSet byte and an endpoint/path.This is now ready to be merged from my side. I will open some issues for features that are still missing from the specification (e.g. retrieving names for given data object IDs).
I created test coverage data using the the Zephyr tests:
The following functions are not tested at all:
Some are obviously not complex and the functionality may be covered by other tests (ts_bin_statement_by_id, ts_txt_statement_by_id). cbor_deserialize_decimal_fraction() is a noop always returning 0.
I think ts_dump_json() and cbor_deserialize_int64() are good candidates for additional tests.
Some comments regarding missing test coverage:
- ts_bin_statement_by_id()
I will add a quick test.
- ts_dump_json()
I did not really consider this function part of the library, but used it only for testing / debugging purposes (e.g. in the example application). But we could still add some tests. I will open a separate issue to improve test coverage.
- ts_txt_statement_by_id()
I will add a quick test.
- cbor_deserialize_int64()
This function is covered in the following tests, but they are currently not enabled by default: https://github.com/LibreSolar/thingset-device-library/blob/0e695f719bb8cf10de212b2b9f41fba65d9327df/test/test_common.c#L192-L197
- cbor_deserialize_decimal_fraction()
Would you suggest to add a test even though it's currently a noop? Just so that we have one and once it's implemented the test is not forgotten?
cbor_deserialize_int64()
This function is covered in the following tests, but they are currently not enabled by default:
Sorry, forgot to enable. Now it is tested. Much better coverage !-)
Would you suggest to add a test even though it's currently a noop? Just so that we have one and once it's implemented the test is not forgotten?
Yes, you may add an additional message in case the number of bytes processed != 0. This makes the test fail in case the function is implemented in some way.
// preset data with decimal fraction float (e.g. 1.5)
int num_bytes = cbor_deserialize_decimal_fraction(data, mantissa, exponent);
TEST_ASSERT_EQUAL_INT_MESSAGE(0, num_bytes, "Please improve test for cbor_deserialize_decimal_fraction()!")
I started to actually implement the decimal fraction function instead of adding a dummy test. But it's taking a bit longer than expected. As it's not really the scope of this PR, I will create a separate PR for that.
@b0661 Can you have a final look at the new commit where I added the missing unit tests for ts_txt_statement_by_id()
and ts_bin_statement_by_id()
?
This PR contains some bugfixes and updates for the new specification v0.4 as suggested in https://github.com/LibreSolar/thingset/pull/18.
See commit messages and protocol spec updates for details.
@b0661 I would appreciate your feedback aswell.