diff options
author | gornekich <n.gorbadey@gmail.com> | 2021-11-08 22:41:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-08 22:41:40 +0300 |
commit | 54dc16134dc8ea9139f88e991a69f648aac302d6 (patch) | |
tree | 6c70e90affb404f4ef8551207166c4f7259bd0d5 /applications/bt | |
parent | 4e9e9f32d702ddde3d8359884687b1e68a86c768 (diff) |
[FL-1922] BLE buffer overflow (#789)
* rpc: increase RPC buffer size. Add get available buffer size API
* bt: add flow control characteristic to serial service
* ble: change updating flow control characteristic logic
* rpc: add buffer is empty callback
* bt: add notification about empty RPC buffer
* ble: add more debug info
* serial_service: add mutex guarding available buffer size
* ble: remove debug logs in serial service
Diffstat (limited to 'applications/bt')
-rwxr-xr-x | applications/bt/bt_service/bt.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/applications/bt/bt_service/bt.c b/applications/bt/bt_service/bt.c index aa999e36..3336ab9f 100755 --- a/applications/bt/bt_service/bt.c +++ b/applications/bt/bt_service/bt.c @@ -81,7 +81,7 @@ Bt* bt_alloc() { } // Called from GAP thread from Serial service -static void bt_on_data_received_callback(uint8_t* data, uint16_t size, void* context) { +static uint16_t bt_on_data_received_callback(uint8_t* data, uint16_t size, void* context) { furi_assert(context); Bt* bt = context; @@ -89,6 +89,7 @@ static void bt_on_data_received_callback(uint8_t* data, uint16_t size, void* con if(bytes_processed != size) { FURI_LOG_E(BT_SERVICE_TAG, "Only %d of %d bytes processed by RPC", bytes_processed, size); } + return rpc_session_get_available_size(bt->rpc_session); } // Called from GAP thread from Serial service @@ -118,6 +119,11 @@ static void bt_rpc_send_bytes_callback(void* context, uint8_t* bytes, size_t byt } } +static void bt_rpc_buffer_is_empty_callback(void* context) { + furi_assert(context); + furi_hal_bt_notify_buffer_is_empty(); +} + // Called from GAP thread static void bt_on_gap_event_callback(BleEvent event, void* context) { furi_assert(context); @@ -132,9 +138,10 @@ static void bt_on_gap_event_callback(BleEvent event, void* context) { FURI_LOG_I(BT_SERVICE_TAG, "Open RPC connection"); bt->rpc_session = rpc_session_open(bt->rpc); rpc_session_set_send_bytes_callback(bt->rpc_session, bt_rpc_send_bytes_callback); + rpc_session_set_buffer_is_empty_callback(bt->rpc_session, bt_rpc_buffer_is_empty_callback); rpc_session_set_context(bt->rpc_session, bt); furi_hal_bt_set_data_event_callbacks( - bt_on_data_received_callback, bt_on_data_sent_callback, bt); + RPC_BUFFER_SIZE, bt_on_data_received_callback, bt_on_data_sent_callback, bt); // Update battery level PowerInfo info; power_get_info(bt->power, &info); |