From 196adb591bd167bc4ee3387c7836f037d106cb5b Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 12 Jun 2017 19:47:50 -0700 Subject: Very early and likely quite broken BLE GATT code This is some very early and hacky code to be able to access BLE-enabled dive computers that use the GATT protocol to send packets back and forth (which seems to be pretty much all of them: a vendor-specific GATT service with a write characteristic and a notification characteristic for reading). For testing only. But it does successfully let me download dives from my EON Steel and my Scubapro G2. NOTE! There are several very hacky pieces in here, including just "knowing" that the write characteristic is the first one, and the notification characteristic is second. The code should actually check the properties rather than have those kinds of hardcoded assumptions. It also checks "vendor specific" by looking at the UUID string representation, and knowing that the standard ones start with zero. Crazily, there doesn't seem to be any normal way to test for this, although I guess that maybe the uuid.minimumSize() function could be used. There are other nasty corners. Don't complain, send me patches. Signed-off-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- core/qtserialbluetooth.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'core/qtserialbluetooth.cpp') diff --git a/core/qtserialbluetooth.cpp b/core/qtserialbluetooth.cpp index d23265d42..ab05a1c73 100644 --- a/core/qtserialbluetooth.cpp +++ b/core/qtserialbluetooth.cpp @@ -19,6 +19,10 @@ #include +#ifdef BLE_SUPPORT +# include "qt-ble.h" +#endif + QList registeredUuids; static QBluetoothUuid getBtUuid() @@ -414,7 +418,15 @@ dc_custom_io_t qt_serial_ops = { .serial_set_dtr = NULL, .serial_set_rts = NULL, .serial_set_halfduplex = NULL, - .serial_set_break = NULL + .serial_set_break = NULL, + +#ifdef BLE_SUPPORT + .packet_size = 20, + .packet_open = qt_ble_open, + .packet_close = qt_ble_close, + .packet_read = qt_ble_read, + .packet_write = qt_ble_write, +#endif }; dc_custom_io_t* get_qt_serial_ops() { -- cgit v1.2.3-70-g09d2