diff --git a/applications/services/bt/application.fam b/applications/services/bt/application.fam index fe3a3c7a1..a4c86c3c9 100644 --- a/applications/services/bt/application.fam +++ b/applications/services/bt/application.fam @@ -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"], ) diff --git a/applications/services/bt/bt_service/bt.c b/applications/services/bt/bt_service/bt.c index a99568da5..acc8dc90c 100644 --- a/applications/services/bt/bt_service/bt.c +++ b/applications/services/bt/bt_service/bt.c @@ -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(); diff --git a/applications/services/bt/bt_service/bt.h b/applications/services/bt/bt_service/bt.h index 0f2f23c1a..270922543 100644 --- a/applications/services/bt/bt_service/bt.h +++ b/applications/services/bt/bt_service/bt.h @@ -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 diff --git a/applications/services/bt/bt_service/bt_i.h b/applications/services/bt/bt_service/bt_i.h index 2ee5e971a..0077f6e51 100644 --- a/applications/services/bt/bt_service/bt_i.h +++ b/applications/services/bt/bt_service/bt_i.h @@ -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); diff --git a/applications/system/updater/util/update_task_worker_backup.c b/applications/system/updater/util/update_task_worker_backup.c index 0081de21d..4dff5fbcf 100644 --- a/applications/system/updater/util/update_task_worker_backup.c +++ b/applications/system/updater/util/update_task_worker_backup.c @@ -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), diff --git a/applications/system/updater/util/update_task_worker_flasher.c b/applications/system/updater/util/update_task_worker_flasher.c index f587f7447..14a8bc39e 100644 --- a/applications/system/updater/util/update_task_worker_flasher.c +++ b/applications/system/updater/util/update_task_worker_flasher.c @@ -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); diff --git a/lib/flipper_application/elf/elf_file.c b/lib/flipper_application/elf/elf_file.c index 5eab0efdd..bd8ecdf7e 100644 --- a/lib/flipper_application/elf/elf_file.c +++ b/lib/flipper_application/elf/elf_file.c @@ -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); diff --git a/lib/lfrfid/protocols/lfrfid_protocols.c b/lib/lfrfid/protocols/lfrfid_protocols.c index 69a62c6d6..cbb1e15a3 100644 --- a/lib/lfrfid/protocols/lfrfid_protocols.c +++ b/lib/lfrfid/protocols/lfrfid_protocols.c @@ -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, diff --git a/lib/lfrfid/protocols/lfrfid_protocols.h b/lib/lfrfid/protocols/lfrfid_protocols.h index 1cab1917b..d6e13c2e4 100644 --- a/lib/lfrfid/protocols/lfrfid_protocols.h +++ b/lib/lfrfid/protocols/lfrfid_protocols.h @@ -10,8 +10,8 @@ typedef enum { typedef enum { LFRFIDProtocolEM4100, - LFRFIDProtocolEM4100_32, - LFRFIDProtocolEM4100_16, + LFRFIDProtocolEM410032, + LFRFIDProtocolEM410016, LFRFIDProtocolElectra, LFRFIDProtocolH10301, LFRFIDProtocolIdteck, diff --git a/lib/subghz/devices/types.h b/lib/subghz/devices/types.h index 3c34aaf0b..30822dc16 100644 --- a/lib/subghz/devices/types.h +++ b/lib/subghz/devices/types.h @@ -13,7 +13,7 @@ #include #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; diff --git a/lib/toolbox/saved_struct.c b/lib/toolbox/saved_struct.c index 173aa4680..db7e4de6e 100644 --- a/lib/toolbox/saved_struct.c +++ b/lib/toolbox/saved_struct.c @@ -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; } } diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index d04c5291c..ba681b03b 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -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, diff --git a/targets/f7/ble_glue/gap.c b/targets/f7/ble_glue/gap.c index f5f7500ff..1fe898ea9 100644 --- a/targets/f7/ble_glue/gap.c +++ b/targets/f7/ble_glue/gap.c @@ -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) { diff --git a/targets/f7/ble_glue/gap.h b/targets/f7/ble_glue/gap.h index 096dcb46a..2f0b097e4 100644 --- a/targets/f7/ble_glue/gap.h +++ b/targets/f7/ble_glue/gap.h @@ -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 diff --git a/targets/f7/furi_hal/furi_hal_bt.c b/targets/f7/furi_hal/furi_hal_bt.c index 1d5c181b8..2c1a9367b 100644 --- a/targets/f7/furi_hal/furi_hal_bt.c +++ b/targets/f7/furi_hal/furi_hal_bt.c @@ -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); diff --git a/targets/f7/furi_hal/furi_hal_flash.c b/targets/f7/furi_hal/furi_hal_flash.c index 28aa45173..8bf1ac702 100644 --- a/targets/f7/furi_hal/furi_hal_flash.c +++ b/targets/f7/furi_hal/furi_hal_flash.c @@ -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__) \ diff --git a/targets/furi_hal_include/furi_hal_bt.h b/targets/furi_hal_include/furi_hal_bt.h index b5cdfc829..6da723311 100644 --- a/targets/furi_hal_include/furi_hal_bt.h +++ b/targets/furi_hal_include/furi_hal_bt.h @@ -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