6 Replies Latest reply: Apr 1, 2017 9:27 AM by vlasov01 RSS

BLE registering for notifications  bt_gatt_enable_notify fails with rc=48 - Not supported

vlasov01 Newbie

Hi,

 

I'm new in BLE development. So I've followed a great article "BlackBerry 10 - Bluetooth LE primer for developers"  by Martin Woolley and John Murray .

 

I'm trying to use code  with Realtag BLE sensor based on TI CC2541 .

It works well till the point where I'm registering for notifications  bt_gatt_enable_notify . I'm always getting rc 48 - Not supported .

 

Do I need to change some constants? Is it not supported by BB10 BLE library, by my Q10 or by Realtag BLE sensor?

 

BlackBerry SDK 10_3_1_12
Momentics IDE Version: 2.1.2 Build id: 201503050937

Device: Q10 10.3.1.1865

 

Code:

for (int i = 0; i < characteristicListSize; i++) {
 qDebug() << "XXXX characteristic: uuid,handle,value_handle:" << characteristicList[i].uuid << "," << characteristicList[i].handle << "," << characteristicList[i].value_handle;
 qDebug() << "XXXX RNS characteristic available";
 app->_handle = characteristicList[i].handle;
 app->_value_handle = characteristicList[i].value_handle;
 qDebug() << "XXXX registering for RNS notification. uuid,handle,value_handle=" << characteristicList[i].uuid << "," << characteristicList[i].handle << "," << characteristicList[i].value_handle;
 errno= 0;
 rc = bt_gatt_enable_notify(instance, &characteristicList[i], (uint8_t)1);
 if (rc != 0) {
  qDebug() << "XXXX bt_gatt_enable_notify errno=" << errno;
  qDebug() << "XXXX bt_gatt_enable_notify errno=" << strerror(errno);
 } else {
  qDebug() << "XXXX bt_gatt_enable_notify was presumably OK";
 }
}

Her is the log output:

 

XXXX found Random Number device
XXXX name= "Bytereal"
XXXX address= "5C:31:3E:39:E7:FA"
XXXX freeing buffer
XXXX Found RNS device: 5C:31:3E:39:E7:FA
XXXX GATT connecting to service: 0xFFA0 , on device: 5C:31:3E:39:E7:FA
XXXX requested connection to RNS service OK
XXXX gatt_service_connected
XXXX registering for notifications
XXXX rc from bt_gatt_reg_notifications= 0
XXXX bt_gatt_reg_notifications was presumably OK
XXXX Allocated memory for notifications
XXXX # characteristics= 8
"XXXX # characteristics: 8"
XXXX characteristic: uuid,handle,value_handle: 0xFFB0 , 22 , 23
XXXX RNS characteristic available
XXXX registering for RNS notification. uuid,handle,value_handle= 0xFFB0 , 22 , 23
XXXX bt_gatt_enable_notify errno= 48
XXXX bt_gatt_enable_notify errno= Not supported
XXXX characteristic: uuid,handle,value_handle: 0xFFB1 , 25 , 26
XXXX RNS characteristic available
XXXX registering for RNS notification. uuid,handle,value_handle= 0xFFB1 , 25 , 26
XXXX bt_gatt_enable_notify errno= 48
XXXX bt_gatt_enable_notify errno= Not supported
XXXX characteristic: uuid,handle,value_handle: 0xFFB2 , 28 , 29
XXXX RNS characteristic available
XXXX registering for RNS notification. uuid,handle,value_handle= 0xFFB2 , 28 , 29
XXXX bt_gatt_enable_notify errno= 48
XXXX bt_gatt_enable_notify errno= Not supported
XXXX characteristic: uuid,handle,value_handle: 0xFFB3 , 31 , 32
XXXX RNS characteristic available
XXXX registering for RNS notification. uuid,handle,value_handle= 0xFFB3 , 31 , 32
XXXX bt_gatt_enable_notify errno= 48
XXXX bt_gatt_enable_notify errno= Not supported
XXXX characteristic: uuid,handle,value_handle: 0xFFB4 , 34 , 35
XXXX RNS characteristic available
XXXX registering for RNS notification. uuid,handle,value_handle= 0xFFB4 , 34 , 35
XXXX bt_gatt_enable_notify errno= 48
XXXX bt_gatt_enable_notify errno= Not supported
XXXX characteristic: uuid,handle,value_handle: 0xFFB5 , 37 , 38
XXXX RNS characteristic available
XXXX registering for RNS notification. uuid,handle,value_handle= 0xFFB5 , 37 , 38
XXXX bt_gatt_enable_notify errno= 48
XXXX bt_gatt_enable_notify errno= Not supported
XXXX characteristic: uuid,handle,value_handle: 0xFFB6 , 40 , 41
XXXX RNS characteristic available
XXXX registering for RNS notification. uuid,handle,value_handle= 0xFFB6 , 40 , 41
XXXX bt_gatt_enable_notify errno= 48
XXXX bt_gatt_enable_notify errno= Not supported
XXXX characteristic: uuid,handle,value_handle: 0xFFB7 , 43 , 44
XXXX RNS characteristic available
XXXX registering for RNS notification. uuid,handle,value_handle= 0xFFB7 , 43 , 44
XXXX bt_gatt_enable_notify errno= 48
XXXX bt_gatt_enable_notify errno= Not supported
XXXX done registering for RNS notifications

 

