From c8054e445c58e2b4c850e98d5a3e210982b9ddf5 Mon Sep 17 00:00:00 2001 From: schneider <schneider@blinkenlichts.net> Date: Sat, 6 Feb 2021 01:52:21 +0100 Subject: [PATCH] change(mp-ble): Use synchronous interface Our interrupts are already scheduled via `mp_schedule()`. By switching to the synchronous interface we avoid yet another `mp_schedule()` call in the bluetooth module. This also allows the bluetooth module to not have to use its internal ring buffer. --- pycardium/modules/modbluetooth_card10.c | 6 ++++++ pycardium/mpconfigport.h | 1 + 2 files changed, 7 insertions(+) diff --git a/pycardium/modules/modbluetooth_card10.c b/pycardium/modules/modbluetooth_card10.c index 9923a2fd6..55bdb99f7 100644 --- a/pycardium/modules/modbluetooth_card10.c +++ b/pycardium/modules/modbluetooth_card10.c @@ -99,6 +99,8 @@ static void handle_att_event(struct epic_att_event *att_event) uint16_t end_handle = (v[i + 3] << 8) | v[i + 2]; mp_obj_bluetooth_uuid_t service_uuid; + service_uuid.base.type = + &mp_type_bluetooth_uuid; if (entry_size == 6) { memcpy(service_uuid.data, v + i + 4, 2); service_uuid.type = @@ -142,6 +144,8 @@ static void handle_att_event(struct epic_att_event *att_event) uint16_t value_handle = (v[i + 4] << 8) | v[i + 3]; mp_obj_bluetooth_uuid_t characteristic_uuid; + characteristic_uuid.base.type = + &mp_type_bluetooth_uuid; if (entry_size == 2 + 1 + 2 + 2) { memcpy(characteristic_uuid.data, v + i + 5, @@ -189,6 +193,8 @@ static void handle_att_event(struct epic_att_event *att_event) uint16_t descriptor_handle = (v[i + 1] << 8) | v[i]; mp_obj_bluetooth_uuid_t descriptor_uuid; + descriptor_uuid.base.type = + &mp_type_bluetooth_uuid; if (entry_size == 2 + 2) { memcpy(descriptor_uuid.data, v + i + 2, diff --git a/pycardium/mpconfigport.h b/pycardium/mpconfigport.h index fbe33070b..943f9c4a5 100644 --- a/pycardium/mpconfigport.h +++ b/pycardium/mpconfigport.h @@ -56,6 +56,7 @@ int mp_hal_csprng_read_int(void); #define MICROPY_PY_BLUETOOTH (1) #define MICROPY_PY_BUILTINS_MEMORYVIEW (1) #define MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE (1) +#define MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS (1) /* Modules */ #define MODULE_BHI160_ENABLED (1) -- GitLab