BLE/GAP fixes (#3533)

* hal: fixed ble_gap race on queue init
* fbt: removed deprecated path_as_posix
* hal: fixed inconsistencies between f7/f18 APIs
* hal: fixed excessively strict event handler re-init checks

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
hedger
2024-03-22 16:36:05 +04:00
committed by GitHub
parent 2aa2dcc71b
commit 6947d3dea2
9 changed files with 19 additions and 23 deletions

View File

@@ -80,7 +80,7 @@ void ble_event_thread_stop(void) {
}
FuriThreadId thread_id = furi_thread_get_id(event_thread);
furi_assert(thread_id);
furi_check(thread_id);
furi_thread_flags_set(thread_id, BLE_EVENT_THREAD_FLAG_KILL_THREAD);
furi_thread_join(event_thread);
furi_thread_free(event_thread);

View File

@@ -224,7 +224,7 @@ bool ble_glue_wait_for_c2_start(int32_t timeout_ms) {
}
bool ble_glue_start(void) {
furi_assert(ble_glue);
furi_check(ble_glue);
if(ble_glue->status != BleGlueStatusC2Started) {
return false;
@@ -243,7 +243,7 @@ bool ble_glue_start(void) {
}
void ble_glue_stop(void) {
furi_assert(ble_glue);
furi_check(ble_glue);
ble_event_thread_stop();
// Free resources

View File

@@ -50,14 +50,14 @@ BleEventFlowStatus ble_event_dispatcher_process_event(void* payload) {
}
void ble_event_dispatcher_init(void) {
furi_assert(!initialized);
GapSvcEventHandlerList_init(handlers);
initialized = true;
if(!initialized) {
GapSvcEventHandlerList_init(handlers);
initialized = true;
}
}
void ble_event_dispatcher_reset(void) {
furi_assert(initialized);
furi_check(initialized);
furi_check(GapSvcEventHandlerList_size(handlers) == 0);
GapSvcEventHandlerList_clear(handlers);

View File

@@ -90,7 +90,7 @@ bool ble_gatt_characteristic_update(
uint16_t svc_handle,
BleGattCharacteristicInstance* char_instance,
const void* source) {
furi_assert(char_instance);
furi_check(char_instance);
const BleGattCharacteristicParams* char_descriptor = char_instance->characteristic;
FURI_LOG_D(TAG, "Updating %s char", char_descriptor->name);

View File

@@ -60,7 +60,7 @@ static void gap_advertise_start(GapState new_state);
static int32_t gap_app(void* context);
static void gap_verify_connection_parameters(Gap* gap) {
furi_assert(gap);
furi_check(gap);
FURI_LOG_I(
TAG,
@@ -480,6 +480,8 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
return false;
}
furi_check(gap == NULL);
gap = malloc(sizeof(Gap));
gap->config = config;
// Create advertising timer
@@ -494,13 +496,13 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
gap->service.connection_handle = 0xFFFF;
gap->enable_adv = true;
// Command queue allocation
gap->command_queue = furi_message_queue_alloc(8, sizeof(GapCommand));
// Thread configuration
gap->thread = furi_thread_alloc_ex("BleGapDriver", 1024, gap_app, gap);
furi_thread_start(gap->thread);
// Command queue allocation
gap->command_queue = furi_message_queue_alloc(8, sizeof(GapCommand));
uint8_t adv_service_uid[2];
gap->service.adv_svc_uuid_len = 1;
adv_service_uid[0] = gap->config->adv_service_uuid & 0xff;