Include user context in sx127x struct#20
Include user context in sx127x struct#20morandg wants to merge 1 commit intodernasherbrezon:mainfrom
Conversation
This addition supports better integration with object-oriented programming languages like C++ and simplifies event dispatching when managing multiple device instances.
|
Good idea! However normally In the example above On the other hand, if we add something similar to the library, then it will require new major version, because it won't be backward compatible anymore. Let me think about it. |
|
Thanks for your feedback! I came up with this approach first because it doesn't break the API. Since you are thinking about it, let me share my thoughts. Probably using the same context for every callback would be sufficient. I wanted first pass it during As you mentioned, giving it back during the callback ( On the other hands, having the I'm not sure what would be the best, it's yours to decide 😉 ! |
|
User context object was included into 5.x release. This release contains several backward incompatible changes including this one. void sx127x_rx_set_callback(void (*rx_callback)(void *, uint8_t *, uint16_t), void *arg, sx127x *device); |
|
Awesome, thanks for letting me know! |
Hi @dernasherbrezon!
Here is another suggestion. It allows me to get rid of an ugly singleton in my cpp application. Now I can do something like:
This is just a proposal, let me know if it makes sense to you or do you see a different approach to achieve what I want to do? I can also add some tests when required.