Notification sent and never received

⚠️
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.
3 posts / 0 new
Last post
nhan.ngodinh
Offline
Last seen:1 year 5 months ago
加入:2017-03-21 10:20
Notification sent and never received

We have created a firmware with 2 characteristics (read/notify and write). You can send a command using the write (with response) characteristic and get back the result using the read characteristic. To inform that the read characteristic contains the response a notification is sent.

When run from the PRO DEVKIT in battery mode everything works smoothly.

If we attach a USB smartphone charger and we try doing the same in that condition, sometimes the notifications don't reach the destination even if apparently they have been sent (ble_gatts_send_event returns success and BLE_EVT_GATTS_EVENT_SENT shows correctly).

The number of write/notification/read events are about 10 each within about 5 seconds. Usually the last command is the one that doesn't get notified.

Any idea?

Regards,
N

Device:
MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi nhan.ngodinh,

Hi nhan.ngodinh,

I dont see how suppling the device from the battery and then directly from the USB could affect the sending of the notifications, there is no obvious reason for that, do you have a sniffer log to verify the amount of packets send over the air ? Are you certain that the issue that you get is related with operating with a battery or when VBUS is plugged in ?

Thanks MT_Dialog

nhan.ngodinh
Offline
Last seen:1 year 5 months ago
加入:2017-03-21 10:20
Unfortunately no sniffer log

不幸的是没有嗅探器日志可用。I confirm that the problem is occurring the way I described.

I've found a workaround to this, the buggy sequence of commands is (simplified):

ble_storage_put_buffer(conn_idx, response_h, length, buf, OS_FREE_FUNC, false);
ble_storage_get_u16(conn_idx, ccc_h, &ccc);
if (ccc & GATT_CCC_NOTIFICATIONS) {
ble_gatts_send_event(conn_idx, response_h, GATT_EVENT_NOTIFICATION, sizeof(notify_body), ¬ify_body); // when VBUS is applied this is not working sometimes
}

I've created a workaround by adding a useless ble_storage_get_buffer() immediately after ble_storage_put_buffer(), with a simplified sequence like:

ble_storage_put_buffer(conn_idx, response_h, length, buf, OS_FREE_FUNC, false);
ble_storage_get_buffer(conn_idx, response_h, &dummylength, &dummybuf, OS_FREE_FUNC, false); // dummy read (workaround)
ble_storage_get_u16(conn_idx, ccc_h, &ccc);
if (ccc & GATT_CCC_NOTIFICATIONS) {
ble_gatts_send_event(conn_idx, response_h, GATT_EVENT_NOTIFICATION, sizeof(notify_body), ¬ify_body);
}