BLE/GAP fixes

by hedger
https://github.com/flipperdevices/flipperzero-firmware/pull/3533/files
This commit is contained in:
MX 2024-03-22 23:43:09 +03:00
parent d1d3c43939
commit 46a90ec97f
No known key found for this signature in database
GPG key ID: 7CCC66B7DBDD1C83
9 changed files with 24 additions and 21 deletions

View file

@ -7,7 +7,7 @@
# construction of certain targets behind command-line options. # construction of certain targets behind command-line options.
import os import os
from fbt.util import path_as_posix from fbt.util import open_browser_action
DefaultEnvironment(tools=[]) DefaultEnvironment(tools=[])

View file

@ -105,7 +105,8 @@ class PosixPathWrapper:
return self.fix_path(env.subst(self.pathobj)) return self.fix_path(env.subst(self.pathobj))
def path_as_posix(path): def open_browser_action(target, source, env):
if SCons.Platform.platform_default() == "win32": if sys.platform == "darwin":
return path.replace(os.path.sep, os.path.altsep) subprocess.run(["open", source[0].abspath])
return path else:
webbrowser.open(source[0].abspath)

View file

@ -639,8 +639,8 @@ Function,+,ble_glue_is_alive,_Bool,
Function,+,ble_glue_is_radio_stack_ready,_Bool, Function,+,ble_glue_is_radio_stack_ready,_Bool,
Function,+,ble_glue_reinit_c2,_Bool, Function,+,ble_glue_reinit_c2,_Bool,
Function,+,ble_glue_set_key_storage_changed_callback,void,"BleGlueKeyStorageChangedCallback, void*" Function,+,ble_glue_set_key_storage_changed_callback,void,"BleGlueKeyStorageChangedCallback, void*"
Function,+,ble_glue_start,_Bool, Function,-,ble_glue_start,_Bool,
Function,+,ble_glue_stop,void, Function,-,ble_glue_stop,void,
Function,+,ble_glue_wait_for_c2_start,_Bool,int32_t Function,+,ble_glue_wait_for_c2_start,_Bool,int32_t
Function,-,ble_profile_hid_consumer_key_press,_Bool,"FuriHalBleProfileBase*, uint16_t" Function,-,ble_profile_hid_consumer_key_press,_Bool,"FuriHalBleProfileBase*, uint16_t"
Function,-,ble_profile_hid_consumer_key_release,_Bool,"FuriHalBleProfileBase*, uint16_t" Function,-,ble_profile_hid_consumer_key_release,_Bool,"FuriHalBleProfileBase*, uint16_t"

1 entry status name type params
639 Function + ble_glue_is_radio_stack_ready _Bool
640 Function + ble_glue_reinit_c2 _Bool
641 Function + ble_glue_set_key_storage_changed_callback void BleGlueKeyStorageChangedCallback, void*
642 Function + - ble_glue_start _Bool
643 Function + - ble_glue_stop void
644 Function + ble_glue_wait_for_c2_start _Bool int32_t
645 Function - ble_profile_hid_consumer_key_press _Bool FuriHalBleProfileBase*, uint16_t
646 Function - ble_profile_hid_consumer_key_release _Bool FuriHalBleProfileBase*, uint16_t

View file

@ -689,7 +689,7 @@ Function,-,ble_app_get_key_storage_buff,void,"uint8_t**, uint16_t*"
Function,-,ble_app_init,_Bool, Function,-,ble_app_init,_Bool,
Function,-,ble_event_app_notification,BleEventFlowStatus,void* Function,-,ble_event_app_notification,BleEventFlowStatus,void*
Function,-,ble_event_dispatcher_init,void, Function,-,ble_event_dispatcher_init,void,
Function,+,ble_event_dispatcher_process_event,BleEventFlowStatus,void* Function,-,ble_event_dispatcher_process_event,BleEventFlowStatus,void*
Function,+,ble_event_dispatcher_register_svc_handler,GapSvcEventHandler*,"BleSvcEventHandlerCb, void*" Function,+,ble_event_dispatcher_register_svc_handler,GapSvcEventHandler*,"BleSvcEventHandlerCb, void*"
Function,-,ble_event_dispatcher_reset,void, Function,-,ble_event_dispatcher_reset,void,
Function,+,ble_event_dispatcher_unregister_svc_handler,void,GapSvcEventHandler* Function,+,ble_event_dispatcher_unregister_svc_handler,void,GapSvcEventHandler*

1 entry status name type params
689 Function - ble_app_init _Bool
690 Function - ble_event_app_notification BleEventFlowStatus void*
691 Function - ble_event_dispatcher_init void
692 Function + - ble_event_dispatcher_process_event BleEventFlowStatus void*
693 Function + ble_event_dispatcher_register_svc_handler GapSvcEventHandler* BleSvcEventHandlerCb, void*
694 Function - ble_event_dispatcher_reset void
695 Function + ble_event_dispatcher_unregister_svc_handler void GapSvcEventHandler*

View file

@ -80,7 +80,7 @@ void ble_event_thread_stop(void) {
} }
FuriThreadId thread_id = furi_thread_get_id(event_thread); 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_flags_set(thread_id, BLE_EVENT_THREAD_FLAG_KILL_THREAD);
furi_thread_join(event_thread); furi_thread_join(event_thread);
furi_thread_free(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) { bool ble_glue_start(void) {
furi_assert(ble_glue); furi_check(ble_glue);
if(ble_glue->status != BleGlueStatusC2Started) { if(ble_glue->status != BleGlueStatusC2Started) {
return false; return false;
@ -243,7 +243,7 @@ bool ble_glue_start(void) {
} }
void ble_glue_stop(void) { void ble_glue_stop(void) {
furi_assert(ble_glue); furi_check(ble_glue);
ble_event_thread_stop(); ble_event_thread_stop();
// Free resources // Free resources

View file

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

View file

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

View file

@ -75,7 +75,7 @@ static inline void fetch_rssi() {
} }
static void gap_verify_connection_parameters(Gap* gap) { static void gap_verify_connection_parameters(Gap* gap) {
furi_assert(gap); furi_check(gap);
FURI_LOG_I( FURI_LOG_I(
TAG, TAG,
@ -515,6 +515,8 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
return false; return false;
} }
furi_check(gap == NULL);
gap = malloc(sizeof(Gap)); gap = malloc(sizeof(Gap));
gap->config = config; gap->config = config;
// Create advertising timer // Create advertising timer
@ -532,13 +534,13 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
gap->conn_rssi = 127; gap->conn_rssi = 127;
gap->time_rssi_sample = 0; gap->time_rssi_sample = 0;
// Command queue allocation
gap->command_queue = furi_message_queue_alloc(8, sizeof(GapCommand));
// Thread configuration // Thread configuration
gap->thread = furi_thread_alloc_ex("BleGapDriver", 1024, gap_app, gap); gap->thread = furi_thread_alloc_ex("BleGapDriver", 1024, gap_app, gap);
furi_thread_start(gap->thread); furi_thread_start(gap->thread);
// Command queue allocation
gap->command_queue = furi_message_queue_alloc(8, sizeof(GapCommand));
uint8_t adv_service_uid[2]; uint8_t adv_service_uid[2];
gap->service.adv_svc_uuid_len = 1; gap->service.adv_svc_uuid_len = 1;
adv_service_uid[0] = gap->config->adv_service_uuid & 0xff; adv_service_uid[0] = gap->config->adv_service_uuid & 0xff;