summaryrefslogtreecommitdiffstats
path: root/core/qt-ble.h
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2020-01-26 12:42:57 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-01-27 09:51:31 -0800
commit9543f53150dec964d86be12af41491ded923c458 (patch)
tree11397c1400bd3f4384691152595fd6c293642341 /core/qt-ble.h
parent5b81997459810f777148e543a8b20b9bb8c486df (diff)
downloadsubsurface-9543f53150dec964d86be12af41491ded923c458.tar.gz
Update to new libdivecomputer version
Jef has changed the libdivecomputer iostream layer and extended it in two different ways: - iostram's now have a 'poll()' method, which does what the name implies: waits for data to be available with a timeout. - iostreams now have a 'ioctl()' method, which can be used to implement miscellaneous operations. Right now the two ones that you can do are "set latency" (this replaces the old 'set_latency()' method) and "get BLE name" (this replaces our 'get_name()' method that was never part of the upstream libdivecomputer interfaces) Neither of these is all that complicated, and the transition is fairly obvious. HOWEVER. I have absolutely no idea how to do 'poll()' on Windows sockets, and I have no intention of figuring it out. We use a direct socket interface to implement the (non-BLE) RFCOMM bluetooth serial protocol, and I'm not sure why Windows is so special here. I suspect - but cannot test - that we should just switch the Windows RFCOMM implementation over to the use the same QtBluetooth code that we use on other platforms. I assume that the Windows Bluetooth support was originally not sufficiently good for that, but these days we depend on Qt doing BLE for us even on Windows, so presumably FRCOMM works too. That would be a nice cleanup, and would make 'poll()' work on RFCOMM under Windows too. However, since I can't test it, I've not done that, but instead just made the Windows RFCOMM 'poll()' method always return success. That may or may not get the thing limping along. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'core/qt-ble.h')
-rw-r--r--core/qt-ble.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/core/qt-ble.h b/core/qt-ble.h
index 2b011163f..4da51a981 100644
--- a/core/qt-ble.h
+++ b/core/qt-ble.h
@@ -23,7 +23,13 @@ public:
inline void set_timeout(int value) { timeout = value; }
dc_status_t write(const void* data, size_t size, size_t *actual);
dc_status_t read(void* data, size_t size, size_t *actual);
- inline const char *get_name() { return device->btname; }
+ inline dc_status_t get_name(char *res, size_t size)
+ {
+ if (!device->btname) return DC_STATUS_UNSUPPORTED;
+ strncpy(res, device->btname, size);
+ return DC_STATUS_SUCCESS;
+ }
+ dc_status_t poll(int timeout);
inline QLowEnergyService *preferredService() { return preferred; }
inline int descriptorWritten() { return desc_written; }
@@ -61,10 +67,11 @@ private:
extern "C" {
dc_status_t qt_ble_open(void **io, dc_context_t *context, const char *devaddr, dc_user_device_t *user_device);
dc_status_t qt_ble_set_timeout(void *io, int timeout);
+dc_status_t qt_ble_poll(void *io, int timeout);
dc_status_t qt_ble_read(void *io, void* data, size_t size, size_t *actual);
dc_status_t qt_ble_write(void *io, const void* data, size_t size, size_t *actual);
+dc_status_t qt_ble_ioctl(void *io, unsigned int request, void *data, size_t size);
dc_status_t qt_ble_close(void *io);
-const char *qt_ble_get_name(void *io);
}
#endif