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.
I wrote a small function accessible by the menu in simple_central.c
/********************************************************************* * @fn SimpleCentral_enableNotif * * @brief Enable Notifications * * @param index - NOT USED * * @return always true */ bool SimpleCentral_enableNotif(uint8_t index) { uint8_t connIndex = SimpleCentral_getConnIndex(scConnHandle); status_t status; attWriteReq_t req; req.pValue = GATT_bm_alloc(scConnHandle, ATT_WRITE_REQ, 2, NULL); if (req.pValue != NULL) { req.handle = connList[connIndex].charHandle; 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 = 0; status = GATT_WriteCharValue(scConnHandle, &req, selfEntity); if (status != SUCCESS) { GATT_bm_free((gattMsg_t*) &req, ATT_WRITE_REQ); } } return (true); }
This is called after BLE_DISC_STATE_CHAR has been encountered and the charHandle has been set. I get status = 0x00 from the function but in SimpleCentral_processGATTMsg I end up with a write error (0x03). I'm pretty confused about getting these notifications enabled. They work on my iPhone central apps, so I know the peripheral is setup correctly and pushing notifications once subscribed.
This example helped a lot and is very near what I'm doing. So I assume it has to do with the handle, do I need to find the CCCD to pass? And how?
SDK 5.20.00.52
Hi,
The code shared writes to a specific characteristic which is 1 byte long. As you are writing two bytes, the write gets rejected.
Now, if you want to turn on notifications, you have to write in the CCCD (not in the characteristic itself).
You can review the simple_serial_socket_client example to see how this is done.
I hope this will help,
Best regards,
Thanks, Clement. I basically co-opted all the structures and functions from that example and eventually got it to work. That example I reference above might work, only if you know the CCCD a priori, which was the bulk of the workload that doesn't already exist in simple_central.c but does in the socket example file tree.
For anyone else, note, this code still manually selects the 0'th characteristic in SimpleCentral_enableNotif(), which is fine for now because I only have one right now: https://github.com/mattgaidica/simple_central_CC26X2R1_ESLO_SPEAKER/tree/2f4f85e6813d3344768a92fe54ccedb5f3d5c0ac It also modifies the UUID fields to be uint_8*2 (i.e. uint_16) and still has some relics from simple_central, but it's operational and encounters pMsg->method == ATT_HANDLE_VALUE_NOTI if the peripheral is indeed pushing notifications.