⚠️
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.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
2 posts / 0 new
Last post
stanley_yeh
Offline
Last seen:1 year 11 months ago
Joined:2016-12-23 06:52
发送消息的问题

Hi Dialog,
I use the function below to send BLE messages to my mobile(host).

void user_send_ble_data(uint16_t handle, const uint8_t* data, const uint16_t length)
{
if (ke_state_get(TASK_APP) != APP_CONNECTED)
return;

struct custs1_val_ntf_ind_req *req = KE_MSG_ALLOC_DYN(CUSTS1_VAL_NTF_REQ, prf_get_task_from_id(TASK_ID_CUSTS1), TASK_APP, custs1_val_ntf_ind_req, length);

req->handle = handle;
req->length = length;
req->notification = false;
memcpy(请求- >价值,data, length);

ke_msg_send(req);
}
I use a test app of Android to send a command message continually to DA14585 every 5 seconds.
Every time my device receives the command message, it should send 10 raw data messages to the test app such as:
for(uint8_t i=0;i<10;i++)
{
user_send_ble_data(TDKAM_IDX_CONTROL_POINT_VAL, ble_report, 10);
}

After a while, the device will disconnect.
After re-connecting, DA14585 can receive message but cannot send any message.
If I still send the command message to DA14585, it will crash.
Even I re-burn the code, it will stuck on "rwip_schedule()" function.
Do you have any idea? Is there any wrong with my sending function?

By the way, if DA14585 receive a message and just send back one message, it's no problem.
Thanks a lot.

Device:
MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
Joined:2015-06-08 11:34
Hi stanley_yeh,

Hi stanley_yeh,

As far as i can tell you are trying to send data using indications, that means that before sending the next indication the peripheral will have to verify that the previous one has been acked by the central. So, as far as i can tell you are keep on allocating messages in order to send indications while the device expects confirmation from the other side of the link, so apparently at some point you perhaps run out of heap. In order to properly send notifications and indications you will have to wait for the completion callback to occur before sending an additional message towards the stack. So you can use the user_send_ble_data and wait until the indication confirmation message, for example the ble_app_peripheral project includes an indicatable characteristic, the message that will indicate that the central confirmed the reception of the indication is the CUSTS1_VAL_IND_CFM and the project handles that in the ble_app_peripheral project. So from that callback you can trigger subsequent indications.

Thanks MT_dialog