summaryrefslogtreecommitdiffstatshomepage
path: root/extmod/btstack/modbluetooth_btstack.c
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2020-10-28 13:06:45 +1100
committerDamien George <damien@micropython.org>2020-11-13 17:19:05 +1100
commit81e92d3d6e1a605a6115821ac24dcbc2546ba0f9 (patch)
treef640bf328a0364808b1946130e802621a554c239 /extmod/btstack/modbluetooth_btstack.c
parent6d9fdff8d07f3fa2a05eddb05e1a55754ae3542f (diff)
downloadmicropython-81e92d3d6e1a605a6115821ac24dcbc2546ba0f9.tar.gz
micropython-81e92d3d6e1a605a6115821ac24dcbc2546ba0f9.zip
extmod/modbluetooth: Re-instate optional no-ringbuf modbluetooth.
This requires that the event handlers are called from non-interrupt context (i.e. the MicroPython scheduler). This will allow the BLE stack (e.g. NimBLE) to run from the scheduler rather than an IRQ like PENDSV, and therefore be able to invoke Python callbacks directly/synchronously. This allows writing Python BLE handlers for events that require immediate response such as _IRQ_READ_REQUEST (which was previous a hard IRQ) and future events relating to pairing/bonding. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'extmod/btstack/modbluetooth_btstack.c')
-rw-r--r--extmod/btstack/modbluetooth_btstack.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/extmod/btstack/modbluetooth_btstack.c b/extmod/btstack/modbluetooth_btstack.c
index a4cc601746..97dd2cbb53 100644
--- a/extmod/btstack/modbluetooth_btstack.c
+++ b/extmod/btstack/modbluetooth_btstack.c
@@ -838,15 +838,15 @@ STATIC uint16_t att_read_callback(hci_con_handle_t connection_handle, uint16_t a
return 0;
}
- #if MICROPY_PY_BLUETOOTH_GATTS_ON_READ_CALLBACK
// Allow Python code to override value (by using gatts_write), or deny (by returning false) the read.
+ // Note this will be a no-op if the ringbuffer implementation is being used, as the Python callback cannot
+ // be executed synchronously. This is currently always the case for btstack.
if ((buffer == NULL) && (buffer_size == 0)) {
if (!mp_bluetooth_gatts_on_read_request(connection_handle, att_handle)) {
DEBUG_printf("att_read_callback: read request denied\n");
return 0;
}
}
- #endif
uint16_t ret = att_read_callback_handle_blob(entry->data, entry->data_len, offset, buffer, buffer_size);
return ret;