- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
SDK function legattdb_regWriteHandleCb() can be used to register to receive a callback when a characteristic is written to by the client.
Is there a similar function that can be called to register to receive a callback when a characteristic is read by the client?
If not, how can the application be made aware that a characteristic has been read by the client?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unfortunately there is no read callback. but you can do it yourself. In the Create function register to process all GATT messages
lel2cap_regConnLessHandler(LEL2CAP_CID_LE_ATT, my_l2capHandler);
add a handler
void my_l2capHandler(LEL2CAP_HDR *l2capHdr)
{
LEATT_PDU_HDR *gattPtr = (LEATT_PDU_HDR*) (l2capHdr +1);
LEATT_PDU_READ_REQ_HDR *p_read_read = (LEATT_PDU_READ_REQ_HDR *)gattPtr;
int opcode = LEATT_OPCODE_MASK & gattPtr->attrCode ;
int handle = p_read_read->attrHandle;
ble_trace2("gatt handle:%04x opcode:%d", handle, opcode);
if ((opcode == LEATT_OPCODE_READ_REQ) && (handle == "handle of your attribute"))
{
// do whatever you need
}
// call the standard handler where peer will grab value of the attribute from the GATT DB
leatt_l2capHandler(l2capHdr);
}