From f945ffc90f8f11d73dc87f2d82bb2d246d446e71 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 19 Oct 2016 13:58:17 +0200 Subject: LE/Android: Pass list of advertised services found in scan record Currently the advertising packet (scan record) received from BLE devices during scanning on Android devices is ignored. Consequently, the serviceUuids() method of the QBluetoothDeviceInfo class returns an empty list for BLE devices. However, this list provides important information needed by clients to identify whether a given device is of interest. This changeset implements parsing of the scan record received from the Android Bluetooth layer. The Java byte array is passed over JNI to the C++ adapter classes, where it's parsed to find any service UUIDs being advertised by the device. Parsing the scan record ourselves is required for compatibility (Qt uses "old-style" LE scan API from Android api level 18.) All found UUIDs are added to a list which is subsequently passed to the user of the QBluetoothDeviceDiscoveryAgent class via the deviceDiscovered(QBluetoothDeviceInfo&) signal. Note: not all Android devices pass the full advertisement data. The service UUID list may be empty in those cases. [ChangeLog][QtBluetooth][Android] Parse list of advertised services found in LE scan record and pass them to API client via QBluetoothDeviceInfo::serviceUuids() Task-number: QTBUG-56625 Change-Id: I253f1b841c7b15b3bbabc9e478de87c81979815e Reviewed-by: Timur Pocheptsov --- .../src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/android') diff --git a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java index deb70dc0..9fe88e9c 100644 --- a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java +++ b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java @@ -114,11 +114,11 @@ public class QtBluetoothLE { if (qtObject == 0) return; - leScanResult(qtObject, device, rssi); + leScanResult(qtObject, device, rssi, scanRecord); } }; - public native void leScanResult(long qtObject, BluetoothDevice device, int rssi); + public native void leScanResult(long qtObject, BluetoothDevice device, int rssi, byte[] scanRecord); /*************************************************************/ /* Service Discovery */ -- cgit v1.2.3