Thank you!

 

Sergey Vlasov

  • Re: BLE registering for notifications  bt_gatt_enable_notify fails with rc=48 - Not supported
    jomurray Novice

    Yes, I have to agree with @oniongarlic's observation.

     

    There is obviously a GATT service at UUID 0xFFA0 on the TI device that you'e successfully connecting to and you're successfully iterating through the list of GATT characteristics ( 0xFFB0, 0xFFB1, ... ) that constitute the attributes of that service.

     

    You need to look at the definitions (either product documentation or as @oniongarlic suggested, a tool to scan the device's GATT) of the various characteristics on the TI device to see what attributes have been assigned to each characteristic; whether READ or WRITE access is allowed or whether Notifications or Indications can be set for it.

     

    John Murray @jomurray

  • Re: BLE registering for notifications  bt_gatt_enable_notify fails with rc=48 - Not supported
    jomurray Novice

    Thanks for providing this data. I think I can see what's going on.

     

     

    handle: 0x0028, char properties: 0x12, char value handle: 0x0029, uuid: 0000ffb6-0000-1000-8000-00805f9b34fb

     

    As you noted the FFB6 characteristic has a characteristic property value of 0x12. The part of the Bluetooth specification that deals wth this field is shown below.

     

    characteristic_png.png

     

    This shows that this characterisic has permissions that allow it to be read and to be notified. Notice that it states that if the Notification flag is set that the corresponding Client Characteristic Configuration Descriptor (with UUID 0x2902) SHALL exist.

     

    The definition of the Client Characteristic Configuration Descriptor (UUID 0x2902) from the Bluetooth specification is shown here:

     

    0x2902 description_png.png

     

    It has an attribute UUID of 0x2902 and can take only two values currently ( 0x0001 and 0x002 ) to allow both Notifications and Indications to be toggled on and off. From your data we see that there are only 3 such characteristic descriptors for this characteristic:

     

     

    [5C:31:3E:39:E7:FA][LE]> char-desc 0x0028 0x002a
    handle: 0x0028, uuid: 00002803-0000-1000-8000-00805f9b34fb
    handle: 0x0029, uuid: 0000ffb6-0000-1000-8000-00805f9b34fb
    handle: 0x002a, uuid: 00002901-0000-1000-8000-00805f9b34fb

     

    At handle 0x0028 is the descriptor itself which contains the permissions flags (0x12).

     

    At handle 0x002a there is a descriptor of type 0x2901 -- this is just an ASCII human readable representation of the characteristic:

     

     

    4d 50 55 36 30 35 30 20 44 61 74 61 == "MPU6050 Data"

     

    FInally handle 0x0029 is the value handle for this characteristic which can be read -- the values you show are mapped as follows:

     

     

    65 04 / 31 04 / 01 fa / 01 00 / 07 00 / 08 00 / 80 e8 / 1f ef / 72 37 / 97 0d
    
    =>MPU6050 Characteristics FFB6: (20bytes)
    X axis acceleration original value: data[0]+data[1]<<8   = 0x0464 
    Y axis acceleration original value: data[2]+data[3]<<8   = 0x0431
    Z axis acceleration original value: data[4]+data[5]<<8   = 0xfa01
    The X axis angular velocity of the original value: data[6]+data[7]<<8 = 0x0001
    The Y axis angular velocity of the original value: data[8]+data[9]<<8 = 0x0007
    The Z axis angular velocity of the original value: data[10]+data[11]<<8 = 0x0008
    The number of the original  W value: data[12]+data[13]<<8  = 0xe880
    The number of the original  x value: data[14]+data[15]<<8  = 0xef1f
    The number of the original y value: data[16]+data[17]<<8  = 0x3772
    The number of the original  Z value: data[18]+data[19]<<8  = 0x0d97

     

    which looks correct.

     

    So, the issue is that the MPU6050 device is identifying the FFB6 characteristic as READABLE ( this is verifiably true ) and NOTIFIABLE; however, it is not supplying a Client Characteristic Configuration Descriptor ( UUID 0x2902 ) to identify the handle of the field that should be used to toggle this characteristic's notification setting on and off. So if you try and set notifications ON for this attribute the underlying handle to which you have to write 0x0001 to set notifications CANNOT be determined from the device's GATT and hence you'll get an error reported.

     

    This is a problem with the GATT database definition in the firmware of the MPU6050 device itself and not of any client device that tries to communicate with it.

     

    It doesn't conform to the Bluetooth GATT specification so you would need to have a conversation with the manufacturer to raise this as an issue.

  • Re: BLE registering for notifications  bt_gatt_enable_notify fails with rc=48 - Not supported
    jomurray Novice

    I'm not sure that this goes anyway to answering the original question. You say that "the service supports notifications" -- however notifications are an attribute of a characteristic and it's at that point your original code gets an error. I'd really need to see the GATT to understand what the device is presenting in terms of services and characteristics.

     

    Let me give you an example

     

    I've got a Bluetooth LE Heart Rate monitor and I want to see what services it offers and whether I can set notifications "on" some characteristics. I use "gatttool" -- I use a Mac but I can run in in an Ubuntu VM. Here's what I do:

     

     

    john@john-VirtualBox:~ $ gatttool -b 00:18:31:F0:F4:2D -I
    [   ][00:18:31:F0:F4:2D][LE]> connect
    ^^^ connect to the heart rate monitor at this BT address

    [CON][00:18:31:F0:F4:2D][LE]> primary
    ^^^ interogate list of primary services on the device
    [CON][00:18:31:F0:F4:2D][LE]> attr handle: 0x0001, end grp handle: 0x000b uuid: 00001800-0000-1000-8000-00805f9b34fb attr handle: 0x000c, end grp handle: 0x000f uuid: 00001801-0000-1000-8000-00805f9b34fb attr handle: 0x0010, end grp handle: 0x0017 uuid: 0000180d-0000-1000-8000-00805f9b34fb ^^^ The service 0x180d has handles between 0x0010 and 0x0017 inclusive
    ^^^ 0x180d is the Heart rate monitor service

    attr handle: 0x0018, end grp handle: 0x002a uuid: 0000180a-0000-1000-8000-00805f9b34fb attr handle: 0x002b, end grp handle: 0x002e uuid: 0000180f-0000-1000-8000-00805f9b34fb attr handle: 0x002f, end grp handle: 0x0035 uuid: befdff10-c979-11e1-9b21-0800200c9a66 attr handle: 0x0036, end grp handle: 0xffff uuid: befdffb0-c979-11e1-9b21-0800200c9a66 [CON][00:18:31:F0:F4:2D][LE]> characteristics 0x0010 0x0017
    ^^^ let's look at the characteristics offered by the heart rate service
    ^^^ in more detail
    [CON][00:18:31:F0:F4:2D][LE]> handle: 0x0011, char properties: 0x10, char value handle: 0x0012, uuid: 00002a37-0000-1000-8000-00805f9b34fb ^^^ UUID 0x2a37 is the one I'm interested in -- it's the heart rate measurement itself
    ^^^ it has a property of 0x10 -- this means that it supports notifications
    ^^^ and that it cannot be read directly nor written.

    handle: 0x0014, char properties: 0x02, char value handle: 0x0015, uuid: 00002a38-0000-1000-8000-00805f9b34fb handle: 0x0016, char properties: 0x08, char value handle: 0x0017, uuid: 00002a39-0000-1000-8000-00805f9b34fb [CON][00:18:31:F0:F4:2D][LE]> char-desc 0x0011 0x0013 ^^^ lets have a look at the characteristic descriptors associated with this characteristic
    ^^^ in more detail

    [CON][00:18:31:F0:F4:2D][LE]> handle: 0x0011, uuid: 2803 handle: 0x0012, uuid: 2a37 handle: 0x0013, uuid: 2902
    ^^^ This is the UUID I'm interested in (0x2902) -- it's a client configuration attribute that
    ^^^ can take two values in this case 0 and 1 -- when it's 0 notifications are turned off
    ^^^ when it's 1 notifications are on
    [CON][00:18:31:F0:F4:2D][LE]> char-read-hnd 0x0012
    ^^^ just to make the point I try and read the heart rate measurement at it's value handle 0x0012

    [CON][00:18:31:F0:F4:2D][LE]> Characteristic value/descriptor read failed: Attribute can't be read
    ^^^ and you get an error that it can't be read -- as expected

    [CON][00:18:31:F0:F4:2D][LE]> char-write-cmd 0x0013 0100
    ^^^ Now I'll set notifications on by writing 1 ( 0x0100 -- little-endian 16 bits ) to handle 0x0013
    ^^^ and I get notifications ...

    [CON][00:18:31:F0:F4:2D][LE]>
    Notification handle = 0x0012 value: 16 52 f4 02 d8 02
    [CON][00:18:31:F0:F4:2D][LE]>
    Notification handle = 0x0012 value: 16 52 d0 02
    [CON][00:18:31:F0:F4:2D][LE]>
    Notification handle = 0x0012 value: 16 52 cc 02
    [CON][00:18:31:F0:F4:2D][LE]>
    Notification handle = 0x0012 value: 16 53 a4 02 fc 02
    [CON][00:18:31:F0:F4:2D][LE]>
    Notification handle = 0x0012 value: 16 52 c8 02
    [CON][00:18:31:F0:F4:2D][LE]>
    Notification handle = 0x0012 value: 16 53 c8 02
    [CON][00:18:31:F0:F4:2D][LE]> char-write-cmd 0x0013 0000
    ^^^ and switch them off again by writing 0 ( 0x0000 little-endian 16 bits )

    [CON][00:18:31:F0:F4:2D][LE]>


     

    So, whenever you're attempting to talk to a BT LE device you need to do something like the above to review its GATT, i.e. the Services it offers, the Characteristics it uses in each service and the attributes of each Characteristic ( e.g. can it be read, written, is it capable of being notified).

     

    Without that information you're just really guessing at how the device would respond.

    • Re: BLE registering for notifications  bt_gatt_enable_notify fails with rc=48 - Not supported
      vlasov01 Newbie

      Thank you for the follow-up.

       

      Here is my findings so far:

       

      # gatttool -b 5C:31:3E:39:E7:FA -I
      [5C:31:3E:39:E7:FA][LE]> connect
      ^^^ connect to the RealTag CC2541 at this BT address
      
      Attempting to connect to 5C:31:3E:39:E7:FA
      Connection successful
      [5C:31:3E:39:E7:FA][LE]> primary
      ^^^ interogate list of primary services on the device
      
      attr handle: 0x0001, end grp handle: 0x000b uuid: 00001800-0000-1000-8000-00805f9b34fb
      attr handle: 0x000c, end grp handle: 0x000f uuid: 00001801-0000-1000-8000-00805f9b34fb
      attr handle: 0x0010, end grp handle: 0x0014 uuid: 0000180f-0000-1000-8000-00805f9b34fb
      attr handle: 0x0015, end grp handle: 0x002d uuid: 0000ffa0-0000-1000-8000-00805f9b34fb
      ^^^ The service 0xffa0 has handles between 0x0015 and 0x002d inclusive
      ^^^ 0xffa0 is the service of my interest
      
      attr handle: 0x002e, end grp handle: 0x0032 uuid: 0000ffe0-0000-1000-8000-00805f9b34fb
      attr handle: 0x0033, end grp handle: 0xffff uuid: f000ffc0-0451-4000-b000-000000000000
      [5C:31:3E:39:E7:FA][LE]> characteristics 0x0015 0x002d
      ^^^ let's look at the characteristics offered by the service 
      ^^^ in more detail
      
      handle: 0x0016, char properties: 0x0a, char value handle: 0x0017, uuid: 0000ffb0-0000-1000-8000-00805f9b34fb
      handle: 0x0019, char properties: 0x0a, char value handle: 0x001a, uuid: 0000ffb1-0000-1000-8000-00805f9b34fb
      handle: 0x001c, char properties: 0x0a, char value handle: 0x001d, uuid: 0000ffb2-0000-1000-8000-00805f9b34fb
      handle: 0x001f, char properties: 0x0a, char value handle: 0x0020, uuid: 0000ffb3-0000-1000-8000-00805f9b34fb
      handle: 0x0022, char properties: 0x0a, char value handle: 0x0023, uuid: 0000ffb4-0000-1000-8000-00805f9b34fb
      handle: 0x0025, char properties: 0x0a, char value handle: 0x0026, uuid: 0000ffb5-0000-1000-8000-00805f9b34fb
      handle: 0x0028, char properties: 0x12, char value handle: 0x0029, uuid: 0000ffb6-0000-1000-8000-00805f9b34fb
      ^^^ ffb6 Motion Sensor MPU6050, what property 0x12 means? Is it read only?
      handle: 0x002b, char properties: 0x02, char value handle: 0x002c, uuid: 0000ffb7-0000-1000-8000-00805f9b34fb [5C:31:3E:39:E7:FA][LE]> char-desc 0x0028 0x002a handle: 0x0028, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x0029, uuid: 0000ffb6-0000-1000-8000-00805f9b34fb handle: 0x002a, uuid: 00002901-0000-1000-8000-00805f9b34fb [5C:31:3E:39:E7:FA][LE]> char-read-hnd 0x0028 Characteristic value/descriptor: 12 29 00 b6 ff [5C:31:3E:39:E7:FA][LE]> char-read-hnd 0x0029 Characteristic value/descriptor: 65 04 31 04 01 fa 01 00 07 00 08 00 80 e8 1f ef 72 37 97 0d [5C:31:3E:39:E7:FA][LE]> char-read-hnd 0x002a Characteristic value/descriptor: 4d 50 55 36 30 35 30 20 44 61 74 61

      I can read information from sensor. Does this mean it only support read and not notifications?

  • Re: BLE registering for notifications  bt_gatt_enable_notify fails with rc=48 - Not supported
    vlasov01 Newbie

    Thank you for the reply!

    I've build an Android app to verify if the service supports notifications. The app output confirmed that it is the case.

     

    Sergey Vlasov

  • Re: BLE registering for notifications  bt_gatt_enable_notify fails with rc=48 - Not supported
    oniongarlic Novice
    Are you sure the characteristics you try to enable notifications for supports notifications ?
    If you are using linux, try playing with gattool and check.