mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
qt-ble: add 'get_name()' function to expose the BLE name to libdivecomputer
Some divecomputer backends (ok, right now really only the Aqualung i770R and i300C) want to know the bluetooth name of the dive computer they connect to, because the name contains identifying information like the serial number. This just adds the support for that to our Qt BLE code. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
9dac90c6bf
commit
9e3a22c522
5 changed files with 11 additions and 1 deletions
|
@ -70,6 +70,7 @@ void DownloadThread::run()
|
||||||
auto internalData = m_data->internalData();
|
auto internalData = m_data->internalData();
|
||||||
internalData->descriptor = descriptorLookup[m_data->vendor() + m_data->product()];
|
internalData->descriptor = descriptorLookup[m_data->vendor() + m_data->product()];
|
||||||
internalData->download_table = &downloadTable;
|
internalData->download_table = &downloadTable;
|
||||||
|
internalData->btname = strdup(m_data->devBluetoothName().toUtf8());
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
// on Android we either use BT, a USB device, or we download via FTDI cable
|
// on Android we either use BT, a USB device, or we download via FTDI cable
|
||||||
if (!internalData->bluetooth_mode && (same_string(internalData->devname, "FTDI") || same_string(internalData->devname, "")))
|
if (!internalData->bluetooth_mode && (same_string(internalData->devname, "FTDI") || same_string(internalData->devname, "")))
|
||||||
|
|
|
@ -30,7 +30,7 @@ typedef struct dc_user_device_t
|
||||||
{
|
{
|
||||||
dc_descriptor_t *descriptor;
|
dc_descriptor_t *descriptor;
|
||||||
const char *vendor, *product, *devname;
|
const char *vendor, *product, *devname;
|
||||||
const char *model;
|
const char *model, *btname;
|
||||||
unsigned char *fingerprint;
|
unsigned char *fingerprint;
|
||||||
unsigned int fsize, fdiveid;
|
unsigned int fsize, fdiveid;
|
||||||
uint32_t libdc_firmware, libdc_serial;
|
uint32_t libdc_firmware, libdc_serial;
|
||||||
|
|
|
@ -542,4 +542,10 @@ dc_status_t qt_ble_write(void *io, const void* data, size_t size, size_t *actual
|
||||||
return ble->write(data, size, actual);
|
return ble->write(data, size, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *qt_ble_get_name(void *io)
|
||||||
|
{
|
||||||
|
BLEObject *ble = (BLEObject *) io;
|
||||||
|
return ble->get_name();
|
||||||
|
}
|
||||||
|
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|
|
@ -23,6 +23,7 @@ public:
|
||||||
inline void set_timeout(int value) { timeout = value; }
|
inline void set_timeout(int value) { timeout = value; }
|
||||||
dc_status_t write(const void* data, size_t size, size_t *actual);
|
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);
|
dc_status_t read(void* data, size_t size, size_t *actual);
|
||||||
|
inline const char *get_name() { return device->btname; }
|
||||||
|
|
||||||
inline QLowEnergyService *preferredService() { return preferred; }
|
inline QLowEnergyService *preferredService() { return preferred; }
|
||||||
inline int descriptorWritten() { return desc_written; }
|
inline int descriptorWritten() { return desc_written; }
|
||||||
|
@ -63,6 +64,7 @@ dc_status_t qt_ble_set_timeout(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_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_write(void *io, const void* data, size_t size, size_t *actual);
|
||||||
dc_status_t qt_ble_close(void *io);
|
dc_status_t qt_ble_close(void *io);
|
||||||
|
const char *qt_ble_get_name(void *io);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -424,6 +424,7 @@ ble_packet_open(dc_iostream_t **iostream, dc_context_t *context, const char* dev
|
||||||
NULL, /* purge */
|
NULL, /* purge */
|
||||||
qt_custom_sleep, /* sleep */
|
qt_custom_sleep, /* sleep */
|
||||||
qt_ble_close, /* close */
|
qt_ble_close, /* close */
|
||||||
|
qt_ble_get_name, /* get_name */
|
||||||
};
|
};
|
||||||
|
|
||||||
rc = qt_ble_open(&io, context, devaddr, (dc_user_device_t *) userdata);
|
rc = qt_ble_open(&io, context, devaddr, (dc_user_device_t *) userdata);
|
||||||
|
|
Loading…
Reference in a new issue