MBluetoothGatt.getService (uuid) returns null

In my application, I pass the UUID number of the hearing aid service, as in the BLE example, from Google, namely 0000a00-0000-1000-8000-00805f9b34fb

But getervice returns null means the service is not supported by BluetoothGatt. Why is this happening, can someone help me.

+4
source share
3 answers

You must first find all the services for this device in the documentation.

This feature requires that service discovery be completed for this device. http://developer.android.com/reference/android/bluetooth/BluetoothGatt.html#getService(java.util.UUID)

@Override
    // New services discovered
    public void onServicesDiscovered(BluetoothGatt gatt, int status) {
        if (status == BluetoothGatt.GATT_SUCCESS) {
            BluetoothGattService mBluetoothGattService = mBluetoothGatt.getService(UUID.fromString(serviceUUID));
            if (mBluetoothGattService != null) {
                Log.i(TAG, "Service characteristic UUID found: " + mBluetoothGattService.getUuid().toString());
            } else {
                Log.i(TAG, "Service characteristic not found for UUID: " + serviceUUID);
        }
    }

for (BluetoothGattService gattService : gattServices) {
    Log.i(TAG, "Service UUID Found: " + gattService.getUuid().toString());
}
+3

UUID . 0000a00X-0000-1000-8000-00805f9b34fb, 0000a00-0000-1000-8000-00805f9b34fb

0

All Articles