-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide standard event handler. #229
Comments
I personally don't find the Registering event handlers would probably be as verbose as the current solution, in terms of lines of code, but with the added cost in terms of RAM and binary size. I expect this kind of user-friendly interface to be offered by Arduino-LoraWAN rather than LMIC. Of course, this is just my personal opinion. |
Unfortunately the name |
I agree that the name Maybe we could simply rename it |
Can't do that, breaks existing code. For my uses, I need the callbacks. I'm enclosing that in The RAM overhead is also negligible; the LMIC structure can be easily rearranged to save many bytes, because no thought was given to byte/word/dword alignment issues that are typical on ARM. (This is surprising because the original code was for ARM. I'm filing a separate bug for that.) |
Oh, I did not understand that this change would be backward compatible! Also, now that I can see the code, it appears that by defining 'LMIC_CFG_disable_user_events' one can opt-out from the cost of storing callback pointers. |
The current upcall-by-name strategy for event handling is really sub-optimal. Each sketch/application must duplicate the case statement and implement the message-based outcall. The Arduino-LoRaWAN library mitigates this, but... it brings in other libraries and is somewhat complex.
However, we don't want to break existing apps.
Although we could have a default event handler in the library with the same name as the user routine, that has caused subtle problems in the past for me, and so I don't think it's robust.
Perhaps this would work.
LMIC_registerEventHandler(pFunction, pClientData)
would get all events;LMIC_registerRxHandler(void (*pfn)(uint8_t port, const char *buffer, size_t len, void *pClientData);
would register a message receipt handler; and so forth. (Look at Arduino-LoRaWANonEvent
for guidance on what's needed.)LMIC_internalDispatchEvent
, and prototype would be in an internal header file (not included by lmic.h).onEvent()
, and a weak reference to the newLMIC_internalDispatchEvent
. If either pointer is non-zero, then the corresponding function is called. If both are non-zero, only the internal function is called (this means thatonEvent
is no longer a reserved symbol in user code).LMIC_internalDispatchEvent
does the work ofonEvent()
and dispatches as needed.The text was updated successfully, but these errors were encountered: