mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-06-07 19:01:54 -07:00
Spring cleaning
This commit is contained in:
@@ -12,7 +12,7 @@ App(
|
||||
"bt_settings",
|
||||
],
|
||||
stack_size=1 * 1024,
|
||||
order=1000,
|
||||
order=20,
|
||||
sdk_headers=["bt_service/bt.h", "bt_service/bt_keys_storage.h"],
|
||||
)
|
||||
|
||||
|
||||
@@ -522,19 +522,6 @@ static void bt_init_keys_settings(Bt* bt) {
|
||||
bt_handle_reload_keys_settings(bt);
|
||||
}
|
||||
|
||||
bool bt_remote_rssi(Bt* bt, uint8_t* rssi) {
|
||||
furi_assert(bt);
|
||||
|
||||
uint8_t rssi_val;
|
||||
uint32_t since = furi_hal_bt_get_conn_rssi(&rssi_val);
|
||||
|
||||
if(since == 0) return false;
|
||||
|
||||
*rssi = rssi_val;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t bt_srv(void* p) {
|
||||
UNUSED(p);
|
||||
Bt* bt = bt_alloc();
|
||||
|
||||
@@ -79,26 +79,6 @@ void bt_keys_storage_set_storage_path(Bt* bt, const char* keys_storage_path);
|
||||
*/
|
||||
void bt_keys_storage_set_default_path(Bt* bt);
|
||||
|
||||
/** Get BLE remote RSSI value
|
||||
*
|
||||
* @param bt Bt instance
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
bool bt_remote_rssi(Bt* bt, uint8_t* rssi);
|
||||
|
||||
/** Open a new RPC connection
|
||||
*
|
||||
* @param bt Bt instance
|
||||
*/
|
||||
void bt_open_rpc_connection(Bt* bt);
|
||||
|
||||
/** Close the active RPC connection
|
||||
*
|
||||
* @param bt Bt instance
|
||||
*/
|
||||
void bt_close_rpc_connection(Bt* bt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -89,3 +89,15 @@ struct Bt {
|
||||
|
||||
bool suppress_pin_screen;
|
||||
};
|
||||
|
||||
/** Open a new RPC connection
|
||||
*
|
||||
* @param bt Bt instance
|
||||
*/
|
||||
void bt_open_rpc_connection(Bt* bt);
|
||||
|
||||
/** Close the active RPC connection
|
||||
*
|
||||
* @param bt Bt instance
|
||||
*/
|
||||
void bt_close_rpc_connection(Bt* bt);
|
||||
|
||||
@@ -138,17 +138,6 @@ static bool update_task_post_update(UpdateTask* update_task) {
|
||||
|
||||
CHECK_RESULT(int_backup_unpack(update_task->storage, furi_string_get_cstr(file_path)));
|
||||
|
||||
// Fix flags for production / development
|
||||
#ifdef FURI_DEBUG
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagDebug);
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagLegacySleep);
|
||||
#else
|
||||
furi_hal_rtc_reset_flag(FuriHalRtcFlagDebug);
|
||||
furi_hal_rtc_reset_flag(FuriHalRtcFlagLegacySleep);
|
||||
furi_hal_rtc_set_log_level(FuriLogLevelNone);
|
||||
furi_hal_rtc_set_heap_track_mode(FuriHalRtcHeapTrackModeNone);
|
||||
#endif
|
||||
|
||||
if(update_task->state.groups & UpdateTaskStageGroupResources) {
|
||||
path_concat(
|
||||
furi_string_get_cstr(update_task->update_path),
|
||||
|
||||
@@ -343,7 +343,17 @@ int32_t update_task_worker_flash_writer(void* context) {
|
||||
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModePostUpdate);
|
||||
// Clean up /int before restoring backup on next boot
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagStorageFormatInternal);
|
||||
|
||||
#ifdef FURI_DEBUG
|
||||
// Development
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagDebug);
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagLegacySleep);
|
||||
#else
|
||||
// Production
|
||||
furi_hal_rtc_set_log_level(FuriLogLevelNone);
|
||||
furi_hal_rtc_reset_flag(FuriHalRtcFlagDebug);
|
||||
furi_hal_rtc_reset_flag(FuriHalRtcFlagLegacySleep);
|
||||
furi_hal_rtc_set_heap_track_mode(FuriHalRtcHeapTrackModeNone);
|
||||
#endif
|
||||
update_task_set_progress(update_task, UpdateTaskStageCompleted, 100);
|
||||
success = true;
|
||||
} while(false);
|
||||
|
||||
@@ -832,9 +832,7 @@ void elf_file_free(ELFFile* elf) {
|
||||
const ELFSectionDict_itref_t* itref = ELFSectionDict_cref(it);
|
||||
aligned_free(itref->value.data);
|
||||
if(itref->value.fast_rel) {
|
||||
if(itref->value.fast_rel->data) {
|
||||
aligned_free(itref->value.fast_rel->data);
|
||||
}
|
||||
aligned_free(itref->value.fast_rel->data);
|
||||
free(itref->value.fast_rel);
|
||||
}
|
||||
free((void*)itref->key);
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
|
||||
const ProtocolBase* const lfrfid_protocols[] = {
|
||||
[LFRFIDProtocolEM4100] = &protocol_em4100,
|
||||
[LFRFIDProtocolEM4100_32] = &protocol_em4100_32,
|
||||
[LFRFIDProtocolEM4100_16] = &protocol_em4100_16,
|
||||
[LFRFIDProtocolEM410032] = &protocol_em4100_32,
|
||||
[LFRFIDProtocolEM410016] = &protocol_em4100_16,
|
||||
[LFRFIDProtocolElectra] = &protocol_electra,
|
||||
[LFRFIDProtocolH10301] = &protocol_h10301,
|
||||
[LFRFIDProtocolIdteck] = &protocol_idteck,
|
||||
|
||||
@@ -10,8 +10,8 @@ typedef enum {
|
||||
|
||||
typedef enum {
|
||||
LFRFIDProtocolEM4100,
|
||||
LFRFIDProtocolEM4100_32,
|
||||
LFRFIDProtocolEM4100_16,
|
||||
LFRFIDProtocolEM410032,
|
||||
LFRFIDProtocolEM410016,
|
||||
LFRFIDProtocolElectra,
|
||||
LFRFIDProtocolH10301,
|
||||
LFRFIDProtocolIdteck,
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <flipper_application/flipper_application.h>
|
||||
|
||||
#define SUBGHZ_RADIO_DEVICE_PLUGIN_APP_ID "subghz_radio_device"
|
||||
#define SUBGHZ_RADIO_DEVICE_PLUGIN_API_VERSION 2
|
||||
#define SUBGHZ_RADIO_DEVICE_PLUGIN_API_VERSION 1
|
||||
|
||||
typedef struct SubGhzDeviceRegistry SubGhzDeviceRegistry;
|
||||
typedef struct SubGhzDevice SubGhzDevice;
|
||||
|
||||
@@ -88,17 +88,12 @@ bool saved_struct_load(const char* path, void* data, size_t size, uint8_t magic,
|
||||
}
|
||||
|
||||
if(result) {
|
||||
size_t bytes_expected = sizeof(SavedStructHeader) + size;
|
||||
uint64_t bytes_file = storage_file_size(file);
|
||||
result = bytes_file == bytes_expected;
|
||||
if(result) {
|
||||
size_t bytes_count = storage_file_read(file, &header, sizeof(SavedStructHeader));
|
||||
bytes_count += storage_file_read(file, data_read, size);
|
||||
result = bytes_count == bytes_expected;
|
||||
}
|
||||
size_t bytes_count = storage_file_read(file, &header, sizeof(SavedStructHeader));
|
||||
bytes_count += storage_file_read(file, data_read, size);
|
||||
|
||||
if(!result) {
|
||||
if(bytes_count != (sizeof(SavedStructHeader) + size)) {
|
||||
FURI_LOG_E(TAG, "Size mismatch of file \"%s\"", path);
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -787,7 +787,6 @@ Function,+,ble_svc_serial_start,BleServiceSerial*,
|
||||
Function,+,ble_svc_serial_stop,void,BleServiceSerial*
|
||||
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,-,bt_close_rpc_connection,void,Bt*
|
||||
Function,+,bt_disconnect,void,Bt*
|
||||
Function,+,bt_forget_bonded_devices,void,Bt*
|
||||
Function,+,bt_keys_storage_alloc,BtKeysStorage*,const char*
|
||||
@@ -800,10 +799,8 @@ Function,+,bt_keys_storage_set_file_path,void,"BtKeysStorage*, const char*"
|
||||
Function,+,bt_keys_storage_set_ram_params,void,"BtKeysStorage*, uint8_t*, uint16_t"
|
||||
Function,+,bt_keys_storage_set_storage_path,void,"Bt*, const char*"
|
||||
Function,+,bt_keys_storage_update,_Bool,"BtKeysStorage*, uint8_t*, uint32_t"
|
||||
Function,-,bt_open_rpc_connection,void,Bt*
|
||||
Function,+,bt_profile_restore_default,_Bool,Bt*
|
||||
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,+,buffered_file_stream_alloc,Stream*,Storage*
|
||||
Function,+,buffered_file_stream_close,_Bool,Stream*
|
||||
@@ -996,8 +993,8 @@ Function,+,dolphin_deed_get_weight,uint8_t,DolphinDeed
|
||||
Function,+,dolphin_flush,void,Dolphin*
|
||||
Function,+,dolphin_get_pubsub,FuriPubSub*,Dolphin*
|
||||
Function,+,dolphin_get_settings,void,"Dolphin*, DolphinSettings*"
|
||||
Function,+,dolphin_set_settings,void,"Dolphin*, DolphinSettings*"
|
||||
Function,+,dolphin_reload_state,void,Dolphin*
|
||||
Function,+,dolphin_set_settings,void,"Dolphin*, DolphinSettings*"
|
||||
Function,+,dolphin_stats,DolphinStats,Dolphin*
|
||||
Function,+,dolphin_upgrade_level,void,Dolphin*
|
||||
Function,-,dprintf,int,"int, const char*, ..."
|
||||
@@ -1338,7 +1335,6 @@ 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_start,_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_radio_stack,FuriHalBtStack,
|
||||
Function,+,furi_hal_bt_get_rssi,float,
|
||||
@@ -1346,7 +1342,6 @@ Function,+,furi_hal_bt_get_transmitted_packets,uint32_t,
|
||||
Function,-,furi_hal_bt_init,void,
|
||||
Function,+,furi_hal_bt_is_active,_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_testing_supported,_Bool,
|
||||
Function,+,furi_hal_bt_lock_core2,void,
|
||||
@@ -2014,7 +2009,6 @@ 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_start,_Bool,
|
||||
Function,-,gap_extra_beacon_stop,_Bool,
|
||||
Function,-,gap_get_remote_conn_rssi,uint32_t,int8_t*
|
||||
Function,-,gap_get_state,GapState,
|
||||
Function,-,gap_init,_Bool,"GapConfig*, GapEventCallback, void*"
|
||||
Function,-,gap_start_advertising,void,
|
||||
|
||||
|
@@ -33,8 +33,6 @@ typedef struct {
|
||||
GapConfig* config;
|
||||
GapConnectionParams connection_params;
|
||||
GapState state;
|
||||
int8_t conn_rssi;
|
||||
uint32_t time_rssi_sample;
|
||||
FuriMutex* state_mutex;
|
||||
GapEventCallback on_event_cb;
|
||||
void* context;
|
||||
@@ -65,19 +63,6 @@ static Gap* gap = NULL;
|
||||
static void gap_advertise_start(GapState new_state);
|
||||
static int32_t gap_app(void* context);
|
||||
|
||||
/** function for updating rssi informations in global Gap object
|
||||
*
|
||||
*/
|
||||
static inline void fetch_rssi(void) {
|
||||
uint8_t ret_rssi = 127;
|
||||
if(hci_read_rssi(gap->service.connection_handle, &ret_rssi) == BLE_STATUS_SUCCESS) {
|
||||
gap->conn_rssi = (int8_t)ret_rssi;
|
||||
gap->time_rssi_sample = furi_get_tick();
|
||||
return;
|
||||
}
|
||||
FURI_LOG_D(TAG, "Failed to read RSSI");
|
||||
}
|
||||
|
||||
static void gap_verify_connection_parameters(Gap* gap) {
|
||||
furi_check(gap);
|
||||
|
||||
@@ -181,9 +166,6 @@ BleEventFlowStatus ble_event_app_notification(void* pckt) {
|
||||
gap->connection_params.supervisor_timeout = event->Supervision_Timeout;
|
||||
FURI_LOG_I(TAG, "Connection parameters event complete");
|
||||
gap_verify_connection_parameters(gap);
|
||||
|
||||
// Save rssi for current connection
|
||||
fetch_rssi();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -301,9 +283,6 @@ BleEventFlowStatus ble_event_app_notification(void* pckt) {
|
||||
pairing_complete->Status);
|
||||
aci_gap_terminate(gap->service.connection_handle, 5);
|
||||
} else {
|
||||
// Save RSSI
|
||||
fetch_rssi();
|
||||
|
||||
FURI_LOG_I(TAG, "Pairing complete");
|
||||
GapEvent event = {.type = GapEventTypeConnected};
|
||||
gap->on_event_cb(event, gap->context); //-V595
|
||||
@@ -380,7 +359,7 @@ static void gap_init_svc(Gap* gap) {
|
||||
// Initialize GATT interface
|
||||
aci_gatt_init();
|
||||
// Initialize GAP interface
|
||||
// Skip first symbol AD_TYPE_COMPLETE_LOCAL_NAME
|
||||
// Skip fist symbol AD_TYPE_COMPLETE_LOCAL_NAME
|
||||
char* name = gap->service.adv_name + 1;
|
||||
aci_gap_init(
|
||||
GAP_PERIPHERAL_ROLE,
|
||||
@@ -550,7 +529,7 @@ void gap_stop_advertising(void) {
|
||||
furi_check(furi_mutex_release(gap->state_mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
static void gap_advertise_timer_callback(void* context) {
|
||||
static void gap_advetise_timer_callback(void* context) {
|
||||
UNUSED(context);
|
||||
GapCommand command = GapCommandAdvLowPower;
|
||||
furi_check(furi_message_queue_put(gap->command_queue, &command, 0) == FuriStatusOk);
|
||||
@@ -566,7 +545,7 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
|
||||
gap = malloc(sizeof(Gap));
|
||||
gap->config = config;
|
||||
// Create advertising timer
|
||||
gap->advertise_timer = furi_timer_alloc(gap_advertise_timer_callback, FuriTimerTypeOnce, NULL);
|
||||
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);
|
||||
@@ -577,9 +556,6 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
|
||||
gap->service.connection_handle = 0xFFFF;
|
||||
gap->enable_adv = true;
|
||||
|
||||
gap->conn_rssi = 127;
|
||||
gap->time_rssi_sample = 0;
|
||||
|
||||
// Command queue allocation
|
||||
gap->command_queue = furi_message_queue_alloc(8, sizeof(GapCommand));
|
||||
|
||||
@@ -619,17 +595,6 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
|
||||
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 state;
|
||||
if(gap) {
|
||||
|
||||
@@ -96,8 +96,6 @@ void gap_thread_stop(void);
|
||||
|
||||
void gap_emit_ble_beacon_status_event(bool active);
|
||||
|
||||
uint32_t gap_get_remote_conn_rssi(int8_t* rssi);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -251,10 +251,6 @@ bool furi_hal_bt_is_active(void) {
|
||||
return gap_get_state() > GapStateIdle;
|
||||
}
|
||||
|
||||
bool furi_hal_bt_is_connected(void) {
|
||||
return gap_get_state() == GapStateConnected;
|
||||
}
|
||||
|
||||
void furi_hal_bt_start_advertising(void) {
|
||||
if(gap_get_state() == GapStateIdle) {
|
||||
gap_start_advertising();
|
||||
@@ -391,21 +387,6 @@ float furi_hal_bt_get_rssi(void) {
|
||||
return val;
|
||||
}
|
||||
|
||||
/** fill the RSSI of the remote host of the bt connection and returns the last
|
||||
* time the RSSI was updated
|
||||
*
|
||||
*/
|
||||
uint32_t furi_hal_bt_get_conn_rssi(uint8_t* rssi) {
|
||||
int8_t ret_rssi = 0;
|
||||
uint32_t since = gap_get_remote_conn_rssi(&ret_rssi);
|
||||
|
||||
if(ret_rssi == 127 || since == 0) return 0;
|
||||
|
||||
*rssi = (uint8_t)abs(ret_rssi);
|
||||
|
||||
return since;
|
||||
}
|
||||
|
||||
uint32_t furi_hal_bt_get_transmitted_packets(void) {
|
||||
uint32_t packets = 0;
|
||||
aci_hal_le_tx_test_packet_number(&packets);
|
||||
|
||||
@@ -47,11 +47,7 @@
|
||||
> If for any reason this test is never passed, this means there is a failure in the system and there is no other
|
||||
> way to recover than applying a device reset.
|
||||
*/
|
||||
// Was previously 3000U, 3 seconds
|
||||
// Changing furi_assert() to furi_check() brought timeout crashes
|
||||
// Internal storage is very slow, and "big" files will often cause a "timeout" with 3 seconds
|
||||
// 10 seconds seems fine, the file operations complete successfully, albeit slowly
|
||||
#define FURI_HAL_FLASH_C2_LOCK_TIMEOUT_MS (10000U) /* 10 seconds */
|
||||
#define FURI_HAL_FLASH_C2_LOCK_TIMEOUT_MS (3000U) /* 3 seconds */
|
||||
|
||||
#define IS_ADDR_ALIGNED_64BITS(__VALUE__) (((__VALUE__) & 0x7U) == (0x00UL))
|
||||
#define IS_FLASH_PROGRAM_ADDRESS(__VALUE__) \
|
||||
|
||||
@@ -231,10 +231,6 @@ float furi_hal_bt_get_rssi(void);
|
||||
*/
|
||||
uint32_t furi_hal_bt_get_transmitted_packets(void);
|
||||
|
||||
uint32_t furi_hal_bt_get_conn_rssi(uint8_t* rssi);
|
||||
|
||||
bool furi_hal_bt_is_connected(void);
|
||||
|
||||
/** Check & switch C2 to given mode
|
||||
*
|
||||
* @param[in] mode mode to switch into
|
||||
|
||||
Reference in New Issue
Block a user