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
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
不幸的是没有嗅探器日志可用。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);
}