Move38 / Blinks-SDK

Development for Blinks starts here. This codebase includes everything you need to get up and running in the Arduino IDE with Blinks.

Home Page:http://forum.move38.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sendDatagramOnFace should indicate ignored packets

mdm373 opened this issue · comments

Without looking at the source it was not obvious why my blink was not sending datagrams since no panic / error was thrown when sending the datagram and the function to send datagrams was void. After going in circles I finally took a look at the source / header notes and noticed the ignore condition. A better function signature might save other devs from my pain 😵

sendDatgramOnFace skips packets of length larger than IR_DATAGRAM_LEN but the function signature does not indicate that the datagram was ignored. It would be helpful to change this function's return type to boolean indicating if the packet was sent.
https://github.com/Move38/Blinks-SDK/blob/master/cores/blinklib/blinklib.cpp#L256

Since we are on a very resource constrained platform here (the FLASH image typically has single digits of bytes to spare!), probably not practical add a return value here. Unfortunately in C/C++ there is also no easy way I know of to enforce this constraint on the caller at compile time (do you know one?!), so we are left with documenting it as part of the function's contract.

This behavior is documented in the definition for the function....

https://github.com/Move38/Blinks-SDK/blob/master/cores/blinklib/blinklib.h#L108

...but should be explicitly called out everywhere the function is documented. Let us know where the incomplete description were you working off of is so we can get that one fixed!

Thanks!

The documentation was clear, no problems there and no, I don't think its impossible to enforce a length at compile time. You could enforce it at run time with an error thrown but that seems less than ideal. I was thinking of the return value more along the lines of self documenting code but I wasn't thinking about the memory constraints. From that perspective I appreciate every byte!