From abe43fe6873bf78c98634eac74de646f70ec0d32 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 11 Feb 2024 15:08:08 +1100 Subject: extmod/btstack: Reset pending_value_handle before calling read-done cb. Similar to the previous commit but for MP_BLUETOOTH_IRQ_GATTC_READ_DONE: the pending_value_handle needs to be reset before calling mp_bluetooth_gattc_on_read_write_status(), which will call the Python IRQ handler, which may in turn call back into BTstack to perform an action like a write. In that case the pending_value_handle will need to be available for the write/read/etc to proceed. Fixes issue #13634. Signed-off-by: Damien George --- extmod/btstack/modbluetooth_btstack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'extmod/btstack/modbluetooth_btstack.c') diff --git a/extmod/btstack/modbluetooth_btstack.c b/extmod/btstack/modbluetooth_btstack.c index 08d64ab012..b3d349c2dc 100644 --- a/extmod/btstack/modbluetooth_btstack.c +++ b/extmod/btstack/modbluetooth_btstack.c @@ -462,8 +462,9 @@ STATIC void btstack_packet_handler_read(uint8_t packet_type, uint16_t channel, u if (!conn) { return; } - mp_bluetooth_gattc_on_read_write_status(MP_BLUETOOTH_IRQ_GATTC_READ_DONE, conn_handle, conn->pending_value_handle, status); + uint16_t value_handle = conn->pending_value_handle; conn->pending_value_handle = 0xffff; + mp_bluetooth_gattc_on_read_write_status(MP_BLUETOOTH_IRQ_GATTC_READ_DONE, conn_handle, value_handle, status); } else if (event_type == GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT) { DEBUG_printf(" --> gatt characteristic value query result\n"); uint16_t conn_handle = gatt_event_characteristic_value_query_result_get_handle(packet); -- cgit v1.2.3