mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-13 13:09:49 +04:00
* ble: profile rework, initial * apps: hid: fix for pairing cleanup * app: hid: select transport based on #define * fixing PVS warnings * ble: serial service: fixed uid naming * bt service: on-demand dialog init; ble profiles: docs; battery svc: proper update * Added shci_cmd_resp_wait/shci_cmd_resp_release impl with semaphore * app: hid: separated transport code * ble: fixed service init order for serial svc; moved hardfault check to ble_glue * cli: ps: added thread prio to output, fixed heap display * ble_glue: naming changes; separate thread for event processing; * furi: added runtime stats; cli: added cpu% to `ps` * cli: fixed thread time calculation * furi: added getter for thread priority * fixing pvs warnings * hid profile: fixed naming * more naming fixes * hal: ble init small cleanup * cleanup & draft beacon api * f18: api sync * apps: moved example_custom_font from debug to examples * BLE extra beacon demo app * naming fix * UI fixes for demo app (wip) * desktop, ble svc: added statusbar icon for beacon * minor cleanup * Minor cleanup & naming fixes * api sync * Removed stale header * hal: added FURI_BLE_EXTRA_LOG for extra logging; comments & code cleanup * naming & macro fixes * quick fixes from review * Eliminated stock svc_ctl * cli: ps: removed runtime stats * minor include fixes * (void) * naming fixes * More naming fixes * fbt: always build all libs * fbt: explicitly globbing libs; dist: logging SDK path * scripts: fixed lib path precedence * hal: bt: profiles: naming changes, support for passing params to a profile; include cleanup * ble: hid: added parameter processing for profile template * api sync * BLE HID: long name trim * Removed unused check * desktop: updated beacon status icon; ble: hid: cleaner device name management * desktop: updated status icon Co-authored-by: あく <alleteam@gmail.com> Co-authored-by: nminaylov <nm29719@gmail.com>
80 lines
2.4 KiB
C
80 lines
2.4 KiB
C
#include "bt_i.h"
|
|
#include <profiles/serial_profile.h>
|
|
|
|
FuriHalBleProfileBase* bt_profile_start(
|
|
Bt* bt,
|
|
const FuriHalBleProfileTemplate* profile_template,
|
|
FuriHalBleProfileParams params) {
|
|
furi_assert(bt);
|
|
|
|
// Send message
|
|
FuriHalBleProfileBase* profile_instance = NULL;
|
|
|
|
BtMessage message = {
|
|
.lock = api_lock_alloc_locked(),
|
|
.type = BtMessageTypeSetProfile,
|
|
.profile_instance = &profile_instance,
|
|
.data.profile.params = params,
|
|
.data.profile.template = profile_template,
|
|
};
|
|
furi_check(
|
|
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
|
// Wait for unlock
|
|
api_lock_wait_unlock_and_free(message.lock);
|
|
|
|
bt->current_profile = profile_instance;
|
|
return profile_instance;
|
|
}
|
|
|
|
bool bt_profile_restore_default(Bt* bt) {
|
|
bt->current_profile = bt_profile_start(bt, ble_profile_serial, NULL);
|
|
return bt->current_profile != NULL;
|
|
}
|
|
|
|
void bt_disconnect(Bt* bt) {
|
|
furi_assert(bt);
|
|
|
|
// Send message
|
|
BtMessage message = {.lock = api_lock_alloc_locked(), .type = BtMessageTypeDisconnect};
|
|
furi_check(
|
|
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
|
// Wait for unlock
|
|
api_lock_wait_unlock_and_free(message.lock);
|
|
}
|
|
|
|
void bt_set_status_changed_callback(Bt* bt, BtStatusChangedCallback callback, void* context) {
|
|
furi_assert(bt);
|
|
|
|
bt->status_changed_cb = callback;
|
|
bt->status_changed_ctx = context;
|
|
}
|
|
|
|
void bt_forget_bonded_devices(Bt* bt) {
|
|
furi_assert(bt);
|
|
BtMessage message = {.type = BtMessageTypeForgetBondedDevices};
|
|
furi_check(
|
|
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
|
}
|
|
|
|
void bt_keys_storage_set_storage_path(Bt* bt, const char* keys_storage_path) {
|
|
furi_assert(bt);
|
|
furi_assert(bt->keys_storage);
|
|
furi_assert(keys_storage_path);
|
|
|
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
FuriString* path = furi_string_alloc_set(keys_storage_path);
|
|
storage_common_resolve_path_and_ensure_app_directory(storage, path);
|
|
|
|
bt_keys_storage_set_file_path(bt->keys_storage, furi_string_get_cstr(path));
|
|
|
|
furi_string_free(path);
|
|
furi_record_close(RECORD_STORAGE);
|
|
}
|
|
|
|
void bt_keys_storage_set_default_path(Bt* bt) {
|
|
furi_assert(bt);
|
|
furi_assert(bt->keys_storage);
|
|
|
|
bt_keys_storage_set_file_path(bt->keys_storage, BT_KEYS_STORAGE_PATH);
|
|
}
|