mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Merge remote-tracking branch 'OFW/dev' into dev
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,86.1,,
|
||||
Version,+,87.0,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
@@ -173,6 +173,7 @@ Header,+,lib/toolbox/protocols/protocol_dict.h,,
|
||||
Header,+,lib/toolbox/pulse_protocols/pulse_glue.h,,
|
||||
Header,+,lib/toolbox/saved_struct.h,,
|
||||
Header,+,lib/toolbox/simple_array.h,,
|
||||
Header,+,lib/toolbox/str_buffer.h,,
|
||||
Header,+,lib/toolbox/stream/buffered_file_stream.h,,
|
||||
Header,+,lib/toolbox/stream/file_stream.h,,
|
||||
Header,+,lib/toolbox/stream/stream.h,,
|
||||
@@ -703,6 +704,7 @@ Function,+,bt_forget_bonded_devices,void,Bt*
|
||||
Function,+,bt_keys_storage_alloc,BtKeysStorage*,const char*
|
||||
Function,+,bt_keys_storage_delete,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_free,void,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_get_root_keys,const GapRootSecurityKeys*,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_is_changed,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_load,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_set_default_path,void,Bt*
|
||||
@@ -1173,7 +1175,7 @@ Function,+,furi_hal_adc_convert_vref,float,"FuriHalAdcHandle*, uint16_t"
|
||||
Function,+,furi_hal_adc_init,void,
|
||||
Function,+,furi_hal_adc_read,uint16_t,"FuriHalAdcHandle*, FuriHalAdcChannel"
|
||||
Function,+,furi_hal_adc_release,void,FuriHalAdcHandle*
|
||||
Function,+,furi_hal_bt_change_app,FuriHalBleProfileBase*,"const FuriHalBleProfileTemplate*, FuriHalBleProfileParams, GapEventCallback, void*"
|
||||
Function,+,furi_hal_bt_change_app,FuriHalBleProfileBase*,"const FuriHalBleProfileTemplate*, FuriHalBleProfileParams, const GapRootSecurityKeys*, GapEventCallback, void*"
|
||||
Function,+,furi_hal_bt_check_profile_type,_Bool,"FuriHalBleProfileBase*, const FuriHalBleProfileTemplate*"
|
||||
Function,+,furi_hal_bt_clear_white_list,_Bool,
|
||||
Function,+,furi_hal_bt_dump_state,void,FuriString*
|
||||
@@ -1200,7 +1202,7 @@ Function,+,furi_hal_bt_nvm_sram_sem_release,void,
|
||||
Function,+,furi_hal_bt_reinit,void,
|
||||
Function,+,furi_hal_bt_set_key_storage_change_callback,void,"BleGlueKeyStorageChangedCallback, 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, const GapRootSecurityKeys*, GapEventCallback, void*"
|
||||
Function,+,furi_hal_bt_start_packet_rx,void,"uint8_t, uint8_t"
|
||||
Function,+,furi_hal_bt_start_packet_tx,void,"uint8_t, uint8_t, uint8_t"
|
||||
Function,+,furi_hal_bt_start_radio_stack,_Bool,
|
||||
@@ -1740,7 +1742,7 @@ Function,-,gap_extra_beacon_set_data,_Bool,"const uint8_t*, uint8_t"
|
||||
Function,-,gap_extra_beacon_start,_Bool,
|
||||
Function,-,gap_extra_beacon_stop,_Bool,
|
||||
Function,-,gap_get_state,GapState,
|
||||
Function,-,gap_init,_Bool,"GapConfig*, GapEventCallback, void*"
|
||||
Function,-,gap_init,_Bool,"GapConfig*, const GapRootSecurityKeys*, GapEventCallback, void*"
|
||||
Function,-,gap_start_advertising,void,
|
||||
Function,-,gap_stop_advertising,void,
|
||||
Function,-,gap_thread_stop,void,
|
||||
@@ -2635,6 +2637,8 @@ Function,+,storage_simply_remove,_Bool,"Storage*, const char*"
|
||||
Function,+,storage_simply_remove_recursive,_Bool,"Storage*, const char*"
|
||||
Function,-,stpcpy,char*,"char*, const char*"
|
||||
Function,-,stpncpy,char*,"char*, const char*, size_t"
|
||||
Function,+,str_buffer_clear_all_clones,void,StrBuffer*
|
||||
Function,+,str_buffer_make_owned_clone,const char*,"StrBuffer*, const char*"
|
||||
Function,+,strcasecmp,int,"const char*, const char*"
|
||||
Function,-,strcasecmp_l,int,"const char*, const char*, locale_t"
|
||||
Function,+,strcasestr,char*,"const char*, const char*"
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,86.1,,
|
||||
Version,+,87.0,,
|
||||
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
|
||||
@@ -257,6 +257,7 @@ Header,+,lib/toolbox/protocols/protocol_dict.h,,
|
||||
Header,+,lib/toolbox/pulse_protocols/pulse_glue.h,,
|
||||
Header,+,lib/toolbox/saved_struct.h,,
|
||||
Header,+,lib/toolbox/simple_array.h,,
|
||||
Header,+,lib/toolbox/str_buffer.h,,
|
||||
Header,+,lib/toolbox/stream/buffered_file_stream.h,,
|
||||
Header,+,lib/toolbox/stream/file_stream.h,,
|
||||
Header,+,lib/toolbox/stream/stream.h,,
|
||||
@@ -792,6 +793,7 @@ Function,+,bt_forget_bonded_devices,void,Bt*
|
||||
Function,+,bt_keys_storage_alloc,BtKeysStorage*,const char*
|
||||
Function,+,bt_keys_storage_delete,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_free,void,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_get_root_keys,const GapRootSecurityKeys*,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_is_changed,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_load,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_set_default_path,void,Bt*
|
||||
@@ -1322,7 +1324,7 @@ Function,+,furi_hal_adc_convert_vref,float,"FuriHalAdcHandle*, uint16_t"
|
||||
Function,+,furi_hal_adc_init,void,
|
||||
Function,+,furi_hal_adc_read,uint16_t,"FuriHalAdcHandle*, FuriHalAdcChannel"
|
||||
Function,+,furi_hal_adc_release,void,FuriHalAdcHandle*
|
||||
Function,+,furi_hal_bt_change_app,FuriHalBleProfileBase*,"const FuriHalBleProfileTemplate*, FuriHalBleProfileParams, GapEventCallback, void*"
|
||||
Function,+,furi_hal_bt_change_app,FuriHalBleProfileBase*,"const FuriHalBleProfileTemplate*, FuriHalBleProfileParams, const GapRootSecurityKeys*, GapEventCallback, void*"
|
||||
Function,+,furi_hal_bt_check_profile_type,_Bool,"FuriHalBleProfileBase*, const FuriHalBleProfileTemplate*"
|
||||
Function,+,furi_hal_bt_clear_white_list,_Bool,
|
||||
Function,+,furi_hal_bt_dump_state,void,FuriString*
|
||||
@@ -1349,7 +1351,7 @@ Function,+,furi_hal_bt_nvm_sram_sem_release,void,
|
||||
Function,+,furi_hal_bt_reinit,void,
|
||||
Function,+,furi_hal_bt_set_key_storage_change_callback,void,"BleGlueKeyStorageChangedCallback, 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, const GapRootSecurityKeys*, GapEventCallback, void*"
|
||||
Function,+,furi_hal_bt_start_packet_rx,void,"uint8_t, uint8_t"
|
||||
Function,+,furi_hal_bt_start_packet_tx,void,"uint8_t, uint8_t, uint8_t"
|
||||
Function,+,furi_hal_bt_start_radio_stack,_Bool,
|
||||
@@ -2009,7 +2011,7 @@ Function,-,gap_extra_beacon_set_data,_Bool,"const uint8_t*, uint8_t"
|
||||
Function,-,gap_extra_beacon_start,_Bool,
|
||||
Function,-,gap_extra_beacon_stop,_Bool,
|
||||
Function,-,gap_get_state,GapState,
|
||||
Function,-,gap_init,_Bool,"GapConfig*, GapEventCallback, void*"
|
||||
Function,-,gap_init,_Bool,"GapConfig*, const GapRootSecurityKeys*, GapEventCallback, void*"
|
||||
Function,-,gap_start_advertising,void,
|
||||
Function,-,gap_stop_advertising,void,
|
||||
Function,-,gap_thread_stop,void,
|
||||
@@ -3413,6 +3415,8 @@ Function,+,storage_simply_remove,_Bool,"Storage*, const char*"
|
||||
Function,+,storage_simply_remove_recursive,_Bool,"Storage*, const char*"
|
||||
Function,-,stpcpy,char*,"char*, const char*"
|
||||
Function,-,stpncpy,char*,"char*, const char*, size_t"
|
||||
Function,+,str_buffer_clear_all_clones,void,StrBuffer*
|
||||
Function,+,str_buffer_make_owned_clone,const char*,"StrBuffer*, const char*"
|
||||
Function,+,strcasecmp,int,"const char*, const char*"
|
||||
Function,-,strcasecmp_l,int,"const char*, const char*, locale_t"
|
||||
Function,+,strcasestr,char*,"const char*, const char*"
|
||||
|
||||
|
@@ -51,13 +51,6 @@ typedef enum {
|
||||
GapCommandKillThread,
|
||||
} GapCommand;
|
||||
|
||||
// Identity root key
|
||||
static const uint8_t gap_irk[16] =
|
||||
{0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0};
|
||||
// Encryption root key
|
||||
static const uint8_t gap_erk[16] =
|
||||
{0xfe, 0xdc, 0xba, 0x09, 0x87, 0x65, 0x43, 0x21, 0xfe, 0xdc, 0xba, 0x09, 0x87, 0x65, 0x43, 0x21};
|
||||
|
||||
static Gap* gap = NULL;
|
||||
|
||||
static void gap_advertise_start(GapState new_state);
|
||||
@@ -335,7 +328,9 @@ static void set_manufacturer_data(uint8_t* mfg_data, uint8_t mfg_data_len) {
|
||||
gap->service.mfg_data_len += mfg_data_len;
|
||||
}
|
||||
|
||||
static void gap_init_svc(Gap* gap) {
|
||||
static void gap_init_svc(Gap* gap, const GapRootSecurityKeys* root_keys) {
|
||||
furi_check(root_keys);
|
||||
|
||||
tBleStatus status;
|
||||
uint32_t srd_bd_addr[2];
|
||||
|
||||
@@ -353,9 +348,9 @@ static void gap_init_svc(Gap* gap) {
|
||||
aci_hal_write_config_data(
|
||||
CONFIG_DATA_RANDOM_ADDRESS_OFFSET, CONFIG_DATA_RANDOM_ADDRESS_LEN, (uint8_t*)srd_bd_addr);
|
||||
// Set Identity root key used to derive LTK and CSRK
|
||||
aci_hal_write_config_data(CONFIG_DATA_IR_OFFSET, CONFIG_DATA_IR_LEN, (uint8_t*)gap_irk);
|
||||
aci_hal_write_config_data(CONFIG_DATA_IR_OFFSET, CONFIG_DATA_IR_LEN, root_keys->irk);
|
||||
// Set Encryption root key used to derive LTK and CSRK
|
||||
aci_hal_write_config_data(CONFIG_DATA_ER_OFFSET, CONFIG_DATA_ER_LEN, (uint8_t*)gap_erk);
|
||||
aci_hal_write_config_data(CONFIG_DATA_ER_OFFSET, CONFIG_DATA_ER_LEN, root_keys->erk);
|
||||
// Set TX Power to 0 dBm
|
||||
aci_hal_set_tx_power_level(1, 0x19);
|
||||
// Initialize GATT interface
|
||||
@@ -537,7 +532,11 @@ static void gap_advertise_timer_callback(void* context) {
|
||||
furi_check(furi_message_queue_put(gap->command_queue, &command, 0) == FuriStatusOk);
|
||||
}
|
||||
|
||||
bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
|
||||
bool gap_init(
|
||||
GapConfig* config,
|
||||
const GapRootSecurityKeys* root_keys,
|
||||
GapEventCallback on_event_cb,
|
||||
void* context) {
|
||||
if(!ble_glue_is_radio_stack_ready()) {
|
||||
return false;
|
||||
}
|
||||
@@ -550,7 +549,7 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
|
||||
gap->advertise_timer = furi_timer_alloc(gap_advertise_timer_callback, FuriTimerTypeOnce, NULL);
|
||||
// Initialization of GATT & GAP layer
|
||||
gap->service.adv_name = config->adv_name;
|
||||
gap_init_svc(gap);
|
||||
gap_init_svc(gap, root_keys);
|
||||
ble_event_dispatcher_init();
|
||||
// Initialization of the GAP state
|
||||
gap->state_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
@@ -575,14 +574,13 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
|
||||
set_manufacturer_data(gap->config->mfg_data, gap->config->mfg_data_len);
|
||||
}
|
||||
|
||||
gap->service.adv_svc_uuid_len = 1;
|
||||
if(gap->config->adv_service.UUID_Type == UUID_TYPE_16) {
|
||||
uint8_t adv_service_uid[2];
|
||||
gap->service.adv_svc_uuid_len = 1;
|
||||
adv_service_uid[0] = gap->config->adv_service.Service_UUID_16 & 0xff;
|
||||
adv_service_uid[1] = gap->config->adv_service.Service_UUID_16 >> 8;
|
||||
set_advertisment_service_uid(adv_service_uid, sizeof(adv_service_uid));
|
||||
} else if(gap->config->adv_service.UUID_Type == UUID_TYPE_128) {
|
||||
gap->service.adv_svc_uuid_len = 1;
|
||||
set_advertisment_service_uid(
|
||||
gap->config->adv_service.Service_UUID_128,
|
||||
sizeof(gap->config->adv_service.Service_UUID_128));
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <furi_hal_version.h>
|
||||
|
||||
#define GAP_MAC_ADDR_SIZE (6)
|
||||
#define GAP_KEY_SIZE (0x10)
|
||||
|
||||
/*
|
||||
* GAP helpers - background thread that handles BLE GAP events and advertising.
|
||||
@@ -84,7 +85,18 @@ typedef struct {
|
||||
GapConnectionParamsRequest conn_param;
|
||||
} GapConfig;
|
||||
|
||||
bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context);
|
||||
typedef struct {
|
||||
// Encryption Root key. Must be unique per-device (or app)
|
||||
uint8_t erk[GAP_KEY_SIZE];
|
||||
// Identity Root key. Used for resolving RPAs, if configured
|
||||
uint8_t irk[GAP_KEY_SIZE];
|
||||
} GapRootSecurityKeys;
|
||||
|
||||
bool gap_init(
|
||||
GapConfig* config,
|
||||
const GapRootSecurityKeys* root_keys,
|
||||
GapEventCallback on_event_cb,
|
||||
void* context);
|
||||
|
||||
void gap_start_advertising(void);
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ static FuriHalBt furi_hal_bt = {
|
||||
.stack = FuriHalBtStackUnknown,
|
||||
};
|
||||
|
||||
static FuriHalBleProfileBase* current_profile = NULL;
|
||||
static GapConfig current_config = {0};
|
||||
|
||||
void furi_hal_bt_init(void) {
|
||||
FURI_LOG_I(TAG, "Start BT initialization");
|
||||
furi_hal_bus_enable(FuriHalBusHSEM);
|
||||
@@ -149,9 +152,6 @@ bool furi_hal_bt_is_testing_supported(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static FuriHalBleProfileBase* current_profile = NULL;
|
||||
static GapConfig current_config = {0};
|
||||
|
||||
bool furi_hal_bt_check_profile_type(
|
||||
FuriHalBleProfileBase* profile,
|
||||
const FuriHalBleProfileTemplate* profile_template) {
|
||||
@@ -165,10 +165,12 @@ bool furi_hal_bt_check_profile_type(
|
||||
FuriHalBleProfileBase* furi_hal_bt_start_app(
|
||||
const FuriHalBleProfileTemplate* profile_template,
|
||||
FuriHalBleProfileParams params,
|
||||
const GapRootSecurityKeys* root_keys,
|
||||
GapEventCallback event_cb,
|
||||
void* context) {
|
||||
furi_check(event_cb);
|
||||
furi_check(profile_template);
|
||||
furi_check(root_keys);
|
||||
furi_check(current_profile == NULL);
|
||||
|
||||
do {
|
||||
@@ -183,7 +185,7 @@ FuriHalBleProfileBase* furi_hal_bt_start_app(
|
||||
|
||||
profile_template->get_gap_config(¤t_config, params);
|
||||
|
||||
if(!gap_init(¤t_config, event_cb, context)) {
|
||||
if(!gap_init(¤t_config, root_keys, event_cb, context)) {
|
||||
gap_thread_stop();
|
||||
FURI_LOG_E(TAG, "Failed to init GAP");
|
||||
break;
|
||||
@@ -239,12 +241,11 @@ void furi_hal_bt_reinit(void) {
|
||||
FuriHalBleProfileBase* furi_hal_bt_change_app(
|
||||
const FuriHalBleProfileTemplate* profile_template,
|
||||
FuriHalBleProfileParams profile_params,
|
||||
const GapRootSecurityKeys* root_keys,
|
||||
GapEventCallback event_cb,
|
||||
void* context) {
|
||||
furi_check(event_cb);
|
||||
|
||||
furi_hal_bt_reinit();
|
||||
return furi_hal_bt_start_app(profile_template, profile_params, event_cb, context);
|
||||
return furi_hal_bt_start_app(profile_template, profile_params, root_keys, event_cb, context);
|
||||
}
|
||||
|
||||
bool furi_hal_bt_is_active(void) {
|
||||
|
||||
@@ -68,7 +68,7 @@ void SystemInit(void) {
|
||||
RCC->PLLSAI1CFGR = 0x22041000U;
|
||||
#endif
|
||||
// Reset HSEBYP bit
|
||||
RCC->CR &= 0xFFFBFFFFU;
|
||||
RCC->CR &= 0xFFFBFFFFU; //-V784
|
||||
// Disable all RCC related interrupts
|
||||
RCC->CIER = 0x00000000;
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ bool furi_hal_bt_check_profile_type(
|
||||
*
|
||||
* @param profile_template FuriHalBleProfileTemplate instance
|
||||
* @param params Parameters to pass to the profile. Can be NULL
|
||||
* @param root_keys pointer to root keys
|
||||
* @param event_cb GapEventCallback instance
|
||||
* @param context pointer to context
|
||||
*
|
||||
@@ -85,6 +86,7 @@ bool furi_hal_bt_check_profile_type(
|
||||
FURI_WARN_UNUSED FuriHalBleProfileBase* furi_hal_bt_start_app(
|
||||
const FuriHalBleProfileTemplate* profile_template,
|
||||
FuriHalBleProfileParams params,
|
||||
const GapRootSecurityKeys* root_keys,
|
||||
GapEventCallback event_cb,
|
||||
void* context);
|
||||
|
||||
@@ -100,6 +102,7 @@ void furi_hal_bt_reinit(void);
|
||||
* @param profile_template FuriHalBleProfileTemplate instance
|
||||
* @param profile_params Parameters to pass to the profile. Can be NULL
|
||||
* @param event_cb GapEventCallback instance
|
||||
* @param root_keys pointer to root keys
|
||||
* @param context pointer to context
|
||||
*
|
||||
* @return instance of profile, NULL on failure
|
||||
@@ -107,6 +110,7 @@ void furi_hal_bt_reinit(void);
|
||||
FURI_WARN_UNUSED FuriHalBleProfileBase* furi_hal_bt_change_app(
|
||||
const FuriHalBleProfileTemplate* profile_template,
|
||||
FuriHalBleProfileParams profile_params,
|
||||
const GapRootSecurityKeys* root_keys,
|
||||
GapEventCallback event_cb,
|
||||
void* context);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user