[riot-notifications] [RIOT-OS/RIOT] sys/senml: add SenML modules (#16384)

Philipp Blum notifications at github.com
Wed Sep 22 18:01:44 CEST 2021

> SAUL is structured in such a way that the dimensions of sensor values are entirely unknowable until you actually read it. I think it can even change on every read (theoretically). This means that the number of sensors and the number of SenML values have a ratio of somewhere between `1` and `PHYDAT_DIM`, and we cannot determine beforehand how many SenML values will be returned.
> As for passing a list with a number of sensors: is it common to have a list in such a way? Why not just pass a `saul_reg_t *dev`, as that's a linked list already?

I think a point you forget is that a user can also create a custom linked list of `saul_reg_t`. Additionally to the default SAUL register. This may be even needed for certain use-cases. Or, like in my case, I need to individually encode each sensor.
I don't want to have one endpoint with all sensors. I need them under seperated endpoints. With the current design of your API, I can't do my use case. I don't mind having a different API for it. I just need to be able to encode each device individually and a custom list.

> Taking the above into account, I have split the implementation in two functions:
> ```c
> int senml_saul_reg_encode_cbor(nanocbor_encoder_t *enc, saul_reg_t *dev);
> size_t senml_saul_encode_cbor(uint8_t *buf, size_t len, saul_reg_t *reg);
> ```
> The first function encodes all dimensions of a SAUL sensor (and returns the number of dimensions encoded), and the second one is encodes all functions in a registry. The second one is extremely simple now, and I think it would be fine to move that to the example if so desired.

For the second function: Why not having `nanocbor_encoder_t ` here as well. I am not familiar with nanocbor. Can't you reuse the encoder instead of initializing another one for each device you may encode?

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210922/7d91f26c/attachment.htm>

More information about the notifications mailing list