diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2014-11-26 14:42:16 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2014-12-01 11:08:44 +0100 |
commit | ae3847db3a4cb17113372cb59955bdaffcec1bea (patch) | |
tree | c6d891274c34f765229c0cc59dfe168a1e770165 /src/android | |
parent | 68332a47fbcc124efedf73b106b7e06bfacd65fd (diff) |
Android: Implements QLEService::includedServices() and type()
Unfortunately it is not possible to say whether a service is
primary or secondary on Android. The platform doesn't expose this
information.
Change-Id: I9b0aad191308120d2d1992a5e7736b985a375e30
Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/android')
-rw-r--r-- | src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java | 31 |
1 files changed, 31 insertions, 0 deletions
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 618be1ea..12935b6a 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 @@ -657,6 +657,37 @@ public class QtBluetoothLE { return true; } + /* + Returns the uuids of the services included by the given service. Otherwise returns null. + Directly called from Qt. + */ + public String includedServices(String serviceUuid) + { + UUID uuid; + try { + uuid = UUID.fromString(serviceUuid); + } catch (Exception ex) { + ex.printStackTrace(); + return null; + } + + //TODO Breaks in case of two services with same uuid + BluetoothGattService service = mBluetoothGatt.getService(uuid); + if (service == null) + return null; + + final List<BluetoothGattService> includes = service.getIncludedServices(); + if (includes.isEmpty()) + return null; + + StringBuilder builder = new StringBuilder(); + for (BluetoothGattService includedService: includes) { + builder.append(includedService.getUuid().toString()).append(" "); //space is separator + } + + return builder.toString(); + } + private void finishCurrentServiceDiscovery() { int currentEntry = currentServiceInDiscovery; |