mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Merge branch 'feat/nfc-type-4-final' into mntm-dev
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,86.0,,
|
||||
Version,+,87.0,,
|
||||
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
|
||||
Header,+,applications/main/archive/helpers/archive_helpers_ext.h,,
|
||||
Header,+,applications/main/subghz/subghz_fap.h,,
|
||||
@@ -136,6 +136,7 @@ Header,+,lib/nanopb/pb.h,,
|
||||
Header,+,lib/nanopb/pb_decode.h,,
|
||||
Header,+,lib/nanopb/pb_encode.h,,
|
||||
Header,+,lib/nfc/helpers/crypto1.h,,
|
||||
Header,+,lib/nfc/helpers/felica_crc.h,,
|
||||
Header,+,lib/nfc/helpers/iso13239_crc.h,,
|
||||
Header,+,lib/nfc/helpers/iso14443_crc.h,,
|
||||
Header,+,lib/nfc/helpers/nfc_data_generator.h,,
|
||||
@@ -264,6 +265,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,,
|
||||
@@ -646,6 +648,8 @@ Function,+,archive_favorites_handle_setting_pin_unpin,void,"const char*, const c
|
||||
Function,+,args_char_to_hex,_Bool,"char, char, uint8_t*"
|
||||
Function,+,args_get_first_word_length,size_t,FuriString*
|
||||
Function,+,args_length,size_t,FuriString*
|
||||
Function,+,args_read_float_and_trim,_Bool,"FuriString*, float*"
|
||||
Function,+,args_read_duration,_Bool,"FuriString*, uint32_t*, const char*"
|
||||
Function,+,args_read_hex_bytes,_Bool,"FuriString*, uint8_t*, size_t"
|
||||
Function,+,args_read_int_and_trim,_Bool,"FuriString*, int*"
|
||||
Function,+,args_read_probably_quoted_string_and_trim,_Bool,"FuriString*, FuriString*"
|
||||
@@ -806,6 +810,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*
|
||||
@@ -906,6 +911,7 @@ Function,+,cli_shell_free,void,CliShell*
|
||||
Function,+,cli_shell_join,void,CliShell*
|
||||
Function,+,cli_shell_set_prompt,void,"CliShell*, const char*"
|
||||
Function,+,cli_shell_start,void,CliShell*
|
||||
Function,+,cli_sleep,_Bool,"PipeSide*, uint32_t"
|
||||
Function,+,cli_vcp_disable,void,CliVcp*
|
||||
Function,+,cli_vcp_enable,void,CliVcp*
|
||||
Function,+,composite_api_resolver_add,void,"CompositeApiResolver*, const ElfApiInterface*"
|
||||
@@ -1119,10 +1125,15 @@ Function,+,felica_calculate_mac_write,void,"mbedtls_des3_context*, const uint8_t
|
||||
Function,+,felica_calculate_session_key,void,"mbedtls_des3_context*, const uint8_t*, const uint8_t*, uint8_t*"
|
||||
Function,+,felica_check_mac,_Bool,"mbedtls_des3_context*, const uint8_t*, const uint8_t*, const uint8_t*, const uint8_t, uint8_t*"
|
||||
Function,+,felica_copy,void,"FelicaData*, const FelicaData*"
|
||||
Function,+,felica_crc_append,void,BitBuffer*
|
||||
Function,+,felica_crc_check,_Bool,const BitBuffer*
|
||||
Function,+,felica_crc_trim,void,BitBuffer*
|
||||
Function,+,felica_free,void,FelicaData*
|
||||
Function,+,felica_get_base_data,FelicaData*,const FelicaData*
|
||||
Function,+,felica_get_device_name,const char*,"const FelicaData*, NfcDeviceNameType"
|
||||
Function,+,felica_get_ic_name,void,"const FelicaData*, FuriString*"
|
||||
Function,+,felica_get_uid,const uint8_t*,"const FelicaData*, size_t*"
|
||||
Function,+,felica_get_workflow_type,void,FelicaData*
|
||||
Function,+,felica_is_equal,_Bool,"const FelicaData*, const FelicaData*"
|
||||
Function,+,felica_load,_Bool,"FelicaData*, FlipperFormat*, uint32_t"
|
||||
Function,+,felica_poller_activate,FelicaError,"FelicaPoller*, FelicaData*"
|
||||
@@ -1130,8 +1141,10 @@ Function,+,felica_poller_read_blocks,FelicaError,"FelicaPoller*, const uint8_t,
|
||||
Function,+,felica_poller_sync_read,FelicaError,"Nfc*, FelicaData*, const FelicaCardKey*"
|
||||
Function,+,felica_reset,void,FelicaData*
|
||||
Function,+,felica_save,_Bool,"const FelicaData*, FlipperFormat*"
|
||||
Function,+,felica_service_get_attribute_string,void,"const FelicaService*, FuriString*"
|
||||
Function,+,felica_set_uid,_Bool,"FelicaData*, const uint8_t*, size_t"
|
||||
Function,+,felica_verify,_Bool,"FelicaData*, const FuriString*"
|
||||
Function,+,felica_write_directory_tree,void,"const FelicaData*, FuriString*"
|
||||
Function,-,feof,int,FILE*
|
||||
Function,-,feof_unlocked,int,FILE*
|
||||
Function,-,ferror,int,FILE*
|
||||
@@ -1351,7 +1364,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*
|
||||
@@ -1378,7 +1391,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,
|
||||
@@ -2038,7 +2051,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,
|
||||
@@ -2965,6 +2978,8 @@ Function,+,nfc_device_set_data,void,"NfcDevice*, NfcProtocol, const NfcDeviceDat
|
||||
Function,+,nfc_device_set_loading_callback,void,"NfcDevice*, NfcLoadingCallback, void*"
|
||||
Function,+,nfc_device_set_uid,_Bool,"NfcDevice*, const uint8_t*, size_t"
|
||||
Function,+,nfc_felica_listener_set_sensf_res_data,NfcError,"Nfc*, const uint8_t*, const uint8_t, const uint8_t*, const uint8_t, const uint16_t"
|
||||
Function,+,nfc_felica_listener_timer_anticol_start,void,"Nfc*, uint8_t"
|
||||
Function,+,nfc_felica_listener_timer_anticol_stop,void,Nfc*
|
||||
Function,+,nfc_free,void,Nfc*
|
||||
Function,+,nfc_iso14443a_listener_set_col_res_data,NfcError,"Nfc*, uint8_t*, uint8_t, uint8_t*, uint8_t"
|
||||
Function,+,nfc_iso14443a_listener_tx_custom_parity,NfcError,"Nfc*, const BitBuffer*"
|
||||
@@ -3009,6 +3024,7 @@ Function,+,notification_internal_message,void,"NotificationApp*, const Notificat
|
||||
Function,+,notification_internal_message_block,void,"NotificationApp*, const NotificationSequence*"
|
||||
Function,+,notification_message,void,"NotificationApp*, const NotificationSequence*"
|
||||
Function,+,notification_message_block,void,"NotificationApp*, const NotificationSequence*"
|
||||
Function,+,notification_messages_notes_frequency_from_name,float,const char*
|
||||
Function,-,nrand48,long,unsigned short[3]
|
||||
Function,+,ntag4xx_alloc,Ntag4xxData*,
|
||||
Function,+,ntag4xx_copy,void,"Ntag4xxData*, const Ntag4xxData*"
|
||||
@@ -3467,6 +3483,8 @@ Function,+,storage_virtual_quit,FS_Error,Storage*
|
||||
Function,+,storage_virtual_unmount,FS_Error,Storage*
|
||||
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);
|
||||
@@ -333,7 +326,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];
|
||||
|
||||
@@ -351,9 +346,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
|
||||
@@ -535,7 +530,11 @@ static void gap_advetise_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;
|
||||
}
|
||||
@@ -548,7 +547,7 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
|
||||
gap->advertise_timer = furi_timer_alloc(gap_advetise_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);
|
||||
@@ -573,14 +572,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) {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "furi_hal_nfc_i.h"
|
||||
#include "furi_hal_nfc_tech_i.h"
|
||||
|
||||
// Prevent FDT timer from starting
|
||||
#define FURI_HAL_NFC_FELICA_LISTENER_FDT_COMP_FC (INT32_MAX)
|
||||
#define FURI_HAL_NFC_FELICA_LISTENER_FDT_COMP_FC (0)
|
||||
|
||||
#define FURI_HAL_FELICA_COMMUNICATION_PERFORMANCE (0x0083U)
|
||||
#define FURI_HAL_FELICA_RESPONSE_CODE (0x01)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user