Navigation Menu

Skip to content
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

Create ne w"custom_io" packet sending model #7

Merged
merged 3 commits into from Jun 23, 2017

Conversation

torvalds
Copy link
Collaborator

This creates a new "custom_io" model that can be used to send and receive "packets" over some transport, currently only USBHID.

It also converts the two USBHID backends (Suunto EON Steel and Scubapro G2) to use that custom IO model.

The plan is to be able to then replace the USBHID transport with a BLE GATT-based transport fairly transparently to the libdivecomputer backends (I say "fairly", because the packetization is going to be exposed, and each dive computer backend will inevitably see some transport specifics because they have their own logic of how to encode the stream over the packet interface).

The custom IO handlers will be extended to not just do serial line
emulation (generally over Bluetooth rfcomm), but do BLE too.

BLE does not look like a serial protocol at all, it's packet-based, and
we may have to add specific routines to indicate which GATT endpoints to
use etc.  But like the traditional custom serial code, we want to do the
actual IO not from within libdivecomputer, but from the user of the
library (because the BLE support will require things like the Qt
Connectivity layer - and we do not want libdivecomputer to have to link
against something like Qt).

So this renames 'custom_serial' to 'custom_io', and instead names the
individual member function pointers 'serial_*' to make it clear that
those members are for serial communication.

It also adds new placeholders for packet_open/close/read/write.  Note
that while these may look similar to the serial counter-parts, they are
not the same or even necessarily mutually exclusive.  It is possible the
the caller fills in one or the other (or both), and they would be used
independently.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Basically, this alows us to hide the usbhid code behind the custom_io
abstraction, so that a dive computer could either be given a supplied
custom_io structure, of if none is given, would create one for a USBHID
device.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This means that they still default to their respective USB devices, but
you can now set custom IO structure to pass in your own data.

Not only will we hopefully have some kind of BLE support, you could also
use this to simply emulate packets from a log-file by having a packet
replay (or by actually emulating a device).  Of course, you can already
do this by actually emulating the device in a virtual environment, but
it might be useful for some kind of libdivecomputer testing environment.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
@dirkhh dirkhh merged commit b7699b6 into subsurface:Subsurface-branch Jun 23, 2017
@dahuoyzs
Copy link

good

@ghost
Copy link

ghost commented Sep 24, 2017

I approve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants