after merge fixes

This commit is contained in:
MX 2024-08-10 14:22:33 +03:00
parent 28272f7a7a
commit 1e5dd001fe
No known key found for this signature in database
GPG Key ID: 7CCC66B7DBDD1C83
22 changed files with 61 additions and 333 deletions

View File

@ -9,17 +9,17 @@
static const char* tab_default_paths[] = { static const char* tab_default_paths[] = {
[ArchiveTabFavorites] = "/app:favorites", [ArchiveTabFavorites] = "/app:favorites",
[ArchiveTabIButton] = ANY_PATH("ibutton"), [ArchiveTabIButton] = EXT_PATH("ibutton"),
[ArchiveTabNFC] = ANY_PATH("nfc"), [ArchiveTabNFC] = EXT_PATH("nfc"),
[ArchiveTabSubGhz] = ANY_PATH("subghz"), [ArchiveTabSubGhz] = EXT_PATH("subghz"),
[ArchiveTabSubGhzRemote] = EXT_PATH("subghz_remote"), [ArchiveTabSubGhzRemote] = EXT_PATH("subghz_remote"),
[ArchiveTabLFRFID] = ANY_PATH("lfrfid"), [ArchiveTabLFRFID] = EXT_PATH("lfrfid"),
[ArchiveTabInfrared] = ANY_PATH("infrared"), [ArchiveTabInfrared] = EXT_PATH("infrared"),
[ArchiveTabBadUsb] = ANY_PATH("badusb"), [ArchiveTabBadUsb] = EXT_PATH("badusb"),
[ArchiveTabU2f] = "/app:u2f", [ArchiveTabU2f] = "/app:u2f",
[ArchiveTabApplications] = ANY_PATH("apps"), [ArchiveTabApplications] = EXT_PATH("apps"),
[ArchiveTabInternal] = STORAGE_INT_PATH_PREFIX, [ArchiveTabInternal] = STORAGE_INT_PATH_PREFIX,
[ArchiveTabBrowser] = STORAGE_ANY_PATH_PREFIX, [ArchiveTabBrowser] = STORAGE_EXT_PATH_PREFIX,
}; };
static const char* known_ext[] = { static const char* known_ext[] = {

View File

@ -478,7 +478,7 @@ void subghz_cli_command_rx_raw(Cli* cli, FuriString* args, void* context) {
void subghz_cli_command_decode_raw(Cli* cli, FuriString* args, void* context) { void subghz_cli_command_decode_raw(Cli* cli, FuriString* args, void* context) {
UNUSED(context); UNUSED(context);
FuriString* file_name = furi_string_alloc(); FuriString* file_name = furi_string_alloc();
furi_string_set(file_name, ANY_PATH("subghz/test.sub")); furi_string_set(file_name, EXT_PATH("subghz/test.sub"));
Storage* storage = furi_record_open(RECORD_STORAGE); Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage); FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);

View File

@ -6,8 +6,8 @@
#define TAG "DesktopSettings" #define TAG "DesktopSettings"
#define DESKTOP_SETTINGS_VER_10 (10) #define DESKTOP_SETTINGS_VER_13 (13)
#define DESKTOP_SETTINGS_VER (11) #define DESKTOP_SETTINGS_VER (14)
#define DESKTOP_SETTINGS_PATH INT_PATH(DESKTOP_SETTINGS_FILE_NAME) #define DESKTOP_SETTINGS_PATH INT_PATH(DESKTOP_SETTINGS_FILE_NAME)
#define DESKTOP_SETTINGS_MAGIC (0x17) #define DESKTOP_SETTINGS_MAGIC (0x17)
@ -15,10 +15,10 @@
typedef struct { typedef struct {
uint8_t reserved[11]; uint8_t reserved[11];
DesktopSettings settings; DesktopSettings settings;
} DesktopSettingsV10; } DesktopSettingsV13;
// Actual size of DesktopSettings v10 // Actual size of DesktopSettings v13
static_assert(sizeof(DesktopSettingsV10) == 1044); //static_assert(sizeof(DesktopSettingsV13) == 1234);
void desktop_settings_load(DesktopSettings* settings) { void desktop_settings_load(DesktopSettings* settings) {
furi_assert(settings); furi_assert(settings);
@ -37,21 +37,21 @@ void desktop_settings_load(DesktopSettings* settings) {
DESKTOP_SETTINGS_MAGIC, DESKTOP_SETTINGS_MAGIC,
DESKTOP_SETTINGS_VER); DESKTOP_SETTINGS_VER);
} else if(version == DESKTOP_SETTINGS_VER_10) { } else if(version == DESKTOP_SETTINGS_VER_13) {
DesktopSettingsV10* settings_v10 = malloc(sizeof(DesktopSettingsV10)); DesktopSettingsV13* settings_v13 = malloc(sizeof(DesktopSettingsV13));
success = saved_struct_load( success = saved_struct_load(
DESKTOP_SETTINGS_PATH, DESKTOP_SETTINGS_PATH,
settings_v10, settings_v13,
sizeof(DesktopSettingsV10), sizeof(DesktopSettingsV13),
DESKTOP_SETTINGS_MAGIC, DESKTOP_SETTINGS_MAGIC,
DESKTOP_SETTINGS_VER_10); DESKTOP_SETTINGS_VER_13);
if(success) { if(success) {
*settings = settings_v10->settings; *settings = settings_v13->settings;
} }
free(settings_v10); free(settings_v13);
} }
} while(false); } while(false);

