2020-12-10 17:25:20 +03:00
|
|
|
#pragma once
|
2021-03-11 12:31:07 +03:00
|
|
|
|
2021-09-10 00:11:32 +03:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
2024-02-16 10:20:45 +03:00
|
|
|
#include <furi_ble/profile_interface.h>
|
|
|
|
#include <core/common_defines.h>
|
2021-09-10 00:11:32 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-07-26 15:21:51 +03:00
|
|
|
#define RECORD_BT "bt"
|
|
|
|
|
2021-03-11 12:31:07 +03:00
|
|
|
typedef struct Bt Bt;
|
2021-09-10 00:11:32 +03:00
|
|
|
|
2021-12-15 20:39:06 +03:00
|
|
|
typedef enum {
|
2022-01-03 01:36:42 +03:00
|
|
|
BtStatusUnavailable,
|
2021-12-15 20:39:06 +03:00
|
|
|
BtStatusOff,
|
|
|
|
BtStatusAdvertising,
|
|
|
|
BtStatusConnected,
|
|
|
|
} BtStatus;
|
|
|
|
|
2024-02-19 03:52:35 +03:00
|
|
|
typedef struct {
|
|
|
|
uint8_t rssi;
|
|
|
|
uint32_t since;
|
|
|
|
} BtRssi;
|
|
|
|
|
2021-12-15 20:39:06 +03:00
|
|
|
typedef void (*BtStatusChangedCallback)(BtStatus status, void* context);
|
|
|
|
|
|
|
|
/** Change BLE Profile
|
2024-02-16 10:20:45 +03:00
|
|
|
* @note Call of this function leads to 2nd core restart
|
|
|
|
*
|
|
|
|
* @param bt Bt instance
|
|
|
|
* @param profile_template Profile template to change to
|
|
|
|
* @param params Profile parameters. Can be NULL
|
|
|
|
*
|
|
|
|
* @return true on success
|
|
|
|
*/
|
|
|
|
FURI_WARN_UNUSED FuriHalBleProfileBase* bt_profile_start(
|
|
|
|
Bt* bt,
|
|
|
|
const FuriHalBleProfileTemplate* profile_template,
|
|
|
|
FuriHalBleProfileParams params);
|
|
|
|
|
|
|
|
/** Stop current BLE Profile and restore default profile
|
2021-12-08 14:28:01 +03:00
|
|
|
* @note Call of this function leads to 2nd core restart
|
|
|
|
*
|
|
|
|
* @param bt Bt instance
|
|
|
|
*
|
|
|
|
* @return true on success
|
|
|
|
*/
|
2024-02-16 10:20:45 +03:00
|
|
|
bool bt_profile_restore_default(Bt* bt);
|
2021-12-08 14:28:01 +03:00
|
|
|
|
2022-06-09 12:07:42 +03:00
|
|
|
/** Disconnect from Central
|
|
|
|
*
|
|
|
|
* @param bt Bt instance
|
|
|
|
*/
|
|
|
|
void bt_disconnect(Bt* bt);
|
|
|
|
|
2021-12-15 20:39:06 +03:00
|
|
|
/** 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);
|
|
|
|
|
2022-01-21 20:32:03 +03:00
|
|
|
/** Forget bonded devices
|
|
|
|
* @note Leads to wipe ble key storage and deleting bt.keys
|
|
|
|
*
|
|
|
|
* @param bt Bt instance
|
|
|
|
*/
|
|
|
|
void bt_forget_bonded_devices(Bt* bt);
|
|
|
|
|
2022-12-20 15:32:24 +03:00
|
|
|
/** Set keys storage file path
|
|
|
|
*
|
|
|
|
* @param bt Bt instance
|
|
|
|
* @param keys_storage_path Path to file with saved keys
|
|
|
|
*/
|
|
|
|
void bt_keys_storage_set_storage_path(Bt* bt, const char* keys_storage_path);
|
|
|
|
|
|
|
|
/** Set default keys storage file path
|
|
|
|
*
|
|
|
|
* @param bt Bt instance
|
|
|
|
*/
|
|
|
|
void bt_keys_storage_set_default_path(Bt* bt);
|
|
|
|
|
2023-05-13 00:14:22 +03:00
|
|
|
bool bt_remote_rssi(Bt* bt, uint8_t* rssi);
|
|
|
|
|
2024-02-19 03:52:35 +03:00
|
|
|
/**
|
2023-05-13 00:14:22 +03:00
|
|
|
*
|
2024-02-19 03:52:35 +03:00
|
|
|
* (Probably bad) way of opening the RPC connection, everywhereTM
|
2023-05-13 00:14:22 +03:00
|
|
|
*/
|
|
|
|
|
2024-02-19 03:52:35 +03:00
|
|
|
void bt_open_rpc_connection(Bt* bt);
|
|
|
|
|
|
|
|
/**
|
2023-05-13 00:14:22 +03:00
|
|
|
*
|
2024-02-19 03:52:35 +03:00
|
|
|
* Closing the RPC connection, everywhereTM
|
2023-05-13 00:14:22 +03:00
|
|
|
*/
|
2024-02-19 03:52:35 +03:00
|
|
|
void bt_close_rpc_connection(Bt* bt);
|
2023-05-13 00:14:22 +03:00
|
|
|
|
2021-09-10 00:11:32 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|