summaryrefslogtreecommitdiffstatshomepage
path: root/extmod/btstack/modbluetooth_btstack.h
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2020-06-16 21:53:22 +1000
committerDamien George <damien@micropython.org>2020-07-18 14:23:47 +1000
commite152d0c19769f26e5416f86fe81afb9376fb531b (patch)
tree122c1a61eaedc86e4077139e0593d222549a2074 /extmod/btstack/modbluetooth_btstack.h
parent07aec4681f6ea5173315e660c6ba39cd12a2aa58 (diff)
downloadmicropython-e152d0c19769f26e5416f86fe81afb9376fb531b.tar.gz
micropython-e152d0c19769f26e5416f86fe81afb9376fb531b.zip
extmod/btstack: Schedule notify/indicate/write ops for bg completion.
The goal of this commit is to allow using ble.gatts_notify() at any time, even if the stack is not ready to send the notification right now. It also addresses the same issue for ble.gatts_indicate() and ble.gattc_write() (without response). In addition this commit fixes the case where the buffer passed to write-with-response wasn't copied, meaning it could be modified by the caller, affecting the in-progress write. The changes are: - gatts_notify/indicate will now run in the background if the ACL buffer is currently full, meaning that notify/indicate can be called at any time. - gattc_write(mode=0) (no response) will now allow for one outstanding write. - gattc_write(mode=1) (with response) will now copy the buffer so that it can't be modified by the caller while the write is in progress. All four paths also now track the buffer while the operation is in progress, which prevents the GC free'ing the buffer while it's still needed.
Diffstat (limited to 'extmod/btstack/modbluetooth_btstack.h')
-rw-r--r--extmod/btstack/modbluetooth_btstack.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/extmod/btstack/modbluetooth_btstack.h b/extmod/btstack/modbluetooth_btstack.h
index 3bdb5f271e..c943b6d72d 100644
--- a/extmod/btstack/modbluetooth_btstack.h
+++ b/extmod/btstack/modbluetooth_btstack.h
@@ -33,6 +33,8 @@
#include "lib/btstack/src/btstack.h"
+typedef struct _mp_btstack_pending_op_t mp_btstack_pending_op_t;
+
typedef struct _mp_bluetooth_btstack_root_pointers_t {
// This stores both the advertising data and the scan response data, concatenated together.
uint8_t *adv_data;
@@ -45,6 +47,7 @@ typedef struct _mp_bluetooth_btstack_root_pointers_t {
#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
// Registration for notify/indicate events.
gatt_client_notification_t notification;
+ btstack_linked_list_t pending_ops;
#endif
} mp_bluetooth_btstack_root_pointers_t;