View File

@ -2,34 +2,6 @@
#include <stdint.h> #include <stdint.h>
#define DESKTOP_SETTINGS_VER (13)
#define DESKTOP_SETTINGS_PATH INT_PATH(DESKTOP_SETTINGS_FILE_NAME)
#define DESKTOP_SETTINGS_MAGIC (0x17)
#define PIN_MAX_LENGTH 12
#define DESKTOP_SETTINGS_RUN_PIN_SETUP_ARG "run_pin_setup"
#define DESKTOP_SETTINGS_SAVE(x) \
saved_struct_save( \
DESKTOP_SETTINGS_PATH, \
(x), \
sizeof(DesktopSettings), \
DESKTOP_SETTINGS_MAGIC, \
DESKTOP_SETTINGS_VER)
#define DESKTOP_SETTINGS_LOAD(x) \
saved_struct_load( \
DESKTOP_SETTINGS_PATH, \
(x), \
sizeof(DesktopSettings), \
DESKTOP_SETTINGS_MAGIC, \
DESKTOP_SETTINGS_VER)
#define MAX_PIN_SIZE 10
#define MIN_PIN_SIZE 4
#define MAX_APP_LENGTH 128
#define DISPLAY_BATTERY_BAR 0 #define DISPLAY_BATTERY_BAR 0
#define DISPLAY_BATTERY_PERCENT 1 #define DISPLAY_BATTERY_PERCENT 1
#define DISPLAY_BATTERY_INVERTED_PERCENT 2 #define DISPLAY_BATTERY_INVERTED_PERCENT 2
@ -47,14 +19,14 @@ typedef enum {
} FavoriteAppShortcut; } FavoriteAppShortcut;
typedef enum { typedef enum {
DummyAppLeft = 0, DummyAppLeftShort,
DummyAppLeftLong, DummyAppLeftLong,
DummyAppRight, DummyAppRightShort,
DummyAppRightLong, DummyAppRightLong,
DummyAppUpLong, DummyAppUpLong,
DummyAppDown, DummyAppDownShort,
DummyAppDownLong, DummyAppDownLong,
DummyAppOk, DummyAppOkShort,
DummyAppOkLong, DummyAppOkLong,
DummyAppNumber, DummyAppNumber,

View File

@ -190,7 +190,7 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
desktop, &desktop->settings.favorite_apps[FavoriteAppRightShort]); desktop, &desktop->settings.favorite_apps[FavoriteAppRightShort]);
} else { } else {
desktop_scene_main_open_app_or_profile( desktop_scene_main_open_app_or_profile(
desktop, &desktop->settings.dummy_apps[DummyAppRight]); desktop, &desktop->settings.dummy_apps[DummyAppRightShort]);
} }
} }
consumed = true; consumed = true;
@ -198,15 +198,15 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
case DesktopDummyEventOpenLeft: case DesktopDummyEventOpenLeft:
desktop_scene_main_open_app_or_profile( desktop_scene_main_open_app_or_profile(
desktop, &desktop->settings.dummy_apps[DummyAppLeft]); desktop, &desktop->settings.dummy_apps[DummyAppLeftShort]);
break; break;
case DesktopDummyEventOpenDown: case DesktopDummyEventOpenDown:
desktop_scene_main_open_app_or_profile( desktop_scene_main_open_app_or_profile(
desktop, &desktop->settings.dummy_apps[DummyAppDown]); desktop, &desktop->settings.dummy_apps[DummyAppDownShort]);
break; break;
case DesktopDummyEventOpenOk: case DesktopDummyEventOpenOk:
desktop_scene_main_open_app_or_profile( desktop_scene_main_open_app_or_profile(
desktop, &desktop->settings.dummy_apps[DummyAppOk]); desktop, &desktop->settings.dummy_apps[DummyAppOkShort]);
break; break;
case DesktopDummyEventOpenUpLong: case DesktopDummyEventOpenUpLong:
if(!desktop_scene_main_check_none( if(!desktop_scene_main_check_none(

View File

@ -1,5 +1,4 @@
#include "expansion.h" #include "expansion.h"
#include "expansion_i.h"
#include <furi_hal_serial_control.h> #include <furi_hal_serial_control.h>
@ -19,7 +18,6 @@ typedef enum {
ExpansionStateDisabled, ExpansionStateDisabled,
ExpansionStateEnabled, ExpansionStateEnabled,
ExpansionStateRunning, ExpansionStateRunning,
ExpansionStateConnectionEstablished,
} ExpansionState; } ExpansionState;
typedef enum { typedef enum {
@ -29,15 +27,10 @@ typedef enum {
ExpansionMessageTypeReloadSettings, ExpansionMessageTypeReloadSettings,
ExpansionMessageTypeModuleConnected, ExpansionMessageTypeModuleConnected,
ExpansionMessageTypeModuleDisconnected, ExpansionMessageTypeModuleDisconnected,
ExpansionMessageTypeConnectionEstablished,
ExpansionMessageTypeIsConnected,
} ExpansionMessageType; } ExpansionMessageType;
typedef union { typedef union {
union { FuriHalSerialId serial_id;
FuriHalSerialId serial_id;
bool* is_connected;
};
} ExpansionMessageData; } ExpansionMessageData;
typedef struct { typedef struct {
@ -52,8 +45,6 @@ struct Expansion {
FuriHalSerialId serial_id; FuriHalSerialId serial_id;
ExpansionWorker* worker; ExpansionWorker* worker;
ExpansionState state; ExpansionState state;
ExpansionSettings settings;
}; };
static const char* const expansion_uart_names[] = { static const char* const expansion_uart_names[] = {
@ -76,21 +67,13 @@ static void expansion_detect_callback(void* context) {
UNUSED(status); UNUSED(status);
} }
static void expansion_worker_callback(void* context, ExpansionWorkerCallbackReason reason) { static void expansion_worker_callback(void* context) {
furi_assert(context); furi_assert(context);
Expansion* instance = context; Expansion* instance = context;
ExpansionMessage message; ExpansionMessage message = {
switch(reason) { .type = ExpansionMessageTypeModuleDisconnected,
case ExpansionWorkerCallbackReasonExit: .api_lock = NULL, // Not locking the API here to avoid a deadlock
message.type = ExpansionMessageTypeModuleDisconnected;
message.api_lock = NULL; // Not locking the API here to avoid a deadlock
break;
case ExpansionWorkerCallbackReasonConnected:
message.type = ExpansionMessageTypeConnectionEstablished;
message.api_lock = api_lock_alloc_locked();
break;
}; };
const FuriStatus status = furi_message_queue_put(instance->queue, &message, FuriWaitForever); const FuriStatus status = furi_message_queue_put(instance->queue, &message, FuriWaitForever);
@ -110,7 +93,7 @@ static void
if(settings.uart_index < FuriHalSerialIdMax) { if(settings.uart_index < FuriHalSerialIdMax) {
instance->state = ExpansionStateEnabled; instance->state = ExpansionStateEnabled;
instance->serial_id = instance->settings.uart_index; instance->serial_id = settings.uart_index;
furi_hal_serial_control_set_expansion_callback( furi_hal_serial_control_set_expansion_callback(
instance->serial_id, expansion_detect_callback, instance); instance->serial_id, expansion_detect_callback, instance);
@ -123,9 +106,7 @@ static void
UNUSED(data); UNUSED(data);
if(instance->state == ExpansionStateDisabled) { if(instance->state == ExpansionStateDisabled) {
return; return;
} else if( } else if(instance->state == ExpansionStateRunning) {
instance->state == ExpansionStateRunning ||
instance->state == ExpansionStateConnectionEstablished) {
expansion_worker_stop(instance->worker); expansion_worker_stop(instance->worker);
expansion_worker_free(instance->worker); expansion_worker_free(instance->worker);
} else { } else {
@ -201,8 +182,7 @@ static void expansion_control_handler_module_disconnected(
Expansion* instance, Expansion* instance,
const ExpansionMessageData* data) { const ExpansionMessageData* data) {
UNUSED(data); UNUSED(data);
if(instance->state != ExpansionStateRunning && if(instance->state != ExpansionStateRunning) {
instance->state != ExpansionStateConnectionEstablished) {
return; return;
} }
@ -212,23 +192,6 @@ static void expansion_control_handler_module_disconnected(
instance->serial_id, expansion_detect_callback, instance); instance->serial_id, expansion_detect_callback, instance);
} }
static void expansion_control_handler_connection_established(
Expansion* instance,
const ExpansionMessageData* data) {
UNUSED(data);
if(instance->state != ExpansionStateRunning &&
instance->state != ExpansionStateConnectionEstablished) {
return;
}
instance->state = ExpansionStateConnectionEstablished;
}
static void
expansion_control_handler_is_connected(Expansion* instance, const ExpansionMessageData* data) {
*data->is_connected = instance->state == ExpansionStateConnectionEstablished;
}
typedef void (*ExpansionControlHandler)(Expansion*, const ExpansionMessageData*); typedef void (*ExpansionControlHandler)(Expansion*, const ExpansionMessageData*);
static const ExpansionControlHandler expansion_control_handlers[] = { static const ExpansionControlHandler expansion_control_handlers[] = {
@ -238,8 +201,6 @@ static const ExpansionControlHandler expansion_control_handlers[] = {
[ExpansionMessageTypeReloadSettings] = expansion_control_handler_reload_settings, [ExpansionMessageTypeReloadSettings] = expansion_control_handler_reload_settings,
[ExpansionMessageTypeModuleConnected] = expansion_control_handler_module_connected, [ExpansionMessageTypeModuleConnected] = expansion_control_handler_module_connected,
[ExpansionMessageTypeModuleDisconnected] = expansion_control_handler_module_disconnected, [ExpansionMessageTypeModuleDisconnected] = expansion_control_handler_module_disconnected,
[ExpansionMessageTypeConnectionEstablished] = expansion_control_handler_connection_established,
[ExpansionMessageTypeIsConnected] = expansion_control_handler_is_connected,
}; };
static int32_t expansion_control(void* context) { static int32_t expansion_control(void* context) {
@ -334,22 +295,6 @@ void expansion_disable(Expansion* instance) {
api_lock_wait_unlock_and_free(message.api_lock); api_lock_wait_unlock_and_free(message.api_lock);
} }
bool expansion_is_connected(Expansion* instance) {
furi_check(instance);
bool is_connected;
ExpansionMessage message = {
.type = ExpansionMessageTypeIsConnected,
.data.is_connected = &is_connected,
.api_lock = api_lock_alloc_locked(),
};
furi_message_queue_put(instance->queue, &message, FuriWaitForever);
api_lock_wait_unlock_and_free(message.api_lock);
return is_connected;
}
void expansion_set_listen_serial(Expansion* instance, FuriHalSerialId serial_id) { void expansion_set_listen_serial(Expansion* instance, FuriHalSerialId serial_id) {
furi_check(instance); furi_check(instance);
furi_check(serial_id < FuriHalSerialIdMax); furi_check(serial_id < FuriHalSerialIdMax);
@ -363,7 +308,3 @@ void expansion_set_listen_serial(Expansion* instance, FuriHalSerialId serial_id)
furi_message_queue_put(instance->queue, &message, FuriWaitForever); furi_message_queue_put(instance->queue, &message, FuriWaitForever);
api_lock_wait_unlock_and_free(message.api_lock); api_lock_wait_unlock_and_free(message.api_lock);
} }
ExpansionSettings* expansion_get_settings(Expansion* instance) {
return &instance->settings;
}

View File

@ -50,15 +50,6 @@ void expansion_enable(Expansion* instance);
*/ */
void expansion_disable(Expansion* instance); void expansion_disable(Expansion* instance);
/**
* @brief Check if an expansion module is connected.
*
* @param[in,out] instance pointer to the Expansion instance.
*
* @returns true if the module is connected and initialized, false otherwise.
*/
bool expansion_is_connected(Expansion* instance);
/** /**
* @brief Enable support for expansion modules on designated serial port. * @brief Enable support for expansion modules on designated serial port.
* *

View File

@ -1,6 +0,0 @@
#pragma once
#include "expansion_settings.h"
#include "expansion.h"
ExpansionSettings* expansion_get_settings(Expansion* instance);

View File

@ -2,7 +2,6 @@
#include <storage/storage.h> #include <storage/storage.h>
#include <toolbox/saved_struct.h> #include <toolbox/saved_struct.h>
#include <furi_hal_serial.h>
#include "expansion_settings_filename.h" #include "expansion_settings_filename.h"

View File

@ -223,7 +223,6 @@ static bool expansion_worker_handle_state_handshake(
if(furi_hal_serial_is_baud_rate_supported(instance->serial_handle, baud_rate)) { if(furi_hal_serial_is_baud_rate_supported(instance->serial_handle, baud_rate)) {
instance->state = ExpansionWorkerStateConnected; instance->state = ExpansionWorkerStateConnected;
instance->callback(instance->cb_context, ExpansionWorkerCallbackReasonConnected);
// Send response at previous baud rate // Send response at previous baud rate
if(!expansion_worker_send_status_response(instance, ExpansionFrameErrorNone)) break; if(!expansion_worker_send_status_response(instance, ExpansionFrameErrorNone)) break;
furi_hal_serial_set_br(instance->serial_handle, baud_rate); furi_hal_serial_set_br(instance->serial_handle, baud_rate);
@ -352,7 +351,7 @@ static int32_t expansion_worker(void* context) {
// Do not invoke worker callback on user-requested exit // Do not invoke worker callback on user-requested exit
if((instance->exit_reason != ExpansionWorkerExitReasonUser) && (instance->callback != NULL)) { if((instance->exit_reason != ExpansionWorkerExitReasonUser) && (instance->callback != NULL)) {
instance->callback(instance->cb_context, ExpansionWorkerCallbackReasonExit); instance->callback(instance->cb_context);
} }
return 0; return 0;

View File

@ -17,20 +17,14 @@
*/ */
typedef struct ExpansionWorker ExpansionWorker; typedef struct ExpansionWorker ExpansionWorker;
typedef enum {
ExpansionWorkerCallbackReasonExit,
ExpansionWorkerCallbackReasonConnected,
} ExpansionWorkerCallbackReason;
/** /**
* @brief Worker callback type. * @brief Worker callback type.
* *
* @see expansion_worker_set_callback() * @see expansion_worker_set_callback()
* *
* @param[in,out] context pointer to a user-defined object. * @param[in,out] context pointer to a user-defined object.
* @param[in] reason reason for the callback.
*/ */
typedef void (*ExpansionWorkerCallback)(void* context, ExpansionWorkerCallbackReason reason); typedef void (*ExpansionWorkerCallback)(void* context);
/** /**
* @brief Create an expansion worker instance. * @brief Create an expansion worker instance.

View File

@ -378,12 +378,8 @@ static void power_check_battery_level_change(Power* power) {
void power_trigger_ui_update(Power* power) { void power_trigger_ui_update(Power* power) {
DesktopSettings* settings = malloc(sizeof(DesktopSettings)); DesktopSettings* settings = malloc(sizeof(DesktopSettings));
bool is_loaded = DESKTOP_SETTINGS_LOAD(settings); desktop_settings_load(settings);
if(is_loaded) { power->displayBatteryPercentage = settings->displayBatteryPercentage;
power->displayBatteryPercentage = settings->displayBatteryPercentage;
} else {
power->displayBatteryPercentage = DISPLAY_BATTERY_BAR;
}
free(settings); free(settings);
view_port_update(power->battery_view_port); view_port_update(power->battery_view_port);
} }
@ -403,7 +399,7 @@ int32_t power_srv(void* p) {
furi_record_create(RECORD_POWER, power); furi_record_create(RECORD_POWER, power);
DesktopSettings* settings = malloc(sizeof(DesktopSettings)); DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings); desktop_settings_load(settings);
power->displayBatteryPercentage = settings->displayBatteryPercentage; power->displayBatteryPercentage = settings->displayBatteryPercentage;
free(settings); free(settings);

View File

@ -1,10 +0,0 @@
App(
appid="region",
name="RegionSrv",
apptype=FlipperAppType.STARTUP,
targets=["f7"],
entry_point="region_on_system_start",
cdefines=["SRV_REGION"],
requires=["storage"],
order=170,
)

View File

@ -1,147 +0,0 @@
#include <furi_hal_region.h>
#include <furi.h>
#include <storage/storage.h>
#include <flipper.pb.h>
#include <pb_decode.h>
#define TAG "RegionSrv"
#define SUBGHZ_REGION_FILENAME INT_PATH(".region_data")
static bool region_istream_read(pb_istream_t* istream, pb_byte_t* buf, size_t count) {
File* file = istream->state;
size_t ret = storage_file_read(file, buf, count);
return count == ret;
}
static bool region_istream_decode_band(pb_istream_t* stream, const pb_field_t* field, void** arg) {
UNUSED(field);
FuriHalRegion* region = *arg;
PB_Region_Band band = {0};
if(!pb_decode(stream, PB_Region_Band_fields, &band)) {
FURI_LOG_E(TAG, "PB Region band decode error: %s", PB_GET_ERROR(stream));
return false;
}
region->bands_count += 1;
region = realloc( //-V701
region,
sizeof(FuriHalRegion) + sizeof(FuriHalRegionBand) * region->bands_count);
size_t pos = region->bands_count - 1;
region->bands[pos].start = band.start;
region->bands[pos].end = band.end;
region->bands[pos].power_limit = band.power_limit;
region->bands[pos].duty_cycle = band.duty_cycle;
*arg = region;
FURI_LOG_I(
TAG,
"Add allowed band: start %luHz, stop %luHz, power_limit %ddBm, duty_cycle %u%%",
band.start,
band.end,
band.power_limit,
band.duty_cycle);
return true;
}
static int32_t region_load_file(void* context) {
UNUSED(context);
Storage* storage = furi_record_open(RECORD_STORAGE);
File* file = storage_file_alloc(storage);
PB_Region pb_region = {0};
pb_region.bands.funcs.decode = region_istream_decode_band;
do {
FileInfo fileinfo = {0};
if(storage_common_stat(storage, SUBGHZ_REGION_FILENAME, &fileinfo) != FSE_OK ||
fileinfo.size == 0) {
FURI_LOG_W(TAG, "Region file missing or empty");
break;
} else if(!storage_file_open(file, SUBGHZ_REGION_FILENAME, FSAM_READ, FSOM_OPEN_EXISTING)) {
FURI_LOG_E(TAG, "Failed to open region file");
break;
}
pb_istream_t istream = {
.callback = region_istream_read,
.state = file,
.errmsg = NULL,
.bytes_left = fileinfo.size,
};
pb_region.bands.arg = malloc(sizeof(FuriHalRegion));
if(!pb_decode(&istream, PB_Region_fields, &pb_region)) {
FURI_LOG_E(TAG, "Failed to decode region file");
free(pb_region.bands.arg);
break;
}
FuriHalRegion* region = pb_region.bands.arg;
memcpy(
region->country_code,
pb_region.country_code->bytes,
MIN(pb_region.country_code->size, sizeof(region->country_code) - 1));
furi_hal_region_set(region);
FURI_LOG_I(TAG, "Dynamic region set: %s", region->country_code);
} while(0);
pb_release(PB_Region_fields, &pb_region);
storage_file_free(file);
furi_record_close(RECORD_STORAGE);
return 0;
}
static void region_loader_pending_callback(void* context, uint32_t arg) {
UNUSED(arg);
FuriThread* loader = context;
furi_thread_join(loader);
furi_thread_free(loader);
}
static void region_loader_state_callback(FuriThreadState state, void* context) {
UNUSED(context);
if(state == FuriThreadStateStopped) {
furi_timer_pending_callback(region_loader_pending_callback, furi_thread_get_current(), 0);
}
}
static void region_storage_callback(const void* message, void* context) {
UNUSED(context);
const StorageEvent* event = message;
if(event->type == StorageEventTypeCardMount) {
FuriThread* loader = furi_thread_alloc_ex(NULL, 2048, region_load_file, NULL);
furi_thread_set_state_callback(loader, region_loader_state_callback);
furi_thread_start(loader);
}
}
int32_t region_on_system_start(void* p) {
UNUSED(p);
Storage* storage = furi_record_open(RECORD_STORAGE);
furi_pubsub_subscribe(storage_get_pubsub(storage), region_storage_callback, NULL);
if(storage_sd_status(storage) != FSE_OK) {
FURI_LOG_D(TAG, "SD Card not ready, skipping dynamic region");
return 0;
}
region_load_file(NULL);
return 0;
}

View File

@ -15,6 +15,8 @@
#include "views/desktop_settings_view_pin_setup_howto.h" #include "views/desktop_settings_view_pin_setup_howto.h"
#include "views/desktop_settings_view_pin_setup_howto2.h" #include "views/desktop_settings_view_pin_setup_howto2.h"
#include <furi_hal_version.h>
typedef enum { typedef enum {
DesktopSettingsAppViewMenu, DesktopSettingsAppViewMenu,
DesktopSettingsAppViewVarItemList, DesktopSettingsAppViewVarItemList,

View File

@ -221,6 +221,5 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e
void desktop_settings_scene_favorite_on_exit(void* context) { void desktop_settings_scene_favorite_on_exit(void* context) {
DesktopSettingsApp* app = context; DesktopSettingsApp* app = context;
DESKTOP_SETTINGS_SAVE(&app->settings);
submenu_reset(app->submenu); submenu_reset(app->submenu);
} }

View File

@ -215,7 +215,7 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even
scene_manager_set_scene_state( scene_manager_set_scene_state(
app->scene_manager, app->scene_manager,
DesktopSettingsAppSceneFavorite, DesktopSettingsAppSceneFavorite,
SCENE_STATE_SET_DUMMY_APP | DummyAppLeft); SCENE_STATE_SET_DUMMY_APP | DummyAppLeftShort);
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite); scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
break; break;
case DesktopSettingsDummyLeftLong: case DesktopSettingsDummyLeftLong:
@ -229,7 +229,7 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even
scene_manager_set_scene_state( scene_manager_set_scene_state(
app->scene_manager, app->scene_manager,
DesktopSettingsAppSceneFavorite, DesktopSettingsAppSceneFavorite,
SCENE_STATE_SET_DUMMY_APP | DummyAppRight); SCENE_STATE_SET_DUMMY_APP | DummyAppRightShort);
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite); scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
break; break;
case DesktopSettingsDummyRightLong: case DesktopSettingsDummyRightLong:
@ -250,7 +250,7 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even
scene_manager_set_scene_state( scene_manager_set_scene_state(
app->scene_manager, app->scene_manager,
DesktopSettingsAppSceneFavorite, DesktopSettingsAppSceneFavorite,
SCENE_STATE_SET_DUMMY_APP | DummyAppDown); SCENE_STATE_SET_DUMMY_APP | DummyAppDownShort);
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite); scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
break; break;
case DesktopSettingsDummyDownLong: case DesktopSettingsDummyDownLong:
@ -264,7 +264,7 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even
scene_manager_set_scene_state( scene_manager_set_scene_state(
app->scene_manager, app->scene_manager,
DesktopSettingsAppSceneFavorite, DesktopSettingsAppSceneFavorite,
SCENE_STATE_SET_DUMMY_APP | DummyAppOk); SCENE_STATE_SET_DUMMY_APP | DummyAppOkShort);
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite); scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
break; break;
case DesktopSettingsDummyOkLong: case DesktopSettingsDummyOkLong:
@ -286,7 +286,7 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even
void desktop_settings_scene_start_on_exit(void* context) { void desktop_settings_scene_start_on_exit(void* context) {
DesktopSettingsApp* app = context; DesktopSettingsApp* app = context;
variable_item_list_reset(app->variable_item_list); variable_item_list_reset(app->variable_item_list);
DESKTOP_SETTINGS_SAVE(&app->settings); desktop_settings_save(&app->settings);
// Trigger UI update in case we changed battery layout // Trigger UI update in case we changed battery layout
Power* power = furi_record_open(RECORD_POWER); Power* power = furi_record_open(RECORD_POWER);

View File

@ -10,7 +10,7 @@ static void expansion_settings_app_uart_changed(VariableItem* item) {
ExpansionSettingsApp* app = variable_item_get_context(item); ExpansionSettingsApp* app = variable_item_get_context(item);
const uint8_t index = variable_item_get_current_value_index(item); const uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, expansion_uart_text[index]); variable_item_set_current_value_text(item, expansion_uart_text[index]);
app->settings->uart_index = index; app->settings.uart_index = index;
if(index < FuriHalSerialIdMax) { if(index < FuriHalSerialIdMax) {
expansion_set_listen_serial(app->expansion, index); expansion_set_listen_serial(app->expansion, index);
@ -31,10 +31,8 @@ static ExpansionSettingsApp* expansion_settings_app_alloc(void) {
app->gui = furi_record_open(RECORD_GUI); app->gui = furi_record_open(RECORD_GUI);
app->expansion = furi_record_open(RECORD_EXPANSION); app->expansion = furi_record_open(RECORD_EXPANSION);
app->settings = expansion_get_settings(app->expansion);
app->view_dispatcher = view_dispatcher_alloc(); app->view_dispatcher = view_dispatcher_alloc();
view_dispatcher_enable_queue(app->view_dispatcher);
view_dispatcher_set_event_callback_context(app->view_dispatcher, app); view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
@ -50,7 +48,7 @@ static ExpansionSettingsApp* expansion_settings_app_alloc(void) {
COUNT_OF(expansion_uart_text), COUNT_OF(expansion_uart_text),
expansion_settings_app_uart_changed, expansion_settings_app_uart_changed,
app); app);
value_index = app->settings->uart_index; value_index = app->settings.uart_index;
variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, expansion_uart_text[value_index]); variable_item_set_current_value_text(item, expansion_uart_text[value_index]);
@ -69,7 +67,7 @@ static ExpansionSettingsApp* expansion_settings_app_alloc(void) {
static void expansion_settings_app_free(ExpansionSettingsApp* app) { static void expansion_settings_app_free(ExpansionSettingsApp* app) {
furi_assert(app); furi_assert(app);
expansion_settings_save(app->settings); expansion_settings_save(&app->settings);
view_dispatcher_remove_view(app->view_dispatcher, ExpansionSettingsViewVarItemList); view_dispatcher_remove_view(app->view_dispatcher, ExpansionSettingsViewVarItemList);
variable_item_list_free(app->var_item_list); variable_item_list_free(app->var_item_list);

View File

@ -8,7 +8,6 @@
#include <gui/modules/variable_item_list.h> #include <gui/modules/variable_item_list.h>
#include <expansion/expansion.h> #include <expansion/expansion.h>
#include <expansion/expansion_i.h>
#include <expansion/expansion_settings.h> #include <expansion/expansion_settings.h>
typedef struct { typedef struct {
@ -16,7 +15,7 @@ typedef struct {
ViewDispatcher* view_dispatcher; ViewDispatcher* view_dispatcher;
VariableItemList* var_item_list; VariableItemList* var_item_list;
Expansion* expansion; Expansion* expansion;
ExpansionSettings* settings; ExpansionSettings settings;
} ExpansionSettingsApp; } ExpansionSettingsApp;
typedef enum { typedef enum {

View File

@ -23,8 +23,9 @@ void subghz_device_registry_init(void) {
firmware_api_interface); firmware_api_interface);
//TODO FL-3556: fix path to plugins //TODO FL-3556: fix path to plugins
//if(plugin_manager_load_all(subghz_device->manager, APP_DATA_PATH("plugins")) !=
//
if(plugin_manager_load_all(subghz_device->manager, EXT_PATH("apps_data/subghz/plugins")) != if(plugin_manager_load_all(subghz_device->manager, EXT_PATH("apps_data/subghz/plugins")) !=
//if(plugin_manager_load_all(subghz_device->manager, APP_DATA_PATH("plugins")) !=
PluginManagerErrorNone) { PluginManagerErrorNone) {
FURI_LOG_E(TAG, "Failed to load all libs"); FURI_LOG_E(TAG, "Failed to load all libs");
} }

View File

@ -1030,7 +1030,6 @@ Function,-,exp2f,float,float
Function,-,exp2l,long double,long double Function,-,exp2l,long double,long double
Function,+,expansion_disable,void,Expansion* Function,+,expansion_disable,void,Expansion*
Function,+,expansion_enable,void,Expansion* Function,+,expansion_enable,void,Expansion*
Function,+,expansion_is_connected,_Bool,Expansion*
Function,+,expansion_set_listen_serial,void,"Expansion*, FuriHalSerialId" Function,+,expansion_set_listen_serial,void,"Expansion*, FuriHalSerialId"
Function,-,expf,float,float Function,-,expf,float,float
Function,-,expl,long double,long double Function,-,expl,long double,long double
@ -1995,8 +1994,8 @@ Function,+,ibutton_protocols_render_data,void,"iButtonProtocols*, const iButtonK
Function,+,ibutton_protocols_render_error,void,"iButtonProtocols*, const iButtonKey*, FuriString*" Function,+,ibutton_protocols_render_error,void,"iButtonProtocols*, const iButtonKey*, FuriString*"
Function,+,ibutton_protocols_render_uid,void,"iButtonProtocols*, const iButtonKey*, FuriString*" Function,+,ibutton_protocols_render_uid,void,"iButtonProtocols*, const iButtonKey*, FuriString*"
Function,+,ibutton_protocols_save,_Bool,"iButtonProtocols*, const iButtonKey*, const char*" Function,+,ibutton_protocols_save,_Bool,"iButtonProtocols*, const iButtonKey*, const char*"
Function,+,ibutton_protocols_write_id,_Bool,"iButtonProtocols*, iButtonKey*"
Function,+,ibutton_protocols_write_copy,_Bool,"iButtonProtocols*, iButtonKey*" Function,+,ibutton_protocols_write_copy,_Bool,"iButtonProtocols*, iButtonKey*"
Function,+,ibutton_protocols_write_id,_Bool,"iButtonProtocols*, iButtonKey*"
Function,+,ibutton_worker_alloc,iButtonWorker*,iButtonProtocols* Function,+,ibutton_worker_alloc,iButtonWorker*,iButtonProtocols*
Function,+,ibutton_worker_emulate_set_callback,void,"iButtonWorker*, iButtonWorkerEmulateCallback, void*" Function,+,ibutton_worker_emulate_set_callback,void,"iButtonWorker*, iButtonWorkerEmulateCallback, void*"
Function,+,ibutton_worker_emulate_start,void,"iButtonWorker*, iButtonKey*" Function,+,ibutton_worker_emulate_start,void,"iButtonWorker*, iButtonKey*"
@ -2006,8 +2005,8 @@ Function,+,ibutton_worker_read_start,void,"iButtonWorker*, iButtonKey*"
Function,+,ibutton_worker_start_thread,void,iButtonWorker* Function,+,ibutton_worker_start_thread,void,iButtonWorker*
Function,+,ibutton_worker_stop,void,iButtonWorker* Function,+,ibutton_worker_stop,void,iButtonWorker*
Function,+,ibutton_worker_stop_thread,void,iButtonWorker* Function,+,ibutton_worker_stop_thread,void,iButtonWorker*
Function,+,ibutton_worker_write_id_start,void,"iButtonWorker*, iButtonKey*"
Function,+,ibutton_worker_write_copy_start,void,"iButtonWorker*, iButtonKey*" Function,+,ibutton_worker_write_copy_start,void,"iButtonWorker*, iButtonKey*"
Function,+,ibutton_worker_write_id_start,void,"iButtonWorker*, iButtonKey*"
Function,+,ibutton_worker_write_set_callback,void,"iButtonWorker*, iButtonWorkerWriteCallback, void*" Function,+,ibutton_worker_write_set_callback,void,"iButtonWorker*, iButtonWorkerWriteCallback, void*"
Function,+,icon_animation_alloc,IconAnimation*,const Icon* Function,+,icon_animation_alloc,IconAnimation*,const Icon*
Function,+,icon_animation_free,void,IconAnimation* Function,+,icon_animation_free,void,IconAnimation*

1 entry status name type params
1030 Function - exp2l long double long double
1031 Function + expansion_disable void Expansion*
1032 Function + expansion_enable void Expansion*
Function + expansion_is_connected _Bool Expansion*
1033 Function + expansion_set_listen_serial void Expansion*, FuriHalSerialId
1034 Function - expf float float
1035 Function - expl long double long double
1994 Function + ibutton_protocols_render_error void iButtonProtocols*, const iButtonKey*, FuriString*
1995 Function + ibutton_protocols_render_uid void iButtonProtocols*, const iButtonKey*, FuriString*
1996 Function + ibutton_protocols_save _Bool iButtonProtocols*, const iButtonKey*, const char*
Function + ibutton_protocols_write_id _Bool iButtonProtocols*, iButtonKey*
1997 Function + ibutton_protocols_write_copy _Bool iButtonProtocols*, iButtonKey*
1998 Function + ibutton_protocols_write_id _Bool iButtonProtocols*, iButtonKey*
1999 Function + ibutton_worker_alloc iButtonWorker* iButtonProtocols*
2000 Function + ibutton_worker_emulate_set_callback void iButtonWorker*, iButtonWorkerEmulateCallback, void*
2001 Function + ibutton_worker_emulate_start void iButtonWorker*, iButtonKey*
2005 Function + ibutton_worker_start_thread void iButtonWorker*
2006 Function + ibutton_worker_stop void iButtonWorker*
2007 Function + ibutton_worker_stop_thread void iButtonWorker*
Function + ibutton_worker_write_id_start void iButtonWorker*, iButtonKey*
2008 Function + ibutton_worker_write_copy_start void iButtonWorker*, iButtonKey*
2009 Function + ibutton_worker_write_id_start void iButtonWorker*, iButtonKey*
2010 Function + ibutton_worker_write_set_callback void iButtonWorker*, iButtonWorkerWriteCallback, void*
2011 Function + icon_animation_alloc IconAnimation* const Icon*
2012 Function + icon_animation_free void IconAnimation*

View File

@ -29,9 +29,10 @@ const FuriHalRegionBand* furi_hal_region_get_band(uint32_t frequency) {
return NULL; return NULL;
} }
for(size_t i = 0; i < region->bands_count; i++) { for(size_t i = 0; i < furi_hal_region->bands_count; i++) {
if(region->bands[i].start <= frequency && region->bands[i].end >= frequency) { if(furi_hal_region->bands[i].start <= frequency &&
return &region->bands[i]; furi_hal_region->bands[i].end >= frequency) {
return &furi_hal_region->bands[i];
} }
} }