Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE/GAP fixes #3533

Merged
merged 5 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# construction of certain targets behind command-line options.

import os
from fbt.util import path_as_posix, open_browser_action
from fbt.util import open_browser_action

DefaultEnvironment(tools=[])

Expand Down
6 changes: 0 additions & 6 deletions scripts/fbt/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,6 @@ def __call__(self, target, source, env, for_signature):
return self.fix_path(env.subst(self.pathobj))


def path_as_posix(path):
if SCons.Platform.platform_default() == "win32":
return path.replace(os.path.sep, os.path.altsep)
return path


def open_browser_action(target, source, env):
if sys.platform == "darwin":
subprocess.run(["open", source[0].abspath])
Expand Down
4 changes: 2 additions & 2 deletions targets/f18/api_symbols.csv
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,8 @@ Function,+,ble_glue_is_alive,_Bool,
Function,+,ble_glue_is_radio_stack_ready,_Bool,
Function,+,ble_glue_reinit_c2,_Bool,
Function,+,ble_glue_set_key_storage_changed_callback,void,"BleGlueKeyStorageChangedCallback, void*"
Function,+,ble_glue_start,_Bool,
Function,+,ble_glue_stop,void,
Function,-,ble_glue_start,_Bool,
Function,-,ble_glue_stop,void,
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_release,_Bool,"FuriHalBleProfileBase*, uint16_t"
Expand Down
2 changes: 1 addition & 1 deletion targets/f7/api_symbols.csv
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ Function,-,ble_app_get_key_storage_buff,void,"uint8_t**, uint16_t*"
Function,-,ble_app_init,_Bool,
Function,-,ble_event_app_notification,BleEventFlowStatus,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_reset,void,
Function,+,ble_event_dispatcher_unregister_svc_handler,void,GapSvcEventHandler*
Expand Down
2 changes: 1 addition & 1 deletion targets/f7/ble_glue/ble_event_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions targets/f7/ble_glue/ble_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions targets/f7/ble_glue/furi_ble/event_dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion targets/f7/ble_glue/furi_ble/gatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
10 changes: 6 additions & 4 deletions targets/f7/ble_glue/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down
Loading