Android Bluetooth Low Energy: character.getPermissions () returns 0?

I am writing an Android BLE application and I am trying to get permissions of a specific attribute. I have already managed to get the characteristic properties with the characteristic .getProperties (), and it returns a nonzero value, however, when I use the getPermission () method, it returns 0, although I am sure that this symptom has PERMISSION_WRITE_ENCRYPTED_MITM (0x00000040).

Here is a snippet of code

// properties int properties = ch.getProperties(); DebugWrapper.infoMsg("properties: " + properties, TAG); //returns non-zero value // permissions int permissions = ch.getPermissions(); DebugWrapper.infoMsg("permissions: " + permissions, TAG); //returns zero value 

Am I doing something wrong? Is there a specific way to get permissions for a feature or is it a problem with android api?

I am using API 19 and testing my program on Samsung Galaxy Note 3.

I appreciate any help.

+6
source share
1 answer

This seems like a problem with the underlying structure. This link shows a block of code that the framework executes when it detects services / features on a remote device. You can see when the new BluetoothGattCharacteristic is created, the permission parameter is always passed as 0 .

In addition, even when this attribute is later read, only the attribute value is updated, no other reset parameters on the object.

Instead, it seems that Android is trying to handle authentication / resolution issues based on trial and error . In other words, the structure always tries to perform a basic read / write operation, and if it fails for authentication reasons, it automatically tries to request MITM authentication again.

+8
source

All Articles