mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 18:43:24 +00:00
Bluetooth: make LE-only devices add "LE:" as an address prefix
This seems a bit odd, but it actually has three different reasons for it: - It's a visual indication of BT LE mode for users - the rfcomm code only works with legacy BT support, and if we scan a device that only does LE, we want the custom serial code to instead automatically fall back on a "emulate serial over LE packets" model. - we want rfcomm to remain the default for devices that do both legacy BT _and_ LE, but we want people to have the ability to override the choice manually. They can now do so by just editing the address field and adding the "LE:" prefix manually, and it automatically gets saved for next time. So while a bit hacky, it's actually a very convenient model that not only works automatically, but allows the manual override. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
bbde0a1741
commit
d0c3ef4cf8
2 changed files with 18 additions and 1 deletions
|
@ -121,6 +121,16 @@ dc_status_t BLEObject::read(void* data, size_t size, size_t *actual)
|
|||
|
||||
dc_status_t qt_ble_open(dc_custom_io_t *io, dc_context_t *context, const char *devaddr)
|
||||
{
|
||||
/*
|
||||
* LE-only devices get the "LE:" prepended by the scanning
|
||||
* code, so that the rfcomm code can see they only do LE.
|
||||
*
|
||||
* We just skip that prefix (and it doesn't always exist,
|
||||
* since the device may support both legacy BT and LE).
|
||||
*/
|
||||
if (!strncmp(devaddr, "LE:", 3))
|
||||
devaddr += 3;
|
||||
|
||||
QBluetoothAddress remoteDeviceAddress(devaddr);
|
||||
|
||||
// HACK ALERT! Qt 5.9 needs this for proper Bluez operation
|
||||
|
|
|
@ -420,7 +420,14 @@ void BtDeviceSelectionDialog::deviceDiscoveryError(QBluetoothDeviceDiscoveryAgen
|
|||
QString BtDeviceSelectionDialog::getSelectedDeviceAddress()
|
||||
{
|
||||
if (selectedRemoteDeviceInfo) {
|
||||
return selectedRemoteDeviceInfo.data()->address().toString();
|
||||
QBluetoothDeviceInfo *deviceInfo = selectedRemoteDeviceInfo.data();
|
||||
QBluetoothDeviceInfo::CoreConfigurations flags;
|
||||
QString prefix = "";
|
||||
|
||||
flags = deviceInfo->coreConfigurations();
|
||||
if (flags == QBluetoothDeviceInfo::LowEnergyCoreConfiguration)
|
||||
prefix = "LE:";
|
||||
return prefix + deviceInfo->address().toString();
|
||||
}
|
||||
|
||||
return QString();
|
||||
|
|
Loading…
Add table
Reference in a new issue