bakercp / PacketSerial

An Arduino Library that facilitates packet-based serial communication using COBS or SLIP encoding.
http://bakercp.github.io/PacketSerial/
MIT License
280 stars 59 forks source link

Callback supporting member function #27

Closed embedded-creations closed 3 years ago

embedded-creations commented 3 years ago

I have the same issue as #13, and found a workaround by adding some code into setup(), but I'd really love to keep PacketSerial fully inside my class. As it stands now, it won't work as 'this' was not captured for this lambda function if I try to setup the lambda function within my class. If I could have the callback return return an optional void* which I setup to point to my class, I could have the callback call a static method in my class.

https://wiki.c2.com/?VirtualStaticIdiom

Please LMK if you'd be interested in supporting this and I can at least prototype how I think it should work, though you might have a better solution than I could come up with. (This is my first time learning about lambda functions let alone trying to use one)