2021-09-02 02:22:40 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "bt.h"
|
|
|
|
|
|
|
|
#include <furi.h>
|
2022-01-05 19:10:18 +03:00
|
|
|
#include <furi_hal.h>
|
2023-09-25 08:12:12 +03:00
|
|
|
#include <api_lock.h>
|
2021-09-02 02:22:40 +03:00
|
|
|
|
|
|
|
#include <gui/gui.h>
|
|
|
|
#include <gui/view_port.h>
|
|
|
|
#include <gui/view.h>
|
|
|
|
|
2021-09-24 19:28:02 +03:00
|
|
|
#include <dialogs/dialogs.h>
|
|
|
|
#include <power/power_service/power.h>
|
2022-09-14 19:11:38 +03:00
|
|
|
#include <rpc/rpc.h>
|
|
|
|
#include <notification/notification.h>
|
2022-12-20 15:32:24 +03:00
|
|
|
#include <storage/storage.h>
|
2021-09-13 14:25:37 +03:00
|
|
|
|
2022-09-14 19:11:38 +03:00
|
|
|
#include <bt/bt_settings.h>
|
2022-12-20 15:32:24 +03:00
|
|
|
#include <bt/bt_service/bt_keys_storage.h>
|
|
|
|
|
|
|
|
#include "bt_keys_filename.h"
|
|
|
|
|
|
|
|
#define BT_KEYS_STORAGE_PATH INT_PATH(BT_KEYS_STORAGE_FILE_NAME)
|
2021-09-02 02:22:40 +03:00
|
|
|
|
|
|
|
typedef enum {
|
2022-01-21 20:32:03 +03:00
|
|
|
BtMessageTypeUpdateStatus,
|
2021-09-10 00:11:32 +03:00
|
|
|
BtMessageTypeUpdateBatteryLevel,
|
2022-05-24 16:42:02 +03:00
|
|
|
BtMessageTypeUpdatePowerState,
|
2021-09-13 14:25:37 +03:00
|
|
|
BtMessageTypePinCodeShow,
|
2021-11-04 20:26:41 +03:00
|
|
|
BtMessageTypeKeysStorageUpdated,
|
2021-12-08 14:28:01 +03:00
|
|
|
BtMessageTypeSetProfile,
|
2022-06-09 12:07:42 +03:00
|
|
|
BtMessageTypeDisconnect,
|
2022-01-21 20:32:03 +03:00
|
|
|
BtMessageTypeForgetBondedDevices,
|
2021-09-02 02:22:40 +03:00
|
|
|
} BtMessageType;
|
|
|
|
|
2022-12-20 15:32:24 +03:00
|
|
|
typedef struct {
|
|
|
|
uint8_t* start_address;
|
|
|
|
uint16_t size;
|
|
|
|
} BtKeyStorageUpdateData;
|
|
|
|
|
2021-09-10 00:11:32 +03:00
|
|
|
typedef union {
|
2021-09-13 14:25:37 +03:00
|
|
|
uint32_t pin_code;
|
2021-09-10 00:11:32 +03:00
|
|
|
uint8_t battery_level;
|
2021-12-08 14:28:01 +03:00
|
|
|
BtProfile profile;
|
2022-12-20 15:32:24 +03:00
|
|
|
BtKeyStorageUpdateData key_storage_data;
|
2021-09-10 00:11:32 +03:00
|
|
|
} BtMessageData;
|
|
|
|
|
2021-09-02 02:22:40 +03:00
|
|
|
typedef struct {
|
2023-09-25 08:12:12 +03:00
|
|
|
FuriApiLock lock;
|
2021-09-02 02:22:40 +03:00
|
|
|
BtMessageType type;
|
2021-09-10 00:11:32 +03:00
|
|
|
BtMessageData data;
|
2021-12-08 14:28:01 +03:00
|
|
|
bool* result;
|
2021-09-02 02:22:40 +03:00
|
|
|
} BtMessage;
|
|
|
|
|
|
|
|
struct Bt {
|
2021-11-04 20:26:41 +03:00
|
|
|
uint8_t* bt_keys_addr_start;
|
|
|
|
uint16_t bt_keys_size;
|
2021-11-21 17:47:54 +03:00
|
|
|
uint16_t max_packet_size;
|
2021-09-02 02:22:40 +03:00
|
|
|
BtSettings bt_settings;
|
2022-12-20 15:32:24 +03:00
|
|
|
BtKeysStorage* keys_storage;
|
2021-10-21 19:27:58 +03:00
|
|
|
BtStatus status;
|
2021-12-08 14:28:01 +03:00
|
|
|
BtProfile profile;
|
2022-07-20 13:56:33 +03:00
|
|
|
FuriMessageQueue* message_queue;
|
2021-12-15 20:39:06 +03:00
|
|
|
NotificationApp* notification;
|
2021-09-02 02:22:40 +03:00
|
|
|
Gui* gui;
|
|
|
|
ViewPort* statusbar_view_port;
|
2022-01-21 20:32:03 +03:00
|
|
|
ViewPort* pin_code_view_port;
|
|
|
|
uint32_t pin_code;
|
2021-09-13 14:25:37 +03:00
|
|
|
DialogsApp* dialogs;
|
|
|
|
DialogMessage* dialog_message;
|
2021-09-24 19:28:02 +03:00
|
|
|
Power* power;
|
2021-10-12 19:41:42 +03:00
|
|
|
Rpc* rpc;
|
|
|
|
RpcSession* rpc_session;
|
2022-07-20 13:56:33 +03:00
|
|
|
FuriEventFlag* rpc_event;
|
|
|
|
FuriEventFlag* api_event;
|
2021-12-15 20:39:06 +03:00
|
|
|
BtStatusChangedCallback status_changed_cb;
|
|
|
|
void* status_changed_ctx;
|
2021-09-02 02:22:40 +03:00
|
|
|
};
|