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.

CC2541: CC2541 --> SimpleBleCentral --> NOTIFICATION/INDICATION

Part Number: CC2541

Hello,

I have to Three Devices..

1. CC2541(1) which is running SimpleBleCentral Code.

2. CC2541(2) which is Advertising the data

3. Mobile phone having BLE Scanner App.

What i did...

(A) 1st i use my mobile and scan Device (2) and then goto Custom Characteristics and then enable notification of 0xFFF4 UUID. and it shows the data 0x03.

(B) 2nd i run Device (1) and then i discover 0xFFF0 characteristic (#define SIMPLEPROFILE_SERV_UUID 0xFFF0) and under this i read 0xFFF1 and i got data what i want.

(C) 3rd i run Device (2) and then i discover 0xFFF0 characteristic (#define SIMPLEPROFILE_SERV_UUID 0xFFF0) and under this i try to enable notification of 0xFFF4 but i am not able to do the same.

 

i also check (simpleBLECharHdl != 0) after using (GATT_ReadUsingCharUUID( simpleBLEConnHandle, &req, simpleBLETaskId )) this function and it returns 0.

 

My questions are...

(1) how and where we need to enable the notification in SimpleBleCentral code ?

(2) Can we use ((GATT_ReadUsingCharUUID) function for 0xFFF4 ?

(3) How to read Data from 0xFFF4 (what i did in (A)) using SimpleBleCentral Code?

 

Hope for positive reply.

Thanks in advance.

  • Hi,

    In scenario (C) which are you connecting SimpleBLECentral(Device 1) to Device 2?
    The notifications are saved per connections. So you would have to enable notifications separately for each device. Then when you reconnect, it should remember the notification configuration.

    the central project only shows how to read/write Char.1, to enable notification, you have to write to the CCCD. Here's an example of writing to the CCCD of a characteristic taken from another project:

    if (events & SBC_NOTI_ENABLE_EVT)
    {
    // Process message.
    uint8 retVal;
    attWriteReq_t req;
    uint8 configData[2] = {0x01,0x00};

    req.pValue = GATT_bm_alloc(connHandle, ATT_WRITE_REQ, 2, NULL);

    if ((charCCCDHdl == NULL) && (charDataHdl != NULL)) {charCCCDHdl = charDataHdl + 1;} //Hardcoded
    if ( (req.pValue != NULL) && charCCCDHdl)
    {
    req.handle = charCCCDHdl; //Handle for CCCD of Data characteristic
    req.len = 2;
    memcpy(req.pValue, configData, 2);
    req.cmd = TRUE; //Has to be true for NoRsp from server(command, not request)
    req.sig = FALSE;
    retVal = GATT_WriteNoRsp(connHandle, &req);
    if (retVal != SUCCESS)
    {
    DEBUG("ERROR enabling notification...\n\r");
    }
    else
    {
    DEBUG("Notification enabled...\n\r");
    }
    }
    }

    Best wishes
  • Hi Zahid,

    Yes in scenario (C) i connect Device (1) to Device (2). And in that i want to enable notification of Characteristics 0xFFF4.

    And yaaa...i will do as your solution shortly and let you know.

    Thank you.
  • I post wrong by mistake. scenario (C) is like...

    (C) 3rd i run Device (1) and then i discover 0xFFF0 characteristic (#define SIMPLEPROFILE_SERV_UUID 0xFFF0) and under this i try to enable notification of 0xFFF4 but i am not able to do the same.

    Rest all are OK.

    Thank you.
  • Hello,

    I did as you suggest but unable to get result.

    What i did ....(different scenarios)

    (A) I try to send the request using [ GATT_WriteNoRsp(connHandle, &req); ] function with all flags those you have suggested. It returns SUCCESS(0) but then after nothing happend.

    (B) I run Device (1) and then connect with Device (2) using [ GATT_DiscCharsByUUID ] function with UUID 0xFFF4 and then i read UUID 0xFFF4 using [ GATT_ReadCharValue ] function. And i got Some response that i decoded and understood.

    (C) I run Device (1) and then connect with Device (2) using [ GATT_ReadUsingCharUUID ] function with UUID 0xFFF4. and in [ void simpleBLEGATTDiscoveryEvent ] function i get 0x01 as METHOD in [ pMsg->method ] which means ERROR RESPONSE.

    So my questions are...

    (a) How to read data ( i mean by using which Function ) from 0xFFF4 after if any how we enabled the notification as you suggested ?

    (b) What is CCCD ?

    Thank You.

  • Hi,

    Instead You suggested, I did little changes(As marked) and Got Success.

    attWriteReq_t req;

    req.pValue = GATT_bm_alloc( simpleBLEConnHandle, ATT_WRITE_REQ, 2, NULL );

    if ( conHndl )
    {

    req.handle = conHndl_write+1;

    req.len = 2;

    req.pValue[0] = LO_UINT16(GATT_CLIENT_CFG_NOTIFY);

    req.pValue[1] = HI_UINT16(GATT_CLIENT_CFG_NOTIFY);

    req.sig = 0;

    req.cmd = 1;

    retVal = GATT_WriteNoRsp(simpleBLEConnHandle, &req);

    if (retVal != SUCCESS)
    {
    //DEBUG("ERROR enabling notification...\n\r");
    sendDataToHost("\r\n\r\nERROR Enabling Notification !!!");
    }
    else
    {
    //DEBUG("Notification enabled...\n\r");
    sendDataToHost("\r\n\r\nNotification enabled");
    }

    }

    Thanks For help.