From 25f9ee9aaa4eeb3a7d9cc08504e7e743fcc9f4a6 Mon Sep 17 00:00:00 2001 From: Raj Nakarja Date: Wed, 31 May 2023 15:25:36 +0200 Subject: [PATCH] Fixed crash when sd_ble_gatts_value_get is checked with invalid connection handle Added guard to send all REPL data before sending raw data --- main.c | 10 ++++++++++ micropython | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 277ce663..da4dd38f 100644 --- a/main.c +++ b/main.c @@ -117,6 +117,11 @@ bool ble_are_tx_notifications_enabled(ble_tx_channel_t channel) .offset = 0, .p_value = &(value_buffer[0])}; + if (ble_handles.connection == BLE_CONN_HANDLE_INVALID) + { + return false; + } + // Read the CCCD attribute value for one of the tx characteristics switch (channel) { @@ -217,6 +222,11 @@ bool ble_send_raw_data(const uint8_t *bytes, size_t len) return true; } + // Send all REPL data before sending raw data + while (ble_send_repl_data() == false) + { + } + // Initialise the handle value parameters ble_gatts_hvx_params_t hvx_params = {0}; hvx_params.handle = ble_handles.data_tx_notification.value_handle; diff --git a/micropython b/micropython index ed7a3b11..b85611da 160000 --- a/micropython +++ b/micropython @@ -1 +1 @@ -Subproject commit ed7a3b11d9a6c21a964d55ebfcdefeb392389d10 +Subproject commit b85611dae8ac13aa4c1eb37377a58cd77d04424e