-
Notifications
You must be signed in to change notification settings - Fork 891
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
Simplify bluetooth API #69
Comments
another nice benefit of this change: someday exposing the same API over serial or a UDP socket becomes trivial. |
Hey @girtsf - I think I will do this now (I'll keep the old API working though). Doing it now will prevent me from wasting some work in the NRF52 port. |
(also - I need a way to tunnel debug output on that platform (rather than serial) so I think I'm going to make an adapter to (if the app asks) to squirt debug messages from the MCU over protobufs in FromRadio. This will also allow bug reports to include device debug putput) also - I just found a nice mac and linux friendly python api: https://github.com/adafruit/Adafruit_Python_BluefruitLE |
@girtsf Did you ever make much progress on the python client idea? (no pressure if not) I'm almost finished with these changes (changing the android app to use them later tonight?). But after that just to test that this new PhoneAPI class really is detached from bluetooth, I'm thinking an easy way to do that is to make a SerialPhoneAPI subclass, which can instantiate it on a serial port. To test that idea I'm interested in making a small python client. |
Merge pull request #69 from mc-hamster/master
In chat @girtsf asked (wrt the python API library/tool he's developing):
Yah, some of this is an accident of history. That was my original implementation - you can see some notes here in the inline docs for ToRadio and FromRadio:
https://github.com/meshtastic/Meshtastic-protobufs/blob/master/mesh.proto#L440
But I switched relatively early to the sixish ble characteristics you see there currently. There were two reasons (which kinda made since then but less so now):
With multiple characteristics I didn't need to build a state machine on the device side to provide complex behavior for when the phone reads FromRadio. i.e. I woudn't need to go "the phone has sent WantNodes to me, so I should send one node from the DB at a time until done with that and then go back to providing received messages from the mesh. In fact, thinking now about it I'm not sure such a statemachine is needed on the device side, it might be better to just pass through any RX mesh packets we have and only if none are waiting, send the node db records? (then let the phone be smart enough to not process those messages until it has a nodedb (which it needs to intelligently provide those messages to higher application layers)
I initially didn't have a working phone app (or trusted/working device bluetooth code), so it was super handy for me to be able to use a tool like NRFConnect to do initial debugging of the device side (and that tool doesn't understand protobufs).
Now that things are a bit more mature, I think it might be a super good idea to go back to just having only the two FromRadio and ToRadio characteristics. This could be done incrementally without breaking the android app by:
At startup read from FromRadio until you get back an empty packet. From then on just subscribe to NOTIFY ble messages for FromRadio. (This is similar to the android app)
Don't implement/use any of the other characteristics.
Uncomment the extra lines you see commented out in FromRadio and ToRadio. You'll also need to add a couple of other Protobufs in that 'API' for things like 'WantConfig', 'WantMyNodeInfo' etc... Change the device code that handles ToRadio writes to properly handle these new operations. Either you can do this, or if you don't feel comfortable yet mucking with that device code tell me you want me to do it.
Finish your python API using just these two characteristics. (Separately I'll change the android app to only use these two characteristics)
Delete the 4ish unneeded characteristics from the docs and the device code.
(cc @jeksys because useful and relevant to you)
The text was updated successfully, but these errors were encountered: