⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
2 posts / 0 new
Last post
didi17000
Offline
Last seen:3 years 7 months ago
加入:2017-05-17 14:19
Received data DA14681

Hi Dialog,
I want to use da14681 to received data from phone. I used ble_peripheral Example. I can received data send by the da14681 to the phone with ble_gatt_set_value function but that doesn't work when i used ble_gatt_get_value function to received data on the da14681. I don't know where the data received was store. I use a sps profile that I modified.

num_attr = ble_gatts_get_num_attr(0, 3, 0);

ble_uuid_from_string(UUID_SPS, &uuid);
ble_gatts_add_service(&uuid, GATT_SERVICE_PRIMARY, num_attr);

/* SPS Server TX */
ble_uuid_from_string(UUID_SPS_SERVER_TX, &uuid);
ble_gatts_add_characteristic(&uuid, GATT_PROP_READ, ATT_PERM_READ,
sps_server_tx_size, 0, NULL, &sps->sps_tx_val_h);

/* SPS Server RX */
ble_uuid_from_string(UUID_SPS_SERVER_RX, &uuid);
ble_gatts_add_characteristic(&uuid, GATT_PROP_WRITE_NO_RESP, ATT_PERM_WRITE,
sps_server_rx_size, 0, NULL, &sps->sps_rx_val_h);

/* Register SPS Service */
ble_gatts_register_service(&sps->svc.start_h, &sps->sps_tx_val_h, &sps->sps_rx_val_h, 0);

/* Set value of Characteristic Descriptions */
ble_gatts_set_value(sps->sps_tx_val_h, sizeof(test), &test);
ble_gatts_get_value(sps->sps_rx_val_h, &sizeData, &receivedData);

sps - > svc。end_h = sps->svc.start_h + num_attr;
sps - > svc。write_req = handle_write_req;
sps - > svc。read_req = handle_read_req;
sps - > svc。event_sent = handle_event_sent;
sps->cb = cb;

return &sps->svc;

Thanks

Dimitri

Device:
MT_dialog
Offline
Last seen:2 months 5 days ago
年代taff
加入:2015-06-08 11:34
Hi didi17000,

Hi didi17000,

I dont quite understand the question, the ble_gatts_send_value() function is used in order to set the value of a characteristic in the internal database of the device, so when the client makes a request in order to read the value of a characteristic, this value will be returned (send to the client). The ble_gatts_get_value() function is used in order to get the value of that characteristic that it was previously set with the ble_gatts_send_value(), not read any value from the client, if that is what you mean. When a client sends data (the more proper word is write data since it writes on a characteristic in the value attribute of your database), the callback function that it is assigned to the write procedure will notify your application. In the code that you have attached the handle_write_req() function should be executed in order to notify you that a client has written to that specific characteristic, so after the write is completed you can read the corresponding characteristic in order to get the value that the client has written.

Thanks MT_dialog