From ae3847db3a4cb17113372cb59955bdaffcec1bea Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 26 Nov 2014 14:42:16 +0100 Subject: 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 Reviewed-by: Alex Blasche --- .../qt5/android/bluetooth/QtBluetoothLE.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (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 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 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; -- cgit v1.2.3