BLE: F3 integration (#260)
* BLE: working version * BLE: cleanup * BLE: update device description and DIS. * BLE: explicitly take semaphore and configure CLK48, bt subsystem status, remove LPM. * HAL: add missing api_hal_bt_is_alive symbol * TODO about valuemutex * duplicate f3-1 (f4) ioc from f3 * regenerate project * use target dir for ble glue path * update f4 from f3 Co-authored-by: coreglitch <mail@s3f.ru>
This commit is contained in:
@@ -32,6 +32,7 @@ void lf_rfid_workaround(void* p);
|
||||
void nfc_task(void* p);
|
||||
void irukagotchi_task(void* p);
|
||||
void power_task(void* p);
|
||||
void bt_task(void* p);
|
||||
void sd_card_test(void* p);
|
||||
void application_vibro(void* p);
|
||||
void app_gpio_test(void* p);
|
||||
@@ -101,6 +102,10 @@ const FlipperStartupApp FLIPPER_STARTUP[] = {
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_BT
|
||||
{.app = bt_task, .name = "bt_task", .libs = {1, FURI_LIB{"cli_task"}}, .icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_CC1101
|
||||
{.app = cc1101_workaround,
|
||||
.name = "cc1101 workaround",
|
||||
|
@@ -11,6 +11,7 @@ ifeq ($(APP_RELEASE), 1)
|
||||
APP_MENU = 1
|
||||
APP_NFC = 1
|
||||
APP_POWER = 1
|
||||
APP_BT = 1
|
||||
APP_CLI = 1
|
||||
BUILD_IRDA = 1
|
||||
APP_IRUKAGOTCHI = 1
|
||||
@@ -45,10 +46,18 @@ endif
|
||||
APP_POWER ?= 0
|
||||
ifeq ($(APP_POWER), 1)
|
||||
APP_GUI = 1
|
||||
APP_CLI = 1
|
||||
CFLAGS += -DAPP_POWER
|
||||
C_SOURCES += $(wildcard $(APP_DIR)/power/*.c)
|
||||
endif
|
||||
|
||||
APP_BT ?= 0
|
||||
ifeq ($(APP_BT), 1)
|
||||
APP_CLI = 1
|
||||
CFLAGS += -DAPP_BT
|
||||
C_SOURCES += $(wildcard $(APP_DIR)/bt/*.c)
|
||||
endif
|
||||
|
||||
APP_MENU ?= 0
|
||||
ifeq ($(APP_MENU), 1)
|
||||
CFLAGS += -DAPP_MENU
|
||||
|
58
applications/bt/bt.c
Normal file
58
applications/bt/bt.c
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "bt_i.h"
|
||||
|
||||
Bt* bt_alloc() {
|
||||
Bt* bt = furi_alloc(sizeof(Bt));
|
||||
bt->cli = furi_open("cli");
|
||||
|
||||
bt->statusbar_icon = assets_icons_get(I_Bluetooth_5x8);
|
||||
bt->statusbar_widget = widget_alloc();
|
||||
widget_set_width(bt->statusbar_widget, icon_get_width(bt->statusbar_icon) + 2);
|
||||
widget_draw_callback_set(bt->statusbar_widget, bt_draw_statusbar_callback, bt);
|
||||
widget_enabled_set(bt->statusbar_widget, false);
|
||||
|
||||
return bt;
|
||||
}
|
||||
|
||||
void bt_draw_statusbar_callback(CanvasApi* canvas, void* context) {
|
||||
assert(context);
|
||||
Bt* bt = context;
|
||||
canvas->draw_icon(canvas, 0, 0, bt->statusbar_icon);
|
||||
}
|
||||
|
||||
void bt_cli_info(string_t args, void* context) {
|
||||
string_t buffer;
|
||||
string_init(buffer);
|
||||
api_hal_bt_dump_state(buffer);
|
||||
cli_print(string_get_cstr(buffer));
|
||||
string_clear(buffer);
|
||||
}
|
||||
|
||||
void bt_task() {
|
||||
Bt* bt = bt_alloc();
|
||||
|
||||
if(bt->cli) {
|
||||
cli_add_command(bt->cli, "bt_info", bt_cli_info, bt);
|
||||
}
|
||||
|
||||
// TODO: add ValueMutex(bt) to "bt" record
|
||||
if(!furi_create("bt", bt)) {
|
||||
printf("[bt_task] unable to create bt record\n");
|
||||
furiac_exit(NULL);
|
||||
}
|
||||
|
||||
FuriRecordSubscriber* gui_record = furi_open_deprecated("gui", false, false, NULL, NULL, NULL);
|
||||
furi_assert(gui_record);
|
||||
GuiApi* gui = furi_take(gui_record);
|
||||
furi_assert(gui);
|
||||
gui->add_widget(gui, bt->statusbar_widget, GuiLayerStatusBarLeft);
|
||||
furi_commit(gui_record);
|
||||
|
||||
furiac_ready();
|
||||
|
||||
api_hal_bt_init();
|
||||
|
||||
while(1) {
|
||||
widget_enabled_set(bt->statusbar_widget, api_hal_bt_is_alive());
|
||||
osDelay(1000);
|
||||
}
|
||||
}
|
1
applications/bt/bt.h
Normal file
1
applications/bt/bt.h
Normal file
@@ -0,0 +1 @@
|
||||
#pragma once
|
19
applications/bt/bt_i.h
Normal file
19
applications/bt/bt_i.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "bt.h"
|
||||
|
||||
#include <cli/cli.h>
|
||||
#include <flipper.h>
|
||||
#include <flipper_v2.h>
|
||||
#include <gui/gui.h>
|
||||
#include <gui/widget.h>
|
||||
|
||||
typedef struct {
|
||||
Cli* cli;
|
||||
Icon* statusbar_icon;
|
||||
Widget* statusbar_widget;
|
||||
} Bt;
|
||||
|
||||
Bt* bt_alloc();
|
||||
|
||||
void bt_draw_statusbar_callback(CanvasApi* canvas, void* context);
|
Reference in New Issue
Block a user