[FL-2119] BT HID App (#888)
* view_dispatcher: add default back processing for Long events * assets: add ble connected and disconnected assets * bt keyboard: introduce new application * bt keyboard: add logic to keyboard mode * bt: remove debug ble hid application * bt hid: introduce media controller * gui canvas: rename CanvasFontDirection -> CanvasDirection * gui canvas: add arrow element * assets: update finilized assets * bt hid: finalise keynote GUI * bt hid: finalise media player GUI * bt: add media key buttons support * bt: add exit confirm view * bt: change Clicker -> Remote * bt: support f6 target * bt: hopefully final bt hid design * bt hid: add blue led notification when device is connected * bt: leave only bt clicker for now * bt: add display notification on pin code show event
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
#include "battery_service.h"
|
||||
#include "bt_keys_storage.h"
|
||||
|
||||
#include <applications/notification/notification-messages.h>
|
||||
|
||||
#define TAG "BtSrv"
|
||||
|
||||
#define BT_RPC_EVENT_BUFF_SENT (1UL << 0)
|
||||
@@ -29,6 +31,7 @@ static ViewPort* bt_statusbar_view_port_alloc(Bt* bt) {
|
||||
|
||||
static void bt_pin_code_show_event_handler(Bt* bt, uint32_t pin) {
|
||||
furi_assert(bt);
|
||||
notification_message(bt->notification, &sequence_display_on);
|
||||
string_t pin_str;
|
||||
dialog_message_set_icon(bt->dialog_message, &I_BLE_Pairing_128x64, 0, 0);
|
||||
string_init_printf(pin_str, "Pairing code\n%06d", pin);
|
||||
@@ -41,6 +44,7 @@ static void bt_pin_code_show_event_handler(Bt* bt, uint32_t pin) {
|
||||
|
||||
static bool bt_pin_code_verify_event_handler(Bt* bt, uint32_t pin) {
|
||||
furi_assert(bt);
|
||||
notification_message(bt->notification, &sequence_display_on);
|
||||
string_t pin_str;
|
||||
dialog_message_set_icon(bt->dialog_message, &I_BLE_Pairing_128x64, 0, 0);
|
||||
string_init_printf(pin_str, "Verify code\n%06d", pin);
|
||||
@@ -80,6 +84,8 @@ Bt* bt_alloc() {
|
||||
|
||||
// Setup statusbar view port
|
||||
bt->statusbar_view_port = bt_statusbar_view_port_alloc(bt);
|
||||
// Notification
|
||||
bt->notification = furi_record_open("notification");
|
||||
// Gui
|
||||
bt->gui = furi_record_open("gui");
|
||||
gui_add_view_port(bt->gui, bt->statusbar_view_port, GuiLayerStatusBarLeft);
|
||||
@@ -288,6 +294,9 @@ int32_t bt_srv() {
|
||||
if(message.type == BtMessageTypeUpdateStatusbar) {
|
||||
// Update statusbar
|
||||
bt_statusbar_update(bt);
|
||||
if(bt->status_changed_cb) {
|
||||
bt->status_changed_cb(bt->status, bt->status_changed_ctx);
|
||||
}
|
||||
} else if(message.type == BtMessageTypeUpdateBatteryLevel) {
|
||||
// Update battery level
|
||||
furi_hal_bt_update_battery_level(message.data.battery_level);
|
||||
|
@@ -9,13 +9,20 @@ extern "C" {
|
||||
|
||||
typedef struct Bt Bt;
|
||||
|
||||
typedef enum {
|
||||
BtStatusOff,
|
||||
BtStatusAdvertising,
|
||||
BtStatusConnected,
|
||||
} BtStatus;
|
||||
|
||||
typedef enum {
|
||||
BtProfileSerial,
|
||||
BtProfileHidKeyboard,
|
||||
} BtProfile;
|
||||
|
||||
/**
|
||||
* Change BLE Profile
|
||||
typedef void (*BtStatusChangedCallback)(BtStatus status, void* context);
|
||||
|
||||
/** Change BLE Profile
|
||||
* @note Call of this function leads to 2nd core restart
|
||||
*
|
||||
* @param bt Bt instance
|
||||
@@ -25,6 +32,14 @@ typedef enum {
|
||||
*/
|
||||
bool bt_set_profile(Bt* bt, BtProfile profile);
|
||||
|
||||
/** Set callback for Bluetooth status change notification
|
||||
*
|
||||
* @param bt Bt instance
|
||||
* @param callback BtStatusChangedCallback instance
|
||||
* @param context pointer to context
|
||||
*/
|
||||
void bt_set_status_changed_callback(Bt* bt, BtStatusChangedCallback callback, void* context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -13,3 +13,10 @@ bool bt_set_profile(Bt* bt, BtProfile profile) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@@ -12,17 +12,12 @@
|
||||
#include <dialogs/dialogs.h>
|
||||
#include <power/power_service/power.h>
|
||||
#include <applications/rpc/rpc.h>
|
||||
#include <applications/notification/notification.h>
|
||||
|
||||
#include "../bt_settings.h"
|
||||
|
||||
#define BT_API_UNLOCK_EVENT (1UL << 0)
|
||||
|
||||
typedef enum {
|
||||
BtStatusOff,
|
||||
BtStatusAdvertising,
|
||||
BtStatusConnected,
|
||||
} BtStatus;
|
||||
|
||||
typedef enum {
|
||||
BtMessageTypeUpdateStatusbar,
|
||||
BtMessageTypeUpdateBatteryLevel,
|
||||
@@ -51,6 +46,7 @@ struct Bt {
|
||||
BtStatus status;
|
||||
BtProfile profile;
|
||||
osMessageQueueId_t message_queue;
|
||||
NotificationApp* notification;
|
||||
Gui* gui;
|
||||
ViewPort* statusbar_view_port;
|
||||
DialogsApp* dialogs;
|
||||
@@ -60,4 +56,6 @@ struct Bt {
|
||||
RpcSession* rpc_session;
|
||||
osEventFlagsId_t rpc_event;
|
||||
osEventFlagsId_t api_event;
|
||||
BtStatusChangedCallback status_changed_cb;
|
||||
void* status_changed_ctx;
|
||||
};
|
||||
|
Reference in New Issue
Block a user