mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 12:10:13 +01:00
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>
This commit is contained in:
committed by
Damien George
parent
6d9fdff8d0
commit
81e92d3d6e
@@ -43,8 +43,10 @@
|
||||
#define MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE (0)
|
||||
#endif
|
||||
|
||||
#ifndef MICROPY_PY_BLUETOOTH_GATTS_ON_READ_CALLBACK
|
||||
#define MICROPY_PY_BLUETOOTH_GATTS_ON_READ_CALLBACK (0)
|
||||
#ifndef MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS
|
||||
// This can be enabled if the BLE stack runs entirely in scheduler context
|
||||
// and therefore is able to call directly into the VM to run Python callbacks.
|
||||
#define MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS (0)
|
||||
#endif
|
||||
|
||||
// This is used to protect the ringbuffer.
|
||||
@@ -261,10 +263,8 @@ void mp_bluetooth_gatts_on_write(uint16_t conn_handle, uint16_t value_handle);
|
||||
// Call this when an acknowledgment is received for an indication.
|
||||
void mp_bluetooth_gatts_on_indicate_complete(uint16_t conn_handle, uint16_t value_handle, uint8_t status);
|
||||
|
||||
#if MICROPY_PY_BLUETOOTH_GATTS_ON_READ_CALLBACK
|
||||
// Call this when a characteristic is read from. Return false to deny the read.
|
||||
bool mp_bluetooth_gatts_on_read_request(uint16_t conn_handle, uint16_t value_handle);
|
||||
#endif
|
||||
|
||||
// Call this when an MTU exchange completes.
|
||||
void mp_bluetooth_gatts_on_mtu_exchanged(uint16_t conn_handle, uint16_t value);
|
||||
|
||||
Reference in New Issue
Block a user