[FL-1796] Disable bluetooth (#703)

* bt: add authentication for all characteristics
* bt: app_ble cleanup
* bt: add start and stop advertising API
* bt: rework application with start and stop advertising API
* bt: support f7 target
* bt: f7 target remove unused files
* bt: stop advertising in bt debug application
* bt: fix bt status bar update
* bt: change bluetooth On Off order
This commit is contained in:
gornekich
2021-09-15 19:58:32 +03:00
committed by GitHub
parent 8fd411097e
commit 4768177cf5
33 changed files with 768 additions and 785 deletions

View File

@@ -3,13 +3,6 @@
#define BT_SERVICE_TAG "BT"
// static void bt_update_statusbar(void* arg) {
// furi_assert(arg);
// Bt* bt = arg;
// BtMessage m = {.type = BtMessageTypeUpdateStatusbar};
// furi_check(osMessageQueuePut(bt->message_queue, &m, 0, osWaitForever) == osOK);
// }
static void bt_draw_statusbar_callback(Canvas* canvas, void* context) {
canvas_draw_icon(canvas, 0, 0, &I_Bluetooth_5x8);
}
@@ -42,10 +35,6 @@ Bt* bt_alloc() {
// Alloc queue
bt->message_queue = osMessageQueueNew(8, sizeof(BtMessage), NULL);
// doesn't make sense if we waiting for transition on service start
// bt->update_status_timer = osTimerNew(bt_update_statusbar, osTimerPeriodic, bt, NULL);
// osTimerStart(bt->update_status_timer, 4000);
// Setup statusbar view port
bt->statusbar_view_port = bt_statusbar_view_port_alloc();
// Gui
@@ -67,15 +56,18 @@ int32_t bt_srv() {
FURI_LOG_E(BT_SERVICE_TAG, "Core2 startup failed");
} else {
view_port_enabled_set(bt->statusbar_view_port, true);
if(bt->bt_settings.enabled) {
bool bt_app_started = furi_hal_bt_start_app();
if(!bt_app_started) {
FURI_LOG_E(BT_SERVICE_TAG, "BT App start failed");
} else {
FURI_LOG_I(BT_SERVICE_TAG, "BT App started");
if(furi_hal_bt_init_app()) {
FURI_LOG_I(BT_SERVICE_TAG, "BLE stack started");
if(bt->bt_settings.enabled) {
furi_hal_bt_start_advertising();
FURI_LOG_I(BT_SERVICE_TAG, "Start advertising");
}
} else {
FURI_LOG_E(BT_SERVICE_TAG, "BT App start failed");
}
}
// Update statusbar
view_port_enabled_set(bt->statusbar_view_port, furi_hal_bt_is_alive());
BtMessage message;
while(1) {

View File

@@ -9,6 +9,8 @@ extern "C" {
typedef struct Bt Bt;
void bt_update_statusbar(Bt* bt);
void bt_update_battery_level(Bt* bt, uint8_t battery_level);
bool bt_pin_code_show(Bt* bt, uint32_t pin_code);

View File

@@ -1,6 +1,12 @@
#include "bt.h"
#include "bt_i.h"
void bt_update_statusbar(Bt* bt) {
furi_assert(bt);
BtMessage message = {.type = BtMessageTypeUpdateStatusbar};
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
}
void bt_update_battery_level(Bt* bt, uint8_t battery_level) {
furi_assert(bt);
BtMessage message = {

View File

@@ -32,7 +32,6 @@ typedef struct {
struct Bt {
BtSettings bt_settings;
osMessageQueueId_t message_queue;
osTimerId_t update_status_timer;
Gui* gui;
ViewPort* statusbar_view_port;
DialogsApp* dialogs;