flipperzero-firmware/applications/bt/bt_service/bt_api.c
あく 936a2f64b2
[FL-2580] FuriHal: add more supported radio stacks (#1301)
* FuriHal: add more supported radio stacks
* Bt: correct ble stack enum value
* Bt: update cli testing commands implementation
* Scripts: always emitting ob data to update manifest; added ob_custradio.data for non-light radio stacks
* Scripts: added stack type whitelist & disclaimer message
* ble: remove scanner
* ble: remove HCI and advances ble stacks support
* bt: correctly close RPC session before bt reinit
* Scripts: update bundler: estimating flash layout & refusing to build dangerous packages; app frame: not adding redundant log handlers
* Docs: additional details on bundling updates; fixed updater error codes
* Docs: wording fixes for OTA.md

Co-authored-by: hedger <hedger@nanode.su>
Co-authored-by: gornekich <n.gorbadey@gmail.com>
Co-authored-by: SG <who.just.the.doctor@gmail.com>
2022-06-09 18:07:42 +09:00

39 lines
1.2 KiB
C
Executable File

#include "bt_i.h"
bool bt_set_profile(Bt* bt, BtProfile profile) {
furi_assert(bt);
// Send message
bool result = false;
BtMessage message = {
.type = BtMessageTypeSetProfile, .data.profile = profile, .result = &result};
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
// Wait for unlock
osEventFlagsWait(bt->api_event, BT_API_UNLOCK_EVENT, osFlagsWaitAny, osWaitForever);
return result;
}
void bt_disconnect(Bt* bt) {
furi_assert(bt);
// Send message
BtMessage message = {.type = BtMessageTypeDisconnect};
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
// Wait for unlock
osEventFlagsWait(bt->api_event, BT_API_UNLOCK_EVENT, osFlagsWaitAny, osWaitForever);
}
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(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
}