long characteristics example?

3 posts / 0 new
Last post
hssmltd
Offline
Last seen:5 months 4 weeks ago
Joined:2015-09-05 08:29
long characteristics example?

Hi,
i'm trying to do the following:
using ble_app_sleepmode, on button press -> wake up, read some sensor data, before start advertising load the data into custom long characteristic
i read the data into fixed size array - 400bytes and everything is ok, but can't figure how to move/link the data into the long characteristic?
is there a way when reading the data from sensor to put it directly in the characteristic instead of reading into array and then move?

Please help :)

Device:
MT_dialog
Offline
Last seen:1 month 1 week ago
Staff
Joined:2015-06-08 11:34
Hi hssmltd,

Hi hssmltd,

程序一样的任何特点,而已send a CUSTS1_VAL_SET_REQ, or you can invoke directly the attmdb_att_set_value() function with a pointer to the
data array that you would like to send, just have a characteristic that is long enough 400 bytes, for example:

struct custs1_val_set_req* req = KE_MSG_ALLOC_DYN(CUSTS1_VAL_SET_REQ,
TASK_CUSTS1,
TASK_APP,
custs1_val_set_req,
DEF_CUST1_LONG_VALUE_CHAR_LEN);

req->conhdl = app_env->conhdl;
req->handle = CUST1_IDX_LONG_VALUE_VAL;
req->length = DEF_CUST1_LONG_VALUE_CHAR_LEN;
memcpy(req->value, data, DEF_CUST1_LONG_VALUE_CHAR_LEN);

ke_msg_send(req);

Where the "data" is a pointer to the data that you would like to send, after you have set the data then you can read it from the central.

Thanks MT_dialog

hssmltd
Offline
Last seen:5 months 4 weeks ago
Joined:2015-09-05 08:29
Dear MT_dialog,

Dear MT_dialog,
works fine, thanks!