EasyManua.ls Logo

TELINK SEMICONDUCTOR TLSR8232 - Callback Function R

Default Icon
211 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1 97 Ver.1.0.0
u8 att; //opcode
u8 hl; //low byte of Atthandle
u8 hh; //high byte of Atthandle
u8 dat[20];
}rf_packet_att_data_t;
“p” points to “dma_len”, valid length of data is l2cap minus 3, and the first valid data is
pw->dat[0].
int my_WriteCallback (void *p)
{
rf_packet_att_data_t *pw = (rf_packet_att_data_t *)p;
int len = pw->l2cap - 3;
//add your code
//valid data is pw->dat[0] ~ pw->dat[len-1]
return 1;
}
The structure “rf_packet_att_data_tabove is available in “stack/ble/ble_common.h”.
3.4.2.6 Callback Function r
The callback function r is a read function, its prototype is:
typedef int (*att_readwrite_callback_t)(void* p);
Users must follow the format above to define callback read function. The callback
function r is also optional, i.e. for an Attribute, user can select whether to set the callback
read function as needed (null pointer 0 indicates not setting callback read function).
The trigger condition for callback function r is: When Slave receives any Attribute PDU
with Attribute Opcode as shown below, Slave will check whether the callback function r is
set.
1) opcode = 0x0A, Read Request, see Core_v5.0.
2) opcode = 0x0C, Read Blob Request, see Core_v5.0.
After Slave receives a read command above,
1) If the callback read function is set, Slave will execute this function, and determine
whether to respond with “Read Response/Read Blob Response” according to the
return value of this function.
a) If the return value is 1, Slave won’t respond with Read Response/Read Blob
Response” to Master.
b) If the return value is not 1, Slave will automatically read “attrLenbytes of data
from the area pointed by the “pAttrValue”, and the data will be responded to
Master via “Read Response/Read Blob Response”.

Table of Contents