react-native-ble-manager icon indicating copy to clipboard operation
react-native-ble-manager copied to clipboard

Properties of a characteristic should have the same structure between iOS/Android

Open alexsegura opened this issue 5 years ago • 3 comments

Version

  • react-native-ble-manager v7.2.0
  • react-native v0.61.5

On iOS, the properties of a characteristic are a zero-indexed array:

{
  properties: ["Read", "WriteWithoutResponse", "Write", "Notify", "Indicate"]
}

On Android, the properties of a characteristic are an object:

{
  properties: {
    "Read":"Read", 
    "WriteWithoutResponse":"WriteWithoutResponse", 
    "Write":"Write", 
    "Notify":"Notify", 
    "Indicate":"Indicate"
  }
}

Actually, I don't know if it's really linked to the OS version, but anyway, it would be nice to always return the same data structure.

IMHO the simplest structure is the zero-indexed array.

If you think it's interesting, I can send a pull-request 🙂 I would be able to do it only in the JavaScript layer however.

The "problem" is that it would be a BC break, and would need a major version bump I think.

alexsegura avatar Apr 04 '20 08:04 alexsegura

Hi @alexsegura , a PR is welcome.

marcosinigaglia avatar Apr 14 '20 14:04 marcosinigaglia

This seems to be a problem of the library developers

characteristicsMap.putMap("properties", Helper.decodeProperties(characteristic))

Instead of WritableArray, WritableMap was used for some reason

Loovery avatar May 12 '22 10:05 Loovery

What is interesting is that only the object with the keys is specified in the types:

export interface Characteristic {
    // See https://developer.apple.com/documentation/corebluetooth/cbcharacteristicproperties
    properties: {
      Broadcast?: "Broadcast";
      Read?: "Read";
      WriteWithoutResponse?: "WriteWithoutResponse";
      Write?: "Write";
      Notify?: "Notify";
      Indicate?: "Indicate";
      AuthenticatedSignedWrites?: "AuthenticatedSignedWrites";
      ExtendedProperties?: "ExtendedProperties";
      NotifyEncryptionRequired?: "NotifyEncryptionRequired";
      IndicateEncryptionRequired?: "IndicateEncryptionRequired";
    }
    characteristic: string;
    service: string;
    descriptors?: Descriptor[];
  }

Loovery avatar May 13 '22 08:05 Loovery