mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-23 13:21:44 +03:00
after merge fixes
This commit is contained in:
parent
28272f7a7a
commit
1e5dd001fe
@ -9,17 +9,17 @@
|
||||
|
||||
static const char* tab_default_paths[] = {
|
||||
[ArchiveTabFavorites] = "/app:favorites",
|
||||
[ArchiveTabIButton] = ANY_PATH("ibutton"),
|
||||
[ArchiveTabNFC] = ANY_PATH("nfc"),
|
||||
[ArchiveTabSubGhz] = ANY_PATH("subghz"),
|
||||
[ArchiveTabIButton] = EXT_PATH("ibutton"),
|
||||
[ArchiveTabNFC] = EXT_PATH("nfc"),
|
||||
[ArchiveTabSubGhz] = EXT_PATH("subghz"),
|
||||
[ArchiveTabSubGhzRemote] = EXT_PATH("subghz_remote"),
|
||||
[ArchiveTabLFRFID] = ANY_PATH("lfrfid"),
|
||||
[ArchiveTabInfrared] = ANY_PATH("infrared"),
|
||||
[ArchiveTabBadUsb] = ANY_PATH("badusb"),
|
||||
[ArchiveTabLFRFID] = EXT_PATH("lfrfid"),
|
||||
[ArchiveTabInfrared] = EXT_PATH("infrared"),
|
||||
[ArchiveTabBadUsb] = EXT_PATH("badusb"),
|
||||
[ArchiveTabU2f] = "/app:u2f",
|
||||
[ArchiveTabApplications] = ANY_PATH("apps"),
|
||||
[ArchiveTabApplications] = EXT_PATH("apps"),
|
||||
[ArchiveTabInternal] = STORAGE_INT_PATH_PREFIX,
|
||||
[ArchiveTabBrowser] = STORAGE_ANY_PATH_PREFIX,
|
||||
[ArchiveTabBrowser] = STORAGE_EXT_PATH_PREFIX,
|
||||
};
|
||||
|
||||
static const char* known_ext[] = {
|
||||
|
@ -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) {
|
||||
UNUSED(context);
|
||||
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);
|
||||
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
#define TAG "DesktopSettings"
|
||||
|
||||
#define DESKTOP_SETTINGS_VER_10 (10)
|
||||
#define DESKTOP_SETTINGS_VER (11)
|
||||
#define DESKTOP_SETTINGS_VER_13 (13)
|
||||
#define DESKTOP_SETTINGS_VER (14)
|
||||
|
||||
#define DESKTOP_SETTINGS_PATH INT_PATH(DESKTOP_SETTINGS_FILE_NAME)
|
||||
#define DESKTOP_SETTINGS_MAGIC (0x17)
|
||||
@ -15,10 +15,10 @@
|
||||
typedef struct {
|
||||
uint8_t reserved[11];
|
||||
DesktopSettings settings;
|
||||
} DesktopSettingsV10;
|
||||
} DesktopSettingsV13;
|
||||
|
||||
// Actual size of DesktopSettings v10
|
||||
static_assert(sizeof(DesktopSettingsV10) == 1044);
|
||||
// Actual size of DesktopSettings v13
|
||||
//static_assert(sizeof(DesktopSettingsV13) == 1234);
|
||||
|
||||
void desktop_settings_load(DesktopSettings* settings) {
|
||||
furi_assert(settings);
|
||||
@ -37,21 +37,21 @@ void desktop_settings_load(DesktopSettings* settings) {
|
||||
DESKTOP_SETTINGS_MAGIC,
|
||||
DESKTOP_SETTINGS_VER);
|
||||
|
||||
} else if(version == DESKTOP_SETTINGS_VER_10) {
|
||||
DesktopSettingsV10* settings_v10 = malloc(sizeof(DesktopSettingsV10));
|
||||
} else if(version == DESKTOP_SETTINGS_VER_13) {
|
||||
DesktopSettingsV13* settings_v13 = malloc(sizeof(DesktopSettingsV13));
|
||||
|
||||
success = saved_struct_load(
|
||||
DESKTOP_SETTINGS_PATH,
|
||||
settings_v10,
|
||||
sizeof(DesktopSettingsV10),
|
||||
settings_v13,
|
||||
sizeof(DesktopSettingsV13),
|
||||
DESKTOP_SETTINGS_MAGIC,
|
||||
DESKTOP_SETTINGS_VER_10);
|
||||
DESKTOP_SETTINGS_VER_13);
|
||||
|
||||
if(success) {
|
||||
*settings = settings_v10->settings;
|
||||
*settings = settings_v13->settings;
|
||||
}
|
||||
|
||||
free(settings_v10);
|
||||
free(settings_v13);
|
||||
}
|
||||
|
||||
} while(false);
|
||||
|
@ -2,34 +2,6 @@
|
||||
|
||||
#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_PERCENT 1
|
||||
#define DISPLAY_BATTERY_INVERTED_PERCENT 2
|
||||
@ -47,14 +19,14 @@ typedef enum {
|
||||
} FavoriteAppShortcut;
|
||||
|
||||
typedef enum {
|
||||
DummyAppLeft = 0,
|
||||
DummyAppLeftShort,
|
||||
DummyAppLeftLong,
|
||||
DummyAppRight,
|
||||
DummyAppRightShort,
|
||||
DummyAppRightLong,
|
||||
DummyAppUpLong,
|
||||
DummyAppDown,
|
||||
DummyAppDownShort,
|
||||
DummyAppDownLong,
|
||||
DummyAppOk,
|
||||
DummyAppOkShort,
|
||||
DummyAppOkLong,
|
||||
|
||||
DummyAppNumber,
|
||||
|
@ -190,7 +190,7 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
|
||||
desktop, &desktop->settings.favorite_apps[FavoriteAppRightShort]);
|
||||
} else {
|
||||
desktop_scene_main_open_app_or_profile(
|
||||
desktop, &desktop->settings.dummy_apps[DummyAppRight]);
|
||||
desktop, &desktop->settings.dummy_apps[DummyAppRightShort]);
|
||||
}
|
||||
}
|
||||
consumed = true;
|
||||
@ -198,15 +198,15 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
case DesktopDummyEventOpenLeft:
|
||||
desktop_scene_main_open_app_or_profile(
|
||||
desktop, &desktop->settings.dummy_apps[DummyAppLeft]);
|
||||
desktop, &desktop->settings.dummy_apps[DummyAppLeftShort]);
|
||||
break;
|
||||
case DesktopDummyEventOpenDown:
|
||||
desktop_scene_main_open_app_or_profile(
|
||||
desktop, &desktop->settings.dummy_apps[DummyAppDown]);
|
||||
desktop, &desktop->settings.dummy_apps[DummyAppDownShort]);
|
||||
break;
|
||||
case DesktopDummyEventOpenOk:
|
||||
desktop_scene_main_open_app_or_profile(
|
||||
desktop, &desktop->settings.dummy_apps[DummyAppOk]);
|
||||
desktop, &desktop->settings.dummy_apps[DummyAppOkShort]);
|
||||
break;
|
||||
case DesktopDummyEventOpenUpLong:
|
||||
if(!desktop_scene_main_check_none(
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "expansion.h"
|
||||
#include "expansion_i.h"
|
||||
|
||||
#include <furi_hal_serial_control.h>
|
||||
|
||||
@ -19,7 +18,6 @@ typedef enum {
|
||||
ExpansionStateDisabled,
|
||||
ExpansionStateEnabled,
|
||||
ExpansionStateRunning,
|
||||
ExpansionStateConnectionEstablished,
|
||||
} ExpansionState;
|
||||
|
||||
typedef enum {
|
||||
@ -29,15 +27,10 @@ typedef enum {
|
||||
ExpansionMessageTypeReloadSettings,
|
||||
ExpansionMessageTypeModuleConnected,
|
||||
ExpansionMessageTypeModuleDisconnected,
|
||||
ExpansionMessageTypeConnectionEstablished,
|
||||
ExpansionMessageTypeIsConnected,
|
||||
} ExpansionMessageType;
|
||||
|
||||
typedef union {
|
||||
union {
|
||||
FuriHalSerialId serial_id;
|
||||
bool* is_connected;
|
||||
};
|
||||
FuriHalSerialId serial_id;
|
||||
} ExpansionMessageData;
|
||||
|
||||
typedef struct {
|
||||
@ -52,8 +45,6 @@ struct Expansion {
|
||||
FuriHalSerialId serial_id;
|
||||
ExpansionWorker* worker;
|
||||
ExpansionState state;
|
||||
|
||||
ExpansionSettings settings;
|
||||
};
|
||||
|
||||
static const char* const expansion_uart_names[] = {
|
||||
@ -76,21 +67,13 @@ static void expansion_detect_callback(void* context) {
|
||||
UNUSED(status);
|
||||
}
|
||||
|
||||
static void expansion_worker_callback(void* context, ExpansionWorkerCallbackReason reason) {
|
||||
static void expansion_worker_callback(void* context) {
|
||||
furi_assert(context);
|
||||
Expansion* instance = context;
|
||||
|
||||
ExpansionMessage message;
|
||||
switch(reason) {
|
||||
case ExpansionWorkerCallbackReasonExit:
|
||||
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;
|
||||
ExpansionMessage message = {
|
||||
.type = ExpansionMessageTypeModuleDisconnected,
|
||||
.api_lock = NULL, // Not locking the API here to avoid a deadlock
|
||||
};
|
||||
|
||||
const FuriStatus status = furi_message_queue_put(instance->queue, &message, FuriWaitForever);
|
||||
@ -110,7 +93,7 @@ static void
|
||||
|
||||
if(settings.uart_index < FuriHalSerialIdMax) {
|
||||
instance->state = ExpansionStateEnabled;
|
||||
instance->serial_id = instance->settings.uart_index;
|
||||
instance->serial_id = settings.uart_index;
|
||||
furi_hal_serial_control_set_expansion_callback(
|
||||
instance->serial_id, expansion_detect_callback, instance);
|
||||
|
||||
@ -123,9 +106,7 @@ static void
|
||||
UNUSED(data);
|
||||
if(instance->state == ExpansionStateDisabled) {
|
||||
return;
|
||||
} else if(
|
||||
instance->state == ExpansionStateRunning ||
|
||||
instance->state == ExpansionStateConnectionEstablished) {
|
||||
} else if(instance->state == ExpansionStateRunning) {
|
||||
expansion_worker_stop(instance->worker);
|
||||
expansion_worker_free(instance->worker);
|
||||
} else {
|
||||
@ -201,8 +182,7 @@ static void expansion_control_handler_module_disconnected(
|
||||
Expansion* instance,
|
||||
const ExpansionMessageData* data) {
|
||||
UNUSED(data);
|
||||
if(instance->state != ExpansionStateRunning &&
|
||||
instance->state != ExpansionStateConnectionEstablished) {
|
||||
if(instance->state != ExpansionStateRunning) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -212,23 +192,6 @@ static void expansion_control_handler_module_disconnected(
|
||||
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*);
|
||||
|
||||
static const ExpansionControlHandler expansion_control_handlers[] = {
|
||||
@ -238,8 +201,6 @@ static const ExpansionControlHandler expansion_control_handlers[] = {
|
||||
[ExpansionMessageTypeReloadSettings] = expansion_control_handler_reload_settings,
|
||||
[ExpansionMessageTypeModuleConnected] = expansion_control_handler_module_connected,
|
||||
[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) {
|
||||
@ -334,22 +295,6 @@ void expansion_disable(Expansion* instance) {
|
||||
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) {
|
||||
furi_check(instance);
|
||||
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);
|
||||
api_lock_wait_unlock_and_free(message.api_lock);
|
||||
}
|
||||
|
||||
ExpansionSettings* expansion_get_settings(Expansion* instance) {
|
||||
return &instance->settings;
|
||||
}
|
||||
|
@ -50,15 +50,6 @@ void expansion_enable(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.
|
||||
*
|
||||
|
@ -1,6 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "expansion_settings.h"
|
||||
#include "expansion.h"
|
||||
|
||||
ExpansionSettings* expansion_get_settings(Expansion* instance);
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include <storage/storage.h>
|
||||
#include <toolbox/saved_struct.h>
|
||||
#include <furi_hal_serial.h>
|
||||
|
||||
#include "expansion_settings_filename.h"
|
||||
|
||||
|
@ -223,7 +223,6 @@ static bool expansion_worker_handle_state_handshake(
|
||||
|
||||
if(furi_hal_serial_is_baud_rate_supported(instance->serial_handle, baud_rate)) {
|
||||
instance->state = ExpansionWorkerStateConnected;
|
||||
instance->callback(instance->cb_context, ExpansionWorkerCallbackReasonConnected);
|
||||
// Send response at previous baud rate
|
||||
if(!expansion_worker_send_status_response(instance, ExpansionFrameErrorNone)) break;
|
||||
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
|
||||
if((instance->exit_reason != ExpansionWorkerExitReasonUser) && (instance->callback != NULL)) {
|
||||
instance->callback(instance->cb_context, ExpansionWorkerCallbackReasonExit);
|
||||
instance->callback(instance->cb_context);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -17,20 +17,14 @@
|
||||
*/
|
||||
typedef struct ExpansionWorker ExpansionWorker;
|
||||
|
||||
typedef enum {
|
||||
ExpansionWorkerCallbackReasonExit,
|
||||
ExpansionWorkerCallbackReasonConnected,
|
||||
} ExpansionWorkerCallbackReason;
|
||||
|
||||
/**
|
||||
* @brief Worker callback type.
|
||||
*
|
||||
* @see expansion_worker_set_callback()
|
||||
*
|
||||
* @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.
|
||||
|
@ -378,12 +378,8 @@ static void power_check_battery_level_change(Power* power) {
|
||||
|
||||
void power_trigger_ui_update(Power* power) {
|
||||
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
|
||||
bool is_loaded = DESKTOP_SETTINGS_LOAD(settings);
|
||||
if(is_loaded) {
|
||||
power->displayBatteryPercentage = settings->displayBatteryPercentage;
|
||||
} else {
|
||||
power->displayBatteryPercentage = DISPLAY_BATTERY_BAR;
|
||||
}
|
||||
desktop_settings_load(settings);
|
||||
power->displayBatteryPercentage = settings->displayBatteryPercentage;
|
||||
free(settings);
|
||||
view_port_update(power->battery_view_port);
|
||||
}
|
||||
@ -403,7 +399,7 @@ int32_t power_srv(void* p) {
|
||||
furi_record_create(RECORD_POWER, power);
|
||||
|
||||
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
|
||||
DESKTOP_SETTINGS_LOAD(settings);
|
||||
desktop_settings_load(settings);
|
||||
power->displayBatteryPercentage = settings->displayBatteryPercentage;
|
||||
free(settings);
|
||||
|
||||
|
@ -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,
|
||||
)
|
@ -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;
|
||||
}
|
@ -15,6 +15,8 @@
|
||||
#include "views/desktop_settings_view_pin_setup_howto.h"
|
||||
#include "views/desktop_settings_view_pin_setup_howto2.h"
|
||||
|
||||
#include <furi_hal_version.h>
|
||||
|
||||
typedef enum {
|
||||
DesktopSettingsAppViewMenu,
|
||||
DesktopSettingsAppViewVarItemList,
|
||||
|
@ -221,6 +221,5 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e
|
||||
|
||||
void desktop_settings_scene_favorite_on_exit(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
DESKTOP_SETTINGS_SAVE(&app->settings);
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_DUMMY_APP | DummyAppLeft);
|
||||
SCENE_STATE_SET_DUMMY_APP | DummyAppLeftShort);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
break;
|
||||
case DesktopSettingsDummyLeftLong:
|
||||
@ -229,7 +229,7 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_DUMMY_APP | DummyAppRight);
|
||||
SCENE_STATE_SET_DUMMY_APP | DummyAppRightShort);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
break;
|
||||
case DesktopSettingsDummyRightLong:
|
||||
@ -250,7 +250,7 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_DUMMY_APP | DummyAppDown);
|
||||
SCENE_STATE_SET_DUMMY_APP | DummyAppDownShort);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
break;
|
||||
case DesktopSettingsDummyDownLong:
|
||||
@ -264,7 +264,7 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_DUMMY_APP | DummyAppOk);
|
||||
SCENE_STATE_SET_DUMMY_APP | DummyAppOkShort);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
break;
|
||||
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) {
|
||||
DesktopSettingsApp* app = context;
|
||||
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
|
||||
Power* power = furi_record_open(RECORD_POWER);
|
||||
|
@ -10,7 +10,7 @@ static void expansion_settings_app_uart_changed(VariableItem* item) {
|
||||
ExpansionSettingsApp* app = variable_item_get_context(item);
|
||||
const uint8_t index = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(item, expansion_uart_text[index]);
|
||||
app->settings->uart_index = index;
|
||||
app->settings.uart_index = index;
|
||||
|
||||
if(index < FuriHalSerialIdMax) {
|
||||
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->expansion = furi_record_open(RECORD_EXPANSION);
|
||||
app->settings = expansion_get_settings(app->expansion);
|
||||
|
||||
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_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),
|
||||
expansion_settings_app_uart_changed,
|
||||
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_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) {
|
||||
furi_assert(app);
|
||||
|
||||
expansion_settings_save(app->settings);
|
||||
expansion_settings_save(&app->settings);
|
||||
|
||||
view_dispatcher_remove_view(app->view_dispatcher, ExpansionSettingsViewVarItemList);
|
||||
variable_item_list_free(app->var_item_list);
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
|
||||
#include <expansion/expansion.h>
|
||||
#include <expansion/expansion_i.h>
|
||||
#include <expansion/expansion_settings.h>
|
||||
|
||||
typedef struct {
|
||||
@ -16,7 +15,7 @@ typedef struct {
|
||||
ViewDispatcher* view_dispatcher;
|
||||
VariableItemList* var_item_list;
|
||||
Expansion* expansion;
|
||||
ExpansionSettings* settings;
|
||||
ExpansionSettings settings;
|
||||
} ExpansionSettingsApp;
|
||||
|
||||
typedef enum {
|
||||
|
@ -23,8 +23,9 @@ void subghz_device_registry_init(void) {
|
||||
firmware_api_interface);
|
||||
|
||||
//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, APP_DATA_PATH("plugins")) !=
|
||||
PluginManagerErrorNone) {
|
||||
FURI_LOG_E(TAG, "Failed to load all libs");
|
||||
}
|
||||
|
@ -1030,7 +1030,6 @@ Function,-,exp2f,float,float
|
||||
Function,-,exp2l,long double,long double
|
||||
Function,+,expansion_disable,void,Expansion*
|
||||
Function,+,expansion_enable,void,Expansion*
|
||||
Function,+,expansion_is_connected,_Bool,Expansion*
|
||||
Function,+,expansion_set_listen_serial,void,"Expansion*, FuriHalSerialId"
|
||||
Function,-,expf,float,float
|
||||
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_uid,void,"iButtonProtocols*, const iButtonKey*, FuriString*"
|
||||
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_id,_Bool,"iButtonProtocols*, iButtonKey*"
|
||||
Function,+,ibutton_worker_alloc,iButtonWorker*,iButtonProtocols*
|
||||
Function,+,ibutton_worker_emulate_set_callback,void,"iButtonWorker*, iButtonWorkerEmulateCallback, void*"
|
||||
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_stop,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_id_start,void,"iButtonWorker*, iButtonKey*"
|
||||
Function,+,ibutton_worker_write_set_callback,void,"iButtonWorker*, iButtonWorkerWriteCallback, void*"
|
||||
Function,+,icon_animation_alloc,IconAnimation*,const Icon*
|
||||
Function,+,icon_animation_free,void,IconAnimation*
|
||||
|
|
@ -29,9 +29,10 @@ const FuriHalRegionBand* furi_hal_region_get_band(uint32_t frequency) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < region->bands_count; i++) {
|
||||
if(region->bands[i].start <= frequency && region->bands[i].end >= frequency) {
|
||||
return ®ion->bands[i];
|
||||
for(size_t i = 0; i < furi_hal_region->bands_count; i++) {
|
||||
if(furi_hal_region->bands[i].start <= frequency &&
|
||||
furi_hal_region->bands[i].end >= frequency) {
|
||||
return &furi_hal_region->bands[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user