This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

cc2540 heartrate ADC

Hi all,

Im currently trying to use the heartrate sample project to perform adc reads and handle 0x0012 on Btool to get the values but it keeps on saying read not permitted

can anyone help me with this ?

thank you.

  • Hey Husain,

    First of all, heart rate data is available on handle 18 (At least in BLEv1.4 Build). Secondly, there is no read permission set in software for that characteristic;

    // Heart Rate Measurement Value
    { 
     { ATT_BT_UUID_SIZE, heartRateMeasUUID },
     0, 
     0, 
     &heartRateMeas 
    },

    To set read permission, change to

    // Heart Rate Measurement Value
    { 
     { ATT_BT_UUID_SIZE, heartRateMeasUUID },
     GATT_PERMIT_READ, 
     0, 
     &heartRateMeas 
    },

    Generally, you should use the CCD on handle 19; which you write 01:00 to, in order to enable automatically sent notifications. This way you don't have to "poll" every time you want to know the heart rate.

    Best Regards

    Joakim

  • Hi Joakim,

    Thanks for your reply it worked. But now im having another problem i keep on getting attribute not found and i'm not sure why.
    I inserted the ADC read into the Heartrate Notify function and im using AIN6 and the internal voltage.
    But apparently there is no values in the attribute to read.

    thanks 

    Husain

  • How to find out which CCD to enable to get notifications automatically.
  • You should discover the CCCD when performing service discovery. The CCCD after the characteristic in question will be the one you should write to.
  • I was able to enable the notifications when I write 01:00 to CCCD 19 with this value using GATT_CharValue. But not able to find out where it shows up when I am doing GATT_DescAllPrimaryServices.

    Is there any document or something that defines this all.
  • If you're looking for a high-level explanation of how GATT services work, you should look at the Bluetooth Spec and the GATT section of the software developer's guide: http://www.ti.com/lit/swru271

    Each GATT command, and the expected events relating to it, is described in the GATT API of the software developer's guide.
  • Hi Tim,
    I am more concerned towards from where I can get the value 19. how to find out which handle to write to.

    My GATT_descALLPrimary Services returns:

    [1] : <Tx> - 01:12:57.153
    -Type : 0x01 (Command)
    -OpCode : 0xFD90 (GATT_DiscAllPrimaryServices)
    -Data Length : 0x02 (2) byte(s)
    ConnHandle : 0x0000 (0)
    Dump(Tx):
    0000:01 90 FD 02 00 00 ......
    --------------------------------------------------------------------
    [2] : <Rx> - 01:12:57.159
    -Type : 0x04 (Event)
    -EventCode : 0x00FF (Event)
    -Data Length : 0x06 (6) bytes(s)
    Event : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
    Status : 0x00 (0) (Success)
    OpCode : 0xFD90 (GATT_DiscAllPrimaryServices)
    DataLength : 0x00 (0)
    Dump(Rx):
    0000:04 FF 06 7F 06 00 90 FD 00 .........
    --------------------------------------------------------------------
    [3] : <Rx> - 01:12:57.339
    -Type : 0x04 (Event)
    -EventCode : 0x00FF (Event)
    -Data Length : 0x19 (25) bytes(s)
    Event : 0x0511 (1297) (ATT_ReadByGrpTypeRsp)
    Status : 0x00 (0) (Success)
    ConnHandle : 0x0000 (0)
    PduLen : 0x13 (19)
    Length : 0x06 (6)
    DataList
    AttrHandle : 0001
    EndGrpHandle : 000B
    Value : 00:18
    AttrHandle : 000C
    EndGrpHandle : 000F
    Value : 01:18
    AttrHandle : 0010
    EndGrpHandle : 0017
    Value : 0D:18

    Dump(Rx):
    0000:04 FF 19 11 05 00 00 00 13 06 01 00 0B 00 00 18 ................
    0010:0C 00 0F 00 01 18 10 00 17 00 0D 18 ............
    --------------------------------------------------------------------
    [4] : <Rx> - 01:12:57.539
    -Type : 0x04 (Event)
    -EventCode : 0x00FF (Event)
    -Data Length : 0x13 (19) bytes(s)
    Event : 0x0511 (1297) (ATT_ReadByGrpTypeRsp)
    Status : 0x00 (0) (Success)
    ConnHandle : 0x0000 (0)
    PduLen : 0x0D (13)
    Length : 0x06 (6)
    DataList
    AttrHandle : 0018
    EndGrpHandle : 002A
    Value : 0A:18
    AttrHandle : 002B
    EndGrpHandle : FFFF
    Value : 0F:18

    Dump(Rx):
    0000:04 FF 13 11 05 00 00 00 0D 06 18 00 2A 00 0A 18 ............*...
    0010:2B 00 FF FF 0F 18 +.....
    --------------------------------------------------------------------
    [5] : <Rx> - 01:12:57.549
    -Type : 0x04 (Event)
    -EventCode : 0x00FF (Event)
    -Data Length : 0x06 (6) bytes(s)
    Event : 0x0511 (1297) (ATT_ReadByGrpTypeRsp)
    Status : 0x1A (26) (The Procedure Is Completed)
    ConnHandle : 0x0000 (0)
    PduLen : 0x00 (0)
    Dump(Rx):
    0000:04 FF 06 11 05 1A 00 00 00 .........
    --------------------------------------------------------------------
  • A process to specifically discover the CCCD of a characteristic where the UUID is known is:
    1. Discover characteristic using known UUID (Discover Characteristics by UUID).
    2. The Read By Type Response returned will contain the attribute handle range and characteristic properties. If the characteristic properties contain notify properties, there will be a CCCD.
    3. Discover All Characteristic Descriptors using the attribute handle range of the characteristic in question.

    There are other ways to do this. Depending on what else you want to do, you may want to discover each primary service and each characteristic.

    Each procedure and response is further defined in detail in the Bluetooth Spec.
  • Thank you, for the clarification