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 sample heartrate project

Other Parts Discussed in Thread: CC2540

Hi all,

I started working on the cc2540 heartrate project and tested it out without connecting any input to the keyfob and initializing notifications on 0x0013 handle on Btool and i start receiving notification values.

Can some one please tell me where do the values come from especially when i do not have anything connected to the keyfob and when i try to read handle 0x0012 i get an error that attribute not found ?

If i wanted to connected an input signal into the keyfob should i connect it to pin 1 on the test port ?

Thank you

 

  • Hi,
    The heartrate project send dummy data in the notifications, you can see where they are formed in the code in heartrate.c in heartRateMeasNotify function. Then a function is called send the actually notification over the air in heartrateservice.c:

    bStatus_t HeartRate_MeasNotify( uint16 connHandle, attHandleValueNoti_t *pNoti )
    {
    uint16 value = GATTServApp_ReadCharCfg( connHandle, heartRateMeasClientCharCfg );

    // If notifications enabled
    if ( value & GATT_CLIENT_CFG_NOTIFY )
    {
    // Set the handle
    pNoti->handle = heartRateAttrTbl[HEARTRATE_MEAS_VALUE_POS].handle;

    // Send the notification
    return GATT_Notification( connHandle, pNoti, FALSE );
    }
    You can't read it because it is only set for only GATT_PROP_NOTIFY not GATT_PROP_READ in this same file.

    Which transport do you plan on using to communicate data(via UART, SPI, etc)?
  • HI zahid thanks for your reply,

    I am using UART to communicate data and what you said makes sense thank you for that, But I was wondering what should I change in order to get ADC results as a notification instead of bogus heart rate values ?
    I wrote this code bellow but don't receive any notifications can you please help me thank you !

    static void heartRateMeasNotify(void)
    {
    HalAdcInit()
    uint8 *p = heartRateMeas.value;

    HalAdcSetReference( HAL_ADC_REF_125V );
    uint16 adc = HalAdcRead (serviceAdcCh, HAL_ADC_RESOLUTION_12) ;

    *p++ = HI_UINT16(adc);
    *p++ = LO_UINT16(adc);


    if (p - heartRateMeas.value==20){

    heartRateMeas.len = (uint8) (p - heartRateMeas.value);
    HeartRate_MeasNotify( gapConnHandle, &heartRateMeas );


    }

    }
  • Hi,
    From your code,
    it looks like
    if (p - heartRateMeas.value==20) will never be true.

    it should work if you do
    if (p - heartRateMeas.value==2)
  • Hi Zahid,

    Thank you that worked, i get notifications but they return a zero.

    Any idea what could be the issue ? 

    I think it is the way im inputting the analogue signal into pin0_6 i'm not sure if the keyfob is receiving the signal correctly can you please show me how ?

    thank you !

  • never mind i got it working.