From 33ef5c3c9ff5107521438cedfea3809500b635d4 Mon Sep 17 00:00:00 2001 From: Astra Date: Fri, 20 Dec 2024 18:49:37 +0900 Subject: [PATCH] Move away from semaphores --- targets/f18/api_symbols.csv | 1 - targets/f7/api_symbols.csv | 1 - targets/f7/ble_glue/furi_ble/gatt.c | 9 +++++---- targets/f7/ble_glue/gap.c | 14 -------------- targets/f7/ble_glue/gap.h | 2 -- 5 files changed, 5 insertions(+), 22 deletions(-) diff --git a/targets/f18/api_symbols.csv b/targets/f18/api_symbols.csv index 79780c186e2..23421712d01 100644 --- a/targets/f18/api_symbols.csv +++ b/targets/f18/api_symbols.csv @@ -1720,7 +1720,6 @@ Function,-,gap_init,_Bool,"GapConfig*, GapEventCallback, void*" Function,-,gap_start_advertising,void, Function,-,gap_stop_advertising,void, Function,-,gap_thread_stop,void, -Function,-,gap_wait_for_tx_pool_available,void,FuriWait Function,-,getc,int,FILE* Function,-,getc_unlocked,int,FILE* Function,-,getchar,int, diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index ebbfa4203cc..6f9fc5466e6 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -1939,7 +1939,6 @@ Function,-,gap_init,_Bool,"GapConfig*, GapEventCallback, void*" Function,-,gap_start_advertising,void, Function,-,gap_stop_advertising,void, Function,-,gap_thread_stop,void, -Function,-,gap_wait_for_tx_pool_available,void,FuriWait Function,-,getc,int,FILE* Function,-,getc_unlocked,int,FILE* Function,-,getchar,int, diff --git a/targets/f7/ble_glue/furi_ble/gatt.c b/targets/f7/ble_glue/furi_ble/gatt.c index 5d5082eb81e..35ffe82288f 100644 --- a/targets/f7/ble_glue/furi_ble/gatt.c +++ b/targets/f7/ble_glue/furi_ble/gatt.c @@ -1,5 +1,4 @@ #include "gatt.h" -#include "gap.h" #include #include @@ -120,9 +119,11 @@ bool ble_gatt_characteristic_update( if(result) { if(result == BLE_STATUS_INSUFFICIENT_RESOURCES) { FURI_LOG_E(TAG, "Insufficient resources for %s characteristic", char_descriptor->name); - gap_wait_for_tx_pool_available(1000); // 1 second timeout - result = aci_gatt_update_char_value( - svc_handle, char_instance->handle, 0, char_data_size, char_data); + do { + furi_delay_ms(1); + result = aci_gatt_update_char_value( + svc_handle, char_instance->handle, 0, char_data_size, char_data); + } while(result == BLE_STATUS_INSUFFICIENT_RESOURCES); } } diff --git a/targets/f7/ble_glue/gap.c b/targets/f7/ble_glue/gap.c index 43af1789a32..732440ccf90 100644 --- a/targets/f7/ble_glue/gap.c +++ b/targets/f7/ble_glue/gap.c @@ -40,7 +40,6 @@ typedef struct { bool enable_adv; bool is_secure; uint8_t negotiation_round; - FuriSemaphore* tx_pool_busy; } Gap; typedef enum { @@ -300,11 +299,6 @@ BleEventFlowStatus ble_event_app_notification(void* pckt) { } break; } - - case ACI_GATT_TX_POOL_AVAILABLE_VSEVT_CODE: - FURI_LOG_D(TAG, "TX pool available event"); - furi_semaphore_release(gap->tx_pool_busy); - break; } default: break; @@ -315,11 +309,6 @@ BleEventFlowStatus ble_event_app_notification(void* pckt) { return BleEventFlowEnable; } -void gap_wait_for_tx_pool_available(FuriWait wait) { - furi_check(gap); - furi_check(furi_semaphore_acquire(gap->tx_pool_busy, wait) == FuriStatusOk); -} - static void set_advertisment_service_uid(uint8_t* uid, uint8_t uid_len) { if(uid_len == 2) { gap->service.adv_svc_uuid[0] = AD_TYPE_16_BIT_SERV_UUID; @@ -538,7 +527,6 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) { gap = malloc(sizeof(Gap)); gap->config = config; - gap->tx_pool_busy = furi_semaphore_alloc(1, 0); // Create advertising timer gap->advertise_timer = furi_timer_alloc(gap_advetise_timer_callback, FuriTimerTypeOnce, NULL); // Initialization of GATT & GAP layer @@ -604,8 +592,6 @@ void gap_thread_stop(void) { gap->command_queue = NULL; furi_timer_free(gap->advertise_timer); gap->advertise_timer = NULL; - furi_semaphore_free(gap->tx_pool_busy); - gap->tx_pool_busy = NULL; ble_event_dispatcher_reset(); free(gap); diff --git a/targets/f7/ble_glue/gap.h b/targets/f7/ble_glue/gap.h index f3107f0bd30..4923b03e1f0 100644 --- a/targets/f7/ble_glue/gap.h +++ b/targets/f7/ble_glue/gap.h @@ -90,8 +90,6 @@ void gap_thread_stop(void); void gap_emit_ble_beacon_status_event(bool active); -void gap_wait_for_tx_pool_available(FuriWait wait); - #ifdef __cplusplus } #endif