mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-25 22:32:29 +03:00
Merge fixes
+ thanks @Willy-JL !
This commit is contained in:
parent
9fcf3795ee
commit
66c60e65aa
@ -77,6 +77,8 @@ static void bt_pin_code_show(Bt* bt, uint32_t pin_code) {
|
|||||||
gui_add_view_port(bt->gui, bt->pin_code_view_port, GuiLayerFullscreen);
|
gui_add_view_port(bt->gui, bt->pin_code_view_port, GuiLayerFullscreen);
|
||||||
}
|
}
|
||||||
notification_message(bt->notification, &sequence_display_backlight_on);
|
notification_message(bt->notification, &sequence_display_backlight_on);
|
||||||
|
if(bt->suppress_pin_screen) return;
|
||||||
|
|
||||||
gui_view_port_send_to_front(bt->gui, bt->pin_code_view_port);
|
gui_view_port_send_to_front(bt->gui, bt->pin_code_view_port);
|
||||||
view_port_enabled_set(bt->pin_code_view_port, true);
|
view_port_enabled_set(bt->pin_code_view_port, true);
|
||||||
}
|
}
|
||||||
@ -91,8 +93,9 @@ static void bt_pin_code_hide(Bt* bt) {
|
|||||||
static bool bt_pin_code_verify_event_handler(Bt* bt, uint32_t pin) {
|
static bool bt_pin_code_verify_event_handler(Bt* bt, uint32_t pin) {
|
||||||
furi_assert(bt);
|
furi_assert(bt);
|
||||||
bt->pin_code = pin;
|
bt->pin_code = pin;
|
||||||
if(bt->suppress_pin_screen) return true;
|
|
||||||
notification_message(bt->notification, &sequence_display_backlight_on);
|
notification_message(bt->notification, &sequence_display_backlight_on);
|
||||||
|
if(bt->suppress_pin_screen) return true;
|
||||||
|
|
||||||
FuriString* pin_str;
|
FuriString* pin_str;
|
||||||
if(!bt->dialog_message) {
|
if(!bt->dialog_message) {
|
||||||
bt->dialog_message = dialog_message_alloc();
|
bt->dialog_message = dialog_message_alloc();
|
||||||
@ -141,9 +144,7 @@ Bt* bt_alloc() {
|
|||||||
bt->max_packet_size = BLE_PROFILE_SERIAL_PACKET_SIZE_MAX;
|
bt->max_packet_size = BLE_PROFILE_SERIAL_PACKET_SIZE_MAX;
|
||||||
bt->current_profile = NULL;
|
bt->current_profile = NULL;
|
||||||
// Load settings
|
// Load settings
|
||||||
if(!bt_settings_load(&bt->bt_settings)) {
|
bt_settings_load(&bt->bt_settings);
|
||||||
bt_settings_save(&bt->bt_settings);
|
|
||||||
}
|
|
||||||
// Keys storage
|
// Keys storage
|
||||||
bt->keys_storage = bt_keys_storage_alloc(BT_KEYS_STORAGE_PATH);
|
bt->keys_storage = bt_keys_storage_alloc(BT_KEYS_STORAGE_PATH);
|
||||||
// Alloc queue
|
// Alloc queue
|
||||||
@ -250,6 +251,7 @@ static bool bt_on_gap_event_callback(GapEvent event, void* context) {
|
|||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
Bt* bt = context;
|
Bt* bt = context;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
bt->pin = 0;
|
||||||
bool do_update_status = false;
|
bool do_update_status = false;
|
||||||
bool current_profile_is_serial =
|
bool current_profile_is_serial =
|
||||||
furi_hal_bt_check_profile_type(bt->current_profile, ble_profile_serial);
|
furi_hal_bt_check_profile_type(bt->current_profile, ble_profile_serial);
|
||||||
@ -258,26 +260,7 @@ static bool bt_on_gap_event_callback(GapEvent event, void* context) {
|
|||||||
// Update status bar
|
// Update status bar
|
||||||
bt->status = BtStatusConnected;
|
bt->status = BtStatusConnected;
|
||||||
do_update_status = true;
|
do_update_status = true;
|
||||||
// Clear BT_RPC_EVENT_DISCONNECTED because it might be set from previous session
|
bt_open_rpc_connection(bt);
|
||||||
furi_event_flag_clear(bt->rpc_event, BT_RPC_EVENT_DISCONNECTED);
|
|
||||||
|
|
||||||
if(current_profile_is_serial) {
|
|
||||||
// Open RPC session
|
|
||||||
bt->rpc_session = rpc_session_open(bt->rpc, RpcOwnerBle);
|
|
||||||
if(bt->rpc_session) {
|
|
||||||
FURI_LOG_I(TAG, "Open RPC connection");
|
|
||||||
rpc_session_set_send_bytes_callback(bt->rpc_session, bt_rpc_send_bytes_callback);
|
|
||||||
rpc_session_set_buffer_is_empty_callback(
|
|
||||||
bt->rpc_session, bt_serial_buffer_is_empty_callback);
|
|
||||||
rpc_session_set_context(bt->rpc_session, bt);
|
|
||||||
ble_profile_serial_set_event_callback(
|
|
||||||
bt->current_profile, RPC_BUFFER_SIZE, bt_serial_event_callback, bt);
|
|
||||||
ble_profile_serial_set_rpc_active(
|
|
||||||
bt->current_profile, FuriHalBtSerialRpcStatusActive);
|
|
||||||
} else {
|
|
||||||
FURI_LOG_W(TAG, "RPC is busy, failed to open new session");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Update battery level
|
// Update battery level
|
||||||
PowerInfo info;
|
PowerInfo info;
|
||||||
power_get_info(bt->power, &info);
|
power_get_info(bt->power, &info);
|
||||||
@ -376,7 +359,31 @@ static void bt_show_warning(Bt* bt, const char* text) {
|
|||||||
dialog_message_show(bt->dialogs, bt->dialog_message);
|
dialog_message_show(bt->dialogs, bt->dialog_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bt_close_rpc_connection(Bt* bt) {
|
void bt_open_rpc_connection(Bt* bt) {
|
||||||
|
if(!bt->rpc_session && bt->status == BtStatusConnected) {
|
||||||
|
// Clear BT_RPC_EVENT_DISCONNECTED because it might be set from previous session
|
||||||
|
furi_event_flag_clear(bt->rpc_event, BT_RPC_EVENT_DISCONNECTED);
|
||||||
|
if(furi_hal_bt_check_profile_type(bt->current_profile, ble_profile_serial)) {
|
||||||
|
// Open RPC session
|
||||||
|
bt->rpc_session = rpc_session_open(bt->rpc, RpcOwnerBle);
|
||||||
|
if(bt->rpc_session) {
|
||||||
|
FURI_LOG_I(TAG, "Open RPC connection");
|
||||||
|
rpc_session_set_send_bytes_callback(bt->rpc_session, bt_rpc_send_bytes_callback);
|
||||||
|
rpc_session_set_buffer_is_empty_callback(
|
||||||
|
bt->rpc_session, bt_serial_buffer_is_empty_callback);
|
||||||
|
rpc_session_set_context(bt->rpc_session, bt);
|
||||||
|
ble_profile_serial_set_event_callback(
|
||||||
|
bt->current_profile, RPC_BUFFER_SIZE, bt_serial_event_callback, bt);
|
||||||
|
ble_profile_serial_set_rpc_active(
|
||||||
|
bt->current_profile, FuriHalBtSerialRpcStatusActive);
|
||||||
|
} else {
|
||||||
|
FURI_LOG_W(TAG, "RPC is busy, failed to open new session");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bt_close_rpc_connection(Bt* bt) {
|
||||||
if(furi_hal_bt_check_profile_type(bt->current_profile, ble_profile_serial) &&
|
if(furi_hal_bt_check_profile_type(bt->current_profile, ble_profile_serial) &&
|
||||||
bt->rpc_session) {
|
bt->rpc_session) {
|
||||||
FURI_LOG_I(TAG, "Close RPC connection");
|
FURI_LOG_I(TAG, "Close RPC connection");
|
||||||
@ -389,7 +396,6 @@ static void bt_close_rpc_connection(Bt* bt) {
|
|||||||
|
|
||||||
static void bt_change_profile(Bt* bt, BtMessage* message) {
|
static void bt_change_profile(Bt* bt, BtMessage* message) {
|
||||||
if(furi_hal_bt_is_gatt_gap_supported()) {
|
if(furi_hal_bt_is_gatt_gap_supported()) {
|
||||||
bt_settings_load(&bt->bt_settings);
|
|
||||||
bt_close_rpc_connection(bt);
|
bt_close_rpc_connection(bt);
|
||||||
|
|
||||||
bt_keys_storage_load(bt->keys_storage);
|
bt_keys_storage_load(bt->keys_storage);
|
||||||
@ -433,52 +439,6 @@ static void bt_close_connection(Bt* bt, BtMessage* message) {
|
|||||||
if(message->lock) api_lock_unlock(message->lock);
|
if(message->lock) api_lock_unlock(message->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline FuriHalBtProfile get_hal_bt_profile(BtProfile profile) {
|
|
||||||
if(profile == BtProfileHidKeyboard) {
|
|
||||||
return FuriHalBtProfileHidKeyboard;
|
|
||||||
} else {
|
|
||||||
return FuriHalBtProfileSerial;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void bt_restart(Bt* bt) {
|
|
||||||
furi_hal_bt_change_app(get_hal_bt_profile(bt->profile), bt_on_gap_event_callback, bt);
|
|
||||||
furi_hal_bt_start_advertising();
|
|
||||||
}
|
|
||||||
|
|
||||||
void bt_set_profile_adv_name(Bt* bt, const char* fmt, ...) {
|
|
||||||
furi_assert(bt);
|
|
||||||
furi_assert(fmt);
|
|
||||||
|
|
||||||
char name[FURI_HAL_BT_ADV_NAME_LENGTH];
|
|
||||||
va_list args;
|
|
||||||
va_start(args, fmt);
|
|
||||||
vsnprintf(name, sizeof(name), fmt, args);
|
|
||||||
va_end(args);
|
|
||||||
furi_hal_bt_set_profile_adv_name(get_hal_bt_profile(bt->profile), name);
|
|
||||||
|
|
||||||
bt_restart(bt);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* bt_get_profile_adv_name(Bt* bt) {
|
|
||||||
furi_assert(bt);
|
|
||||||
return furi_hal_bt_get_profile_adv_name(get_hal_bt_profile(bt->profile));
|
|
||||||
}
|
|
||||||
|
|
||||||
void bt_set_profile_mac_address(Bt* bt, const uint8_t mac[6]) {
|
|
||||||
furi_assert(bt);
|
|
||||||
furi_assert(mac);
|
|
||||||
|
|
||||||
furi_hal_bt_set_profile_mac_addr(get_hal_bt_profile(bt->profile), mac);
|
|
||||||
|
|
||||||
bt_restart(bt);
|
|
||||||
}
|
|
||||||
|
|
||||||
const uint8_t* bt_get_profile_mac_address(Bt* bt) {
|
|
||||||
furi_assert(bt);
|
|
||||||
return furi_hal_bt_get_profile_mac_addr(get_hal_bt_profile(bt->profile));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bt_remote_rssi(Bt* bt, uint8_t* rssi) {
|
bool bt_remote_rssi(Bt* bt, uint8_t* rssi) {
|
||||||
furi_assert(bt);
|
furi_assert(bt);
|
||||||
|
|
||||||
@ -492,27 +452,6 @@ bool bt_remote_rssi(Bt* bt, uint8_t* rssi) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_set_profile_pairing_method(Bt* bt, GapPairing pairing_method) {
|
|
||||||
furi_assert(bt);
|
|
||||||
furi_hal_bt_set_profile_pairing_method(get_hal_bt_profile(bt->profile), pairing_method);
|
|
||||||
bt_restart(bt);
|
|
||||||
}
|
|
||||||
|
|
||||||
GapPairing bt_get_profile_pairing_method(Bt* bt) {
|
|
||||||
furi_assert(bt);
|
|
||||||
return furi_hal_bt_get_profile_pairing_method(get_hal_bt_profile(bt->profile));
|
|
||||||
}
|
|
||||||
|
|
||||||
void bt_disable_peer_key_update(Bt* bt) {
|
|
||||||
UNUSED(bt);
|
|
||||||
furi_hal_bt_set_key_storage_change_callback(NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void bt_enable_peer_key_update(Bt* bt) {
|
|
||||||
furi_assert(bt);
|
|
||||||
furi_hal_bt_set_key_storage_change_callback(bt_on_key_storage_change_callback, bt);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t bt_srv(void* p) {
|
int32_t bt_srv(void* p) {
|
||||||
UNUSED(p);
|
UNUSED(p);
|
||||||
Bt* bt = bt_alloc();
|
Bt* bt = bt_alloc();
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
#include <furi_ble/profile_interface.h>
|
#include <furi_ble/profile_interface.h>
|
||||||
#include <core/common_defines.h>
|
#include <core/common_defines.h>
|
||||||
|
|
||||||
#include <furi_hal_bt.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -22,6 +20,11 @@ typedef enum {
|
|||||||
BtStatusConnected,
|
BtStatusConnected,
|
||||||
} BtStatus;
|
} BtStatus;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t rssi;
|
||||||
|
uint32_t since;
|
||||||
|
} BtRssi;
|
||||||
|
|
||||||
typedef void (*BtStatusChangedCallback)(BtStatus status, void* context);
|
typedef void (*BtStatusChangedCallback)(BtStatus status, void* context);
|
||||||
|
|
||||||
/** Change BLE Profile
|
/** Change BLE Profile
|
||||||
@ -81,31 +84,20 @@ void bt_keys_storage_set_storage_path(Bt* bt, const char* keys_storage_path);
|
|||||||
*/
|
*/
|
||||||
void bt_keys_storage_set_default_path(Bt* bt);
|
void bt_keys_storage_set_default_path(Bt* bt);
|
||||||
|
|
||||||
// New methods
|
|
||||||
|
|
||||||
void bt_set_profile_adv_name(Bt* bt, const char* fmt, ...);
|
|
||||||
|
|
||||||
const char* bt_get_profile_adv_name(Bt* bt);
|
|
||||||
|
|
||||||
void bt_set_profile_mac_address(Bt* bt, const uint8_t mac[6]);
|
|
||||||
|
|
||||||
const uint8_t* bt_get_profile_mac_address(Bt* bt);
|
|
||||||
|
|
||||||
bool bt_remote_rssi(Bt* bt, uint8_t* rssi);
|
bool bt_remote_rssi(Bt* bt, uint8_t* rssi);
|
||||||
|
|
||||||
void bt_set_profile_pairing_method(Bt* bt, GapPairing pairing_method);
|
/**
|
||||||
GapPairing bt_get_profile_pairing_method(Bt* bt);
|
|
||||||
|
|
||||||
/** Stop saving new peer key to flash (in .bt.keys file)
|
|
||||||
*
|
*
|
||||||
|
* (Probably bad) way of opening the RPC connection, everywhereTM
|
||||||
*/
|
*/
|
||||||
void bt_disable_peer_key_update(Bt* bt);
|
|
||||||
|
|
||||||
/** Enable saving peer key to internal flash (enable by default)
|
void bt_open_rpc_connection(Bt* bt);
|
||||||
|
|
||||||
|
/**
|
||||||
*
|
*
|
||||||
* @note This function should be called if bt_disable_peer_key_update was called before
|
* Closing the RPC connection, everywhereTM
|
||||||
*/
|
*/
|
||||||
void bt_enable_peer_key_update(Bt* bt);
|
void bt_close_rpc_connection(Bt* bt);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ int32_t namechanger_on_system_start(void* p) {
|
|||||||
|
|
||||||
furi_delay_ms(3);
|
furi_delay_ms(3);
|
||||||
Bt* bt = furi_record_open(RECORD_BT);
|
Bt* bt = furi_record_open(RECORD_BT);
|
||||||
if(!bt_set_profile(bt, BtProfileSerial)) {
|
if(!bt_profile_restore_default(bt)) {
|
||||||
//FURI_LOG_D(TAG, "Failed to touch bluetooth to name change");
|
//FURI_LOG_D(TAG, "Failed to touch bluetooth to name change");
|
||||||
}
|
}
|
||||||
furi_record_close(RECORD_BT);
|
furi_record_close(RECORD_BT);
|
||||||
|
@ -100,13 +100,6 @@ bool ble_profile_hid_mouse_release_all(FuriHalBleProfileBase* profile);
|
|||||||
*/
|
*/
|
||||||
bool ble_profile_hid_mouse_scroll(FuriHalBleProfileBase* profile, int8_t delta);
|
bool ble_profile_hid_mouse_scroll(FuriHalBleProfileBase* profile, int8_t delta);
|
||||||
|
|
||||||
/** Retrieves LED state from remote BT HID host
|
|
||||||
*
|
|
||||||
* @return (look at HID usage page to know what each bit of the returned byte means)
|
|
||||||
* NB: RFU bit has been shifted out in the returned octet so USB defines should work
|
|
||||||
*/
|
|
||||||
uint8_t furi_hal_bt_hid_get_led_state(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -748,17 +748,15 @@ Function,+,ble_svc_serial_start,BleServiceSerial*,
|
|||||||
Function,+,ble_svc_serial_stop,void,BleServiceSerial*
|
Function,+,ble_svc_serial_stop,void,BleServiceSerial*
|
||||||
Function,+,ble_svc_serial_update_tx,_Bool,"BleServiceSerial*, uint8_t*, uint16_t"
|
Function,+,ble_svc_serial_update_tx,_Bool,"BleServiceSerial*, uint8_t*, uint16_t"
|
||||||
Function,-,bsearch,void*,"const void*, const void*, size_t, size_t, __compar_fn_t"
|
Function,-,bsearch,void*,"const void*, const void*, size_t, size_t, __compar_fn_t"
|
||||||
Function,+,bt_disable_peer_key_update,void,Bt*
|
Function,-,bt_close_rpc_connection,void,Bt*
|
||||||
Function,+,bt_disconnect,void,Bt*
|
Function,+,bt_disconnect,void,Bt*
|
||||||
Function,+,bt_enable_peer_key_update,void,Bt*
|
|
||||||
Function,+,bt_forget_bonded_devices,void,Bt*
|
Function,+,bt_forget_bonded_devices,void,Bt*
|
||||||
Function,+,bt_get_profile_adv_name,const char*,Bt*
|
|
||||||
Function,+,bt_get_profile_mac_address,const uint8_t*,Bt*
|
|
||||||
Function,+,bt_get_profile_pairing_method,GapPairing,Bt*
|
|
||||||
Function,+,bt_keys_storage_set_default_path,void,Bt*
|
Function,+,bt_keys_storage_set_default_path,void,Bt*
|
||||||
Function,+,bt_keys_storage_set_storage_path,void,"Bt*, const char*"
|
Function,+,bt_keys_storage_set_storage_path,void,"Bt*, const char*"
|
||||||
|
Function,-,bt_open_rpc_connection,void,Bt*
|
||||||
Function,+,bt_profile_restore_default,_Bool,Bt*
|
Function,+,bt_profile_restore_default,_Bool,Bt*
|
||||||
Function,+,bt_profile_start,FuriHalBleProfileBase*,"Bt*, const FuriHalBleProfileTemplate*, FuriHalBleProfileParams"
|
Function,+,bt_profile_start,FuriHalBleProfileBase*,"Bt*, const FuriHalBleProfileTemplate*, FuriHalBleProfileParams"
|
||||||
|
Function,+,bt_remote_rssi,_Bool,"Bt*, uint8_t*"
|
||||||
Function,+,bt_set_status_changed_callback,void,"Bt*, BtStatusChangedCallback, void*"
|
Function,+,bt_set_status_changed_callback,void,"Bt*, BtStatusChangedCallback, void*"
|
||||||
Function,+,buffered_file_stream_alloc,Stream*,Storage*
|
Function,+,buffered_file_stream_alloc,Stream*,Storage*
|
||||||
Function,+,buffered_file_stream_close,_Bool,Stream*
|
Function,+,buffered_file_stream_close,_Bool,Stream*
|
||||||
@ -1190,9 +1188,6 @@ Function,+,furi_get_tick,uint32_t,
|
|||||||
Function,+,furi_hal_bt_change_app,FuriHalBleProfileBase*,"const FuriHalBleProfileTemplate*, FuriHalBleProfileParams, GapEventCallback, void*"
|
Function,+,furi_hal_bt_change_app,FuriHalBleProfileBase*,"const FuriHalBleProfileTemplate*, FuriHalBleProfileParams, GapEventCallback, void*"
|
||||||
Function,+,furi_hal_bt_check_profile_type,_Bool,"FuriHalBleProfileBase*, const FuriHalBleProfileTemplate*"
|
Function,+,furi_hal_bt_check_profile_type,_Bool,"FuriHalBleProfileBase*, const FuriHalBleProfileTemplate*"
|
||||||
Function,+,furi_hal_bt_clear_white_list,_Bool,
|
Function,+,furi_hal_bt_clear_white_list,_Bool,
|
||||||
Function,+,furi_hal_bt_custom_adv_set,_Bool,"const uint8_t*, size_t"
|
|
||||||
Function,+,furi_hal_bt_custom_adv_start,_Bool,"uint16_t, uint16_t, uint8_t, const uint8_t[( 6 )], uint8_t"
|
|
||||||
Function,+,furi_hal_bt_custom_adv_stop,_Bool,
|
|
||||||
Function,+,furi_hal_bt_dump_state,void,FuriString*
|
Function,+,furi_hal_bt_dump_state,void,FuriString*
|
||||||
Function,+,furi_hal_bt_ensure_c2_mode,_Bool,BleGlueC2Mode
|
Function,+,furi_hal_bt_ensure_c2_mode,_Bool,BleGlueC2Mode
|
||||||
Function,+,furi_hal_bt_extra_beacon_get_config,const GapExtraBeaconConfig*,
|
Function,+,furi_hal_bt_extra_beacon_get_config,const GapExtraBeaconConfig*,
|
||||||
@ -1202,17 +1197,15 @@ Function,+,furi_hal_bt_extra_beacon_set_config,_Bool,const GapExtraBeaconConfig*
|
|||||||
Function,+,furi_hal_bt_extra_beacon_set_data,_Bool,"const uint8_t*, uint8_t"
|
Function,+,furi_hal_bt_extra_beacon_set_data,_Bool,"const uint8_t*, uint8_t"
|
||||||
Function,+,furi_hal_bt_extra_beacon_start,_Bool,
|
Function,+,furi_hal_bt_extra_beacon_start,_Bool,
|
||||||
Function,+,furi_hal_bt_extra_beacon_stop,_Bool,
|
Function,+,furi_hal_bt_extra_beacon_stop,_Bool,
|
||||||
|
Function,-,furi_hal_bt_get_conn_rssi,uint32_t,uint8_t*
|
||||||
Function,+,furi_hal_bt_get_key_storage_buff,void,"uint8_t**, uint16_t*"
|
Function,+,furi_hal_bt_get_key_storage_buff,void,"uint8_t**, uint16_t*"
|
||||||
Function,+,furi_hal_bt_get_profile_adv_name,const char*,FuriHalBtProfile
|
|
||||||
Function,+,furi_hal_bt_get_profile_mac_addr,const uint8_t*,FuriHalBtProfile
|
|
||||||
Function,-,furi_hal_bt_get_profile_pairing_method,GapPairing,FuriHalBtProfile
|
|
||||||
Function,+,furi_hal_bt_get_radio_stack,FuriHalBtStack,
|
Function,+,furi_hal_bt_get_radio_stack,FuriHalBtStack,
|
||||||
Function,+,furi_hal_bt_get_rssi,float,
|
Function,+,furi_hal_bt_get_rssi,float,
|
||||||
Function,+,furi_hal_bt_get_transmitted_packets,uint32_t,
|
Function,+,furi_hal_bt_get_transmitted_packets,uint32_t,
|
||||||
Function,+,furi_hal_bt_hid_consumer_key_press,_Bool,uint16_t
|
|
||||||
Function,-,furi_hal_bt_init,void,
|
Function,-,furi_hal_bt_init,void,
|
||||||
Function,+,furi_hal_bt_is_active,_Bool,
|
Function,+,furi_hal_bt_is_active,_Bool,
|
||||||
Function,+,furi_hal_bt_is_alive,_Bool,
|
Function,+,furi_hal_bt_is_alive,_Bool,
|
||||||
|
Function,+,furi_hal_bt_is_connected,_Bool,
|
||||||
Function,+,furi_hal_bt_is_gatt_gap_supported,_Bool,
|
Function,+,furi_hal_bt_is_gatt_gap_supported,_Bool,
|
||||||
Function,+,furi_hal_bt_is_testing_supported,_Bool,
|
Function,+,furi_hal_bt_is_testing_supported,_Bool,
|
||||||
Function,+,furi_hal_bt_lock_core2,void,
|
Function,+,furi_hal_bt_lock_core2,void,
|
||||||
@ -1221,9 +1214,6 @@ Function,+,furi_hal_bt_nvm_sram_sem_release,void,
|
|||||||
Function,+,furi_hal_bt_reinit,void,
|
Function,+,furi_hal_bt_reinit,void,
|
||||||
Function,+,furi_hal_bt_reverse_mac_addr,void,uint8_t[( 6 )]
|
Function,+,furi_hal_bt_reverse_mac_addr,void,uint8_t[( 6 )]
|
||||||
Function,+,furi_hal_bt_set_key_storage_change_callback,void,"BleGlueKeyStorageChangedCallback, void*"
|
Function,+,furi_hal_bt_set_key_storage_change_callback,void,"BleGlueKeyStorageChangedCallback, void*"
|
||||||
Function,+,furi_hal_bt_set_profile_adv_name,void,"FuriHalBtProfile, const char[( ( 1 + 8 + ( 8 + 1 ) ) + 1 )]"
|
|
||||||
Function,+,furi_hal_bt_set_profile_mac_addr,void,"FuriHalBtProfile, const uint8_t[( 6 )]"
|
|
||||||
Function,+,furi_hal_bt_set_profile_pairing_method,void,"FuriHalBtProfile, GapPairing"
|
|
||||||
Function,+,furi_hal_bt_start_advertising,void,
|
Function,+,furi_hal_bt_start_advertising,void,
|
||||||
Function,+,furi_hal_bt_start_app,FuriHalBleProfileBase*,"const FuriHalBleProfileTemplate*, FuriHalBleProfileParams, GapEventCallback, void*"
|
Function,+,furi_hal_bt_start_app,FuriHalBleProfileBase*,"const FuriHalBleProfileTemplate*, FuriHalBleProfileParams, GapEventCallback, void*"
|
||||||
Function,+,furi_hal_bt_start_packet_rx,void,"uint8_t, uint8_t"
|
Function,+,furi_hal_bt_start_packet_rx,void,"uint8_t, uint8_t"
|
||||||
@ -1851,6 +1841,7 @@ Function,-,gap_extra_beacon_set_config,_Bool,const GapExtraBeaconConfig*
|
|||||||
Function,-,gap_extra_beacon_set_data,_Bool,"const uint8_t*, uint8_t"
|
Function,-,gap_extra_beacon_set_data,_Bool,"const uint8_t*, uint8_t"
|
||||||
Function,-,gap_extra_beacon_start,_Bool,
|
Function,-,gap_extra_beacon_start,_Bool,
|
||||||
Function,-,gap_extra_beacon_stop,_Bool,
|
Function,-,gap_extra_beacon_stop,_Bool,
|
||||||
|
Function,-,gap_get_remote_conn_rssi,uint32_t,int8_t*
|
||||||
Function,-,gap_get_state,GapState,
|
Function,-,gap_get_state,GapState,
|
||||||
Function,-,gap_init,_Bool,"GapConfig*, GapEventCallback, void*"
|
Function,-,gap_init,_Bool,"GapConfig*, GapEventCallback, void*"
|
||||||
Function,-,gap_start_advertising,void,
|
Function,-,gap_start_advertising,void,
|
||||||
|
|
@ -63,7 +63,7 @@ void ble_gatt_characteristic_init(
|
|||||||
char_data_descriptor->security_permissions,
|
char_data_descriptor->security_permissions,
|
||||||
char_data_descriptor->access_permissions,
|
char_data_descriptor->access_permissions,
|
||||||
char_data_descriptor->gatt_evt_mask,
|
char_data_descriptor->gatt_evt_mask,
|
||||||
MIN_ENCRY_KEY_SIZE,
|
GATT_MIN_READ_KEY_SIZE,
|
||||||
char_data_descriptor->is_variable,
|
char_data_descriptor->is_variable,
|
||||||
&char_instance->descriptor_handle);
|
&char_instance->descriptor_handle);
|
||||||
if(status) {
|
if(status) {
|
||||||
|
@ -372,35 +372,33 @@ static void gap_init_svc(Gap* gap) {
|
|||||||
// Set default PHY
|
// Set default PHY
|
||||||
hci_le_set_default_phy(ALL_PHYS_PREFERENCE, TX_2M_PREFERRED, RX_2M_PREFERRED);
|
hci_le_set_default_phy(ALL_PHYS_PREFERENCE, TX_2M_PREFERRED, RX_2M_PREFERRED);
|
||||||
// Set I/O capability
|
// Set I/O capability
|
||||||
|
bool bonding_mode = gap->config->bonding_mode;
|
||||||
|
uint8_t cfg_mitm_protection = CFG_MITM_PROTECTION;
|
||||||
|
uint8_t cfg_used_fixed_pin = CFG_USED_FIXED_PIN;
|
||||||
bool keypress_supported = false;
|
bool keypress_supported = false;
|
||||||
// New things below
|
|
||||||
uint8_t conf_mitm = CFG_MITM_PROTECTION;
|
|
||||||
uint8_t conf_used_fixed_pin = CFG_USED_FIXED_PIN;
|
|
||||||
bool conf_bonding = gap->config->bonding_mode;
|
|
||||||
|
|
||||||
if(gap->config->pairing_method == GapPairingPinCodeShow) {
|
if(gap->config->pairing_method == GapPairingPinCodeShow) {
|
||||||
aci_gap_set_io_capability(IO_CAP_DISPLAY_ONLY);
|
aci_gap_set_io_capability(IO_CAP_DISPLAY_ONLY);
|
||||||
} else if(gap->config->pairing_method == GapPairingPinCodeVerifyYesNo) {
|
} else if(gap->config->pairing_method == GapPairingPinCodeVerifyYesNo) {
|
||||||
aci_gap_set_io_capability(IO_CAP_DISPLAY_YES_NO);
|
aci_gap_set_io_capability(IO_CAP_DISPLAY_YES_NO);
|
||||||
keypress_supported = true;
|
keypress_supported = true;
|
||||||
} else if(gap->config->pairing_method == GapPairingNone) {
|
} else if(gap->config->pairing_method == GapPairingNone) {
|
||||||
// Just works pairing method (IOS accept it, it seems android and linux doesn't)
|
// "Just works" pairing method (iOS accepts it, it seems Android and Linux don't)
|
||||||
conf_mitm = 0;
|
bonding_mode = false;
|
||||||
conf_used_fixed_pin = 0;
|
cfg_mitm_protection = MITM_PROTECTION_NOT_REQUIRED;
|
||||||
conf_bonding = false;
|
cfg_used_fixed_pin = USE_FIXED_PIN_FOR_PAIRING_ALLOWED;
|
||||||
// if just works isn't supported, we want the numeric comparaison method
|
// If "just works" isn't supported, we want the numeric comparaison method
|
||||||
aci_gap_set_io_capability(IO_CAP_DISPLAY_YES_NO);
|
aci_gap_set_io_capability(IO_CAP_DISPLAY_YES_NO);
|
||||||
keypress_supported = true;
|
keypress_supported = true;
|
||||||
}
|
}
|
||||||
// Setup authentication
|
// Setup authentication
|
||||||
aci_gap_set_authentication_requirement(
|
aci_gap_set_authentication_requirement(
|
||||||
conf_bonding,
|
bonding_mode,
|
||||||
conf_mitm,
|
cfg_mitm_protection,
|
||||||
CFG_SC_SUPPORT,
|
CFG_SC_SUPPORT,
|
||||||
keypress_supported,
|
keypress_supported,
|
||||||
CFG_ENCRYPTION_KEY_SIZE_MIN,
|
CFG_ENCRYPTION_KEY_SIZE_MIN,
|
||||||
CFG_ENCRYPTION_KEY_SIZE_MAX,
|
CFG_ENCRYPTION_KEY_SIZE_MAX,
|
||||||
conf_used_fixed_pin, // 0x0 for no pin
|
cfg_used_fixed_pin,
|
||||||
0,
|
0,
|
||||||
CFG_IDENTITY_ADDRESS);
|
CFG_IDENTITY_ADDRESS);
|
||||||
// Configure whitelist
|
// Configure whitelist
|
||||||
@ -554,6 +552,17 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get RSSI
|
||||||
|
uint32_t gap_get_remote_conn_rssi(int8_t* rssi) {
|
||||||
|
if(gap && gap->state == GapStateConnected) {
|
||||||
|
fetch_rssi();
|
||||||
|
*rssi = gap->conn_rssi;
|
||||||
|
|
||||||
|
if(gap->time_rssi_sample) return furi_get_tick() - gap->time_rssi_sample;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
GapState gap_get_state(void) {
|
GapState gap_get_state(void) {
|
||||||
GapState state;
|
GapState state;
|
||||||
if(gap) {
|
if(gap) {
|
||||||
|
@ -73,7 +73,7 @@ typedef struct {
|
|||||||
bool bonding_mode;
|
bool bonding_mode;
|
||||||
GapPairing pairing_method;
|
GapPairing pairing_method;
|
||||||
uint8_t mac_address[GAP_MAC_ADDR_SIZE];
|
uint8_t mac_address[GAP_MAC_ADDR_SIZE];
|
||||||
char adv_name[FURI_HAL_BT_ADV_NAME_LENGTH];
|
char adv_name[FURI_HAL_VERSION_DEVICE_NAME_LENGTH];
|
||||||
GapConnectionParamsRequest conn_param;
|
GapConnectionParamsRequest conn_param;
|
||||||
} GapConfig;
|
} GapConfig;
|
||||||
|
|
||||||
|
@ -402,51 +402,6 @@ uint32_t furi_hal_bt_get_conn_rssi(uint8_t* rssi) {
|
|||||||
return since;
|
return since;
|
||||||
}
|
}
|
||||||
|
|
||||||
// API for BLE beacon plugin
|
|
||||||
bool furi_hal_bt_custom_adv_set(const uint8_t* adv_data, size_t adv_len) {
|
|
||||||
tBleStatus status = aci_gap_additional_beacon_set_data(adv_len, adv_data);
|
|
||||||
if(status) {
|
|
||||||
FURI_LOG_E(TAG, "custom_adv_set failed %d", status);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
FURI_LOG_D(TAG, "custom_adv_set success");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool furi_hal_bt_custom_adv_start(
|
|
||||||
uint16_t min_interval,
|
|
||||||
uint16_t max_interval,
|
|
||||||
uint8_t mac_type,
|
|
||||||
const uint8_t mac_addr[GAP_MAC_ADDR_SIZE],
|
|
||||||
uint8_t power_amp_level) {
|
|
||||||
tBleStatus status = aci_gap_additional_beacon_start(
|
|
||||||
min_interval / 0.625, // Millis to gap time
|
|
||||||
max_interval / 0.625, // Millis to gap time
|
|
||||||
0b00000111, // All 3 channels
|
|
||||||
mac_type,
|
|
||||||
mac_addr,
|
|
||||||
power_amp_level);
|
|
||||||
if(status) {
|
|
||||||
FURI_LOG_E(TAG, "custom_adv_start failed %d", status);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
FURI_LOG_D(TAG, "custom_adv_start success");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool furi_hal_bt_custom_adv_stop() {
|
|
||||||
tBleStatus status = aci_gap_additional_beacon_stop();
|
|
||||||
if(status) {
|
|
||||||
FURI_LOG_E(TAG, "custom_adv_stop failed %d", status);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
FURI_LOG_D(TAG, "custom_adv_stop success");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void furi_hal_bt_reverse_mac_addr(uint8_t mac_addr[GAP_MAC_ADDR_SIZE]) {
|
void furi_hal_bt_reverse_mac_addr(uint8_t mac_addr[GAP_MAC_ADDR_SIZE]) {
|
||||||
uint8_t tmp;
|
uint8_t tmp;
|
||||||
for(size_t i = 0; i < GAP_MAC_ADDR_SIZE / 2; i++) {
|
for(size_t i = 0; i < GAP_MAC_ADDR_SIZE / 2; i++) {
|
||||||
@ -456,52 +411,6 @@ void furi_hal_bt_reverse_mac_addr(uint8_t mac_addr[GAP_MAC_ADDR_SIZE]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_bt_set_profile_adv_name(
|
|
||||||
FuriHalBtProfile profile,
|
|
||||||
const char name[FURI_HAL_BT_ADV_NAME_LENGTH]) {
|
|
||||||
furi_assert(profile < FuriHalBtProfileNumber);
|
|
||||||
furi_assert(name);
|
|
||||||
|
|
||||||
if(strlen(name) == 0) {
|
|
||||||
memset(&(profile_config[profile].config.adv_name[1]), 0, FURI_HAL_BT_ADV_NAME_LENGTH - 1);
|
|
||||||
} else {
|
|
||||||
profile_config[profile].config.adv_name[0] = AD_TYPE_COMPLETE_LOCAL_NAME;
|
|
||||||
strlcpy(
|
|
||||||
&(profile_config[profile].config.adv_name[1]),
|
|
||||||
name,
|
|
||||||
FURI_HAL_BT_ADV_NAME_LENGTH - 1 /* BLE symbol */);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* furi_hal_bt_get_profile_adv_name(FuriHalBtProfile profile) {
|
|
||||||
furi_assert(profile < FuriHalBtProfileNumber);
|
|
||||||
return &(profile_config[profile].config.adv_name[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void furi_hal_bt_set_profile_mac_addr(
|
|
||||||
FuriHalBtProfile profile,
|
|
||||||
const uint8_t mac_addr[GAP_MAC_ADDR_SIZE]) {
|
|
||||||
furi_assert(profile < FuriHalBtProfileNumber);
|
|
||||||
furi_assert(mac_addr);
|
|
||||||
|
|
||||||
memcpy(profile_config[profile].config.mac_address, mac_addr, GAP_MAC_ADDR_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
const uint8_t* furi_hal_bt_get_profile_mac_addr(FuriHalBtProfile profile) {
|
|
||||||
furi_assert(profile < FuriHalBtProfileNumber);
|
|
||||||
return profile_config[profile].config.mac_address;
|
|
||||||
}
|
|
||||||
|
|
||||||
void furi_hal_bt_set_profile_pairing_method(FuriHalBtProfile profile, GapPairing pairing_method) {
|
|
||||||
furi_assert(profile < FuriHalBtProfileNumber);
|
|
||||||
profile_config[profile].config.pairing_method = pairing_method;
|
|
||||||
}
|
|
||||||
|
|
||||||
GapPairing furi_hal_bt_get_profile_pairing_method(FuriHalBtProfile profile) {
|
|
||||||
furi_assert(profile < FuriHalBtProfileNumber);
|
|
||||||
return profile_config[profile].config.pairing_method;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t furi_hal_bt_get_transmitted_packets() {
|
uint32_t furi_hal_bt_get_transmitted_packets() {
|
||||||
uint32_t packets = 0;
|
uint32_t packets = 0;
|
||||||
aci_hal_le_tx_test_packet_number(&packets);
|
aci_hal_le_tx_test_packet_number(&packets);
|
||||||
|
@ -91,7 +91,14 @@ typedef struct {
|
|||||||
static FuriHalVersion furi_hal_version = {0};
|
static FuriHalVersion furi_hal_version = {0};
|
||||||
|
|
||||||
void furi_hal_version_set_name(const char* name) {
|
void furi_hal_version_set_name(const char* name) {
|
||||||
|
uint32_t udn = LL_FLASH_GetUDN();
|
||||||
|
if(name == NULL) {
|
||||||
|
name = version_get_custom_name(NULL);
|
||||||
if(name != NULL) {
|
if(name != NULL) {
|
||||||
|
udn = *((uint32_t*)name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(name != NULL && strlen(name)) {
|
||||||
strlcpy(furi_hal_version.name, name, FURI_HAL_VERSION_ARRAY_NAME_LENGTH);
|
strlcpy(furi_hal_version.name, name, FURI_HAL_VERSION_ARRAY_NAME_LENGTH);
|
||||||
snprintf(
|
snprintf(
|
||||||
furi_hal_version.device_name,
|
furi_hal_version.device_name,
|
||||||
@ -105,11 +112,6 @@ void furi_hal_version_set_name(const char* name) {
|
|||||||
furi_hal_version.device_name[0] = AD_TYPE_COMPLETE_LOCAL_NAME;
|
furi_hal_version.device_name[0] = AD_TYPE_COMPLETE_LOCAL_NAME;
|
||||||
|
|
||||||
// BLE Mac address
|
// BLE Mac address
|
||||||
uint32_t udn = LL_FLASH_GetUDN();
|
|
||||||
if(version_get_custom_name(NULL) != NULL) {
|
|
||||||
udn = *((uint32_t*)version_get_custom_name(NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t company_id = LL_FLASH_GetSTCompanyID();
|
uint32_t company_id = LL_FLASH_GetSTCompanyID();
|
||||||
// uint32_t device_id = LL_FLASH_GetDeviceID();
|
// uint32_t device_id = LL_FLASH_GetDeviceID();
|
||||||
// Some flippers return 0x27 (flippers with chip revision 2003 6495) instead of 0x26 (flippers with chip revision 2001 6495)
|
// Some flippers return 0x27 (flippers with chip revision 2003 6495) instead of 0x26 (flippers with chip revision 2001 6495)
|
||||||
@ -137,11 +139,7 @@ static void furi_hal_version_load_otp_v0() {
|
|||||||
furi_hal_version.board_body = otp->board_body;
|
furi_hal_version.board_body = otp->board_body;
|
||||||
furi_hal_version.board_connect = otp->board_connect;
|
furi_hal_version.board_connect = otp->board_connect;
|
||||||
|
|
||||||
if(version_get_custom_name(NULL) != NULL) {
|
|
||||||
furi_hal_version_set_name(version_get_custom_name(NULL));
|
|
||||||
} else {
|
|
||||||
furi_hal_version_set_name(otp->name);
|
furi_hal_version_set_name(otp->name);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void furi_hal_version_load_otp_v1() {
|
static void furi_hal_version_load_otp_v1() {
|
||||||
@ -155,11 +153,7 @@ static void furi_hal_version_load_otp_v1() {
|
|||||||
furi_hal_version.board_color = otp->board_color;
|
furi_hal_version.board_color = otp->board_color;
|
||||||
furi_hal_version.board_region = otp->board_region;
|
furi_hal_version.board_region = otp->board_region;
|
||||||
|
|
||||||
if(version_get_custom_name(NULL) != NULL) {
|
|
||||||
furi_hal_version_set_name(version_get_custom_name(NULL));
|
|
||||||
} else {
|
|
||||||
furi_hal_version_set_name(otp->name);
|
furi_hal_version_set_name(otp->name);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void furi_hal_version_load_otp_v2() {
|
static void furi_hal_version_load_otp_v2() {
|
||||||
@ -179,11 +173,7 @@ static void furi_hal_version_load_otp_v2() {
|
|||||||
if(otp->board_color != 0xFF) {
|
if(otp->board_color != 0xFF) {
|
||||||
furi_hal_version.board_color = otp->board_color;
|
furi_hal_version.board_color = otp->board_color;
|
||||||
furi_hal_version.board_region = otp->board_region;
|
furi_hal_version.board_region = otp->board_region;
|
||||||
if(version_get_custom_name(NULL) != NULL) {
|
|
||||||
furi_hal_version_set_name(version_get_custom_name(NULL));
|
|
||||||
} else {
|
|
||||||
furi_hal_version_set_name(otp->name);
|
furi_hal_version_set_name(otp->name);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
furi_hal_version.board_color = 0;
|
furi_hal_version.board_color = 0;
|
||||||
furi_hal_version.board_region = 0;
|
furi_hal_version.board_region = 0;
|
||||||
|
@ -18,12 +18,6 @@
|
|||||||
#define FURI_HAL_BT_STACK_VERSION_MINOR (12)
|
#define FURI_HAL_BT_STACK_VERSION_MINOR (12)
|
||||||
#define FURI_HAL_BT_C2_START_TIMEOUT (1000)
|
#define FURI_HAL_BT_C2_START_TIMEOUT (1000)
|
||||||
|
|
||||||
#define FURI_HAL_BT_EMPTY_MAC_ADDR \
|
|
||||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
|
||||||
|
|
||||||
#define FURI_HAL_BT_DEFAULT_MAC_ADDR \
|
|
||||||
{ 0x6c, 0x7a, 0xd8, 0xac, 0x57, 0x72 }
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -236,69 +230,13 @@ float furi_hal_bt_get_rssi();
|
|||||||
*/
|
*/
|
||||||
uint32_t furi_hal_bt_get_transmitted_packets();
|
uint32_t furi_hal_bt_get_transmitted_packets();
|
||||||
|
|
||||||
// BadBT Stuff
|
|
||||||
/** Reverse a MAC address byte order in-place
|
/** Reverse a MAC address byte order in-place
|
||||||
* @param[in] mac mac address to reverse
|
* @param[in] mac mac address to reverse
|
||||||
*/
|
*/
|
||||||
void furi_hal_bt_reverse_mac_addr(uint8_t mac_addr[GAP_MAC_ADDR_SIZE]);
|
void furi_hal_bt_reverse_mac_addr(uint8_t mac_addr[GAP_MAC_ADDR_SIZE]);
|
||||||
|
|
||||||
/** Modify profile advertisement name and restart bluetooth
|
|
||||||
* @param[in] profile profile type
|
|
||||||
* @param[in] name new adv name
|
|
||||||
*/
|
|
||||||
void furi_hal_bt_set_profile_adv_name(
|
|
||||||
FuriHalBtProfile profile,
|
|
||||||
const char name[FURI_HAL_BT_ADV_NAME_LENGTH]);
|
|
||||||
|
|
||||||
const char* furi_hal_bt_get_profile_adv_name(FuriHalBtProfile profile);
|
|
||||||
|
|
||||||
/** Modify profile mac address and restart bluetooth
|
|
||||||
* @param[in] profile profile type
|
|
||||||
* @param[in] mac new mac address
|
|
||||||
*/
|
|
||||||
void furi_hal_bt_set_profile_mac_addr(
|
|
||||||
FuriHalBtProfile profile,
|
|
||||||
const uint8_t mac_addr[GAP_MAC_ADDR_SIZE]);
|
|
||||||
|
|
||||||
const uint8_t* furi_hal_bt_get_profile_mac_addr(FuriHalBtProfile profile);
|
|
||||||
|
|
||||||
uint32_t furi_hal_bt_get_conn_rssi(uint8_t* rssi);
|
uint32_t furi_hal_bt_get_conn_rssi(uint8_t* rssi);
|
||||||
|
|
||||||
// API for BLE Beacon plugin
|
|
||||||
/** Set custom advertisement packet data
|
|
||||||
* @param[in] adv_data pointer to advertisement data
|
|
||||||
* @param[in] adv_len length of advertisement data
|
|
||||||
*
|
|
||||||
* @return true on success
|
|
||||||
*/
|
|
||||||
bool furi_hal_bt_custom_adv_set(const uint8_t* adv_data, size_t adv_len);
|
|
||||||
|
|
||||||
/** Start custom advertisement beacon
|
|
||||||
* @param[in] min_interval minimum advertisement interval (20 - 10240 ms)
|
|
||||||
* @param[in] max_interval maximum advertisement interval (20 - 10240 ms)
|
|
||||||
* @param[in] mac_type type of mac address (0x00 public, 0x01 static random)
|
|
||||||
* @param[in] mac_addr pointer to mac address
|
|
||||||
* @param[in] power_amp_level amplifier level (output dBm) (0x00 - 0x1F)
|
|
||||||
*
|
|
||||||
* @return true on success
|
|
||||||
*/
|
|
||||||
bool furi_hal_bt_custom_adv_start(
|
|
||||||
uint16_t min_interval,
|
|
||||||
uint16_t max_interval,
|
|
||||||
uint8_t mac_type,
|
|
||||||
const uint8_t mac_addr[GAP_MAC_ADDR_SIZE],
|
|
||||||
uint8_t power_amp_level);
|
|
||||||
|
|
||||||
/** Stop custom advertisement beacon
|
|
||||||
*
|
|
||||||
* @return true on success
|
|
||||||
*/
|
|
||||||
bool furi_hal_bt_custom_adv_stop();
|
|
||||||
|
|
||||||
void furi_hal_bt_set_profile_pairing_method(FuriHalBtProfile profile, GapPairing pairing_method);
|
|
||||||
|
|
||||||
GapPairing furi_hal_bt_get_profile_pairing_method(FuriHalBtProfile profile);
|
|
||||||
|
|
||||||
bool furi_hal_bt_is_connected(void);
|
bool furi_hal_bt_is_connected(void);
|
||||||
|
|
||||||
/** Check & switch C2 to given mode
|
/** Check & switch C2 to given mode
|
||||||
|
@ -46,8 +46,6 @@ bool furi_hal_region_is_provisioned();
|
|||||||
*
|
*
|
||||||
* 2 letter Region code according to iso 3166 standard
|
* 2 letter Region code according to iso 3166 standard
|
||||||
* There are 2 extra values that we use in special cases:
|
* There are 2 extra values that we use in special cases:
|
||||||
* RM, whats the reason you not doing a release?
|
|
||||||
* Waiting for my commits?
|
|
||||||
* - "00" - developer edition, unlocked
|
* - "00" - developer edition, unlocked
|
||||||
* - "WW" - world wide, region provisioned by default
|
* - "WW" - world wide, region provisioned by default
|
||||||
* - "--" - no provisioned region
|
* - "--" - no provisioned region
|
||||||
|
@ -16,10 +16,9 @@ extern "C" {
|
|||||||
|
|
||||||
#define FURI_HAL_VERSION_NAME_LENGTH 8
|
#define FURI_HAL_VERSION_NAME_LENGTH 8
|
||||||
#define FURI_HAL_VERSION_ARRAY_NAME_LENGTH (FURI_HAL_VERSION_NAME_LENGTH + 1)
|
#define FURI_HAL_VERSION_ARRAY_NAME_LENGTH (FURI_HAL_VERSION_NAME_LENGTH + 1)
|
||||||
/** BLE symbol + "Flipper " + name */
|
#define FURI_HAL_BT_ADV_NAME_LENGTH (18 + 1) // 18 characters + null terminator
|
||||||
#define FURI_HAL_VERSION_DEVICE_NAME_LENGTH (1 + 8 + FURI_HAL_VERSION_ARRAY_NAME_LENGTH)
|
#define FURI_HAL_VERSION_DEVICE_NAME_LENGTH \
|
||||||
// 18 characters + null terminator
|
(1 + FURI_HAL_BT_ADV_NAME_LENGTH) // Used for custom BT name, BLE symbol + name
|
||||||
#define FURI_HAL_BT_ADV_NAME_LENGTH (FURI_HAL_VERSION_DEVICE_NAME_LENGTH + 1)
|
|
||||||
|
|
||||||
/** OTP Versions enum */
|
/** OTP Versions enum */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
Loading…
Reference in New Issue
Block a user