diff --git a/.vscode/example/launch.json b/.vscode/example/launch.json
index 7cb2542de..f4df96592 100644
--- a/.vscode/example/launch.json
+++ b/.vscode/example/launch.json
@@ -28,13 +28,14 @@
"servertype": "openocd",
"device": "stlink",
"svdFile": "./debug/STM32WB55_CM4.svd",
+ // If you're debugging early in the boot process, before OS scheduler is running,
+ // you have to comment out the following line.
"rtos": "FreeRTOS",
"configFiles": [
"interface/stlink.cfg",
"./debug/stm32wbx.cfg",
],
"postAttachCommands": [
- // "attach 1",
// "compare-sections",
"source debug/flipperapps.py",
// "source debug/FreeRTOS/FreeRTOS.py",
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 00640615d..2c7750c5e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,17 +1,28 @@
### New changes
-* PR: SubGHz new feature -> press Ok in Frequency analyzer to use frequency in Read modes (by @derskythe | PR #77)
-* PR: SubGHz save last settings (frequency and modulation) (by @derskythe | PR #77)
-* Plugins: SubGHz Bruteforcer - add chamberlain 9bit 300mhz, removed unnecessary checks (made it a bit faster), fixed title position & menu text
-* SubGHz: Fix Add Manually item names, Add BETT protocol in add manually
-* Infrared: Update assets (by @Amec0e)
-* OFW: Refactor infrared brute force code
-* OFW: Add formatting to DESfire data dump
+* Add 312.2 MHz to subghz user config
+* PR: Add CAME 12bit 303MHz to SubGHz Bruteforcer (by @derskythe | PR #87)
+* PR: Added norwegian keyboard layout for badusb (by @jd-raymaker | PR #88)
+* Adapted all plugins and other code to new FuriString, fixed archive menu issues with new string type
+* SubGHz: Fix double click after delete scene, fix rename bug
+* Plugins: SubGHz Bruteforcer - Fix wrong max value in BF existing dump
+* API 3.0 -> 3.1 (all previous compiled apps still compatible)
+* SubGHz: proper free of rainbow tables
+* OFW: Show in-app icons & names in archive browser
+* OFW: M*LIB: non-inlined strings, FuriString primitive
+* OFW PR: Remove string_push_uint64 (OFW PR 1832 by Astrrra)
+* OFW PR: updated icon names (OFW PR 1829 by nminaylov)
-#### **DFU files no longer included in releases to avoid issues with wrong manual installation of assets - use .tgz file with qFlipper, or install automatically via web updater or use microSD update package**
+#### [🎲 Download extra apps pack](https://download-directory.github.io/?url=https://github.com/UberGuidoZ/Flipper/tree/main/Applications/Unleashed)
-[- How to install](https://github.com/Eng1n33r/flipperzero-firmware/blob/dev/documentation/HowToInstall.md)
+[-> How to install firmware](https://github.com/Eng1n33r/flipperzero-firmware/blob/dev/documentation/HowToInstall.md)
-[- Download qFlipper 1.2.0 (allows .tgz installation) (official link)](https://update.flipperzero.one/builds/qFlipper/1.2.0/)
+[-> Download qFlipper 1.2.0 (allows .tgz installation) (official link)](https://update.flipperzero.one/builds/qFlipper/1.2.0/)
+
+## Please support development of the project
+* ETH/BSC/ERC20-Tokens: `0xFebF1bBc8229418FF2408C07AF6Afa49152fEc6a`
+* BTC: `bc1q0np836jk9jwr4dd7p6qv66d04vamtqkxrecck9`
+* DOGE: `D6R6gYgBn5LwTNmPyvAQR6bZ9EtGgFCpvv`
+* LTC: `ltc1q3ex4ejkl0xpx3znwrmth4lyuadr5qgv8tmq8z9`
**Note: To avoid issues with .dfu, prefer installing using .tgz with qFlipper, web updater or by self update package, all needed assets will be installed**
diff --git a/ReadMe.md b/ReadMe.md
index fbc97304f..ca765145b 100644
--- a/ReadMe.md
+++ b/ReadMe.md
@@ -36,9 +36,12 @@ Our Discord Community:
* Universal remote for Projectors, Fans, A/Cs and Audio(soundbars, etc.)
* BadUSB keyboard layouts
* Customizable Flipper name
+* SubGHz -> Press OK in frequency analyzer to use detected frequency in Read modes
+* SubGHz -> Long press OK button in SubGHz Frequency analyzer to switch to Read menu
* Other small fixes and changes throughout
+* See other changes in changelog and in readme below
-See changelog in releases for latest updates!
+Also check changelog in releases for latest updates!
### Current modified and new SubGHz protocols list:
- HCS101
@@ -59,8 +62,8 @@ See changelog in releases for latest updates!
### Community apps included:
-- RFID Fuzzer plugin [(by Ganapati)](https://github.com/Eng1n33r/flipperzero-firmware/pull/54) with some changes by xMasterX
-- Sub-GHz bruteforce plugin [(by Ganapati & xMasterX)](https://github.com/Eng1n33r/flipperzero-firmware/pull/57)
+- RFID Fuzzer plugin [(by Ganapati)](https://github.com/Eng1n33r/flipperzero-firmware/pull/54) with changes by @xMasterX & New protocols by @mvanzanten
+- Sub-GHz bruteforce plugin [(by Ganapati & xMasterX)](https://github.com/Eng1n33r/flipperzero-firmware/pull/57) & Refactored by @derskythe
- Sub-GHz playlist plugin [(by darmiel)](https://github.com/Eng1n33r/flipperzero-firmware/pull/62)
- ESP8266 Deauther plugin [(by SequoiaSan)](https://github.com/SequoiaSan/FlipperZero-Wifi-ESP8266-Deauther-Module)
- WiFi Scanner plugin [(by SequoiaSan)](https://github.com/SequoiaSan/FlipperZero-WiFi-Scanner_Module)
@@ -85,8 +88,11 @@ Games:
### Other changes
- BadUSB -> Keyboard layouts [(by rien > dummy-decoy)](https://github.com/dummy-decoy/flipperzero-firmware/tree/dummy_decoy/bad_usb_keyboard_layout)
-- SubGHz -> New frequency analyzer - [(by ClusterM)](https://github.com/ClusterM)
+- SubGHz -> New frequency analyzer - [(by ClusterM)](https://github.com/Eng1n33r/flipperzero-firmware/pull/43)
- SubGHz -> Detect RAW feature - [(by perspecdev)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/pull/152)
+- SubGHz -> Save last used frequency and moduluation [(by derskythe)](https://github.com/Eng1n33r/flipperzero-firmware/pull/77)
+- SubGHz -> Press OK in frequency analyzer to use detected frequency in Read modes [(by derskythe)](https://github.com/Eng1n33r/flipperzero-firmware/pull/77)
+* SubGHz -> Long press OK button in SubGHz Frequency analyzer to switch to Read menu [(by derskythe)](https://github.com/Eng1n33r/flipperzero-firmware/pull/79)
# Instructions
## [- How to install firmware](https://github.com/Eng1n33r/flipperzero-firmware/blob/dev/documentation/HowToInstall.md)
@@ -99,7 +105,7 @@ Games:
### **Plugins**
-## [- 💎 Extra plugins precompiled for Unleashed](https://github.com/UberGuidoZ/Flipper/tree/main/Applications/Unleashed)
+## [- 🎲 Download Extra plugins for Unleashed](https://github.com/UberGuidoZ/Flipper/tree/main/Applications/Unleashed)
## [- Configure Sub-GHz Remote App](https://github.com/Eng1n33r/flipperzero-firmware/blob/dev/documentation/SubGHzRemotePlugin.md)
@@ -139,9 +145,10 @@ Games:
# Where I can find IR, SubGhz, ... files, DBs, and other stuff?
-## [Awesome Flipper Zero - Github](https://github.com/djsime1/awesome-flipperzero)
## [UberGuidoZ Playground - Large collection of files - Github](https://github.com/UberGuidoZ/Flipper)
+## [Awesome Flipper Zero - Github](https://github.com/djsime1/awesome-flipperzero)
## [CAME-12bit, NICE-12bit, Linear-10bit, PT-2240 - SubGHz fixed code bruteforce](https://github.com/tobiabocchi/flipperzero-bruteforce)
+## [SMC5326, UNILARM - SubGHz fixed code bruteforce](https://github.com/Hong5489/flipperzero-gate-bruteforce)
diff --git a/applications/debug/application.fam b/applications/debug/application.fam
index a33b3693d..c52907002 100644
--- a/applications/debug/application.fam
+++ b/applications/debug/application.fam
@@ -7,8 +7,8 @@ App(
"vibro_test",
"keypad_test",
"usb_test",
- "usb_mouse",
- "uart_echo",
+ "USB_Mouse",
+ "UART_Echo",
"display_test",
"text_box_test",
"file_browser_test",
diff --git a/applications/debug/bt_debug_app/views/bt_test.c b/applications/debug/bt_debug_app/views/bt_test.c
index 70f57c12c..9f2830d34 100644
--- a/applications/debug/bt_debug_app/views/bt_test.c
+++ b/applications/debug/bt_debug_app/views/bt_test.c
@@ -3,14 +3,13 @@
#include
#include
#include
-#include
#include
#include
struct BtTestParam {
const char* label;
uint8_t current_value_index;
- string_t current_value_text;
+ FuriString* current_value_text;
uint8_t values_count;
BtTestParamChangeCallback change_callback;
void* context;
@@ -85,7 +84,8 @@ static void bt_test_draw_callback(Canvas* canvas, void* _model) {
canvas_draw_str(canvas, 50, param_text_y, "<");
}
- canvas_draw_str(canvas, 61, param_text_y, string_get_cstr(param->current_value_text));
+ canvas_draw_str(
+ canvas, 61, param_text_y, furi_string_get_cstr(param->current_value_text));
if(param->current_value_index < (param->values_count - 1)) {
canvas_draw_str(canvas, 113, param_text_y, ">");
@@ -322,7 +322,7 @@ void bt_test_free(BtTest* bt_test) {
BtTestParamArray_it_t it;
for(BtTestParamArray_it(it, model->params); !BtTestParamArray_end_p(it);
BtTestParamArray_next(it)) {
- string_clear(BtTestParamArray_ref(it)->current_value_text);
+ furi_string_free(BtTestParamArray_ref(it)->current_value_text);
}
BtTestParamArray_clear(model->params);
return false;
@@ -354,7 +354,7 @@ BtTestParam* bt_test_param_add(
param->change_callback = change_callback;
param->context = context;
param->current_value_index = 0;
- string_init(param->current_value_text);
+ param->current_value_text = furi_string_alloc();
return true;
});
@@ -410,7 +410,7 @@ void bt_test_set_current_value_index(BtTestParam* param, uint8_t current_value_i
}
void bt_test_set_current_value_text(BtTestParam* param, const char* current_value_text) {
- string_set_str(param->current_value_text, current_value_text);
+ furi_string_set(param->current_value_text, current_value_text);
}
uint8_t bt_test_get_current_value_index(BtTestParam* param) {
diff --git a/applications/debug/display_test/display_test.c b/applications/debug/display_test/display_test.c
index 947e4dc8b..e7f366cbb 100644
--- a/applications/debug/display_test/display_test.c
+++ b/applications/debug/display_test/display_test.c
@@ -113,11 +113,11 @@ static void display_config_set_regulation_ratio(VariableItem* item) {
static void display_config_set_contrast(VariableItem* item) {
DisplayTest* instance = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
- string_t temp;
- string_init(temp);
- string_cat_printf(temp, "%d", index);
- variable_item_set_current_value_text(item, string_get_cstr(temp));
- string_clear(temp);
+ FuriString* temp;
+ temp = furi_string_alloc();
+ furi_string_cat_printf(temp, "%d", index);
+ variable_item_set_current_value_text(item, furi_string_get_cstr(temp));
+ furi_string_free(temp);
instance->config_contrast = index;
display_test_reload_config(instance);
}
diff --git a/applications/debug/file_browser_test/file_browser_app.c b/applications/debug/file_browser_test/file_browser_app.c
index c7f461d40..5c7b93bcb 100644
--- a/applications/debug/file_browser_test/file_browser_app.c
+++ b/applications/debug/file_browser_test/file_browser_app.c
@@ -1,7 +1,6 @@
#include "assets_icons.h"
#include "file_browser_app_i.h"
#include "gui/modules/file_browser.h"
-#include "m-string.h"
#include
#include
#include
@@ -47,7 +46,7 @@ FileBrowserApp* file_browser_app_alloc(char* arg) {
app->widget = widget_alloc();
- string_init(app->file_path);
+ app->file_path = furi_string_alloc();
app->file_browser = file_browser_alloc(app->file_path);
file_browser_configure(app->file_browser, "*", true, &I_badusb_10px, true);
@@ -84,7 +83,7 @@ void file_browser_app_free(FileBrowserApp* app) {
furi_record_close(RECORD_NOTIFICATION);
furi_record_close(RECORD_DIALOGS);
- string_clear(app->file_path);
+ furi_string_free(app->file_path);
free(app);
}
diff --git a/applications/debug/file_browser_test/file_browser_app_i.h b/applications/debug/file_browser_test/file_browser_app_i.h
index 6e8412c9b..20f4c3a03 100644
--- a/applications/debug/file_browser_test/file_browser_app_i.h
+++ b/applications/debug/file_browser_test/file_browser_app_i.h
@@ -22,7 +22,7 @@ struct FileBrowserApp {
Widget* widget;
FileBrowser* file_browser;
- string_t file_path;
+ FuriString* file_path;
};
typedef enum {
diff --git a/applications/debug/file_browser_test/scenes/file_browser_scene_browser.c b/applications/debug/file_browser_test/scenes/file_browser_scene_browser.c
index d9bd1ac53..0bf70e9c6 100644
--- a/applications/debug/file_browser_test/scenes/file_browser_scene_browser.c
+++ b/applications/debug/file_browser_test/scenes/file_browser_scene_browser.c
@@ -1,8 +1,5 @@
#include "../file_browser_app_i.h"
-#include
-#include
-#include "furi_hal.h"
-#include "m-string.h"
+#include
#define DEFAULT_PATH "/"
#define EXTENSION "*"
diff --git a/applications/debug/file_browser_test/scenes/file_browser_scene_result.c b/applications/debug/file_browser_test/scenes/file_browser_scene_result.c
index 53576cef4..4c68d80f7 100644
--- a/applications/debug/file_browser_test/scenes/file_browser_scene_result.c
+++ b/applications/debug/file_browser_test/scenes/file_browser_scene_result.c
@@ -1,6 +1,5 @@
#include "../file_browser_app_i.h"
-#include "furi_hal.h"
-#include "m-string.h"
+#include
void file_browser_scene_result_ok_callback(InputType type, void* context) {
furi_assert(context);
@@ -24,7 +23,13 @@ void file_browser_scene_result_on_enter(void* context) {
FileBrowserApp* app = context;
widget_add_string_multiline_element(
- app->widget, 64, 10, AlignCenter, AlignTop, FontSecondary, string_get_cstr(app->file_path));
+ app->widget,
+ 64,
+ 10,
+ AlignCenter,
+ AlignTop,
+ FontSecondary,
+ furi_string_get_cstr(app->file_path));
view_dispatcher_switch_to_view(app->view_dispatcher, FileBrowserAppViewResult);
}
diff --git a/applications/debug/file_browser_test/scenes/file_browser_scene_start.c b/applications/debug/file_browser_test/scenes/file_browser_scene_start.c
index b3381f0ad..9eb26944f 100644
--- a/applications/debug/file_browser_test/scenes/file_browser_scene_start.c
+++ b/applications/debug/file_browser_test/scenes/file_browser_scene_start.c
@@ -19,7 +19,7 @@ bool file_browser_scene_start_on_event(void* context, SceneManagerEvent event) {
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
- string_set_str(app->file_path, ANY_PATH("badusb/demo_windows.txt"));
+ furi_string_set(app->file_path, ANY_PATH("badusb/demo_windows.txt"));
scene_manager_next_scene(app->scene_manager, FileBrowserSceneBrowser);
consumed = true;
} else if(event.type == SceneManagerEventTypeTick) {
diff --git a/applications/debug/uart_echo/application.fam b/applications/debug/uart_echo/application.fam
index 956aa17af..a979c2e4f 100644
--- a/applications/debug/uart_echo/application.fam
+++ b/applications/debug/uart_echo/application.fam
@@ -1,5 +1,5 @@
App(
- appid="uart_echo",
+ appid="UART_Echo",
name="UART Echo",
apptype=FlipperAppType.PLUGIN,
entry_point="uart_echo_app",
diff --git a/applications/debug/uart_echo/uart_echo.c b/applications/debug/uart_echo/uart_echo.c
index 7a0f5c393..122862dd9 100644
--- a/applications/debug/uart_echo/uart_echo.c
+++ b/applications/debug/uart_echo/uart_echo.c
@@ -1,10 +1,8 @@
#include
-#include
#include
#include
#include
#include
-#include
#include
#include
#include
@@ -21,11 +19,11 @@ typedef struct {
ViewDispatcher* view_dispatcher;
View* view;
FuriThread* worker_thread;
- StreamBufferHandle_t rx_stream;
+ FuriStreamBuffer* rx_stream;
} UartEchoApp;
typedef struct {
- string_t text;
+ FuriString* text;
} ListElement;
struct UartDumpModel {
@@ -64,10 +62,11 @@ static void uart_echo_view_draw_callback(Canvas* canvas, void* _model) {
canvas,
0,
(i + 1) * (canvas_current_font_height(canvas) - 1),
- string_get_cstr(model->list[i]->text));
+ furi_string_get_cstr(model->list[i]->text));
if(i == model->line) {
- uint8_t width = canvas_string_width(canvas, string_get_cstr(model->list[i]->text));
+ uint8_t width =
+ canvas_string_width(canvas, furi_string_get_cstr(model->list[i]->text));
canvas_draw_box(
canvas,
@@ -92,13 +91,11 @@ static uint32_t uart_echo_exit(void* context) {
static void uart_echo_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
furi_assert(context);
- BaseType_t xHigherPriorityTaskWoken = pdFALSE;
UartEchoApp* app = context;
if(ev == UartIrqEventRXNE) {
- xStreamBufferSendFromISR(app->rx_stream, &data, 1, &xHigherPriorityTaskWoken);
+ furi_stream_buffer_send(app->rx_stream, &data, 1, 0);
furi_thread_flags_set(furi_thread_get_id(app->worker_thread), WorkerEventRx);
- portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}
@@ -113,7 +110,7 @@ static void uart_echo_push_to_list(UartDumpModel* model, const char data) {
model->escape = true;
} else if((data >= ' ' && data <= '~') || (data == '\n' || data == '\r')) {
bool new_string_needed = false;
- if(string_size(model->list[model->line]->text) >= COLUMNS_ON_SCREEN) {
+ if(furi_string_size(model->list[model->line]->text) >= COLUMNS_ON_SCREEN) {
new_string_needed = true;
} else if((data == '\n' || data == '\r')) {
// pack line breaks
@@ -132,13 +129,13 @@ static void uart_echo_push_to_list(UartDumpModel* model, const char data) {
model->list[i - 1] = model->list[i];
}
- string_reset(first->text);
+ furi_string_reset(first->text);
model->list[model->line] = first;
}
}
if(data != '\n' && data != '\r') {
- string_push_back(model->list[model->line]->text, data);
+ furi_string_push_back(model->list[model->line]->text, data);
}
}
model->last_char = data;
@@ -158,7 +155,7 @@ static int32_t uart_echo_worker(void* context) {
size_t length = 0;
do {
uint8_t data[64];
- length = xStreamBufferReceive(app->rx_stream, data, 64, 0);
+ length = furi_stream_buffer_receive(app->rx_stream, data, 64, 0);
if(length > 0) {
furi_hal_uart_tx(FuriHalUartIdUSART1, data, length);
with_view_model(
@@ -186,7 +183,7 @@ static int32_t uart_echo_worker(void* context) {
static UartEchoApp* uart_echo_app_alloc() {
UartEchoApp* app = malloc(sizeof(UartEchoApp));
- app->rx_stream = xStreamBufferCreate(2048, 1);
+ app->rx_stream = furi_stream_buffer_alloc(2048, 1);
// Gui
app->gui = furi_record_open(RECORD_GUI);
@@ -208,7 +205,7 @@ static UartEchoApp* uart_echo_app_alloc() {
model->line = 0;
model->escape = false;
model->list[i] = malloc(sizeof(ListElement));
- string_init(model->list[i]->text);
+ model->list[i]->text = furi_string_alloc();
}
return true;
});
@@ -247,7 +244,7 @@ static void uart_echo_app_free(UartEchoApp* app) {
with_view_model(
app->view, (UartDumpModel * model) {
for(size_t i = 0; i < LINES_ON_SCREEN; i++) {
- string_clear(model->list[i]->text);
+ furi_string_free(model->list[i]->text);
free(model->list[i]);
}
return true;
@@ -260,7 +257,7 @@ static void uart_echo_app_free(UartEchoApp* app) {
furi_record_close(RECORD_NOTIFICATION);
app->gui = NULL;
- vStreamBufferDelete(app->rx_stream);
+ furi_stream_buffer_free(app->rx_stream);
// Free rest
free(app);
diff --git a/applications/debug/unit_tests/flipper_format/flipper_format_string_test.c b/applications/debug/unit_tests/flipper_format/flipper_format_string_test.c
index b22b333a3..920a22a43 100644
--- a/applications/debug/unit_tests/flipper_format/flipper_format_string_test.c
+++ b/applications/debug/unit_tests/flipper_format/flipper_format_string_test.c
@@ -58,7 +58,7 @@ static const char* test_data_win = "Filetype: Flipper Format test\r\n"
#define ARRAY_W_BSIZE(x) (x), (sizeof(x))
MU_TEST_1(flipper_format_read_and_update_test, FlipperFormat* flipper_format) {
- string_t tmpstr;
+ FuriString* tmpstr;
uint32_t version;
uint32_t uint32_data[COUNT_OF(test_uint_data)];
int32_t int32_data[COUNT_OF(test_int_data)];
@@ -101,14 +101,14 @@ MU_TEST_1(flipper_format_read_and_update_test, FlipperFormat* flipper_format) {
mu_assert_int_eq(position_before, stream_tell(flipper_format_get_raw_stream(flipper_format)));
// read test
- string_init(tmpstr);
+ tmpstr = furi_string_alloc();
mu_check(flipper_format_read_header(flipper_format, tmpstr, &version));
- mu_assert_string_eq(test_filetype, string_get_cstr(tmpstr));
+ mu_assert_string_eq(test_filetype, furi_string_get_cstr(tmpstr));
mu_assert_int_eq(test_version, version);
mu_check(flipper_format_read_string(flipper_format, test_string_key, tmpstr));
- mu_assert_string_eq(test_string_data, string_get_cstr(tmpstr));
+ mu_assert_string_eq(test_string_data, furi_string_get_cstr(tmpstr));
mu_check(flipper_format_get_value_count(flipper_format, test_int_key, &count));
mu_assert_int_eq(COUNT_OF(test_int_data), count);
@@ -133,7 +133,7 @@ MU_TEST_1(flipper_format_read_and_update_test, FlipperFormat* flipper_format) {
mu_check(!flipper_format_read_string(flipper_format, "Key that doesn't exist", tmpstr));
- string_clear(tmpstr);
+ furi_string_free(tmpstr);
// update data
mu_check(flipper_format_rewind(flipper_format));
@@ -155,14 +155,14 @@ MU_TEST_1(flipper_format_read_and_update_test, FlipperFormat* flipper_format) {
uint8_t hex_updated_data[COUNT_OF(test_hex_updated_data)];
mu_check(flipper_format_rewind(flipper_format));
- string_init(tmpstr);
+ tmpstr = furi_string_alloc();
mu_check(flipper_format_read_header(flipper_format, tmpstr, &version));
- mu_assert_string_eq(test_filetype, string_get_cstr(tmpstr));
+ mu_assert_string_eq(test_filetype, furi_string_get_cstr(tmpstr));
mu_assert_int_eq(test_version, version);
mu_check(flipper_format_read_string(flipper_format, test_string_key, tmpstr));
- mu_assert_string_eq(test_string_updated_data, string_get_cstr(tmpstr));
+ mu_assert_string_eq(test_string_updated_data, furi_string_get_cstr(tmpstr));
mu_check(flipper_format_get_value_count(flipper_format, test_int_key, &count));
mu_assert_int_eq(COUNT_OF(test_int_updated_data), count);
@@ -190,7 +190,7 @@ MU_TEST_1(flipper_format_read_and_update_test, FlipperFormat* flipper_format) {
mu_check(!flipper_format_read_string(flipper_format, "Key that doesn't exist", tmpstr));
- string_clear(tmpstr);
+ furi_string_free(tmpstr);
// update data
mu_check(flipper_format_rewind(flipper_format));
@@ -214,14 +214,14 @@ MU_TEST_1(flipper_format_read_and_update_test, FlipperFormat* flipper_format) {
uint8_t hex_new_data[COUNT_OF(test_hex_new_data)];
mu_check(flipper_format_rewind(flipper_format));
- string_init(tmpstr);
+ tmpstr = furi_string_alloc();
mu_check(flipper_format_read_header(flipper_format, tmpstr, &version));
- mu_assert_string_eq(test_filetype, string_get_cstr(tmpstr));
+ mu_assert_string_eq(test_filetype, furi_string_get_cstr(tmpstr));
mu_assert_int_eq(test_version, version);
mu_check(flipper_format_read_string(flipper_format, test_string_key, tmpstr));
- mu_assert_string_eq(test_string_updated_2_data, string_get_cstr(tmpstr));
+ mu_assert_string_eq(test_string_updated_2_data, furi_string_get_cstr(tmpstr));
mu_check(flipper_format_get_value_count(flipper_format, test_int_key, &count));
mu_assert_int_eq(COUNT_OF(test_int_updated_2_data), count);
@@ -255,7 +255,7 @@ MU_TEST_1(flipper_format_read_and_update_test, FlipperFormat* flipper_format) {
mu_check(!flipper_format_read_string(flipper_format, "Key that doesn't exist", tmpstr));
- string_clear(tmpstr);
+ furi_string_free(tmpstr);
// delete key test
mu_check(flipper_format_rewind(flipper_format));
diff --git a/applications/debug/unit_tests/flipper_format/flipper_format_test.c b/applications/debug/unit_tests/flipper_format/flipper_format_test.c
index 86e2df21e..012e905b6 100644
--- a/applications/debug/unit_tests/flipper_format/flipper_format_test.c
+++ b/applications/debug/unit_tests/flipper_format/flipper_format_test.c
@@ -57,6 +57,23 @@ static const char* test_data_win = "Filetype: Flipper File test\r\n"
"Hex data: DE AD BE";
#define READ_TEST_FLP "ff_flp.test"
+#define READ_TEST_ODD "ff_oddities.test"
+static const char* test_data_odd = "Filetype: Flipper File test\n"
+ // Tabs before newline
+ "Version: 666\t\t\n"
+ "# This is comment\n"
+ // Windows newline in a UNIX file
+ "String data: String\r\n"
+ // Trailing whitespace
+ "Int32 data: 1234 -6345 7813 0 \n"
+ // Extra whitespace
+ "Uint32 data: 1234 0 5678 9098 7654321 \n"
+ // Mixed whitespace
+ "Float data: 1.5\t \t1000.0\n"
+ // Leading tabs after key
+ "Bool data:\t\ttrue false\n"
+ // Mixed trailing whitespace
+ "Hex data: DE AD BE\t ";
// data created by user on linux machine
static const char* test_file_linux = TEST_DIR READ_TEST_NIX;
@@ -64,6 +81,8 @@ static const char* test_file_linux = TEST_DIR READ_TEST_NIX;
static const char* test_file_windows = TEST_DIR READ_TEST_WIN;
// data created by flipper itself
static const char* test_file_flipper = TEST_DIR READ_TEST_FLP;
+// data containing odd user input
+static const char* test_file_oddities = TEST_DIR READ_TEST_ODD;
static bool storage_write_string(const char* path, const char* data) {
Storage* storage = furi_record_open(RECORD_STORAGE);
@@ -102,8 +121,8 @@ static bool test_read(const char* file_name) {
bool result = false;
FlipperFormat* file = flipper_format_file_alloc(storage);
- string_t string_value;
- string_init(string_value);
+ FuriString* string_value;
+ string_value = furi_string_alloc();
uint32_t uint32_value;
void* scratchpad = malloc(512);
@@ -111,11 +130,11 @@ static bool test_read(const char* file_name) {
if(!flipper_format_file_open_existing(file, file_name)) break;
if(!flipper_format_read_header(file, string_value, &uint32_value)) break;
- if(string_cmp_str(string_value, test_filetype) != 0) break;
+ if(furi_string_cmp_str(string_value, test_filetype) != 0) break;
if(uint32_value != test_version) break;
if(!flipper_format_read_string(file, test_string_key, string_value)) break;
- if(string_cmp_str(string_value, test_string_data) != 0) break;
+ if(furi_string_cmp_str(string_value, test_string_data) != 0) break;
if(!flipper_format_get_value_count(file, test_int_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_int_data)) break;
@@ -150,7 +169,7 @@ static bool test_read(const char* file_name) {
} while(false);
free(scratchpad);
- string_clear(string_value);
+ furi_string_free(string_value);
flipper_format_free(file);
@@ -164,8 +183,8 @@ static bool test_read_updated(const char* file_name) {
bool result = false;
FlipperFormat* file = flipper_format_file_alloc(storage);
- string_t string_value;
- string_init(string_value);
+ FuriString* string_value;
+ string_value = furi_string_alloc();
uint32_t uint32_value;
void* scratchpad = malloc(512);
@@ -173,11 +192,11 @@ static bool test_read_updated(const char* file_name) {
if(!flipper_format_file_open_existing(file, file_name)) break;
if(!flipper_format_read_header(file, string_value, &uint32_value)) break;
- if(string_cmp_str(string_value, test_filetype) != 0) break;
+ if(furi_string_cmp_str(string_value, test_filetype) != 0) break;
if(uint32_value != test_version) break;
if(!flipper_format_read_string(file, test_string_key, string_value)) break;
- if(string_cmp_str(string_value, test_string_updated_data) != 0) break;
+ if(furi_string_cmp_str(string_value, test_string_updated_data) != 0) break;
if(!flipper_format_get_value_count(file, test_int_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_int_updated_data)) break;
@@ -228,7 +247,7 @@ static bool test_read_updated(const char* file_name) {
} while(false);
free(scratchpad);
- string_clear(string_value);
+ furi_string_free(string_value);
flipper_format_free(file);
@@ -401,14 +420,14 @@ static bool test_read_multikey(const char* file_name) {
bool result = false;
FlipperFormat* file = flipper_format_file_alloc(storage);
- string_t string_value;
- string_init(string_value);
+ FuriString* string_value;
+ string_value = furi_string_alloc();
uint32_t uint32_value;
do {
if(!flipper_format_file_open_existing(file, file_name)) break;
if(!flipper_format_read_header(file, string_value, &uint32_value)) break;
- if(string_cmp_str(string_value, test_filetype) != 0) break;
+ if(furi_string_cmp_str(string_value, test_filetype) != 0) break;
if(uint32_value != test_version) break;
bool error = false;
@@ -429,7 +448,7 @@ static bool test_read_multikey(const char* file_name) {
result = true;
} while(false);
- string_clear(string_value);
+ furi_string_free(string_value);
flipper_format_free(file);
furi_record_close(RECORD_STORAGE);
@@ -503,6 +522,12 @@ MU_TEST(flipper_format_multikey_test) {
mu_assert(test_read_multikey(TEST_DIR "ff_multiline.test"), "Multikey read test error");
}
+MU_TEST(flipper_format_oddities_test) {
+ mu_assert(
+ storage_write_string(test_file_oddities, test_data_odd), "Write test error [Oddities]");
+ mu_assert(test_read(test_file_linux), "Read test error [Oddities]");
+}
+
MU_TEST_SUITE(flipper_format) {
tests_setup();
MU_RUN_TEST(flipper_format_write_test);
@@ -516,6 +541,7 @@ MU_TEST_SUITE(flipper_format) {
MU_RUN_TEST(flipper_format_update_2_test);
MU_RUN_TEST(flipper_format_update_2_result_test);
MU_RUN_TEST(flipper_format_multikey_test);
+ MU_RUN_TEST(flipper_format_oddities_test);
tests_teardown();
}
diff --git a/applications/debug/unit_tests/furi/furi_string_test.c b/applications/debug/unit_tests/furi/furi_string_test.c
new file mode 100644
index 000000000..3ea95b92b
--- /dev/null
+++ b/applications/debug/unit_tests/furi/furi_string_test.c
@@ -0,0 +1,469 @@
+#include
+#include "../minunit.h"
+
+static void test_setup(void) {
+}
+
+static void test_teardown(void) {
+}
+
+static FuriString* furi_string_alloc_vprintf_test(const char format[], ...) {
+ va_list args;
+ va_start(args, format);
+ FuriString* string = furi_string_alloc_vprintf(format, args);
+ va_end(args);
+ return string;
+}
+
+MU_TEST(mu_test_furi_string_alloc_free) {
+ FuriString* tmp;
+ FuriString* string;
+
+ // test alloc and free
+ string = furi_string_alloc();
+ mu_check(string != NULL);
+ mu_check(furi_string_empty(string));
+ furi_string_free(string);
+
+ // test furi_string_alloc_set_str and free
+ string = furi_string_alloc_set_str("test");
+ mu_check(string != NULL);
+ mu_check(!furi_string_empty(string));
+ mu_check(furi_string_cmp(string, "test") == 0);
+ furi_string_free(string);
+
+ // test furi_string_alloc_set and free
+ tmp = furi_string_alloc_set("more");
+ string = furi_string_alloc_set(tmp);
+ furi_string_free(tmp);
+ mu_check(string != NULL);
+ mu_check(!furi_string_empty(string));
+ mu_check(furi_string_cmp(string, "more") == 0);
+ furi_string_free(string);
+
+ // test alloc_printf and free
+ string = furi_string_alloc_printf("test %d %s %c 0x%02x", 1, "two", '3', 0x04);
+ mu_check(string != NULL);
+ mu_check(!furi_string_empty(string));
+ mu_check(furi_string_cmp(string, "test 1 two 3 0x04") == 0);
+ furi_string_free(string);
+
+ // test alloc_vprintf and free
+ string = furi_string_alloc_vprintf_test("test %d %s %c 0x%02x", 4, "five", '6', 0x07);
+ mu_check(string != NULL);
+ mu_check(!furi_string_empty(string));
+ mu_check(furi_string_cmp(string, "test 4 five 6 0x07") == 0);
+ furi_string_free(string);
+
+ // test alloc_move and free
+ tmp = furi_string_alloc_set("move");
+ string = furi_string_alloc_move(tmp);
+ mu_check(string != NULL);
+ mu_check(!furi_string_empty(string));
+ mu_check(furi_string_cmp(string, "move") == 0);
+ furi_string_free(string);
+}
+
+MU_TEST(mu_test_furi_string_mem) {
+ FuriString* string = furi_string_alloc_set("test");
+ mu_check(string != NULL);
+ mu_check(!furi_string_empty(string));
+
+ // TODO: how to test furi_string_reserve?
+
+ // test furi_string_reset
+ furi_string_reset(string);
+ mu_check(furi_string_empty(string));
+
+ // test furi_string_swap
+ furi_string_set(string, "test");
+ FuriString* swap_string = furi_string_alloc_set("swap");
+ furi_string_swap(string, swap_string);
+ mu_check(furi_string_cmp(string, "swap") == 0);
+ mu_check(furi_string_cmp(swap_string, "test") == 0);
+ furi_string_free(swap_string);
+
+ // test furi_string_move
+ FuriString* move_string = furi_string_alloc_set("move");
+ furi_string_move(string, move_string);
+ mu_check(furi_string_cmp(string, "move") == 0);
+ // move_string is now empty
+ // and tested by leaked memory check at the end of the tests
+
+ furi_string_set(string, "abracadabra");
+
+ // test furi_string_hash
+ mu_assert_int_eq(0xc3bc16d7, furi_string_hash(string));
+
+ // test furi_string_size
+ mu_assert_int_eq(11, furi_string_size(string));
+
+ // test furi_string_empty
+ mu_check(!furi_string_empty(string));
+ furi_string_reset(string);
+ mu_check(furi_string_empty(string));
+
+ furi_string_free(string);
+}
+
+MU_TEST(mu_test_furi_string_getters) {
+ FuriString* string = furi_string_alloc_set("test");
+
+ // test furi_string_get_char
+ mu_check(furi_string_get_char(string, 0) == 't');
+ mu_check(furi_string_get_char(string, 1) == 'e');
+ mu_check(furi_string_get_char(string, 2) == 's');
+ mu_check(furi_string_get_char(string, 3) == 't');
+
+ // test furi_string_get_cstr
+ mu_assert_string_eq("test", furi_string_get_cstr(string));
+ furi_string_free(string);
+}
+
+static FuriString* furi_string_vprintf_test(FuriString* string, const char format[], ...) {
+ va_list args;
+ va_start(args, format);
+ furi_string_vprintf(string, format, args);
+ va_end(args);
+ return string;
+}
+
+MU_TEST(mu_test_furi_string_setters) {
+ FuriString* tmp;
+ FuriString* string = furi_string_alloc();
+
+ // test furi_string_set_str
+ furi_string_set_str(string, "test");
+ mu_assert_string_eq("test", furi_string_get_cstr(string));
+
+ // test furi_string_set
+ tmp = furi_string_alloc_set("more");
+ furi_string_set(string, tmp);
+ furi_string_free(tmp);
+ mu_assert_string_eq("more", furi_string_get_cstr(string));
+
+ // test furi_string_set_strn
+ furi_string_set_strn(string, "test", 2);
+ mu_assert_string_eq("te", furi_string_get_cstr(string));
+
+ // test furi_string_set_char
+ furi_string_set_char(string, 0, 'a');
+ furi_string_set_char(string, 1, 'b');
+ mu_assert_string_eq("ab", furi_string_get_cstr(string));
+
+ // test furi_string_set_n
+ tmp = furi_string_alloc_set("dodecahedron");
+ furi_string_set_n(string, tmp, 4, 5);
+ furi_string_free(tmp);
+ mu_assert_string_eq("cahed", furi_string_get_cstr(string));
+
+ // test furi_string_printf
+ furi_string_printf(string, "test %d %s %c 0x%02x", 1, "two", '3', 0x04);
+ mu_assert_string_eq("test 1 two 3 0x04", furi_string_get_cstr(string));
+
+ // test furi_string_vprintf
+ furi_string_vprintf_test(string, "test %d %s %c 0x%02x", 4, "five", '6', 0x07);
+ mu_assert_string_eq("test 4 five 6 0x07", furi_string_get_cstr(string));
+
+ furi_string_free(string);
+}
+
+static FuriString* furi_string_cat_vprintf_test(FuriString* string, const char format[], ...) {
+ va_list args;
+ va_start(args, format);
+ furi_string_cat_vprintf(string, format, args);
+ va_end(args);
+ return string;
+}
+
+MU_TEST(mu_test_furi_string_appends) {
+ FuriString* tmp;
+ FuriString* string = furi_string_alloc();
+
+ // test furi_string_push_back
+ furi_string_push_back(string, 't');
+ furi_string_push_back(string, 'e');
+ furi_string_push_back(string, 's');
+ furi_string_push_back(string, 't');
+ mu_assert_string_eq("test", furi_string_get_cstr(string));
+ furi_string_push_back(string, '!');
+ mu_assert_string_eq("test!", furi_string_get_cstr(string));
+
+ // test furi_string_cat_str
+ furi_string_cat_str(string, "test");
+ mu_assert_string_eq("test!test", furi_string_get_cstr(string));
+
+ // test furi_string_cat
+ tmp = furi_string_alloc_set("more");
+ furi_string_cat(string, tmp);
+ furi_string_free(tmp);
+ mu_assert_string_eq("test!testmore", furi_string_get_cstr(string));
+
+ // test furi_string_cat_printf
+ furi_string_cat_printf(string, "test %d %s %c 0x%02x", 1, "two", '3', 0x04);
+ mu_assert_string_eq("test!testmoretest 1 two 3 0x04", furi_string_get_cstr(string));
+
+ // test furi_string_cat_vprintf
+ furi_string_cat_vprintf_test(string, "test %d %s %c 0x%02x", 4, "five", '6', 0x07);
+ mu_assert_string_eq(
+ "test!testmoretest 1 two 3 0x04test 4 five 6 0x07", furi_string_get_cstr(string));
+
+ furi_string_free(string);
+}
+
+MU_TEST(mu_test_furi_string_compare) {
+ FuriString* string_1 = furi_string_alloc_set("string_1");
+ FuriString* string_2 = furi_string_alloc_set("string_2");
+
+ // test furi_string_cmp
+ mu_assert_int_eq(0, furi_string_cmp(string_1, string_1));
+ mu_assert_int_eq(0, furi_string_cmp(string_2, string_2));
+ mu_assert_int_eq(-1, furi_string_cmp(string_1, string_2));
+ mu_assert_int_eq(1, furi_string_cmp(string_2, string_1));
+
+ // test furi_string_cmp_str
+ mu_assert_int_eq(0, furi_string_cmp_str(string_1, "string_1"));
+ mu_assert_int_eq(0, furi_string_cmp_str(string_2, "string_2"));
+ mu_assert_int_eq(-1, furi_string_cmp_str(string_1, "string_2"));
+ mu_assert_int_eq(1, furi_string_cmp_str(string_2, "string_1"));
+
+ // test furi_string_cmpi
+ furi_string_set(string_1, "string");
+ furi_string_set(string_2, "StrIng");
+ mu_assert_int_eq(0, furi_string_cmpi(string_1, string_1));
+ mu_assert_int_eq(0, furi_string_cmpi(string_2, string_2));
+ mu_assert_int_eq(0, furi_string_cmpi(string_1, string_2));
+ mu_assert_int_eq(0, furi_string_cmpi(string_2, string_1));
+ furi_string_set(string_1, "string_1");
+ furi_string_set(string_2, "StrIng_2");
+ mu_assert_int_eq(32, furi_string_cmp(string_1, string_2));
+ mu_assert_int_eq(-32, furi_string_cmp(string_2, string_1));
+ mu_assert_int_eq(-1, furi_string_cmpi(string_1, string_2));
+ mu_assert_int_eq(1, furi_string_cmpi(string_2, string_1));
+
+ // test furi_string_cmpi_str
+ furi_string_set(string_1, "string");
+ mu_assert_int_eq(0, furi_string_cmp_str(string_1, "string"));
+ mu_assert_int_eq(32, furi_string_cmp_str(string_1, "String"));
+ mu_assert_int_eq(32, furi_string_cmp_str(string_1, "STring"));
+ mu_assert_int_eq(32, furi_string_cmp_str(string_1, "STRing"));
+ mu_assert_int_eq(32, furi_string_cmp_str(string_1, "STRIng"));
+ mu_assert_int_eq(32, furi_string_cmp_str(string_1, "STRINg"));
+ mu_assert_int_eq(32, furi_string_cmp_str(string_1, "STRING"));
+ mu_assert_int_eq(0, furi_string_cmpi_str(string_1, "string"));
+ mu_assert_int_eq(0, furi_string_cmpi_str(string_1, "String"));
+ mu_assert_int_eq(0, furi_string_cmpi_str(string_1, "STring"));
+ mu_assert_int_eq(0, furi_string_cmpi_str(string_1, "STRing"));
+ mu_assert_int_eq(0, furi_string_cmpi_str(string_1, "STRIng"));
+ mu_assert_int_eq(0, furi_string_cmpi_str(string_1, "STRINg"));
+ mu_assert_int_eq(0, furi_string_cmpi_str(string_1, "STRING"));
+
+ furi_string_free(string_1);
+ furi_string_free(string_2);
+}
+
+MU_TEST(mu_test_furi_string_search) {
+ // 012345678901234567
+ FuriString* haystack = furi_string_alloc_set("test321test123test");
+ FuriString* needle = furi_string_alloc_set("test");
+
+ // test furi_string_search
+ mu_assert_int_eq(0, furi_string_search(haystack, needle));
+ mu_assert_int_eq(7, furi_string_search(haystack, needle, 1));
+ mu_assert_int_eq(14, furi_string_search(haystack, needle, 8));
+ mu_assert_int_eq(FURI_STRING_FAILURE, furi_string_search(haystack, needle, 15));
+
+ FuriString* tmp = furi_string_alloc_set("testnone");
+ mu_assert_int_eq(FURI_STRING_FAILURE, furi_string_search(haystack, tmp));
+ furi_string_free(tmp);
+
+ // test furi_string_search_str
+ mu_assert_int_eq(0, furi_string_search_str(haystack, "test"));
+ mu_assert_int_eq(7, furi_string_search_str(haystack, "test", 1));
+ mu_assert_int_eq(14, furi_string_search_str(haystack, "test", 8));
+ mu_assert_int_eq(4, furi_string_search_str(haystack, "321"));
+ mu_assert_int_eq(11, furi_string_search_str(haystack, "123"));
+ mu_assert_int_eq(FURI_STRING_FAILURE, furi_string_search_str(haystack, "testnone"));
+ mu_assert_int_eq(FURI_STRING_FAILURE, furi_string_search_str(haystack, "test", 15));
+
+ // test furi_string_search_char
+ mu_assert_int_eq(0, furi_string_search_char(haystack, 't'));
+ mu_assert_int_eq(1, furi_string_search_char(haystack, 'e'));
+ mu_assert_int_eq(2, furi_string_search_char(haystack, 's'));
+ mu_assert_int_eq(3, furi_string_search_char(haystack, 't', 1));
+ mu_assert_int_eq(7, furi_string_search_char(haystack, 't', 4));
+ mu_assert_int_eq(FURI_STRING_FAILURE, furi_string_search_char(haystack, 'x'));
+
+ // test furi_string_search_rchar
+ mu_assert_int_eq(17, furi_string_search_rchar(haystack, 't'));
+ mu_assert_int_eq(15, furi_string_search_rchar(haystack, 'e'));
+ mu_assert_int_eq(16, furi_string_search_rchar(haystack, 's'));
+ mu_assert_int_eq(13, furi_string_search_rchar(haystack, '3'));
+ mu_assert_int_eq(FURI_STRING_FAILURE, furi_string_search_rchar(haystack, '3', 14));
+ mu_assert_int_eq(FURI_STRING_FAILURE, furi_string_search_rchar(haystack, 'x'));
+
+ furi_string_free(haystack);
+ furi_string_free(needle);
+}
+
+MU_TEST(mu_test_furi_string_equality) {
+ FuriString* string = furi_string_alloc_set("test");
+ FuriString* string_eq = furi_string_alloc_set("test");
+ FuriString* string_neq = furi_string_alloc_set("test2");
+
+ // test furi_string_equal
+ mu_check(furi_string_equal(string, string_eq));
+ mu_check(!furi_string_equal(string, string_neq));
+
+ // test furi_string_equal_str
+ mu_check(furi_string_equal_str(string, "test"));
+ mu_check(!furi_string_equal_str(string, "test2"));
+ mu_check(furi_string_equal_str(string_neq, "test2"));
+ mu_check(!furi_string_equal_str(string_neq, "test"));
+
+ furi_string_free(string);
+ furi_string_free(string_eq);
+ furi_string_free(string_neq);
+}
+
+MU_TEST(mu_test_furi_string_replace) {
+ FuriString* needle = furi_string_alloc_set("test");
+ FuriString* replace = furi_string_alloc_set("replace");
+ FuriString* string = furi_string_alloc_set("test123test");
+
+ // test furi_string_replace_at
+ furi_string_replace_at(string, 4, 3, "!biglongword!");
+ mu_assert_string_eq("test!biglongword!test", furi_string_get_cstr(string));
+
+ // test furi_string_replace
+ mu_assert_int_eq(17, furi_string_replace(string, needle, replace, 1));
+ mu_assert_string_eq("test!biglongword!replace", furi_string_get_cstr(string));
+ mu_assert_int_eq(0, furi_string_replace(string, needle, replace));
+ mu_assert_string_eq("replace!biglongword!replace", furi_string_get_cstr(string));
+ mu_assert_int_eq(FURI_STRING_FAILURE, furi_string_replace(string, needle, replace));
+ mu_assert_string_eq("replace!biglongword!replace", furi_string_get_cstr(string));
+
+ // test furi_string_replace_str
+ mu_assert_int_eq(20, furi_string_replace_str(string, "replace", "test", 1));
+ mu_assert_string_eq("replace!biglongword!test", furi_string_get_cstr(string));
+ mu_assert_int_eq(0, furi_string_replace_str(string, "replace", "test"));
+ mu_assert_string_eq("test!biglongword!test", furi_string_get_cstr(string));
+ mu_assert_int_eq(FURI_STRING_FAILURE, furi_string_replace_str(string, "replace", "test"));
+ mu_assert_string_eq("test!biglongword!test", furi_string_get_cstr(string));
+
+ // test furi_string_replace_all
+ furi_string_replace_all(string, needle, replace);
+ mu_assert_string_eq("replace!biglongword!replace", furi_string_get_cstr(string));
+
+ // test furi_string_replace_all_str
+ furi_string_replace_all_str(string, "replace", "test");
+ mu_assert_string_eq("test!biglongword!test", furi_string_get_cstr(string));
+
+ furi_string_free(string);
+ furi_string_free(needle);
+ furi_string_free(replace);
+}
+
+MU_TEST(mu_test_furi_string_start_end) {
+ FuriString* string = furi_string_alloc_set("start_end");
+ FuriString* start = furi_string_alloc_set("start");
+ FuriString* end = furi_string_alloc_set("end");
+
+ // test furi_string_start_with
+ mu_check(furi_string_start_with(string, start));
+ mu_check(!furi_string_start_with(string, end));
+
+ // test furi_string_start_with_str
+ mu_check(furi_string_start_with_str(string, "start"));
+ mu_check(!furi_string_start_with_str(string, "end"));
+
+ // test furi_string_end_with
+ mu_check(furi_string_end_with(string, end));
+ mu_check(!furi_string_end_with(string, start));
+
+ // test furi_string_end_with_str
+ mu_check(furi_string_end_with_str(string, "end"));
+ mu_check(!furi_string_end_with_str(string, "start"));
+
+ furi_string_free(string);
+ furi_string_free(start);
+ furi_string_free(end);
+}
+
+MU_TEST(mu_test_furi_string_trim) {
+ FuriString* string = furi_string_alloc_set("biglongstring");
+
+ // test furi_string_left
+ furi_string_left(string, 7);
+ mu_assert_string_eq("biglong", furi_string_get_cstr(string));
+
+ // test furi_string_right
+ furi_string_right(string, 3);
+ mu_assert_string_eq("long", furi_string_get_cstr(string));
+
+ // test furi_string_mid
+ furi_string_mid(string, 1, 2);
+ mu_assert_string_eq("on", furi_string_get_cstr(string));
+
+ // test furi_string_trim
+ furi_string_set(string, " \n\r\tbiglongstring \n\r\t ");
+ furi_string_trim(string);
+ mu_assert_string_eq("biglongstring", furi_string_get_cstr(string));
+ furi_string_set(string, "aaaabaaaabbaaabaaaabbtestaaaaaabbaaabaababaa");
+ furi_string_trim(string, "ab");
+ mu_assert_string_eq("test", furi_string_get_cstr(string));
+
+ furi_string_free(string);
+}
+
+MU_TEST(mu_test_furi_string_utf8) {
+ FuriString* utf8_string = furi_string_alloc_set("イルカ");
+
+ // test furi_string_utf8_length
+ mu_assert_int_eq(9, furi_string_size(utf8_string));
+ mu_assert_int_eq(3, furi_string_utf8_length(utf8_string));
+
+ // test furi_string_utf8_decode
+ const uint8_t dolphin_emoji_array[4] = {0xF0, 0x9F, 0x90, 0xAC};
+ FuriStringUTF8State state = FuriStringUTF8StateStarting;
+ FuriStringUnicodeValue value = 0;
+ furi_string_utf8_decode(dolphin_emoji_array[0], &state, &value);
+ mu_assert_int_eq(FuriStringUTF8StateDecoding3, state);
+ furi_string_utf8_decode(dolphin_emoji_array[1], &state, &value);
+ mu_assert_int_eq(FuriStringUTF8StateDecoding2, state);
+ furi_string_utf8_decode(dolphin_emoji_array[2], &state, &value);
+ mu_assert_int_eq(FuriStringUTF8StateDecoding1, state);
+ furi_string_utf8_decode(dolphin_emoji_array[3], &state, &value);
+ mu_assert_int_eq(FuriStringUTF8StateStarting, state);
+ mu_assert_int_eq(0x1F42C, value);
+
+ // test furi_string_utf8_push
+ furi_string_set(utf8_string, "");
+ furi_string_utf8_push(utf8_string, value);
+ mu_assert_string_eq("🐬", furi_string_get_cstr(utf8_string));
+
+ furi_string_free(utf8_string);
+}
+
+MU_TEST_SUITE(test_suite) {
+ MU_SUITE_CONFIGURE(&test_setup, &test_teardown);
+
+ MU_RUN_TEST(mu_test_furi_string_alloc_free);
+ MU_RUN_TEST(mu_test_furi_string_mem);
+ MU_RUN_TEST(mu_test_furi_string_getters);
+ MU_RUN_TEST(mu_test_furi_string_setters);
+ MU_RUN_TEST(mu_test_furi_string_appends);
+ MU_RUN_TEST(mu_test_furi_string_compare);
+ MU_RUN_TEST(mu_test_furi_string_search);
+ MU_RUN_TEST(mu_test_furi_string_equality);
+ MU_RUN_TEST(mu_test_furi_string_replace);
+ MU_RUN_TEST(mu_test_furi_string_start_end);
+ MU_RUN_TEST(mu_test_furi_string_trim);
+ MU_RUN_TEST(mu_test_furi_string_utf8);
+}
+
+int run_minunit_test_furi_string() {
+ MU_RUN_SUITE(test_suite);
+
+ return MU_EXIT_CODE;
+}
\ No newline at end of file
diff --git a/applications/debug/unit_tests/infrared/infrared_test.c b/applications/debug/unit_tests/infrared/infrared_test.c
index 32266c48e..8879c8fc8 100644
--- a/applications/debug/unit_tests/infrared/infrared_test.c
+++ b/applications/debug/unit_tests/infrared/infrared_test.c
@@ -11,7 +11,7 @@
typedef struct {
InfraredDecoderHandler* decoder_handler;
InfraredEncoderHandler* encoder_handler;
- string_t file_path;
+ FuriString* file_path;
FlipperFormat* ff;
} InfraredTest;
@@ -23,7 +23,7 @@ static void infrared_test_alloc() {
test->decoder_handler = infrared_alloc_decoder();
test->encoder_handler = infrared_alloc_encoder();
test->ff = flipper_format_buffered_file_alloc(storage);
- string_init(test->file_path);
+ test->file_path = furi_string_alloc();
}
static void infrared_test_free() {
@@ -31,18 +31,18 @@ static void infrared_test_free() {
infrared_free_decoder(test->decoder_handler);
infrared_free_encoder(test->encoder_handler);
flipper_format_free(test->ff);
- string_clear(test->file_path);
+ furi_string_free(test->file_path);
furi_record_close(RECORD_STORAGE);
free(test);
test = NULL;
}
static bool infrared_test_prepare_file(const char* protocol_name) {
- string_t file_type;
- string_init(file_type);
+ FuriString* file_type;
+ file_type = furi_string_alloc();
bool success = false;
- string_printf(
+ furi_string_printf(
test->file_path,
"%s%s%s%s",
IR_TEST_FILES_DIR,
@@ -52,14 +52,15 @@ static bool infrared_test_prepare_file(const char* protocol_name) {
do {
uint32_t format_version;
- if(!flipper_format_buffered_file_open_existing(test->ff, string_get_cstr(test->file_path)))
+ if(!flipper_format_buffered_file_open_existing(
+ test->ff, furi_string_get_cstr(test->file_path)))
break;
if(!flipper_format_read_header(test->ff, file_type, &format_version)) break;
- if(string_cmp_str(file_type, "IR tests file") || format_version != 1) break;
+ if(furi_string_cmp_str(file_type, "IR tests file") || format_version != 1) break;
success = true;
} while(false);
- string_clear(file_type);
+ furi_string_free(file_type);
return success;
}
@@ -68,18 +69,18 @@ static bool infrared_test_load_raw_signal(
const char* signal_name,
uint32_t** timings,
uint32_t* timings_count) {
- string_t buf;
- string_init(buf);
+ FuriString* buf;
+ buf = furi_string_alloc();
bool success = false;
do {
bool is_name_found = false;
for(; !is_name_found && flipper_format_read_string(ff, "name", buf);
- is_name_found = !string_cmp_str(buf, signal_name))
+ is_name_found = !furi_string_cmp(buf, signal_name))
;
if(!is_name_found) break;
- if(!flipper_format_read_string(ff, "type", buf) || string_cmp_str(buf, "raw")) break;
+ if(!flipper_format_read_string(ff, "type", buf) || furi_string_cmp_str(buf, "raw")) break;
if(!flipper_format_get_value_count(ff, "data", timings_count)) break;
if(!*timings_count) break;
@@ -91,18 +92,18 @@ static bool infrared_test_load_raw_signal(
success = true;
} while(false);
- string_clear(buf);
+ furi_string_free(buf);
return success;
}
static bool infrared_test_read_message(FlipperFormat* ff, InfraredMessage* message) {
- string_t buf;
- string_init(buf);
+ FuriString* buf;
+ buf = furi_string_alloc();
bool success = false;
do {
if(!flipper_format_read_string(ff, "protocol", buf)) break;
- message->protocol = infrared_get_protocol_by_name(string_get_cstr(buf));
+ message->protocol = infrared_get_protocol_by_name(furi_string_get_cstr(buf));
if(!infrared_is_protocol_valid(message->protocol)) break;
if(!flipper_format_read_hex(ff, "address", (uint8_t*)&message->address, sizeof(uint32_t)))
break;
@@ -112,7 +113,7 @@ static bool infrared_test_read_message(FlipperFormat* ff, InfraredMessage* messa
success = true;
} while(false);
- string_clear(buf);
+ furi_string_free(buf);
return success;
}
@@ -121,18 +122,19 @@ static bool infrared_test_load_messages(
const char* signal_name,
InfraredMessage** messages,
uint32_t* messages_count) {
- string_t buf;
- string_init(buf);
+ FuriString* buf;
+ buf = furi_string_alloc();
bool success = false;
do {
bool is_name_found = false;
for(; !is_name_found && flipper_format_read_string(ff, "name", buf);
- is_name_found = !string_cmp_str(buf, signal_name))
+ is_name_found = !furi_string_cmp(buf, signal_name))
;
if(!is_name_found) break;
- if(!flipper_format_read_string(ff, "type", buf) || string_cmp_str(buf, "parsed_array"))
+ if(!flipper_format_read_string(ff, "type", buf) ||
+ furi_string_cmp_str(buf, "parsed_array"))
break;
if(!flipper_format_read_uint32(ff, "count", messages_count, 1)) break;
if(!*messages_count) break;
@@ -151,7 +153,7 @@ static bool infrared_test_load_messages(
success = true;
} while(false);
- string_clear(buf);
+ furi_string_free(buf);
return success;
}
@@ -213,26 +215,26 @@ static void infrared_test_run_encoder(InfraredProtocol protocol, uint32_t test_i
InfraredMessage* input_messages;
uint32_t input_messages_count;
- string_t buf;
- string_init(buf);
+ FuriString* buf;
+ buf = furi_string_alloc();
const char* protocol_name = infrared_get_protocol_name(protocol);
mu_assert(infrared_test_prepare_file(protocol_name), "Failed to prepare test file");
- string_printf(buf, "encoder_input%d", test_index);
+ furi_string_printf(buf, "encoder_input%ld", test_index);
mu_assert(
infrared_test_load_messages(
- test->ff, string_get_cstr(buf), &input_messages, &input_messages_count),
+ test->ff, furi_string_get_cstr(buf), &input_messages, &input_messages_count),
"Failed to load messages from file");
- string_printf(buf, "encoder_expected%d", test_index);
+ furi_string_printf(buf, "encoder_expected%ld", test_index);
mu_assert(
infrared_test_load_raw_signal(
- test->ff, string_get_cstr(buf), &expected_timings, &expected_timings_count),
+ test->ff, furi_string_get_cstr(buf), &expected_timings, &expected_timings_count),
"Failed to load raw signal from file");
flipper_format_buffered_file_close(test->ff);
- string_clear(buf);
+ furi_string_free(buf);
uint32_t j = 0;
timings = malloc(sizeof(uint32_t) * timings_count);
@@ -267,22 +269,22 @@ static void infrared_test_run_encoder_decoder(InfraredProtocol protocol, uint32_
uint32_t input_messages_count;
bool level = false;
- string_t buf;
- string_init(buf);
+ FuriString* buf;
+ buf = furi_string_alloc();
timings = malloc(sizeof(uint32_t) * timings_count);
const char* protocol_name = infrared_get_protocol_name(protocol);
mu_assert(infrared_test_prepare_file(protocol_name), "Failed to prepare test file");
- string_printf(buf, "encoder_decoder_input%d", test_index);
+ furi_string_printf(buf, "encoder_decoder_input%ld", test_index);
mu_assert(
infrared_test_load_messages(
- test->ff, string_get_cstr(buf), &input_messages, &input_messages_count),
+ test->ff, furi_string_get_cstr(buf), &input_messages, &input_messages_count),
"Failed to load messages from file");
flipper_format_buffered_file_close(test->ff);
- string_clear(buf);
+ furi_string_free(buf);
for(uint32_t message_counter = 0; message_counter < input_messages_count; ++message_counter) {
const InfraredMessage* message_encoded = &input_messages[message_counter];
@@ -327,25 +329,27 @@ static void infrared_test_run_decoder(InfraredProtocol protocol, uint32_t test_i
InfraredMessage* messages;
uint32_t messages_count;
- string_t buf;
- string_init(buf);
+ FuriString* buf;
+ buf = furi_string_alloc();
mu_assert(
infrared_test_prepare_file(infrared_get_protocol_name(protocol)),
"Failed to prepare test file");
- string_printf(buf, "decoder_input%d", test_index);
+ furi_string_printf(buf, "decoder_input%ld", test_index);
mu_assert(
- infrared_test_load_raw_signal(test->ff, string_get_cstr(buf), &timings, &timings_count),
+ infrared_test_load_raw_signal(
+ test->ff, furi_string_get_cstr(buf), &timings, &timings_count),
"Failed to load raw signal from file");
- string_printf(buf, "decoder_expected%d", test_index);
+ furi_string_printf(buf, "decoder_expected%ld", test_index);
mu_assert(
- infrared_test_load_messages(test->ff, string_get_cstr(buf), &messages, &messages_count),
+ infrared_test_load_messages(
+ test->ff, furi_string_get_cstr(buf), &messages, &messages_count),
"Failed to load messages from file");
flipper_format_buffered_file_close(test->ff);
- string_clear(buf);
+ furi_string_free(buf);
InfraredMessage message_decoded_check_local;
bool level = 0;
diff --git a/applications/debug/unit_tests/nfc/nfc_test.c b/applications/debug/unit_tests/nfc/nfc_test.c
index 580943f24..f149508b0 100644
--- a/applications/debug/unit_tests/nfc/nfc_test.c
+++ b/applications/debug/unit_tests/nfc/nfc_test.c
@@ -53,14 +53,15 @@ static bool nfc_test_read_signal_from_file(const char* file_name) {
bool success = false;
FlipperFormat* file = flipper_format_file_alloc(nfc_test->storage);
- string_t file_type;
- string_init(file_type);
+ FuriString* file_type;
+ file_type = furi_string_alloc();
uint32_t file_version = 0;
do {
if(!flipper_format_file_open_existing(file, file_name)) break;
if(!flipper_format_read_header(file, file_type, &file_version)) break;
- if(string_cmp_str(file_type, nfc_test_file_type) || file_version != nfc_test_file_version)
+ if(furi_string_cmp_str(file_type, nfc_test_file_type) ||
+ file_version != nfc_test_file_version)
break;
if(!flipper_format_read_uint32(file, "Data length", &nfc_test->test_data_len, 1)) break;
if(nfc_test->test_data_len > NFC_TEST_DATA_MAX_LEN) break;
@@ -76,7 +77,7 @@ static bool nfc_test_read_signal_from_file(const char* file_name) {
success = true;
} while(false);
- string_clear(file_type);
+ furi_string_free(file_type);
flipper_format_free(file);
return success;
@@ -111,7 +112,7 @@ static bool nfc_test_digital_signal_test_encode(
// Check timings
if(time > encode_max_time) {
FURI_LOG_E(
- TAG, "Encoding time: %d us while accepted value: %d us", time, encode_max_time);
+ TAG, "Encoding time: %ld us while accepted value: %ld us", time, encode_max_time);
break;
}
@@ -131,7 +132,7 @@ static bool nfc_test_digital_signal_test_encode(
ref_timings_sum += ref[i];
if(timings_diff > timing_tolerance) {
FURI_LOG_E(
- TAG, "Too big differece in %d timings. Ref: %d, DUT: %d", i, ref[i], dut[i]);
+ TAG, "Too big differece in %d timings. Ref: %ld, DUT: %ld", i, ref[i], dut[i]);
timing_check_success = false;
break;
}
@@ -142,16 +143,16 @@ static bool nfc_test_digital_signal_test_encode(
if(sum_diff > timings_sum_tolerance) {
FURI_LOG_E(
TAG,
- "Too big difference in timings sum. Ref: %d, DUT: %d",
+ "Too big difference in timings sum. Ref: %ld, DUT: %ld",
ref_timings_sum,
dut_timings_sum);
break;
}
- FURI_LOG_I(TAG, "Encoding time: %d us. Acceptable time: %d us", time, encode_max_time);
+ FURI_LOG_I(TAG, "Encoding time: %ld us. Acceptable time: %ld us", time, encode_max_time);
FURI_LOG_I(
TAG,
- "Timings sum difference: %d [1/64MHZ]. Acceptable difference: %d [1/64MHz]",
+ "Timings sum difference: %ld [1/64MHZ]. Acceptable difference: %ld [1/64MHz]",
sum_diff,
timings_sum_tolerance);
success = true;
@@ -174,8 +175,8 @@ MU_TEST(nfc_digital_signal_test) {
MU_TEST(mf_classic_dict_test) {
MfClassicDict* instance = NULL;
uint64_t key = 0;
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
instance = mf_classic_dict_alloc(MfClassicDictTypeUnitTest);
mu_assert(instance != NULL, "mf_classic_dict_alloc\r\n");
@@ -184,7 +185,7 @@ MU_TEST(mf_classic_dict_test) {
mf_classic_dict_get_total_keys(instance) == 0,
"mf_classic_dict_get_total_keys == 0 assert failed\r\n");
- string_set(temp_str, "2196FAD8115B");
+ furi_string_set(temp_str, "2196FAD8115B");
mu_assert(
mf_classic_dict_add_key_str(instance, temp_str),
"mf_classic_dict_add_key == true assert failed\r\n");
@@ -199,7 +200,7 @@ MU_TEST(mf_classic_dict_test) {
mf_classic_dict_get_key_at_index_str(instance, temp_str, 0),
"mf_classic_dict_get_key_at_index_str == true assert failed\r\n");
mu_assert(
- string_cmp(temp_str, "2196FAD8115B") == 0,
+ furi_string_cmp(temp_str, "2196FAD8115B") == 0,
"string_cmp(temp_str, \"2196FAD8115B\") == 0 assert failed\r\n");
mu_assert(mf_classic_dict_rewind(instance), "mf_classic_dict_rewind == 1 assert failed\r\n");
@@ -216,7 +217,7 @@ MU_TEST(mf_classic_dict_test) {
"mf_classic_dict_delete_index == true assert failed\r\n");
mf_classic_dict_free(instance);
- string_clear(temp_str);
+ furi_string_free(temp_str);
}
MU_TEST_SUITE(nfc) {
diff --git a/applications/debug/unit_tests/rpc/rpc_test.c b/applications/debug/unit_tests/rpc/rpc_test.c
index 6ee2aed65..5b52df2fa 100644
--- a/applications/debug/unit_tests/rpc/rpc_test.c
+++ b/applications/debug/unit_tests/rpc/rpc_test.c
@@ -10,7 +10,6 @@
#include
#include "../minunit.h"
#include
-#include
#include
#include
#include
@@ -34,7 +33,7 @@ static uint32_t command_id = 0;
typedef struct {
RpcSession* session;
- StreamBufferHandle_t output_stream;
+ FuriStreamBuffer* output_stream;
SemaphoreHandle_t close_session_semaphore;
SemaphoreHandle_t terminate_semaphore;
TickType_t timeout;
@@ -90,7 +89,7 @@ static void test_rpc_setup(void) {
}
furi_check(rpc_session[0].session);
- rpc_session[0].output_stream = xStreamBufferCreate(1000, 1);
+ rpc_session[0].output_stream = furi_stream_buffer_alloc(1000, 1);
rpc_session_set_send_bytes_callback(rpc_session[0].session, output_bytes_callback);
rpc_session[0].close_session_semaphore = xSemaphoreCreateBinary();
rpc_session[0].terminate_semaphore = xSemaphoreCreateBinary();
@@ -110,7 +109,7 @@ static void test_rpc_setup_second_session(void) {
}
furi_check(rpc_session[1].session);
- rpc_session[1].output_stream = xStreamBufferCreate(1000, 1);
+ rpc_session[1].output_stream = furi_stream_buffer_alloc(1000, 1);
rpc_session_set_send_bytes_callback(rpc_session[1].session, output_bytes_callback);
rpc_session[1].close_session_semaphore = xSemaphoreCreateBinary();
rpc_session[1].terminate_semaphore = xSemaphoreCreateBinary();
@@ -126,7 +125,7 @@ static void test_rpc_teardown(void) {
rpc_session_close(rpc_session[0].session);
furi_check(xSemaphoreTake(rpc_session[0].terminate_semaphore, portMAX_DELAY));
furi_record_close(RECORD_RPC);
- vStreamBufferDelete(rpc_session[0].output_stream);
+ furi_stream_buffer_free(rpc_session[0].output_stream);
vSemaphoreDelete(rpc_session[0].close_session_semaphore);
vSemaphoreDelete(rpc_session[0].terminate_semaphore);
++command_id;
@@ -141,7 +140,7 @@ static void test_rpc_teardown_second_session(void) {
xSemaphoreTake(rpc_session[1].terminate_semaphore, 0);
rpc_session_close(rpc_session[1].session);
furi_check(xSemaphoreTake(rpc_session[1].terminate_semaphore, portMAX_DELAY));
- vStreamBufferDelete(rpc_session[1].output_stream);
+ furi_stream_buffer_free(rpc_session[1].output_stream);
vSemaphoreDelete(rpc_session[1].close_session_semaphore);
vSemaphoreDelete(rpc_session[1].terminate_semaphore);
++command_id;
@@ -268,8 +267,8 @@ static PB_CommandStatus test_rpc_storage_get_file_error(File* file) {
static void output_bytes_callback(void* ctx, uint8_t* got_bytes, size_t got_size) {
RpcSessionContext* callbacks_context = ctx;
- size_t bytes_sent =
- xStreamBufferSend(callbacks_context->output_stream, got_bytes, got_size, FuriWaitForever);
+ size_t bytes_sent = furi_stream_buffer_send(
+ callbacks_context->output_stream, got_bytes, got_size, FuriWaitForever);
(void)bytes_sent;
furi_check(bytes_sent == got_size);
}
@@ -534,7 +533,8 @@ static bool test_rpc_pb_stream_read(pb_istream_t* istream, pb_byte_t* buf, size_
TickType_t now = xTaskGetTickCount();
int32_t time_left = session_context->timeout - now;
time_left = MAX(time_left, 0);
- bytes_received = xStreamBufferReceive(session_context->output_stream, buf, count, time_left);
+ bytes_received =
+ furi_stream_buffer_receive(session_context->output_stream, buf, count, time_left);
return (count == bytes_received);
}
diff --git a/applications/debug/unit_tests/storage/dirwalk_test.c b/applications/debug/unit_tests/storage/dirwalk_test.c
index db3d91a96..97aaa3580 100644
--- a/applications/debug/unit_tests/storage/dirwalk_test.c
+++ b/applications/debug/unit_tests/storage/dirwalk_test.c
@@ -75,7 +75,7 @@ typedef struct {
bool visited;
} StorageTestPath;
-DICT_DEF2(StorageTestPathDict, string_t, STRING_OPLIST, StorageTestPath, M_POD_OPLIST)
+DICT_DEF2(StorageTestPathDict, FuriString*, FURI_STRING_OPLIST, StorageTestPath, M_POD_OPLIST)
static StorageTestPathDict_t*
storage_test_paths_alloc(const StorageTestPathDesc paths[], size_t paths_count) {
@@ -83,15 +83,15 @@ static StorageTestPathDict_t*
StorageTestPathDict_init(*data);
for(size_t i = 0; i < paths_count; i++) {
- string_t key;
- string_init_set(key, paths[i].path);
+ FuriString* key;
+ key = furi_string_alloc_set(paths[i].path);
StorageTestPath value = {
.is_dir = paths[i].is_dir,
.visited = false,
};
StorageTestPathDict_set_at(*data, key, value);
- string_clear(key);
+ furi_string_free(key);
}
return data;
@@ -102,7 +102,7 @@ static void storage_test_paths_free(StorageTestPathDict_t* data) {
free(data);
}
-static bool storage_test_paths_mark(StorageTestPathDict_t* data, string_t path, bool is_dir) {
+static bool storage_test_paths_mark(StorageTestPathDict_t* data, FuriString* path, bool is_dir) {
bool found = false;
StorageTestPath* record = StorageTestPathDict_get(*data, path);
@@ -148,27 +148,27 @@ static bool write_file_13DA(Storage* storage, const char* path) {
}
static void storage_dirs_create(Storage* storage, const char* base) {
- string_t path;
- string_init(path);
+ FuriString* path;
+ path = furi_string_alloc();
storage_common_mkdir(storage, base);
for(size_t i = 0; i < COUNT_OF(storage_test_dirwalk_paths); i++) {
- string_printf(path, "%s/%s", base, storage_test_dirwalk_paths[i]);
- storage_common_mkdir(storage, string_get_cstr(path));
+ furi_string_printf(path, "%s/%s", base, storage_test_dirwalk_paths[i]);
+ storage_common_mkdir(storage, furi_string_get_cstr(path));
}
for(size_t i = 0; i < COUNT_OF(storage_test_dirwalk_files); i++) {
- string_printf(path, "%s/%s", base, storage_test_dirwalk_files[i]);
- write_file_13DA(storage, string_get_cstr(path));
+ furi_string_printf(path, "%s/%s", base, storage_test_dirwalk_files[i]);
+ write_file_13DA(storage, furi_string_get_cstr(path));
}
- string_clear(path);
+ furi_string_free(path);
}
MU_TEST_1(test_dirwalk_full, Storage* storage) {
- string_t path;
- string_init(path);
+ FuriString* path;
+ path = furi_string_alloc();
FileInfo fileinfo;
StorageTestPathDict_t* paths =
@@ -178,12 +178,12 @@ MU_TEST_1(test_dirwalk_full, Storage* storage) {
mu_check(dir_walk_open(dir_walk, EXT_PATH("dirwalk")));
while(dir_walk_read(dir_walk, path, &fileinfo) == DirWalkOK) {
- string_right(path, strlen(EXT_PATH("dirwalk/")));
+ furi_string_right(path, strlen(EXT_PATH("dirwalk/")));
mu_check(storage_test_paths_mark(paths, path, (fileinfo.flags & FSF_DIRECTORY)));
}
dir_walk_free(dir_walk);
- string_clear(path);
+ furi_string_free(path);
mu_check(storage_test_paths_check(paths) == false);
@@ -191,8 +191,8 @@ MU_TEST_1(test_dirwalk_full, Storage* storage) {
}
MU_TEST_1(test_dirwalk_no_recursive, Storage* storage) {
- string_t path;
- string_init(path);
+ FuriString* path;
+ path = furi_string_alloc();
FileInfo fileinfo;
StorageTestPathDict_t* paths = storage_test_paths_alloc(
@@ -203,12 +203,12 @@ MU_TEST_1(test_dirwalk_no_recursive, Storage* storage) {
mu_check(dir_walk_open(dir_walk, EXT_PATH("dirwalk")));
while(dir_walk_read(dir_walk, path, &fileinfo) == DirWalkOK) {
- string_right(path, strlen(EXT_PATH("dirwalk/")));
+ furi_string_right(path, strlen(EXT_PATH("dirwalk/")));
mu_check(storage_test_paths_mark(paths, path, (fileinfo.flags & FSF_DIRECTORY)));
}
dir_walk_free(dir_walk);
- string_clear(path);
+ furi_string_free(path);
mu_check(storage_test_paths_check(paths) == false);
@@ -230,8 +230,8 @@ static bool test_dirwalk_filter_no_folder_ext(const char* name, FileInfo* filein
}
MU_TEST_1(test_dirwalk_filter, Storage* storage) {
- string_t path;
- string_init(path);
+ FuriString* path;
+ path = furi_string_alloc();
FileInfo fileinfo;
StorageTestPathDict_t* paths = storage_test_paths_alloc(
@@ -242,12 +242,12 @@ MU_TEST_1(test_dirwalk_filter, Storage* storage) {
mu_check(dir_walk_open(dir_walk, EXT_PATH("dirwalk")));
while(dir_walk_read(dir_walk, path, &fileinfo) == DirWalkOK) {
- string_right(path, strlen(EXT_PATH("dirwalk/")));
+ furi_string_right(path, strlen(EXT_PATH("dirwalk/")));
mu_check(storage_test_paths_mark(paths, path, (fileinfo.flags & FSF_DIRECTORY)));
}
dir_walk_free(dir_walk);
- string_clear(path);
+ furi_string_free(path);
mu_check(storage_test_paths_check(paths) == false);
diff --git a/applications/debug/unit_tests/storage/storage_test.c b/applications/debug/unit_tests/storage/storage_test.c
index c3628a4f9..7c1c669ff 100644
--- a/applications/debug/unit_tests/storage/storage_test.c
+++ b/applications/debug/unit_tests/storage/storage_test.c
@@ -58,7 +58,7 @@ MU_TEST(storage_file_open_lock) {
storage_file_close(file);
// file_locker thread stop
- mu_check(furi_thread_join(locker_thread) == FuriStatusOk);
+ mu_check(furi_thread_join(locker_thread));
furi_thread_free(locker_thread);
// clean data
@@ -148,7 +148,7 @@ MU_TEST(storage_dir_open_lock) {
storage_dir_close(file);
// file_locker thread stop
- mu_check(furi_thread_join(locker_thread) == FuriStatusOk);
+ mu_check(furi_thread_join(locker_thread));
furi_thread_free(locker_thread);
// clean data
@@ -211,22 +211,22 @@ static bool check_file_13DA(Storage* storage, const char* path) {
}
static void storage_dir_create(Storage* storage, const char* base) {
- string_t path;
- string_init(path);
+ FuriString* path;
+ path = furi_string_alloc();
storage_common_mkdir(storage, base);
for(size_t i = 0; i < COUNT_OF(storage_copy_test_paths); i++) {
- string_printf(path, "%s/%s", base, storage_copy_test_paths[i]);
- storage_common_mkdir(storage, string_get_cstr(path));
+ furi_string_printf(path, "%s/%s", base, storage_copy_test_paths[i]);
+ storage_common_mkdir(storage, furi_string_get_cstr(path));
}
for(size_t i = 0; i < COUNT_OF(storage_copy_test_files); i++) {
- string_printf(path, "%s/%s", base, storage_copy_test_files[i]);
- write_file_13DA(storage, string_get_cstr(path));
+ furi_string_printf(path, "%s/%s", base, storage_copy_test_files[i]);
+ write_file_13DA(storage, furi_string_get_cstr(path));
}
- string_clear(path);
+ furi_string_free(path);
}
static void storage_dir_remove(Storage* storage, const char* base) {
@@ -235,15 +235,15 @@ static void storage_dir_remove(Storage* storage, const char* base) {
static bool storage_dir_rename_check(Storage* storage, const char* base) {
bool result = false;
- string_t path;
- string_init(path);
+ FuriString* path;
+ path = furi_string_alloc();
result = (storage_common_stat(storage, base, NULL) == FSE_OK);
if(result) {
for(size_t i = 0; i < COUNT_OF(storage_copy_test_paths); i++) {
- string_printf(path, "%s/%s", base, storage_copy_test_paths[i]);
- result = (storage_common_stat(storage, string_get_cstr(path), NULL) == FSE_OK);
+ furi_string_printf(path, "%s/%s", base, storage_copy_test_paths[i]);
+ result = (storage_common_stat(storage, furi_string_get_cstr(path), NULL) == FSE_OK);
if(!result) {
break;
}
@@ -252,15 +252,15 @@ static bool storage_dir_rename_check(Storage* storage, const char* base) {
if(result) {
for(size_t i = 0; i < COUNT_OF(storage_copy_test_files); i++) {
- string_printf(path, "%s/%s", base, storage_copy_test_files[i]);
- result = check_file_13DA(storage, string_get_cstr(path));
+ furi_string_printf(path, "%s/%s", base, storage_copy_test_files[i]);
+ result = check_file_13DA(storage, furi_string_get_cstr(path));
if(!result) {
break;
}
}
}
- string_clear(path);
+ furi_string_free(path);
return result;
}
diff --git a/applications/debug/unit_tests/stream/stream_test.c b/applications/debug/unit_tests/stream/stream_test.c
index b5a2d3980..c04e119c6 100644
--- a/applications/debug/unit_tests/stream/stream_test.c
+++ b/applications/debug/unit_tests/stream/stream_test.c
@@ -18,8 +18,8 @@ static const char* stream_test_right_data =
MU_TEST_1(stream_composite_subtest, Stream* stream) {
const size_t data_size = 128;
uint8_t data[data_size];
- string_t string_lee;
- string_init_set(string_lee, "lee");
+ FuriString* string_lee;
+ string_lee = furi_string_alloc_set("lee");
// test that stream is empty
// "" -> ""
@@ -267,7 +267,7 @@ MU_TEST_1(stream_composite_subtest, Stream* stream) {
mu_assert_int_eq(9, stream_tell(stream));
mu_check(stream_eof(stream));
- string_clear(string_lee);
+ furi_string_free(string_lee);
}
MU_TEST(stream_composite_test) {
@@ -416,10 +416,10 @@ MU_TEST(stream_buffered_write_after_read_test) {
}
MU_TEST(stream_buffered_large_file_test) {
- string_t input_data;
- string_t output_data;
- string_init(input_data);
- string_init(output_data);
+ FuriString* input_data;
+ FuriString* output_data;
+ input_data = furi_string_alloc();
+ output_data = furi_string_alloc();
Storage* storage = furi_record_open(RECORD_STORAGE);
@@ -429,7 +429,7 @@ MU_TEST(stream_buffered_large_file_test) {
const size_t rep_count = data_size / line_size + 1;
for(size_t i = 0; i < rep_count; ++i) {
- string_cat_printf(input_data, "%s\n", stream_test_data);
+ furi_string_cat_printf(input_data, "%s\n", stream_test_data);
}
// write test data to file
@@ -437,8 +437,8 @@ MU_TEST(stream_buffered_large_file_test) {
mu_check(buffered_file_stream_open(
stream, EXT_PATH("filestream.str"), FSAM_READ_WRITE, FSOM_CREATE_ALWAYS));
mu_assert_int_eq(0, stream_size(stream));
- mu_assert_int_eq(string_size(input_data), stream_write_string(stream, input_data));
- mu_assert_int_eq(string_size(input_data), stream_size(stream));
+ mu_assert_int_eq(furi_string_size(input_data), stream_write_string(stream, input_data));
+ mu_assert_int_eq(furi_string_size(input_data), stream_size(stream));
const size_t substr_start = 8;
const size_t substr_len = 11;
@@ -475,23 +475,23 @@ MU_TEST(stream_buffered_large_file_test) {
// read the whole file
mu_check(stream_rewind(stream));
- string_t tmp;
- string_init(tmp);
+ FuriString* tmp;
+ tmp = furi_string_alloc();
while(stream_read_line(stream, tmp)) {
- string_cat(output_data, tmp);
+ furi_string_cat(output_data, tmp);
}
- string_clear(tmp);
+ furi_string_free(tmp);
// check against generated data
- mu_assert_int_eq(string_size(input_data), string_size(output_data));
- mu_check(string_equal_p(input_data, output_data));
+ mu_assert_int_eq(furi_string_size(input_data), furi_string_size(output_data));
+ mu_check(furi_string_equal(input_data, output_data));
mu_check(stream_eof(stream));
stream_free(stream);
furi_record_close(RECORD_STORAGE);
- string_clear(input_data);
- string_clear(output_data);
+ furi_string_free(input_data);
+ furi_string_free(output_data);
}
MU_TEST_SUITE(stream_suite) {
diff --git a/applications/debug/unit_tests/subghz/subghz_test.c b/applications/debug/unit_tests/subghz/subghz_test.c
index 36f5b94c2..210d3770f 100644
--- a/applications/debug/unit_tests/subghz/subghz_test.c
+++ b/applications/debug/unit_tests/subghz/subghz_test.c
@@ -28,12 +28,12 @@ static void subghz_test_rx_callback(
void* context) {
UNUSED(receiver);
UNUSED(context);
- string_t text;
- string_init(text);
+ FuriString* text;
+ text = furi_string_alloc();
subghz_protocol_decoder_base_get_string(decoder_base, text);
subghz_receiver_reset(receiver_handler);
- FURI_LOG_T(TAG, "\r\n%s", string_get_cstr(text));
- string_clear(text);
+ FURI_LOG_T(TAG, "\r\n%s", furi_string_get_cstr(text));
+ furi_string_free(text);
subghz_test_decoder_count++;
}
@@ -141,8 +141,8 @@ static bool subghz_decode_random_test(const char* path) {
static bool subghz_encoder_test(const char* path) {
subghz_test_decoder_count = 0;
uint32_t test_start = furi_get_tick();
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
bool file_load = false;
Storage* storage = furi_record_open(RECORD_STORAGE);
@@ -167,11 +167,11 @@ static bool subghz_encoder_test(const char* path) {
} while(false);
if(file_load) {
SubGhzTransmitter* transmitter =
- subghz_transmitter_alloc_init(environment_handler, string_get_cstr(temp_str));
+ subghz_transmitter_alloc_init(environment_handler, furi_string_get_cstr(temp_str));
subghz_transmitter_deserialize(transmitter, fff_data_file);
SubGhzProtocolDecoderBase* decoder = subghz_receiver_search_decoder_base_by_name(
- receiver_handler, string_get_cstr(temp_str));
+ receiver_handler, furi_string_get_cstr(temp_str));
if(decoder) {
LevelDuration level_duration;
@@ -192,10 +192,11 @@ static bool subghz_encoder_test(const char* path) {
flipper_format_free(fff_data_file);
FURI_LOG_T(TAG, "\r\n Decoder count parse \033[0;33m%d\033[0m ", subghz_test_decoder_count);
if(furi_get_tick() - test_start > TEST_TIMEOUT) {
- printf("\033[0;31mTest encoder %s ERROR TimeOut\033[0m\r\n", string_get_cstr(temp_str));
+ printf(
+ "\033[0;31mTest encoder %s ERROR TimeOut\033[0m\r\n", furi_string_get_cstr(temp_str));
subghz_test_decoder_count = 0;
}
- string_clear(temp_str);
+ furi_string_free(temp_str);
return subghz_test_decoder_count ? true : false;
}
diff --git a/applications/debug/unit_tests/test_index.c b/applications/debug/unit_tests/test_index.c
index 81d891b2b..2009d4a5b 100644
--- a/applications/debug/unit_tests/test_index.c
+++ b/applications/debug/unit_tests/test_index.c
@@ -1,5 +1,3 @@
-#include "m-string.h"
-
#include
#include
#include
@@ -11,6 +9,7 @@
#define TAG "UnitTests"
int run_minunit_test_furi();
+int run_minunit_test_furi_string();
int run_minunit_test_infrared();
int run_minunit_test_rpc();
int run_minunit_test_flipper_format();
@@ -33,6 +32,7 @@ typedef struct {
const UnitTest unit_tests[] = {
{.name = "furi", .entry = run_minunit_test_furi},
+ {.name = "furi_string", .entry = run_minunit_test_furi_string},
{.name = "storage", .entry = run_minunit_test_storage},
{.name = "stream", .entry = run_minunit_test_stream},
{.name = "dirwalk", .entry = run_minunit_test_dirwalk},
@@ -63,7 +63,7 @@ void minunit_print_fail(const char* str) {
printf(FURI_LOG_CLR_E "%s\r\n" FURI_LOG_CLR_RESET, str);
}
-void unit_tests_cli(Cli* cli, string_t args, void* context) {
+void unit_tests_cli(Cli* cli, FuriString* args, void* context) {
UNUSED(cli);
UNUSED(args);
UNUSED(context);
@@ -91,8 +91,8 @@ void unit_tests_cli(Cli* cli, string_t args, void* context) {
break;
}
- if(string_size(args)) {
- if(string_cmp_str(args, unit_tests[i].name) == 0) {
+ if(furi_string_size(args)) {
+ if(furi_string_cmp_str(args, unit_tests[i].name) == 0) {
failed_tests += unit_tests[i].entry();
} else {
printf("Skipping %s\r\n", unit_tests[i].name);
diff --git a/applications/debug/usb_mouse/application.fam b/applications/debug/usb_mouse/application.fam
index 9c2f19da6..fb7595e10 100644
--- a/applications/debug/usb_mouse/application.fam
+++ b/applications/debug/usb_mouse/application.fam
@@ -1,5 +1,5 @@
App(
- appid="usb_mouse",
+ appid="USB_Mouse",
name="USB Mouse",
apptype=FlipperAppType.PLUGIN,
entry_point="usb_mouse_app",
diff --git a/applications/examples/application.fam b/applications/examples/application.fam
new file mode 100644
index 000000000..16d240ccf
--- /dev/null
+++ b/applications/examples/application.fam
@@ -0,0 +1,5 @@
+App(
+ appid="sample_apps",
+ name="Sample apps bundle",
+ apptype=FlipperAppType.METAPACKAGE,
+)
diff --git a/applications/examples/example_images/application.fam b/applications/examples/example_images/application.fam
new file mode 100644
index 000000000..9a5f8e030
--- /dev/null
+++ b/applications/examples/example_images/application.fam
@@ -0,0 +1,10 @@
+App(
+ appid="example_images",
+ name="Example: Images",
+ apptype=FlipperAppType.EXTERNAL,
+ entry_point="example_images_main",
+ requires=["gui"],
+ stack_size=1 * 1024,
+ fap_category="Examples",
+ fap_icon_assets="images",
+)
diff --git a/applications/examples/example_images/example_images.c b/applications/examples/example_images/example_images.c
new file mode 100644
index 000000000..48fa5e77e
--- /dev/null
+++ b/applications/examples/example_images/example_images.c
@@ -0,0 +1,79 @@
+#include
+#include
+
+#include
+#include
+
+#include "example_images_icons.h"
+
+typedef struct {
+ uint8_t x, y;
+} ImagePosition;
+
+static ImagePosition image_position = {.x = 0, .y = 0};
+
+// Screen is 128x64 px
+static void app_draw_callback(Canvas* canvas, void* ctx) {
+ UNUSED(ctx);
+
+ canvas_clear(canvas);
+ canvas_draw_icon(canvas, image_position.x % 128, image_position.y % 64, &I_dolphin_71x25);
+}
+
+static void app_input_callback(InputEvent* input_event, void* ctx) {
+ furi_assert(ctx);
+
+ FuriMessageQueue* event_queue = ctx;
+ furi_message_queue_put(event_queue, input_event, FuriWaitForever);
+}
+
+int32_t example_images_main(void* p) {
+ UNUSED(p);
+ FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
+
+ // Configure view port
+ ViewPort* view_port = view_port_alloc();
+ view_port_draw_callback_set(view_port, app_draw_callback, view_port);
+ view_port_input_callback_set(view_port, app_input_callback, event_queue);
+
+ // Register view port in GUI
+ Gui* gui = furi_record_open(RECORD_GUI);
+ gui_add_view_port(gui, view_port, GuiLayerFullscreen);
+
+ InputEvent event;
+
+ bool running = true;
+ while(running) {
+ if(furi_message_queue_get(event_queue, &event, 100) == FuriStatusOk) {
+ if((event.type == InputTypePress) || (event.type == InputTypeRepeat)) {
+ switch(event.key) {
+ case InputKeyLeft:
+ image_position.x -= 2;
+ break;
+ case InputKeyRight:
+ image_position.x += 2;
+ break;
+ case InputKeyUp:
+ image_position.y -= 2;
+ break;
+ case InputKeyDown:
+ image_position.y += 2;
+ break;
+ default:
+ running = false;
+ break;
+ }
+ }
+ }
+ view_port_update(view_port);
+ }
+
+ view_port_enabled_set(view_port, false);
+ gui_remove_view_port(gui, view_port);
+ view_port_free(view_port);
+ furi_message_queue_free(event_queue);
+
+ furi_record_close(RECORD_GUI);
+
+ return 0;
+}
diff --git a/applications/examples/example_images/images/dolphin_71x25.png b/applications/examples/example_images/images/dolphin_71x25.png
new file mode 100644
index 000000000..6b3f8aa59
Binary files /dev/null and b/applications/examples/example_images/images/dolphin_71x25.png differ
diff --git a/applications/main/archive/archive.c b/applications/main/archive/archive.c
index 6eedc8ea0..588087fd2 100644
--- a/applications/main/archive/archive.c
+++ b/applications/main/archive/archive.c
@@ -21,7 +21,7 @@ static void archive_tick_event_callback(void* context) {
static ArchiveApp* archive_alloc() {
ArchiveApp* archive = malloc(sizeof(ArchiveApp));
- string_init(archive->fav_move_str);
+ archive->fav_move_str = furi_string_alloc();
archive->scene_manager = scene_manager_alloc(&archive_scene_handlers, archive);
archive->view_dispatcher = view_dispatcher_alloc();
@@ -81,7 +81,7 @@ void archive_free(ArchiveApp* archive) {
scene_manager_free(archive->scene_manager);
browser_free(archive->browser);
- string_clear(archive->fav_move_str);
+ furi_string_free(archive->fav_move_str);
furi_record_close(RECORD_DIALOGS);
archive->dialogs = NULL;
diff --git a/applications/main/archive/archive_i.h b/applications/main/archive/archive_i.h
index 7f4ff5a7b..b96145827 100644
--- a/applications/main/archive/archive_i.h
+++ b/applications/main/archive/archive_i.h
@@ -36,7 +36,7 @@ struct ArchiveApp {
Loading* loading;
FuriPubSubSubscription* loader_stop_subscription;
- string_t fav_move_str;
+ FuriString* fav_move_str;
char text_store[MAX_NAME_LEN];
char file_extension[MAX_EXT_LEN + 1];
};
diff --git a/applications/main/archive/helpers/archive_browser.c b/applications/main/archive/helpers/archive_browser.c
index 034555560..0f44cf585 100644
--- a/applications/main/archive/helpers/archive_browser.c
+++ b/applications/main/archive/helpers/archive_browser.c
@@ -5,7 +5,7 @@
#include
#include
#include "gui/modules/file_browser_worker.h"
-#include "m-string.h"
+#include
#include
static void
@@ -19,7 +19,7 @@ static void
if((item_cnt == 0) && (archive_is_home(browser)) && (tab != ArchiveTabBrowser)) {
archive_switch_tab(browser, browser->last_tab_switch_dir);
- } else if(!string_start_with_str_p(browser->path, "/app:")) {
+ } else if(!furi_string_start_with_str(browser->path, "/app:")) {
with_view_model(
browser->view, (ArchiveBrowserViewModel * model) {
files_array_reset(model->files);
@@ -51,12 +51,13 @@ static void archive_list_load_cb(void* context, uint32_t list_load_offset) {
});
}
-static void archive_list_item_cb(void* context, string_t item_path, bool is_folder, bool is_last) {
+static void
+ archive_list_item_cb(void* context, FuriString* item_path, bool is_folder, bool is_last) {
furi_assert(context);
ArchiveBrowserView* browser = (ArchiveBrowserView*)context;
if(!is_last) {
- archive_add_file_item(browser, is_folder, string_get_cstr(item_path));
+ archive_add_file_item(browser, is_folder, furi_string_get_cstr(item_path));
} else {
with_view_model(
browser->view, (ArchiveBrowserViewModel * model) {
@@ -79,7 +80,7 @@ static void archive_long_load_cb(void* context) {
static void archive_file_browser_set_path(
ArchiveBrowserView* browser,
- string_t path,
+ FuriString* path,
const char* filter_ext,
bool skip_assets) {
furi_assert(browser);
@@ -133,7 +134,7 @@ void archive_update_focus(ArchiveBrowserView* browser, const char* target) {
furi_assert(browser);
furi_assert(target);
- archive_get_items(browser, string_get_cstr(browser->path));
+ archive_get_items(browser, furi_string_get_cstr(browser->path));
if(!archive_file_get_array_size(browser) && archive_is_home(browser)) {
archive_switch_tab(browser, TAB_RIGHT);
@@ -143,7 +144,7 @@ void archive_update_focus(ArchiveBrowserView* browser, const char* target) {
uint16_t idx = 0;
while(idx < files_array_size(model->files)) {
ArchiveFile_t* current = files_array_get(model->files, idx);
- if(!string_search(current->path, target)) {
+ if(!furi_string_search(current->path, target)) {
model->item_idx = idx + model->array_offset;
break;
}
@@ -315,12 +316,12 @@ bool archive_is_home(ArchiveBrowserView* browser) {
}
const char* default_path = archive_get_default_path(archive_get_tab(browser));
- return (string_cmp_str(browser->path, default_path) == 0);
+ return (furi_string_cmp_str(browser->path, default_path) == 0);
}
const char* archive_get_name(ArchiveBrowserView* browser) {
ArchiveFile_t* selected = archive_get_current_file(browser);
- return string_get_cstr(selected->path);
+ return furi_string_get_cstr(selected->path);
}
void archive_set_tab(ArchiveBrowserView* browser, ArchiveTabEnum tab) {
@@ -339,7 +340,7 @@ void archive_add_app_item(ArchiveBrowserView* browser, const char* name) {
ArchiveFile_t item;
ArchiveFile_t_init(&item);
- string_set_str(item.path, name);
+ furi_string_set(item.path, name);
archive_set_file_type(&item, name, false, true);
with_view_model(
@@ -351,16 +352,32 @@ void archive_add_app_item(ArchiveBrowserView* browser, const char* name) {
ArchiveFile_t_clear(&item);
}
+static bool archive_get_fap_meta(FuriString* file_path, FuriString* fap_name, uint8_t** icon_ptr) {
+ Storage* storage = furi_record_open(RECORD_STORAGE);
+ bool success = false;
+ if(fap_loader_load_name_and_icon(file_path, storage, icon_ptr, fap_name)) {
+ success = true;
+ }
+ furi_record_close(RECORD_STORAGE);
+ return success;
+}
+
void archive_add_file_item(ArchiveBrowserView* browser, bool is_folder, const char* name) {
furi_assert(browser);
furi_assert(name);
ArchiveFile_t item;
-
ArchiveFile_t_init(&item);
- string_init_set_str(item.path, name);
- archive_set_file_type(&item, string_get_cstr(browser->path), is_folder, false);
+ furi_string_set(item.path, name);
+ archive_set_file_type(&item, furi_string_get_cstr(browser->path), is_folder, false);
+ if(item.type == ArchiveFileTypeApplication) {
+ item.custom_icon_data = malloc(FAP_MANIFEST_MAX_ICON_SIZE);
+ if(!archive_get_fap_meta(item.path, item.custom_name, &item.custom_icon_data)) {
+ free(item.custom_icon_data);
+ item.custom_icon_data = NULL;
+ }
+ }
with_view_model(
browser->view, (ArchiveBrowserViewModel * model) {
files_array_push_back(model->files, item);
@@ -380,7 +397,8 @@ void archive_show_file_menu(ArchiveBrowserView* browser, bool show) {
menu_array_reset(model->context_menu);
ArchiveFile_t* selected =
files_array_get(model->files, model->item_idx - model->array_offset);
- selected->fav = archive_is_favorite("%s", string_get_cstr(selected->path));
+ selected->fav =
+ archive_is_favorite("%s", furi_string_get_cstr(selected->path));
}
} else {
model->menu = false;
@@ -401,14 +419,14 @@ void archive_favorites_move_mode(ArchiveBrowserView* browser, bool active) {
});
}
-static bool archive_is_dir_exists(string_t path) {
- if(string_equal_str_p(path, STORAGE_ANY_PATH_PREFIX)) {
+static bool archive_is_dir_exists(FuriString* path) {
+ if(furi_string_equal(path, STORAGE_ANY_PATH_PREFIX)) {
return true;
}
bool state = false;
FileInfo file_info;
Storage* storage = furi_record_open(RECORD_STORAGE);
- if(storage_common_stat(storage, string_get_cstr(path), &file_info) == FSE_OK) {
+ if(storage_common_stat(storage, furi_string_get_cstr(path), &file_info) == FSE_OK) {
if(file_info.flags & FSF_DIRECTORY) {
state = true;
}
@@ -432,16 +450,16 @@ void archive_switch_tab(ArchiveBrowserView* browser, InputKey key) {
browser->is_root = true;
archive_set_tab(browser, tab);
- string_set_str(browser->path, archive_get_default_path(tab));
+ furi_string_set(browser->path, archive_get_default_path(tab));
bool tab_empty = true;
if(tab == ArchiveTabFavorites) {
if(archive_favorites_count(browser) > 0) {
tab_empty = false;
}
- } else if(string_start_with_str_p(browser->path, "/app:")) {
- char* app_name = strchr(string_get_cstr(browser->path), ':');
+ } else if(furi_string_start_with_str(browser->path, "/app:")) {
+ char* app_name = strchr(furi_string_get_cstr(browser->path), ':');
if(app_name != NULL) {
- if(archive_app_is_available(browser, string_get_cstr(browser->path))) {
+ if(archive_app_is_available(browser, furi_string_get_cstr(browser->path))) {
tab_empty = false;
}
}
@@ -464,12 +482,12 @@ void archive_switch_tab(ArchiveBrowserView* browser, InputKey key) {
model->array_offset = 0;
return false;
});
- archive_get_items(browser, string_get_cstr(browser->path));
+ archive_get_items(browser, furi_string_get_cstr(browser->path));
archive_update_offset(browser);
}
}
-void archive_enter_dir(ArchiveBrowserView* browser, string_t path) {
+void archive_enter_dir(ArchiveBrowserView* browser, FuriString* path) {
furi_assert(browser);
furi_assert(path);
@@ -481,7 +499,7 @@ void archive_enter_dir(ArchiveBrowserView* browser, string_t path) {
return false;
});
- string_set(browser->path, path);
+ furi_string_set(browser->path, path);
file_browser_worker_folder_enter(browser->worker, path, idx_temp);
}
diff --git a/applications/main/archive/helpers/archive_browser.h b/applications/main/archive/helpers/archive_browser.h
index de4bb9382..519a34a2d 100644
--- a/applications/main/archive/helpers/archive_browser.h
+++ b/applications/main/archive/helpers/archive_browser.h
@@ -16,7 +16,7 @@ static const char* tab_default_paths[] = {
[ArchiveTabInfrared] = ANY_PATH("infrared"),
[ArchiveTabBadUsb] = ANY_PATH("badusb"),
[ArchiveTabU2f] = "/app:u2f",
- [ArchiveTabApps] = ANY_PATH("apps"),
+ [ArchiveTabApplications] = ANY_PATH("apps"),
[ArchiveTabBrowser] = STORAGE_ANY_PATH_PREFIX,
};
@@ -28,7 +28,7 @@ static const char* known_ext[] = {
[ArchiveFileTypeInfrared] = ".ir",
[ArchiveFileTypeBadUsb] = ".txt",
[ArchiveFileTypeU2f] = "?",
- [ArchiveFileTypeApps] = ".fap",
+ [ArchiveFileTypeApplication] = ".fap",
[ArchiveFileTypeUpdateManifest] = ".fuf",
[ArchiveFileTypeFolder] = "?",
[ArchiveFileTypeUnknown] = "*",
@@ -43,7 +43,7 @@ static const ArchiveFileTypeEnum known_type[] = {
[ArchiveTabInfrared] = ArchiveFileTypeInfrared,
[ArchiveTabBadUsb] = ArchiveFileTypeBadUsb,
[ArchiveTabU2f] = ArchiveFileTypeU2f,
- [ArchiveTabApps] = ArchiveFileTypeApps,
+ [ArchiveTabApplications] = ArchiveFileTypeApplication,
[ArchiveTabBrowser] = ArchiveFileTypeUnknown,
};
@@ -87,6 +87,6 @@ void archive_show_file_menu(ArchiveBrowserView* browser, bool show);
void archive_favorites_move_mode(ArchiveBrowserView* browser, bool active);
void archive_switch_tab(ArchiveBrowserView* browser, InputKey key);
-void archive_enter_dir(ArchiveBrowserView* browser, string_t name);
+void archive_enter_dir(ArchiveBrowserView* browser, FuriString* name);
void archive_leave_dir(ArchiveBrowserView* browser);
void archive_refresh_dir(ArchiveBrowserView* browser);
diff --git a/applications/main/archive/helpers/archive_favorites.c b/applications/main/archive/helpers/archive_favorites.c
index 4d5b555f5..86a294f78 100644
--- a/applications/main/archive/helpers/archive_favorites.c
+++ b/applications/main/archive/helpers/archive_favorites.c
@@ -6,8 +6,8 @@
#define ARCHIVE_FAV_FILE_BUF_LEN 32
-static bool archive_favorites_read_line(File* file, string_t str_result) {
- string_reset(str_result);
+static bool archive_favorites_read_line(File* file, FuriString* str_result) {
+ furi_string_reset(str_result);
uint8_t buffer[ARCHIVE_FAV_FILE_BUF_LEN];
bool result = false;
@@ -34,7 +34,7 @@ static bool archive_favorites_read_line(File* file, string_t str_result) {
result = true;
break;
} else {
- string_push_back(str_result, buffer[i]);
+ furi_string_push_back(str_result, buffer[i]);
}
}
@@ -52,8 +52,8 @@ uint16_t archive_favorites_count(void* context) {
Storage* fs_api = furi_record_open(RECORD_STORAGE);
File* file = storage_file_alloc(fs_api);
- string_t buffer;
- string_init(buffer);
+ FuriString* buffer;
+ buffer = furi_string_alloc();
bool result = storage_file_open(file, ARCHIVE_FAV_PATH, FSAM_READ, FSOM_OPEN_EXISTING);
uint16_t lines = 0;
@@ -63,7 +63,7 @@ uint16_t archive_favorites_count(void* context) {
if(!archive_favorites_read_line(file, buffer)) {
break;
}
- if(!string_size(buffer)) {
+ if(!furi_string_size(buffer)) {
continue; // Skip empty lines
}
++lines;
@@ -72,7 +72,7 @@ uint16_t archive_favorites_count(void* context) {
storage_file_close(file);
- string_clear(buffer);
+ furi_string_free(buffer);
storage_file_free(file);
furi_record_close(RECORD_STORAGE);
@@ -80,8 +80,8 @@ uint16_t archive_favorites_count(void* context) {
}
static bool archive_favourites_rescan() {
- string_t buffer;
- string_init(buffer);
+ FuriString* buffer;
+ buffer = furi_string_alloc();
Storage* storage = furi_record_open(RECORD_STORAGE);
File* file = storage_file_alloc(storage);
@@ -91,23 +91,25 @@ static bool archive_favourites_rescan() {
if(!archive_favorites_read_line(file, buffer)) {
break;
}
- if(!string_size(buffer)) {
+ if(!furi_string_size(buffer)) {
continue;
}
- if(string_search(buffer, "/app:") == 0) {
- if(archive_app_is_available(NULL, string_get_cstr(buffer))) {
- archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", string_get_cstr(buffer));
+ if(furi_string_search(buffer, "/app:") == 0) {
+ if(archive_app_is_available(NULL, furi_string_get_cstr(buffer))) {
+ archive_file_append(
+ ARCHIVE_FAV_TEMP_PATH, "%s\n", furi_string_get_cstr(buffer));
}
} else {
- if(storage_file_exists(storage, string_get_cstr(buffer))) {
- archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", string_get_cstr(buffer));
+ if(storage_file_exists(storage, furi_string_get_cstr(buffer))) {
+ archive_file_append(
+ ARCHIVE_FAV_TEMP_PATH, "%s\n", furi_string_get_cstr(buffer));
}
}
}
}
- string_clear(buffer);
+ furi_string_free(buffer);
storage_file_close(file);
storage_common_remove(storage, ARCHIVE_FAV_PATH);
@@ -127,9 +129,9 @@ bool archive_favorites_read(void* context) {
Storage* storage = furi_record_open(RECORD_STORAGE);
File* file = storage_file_alloc(storage);
- string_t buffer;
+ FuriString* buffer;
FileInfo file_info;
- string_init(buffer);
+ buffer = furi_string_alloc();
bool need_refresh = false;
uint16_t file_count = 0;
@@ -143,33 +145,33 @@ bool archive_favorites_read(void* context) {
if(!archive_favorites_read_line(file, buffer)) {
break;
}
- if(!string_size(buffer)) {
+ if(!furi_string_size(buffer)) {
continue;
}
- if(string_search(buffer, "/app:") == 0) {
- if(archive_app_is_available(browser, string_get_cstr(buffer))) {
- archive_add_app_item(browser, string_get_cstr(buffer));
+ if(furi_string_search(buffer, "/app:") == 0) {
+ if(archive_app_is_available(browser, furi_string_get_cstr(buffer))) {
+ archive_add_app_item(browser, furi_string_get_cstr(buffer));
file_count++;
} else {
need_refresh = true;
}
} else {
- if(storage_file_exists(storage, string_get_cstr(buffer))) {
- storage_common_stat(storage, string_get_cstr(buffer), &file_info);
+ if(storage_file_exists(storage, furi_string_get_cstr(buffer))) {
+ storage_common_stat(storage, furi_string_get_cstr(buffer), &file_info);
archive_add_file_item(
- browser, (file_info.flags & FSF_DIRECTORY), string_get_cstr(buffer));
+ browser, (file_info.flags & FSF_DIRECTORY), furi_string_get_cstr(buffer));
file_count++;
} else {
need_refresh = true;
}
}
- string_reset(buffer);
+ furi_string_reset(buffer);
}
}
storage_file_close(file);
- string_clear(buffer);
+ furi_string_free(buffer);
storage_file_free(file);
furi_record_close(RECORD_STORAGE);
@@ -183,14 +185,14 @@ bool archive_favorites_read(void* context) {
}
bool archive_favorites_delete(const char* format, ...) {
- string_t buffer;
- string_t filename;
+ FuriString* buffer;
+ FuriString* filename;
va_list args;
va_start(args, format);
- string_init_vprintf(filename, format, args);
+ filename = furi_string_alloc_vprintf(format, args);
va_end(args);
- string_init(buffer);
+ buffer = furi_string_alloc();
Storage* fs_api = furi_record_open(RECORD_STORAGE);
File* file = storage_file_alloc(fs_api);
@@ -201,18 +203,18 @@ bool archive_favorites_delete(const char* format, ...) {
if(!archive_favorites_read_line(file, buffer)) {
break;
}
- if(!string_size(buffer)) {
+ if(!furi_string_size(buffer)) {
continue;
}
- if(string_search(buffer, filename)) {
- archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", string_get_cstr(buffer));
+ if(furi_string_search(buffer, filename)) {
+ archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", furi_string_get_cstr(buffer));
}
}
}
- string_clear(buffer);
- string_clear(filename);
+ furi_string_free(buffer);
+ furi_string_free(filename);
storage_file_close(file);
storage_common_remove(fs_api, ARCHIVE_FAV_PATH);
@@ -226,14 +228,14 @@ bool archive_favorites_delete(const char* format, ...) {
}
bool archive_is_favorite(const char* format, ...) {
- string_t buffer;
- string_t filename;
+ FuriString* buffer;
+ FuriString* filename;
va_list args;
va_start(args, format);
- string_init_vprintf(filename, format, args);
+ filename = furi_string_alloc_vprintf(format, args);
va_end(args);
- string_init(buffer);
+ buffer = furi_string_alloc();
Storage* fs_api = furi_record_open(RECORD_STORAGE);
File* file = storage_file_alloc(fs_api);
@@ -245,10 +247,10 @@ bool archive_is_favorite(const char* format, ...) {
if(!archive_favorites_read_line(file, buffer)) {
break;
}
- if(!string_size(buffer)) {
+ if(!furi_string_size(buffer)) {
continue;
}
- if(!string_search(buffer, filename)) {
+ if(!furi_string_search(buffer, filename)) {
found = true;
break;
}
@@ -256,8 +258,8 @@ bool archive_is_favorite(const char* format, ...) {
}
storage_file_close(file);
- string_clear(buffer);
- string_clear(filename);
+ furi_string_free(buffer);
+ furi_string_free(filename);
storage_file_free(file);
furi_record_close(RECORD_STORAGE);
@@ -271,13 +273,13 @@ bool archive_favorites_rename(const char* src, const char* dst) {
Storage* fs_api = furi_record_open(RECORD_STORAGE);
File* file = storage_file_alloc(fs_api);
- string_t path;
- string_t buffer;
+ FuriString* path;
+ FuriString* buffer;
- string_init(buffer);
- string_init(path);
+ buffer = furi_string_alloc();
+ path = furi_string_alloc();
- string_printf(path, "%s", src);
+ furi_string_printf(path, "%s", src);
bool result = storage_file_open(file, ARCHIVE_FAV_PATH, FSAM_READ, FSOM_OPEN_EXISTING);
if(result) {
@@ -285,19 +287,19 @@ bool archive_favorites_rename(const char* src, const char* dst) {
if(!archive_favorites_read_line(file, buffer)) {
break;
}
- if(!string_size(buffer)) {
+ if(!furi_string_size(buffer)) {
continue;
}
archive_file_append(
ARCHIVE_FAV_TEMP_PATH,
"%s\n",
- string_search(buffer, path) ? string_get_cstr(buffer) : dst);
+ furi_string_search(buffer, path) ? furi_string_get_cstr(buffer) : dst);
}
}
- string_clear(buffer);
- string_clear(path);
+ furi_string_free(buffer);
+ furi_string_free(path);
storage_file_close(file);
storage_common_remove(fs_api, ARCHIVE_FAV_PATH);
@@ -325,7 +327,7 @@ void archive_favorites_save(void* context) {
for(size_t i = 0; i < archive_file_get_array_size(browser); i++) {
ArchiveFile_t* item = archive_get_file_at(browser, i);
- archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", string_get_cstr(item->path));
+ archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", furi_string_get_cstr(item->path));
}
storage_common_remove(fs_api, ARCHIVE_FAV_PATH);
diff --git a/applications/main/archive/helpers/archive_favorites.h b/applications/main/archive/helpers/archive_favorites.h
index 29eedcdb6..db8943378 100644
--- a/applications/main/archive/helpers/archive_favorites.h
+++ b/applications/main/archive/helpers/archive_favorites.h
@@ -7,8 +7,8 @@
uint16_t archive_favorites_count(void* context);
bool archive_favorites_read(void* context);
-bool archive_favorites_delete(const char* format, ...);
-bool archive_is_favorite(const char* format, ...);
+bool archive_favorites_delete(const char* format, ...) _ATTRIBUTE((__format__(__printf__, 1, 2)));
+bool archive_is_favorite(const char* format, ...) _ATTRIBUTE((__format__(__printf__, 1, 2)));
bool archive_favorites_rename(const char* src, const char* dst);
void archive_add_to_favorites(const char* file_path);
void archive_favorites_save(void* context);
diff --git a/applications/main/archive/helpers/archive_files.c b/applications/main/archive/helpers/archive_files.c
index d53c74da4..1bf51a2b0 100644
--- a/applications/main/archive/helpers/archive_files.c
+++ b/applications/main/archive/helpers/archive_files.c
@@ -15,10 +15,10 @@ void archive_set_file_type(ArchiveFile_t* file, const char* path, bool is_folder
} else {
for(size_t i = 0; i < COUNT_OF(known_ext); i++) {
if((known_ext[i][0] == '?') || (known_ext[i][0] == '*')) continue;
- if(string_search_str(file->path, known_ext[i], 0) != STRING_FAILURE) {
+ if(furi_string_search(file->path, known_ext[i], 0) != FURI_STRING_FAILURE) {
if(i == ArchiveFileTypeBadUsb) {
- if(string_search_str(file->path, archive_get_default_path(ArchiveTabBadUsb)) ==
- 0) {
+ if(furi_string_search(
+ file->path, archive_get_default_path(ArchiveTabBadUsb)) == 0) {
file->type = i;
return; // *.txt file is a BadUSB script only if it is in BadUSB folder
}
@@ -54,10 +54,10 @@ bool archive_get_items(void* context, const char* path) {
void archive_file_append(const char* path, const char* format, ...) {
furi_assert(path);
- string_t string;
+ FuriString* string;
va_list args;
va_start(args, format);
- string_init_vprintf(string, format, args);
+ string = furi_string_alloc_vprintf(format, args);
va_end(args);
Storage* fs_api = furi_record_open(RECORD_STORAGE);
@@ -66,7 +66,7 @@ void archive_file_append(const char* path, const char* format, ...) {
bool res = storage_file_open(file, path, FSAM_WRITE, FSOM_OPEN_APPEND);
if(res) {
- storage_file_write(file, string_get_cstr(string), string_size(string));
+ storage_file_write(file, furi_string_get_cstr(string), furi_string_size(string));
}
storage_file_close(file);
@@ -77,37 +77,37 @@ void archive_file_append(const char* path, const char* format, ...) {
void archive_delete_file(void* context, const char* format, ...) {
furi_assert(context);
- string_t filename;
+ FuriString* filename;
va_list args;
va_start(args, format);
- string_init_vprintf(filename, format, args);
+ filename = furi_string_alloc_vprintf(format, args);
va_end(args);
ArchiveBrowserView* browser = context;
Storage* fs_api = furi_record_open(RECORD_STORAGE);
FileInfo fileinfo;
- storage_common_stat(fs_api, string_get_cstr(filename), &fileinfo);
+ storage_common_stat(fs_api, furi_string_get_cstr(filename), &fileinfo);
bool res = false;
if(fileinfo.flags & FSF_DIRECTORY) {
- res = storage_simply_remove_recursive(fs_api, string_get_cstr(filename));
+ res = storage_simply_remove_recursive(fs_api, furi_string_get_cstr(filename));
} else {
- res = (storage_common_remove(fs_api, string_get_cstr(filename)) == FSE_OK);
+ res = (storage_common_remove(fs_api, furi_string_get_cstr(filename)) == FSE_OK);
}
furi_record_close(RECORD_STORAGE);
- if(archive_is_favorite("%s", string_get_cstr(filename))) {
- archive_favorites_delete("%s", string_get_cstr(filename));
+ if(archive_is_favorite("%s", furi_string_get_cstr(filename))) {
+ archive_favorites_delete("%s", furi_string_get_cstr(filename));
}
if(res) {
archive_file_array_rm_selected(browser);
}
- string_clear(filename);
+ furi_string_free(filename);
}
FS_Error archive_rename_file_or_dir(void* context, const char* src_path, const char* dst_path) {
diff --git a/applications/main/archive/helpers/archive_files.h b/applications/main/archive/helpers/archive_files.h
index de07a2e19..d7b25a64b 100644
--- a/applications/main/archive/helpers/archive_files.h
+++ b/applications/main/archive/helpers/archive_files.h
@@ -1,10 +1,12 @@
#pragma once
#include
-#include
+#include
#include
#include "toolbox/path.h"
+#define FAP_MANIFEST_MAX_ICON_SIZE 32
+
typedef enum {
ArchiveFileTypeIButton,
ArchiveFileTypeNFC,
@@ -13,7 +15,7 @@ typedef enum {
ArchiveFileTypeInfrared,
ArchiveFileTypeBadUsb,
ArchiveFileTypeU2f,
- ArchiveFileTypeApps,
+ ArchiveFileTypeApplication,
ArchiveFileTypeUpdateManifest,
ArchiveFileTypeFolder,
ArchiveFileTypeUnknown,
@@ -21,35 +23,58 @@ typedef enum {
} ArchiveFileTypeEnum;
typedef struct {
- string_t path;
+ FuriString* path;
ArchiveFileTypeEnum type;
+ uint8_t* custom_icon_data;
+ FuriString* custom_name;
bool fav;
bool is_app;
} ArchiveFile_t;
static void ArchiveFile_t_init(ArchiveFile_t* obj) {
+ obj->path = furi_string_alloc();
obj->type = ArchiveFileTypeUnknown;
- obj->is_app = false;
+ obj->custom_icon_data = NULL;
+ obj->custom_name = furi_string_alloc();
obj->fav = false;
- string_init(obj->path);
+ obj->is_app = false;
}
static void ArchiveFile_t_init_set(ArchiveFile_t* obj, const ArchiveFile_t* src) {
+ obj->path = furi_string_alloc_set(src->path);
obj->type = src->type;
- obj->is_app = src->is_app;
+ if(src->custom_icon_data) {
+ obj->custom_icon_data = malloc(FAP_MANIFEST_MAX_ICON_SIZE);
+ memcpy(obj->custom_icon_data, src->custom_icon_data, FAP_MANIFEST_MAX_ICON_SIZE);
+ } else {
+ obj->custom_icon_data = NULL;
+ }
+ obj->custom_name = furi_string_alloc_set(src->custom_name);
obj->fav = src->fav;
- string_init_set(obj->path, src->path);
+ obj->is_app = src->is_app;
}
static void ArchiveFile_t_set(ArchiveFile_t* obj, const ArchiveFile_t* src) {
+ furi_string_set(obj->path, src->path);
obj->type = src->type;
- obj->is_app = src->is_app;
+ if(src->custom_icon_data) {
+ obj->custom_icon_data = malloc(FAP_MANIFEST_MAX_ICON_SIZE);
+ memcpy(obj->custom_icon_data, src->custom_icon_data, FAP_MANIFEST_MAX_ICON_SIZE);
+ } else {
+ obj->custom_icon_data = NULL;
+ }
+ furi_string_set(obj->custom_name, src->custom_name);
obj->fav = src->fav;
- string_set(obj->path, src->path);
+ obj->is_app = src->is_app;
}
static void ArchiveFile_t_clear(ArchiveFile_t* obj) {
- string_clear(obj->path);
+ furi_string_free(obj->path);
+ if(obj->custom_icon_data) {
+ free(obj->custom_icon_data);
+ obj->custom_icon_data = NULL;
+ }
+ furi_string_free(obj->custom_name);
}
ARRAY_DEF(
@@ -62,6 +87,8 @@ ARRAY_DEF(
void archive_set_file_type(ArchiveFile_t* file, const char* path, bool is_folder, bool is_app);
bool archive_get_items(void* context, const char* path);
-void archive_file_append(const char* path, const char* format, ...);
-void archive_delete_file(void* context, const char* format, ...);
+void archive_file_append(const char* path, const char* format, ...)
+ _ATTRIBUTE((__format__(__printf__, 2, 3)));
+void archive_delete_file(void* context, const char* format, ...)
+ _ATTRIBUTE((__format__(__printf__, 2, 3)));
FS_Error archive_rename_file_or_dir(void* context, const char* src_path, const char* dst_path);
diff --git a/applications/main/archive/helpers/archive_menu.h b/applications/main/archive/helpers/archive_menu.h
index 201333987..4a85b851d 100644
--- a/applications/main/archive/helpers/archive_menu.h
+++ b/applications/main/archive/helpers/archive_menu.h
@@ -1,34 +1,34 @@
#pragma once
+#include
#include
-#include
typedef struct {
- string_t text;
+ FuriString* text;
uint32_t event;
} ArchiveContextMenuItem_t;
static void ArchiveContextMenuItem_t_init(ArchiveContextMenuItem_t* obj) {
- string_init(obj->text);
+ obj->text = furi_string_alloc();
obj->event = 0; // ArchiveBrowserEventFileMenuNone
}
static void ArchiveContextMenuItem_t_init_set(
ArchiveContextMenuItem_t* obj,
const ArchiveContextMenuItem_t* src) {
- string_init_set(obj->text, src->text);
+ obj->text = furi_string_alloc_set(src->text);
obj->event = src->event;
}
static void ArchiveContextMenuItem_t_set(
ArchiveContextMenuItem_t* obj,
const ArchiveContextMenuItem_t* src) {
- string_init_set(obj->text, src->text);
+ furi_string_set(obj->text, src->text);
obj->event = src->event;
}
static void ArchiveContextMenuItem_t_clear(ArchiveContextMenuItem_t* obj) {
- string_clear(obj->text);
+ furi_string_free(obj->text);
}
ARRAY_DEF(
@@ -42,8 +42,9 @@ ARRAY_DEF(
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
// Using in applications/archive/views/archive_browser_view.c
-static void archive_menu_add_item(ArchiveContextMenuItem_t* obj, string_t text, uint32_t event) {
- string_init_move(obj->text, text);
+static void
+ archive_menu_add_item(ArchiveContextMenuItem_t* obj, FuriString* text, uint32_t event) {
+ obj->text = furi_string_alloc_set(text);
obj->event = event;
}
#pragma GCC diagnostic pop
\ No newline at end of file
diff --git a/applications/main/archive/scenes/archive_scene_browser.c b/applications/main/archive/scenes/archive_scene_browser.c
index 552a6557e..dbf221990 100644
--- a/applications/main/archive/scenes/archive_scene_browser.c
+++ b/applications/main/archive/scenes/archive_scene_browser.c
@@ -19,7 +19,7 @@ static const char* flipper_app_name[] = {
[ArchiveFileTypeInfrared] = "Infrared",
[ArchiveFileTypeBadUsb] = "Bad USB",
[ArchiveFileTypeU2f] = "U2F",
- [ArchiveFileTypeApps] = "Applications",
+ [ArchiveFileTypeApplication] = "Applications",
[ArchiveFileTypeUpdateManifest] = "UpdaterApp",
};
@@ -41,14 +41,14 @@ static void archive_run_in_app(ArchiveBrowserView* browser, ArchiveFile_t* selec
LoaderStatus status;
if(selected->is_app) {
- char* param = strrchr(string_get_cstr(selected->path), '/');
+ char* param = strrchr(furi_string_get_cstr(selected->path), '/');
if(param != NULL) {
param++;
}
status = loader_start(loader, flipper_app_name[selected->type], param);
} else {
status = loader_start(
- loader, flipper_app_name[selected->type], string_get_cstr(selected->path));
+ loader, flipper_app_name[selected->type], furi_string_get_cstr(selected->path));
}
if(status != LoaderStatusOk) {
@@ -169,13 +169,13 @@ bool archive_scene_browser_on_event(void* context, SceneManagerEvent event) {
consumed = true;
break;
case ArchiveBrowserEventEnterFavMove:
- string_set(archive->fav_move_str, selected->path);
+ furi_string_set(archive->fav_move_str, selected->path);
archive_show_file_menu(browser, false);
archive_favorites_move_mode(archive->browser, true);
consumed = true;
break;
case ArchiveBrowserEventExitFavMove:
- archive_update_focus(browser, string_get_cstr(archive->fav_move_str));
+ archive_update_focus(browser, furi_string_get_cstr(archive->fav_move_str));
archive_favorites_move_mode(archive->browser, false);
consumed = true;
break;
diff --git a/applications/main/archive/scenes/archive_scene_delete.c b/applications/main/archive/scenes/archive_scene_delete.c
index cca84fea3..6c7a90cb4 100644
--- a/applications/main/archive/scenes/archive_scene_delete.c
+++ b/applications/main/archive/scenes/archive_scene_delete.c
@@ -22,18 +22,18 @@ void archive_scene_delete_on_enter(void* context) {
widget_add_button_element(
app->widget, GuiButtonTypeRight, "Delete", archive_scene_delete_widget_callback, app);
- string_t filename;
- string_init(filename);
+ FuriString* filename;
+ filename = furi_string_alloc();
ArchiveFile_t* current = archive_get_current_file(app->browser);
path_extract_filename(current->path, filename, false);
char delete_str[64];
- snprintf(delete_str, sizeof(delete_str), "\e#Delete %s?\e#", string_get_cstr(filename));
+ snprintf(delete_str, sizeof(delete_str), "\e#Delete %s?\e#", furi_string_get_cstr(filename));
widget_add_text_box_element(
app->widget, 0, 0, 128, 23, AlignCenter, AlignCenter, delete_str, false);
- string_clear(filename);
+ furi_string_free(filename);
view_dispatcher_switch_to_view(app->view_dispatcher, ArchiveViewWidget);
}
diff --git a/applications/main/archive/scenes/archive_scene_info.c b/applications/main/archive/scenes/archive_scene_info.c
index 08c403b4b..e1a963d33 100644
--- a/applications/main/archive/scenes/archive_scene_info.c
+++ b/applications/main/archive/scenes/archive_scene_info.c
@@ -18,12 +18,12 @@ void archive_scene_info_on_enter(void* context) {
widget_add_button_element(
instance->widget, GuiButtonTypeLeft, "Back", archive_scene_info_widget_callback, instance);
- string_t filename;
- string_t dirname;
- string_t str_size;
- string_init(filename);
- string_init(dirname);
- string_init(str_size);
+ FuriString* filename;
+ FuriString* dirname;
+ FuriString* str_size;
+ filename = furi_string_alloc();
+ dirname = furi_string_alloc();
+ str_size = furi_string_alloc();
ArchiveFile_t* current = archive_get_current_file(instance->browser);
char file_info_message[128];
@@ -31,48 +31,49 @@ void archive_scene_info_on_enter(void* context) {
// Filename
path_extract_filename(current->path, filename, false);
- snprintf(file_info_message, sizeof(file_info_message), "\e#%s\e#", string_get_cstr(filename));
+ snprintf(
+ file_info_message, sizeof(file_info_message), "\e#%s\e#", furi_string_get_cstr(filename));
widget_add_text_box_element(
instance->widget, 0, 0, 128, 25, AlignLeft, AlignCenter, file_info_message, false);
// Directory path
- path_extract_dirname(string_get_cstr(current->path), dirname);
- if(strcmp(string_get_cstr(dirname), "/any") == 0) {
- string_replace_str(dirname, STORAGE_ANY_PATH_PREFIX, "/");
+ path_extract_dirname(furi_string_get_cstr(current->path), dirname);
+ if(strcmp(furi_string_get_cstr(dirname), "/any") == 0) {
+ furi_string_replace(dirname, STORAGE_ANY_PATH_PREFIX, "/");
} else {
- string_replace_str(dirname, STORAGE_ANY_PATH_PREFIX, "");
+ furi_string_replace(dirname, STORAGE_ANY_PATH_PREFIX, "");
}
// File size
FileInfo fileinfo;
- storage_common_stat(fs_api, string_get_cstr(current->path), &fileinfo);
+ storage_common_stat(fs_api, furi_string_get_cstr(current->path), &fileinfo);
if(fileinfo.size <= 1024) {
- string_printf(str_size, "%d", fileinfo.size);
+ furi_string_printf(str_size, "%lld", fileinfo.size);
snprintf(
file_info_message,
sizeof(file_info_message),
"Size: \e#%s\e# bytes\n%s",
- string_get_cstr(str_size),
- string_get_cstr(dirname));
+ furi_string_get_cstr(str_size),
+ furi_string_get_cstr(dirname));
} else {
- string_printf(str_size, "%d", fileinfo.size / 1024);
+ furi_string_printf(str_size, "%lld", fileinfo.size / 1024);
snprintf(
file_info_message,
sizeof(file_info_message),
"Size: \e#%s\e# Kb.\n%s",
- string_get_cstr(str_size),
- string_get_cstr(dirname));
+ furi_string_get_cstr(str_size),
+ furi_string_get_cstr(dirname));
}
widget_add_text_box_element(
instance->widget, 0, 25, 128, 25, AlignLeft, AlignCenter, file_info_message, true);
// This one to return and cursor select this file
- path_extract_filename_no_ext(string_get_cstr(current->path), filename);
- strlcpy(instance->text_store, string_get_cstr(filename), MAX_NAME_LEN);
+ path_extract_filename_no_ext(furi_string_get_cstr(current->path), filename);
+ strlcpy(instance->text_store, furi_string_get_cstr(filename), MAX_NAME_LEN);
- string_clear(filename);
- string_clear(dirname);
- string_clear(str_size);
+ furi_string_free(filename);
+ furi_string_free(dirname);
+ furi_string_free(str_size);
view_dispatcher_switch_to_view(instance->view_dispatcher, ArchiveViewWidget);
}
diff --git a/applications/main/archive/scenes/archive_scene_rename.c b/applications/main/archive/scenes/archive_scene_rename.c
index ca15ee88e..5512b0619 100644
--- a/applications/main/archive/scenes/archive_scene_rename.c
+++ b/applications/main/archive/scenes/archive_scene_rename.c
@@ -22,22 +22,22 @@ void archive_scene_rename_on_enter(void* context) {
TextInput* text_input = archive->text_input;
ArchiveFile_t* current = archive_get_current_file(archive->browser);
- string_t path_name;
- string_init(path_name);
+ FuriString* path_name;
+ path_name = furi_string_alloc();
if(current->type == ArchiveFileTypeFolder) {
- path_extract_basename(string_get_cstr(current->path), path_name);
- strlcpy(archive->text_store, string_get_cstr(path_name), MAX_NAME_LEN);
+ path_extract_basename(furi_string_get_cstr(current->path), path_name);
+ strlcpy(archive->text_store, furi_string_get_cstr(path_name), MAX_NAME_LEN);
text_input_set_header_text(text_input, "Rename directory:");
} else /*if(current->type != ArchiveFileTypeUnknown) */ {
path_extract_filename(current->path, path_name, true);
- strlcpy(archive->text_store, string_get_cstr(path_name), MAX_NAME_LEN);
+ strlcpy(archive->text_store, furi_string_get_cstr(path_name), MAX_NAME_LEN);
path_extract_extension(current->path, archive->file_extension, MAX_EXT_LEN);
text_input_set_header_text(text_input, "Rename file:");
} /*else {
path_extract_filename(current->path, path_name, false);
- strlcpy(archive->text_store, string_get_cstr(path_name), MAX_NAME_LEN);
+ strlcpy(archive->text_store, furi_string_get_cstr(path_name), MAX_NAME_LEN);
text_input_set_header_text(text_input, "Rename unknown file:");
}*/
@@ -49,7 +49,7 @@ void archive_scene_rename_on_enter(void* context) {
MAX_TEXT_INPUT_LEN,
false);
- string_clear(path_name);
+ furi_string_free(path_name);
view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewTextInput);
}
@@ -63,40 +63,43 @@ bool archive_scene_rename_on_event(void* context, SceneManagerEvent event) {
const char* path_src = archive_get_name(archive->browser);
ArchiveFile_t* file = archive_get_current_file(archive->browser);
- string_t path_dst;
- string_init(path_dst);
+ FuriString* path_dst;
+ path_dst = furi_string_alloc();
if(file->type == ArchiveFileTypeFolder) {
// Rename folder/dir
path_extract_dirname(path_src, path_dst);
- string_cat_printf(path_dst, "/%s", archive->text_store);
+ furi_string_cat_printf(path_dst, "/%s", archive->text_store);
} else if(file->type != ArchiveFileTypeUnknown) {
// Rename known type
path_extract_dirname(path_src, path_dst);
- string_cat_printf(path_dst, "/%s%s", archive->text_store, known_ext[file->type]);
+ furi_string_cat_printf(
+ path_dst, "/%s%s", archive->text_store, known_ext[file->type]);
} else {
// Rename unknown type
path_extract_dirname(path_src, path_dst);
- string_cat_printf(path_dst, "/%s%s", archive->text_store, archive->file_extension);
+ furi_string_cat_printf(
+ path_dst, "/%s%s", archive->text_store, archive->file_extension);
}
// Long time process if this is directory
view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewStack);
archive_show_loading_popup(archive, true);
- FS_Error error =
- archive_rename_file_or_dir(archive->browser, path_src, string_get_cstr(path_dst));
+ FS_Error error = archive_rename_file_or_dir(
+ archive->browser, path_src, furi_string_get_cstr(path_dst));
archive_show_loading_popup(archive, false);
archive_show_file_menu(archive->browser, false);
- string_clear(path_dst);
+ furi_string_free(path_dst);
if(error == FSE_OK || error == FSE_EXIST) {
scene_manager_next_scene(archive->scene_manager, ArchiveAppSceneBrowser);
} else {
- string_t dialog_msg;
- string_init(dialog_msg);
- string_cat_printf(dialog_msg, "Cannot rename\nCode: %d", error);
- dialog_message_show_storage_error(archive->dialogs, string_get_cstr(dialog_msg));
- string_clear(dialog_msg);
+ FuriString* dialog_msg;
+ dialog_msg = furi_string_alloc();
+ furi_string_cat_printf(dialog_msg, "Cannot rename\nCode: %d", error);
+ dialog_message_show_storage_error(
+ archive->dialogs, furi_string_get_cstr(dialog_msg));
+ furi_string_free(dialog_msg);
}
consumed = true;
}
diff --git a/applications/main/archive/views/archive_browser_view.c b/applications/main/archive/views/archive_browser_view.c
index d82145bea..0f9cd0723 100644
--- a/applications/main/archive/views/archive_browser_view.c
+++ b/applications/main/archive/views/archive_browser_view.c
@@ -16,7 +16,7 @@ static const char* ArchiveTabNames[] = {
[ArchiveTabInfrared] = "Infrared",
[ArchiveTabBadUsb] = "Bad USB",
[ArchiveTabU2f] = "U2F",
- [ArchiveTabApps] = "Apps",
+ [ArchiveTabApplications] = "Apps",
[ArchiveTabBrowser] = "Browser",
};
@@ -28,7 +28,7 @@ static const Icon* ArchiveItemIcons[] = {
[ArchiveFileTypeInfrared] = &I_ir_10px,
[ArchiveFileTypeBadUsb] = &I_badusb_10px,
[ArchiveFileTypeU2f] = &I_u2f_10px,
- [ArchiveFileTypeApps] = &I_Apps_10px,
+ [ArchiveFileTypeApplication] = &I_Apps_10px,
[ArchiveFileTypeUpdateManifest] = &I_update_10px,
[ArchiveFileTypeFolder] = &I_dir_10px,
[ArchiveFileTypeUnknown] = &I_unknown_10px,
@@ -48,24 +48,18 @@ void archive_browser_set_callback(
static void render_item_menu(Canvas* canvas, ArchiveBrowserViewModel* model) {
if(menu_array_size(model->context_menu) == 0) {
// Context menu is empty, init array
- string_t item_run;
- string_t item_pin;
- string_t item_info;
- string_t item_rename;
- string_t item_delete;
-
- string_init_set_str(item_run, "Run In App");
- string_init_set_str(item_pin, "Pin");
- string_init_set_str(item_info, "Info");
- string_init_set_str(item_rename, "Rename");
- string_init_set_str(item_delete, "Delete");
+ FuriString* item_run = furi_string_alloc_set("Run In App");
+ FuriString* item_pin = furi_string_alloc_set("Pin");
+ FuriString* item_info = furi_string_alloc_set("Info");
+ FuriString* item_rename = furi_string_alloc_set("Rename");
+ FuriString* item_delete = furi_string_alloc_set("Delete");
// Need init context menu
ArchiveFile_t* selected =
files_array_get(model->files, model->item_idx - model->array_offset);
if((selected->fav) || (model->tab_idx == ArchiveTabFavorites)) {
- string_set_str(item_pin, "Unpin");
+ furi_string_set(item_pin, "Unpin");
}
if(selected->type == ArchiveFileTypeFolder) {
@@ -96,7 +90,7 @@ static void render_item_menu(Canvas* canvas, ArchiveBrowserViewModel* model) {
} else if(model->tab_idx == ArchiveTabFavorites) {
//FURI_LOG_D(TAG, "ArchiveTabFavorites");
- string_set_str(item_rename, "Move");
+ furi_string_set(item_rename, "Move");
archive_menu_add_item(
menu_array_push_raw(model->context_menu),
@@ -152,11 +146,11 @@ static void render_item_menu(Canvas* canvas, ArchiveBrowserViewModel* model) {
ArchiveBrowserEventFileMenuDelete);
}
- string_clear(item_run);
- string_clear(item_pin);
- string_clear(item_info);
- string_clear(item_rename);
- string_clear(item_delete);
+ furi_string_free(item_run);
+ furi_string_free(item_pin);
+ furi_string_free(item_info);
+ furi_string_free(item_rename);
+ furi_string_free(item_delete);
} /*else {
FURI_LOG_D(TAG, "menu_array_size already set: %d", menu_array_size(model->context_menu));
}*/
@@ -178,7 +172,7 @@ static void render_item_menu(Canvas* canvas, ArchiveBrowserViewModel* model) {
model->menu_idx);*/
for(size_t i = 0; i < size_menu; i++) {
ArchiveContextMenuItem_t* current = menu_array_get(model->context_menu, i);
- canvas_draw_str(canvas, 82, 21 + i * line_height, string_get_cstr(current->text));
+ canvas_draw_str(canvas, 82, 21 + i * line_height, furi_string_get_cstr(current->text));
}
canvas_draw_icon(canvas, 74, 14 + model->menu_idx * line_height, &I_ButtonRight_4x7);
@@ -221,20 +215,31 @@ static void draw_list(Canvas* canvas, ArchiveBrowserViewModel* model) {
bool scrollbar = model->item_cnt > 4;
for(uint32_t i = 0; i < MIN(model->item_cnt, MENU_ITEMS); ++i) {
- string_t str_buf;
- string_init(str_buf);
+ FuriString* str_buf;
+ str_buf = furi_string_alloc();
int32_t idx = CLAMP((uint32_t)(i + model->list_offset), model->item_cnt, 0u);
uint8_t x_offset = (model->move_fav && model->item_idx == idx) ? MOVE_OFFSET : 0;
ArchiveFileTypeEnum file_type = ArchiveFileTypeLoading;
+ uint8_t* custom_icon_data = NULL;
if(archive_is_item_in_array(model, idx)) {
ArchiveFile_t* file = files_array_get(
model->files, CLAMP(idx - model->array_offset, (int32_t)(array_size - 1), 0));
- path_extract_filename(file->path, str_buf, archive_is_known_app(file->type));
file_type = file->type;
+ if(file_type == ArchiveFileTypeApplication) {
+ if(file->custom_icon_data) {
+ custom_icon_data = file->custom_icon_data;
+ furi_string_set(str_buf, file->custom_name);
+ } else {
+ file_type = ArchiveFileTypeUnknown;
+ path_extract_filename(file->path, str_buf, archive_is_known_app(file->type));
+ }
+ } else {
+ path_extract_filename(file->path, str_buf, archive_is_known_app(file->type));
+ }
} else {
- string_set_str(str_buf, "---");
+ furi_string_set(str_buf, "---");
}
elements_string_fit_width(
@@ -246,10 +251,17 @@ static void draw_list(Canvas* canvas, ArchiveBrowserViewModel* model) {
canvas_set_color(canvas, ColorBlack);
}
- canvas_draw_icon(canvas, 2 + x_offset, 16 + i * FRAME_HEIGHT, ArchiveItemIcons[file_type]);
- canvas_draw_str(canvas, 15 + x_offset, 24 + i * FRAME_HEIGHT, string_get_cstr(str_buf));
+ if(custom_icon_data) {
+ canvas_draw_bitmap(
+ canvas, 2 + x_offset, 16 + i * FRAME_HEIGHT, 11, 10, custom_icon_data);
+ } else {
+ canvas_draw_icon(
+ canvas, 2 + x_offset, 16 + i * FRAME_HEIGHT, ArchiveItemIcons[file_type]);
+ }
+ canvas_draw_str(
+ canvas, 15 + x_offset, 24 + i * FRAME_HEIGHT, furi_string_get_cstr(str_buf));
- string_clear(str_buf);
+ furi_string_free(str_buf);
}
if(scrollbar) {
@@ -465,7 +477,7 @@ ArchiveBrowserView* browser_alloc() {
view_set_draw_callback(browser->view, archive_view_render);
view_set_input_callback(browser->view, archive_view_input);
- string_init_set_str(browser->path, archive_get_default_path(TAB_DEFAULT));
+ browser->path = furi_string_alloc_set(archive_get_default_path(TAB_DEFAULT));
with_view_model(
browser->view, (ArchiveBrowserViewModel * model) {
@@ -492,7 +504,7 @@ void browser_free(ArchiveBrowserView* browser) {
return false;
});
- string_clear(browser->path);
+ furi_string_free(browser->path);
view_free(browser->view);
free(browser);
diff --git a/applications/main/archive/views/archive_browser_view.h b/applications/main/archive/views/archive_browser_view.h
index c19ccab84..67b50cb02 100644
--- a/applications/main/archive/views/archive_browser_view.h
+++ b/applications/main/archive/views/archive_browser_view.h
@@ -27,7 +27,7 @@ typedef enum {
ArchiveTabIButton,
ArchiveTabBadUsb,
ArchiveTabU2f,
- ArchiveTabApps,
+ ArchiveTabApplications,
ArchiveTabBrowser,
ArchiveTabTotal,
} ArchiveTabEnum;
@@ -74,7 +74,7 @@ struct ArchiveBrowserView {
bool worker_running;
ArchiveBrowserViewCallback callback;
void* context;
- string_t path;
+ FuriString* path;
InputKey last_tab_switch_dir;
bool is_root;
};
diff --git a/applications/main/bad_usb/bad_usb_app.c b/applications/main/bad_usb/bad_usb_app.c
index bf3f7741f..bb29d3be5 100644
--- a/applications/main/bad_usb/bad_usb_app.c
+++ b/applications/main/bad_usb/bad_usb_app.c
@@ -1,6 +1,5 @@
#include "bad_usb_app_i.h"
#include "bad_usb_settings_filename.h"
-#include "m-string.h"
#include
#include
#include
@@ -32,7 +31,7 @@ static void bad_usb_load_settings(BadUsbApp* app) {
char chr;
while((storage_file_read(settings_file, &chr, 1) == 1) &&
!storage_file_eof(settings_file) && !isspace(chr)) {
- string_push_back(app->keyboard_layout, chr);
+ furi_string_push_back(app->keyboard_layout, chr);
}
}
storage_file_close(settings_file);
@@ -44,8 +43,8 @@ static void bad_usb_save_settings(BadUsbApp* app) {
if(storage_file_open(settings_file, BAD_USB_SETTINGS_PATH, FSAM_WRITE, FSOM_OPEN_ALWAYS)) {
storage_file_write(
settings_file,
- string_get_cstr(app->keyboard_layout),
- string_size(app->keyboard_layout));
+ furi_string_get_cstr(app->keyboard_layout),
+ furi_string_size(app->keyboard_layout));
storage_file_write(settings_file, "\n", 1);
}
storage_file_close(settings_file);
@@ -57,10 +56,10 @@ BadUsbApp* bad_usb_app_alloc(char* arg) {
app->bad_usb_script = NULL;
- string_init(app->file_path);
- string_init(app->keyboard_layout);
+ app->file_path = furi_string_alloc();
+ app->keyboard_layout = furi_string_alloc();
if(arg && strlen(arg)) {
- string_set_str(app->file_path, arg);
+ furi_string_set(app->file_path, arg);
}
bad_usb_load_settings(app);
@@ -101,12 +100,12 @@ BadUsbApp* bad_usb_app_alloc(char* arg) {
app->error = BadUsbAppErrorCloseRpc;
scene_manager_next_scene(app->scene_manager, BadUsbSceneError);
} else {
- if(!string_empty_p(app->file_path)) {
+ if(!furi_string_empty(app->file_path)) {
app->bad_usb_script = bad_usb_script_open(app->file_path);
bad_usb_script_set_keyboard_layout(app->bad_usb_script, app->keyboard_layout);
scene_manager_next_scene(app->scene_manager, BadUsbSceneWork);
} else {
- string_set_str(app->file_path, BAD_USB_APP_BASE_FOLDER);
+ furi_string_set(app->file_path, BAD_USB_APP_BASE_FOLDER);
scene_manager_next_scene(app->scene_manager, BadUsbSceneFileSelect);
}
}
@@ -145,8 +144,8 @@ void bad_usb_app_free(BadUsbApp* app) {
bad_usb_save_settings(app);
- string_clear(app->file_path);
- string_clear(app->keyboard_layout);
+ furi_string_free(app->file_path);
+ furi_string_free(app->keyboard_layout);
free(app);
}
diff --git a/applications/main/bad_usb/bad_usb_app_i.h b/applications/main/bad_usb/bad_usb_app_i.h
index 392411485..e950c0198 100644
--- a/applications/main/bad_usb/bad_usb_app_i.h
+++ b/applications/main/bad_usb/bad_usb_app_i.h
@@ -34,8 +34,8 @@ struct BadUsbApp {
Submenu* submenu;
BadUsbAppError error;
- string_t file_path;
- string_t keyboard_layout;
+ FuriString* file_path;
+ FuriString* keyboard_layout;
BadUsb* bad_usb_view;
BadUsbScript* bad_usb_script;
};
diff --git a/applications/main/bad_usb/bad_usb_script.c b/applications/main/bad_usb/bad_usb_script.c
index 140ffffea..f9d2a6b64 100644
--- a/applications/main/bad_usb/bad_usb_script.c
+++ b/applications/main/bad_usb/bad_usb_script.c
@@ -29,7 +29,7 @@ typedef enum {
struct BadUsbScript {
FuriHalUsbHidConfig hid_cfg;
BadUsbState st;
- string_t file_path;
+ FuriString* file_path;
uint32_t defdelay;
uint16_t layout[128];
FuriThread* thread;
@@ -37,9 +37,9 @@ struct BadUsbScript {
uint8_t buf_start;
uint8_t buf_len;
bool file_end;
- string_t line;
+ FuriString* line;
- string_t line_prev;
+ FuriString* line_prev;
uint32_t repeat_cnt;
};
@@ -236,9 +236,9 @@ static uint16_t ducky_get_keycode(BadUsbScript* bad_usb, const char* param, bool
return 0;
}
-static int32_t ducky_parse_line(BadUsbScript* bad_usb, string_t line) {
- uint32_t line_len = string_size(line);
- const char* line_tmp = string_get_cstr(line);
+static int32_t ducky_parse_line(BadUsbScript* bad_usb, FuriString* line) {
+ uint32_t line_len = furi_string_size(line);
+ const char* line_tmp = furi_string_get_cstr(line);
bool state = false;
for(uint32_t i = 0; i < line_len; i++) {
@@ -332,7 +332,7 @@ static bool ducky_set_usb_id(BadUsbScript* bad_usb, const char* line) {
}
FURI_LOG_D(
WORKER_TAG,
- "set id: %04X:%04X mfr:%s product:%s",
+ "set id: %04lX:%04lX mfr:%s product:%s",
bad_usb->hid_cfg.vid,
bad_usb->hid_cfg.pid,
bad_usb->hid_cfg.manuf,
@@ -346,7 +346,7 @@ static bool ducky_script_preload(BadUsbScript* bad_usb, File* script_file) {
uint8_t ret = 0;
uint32_t line_len = 0;
- string_reset(bad_usb->line);
+ furi_string_reset(bad_usb->line);
do {
ret = storage_file_read(script_file, bad_usb->file_buf, FILE_BUFFER_LEN);
@@ -356,7 +356,7 @@ static bool ducky_script_preload(BadUsbScript* bad_usb, File* script_file) {
line_len = 0;
} else {
if(bad_usb->st.line_nb == 0) { // Save first line
- string_push_back(bad_usb->line, bad_usb->file_buf[i]);
+ furi_string_push_back(bad_usb->line, bad_usb->file_buf[i]);
}
line_len++;
}
@@ -369,7 +369,7 @@ static bool ducky_script_preload(BadUsbScript* bad_usb, File* script_file) {
}
} while(ret > 0);
- const char* line_tmp = string_get_cstr(bad_usb->line);
+ const char* line_tmp = furi_string_get_cstr(bad_usb->line);
bool id_set = false; // Looking for ID command at first line
if(strncmp(line_tmp, ducky_cmd_id, strlen(ducky_cmd_id)) == 0) {
id_set = ducky_set_usb_id(bad_usb, &line_tmp[strlen(ducky_cmd_id) + 1]);
@@ -382,7 +382,7 @@ static bool ducky_script_preload(BadUsbScript* bad_usb, File* script_file) {
}
storage_file_seek(script_file, 0, true);
- string_reset(bad_usb->line);
+ furi_string_reset(bad_usb->line);
return true;
}
@@ -397,15 +397,15 @@ static int32_t ducky_script_execute_next(BadUsbScript* bad_usb, File* script_fil
return 0;
} else if(delay_val < 0) { // Script error
bad_usb->st.error_line = bad_usb->st.line_cur - 1;
- FURI_LOG_E(WORKER_TAG, "Unknown command at line %lu", bad_usb->st.line_cur - 1);
+ FURI_LOG_E(WORKER_TAG, "Unknown command at line %u", bad_usb->st.line_cur - 1);
return SCRIPT_STATE_ERROR;
} else {
return (delay_val + bad_usb->defdelay);
}
}
- string_set(bad_usb->line_prev, bad_usb->line);
- string_reset(bad_usb->line);
+ furi_string_set(bad_usb->line_prev, bad_usb->line);
+ furi_string_reset(bad_usb->line);
while(1) {
if(bad_usb->buf_len == 0) {
@@ -422,20 +422,20 @@ static int32_t ducky_script_execute_next(BadUsbScript* bad_usb, File* script_fil
if(bad_usb->buf_len == 0) return SCRIPT_STATE_END;
}
for(uint8_t i = bad_usb->buf_start; i < (bad_usb->buf_start + bad_usb->buf_len); i++) {
- if(bad_usb->file_buf[i] == '\n' && string_size(bad_usb->line) > 0) {
+ if(bad_usb->file_buf[i] == '\n' && furi_string_size(bad_usb->line) > 0) {
bad_usb->st.line_cur++;
bad_usb->buf_len = bad_usb->buf_len + bad_usb->buf_start - (i + 1);
bad_usb->buf_start = i + 1;
delay_val = ducky_parse_line(bad_usb, bad_usb->line);
if(delay_val < 0) {
bad_usb->st.error_line = bad_usb->st.line_cur;
- FURI_LOG_E(WORKER_TAG, "Unknown command at line %lu", bad_usb->st.line_cur);
+ FURI_LOG_E(WORKER_TAG, "Unknown command at line %u", bad_usb->st.line_cur);
return SCRIPT_STATE_ERROR;
} else {
return (delay_val + bad_usb->defdelay);
}
} else {
- string_push_back(bad_usb->line, bad_usb->file_buf[i]);
+ furi_string_push_back(bad_usb->line, bad_usb->file_buf[i]);
}
}
bad_usb->buf_len = 0;
@@ -465,8 +465,8 @@ static int32_t bad_usb_worker(void* context) {
FURI_LOG_I(WORKER_TAG, "Init");
File* script_file = storage_file_alloc(furi_record_open(RECORD_STORAGE));
- string_init(bad_usb->line);
- string_init(bad_usb->line_prev);
+ bad_usb->line = furi_string_alloc();
+ bad_usb->line_prev = furi_string_alloc();
furi_hal_hid_set_state_callback(bad_usb_hid_state_callback, bad_usb);
@@ -474,7 +474,7 @@ static int32_t bad_usb_worker(void* context) {
if(worker_state == BadUsbStateInit) { // State: initialization
if(storage_file_open(
script_file,
- string_get_cstr(bad_usb->file_path),
+ furi_string_get_cstr(bad_usb->file_path),
FSAM_READ,
FSOM_OPEN_EXISTING)) {
if((ducky_script_preload(bad_usb, script_file)) && (bad_usb->st.line_nb > 0)) {
@@ -586,8 +586,8 @@ static int32_t bad_usb_worker(void* context) {
storage_file_close(script_file);
storage_file_free(script_file);
- string_clear(bad_usb->line);
- string_clear(bad_usb->line_prev);
+ furi_string_free(bad_usb->line);
+ furi_string_free(bad_usb->line_prev);
FURI_LOG_I(WORKER_TAG, "End");
@@ -600,12 +600,12 @@ static void bad_usb_script_set_default_keyboard_layout(BadUsbScript* bad_usb) {
memcpy(bad_usb->layout, hid_asciimap, MIN(sizeof(hid_asciimap), sizeof(bad_usb->layout)));
}
-BadUsbScript* bad_usb_script_open(string_t file_path) {
+BadUsbScript* bad_usb_script_open(FuriString* file_path) {
furi_assert(file_path);
BadUsbScript* bad_usb = malloc(sizeof(BadUsbScript));
- string_init(bad_usb->file_path);
- string_set(bad_usb->file_path, file_path);
+ bad_usb->file_path = furi_string_alloc();
+ furi_string_set(bad_usb->file_path, file_path);
bad_usb_script_set_default_keyboard_layout(bad_usb);
bad_usb->st.state = BadUsbStateInit;
@@ -625,11 +625,11 @@ void bad_usb_script_close(BadUsbScript* bad_usb) {
furi_thread_flags_set(furi_thread_get_id(bad_usb->thread), WorkerEvtEnd);
furi_thread_join(bad_usb->thread);
furi_thread_free(bad_usb->thread);
- string_clear(bad_usb->file_path);
+ furi_string_free(bad_usb->file_path);
free(bad_usb);
}
-void bad_usb_script_set_keyboard_layout(BadUsbScript* bad_usb, string_t layout_path) {
+void bad_usb_script_set_keyboard_layout(BadUsbScript* bad_usb, FuriString* layout_path) {
furi_assert(bad_usb);
if((bad_usb->st.state == BadUsbStateRunning) || (bad_usb->st.state == BadUsbStateDelay)) {
@@ -638,9 +638,9 @@ void bad_usb_script_set_keyboard_layout(BadUsbScript* bad_usb, string_t layout_p
}
File* layout_file = storage_file_alloc(furi_record_open(RECORD_STORAGE));
- if(!string_empty_p(layout_path)) {
+ if(!furi_string_empty(layout_path)) {
if(storage_file_open(
- layout_file, string_get_cstr(layout_path), FSAM_READ, FSOM_OPEN_EXISTING)) {
+ layout_file, furi_string_get_cstr(layout_path), FSAM_READ, FSOM_OPEN_EXISTING)) {
uint16_t layout[128];
if(storage_file_read(layout_file, layout, sizeof(layout)) == sizeof(layout)) {
memcpy(bad_usb->layout, layout, sizeof(layout));
diff --git a/applications/main/bad_usb/bad_usb_script.h b/applications/main/bad_usb/bad_usb_script.h
index 119beb4aa..d3bc37fbe 100644
--- a/applications/main/bad_usb/bad_usb_script.h
+++ b/applications/main/bad_usb/bad_usb_script.h
@@ -5,7 +5,6 @@ extern "C" {
#endif
#include
-#include
typedef struct BadUsbScript BadUsbScript;
@@ -28,11 +27,11 @@ typedef struct {
uint16_t error_line;
} BadUsbState;
-BadUsbScript* bad_usb_script_open(string_t file_path);
+BadUsbScript* bad_usb_script_open(FuriString* file_path);
void bad_usb_script_close(BadUsbScript* bad_usb);
-void bad_usb_script_set_keyboard_layout(BadUsbScript* bad_usb, string_t layout_path);
+void bad_usb_script_set_keyboard_layout(BadUsbScript* bad_usb, FuriString* layout_path);
void bad_usb_script_start(BadUsbScript* bad_usb);
diff --git a/applications/main/bad_usb/scenes/bad_usb_scene_config_layout.c b/applications/main/bad_usb/scenes/bad_usb_scene_config_layout.c
index a1067f215..44dcd55af 100644
--- a/applications/main/bad_usb/scenes/bad_usb_scene_config_layout.c
+++ b/applications/main/bad_usb/scenes/bad_usb_scene_config_layout.c
@@ -6,12 +6,12 @@
static bool bad_usb_layout_select(BadUsbApp* bad_usb) {
furi_assert(bad_usb);
- string_t predefined_path;
- string_init(predefined_path);
- if(!string_empty_p(bad_usb->keyboard_layout)) {
- string_set(predefined_path, bad_usb->keyboard_layout);
+ FuriString* predefined_path;
+ predefined_path = furi_string_alloc();
+ if(!furi_string_empty(bad_usb->keyboard_layout)) {
+ furi_string_set(predefined_path, bad_usb->keyboard_layout);
} else {
- string_set_str(predefined_path, BAD_USB_APP_PATH_LAYOUT_FOLDER);
+ furi_string_set(predefined_path, BAD_USB_APP_PATH_LAYOUT_FOLDER);
}
DialogsFileBrowserOptions browser_options;
@@ -22,7 +22,7 @@ static bool bad_usb_layout_select(BadUsbApp* bad_usb) {
bool res = dialog_file_browser_show(
bad_usb->dialogs, bad_usb->keyboard_layout, predefined_path, &browser_options);
- string_clear(predefined_path);
+ furi_string_free(predefined_path);
return res;
}
diff --git a/applications/main/bad_usb/scenes/bad_usb_scene_file_select.c b/applications/main/bad_usb/scenes/bad_usb_scene_file_select.c
index 9eb225fd1..53e5ecc7b 100644
--- a/applications/main/bad_usb/scenes/bad_usb_scene_file_select.c
+++ b/applications/main/bad_usb/scenes/bad_usb_scene_file_select.c
@@ -8,6 +8,7 @@ static bool bad_usb_file_select(BadUsbApp* bad_usb) {
DialogsFileBrowserOptions browser_options;
dialog_file_browser_set_basic_options(
&browser_options, BAD_USB_APP_SCRIPT_EXTENSION, &I_badusb_10px);
+ browser_options.skip_assets = true;
// Input events and views are managed by file_browser
bool res = dialog_file_browser_show(
diff --git a/applications/main/bad_usb/scenes/bad_usb_scene_work.c b/applications/main/bad_usb/scenes/bad_usb_scene_work.c
index 1fdcfa999..2971c01e9 100644
--- a/applications/main/bad_usb/scenes/bad_usb_scene_work.c
+++ b/applications/main/bad_usb/scenes/bad_usb_scene_work.c
@@ -2,7 +2,6 @@
#include "../bad_usb_app_i.h"
#include "../views/bad_usb_view.h"
#include "furi_hal.h"
-#include "m-string.h"
#include "toolbox/path.h"
void bad_usb_scene_work_button_callback(InputKey key, void* context) {
@@ -32,17 +31,17 @@ bool bad_usb_scene_work_on_event(void* context, SceneManagerEvent event) {
void bad_usb_scene_work_on_enter(void* context) {
BadUsbApp* app = context;
- string_t file_name;
- string_init(file_name);
+ FuriString* file_name;
+ file_name = furi_string_alloc();
path_extract_filename(app->file_path, file_name, true);
- bad_usb_set_file_name(app->bad_usb_view, string_get_cstr(file_name));
- string_clear(file_name);
+ bad_usb_set_file_name(app->bad_usb_view, furi_string_get_cstr(file_name));
+ furi_string_free(file_name);
- string_t layout;
- string_init(layout);
+ FuriString* layout;
+ layout = furi_string_alloc();
path_extract_filename(app->keyboard_layout, layout, true);
- bad_usb_set_layout(app->bad_usb_view, string_get_cstr(layout));
- string_clear(layout);
+ bad_usb_set_layout(app->bad_usb_view, furi_string_get_cstr(layout));
+ furi_string_free(layout);
bad_usb_set_state(app->bad_usb_view, bad_usb_script_get_state(app->bad_usb_script));
diff --git a/applications/main/bad_usb/views/bad_usb_view.c b/applications/main/bad_usb/views/bad_usb_view.c
index 87c5fae49..601ea453a 100644
--- a/applications/main/bad_usb/views/bad_usb_view.c
+++ b/applications/main/bad_usb/views/bad_usb_view.c
@@ -21,25 +21,26 @@ typedef struct {
static void bad_usb_draw_callback(Canvas* canvas, void* _model) {
BadUsbModel* model = _model;
- string_t disp_str;
- string_init_set_str(disp_str, model->file_name);
+ FuriString* disp_str;
+ disp_str = furi_string_alloc_set(model->file_name);
elements_string_fit_width(canvas, disp_str, 128 - 2);
canvas_set_font(canvas, FontSecondary);
- canvas_draw_str(canvas, 2, 8, string_get_cstr(disp_str));
+ canvas_draw_str(canvas, 2, 8, furi_string_get_cstr(disp_str));
if(strlen(model->layout) == 0) {
- string_set(disp_str, "(default)");
+ furi_string_set(disp_str, "(default)");
} else {
- string_reset(disp_str);
- string_push_back(disp_str, '(');
+ furi_string_reset(disp_str);
+ furi_string_push_back(disp_str, '(');
for(size_t i = 0; i < strlen(model->layout); i++)
- string_push_back(disp_str, model->layout[i]);
- string_push_back(disp_str, ')');
+ furi_string_push_back(disp_str, model->layout[i]);
+ furi_string_push_back(disp_str, ')');
}
elements_string_fit_width(canvas, disp_str, 128 - 2);
- canvas_draw_str(canvas, 2, 8 + canvas_current_font_height(canvas), string_get_cstr(disp_str));
+ canvas_draw_str(
+ canvas, 2, 8 + canvas_current_font_height(canvas), furi_string_get_cstr(disp_str));
- string_reset(disp_str);
+ furi_string_reset(disp_str);
canvas_draw_icon(canvas, 22, 24, &I_UsbTree_48x22);
@@ -69,10 +70,10 @@ static void bad_usb_draw_callback(Canvas* canvas, void* _model) {
canvas_set_font(canvas, FontPrimary);
canvas_draw_str_aligned(canvas, 127, 33, AlignRight, AlignBottom, "ERROR:");
canvas_set_font(canvas, FontSecondary);
- string_printf(disp_str, "line %u", model->state.error_line);
+ furi_string_printf(disp_str, "line %u", model->state.error_line);
canvas_draw_str_aligned(
- canvas, 127, 46, AlignRight, AlignBottom, string_get_cstr(disp_str));
- string_reset(disp_str);
+ canvas, 127, 46, AlignRight, AlignBottom, furi_string_get_cstr(disp_str));
+ furi_string_reset(disp_str);
} else if(model->state.state == BadUsbStateIdle) {
canvas_draw_icon(canvas, 4, 26, &I_Smile_18x18);
canvas_set_font(canvas, FontBigNumbers);
@@ -85,16 +86,17 @@ static void bad_usb_draw_callback(Canvas* canvas, void* _model) {
canvas_draw_icon(canvas, 4, 23, &I_EviSmile2_18x21);
}
canvas_set_font(canvas, FontBigNumbers);
- string_printf(disp_str, "%u", ((model->state.line_cur - 1) * 100) / model->state.line_nb);
+ furi_string_printf(
+ disp_str, "%u", ((model->state.line_cur - 1) * 100) / model->state.line_nb);
canvas_draw_str_aligned(
- canvas, 114, 40, AlignRight, AlignBottom, string_get_cstr(disp_str));
- string_reset(disp_str);
+ canvas, 114, 40, AlignRight, AlignBottom, furi_string_get_cstr(disp_str));
+ furi_string_reset(disp_str);
canvas_draw_icon(canvas, 117, 26, &I_Percent_10x14);
} else if(model->state.state == BadUsbStateDone) {
canvas_draw_icon(canvas, 4, 23, &I_EviSmile1_18x21);
canvas_set_font(canvas, FontBigNumbers);
canvas_draw_str_aligned(canvas, 114, 40, AlignRight, AlignBottom, "100");
- string_reset(disp_str);
+ furi_string_reset(disp_str);
canvas_draw_icon(canvas, 117, 26, &I_Percent_10x14);
} else if(model->state.state == BadUsbStateDelay) {
if(model->anim_frame == 0) {
@@ -103,21 +105,22 @@ static void bad_usb_draw_callback(Canvas* canvas, void* _model) {
canvas_draw_icon(canvas, 4, 23, &I_EviWaiting2_18x21);
}
canvas_set_font(canvas, FontBigNumbers);
- string_printf(disp_str, "%u", ((model->state.line_cur - 1) * 100) / model->state.line_nb);
+ furi_string_printf(
+ disp_str, "%u", ((model->state.line_cur - 1) * 100) / model->state.line_nb);
canvas_draw_str_aligned(
- canvas, 114, 40, AlignRight, AlignBottom, string_get_cstr(disp_str));
- string_reset(disp_str);
+ canvas, 114, 40, AlignRight, AlignBottom, furi_string_get_cstr(disp_str));
+ furi_string_reset(disp_str);
canvas_draw_icon(canvas, 117, 26, &I_Percent_10x14);
canvas_set_font(canvas, FontSecondary);
- string_printf(disp_str, "delay %us", model->state.delay_remain);
+ furi_string_printf(disp_str, "delay %lus", model->state.delay_remain);
canvas_draw_str_aligned(
- canvas, 127, 50, AlignRight, AlignBottom, string_get_cstr(disp_str));
- string_reset(disp_str);
+ canvas, 127, 50, AlignRight, AlignBottom, furi_string_get_cstr(disp_str));
+ furi_string_reset(disp_str);
} else {
canvas_draw_icon(canvas, 4, 26, &I_Clock_18x18);
}
- string_clear(disp_str);
+ furi_string_free(disp_str);
}
static bool bad_usb_input_callback(InputEvent* event, void* context) {
diff --git a/applications/main/clock_app/clock_app.c b/applications/main/clock_app/clock_app.c
index deb209c38..1bd92d9ec 100644
--- a/applications/main/clock_app/clock_app.c
+++ b/applications/main/clock_app/clock_app.c
@@ -38,6 +38,7 @@ static void clock_render_callback(Canvas* const canvas, void* ctx) {
time_string, TIME_LEN, CLOCK_TIME_FORMAT, curr_dt.hour, curr_dt.minute, curr_dt.second);
} else {
bool pm = curr_dt.hour > 12;
+ bool pm12 = curr_dt.hour >= 12;
snprintf(
time_string,
TIME_LEN,
@@ -50,7 +51,7 @@ static void clock_render_callback(Canvas* const canvas, void* ctx) {
meridian_string,
MERIDIAN_LEN,
MERIDIAN_FORMAT,
- pm ? MERIDIAN_STRING_PM : MERIDIAN_STRING_AM);
+ pm12 ? MERIDIAN_STRING_PM : MERIDIAN_STRING_AM);
}
if(state->settings.date_format == Iso) {
diff --git a/applications/main/fap_loader/elf_cpp/elf_hashtable.cpp b/applications/main/fap_loader/elf_cpp/elf_hashtable.cpp
index 17e2ba83f..f8adbf9d8 100644
--- a/applications/main/fap_loader/elf_cpp/elf_hashtable.cpp
+++ b/applications/main/fap_loader/elf_cpp/elf_hashtable.cpp
@@ -31,7 +31,7 @@ bool elf_resolve_from_hashtable(const char* name, Elf32_Addr* address) {
auto find_res = std::lower_bound(elf_api_table.cbegin(), elf_api_table.cend(), key);
if((find_res == elf_api_table.cend() || (find_res->hash != gnu_sym_hash))) {
- FURI_LOG_W(TAG, "Cant find symbol '%s' (hash %x)!", name, gnu_sym_hash);
+ FURI_LOG_W(TAG, "Cant find symbol '%s' (hash %lx)!", name, gnu_sym_hash);
result = false;
} else {
result = true;
diff --git a/applications/main/fap_loader/fap_loader_app.c b/applications/main/fap_loader/fap_loader_app.c
index c0f60ceca..d2f6b1f41 100644
--- a/applications/main/fap_loader/fap_loader_app.c
+++ b/applications/main/fap_loader/fap_loader_app.c
@@ -1,34 +1,34 @@
#include
#include
#include
-#include
#include
+#include
#include
-#include "elf_cpp/elf_hashtable.h"
#include
+#include "elf_cpp/elf_hashtable.h"
+#include "fap_loader_app.h"
#define TAG "fap_loader_app"
-typedef struct {
+struct FapLoader {
FlipperApplication* app;
Storage* storage;
DialogsApp* dialogs;
Gui* gui;
- string_t fap_path;
-
+ FuriString* fap_path;
ViewDispatcher* view_dispatcher;
Loading* loading;
-} FapLoader;
+};
-static bool
- fap_loader_item_callback(string_t path, void* context, uint8_t** icon_ptr, string_t item_name) {
- FapLoader* loader = context;
- furi_assert(loader);
-
- FlipperApplication* app = flipper_application_alloc(loader->storage, &hashtable_api_interface);
+bool fap_loader_load_name_and_icon(
+ FuriString* path,
+ Storage* storage,
+ uint8_t** icon_ptr,
+ FuriString* item_name) {
+ FlipperApplication* app = flipper_application_alloc(storage, &hashtable_api_interface);
FlipperApplicationPreloadStatus preload_res =
- flipper_application_preload_manifest(app, string_get_cstr(path));
+ flipper_application_preload_manifest(app, furi_string_get_cstr(path));
bool load_success = false;
@@ -37,10 +37,10 @@ static bool
if(manifest->has_icon) {
memcpy(*icon_ptr, manifest->icon, FAP_MANIFEST_MAX_ICON_SIZE);
}
- string_set_str(item_name, manifest->name);
+ furi_string_set(item_name, manifest->name);
load_success = true;
} else {
- FURI_LOG_E(TAG, "FAP Loader failed to preload %s", string_get_cstr(path));
+ FURI_LOG_E(TAG, "FAP Loader failed to preload %s", furi_string_get_cstr(path));
load_success = false;
}
@@ -48,30 +48,41 @@ static bool
return load_success;
}
+static bool fap_loader_item_callback(
+ FuriString* path,
+ void* context,
+ uint8_t** icon_ptr,
+ FuriString* item_name) {
+ FapLoader* fap_loader = context;
+ furi_assert(fap_loader);
+ return fap_loader_load_name_and_icon(path, fap_loader->storage, icon_ptr, item_name);
+}
+
static bool fap_loader_run_selected_app(FapLoader* loader) {
furi_assert(loader);
- string_t error_message;
+ FuriString* error_message;
- string_init_set(error_message, "unknown error");
+ error_message = furi_string_alloc_set("unknown error");
bool file_selected = false;
bool show_error = true;
do {
file_selected = true;
loader->app = flipper_application_alloc(loader->storage, &hashtable_api_interface);
+ size_t start = furi_get_tick();
- FURI_LOG_I(TAG, "FAP Loader is loading %s", string_get_cstr(loader->fap_path));
+ FURI_LOG_I(TAG, "FAP Loader is loading %s", furi_string_get_cstr(loader->fap_path));
FlipperApplicationPreloadStatus preload_res =
- flipper_application_preload(loader->app, string_get_cstr(loader->fap_path));
+ flipper_application_preload(loader->app, furi_string_get_cstr(loader->fap_path));
if(preload_res != FlipperApplicationPreloadStatusSuccess) {
const char* err_msg = flipper_application_preload_status_to_string(preload_res);
- string_printf(error_message, "Preload failed: %s", err_msg);
+ furi_string_printf(error_message, "Preload failed: %s", err_msg);
FURI_LOG_E(
TAG,
"FAP Loader failed to preload %s: %s",
- string_get_cstr(loader->fap_path),
+ furi_string_get_cstr(loader->fap_path),
err_msg);
break;
}
@@ -80,15 +91,16 @@ static bool fap_loader_run_selected_app(FapLoader* loader) {
FlipperApplicationLoadStatus load_status = flipper_application_map_to_memory(loader->app);
if(load_status != FlipperApplicationLoadStatusSuccess) {
const char* err_msg = flipper_application_load_status_to_string(load_status);
- string_printf(error_message, "Load failed: %s", err_msg);
+ furi_string_printf(error_message, "Load failed: %s", err_msg);
FURI_LOG_E(
TAG,
"FAP Loader failed to map to memory %s: %s",
- string_get_cstr(loader->fap_path),
+ furi_string_get_cstr(loader->fap_path),
err_msg);
break;
}
+ FURI_LOG_I(TAG, "Loaded in %ums", (size_t)(furi_get_tick() - start));
FURI_LOG_I(TAG, "FAP Loader is staring app");
FuriThread* thread = flipper_application_spawn(loader->app, NULL);
@@ -106,19 +118,19 @@ static bool fap_loader_run_selected_app(FapLoader* loader) {
dialog_message_set_header(message, "Error", 64, 0, AlignCenter, AlignTop);
dialog_message_set_buttons(message, NULL, NULL, NULL);
- string_t buffer;
- string_init(buffer);
- string_printf(buffer, "%s", string_get_cstr(error_message));
- string_replace_str(buffer, ":", "\n");
+ FuriString* buffer;
+ buffer = furi_string_alloc();
+ furi_string_printf(buffer, "%s", furi_string_get_cstr(error_message));
+ furi_string_replace(buffer, ":", "\n");
dialog_message_set_text(
- message, string_get_cstr(buffer), 64, 32, AlignCenter, AlignCenter);
+ message, furi_string_get_cstr(buffer), 64, 32, AlignCenter, AlignCenter);
dialog_message_show(loader->dialogs, message);
dialog_message_free(message);
- string_clear(buffer);
+ furi_string_free(buffer);
}
- string_clear(error_message);
+ furi_string_free(error_message);
if(file_selected) {
flipper_application_free(loader->app);
@@ -131,7 +143,7 @@ static bool fap_loader_select_app(FapLoader* loader) {
const DialogsFileBrowserOptions browser_options = {
.extension = ".fap",
.skip_assets = true,
- .icon = &I_badusb_10px,
+ .icon = &I_unknown_10px,
.hide_ext = true,
.item_loader_callback = fap_loader_item_callback,
.item_loader_context = loader,
@@ -141,39 +153,44 @@ static bool fap_loader_select_app(FapLoader* loader) {
loader->dialogs, loader->fap_path, loader->fap_path, &browser_options);
}
-int32_t fap_loader_app(void* p) {
+static FapLoader* fap_loader_alloc(const char* path) {
FapLoader* loader = malloc(sizeof(FapLoader));
+ loader->fap_path = furi_string_alloc_set(path);
loader->storage = furi_record_open(RECORD_STORAGE);
loader->dialogs = furi_record_open(RECORD_DIALOGS);
loader->gui = furi_record_open(RECORD_GUI);
-
loader->view_dispatcher = view_dispatcher_alloc();
loader->loading = loading_alloc();
-
view_dispatcher_attach_to_gui(
loader->view_dispatcher, loader->gui, ViewDispatcherTypeFullscreen);
view_dispatcher_add_view(loader->view_dispatcher, 0, loading_get_view(loader->loading));
+ return loader;
+}
+static void fap_loader_free(FapLoader* loader) {
+ view_dispatcher_remove_view(loader->view_dispatcher, 0);
+ loading_free(loader->loading);
+ view_dispatcher_free(loader->view_dispatcher);
+ furi_string_free(loader->fap_path);
+ furi_record_close(RECORD_GUI);
+ furi_record_close(RECORD_DIALOGS);
+ furi_record_close(RECORD_STORAGE);
+ free(loader);
+}
+
+int32_t fap_loader_app(void* p) {
+ FapLoader* loader;
if(p) {
- string_init_set(loader->fap_path, (const char*)p);
+ loader = fap_loader_alloc((const char*)p);
fap_loader_run_selected_app(loader);
} else {
- string_init_set(loader->fap_path, EXT_PATH("apps"));
-
+ loader = fap_loader_alloc(EXT_PATH("apps"));
while(fap_loader_select_app(loader)) {
view_dispatcher_switch_to_view(loader->view_dispatcher, 0);
fap_loader_run_selected_app(loader);
};
}
- view_dispatcher_remove_view(loader->view_dispatcher, 0);
- loading_free(loader->loading);
- view_dispatcher_free(loader->view_dispatcher);
-
- string_clear(loader->fap_path);
- furi_record_close(RECORD_GUI);
- furi_record_close(RECORD_DIALOGS);
- furi_record_close(RECORD_STORAGE);
- free(loader);
+ fap_loader_free(loader);
return 0;
-}
\ No newline at end of file
+}
diff --git a/applications/main/fap_loader/fap_loader_app.h b/applications/main/fap_loader/fap_loader_app.h
new file mode 100644
index 000000000..9ed725efe
--- /dev/null
+++ b/applications/main/fap_loader/fap_loader_app.h
@@ -0,0 +1,27 @@
+#pragma once
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct FapLoader FapLoader;
+
+/**
+ * @brief Load name and icon from FAP file.
+ *
+ * @param path Path to FAP file.
+ * @param storage Storage instance.
+ * @param icon_ptr Icon pointer.
+ * @param item_name Application name.
+ * @return true if icon and name were loaded successfully.
+ */
+bool fap_loader_load_name_and_icon(
+ FuriString* path,
+ Storage* storage,
+ uint8_t** icon_ptr,
+ FuriString* item_name);
+
+#ifdef __cplusplus
+}
+#endif
\ No newline at end of file
diff --git a/applications/main/gpio/usb_uart_bridge.c b/applications/main/gpio/usb_uart_bridge.c
index 02f58ed10..6e0bce736 100644
--- a/applications/main/gpio/usb_uart_bridge.c
+++ b/applications/main/gpio/usb_uart_bridge.c
@@ -1,6 +1,5 @@
#include "usb_uart_bridge.h"
#include "furi_hal.h"
-#include
#include
#include "usb_cdc.h"
#include "cli/cli_vcp.h"
@@ -43,7 +42,7 @@ struct UsbUartBridge {
FuriThread* thread;
FuriThread* tx_thread;
- StreamBufferHandle_t rx_stream;
+ FuriStreamBuffer* rx_stream;
FuriMutex* usb_mutex;
@@ -74,12 +73,10 @@ static int32_t usb_uart_tx_thread(void* context);
static void usb_uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
UsbUartBridge* usb_uart = (UsbUartBridge*)context;
- BaseType_t xHigherPriorityTaskWoken = pdFALSE;
if(ev == UartIrqEventRXNE) {
- xStreamBufferSendFromISR(usb_uart->rx_stream, &data, 1, &xHigherPriorityTaskWoken);
+ furi_stream_buffer_send(usb_uart->rx_stream, &data, 1, 0);
furi_thread_flags_set(furi_thread_get_id(usb_uart->thread), WorkerEvtRxDone);
- portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}
@@ -156,7 +153,7 @@ static int32_t usb_uart_worker(void* context) {
memcpy(&usb_uart->cfg, &usb_uart->cfg_new, sizeof(UsbUartConfig));
- usb_uart->rx_stream = xStreamBufferCreate(USB_UART_RX_BUF_SIZE, 1);
+ usb_uart->rx_stream = furi_stream_buffer_alloc(USB_UART_RX_BUF_SIZE, 1);
usb_uart->tx_sem = furi_semaphore_alloc(1, 1);
usb_uart->usb_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
@@ -189,8 +186,8 @@ static int32_t usb_uart_worker(void* context) {
furi_check((events & FuriFlagError) == 0);
if(events & WorkerEvtStop) break;
if(events & WorkerEvtRxDone) {
- size_t len =
- xStreamBufferReceive(usb_uart->rx_stream, usb_uart->rx_buf, USB_CDC_PKT_LEN, 0);
+ size_t len = furi_stream_buffer_receive(
+ usb_uart->rx_stream, usb_uart->rx_buf, USB_CDC_PKT_LEN, 0);
if(len > 0) {
if(furi_semaphore_acquire(usb_uart->tx_sem, 100) == FuriStatusOk) {
usb_uart->st.rx_cnt += len;
@@ -199,7 +196,7 @@ static int32_t usb_uart_worker(void* context) {
furi_hal_cdc_send(usb_uart->cfg.vcp_ch, usb_uart->rx_buf, len);
furi_check(furi_mutex_release(usb_uart->usb_mutex) == FuriStatusOk);
} else {
- xStreamBufferReset(usb_uart->rx_stream);
+ furi_stream_buffer_reset(usb_uart->rx_stream);
}
}
}
@@ -270,7 +267,7 @@ static int32_t usb_uart_worker(void* context) {
furi_thread_join(usb_uart->tx_thread);
furi_thread_free(usb_uart->tx_thread);
- vStreamBufferDelete(usb_uart->rx_stream);
+ furi_stream_buffer_free(usb_uart->rx_stream);
furi_mutex_free(usb_uart->usb_mutex);
furi_semaphore_free(usb_uart->tx_sem);
diff --git a/applications/main/gpio/views/gpio_usb_uart.c b/applications/main/gpio/views/gpio_usb_uart.c
index d2d371b68..d190ecab0 100644
--- a/applications/main/gpio/views/gpio_usb_uart.c
+++ b/applications/main/gpio/views/gpio_usb_uart.c
@@ -54,7 +54,7 @@ static void gpio_usb_uart_draw_callback(Canvas* canvas, void* _model) {
canvas_draw_str_aligned(canvas, 116, 24, AlignRight, AlignBottom, temp_str);
} else {
canvas_set_font(canvas, FontSecondary);
- canvas_draw_str_aligned(canvas, 127, 24, AlignRight, AlignBottom, "KB.");
+ canvas_draw_str_aligned(canvas, 127, 24, AlignRight, AlignBottom, "KiB.");
canvas_set_font(canvas, FontKeyboard);
snprintf(temp_str, 18, "%lu", model->tx_cnt / 1024);
canvas_draw_str_aligned(canvas, 111, 24, AlignRight, AlignBottom, temp_str);
@@ -68,7 +68,7 @@ static void gpio_usb_uart_draw_callback(Canvas* canvas, void* _model) {
canvas_draw_str_aligned(canvas, 116, 41, AlignRight, AlignBottom, temp_str);
} else {
canvas_set_font(canvas, FontSecondary);
- canvas_draw_str_aligned(canvas, 127, 41, AlignRight, AlignBottom, "KB.");
+ canvas_draw_str_aligned(canvas, 127, 41, AlignRight, AlignBottom, "KiB.");
canvas_set_font(canvas, FontKeyboard);
snprintf(temp_str, 18, "%lu", model->rx_cnt / 1024);
canvas_draw_str_aligned(canvas, 111, 41, AlignRight, AlignBottom, temp_str);
diff --git a/applications/main/ibutton/ibutton.c b/applications/main/ibutton/ibutton.c
index e9ec614ec..887fb3e75 100644
--- a/applications/main/ibutton/ibutton.c
+++ b/applications/main/ibutton/ibutton.c
@@ -2,7 +2,6 @@
#include "assets_icons.h"
#include "ibutton_i.h"
#include "ibutton/scenes/ibutton_scene.h"
-#include "m-string.h"
#include
#include
#include
@@ -39,25 +38,25 @@ static void ibutton_make_app_folder(iButton* ibutton) {
}
}
-bool ibutton_load_key_data(iButton* ibutton, string_t key_path, bool show_dialog) {
+bool ibutton_load_key_data(iButton* ibutton, FuriString* key_path, bool show_dialog) {
FlipperFormat* file = flipper_format_file_alloc(ibutton->storage);
bool result = false;
- string_t data;
- string_init(data);
+ FuriString* data;
+ data = furi_string_alloc();
do {
- if(!flipper_format_file_open_existing(file, string_get_cstr(key_path))) break;
+ if(!flipper_format_file_open_existing(file, furi_string_get_cstr(key_path))) break;
// header
uint32_t version;
if(!flipper_format_read_header(file, data, &version)) break;
- if(string_cmp_str(data, IBUTTON_APP_FILE_TYPE) != 0) break;
+ if(furi_string_cmp_str(data, IBUTTON_APP_FILE_TYPE) != 0) break;
if(version != 1) break;
// key type
iButtonKeyType type;
if(!flipper_format_read_string(file, "Key type", data)) break;
- if(!ibutton_key_get_type_by_string(string_get_cstr(data), &type)) break;
+ if(!ibutton_key_get_type_by_string(furi_string_get_cstr(data), &type)) break;
// key data
uint8_t key_data[IBUTTON_KEY_DATA_SIZE] = {0};
@@ -71,7 +70,7 @@ bool ibutton_load_key_data(iButton* ibutton, string_t key_path, bool show_dialog
} while(false);
flipper_format_free(file);
- string_clear(data);
+ furi_string_free(data);
if((!result) && (show_dialog)) {
dialog_message_show_storage_error(ibutton->dialogs, "Cannot load\nkey file");
@@ -119,7 +118,7 @@ void ibutton_tick_event_callback(void* context) {
iButton* ibutton_alloc() {
iButton* ibutton = malloc(sizeof(iButton));
- string_init(ibutton->file_path);
+ ibutton->file_path = furi_string_alloc();
ibutton->scene_manager = scene_manager_alloc(&ibutton_scene_handlers, ibutton);
@@ -210,7 +209,7 @@ void ibutton_free(iButton* ibutton) {
ibutton_worker_free(ibutton->key_worker);
ibutton_key_free(ibutton->key);
- string_clear(ibutton->file_path);
+ furi_string_free(ibutton->file_path);
free(ibutton);
}
@@ -240,19 +239,19 @@ bool ibutton_save_key(iButton* ibutton, const char* key_name) {
do {
// Check if we has old key
- if(string_end_with_str_p(ibutton->file_path, IBUTTON_APP_EXTENSION)) {
+ if(furi_string_end_with(ibutton->file_path, IBUTTON_APP_EXTENSION)) {
// First remove old key
ibutton_delete_key(ibutton);
// Remove old key name from path
- size_t filename_start = string_search_rchar(ibutton->file_path, '/');
- string_left(ibutton->file_path, filename_start);
+ size_t filename_start = furi_string_search_rchar(ibutton->file_path, '/');
+ furi_string_left(ibutton->file_path, filename_start);
}
- string_cat_printf(ibutton->file_path, "/%s%s", key_name, IBUTTON_APP_EXTENSION);
+ furi_string_cat_printf(ibutton->file_path, "/%s%s", key_name, IBUTTON_APP_EXTENSION);
// Open file for write
- if(!flipper_format_file_open_always(file, string_get_cstr(ibutton->file_path))) break;
+ if(!flipper_format_file_open_always(file, furi_string_get_cstr(ibutton->file_path))) break;
// Write header
if(!flipper_format_write_header_cstr(file, IBUTTON_APP_FILE_TYPE, 1)) break;
@@ -286,7 +285,7 @@ bool ibutton_save_key(iButton* ibutton, const char* key_name) {
bool ibutton_delete_key(iButton* ibutton) {
bool result = false;
- result = storage_simply_remove(ibutton->storage, string_get_cstr(ibutton->file_path));
+ result = storage_simply_remove(ibutton->storage, furi_string_get_cstr(ibutton->file_path));
return result;
}
@@ -326,7 +325,7 @@ int32_t ibutton_app(void* p) {
rpc_system_app_set_callback(ibutton->rpc_ctx, ibutton_rpc_command_callback, ibutton);
rpc_system_app_send_started(ibutton->rpc_ctx);
} else {
- string_set_str(ibutton->file_path, (const char*)p);
+ furi_string_set(ibutton->file_path, (const char*)p);
if(ibutton_load_key_data(ibutton, ibutton->file_path, true)) {
key_loaded = true;
// TODO: Display an error if the key from p could not be loaded
diff --git a/applications/main/ibutton/ibutton_cli.c b/applications/main/ibutton/ibutton_cli.c
index d36d3dffd..fab1ccf05 100644
--- a/applications/main/ibutton/ibutton_cli.c
+++ b/applications/main/ibutton/ibutton_cli.c
@@ -6,8 +6,8 @@
#include
#include
-static void ibutton_cli(Cli* cli, string_t args, void* context);
-static void onewire_cli(Cli* cli, string_t args, void* context);
+static void ibutton_cli(Cli* cli, FuriString* args, void* context);
+static void onewire_cli(Cli* cli, FuriString* args, void* context);
// app cli function
void ibutton_on_system_start() {
@@ -34,16 +34,16 @@ void ibutton_cli_print_usage() {
printf("\t are hex-formatted\r\n");
};
-bool ibutton_cli_get_key_type(string_t data, iButtonKeyType* type) {
+bool ibutton_cli_get_key_type(FuriString* data, iButtonKeyType* type) {
bool result = false;
- if(string_cmp_str(data, "Dallas") == 0 || string_cmp_str(data, "dallas") == 0) {
+ if(furi_string_cmp_str(data, "Dallas") == 0 || furi_string_cmp_str(data, "dallas") == 0) {
result = true;
*type = iButtonKeyDS1990;
- } else if(string_cmp_str(data, "Cyfral") == 0 || string_cmp_str(data, "cyfral") == 0) {
+ } else if(furi_string_cmp_str(data, "Cyfral") == 0 || furi_string_cmp_str(data, "cyfral") == 0) {
result = true;
*type = iButtonKeyCyfral;
- } else if(string_cmp_str(data, "Metakom") == 0 || string_cmp_str(data, "metakom") == 0) {
+ } else if(furi_string_cmp_str(data, "Metakom") == 0 || furi_string_cmp_str(data, "metakom") == 0) {
result = true;
*type = iButtonKeyMetakom;
}
@@ -123,17 +123,17 @@ static void ibutton_cli_worker_write_cb(void* context, iButtonWorkerWriteResult
furi_event_flag_set(write_context->event, EVENT_FLAG_IBUTTON_COMPLETE);
}
-void ibutton_cli_write(Cli* cli, string_t args) {
+void ibutton_cli_write(Cli* cli, FuriString* args) {
iButtonKey* key = ibutton_key_alloc();
iButtonWorker* worker = ibutton_worker_alloc();
iButtonKeyType type;
iButtonWriteContext write_context;
uint8_t key_data[IBUTTON_KEY_DATA_SIZE];
- string_t data;
+ FuriString* data;
write_context.event = furi_event_flag_alloc();
- string_init(data);
+ data = furi_string_alloc();
ibutton_worker_start_thread(worker);
ibutton_worker_write_set_callback(worker, ibutton_cli_worker_write_cb, &write_context);
@@ -186,7 +186,7 @@ void ibutton_cli_write(Cli* cli, string_t args) {
ibutton_worker_stop(worker);
} while(false);
- string_clear(data);
+ furi_string_free(data);
ibutton_worker_stop_thread(worker);
ibutton_worker_free(worker);
ibutton_key_free(key);
@@ -194,14 +194,14 @@ void ibutton_cli_write(Cli* cli, string_t args) {
furi_event_flag_free(write_context.event);
};
-void ibutton_cli_emulate(Cli* cli, string_t args) {
+void ibutton_cli_emulate(Cli* cli, FuriString* args) {
iButtonKey* key = ibutton_key_alloc();
iButtonWorker* worker = ibutton_worker_alloc();
iButtonKeyType type;
uint8_t key_data[IBUTTON_KEY_DATA_SIZE];
- string_t data;
+ FuriString* data;
- string_init(data);
+ data = furi_string_alloc();
ibutton_worker_start_thread(worker);
do {
@@ -234,34 +234,34 @@ void ibutton_cli_emulate(Cli* cli, string_t args) {
ibutton_worker_stop(worker);
} while(false);
- string_clear(data);
+ furi_string_free(data);
ibutton_worker_stop_thread(worker);
ibutton_worker_free(worker);
ibutton_key_free(key);
};
-static void ibutton_cli(Cli* cli, string_t args, void* context) {
+static void ibutton_cli(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
- string_t cmd;
- string_init(cmd);
+ FuriString* cmd;
+ cmd = furi_string_alloc();
if(!args_read_string_and_trim(args, cmd)) {
- string_clear(cmd);
+ furi_string_free(cmd);
ibutton_cli_print_usage();
return;
}
- if(string_cmp_str(cmd, "read") == 0) {
+ if(furi_string_cmp_str(cmd, "read") == 0) {
ibutton_cli_read(cli);
- } else if(string_cmp_str(cmd, "write") == 0) {
+ } else if(furi_string_cmp_str(cmd, "write") == 0) {
ibutton_cli_write(cli, args);
- } else if(string_cmp_str(cmd, "emulate") == 0) {
+ } else if(furi_string_cmp_str(cmd, "emulate") == 0) {
ibutton_cli_emulate(cli, args);
} else {
ibutton_cli_print_usage();
}
- string_clear(cmd);
+ furi_string_free(cmd);
}
void onewire_cli_print_usage() {
@@ -299,20 +299,20 @@ static void onewire_cli_search(Cli* cli) {
onewire_host_free(onewire);
}
-void onewire_cli(Cli* cli, string_t args, void* context) {
+void onewire_cli(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
- string_t cmd;
- string_init(cmd);
+ FuriString* cmd;
+ cmd = furi_string_alloc();
if(!args_read_string_and_trim(args, cmd)) {
- string_clear(cmd);
+ furi_string_free(cmd);
onewire_cli_print_usage();
return;
}
- if(string_cmp_str(cmd, "search") == 0) {
+ if(furi_string_cmp_str(cmd, "search") == 0) {
onewire_cli_search(cli);
}
- string_clear(cmd);
+ furi_string_free(cmd);
}
diff --git a/applications/main/ibutton/ibutton_i.h b/applications/main/ibutton/ibutton_i.h
index fd11b8c19..a9515195e 100644
--- a/applications/main/ibutton/ibutton_i.h
+++ b/applications/main/ibutton/ibutton_i.h
@@ -41,7 +41,7 @@ struct iButton {
iButtonWorker* key_worker;
iButtonKey* key;
- string_t file_path;
+ FuriString* file_path;
char text_store[IBUTTON_TEXT_STORE_SIZE + 1];
Submenu* submenu;
@@ -78,7 +78,7 @@ typedef enum {
} iButtonNotificationMessage;
bool ibutton_file_select(iButton* ibutton);
-bool ibutton_load_key_data(iButton* ibutton, string_t key_path, bool show_dialog);
+bool ibutton_load_key_data(iButton* ibutton, FuriString* key_path, bool show_dialog);
bool ibutton_save_key(iButton* ibutton, const char* key_name);
bool ibutton_delete_key(iButton* ibutton);
void ibutton_text_store_set(iButton* ibutton, const char* text, ...);
diff --git a/applications/main/ibutton/scenes/ibutton_scene_add_type.c b/applications/main/ibutton/scenes/ibutton_scene_add_type.c
index 9a0583a58..38373999c 100644
--- a/applications/main/ibutton/scenes/ibutton_scene_add_type.c
+++ b/applications/main/ibutton/scenes/ibutton_scene_add_type.c
@@ -1,5 +1,4 @@
#include "../ibutton_i.h"
-#include "m-string.h"
enum SubmenuIndex {
SubmenuIndexCyfral,
@@ -47,7 +46,7 @@ bool ibutton_scene_add_type_on_event(void* context, SceneManagerEvent event) {
furi_crash("Unknown key type");
}
- string_set_str(ibutton->file_path, IBUTTON_APP_FOLDER);
+ furi_string_set(ibutton->file_path, IBUTTON_APP_FOLDER);
ibutton_key_clear_data(key);
scene_manager_next_scene(ibutton->scene_manager, iButtonSceneAddValue);
}
diff --git a/applications/main/ibutton/scenes/ibutton_scene_delete_confirm.c b/applications/main/ibutton/scenes/ibutton_scene_delete_confirm.c
index 51f1f2794..3d609e833 100644
--- a/applications/main/ibutton/scenes/ibutton_scene_delete_confirm.c
+++ b/applications/main/ibutton/scenes/ibutton_scene_delete_confirm.c
@@ -17,13 +17,13 @@ void ibutton_scene_delete_confirm_on_enter(void* context) {
iButtonKey* key = ibutton->key;
const uint8_t* key_data = ibutton_key_get_data_p(key);
- string_t key_name;
- string_init(key_name);
+ FuriString* key_name;
+ key_name = furi_string_alloc();
path_extract_filename(ibutton->file_path, key_name, true);
- ibutton_text_store_set(ibutton, "\e#Delete %s?\e#", string_get_cstr(key_name));
+ ibutton_text_store_set(ibutton, "\e#Delete %s?\e#", furi_string_get_cstr(key_name));
widget_add_text_box_element(
- widget, 0, 0, 128, 27, AlignCenter, AlignCenter, ibutton->text_store, false);
+ widget, 0, 0, 128, 27, AlignCenter, AlignCenter, ibutton->text_store, true);
widget_add_button_element(
widget, GuiButtonTypeLeft, "Cancel", ibutton_scene_delete_confirm_widget_callback, ibutton);
widget_add_button_element(
@@ -47,28 +47,28 @@ void ibutton_scene_delete_confirm_on_enter(void* context) {
key_data[6],
key_data[7]);
widget_add_string_element(
- widget, 64, 45, AlignCenter, AlignBottom, FontSecondary, "Dallas");
+ widget, 64, 34, AlignCenter, AlignBottom, FontSecondary, "Dallas");
break;
case iButtonKeyCyfral:
ibutton_text_store_set(ibutton, "%02X %02X", key_data[0], key_data[1]);
widget_add_string_element(
- widget, 64, 45, AlignCenter, AlignBottom, FontSecondary, "Cyfral");
+ widget, 64, 34, AlignCenter, AlignBottom, FontSecondary, "Cyfral");
break;
case iButtonKeyMetakom:
ibutton_text_store_set(
ibutton, "%02X %02X %02X %02X", key_data[0], key_data[1], key_data[2], key_data[3]);
widget_add_string_element(
- widget, 64, 45, AlignCenter, AlignBottom, FontSecondary, "Metakom");
+ widget, 64, 34, AlignCenter, AlignBottom, FontSecondary, "Metakom");
break;
}
widget_add_string_element(
- widget, 64, 33, AlignCenter, AlignBottom, FontSecondary, ibutton->text_store);
+ widget, 64, 46, AlignCenter, AlignBottom, FontSecondary, ibutton->text_store);
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewWidget);
- string_clear(key_name);
+ furi_string_free(key_name);
}
bool ibutton_scene_delete_confirm_on_event(void* context, SceneManagerEvent event) {
diff --git a/applications/main/ibutton/scenes/ibutton_scene_emulate.c b/applications/main/ibutton/scenes/ibutton_scene_emulate.c
index 3420f8471..b3bc38ead 100644
--- a/applications/main/ibutton/scenes/ibutton_scene_emulate.c
+++ b/applications/main/ibutton/scenes/ibutton_scene_emulate.c
@@ -15,31 +15,29 @@ static void ibutton_scene_emulate_callback(void* context, bool emulated) {
void ibutton_scene_emulate_on_enter(void* context) {
iButton* ibutton = context;
- Popup* popup = ibutton->popup;
+ Widget* widget = ibutton->widget;
iButtonKey* key = ibutton->key;
const uint8_t* key_data = ibutton_key_get_data_p(key);
- string_t key_name;
- string_init(key_name);
- if(string_end_with_str_p(ibutton->file_path, IBUTTON_APP_EXTENSION)) {
+ FuriString* key_name;
+ key_name = furi_string_alloc();
+ if(furi_string_end_with(ibutton->file_path, IBUTTON_APP_EXTENSION)) {
path_extract_filename(ibutton->file_path, key_name, true);
}
- uint8_t line_count = 2;
DOLPHIN_DEED(DolphinDeedIbuttonEmulate);
// check that stored key has name
- if(!string_empty_p(key_name)) {
- ibutton_text_store_set(ibutton, "emulating\n%s", string_get_cstr(key_name));
- line_count = 2;
+ if(!furi_string_empty(key_name)) {
+ ibutton_text_store_set(ibutton, "%s", furi_string_get_cstr(key_name));
} else {
// if not, show key data
switch(ibutton_key_get_type(key)) {
case iButtonKeyDS1990:
ibutton_text_store_set(
ibutton,
- "emulating\n%02X %02X %02X %02X\n%02X %02X %02X %02X",
+ "%02X %02X %02X %02X\n%02X %02X %02X %02X",
key_data[0],
key_data[1],
key_data[2],
@@ -48,46 +46,30 @@ void ibutton_scene_emulate_on_enter(void* context) {
key_data[5],
key_data[6],
key_data[7]);
- line_count = 3;
break;
case iButtonKeyCyfral:
- ibutton_text_store_set(ibutton, "emulating\n%02X %02X", key_data[0], key_data[1]);
- line_count = 2;
+ ibutton_text_store_set(ibutton, "%02X %02X", key_data[0], key_data[1]);
break;
case iButtonKeyMetakom:
ibutton_text_store_set(
- ibutton,
- "emulating\n%02X %02X %02X %02X",
- key_data[0],
- key_data[1],
- key_data[2],
- key_data[3]);
- line_count = 2;
+ ibutton, "%02X %02X %02X %02X", key_data[0], key_data[1], key_data[2], key_data[3]);
break;
}
}
- switch(line_count) {
- case 3:
- popup_set_header(popup, "iButton", 82, 18, AlignCenter, AlignBottom);
- popup_set_text(popup, ibutton->text_store, 82, 22, AlignCenter, AlignTop);
- break;
+ widget_add_string_multiline_element(
+ widget, 90, 10, AlignCenter, AlignTop, FontPrimary, "iButton\nemulating");
+ widget_add_icon_element(widget, 3, 10, &I_iButtonKey_49x44);
+ widget_add_text_box_element(
+ widget, 54, 39, 75, 22, AlignCenter, AlignCenter, ibutton->text_store, true);
- default:
- popup_set_header(popup, "iButton", 82, 24, AlignCenter, AlignBottom);
- popup_set_text(popup, ibutton->text_store, 82, 28, AlignCenter, AlignTop);
- break;
- }
-
- popup_set_icon(popup, 2, 10, &I_iButtonKey_49x44);
-
- view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup);
+ view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewWidget);
ibutton_worker_emulate_set_callback(
ibutton->key_worker, ibutton_scene_emulate_callback, ibutton);
ibutton_worker_emulate_start(ibutton->key_worker, key);
- string_clear(key_name);
+ furi_string_free(key_name);
ibutton_notification_message(ibutton, iButtonNotificationMessageEmulateStart);
}
@@ -122,10 +104,7 @@ bool ibutton_scene_emulate_on_event(void* context, SceneManagerEvent event) {
void ibutton_scene_emulate_on_exit(void* context) {
iButton* ibutton = context;
- Popup* popup = ibutton->popup;
ibutton_worker_stop(ibutton->key_worker);
- popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
- popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
- popup_set_icon(popup, 0, 0, NULL);
+ widget_reset(ibutton->widget);
ibutton_notification_message(ibutton, iButtonNotificationMessageBlinkStop);
}
diff --git a/applications/main/ibutton/scenes/ibutton_scene_info.c b/applications/main/ibutton/scenes/ibutton_scene_info.c
index bd364ada8..15648f6f2 100644
--- a/applications/main/ibutton/scenes/ibutton_scene_info.c
+++ b/applications/main/ibutton/scenes/ibutton_scene_info.c
@@ -8,13 +8,13 @@ void ibutton_scene_info_on_enter(void* context) {
const uint8_t* key_data = ibutton_key_get_data_p(key);
- string_t key_name;
- string_init(key_name);
+ FuriString* key_name;
+ key_name = furi_string_alloc();
path_extract_filename(ibutton->file_path, key_name, true);
- ibutton_text_store_set(ibutton, "%s", string_get_cstr(key_name));
+ ibutton_text_store_set(ibutton, "%s", furi_string_get_cstr(key_name));
widget_add_text_box_element(
- widget, 0, 0, 128, 28, AlignCenter, AlignCenter, ibutton->text_store, false);
+ widget, 0, 0, 128, 23, AlignCenter, AlignCenter, ibutton->text_store, true);
switch(ibutton_key_get_type(key)) {
case iButtonKeyDS1990:
@@ -29,30 +29,28 @@ void ibutton_scene_info_on_enter(void* context) {
key_data[5],
key_data[6],
key_data[7]);
- widget_add_string_element(
- widget, 64, 51, AlignCenter, AlignBottom, FontSecondary, "Dallas");
+ widget_add_string_element(widget, 64, 36, AlignCenter, AlignBottom, FontPrimary, "Dallas");
break;
case iButtonKeyMetakom:
ibutton_text_store_set(
ibutton, "%02X %02X %02X %02X", key_data[0], key_data[1], key_data[2], key_data[3]);
widget_add_string_element(
- widget, 64, 51, AlignCenter, AlignBottom, FontSecondary, "Metakom");
+ widget, 64, 36, AlignCenter, AlignBottom, FontPrimary, "Metakom");
break;
case iButtonKeyCyfral:
ibutton_text_store_set(ibutton, "%02X %02X", key_data[0], key_data[1]);
- widget_add_string_element(
- widget, 64, 51, AlignCenter, AlignBottom, FontSecondary, "Cyfral");
+ widget_add_string_element(widget, 64, 36, AlignCenter, AlignBottom, FontPrimary, "Cyfral");
break;
}
widget_add_string_element(
- widget, 64, 35, AlignCenter, AlignBottom, FontPrimary, ibutton->text_store);
+ widget, 64, 50, AlignCenter, AlignBottom, FontSecondary, ibutton->text_store);
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewWidget);
- string_clear(key_name);
+ furi_string_free(key_name);
}
bool ibutton_scene_info_on_event(void* context, SceneManagerEvent event) {
diff --git a/applications/main/ibutton/scenes/ibutton_scene_read.c b/applications/main/ibutton/scenes/ibutton_scene_read.c
index 7af351f06..05920a0ad 100644
--- a/applications/main/ibutton/scenes/ibutton_scene_read.c
+++ b/applications/main/ibutton/scenes/ibutton_scene_read.c
@@ -18,7 +18,7 @@ void ibutton_scene_read_on_enter(void* context) {
popup_set_icon(popup, 0, 5, &I_DolphinWait_61x59);
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup);
- string_set_str(ibutton->file_path, IBUTTON_APP_FOLDER);
+ furi_string_set(ibutton->file_path, IBUTTON_APP_FOLDER);
ibutton_worker_read_set_callback(worker, ibutton_scene_read_callback, ibutton);
ibutton_worker_read_start(worker, key);
diff --git a/applications/main/ibutton/scenes/ibutton_scene_rpc.c b/applications/main/ibutton/scenes/ibutton_scene_rpc.c
index 0755c8ff8..b25b1b8dd 100644
--- a/applications/main/ibutton/scenes/ibutton_scene_rpc.c
+++ b/applications/main/ibutton/scenes/ibutton_scene_rpc.c
@@ -29,19 +29,19 @@ bool ibutton_scene_rpc_on_event(void* context, SceneManagerEvent event) {
if(event.event == iButtonCustomEventRpcLoad) {
const char* arg = rpc_system_app_get_data(ibutton->rpc_ctx);
bool result = false;
- if(arg && (string_empty_p(ibutton->file_path))) {
- string_set_str(ibutton->file_path, arg);
+ if(arg && (furi_string_empty(ibutton->file_path))) {
+ furi_string_set(ibutton->file_path, arg);
if(ibutton_load_key_data(ibutton, ibutton->file_path, false)) {
ibutton_worker_emulate_start(ibutton->key_worker, ibutton->key);
- string_t key_name;
- string_init(key_name);
- if(string_end_with_str_p(ibutton->file_path, IBUTTON_APP_EXTENSION)) {
+ FuriString* key_name;
+ key_name = furi_string_alloc();
+ if(furi_string_end_with(ibutton->file_path, IBUTTON_APP_EXTENSION)) {
path_extract_filename(ibutton->file_path, key_name, true);
}
- if(!string_empty_p(key_name)) {
+ if(!furi_string_empty(key_name)) {
ibutton_text_store_set(
- ibutton, "emulating\n%s", string_get_cstr(key_name));
+ ibutton, "emulating\n%s", furi_string_get_cstr(key_name));
} else {
ibutton_text_store_set(ibutton, "emulating");
}
@@ -49,10 +49,10 @@ bool ibutton_scene_rpc_on_event(void* context, SceneManagerEvent event) {
ibutton_notification_message(ibutton, iButtonNotificationMessageEmulateStart);
- string_clear(key_name);
+ furi_string_free(key_name);
result = true;
} else {
- string_reset(ibutton->file_path);
+ furi_string_reset(ibutton->file_path);
}
}
rpc_system_app_confirm(ibutton->rpc_ctx, RpcAppEventLoadFile, result);
diff --git a/applications/main/ibutton/scenes/ibutton_scene_save_name.c b/applications/main/ibutton/scenes/ibutton_scene_save_name.c
index be6403874..773b93e0c 100644
--- a/applications/main/ibutton/scenes/ibutton_scene_save_name.c
+++ b/applications/main/ibutton/scenes/ibutton_scene_save_name.c
@@ -1,5 +1,4 @@
#include "../ibutton_i.h"
-#include "m-string.h"
#include
#include
@@ -12,17 +11,17 @@ void ibutton_scene_save_name_on_enter(void* context) {
iButton* ibutton = context;
TextInput* text_input = ibutton->text_input;
- string_t key_name;
- string_init(key_name);
- if(string_end_with_str_p(ibutton->file_path, IBUTTON_APP_EXTENSION)) {
+ FuriString* key_name;
+ key_name = furi_string_alloc();
+ if(furi_string_end_with(ibutton->file_path, IBUTTON_APP_EXTENSION)) {
path_extract_filename(ibutton->file_path, key_name, true);
}
- const bool key_name_is_empty = string_empty_p(key_name);
+ const bool key_name_is_empty = furi_string_empty(key_name);
if(key_name_is_empty) {
set_random_name(ibutton->text_store, IBUTTON_TEXT_STORE_SIZE);
} else {
- ibutton_text_store_set(ibutton, "%s", string_get_cstr(key_name));
+ ibutton_text_store_set(ibutton, "%s", furi_string_get_cstr(key_name));
}
text_input_set_header_text(text_input, "Name the key");
@@ -34,19 +33,19 @@ void ibutton_scene_save_name_on_enter(void* context) {
IBUTTON_KEY_NAME_SIZE,
key_name_is_empty);
- string_t folder_path;
- string_init(folder_path);
+ FuriString* folder_path;
+ folder_path = furi_string_alloc();
- path_extract_dirname(string_get_cstr(ibutton->file_path), folder_path);
+ path_extract_dirname(furi_string_get_cstr(ibutton->file_path), folder_path);
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
- string_get_cstr(folder_path), IBUTTON_APP_EXTENSION, string_get_cstr(key_name));
+ furi_string_get_cstr(folder_path), IBUTTON_APP_EXTENSION, furi_string_get_cstr(key_name));
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewTextInput);
- string_clear(key_name);
- string_clear(folder_path);
+ furi_string_free(key_name);
+ furi_string_free(folder_path);
}
bool ibutton_scene_save_name_on_event(void* context, SceneManagerEvent event) {
diff --git a/applications/main/ibutton/scenes/ibutton_scene_save_success.c b/applications/main/ibutton/scenes/ibutton_scene_save_success.c
index 6c24a897c..43237f429 100644
--- a/applications/main/ibutton/scenes/ibutton_scene_save_success.c
+++ b/applications/main/ibutton/scenes/ibutton_scene_save_success.c
@@ -29,10 +29,8 @@ bool ibutton_scene_save_success_on_event(void* context, SceneManagerEvent event)
if(event.type == SceneManagerEventTypeCustom) {
consumed = true;
if(event.event == iButtonCustomEventBack) {
- const uint32_t possible_scenes[] = {
- iButtonSceneReadKeyMenu, iButtonSceneSavedKeyMenu, iButtonSceneAddType};
- scene_manager_search_and_switch_to_previous_scene_one_of(
- ibutton->scene_manager, possible_scenes, COUNT_OF(possible_scenes));
+ scene_manager_search_and_switch_to_another_scene(
+ ibutton->scene_manager, iButtonSceneSelectKey);
}
}
diff --git a/applications/main/ibutton/scenes/ibutton_scene_start.c b/applications/main/ibutton/scenes/ibutton_scene_start.c
index c2844cde9..dde224e15 100644
--- a/applications/main/ibutton/scenes/ibutton_scene_start.c
+++ b/applications/main/ibutton/scenes/ibutton_scene_start.c
@@ -39,7 +39,7 @@ bool ibutton_scene_start_on_event(void* context, SceneManagerEvent event) {
if(event.event == SubmenuIndexRead) {
scene_manager_next_scene(ibutton->scene_manager, iButtonSceneRead);
} else if(event.event == SubmenuIndexSaved) {
- string_set_str(ibutton->file_path, IBUTTON_APP_FOLDER);
+ furi_string_set(ibutton->file_path, IBUTTON_APP_FOLDER);
scene_manager_next_scene(ibutton->scene_manager, iButtonSceneSelectKey);
} else if(event.event == SubmenuIndexAdd) {
scene_manager_next_scene(ibutton->scene_manager, iButtonSceneAddType);
diff --git a/applications/main/ibutton/scenes/ibutton_scene_write.c b/applications/main/ibutton/scenes/ibutton_scene_write.c
index 195758d2c..cdea04db3 100644
--- a/applications/main/ibutton/scenes/ibutton_scene_write.c
+++ b/applications/main/ibutton/scenes/ibutton_scene_write.c
@@ -1,5 +1,4 @@
#include "../ibutton_i.h"
-#include "m-string.h"
#include "toolbox/path.h"
typedef enum {
@@ -14,31 +13,28 @@ static void ibutton_scene_write_callback(void* context, iButtonWorkerWriteResult
void ibutton_scene_write_on_enter(void* context) {
iButton* ibutton = context;
- Popup* popup = ibutton->popup;
iButtonKey* key = ibutton->key;
+ Widget* widget = ibutton->widget;
iButtonWorker* worker = ibutton->key_worker;
const uint8_t* key_data = ibutton_key_get_data_p(key);
- string_t key_name;
- string_init(key_name);
- if(string_end_with_str_p(ibutton->file_path, IBUTTON_APP_EXTENSION)) {
+ FuriString* key_name;
+ key_name = furi_string_alloc();
+ if(furi_string_end_with(ibutton->file_path, IBUTTON_APP_EXTENSION)) {
path_extract_filename(ibutton->file_path, key_name, true);
}
- uint8_t line_count = 2;
-
// check that stored key has name
- if(!string_empty_p(key_name)) {
- ibutton_text_store_set(ibutton, "writing\n%s", string_get_cstr(key_name));
- line_count = 2;
+ if(!furi_string_empty(key_name)) {
+ ibutton_text_store_set(ibutton, "%s", furi_string_get_cstr(key_name));
} else {
// if not, show key data
switch(ibutton_key_get_type(key)) {
case iButtonKeyDS1990:
ibutton_text_store_set(
ibutton,
- "writing\n%02X %02X %02X %02X\n%02X %02X %02X %02X",
+ "%02X %02X %02X %02X\n%02X %02X %02X %02X",
key_data[0],
key_data[1],
key_data[2],
@@ -47,45 +43,29 @@ void ibutton_scene_write_on_enter(void* context) {
key_data[5],
key_data[6],
key_data[7]);
- line_count = 3;
break;
case iButtonKeyCyfral:
- ibutton_text_store_set(ibutton, "writing\n%02X %02X", key_data[0], key_data[1]);
- line_count = 2;
+ ibutton_text_store_set(ibutton, "%02X %02X", key_data[0], key_data[1]);
break;
case iButtonKeyMetakom:
ibutton_text_store_set(
- ibutton,
- "writing\n%02X %02X %02X %02X",
- key_data[0],
- key_data[1],
- key_data[2],
- key_data[3]);
- line_count = 2;
+ ibutton, "%02X %02X %02X %02X", key_data[0], key_data[1], key_data[2], key_data[3]);
break;
}
}
- switch(line_count) {
- case 3:
- popup_set_header(popup, "iButton", 82, 18, AlignCenter, AlignBottom);
- popup_set_text(popup, ibutton->text_store, 82, 22, AlignCenter, AlignTop);
- break;
+ widget_add_string_multiline_element(
+ widget, 90, 10, AlignCenter, AlignTop, FontPrimary, "iButton\nwriting");
+ widget_add_icon_element(widget, 3, 10, &I_iButtonKey_49x44);
+ widget_add_text_box_element(
+ widget, 54, 39, 75, 22, AlignCenter, AlignCenter, ibutton->text_store, true);
- default:
- popup_set_header(popup, "iButton", 82, 24, AlignCenter, AlignBottom);
- popup_set_text(popup, ibutton->text_store, 82, 28, AlignCenter, AlignTop);
- break;
- }
-
- popup_set_icon(popup, 2, 10, &I_iButtonKey_49x44);
-
- view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup);
+ view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewWidget);
ibutton_worker_write_set_callback(worker, ibutton_scene_write_callback, ibutton);
ibutton_worker_write_start(worker, key);
- string_clear(key_name);
+ furi_string_free(key_name);
ibutton_notification_message(ibutton, iButtonNotificationMessageEmulateStart);
}
@@ -114,11 +94,8 @@ bool ibutton_scene_write_on_event(void* context, SceneManagerEvent event) {
void ibutton_scene_write_on_exit(void* context) {
iButton* ibutton = context;
- Popup* popup = ibutton->popup;
ibutton_worker_stop(ibutton->key_worker);
- popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
- popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
- popup_set_icon(popup, 0, 0, NULL);
+ widget_reset(ibutton->widget);
ibutton_notification_message(ibutton, iButtonNotificationMessageBlinkStop);
}
diff --git a/applications/main/infrared/infrared.c b/applications/main/infrared/infrared.c
index 60809e787..f62db14c1 100644
--- a/applications/main/infrared/infrared.c
+++ b/applications/main/infrared/infrared.c
@@ -65,51 +65,52 @@ static void infrared_rpc_command_callback(RpcAppSystemEvent event, void* context
}
}
-static void infrared_find_vacant_remote_name(string_t name, const char* path) {
+static void infrared_find_vacant_remote_name(FuriString* name, const char* path) {
Storage* storage = furi_record_open(RECORD_STORAGE);
- string_t base_path;
- string_init_set_str(base_path, path);
+ FuriString* base_path;
+ base_path = furi_string_alloc_set(path);
- if(string_end_with_str_p(base_path, INFRARED_APP_EXTENSION)) {
- size_t filename_start = string_search_rchar(base_path, '/');
- string_left(base_path, filename_start);
+ if(furi_string_end_with(base_path, INFRARED_APP_EXTENSION)) {
+ size_t filename_start = furi_string_search_rchar(base_path, '/');
+ furi_string_left(base_path, filename_start);
}
- string_printf(base_path, "%s/%s%s", path, string_get_cstr(name), INFRARED_APP_EXTENSION);
+ furi_string_printf(
+ base_path, "%s/%s%s", path, furi_string_get_cstr(name), INFRARED_APP_EXTENSION);
- FS_Error status = storage_common_stat(storage, string_get_cstr(base_path), NULL);
+ FS_Error status = storage_common_stat(storage, furi_string_get_cstr(base_path), NULL);
if(status == FSE_OK) {
/* If the suggested name is occupied, try another one (name2, name3, etc) */
- size_t dot = string_search_rchar(base_path, '.');
- string_left(base_path, dot);
+ size_t dot = furi_string_search_rchar(base_path, '.');
+ furi_string_left(base_path, dot);
- string_t path_temp;
- string_init(path_temp);
+ FuriString* path_temp;
+ path_temp = furi_string_alloc();
uint32_t i = 1;
do {
- string_printf(
- path_temp, "%s%u%s", string_get_cstr(base_path), ++i, INFRARED_APP_EXTENSION);
- status = storage_common_stat(storage, string_get_cstr(path_temp), NULL);
+ furi_string_printf(
+ path_temp, "%s%lu%s", furi_string_get_cstr(base_path), ++i, INFRARED_APP_EXTENSION);
+ status = storage_common_stat(storage, furi_string_get_cstr(path_temp), NULL);
} while(status == FSE_OK);
- string_clear(path_temp);
+ furi_string_free(path_temp);
if(status == FSE_NOT_EXIST) {
- string_cat_printf(name, "%u", i);
+ furi_string_cat_printf(name, "%lu", i);
}
}
- string_clear(base_path);
+ furi_string_free(base_path);
furi_record_close(RECORD_STORAGE);
}
static Infrared* infrared_alloc() {
Infrared* infrared = malloc(sizeof(Infrared));
- string_init(infrared->file_path);
+ infrared->file_path = furi_string_alloc();
InfraredAppState* app_state = &infrared->app_state;
app_state->is_learning_new_remote = false;
@@ -232,7 +233,7 @@ static void infrared_free(Infrared* infrared) {
furi_record_close(RECORD_GUI);
infrared->gui = NULL;
- string_clear(infrared->file_path);
+ furi_string_free(infrared->file_path);
free(infrared);
}
@@ -243,19 +244,20 @@ bool infrared_add_remote_with_button(
InfraredSignal* signal) {
InfraredRemote* remote = infrared->remote;
- string_t new_name, new_path;
- string_init_set_str(new_name, INFRARED_DEFAULT_REMOTE_NAME);
- string_init_set_str(new_path, INFRARED_APP_FOLDER);
+ FuriString *new_name, *new_path;
+ new_name = furi_string_alloc_set(INFRARED_DEFAULT_REMOTE_NAME);
+ new_path = furi_string_alloc_set(INFRARED_APP_FOLDER);
- infrared_find_vacant_remote_name(new_name, string_get_cstr(new_path));
- string_cat_printf(new_path, "/%s%s", string_get_cstr(new_name), INFRARED_APP_EXTENSION);
+ infrared_find_vacant_remote_name(new_name, furi_string_get_cstr(new_path));
+ furi_string_cat_printf(
+ new_path, "/%s%s", furi_string_get_cstr(new_name), INFRARED_APP_EXTENSION);
infrared_remote_reset(remote);
- infrared_remote_set_name(remote, string_get_cstr(new_name));
- infrared_remote_set_path(remote, string_get_cstr(new_path));
+ infrared_remote_set_name(remote, furi_string_get_cstr(new_name));
+ infrared_remote_set_path(remote, furi_string_get_cstr(new_path));
- string_clear(new_name);
- string_clear(new_path);
+ furi_string_free(new_name);
+ furi_string_free(new_path);
return infrared_remote_add_button(remote, button_name, signal);
}
@@ -267,28 +269,29 @@ bool infrared_rename_current_remote(Infrared* infrared, const char* name) {
return true;
}
- string_t new_name;
- string_init_set_str(new_name, name);
+ FuriString* new_name;
+ new_name = furi_string_alloc_set(name);
infrared_find_vacant_remote_name(new_name, remote_path);
- string_t new_path;
- string_init_set(new_path, infrared_remote_get_path(remote));
- if(string_end_with_str_p(new_path, INFRARED_APP_EXTENSION)) {
- size_t filename_start = string_search_rchar(new_path, '/');
- string_left(new_path, filename_start);
+ FuriString* new_path;
+ new_path = furi_string_alloc_set(infrared_remote_get_path(remote));
+ if(furi_string_end_with(new_path, INFRARED_APP_EXTENSION)) {
+ size_t filename_start = furi_string_search_rchar(new_path, '/');
+ furi_string_left(new_path, filename_start);
}
- string_cat_printf(new_path, "/%s%s", string_get_cstr(new_name), INFRARED_APP_EXTENSION);
+ furi_string_cat_printf(
+ new_path, "/%s%s", furi_string_get_cstr(new_name), INFRARED_APP_EXTENSION);
Storage* storage = furi_record_open(RECORD_STORAGE);
FS_Error status = storage_common_rename(
- storage, infrared_remote_get_path(remote), string_get_cstr(new_path));
- infrared_remote_set_name(remote, string_get_cstr(new_name));
- infrared_remote_set_path(remote, string_get_cstr(new_path));
+ storage, infrared_remote_get_path(remote), furi_string_get_cstr(new_path));
+ infrared_remote_set_name(remote, furi_string_get_cstr(new_name));
+ infrared_remote_set_path(remote, furi_string_get_cstr(new_path));
- string_clear(new_name);
- string_clear(new_path);
+ furi_string_free(new_name);
+ furi_string_free(new_path);
furi_record_close(RECORD_STORAGE);
return (status == FSE_OK || status == FSE_EXIST);
@@ -435,7 +438,7 @@ int32_t infrared_app(void* p) {
rpc_system_app_send_started(infrared->rpc_ctx);
is_rpc_mode = true;
} else {
- string_set_str(infrared->file_path, (const char*)p);
+ furi_string_set(infrared->file_path, (const char*)p);
is_remote_loaded = infrared_remote_load(infrared->remote, infrared->file_path);
if(!is_remote_loaded) {
dialog_message_show_storage_error(
diff --git a/applications/main/infrared/infrared_brute_force.c b/applications/main/infrared/infrared_brute_force.c
index e9bf1a140..ebc34bd15 100644
--- a/applications/main/infrared/infrared_brute_force.c
+++ b/applications/main/infrared/infrared_brute_force.c
@@ -2,7 +2,6 @@
#include
#include
-#include
#include
#include "infrared_signal.h"
@@ -14,15 +13,15 @@ typedef struct {
DICT_DEF2(
InfraredBruteForceRecordDict,
- string_t,
- STRING_OPLIST,
+ FuriString*,
+ FURI_STRING_OPLIST,
InfraredBruteForceRecord,
M_POD_OPLIST);
struct InfraredBruteForce {
FlipperFormat* ff;
const char* db_filename;
- string_t current_record_name;
+ FuriString* current_record_name;
InfraredSignal* current_signal;
InfraredBruteForceRecordDict_t records;
bool is_started;
@@ -34,7 +33,7 @@ InfraredBruteForce* infrared_brute_force_alloc() {
brute_force->db_filename = NULL;
brute_force->current_signal = NULL;
brute_force->is_started = false;
- string_init(brute_force->current_record_name);
+ brute_force->current_record_name = furi_string_alloc();
InfraredBruteForceRecordDict_init(brute_force->records);
return brute_force;
}
@@ -47,7 +46,7 @@ void infrared_brute_force_clear_records(InfraredBruteForce* brute_force) {
void infrared_brute_force_free(InfraredBruteForce* brute_force) {
furi_assert(!brute_force->is_started);
InfraredBruteForceRecordDict_clear(brute_force->records);
- string_clear(brute_force->current_record_name);
+ furi_string_free(brute_force->current_record_name);
free(brute_force);
}
@@ -66,8 +65,8 @@ bool infrared_brute_force_calculate_messages(InfraredBruteForce* brute_force) {
success = flipper_format_buffered_file_open_existing(ff, brute_force->db_filename);
if(success) {
- string_t signal_name;
- string_init(signal_name);
+ FuriString* signal_name;
+ signal_name = furi_string_alloc();
while(flipper_format_read_string(ff, "name", signal_name)) {
InfraredBruteForceRecord* record =
InfraredBruteForceRecordDict_get(brute_force->records, signal_name);
@@ -75,7 +74,7 @@ bool infrared_brute_force_calculate_messages(InfraredBruteForce* brute_force) {
++(record->count);
}
}
- string_clear(signal_name);
+ furi_string_free(signal_name);
}
flipper_format_free(ff);
@@ -99,7 +98,7 @@ bool infrared_brute_force_start(
if(record->value.index == index) {
*record_count = record->value.count;
if(*record_count) {
- string_set(brute_force->current_record_name, record->key);
+ furi_string_set(brute_force->current_record_name, record->key);
}
break;
}
@@ -123,7 +122,7 @@ bool infrared_brute_force_is_started(InfraredBruteForce* brute_force) {
void infrared_brute_force_stop(InfraredBruteForce* brute_force) {
furi_assert(brute_force->is_started);
- string_reset(brute_force->current_record_name);
+ furi_string_reset(brute_force->current_record_name);
infrared_signal_free(brute_force->current_signal);
flipper_format_free(brute_force->ff);
brute_force->current_signal = NULL;
@@ -147,8 +146,8 @@ void infrared_brute_force_add_record(
uint32_t index,
const char* name) {
InfraredBruteForceRecord value = {.index = index, .count = 0};
- string_t key;
- string_init_set_str(key, name);
+ FuriString* key;
+ key = furi_string_alloc_set(name);
InfraredBruteForceRecordDict_set_at(brute_force->records, key, value);
- string_clear(key);
+ furi_string_free(key);
}
diff --git a/applications/main/infrared/infrared_cli.c b/applications/main/infrared/infrared_cli.c
index 693e191ee..5ec57c757 100644
--- a/applications/main/infrared/infrared_cli.c
+++ b/applications/main/infrared/infrared_cli.c
@@ -1,4 +1,3 @@
-#include
#include
#include
#include
@@ -10,13 +9,13 @@
#define INFRARED_CLI_BUF_SIZE 10
-static void infrared_cli_start_ir_rx(Cli* cli, string_t args);
-static void infrared_cli_start_ir_tx(Cli* cli, string_t args);
-static void infrared_cli_process_decode(Cli* cli, string_t args);
+static void infrared_cli_start_ir_rx(Cli* cli, FuriString* args);
+static void infrared_cli_start_ir_tx(Cli* cli, FuriString* args);
+static void infrared_cli_process_decode(Cli* cli, FuriString* args);
static const struct {
const char* cmd;
- void (*process_function)(Cli* cli, string_t args);
+ void (*process_function)(Cli* cli, FuriString* args);
} infrared_cli_commands[] = {
{.cmd = "rx", .process_function = infrared_cli_start_ir_rx},
{.cmd = "tx", .process_function = infrared_cli_start_ir_tx},
@@ -58,7 +57,7 @@ static void signal_received_callback(void* context, InfraredWorkerSignal* receiv
}
}
-static void infrared_cli_start_ir_rx(Cli* cli, string_t args) {
+static void infrared_cli_start_ir_rx(Cli* cli, FuriString* args) {
UNUSED(cli);
UNUSED(args);
InfraredWorker* worker = infrared_worker_alloc();
@@ -151,9 +150,9 @@ static bool infrared_cli_parse_raw(const char* str, InfraredSignal* signal) {
return infrared_signal_is_valid(signal);
}
-static void infrared_cli_start_ir_tx(Cli* cli, string_t args) {
+static void infrared_cli_start_ir_tx(Cli* cli, FuriString* args) {
UNUSED(cli);
- const char* str = string_get_cstr(args);
+ const char* str = furi_string_get_cstr(args);
InfraredSignal* signal = infrared_signal_alloc();
bool success = infrared_cli_parse_message(str, signal) || infrared_cli_parse_raw(str, signal);
@@ -231,8 +230,8 @@ static bool infrared_cli_decode_file(FlipperFormat* input_file, FlipperFormat* o
InfraredSignal* signal = infrared_signal_alloc();
InfraredDecoderHandler* decoder = infrared_alloc_decoder();
- string_t tmp;
- string_init(tmp);
+ FuriString* tmp;
+ tmp = furi_string_alloc();
while(infrared_signal_read(signal, input_file, tmp)) {
ret = false;
@@ -242,7 +241,7 @@ static bool infrared_cli_decode_file(FlipperFormat* input_file, FlipperFormat* o
}
if(!infrared_signal_is_raw(signal)) {
if(output_file &&
- !infrared_cli_save_signal(signal, output_file, string_get_cstr(tmp))) {
+ !infrared_cli_save_signal(signal, output_file, furi_string_get_cstr(tmp))) {
break;
} else {
printf("Skipping decoded signal\r\n");
@@ -250,31 +249,33 @@ static bool infrared_cli_decode_file(FlipperFormat* input_file, FlipperFormat* o
}
}
InfraredRawSignal* raw_signal = infrared_signal_get_raw_signal(signal);
- printf("Raw signal: %s, %u samples\r\n", string_get_cstr(tmp), raw_signal->timings_size);
- if(!infrared_cli_decode_raw_signal(raw_signal, decoder, output_file, string_get_cstr(tmp)))
+ printf(
+ "Raw signal: %s, %u samples\r\n", furi_string_get_cstr(tmp), raw_signal->timings_size);
+ if(!infrared_cli_decode_raw_signal(
+ raw_signal, decoder, output_file, furi_string_get_cstr(tmp)))
break;
ret = true;
}
infrared_free_decoder(decoder);
infrared_signal_free(signal);
- string_clear(tmp);
+ furi_string_free(tmp);
return ret;
}
-static void infrared_cli_process_decode(Cli* cli, string_t args) {
+static void infrared_cli_process_decode(Cli* cli, FuriString* args) {
UNUSED(cli);
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* input_file = flipper_format_buffered_file_alloc(storage);
FlipperFormat* output_file = NULL;
uint32_t version;
- string_t tmp, header, input_path, output_path;
- string_init(tmp);
- string_init(header);
- string_init(input_path);
- string_init(output_path);
+ FuriString *tmp, *header, *input_path, *output_path;
+ tmp = furi_string_alloc();
+ header = furi_string_alloc();
+ input_path = furi_string_alloc();
+ output_path = furi_string_alloc();
do {
if(!args_read_probably_quoted_string_and_trim(args, input_path)) {
@@ -283,26 +284,32 @@ static void infrared_cli_process_decode(Cli* cli, string_t args) {
break;
}
args_read_probably_quoted_string_and_trim(args, output_path);
- if(!flipper_format_buffered_file_open_existing(input_file, string_get_cstr(input_path))) {
- printf("Failed to open file for reading: \"%s\"\r\n", string_get_cstr(input_path));
+ if(!flipper_format_buffered_file_open_existing(
+ input_file, furi_string_get_cstr(input_path))) {
+ printf(
+ "Failed to open file for reading: \"%s\"\r\n", furi_string_get_cstr(input_path));
break;
}
if(!flipper_format_read_header(input_file, header, &version) ||
- (!string_start_with_str_p(header, "IR")) || version != 1) {
- printf("Invalid or corrupted input file: \"%s\"\r\n", string_get_cstr(input_path));
+ (!furi_string_start_with_str(header, "IR")) || version != 1) {
+ printf(
+ "Invalid or corrupted input file: \"%s\"\r\n", furi_string_get_cstr(input_path));
break;
}
- if(!string_empty_p(output_path)) {
- printf("Writing output to file: \"%s\"\r\n", string_get_cstr(output_path));
+ if(!furi_string_empty(output_path)) {
+ printf("Writing output to file: \"%s\"\r\n", furi_string_get_cstr(output_path));
output_file = flipper_format_file_alloc(storage);
}
if(output_file &&
- !flipper_format_file_open_always(output_file, string_get_cstr(output_path))) {
- printf("Failed to open file for writing: \"%s\"\r\n", string_get_cstr(output_path));
+ !flipper_format_file_open_always(output_file, furi_string_get_cstr(output_path))) {
+ printf(
+ "Failed to open file for writing: \"%s\"\r\n", furi_string_get_cstr(output_path));
break;
}
if(output_file && !flipper_format_write_header(output_file, header, version)) {
- printf("Failed to write to the output file: \"%s\"\r\n", string_get_cstr(output_path));
+ printf(
+ "Failed to write to the output file: \"%s\"\r\n",
+ furi_string_get_cstr(output_path));
break;
}
if(!infrared_cli_decode_file(input_file, output_file)) {
@@ -311,31 +318,31 @@ static void infrared_cli_process_decode(Cli* cli, string_t args) {
printf("File successfully decoded.\r\n");
} while(false);
- string_clear(tmp);
- string_clear(header);
- string_clear(input_path);
- string_clear(output_path);
+ furi_string_free(tmp);
+ furi_string_free(header);
+ furi_string_free(input_path);
+ furi_string_free(output_path);
flipper_format_free(input_file);
if(output_file) flipper_format_free(output_file);
furi_record_close(RECORD_STORAGE);
}
-static void infrared_cli_start_ir(Cli* cli, string_t args, void* context) {
+static void infrared_cli_start_ir(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
if(furi_hal_infrared_is_busy()) {
printf("INFRARED is busy. Exiting.");
return;
}
- string_t command;
- string_init(command);
+ FuriString* command;
+ command = furi_string_alloc();
args_read_string_and_trim(args, command);
size_t i = 0;
for(; i < COUNT_OF(infrared_cli_commands); ++i) {
size_t cmd_len = strlen(infrared_cli_commands[i].cmd);
- if(!strncmp(string_get_cstr(command), infrared_cli_commands[i].cmd, cmd_len)) {
+ if(!strncmp(furi_string_get_cstr(command), infrared_cli_commands[i].cmd, cmd_len)) {
break;
}
}
@@ -346,7 +353,7 @@ static void infrared_cli_start_ir(Cli* cli, string_t args, void* context) {
infrared_cli_print_usage();
}
- string_clear(command);
+ furi_string_free(command);
}
void infrared_on_system_start() {
#ifdef SRV_CLI
diff --git a/applications/main/infrared/infrared_i.h b/applications/main/infrared/infrared_i.h
index 952152587..6d25d1609 100644
--- a/applications/main/infrared/infrared_i.h
+++ b/applications/main/infrared/infrared_i.h
@@ -96,7 +96,7 @@ struct Infrared {
Loading* loading;
InfraredProgressView* progress;
- string_t file_path;
+ FuriString* file_path;
char text_store[INFRARED_TEXT_STORE_NUM][INFRARED_TEXT_STORE_SIZE + 1];
InfraredAppState app_state;
diff --git a/applications/main/infrared/infrared_remote.c b/applications/main/infrared/infrared_remote.c
index 4417c3c73..3a528a656 100644
--- a/applications/main/infrared/infrared_remote.c
+++ b/applications/main/infrared/infrared_remote.c
@@ -3,7 +3,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -15,8 +14,8 @@ ARRAY_DEF(InfraredButtonArray, InfraredRemoteButton*, M_PTR_OPLIST);
struct InfraredRemote {
InfraredButtonArray_t buttons;
- string_t name;
- string_t path;
+ FuriString* name;
+ FuriString* path;
};
static void infrared_remote_clear_buttons(InfraredRemote* remote) {
@@ -31,39 +30,39 @@ static void infrared_remote_clear_buttons(InfraredRemote* remote) {
InfraredRemote* infrared_remote_alloc() {
InfraredRemote* remote = malloc(sizeof(InfraredRemote));
InfraredButtonArray_init(remote->buttons);
- string_init(remote->name);
- string_init(remote->path);
+ remote->name = furi_string_alloc();
+ remote->path = furi_string_alloc();
return remote;
}
void infrared_remote_free(InfraredRemote* remote) {
infrared_remote_clear_buttons(remote);
InfraredButtonArray_clear(remote->buttons);
- string_clear(remote->path);
- string_clear(remote->name);
+ furi_string_free(remote->path);
+ furi_string_free(remote->name);
free(remote);
}
void infrared_remote_reset(InfraredRemote* remote) {
infrared_remote_clear_buttons(remote);
- string_reset(remote->name);
- string_reset(remote->path);
+ furi_string_reset(remote->name);
+ furi_string_reset(remote->path);
}
void infrared_remote_set_name(InfraredRemote* remote, const char* name) {
- string_set_str(remote->name, name);
+ furi_string_set(remote->name, name);
}
const char* infrared_remote_get_name(InfraredRemote* remote) {
- return string_get_cstr(remote->name);
+ return furi_string_get_cstr(remote->name);
}
void infrared_remote_set_path(InfraredRemote* remote, const char* path) {
- string_set_str(remote->path, path);
+ furi_string_set(remote->path, path);
}
const char* infrared_remote_get_path(InfraredRemote* remote) {
- return string_get_cstr(remote->path);
+ return furi_string_get_cstr(remote->path);
}
size_t infrared_remote_get_button_count(InfraredRemote* remote) {
@@ -112,7 +111,7 @@ bool infrared_remote_delete_button(InfraredRemote* remote, size_t index) {
bool infrared_remote_store(InfraredRemote* remote) {
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* ff = flipper_format_file_alloc(storage);
- const char* path = string_get_cstr(remote->path);
+ const char* path = furi_string_get_cstr(remote->path);
FURI_LOG_I(TAG, "store file: \'%s\'", path);
@@ -138,33 +137,33 @@ bool infrared_remote_store(InfraredRemote* remote) {
return success;
}
-bool infrared_remote_load(InfraredRemote* remote, string_t path) {
+bool infrared_remote_load(InfraredRemote* remote, FuriString* path) {
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* ff = flipper_format_buffered_file_alloc(storage);
- string_t buf;
- string_init(buf);
+ FuriString* buf;
+ buf = furi_string_alloc();
- FURI_LOG_I(TAG, "load file: \'%s\'", string_get_cstr(path));
- bool success = flipper_format_buffered_file_open_existing(ff, string_get_cstr(path));
+ FURI_LOG_I(TAG, "load file: \'%s\'", furi_string_get_cstr(path));
+ bool success = flipper_format_buffered_file_open_existing(ff, furi_string_get_cstr(path));
if(success) {
uint32_t version;
success = flipper_format_read_header(ff, buf, &version) &&
- !string_cmp_str(buf, "IR signals file") && (version == 1);
+ !furi_string_cmp(buf, "IR signals file") && (version == 1);
}
if(success) {
path_extract_filename(path, buf, true);
infrared_remote_clear_buttons(remote);
- infrared_remote_set_name(remote, string_get_cstr(buf));
- infrared_remote_set_path(remote, string_get_cstr(path));
+ infrared_remote_set_name(remote, furi_string_get_cstr(buf));
+ infrared_remote_set_path(remote, furi_string_get_cstr(path));
for(bool can_read = true; can_read;) {
InfraredRemoteButton* button = infrared_remote_button_alloc();
can_read = infrared_signal_read(infrared_remote_button_get_signal(button), ff, buf);
if(can_read) {
- infrared_remote_button_set_name(button, string_get_cstr(buf));
+ infrared_remote_button_set_name(button, furi_string_get_cstr(buf));
InfraredButtonArray_push_back(remote->buttons, button);
} else {
infrared_remote_button_free(button);
@@ -172,7 +171,7 @@ bool infrared_remote_load(InfraredRemote* remote, string_t path) {
}
}
- string_clear(buf);
+ furi_string_free(buf);
flipper_format_free(ff);
furi_record_close(RECORD_STORAGE);
return success;
@@ -181,7 +180,7 @@ bool infrared_remote_load(InfraredRemote* remote, string_t path) {
bool infrared_remote_remove(InfraredRemote* remote) {
Storage* storage = furi_record_open(RECORD_STORAGE);
- FS_Error status = storage_common_remove(storage, string_get_cstr(remote->path));
+ FS_Error status = storage_common_remove(storage, furi_string_get_cstr(remote->path));
infrared_remote_reset(remote);
furi_record_close(RECORD_STORAGE);
diff --git a/applications/main/infrared/infrared_remote.h b/applications/main/infrared/infrared_remote.h
index b6f63a198..6eac193d3 100644
--- a/applications/main/infrared/infrared_remote.h
+++ b/applications/main/infrared/infrared_remote.h
@@ -25,5 +25,5 @@ bool infrared_remote_rename_button(InfraredRemote* remote, const char* new_name,
bool infrared_remote_delete_button(InfraredRemote* remote, size_t index);
bool infrared_remote_store(InfraredRemote* remote);
-bool infrared_remote_load(InfraredRemote* remote, string_t path);
+bool infrared_remote_load(InfraredRemote* remote, FuriString* path);
bool infrared_remote_remove(InfraredRemote* remote);
diff --git a/applications/main/infrared/infrared_remote_button.c b/applications/main/infrared/infrared_remote_button.c
index 7525ce48f..1f6315ec5 100644
--- a/applications/main/infrared/infrared_remote_button.c
+++ b/applications/main/infrared/infrared_remote_button.c
@@ -1,32 +1,31 @@
#include "infrared_remote_button.h"
#include
-#include
struct InfraredRemoteButton {
- string_t name;
+ FuriString* name;
InfraredSignal* signal;
};
InfraredRemoteButton* infrared_remote_button_alloc() {
InfraredRemoteButton* button = malloc(sizeof(InfraredRemoteButton));
- string_init(button->name);
+ button->name = furi_string_alloc();
button->signal = infrared_signal_alloc();
return button;
}
void infrared_remote_button_free(InfraredRemoteButton* button) {
- string_clear(button->name);
+ furi_string_free(button->name);
infrared_signal_free(button->signal);
free(button);
}
void infrared_remote_button_set_name(InfraredRemoteButton* button, const char* name) {
- string_set_str(button->name, name);
+ furi_string_set(button->name, name);
}
const char* infrared_remote_button_get_name(InfraredRemoteButton* button) {
- return string_get_cstr(button->name);
+ return furi_string_get_cstr(button->name);
}
void infrared_remote_button_set_signal(InfraredRemoteButton* button, InfraredSignal* signal) {
diff --git a/applications/main/infrared/infrared_signal.c b/applications/main/infrared/infrared_signal.c
index f2e359c8a..d399b9587 100644
--- a/applications/main/infrared/infrared_signal.c
+++ b/applications/main/infrared/infrared_signal.c
@@ -61,7 +61,7 @@ static bool infrared_signal_is_raw_valid(InfraredRawSignal* raw) {
if((raw->frequency > INFRARED_MAX_FREQUENCY) || (raw->frequency < INFRARED_MIN_FREQUENCY)) {
FURI_LOG_E(
TAG,
- "Frequency is out of range (%lX - %lX): %lX",
+ "Frequency is out of range (%X - %X): %lX",
INFRARED_MIN_FREQUENCY,
INFRARED_MAX_FREQUENCY,
raw->frequency);
@@ -74,7 +74,7 @@ static bool infrared_signal_is_raw_valid(InfraredRawSignal* raw) {
} else if((raw->timings_size <= 0) || (raw->timings_size > MAX_TIMINGS_AMOUNT)) {
FURI_LOG_E(
TAG,
- "Timings amount is out of range (0 - %lX): %lX",
+ "Timings amount is out of range (0 - %X): %X",
MAX_TIMINGS_AMOUNT,
raw->timings_size);
return false;
@@ -100,15 +100,15 @@ static inline bool infrared_signal_save_raw(InfraredRawSignal* raw, FlipperForma
}
static inline bool infrared_signal_read_message(InfraredSignal* signal, FlipperFormat* ff) {
- string_t buf;
- string_init(buf);
+ FuriString* buf;
+ buf = furi_string_alloc();
bool success = false;
do {
if(!flipper_format_read_string(ff, "protocol", buf)) break;
InfraredMessage message;
- message.protocol = infrared_get_protocol_by_name(string_get_cstr(buf));
+ message.protocol = infrared_get_protocol_by_name(furi_string_get_cstr(buf));
success = flipper_format_read_hex(ff, "address", (uint8_t*)&message.address, 4) &&
flipper_format_read_hex(ff, "command", (uint8_t*)&message.command, 4) &&
@@ -119,7 +119,7 @@ static inline bool infrared_signal_read_message(InfraredSignal* signal, FlipperF
infrared_signal_set_message(signal, &message);
} while(0);
- string_clear(buf);
+ furi_string_free(buf);
return success;
}
@@ -147,22 +147,22 @@ static inline bool infrared_signal_read_raw(InfraredSignal* signal, FlipperForma
}
static bool infrared_signal_read_body(InfraredSignal* signal, FlipperFormat* ff) {
- string_t tmp;
- string_init(tmp);
+ FuriString* tmp = furi_string_alloc();
+
bool success = false;
do {
if(!flipper_format_read_string(ff, "type", tmp)) break;
- if(string_equal_p(tmp, "raw")) {
+ if(furi_string_equal(tmp, "raw")) {
success = infrared_signal_read_raw(signal, ff);
- } else if(string_equal_p(tmp, "parsed")) {
+ } else if(furi_string_equal(tmp, "parsed")) {
success = infrared_signal_read_message(signal, ff);
} else {
FURI_LOG_E(TAG, "Unknown signal type");
}
} while(false);
- string_clear(tmp);
+ furi_string_free(tmp);
return success;
}
@@ -246,34 +246,33 @@ bool infrared_signal_save(InfraredSignal* signal, FlipperFormat* ff, const char*
}
}
-bool infrared_signal_read(InfraredSignal* signal, FlipperFormat* ff, string_t name) {
- string_t tmp;
- string_init(tmp);
+bool infrared_signal_read(InfraredSignal* signal, FlipperFormat* ff, FuriString* name) {
+ FuriString* tmp = furi_string_alloc();
+
bool success = false;
do {
if(!flipper_format_read_string(ff, "name", tmp)) break;
- string_set(name, tmp);
+ furi_string_set(name, tmp);
if(!infrared_signal_read_body(signal, ff)) break;
success = true;
} while(0);
- string_clear(tmp);
+ furi_string_free(tmp);
return success;
}
bool infrared_signal_search_and_read(
InfraredSignal* signal,
FlipperFormat* ff,
- const string_t name) {
+ const FuriString* name) {
bool success = false;
- string_t tmp;
- string_init(tmp);
+ FuriString* tmp = furi_string_alloc();
do {
bool is_name_found = false;
while(flipper_format_read_string(ff, "name", tmp)) {
- is_name_found = string_equal_p(name, tmp);
+ is_name_found = furi_string_equal(name, tmp);
if(is_name_found) break;
}
if(!is_name_found) break;
@@ -281,7 +280,7 @@ bool infrared_signal_search_and_read(
success = true;
} while(false);
- string_clear(tmp);
+ furi_string_free(tmp);
return success;
}
diff --git a/applications/main/infrared/infrared_signal.h b/applications/main/infrared/infrared_signal.h
index ad2f5d57a..29c661938 100644
--- a/applications/main/infrared/infrared_signal.h
+++ b/applications/main/infrared/infrared_signal.h
@@ -36,10 +36,10 @@ void infrared_signal_set_message(InfraredSignal* signal, const InfraredMessage*
InfraredMessage* infrared_signal_get_message(InfraredSignal* signal);
bool infrared_signal_save(InfraredSignal* signal, FlipperFormat* ff, const char* name);
-bool infrared_signal_read(InfraredSignal* signal, FlipperFormat* ff, string_t name);
+bool infrared_signal_read(InfraredSignal* signal, FlipperFormat* ff, FuriString* name);
bool infrared_signal_search_and_read(
InfraredSignal* signal,
FlipperFormat* ff,
- const string_t name);
+ const FuriString* name);
void infrared_signal_transmit(InfraredSignal* signal);
diff --git a/applications/main/infrared/scenes/infrared_scene_edit_rename.c b/applications/main/infrared/scenes/infrared_scene_edit_rename.c
index ebe7c2a96..a2199215d 100644
--- a/applications/main/infrared/scenes/infrared_scene_edit_rename.c
+++ b/applications/main/infrared/scenes/infrared_scene_edit_rename.c
@@ -29,20 +29,20 @@ void infrared_scene_edit_rename_on_enter(void* context) {
enter_name_length = INFRARED_MAX_REMOTE_NAME_LENGTH;
strncpy(infrared->text_store[0], infrared_remote_get_name(remote), enter_name_length);
- string_t folder_path;
- string_init(folder_path);
+ FuriString* folder_path;
+ folder_path = furi_string_alloc();
- if(string_end_with_str_p(infrared->file_path, INFRARED_APP_EXTENSION)) {
- path_extract_dirname(string_get_cstr(infrared->file_path), folder_path);
+ if(furi_string_end_with(infrared->file_path, INFRARED_APP_EXTENSION)) {
+ path_extract_dirname(furi_string_get_cstr(infrared->file_path), folder_path);
}
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
- string_get_cstr(folder_path),
+ furi_string_get_cstr(folder_path),
INFRARED_APP_EXTENSION,
infrared_remote_get_name(remote));
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
- string_clear(folder_path);
+ furi_string_free(folder_path);
} else {
furi_assert(0);
}
diff --git a/applications/main/infrared/scenes/infrared_scene_learn_enter_name.c b/applications/main/infrared/scenes/infrared_scene_learn_enter_name.c
index b7f4179ea..b6a7eac0d 100644
--- a/applications/main/infrared/scenes/infrared_scene_learn_enter_name.c
+++ b/applications/main/infrared/scenes/infrared_scene_learn_enter_name.c
@@ -50,8 +50,10 @@ bool infrared_scene_learn_enter_name_on_event(void* context, SceneManagerEvent e
if(success) {
scene_manager_next_scene(scene_manager, InfraredSceneLearnDone);
} else {
- scene_manager_search_and_switch_to_previous_scene(
- scene_manager, InfraredSceneRemoteList);
+ dialog_message_show_storage_error(infrared->dialogs, "Failed to save file");
+ const uint32_t possible_scenes[] = {InfraredSceneRemoteList, InfraredSceneStart};
+ scene_manager_search_and_switch_to_previous_scene_one_of(
+ scene_manager, possible_scenes, COUNT_OF(possible_scenes));
}
consumed = true;
}
diff --git a/applications/main/infrared/scenes/infrared_scene_rpc.c b/applications/main/infrared/scenes/infrared_scene_rpc.c
index ca7bbd8df..8044e8318 100644
--- a/applications/main/infrared/scenes/infrared_scene_rpc.c
+++ b/applications/main/infrared/scenes/infrared_scene_rpc.c
@@ -42,7 +42,7 @@ bool infrared_scene_rpc_on_event(void* context, SceneManagerEvent event) {
bool result = false;
const char* arg = rpc_system_app_get_data(infrared->rpc_ctx);
if(arg && (state == InfraredRpcStateIdle)) {
- string_set_str(infrared->file_path, arg);
+ furi_string_set(infrared->file_path, arg);
result = infrared_remote_load(infrared->remote, infrared->file_path);
if(result) {
scene_manager_set_scene_state(
diff --git a/applications/main/infrared/scenes/infrared_scene_start.c b/applications/main/infrared/scenes/infrared_scene_start.c
index d188a6c36..c7df0f45b 100644
--- a/applications/main/infrared/scenes/infrared_scene_start.c
+++ b/applications/main/infrared/scenes/infrared_scene_start.c
@@ -66,7 +66,7 @@ bool infrared_scene_start_on_event(void* context, SceneManagerEvent event) {
scene_manager_next_scene(scene_manager, InfraredSceneLearn);
consumed = true;
} else if(submenu_index == SubmenuIndexSavedRemotes) {
- string_set_str(infrared->file_path, INFRARED_APP_FOLDER);
+ furi_string_set(infrared->file_path, INFRARED_APP_FOLDER);
scene_manager_next_scene(scene_manager, InfraredSceneRemoteList);
consumed = true;
} else if(submenu_index == SubmenuIndexDebug) {
diff --git a/applications/main/infrared/views/infrared_progress_view.c b/applications/main/infrared/views/infrared_progress_view.c
index 5c84ce0d9..3c50f89e4 100644
--- a/applications/main/infrared/views/infrared_progress_view.c
+++ b/applications/main/infrared/views/infrared_progress_view.c
@@ -4,7 +4,6 @@
#include "gui/canvas.h"
#include "gui/view.h"
#include "input/input.h"
-#include "m-string.h"
#include
#include
#include "infrared_progress_view.h"
diff --git a/applications/main/lfrfid/lfrfid.c b/applications/main/lfrfid/lfrfid.c
index dbed9f3af..b0f989374 100644
--- a/applications/main/lfrfid/lfrfid.c
+++ b/applications/main/lfrfid/lfrfid.c
@@ -36,9 +36,9 @@ static LfRfid* lfrfid_alloc() {
lfrfid->storage = furi_record_open(RECORD_STORAGE);
lfrfid->dialogs = furi_record_open(RECORD_DIALOGS);
- string_init(lfrfid->file_name);
- string_init(lfrfid->raw_file_name);
- string_init_set_str(lfrfid->file_path, LFRFID_APP_FOLDER);
+ lfrfid->file_name = furi_string_alloc();
+ lfrfid->raw_file_name = furi_string_alloc();
+ lfrfid->file_path = furi_string_alloc_set(LFRFID_APP_FOLDER);
lfrfid->dict = protocol_dict_alloc(lfrfid_protocols, LFRFIDProtocolMax);
@@ -104,9 +104,9 @@ static LfRfid* lfrfid_alloc() {
static void lfrfid_free(LfRfid* lfrfid) {
furi_assert(lfrfid);
- string_clear(lfrfid->raw_file_name);
- string_clear(lfrfid->file_name);
- string_clear(lfrfid->file_path);
+ furi_string_free(lfrfid->raw_file_name);
+ furi_string_free(lfrfid->file_name);
+ furi_string_free(lfrfid->file_path);
protocol_dict_free(lfrfid->dict);
lfrfid_worker_free(lfrfid->lfworker);
@@ -183,7 +183,7 @@ int32_t lfrfid_app(void* p) {
app->view_dispatcher, app->gui, ViewDispatcherTypeDesktop);
scene_manager_next_scene(app->scene_manager, LfRfidSceneRpc);
} else {
- string_set_str(app->file_path, args);
+ furi_string_set(app->file_path, args);
lfrfid_load_key_data(app, app->file_path, true);
view_dispatcher_attach_to_gui(
app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
@@ -210,13 +210,13 @@ bool lfrfid_save_key(LfRfid* app) {
lfrfid_make_app_folder(app);
- if(string_end_with_str_p(app->file_path, LFRFID_APP_EXTENSION)) {
- size_t filename_start = string_search_rchar(app->file_path, '/');
- string_left(app->file_path, filename_start);
+ if(furi_string_end_with(app->file_path, LFRFID_APP_EXTENSION)) {
+ size_t filename_start = furi_string_search_rchar(app->file_path, '/');
+ furi_string_left(app->file_path, filename_start);
}
- string_cat_printf(
- app->file_path, "/%s%s", string_get_cstr(app->file_name), LFRFID_APP_EXTENSION);
+ furi_string_cat_printf(
+ app->file_path, "/%s%s", furi_string_get_cstr(app->file_name), LFRFID_APP_EXTENSION);
result = lfrfid_save_key_data(app, app->file_path);
return result;
@@ -242,14 +242,14 @@ bool lfrfid_load_key_from_file_select(LfRfid* app) {
bool lfrfid_delete_key(LfRfid* app) {
furi_assert(app);
- return storage_simply_remove(app->storage, string_get_cstr(app->file_path));
+ return storage_simply_remove(app->storage, furi_string_get_cstr(app->file_path));
}
-bool lfrfid_load_key_data(LfRfid* app, string_t path, bool show_dialog) {
+bool lfrfid_load_key_data(LfRfid* app, FuriString* path, bool show_dialog) {
bool result = false;
do {
- app->protocol_id = lfrfid_dict_file_load(app->dict, string_get_cstr(path));
+ app->protocol_id = lfrfid_dict_file_load(app->dict, furi_string_get_cstr(path));
if(app->protocol_id == PROTOCOL_NO) break;
path_extract_filename(path, app->file_name, true);
@@ -263,8 +263,8 @@ bool lfrfid_load_key_data(LfRfid* app, string_t path, bool show_dialog) {
return result;
}
-bool lfrfid_save_key_data(LfRfid* app, string_t path) {
- bool result = lfrfid_dict_file_save(app->dict, app->protocol_id, string_get_cstr(path));
+bool lfrfid_save_key_data(LfRfid* app, FuriString* path) {
+ bool result = lfrfid_dict_file_save(app->dict, app->protocol_id, furi_string_get_cstr(path));
if(!result) {
dialog_message_show_storage_error(app->dialogs, "Cannot save\nkey file");
diff --git a/applications/main/lfrfid/lfrfid_cli.c b/applications/main/lfrfid/lfrfid_cli.c
index 281a0e963..640274529 100644
--- a/applications/main/lfrfid/lfrfid_cli.c
+++ b/applications/main/lfrfid/lfrfid_cli.c
@@ -14,7 +14,7 @@
#include
#include
-static void lfrfid_cli(Cli* cli, string_t args, void* context);
+static void lfrfid_cli(Cli* cli, FuriString* args, void* context);
// app cli function
void lfrfid_on_system_start() {
@@ -46,27 +46,28 @@ static void lfrfid_cli_read_callback(LFRFIDWorkerReadResult result, ProtocolId p
furi_event_flag_set(context->event, 1 << result);
}
-static void lfrfid_cli_read(Cli* cli, string_t args) {
- string_t type_string;
- string_init(type_string);
+static void lfrfid_cli_read(Cli* cli, FuriString* args) {
+ FuriString* type_string;
+ type_string = furi_string_alloc();
LFRFIDWorkerReadType type = LFRFIDWorkerReadTypeAuto;
if(args_read_string_and_trim(args, type_string)) {
- if(string_cmp_str(type_string, "normal") == 0 || string_cmp_str(type_string, "ask") == 0) {
+ if(furi_string_cmp_str(type_string, "normal") == 0 ||
+ furi_string_cmp_str(type_string, "ask") == 0) {
// ask
type = LFRFIDWorkerReadTypeASKOnly;
} else if(
- string_cmp_str(type_string, "indala") == 0 ||
- string_cmp_str(type_string, "psk") == 0) {
+ furi_string_cmp_str(type_string, "indala") == 0 ||
+ furi_string_cmp_str(type_string, "psk") == 0) {
// psk
type = LFRFIDWorkerReadTypePSKOnly;
} else {
lfrfid_cli_print_usage();
- string_clear(type_string);
+ furi_string_free(type_string);
return;
}
}
- string_clear(type_string);
+ furi_string_free(type_string);
ProtocolDict* dict = protocol_dict_alloc(lfrfid_protocols, LFRFIDProtocolMax);
LFRFIDWorker* worker = lfrfid_worker_alloc(dict);
@@ -111,13 +112,13 @@ static void lfrfid_cli_read(Cli* cli, string_t args) {
printf("\r\n");
free(data);
- string_t info;
- string_init(info);
+ FuriString* info;
+ info = furi_string_alloc();
protocol_dict_render_data(dict, info, context.protocol);
- if(!string_empty_p(info)) {
- printf("%s\r\n", string_get_cstr(info));
+ if(!furi_string_empty(info)) {
+ printf("%s\r\n", furi_string_get_cstr(info));
}
- string_clear(info);
+ furi_string_free(info);
}
printf("Reading stopped\r\n");
@@ -126,11 +127,11 @@ static void lfrfid_cli_read(Cli* cli, string_t args) {
furi_event_flag_free(context.event);
}
-static bool lfrfid_cli_parse_args(string_t args, ProtocolDict* dict, ProtocolId* protocol) {
+static bool lfrfid_cli_parse_args(FuriString* args, ProtocolDict* dict, ProtocolId* protocol) {
bool result = false;
- string_t protocol_name, data_text;
- string_init(protocol_name);
- string_init(data_text);
+ FuriString *protocol_name, *data_text;
+ protocol_name = furi_string_alloc();
+ data_text = furi_string_alloc();
size_t data_size = protocol_dict_get_max_data_size(dict);
uint8_t* data = malloc(data_size);
@@ -143,12 +144,12 @@ static bool lfrfid_cli_parse_args(string_t args, ProtocolDict* dict, ProtocolId*
}
// check protocol arg
- *protocol = protocol_dict_get_protocol_by_name(dict, string_get_cstr(protocol_name));
+ *protocol = protocol_dict_get_protocol_by_name(dict, furi_string_get_cstr(protocol_name));
if(*protocol == PROTOCOL_NO) {
printf(
"Unknown protocol: %s\r\n"
"Available protocols:\r\n",
- string_get_cstr(protocol_name));
+ furi_string_get_cstr(protocol_name));
for(ProtocolId i = 0; i < LFRFIDProtocolMax; i++) {
printf(
@@ -177,8 +178,8 @@ static bool lfrfid_cli_parse_args(string_t args, ProtocolDict* dict, ProtocolId*
} while(false);
free(data);
- string_clear(protocol_name);
- string_clear(data_text);
+ furi_string_free(protocol_name);
+ furi_string_free(data_text);
return result;
}
@@ -188,7 +189,7 @@ static void lfrfid_cli_write_callback(LFRFIDWorkerWriteResult result, void* ctx)
furi_event_flag_set(events, 1 << result);
}
-static void lfrfid_cli_write(Cli* cli, string_t args) {
+static void lfrfid_cli_write(Cli* cli, FuriString* args) {
ProtocolDict* dict = protocol_dict_alloc(lfrfid_protocols, LFRFIDProtocolMax);
ProtocolId protocol;
@@ -235,7 +236,7 @@ static void lfrfid_cli_write(Cli* cli, string_t args) {
furi_event_flag_free(event);
}
-static void lfrfid_cli_emulate(Cli* cli, string_t args) {
+static void lfrfid_cli_emulate(Cli* cli, FuriString* args) {
ProtocolDict* dict = protocol_dict_alloc(lfrfid_protocols, LFRFIDProtocolMax);
ProtocolId protocol;
@@ -261,11 +262,11 @@ static void lfrfid_cli_emulate(Cli* cli, string_t args) {
protocol_dict_free(dict);
}
-static void lfrfid_cli_raw_analyze(Cli* cli, string_t args) {
+static void lfrfid_cli_raw_analyze(Cli* cli, FuriString* args) {
UNUSED(cli);
- string_t filepath, info_string;
- string_init(filepath);
- string_init(info_string);
+ FuriString *filepath, *info_string;
+ filepath = furi_string_alloc();
+ info_string = furi_string_alloc();
Storage* storage = furi_record_open(RECORD_STORAGE);
LFRFIDRawFile* file = lfrfid_raw_file_alloc(storage);
@@ -278,7 +279,7 @@ static void lfrfid_cli_raw_analyze(Cli* cli, string_t args) {
break;
}
- if(!lfrfid_raw_file_open_read(file, string_get_cstr(filepath))) {
+ if(!lfrfid_raw_file_open_read(file, furi_string_get_cstr(filepath))) {
printf("Failed to open file\r\n");
break;
}
@@ -308,10 +309,10 @@ static void lfrfid_cli_raw_analyze(Cli* cli, string_t args) {
warn = true;
}
- string_printf(info_string, "[%ld %ld]", pulse, duration);
- printf("%-16s", string_get_cstr(info_string));
- string_printf(info_string, "[%ld %ld]", pulse, duration - pulse);
- printf("%-16s", string_get_cstr(info_string));
+ furi_string_printf(info_string, "[%ld %ld]", pulse, duration);
+ printf("%-16s", furi_string_get_cstr(info_string));
+ furi_string_printf(info_string, "[%ld %ld]", pulse, duration - pulse);
+ printf("%-16s", furi_string_get_cstr(info_string));
if(warn) {
printf(" <<----");
@@ -366,7 +367,7 @@ static void lfrfid_cli_raw_analyze(Cli* cli, string_t args) {
printf("]\r\n");
protocol_dict_render_data(dict, info_string, total_protocol);
- printf("%s\r\n", string_get_cstr(info_string));
+ printf("%s\r\n", furi_string_get_cstr(info_string));
free(data);
} else {
@@ -376,8 +377,8 @@ static void lfrfid_cli_raw_analyze(Cli* cli, string_t args) {
protocol_dict_free(dict);
} while(false);
- string_clear(filepath);
- string_clear(info_string);
+ furi_string_free(filepath);
+ furi_string_free(info_string);
lfrfid_raw_file_free(file);
furi_record_close(RECORD_STORAGE);
}
@@ -388,23 +389,23 @@ static void lfrfid_cli_raw_read_callback(LFRFIDWorkerReadRawResult result, void*
furi_event_flag_set(event, 1 << result);
}
-static void lfrfid_cli_raw_read(Cli* cli, string_t args) {
+static void lfrfid_cli_raw_read(Cli* cli, FuriString* args) {
UNUSED(cli);
- string_t filepath, type_string;
- string_init(filepath);
- string_init(type_string);
+ FuriString *filepath, *type_string;
+ filepath = furi_string_alloc();
+ type_string = furi_string_alloc();
LFRFIDWorkerReadType type = LFRFIDWorkerReadTypeAuto;
do {
if(args_read_string_and_trim(args, type_string)) {
- if(string_cmp_str(type_string, "normal") == 0 ||
- string_cmp_str(type_string, "ask") == 0) {
+ if(furi_string_cmp_str(type_string, "normal") == 0 ||
+ furi_string_cmp_str(type_string, "ask") == 0) {
// ask
type = LFRFIDWorkerReadTypeASKOnly;
} else if(
- string_cmp_str(type_string, "indala") == 0 ||
- string_cmp_str(type_string, "psk") == 0) {
+ furi_string_cmp_str(type_string, "indala") == 0 ||
+ furi_string_cmp_str(type_string, "psk") == 0) {
// psk
type = LFRFIDWorkerReadTypePSKOnly;
} else {
@@ -430,7 +431,7 @@ static void lfrfid_cli_raw_read(Cli* cli, string_t args) {
(1 << LFRFIDWorkerReadRawOverrun);
lfrfid_worker_read_raw_start(
- worker, string_get_cstr(filepath), type, lfrfid_cli_raw_read_callback, event);
+ worker, furi_string_get_cstr(filepath), type, lfrfid_cli_raw_read_callback, event);
while(true) {
uint32_t flags = furi_event_flag_wait(event, available_flags, FuriFlagWaitAny, 100);
@@ -465,8 +466,8 @@ static void lfrfid_cli_raw_read(Cli* cli, string_t args) {
} while(false);
- string_clear(filepath);
- string_clear(type_string);
+ furi_string_free(filepath);
+ furi_string_free(type_string);
}
static void lfrfid_cli_raw_emulate_callback(LFRFIDWorkerEmulateRawResult result, void* context) {
@@ -475,11 +476,11 @@ static void lfrfid_cli_raw_emulate_callback(LFRFIDWorkerEmulateRawResult result,
furi_event_flag_set(event, 1 << result);
}
-static void lfrfid_cli_raw_emulate(Cli* cli, string_t args) {
+static void lfrfid_cli_raw_emulate(Cli* cli, FuriString* args) {
UNUSED(cli);
- string_t filepath;
- string_init(filepath);
+ FuriString* filepath;
+ filepath = furi_string_alloc();
Storage* storage = furi_record_open(RECORD_STORAGE);
do {
@@ -488,8 +489,8 @@ static void lfrfid_cli_raw_emulate(Cli* cli, string_t args) {
break;
}
- if(!storage_file_exists(storage, string_get_cstr(filepath))) {
- printf("File not found: \"%s\"\r\n", string_get_cstr(filepath));
+ if(!storage_file_exists(storage, furi_string_get_cstr(filepath))) {
+ printf("File not found: \"%s\"\r\n", furi_string_get_cstr(filepath));
break;
}
@@ -505,7 +506,7 @@ static void lfrfid_cli_raw_emulate(Cli* cli, string_t args) {
(1 << LFRFIDWorkerEmulateRawOverrun);
lfrfid_worker_emulate_raw_start(
- worker, string_get_cstr(filepath), lfrfid_cli_raw_emulate_callback, event);
+ worker, furi_string_get_cstr(filepath), lfrfid_cli_raw_emulate_callback, event);
while(true) {
uint32_t flags = furi_event_flag_wait(event, available_flags, FuriFlagWaitAny, 100);
@@ -541,35 +542,35 @@ static void lfrfid_cli_raw_emulate(Cli* cli, string_t args) {
} while(false);
furi_record_close(RECORD_STORAGE);
- string_clear(filepath);
+ furi_string_free(filepath);
}
-static void lfrfid_cli(Cli* cli, string_t args, void* context) {
+static void lfrfid_cli(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
- string_t cmd;
- string_init(cmd);
+ FuriString* cmd;
+ cmd = furi_string_alloc();
if(!args_read_string_and_trim(args, cmd)) {
- string_clear(cmd);
+ furi_string_free(cmd);
lfrfid_cli_print_usage();
return;
}
- if(string_cmp_str(cmd, "read") == 0) {
+ if(furi_string_cmp_str(cmd, "read") == 0) {
lfrfid_cli_read(cli, args);
- } else if(string_cmp_str(cmd, "write") == 0) {
+ } else if(furi_string_cmp_str(cmd, "write") == 0) {
lfrfid_cli_write(cli, args);
- } else if(string_cmp_str(cmd, "emulate") == 0) {
+ } else if(furi_string_cmp_str(cmd, "emulate") == 0) {
lfrfid_cli_emulate(cli, args);
- } else if(string_cmp_str(cmd, "raw_read") == 0) {
+ } else if(furi_string_cmp_str(cmd, "raw_read") == 0) {
lfrfid_cli_raw_read(cli, args);
- } else if(string_cmp_str(cmd, "raw_emulate") == 0) {
+ } else if(furi_string_cmp_str(cmd, "raw_emulate") == 0) {
lfrfid_cli_raw_emulate(cli, args);
- } else if(string_cmp_str(cmd, "raw_analyze") == 0) {
+ } else if(furi_string_cmp_str(cmd, "raw_analyze") == 0) {
lfrfid_cli_raw_analyze(cli, args);
} else {
lfrfid_cli_print_usage();
}
- string_clear(cmd);
+ furi_string_free(cmd);
}
\ No newline at end of file
diff --git a/applications/main/lfrfid/lfrfid_i.h b/applications/main/lfrfid/lfrfid_i.h
index 77e872527..71917c0c2 100644
--- a/applications/main/lfrfid/lfrfid_i.h
+++ b/applications/main/lfrfid/lfrfid_i.h
@@ -1,7 +1,5 @@
#pragma once
-#include "m-string.h"
-
#include
#include
@@ -86,9 +84,9 @@ struct LfRfid {
Widget* widget;
char text_store[LFRFID_TEXT_STORE_SIZE + 1];
- string_t file_path;
- string_t file_name;
- string_t raw_file_name;
+ FuriString* file_path;
+ FuriString* file_name;
+ FuriString* raw_file_name;
ProtocolDict* dict;
ProtocolId protocol_id;
@@ -128,9 +126,9 @@ bool lfrfid_load_key_from_file_select(LfRfid* app);
bool lfrfid_delete_key(LfRfid* app);
-bool lfrfid_load_key_data(LfRfid* app, string_t path, bool show_dialog);
+bool lfrfid_load_key_data(LfRfid* app, FuriString* path, bool show_dialog);
-bool lfrfid_save_key_data(LfRfid* app, string_t path);
+bool lfrfid_save_key_data(LfRfid* app, FuriString* path);
void lfrfid_make_app_folder(LfRfid* app);
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_delete_confirm.c b/applications/main/lfrfid/scenes/lfrfid_scene_delete_confirm.c
index dc1c3df26..b7702e269 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_delete_confirm.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_delete_confirm.c
@@ -4,31 +4,31 @@ void lfrfid_scene_delete_confirm_on_enter(void* context) {
LfRfid* app = context;
Widget* widget = app->widget;
- string_t tmp_string;
- string_init(tmp_string);
+ FuriString* tmp_string;
+ tmp_string = furi_string_alloc();
widget_add_button_element(widget, GuiButtonTypeLeft, "Back", lfrfid_widget_callback, app);
widget_add_button_element(widget, GuiButtonTypeRight, "Delete", lfrfid_widget_callback, app);
- string_printf(tmp_string, "Delete %s?", string_get_cstr(app->file_name));
+ furi_string_printf(tmp_string, "Delete %s?", furi_string_get_cstr(app->file_name));
widget_add_string_element(
- widget, 64, 0, AlignCenter, AlignTop, FontPrimary, string_get_cstr(tmp_string));
+ widget, 64, 0, AlignCenter, AlignTop, FontPrimary, furi_string_get_cstr(tmp_string));
- string_reset(tmp_string);
+ furi_string_reset(tmp_string);
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
uint8_t* data = (uint8_t*)malloc(size);
protocol_dict_get_data(app->dict, app->protocol_id, data, size);
for(uint8_t i = 0; i < MIN(size, (size_t)8); i++) {
if(i != 0) {
- string_cat_printf(tmp_string, " ");
+ furi_string_cat_printf(tmp_string, " ");
}
- string_cat_printf(tmp_string, "%02X", data[i]);
+ furi_string_cat_printf(tmp_string, "%02X", data[i]);
}
free(data);
widget_add_string_element(
- widget, 64, 19, AlignCenter, AlignTop, FontSecondary, string_get_cstr(tmp_string));
+ widget, 64, 19, AlignCenter, AlignTop, FontSecondary, furi_string_get_cstr(tmp_string));
widget_add_string_element(
widget,
64,
@@ -39,7 +39,7 @@ void lfrfid_scene_delete_confirm_on_enter(void* context) {
protocol_dict_get_name(app->dict, app->protocol_id));
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewWidget);
- string_clear(tmp_string);
+ furi_string_free(tmp_string);
}
bool lfrfid_scene_delete_confirm_on_event(void* context, SceneManagerEvent event) {
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c b/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c
index 70cc2418c..2725982f0 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c
@@ -8,8 +8,8 @@ void lfrfid_scene_emulate_on_enter(void* context) {
DOLPHIN_DEED(DolphinDeedRfidEmulate);
popup_set_header(popup, "Emulating", 89, 30, AlignCenter, AlignTop);
- if(!string_empty_p(app->file_name)) {
- popup_set_text(popup, string_get_cstr(app->file_name), 89, 43, AlignCenter, AlignTop);
+ if(!furi_string_empty(app->file_name)) {
+ popup_set_text(popup, furi_string_get_cstr(app->file_name), 89, 43, AlignCenter, AlignTop);
} else {
popup_set_text(
popup,
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_extra_actions.c b/applications/main/lfrfid/scenes/lfrfid_scene_extra_actions.c
index 58082cf10..39ae3c63b 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_extra_actions.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_extra_actions.c
@@ -42,7 +42,7 @@ void lfrfid_scene_extra_actions_on_enter(void* context) {
submenu, scene_manager_get_scene_state(app->scene_manager, LfRfidSceneExtraActions));
// clear key
- string_reset(app->file_name);
+ furi_string_reset(app->file_name);
app->protocol_id = PROTOCOL_NO;
app->read_type = LFRFIDWorkerReadTypeAuto;
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_raw_info.c b/applications/main/lfrfid/scenes/lfrfid_scene_raw_info.c
index f60dd6243..f403c1f38 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_raw_info.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_raw_info.c
@@ -4,8 +4,8 @@ void lfrfid_scene_raw_info_on_enter(void* context) {
LfRfid* app = context;
Widget* widget = app->widget;
- // string_t tmp_string;
- // string_init(tmp_string);
+ // FuriString* tmp_string;
+ // tmp_string = furi_string_alloc();
bool sd_exist = storage_sd_status(app->storage) == FSE_OK;
if(!sd_exist) {
@@ -34,7 +34,7 @@ void lfrfid_scene_raw_info_on_enter(void* context) {
}
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewWidget);
- //string_clear(tmp_string);
+ //furi_string_free(tmp_string);
}
bool lfrfid_scene_raw_info_on_event(void* context, SceneManagerEvent event) {
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_raw_name.c b/applications/main/lfrfid/scenes/lfrfid_scene_raw_name.c
index 512f9ee4c..3e09dbf08 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_raw_name.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_raw_name.c
@@ -4,9 +4,9 @@ void lfrfid_scene_raw_name_on_enter(void* context) {
LfRfid* app = context;
TextInput* text_input = app->text_input;
- const char* key_name = string_get_cstr(app->raw_file_name);
+ const char* key_name = furi_string_get_cstr(app->raw_file_name);
- bool key_name_is_empty = string_empty_p(app->file_name);
+ bool key_name_is_empty = furi_string_empty(app->file_name);
if(key_name_is_empty) {
lfrfid_text_store_set(app, "RfidRecord");
} else {
@@ -38,7 +38,7 @@ bool lfrfid_scene_raw_name_on_event(void* context, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == LfRfidEventNext) {
consumed = true;
- string_set_str(app->raw_file_name, app->text_store);
+ furi_string_set(app->raw_file_name, app->text_store);
scene_manager_next_scene(scene_manager, LfRfidSceneRawInfo);
}
}
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_raw_read.c b/applications/main/lfrfid/scenes/lfrfid_scene_raw_read.c
index d0c03ffa9..b2c7c364e 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_raw_read.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_raw_read.c
@@ -3,7 +3,7 @@
#define RAW_READ_TIME 5000
typedef struct {
- string_t string_file_name;
+ FuriString* string_file_name;
FuriTimer* timer;
bool is_psk;
bool error;
@@ -31,7 +31,7 @@ void lfrfid_scene_raw_read_on_enter(void* context) {
LfRfidReadRawState* state = malloc(sizeof(LfRfidReadRawState));
scene_manager_set_scene_state(app->scene_manager, LfRfidSceneRawRead, (uint32_t)state);
- string_init(state->string_file_name);
+ state->string_file_name = furi_string_alloc();
popup_set_icon(popup, 0, 3, &I_RFIDDolphinReceive_97x61);
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
@@ -40,16 +40,16 @@ void lfrfid_scene_raw_read_on_enter(void* context) {
state->timer = furi_timer_alloc(timer_callback, FuriTimerTypeOnce, app);
furi_timer_start(state->timer, RAW_READ_TIME);
- string_printf(
+ furi_string_printf(
state->string_file_name,
"%s/%s%s",
LFRFID_SD_FOLDER,
- string_get_cstr(app->raw_file_name),
+ furi_string_get_cstr(app->raw_file_name),
LFRFID_APP_RAW_ASK_EXTENSION);
popup_set_header(popup, "Reading\nRAW RFID\nASK", 89, 30, AlignCenter, AlignTop);
lfrfid_worker_read_raw_start(
app->lfworker,
- string_get_cstr(state->string_file_name),
+ furi_string_get_cstr(state->string_file_name),
LFRFIDWorkerReadTypeASKOnly,
lfrfid_read_callback,
app);
@@ -88,15 +88,15 @@ bool lfrfid_scene_raw_read_on_event(void* context, SceneManagerEvent event) {
popup, "Reading\nRAW RFID\nPSK", 89, 30, AlignCenter, AlignTop);
notification_message(app->notifications, &sequence_blink_start_yellow);
lfrfid_worker_stop(app->lfworker);
- string_printf(
+ furi_string_printf(
state->string_file_name,
"%s/%s%s",
LFRFID_SD_FOLDER,
- string_get_cstr(app->raw_file_name),
+ furi_string_get_cstr(app->raw_file_name),
LFRFID_APP_RAW_PSK_EXTENSION);
lfrfid_worker_read_raw_start(
app->lfworker,
- string_get_cstr(state->string_file_name),
+ furi_string_get_cstr(state->string_file_name),
LFRFIDWorkerReadTypePSKOnly,
lfrfid_read_callback,
app);
@@ -121,6 +121,6 @@ void lfrfid_scene_raw_read_on_exit(void* context) {
lfrfid_worker_stop_thread(app->lfworker);
furi_timer_free(state->timer);
- string_clear(state->string_file_name);
+ furi_string_free(state->string_file_name);
free(state);
}
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_read.c b/applications/main/lfrfid/scenes/lfrfid_scene_read.c
index 661680381..4bdb215d1 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_read.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_read.c
@@ -81,7 +81,7 @@ bool lfrfid_scene_read_on_event(void* context, SceneManagerEvent event) {
app->protocol_id = app->protocol_id_next;
DOLPHIN_DEED(DolphinDeedRfidReadSuccess);
notification_message(app->notifications, &sequence_success);
- string_reset(app->file_name);
+ furi_string_reset(app->file_name);
scene_manager_next_scene(app->scene_manager, LfRfidSceneReadSuccess);
consumed = true;
} else if(event.event == LfRfidEventReadStartPSK) {
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_read_key_menu.c b/applications/main/lfrfid/scenes/lfrfid_scene_read_key_menu.c
index 221cc0084..7480304b6 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_read_key_menu.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_read_key_menu.c
@@ -38,7 +38,7 @@ bool lfrfid_scene_read_key_menu_on_event(void* context, SceneManagerEvent event)
scene_manager_next_scene(app->scene_manager, LfRfidSceneWrite);
consumed = true;
} else if(event.event == SubmenuIndexSave) {
- string_reset(app->file_name);
+ furi_string_reset(app->file_name);
scene_manager_next_scene(app->scene_manager, LfRfidSceneSaveName);
consumed = true;
} else if(event.event == SubmenuIndexEmulate) {
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_read_success.c b/applications/main/lfrfid/scenes/lfrfid_scene_read_success.c
index c250fe4ea..b3b60b5ee 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_read_success.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_read_success.c
@@ -4,53 +4,53 @@ void lfrfid_scene_read_success_on_enter(void* context) {
LfRfid* app = context;
Widget* widget = app->widget;
- string_t tmp_string;
- string_init(tmp_string);
+ FuriString* tmp_string;
+ tmp_string = furi_string_alloc();
widget_add_button_element(widget, GuiButtonTypeLeft, "Retry", lfrfid_widget_callback, app);
widget_add_button_element(widget, GuiButtonTypeRight, "More", lfrfid_widget_callback, app);
- string_printf(
+ furi_string_printf(
tmp_string,
"%s[%s]",
protocol_dict_get_name(app->dict, app->protocol_id),
protocol_dict_get_manufacturer(app->dict, app->protocol_id));
widget_add_string_element(
- widget, 16, 3, AlignLeft, AlignTop, FontPrimary, string_get_cstr(tmp_string));
+ widget, 16, 3, AlignLeft, AlignTop, FontPrimary, furi_string_get_cstr(tmp_string));
- string_reset(tmp_string);
+ furi_string_reset(tmp_string);
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
uint8_t* data = (uint8_t*)malloc(size);
protocol_dict_get_data(app->dict, app->protocol_id, data, size);
for(uint8_t i = 0; i < size; i++) {
if(i >= 9) {
- string_cat_printf(tmp_string, "..");
+ furi_string_cat_printf(tmp_string, "..");
break;
} else {
if(i != 0) {
- string_cat_printf(tmp_string, ":");
+ furi_string_cat_printf(tmp_string, ":");
}
- string_cat_printf(tmp_string, "%02X", data[i]);
+ furi_string_cat_printf(tmp_string, "%02X", data[i]);
}
}
free(data);
- string_t render_data;
- string_init(render_data);
+ FuriString* render_data;
+ render_data = furi_string_alloc();
protocol_dict_render_brief_data(app->dict, render_data, app->protocol_id);
- string_cat_printf(tmp_string, "\r\n%s", string_get_cstr(render_data));
- string_clear(render_data);
+ furi_string_cat_printf(tmp_string, "\r\n%s", furi_string_get_cstr(render_data));
+ furi_string_free(render_data);
widget_add_string_multiline_element(
- widget, 0, 16, AlignLeft, AlignTop, FontSecondary, string_get_cstr(tmp_string));
+ widget, 0, 16, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(tmp_string));
widget_add_icon_element(app->widget, 0, 0, &I_RFIDSmallChip_14x14);
notification_message_block(app->notifications, &sequence_set_green_255);
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewWidget);
- string_clear(tmp_string);
+ furi_string_free(tmp_string);
}
bool lfrfid_scene_read_success_on_event(void* context, SceneManagerEvent event) {
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_rpc.c b/applications/main/lfrfid/scenes/lfrfid_scene_rpc.c
index a69d6453a..156dd97af 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_rpc.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_rpc.c
@@ -34,13 +34,14 @@ bool lfrfid_scene_rpc_on_event(void* context, SceneManagerEvent event) {
const char* arg = rpc_system_app_get_data(app->rpc_ctx);
bool result = false;
if(arg && (app->rpc_state == LfRfidRpcStateIdle)) {
- string_set_str(app->file_path, arg);
+ furi_string_set(app->file_path, arg);
if(lfrfid_load_key_data(app, app->file_path, false)) {
lfrfid_worker_start_thread(app->lfworker);
lfrfid_worker_emulate_start(app->lfworker, (LFRFIDProtocol)app->protocol_id);
app->rpc_state = LfRfidRpcStateEmulating;
- lfrfid_text_store_set(app, "emulating\n%s", string_get_cstr(app->file_name));
+ lfrfid_text_store_set(
+ app, "emulating\n%s", furi_string_get_cstr(app->file_name));
popup_set_text(popup, app->text_store, 89, 44, AlignCenter, AlignTop);
notification_message(app->notifications, &sequence_blink_start_magenta);
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_save_data.c b/applications/main/lfrfid/scenes/lfrfid_scene_save_data.c
index 2ca1bb433..6c5ea2f2d 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_save_data.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_save_data.c
@@ -9,14 +9,11 @@ void lfrfid_scene_save_data_on_enter(void* context) {
bool need_restore = scene_manager_get_scene_state(app->scene_manager, LfRfidSceneSaveData);
- if(need_restore) {
- protocol_dict_set_data(app->dict, app->protocol_id, app->old_key_data, size);
- } else {
+ if(!need_restore) {
protocol_dict_get_data(app->dict, app->protocol_id, app->old_key_data, size);
+ protocol_dict_get_data(app->dict, app->protocol_id, app->new_key_data, size);
}
- protocol_dict_get_data(app->dict, app->protocol_id, app->new_key_data, size);
-
byte_input_set_header_text(byte_input, "Enter the data in hex");
byte_input_set_result_callback(
@@ -41,6 +38,8 @@ bool lfrfid_scene_save_data_on_event(void* context, SceneManagerEvent event) {
}
} else if(event.type == SceneManagerEventTypeBack) {
scene_manager_set_scene_state(scene_manager, LfRfidSceneSaveData, 0);
+ size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
+ protocol_dict_set_data(app->dict, app->protocol_id, app->old_key_data, size);
}
return consumed;
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_save_name.c b/applications/main/lfrfid/scenes/lfrfid_scene_save_name.c
index febf30a41..ca9a52de0 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_save_name.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_save_name.c
@@ -1,21 +1,20 @@
-#include "m-string.h"
#include
#include "../lfrfid_i.h"
void lfrfid_scene_save_name_on_enter(void* context) {
LfRfid* app = context;
TextInput* text_input = app->text_input;
- string_t folder_path;
- string_init(folder_path);
+ FuriString* folder_path;
+ folder_path = furi_string_alloc();
- bool key_name_is_empty = string_empty_p(app->file_name);
+ bool key_name_is_empty = furi_string_empty(app->file_name);
if(key_name_is_empty) {
- string_set_str(app->file_path, LFRFID_APP_FOLDER);
+ furi_string_set(app->file_path, LFRFID_APP_FOLDER);
set_random_name(app->text_store, LFRFID_TEXT_STORE_SIZE);
- string_set_str(folder_path, LFRFID_APP_FOLDER);
+ furi_string_set(folder_path, LFRFID_APP_FOLDER);
} else {
- lfrfid_text_store_set(app, "%s", string_get_cstr(app->file_name));
- path_extract_dirname(string_get_cstr(app->file_path), folder_path);
+ lfrfid_text_store_set(app, "%s", furi_string_get_cstr(app->file_name));
+ path_extract_dirname(furi_string_get_cstr(app->file_path), folder_path);
}
text_input_set_header_text(text_input, "Name the card");
@@ -27,13 +26,15 @@ void lfrfid_scene_save_name_on_enter(void* context) {
LFRFID_KEY_NAME_SIZE,
key_name_is_empty);
- FURI_LOG_I("", "%s %s", string_get_cstr(folder_path), app->text_store);
+ FURI_LOG_I("", "%s %s", furi_string_get_cstr(folder_path), app->text_store);
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
- string_get_cstr(folder_path), LFRFID_APP_EXTENSION, string_get_cstr(app->file_name));
+ furi_string_get_cstr(folder_path),
+ LFRFID_APP_EXTENSION,
+ furi_string_get_cstr(app->file_name));
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
- string_clear(folder_path);
+ furi_string_free(folder_path);
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewTextInput);
}
@@ -46,11 +47,11 @@ bool lfrfid_scene_save_name_on_event(void* context, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == LfRfidEventNext) {
consumed = true;
- if(!string_empty_p(app->file_name)) {
+ if(!furi_string_empty(app->file_name)) {
lfrfid_delete_key(app);
}
- string_set_str(app->file_name, app->text_store);
+ furi_string_set(app->file_name, app->text_store);
if(lfrfid_save_key(app)) {
scene_manager_next_scene(scene_manager, LfRfidSceneSaveSuccess);
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_save_success.c b/applications/main/lfrfid/scenes/lfrfid_scene_save_success.c
index 830ef3368..e91ad04e3 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_save_success.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_save_success.c
@@ -5,6 +5,9 @@ void lfrfid_scene_save_success_on_enter(void* context) {
LfRfid* app = context;
Popup* popup = app->popup;
+ // Clear state of data enter scene
+ scene_manager_set_scene_state(app->scene_manager, LfRfidSceneSaveData, 0);
+
DOLPHIN_DEED(DolphinDeedRfidSave);
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
popup_set_header(popup, "Saved!", 5, 7, AlignLeft, AlignTop);
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_save_type.c b/applications/main/lfrfid/scenes/lfrfid_scene_save_type.c
index 827e6d151..6077348f1 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_save_type.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_save_type.c
@@ -1,7 +1,7 @@
#include "../lfrfid_i.h"
typedef struct {
- string_t menu_item_name[LFRFIDProtocolMax];
+ FuriString* menu_item_name[LFRFIDProtocolMax];
uint32_t line_sel;
} SaveTypeCtx;
@@ -21,18 +21,17 @@ void lfrfid_scene_save_type_on_enter(void* context) {
protocol_dict_get_manufacturer(app->dict, i),
protocol_dict_get_name(app->dict, i)) != 0) &&
(strcmp(protocol_dict_get_manufacturer(app->dict, i), "N/A") != 0)) {
- string_init_printf(
- state->menu_item_name[i],
+ state->menu_item_name[i] = furi_string_alloc_printf(
"%s %s",
protocol_dict_get_manufacturer(app->dict, i),
protocol_dict_get_name(app->dict, i));
} else {
- string_init_printf(
- state->menu_item_name[i], "%s", protocol_dict_get_name(app->dict, i));
+ state->menu_item_name[i] =
+ furi_string_alloc_printf("%s", protocol_dict_get_name(app->dict, i));
}
submenu_add_item(
submenu,
- string_get_cstr(state->menu_item_name[i]),
+ furi_string_get_cstr(state->menu_item_name[i]),
i,
lfrfid_scene_save_type_submenu_callback,
app);
@@ -44,7 +43,7 @@ void lfrfid_scene_save_type_on_enter(void* context) {
scene_manager_set_scene_state(app->scene_manager, LfRfidSceneSaveType, (uint32_t)state);
// clear key name
- string_reset(app->file_name);
+ furi_string_reset(app->file_name);
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewSubmenu);
}
@@ -76,7 +75,7 @@ void lfrfid_scene_save_type_on_exit(void* context) {
submenu_reset(app->submenu);
for(uint8_t i = 0; i < LFRFIDProtocolMax; i++) {
- string_clear(state->menu_item_name[i]);
+ furi_string_free(state->menu_item_name[i]);
}
uint32_t line_sel = state->line_sel;
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_saved_info.c b/applications/main/lfrfid/scenes/lfrfid_scene_saved_info.c
index 7e376ca01..c901629c3 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_saved_info.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_saved_info.c
@@ -4,13 +4,13 @@ void lfrfid_scene_saved_info_on_enter(void* context) {
LfRfid* app = context;
Widget* widget = app->widget;
- string_t tmp_string;
- string_init(tmp_string);
+ FuriString* tmp_string;
+ tmp_string = furi_string_alloc();
- string_printf(
+ furi_string_printf(
tmp_string,
"%s [%s]\r\n",
- string_get_cstr(app->file_name),
+ furi_string_get_cstr(app->file_name),
protocol_dict_get_name(app->dict, app->protocol_id));
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
@@ -18,24 +18,24 @@ void lfrfid_scene_saved_info_on_enter(void* context) {
protocol_dict_get_data(app->dict, app->protocol_id, data, size);
for(uint8_t i = 0; i < size; i++) {
if(i != 0) {
- string_cat_printf(tmp_string, ":");
+ furi_string_cat_printf(tmp_string, ":");
}
- string_cat_printf(tmp_string, "%02X", data[i]);
+ furi_string_cat_printf(tmp_string, "%02X", data[i]);
}
free(data);
- string_t render_data;
- string_init(render_data);
+ FuriString* render_data;
+ render_data = furi_string_alloc();
protocol_dict_render_data(app->dict, render_data, app->protocol_id);
- string_cat_printf(tmp_string, "\r\n%s", string_get_cstr(render_data));
- string_clear(render_data);
+ furi_string_cat_printf(tmp_string, "\r\n%s", furi_string_get_cstr(render_data));
+ furi_string_free(render_data);
widget_add_string_multiline_element(
- widget, 0, 1, AlignLeft, AlignTop, FontSecondary, string_get_cstr(tmp_string));
+ widget, 0, 1, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(tmp_string));
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewWidget);
- string_clear(tmp_string);
+ furi_string_free(tmp_string);
}
bool lfrfid_scene_saved_info_on_event(void* context, SceneManagerEvent event) {
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_start.c b/applications/main/lfrfid/scenes/lfrfid_scene_start.c
index 9074e859b..d6d87f441 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_start.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_start.c
@@ -33,7 +33,7 @@ void lfrfid_scene_start_on_enter(void* context) {
submenu, scene_manager_get_scene_state(app->scene_manager, LfRfidSceneStart));
// clear key
- string_reset(app->file_name);
+ furi_string_reset(app->file_name);
app->protocol_id = PROTOCOL_NO;
app->read_type = LFRFIDWorkerReadTypeAuto;
@@ -49,7 +49,7 @@ bool lfrfid_scene_start_on_event(void* context, SceneManagerEvent event) {
scene_manager_next_scene(app->scene_manager, LfRfidSceneRead);
consumed = true;
} else if(event.event == SubmenuIndexSaved) {
- string_set_str(app->file_path, LFRFID_APP_FOLDER);
+ furi_string_set(app->file_path, LFRFID_APP_FOLDER);
scene_manager_next_scene(app->scene_manager, LfRfidSceneSelectKey);
consumed = true;
} else if(event.event == SubmenuIndexAddManually) {
diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_write.c b/applications/main/lfrfid/scenes/lfrfid_scene_write.c
index 4b03bac15..b7faed69f 100644
--- a/applications/main/lfrfid/scenes/lfrfid_scene_write.c
+++ b/applications/main/lfrfid/scenes/lfrfid_scene_write.c
@@ -22,8 +22,8 @@ void lfrfid_scene_write_on_enter(void* context) {
Popup* popup = app->popup;
popup_set_header(popup, "Writing", 89, 30, AlignCenter, AlignTop);
- if(!string_empty_p(app->file_name)) {
- popup_set_text(popup, string_get_cstr(app->file_name), 89, 43, AlignCenter, AlignTop);
+ if(!furi_string_empty(app->file_name)) {
+ popup_set_text(popup, furi_string_get_cstr(app->file_name), 89, 43, AlignCenter, AlignTop);
} else {
popup_set_text(
popup,
@@ -38,7 +38,6 @@ void lfrfid_scene_write_on_enter(void* context) {
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
- app->old_key_data = (uint8_t*)malloc(size);
protocol_dict_get_data(app->dict, app->protocol_id, app->old_key_data, size);
lfrfid_worker_start_thread(app->lfworker);
@@ -92,5 +91,4 @@ void lfrfid_scene_write_on_exit(void* context) {
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
protocol_dict_set_data(app->dict, app->protocol_id, app->old_key_data, size);
- free(app->old_key_data);
}
diff --git a/applications/main/nfc/helpers/nfc_emv_parser.c b/applications/main/nfc/helpers/nfc_emv_parser.c
index 0d7cb5a33..30e102405 100644
--- a/applications/main/nfc/helpers/nfc_emv_parser.c
+++ b/applications/main/nfc/helpers/nfc_emv_parser.c
@@ -7,12 +7,12 @@ static const uint32_t nfc_resources_file_version = 1;
static bool nfc_emv_parser_search_data(
Storage* storage,
const char* file_name,
- string_t key,
- string_t data) {
+ FuriString* key,
+ FuriString* data) {
bool parsed = false;
FlipperFormat* file = flipper_format_file_alloc(storage);
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
do {
// Open file
@@ -20,14 +20,14 @@ static bool nfc_emv_parser_search_data(
// Read file header and version
uint32_t version = 0;
if(!flipper_format_read_header(file, temp_str, &version)) break;
- if(string_cmp_str(temp_str, nfc_resources_header) ||
+ if(furi_string_cmp_str(temp_str, nfc_resources_header) ||
(version != nfc_resources_file_version))
break;
- if(!flipper_format_read_string(file, string_get_cstr(key), data)) break;
+ if(!flipper_format_read_string(file, furi_string_get_cstr(key), data)) break;
parsed = true;
} while(false);
- string_clear(temp_str);
+ furi_string_free(temp_str);
flipper_format_free(file);
return parsed;
}
@@ -36,47 +36,47 @@ bool nfc_emv_parser_get_aid_name(
Storage* storage,
uint8_t* aid,
uint8_t aid_len,
- string_t aid_name) {
+ FuriString* aid_name) {
furi_assert(storage);
bool parsed = false;
- string_t key;
- string_init(key);
+ FuriString* key;
+ key = furi_string_alloc();
for(uint8_t i = 0; i < aid_len; i++) {
- string_cat_printf(key, "%02X", aid[i]);
+ furi_string_cat_printf(key, "%02X", aid[i]);
}
if(nfc_emv_parser_search_data(storage, EXT_PATH("nfc/assets/aid.nfc"), key, aid_name)) {
parsed = true;
}
- string_clear(key);
+ furi_string_free(key);
return parsed;
}
bool nfc_emv_parser_get_country_name(
Storage* storage,
uint16_t country_code,
- string_t country_name) {
+ FuriString* country_name) {
bool parsed = false;
- string_t key;
- string_init_printf(key, "%04X", country_code);
+ FuriString* key;
+ key = furi_string_alloc_printf("%04X", country_code);
if(nfc_emv_parser_search_data(
storage, EXT_PATH("nfc/assets/country_code.nfc"), key, country_name)) {
parsed = true;
}
- string_clear(key);
+ furi_string_free(key);
return parsed;
}
bool nfc_emv_parser_get_currency_name(
Storage* storage,
uint16_t currency_code,
- string_t currency_name) {
+ FuriString* currency_name) {
bool parsed = false;
- string_t key;
- string_init_printf(key, "%04X", currency_code);
+ FuriString* key;
+ key = furi_string_alloc_printf("%04X", currency_code);
if(nfc_emv_parser_search_data(
storage, EXT_PATH("nfc/assets/currency_code.nfc"), key, currency_name)) {
parsed = true;
}
- string_clear(key);
+ furi_string_free(key);
return parsed;
}
diff --git a/applications/main/nfc/helpers/nfc_emv_parser.h b/applications/main/nfc/helpers/nfc_emv_parser.h
index 5948ed340..abe57f470 100644
--- a/applications/main/nfc/helpers/nfc_emv_parser.h
+++ b/applications/main/nfc/helpers/nfc_emv_parser.h
@@ -2,7 +2,6 @@
#include
#include
-#include
#include
/** Get EMV application name by number
@@ -16,7 +15,7 @@ bool nfc_emv_parser_get_aid_name(
Storage* storage,
uint8_t* aid,
uint8_t aid_len,
- string_t aid_name);
+ FuriString* aid_name);
/** Get country name by country code
* @param storage Storage instance
@@ -27,7 +26,7 @@ bool nfc_emv_parser_get_aid_name(
bool nfc_emv_parser_get_country_name(
Storage* storage,
uint16_t country_code,
- string_t country_name);
+ FuriString* country_name);
/** Get currency name by currency code
* @param storage Storage instance
@@ -38,4 +37,4 @@ bool nfc_emv_parser_get_country_name(
bool nfc_emv_parser_get_currency_name(
Storage* storage,
uint16_t currency_code,
- string_t currency_name);
+ FuriString* currency_name);
diff --git a/applications/main/nfc/nfc.c b/applications/main/nfc/nfc.c
index f47a5bac2..0b685f545 100644
--- a/applications/main/nfc/nfc.c
+++ b/applications/main/nfc/nfc.c
@@ -83,7 +83,7 @@ Nfc* nfc_alloc() {
nfc->text_box = text_box_alloc();
view_dispatcher_add_view(
nfc->view_dispatcher, NfcViewTextBox, text_box_get_view(nfc->text_box));
- string_init(nfc->text_box_store);
+ nfc->text_box_store = furi_string_alloc();
// Custom Widget
nfc->widget = widget_alloc();
@@ -153,7 +153,7 @@ void nfc_free(Nfc* nfc) {
// TextBox
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewTextBox);
text_box_free(nfc->text_box);
- string_clear(nfc->text_box_store);
+ furi_string_free(nfc->text_box_store);
// Custom Widget
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewWidget);
@@ -277,6 +277,8 @@ int32_t nfc_app(void* p) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfUltralightEmulate);
} else if(nfc->dev->format == NfcDeviceSaveFormatMifareClassic) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicEmulate);
+ } else if(nfc->dev->format == NfcDeviceSaveFormatBankCard) {
+ scene_manager_next_scene(nfc->scene_manager, NfcSceneDeviceInfo);
} else {
scene_manager_next_scene(nfc->scene_manager, NfcSceneEmulateUid);
}
diff --git a/applications/main/nfc/nfc_cli.c b/applications/main/nfc/nfc_cli.c
index 4ac95f043..a6475ca68 100644
--- a/applications/main/nfc/nfc_cli.c
+++ b/applications/main/nfc/nfc_cli.c
@@ -17,7 +17,7 @@ static void nfc_cli_print_usage() {
}
}
-static void nfc_cli_detect(Cli* cli, string_t args) {
+static void nfc_cli_detect(Cli* cli, FuriString* args) {
UNUSED(args);
// Check if nfc worker is not busy
if(furi_hal_nfc_is_busy()) {
@@ -46,7 +46,7 @@ static void nfc_cli_detect(Cli* cli, string_t args) {
furi_hal_nfc_sleep();
}
-static void nfc_cli_emulate(Cli* cli, string_t args) {
+static void nfc_cli_emulate(Cli* cli, FuriString* args) {
UNUSED(args);
// Check if nfc worker is not busy
if(furi_hal_nfc_is_busy()) {
@@ -76,7 +76,7 @@ static void nfc_cli_emulate(Cli* cli, string_t args) {
furi_hal_nfc_sleep();
}
-static void nfc_cli_field(Cli* cli, string_t args) {
+static void nfc_cli_field(Cli* cli, FuriString* args) {
UNUSED(args);
// Check if nfc worker is not busy
if(furi_hal_nfc_is_busy()) {
@@ -98,27 +98,27 @@ static void nfc_cli_field(Cli* cli, string_t args) {
furi_hal_nfc_sleep();
}
-static void nfc_cli(Cli* cli, string_t args, void* context) {
+static void nfc_cli(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
- string_t cmd;
- string_init(cmd);
+ FuriString* cmd;
+ cmd = furi_string_alloc();
do {
if(!args_read_string_and_trim(args, cmd)) {
nfc_cli_print_usage();
break;
}
- if(string_cmp_str(cmd, "detect") == 0) {
+ if(furi_string_cmp_str(cmd, "detect") == 0) {
nfc_cli_detect(cli, args);
break;
}
- if(string_cmp_str(cmd, "emulate") == 0) {
+ if(furi_string_cmp_str(cmd, "emulate") == 0) {
nfc_cli_emulate(cli, args);
break;
}
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
- if(string_cmp_str(cmd, "field") == 0) {
+ if(furi_string_cmp_str(cmd, "field") == 0) {
nfc_cli_field(cli, args);
break;
}
@@ -127,7 +127,7 @@ static void nfc_cli(Cli* cli, string_t args, void* context) {
nfc_cli_print_usage();
} while(false);
- string_clear(cmd);
+ furi_string_free(cmd);
}
void nfc_on_system_start() {
diff --git a/applications/main/nfc/nfc_i.h b/applications/main/nfc/nfc_i.h
index 15ea5348f..fa5b54edc 100644
--- a/applications/main/nfc/nfc_i.h
+++ b/applications/main/nfc/nfc_i.h
@@ -62,7 +62,7 @@ struct Nfc {
FuriHalNfcDevData dev_edit_data;
char text_store[NFC_TEXT_STORE_SIZE + 1];
- string_t text_box_store;
+ FuriString* text_box_store;
uint8_t byte_input_store[6];
MfClassicUserKeys_t mfc_key_strs; // Used in MFC key listing
diff --git a/applications/main/nfc/scenes/nfc_scene_delete.c b/applications/main/nfc/scenes/nfc_scene_delete.c
index 987927e19..cbb52bfd0 100644
--- a/applications/main/nfc/scenes/nfc_scene_delete.c
+++ b/applications/main/nfc/scenes/nfc_scene_delete.c
@@ -12,40 +12,40 @@ void nfc_scene_delete_on_enter(void* context) {
FuriHalNfcDevData* nfc_data = &nfc->dev->dev_data.nfc_data;
// Setup Custom Widget view
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
- string_printf(temp_str, "\e#Delete %s?\e#", nfc->dev->dev_name);
+ furi_string_printf(temp_str, "\e#Delete %s?\e#", nfc->dev->dev_name);
widget_add_text_box_element(
- nfc->widget, 0, 0, 128, 23, AlignCenter, AlignCenter, string_get_cstr(temp_str), false);
+ nfc->widget, 0, 0, 128, 23, AlignCenter, AlignCenter, furi_string_get_cstr(temp_str), false);
widget_add_button_element(
nfc->widget, GuiButtonTypeLeft, "Cancel", nfc_scene_delete_widget_callback, nfc);
widget_add_button_element(
nfc->widget, GuiButtonTypeRight, "Delete", nfc_scene_delete_widget_callback, nfc);
- string_set_str(temp_str, "UID:");
+ furi_string_set(temp_str, "UID:");
for(size_t i = 0; i < nfc_data->uid_len; i++) {
- string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
+ furi_string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
}
widget_add_string_element(
- nfc->widget, 64, 24, AlignCenter, AlignTop, FontSecondary, string_get_cstr(temp_str));
+ nfc->widget, 64, 24, AlignCenter, AlignTop, FontSecondary, furi_string_get_cstr(temp_str));
NfcProtocol protocol = nfc->dev->dev_data.protocol;
if(protocol == NfcDeviceProtocolEMV) {
- string_set_str(temp_str, "EMV bank card");
+ furi_string_set(temp_str, "EMV bank card");
} else if(protocol == NfcDeviceProtocolMifareUl) {
- string_set_str(temp_str, nfc_mf_ul_type(nfc->dev->dev_data.mf_ul_data.type, true));
+ furi_string_set(temp_str, nfc_mf_ul_type(nfc->dev->dev_data.mf_ul_data.type, true));
} else if(protocol == NfcDeviceProtocolMifareClassic) {
- string_set_str(temp_str, nfc_mf_classic_type(nfc->dev->dev_data.mf_classic_data.type));
+ furi_string_set(temp_str, nfc_mf_classic_type(nfc->dev->dev_data.mf_classic_data.type));
} else if(protocol == NfcDeviceProtocolMifareDesfire) {
- string_set_str(temp_str, "MIFARE DESFire");
+ furi_string_set(temp_str, "MIFARE DESFire");
} else {
- string_set_str(temp_str, "Unknown ISO tag");
+ furi_string_set(temp_str, "Unknown ISO tag");
}
widget_add_string_element(
- nfc->widget, 64, 34, AlignCenter, AlignTop, FontSecondary, string_get_cstr(temp_str));
+ nfc->widget, 64, 34, AlignCenter, AlignTop, FontSecondary, furi_string_get_cstr(temp_str));
widget_add_string_element(nfc->widget, 64, 44, AlignCenter, AlignTop, FontSecondary, "NFC-A");
- string_clear(temp_str);
+ furi_string_free(temp_str);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
}
diff --git a/applications/main/nfc/scenes/nfc_scene_detect_reader.c b/applications/main/nfc/scenes/nfc_scene_detect_reader.c
index 5f4582d8e..e8c2b5ee8 100644
--- a/applications/main/nfc/scenes/nfc_scene_detect_reader.c
+++ b/applications/main/nfc/scenes/nfc_scene_detect_reader.c
@@ -1,6 +1,15 @@
#include "../nfc_i.h"
#include
+#define NFC_SCENE_DETECT_READER_PAIR_NONCES_MAX (10U)
+
+static const NotificationSequence sequence_detect_reader = {
+ &message_green_255,
+ &message_blue_255,
+ &message_do_not_reset,
+ NULL,
+};
+
bool nfc_detect_reader_worker_callback(NfcWorkerEvent event, void* context) {
UNUSED(event);
furi_assert(context);
@@ -20,21 +29,26 @@ void nfc_scene_detect_reader_on_enter(void* context) {
DOLPHIN_DEED(DolphinDeedNfcEmulate);
detect_reader_set_callback(nfc->detect_reader, nfc_scene_detect_reader_callback, nfc);
+ detect_reader_set_nonces_max(nfc->detect_reader, NFC_SCENE_DETECT_READER_PAIR_NONCES_MAX);
+
+ // Store number of collected nonces in scene state
+ scene_manager_set_scene_state(nfc->scene_manager, NfcSceneDetectReader, 0);
+ notification_message(nfc->notifications, &sequence_detect_reader);
+
nfc_worker_start(
nfc->worker,
NfcWorkerStateAnalyzeReader,
&nfc->dev->dev_data,
nfc_detect_reader_worker_callback,
nfc);
-
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewDetectReader);
-
- nfc_blink_read_start(nfc);
}
bool nfc_scene_detect_reader_on_event(void* context, SceneManagerEvent event) {
Nfc* nfc = context;
bool consumed = false;
+ uint32_t nonces_collected =
+ scene_manager_get_scene_state(nfc->scene_manager, NfcSceneDetectReader);
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcCustomEventViewExit) {
@@ -42,8 +56,29 @@ bool nfc_scene_detect_reader_on_event(void* context, SceneManagerEvent event) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfkeyNoncesInfo);
consumed = true;
} else if(event.event == NfcWorkerEventDetectReaderMfkeyCollected) {
- detect_reader_inc_nonce_cnt(nfc->detect_reader);
+ nonces_collected += 2;
+ scene_manager_set_scene_state(
+ nfc->scene_manager, NfcSceneDetectReader, nonces_collected);
+ detect_reader_set_nonces_collected(nfc->detect_reader, nonces_collected);
+ if(nonces_collected >= NFC_SCENE_DETECT_READER_PAIR_NONCES_MAX) {
+ detect_reader_set_state(nfc->detect_reader, DetectReaderStateDone);
+ nfc_blink_stop(nfc);
+ notification_message(nfc->notifications, &sequence_single_vibro);
+ notification_message(nfc->notifications, &sequence_set_green_255);
+ nfc_worker_stop(nfc->worker);
+ }
consumed = true;
+ } else if(event.event == NfcWorkerEventDetectReaderDetected) {
+ if(nonces_collected < NFC_SCENE_DETECT_READER_PAIR_NONCES_MAX) {
+ notification_message(nfc->notifications, &sequence_blink_start_cyan);
+ detect_reader_set_state(nfc->detect_reader, DetectReaderStateReaderDetected);
+ }
+ } else if(event.event == NfcWorkerEventDetectReaderLost) {
+ if(nonces_collected < NFC_SCENE_DETECT_READER_PAIR_NONCES_MAX) {
+ nfc_blink_stop(nfc);
+ notification_message(nfc->notifications, &sequence_detect_reader);
+ detect_reader_set_state(nfc->detect_reader, DetectReaderStateReaderLost);
+ }
}
}
@@ -59,5 +94,7 @@ void nfc_scene_detect_reader_on_exit(void* context) {
// Clear view
detect_reader_reset(nfc->detect_reader);
+ // Stop notifications
nfc_blink_stop(nfc);
+ notification_message(nfc->notifications, &sequence_reset_green);
}
diff --git a/applications/main/nfc/scenes/nfc_scene_device_info.c b/applications/main/nfc/scenes/nfc_scene_device_info.c
index 245aea5c5..9780ffe41 100644
--- a/applications/main/nfc/scenes/nfc_scene_device_info.c
+++ b/applications/main/nfc/scenes/nfc_scene_device_info.c
@@ -12,49 +12,52 @@ void nfc_scene_device_info_on_enter(void* context) {
Nfc* nfc = context;
NfcDeviceData* dev_data = &nfc->dev->dev_data;
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
if(dev_data->protocol == NfcDeviceProtocolEMV) {
EmvData* emv_data = &dev_data->emv_data;
- string_printf(temp_str, "\e#%s\n", emv_data->name);
+ furi_string_printf(temp_str, "\e#%s\n", emv_data->name);
for(uint8_t i = 0; i < emv_data->number_len; i += 2) {
- string_cat_printf(temp_str, "%02X%02X ", emv_data->number[i], emv_data->number[i + 1]);
+ furi_string_cat_printf(
+ temp_str, "%02X%02X ", emv_data->number[i], emv_data->number[i + 1]);
}
- string_strim(temp_str);
+ furi_string_trim(temp_str);
// Add expiration date
if(emv_data->exp_mon) {
- string_cat_printf(temp_str, "\nExp: %02X/%02X", emv_data->exp_mon, emv_data->exp_year);
+ furi_string_cat_printf(
+ temp_str, "\nExp: %02X/%02X", emv_data->exp_mon, emv_data->exp_year);
}
// Parse currency code
if((emv_data->currency_code)) {
- string_t currency_name;
- string_init(currency_name);
+ FuriString* currency_name;
+ currency_name = furi_string_alloc();
if(nfc_emv_parser_get_currency_name(
nfc->dev->storage, emv_data->currency_code, currency_name)) {
- string_cat_printf(temp_str, "\nCur: %s ", string_get_cstr(currency_name));
+ furi_string_cat_printf(
+ temp_str, "\nCur: %s ", furi_string_get_cstr(currency_name));
}
- string_clear(currency_name);
+ furi_string_free(currency_name);
}
// Parse country code
if((emv_data->country_code)) {
- string_t country_name;
- string_init(country_name);
+ FuriString* country_name;
+ country_name = furi_string_alloc();
if(nfc_emv_parser_get_country_name(
nfc->dev->storage, emv_data->country_code, country_name)) {
- string_cat_printf(temp_str, "Reg: %s", string_get_cstr(country_name));
+ furi_string_cat_printf(temp_str, "Reg: %s", furi_string_get_cstr(country_name));
}
- string_clear(country_name);
+ furi_string_free(country_name);
}
} else if(
dev_data->protocol == NfcDeviceProtocolMifareClassic ||
dev_data->protocol == NfcDeviceProtocolMifareUl) {
- string_set(temp_str, nfc->dev->dev_data.parsed_data);
+ furi_string_set(temp_str, nfc->dev->dev_data.parsed_data);
}
- widget_add_text_scroll_element(nfc->widget, 0, 0, 128, 52, string_get_cstr(temp_str));
- string_clear(temp_str);
+ widget_add_text_scroll_element(nfc->widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
+ furi_string_free(temp_str);
widget_add_button_element(
nfc->widget, GuiButtonTypeRight, "More", nfc_scene_device_info_widget_callback, nfc);
diff --git a/applications/main/nfc/scenes/nfc_scene_emulate_uid.c b/applications/main/nfc/scenes/nfc_scene_emulate_uid.c
index f64023010..8bb207960 100644
--- a/applications/main/nfc/scenes/nfc_scene_emulate_uid.c
+++ b/applications/main/nfc/scenes/nfc_scene_emulate_uid.c
@@ -35,22 +35,22 @@ static void nfc_scene_emulate_uid_widget_config(Nfc* nfc, bool data_received) {
FuriHalNfcDevData* data = &nfc->dev->dev_data.nfc_data;
Widget* widget = nfc->widget;
widget_reset(widget);
- string_t info_str;
- string_init(info_str);
+ FuriString* info_str;
+ info_str = furi_string_alloc();
widget_add_icon_element(widget, 0, 3, &I_RFIDDolphinSend_97x61);
widget_add_string_element(widget, 89, 32, AlignCenter, AlignTop, FontPrimary, "Emulating UID");
if(strcmp(nfc->dev->dev_name, "")) {
- string_printf(info_str, "%s", nfc->dev->dev_name);
+ furi_string_printf(info_str, "%s", nfc->dev->dev_name);
} else {
for(uint8_t i = 0; i < data->uid_len; i++) {
- string_cat_printf(info_str, "%02X ", data->uid[i]);
+ furi_string_cat_printf(info_str, "%02X ", data->uid[i]);
}
}
- string_strim(info_str);
+ furi_string_trim(info_str);
widget_add_text_box_element(
- widget, 56, 43, 70, 21, AlignCenter, AlignTop, string_get_cstr(info_str), true);
- string_clear(info_str);
+ widget, 56, 43, 70, 21, AlignCenter, AlignTop, furi_string_get_cstr(info_str), true);
+ furi_string_free(info_str);
if(data_received) {
widget_add_button_element(
widget, GuiButtonTypeCenter, "Log", nfc_scene_emulate_uid_widget_callback, nfc);
@@ -67,7 +67,7 @@ void nfc_scene_emulate_uid_on_enter(void* context) {
TextBox* text_box = nfc->text_box;
text_box_set_font(text_box, TextBoxFontHex);
text_box_set_focus(text_box, TextBoxFocusEnd);
- string_reset(nfc->text_box_store);
+ furi_string_reset(nfc->text_box_store);
// Set Widget state and view
scene_manager_set_scene_state(
@@ -94,17 +94,17 @@ bool nfc_scene_emulate_uid_on_event(void* context, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcCustomEventWorkerExit) {
// Add data button to widget if data is received for the first time
- if(!string_size(nfc->text_box_store)) {
+ if(!furi_string_size(nfc->text_box_store)) {
nfc_scene_emulate_uid_widget_config(nfc, true);
}
// Update TextBox data
- if(string_size(nfc->text_box_store) < NFC_SCENE_EMULATE_UID_LOG_SIZE_MAX) {
- string_cat_printf(nfc->text_box_store, "R:");
+ if(furi_string_size(nfc->text_box_store) < NFC_SCENE_EMULATE_UID_LOG_SIZE_MAX) {
+ furi_string_cat_printf(nfc->text_box_store, "R:");
for(uint16_t i = 0; i < reader_data->size; i++) {
- string_cat_printf(nfc->text_box_store, " %02X", reader_data->data[i]);
+ furi_string_cat_printf(nfc->text_box_store, " %02X", reader_data->data[i]);
}
- string_push_back(nfc->text_box_store, '\n');
- text_box_set_text(nfc->text_box, string_get_cstr(nfc->text_box_store));
+ furi_string_push_back(nfc->text_box_store, '\n');
+ text_box_set_text(nfc->text_box, furi_string_get_cstr(nfc->text_box_store));
}
memset(reader_data, 0, sizeof(NfcReaderRequestData));
consumed = true;
@@ -140,7 +140,7 @@ void nfc_scene_emulate_uid_on_exit(void* context) {
// Clear view
widget_reset(nfc->widget);
text_box_reset(nfc->text_box);
- string_reset(nfc->text_box_store);
+ furi_string_reset(nfc->text_box_store);
nfc_blink_stop(nfc);
}
diff --git a/applications/main/nfc/scenes/nfc_scene_emv_read_success.c b/applications/main/nfc/scenes/nfc_scene_emv_read_success.c
index a40b4c1c9..8b6ab160e 100644
--- a/applications/main/nfc/scenes/nfc_scene_emv_read_success.c
+++ b/applications/main/nfc/scenes/nfc_scene_emv_read_success.c
@@ -23,42 +23,44 @@ void nfc_scene_emv_read_success_on_enter(void* context) {
widget_add_button_element(
nfc->widget, GuiButtonTypeRight, "More", nfc_scene_emv_read_success_widget_callback, nfc);
- string_t temp_str;
- string_init_printf(temp_str, "\e#%s\n", emv_data->name);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc_printf("\e#%s\n", emv_data->name);
for(uint8_t i = 0; i < emv_data->number_len; i += 2) {
- string_cat_printf(temp_str, "%02X%02X ", emv_data->number[i], emv_data->number[i + 1]);
+ furi_string_cat_printf(
+ temp_str, "%02X%02X ", emv_data->number[i], emv_data->number[i + 1]);
}
- string_strim(temp_str);
+ furi_string_trim(temp_str);
// Add expiration date
if(emv_data->exp_mon) {
- string_cat_printf(temp_str, "\nExp: %02X/%02X", emv_data->exp_mon, emv_data->exp_year);
+ furi_string_cat_printf(
+ temp_str, "\nExp: %02X/%02X", emv_data->exp_mon, emv_data->exp_year);
}
// Parse currency code
if((emv_data->currency_code)) {
- string_t currency_name;
- string_init(currency_name);
+ FuriString* currency_name;
+ currency_name = furi_string_alloc();
if(nfc_emv_parser_get_currency_name(
nfc->dev->storage, emv_data->currency_code, currency_name)) {
- string_cat_printf(temp_str, "\nCur: %s ", string_get_cstr(currency_name));
+ furi_string_cat_printf(temp_str, "\nCur: %s ", furi_string_get_cstr(currency_name));
}
- string_clear(currency_name);
+ furi_string_free(currency_name);
}
// Parse country code
if((emv_data->country_code)) {
- string_t country_name;
- string_init(country_name);
+ FuriString* country_name;
+ country_name = furi_string_alloc();
if(nfc_emv_parser_get_country_name(
nfc->dev->storage, emv_data->country_code, country_name)) {
- string_cat_printf(temp_str, "Reg: %s", string_get_cstr(country_name));
+ furi_string_cat_printf(temp_str, "Reg: %s", furi_string_get_cstr(country_name));
}
- string_clear(country_name);
+ furi_string_free(country_name);
}
notification_message_block(nfc->notifications, &sequence_set_green_255);
- widget_add_text_scroll_element(nfc->widget, 0, 0, 128, 52, string_get_cstr(temp_str));
- string_clear(temp_str);
+ widget_add_text_scroll_element(nfc->widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
+ furi_string_free(temp_str);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
}
diff --git a/applications/main/nfc/scenes/nfc_scene_generate_info.c b/applications/main/nfc/scenes/nfc_scene_generate_info.c
index 7fb7eb942..66900767e 100644
--- a/applications/main/nfc/scenes/nfc_scene_generate_info.c
+++ b/applications/main/nfc/scenes/nfc_scene_generate_info.c
@@ -16,15 +16,15 @@ void nfc_scene_generate_info_on_enter(void* context) {
dialog_ex_set_right_button_text(dialog_ex, "More");
// Create info text
- string_t info_str;
- string_init_printf(
- info_str, "%s\n%s\nUID:", nfc->generator->name, nfc_get_dev_type(data->type));
+ FuriString* info_str = furi_string_alloc_printf(
+ "%s\n%s\nUID:", nfc->generator->name, nfc_get_dev_type(data->type));
+
// Append UID
for(int i = 0; i < data->uid_len; ++i) {
- string_cat_printf(info_str, " %02X", data->uid[i]);
+ furi_string_cat_printf(info_str, " %02X", data->uid[i]);
}
- nfc_text_store_set(nfc, string_get_cstr(info_str));
- string_clear(info_str);
+ nfc_text_store_set(nfc, furi_string_get_cstr(info_str));
+ furi_string_free(info_str);
dialog_ex_set_text(dialog_ex, nfc->text_store, 0, 0, AlignLeft, AlignTop);
dialog_ex_set_context(dialog_ex, nfc);
diff --git a/applications/main/nfc/scenes/nfc_scene_mf_classic_dict_attack.c b/applications/main/nfc/scenes/nfc_scene_mf_classic_dict_attack.c
index b23f4b8f1..813546905 100644
--- a/applications/main/nfc/scenes/nfc_scene_mf_classic_dict_attack.c
+++ b/applications/main/nfc/scenes/nfc_scene_mf_classic_dict_attack.c
@@ -91,6 +91,7 @@ void nfc_scene_mf_classic_dict_attack_on_enter(void* context) {
nfc_scene_mf_classic_dict_attack_prepare_view(nfc, DictAttackStateIdle);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewDictAttack);
nfc_blink_read_start(nfc);
+ notification_message(nfc->notifications, &sequence_display_backlight_enforce_on);
}
bool nfc_scene_mf_classic_dict_attack_on_event(void* context, SceneManagerEvent event) {
@@ -167,4 +168,5 @@ void nfc_scene_mf_classic_dict_attack_on_exit(void* context) {
}
dict_attack_reset(nfc->dict_attack);
nfc_blink_stop(nfc);
+ notification_message(nfc->notifications, &sequence_display_backlight_enforce_auto);
}
diff --git a/applications/main/nfc/scenes/nfc_scene_mf_classic_keys_delete.c b/applications/main/nfc/scenes/nfc_scene_mf_classic_keys_delete.c
index 16a189da6..0ea3f59a4 100644
--- a/applications/main/nfc/scenes/nfc_scene_mf_classic_keys_delete.c
+++ b/applications/main/nfc/scenes/nfc_scene_mf_classic_keys_delete.c
@@ -16,8 +16,8 @@ void nfc_scene_mf_classic_keys_delete_on_enter(void* context) {
uint32_t key_index =
scene_manager_get_scene_state(nfc->scene_manager, NfcSceneMfClassicKeysDelete);
// Setup Custom Widget view
- string_t key_str;
- string_init(key_str);
+ FuriString* key_str;
+ key_str = furi_string_alloc();
widget_add_string_element(
nfc->widget, 64, 0, AlignCenter, AlignTop, FontPrimary, "Delete this key?");
@@ -36,9 +36,15 @@ void nfc_scene_mf_classic_keys_delete_on_enter(void* context) {
mf_classic_dict_get_key_at_index_str(dict, key_str, key_index);
widget_add_string_element(
- nfc->widget, 64, 32, AlignCenter, AlignCenter, FontSecondary, string_get_cstr(key_str));
+ nfc->widget,
+ 64,
+ 32,
+ AlignCenter,
+ AlignCenter,
+ FontSecondary,
+ furi_string_get_cstr(key_str));
- string_clear(key_str);
+ furi_string_free(key_str);
mf_classic_dict_free(dict);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
diff --git a/applications/main/nfc/scenes/nfc_scene_mf_classic_keys_list.c b/applications/main/nfc/scenes/nfc_scene_mf_classic_keys_list.c
index 6670ae132..19d2f556f 100644
--- a/applications/main/nfc/scenes/nfc_scene_mf_classic_keys_list.c
+++ b/applications/main/nfc/scenes/nfc_scene_mf_classic_keys_list.c
@@ -19,19 +19,19 @@ void nfc_scene_mf_classic_keys_list_popup_callback(void* context) {
void nfc_scene_mf_classic_keys_list_prepare(Nfc* nfc, MfClassicDict* dict) {
Submenu* submenu = nfc->submenu;
uint32_t index = 0;
- string_t temp_key;
- string_init(temp_key);
+ FuriString* temp_key;
+ temp_key = furi_string_alloc();
submenu_set_header(submenu, "Select key to delete:");
while(mf_classic_dict_get_next_key_str(dict, temp_key)) {
char* current_key = (char*)malloc(sizeof(char) * 13);
- strncpy(current_key, string_get_cstr(temp_key), 12);
+ strncpy(current_key, furi_string_get_cstr(temp_key), 12);
MfClassicUserKeys_push_back(nfc->mfc_key_strs, current_key);
- FURI_LOG_D("ListKeys", "Key %d: %s", index, current_key);
+ FURI_LOG_D("ListKeys", "Key %ld: %s", index, current_key);
submenu_add_item(
submenu, current_key, index++, nfc_scene_mf_classic_keys_list_submenu_callback, nfc);
}
- string_clear(temp_key);
+ furi_string_free(temp_key);
}
void nfc_scene_mf_classic_keys_list_on_enter(void* context) {
diff --git a/applications/main/nfc/scenes/nfc_scene_mf_classic_read_success.c b/applications/main/nfc/scenes/nfc_scene_mf_classic_read_success.c
index 3ca24416a..0cdb86464 100644
--- a/applications/main/nfc/scenes/nfc_scene_mf_classic_read_success.c
+++ b/applications/main/nfc/scenes/nfc_scene_mf_classic_read_success.c
@@ -27,26 +27,26 @@ void nfc_scene_mf_classic_read_success_on_enter(void* context) {
widget_add_button_element(
widget, GuiButtonTypeRight, "More", nfc_scene_mf_classic_read_success_widget_callback, nfc);
- string_t temp_str;
- if(string_size(nfc->dev->dev_data.parsed_data)) {
- string_init_set(temp_str, nfc->dev->dev_data.parsed_data);
+ FuriString* temp_str;
+ if(furi_string_size(nfc->dev->dev_data.parsed_data)) {
+ temp_str = furi_string_alloc_set(nfc->dev->dev_data.parsed_data);
} else {
- string_init_printf(temp_str, "\e#%s\n", nfc_mf_classic_type(mf_data->type));
- string_cat_printf(temp_str, "UID:");
+ temp_str = furi_string_alloc_printf("\e#%s\n", nfc_mf_classic_type(mf_data->type));
+ furi_string_cat_printf(temp_str, "UID:");
for(size_t i = 0; i < dev_data->nfc_data.uid_len; i++) {
- string_cat_printf(temp_str, " %02X", dev_data->nfc_data.uid[i]);
+ furi_string_cat_printf(temp_str, " %02X", dev_data->nfc_data.uid[i]);
}
uint8_t sectors_total = mf_classic_get_total_sectors_num(mf_data->type);
uint8_t keys_total = sectors_total * 2;
uint8_t keys_found = 0;
uint8_t sectors_read = 0;
mf_classic_get_read_sectors_and_keys(mf_data, §ors_read, &keys_found);
- string_cat_printf(temp_str, "\nKeys Found: %d/%d", keys_found, keys_total);
- string_cat_printf(temp_str, "\nSectors Read: %d/%d", sectors_read, sectors_total);
+ furi_string_cat_printf(temp_str, "\nKeys Found: %d/%d", keys_found, keys_total);
+ furi_string_cat_printf(temp_str, "\nSectors Read: %d/%d", sectors_read, sectors_total);
}
- widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str));
- string_clear(temp_str);
+ widget_add_text_scroll_element(widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
+ furi_string_free(temp_str);
notification_message_block(nfc->notifications, &sequence_set_green_255);
diff --git a/applications/main/nfc/scenes/nfc_scene_mf_desfire_app.c b/applications/main/nfc/scenes/nfc_scene_mf_desfire_app.c
index dd8424641..afc5f0dee 100644
--- a/applications/main/nfc/scenes/nfc_scene_mf_desfire_app.c
+++ b/applications/main/nfc/scenes/nfc_scene_mf_desfire_app.c
@@ -84,7 +84,7 @@ bool nfc_scene_mf_desfire_app_on_event(void* context, SceneManagerEvent event) {
} else {
MifareDesfireApplication* app = nfc_scene_mf_desfire_app_get_app(nfc);
TextBox* text_box = nfc->text_box;
- string_reset(nfc->text_box_store);
+ furi_string_reset(nfc->text_box_store);
if(event.event == SubmenuIndexAppInfo) {
mf_df_cat_application_info(app, nfc->text_box_store);
} else {
@@ -98,7 +98,7 @@ bool nfc_scene_mf_desfire_app_on_event(void* context, SceneManagerEvent event) {
}
mf_df_cat_file(file, nfc->text_box_store);
}
- text_box_set_text(text_box, string_get_cstr(nfc->text_box_store));
+ text_box_set_text(text_box, furi_string_get_cstr(nfc->text_box_store));
scene_manager_set_scene_state(nfc->scene_manager, NfcSceneMfDesfireApp, state | 1);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewTextBox);
consumed = true;
@@ -120,6 +120,6 @@ void nfc_scene_mf_desfire_app_on_exit(void* context) {
// Clear views
popup_reset(nfc->popup);
text_box_reset(nfc->text_box);
- string_reset(nfc->text_box_store);
+ furi_string_reset(nfc->text_box_store);
submenu_reset(nfc->submenu);
}
diff --git a/applications/main/nfc/scenes/nfc_scene_mf_desfire_data.c b/applications/main/nfc/scenes/nfc_scene_mf_desfire_data.c
index 0019a0846..e619d0377 100644
--- a/applications/main/nfc/scenes/nfc_scene_mf_desfire_data.c
+++ b/applications/main/nfc/scenes/nfc_scene_mf_desfire_data.c
@@ -67,10 +67,10 @@ bool nfc_scene_mf_desfire_data_on_event(void* context, SceneManagerEvent event)
if(event.type == SceneManagerEventTypeCustom) {
TextBox* text_box = nfc->text_box;
- string_reset(nfc->text_box_store);
+ furi_string_reset(nfc->text_box_store);
if(event.event == SubmenuIndexCardInfo) {
mf_df_cat_card_info(data, nfc->text_box_store);
- text_box_set_text(text_box, string_get_cstr(nfc->text_box_store));
+ text_box_set_text(text_box, furi_string_get_cstr(nfc->text_box_store));
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewTextBox);
scene_manager_set_scene_state(
nfc->scene_manager,
@@ -102,6 +102,6 @@ void nfc_scene_mf_desfire_data_on_exit(void* context) {
// Clear views
text_box_reset(nfc->text_box);
- string_reset(nfc->text_box_store);
+ furi_string_reset(nfc->text_box_store);
submenu_reset(nfc->submenu);
}
diff --git a/applications/main/nfc/scenes/nfc_scene_mf_desfire_read_success.c b/applications/main/nfc/scenes/nfc_scene_mf_desfire_read_success.c
index 12047c15a..2ab0355ca 100644
--- a/applications/main/nfc/scenes/nfc_scene_mf_desfire_read_success.c
+++ b/applications/main/nfc/scenes/nfc_scene_mf_desfire_read_success.c
@@ -20,20 +20,19 @@ void nfc_scene_mf_desfire_read_success_on_enter(void* context) {
Widget* widget = nfc->widget;
// Prepare string for data display
- string_t temp_str;
- string_init_printf(temp_str, "\e#MIFARE DESfire\n");
- string_cat_printf(temp_str, "UID:");
+ FuriString* temp_str = furi_string_alloc_printf("\e#MIFARE DESfire\n");
+ furi_string_cat_printf(temp_str, "UID:");
for(size_t i = 0; i < nfc_data->uid_len; i++) {
- string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
+ furi_string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
}
uint32_t bytes_total = 1 << (data->version.sw_storage >> 1);
uint32_t bytes_free = data->free_memory ? data->free_memory->bytes : 0;
- string_cat_printf(temp_str, "\n%d", bytes_total);
+ furi_string_cat_printf(temp_str, "\n%ld", bytes_total);
if(data->version.sw_storage & 1) {
- string_push_back(temp_str, '+');
+ furi_string_push_back(temp_str, '+');
}
- string_cat_printf(temp_str, " bytes, %d bytes free\n", bytes_free);
+ furi_string_cat_printf(temp_str, " bytes, %ld bytes free\n", bytes_free);
uint16_t n_apps = 0;
uint16_t n_files = 0;
@@ -43,20 +42,20 @@ void nfc_scene_mf_desfire_read_success_on_enter(void* context) {
n_files++;
}
}
- string_cat_printf(temp_str, "%d Application", n_apps);
+ furi_string_cat_printf(temp_str, "%d Application", n_apps);
if(n_apps != 1) {
- string_push_back(temp_str, 's');
+ furi_string_push_back(temp_str, 's');
}
- string_cat_printf(temp_str, ", %d file", n_files);
+ furi_string_cat_printf(temp_str, ", %d file", n_files);
if(n_files != 1) {
- string_push_back(temp_str, 's');
+ furi_string_push_back(temp_str, 's');
}
notification_message_block(nfc->notifications, &sequence_set_green_255);
// Add text scroll element
- widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str));
- string_clear(temp_str);
+ widget_add_text_scroll_element(widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
+ furi_string_free(temp_str);
// Add button elements
widget_add_button_element(
diff --git a/applications/main/nfc/scenes/nfc_scene_mf_ultralight_data.c b/applications/main/nfc/scenes/nfc_scene_mf_ultralight_data.c
index d4184a6b4..8cd223ee6 100644
--- a/applications/main/nfc/scenes/nfc_scene_mf_ultralight_data.c
+++ b/applications/main/nfc/scenes/nfc_scene_mf_ultralight_data.c
@@ -8,11 +8,11 @@ void nfc_scene_mf_ultralight_data_on_enter(void* context) {
text_box_set_font(text_box, TextBoxFontHex);
for(uint16_t i = 0; i < data->data_size; i += 2) {
if(!(i % 8) && i) {
- string_push_back(nfc->text_box_store, '\n');
+ furi_string_push_back(nfc->text_box_store, '\n');
}
- string_cat_printf(nfc->text_box_store, "%02X%02X ", data->data[i], data->data[i + 1]);
+ furi_string_cat_printf(nfc->text_box_store, "%02X%02X ", data->data[i], data->data[i + 1]);
}
- text_box_set_text(text_box, string_get_cstr(nfc->text_box_store));
+ text_box_set_text(text_box, furi_string_get_cstr(nfc->text_box_store));
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewTextBox);
}
@@ -28,5 +28,5 @@ void nfc_scene_mf_ultralight_data_on_exit(void* context) {
// Clean view
text_box_reset(nfc->text_box);
- string_reset(nfc->text_box_store);
+ furi_string_reset(nfc->text_box_store);
}
\ No newline at end of file
diff --git a/applications/main/nfc/scenes/nfc_scene_mf_ultralight_read_auth_result.c b/applications/main/nfc/scenes/nfc_scene_mf_ultralight_read_auth_result.c
index b94215455..f0c53c9ba 100644
--- a/applications/main/nfc/scenes/nfc_scene_mf_ultralight_read_auth_result.c
+++ b/applications/main/nfc/scenes/nfc_scene_mf_ultralight_read_auth_result.c
@@ -21,8 +21,8 @@ void nfc_scene_mf_ultralight_read_auth_result_on_enter(void* context) {
MfUltralightData* mf_ul_data = &nfc->dev->dev_data.mf_ul_data;
MfUltralightConfigPages* config_pages = mf_ultralight_get_config_pages(mf_ul_data);
Widget* widget = nfc->widget;
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
if((mf_ul_data->data_read == mf_ul_data->data_size) && (mf_ul_data->data_read > 0)) {
widget_add_string_element(
@@ -31,14 +31,14 @@ void nfc_scene_mf_ultralight_read_auth_result_on_enter(void* context) {
widget_add_string_element(
widget, 64, 0, AlignCenter, AlignTop, FontPrimary, "Not all pages unlocked!");
}
- string_set_str(temp_str, "UID:");
+ furi_string_set(temp_str, "UID:");
for(size_t i = 0; i < nfc_data->uid_len; i++) {
- string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
+ furi_string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
}
widget_add_string_element(
- widget, 0, 17, AlignLeft, AlignTop, FontSecondary, string_get_cstr(temp_str));
+ widget, 0, 17, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(temp_str));
if(mf_ul_data->auth_success) {
- string_printf(
+ furi_string_printf(
temp_str,
"Password: %02X %02X %02X %02X",
config_pages->auth_data.pwd.raw[0],
@@ -46,19 +46,19 @@ void nfc_scene_mf_ultralight_read_auth_result_on_enter(void* context) {
config_pages->auth_data.pwd.raw[2],
config_pages->auth_data.pwd.raw[3]);
widget_add_string_element(
- widget, 0, 28, AlignLeft, AlignTop, FontSecondary, string_get_cstr(temp_str));
- string_printf(
+ widget, 0, 28, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(temp_str));
+ furi_string_printf(
temp_str,
"PACK: %02X %02X",
config_pages->auth_data.pack.raw[0],
config_pages->auth_data.pack.raw[1]);
widget_add_string_element(
- widget, 0, 39, AlignLeft, AlignTop, FontSecondary, string_get_cstr(temp_str));
+ widget, 0, 39, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(temp_str));
}
- string_printf(
+ furi_string_printf(
temp_str, "Pages Read: %d/%d", mf_ul_data->data_read / 4, mf_ul_data->data_size / 4);
widget_add_string_element(
- widget, 0, 50, AlignLeft, AlignTop, FontSecondary, string_get_cstr(temp_str));
+ widget, 0, 50, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(temp_str));
widget_add_button_element(
widget,
GuiButtonTypeRight,
@@ -66,7 +66,7 @@ void nfc_scene_mf_ultralight_read_auth_result_on_enter(void* context) {
nfc_scene_mf_ultralight_read_auth_result_widget_callback,
nfc);
- string_clear(temp_str);
+ furi_string_free(temp_str);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
}
diff --git a/applications/main/nfc/scenes/nfc_scene_mf_ultralight_read_success.c b/applications/main/nfc/scenes/nfc_scene_mf_ultralight_read_success.c
index f6dc5984e..77034ea80 100644
--- a/applications/main/nfc/scenes/nfc_scene_mf_ultralight_read_success.c
+++ b/applications/main/nfc/scenes/nfc_scene_mf_ultralight_read_success.c
@@ -33,23 +33,23 @@ void nfc_scene_mf_ultralight_read_success_on_enter(void* context) {
nfc_scene_mf_ultralight_read_success_widget_callback,
nfc);
- string_t temp_str;
- if(string_size(nfc->dev->dev_data.parsed_data)) {
- string_init_set(temp_str, nfc->dev->dev_data.parsed_data);
+ FuriString* temp_str;
+ if(furi_string_size(nfc->dev->dev_data.parsed_data)) {
+ temp_str = furi_string_alloc_set(nfc->dev->dev_data.parsed_data);
} else {
- string_init_printf(temp_str, "\e#%s\n", nfc_mf_ul_type(mf_ul_data->type, true));
- string_cat_printf(temp_str, "UID:");
+ temp_str = furi_string_alloc_printf("\e#%s\n", nfc_mf_ul_type(mf_ul_data->type, true));
+ furi_string_cat_printf(temp_str, "UID:");
for(size_t i = 0; i < data->uid_len; i++) {
- string_cat_printf(temp_str, " %02X", data->uid[i]);
+ furi_string_cat_printf(temp_str, " %02X", data->uid[i]);
}
- string_cat_printf(
+ furi_string_cat_printf(
temp_str, "\nPages Read: %d/%d", mf_ul_data->data_read / 4, mf_ul_data->data_size / 4);
if(mf_ul_data->data_read != mf_ul_data->data_size) {
- string_cat_printf(temp_str, "\nPassword-protected pages!");
+ furi_string_cat_printf(temp_str, "\nPassword-protected pages!");
}
}
- widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str));
- string_clear(temp_str);
+ widget_add_text_scroll_element(widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
+ furi_string_free(temp_str);
notification_message_block(nfc->notifications, &sequence_set_green_255);
diff --git a/applications/main/nfc/scenes/nfc_scene_mfkey_nonces_info.c b/applications/main/nfc/scenes/nfc_scene_mfkey_nonces_info.c
index b45b690d3..6d9852f3e 100644
--- a/applications/main/nfc/scenes/nfc_scene_mfkey_nonces_info.c
+++ b/applications/main/nfc/scenes/nfc_scene_mfkey_nonces_info.c
@@ -11,21 +11,21 @@ void nfc_scene_mfkey_nonces_info_callback(GuiButtonType result, InputType type,
void nfc_scene_mfkey_nonces_info_on_enter(void* context) {
Nfc* nfc = context;
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
uint16_t nonces_saved = mfkey32_get_auth_sectors(temp_str);
- widget_add_text_scroll_element(nfc->widget, 0, 22, 128, 42, string_get_cstr(temp_str));
- string_printf(temp_str, "Nonces saved %d", nonces_saved);
+ widget_add_text_scroll_element(nfc->widget, 0, 22, 128, 42, furi_string_get_cstr(temp_str));
+ furi_string_printf(temp_str, "Nonce pairs saved: %d", nonces_saved);
widget_add_string_element(
- nfc->widget, 0, 0, AlignLeft, AlignTop, FontPrimary, string_get_cstr(temp_str));
+ nfc->widget, 0, 0, AlignLeft, AlignTop, FontPrimary, furi_string_get_cstr(temp_str));
widget_add_string_element(
nfc->widget, 0, 12, AlignLeft, AlignTop, FontSecondary, "Authenticated sectors:");
widget_add_button_element(
- nfc->widget, GuiButtonTypeRight, "Next", nfc_scene_mfkey_nonces_info_callback, nfc);
+ nfc->widget, GuiButtonTypeCenter, "OK", nfc_scene_mfkey_nonces_info_callback, nfc);
- string_clear(temp_str);
+ furi_string_free(temp_str);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
}
@@ -35,7 +35,7 @@ bool nfc_scene_mfkey_nonces_info_on_event(void* context, SceneManagerEvent event
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
- if(event.event == GuiButtonTypeRight) {
+ if(event.event == GuiButtonTypeCenter) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfkeyComplete);
consumed = true;
}
diff --git a/applications/main/nfc/scenes/nfc_scene_nfc_data_info.c b/applications/main/nfc/scenes/nfc_scene_nfc_data_info.c
index 33f5e44af..8f33972e0 100644
--- a/applications/main/nfc/scenes/nfc_scene_nfc_data_info.c
+++ b/applications/main/nfc/scenes/nfc_scene_nfc_data_info.c
@@ -22,47 +22,48 @@ void nfc_scene_nfc_data_info_on_enter(void* context) {
text_scroll_height = 64;
}
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
// Set name if present
if(nfc->dev->dev_name[0] != '\0') {
- string_printf(temp_str, "\ec%s\n", nfc->dev->dev_name);
+ furi_string_printf(temp_str, "\ec%s\n", nfc->dev->dev_name);
}
// Set tag type
if(protocol == NfcDeviceProtocolEMV) {
- string_cat_printf(temp_str, "\e#EMV Bank Card\n");
+ furi_string_cat_printf(temp_str, "\e#EMV Bank Card\n");
} else if(protocol == NfcDeviceProtocolMifareUl) {
- string_cat_printf(temp_str, "\e#%s\n", nfc_mf_ul_type(dev_data->mf_ul_data.type, true));
+ furi_string_cat_printf(
+ temp_str, "\e#%s\n", nfc_mf_ul_type(dev_data->mf_ul_data.type, true));
} else if(protocol == NfcDeviceProtocolMifareClassic) {
- string_cat_printf(
+ furi_string_cat_printf(
temp_str, "\e#%s\n", nfc_mf_classic_type(dev_data->mf_classic_data.type));
} else if(protocol == NfcDeviceProtocolMifareDesfire) {
- string_cat_printf(temp_str, "\e#MIFARE DESfire\n");
+ furi_string_cat_printf(temp_str, "\e#MIFARE DESfire\n");
} else {
- string_cat_printf(temp_str, "\e#Unknown ISO tag\n");
+ furi_string_cat_printf(temp_str, "\e#Unknown ISO tag\n");
}
// Set tag iso data
char iso_type = FURI_BIT(nfc_data->sak, 5) ? '4' : '3';
- string_cat_printf(temp_str, "ISO 14443-%c (NFC-A)\n", iso_type);
- string_cat_printf(temp_str, "UID:");
+ furi_string_cat_printf(temp_str, "ISO 14443-%c (NFC-A)\n", iso_type);
+ furi_string_cat_printf(temp_str, "UID:");
for(size_t i = 0; i < nfc_data->uid_len; i++) {
- string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
+ furi_string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
}
- string_cat_printf(temp_str, "\nATQA: %02X %02X ", nfc_data->atqa[1], nfc_data->atqa[0]);
- string_cat_printf(temp_str, " SAK: %02X", nfc_data->sak);
+ furi_string_cat_printf(temp_str, "\nATQA: %02X %02X ", nfc_data->atqa[1], nfc_data->atqa[0]);
+ furi_string_cat_printf(temp_str, " SAK: %02X", nfc_data->sak);
// Set application specific data
if(protocol == NfcDeviceProtocolMifareDesfire) {
MifareDesfireData* data = &dev_data->mf_df_data;
uint32_t bytes_total = 1 << (data->version.sw_storage >> 1);
uint32_t bytes_free = data->free_memory ? data->free_memory->bytes : 0;
- string_cat_printf(temp_str, "\n%d", bytes_total);
+ furi_string_cat_printf(temp_str, "\n%ld", bytes_total);
if(data->version.sw_storage & 1) {
- string_push_back(temp_str, '+');
+ furi_string_push_back(temp_str, '+');
}
- string_cat_printf(temp_str, " bytes, %d bytes free\n", bytes_free);
+ furi_string_cat_printf(temp_str, " bytes, %ld bytes free\n", bytes_free);
uint16_t n_apps = 0;
uint16_t n_files = 0;
@@ -72,20 +73,20 @@ void nfc_scene_nfc_data_info_on_enter(void* context) {
n_files++;
}
}
- string_cat_printf(temp_str, "%d Application", n_apps);
+ furi_string_cat_printf(temp_str, "%d Application", n_apps);
if(n_apps != 1) {
- string_push_back(temp_str, 's');
+ furi_string_push_back(temp_str, 's');
}
- string_cat_printf(temp_str, ", %d file", n_files);
+ furi_string_cat_printf(temp_str, ", %d file", n_files);
if(n_files != 1) {
- string_push_back(temp_str, 's');
+ furi_string_push_back(temp_str, 's');
}
} else if(protocol == NfcDeviceProtocolMifareUl) {
MfUltralightData* data = &dev_data->mf_ul_data;
- string_cat_printf(
+ furi_string_cat_printf(
temp_str, "\nPages Read %d/%d", data->data_read / 4, data->data_size / 4);
if(data->data_size > data->data_read) {
- string_cat_printf(temp_str, "\nPassword-protected");
+ furi_string_cat_printf(temp_str, "\nPassword-protected");
}
} else if(protocol == NfcDeviceProtocolMifareClassic) {
MfClassicData* data = &dev_data->mf_classic_data;
@@ -94,14 +95,14 @@ void nfc_scene_nfc_data_info_on_enter(void* context) {
uint8_t keys_found = 0;
uint8_t sectors_read = 0;
mf_classic_get_read_sectors_and_keys(data, §ors_read, &keys_found);
- string_cat_printf(temp_str, "\nKeys Found %d/%d", keys_found, keys_total);
- string_cat_printf(temp_str, "\nSectors Read %d/%d", sectors_read, sectors_total);
+ furi_string_cat_printf(temp_str, "\nKeys Found %d/%d", keys_found, keys_total);
+ furi_string_cat_printf(temp_str, "\nSectors Read %d/%d", sectors_read, sectors_total);
}
// Add text scroll widget
widget_add_text_scroll_element(
- widget, 0, 0, 128, text_scroll_height, string_get_cstr(temp_str));
- string_clear(temp_str);
+ widget, 0, 0, 128, text_scroll_height, furi_string_get_cstr(temp_str));
+ furi_string_free(temp_str);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
}
diff --git a/applications/main/nfc/scenes/nfc_scene_nfca_read_success.c b/applications/main/nfc/scenes/nfc_scene_nfca_read_success.c
index c695da247..2ea7c9921 100644
--- a/applications/main/nfc/scenes/nfc_scene_nfca_read_success.c
+++ b/applications/main/nfc/scenes/nfc_scene_nfca_read_success.c
@@ -22,22 +22,22 @@ void nfc_scene_nfca_read_success_on_enter(void* context) {
FuriHalNfcDevData* data = &nfc->dev->dev_data.nfc_data;
Widget* widget = nfc->widget;
- string_t temp_str;
- string_init_set_str(temp_str, "\e#Unknown ISO tag\n");
+ FuriString* temp_str;
+ temp_str = furi_string_alloc_set("\e#Unknown ISO tag\n");
notification_message_block(nfc->notifications, &sequence_set_green_255);
char iso_type = FURI_BIT(data->sak, 5) ? '4' : '3';
- string_cat_printf(temp_str, "ISO 14443-%c (NFC-A)\n", iso_type);
- string_cat_printf(temp_str, "UID:");
+ furi_string_cat_printf(temp_str, "ISO 14443-%c (NFC-A)\n", iso_type);
+ furi_string_cat_printf(temp_str, "UID:");
for(size_t i = 0; i < data->uid_len; i++) {
- string_cat_printf(temp_str, " %02X", data->uid[i]);
+ furi_string_cat_printf(temp_str, " %02X", data->uid[i]);
}
- string_cat_printf(temp_str, "\nATQA: %02X %02X ", data->atqa[1], data->atqa[0]);
- string_cat_printf(temp_str, " SAK: %02X", data->sak);
+ furi_string_cat_printf(temp_str, "\nATQA: %02X %02X ", data->atqa[1], data->atqa[0]);
+ furi_string_cat_printf(temp_str, " SAK: %02X", data->sak);
- widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str));
- string_clear(temp_str);
+ widget_add_text_scroll_element(widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
+ furi_string_free(temp_str);
widget_add_button_element(
widget, GuiButtonTypeLeft, "Retry", nfc_scene_nfca_read_success_widget_callback, nfc);
diff --git a/applications/main/nfc/scenes/nfc_scene_read_card_success.c b/applications/main/nfc/scenes/nfc_scene_read_card_success.c
index 0cb38cbdf..352cb4a7e 100644
--- a/applications/main/nfc/scenes/nfc_scene_read_card_success.c
+++ b/applications/main/nfc/scenes/nfc_scene_read_card_success.c
@@ -16,26 +16,26 @@ void nfc_scene_read_card_success_widget_callback(
void nfc_scene_read_card_success_on_enter(void* context) {
Nfc* nfc = context;
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
// Setup view
FuriHalNfcDevData* data = &nfc->dev->dev_data.nfc_data;
Widget* widget = nfc->widget;
- string_set_str(temp_str, nfc_get_dev_type(data->type));
+ furi_string_set(temp_str, nfc_get_dev_type(data->type));
widget_add_string_element(
- widget, 64, 12, AlignCenter, AlignBottom, FontPrimary, string_get_cstr(temp_str));
- string_set_str(temp_str, "UID:");
+ widget, 64, 12, AlignCenter, AlignBottom, FontPrimary, furi_string_get_cstr(temp_str));
+ furi_string_set(temp_str, "UID:");
for(uint8_t i = 0; i < data->uid_len; i++) {
- string_cat_printf(temp_str, " %02X", data->uid[i]);
+ furi_string_cat_printf(temp_str, " %02X", data->uid[i]);
}
widget_add_string_element(
- widget, 64, 32, AlignCenter, AlignCenter, FontSecondary, string_get_cstr(temp_str));
+ widget, 64, 32, AlignCenter, AlignCenter, FontSecondary, furi_string_get_cstr(temp_str));
widget_add_button_element(
widget, GuiButtonTypeLeft, "Retry", nfc_scene_read_card_success_widget_callback, nfc);
- string_clear(temp_str);
+ furi_string_free(temp_str);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
}
diff --git a/applications/main/nfc/scenes/nfc_scene_save_name.c b/applications/main/nfc/scenes/nfc_scene_save_name.c
index d5e05472a..736eab7de 100644
--- a/applications/main/nfc/scenes/nfc_scene_save_name.c
+++ b/applications/main/nfc/scenes/nfc_scene_save_name.c
@@ -1,5 +1,4 @@
#include "../nfc_i.h"
-#include "m-string.h"
#include
#include
#include
@@ -31,22 +30,22 @@ void nfc_scene_save_name_on_enter(void* context) {
NFC_DEV_NAME_MAX_LEN,
dev_name_empty);
- string_t folder_path;
- string_init(folder_path);
+ FuriString* folder_path;
+ folder_path = furi_string_alloc();
- if(string_end_with_str_p(nfc->dev->load_path, NFC_APP_EXTENSION)) {
- path_extract_dirname(string_get_cstr(nfc->dev->load_path), folder_path);
+ if(furi_string_end_with(nfc->dev->load_path, NFC_APP_EXTENSION)) {
+ path_extract_dirname(furi_string_get_cstr(nfc->dev->load_path), folder_path);
} else {
- string_set_str(folder_path, NFC_APP_FOLDER);
+ furi_string_set(folder_path, NFC_APP_FOLDER);
}
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
- string_get_cstr(folder_path), NFC_APP_EXTENSION, nfc->dev->dev_name);
+ furi_string_get_cstr(folder_path), NFC_APP_EXTENSION, nfc->dev->dev_name);
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewTextInput);
- string_clear(folder_path);
+ furi_string_free(folder_path);
}
bool nfc_scene_save_name_on_event(void* context, SceneManagerEvent event) {
diff --git a/applications/main/nfc/scenes/nfc_scene_saved_menu.c b/applications/main/nfc/scenes/nfc_scene_saved_menu.c
index c1043b3a7..fe65b5b8a 100644
--- a/applications/main/nfc/scenes/nfc_scene_saved_menu.c
+++ b/applications/main/nfc/scenes/nfc_scene_saved_menu.c
@@ -20,8 +20,7 @@ void nfc_scene_saved_menu_on_enter(void* context) {
Submenu* submenu = nfc->submenu;
if(nfc->dev->format == NfcDeviceSaveFormatUid ||
- nfc->dev->format == NfcDeviceSaveFormatMifareDesfire ||
- nfc->dev->format == NfcDeviceSaveFormatBankCard) {
+ nfc->dev->format == NfcDeviceSaveFormatMifareDesfire) {
submenu_add_item(
submenu,
"Emulate UID",
diff --git a/applications/main/nfc/scenes/nfc_scene_set_type.c b/applications/main/nfc/scenes/nfc_scene_set_type.c
index ec6d11447..3e08aeb3f 100644
--- a/applications/main/nfc/scenes/nfc_scene_set_type.c
+++ b/applications/main/nfc/scenes/nfc_scene_set_type.c
@@ -1,5 +1,4 @@
#include "../nfc_i.h"
-#include "m-string.h"
#include "../helpers/nfc_generators.h"
enum SubmenuIndex {
@@ -19,7 +18,7 @@ void nfc_scene_set_type_on_enter(void* context) {
Submenu* submenu = nfc->submenu;
// Clear device name
nfc_device_set_name(nfc->dev, "");
- string_set_str(nfc->dev->load_path, "");
+ furi_string_set(nfc->dev->load_path, "");
submenu_add_item(
submenu, "NFC-A 7-bytes UID", SubmenuIndexNFCA7, nfc_scene_set_type_submenu_callback, nfc);
submenu_add_item(
diff --git a/applications/main/nfc/views/detect_reader.c b/applications/main/nfc/views/detect_reader.c
index 177c13f75..9a0770438 100644
--- a/applications/main/nfc/views/detect_reader.c
+++ b/applications/main/nfc/views/detect_reader.c
@@ -10,29 +10,50 @@ struct DetectReader {
typedef struct {
uint16_t nonces;
+ uint16_t nonces_max;
+ DetectReaderState state;
} DetectReaderViewModel;
static void detect_reader_draw_callback(Canvas* canvas, void* model) {
DetectReaderViewModel* m = model;
char text[32] = {};
- snprintf(text, sizeof(text), "Tap the reader several times");
- canvas_draw_str_aligned(canvas, 64, 0, AlignCenter, AlignTop, "Tap the reader several times");
+ // Draw header and icon
+ canvas_draw_icon(canvas, 0, 16, &I_Modern_reader_18x34);
+ if(m->state == DetectReaderStateStart) {
+ snprintf(text, sizeof(text), "Touch the reader");
+ canvas_draw_icon(canvas, 21, 13, &I_Move_flipper_26x39);
+ } else if(m->state == DetectReaderStateReaderDetected) {
+ snprintf(text, sizeof(text), "Move the Flipper away");
+ canvas_draw_icon(canvas, 24, 25, &I_Release_arrow_18x15);
+ } else if(m->state == DetectReaderStateReaderLost) {
+ snprintf(text, sizeof(text), "Touch the reader again");
+ canvas_draw_icon(canvas, 21, 13, &I_Move_flipper_26x39);
+ }
- if(m->nonces == 0) {
+ canvas_draw_str_aligned(canvas, 64, 0, AlignCenter, AlignTop, text);
+
+ // Draw collected nonces
+ if(m->state == DetectReaderStateStart) {
canvas_set_font(canvas, FontPrimary);
- canvas_draw_str_aligned(canvas, 52, 22, AlignLeft, AlignTop, "Emulating...");
+ canvas_draw_str_aligned(canvas, 51, 22, AlignLeft, AlignTop, "Emulating...");
canvas_set_font(canvas, FontSecondary);
- canvas_draw_str_aligned(canvas, 52, 35, AlignLeft, AlignTop, "MIFARE Classic");
- canvas_draw_icon(canvas, 0, 13, &I_Tap_reader_36x38);
+ canvas_draw_str_aligned(canvas, 51, 35, AlignLeft, AlignTop, "MIFARE MFkey32");
} else {
- canvas_set_font(canvas, FontPrimary);
- canvas_draw_str_aligned(canvas, 54, 22, AlignLeft, AlignTop, "Collecting...");
+ if(m->state == DetectReaderStateDone) {
+ canvas_set_font(canvas, FontPrimary);
+ canvas_draw_str_aligned(canvas, 51, 22, AlignLeft, AlignTop, "Completed!");
+ } else {
+ canvas_set_font(canvas, FontPrimary);
+ canvas_draw_str_aligned(canvas, 51, 22, AlignLeft, AlignTop, "Collecting...");
+ }
canvas_set_font(canvas, FontSecondary);
- snprintf(text, sizeof(text), "Nonces: %d", m->nonces);
- canvas_draw_str_aligned(canvas, 54, 35, AlignLeft, AlignTop, text);
- elements_button_right(canvas, "Next");
- canvas_draw_icon(canvas, 6, 15, &I_ArrowC_1_36x36);
+ snprintf(text, sizeof(text), "Nonce pairs: %d/%d", m->nonces, m->nonces_max);
+ canvas_draw_str_aligned(canvas, 51, 35, AlignLeft, AlignTop, text);
+ }
+ // Draw button
+ if(m->nonces > 0) {
+ elements_button_center(canvas, "Done");
}
}
@@ -49,7 +70,7 @@ static bool detect_reader_input_callback(InputEvent* event, void* context) {
});
if(event->type == InputTypeShort) {
- if(event->key == InputKeyRight) {
+ if(event->key == InputKeyOk) {
if(nonces > 0) {
detect_reader->callback(detect_reader->context);
consumed = true;
@@ -84,6 +105,8 @@ void detect_reader_reset(DetectReader* detect_reader) {
with_view_model(
detect_reader->view, (DetectReaderViewModel * model) {
model->nonces = 0;
+ model->nonces_max = 0;
+ model->state = DetectReaderStateStart;
return false;
});
}
@@ -105,11 +128,31 @@ void detect_reader_set_callback(
detect_reader->context = context;
}
-void detect_reader_inc_nonce_cnt(DetectReader* detect_reader) {
+void detect_reader_set_nonces_max(DetectReader* detect_reader, uint16_t nonces_max) {
furi_assert(detect_reader);
+
with_view_model(
detect_reader->view, (DetectReaderViewModel * model) {
- model->nonces++;
+ model->nonces_max = nonces_max;
return false;
});
}
+
+void detect_reader_set_nonces_collected(DetectReader* detect_reader, uint16_t nonces_collected) {
+ furi_assert(detect_reader);
+
+ with_view_model(
+ detect_reader->view, (DetectReaderViewModel * model) {
+ model->nonces = nonces_collected;
+ return false;
+ });
+}
+
+void detect_reader_set_state(DetectReader* detect_reader, DetectReaderState state) {
+ furi_assert(detect_reader);
+ with_view_model(
+ detect_reader->view, (DetectReaderViewModel * model) {
+ model->state = state;
+ return true;
+ });
+}
diff --git a/applications/main/nfc/views/detect_reader.h b/applications/main/nfc/views/detect_reader.h
index 12cd03db4..aabdd7c87 100644
--- a/applications/main/nfc/views/detect_reader.h
+++ b/applications/main/nfc/views/detect_reader.h
@@ -5,6 +5,13 @@
typedef struct DetectReader DetectReader;
+typedef enum {
+ DetectReaderStateStart,
+ DetectReaderStateReaderDetected,
+ DetectReaderStateReaderLost,
+ DetectReaderStateDone,
+} DetectReaderState;
+
typedef void (*DetectReaderDoneCallback)(void* context);
DetectReader* detect_reader_alloc();
@@ -20,4 +27,8 @@ void detect_reader_set_callback(
DetectReaderDoneCallback callback,
void* context);
-void detect_reader_inc_nonce_cnt(DetectReader* detect_reader);
+void detect_reader_set_nonces_max(DetectReader* detect_reader, uint16_t nonces_max);
+
+void detect_reader_set_nonces_collected(DetectReader* detect_reader, uint16_t nonces_collected);
+
+void detect_reader_set_state(DetectReader* detect_reader, DetectReaderState state);
diff --git a/applications/main/nfc/views/dict_attack.c b/applications/main/nfc/views/dict_attack.c
index b4674fd31..cbafbf69a 100644
--- a/applications/main/nfc/views/dict_attack.c
+++ b/applications/main/nfc/views/dict_attack.c
@@ -1,6 +1,5 @@
#include "dict_attack.h"
-#include
#include
typedef enum {
@@ -17,7 +16,7 @@ struct DictAttack {
typedef struct {
DictAttackState state;
MfClassicType type;
- string_t header;
+ FuriString* header;
uint8_t sectors_total;
uint8_t sectors_read;
uint8_t sector_current;
@@ -38,7 +37,8 @@ static void dict_attack_draw_callback(Canvas* canvas, void* model) {
} else if(m->state == DictAttackStateRead) {
char draw_str[32] = {};
canvas_set_font(canvas, FontPrimary);
- canvas_draw_str_aligned(canvas, 64, 2, AlignCenter, AlignTop, string_get_cstr(m->header));
+ canvas_draw_str_aligned(
+ canvas, 64, 2, AlignCenter, AlignTop, furi_string_get_cstr(m->header));
canvas_set_font(canvas, FontSecondary);
float dict_progress = m->dict_keys_total == 0 ?
0 :
@@ -81,7 +81,7 @@ DictAttack* dict_attack_alloc() {
view_set_context(dict_attack->view, dict_attack);
with_view_model(
dict_attack->view, (DictAttackViewModel * model) {
- string_init(model->header);
+ model->header = furi_string_alloc();
return false;
});
return dict_attack;
@@ -91,7 +91,7 @@ void dict_attack_free(DictAttack* dict_attack) {
furi_assert(dict_attack);
with_view_model(
dict_attack->view, (DictAttackViewModel * model) {
- string_clear(model->header);
+ furi_string_free(model->header);
return false;
});
view_free(dict_attack->view);
@@ -111,7 +111,7 @@ void dict_attack_reset(DictAttack* dict_attack) {
model->keys_found = 0;
model->dict_keys_total = 0;
model->dict_keys_current = 0;
- string_reset(model->header);
+ furi_string_reset(model->header);
return false;
});
}
@@ -134,7 +134,7 @@ void dict_attack_set_header(DictAttack* dict_attack, const char* header) {
with_view_model(
dict_attack->view, (DictAttackViewModel * model) {
- string_set_str(model->header, header);
+ furi_string_set(model->header, header);
return true;
});
}
diff --git a/applications/main/subghz/helpers/subghz_frequency_analyzer_worker.c b/applications/main/subghz/helpers/subghz_frequency_analyzer_worker.c
index 260676a24..88aa4a18c 100644
--- a/applications/main/subghz/helpers/subghz_frequency_analyzer_worker.c
+++ b/applications/main/subghz/helpers/subghz_frequency_analyzer_worker.c
@@ -148,7 +148,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
FURI_LOG_T(
TAG,
- "RSSI: avg %f, max %f at %u, min %f",
+ "RSSI: avg %f, max %f at %lu, min %f",
(double)(rssi_avg / rssi_avg_samples),
(double)frequency_rssi.rssi_coarse,
frequency_rssi.frequency_coarse,
@@ -179,7 +179,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
rssi = furi_hal_subghz_get_rssi();
- FURI_LOG_T(TAG, "#:%u:%f", frequency, (double)rssi);
+ FURI_LOG_T(TAG, "#:%lu:%f", frequency, (double)rssi);
if(frequency_rssi.rssi_fine < rssi) {
frequency_rssi.rssi_fine = rssi;
@@ -192,7 +192,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
// Deliver results fine
if(frequency_rssi.rssi_fine > instance->trigger_level) {
FURI_LOG_D(
- TAG, "=:%u:%f", frequency_rssi.frequency_fine, (double)frequency_rssi.rssi_fine);
+ TAG, "=:%lu:%f", frequency_rssi.frequency_fine, (double)frequency_rssi.rssi_fine);
instance->sample_hold_counter = 20;
if(instance->filVal) {
@@ -210,7 +210,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
(instance->sample_hold_counter < 10)) {
FURI_LOG_D(
TAG,
- "~:%u:%f",
+ "~:%lu:%f",
frequency_rssi.frequency_coarse,
(double)frequency_rssi.rssi_coarse);
diff --git a/applications/main/subghz/helpers/subghz_types.h b/applications/main/subghz/helpers/subghz_types.h
index d6d6d025f..906879020 100644
--- a/applications/main/subghz/helpers/subghz_types.h
+++ b/applications/main/subghz/helpers/subghz_types.h
@@ -1,6 +1,5 @@
#pragma once
-#include "m-string.h"
#include
#include
@@ -74,7 +73,7 @@ typedef enum {
} SubGhzViewId;
struct SubGhzPresetDefinition {
- string_t name;
+ FuriString* name;
uint32_t frequency;
uint8_t* data;
size_t data_size;
@@ -86,3 +85,5 @@ typedef enum {
SubGhzViewReceiverModeLive,
SubGhzViewReceiverModeFile,
} SubGhzViewReceiverMode;
+
+#define SUBGHZ_HISTORY_REMOVE_SAVED_ITEMS 1
diff --git a/applications/main/subghz/scenes/subghz_scene_config.h b/applications/main/subghz/scenes/subghz_scene_config.h
index c2731910b..f265644b7 100644
--- a/applications/main/subghz/scenes/subghz_scene_config.h
+++ b/applications/main/subghz/scenes/subghz_scene_config.h
@@ -13,9 +13,11 @@ ADD_SCENE(subghz, saved_menu, SavedMenu)
ADD_SCENE(subghz, delete, Delete)
ADD_SCENE(subghz, delete_success, DeleteSuccess)
ADD_SCENE(subghz, test, Test)
-ADD_SCENE(subghz, test_static, TestStatic)
ADD_SCENE(subghz, test_carrier, TestCarrier)
+#if FURI_DEBUG
+ADD_SCENE(subghz, test_static, TestStatic)
ADD_SCENE(subghz, test_packet, TestPacket)
+#endif
ADD_SCENE(subghz, set_type, SetType)
ADD_SCENE(subghz, set_fix_faac_868, SetFixFaac868)
ADD_SCENE(subghz, set_cnt_faac_868, SetCntFaac868)
diff --git a/applications/main/subghz/scenes/subghz_scene_decode_raw.c b/applications/main/subghz/scenes/subghz_scene_decode_raw.c
index 7593d3aec..4412cc023 100644
--- a/applications/main/subghz/scenes/subghz_scene_decode_raw.c
+++ b/applications/main/subghz/scenes/subghz_scene_decode_raw.c
@@ -33,30 +33,30 @@ SubGhzFileEncoderWorker* file_worker_encoder;
static void subghz_scene_receiver_update_statusbar(void* context) {
SubGhz* subghz = context;
- string_t history_stat_str;
- string_init(history_stat_str);
+ FuriString* history_stat_str;
+ history_stat_str = furi_string_alloc();
if(!subghz_history_get_text_space_left(subghz->txrx->history, history_stat_str)) {
- string_t frequency_str;
- string_t modulation_str;
+ FuriString* frequency_str;
+ FuriString* modulation_str;
- string_init(frequency_str);
- string_init(modulation_str);
+ frequency_str = furi_string_alloc();
+ modulation_str = furi_string_alloc();
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
subghz_view_receiver_add_data_statusbar(
subghz->subghz_receiver,
- string_get_cstr(frequency_str),
- string_get_cstr(modulation_str),
- string_get_cstr(history_stat_str));
+ furi_string_get_cstr(frequency_str),
+ furi_string_get_cstr(modulation_str),
+ furi_string_get_cstr(history_stat_str));
- string_clear(frequency_str);
- string_clear(modulation_str);
+ furi_string_free(frequency_str);
+ furi_string_free(modulation_str);
} else {
subghz_view_receiver_add_data_statusbar(
- subghz->subghz_receiver, string_get_cstr(history_stat_str), "", "");
+ subghz->subghz_receiver, furi_string_get_cstr(history_stat_str), "", "");
}
- string_clear(history_stat_str);
+ furi_string_free(history_stat_str);
}
void subghz_scene_decode_raw_callback(SubGhzCustomEvent event, void* context) {
@@ -71,11 +71,11 @@ static void subghz_scene_add_to_history_callback(
void* context) {
furi_assert(context);
SubGhz* subghz = context;
- string_t str_buff;
- string_init(str_buff);
+ FuriString* str_buff;
+ str_buff = furi_string_alloc();
if(subghz_history_add_to_history(subghz->txrx->history, decoder_base, subghz->txrx->preset)) {
- string_reset(str_buff);
+ furi_string_reset(str_buff);
subghz->state_notifications = SubGhzNotificationStateRxDone;
@@ -83,19 +83,19 @@ static void subghz_scene_add_to_history_callback(
subghz->txrx->history, str_buff, subghz_history_get_item(subghz->txrx->history) - 1);
subghz_view_receiver_add_item_to_menu(
subghz->subghz_receiver,
- string_get_cstr(str_buff),
+ furi_string_get_cstr(str_buff),
subghz_history_get_type_protocol(
subghz->txrx->history, subghz_history_get_item(subghz->txrx->history) - 1));
subghz_scene_receiver_update_statusbar(subghz);
}
subghz_receiver_reset(receiver);
- string_clear(str_buff);
+ furi_string_free(str_buff);
}
bool subghz_scene_decode_raw_start(SubGhz* subghz) {
- string_t file_name;
- string_init(file_name);
+ FuriString* file_name;
+ file_name = furi_string_alloc();
bool success = false;
do {
if(!flipper_format_rewind(subghz->txrx->fff_data)) {
@@ -112,10 +112,10 @@ bool subghz_scene_decode_raw_start(SubGhz* subghz) {
} while(false);
if(success) {
- //FURI_LOG_I(TAG, "Listening at \033[0;33m%s\033[0m.", string_get_cstr(file_name));
+ //FURI_LOG_I(TAG, "Listening at \033[0;33m%s\033[0m.", furi_string_get_cstr(file_name));
file_worker_encoder = subghz_file_encoder_worker_alloc();
- if(subghz_file_encoder_worker_start(file_worker_encoder, string_get_cstr(file_name))) {
+ if(subghz_file_encoder_worker_start(file_worker_encoder, furi_string_get_cstr(file_name))) {
//the worker needs a file in order to open and read part of the file
furi_delay_ms(100);
} else {
@@ -127,7 +127,7 @@ bool subghz_scene_decode_raw_start(SubGhz* subghz) {
}
}
- string_clear(file_name);
+ furi_string_free(file_name);
return success;
}
@@ -150,13 +150,14 @@ bool subghz_scene_decode_raw_next(SubGhz* subghz) {
}
// Update progress info
- string_t progress_str;
- string_init(progress_str);
+ FuriString* progress_str;
+ progress_str = furi_string_alloc();
subghz_file_encoder_worker_get_text_progress(file_worker_encoder, progress_str);
- subghz_view_receiver_add_data_progress(subghz->subghz_receiver, string_get_cstr(progress_str));
+ subghz_view_receiver_add_data_progress(
+ subghz->subghz_receiver, furi_string_get_cstr(progress_str));
- string_clear(progress_str);
+ furi_string_free(progress_str);
return true; // More samples available
}
@@ -164,8 +165,8 @@ bool subghz_scene_decode_raw_next(SubGhz* subghz) {
void subghz_scene_decode_raw_on_enter(void* context) {
SubGhz* subghz = context;
- string_t str_buff;
- string_init(str_buff);
+ FuriString* str_buff;
+ str_buff = furi_string_alloc();
subghz_view_receiver_set_lock(subghz->subghz_receiver, subghz->lock);
subghz_view_receiver_set_mode(subghz->subghz_receiver, SubGhzViewReceiverModeFile);
@@ -193,14 +194,14 @@ void subghz_scene_decode_raw_on_enter(void* context) {
//Load history to receiver
subghz_view_receiver_exit(subghz->subghz_receiver);
for(uint8_t i = 0; i < subghz_history_get_item(subghz->txrx->history); i++) {
- string_reset(str_buff);
+ furi_string_reset(str_buff);
subghz_history_get_text_item_menu(subghz->txrx->history, str_buff, i);
subghz_view_receiver_add_item_to_menu(
subghz->subghz_receiver,
- string_get_cstr(str_buff),
+ furi_string_get_cstr(str_buff),
subghz_history_get_type_protocol(subghz->txrx->history, i));
}
- string_clear(str_buff);
+ furi_string_free(str_buff);
subghz_view_receiver_set_idx_menu(subghz->subghz_receiver, subghz->txrx->idx_menu_chosen);
}
diff --git a/applications/main/subghz/scenes/subghz_scene_delete.c b/applications/main/subghz/scenes/subghz_scene_delete.c
index 43151de20..94814b143 100644
--- a/applications/main/subghz/scenes/subghz_scene_delete.c
+++ b/applications/main/subghz/scenes/subghz_scene_delete.c
@@ -11,17 +11,23 @@ void subghz_scene_delete_callback(GuiButtonType result, InputType type, void* co
void subghz_scene_delete_on_enter(void* context) {
SubGhz* subghz = context;
- string_t frequency_str;
- string_t modulation_str;
- string_t text;
+ FuriString* frequency_str;
+ FuriString* modulation_str;
+ FuriString* text;
- string_init(frequency_str);
- string_init(modulation_str);
- string_init(text);
+ frequency_str = furi_string_alloc();
+ modulation_str = furi_string_alloc();
+ text = furi_string_alloc();
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
widget_add_string_element(
- subghz->widget, 78, 0, AlignLeft, AlignTop, FontSecondary, string_get_cstr(frequency_str));
+ subghz->widget,
+ 78,
+ 0,
+ AlignLeft,
+ AlignTop,
+ FontSecondary,
+ furi_string_get_cstr(frequency_str));
widget_add_string_element(
subghz->widget,
@@ -30,14 +36,14 @@ void subghz_scene_delete_on_enter(void* context) {
AlignLeft,
AlignTop,
FontSecondary,
- string_get_cstr(modulation_str));
+ furi_string_get_cstr(modulation_str));
subghz_protocol_decoder_base_get_string(subghz->txrx->decoder_result, text);
widget_add_string_multiline_element(
- subghz->widget, 0, 0, AlignLeft, AlignTop, FontSecondary, string_get_cstr(text));
+ subghz->widget, 0, 0, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(text));
- string_clear(frequency_str);
- string_clear(modulation_str);
- string_clear(text);
+ furi_string_free(frequency_str);
+ furi_string_free(modulation_str);
+ furi_string_free(text);
widget_add_button_element(
subghz->widget, GuiButtonTypeRight, "Delete", subghz_scene_delete_callback, subghz);
@@ -49,7 +55,7 @@ bool subghz_scene_delete_on_event(void* context, SceneManagerEvent event) {
SubGhz* subghz = context;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubGhzCustomEventSceneDelete) {
- string_set(subghz->file_path_tmp, subghz->file_path);
+ furi_string_set(subghz->file_path_tmp, subghz->file_path);
if(subghz_delete_file(subghz)) {
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDeleteSuccess);
} else {
diff --git a/applications/main/subghz/scenes/subghz_scene_delete_raw.c b/applications/main/subghz/scenes/subghz_scene_delete_raw.c
index a20968d5b..fa4fc6f64 100644
--- a/applications/main/subghz/scenes/subghz_scene_delete_raw.c
+++ b/applications/main/subghz/scenes/subghz_scene_delete_raw.c
@@ -15,18 +15,18 @@ void subghz_scene_delete_raw_callback(GuiButtonType result, InputType type, void
void subghz_scene_delete_raw_on_enter(void* context) {
SubGhz* subghz = context;
- string_t frequency_str;
- string_t modulation_str;
+ FuriString* frequency_str;
+ FuriString* modulation_str;
- string_init(frequency_str);
- string_init(modulation_str);
+ frequency_str = furi_string_alloc();
+ modulation_str = furi_string_alloc();
char delete_str[SUBGHZ_MAX_LEN_NAME + 16];
- string_t file_name;
- string_init(file_name);
+ FuriString* file_name;
+ file_name = furi_string_alloc();
path_extract_filename(subghz->file_path, file_name, true);
- snprintf(delete_str, sizeof(delete_str), "\e#Delete %s?\e#", string_get_cstr(file_name));
- string_clear(file_name);
+ snprintf(delete_str, sizeof(delete_str), "\e#Delete %s?\e#", furi_string_get_cstr(file_name));
+ furi_string_free(file_name);
widget_add_text_box_element(
subghz->widget, 0, 0, 128, 23, AlignCenter, AlignCenter, delete_str, false);
@@ -35,7 +35,13 @@ void subghz_scene_delete_raw_on_enter(void* context) {
subghz->widget, 38, 25, AlignLeft, AlignTop, FontSecondary, "RAW signal");
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
widget_add_string_element(
- subghz->widget, 35, 37, AlignLeft, AlignTop, FontSecondary, string_get_cstr(frequency_str));
+ subghz->widget,
+ 35,
+ 37,
+ AlignLeft,
+ AlignTop,
+ FontSecondary,
+ furi_string_get_cstr(frequency_str));
widget_add_string_element(
subghz->widget,
@@ -44,10 +50,10 @@ void subghz_scene_delete_raw_on_enter(void* context) {
AlignLeft,
AlignTop,
FontSecondary,
- string_get_cstr(modulation_str));
+ furi_string_get_cstr(modulation_str));
- string_clear(frequency_str);
- string_clear(modulation_str);
+ furi_string_free(frequency_str);
+ furi_string_free(modulation_str);
widget_add_button_element(
subghz->widget, GuiButtonTypeRight, "Delete", subghz_scene_delete_raw_callback, subghz);
@@ -61,7 +67,7 @@ bool subghz_scene_delete_raw_on_event(void* context, SceneManagerEvent event) {
SubGhz* subghz = context;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubGhzCustomEventSceneDeleteRAW) {
- string_set(subghz->file_path_tmp, subghz->file_path);
+ furi_string_set(subghz->file_path_tmp, subghz->file_path);
if(subghz_delete_file(subghz)) {
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDeleteSuccess);
} else {
diff --git a/applications/main/subghz/scenes/subghz_scene_delete_success.c b/applications/main/subghz/scenes/subghz_scene_delete_success.c
index d6e1f8dd4..9a07be5f5 100644
--- a/applications/main/subghz/scenes/subghz_scene_delete_success.c
+++ b/applications/main/subghz/scenes/subghz_scene_delete_success.c
@@ -31,7 +31,7 @@ bool subghz_scene_delete_success_on_event(void* context, SceneManagerEvent event
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW);
} else if(scene_manager_search_and_switch_to_previous_scene(
subghz->scene_manager, SubGhzSceneSaved)) {
- scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaved);
+ //scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaved);
} else {
scene_manager_search_and_switch_to_previous_scene(
subghz->scene_manager, SubGhzSceneStart);
diff --git a/applications/main/subghz/scenes/subghz_scene_frequency_analyzer.c b/applications/main/subghz/scenes/subghz_scene_frequency_analyzer.c
index a78fccd3f..8889dac83 100644
--- a/applications/main/subghz/scenes/subghz_scene_frequency_analyzer.c
+++ b/applications/main/subghz/scenes/subghz_scene_frequency_analyzer.c
@@ -1,6 +1,8 @@
#include "../subghz_i.h"
#include
+#define TAG "SubGhzSceneFrequencyAnalyzer"
+
void subghz_scene_frequency_analyzer_callback(SubGhzCustomEvent event, void* context) {
furi_assert(context);
SubGhz* subghz = context;
@@ -17,16 +19,24 @@ void subghz_scene_frequency_analyzer_on_enter(void* context) {
bool subghz_scene_frequency_analyzer_on_event(void* context, SceneManagerEvent event) {
SubGhz* subghz = context;
- if(event.type == SceneManagerEventTypeCustom &&
- event.event == SubGhzCustomEventViewReceiverOK) {
- uint32_t frequency =
- subghz_frequency_analyzer_get_frequency_to_save(subghz->subghz_frequency_analyzer);
- if(frequency > 0) {
- subghz->last_settings->frequency = frequency;
- subghz_last_settings_save(subghz->last_settings);
- }
+ if(event.type == SceneManagerEventTypeCustom) {
+ if(event.event == SubGhzCustomEventViewReceiverOK) {
+ uint32_t frequency =
+ subghz_frequency_analyzer_get_frequency_to_save(subghz->subghz_frequency_analyzer);
+ if(frequency > 0) {
+ subghz->last_settings->frequency = frequency;
+ subghz_last_settings_save(subghz->last_settings);
+ }
- return true;
+ return true;
+ } else if(event.event == SubGhzCustomEventViewReceiverUnlock) {
+ // Don't need to save, we already saved on short event
+#ifdef FURI_DEBUG
+ FURI_LOG_W(TAG, "Goto next scene!");
+#endif
+ scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiver);
+ return true;
+ }
}
return false;
}
diff --git a/applications/main/subghz/scenes/subghz_scene_more_raw.c b/applications/main/subghz/scenes/subghz_scene_more_raw.c
index 7c1b8f7bf..f90d95de6 100644
--- a/applications/main/subghz/scenes/subghz_scene_more_raw.c
+++ b/applications/main/subghz/scenes/subghz_scene_more_raw.c
@@ -53,7 +53,7 @@ bool subghz_scene_more_raw_on_event(void* context, SceneManagerEvent event) {
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDeleteRAW);
return true;
} else if(event.event == SubmenuIndexEdit) {
- string_reset(subghz->file_path_tmp);
+ furi_string_reset(subghz->file_path_tmp);
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneMoreRAW, SubmenuIndexEdit);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
diff --git a/applications/main/subghz/scenes/subghz_scene_read_raw.c b/applications/main/subghz/scenes/subghz_scene_read_raw.c
index 7392221dc..a518c3594 100644
--- a/applications/main/subghz/scenes/subghz_scene_read_raw.c
+++ b/applications/main/subghz/scenes/subghz_scene_read_raw.c
@@ -10,8 +10,8 @@
bool subghz_scene_read_raw_update_filename(SubGhz* subghz) {
bool ret = false;
//set the path to read the file
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
do {
if(!flipper_format_rewind(subghz->txrx->fff_data)) {
FURI_LOG_E(TAG, "Rewind error");
@@ -23,12 +23,12 @@ bool subghz_scene_read_raw_update_filename(SubGhz* subghz) {
break;
}
- string_set(subghz->file_path, temp_str);
+ furi_string_set(subghz->file_path, temp_str);
ret = true;
} while(false);
- string_clear(temp_str);
+ furi_string_free(temp_str);
return ret;
}
@@ -36,18 +36,20 @@ static void subghz_scene_read_raw_update_statusbar(void* context) {
furi_assert(context);
SubGhz* subghz = context;
- string_t frequency_str;
- string_t modulation_str;
+ FuriString* frequency_str;
+ FuriString* modulation_str;
- string_init(frequency_str);
- string_init(modulation_str);
+ frequency_str = furi_string_alloc();
+ modulation_str = furi_string_alloc();
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
subghz_read_raw_add_data_statusbar(
- subghz->subghz_read_raw, string_get_cstr(frequency_str), string_get_cstr(modulation_str));
+ subghz->subghz_read_raw,
+ furi_string_get_cstr(frequency_str),
+ furi_string_get_cstr(modulation_str));
- string_clear(frequency_str);
- string_clear(modulation_str);
+ furi_string_free(frequency_str);
+ furi_string_free(modulation_str);
}
void subghz_scene_read_raw_callback(SubGhzCustomEvent event, void* context) {
@@ -65,8 +67,8 @@ void subghz_scene_read_raw_callback_end_tx(void* context) {
void subghz_scene_read_raw_on_enter(void* context) {
SubGhz* subghz = context;
- string_t file_name;
- string_init(file_name);
+ FuriString* file_name;
+ file_name = furi_string_alloc();
switch(subghz->txrx->rx_key_state) {
case SubGhzRxKeyStateBack:
@@ -75,13 +77,15 @@ void subghz_scene_read_raw_on_enter(void* context) {
case SubGhzRxKeyStateRAWLoad:
path_extract_filename(subghz->file_path, file_name, true);
subghz_read_raw_set_status(
- subghz->subghz_read_raw, SubGhzReadRAWStatusLoadKeyTX, string_get_cstr(file_name));
+ subghz->subghz_read_raw,
+ SubGhzReadRAWStatusLoadKeyTX,
+ furi_string_get_cstr(file_name));
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
break;
case SubGhzRxKeyStateRAWSave:
path_extract_filename(subghz->file_path, file_name, true);
subghz_read_raw_set_status(
- subghz->subghz_read_raw, SubGhzReadRAWStatusSaveKey, string_get_cstr(file_name));
+ subghz->subghz_read_raw, SubGhzReadRAWStatusSaveKey, furi_string_get_cstr(file_name));
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
break;
default:
@@ -89,7 +93,7 @@ void subghz_scene_read_raw_on_enter(void* context) {
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
break;
}
- string_clear(file_name);
+ furi_string_free(file_name);
subghz_scene_read_raw_update_statusbar(subghz);
//set callback view raw
@@ -134,12 +138,22 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving);
} else {
//Restore default setting
- subghz_preset_init(
- subghz,
- subghz_setting_get_preset_name(subghz->setting, subghz->last_settings->preset),
- subghz->last_settings->frequency,
- NULL,
- 0);
+ if(subghz->raw_send_only) {
+ subghz_preset_init(
+ subghz,
+ "AM650",
+ subghz_setting_get_default_frequency(subghz->setting),
+ NULL,
+ 0);
+ } else {
+ subghz_preset_init(
+ subghz,
+ subghz_setting_get_preset_name(
+ subghz->setting, subghz->last_settings->preset),
+ subghz->last_settings->frequency,
+ NULL,
+ 0);
+ }
if(!scene_manager_search_and_switch_to_previous_scene(
subghz->scene_manager, SubGhzSceneSaved)) {
if(!scene_manager_search_and_switch_to_previous_scene(
@@ -177,7 +191,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
case SubGhzCustomEventViewReadRAWErase:
if(subghz->txrx->rx_key_state == SubGhzRxKeyStateAddKey) {
if(subghz_scene_read_raw_update_filename(subghz)) {
- string_set(subghz->file_path_tmp, subghz->file_path);
+ furi_string_set(subghz->file_path_tmp, subghz->file_path);
subghz_delete_file(subghz);
}
}
@@ -248,12 +262,13 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
subghz_protocol_raw_save_to_file_stop(
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result);
- string_t temp_str;
- string_init(temp_str);
- string_printf(
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
+ furi_string_printf(
temp_str, "%s/%s%s", SUBGHZ_RAW_FOLDER, RAW_FILE_NAME, SUBGHZ_APP_EXTENSION);
- subghz_protocol_raw_gen_fff_data(subghz->txrx->fff_data, string_get_cstr(temp_str));
- string_clear(temp_str);
+ subghz_protocol_raw_gen_fff_data(
+ subghz->txrx->fff_data, furi_string_get_cstr(temp_str));
+ furi_string_free(temp_str);
if(spl_count > 0) {
notification_message(subghz->notifications, &sequence_set_green_255);
@@ -282,13 +297,14 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
subghz_begin(
subghz,
subghz_setting_get_preset_data_by_name(
- subghz->setting, string_get_cstr(subghz->txrx->preset->name)));
+ subghz->setting,
+ furi_string_get_cstr(subghz->txrx->preset->name)));
subghz_rx(subghz, subghz->txrx->preset->frequency);
}
subghz->state_notifications = SubGhzNotificationStateRx;
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;
} else {
- string_set_str(subghz->error_str, "Function requires\nan SD card.");
+ furi_string_set(subghz->error_str, "Function requires\nan SD card.");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
}
}
@@ -340,6 +356,10 @@ void subghz_scene_read_raw_on_exit(void* context) {
subghz->state_notifications = SubGhzNotificationStateIDLE;
notification_message(subghz->notifications, &sequence_reset_rgb);
- //filter restoration
+//filter restoration
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+ subghz_last_settings_set_detect_raw_values(subghz);
+#else
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable);
+#endif
}
\ No newline at end of file
diff --git a/applications/main/subghz/scenes/subghz_scene_receiver.c b/applications/main/subghz/scenes/subghz_scene_receiver.c
index 4a35c5f2c..8333f5343 100644
--- a/applications/main/subghz/scenes/subghz_scene_receiver.c
+++ b/applications/main/subghz/scenes/subghz_scene_receiver.c
@@ -6,6 +6,8 @@
const NotificationSequence subghz_sequence_rx = {
&message_green_255,
+ &message_display_backlight_on,
+
&message_vibro_on,
&message_note_c6,
&message_delay_50,
@@ -35,31 +37,31 @@ const NotificationSequence subghz_sequence_rx_locked = {
static void subghz_scene_receiver_update_statusbar(void* context) {
SubGhz* subghz = context;
- string_t history_stat_str;
- string_init(history_stat_str);
+ FuriString* history_stat_str;
+ history_stat_str = furi_string_alloc();
if(!subghz_history_get_text_space_left(subghz->txrx->history, history_stat_str)) {
- string_t frequency_str;
- string_t modulation_str;
+ FuriString* frequency_str;
+ FuriString* modulation_str;
- string_init(frequency_str);
- string_init(modulation_str);
+ frequency_str = furi_string_alloc();
+ modulation_str = furi_string_alloc();
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
subghz_view_receiver_add_data_statusbar(
subghz->subghz_receiver,
- string_get_cstr(frequency_str),
- string_get_cstr(modulation_str),
- string_get_cstr(history_stat_str));
+ furi_string_get_cstr(frequency_str),
+ furi_string_get_cstr(modulation_str),
+ furi_string_get_cstr(history_stat_str));
- string_clear(frequency_str);
- string_clear(modulation_str);
+ furi_string_free(frequency_str);
+ furi_string_free(modulation_str);
} else {
subghz_view_receiver_add_data_statusbar(
- subghz->subghz_receiver, string_get_cstr(history_stat_str), "", "");
+ subghz->subghz_receiver, furi_string_get_cstr(history_stat_str), "", "");
subghz->state_notifications = SubGhzNotificationStateIDLE;
}
- string_clear(history_stat_str);
+ furi_string_free(history_stat_str);
}
void subghz_scene_receiver_callback(SubGhzCustomEvent event, void* context) {
@@ -74,11 +76,11 @@ static void subghz_scene_add_to_history_callback(
void* context) {
furi_assert(context);
SubGhz* subghz = context;
- string_t str_buff;
- string_init(str_buff);
+ FuriString* str_buff;
+ str_buff = furi_string_alloc();
if(subghz_history_add_to_history(subghz->txrx->history, decoder_base, subghz->txrx->preset)) {
- string_reset(str_buff);
+ furi_string_reset(str_buff);
subghz->state_notifications = SubGhzNotificationStateRxDone;
@@ -86,22 +88,22 @@ static void subghz_scene_add_to_history_callback(
subghz->txrx->history, str_buff, subghz_history_get_item(subghz->txrx->history) - 1);
subghz_view_receiver_add_item_to_menu(
subghz->subghz_receiver,
- string_get_cstr(str_buff),
+ furi_string_get_cstr(str_buff),
subghz_history_get_type_protocol(
subghz->txrx->history, subghz_history_get_item(subghz->txrx->history) - 1));
subghz_scene_receiver_update_statusbar(subghz);
}
subghz_receiver_reset(receiver);
- string_clear(str_buff);
+ furi_string_free(str_buff);
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;
}
void subghz_scene_receiver_on_enter(void* context) {
SubGhz* subghz = context;
- string_t str_buff;
- string_init(str_buff);
+ FuriString* str_buff;
+ str_buff = furi_string_alloc();
if(subghz->txrx->rx_key_state == SubGhzRxKeyStateIDLE) {
subghz_preset_init(
@@ -120,15 +122,15 @@ void subghz_scene_receiver_on_enter(void* context) {
//Load history to receiver
subghz_view_receiver_exit(subghz->subghz_receiver);
for(uint8_t i = 0; i < subghz_history_get_item(subghz->txrx->history); i++) {
- string_reset(str_buff);
+ furi_string_reset(str_buff);
subghz_history_get_text_item_menu(subghz->txrx->history, str_buff, i);
subghz_view_receiver_add_item_to_menu(
subghz->subghz_receiver,
- string_get_cstr(str_buff),
+ furi_string_get_cstr(str_buff),
subghz_history_get_type_protocol(subghz->txrx->history, i));
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;
}
- string_clear(str_buff);
+ furi_string_free(str_buff);
subghz_scene_receiver_update_statusbar(subghz);
subghz_view_receiver_set_callback(
subghz->subghz_receiver, subghz_scene_receiver_callback, subghz);
@@ -144,7 +146,7 @@ void subghz_scene_receiver_on_enter(void* context) {
subghz_begin(
subghz,
subghz_setting_get_preset_data_by_name(
- subghz->setting, string_get_cstr(subghz->txrx->preset->name)));
+ subghz->setting, furi_string_get_cstr(subghz->txrx->preset->name)));
subghz_rx(subghz, subghz->txrx->preset->frequency);
}
subghz_view_receiver_set_idx_menu(subghz->subghz_receiver, subghz->txrx->idx_menu_chosen);
@@ -185,6 +187,7 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
consumed = true;
break;
case SubGhzCustomEventViewReceiverOK:
+ // Show file info, scene: receiver_info
subghz->txrx->idx_menu_chosen =
subghz_view_receiver_get_idx_menu(subghz->subghz_receiver);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverInfo);
diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_config.c b/applications/main/subghz/scenes/subghz_scene_receiver_config.c
index 0175cd0fd..ab5cde516 100644
--- a/applications/main/subghz/scenes/subghz_scene_receiver_config.c
+++ b/applications/main/subghz/scenes/subghz_scene_receiver_config.c
@@ -29,10 +29,12 @@ const char* const detect_raw_text[DETECT_RAW_COUNT] = {
"ON",
};
+#ifndef SUBGHZ_SAVE_DETECT_RAW_SETTING
const SubGhzProtocolFlag detect_raw_value[DETECT_RAW_COUNT] = {
SubGhzProtocolFlag_Decodable,
SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_RAW,
};
+#endif
#define RSSI_THRESHOLD_COUNT 7
const char* const rssi_threshold_text[RSSI_THRESHOLD_COUNT] = {
@@ -105,6 +107,7 @@ uint8_t subghz_scene_receiver_config_hopper_value_index(
}
}
+#ifndef SUBGHZ_SAVE_DETECT_RAW_SETTING
uint8_t subghz_scene_receiver_config_detect_raw_value_index(
const SubGhzProtocolFlag value,
const SubGhzProtocolFlag values[],
@@ -118,6 +121,7 @@ uint8_t subghz_scene_receiver_config_detect_raw_value_index(
}
return index;
}
+#endif
uint8_t subghz_scene_receiver_config_rssi_threshold_value_index(
const int value,
@@ -185,49 +189,64 @@ static void subghz_scene_receiver_config_set_detect_raw(VariableItem* item) {
SubGhz* subghz = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
- variable_item_set_current_value_text(item, detect_raw_text[index]);
- subghz_receiver_set_filter(subghz->txrx->receiver, detect_raw_value[index]);
+ if(subghz->txrx->hopper_state == 0) {
+ variable_item_set_current_value_text(item, detect_raw_text[index]);
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+ subghz->last_settings->detect_raw = index;
- subghz_protocol_decoder_raw_set_auto_mode(
- subghz_receiver_search_decoder_base_by_name(
- subghz->txrx->receiver, SUBGHZ_PROTOCOL_RAW_NAME),
- (index == 1));
+ subghz_last_settings_set_detect_raw_values(subghz);
+#else
+ subghz_receiver_set_filter(subghz->txrx->receiver, detect_raw_value[index]);
+
+ subghz_protocol_decoder_raw_set_auto_mode(
+ subghz_receiver_search_decoder_base_by_name(
+ subghz->txrx->receiver, SUBGHZ_PROTOCOL_RAW_NAME),
+ (index == 1));
+#endif
+ } else {
+ variable_item_set_current_value_index(item, 0);
+ }
}
static void subghz_scene_receiver_config_set_hopping_running(VariableItem* item) {
SubGhz* subghz = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
- variable_item_set_current_value_text(item, hopping_text[index]);
- if(hopping_value[index] == SubGhzHopperStateOFF) {
- char text_buf[10] = {0};
- snprintf(
- text_buf,
- sizeof(text_buf),
- "%lu.%02lu",
- subghz_setting_get_default_frequency(subghz->setting) / 1000000,
- (subghz_setting_get_default_frequency(subghz->setting) % 1000000) / 10000);
- variable_item_set_current_value_text(
- (VariableItem*)scene_manager_get_scene_state(
- subghz->scene_manager, SubGhzSceneReceiverConfig),
- text_buf);
- subghz->txrx->preset->frequency = subghz_setting_get_default_frequency(subghz->setting);
- variable_item_set_current_value_index(
- (VariableItem*)scene_manager_get_scene_state(
- subghz->scene_manager, SubGhzSceneReceiverConfig),
- subghz_setting_get_frequency_default_index(subghz->setting));
- } else {
- variable_item_set_current_value_text(
- (VariableItem*)scene_manager_get_scene_state(
- subghz->scene_manager, SubGhzSceneReceiverConfig),
- " -----");
- variable_item_set_current_value_index(
- (VariableItem*)scene_manager_get_scene_state(
- subghz->scene_manager, SubGhzSceneReceiverConfig),
- subghz_setting_get_frequency_default_index(subghz->setting));
- }
+ if(subghz_receiver_get_filter(subghz->txrx->receiver) == SubGhzProtocolFlag_Decodable) {
+ variable_item_set_current_value_text(item, hopping_text[index]);
+ if(hopping_value[index] == SubGhzHopperStateOFF) {
+ char text_buf[10] = {0};
+ snprintf(
+ text_buf,
+ sizeof(text_buf),
+ "%lu.%02lu",
+ subghz_setting_get_default_frequency(subghz->setting) / 1000000,
+ (subghz_setting_get_default_frequency(subghz->setting) % 1000000) / 10000);
+ variable_item_set_current_value_text(
+ (VariableItem*)scene_manager_get_scene_state(
+ subghz->scene_manager, SubGhzSceneReceiverConfig),
+ text_buf);
+ subghz->txrx->preset->frequency =
+ subghz_setting_get_default_frequency(subghz->setting);
+ variable_item_set_current_value_index(
+ (VariableItem*)scene_manager_get_scene_state(
+ subghz->scene_manager, SubGhzSceneReceiverConfig),
+ subghz_setting_get_frequency_default_index(subghz->setting));
+ } else {
+ variable_item_set_current_value_text(
+ (VariableItem*)scene_manager_get_scene_state(
+ subghz->scene_manager, SubGhzSceneReceiverConfig),
+ " -----");
+ variable_item_set_current_value_index(
+ (VariableItem*)scene_manager_get_scene_state(
+ subghz->scene_manager, SubGhzSceneReceiverConfig),
+ subghz_setting_get_frequency_default_index(subghz->setting));
+ }
- subghz->txrx->hopper_state = hopping_value[index];
+ subghz->txrx->hopper_state = hopping_value[index];
+ } else {
+ variable_item_set_current_value_index(item, 0);
+ }
}
static void subghz_scene_receiver_config_var_list_enter_callback(void* context, uint32_t index) {
@@ -244,10 +263,10 @@ void subghz_scene_receiver_config_on_enter(void* context) {
VariableItem* item;
uint8_t value_index;
-#if FURI_DEBUG
+#ifdef FURI_DEBUG
FURI_LOG_D(
TAG,
- "last frequency: %d, preset: %d",
+ "Last frequency: %ld, Preset: %ld",
subghz->last_settings->frequency,
subghz->last_settings->preset);
#endif
@@ -278,7 +297,7 @@ void subghz_scene_receiver_config_on_enter(void* context) {
subghz_scene_receiver_config_set_preset,
subghz);
value_index = subghz_scene_receiver_config_next_preset(
- string_get_cstr(subghz->txrx->preset->name), subghz);
+ furi_string_get_cstr(subghz->txrx->preset->name), subghz);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(
item, subghz_setting_get_preset_name(subghz->setting, value_index));
@@ -304,10 +323,14 @@ void subghz_scene_receiver_config_on_enter(void* context) {
DETECT_RAW_COUNT,
subghz_scene_receiver_config_set_detect_raw,
subghz);
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+ value_index = subghz->last_settings->detect_raw;
+#else
value_index = subghz_scene_receiver_config_detect_raw_value_index(
subghz_receiver_get_filter(subghz->txrx->receiver),
detect_raw_value,
DETECT_RAW_COUNT);
+#endif
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, detect_raw_text[value_index]);
diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_info.c b/applications/main/subghz/scenes/subghz_scene_receiver_info.c
index 5621bb847..516e63494 100644
--- a/applications/main/subghz/scenes/subghz_scene_receiver_info.c
+++ b/applications/main/subghz/scenes/subghz_scene_receiver_info.c
@@ -26,6 +26,7 @@ static bool subghz_scene_receiver_info_update_parser(void* context) {
subghz->txrx->receiver,
subghz_history_get_protocol_name(subghz->txrx->history, subghz->txrx->idx_menu_chosen));
if(subghz->txrx->decoder_result) {
+ // In this case flipper format was changed to short file content
subghz_protocol_decoder_base_deserialize(
subghz->txrx->decoder_result,
subghz_history_get_raw_data(subghz->txrx->history, subghz->txrx->idx_menu_chosen));
@@ -34,7 +35,7 @@ static bool subghz_scene_receiver_info_update_parser(void* context) {
subghz_history_get_preset_def(subghz->txrx->history, subghz->txrx->idx_menu_chosen);
subghz_preset_init(
subghz,
- string_get_cstr(preset->name),
+ furi_string_get_cstr(preset->name),
preset->frequency,
preset->data,
preset->data_size);
@@ -46,13 +47,13 @@ static bool subghz_scene_receiver_info_update_parser(void* context) {
void subghz_scene_receiver_info_draw_widget(SubGhz* subghz) {
if(subghz_scene_receiver_info_update_parser(subghz)) {
- string_t frequency_str;
- string_t modulation_str;
- string_t text;
+ FuriString* frequency_str;
+ FuriString* modulation_str;
+ FuriString* text;
- string_init(frequency_str);
- string_init(modulation_str);
- string_init(text);
+ frequency_str = furi_string_alloc();
+ modulation_str = furi_string_alloc();
+ text = furi_string_alloc();
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
widget_add_string_element(
@@ -62,7 +63,7 @@ void subghz_scene_receiver_info_draw_widget(SubGhz* subghz) {
AlignLeft,
AlignTop,
FontSecondary,
- string_get_cstr(frequency_str));
+ furi_string_get_cstr(frequency_str));
widget_add_string_element(
subghz->widget,
@@ -71,14 +72,14 @@ void subghz_scene_receiver_info_draw_widget(SubGhz* subghz) {
AlignLeft,
AlignTop,
FontSecondary,
- string_get_cstr(modulation_str));
+ furi_string_get_cstr(modulation_str));
subghz_protocol_decoder_base_get_string(subghz->txrx->decoder_result, text);
widget_add_string_multiline_element(
- subghz->widget, 0, 0, AlignLeft, AlignTop, FontSecondary, string_get_cstr(text));
+ subghz->widget, 0, 0, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(text));
- string_clear(frequency_str);
- string_clear(modulation_str);
- string_clear(text);
+ furi_string_free(frequency_str);
+ furi_string_free(modulation_str);
+ furi_string_free(text);
if((subghz->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) ==
SubGhzProtocolFlag_Save) {
@@ -159,7 +160,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
subghz_begin(
subghz,
subghz_setting_get_preset_data_by_name(
- subghz->setting, string_get_cstr(subghz->txrx->preset->name)));
+ subghz->setting, furi_string_get_cstr(subghz->txrx->preset->name)));
subghz_rx(subghz, subghz->txrx->preset->frequency);
}
if(subghz->txrx->hopper_state == SubGhzHopperStatePause) {
diff --git a/applications/main/subghz/scenes/subghz_scene_rpc.c b/applications/main/subghz/scenes/subghz_scene_rpc.c
index 652499d05..4ccc15f9e 100644
--- a/applications/main/subghz/scenes/subghz_scene_rpc.c
+++ b/applications/main/subghz/scenes/subghz_scene_rpc.c
@@ -1,4 +1,6 @@
#include "../subghz_i.h"
+#include
+#include
typedef enum {
SubGhzRpcStateIdle,
@@ -61,20 +63,20 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
if(subghz_key_load(subghz, arg, false)) {
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneRpc, SubGhzRpcStateLoaded);
- string_set_str(subghz->file_path, arg);
+ furi_string_set(subghz->file_path, arg);
result = true;
- string_t file_name;
- string_init(file_name);
+ FuriString* file_name;
+ file_name = furi_string_alloc();
path_extract_filename(subghz->file_path, file_name, true);
snprintf(
subghz->file_name_tmp,
SUBGHZ_MAX_LEN_NAME,
"loaded\n%s",
- string_get_cstr(file_name));
+ furi_string_get_cstr(file_name));
popup_set_text(popup, subghz->file_name_tmp, 89, 44, AlignCenter, AlignTop);
- string_clear(file_name);
+ furi_string_free(file_name);
}
}
rpc_system_app_confirm(subghz->rpc_ctx, RpcAppEventLoadFile, result);
@@ -97,4 +99,9 @@ void subghz_scene_rpc_on_exit(void* context) {
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
popup_set_icon(popup, 0, 0, NULL);
+
+ keeloq_reset_mfname();
+ keeloq_reset_kl_type();
+ star_line_reset_mfname();
+ star_line_reset_kl_type();
}
diff --git a/applications/main/subghz/scenes/subghz_scene_save_name.c b/applications/main/subghz/scenes/subghz_scene_save_name.c
index 4b779228d..99596e983 100644
--- a/applications/main/subghz/scenes/subghz_scene_save_name.c
+++ b/applications/main/subghz/scenes/subghz_scene_save_name.c
@@ -1,12 +1,11 @@
#include "../subghz_i.h"
-#include "m-string.h"
#include "subghz/types.h"
#include
#include "../helpers/subghz_custom_event.h"
#include
#include
-#define MAX_TEXT_INPUT_LEN 22
+#define MAX_TEXT_INPUT_LEN 23
void subghz_scene_save_name_text_input_callback(void* context) {
furi_assert(context);
@@ -14,20 +13,18 @@ void subghz_scene_save_name_text_input_callback(void* context) {
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneSaveName);
}
-void subghz_scene_save_name_get_timefilename(string_t name, uint32_t frequency) {
+void subghz_scene_save_name_get_timefilename(FuriString* name) {
FuriHalRtcDateTime datetime = {0};
furi_hal_rtc_get_datetime(&datetime);
- string_printf(
+ furi_string_printf(
name,
- "RAW_%.4d.%.2d.%.2d-%.2d.%.2d.%.2d-%d.%.2dMHz",
+ "RAW_%.4d.%.2d.%.2d-%.2d.%.2d.%.2d",
datetime.year,
datetime.month,
datetime.day,
datetime.hour,
datetime.minute,
- datetime.second,
- frequency / 1000000,
- (frequency / 10000) % 100);
+ datetime.second);
}
void subghz_scene_save_name_on_enter(void* context) {
@@ -37,35 +34,35 @@ void subghz_scene_save_name_on_enter(void* context) {
TextInput* text_input = subghz->text_input;
bool dev_name_empty = false;
- string_t file_name;
- string_t dir_name;
- string_init(file_name);
- string_init(dir_name);
+ FuriString* file_name;
+ FuriString* dir_name;
+ file_name = furi_string_alloc();
+ dir_name = furi_string_alloc();
if(!subghz_path_is_file(subghz->file_path)) {
char file_name_buf[SUBGHZ_MAX_LEN_NAME] = {0};
set_random_name(file_name_buf, SUBGHZ_MAX_LEN_NAME);
- string_set_str(file_name, file_name_buf);
- string_set_str(subghz->file_path, SUBGHZ_APP_FOLDER);
+ furi_string_set(file_name, file_name_buf);
+ furi_string_set(subghz->file_path, SUBGHZ_APP_FOLDER);
//highlighting the entire filename by default
dev_name_empty = true;
} else {
- string_set(subghz->file_path_tmp, subghz->file_path);
- path_extract_dirname(string_get_cstr(subghz->file_path), dir_name);
+ furi_string_reset(subghz->file_path_tmp);
+ furi_string_set(subghz->file_path_tmp, subghz->file_path);
+ path_extract_dirname(furi_string_get_cstr(subghz->file_path), dir_name);
path_extract_filename(subghz->file_path, file_name, true);
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
SubGhzCustomEventManagerNoSet) {
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) ==
SubGhzCustomEventManagerSetRAW) {
dev_name_empty = true;
- subghz_scene_save_name_get_timefilename(
- file_name, subghz->txrx->preset->frequency);
+ subghz_scene_save_name_get_timefilename(file_name);
}
}
- string_set(subghz->file_path, dir_name);
+ furi_string_set(subghz->file_path, dir_name);
}
- strncpy(subghz->file_name_tmp, string_get_cstr(file_name), SUBGHZ_MAX_LEN_NAME);
+ strncpy(subghz->file_name_tmp, furi_string_get_cstr(file_name), SUBGHZ_MAX_LEN_NAME);
text_input_set_header_text(text_input, "Name signal");
text_input_set_result_callback(
text_input,
@@ -75,12 +72,12 @@ void subghz_scene_save_name_on_enter(void* context) {
MAX_TEXT_INPUT_LEN, // buffer size
dev_name_empty);
- ValidatorIsFile* validator_is_file =
- validator_is_file_alloc_init(string_get_cstr(subghz->file_path), SUBGHZ_APP_EXTENSION, "");
+ ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
+ furi_string_get_cstr(subghz->file_path), SUBGHZ_APP_EXTENSION, "");
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
- string_clear(file_name);
- string_clear(dir_name);
+ furi_string_free(file_name);
+ furi_string_free(dir_name);
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdTextInput);
}
@@ -88,17 +85,17 @@ void subghz_scene_save_name_on_enter(void* context) {
bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
SubGhz* subghz = context;
if(event.type == SceneManagerEventTypeBack) {
- if(!strcmp(subghz->file_name_tmp, "") ||
+ if(!(strcmp(subghz->file_name_tmp, "") == 0) ||
scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
SubGhzCustomEventManagerNoSet) {
- string_set(subghz->file_path, subghz->file_path_tmp);
+ furi_string_set(subghz->file_path, subghz->file_path_tmp);
}
scene_manager_previous_scene(subghz->scene_manager);
return true;
} else if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubGhzCustomEventSceneSaveName) {
if(strcmp(subghz->file_name_tmp, "")) {
- string_cat_printf(
+ furi_string_cat_printf(
subghz->file_path, "/%s%s", subghz->file_name_tmp, SUBGHZ_APP_EXTENSION);
if(subghz_path_is_file(subghz->file_path_tmp)) {
if(!subghz_rename_file(subghz)) {
@@ -108,7 +105,9 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType) !=
SubGhzCustomEventManagerNoSet) {
subghz_save_protocol_to_file(
- subghz, subghz->txrx->fff_data, string_get_cstr(subghz->file_path));
+ subghz,
+ subghz->txrx->fff_data,
+ furi_string_get_cstr(subghz->file_path));
scene_manager_set_scene_state(
subghz->scene_manager,
SubGhzSceneSetType,
@@ -118,14 +117,14 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
subghz,
subghz_history_get_raw_data(
subghz->txrx->history, subghz->txrx->idx_menu_chosen),
- string_get_cstr(subghz->file_path));
+ furi_string_get_cstr(subghz->file_path));
}
}
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
SubGhzCustomEventManagerNoSet) {
subghz_protocol_raw_gen_fff_data(
- subghz->txrx->fff_data, string_get_cstr(subghz->file_path));
+ subghz->txrx->fff_data, furi_string_get_cstr(subghz->file_path));
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerNoSet);
} else {
@@ -135,7 +134,7 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveSuccess);
return true;
} else {
- string_set_str(subghz->error_str, "No name file");
+ furi_string_set(subghz->error_str, "No name file");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
return true;
}
diff --git a/applications/main/subghz/scenes/subghz_scene_set_seed_bft.c b/applications/main/subghz/scenes/subghz_scene_set_seed_bft.c
index f16d7c951..dcb7e6850 100644
--- a/applications/main/subghz/scenes/subghz_scene_set_seed_bft.c
+++ b/applications/main/subghz/scenes/subghz_scene_set_seed_bft.c
@@ -75,7 +75,7 @@ bool subghz_scene_set_seed_bft_on_event(void* context, SceneManagerEvent event)
subghz_transmitter_free(subghz->txrx->transmitter);
if(!generated_protocol) {
- string_set_str(
+ furi_string_set(
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
}
diff --git a/applications/main/subghz/scenes/subghz_scene_set_seed_faac_433.c b/applications/main/subghz/scenes/subghz_scene_set_seed_faac_433.c
index 39559d4a3..efe16f0b3 100644
--- a/applications/main/subghz/scenes/subghz_scene_set_seed_faac_433.c
+++ b/applications/main/subghz/scenes/subghz_scene_set_seed_faac_433.c
@@ -75,7 +75,7 @@ bool subghz_scene_set_seed_faac_433_on_event(void* context, SceneManagerEvent ev
subghz_transmitter_free(subghz->txrx->transmitter);
if(!generated_protocol) {
- string_set_str(
+ furi_string_set(
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
}
diff --git a/applications/main/subghz/scenes/subghz_scene_set_seed_faac_868.c b/applications/main/subghz/scenes/subghz_scene_set_seed_faac_868.c
index f6815a16b..dd9f45652 100644
--- a/applications/main/subghz/scenes/subghz_scene_set_seed_faac_868.c
+++ b/applications/main/subghz/scenes/subghz_scene_set_seed_faac_868.c
@@ -75,7 +75,7 @@ bool subghz_scene_set_seed_faac_868_on_event(void* context, SceneManagerEvent ev
subghz_transmitter_free(subghz->txrx->transmitter);
if(!generated_protocol) {
- string_set_str(
+ furi_string_set(
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
}
diff --git a/applications/main/subghz/scenes/subghz_scene_set_type.c b/applications/main/subghz/scenes/subghz_scene_set_type.c
index 93734023d..1771c984b 100644
--- a/applications/main/subghz/scenes/subghz_scene_set_type.c
+++ b/applications/main/subghz/scenes/subghz_scene_set_type.c
@@ -28,7 +28,7 @@ bool subghz_scene_set_type_submenu_gen_data_protocol(
subghz_receiver_search_decoder_base_by_name(subghz->txrx->receiver, protocol_name);
if(subghz->txrx->decoder_result == NULL) {
- string_set_str(subghz->error_str, "Protocol not\nfound!");
+ furi_string_set(subghz->error_str, "Protocol not\nfound!");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
return false;
}
@@ -302,7 +302,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
}
subghz_transmitter_free(subghz->txrx->transmitter);
if(!generated_protocol) {
- string_set_str(
+ furi_string_set(
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
}
@@ -326,7 +326,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
}
subghz_transmitter_free(subghz->txrx->transmitter);
if(!generated_protocol) {
- string_set_str(
+ furi_string_set(
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
}
diff --git a/applications/main/subghz/scenes/subghz_scene_show_error.c b/applications/main/subghz/scenes/subghz_scene_show_error.c
index 7b0350bf7..107189cae 100644
--- a/applications/main/subghz/scenes/subghz_scene_show_error.c
+++ b/applications/main/subghz/scenes/subghz_scene_show_error.c
@@ -33,7 +33,7 @@ void subghz_scene_show_error_on_enter(void* context) {
AlignCenter,
AlignCenter,
FontSecondary,
- string_get_cstr(subghz->error_str));
+ furi_string_get_cstr(subghz->error_str));
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneShowError) ==
SubGhzCustomEventManagerSet) {
widget_add_button_element(
@@ -89,6 +89,6 @@ void subghz_scene_show_error_on_exit(void* context) {
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneShowError, SubGhzCustomEventManagerNoSet);
widget_reset(subghz->widget);
- string_reset(subghz->error_str);
+ furi_string_reset(subghz->error_str);
notification_message(subghz->notifications, &sequence_reset_rgb);
}
diff --git a/applications/main/subghz/scenes/subghz_scene_show_error_sub.c b/applications/main/subghz/scenes/subghz_scene_show_error_sub.c
index 74e034323..2720b2b94 100644
--- a/applications/main/subghz/scenes/subghz_scene_show_error_sub.c
+++ b/applications/main/subghz/scenes/subghz_scene_show_error_sub.c
@@ -12,7 +12,7 @@ void subghz_scene_show_error_sub_on_enter(void* context) {
// Setup view
Popup* popup = subghz->popup;
popup_set_icon(popup, 72, 17, &I_DolphinCommon_56x48);
- popup_set_header(popup, string_get_cstr(subghz->error_str), 14, 15, AlignLeft, AlignTop);
+ popup_set_header(popup, furi_string_get_cstr(subghz->error_str), 14, 15, AlignLeft, AlignTop);
popup_set_timeout(popup, 1500);
popup_set_context(popup, subghz);
popup_set_callback(popup, subghz_scene_show_error_sub_popup_callback);
@@ -46,7 +46,7 @@ void subghz_scene_show_error_sub_on_exit(void* context) {
popup_set_context(popup, NULL);
popup_set_timeout(popup, 0);
popup_disable_timeout(popup);
- string_reset(subghz->error_str);
+ furi_string_reset(subghz->error_str);
notification_message(subghz->notifications, &sequence_reset_rgb);
}
diff --git a/applications/main/subghz/scenes/subghz_scene_start.c b/applications/main/subghz/scenes/subghz_scene_start.c
index 35c7ecb9c..cf8cd2499 100644
--- a/applications/main/subghz/scenes/subghz_scene_start.c
+++ b/applications/main/subghz/scenes/subghz_scene_start.c
@@ -21,11 +21,15 @@ void subghz_scene_start_on_enter(void* context) {
if(subghz->state_notifications == SubGhzNotificationStateStarting) {
subghz->state_notifications = SubGhzNotificationStateIDLE;
}
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+ subghz_last_settings_set_detect_raw_values(subghz);
+#else
subghz_protocol_decoder_raw_set_auto_mode(
subghz_receiver_search_decoder_base_by_name(
subghz->txrx->receiver, SUBGHZ_PROTOCOL_RAW_NAME),
false);
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable);
+#endif
submenu_add_item(
subghz->submenu, "Read", SubmenuIndexRead, subghz_scene_start_submenu_callback, subghz);
@@ -93,6 +97,7 @@ bool subghz_scene_start_on_event(void* context, SceneManagerEvent event) {
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexFrequencyAnalyzer);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneFrequencyAnalyzer);
return true;
+
} else if(event.event == SubmenuIndexTest) {
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexTest);
diff --git a/applications/main/subghz/scenes/subghz_scene_test.c b/applications/main/subghz/scenes/subghz_scene_test.c
index 65f9bbdef..fa333edca 100644
--- a/applications/main/subghz/scenes/subghz_scene_test.c
+++ b/applications/main/subghz/scenes/subghz_scene_test.c
@@ -20,11 +20,12 @@ void subghz_scene_test_on_enter(void* context) {
SubmenuIndexCarrier,
subghz_scene_test_submenu_callback,
subghz);
+#if FURI_DEBUG
submenu_add_item(
subghz->submenu, "Packet", SubmenuIndexPacket, subghz_scene_test_submenu_callback, subghz);
submenu_add_item(
subghz->submenu, "Static", SubmenuIndexStatic, subghz_scene_test_submenu_callback, subghz);
-
+#endif
submenu_set_selected_item(
subghz->submenu, scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneTest));
@@ -40,7 +41,9 @@ bool subghz_scene_test_on_event(void* context, SceneManagerEvent event) {
subghz->scene_manager, SubGhzSceneTest, SubmenuIndexCarrier);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTestCarrier);
return true;
- } else if(event.event == SubmenuIndexPacket) {
+ }
+#if FURI_DEBUG
+ else if(event.event == SubmenuIndexPacket) {
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneTest, SubmenuIndexPacket);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTestPacket);
@@ -51,6 +54,7 @@ bool subghz_scene_test_on_event(void* context, SceneManagerEvent event) {
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTestStatic);
return true;
}
+#endif
}
return false;
}
diff --git a/applications/main/subghz/scenes/subghz_scene_test_carrier.c b/applications/main/subghz/scenes/subghz_scene_test_carrier.c
index 9677792ba..2e1ec4d9c 100644
--- a/applications/main/subghz/scenes/subghz_scene_test_carrier.c
+++ b/applications/main/subghz/scenes/subghz_scene_test_carrier.c
@@ -27,4 +27,4 @@ bool subghz_scene_test_carrier_on_event(void* context, SceneManagerEvent event)
void subghz_scene_test_carrier_on_exit(void* context) {
UNUSED(context);
-}
+}
\ No newline at end of file
diff --git a/applications/main/subghz/scenes/subghz_scene_test_packet.c b/applications/main/subghz/scenes/subghz_scene_test_packet.c
index 99f0ab179..4757f9f3a 100644
--- a/applications/main/subghz/scenes/subghz_scene_test_packet.c
+++ b/applications/main/subghz/scenes/subghz_scene_test_packet.c
@@ -1,3 +1,4 @@
+#if FURI_DEBUG
#include "../subghz_i.h"
#include "../views/subghz_test_packet.h"
@@ -28,3 +29,4 @@ bool subghz_scene_test_packet_on_event(void* context, SceneManagerEvent event) {
void subghz_scene_test_packet_on_exit(void* context) {
UNUSED(context);
}
+#endif
\ No newline at end of file
diff --git a/applications/main/subghz/scenes/subghz_scene_test_static.c b/applications/main/subghz/scenes/subghz_scene_test_static.c
index 10e6d02a1..959eb75b8 100644
--- a/applications/main/subghz/scenes/subghz_scene_test_static.c
+++ b/applications/main/subghz/scenes/subghz_scene_test_static.c
@@ -1,3 +1,4 @@
+#if FURI_DEBUG
#include "../subghz_i.h"
#include "../views/subghz_test_static.h"
@@ -28,3 +29,4 @@ bool subghz_scene_test_static_on_event(void* context, SceneManagerEvent event) {
void subghz_scene_test_static_on_exit(void* context) {
UNUSED(context);
}
+#endif
\ No newline at end of file
diff --git a/applications/main/subghz/scenes/subghz_scene_transmitter.c b/applications/main/subghz/scenes/subghz_scene_transmitter.c
index 81d96c33c..2d172de67 100644
--- a/applications/main/subghz/scenes/subghz_scene_transmitter.c
+++ b/applications/main/subghz/scenes/subghz_scene_transmitter.c
@@ -15,13 +15,13 @@ bool subghz_scene_transmitter_update_data_show(void* context) {
SubGhz* subghz = context;
if(subghz->txrx->decoder_result) {
- string_t key_str;
- string_t frequency_str;
- string_t modulation_str;
+ FuriString* key_str;
+ FuriString* frequency_str;
+ FuriString* modulation_str;
- string_init(key_str);
- string_init(frequency_str);
- string_init(modulation_str);
+ key_str = furi_string_alloc();
+ frequency_str = furi_string_alloc();
+ modulation_str = furi_string_alloc();
uint8_t show_button = 0;
subghz_protocol_decoder_base_deserialize(
@@ -36,14 +36,14 @@ bool subghz_scene_transmitter_update_data_show(void* context) {
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
subghz_view_transmitter_add_data_to_show(
subghz->subghz_transmitter,
- string_get_cstr(key_str),
- string_get_cstr(frequency_str),
- string_get_cstr(modulation_str),
+ furi_string_get_cstr(key_str),
+ furi_string_get_cstr(frequency_str),
+ furi_string_get_cstr(modulation_str),
show_button);
- string_clear(frequency_str);
- string_clear(modulation_str);
- string_clear(key_str);
+ furi_string_free(frequency_str);
+ furi_string_free(modulation_str);
+ furi_string_free(key_str);
return true;
}
@@ -96,7 +96,7 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
subghz->scene_manager, SubGhzSceneStart);
return true;
} else if(event.event == SubGhzCustomEventViewTransmitterError) {
- string_set_str(subghz->error_str, "Protocol not\nfound!");
+ furi_string_set(subghz->error_str, "Protocol not\nfound!");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
}
} else if(event.type == SceneManagerEventTypeTick) {
diff --git a/applications/main/subghz/subghz.c b/applications/main/subghz/subghz.c
index 8b9dd399f..df8110ac1 100644
--- a/applications/main/subghz/subghz.c
+++ b/applications/main/subghz/subghz.c
@@ -1,6 +1,5 @@
/* Abandon hope, all ye who enter here. */
-#include
#include
#include
#include "subghz_i.h"
@@ -61,11 +60,11 @@ void subghz_blink_stop(SubGhz* instance) {
notification_message(instance->notifications, &sequence_blink_stop);
}
-SubGhz* subghz_alloc() {
+SubGhz* subghz_alloc(bool alloc_for_tx_only) {
SubGhz* subghz = malloc(sizeof(SubGhz));
- string_init(subghz->file_path);
- string_init(subghz->file_path_tmp);
+ subghz->file_path = furi_string_alloc();
+ subghz->file_path_tmp = furi_string_alloc();
// GUI
subghz->gui = furi_record_open(RECORD_GUI);
@@ -88,38 +87,43 @@ SubGhz* subghz_alloc() {
// Open Notification record
subghz->notifications = furi_record_open(RECORD_NOTIFICATION);
- // SubMenu
- subghz->submenu = submenu_alloc();
- view_dispatcher_add_view(
- subghz->view_dispatcher, SubGhzViewIdMenu, submenu_get_view(subghz->submenu));
-
- // Receiver
- subghz->subghz_receiver = subghz_view_receiver_alloc();
- view_dispatcher_add_view(
- subghz->view_dispatcher,
- SubGhzViewIdReceiver,
- subghz_view_receiver_get_view(subghz->subghz_receiver));
+ if(!alloc_for_tx_only) {
+ // SubMenu
+ subghz->submenu = submenu_alloc();
+ view_dispatcher_add_view(
+ subghz->view_dispatcher, SubGhzViewIdMenu, submenu_get_view(subghz->submenu));
+ // Receiver
+ subghz->subghz_receiver = subghz_view_receiver_alloc();
+ view_dispatcher_add_view(
+ subghz->view_dispatcher,
+ SubGhzViewIdReceiver,
+ subghz_view_receiver_get_view(subghz->subghz_receiver));
+ }
// Popup
subghz->popup = popup_alloc();
view_dispatcher_add_view(
subghz->view_dispatcher, SubGhzViewIdPopup, popup_get_view(subghz->popup));
+ if(!alloc_for_tx_only) {
+ // Text Input
+ subghz->text_input = text_input_alloc();
+ view_dispatcher_add_view(
+ subghz->view_dispatcher,
+ SubGhzViewIdTextInput,
+ text_input_get_view(subghz->text_input));
- // Text Input
- subghz->text_input = text_input_alloc();
- view_dispatcher_add_view(
- subghz->view_dispatcher, SubGhzViewIdTextInput, text_input_get_view(subghz->text_input));
-
- // Byte Input
- subghz->byte_input = byte_input_alloc();
- view_dispatcher_add_view(
- subghz->view_dispatcher, SubGhzViewIdByteInput, byte_input_get_view(subghz->byte_input));
-
- // Custom Widget
- subghz->widget = widget_alloc();
- view_dispatcher_add_view(
- subghz->view_dispatcher, SubGhzViewIdWidget, widget_get_view(subghz->widget));
+ // Byte Input
+ subghz->byte_input = byte_input_alloc();
+ view_dispatcher_add_view(
+ subghz->view_dispatcher,
+ SubGhzViewIdByteInput,
+ byte_input_get_view(subghz->byte_input));
+ // Custom Widget
+ subghz->widget = widget_alloc();
+ view_dispatcher_add_view(
+ subghz->view_dispatcher, SubGhzViewIdWidget, widget_get_view(subghz->widget));
+ }
//Dialog
subghz->dialogs = furi_record_open(RECORD_DIALOGS);
@@ -129,35 +133,36 @@ SubGhz* subghz_alloc() {
subghz->view_dispatcher,
SubGhzViewIdTransmitter,
subghz_view_transmitter_get_view(subghz->subghz_transmitter));
+ if(!alloc_for_tx_only) {
+ // Variable Item List
+ subghz->variable_item_list = variable_item_list_alloc();
+ view_dispatcher_add_view(
+ subghz->view_dispatcher,
+ SubGhzViewIdVariableItemList,
+ variable_item_list_get_view(subghz->variable_item_list));
- // Variable Item List
- subghz->variable_item_list = variable_item_list_alloc();
- view_dispatcher_add_view(
- subghz->view_dispatcher,
- SubGhzViewIdVariableItemList,
- variable_item_list_get_view(subghz->variable_item_list));
-
- // Frequency Analyzer
- subghz->subghz_frequency_analyzer = subghz_frequency_analyzer_alloc();
- view_dispatcher_add_view(
- subghz->view_dispatcher,
- SubGhzViewIdFrequencyAnalyzer,
- subghz_frequency_analyzer_get_view(subghz->subghz_frequency_analyzer));
+ // Frequency Analyzer
+ subghz->subghz_frequency_analyzer = subghz_frequency_analyzer_alloc();
+ view_dispatcher_add_view(
+ subghz->view_dispatcher,
+ SubGhzViewIdFrequencyAnalyzer,
+ subghz_frequency_analyzer_get_view(subghz->subghz_frequency_analyzer));
+ // Carrier Test Module
+ subghz->subghz_test_carrier = subghz_test_carrier_alloc();
+ view_dispatcher_add_view(
+ subghz->view_dispatcher,
+ SubGhzViewIdTestCarrier,
+ subghz_test_carrier_get_view(subghz->subghz_test_carrier));
+ }
// Read RAW
- subghz->subghz_read_raw = subghz_read_raw_alloc();
+ subghz->subghz_read_raw = subghz_read_raw_alloc(alloc_for_tx_only);
view_dispatcher_add_view(
subghz->view_dispatcher,
SubGhzViewIdReadRAW,
subghz_read_raw_get_view(subghz->subghz_read_raw));
- // Carrier Test Module
- subghz->subghz_test_carrier = subghz_test_carrier_alloc();
- view_dispatcher_add_view(
- subghz->view_dispatcher,
- SubGhzViewIdTestCarrier,
- subghz_test_carrier_get_view(subghz->subghz_test_carrier));
-
+#if FURI_DEBUG
// Packet Test
subghz->subghz_test_packet = subghz_test_packet_alloc();
view_dispatcher_add_view(
@@ -171,41 +176,64 @@ SubGhz* subghz_alloc() {
subghz->view_dispatcher,
SubGhzViewIdStatic,
subghz_test_static_get_view(subghz->subghz_test_static));
+#endif
//init setting
subghz->setting = subghz_setting_alloc();
- subghz_setting_load(subghz->setting, EXT_PATH("subghz/assets/setting_user"));
+ if(alloc_for_tx_only) {
+ subghz_setting_load(subghz->setting, EXT_PATH("subghz/assets/setting_user"), false);
+ } else {
+ subghz_setting_load(subghz->setting, EXT_PATH("subghz/assets/setting_user"), true);
+ }
// Load last used values for Read, Read RAW, etc. or default
- subghz->last_settings = subghz_last_settings_alloc();
- subghz_last_settings_load(
- subghz->last_settings, subghz_setting_get_preset_count(subghz->setting));
+ if(!alloc_for_tx_only) {
+ subghz->last_settings = subghz_last_settings_alloc();
+ subghz_last_settings_load(
+ subghz->last_settings, subghz_setting_get_preset_count(subghz->setting));
#if FURI_DEBUG
- FURI_LOG_D(
- TAG,
- "last frequency: %d, preset: %d",
- subghz->last_settings->frequency,
- subghz->last_settings->preset);
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+ FURI_LOG_D(
+ TAG,
+ "last frequency: %ld, preset: %ld, detect_raw: %d",
+ subghz->last_settings->frequency,
+ subghz->last_settings->preset,
+ subghz->last_settings->detect_raw);
+#else
+ FURI_LOG_D(
+ TAG,
+ "last frequency: %ld, preset: %ld",
+ subghz->last_settings->frequency,
+ subghz->last_settings->preset);
#endif
- subghz_setting_set_default_frequency(subghz->setting, subghz->last_settings->frequency);
-
+#endif
+ subghz_setting_set_default_frequency(subghz->setting, subghz->last_settings->frequency);
+ }
//init Worker & Protocol & History & KeyBoard
subghz->lock = SubGhzLockOff;
subghz->txrx = malloc(sizeof(SubGhzTxRx));
subghz->txrx->preset = malloc(sizeof(SubGhzPresetDefinition));
- string_init(subghz->txrx->preset->name);
- subghz_preset_init(
- subghz,
- subghz_setting_get_preset_name(subghz->setting, subghz->last_settings->preset),
- subghz->last_settings->frequency,
- NULL,
- 0);
-
+ subghz->txrx->preset->name = furi_string_alloc();
+ if(!alloc_for_tx_only) {
+ subghz_preset_init(
+ subghz,
+ subghz_setting_get_preset_name(subghz->setting, subghz->last_settings->preset),
+ subghz->last_settings->frequency,
+ NULL,
+ 0);
+ } else {
+ subghz_preset_init(
+ subghz, "AM650", subghz_setting_get_default_frequency(subghz->setting), NULL, 0);
+ }
subghz->txrx->txrx_state = SubGhzTxRxStateSleep;
subghz->txrx->hopper_state = SubGhzHopperStateOFF;
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
- subghz->txrx->history = subghz_history_alloc();
+ if(!alloc_for_tx_only) {
+ subghz->txrx->history = subghz_history_alloc();
+ }
+
subghz->txrx->worker = subghz_worker_alloc();
+
subghz->txrx->fff_data = flipper_format_string_alloc();
subghz->txrx->secure_data = malloc(sizeof(SecureData));
@@ -214,8 +242,13 @@ SubGhz* subghz_alloc() {
subghz->txrx->environment, EXT_PATH("subghz/assets/came_atomo"));
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
subghz->txrx->environment, EXT_PATH("subghz/assets/nice_flor_s"));
+
subghz->txrx->receiver = subghz_receiver_alloc_init(subghz->txrx->environment);
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+ subghz_last_settings_set_detect_raw_values(subghz);
+#else
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable);
+#endif
subghz_worker_set_overrun_callback(
subghz->txrx->worker, (SubGhzWorkerOverrunCallback)subghz_receiver_reset);
@@ -224,12 +257,12 @@ SubGhz* subghz_alloc() {
subghz_worker_set_context(subghz->txrx->worker, subghz->txrx->receiver);
//Init Error_str
- string_init(subghz->error_str);
+ subghz->error_str = furi_string_alloc();
return subghz;
}
-void subghz_free(SubGhz* subghz) {
+void subghz_free(SubGhz* subghz, bool alloc_for_tx_only) {
furi_assert(subghz);
if(subghz->rpc_ctx) {
@@ -239,57 +272,60 @@ void subghz_free(SubGhz* subghz) {
subghz->rpc_ctx = NULL;
}
+#if FURI_DEBUG
// Packet Test
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTestPacket);
subghz_test_packet_free(subghz->subghz_test_packet);
- // Carrier Test
- view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTestCarrier);
- subghz_test_carrier_free(subghz->subghz_test_carrier);
-
// Static
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdStatic);
subghz_test_static_free(subghz->subghz_test_static);
+#endif
- // Receiver
- view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdReceiver);
- subghz_view_receiver_free(subghz->subghz_receiver);
+ if(!alloc_for_tx_only) {
+ // Carrier Test
+ view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTestCarrier);
+ subghz_test_carrier_free(subghz->subghz_test_carrier);
- // TextInput
- view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTextInput);
- text_input_free(subghz->text_input);
+ // Receiver
+ view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdReceiver);
+ subghz_view_receiver_free(subghz->subghz_receiver);
- // ByteInput
- view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdByteInput);
- byte_input_free(subghz->byte_input);
+ // TextInput
+ view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTextInput);
+ text_input_free(subghz->text_input);
- // Custom Widget
- view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdWidget);
- widget_free(subghz->widget);
+ // ByteInput
+ view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdByteInput);
+ byte_input_free(subghz->byte_input);
+ // Custom Widget
+ view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdWidget);
+ widget_free(subghz->widget);
+ }
//Dialog
furi_record_close(RECORD_DIALOGS);
// Transmitter
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTransmitter);
subghz_view_transmitter_free(subghz->subghz_transmitter);
+ if(!alloc_for_tx_only) {
+ // Variable Item List
+ view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList);
+ variable_item_list_free(subghz->variable_item_list);
- // Variable Item List
- view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList);
- variable_item_list_free(subghz->variable_item_list);
-
- // Frequency Analyzer
- view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdFrequencyAnalyzer);
- subghz_frequency_analyzer_free(subghz->subghz_frequency_analyzer);
-
+ // Frequency Analyzer
+ view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdFrequencyAnalyzer);
+ subghz_frequency_analyzer_free(subghz->subghz_frequency_analyzer);
+ }
// Read RAW
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdReadRAW);
subghz_read_raw_free(subghz->subghz_read_raw);
-
- // Submenu
- view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdMenu);
- submenu_free(subghz->submenu);
-
+ if(!alloc_for_tx_only) {
+ // Submenu
+ view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdMenu);
+ submenu_free(subghz->submenu);
+ }
// Popup
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdPopup);
popup_free(subghz->popup);
@@ -306,36 +342,56 @@ void subghz_free(SubGhz* subghz) {
//setting
subghz_setting_free(subghz->setting);
- subghz_last_settings_free(subghz->last_settings);
-
+ if(!alloc_for_tx_only) {
+ subghz_last_settings_free(subghz->last_settings);
+ }
//Worker & Protocol & History
+
subghz_receiver_free(subghz->txrx->receiver);
+
subghz_environment_free(subghz->txrx->environment);
+
subghz_worker_free(subghz->txrx->worker);
+
flipper_format_free(subghz->txrx->fff_data);
- subghz_history_free(subghz->txrx->history);
- string_clear(subghz->txrx->preset->name);
+ if(!alloc_for_tx_only) {
+ subghz_history_free(subghz->txrx->history);
+ }
+ furi_string_free(subghz->txrx->preset->name);
free(subghz->txrx->preset);
free(subghz->txrx->secure_data);
free(subghz->txrx);
//Error string
- string_clear(subghz->error_str);
+ furi_string_free(subghz->error_str);
// Notifications
furi_record_close(RECORD_NOTIFICATION);
subghz->notifications = NULL;
// Path strings
- string_clear(subghz->file_path);
- string_clear(subghz->file_path_tmp);
+ furi_string_free(subghz->file_path);
+ furi_string_free(subghz->file_path_tmp);
// The rest
free(subghz);
}
int32_t subghz_app(void* p) {
- SubGhz* subghz = subghz_alloc();
+ bool alloc_for_tx;
+ if(p && strlen(p)) {
+ alloc_for_tx = true;
+ } else {
+ alloc_for_tx = false;
+ }
+
+ SubGhz* subghz = subghz_alloc(alloc_for_tx);
+
+ if(alloc_for_tx) {
+ subghz->raw_send_only = true;
+ } else {
+ subghz->raw_send_only = false;
+ }
//Load database
bool load_database = subghz_environment_load_keystore(
@@ -356,7 +412,7 @@ int32_t subghz_app(void* p) {
view_dispatcher_attach_to_gui(
subghz->view_dispatcher, subghz->gui, ViewDispatcherTypeFullscreen);
if(subghz_key_load(subghz, p, true)) {
- string_set_str(subghz->file_path, p);
+ furi_string_set(subghz->file_path, (const char*)p);
if((!strcmp(subghz->txrx->decoder_result->protocol->name, "RAW"))) {
//Load Raw TX
@@ -375,13 +431,13 @@ int32_t subghz_app(void* p) {
} else {
view_dispatcher_attach_to_gui(
subghz->view_dispatcher, subghz->gui, ViewDispatcherTypeFullscreen);
- string_set_str(subghz->file_path, SUBGHZ_APP_FOLDER);
+ furi_string_set(subghz->file_path, SUBGHZ_APP_FOLDER);
if(load_database) {
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneStart);
} else {
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneShowError, SubGhzCustomEventManagerSet);
- string_set_str(
+ furi_string_set(
subghz->error_str,
"No SD card or\ndatabase found.\nSome app function\nmay be reduced.");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
@@ -394,7 +450,7 @@ int32_t subghz_app(void* p) {
furi_hal_power_suppress_charge_exit();
- subghz_free(subghz);
+ subghz_free(subghz, alloc_for_tx);
return 0;
}
diff --git a/applications/main/subghz/subghz_cli.c b/applications/main/subghz/subghz_cli.c
index 204533134..e378eaccd 100644
--- a/applications/main/subghz/subghz_cli.c
+++ b/applications/main/subghz/subghz_cli.c
@@ -2,7 +2,6 @@
#include
#include
-#include
#include
#include
@@ -19,15 +18,15 @@
#define SUBGHZ_FREQUENCY_RANGE_STR \
"299999755...348000000 or 386999938...464000000 or 778999847...928000000"
-void subghz_cli_command_tx_carrier(Cli* cli, string_t args, void* context) {
+void subghz_cli_command_tx_carrier(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
uint32_t frequency = 433920000;
- if(string_size(args)) {
- int ret = sscanf(string_get_cstr(args), "%lu", &frequency);
+ if(furi_string_size(args)) {
+ int ret = sscanf(furi_string_get_cstr(args), "%lu", &frequency);
if(ret != 1) {
printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency);
- cli_print_usage("subghz tx_carrier", "", string_get_cstr(args));
+ cli_print_usage("subghz tx_carrier", "", furi_string_get_cstr(args));
return;
}
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
@@ -63,15 +62,15 @@ void subghz_cli_command_tx_carrier(Cli* cli, string_t args, void* context) {
furi_hal_power_suppress_charge_exit();
}
-void subghz_cli_command_rx_carrier(Cli* cli, string_t args, void* context) {
+void subghz_cli_command_rx_carrier(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
uint32_t frequency = 433920000;
- if(string_size(args)) {
- int ret = sscanf(string_get_cstr(args), "%lu", &frequency);
+ if(furi_string_size(args)) {
+ int ret = sscanf(furi_string_get_cstr(args), "%lu", &frequency);
if(ret != 1) {
printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency);
- cli_print_usage("subghz rx_carrier", "", string_get_cstr(args));
+ cli_print_usage("subghz rx_carrier", "", furi_string_get_cstr(args));
return;
}
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
@@ -104,15 +103,16 @@ void subghz_cli_command_rx_carrier(Cli* cli, string_t args, void* context) {
furi_hal_subghz_sleep();
}
-void subghz_cli_command_tx(Cli* cli, string_t args, void* context) {
+void subghz_cli_command_tx(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
uint32_t frequency = 433920000;
uint32_t key = 0x0074BADE;
uint32_t repeat = 10;
uint32_t te = 403;
- if(string_size(args)) {
- int ret = sscanf(string_get_cstr(args), "%lx %lu %lu %lu", &key, &frequency, &te, &repeat);
+ if(furi_string_size(args)) {
+ int ret =
+ sscanf(furi_string_get_cstr(args), "%lx %lu %lu %lu", &key, &frequency, &te, &repeat);
if(ret != 4) {
printf(
"sscanf returned %d, key: %lx, frequency: %lu, te:%lu, repeat: %lu\r\n",
@@ -124,7 +124,7 @@ void subghz_cli_command_tx(Cli* cli, string_t args, void* context) {
cli_print_usage(
"subghz tx",
"<3 Byte Key: in hex> ",
- string_get_cstr(args));
+ furi_string_get_cstr(args));
return;
}
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
@@ -142,14 +142,12 @@ void subghz_cli_command_tx(Cli* cli, string_t args, void* context) {
te,
repeat);
- string_t flipper_format_string;
- string_init_printf(
- flipper_format_string,
+ FuriString* flipper_format_string = furi_string_alloc_printf(
"Protocol: Princeton\n"
"Bit: 24\n"
"Key: 00 00 00 00 00 %02X %02X %02X\n"
- "TE: %d\n"
- "Repeat: %d\n",
+ "TE: %ld\n"
+ "Repeat: %ld\n",
(uint8_t)((key >> 16) & 0xFF),
(uint8_t)((key >> 8) & 0xFF),
(uint8_t)(key & 0xFF),
@@ -158,7 +156,7 @@ void subghz_cli_command_tx(Cli* cli, string_t args, void* context) {
FlipperFormat* flipper_format = flipper_format_string_alloc();
Stream* stream = flipper_format_get_raw_stream(flipper_format);
stream_clean(stream);
- stream_write_cstring(stream, string_get_cstr(flipper_format_string));
+ stream_write_cstring(stream, furi_string_get_cstr(flipper_format_string));
SubGhzEnvironment* environment = subghz_environment_alloc();
@@ -190,23 +188,21 @@ void subghz_cli_command_tx(Cli* cli, string_t args, void* context) {
typedef struct {
volatile bool overrun;
- StreamBufferHandle_t stream;
+ FuriStreamBuffer* stream;
size_t packet_count;
} SubGhzCliCommandRx;
static void subghz_cli_command_rx_capture_callback(bool level, uint32_t duration, void* context) {
SubGhzCliCommandRx* instance = context;
- BaseType_t xHigherPriorityTaskWoken = pdFALSE;
LevelDuration level_duration = level_duration_make(level, duration);
if(instance->overrun) {
instance->overrun = false;
level_duration = level_duration_reset();
}
- size_t ret = xStreamBufferSendFromISR(
- instance->stream, &level_duration, sizeof(LevelDuration), &xHigherPriorityTaskWoken);
+ size_t ret =
+ furi_stream_buffer_send(instance->stream, &level_duration, sizeof(LevelDuration), 0);
if(sizeof(LevelDuration) != ret) instance->overrun = true;
- portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
static void subghz_cli_command_rx_callback(
@@ -216,23 +212,23 @@ static void subghz_cli_command_rx_callback(
SubGhzCliCommandRx* instance = context;
instance->packet_count++;
- string_t text;
- string_init(text);
+ FuriString* text;
+ text = furi_string_alloc();
subghz_protocol_decoder_base_get_string(decoder_base, text);
subghz_receiver_reset(receiver);
- printf("%s", string_get_cstr(text));
- string_clear(text);
+ printf("%s", furi_string_get_cstr(text));
+ furi_string_free(text);
}
-void subghz_cli_command_rx(Cli* cli, string_t args, void* context) {
+void subghz_cli_command_rx(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
uint32_t frequency = 433920000;
- if(string_size(args)) {
- int ret = sscanf(string_get_cstr(args), "%lu", &frequency);
+ if(furi_string_size(args)) {
+ int ret = sscanf(furi_string_get_cstr(args), "%lu", &frequency);
if(ret != 1) {
printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency);
- cli_print_usage("subghz rx", "", string_get_cstr(args));
+ cli_print_usage("subghz rx", "", furi_string_get_cstr(args));
return;
}
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
@@ -245,7 +241,8 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) {
// Allocate context and buffers
SubGhzCliCommandRx* instance = malloc(sizeof(SubGhzCliCommandRx));
- instance->stream = xStreamBufferCreate(sizeof(LevelDuration) * 1024, sizeof(LevelDuration));
+ instance->stream =
+ furi_stream_buffer_alloc(sizeof(LevelDuration) * 1024, sizeof(LevelDuration));
furi_check(instance->stream);
SubGhzEnvironment* environment = subghz_environment_alloc();
@@ -275,8 +272,8 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) {
printf("Listening at %lu. Press CTRL+C to stop\r\n", frequency);
LevelDuration level_duration;
while(!cli_cmd_interrupt_received(cli)) {
- int ret =
- xStreamBufferReceive(instance->stream, &level_duration, sizeof(LevelDuration), 10);
+ int ret = furi_stream_buffer_receive(
+ instance->stream, &level_duration, sizeof(LevelDuration), 10);
if(ret == sizeof(LevelDuration)) {
if(level_duration_is_reset(level_duration)) {
printf(".");
@@ -300,36 +297,36 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) {
// Cleanup
subghz_receiver_free(receiver);
subghz_environment_free(environment);
- vStreamBufferDelete(instance->stream);
+ furi_stream_buffer_free(instance->stream);
free(instance);
}
-void subghz_cli_command_decode_raw(Cli* cli, string_t args, void* context) {
+void subghz_cli_command_decode_raw(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
- string_t file_name;
- string_init(file_name);
- string_set_str(file_name, ANY_PATH("subghz/test.sub"));
+ FuriString* file_name;
+ file_name = furi_string_alloc();
+ furi_string_set(file_name, ANY_PATH("subghz/test.sub"));
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
uint32_t temp_data32;
bool check_file = false;
do {
- if(string_size(args)) {
+ if(furi_string_size(args)) {
if(!args_read_string_and_trim(args, file_name)) {
cli_print_usage(
- "subghz decode_raw", "", string_get_cstr(args));
+ "subghz decode_raw", "", furi_string_get_cstr(args));
break;
}
}
- if(!flipper_format_file_open_existing(fff_data_file, string_get_cstr(file_name))) {
+ if(!flipper_format_file_open_existing(fff_data_file, furi_string_get_cstr(file_name))) {
printf(
"subghz decode_raw \033[0;31mError open file\033[0m %s\r\n",
- string_get_cstr(file_name));
+ furi_string_get_cstr(file_name));
break;
}
@@ -338,7 +335,7 @@ void subghz_cli_command_decode_raw(Cli* cli, string_t args, void* context) {
break;
}
- if(!strcmp(string_get_cstr(temp_str), SUBGHZ_RAW_FILE_TYPE) &&
+ if(!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_RAW_FILE_TYPE) &&
temp_data32 == SUBGHZ_KEY_FILE_VERSION) {
} else {
printf("subghz decode_raw \033[0;31mType or version mismatch\033[0m\r\n");
@@ -348,7 +345,7 @@ void subghz_cli_command_decode_raw(Cli* cli, string_t args, void* context) {
check_file = true;
} while(false);
- string_clear(temp_str);
+ furi_string_free(temp_str);
flipper_format_free(fff_data_file);
furi_record_close(RECORD_STORAGE);
@@ -380,14 +377,14 @@ void subghz_cli_command_decode_raw(Cli* cli, string_t args, void* context) {
subghz_receiver_set_rx_callback(receiver, subghz_cli_command_rx_callback, instance);
SubGhzFileEncoderWorker* file_worker_encoder = subghz_file_encoder_worker_alloc();
- if(subghz_file_encoder_worker_start(file_worker_encoder, string_get_cstr(file_name))) {
+ if(subghz_file_encoder_worker_start(file_worker_encoder, furi_string_get_cstr(file_name))) {
//the worker needs a file in order to open and read part of the file
furi_delay_ms(100);
}
printf(
"Listening at \033[0;33m%s\033[0m.\r\n\r\nPress CTRL+C to stop\r\n\r\n",
- string_get_cstr(file_name));
+ furi_string_get_cstr(file_name));
LevelDuration level_duration;
while(!cli_cmd_interrupt_received(cli)) {
@@ -414,7 +411,7 @@ void subghz_cli_command_decode_raw(Cli* cli, string_t args, void* context) {
subghz_file_encoder_worker_free(file_worker_encoder);
free(instance);
}
- string_clear(file_name);
+ furi_string_free(file_name);
}
static void subghz_cli_command_print_usage() {
@@ -440,14 +437,14 @@ static void subghz_cli_command_print_usage() {
}
}
-static void subghz_cli_command_encrypt_keeloq(Cli* cli, string_t args) {
+static void subghz_cli_command_encrypt_keeloq(Cli* cli, FuriString* args) {
UNUSED(cli);
uint8_t iv[16];
- string_t source;
- string_t destination;
- string_init(source);
- string_init(destination);
+ FuriString* source;
+ FuriString* destination;
+ source = furi_string_alloc();
+ destination = furi_string_alloc();
SubGhzKeystore* keystore = subghz_keystore_alloc();
@@ -467,30 +464,30 @@ static void subghz_cli_command_encrypt_keeloq(Cli* cli, string_t args) {
break;
}
- if(!subghz_keystore_load(keystore, string_get_cstr(source))) {
+ if(!subghz_keystore_load(keystore, furi_string_get_cstr(source))) {
printf("Failed to load Keystore");
break;
}
- if(!subghz_keystore_save(keystore, string_get_cstr(destination), iv)) {
+ if(!subghz_keystore_save(keystore, furi_string_get_cstr(destination), iv)) {
printf("Failed to save Keystore");
break;
}
} while(false);
subghz_keystore_free(keystore);
- string_clear(destination);
- string_clear(source);
+ furi_string_free(destination);
+ furi_string_free(source);
}
-static void subghz_cli_command_encrypt_raw(Cli* cli, string_t args) {
+static void subghz_cli_command_encrypt_raw(Cli* cli, FuriString* args) {
UNUSED(cli);
uint8_t iv[16];
- string_t source;
- string_t destination;
- string_init(source);
- string_init(destination);
+ FuriString* source;
+ FuriString* destination;
+ source = furi_string_alloc();
+ destination = furi_string_alloc();
do {
if(!args_read_string_and_trim(args, source)) {
@@ -509,25 +506,25 @@ static void subghz_cli_command_encrypt_raw(Cli* cli, string_t args) {
}
if(!subghz_keystore_raw_encrypted_save(
- string_get_cstr(source), string_get_cstr(destination), iv)) {
+ furi_string_get_cstr(source), furi_string_get_cstr(destination), iv)) {
printf("Failed to save Keystore");
break;
}
} while(false);
- string_clear(destination);
- string_clear(source);
+ furi_string_free(destination);
+ furi_string_free(source);
}
-static void subghz_cli_command_chat(Cli* cli, string_t args) {
+static void subghz_cli_command_chat(Cli* cli, FuriString* args) {
uint32_t frequency = 433920000;
- if(string_size(args)) {
- int ret = sscanf(string_get_cstr(args), "%lu", &frequency);
+ if(furi_string_size(args)) {
+ int ret = sscanf(furi_string_get_cstr(args), "%lu", &frequency);
if(ret != 1) {
printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency);
- cli_print_usage("subghz chat", "", string_get_cstr(args));
+ cli_print_usage("subghz chat", "", furi_string_get_cstr(args));
return;
}
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
@@ -563,22 +560,22 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) {
size_t message_max_len = 64;
uint8_t message[64] = {0};
- string_t input;
- string_init(input);
- string_t name;
- string_init(name);
- string_t output;
- string_init(output);
- string_t sysmsg;
- string_init(sysmsg);
+ FuriString* input;
+ input = furi_string_alloc();
+ FuriString* name;
+ name = furi_string_alloc();
+ FuriString* output;
+ output = furi_string_alloc();
+ FuriString* sysmsg;
+ sysmsg = furi_string_alloc();
bool exit = false;
SubGhzChatEvent chat_event;
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
- string_printf(name, "\033[0;33m%s\033[0m: ", furi_hal_version_get_name_ptr());
- string_set(input, name);
- printf("%s", string_get_cstr(input));
+ furi_string_printf(name, "\033[0;33m%s\033[0m: ", furi_hal_version_get_name_ptr());
+ furi_string_set(input, name);
+ printf("%s", furi_string_get_cstr(input));
fflush(stdout);
while(!exit) {
@@ -592,63 +589,63 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) {
break;
} else if(
(chat_event.c == CliSymbolAsciiBackspace) || (chat_event.c == CliSymbolAsciiDel)) {
- size_t len = string_length_u(input);
- if(len > string_length_u(name)) {
+ size_t len = furi_string_utf8_length(input);
+ if(len > furi_string_utf8_length(name)) {
printf("%s", "\e[D\e[1P");
fflush(stdout);
//delete 1 char UTF
- const char* str = string_get_cstr(input);
+ const char* str = furi_string_get_cstr(input);
size_t size = 0;
- m_str1ng_utf8_state_e s = M_STRING_UTF8_STARTING;
- string_unicode_t u = 0;
- string_reset(sysmsg);
+ FuriStringUTF8State s = FuriStringUTF8StateStarting;
+ FuriStringUnicodeValue u = 0;
+ furi_string_reset(sysmsg);
while(*str) {
- m_str1ng_utf8_decode(*str, &s, &u);
- if((s == M_STRING_UTF8_ERROR) || s == M_STRING_UTF8_STARTING) {
- string_push_u(sysmsg, u);
+ furi_string_utf8_decode(*str, &s, &u);
+ if((s == FuriStringUTF8StateError) || s == FuriStringUTF8StateStarting) {
+ furi_string_utf8_push(sysmsg, u);
if(++size >= len - 1) break;
- s = M_STRING_UTF8_STARTING;
+ s = FuriStringUTF8StateStarting;
}
str++;
}
- string_set(input, sysmsg);
+ furi_string_set(input, sysmsg);
}
} else if(chat_event.c == CliSymbolAsciiCR) {
printf("\r\n");
- string_push_back(input, '\r');
- string_push_back(input, '\n');
+ furi_string_push_back(input, '\r');
+ furi_string_push_back(input, '\n');
while(!subghz_chat_worker_write(
subghz_chat,
- (uint8_t*)string_get_cstr(input),
- strlen(string_get_cstr(input)))) {
+ (uint8_t*)furi_string_get_cstr(input),
+ strlen(furi_string_get_cstr(input)))) {
furi_delay_ms(10);
}
- string_printf(input, "%s", string_get_cstr(name));
- printf("%s", string_get_cstr(input));
+ furi_string_printf(input, "%s", furi_string_get_cstr(name));
+ printf("%s", furi_string_get_cstr(input));
fflush(stdout);
} else if(chat_event.c == CliSymbolAsciiLF) {
//cut out the symbol \n
} else {
putc(chat_event.c, stdout);
fflush(stdout);
- string_push_back(input, chat_event.c);
+ furi_string_push_back(input, chat_event.c);
break;
case SubGhzChatEventRXData:
do {
memset(message, 0x00, message_max_len);
size_t len = subghz_chat_worker_read(subghz_chat, message, message_max_len);
for(size_t i = 0; i < len; i++) {
- string_push_back(output, message[i]);
+ furi_string_push_back(output, message[i]);
if(message[i] == '\n') {
printf("\r");
for(uint8_t i = 0; i < 80; i++) {
printf(" ");
}
- printf("\r %s", string_get_cstr(output));
- printf("%s", string_get_cstr(input));
+ printf("\r %s", furi_string_get_cstr(output));
+ printf("%s", furi_string_get_cstr(input));
fflush(stdout);
- string_reset(output);
+ furi_string_reset(output);
}
}
} while(subghz_chat_worker_available(subghz_chat));
@@ -657,22 +654,22 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) {
notification_message(notification, &sequence_single_vibro);
break;
case SubGhzChatEventUserEntrance:
- string_printf(
+ furi_string_printf(
sysmsg,
"\033[0;34m%s joined chat.\033[0m\r\n",
furi_hal_version_get_name_ptr());
subghz_chat_worker_write(
subghz_chat,
- (uint8_t*)string_get_cstr(sysmsg),
- strlen(string_get_cstr(sysmsg)));
+ (uint8_t*)furi_string_get_cstr(sysmsg),
+ strlen(furi_string_get_cstr(sysmsg)));
break;
case SubGhzChatEventUserExit:
- string_printf(
+ furi_string_printf(
sysmsg, "\033[0;31m%s left chat.\033[0m\r\n", furi_hal_version_get_name_ptr());
subghz_chat_worker_write(
subghz_chat,
- (uint8_t*)string_get_cstr(sysmsg),
- strlen(string_get_cstr(sysmsg)));
+ (uint8_t*)furi_string_get_cstr(sysmsg),
+ strlen(furi_string_get_cstr(sysmsg)));
furi_delay_ms(10);
exit = true;
break;
@@ -688,10 +685,10 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) {
}
}
- string_clear(input);
- string_clear(name);
- string_clear(output);
- string_clear(sysmsg);
+ furi_string_free(input);
+ furi_string_free(name);
+ furi_string_free(output);
+ furi_string_free(sysmsg);
furi_hal_power_suppress_charge_exit();
furi_record_close(RECORD_NOTIFICATION);
@@ -702,9 +699,9 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) {
printf("\r\nExit chat\r\n");
}
-static void subghz_cli_command(Cli* cli, string_t args, void* context) {
- string_t cmd;
- string_init(cmd);
+static void subghz_cli_command(Cli* cli, FuriString* args, void* context) {
+ FuriString* cmd;
+ cmd = furi_string_alloc();
do {
if(!args_read_string_and_trim(args, cmd)) {
@@ -712,43 +709,43 @@ static void subghz_cli_command(Cli* cli, string_t args, void* context) {
break;
}
- if(string_cmp_str(cmd, "chat") == 0) {
+ if(furi_string_cmp_str(cmd, "chat") == 0) {
subghz_cli_command_chat(cli, args);
break;
}
- if(string_cmp_str(cmd, "tx") == 0) {
+ if(furi_string_cmp_str(cmd, "tx") == 0) {
subghz_cli_command_tx(cli, args, context);
break;
}
- if(string_cmp_str(cmd, "rx") == 0) {
+ if(furi_string_cmp_str(cmd, "rx") == 0) {
subghz_cli_command_rx(cli, args, context);
break;
}
- if(string_cmp_str(cmd, "decode_raw") == 0) {
+ if(furi_string_cmp_str(cmd, "decode_raw") == 0) {
subghz_cli_command_decode_raw(cli, args, context);
break;
}
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
- if(string_cmp_str(cmd, "encrypt_keeloq") == 0) {
+ if(furi_string_cmp_str(cmd, "encrypt_keeloq") == 0) {
subghz_cli_command_encrypt_keeloq(cli, args);
break;
}
- if(string_cmp_str(cmd, "encrypt_raw") == 0) {
+ if(furi_string_cmp_str(cmd, "encrypt_raw") == 0) {
subghz_cli_command_encrypt_raw(cli, args);
break;
}
- if(string_cmp_str(cmd, "tx_carrier") == 0) {
+ if(furi_string_cmp_str(cmd, "tx_carrier") == 0) {
subghz_cli_command_tx_carrier(cli, args, context);
break;
}
- if(string_cmp_str(cmd, "rx_carrier") == 0) {
+ if(furi_string_cmp_str(cmd, "rx_carrier") == 0) {
subghz_cli_command_rx_carrier(cli, args, context);
break;
}
@@ -757,7 +754,7 @@ static void subghz_cli_command(Cli* cli, string_t args, void* context) {
subghz_cli_command_print_usage();
} while(false);
- string_clear(cmd);
+ furi_string_free(cmd);
}
void subghz_on_system_start() {
diff --git a/applications/main/subghz/subghz_history.c b/applications/main/subghz/subghz_history.c
index 0af8c0a15..c8c733476 100644
--- a/applications/main/subghz/subghz_history.c
+++ b/applications/main/subghz/subghz_history.c
@@ -1,14 +1,28 @@
#include "subghz_history.h"
+#include "subghz_history_private.h"
#include
-#include
-#include
+#include
#define SUBGHZ_HISTORY_MAX 65
+
+/**
+ * @brief Settings for temporary files
+ *
+ */
+#define SUBGHZ_HISTORY_TMP_DIR EXT_PATH("subghz/tmp_history")
+#define SUBGHZ_HISTORY_TMP_EXTENSION ".tmp"
+#define SUBGHZ_HISTORY_TMP_SIGNAL_MAX_LEVEL_DURATION 700
+#define SUBGHZ_HISTORY_TMP_SIGNAL_MIN_LEVEL_DURATION 100
+#define SUBGHZ_HISTORY_TMP_REMOVE_FILES true
+#define SUBGHZ_HISTORY_TMP_RAW_KEY "RAW_Data"
+
#define TAG "SubGhzHistory"
typedef struct {
- string_t item_str;
+ FuriString* item_str;
FlipperFormat* flipper_string;
+ FuriString* protocol_name;
+ bool is_file;
uint8_t type;
SubGhzPresetDefinition* preset;
} SubGhzHistoryItem;
@@ -25,31 +39,144 @@ struct SubGhzHistory {
uint32_t last_update_timestamp;
uint16_t last_index_write;
uint8_t code_last_hash_data;
- string_t tmp_string;
+ FuriString* tmp_string;
+ bool write_tmp_files;
+ Storage* storage;
SubGhzHistoryStruct* history;
};
+#ifdef FURI_DEBUG
+#define LOG_DELAY 0
+#endif
+
+FuriString* subghz_history_generate_temp_filename(uint32_t index) {
+ FuriHalRtcDateTime datetime = {0};
+ furi_hal_rtc_get_datetime(&datetime);
+ return furi_string_alloc_printf("%03ld%s", index, SUBGHZ_HISTORY_TMP_EXTENSION);
+}
+
+bool subghz_history_is_tmp_dir_exists(SubGhzHistory* instance) {
+ FileInfo file_info;
+ storage_common_stat(instance->storage, SUBGHZ_HISTORY_TMP_DIR, &file_info);
+
+ if(storage_common_stat(instance->storage, SUBGHZ_HISTORY_TMP_DIR, &file_info) == FSE_OK) {
+ if(file_info.flags & FSF_DIRECTORY) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool subghz_history_check_sdcard(SubGhzHistory* instance) {
+#ifdef FURI_DEBUG
+ FURI_LOG_I(TAG, "check_sdcard");
+ uint32_t start_time = furi_get_tick();
+#endif
+
+ bool result = false;
+ // Stage 0 - check SD Card
+ FS_Error status = storage_sd_status(instance->storage);
+ if(status == FSE_OK) {
+ result = subghz_history_is_tmp_dir_exists(instance);
+ if(!subghz_history_is_tmp_dir_exists(instance)) {
+ result = storage_simply_mkdir(instance->storage, SUBGHZ_HISTORY_TMP_DIR);
+ }
+ } else {
+ FURI_LOG_W(TAG, "SD storage not installed! Status: %d", status);
+ }
+#ifdef FURI_DEBUG
+ FURI_LOG_I(TAG, "Running time (check_sdcard): %ld ms", furi_get_tick() - start_time);
+#endif
+
+ return result;
+}
+
+void subghz_history_clear_tmp_dir(SubGhzHistory* instance) {
+ furi_assert(instance);
+#ifdef FURI_DEBUG
+ FURI_LOG_I(TAG, "clear_tmp_dir");
+#endif
+
+ if(!instance->write_tmp_files) {
+ // Nothing to do here!
+ return;
+ }
+ //uint32_t start_time = furi_get_tick();
+#ifdef SUBGHZ_HISTORY_TMP_REMOVE_FILES
+ // Stage 0 - Dir exists?
+ bool res = subghz_history_is_tmp_dir_exists(instance);
+ if(res) {
+ // Stage 1 - delete all content if exists
+ FileInfo fileinfo;
+ storage_common_stat(instance->storage, SUBGHZ_HISTORY_TMP_DIR, &fileinfo);
+
+ res = fileinfo.flags & FSF_DIRECTORY ?
+ storage_simply_remove_recursive(instance->storage, SUBGHZ_HISTORY_TMP_DIR) :
+ (storage_common_remove(instance->storage, SUBGHZ_HISTORY_TMP_DIR) == FSE_OK);
+ }
+
+ // Stage 2 - create dir if necessary
+ res = !storage_simply_mkdir(instance->storage, SUBGHZ_HISTORY_TMP_DIR);
+ if(!res) {
+ FURI_LOG_E(TAG, "Cannot process temp dir!");
+ }
+#endif
+ /* uint32_t stop_time = furi_get_tick() - start_time;
+ FURI_LOG_I(TAG, "Running time (clear_tmp_dir): %d ms", stop_time);*/
+}
+
SubGhzHistory* subghz_history_alloc(void) {
SubGhzHistory* instance = malloc(sizeof(SubGhzHistory));
- string_init(instance->tmp_string);
+ instance->tmp_string = furi_string_alloc();
instance->history = malloc(sizeof(SubGhzHistoryStruct));
SubGhzHistoryItemArray_init(instance->history->data);
+ instance->storage = furi_record_open(RECORD_STORAGE);
+ instance->write_tmp_files = subghz_history_check_sdcard(instance);
+
+ if(!instance->write_tmp_files) {
+ FURI_LOG_E(TAG, "Unstable work! Cannot use SD Card!");
+ }
+
return instance;
}
+void subghz_history_item_free(void* current_item) {
+ furi_assert(current_item);
+ SubGhzHistoryItem* item = (SubGhzHistoryItem*)current_item;
+ furi_string_free(item->item_str);
+ furi_string_free(item->preset->name);
+ furi_string_free(item->protocol_name);
+
+ free(item->preset);
+ item->type = 0;
+ item->is_file = false;
+
+ if(item->flipper_string != NULL) {
+ flipper_format_free(item->flipper_string);
+ }
+}
+
+void subghz_history_clean_item_array(SubGhzHistory* instance) {
+ for
+ M_EACH(item, instance->history->data, SubGhzHistoryItemArray_t) {
+ subghz_history_item_free(item);
+ }
+}
+
void subghz_history_free(SubGhzHistory* instance) {
furi_assert(instance);
- string_clear(instance->tmp_string);
- for
- M_EACH(item, instance->history->data, SubGhzHistoryItemArray_t) {
- string_clear(item->item_str);
- string_clear(item->preset->name);
- free(item->preset);
- flipper_format_free(item->flipper_string);
- item->type = 0;
- }
+ furi_string_free(instance->tmp_string);
+
+ subghz_history_clean_item_array(instance);
SubGhzHistoryItemArray_clear(instance->history->data);
free(instance->history);
+
+ // Delete all temporary file, on exit it's ok
+ subghz_history_clear_tmp_dir(instance);
+
+ furi_record_close(RECORD_STORAGE);
+
free(instance);
}
@@ -68,20 +195,15 @@ SubGhzPresetDefinition* subghz_history_get_preset_def(SubGhzHistory* instance, u
const char* subghz_history_get_preset(SubGhzHistory* instance, uint16_t idx) {
furi_assert(instance);
SubGhzHistoryItem* item = SubGhzHistoryItemArray_get(instance->history->data, idx);
- return string_get_cstr(item->preset->name);
+ return furi_string_get_cstr(item->preset->name);
}
void subghz_history_reset(SubGhzHistory* instance) {
furi_assert(instance);
- string_reset(instance->tmp_string);
- for
- M_EACH(item, instance->history->data, SubGhzHistoryItemArray_t) {
- string_clear(item->item_str);
- string_clear(item->preset->name);
- free(item->preset);
- flipper_format_free(item->flipper_string);
- item->type = 0;
- }
+ furi_string_reset(instance->tmp_string);
+
+ subghz_history_clean_item_array(instance);
+
SubGhzHistoryItemArray_reset(instance->history->data);
instance->last_index_write = 0;
instance->code_last_hash_data = 0;
@@ -101,12 +223,8 @@ uint8_t subghz_history_get_type_protocol(SubGhzHistory* instance, uint16_t idx)
const char* subghz_history_get_protocol_name(SubGhzHistory* instance, uint16_t idx) {
furi_assert(instance);
SubGhzHistoryItem* item = SubGhzHistoryItemArray_get(instance->history->data, idx);
- flipper_format_rewind(item->flipper_string);
- if(!flipper_format_read_string(item->flipper_string, "Protocol", instance->tmp_string)) {
- FURI_LOG_E(TAG, "Missing Protocol");
- string_reset(instance->tmp_string);
- }
- return string_get_cstr(instance->tmp_string);
+
+ return furi_string_get_cstr(item->protocol_name);
}
FlipperFormat* subghz_history_get_raw_data(SubGhzHistory* instance, uint16_t idx) {
@@ -115,23 +233,71 @@ FlipperFormat* subghz_history_get_raw_data(SubGhzHistory* instance, uint16_t idx
if(item->flipper_string) {
return item->flipper_string;
} else {
- return NULL;
+ bool result_ok = false;
+ if(instance->write_tmp_files && item->is_file) {
+ // We have files!
+ FuriString* filename = subghz_history_generate_temp_filename(idx);
+ FuriString* dir_path;
+
+ dir_path = furi_string_alloc_printf(
+ "%s/%s", SUBGHZ_HISTORY_TMP_DIR, furi_string_get_cstr(filename));
+
+ if(storage_file_exists(instance->storage, furi_string_get_cstr(dir_path))) {
+#ifdef FURI_DEBUG
+ FURI_LOG_D(TAG, "Exist: %s", furi_string_get_cstr(dir_path));
+ furi_delay_ms(LOG_DELAY);
+#endif
+ // Set to current anyway it has NULL value
+ item->flipper_string = flipper_format_string_alloc();
+ Stream* dst_stream = flipper_format_get_raw_stream(item->flipper_string);
+ stream_clean(dst_stream);
+
+ size_t size = stream_load_from_file(
+ dst_stream, instance->storage, furi_string_get_cstr(dir_path));
+ if(size > 0) {
+#ifdef FURI_DEBUG
+ FURI_LOG_I(TAG, "Save ok!");
+ furi_delay_ms(LOG_DELAY);
+#endif
+ // We changed contents of file, so we no needed to load
+ // content from disk for the next time
+ item->is_file = false;
+ result_ok = true;
+ } else {
+ FURI_LOG_E(TAG, "Stream copy failed!");
+ flipper_format_free(item->flipper_string);
+ }
+ } else {
+ FURI_LOG_E(TAG, "Can't convert filename to file");
+ }
+
+ furi_string_free(filename);
+ furi_string_free(dir_path);
+ } else {
+#ifdef FURI_DEBUG
+ FURI_LOG_W(TAG, "Write TMP files failed!");
+ furi_delay_ms(LOG_DELAY);
+#endif
+ }
+ return result_ok ? item->flipper_string : NULL;
}
}
-bool subghz_history_get_text_space_left(SubGhzHistory* instance, string_t output) {
+
+bool subghz_history_get_text_space_left(SubGhzHistory* instance, FuriString* output) {
furi_assert(instance);
if(instance->last_index_write == SUBGHZ_HISTORY_MAX) {
- if(output != NULL) string_printf(output, "Memory is FULL");
+ if(output != NULL) furi_string_printf(output, "Memory is FULL");
return true;
}
- if(output != NULL)
- string_printf(output, "%02u/%02u", instance->last_index_write, SUBGHZ_HISTORY_MAX);
+ if(output != NULL) {
+ furi_string_printf(output, "%02u/%02u", instance->last_index_write, SUBGHZ_HISTORY_MAX);
+ }
return false;
}
-void subghz_history_get_text_item_menu(SubGhzHistory* instance, string_t output, uint16_t idx) {
+void subghz_history_get_text_item_menu(SubGhzHistory* instance, FuriString* output, uint16_t idx) {
SubGhzHistoryItem* item = SubGhzHistoryItemArray_get(instance->history->data, idx);
- string_set(output, item->item_str);
+ furi_string_set(output, item->item_str);
}
bool subghz_history_add_to_history(
@@ -141,7 +307,9 @@ bool subghz_history_add_to_history(
furi_assert(instance);
furi_assert(context);
- if(instance->last_index_write >= SUBGHZ_HISTORY_MAX) return false;
+ if(instance->last_index_write >= SUBGHZ_HISTORY_MAX) {
+ return false;
+ }
SubGhzProtocolDecoderBase* decoder_base = context;
if((instance->code_last_hash_data ==
@@ -153,19 +321,23 @@ bool subghz_history_add_to_history(
instance->code_last_hash_data = subghz_protocol_decoder_base_get_hash_data(decoder_base);
instance->last_update_timestamp = furi_get_tick();
-
- string_t text;
- string_init(text);
+ FuriString* text;
+ text = furi_string_alloc();
SubGhzHistoryItem* item = SubGhzHistoryItemArray_push_raw(instance->history->data);
item->preset = malloc(sizeof(SubGhzPresetDefinition));
item->type = decoder_base->protocol->type;
item->preset->frequency = preset->frequency;
- string_init(item->preset->name);
- string_set(item->preset->name, preset->name);
+ item->preset->name = furi_string_alloc();
+ furi_string_set(item->preset->name, preset->name);
item->preset->data = preset->data;
item->preset->data_size = preset->data_size;
- string_init(item->item_str);
+ item->item_str = furi_string_alloc();
+ item->protocol_name = furi_string_alloc();
+
+ bool tmp_file_for_raw = false;
+
+ // At this point file mapped to memory otherwise file cannot decode
item->flipper_string = flipper_format_string_alloc();
subghz_protocol_decoder_base_serialize(decoder_base, item->flipper_string, preset);
@@ -177,9 +349,12 @@ bool subghz_history_add_to_history(
if(!flipper_format_read_string(item->flipper_string, "Protocol", instance->tmp_string)) {
FURI_LOG_E(TAG, "Missing Protocol");
break;
+ } else {
+ furi_string_printf(
+ item->protocol_name, "%s", furi_string_get_cstr(instance->tmp_string));
}
- if(!strcmp(string_get_cstr(instance->tmp_string), "RAW")) {
- string_printf(
+ if(!strcmp(furi_string_get_cstr(instance->tmp_string), "RAW")) {
+ furi_string_printf(
item->item_str,
"RAW %03ld.%02ld",
preset->frequency / 1000000 % 1000,
@@ -188,22 +363,22 @@ bool subghz_history_add_to_history(
if(!flipper_format_rewind(item->flipper_string)) {
FURI_LOG_E(TAG, "Rewind error");
}
-
+ tmp_file_for_raw = true;
break;
- } else if(!strcmp(string_get_cstr(instance->tmp_string), "KeeLoq")) {
- string_set_str(instance->tmp_string, "KL ");
+ } else if(!strcmp(furi_string_get_cstr(instance->tmp_string), "KeeLoq")) {
+ furi_string_set(instance->tmp_string, "KL ");
if(!flipper_format_read_string(item->flipper_string, "Manufacture", text)) {
FURI_LOG_E(TAG, "Missing Protocol");
break;
}
- string_cat(instance->tmp_string, text);
- } else if(!strcmp(string_get_cstr(instance->tmp_string), "Star Line")) {
- string_set_str(instance->tmp_string, "SL ");
+ furi_string_cat(instance->tmp_string, text);
+ } else if(!strcmp(furi_string_get_cstr(instance->tmp_string), "Star Line")) {
+ furi_string_set(instance->tmp_string, "SL ");
if(!flipper_format_read_string(item->flipper_string, "Manufacture", text)) {
FURI_LOG_E(TAG, "Missing Protocol");
break;
}
- string_cat(instance->tmp_string, text);
+ furi_string_cat(instance->tmp_string, text);
}
if(!flipper_format_rewind(item->flipper_string)) {
FURI_LOG_E(TAG, "Rewind error");
@@ -219,22 +394,86 @@ bool subghz_history_add_to_history(
data = (data << 8) | key_data[i];
}
if(!(uint32_t)(data >> 32)) {
- string_printf(
+ furi_string_printf(
item->item_str,
"%s %lX",
- string_get_cstr(instance->tmp_string),
+ furi_string_get_cstr(instance->tmp_string),
(uint32_t)(data & 0xFFFFFFFF));
} else {
- string_printf(
+ furi_string_printf(
item->item_str,
"%s %lX%08lX",
- string_get_cstr(instance->tmp_string),
+ furi_string_get_cstr(instance->tmp_string),
(uint32_t)(data >> 32),
(uint32_t)(data & 0xFFFFFFFF));
}
} while(false);
- string_clear(text);
+ // If we can write to files
+ if(instance->write_tmp_files && tmp_file_for_raw) {
+ FuriString* filename = subghz_history_generate_temp_filename(instance->last_index_write);
+ FuriString* dir_path;
+ dir_path = furi_string_alloc();
+
+ furi_string_cat_printf(
+ dir_path, "%s/%s", SUBGHZ_HISTORY_TMP_DIR, furi_string_get_cstr(filename));
+#ifdef FURI_DEBUG
+ FURI_LOG_I(TAG, "Save temp file: %s", furi_string_get_cstr(dir_path));
+#endif
+ if(!subghz_history_tmp_write_file_split(instance, item, dir_path)) {
+ // Plan B!
+ subghz_history_tmp_write_file_full(instance, item, dir_path);
+ }
+ furi_string_free(filename);
+ furi_string_free(dir_path);
+
+ } else {
+#ifdef FURI_DEBUG
+ FURI_LOG_I(TAG, "Old fashion way");
+#endif
+ }
+
+ furi_string_free(text);
+
instance->last_index_write++;
return true;
}
+
+bool subghz_history_tmp_write_file_split(
+ SubGhzHistory* instance,
+ void* current_item,
+ FuriString* dir_path) {
+ UNUSED(instance);
+ UNUSED(current_item);
+ UNUSED(dir_path);
+ /*furi_assert(instance);
+ furi_assert(current_item);
+ furi_assert(dir_path);*/
+ //SubGhzHistoryItem* item = (SubGhzHistoryItem*)current_item;
+
+ return false;
+}
+
+void subghz_history_tmp_write_file_full(
+ SubGhzHistory* instance,
+ void* current_item,
+ FuriString* dir_path) {
+ SubGhzHistoryItem* item = (SubGhzHistoryItem*)current_item;
+#ifdef FURI_DEBUG
+ FURI_LOG_W(TAG, "Save temp file full: %s", furi_string_get_cstr(dir_path));
+#endif
+ Stream* dst = flipper_format_get_raw_stream(item->flipper_string);
+ stream_rewind(dst);
+ if(stream_save_to_file(
+ dst, instance->storage, furi_string_get_cstr(dir_path), FSOM_CREATE_ALWAYS) > 0) {
+ flipper_format_free(item->flipper_string);
+ item->flipper_string = NULL;
+#ifdef FURI_DEBUG
+ FURI_LOG_I(TAG, "Save done!");
+#endif
+ // This item contains fake data to load from SD
+ item->is_file = true;
+ } else {
+ FURI_LOG_E(TAG, "Stream copy failed!");
+ }
+}
\ No newline at end of file
diff --git a/applications/main/subghz/subghz_history.h b/applications/main/subghz/subghz_history.h
index adbcfc18a..7bff3df5e 100644
--- a/applications/main/subghz/subghz_history.h
+++ b/applications/main/subghz/subghz_history.h
@@ -71,18 +71,18 @@ const char* subghz_history_get_protocol_name(SubGhzHistory* instance, uint16_t i
/** Get string item menu to history[idx]
*
* @param instance - SubGhzHistory instance
- * @param output - string_t output
+ * @param output - FuriString* output
* @param idx - record index
*/
-void subghz_history_get_text_item_menu(SubGhzHistory* instance, string_t output, uint16_t idx);
+void subghz_history_get_text_item_menu(SubGhzHistory* instance, FuriString* output, uint16_t idx);
/** Get string the remaining number of records to history
*
* @param instance - SubGhzHistory instance
- * @param output - string_t output
+ * @param output - FuriString* output
* @return bool - is FUUL
*/
-bool subghz_history_get_text_space_left(SubGhzHistory* instance, string_t output);
+bool subghz_history_get_text_space_left(SubGhzHistory* instance, FuriString* output);
/** Add protocol to history
*
diff --git a/applications/main/subghz/subghz_history_private.h b/applications/main/subghz/subghz_history_private.h
new file mode 100644
index 000000000..aac330c33
--- /dev/null
+++ b/applications/main/subghz/subghz_history_private.h
@@ -0,0 +1,78 @@
+#pragma once
+
+#include "subghz_history.h"
+
+/**
+ * @brief Generate filename like 000.tmp
+ *
+ * @param index - index of file, timestamp doesn't accepted!
+ */
+FuriString* subghz_history_generate_temp_filename(uint32_t index);
+
+/**
+ * @brief Check if directory for temporary files is exists
+ *
+ * @param instance SubGhzHistory*
+ * @return true
+ * @return false
+ */
+bool subghz_history_is_tmp_dir_exists(SubGhzHistory* instance);
+
+/**
+ * @brief Check SD card and create temporary dir if not exists,
+ * Result write_tmp_files without this unstable work is GUARANTEED
+ *
+ * @param instance - SubGhzHistory*
+ * @return - true all ok
+ * @return - false we have a problems
+ */
+bool subghz_history_check_sdcard(SubGhzHistory* instance);
+
+/**
+ * @brief Recursive delete dir and files and create new temp dir
+ *
+ * @param instance - SubGhzHistory*
+ * @return true - if all ok
+ * @return false - if something failed
+ */
+void subghz_history_clear_tmp_dir(SubGhzHistory* instance);
+
+/**
+ * @brief Free item and free all resources
+ *
+ * @param current_item - SubGhzHistoryItem*
+ */
+void subghz_history_item_free(void* current_item);
+
+/**
+ * @brief free all items in array
+ *
+ * @param instance
+ */
+void subghz_history_clean_item_array(SubGhzHistory* instance);
+
+/**
+ * @brief Write temp file fully, without spliting
+ *
+ * @param instance - SubGhzHistory*
+ * @param current_item - SubGhzHistoryItem*
+ * @param dir_path - full path to file
+ */
+void subghz_history_tmp_write_file_full(
+ SubGhzHistory* instance,
+ void* current_item,
+ FuriString* dir_path);
+
+/**
+ * @brief Write temp splited to lines
+ *
+ * @param instance - SubGhzHistory*
+ * @param current_item - SubGhzHistoryItem*
+ * @param dir_path - full path to file
+ * @return true - file saved
+ * @return false - error occured
+ */
+bool subghz_history_tmp_write_file_split(
+ SubGhzHistory* instance,
+ void* current_item,
+ FuriString* dir_path);
\ No newline at end of file
diff --git a/applications/main/subghz/subghz_i.c b/applications/main/subghz/subghz_i.c
index 2a02b2a01..1b6496bbc 100644
--- a/applications/main/subghz/subghz_i.c
+++ b/applications/main/subghz/subghz_i.c
@@ -26,7 +26,7 @@ void subghz_preset_init(
size_t preset_data_size) {
furi_assert(context);
SubGhz* subghz = context;
- string_set(subghz->txrx->preset->name, preset_name);
+ furi_string_set(subghz->txrx->preset->name, preset_name);
subghz->txrx->preset->frequency = frequency;
subghz->txrx->preset->data = preset_data;
subghz->txrx->preset->data_size = preset_data_size;
@@ -34,15 +34,15 @@ void subghz_preset_init(
bool subghz_set_preset(SubGhz* subghz, const char* preset) {
if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) {
- string_set(subghz->txrx->preset->name, "AM270");
+ furi_string_set(subghz->txrx->preset->name, "AM270");
} else if(!strcmp(preset, "FuriHalSubGhzPresetOok650Async")) {
- string_set(subghz->txrx->preset->name, "AM650");
+ furi_string_set(subghz->txrx->preset->name, "AM650");
} else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev238Async")) {
- string_set(subghz->txrx->preset->name, "FM238");
+ furi_string_set(subghz->txrx->preset->name, "FM238");
} else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev476Async")) {
- string_set(subghz->txrx->preset->name, "FM476");
+ furi_string_set(subghz->txrx->preset->name, "FM476");
} else if(!strcmp(preset, "FuriHalSubGhzPresetCustom")) {
- string_set(subghz->txrx->preset->name, "CUSTOM");
+ furi_string_set(subghz->txrx->preset->name, "CUSTOM");
} else {
FURI_LOG_E(TAG, "Unknown preset");
return false;
@@ -50,17 +50,17 @@ bool subghz_set_preset(SubGhz* subghz, const char* preset) {
return true;
}
-void subghz_get_frequency_modulation(SubGhz* subghz, string_t frequency, string_t modulation) {
+void subghz_get_frequency_modulation(SubGhz* subghz, FuriString* frequency, FuriString* modulation) {
furi_assert(subghz);
if(frequency != NULL) {
- string_printf(
+ furi_string_printf(
frequency,
"%03ld.%02ld",
subghz->txrx->preset->frequency / 1000000 % 1000,
subghz->txrx->preset->frequency / 10000 % 100);
}
if(modulation != NULL) {
- string_printf(modulation, "%0.2s", string_get_cstr(subghz->txrx->preset->name));
+ furi_string_printf(modulation, "%.2s", furi_string_get_cstr(subghz->txrx->preset->name));
}
}
@@ -137,8 +137,8 @@ bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format) {
furi_assert(subghz);
bool ret = false;
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
uint32_t repeat = 200;
do {
if(!flipper_format_rewind(flipper_format)) {
@@ -155,21 +155,21 @@ bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format) {
break;
}
- subghz->txrx->transmitter =
- subghz_transmitter_alloc_init(subghz->txrx->environment, string_get_cstr(temp_str));
+ subghz->txrx->transmitter = subghz_transmitter_alloc_init(
+ subghz->txrx->environment, furi_string_get_cstr(temp_str));
if(subghz->txrx->transmitter) {
if(subghz_transmitter_deserialize(subghz->txrx->transmitter, flipper_format)) {
- if(strcmp(string_get_cstr(subghz->txrx->preset->name), "")) {
+ if(strcmp(furi_string_get_cstr(subghz->txrx->preset->name), "")) {
subghz_begin(
subghz,
subghz_setting_get_preset_data_by_name(
- subghz->setting, string_get_cstr(subghz->txrx->preset->name)));
+ subghz->setting, furi_string_get_cstr(subghz->txrx->preset->name)));
} else {
FURI_LOG_E(
TAG,
"Unknown name preset \" %s \"",
- string_get_cstr(subghz->txrx->preset->name));
+ furi_string_get_cstr(subghz->txrx->preset->name));
subghz_begin(
subghz, subghz_setting_get_preset_data_by_name(subghz->setting, "AM650"));
}
@@ -193,7 +193,7 @@ bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format) {
}
} while(false);
- string_clear(temp_str);
+ furi_string_free(temp_str);
return ret;
}
@@ -209,7 +209,7 @@ void subghz_tx_stop(SubGhz* subghz) {
if((subghz->txrx->decoder_result->protocol->type == SubGhzProtocolTypeDynamic) &&
(subghz_path_is_file(subghz->file_path))) {
subghz_save_protocol_to_file(
- subghz, subghz->txrx->fff_data, string_get_cstr(subghz->file_path));
+ subghz, subghz->txrx->fff_data, furi_string_get_cstr(subghz->file_path));
}
subghz_idle(subghz);
notification_message(subghz->notifications, &sequence_reset_red);
@@ -240,8 +240,8 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
Stream* fff_data_stream = flipper_format_get_raw_stream(subghz->txrx->fff_data);
SubGhzLoadKeyState load_key_state = SubGhzLoadKeyStateParseErr;
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
uint32_t temp_data32;
do {
@@ -256,8 +256,8 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
break;
}
- if(((!strcmp(string_get_cstr(temp_str), SUBGHZ_KEY_FILE_TYPE)) ||
- (!strcmp(string_get_cstr(temp_str), SUBGHZ_RAW_FILE_TYPE))) &&
+ if(((!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_KEY_FILE_TYPE)) ||
+ (!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_RAW_FILE_TYPE))) &&
temp_data32 == SUBGHZ_KEY_FILE_VERSION) {
} else {
FURI_LOG_E(TAG, "Type or version mismatch");
@@ -286,27 +286,29 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
break;
}
- if(!subghz_set_preset(subghz, string_get_cstr(temp_str))) {
+ if(!subghz_set_preset(subghz, furi_string_get_cstr(temp_str))) {
break;
}
- if(!strcmp(string_get_cstr(temp_str), "FuriHalSubGhzPresetCustom")) {
+ if(!strcmp(furi_string_get_cstr(temp_str), "FuriHalSubGhzPresetCustom")) {
//Todo add Custom_preset_module
//delete preset if it already exists
subghz_setting_delete_custom_preset(
- subghz->setting, string_get_cstr(subghz->txrx->preset->name));
+ subghz->setting, furi_string_get_cstr(subghz->txrx->preset->name));
//load custom preset from file
if(!subghz_setting_load_custom_preset(
- subghz->setting, string_get_cstr(subghz->txrx->preset->name), fff_data_file)) {
+ subghz->setting,
+ furi_string_get_cstr(subghz->txrx->preset->name),
+ fff_data_file)) {
FURI_LOG_E(TAG, "Missing Custom preset");
break;
}
}
size_t preset_index = subghz_setting_get_inx_preset_by_name(
- subghz->setting, string_get_cstr(subghz->txrx->preset->name));
+ subghz->setting, furi_string_get_cstr(subghz->txrx->preset->name));
subghz_preset_init(
subghz,
- string_get_cstr(subghz->txrx->preset->name),
+ furi_string_get_cstr(subghz->txrx->preset->name),
subghz->txrx->preset->frequency,
subghz_setting_get_preset_data(subghz->setting, preset_index),
subghz_setting_get_preset_data_size(subghz->setting, preset_index));
@@ -315,7 +317,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
FURI_LOG_E(TAG, "Missing Protocol");
break;
}
- if(!strcmp(string_get_cstr(temp_str), "RAW")) {
+ if(!strcmp(furi_string_get_cstr(temp_str), "RAW")) {
//if RAW
subghz_protocol_raw_gen_fff_data(subghz->txrx->fff_data, file_path);
} else {
@@ -325,7 +327,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
}
subghz->txrx->decoder_result = subghz_receiver_search_decoder_base_by_name(
- subghz->txrx->receiver, string_get_cstr(temp_str));
+ subghz->txrx->receiver, furi_string_get_cstr(temp_str));
if(subghz->txrx->decoder_result) {
if(!subghz_protocol_decoder_base_deserialize(
subghz->txrx->decoder_result, subghz->txrx->fff_data)) {
@@ -339,7 +341,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
load_key_state = SubGhzLoadKeyStateOK;
} while(0);
- string_clear(temp_str);
+ furi_string_free(temp_str);
flipper_format_free(fff_data_file);
furi_record_close(RECORD_STORAGE);
@@ -369,42 +371,42 @@ bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len) {
furi_assert(subghz);
Storage* storage = furi_record_open(RECORD_STORAGE);
- string_t temp_str;
- string_t file_name;
- string_t file_path;
+ FuriString* temp_str;
+ FuriString* file_name;
+ FuriString* file_path;
- string_init(temp_str);
- string_init(file_name);
- string_init(file_path);
+ temp_str = furi_string_alloc();
+ file_name = furi_string_alloc();
+ file_path = furi_string_alloc();
bool res = false;
if(subghz_path_is_file(subghz->file_path)) {
//get the name of the next free file
path_extract_filename(subghz->file_path, file_name, true);
- path_extract_dirname(string_get_cstr(subghz->file_path), file_path);
+ path_extract_dirname(furi_string_get_cstr(subghz->file_path), file_path);
storage_get_next_filename(
storage,
- string_get_cstr(file_path),
- string_get_cstr(file_name),
+ furi_string_get_cstr(file_path),
+ furi_string_get_cstr(file_name),
SUBGHZ_APP_EXTENSION,
file_name,
max_len);
- string_printf(
+ furi_string_printf(
temp_str,
"%s/%s%s",
- string_get_cstr(file_path),
- string_get_cstr(file_name),
+ furi_string_get_cstr(file_path),
+ furi_string_get_cstr(file_name),
SUBGHZ_APP_EXTENSION);
- string_set(subghz->file_path, temp_str);
+ furi_string_set(subghz->file_path, temp_str);
res = true;
}
- string_clear(temp_str);
- string_clear(file_path);
- string_clear(file_name);
+ furi_string_free(temp_str);
+ furi_string_free(file_path);
+ furi_string_free(file_name);
furi_record_close(RECORD_STORAGE);
return res;
@@ -422,8 +424,8 @@ bool subghz_save_protocol_to_file(
Stream* flipper_format_stream = flipper_format_get_raw_stream(flipper_format);
bool saved = false;
- string_t file_dir;
- string_init(file_dir);
+ FuriString* file_dir;
+ file_dir = furi_string_alloc();
path_extract_dirname(dev_file_name, file_dir);
do {
@@ -432,7 +434,7 @@ bool subghz_save_protocol_to_file(
flipper_format_delete_key(flipper_format, "Manufacture");
// Create subghz folder directory if necessary
- if(!storage_simply_mkdir(storage, string_get_cstr(file_dir))) {
+ if(!storage_simply_mkdir(storage, furi_string_get_cstr(file_dir))) {
dialog_message_show_storage_error(subghz->dialogs, "Cannot create\nfolder");
break;
}
@@ -446,7 +448,7 @@ bool subghz_save_protocol_to_file(
saved = true;
} while(0);
- string_clear(file_dir);
+ furi_string_free(file_dir);
furi_record_close(RECORD_STORAGE);
return saved;
}
@@ -454,8 +456,8 @@ bool subghz_save_protocol_to_file(
bool subghz_load_protocol_from_file(SubGhz* subghz) {
furi_assert(subghz);
- string_t file_path;
- string_init(file_path);
+ FuriString* file_path;
+ file_path = furi_string_alloc();
DialogsFileBrowserOptions browser_options;
dialog_file_browser_set_basic_options(&browser_options, SUBGHZ_APP_EXTENSION, &I_sub1_10px);
@@ -465,10 +467,10 @@ bool subghz_load_protocol_from_file(SubGhz* subghz) {
subghz->dialogs, subghz->file_path, subghz->file_path, &browser_options);
if(res) {
- res = subghz_key_load(subghz, string_get_cstr(subghz->file_path), true);
+ res = subghz_key_load(subghz, furi_string_get_cstr(subghz->file_path), true);
}
- string_clear(file_path);
+ furi_string_free(file_path);
return res;
}
@@ -479,9 +481,11 @@ bool subghz_rename_file(SubGhz* subghz) {
Storage* storage = furi_record_open(RECORD_STORAGE);
- if(string_cmp(subghz->file_path_tmp, subghz->file_path)) {
+ if(furi_string_cmp(subghz->file_path_tmp, subghz->file_path)) {
FS_Error fs_result = storage_common_rename(
- storage, string_get_cstr(subghz->file_path_tmp), string_get_cstr(subghz->file_path));
+ storage,
+ furi_string_get_cstr(subghz->file_path_tmp),
+ furi_string_get_cstr(subghz->file_path));
if(fs_result != FSE_OK) {
dialog_message_show_storage_error(subghz->dialogs, "Cannot rename\n file/directory");
@@ -497,7 +501,7 @@ bool subghz_delete_file(SubGhz* subghz) {
furi_assert(subghz);
Storage* storage = furi_record_open(RECORD_STORAGE);
- bool result = storage_simply_remove(storage, string_get_cstr(subghz->file_path_tmp));
+ bool result = storage_simply_remove(storage, furi_string_get_cstr(subghz->file_path_tmp));
furi_record_close(RECORD_STORAGE);
subghz_file_name_clear(subghz);
@@ -507,12 +511,12 @@ bool subghz_delete_file(SubGhz* subghz) {
void subghz_file_name_clear(SubGhz* subghz) {
furi_assert(subghz);
- string_set_str(subghz->file_path, SUBGHZ_APP_FOLDER);
- string_reset(subghz->file_path_tmp);
+ furi_string_set(subghz->file_path, SUBGHZ_APP_FOLDER);
+ furi_string_reset(subghz->file_path_tmp);
}
-bool subghz_path_is_file(string_t path) {
- return string_end_with_str_p(path, SUBGHZ_APP_EXTENSION);
+bool subghz_path_is_file(FuriString* path) {
+ return furi_string_end_with(path, SUBGHZ_APP_EXTENSION);
}
uint32_t subghz_random_serial(void) {
diff --git a/applications/main/subghz/subghz_i.h b/applications/main/subghz/subghz_i.h
index 8872d31f6..832ae8696 100644
--- a/applications/main/subghz/subghz_i.h
+++ b/applications/main/subghz/subghz_i.h
@@ -7,10 +7,11 @@
#include "views/subghz_frequency_analyzer.h"
#include "views/subghz_read_raw.h"
-#include "views/subghz_test_static.h"
#include "views/subghz_test_carrier.h"
+#if FURI_DEBUG
+#include "views/subghz_test_static.h"
#include "views/subghz_test_packet.h"
-
+#endif
// #include
// #include
#include
@@ -85,8 +86,8 @@ struct SubGhz {
ByteInput* byte_input;
Widget* widget;
DialogsApp* dialogs;
- string_t file_path;
- string_t file_path_tmp;
+ FuriString* file_path;
+ FuriString* file_path_tmp;
char file_name_tmp[SUBGHZ_MAX_LEN_NAME];
SubGhzNotificationState state_notifications;
@@ -96,10 +97,13 @@ struct SubGhz {
SubGhzFrequencyAnalyzer* subghz_frequency_analyzer;
SubGhzReadRAW* subghz_read_raw;
- SubGhzTestStatic* subghz_test_static;
+ bool raw_send_only;
SubGhzTestCarrier* subghz_test_carrier;
+#if FURI_DEBUG
+ SubGhzTestStatic* subghz_test_static;
SubGhzTestPacket* subghz_test_packet;
- string_t error_str;
+#endif
+ FuriString* error_str;
SubGhzSetting* setting;
SubGhzLastSettings* last_settings;
SubGhzLock lock;
@@ -115,7 +119,7 @@ void subghz_preset_init(
uint8_t* preset_data,
size_t preset_data_size);
bool subghz_set_preset(SubGhz* subghz, const char* preset);
-void subghz_get_frequency_modulation(SubGhz* subghz, string_t frequency, string_t modulation);
+void subghz_get_frequency_modulation(SubGhz* subghz, FuriString* frequency, FuriString* modulation);
void subghz_begin(SubGhz* subghz, uint8_t* preset_data);
uint32_t subghz_rx(SubGhz* subghz, uint32_t frequency);
void subghz_rx_end(SubGhz* subghz);
@@ -137,7 +141,7 @@ bool subghz_load_protocol_from_file(SubGhz* subghz);
bool subghz_rename_file(SubGhz* subghz);
bool subghz_delete_file(SubGhz* subghz);
void subghz_file_name_clear(SubGhz* subghz);
-bool subghz_path_is_file(string_t path);
+bool subghz_path_is_file(FuriString* path);
uint32_t subghz_random_serial(void);
void subghz_hopper_update(SubGhz* subghz);
diff --git a/applications/main/subghz/subghz_last_settings.c b/applications/main/subghz/subghz_last_settings.c
index b24273cf3..6382253b8 100644
--- a/applications/main/subghz/subghz_last_settings.c
+++ b/applications/main/subghz/subghz_last_settings.c
@@ -1,5 +1,8 @@
#include "subghz_last_settings.h"
-#include
+#include "subghz_i.h"
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+#include
+#endif
#define TAG "SubGhzLastSettings"
@@ -11,6 +14,14 @@
#define SUBGHZ_LAST_SETTING_DEFAULT_PRESET 1
#define SUBGHZ_LAST_SETTING_DEFAULT_FREQUENCY 433920000
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+#define SUBGHZ_LAST_SETTING_DEFAULT_READ_RAW 0
+#define SUBGHZ_LAST_SETTING_FIELD_DETECT_RAW "DetectRaw"
+#endif
+
+#define SUBGHZ_LAST_SETTING_FIELD_FREQUENCY "Frequency"
+#define SUBGHZ_LAST_SETTING_FIELD_PRESET "Preset"
+
SubGhzLastSettings* subghz_last_settings_alloc(void) {
SubGhzLastSettings* instance = malloc(sizeof(SubGhzLastSettings));
return instance;
@@ -23,7 +34,7 @@ void subghz_last_settings_free(SubGhzLastSettings* instance) {
void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count) {
furi_assert(instance);
-#if FURI_DEBUG
+#ifdef FURI_DEBUG
FURI_LOG_I(TAG, "subghz_last_settings_load");
#endif
@@ -32,11 +43,20 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
uint32_t temp_frequency = 0;
int32_t temp_preset = 0;
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+ uint32_t temp_read_raw = 0;
+#endif
if(FSE_OK == storage_sd_status(storage) && SUBGHZ_LAST_SETTINGS_PATH &&
flipper_format_file_open_existing(fff_data_file, SUBGHZ_LAST_SETTINGS_PATH)) {
- flipper_format_read_int32(fff_data_file, "Preset", (int32_t*)&temp_preset, 1);
- flipper_format_read_uint32(fff_data_file, "Frequency", (uint32_t*)&temp_frequency, 1);
+ flipper_format_read_int32(
+ fff_data_file, SUBGHZ_LAST_SETTING_FIELD_PRESET, (int32_t*)&temp_preset, 1);
+ flipper_format_read_uint32(
+ fff_data_file, SUBGHZ_LAST_SETTING_FIELD_FREQUENCY, (uint32_t*)&temp_frequency, 1);
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+ flipper_format_read_uint32(
+ fff_data_file, SUBGHZ_LAST_SETTING_FIELD_DETECT_RAW, (uint32_t*)&temp_read_raw, 1);
+#endif
} else {
FURI_LOG_E(TAG, "Error open file %s", SUBGHZ_LAST_SETTINGS_PATH);
}
@@ -45,8 +65,14 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
FURI_LOG_W(TAG, "Last used frequency not found or can't be used!");
instance->frequency = SUBGHZ_LAST_SETTING_DEFAULT_FREQUENCY;
instance->preset = SUBGHZ_LAST_SETTING_DEFAULT_PRESET;
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+ instance->detect_raw = SUBGHZ_LAST_SETTING_DEFAULT_READ_RAW;
+#endif
} else {
instance->frequency = temp_frequency;
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+ instance->detect_raw = temp_read_raw;
+#endif
if(temp_preset > (int32_t)preset_count - 1 || temp_preset < 0) {
FURI_LOG_W(TAG, "Last used preset no found");
@@ -63,8 +89,8 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
bool subghz_last_settings_save(SubGhzLastSettings* instance) {
furi_assert(instance);
-#if FURI_DEBUG
- FURI_LOG_I(TAG, "subghz_last_settings_save");
+#ifdef FURI_DEBUG
+ FURI_LOG_I(TAG, "last_settings_save");
#endif
bool saved = false;
@@ -84,12 +110,20 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) {
file, SUBGHZ_LAST_SETTING_FILE_TYPE, SUBGHZ_LAST_SETTING_FILE_VERSION))
break;
- if(!flipper_format_insert_or_update_int32(file, "Preset", &instance->preset, 1)) {
+ if(!flipper_format_insert_or_update_int32(
+ file, SUBGHZ_LAST_SETTING_FIELD_PRESET, &instance->preset, 1)) {
break;
}
- if(!flipper_format_insert_or_update_uint32(file, "Frequency", &instance->frequency, 1)) {
+ if(!flipper_format_insert_or_update_uint32(
+ file, SUBGHZ_LAST_SETTING_FIELD_FREQUENCY, &instance->frequency, 1)) {
break;
}
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+ if(!flipper_format_insert_or_update_uint32(
+ file, SUBGHZ_LAST_SETTING_FIELD_DETECT_RAW, &instance->detect_raw, 1)) {
+ break;
+ }
+#endif
saved = true;
} while(0);
@@ -102,4 +136,18 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) {
furi_record_close(RECORD_STORAGE);
return saved;
-}
\ No newline at end of file
+}
+
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+void subghz_last_settings_set_detect_raw_values(void* context) {
+ furi_assert(context);
+ SubGhz* instance = (SubGhz*)context;
+ bool is_detect_raw = instance->last_settings->detect_raw > 0;
+ subghz_receiver_set_filter(
+ instance->txrx->receiver, is_detect_raw ? DETECT_RAW_TRUE : DETECT_RAW_FALSE);
+ subghz_protocol_decoder_raw_set_auto_mode(
+ subghz_receiver_search_decoder_base_by_name(
+ instance->txrx->receiver, SUBGHZ_PROTOCOL_RAW_NAME),
+ is_detect_raw);
+}
+#endif
\ No newline at end of file
diff --git a/applications/main/subghz/subghz_last_settings.h b/applications/main/subghz/subghz_last_settings.h
index 8067bb66a..116eacadd 100644
--- a/applications/main/subghz/subghz_last_settings.h
+++ b/applications/main/subghz/subghz_last_settings.h
@@ -1,12 +1,23 @@
#pragma once
+// Enable saving detect raw setting state
+// #define SUBGHZ_SAVE_DETECT_RAW_SETTING 1
+
#include
#include
#include
#include
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+#include
+#define DETECT_RAW_FALSE SubGhzProtocolFlag_Decodable
+#define DETECT_RAW_TRUE SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_RAW
+#endif
typedef struct {
uint32_t frequency;
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+ uint32_t detect_raw;
+#endif
int32_t preset;
} SubGhzLastSettings;
@@ -16,4 +27,7 @@ void subghz_last_settings_free(SubGhzLastSettings* instance);
void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count);
-bool subghz_last_settings_save(SubGhzLastSettings* instance);
\ No newline at end of file
+bool subghz_last_settings_save(SubGhzLastSettings* instance);
+#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
+void subghz_last_settings_set_detect_raw_values(void* context);
+#endif
\ No newline at end of file
diff --git a/applications/main/subghz/subghz_setting.c b/applications/main/subghz/subghz_setting.c
index 2e94011cf..322e80e7d 100644
--- a/applications/main/subghz/subghz_setting.c
+++ b/applications/main/subghz/subghz_setting.c
@@ -51,7 +51,7 @@ static const uint32_t subghz_hopper_frequency_list[] = {
};
typedef struct {
- string_t custom_preset_name;
+ FuriString* custom_preset_name;
uint8_t* custom_preset_data;
size_t custom_preset_data_size;
} SubGhzSettingCustomPresetItem;
@@ -87,7 +87,7 @@ SubGhzSetting* subghz_setting_alloc(void) {
static void subghz_setting_preset_reset(SubGhzSetting* instance) {
for
M_EACH(item, instance->preset->data, SubGhzSettingCustomPresetItemArray_t) {
- string_clear(item->custom_preset_name);
+ furi_string_free(item->custom_preset_name);
free(item->custom_preset_data);
}
SubGhzSettingCustomPresetItemArray_reset(instance->preset->data);
@@ -99,7 +99,7 @@ void subghz_setting_free(SubGhzSetting* instance) {
FrequencyList_clear(instance->hopper_frequencies);
for
M_EACH(item, instance->preset->data, SubGhzSettingCustomPresetItemArray_t) {
- string_clear(item->custom_preset_name);
+ furi_string_free(item->custom_preset_name);
free(item->custom_preset_data);
}
SubGhzSettingCustomPresetItemArray_clear(instance->preset->data);
@@ -118,8 +118,8 @@ static void subghz_setting_load_default_preset(
SubGhzSettingCustomPresetItem* item =
SubGhzSettingCustomPresetItemArray_push_raw(instance->preset->data);
- string_init(item->custom_preset_name);
- string_set(item->custom_preset_name, preset_name);
+ item->custom_preset_name = furi_string_alloc();
+ furi_string_set(item->custom_preset_name, preset_name);
while(preset_data[preset_data_count]) {
preset_data_count += 2;
@@ -181,14 +181,14 @@ void subghz_setting_load_default(SubGhzSetting* instance) {
instance, subghz_frequency_list, subghz_hopper_frequency_list);
}
-void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
+void subghz_setting_load(SubGhzSetting* instance, const char* file_path, bool not_skip_frequencies) {
furi_assert(instance);
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
uint32_t temp_data32;
bool temp_bool;
@@ -206,7 +206,7 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
break;
}
- if((!strcmp(string_get_cstr(temp_str), SUBGHZ_SETTING_FILE_TYPE)) &&
+ if((!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_SETTING_FILE_TYPE)) &&
temp_data32 == SUBGHZ_SETTING_FILE_VERSION) {
} else {
FURI_LOG_E(TAG, "Type or version mismatch");
@@ -214,53 +214,56 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
}
// Standard frequencies (optional)
- temp_bool = true;
- flipper_format_read_bool(fff_data_file, "Add_standard_frequencies", &temp_bool, 1);
- if(!temp_bool) {
- FURI_LOG_I(TAG, "Removing standard frequencies");
- FrequencyList_reset(instance->frequencies);
- FrequencyList_reset(instance->hopper_frequencies);
- } else {
- FURI_LOG_I(TAG, "Keeping standard frequencies");
- }
-
- // Load frequencies
- if(!flipper_format_rewind(fff_data_file)) {
- FURI_LOG_E(TAG, "Rewind error");
- break;
- }
- while(flipper_format_read_uint32(
- fff_data_file, "Frequency", (uint32_t*)&temp_data32, 1)) {
- if(furi_hal_subghz_is_frequency_valid(temp_data32)) {
- FURI_LOG_I(TAG, "Frequency loaded %lu", temp_data32);
- FrequencyList_push_back(instance->frequencies, temp_data32);
+ if(not_skip_frequencies) {
+ temp_bool = true;
+ flipper_format_read_bool(fff_data_file, "Add_standard_frequencies", &temp_bool, 1);
+ if(!temp_bool) {
+ FURI_LOG_I(TAG, "Removing standard frequencies");
+ FrequencyList_reset(instance->frequencies);
+ FrequencyList_reset(instance->hopper_frequencies);
} else {
- FURI_LOG_E(TAG, "Frequency not supported %lu", temp_data32);
+ FURI_LOG_I(TAG, "Keeping standard frequencies");
}
- }
- // Load hopper frequencies
- if(!flipper_format_rewind(fff_data_file)) {
- FURI_LOG_E(TAG, "Rewind error");
- break;
- }
- while(flipper_format_read_uint32(
- fff_data_file, "Hopper_frequency", (uint32_t*)&temp_data32, 1)) {
- if(furi_hal_subghz_is_frequency_valid(temp_data32)) {
- FURI_LOG_I(TAG, "Hopper frequency loaded %lu", temp_data32);
- FrequencyList_push_back(instance->hopper_frequencies, temp_data32);
- } else {
- FURI_LOG_E(TAG, "Hopper frequency not supported %lu", temp_data32);
+ // Load frequencies
+ if(!flipper_format_rewind(fff_data_file)) {
+ FURI_LOG_E(TAG, "Rewind error");
+ break;
+ }
+ while(flipper_format_read_uint32(
+ fff_data_file, "Frequency", (uint32_t*)&temp_data32, 1)) {
+ if(furi_hal_subghz_is_frequency_valid(temp_data32)) {
+ FURI_LOG_I(TAG, "Frequency loaded %lu", temp_data32);
+ FrequencyList_push_back(instance->frequencies, temp_data32);
+ } else {
+ FURI_LOG_E(TAG, "Frequency not supported %lu", temp_data32);
+ }
}
- }
- // Default frequency (optional)
- if(!flipper_format_rewind(fff_data_file)) {
- FURI_LOG_E(TAG, "Rewind error");
- break;
- }
- if(flipper_format_read_uint32(fff_data_file, "Default_frequency", &temp_data32, 1)) {
- subghz_setting_set_default_frequency(instance, temp_data32);
+ // Load hopper frequencies
+ if(!flipper_format_rewind(fff_data_file)) {
+ FURI_LOG_E(TAG, "Rewind error");
+ break;
+ }
+ while(flipper_format_read_uint32(
+ fff_data_file, "Hopper_frequency", (uint32_t*)&temp_data32, 1)) {
+ if(furi_hal_subghz_is_frequency_valid(temp_data32)) {
+ FURI_LOG_I(TAG, "Hopper frequency loaded %lu", temp_data32);
+ FrequencyList_push_back(instance->hopper_frequencies, temp_data32);
+ } else {
+ FURI_LOG_E(TAG, "Hopper frequency not supported %lu", temp_data32);
+ }
+ }
+
+ // Default frequency (optional)
+ if(!flipper_format_rewind(fff_data_file)) {
+ FURI_LOG_E(TAG, "Rewind error");
+ break;
+ }
+ if(flipper_format_read_uint32(
+ fff_data_file, "Default_frequency", &temp_data32, 1)) {
+ subghz_setting_set_default_frequency(instance, temp_data32);
+ }
}
// custom preset (optional)
@@ -269,15 +272,15 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
break;
}
while(flipper_format_read_string(fff_data_file, "Custom_preset_name", temp_str)) {
- FURI_LOG_I(TAG, "Custom preset loaded %s", string_get_cstr(temp_str));
+ FURI_LOG_I(TAG, "Custom preset loaded %s", furi_string_get_cstr(temp_str));
subghz_setting_load_custom_preset(
- instance, string_get_cstr(temp_str), fff_data_file);
+ instance, furi_string_get_cstr(temp_str), fff_data_file);
}
} while(false);
}
- string_clear(temp_str);
+ furi_string_free(temp_str);
flipper_format_free(fff_data_file);
furi_record_close(RECORD_STORAGE);
@@ -320,7 +323,7 @@ const char* subghz_setting_get_preset_name(SubGhzSetting* instance, size_t idx)
}
SubGhzSettingCustomPresetItem* item =
SubGhzSettingCustomPresetItemArray_get(instance->preset->data, idx);
- return string_get_cstr(item->custom_preset_name);
+ return furi_string_get_cstr(item->custom_preset_name);
}
int subghz_setting_get_inx_preset_by_name(SubGhzSetting* instance, const char* preset_name) {
@@ -328,7 +331,7 @@ int subghz_setting_get_inx_preset_by_name(SubGhzSetting* instance, const char* p
size_t idx = 0;
for
M_EACH(item, instance->preset->data, SubGhzSettingCustomPresetItemArray_t) {
- if(strcmp(string_get_cstr(item->custom_preset_name), preset_name) == 0) {
+ if(strcmp(furi_string_get_cstr(item->custom_preset_name), preset_name) == 0) {
return idx;
}
idx++;
@@ -346,8 +349,8 @@ bool subghz_setting_load_custom_preset(
uint32_t temp_data32;
SubGhzSettingCustomPresetItem* item =
SubGhzSettingCustomPresetItemArray_push_raw(instance->preset->data);
- string_init(item->custom_preset_name);
- string_set(item->custom_preset_name, preset_name);
+ item->custom_preset_name = furi_string_alloc();
+ furi_string_set(item->custom_preset_name, preset_name);
do {
if(!flipper_format_get_value_count(fff_data_file, "Custom_preset_data", &temp_data32))
break;
@@ -377,8 +380,8 @@ bool subghz_setting_delete_custom_preset(SubGhzSetting* instance, const char* pr
SubGhzSettingCustomPresetItemArray_it_last(it, instance->preset->data);
while(!SubGhzSettingCustomPresetItemArray_end_p(it)) {
SubGhzSettingCustomPresetItem* item = SubGhzSettingCustomPresetItemArray_ref(it);
- if(strcmp(string_get_cstr(item->custom_preset_name), preset_name) == 0) {
- string_clear(item->custom_preset_name);
+ if(strcmp(furi_string_get_cstr(item->custom_preset_name), preset_name) == 0) {
+ furi_string_free(item->custom_preset_name);
free(item->custom_preset_data);
SubGhzSettingCustomPresetItemArray_remove(instance->preset->data, it);
return true;
diff --git a/applications/main/subghz/subghz_setting.h b/applications/main/subghz/subghz_setting.h
index d6fde1bd6..3b3b1131a 100644
--- a/applications/main/subghz/subghz_setting.h
+++ b/applications/main/subghz/subghz_setting.h
@@ -14,7 +14,7 @@ SubGhzSetting* subghz_setting_alloc(void);
void subghz_setting_free(SubGhzSetting* instance);
-void subghz_setting_load(SubGhzSetting* instance, const char* file_path);
+void subghz_setting_load(SubGhzSetting* instance, const char* file_path, bool not_skip_frequencies);
size_t subghz_setting_get_frequency_count(SubGhzSetting* instance);
diff --git a/applications/main/subghz/views/receiver.c b/applications/main/subghz/views/receiver.c
index 5736ceb7a..5355df463 100644
--- a/applications/main/subghz/views/receiver.c
+++ b/applications/main/subghz/views/receiver.c
@@ -5,7 +5,6 @@
#include
#include
#include
-#include
#include
#define FRAME_HEIGHT 12
@@ -14,7 +13,7 @@
#define UNLOCK_CNT 3
typedef struct {
- string_t item_str;
+ FuriString* item_str;
uint8_t type;
} SubGhzReceiverMenuItem;
@@ -53,10 +52,10 @@ struct SubGhzViewReceiver {
};
typedef struct {
- string_t frequency_str;
- string_t preset_str;
- string_t history_stat_str;
- string_t progress_str;
+ FuriString* frequency_str;
+ FuriString* preset_str;
+ FuriString* history_stat_str;
+ FuriString* progress_str;
SubGhzReceiverHistory* history;
uint16_t idx;
uint16_t list_offset;
@@ -134,7 +133,7 @@ void subghz_view_receiver_add_item_to_menu(
subghz_receiver->view, (SubGhzViewReceiverModel * model) {
SubGhzReceiverMenuItem* item_menu =
SubGhzReceiverMenuItemArray_push_raw(model->history->data);
- string_init_set_str(item_menu->item_str, name);
+ item_menu->item_str = furi_string_alloc_set(name);
item_menu->type = type;
if((model->idx == model->history_item - 1)) {
model->history_item++;
@@ -156,9 +155,9 @@ void subghz_view_receiver_add_data_statusbar(
furi_assert(subghz_receiver);
with_view_model(
subghz_receiver->view, (SubGhzViewReceiverModel * model) {
- string_set_str(model->frequency_str, frequency_str);
- string_set_str(model->preset_str, preset_str);
- string_set_str(model->history_stat_str, history_stat_str);
+ furi_string_set(model->frequency_str, frequency_str);
+ furi_string_set(model->preset_str, preset_str);
+ furi_string_set(model->history_stat_str, history_stat_str);
return true;
});
}
@@ -169,7 +168,7 @@ void subghz_view_receiver_add_data_progress(
furi_assert(subghz_receiver);
with_view_model(
subghz_receiver->view, (SubGhzViewReceiverModel * model) {
- string_set_str(model->progress_str, progress_str);
+ furi_string_set(model->progress_str, progress_str);
return true;
});
}
@@ -197,19 +196,19 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) {
elements_button_left(canvas, "Config");
canvas_draw_line(canvas, 46, 51, 125, 51);
} else {
- canvas_draw_str(canvas, 3, 62, string_get_cstr(model->progress_str));
+ canvas_draw_str(canvas, 3, 62, furi_string_get_cstr(model->progress_str));
}
bool scrollbar = model->history_item > 4;
- string_t str_buff;
- string_init(str_buff);
+ FuriString* str_buff;
+ str_buff = furi_string_alloc();
SubGhzReceiverMenuItem* item_menu;
for(size_t i = 0; i < MIN(model->history_item, MENU_ITEMS); ++i) {
size_t idx = CLAMP((uint16_t)(i + model->list_offset), model->history_item, 0);
item_menu = SubGhzReceiverMenuItemArray_get(model->history->data, idx);
- string_set(str_buff, item_menu->item_str);
+ furi_string_set(str_buff, item_menu->item_str);
elements_string_fit_width(canvas, str_buff, scrollbar ? MAX_LEN_PX - 6 : MAX_LEN_PX);
if(model->idx == idx) {
subghz_view_receiver_draw_frame(canvas, i, scrollbar);
@@ -217,13 +216,13 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) {
canvas_set_color(canvas, ColorBlack);
}
canvas_draw_icon(canvas, 1, 2 + i * FRAME_HEIGHT, ReceiverItemIcons[item_menu->type]);
- canvas_draw_str(canvas, 15, 9 + i * FRAME_HEIGHT, string_get_cstr(str_buff));
- string_reset(str_buff);
+ canvas_draw_str(canvas, 15, 9 + i * FRAME_HEIGHT, furi_string_get_cstr(str_buff));
+ furi_string_reset(str_buff);
}
if(scrollbar) {
elements_scrollbar_pos(canvas, 128, 0, 49, model->idx, model->history_item);
}
- string_clear(str_buff);
+ furi_string_free(str_buff);
canvas_set_color(canvas, ColorBlack);
@@ -248,9 +247,9 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) {
canvas_draw_str(canvas, 74, 62, "Locked");
break;
case SubGhzViewReceiverBarShowToUnlockPress:
- canvas_draw_str(canvas, 44, 62, string_get_cstr(model->frequency_str));
- canvas_draw_str(canvas, 79, 62, string_get_cstr(model->preset_str));
- canvas_draw_str(canvas, 96, 62, string_get_cstr(model->history_stat_str));
+ canvas_draw_str(canvas, 44, 62, furi_string_get_cstr(model->frequency_str));
+ canvas_draw_str(canvas, 79, 62, furi_string_get_cstr(model->preset_str));
+ canvas_draw_str(canvas, 96, 62, furi_string_get_cstr(model->history_stat_str));
canvas_set_font(canvas, FontSecondary);
elements_bold_rounded_frame(canvas, 14, 8, 99, 48);
elements_multiline_text(canvas, 65, 26, "To unlock\npress:");
@@ -265,9 +264,9 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) {
canvas_draw_str(canvas, 74, 62, "Unlocked");
break;
default:
- canvas_draw_str(canvas, 44, 62, string_get_cstr(model->frequency_str));
- canvas_draw_str(canvas, 79, 62, string_get_cstr(model->preset_str));
- canvas_draw_str(canvas, 96, 62, string_get_cstr(model->history_stat_str));
+ canvas_draw_str(canvas, 44, 62, furi_string_get_cstr(model->frequency_str));
+ canvas_draw_str(canvas, 79, 62, furi_string_get_cstr(model->preset_str));
+ canvas_draw_str(canvas, 96, 62, furi_string_get_cstr(model->history_stat_str));
break;
}
}
@@ -366,13 +365,13 @@ void subghz_view_receiver_exit(void* context) {
SubGhzViewReceiver* subghz_receiver = context;
with_view_model(
subghz_receiver->view, (SubGhzViewReceiverModel * model) {
- string_reset(model->frequency_str);
- string_reset(model->preset_str);
- string_reset(model->history_stat_str);
+ furi_string_reset(model->frequency_str);
+ furi_string_reset(model->preset_str);
+ furi_string_reset(model->history_stat_str);
for
M_EACH(item_menu, model->history->data, SubGhzReceiverMenuItemArray_t) {
- string_clear(item_menu->item_str);
+ furi_string_free(item_menu->item_str);
item_menu->type = 0;
}
SubGhzReceiverMenuItemArray_reset(model->history->data);
@@ -402,10 +401,10 @@ SubGhzViewReceiver* subghz_view_receiver_alloc() {
with_view_model(
subghz_receiver->view, (SubGhzViewReceiverModel * model) {
- string_init(model->frequency_str);
- string_init(model->preset_str);
- string_init(model->history_stat_str);
- string_init(model->progress_str);
+ model->frequency_str = furi_string_alloc();
+ model->preset_str = furi_string_alloc();
+ model->history_stat_str = furi_string_alloc();
+ model->progress_str = furi_string_alloc();
model->bar_show = SubGhzViewReceiverBarShowDefault;
model->history = malloc(sizeof(SubGhzReceiverHistory));
SubGhzReceiverMenuItemArray_init(model->history->data);
@@ -421,13 +420,13 @@ void subghz_view_receiver_free(SubGhzViewReceiver* subghz_receiver) {
with_view_model(
subghz_receiver->view, (SubGhzViewReceiverModel * model) {
- string_clear(model->frequency_str);
- string_clear(model->preset_str);
- string_clear(model->history_stat_str);
- string_clear(model->progress_str);
+ furi_string_free(model->frequency_str);
+ furi_string_free(model->preset_str);
+ furi_string_free(model->history_stat_str);
+ furi_string_free(model->progress_str);
for
M_EACH(item_menu, model->history->data, SubGhzReceiverMenuItemArray_t) {
- string_clear(item_menu->item_str);
+ furi_string_free(item_menu->item_str);
item_menu->type = 0;
}
SubGhzReceiverMenuItemArray_clear(model->history->data);
diff --git a/applications/main/subghz/views/subghz_frequency_analyzer.c b/applications/main/subghz/views/subghz_frequency_analyzer.c
index 9900c32c9..677cd91ae 100644
--- a/applications/main/subghz/views/subghz_frequency_analyzer.c
+++ b/applications/main/subghz/views/subghz_frequency_analyzer.c
@@ -40,14 +40,33 @@ static const NotificationSequence sequence_saved = {
&message_vibro_off,
NULL,
};
-static const NotificationSequence sequence_not_saved = {
- &message_blink_stop,
+
+static const NotificationSequence sequence_frequency = {
+ &message_display_backlight_on,
&message_green_255,
+ &message_vibro_on,
+ &message_delay_100,
+ &message_green_0,
&message_blue_255,
- &message_red_255,
+ &message_vibro_off,
+ &message_delay_100,
+ &message_blue_0,
+ &message_green_255,
+ &message_vibro_on,
+ &message_delay_100,
+ &message_green_0,
+ &message_vibro_off,
NULL,
};
+//static const NotificationSequence sequence_not_saved = {
+// &message_blink_stop,
+// &message_green_255,
+// &message_blue_255,
+// &message_red_255,
+// NULL,
+//};
+
static const uint32_t subghz_frequency_list[] = {
300000000, 302757000, 303875000, 304250000, 307000000, 307500000, 307800000,
309000000, 310000000, 312000000, 312100000, 313000000, 313850000, 314000000,
@@ -194,8 +213,8 @@ uint32_t subghz_frequency_find_correct(uint32_t input) {
uint32_t prev_freq = 0;
uint32_t current = 0;
uint32_t result = 0;
-#if FURI_DEBUG
- FURI_LOG_D(TAG, "input: %d", input);
+#ifdef FURI_DEBUG
+ FURI_LOG_D(TAG, "input: %ld", input);
#endif
for(size_t i = 0; i < sizeof(subghz_frequency_list); i++) {
current = subghz_frequency_list[i];
@@ -255,7 +274,8 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
need_redraw = true;
}
- if(event->type == InputTypeShort && event->key == InputKeyOk) {
+ if(event->key == InputKeyOk) {
+ bool updated = false;
with_view_model(
instance->view, (SubGhzFrequencyAnalyzerModel * model) {
uint32_t prev_freq_to_save = model->frequency_to_save;
@@ -273,23 +293,48 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
frequency_candidate = subghz_frequency_find_correct(frequency_candidate);
}
if(frequency_candidate > 0 && frequency_candidate != model->frequency_to_save) {
-#if FURI_DEBUG
+#ifdef FURI_DEBUG
FURI_LOG_D(
TAG,
- "frequency_to_save: %d, candidate: %d",
+ "frequency_to_save: %ld, candidate: %ld",
model->frequency_to_save,
frequency_candidate);
#endif
model->frequency_to_save = frequency_candidate;
notification_message(instance->notifications, &sequence_saved);
- instance->callback(SubGhzCustomEventViewReceiverOK, instance->context);
- notification_message(instance->notifications, &sequence_hw_blink);
- } else {
- notification_message(instance->notifications, &sequence_not_saved);
notification_message(instance->notifications, &sequence_hw_blink);
+ updated = true;
}
return true;
});
+
+#ifdef FURI_DEBUG
+ FURI_LOG_I(
+ TAG,
+ "updated: %d, long: %d, type: %d",
+ updated,
+ (event->type == InputTypeLong),
+ event->type);
+#endif
+
+ if(updated) {
+ instance->callback(SubGhzCustomEventViewReceiverOK, instance->context);
+ }
+
+ // First device receive short, then when user release button we get long
+ if(event->type == InputTypeLong) {
+#ifdef FURI_DEBUG
+ FURI_LOG_I(TAG, "Longpress!");
+#endif
+ // Stop blinking
+ notification_message(instance->notifications, &sequence_hw_blink_stop);
+
+ // Stop worker
+ if(subghz_frequency_analyzer_worker_is_running(instance->worker)) {
+ subghz_frequency_analyzer_worker_stop(instance->worker);
+ }
+ instance->callback(SubGhzCustomEventViewReceiverUnlock, instance->context);
+ }
}
if(need_redraw) {
@@ -331,7 +376,7 @@ void subghz_frequency_analyzer_pair_callback(void* context, uint32_t frequency,
if((rssi != 0.f) && (frequency != 0)) {
// Threre is some signal
- FURI_LOG_I(TAG, "rssi = %.2f, frequency = %d Hz", (double)rssi, frequency);
+ FURI_LOG_I(TAG, "rssi = %.2f, frequency = %ld Hz", (double)rssi, frequency);
frequency = round_int(frequency, 3); // Round 299999990Hz to 300000000Hz
if(!instance->locked) {
// Triggered!
@@ -340,12 +385,13 @@ void subghz_frequency_analyzer_pair_callback(void* context, uint32_t frequency,
switch(instance->feedback_level) {
case 1: // 1 - only vibro
- notification_message(instance->notifications, &sequence_single_vibro);
+ notification_message(instance->notifications, &sequence_frequency);
break;
case 2: // 2 - vibro and beep
notification_message(instance->notifications, &sequence_success);
break;
default: // 0 - no feedback
+ notification_message(instance->notifications, &sequence_display_backlight_on);
break;
}
diff --git a/applications/main/subghz/views/subghz_read_raw.c b/applications/main/subghz/views/subghz_read_raw.c
index ccffaf42f..1b1d3c8c9 100644
--- a/applications/main/subghz/views/subghz_read_raw.c
+++ b/applications/main/subghz/views/subghz_read_raw.c
@@ -18,15 +18,16 @@ struct SubGhzReadRAW {
};
typedef struct {
- string_t frequency_str;
- string_t preset_str;
- string_t sample_write;
- string_t file_name;
+ FuriString* frequency_str;
+ FuriString* preset_str;
+ FuriString* sample_write;
+ FuriString* file_name;
uint8_t* rssi_history;
bool rssi_history_end;
uint8_t ind_write;
uint8_t ind_sin;
SubGhzReadRAWStatus status;
+ bool raw_send_only;
} SubGhzReadRAWModel;
void subghz_read_raw_set_callback(
@@ -46,8 +47,8 @@ void subghz_read_raw_add_data_statusbar(
furi_assert(instance);
with_view_model(
instance->view, (SubGhzReadRAWModel * model) {
- string_set_str(model->frequency_str, frequency_str);
- string_set_str(model->preset_str, preset_str);
+ furi_string_set(model->frequency_str, frequency_str);
+ furi_string_set(model->preset_str, preset_str);
return true;
});
}
@@ -78,7 +79,7 @@ void subghz_read_raw_update_sample_write(SubGhzReadRAW* instance, size_t sample)
with_view_model(
instance->view, (SubGhzReadRAWModel * model) {
- string_printf(model->sample_write, "%d spl.", sample);
+ furi_string_printf(model->sample_write, "%d spl.", sample);
return false;
});
}
@@ -216,10 +217,10 @@ void subghz_read_raw_draw(Canvas* canvas, SubGhzReadRAWModel* model) {
uint8_t graphics_mode = 1;
canvas_set_color(canvas, ColorBlack);
canvas_set_font(canvas, FontSecondary);
- canvas_draw_str(canvas, 5, 7, string_get_cstr(model->frequency_str));
- canvas_draw_str(canvas, 40, 7, string_get_cstr(model->preset_str));
+ canvas_draw_str(canvas, 5, 7, furi_string_get_cstr(model->frequency_str));
+ canvas_draw_str(canvas, 40, 7, furi_string_get_cstr(model->preset_str));
canvas_draw_str_aligned(
- canvas, 126, 0, AlignRight, AlignTop, string_get_cstr(model->sample_write));
+ canvas, 126, 0, AlignRight, AlignTop, furi_string_get_cstr(model->sample_write));
canvas_draw_line(canvas, 0, 14, 115, 14);
canvas_draw_line(canvas, 0, 48, 115, 48);
@@ -232,9 +233,11 @@ void subghz_read_raw_draw(Canvas* canvas, SubGhzReadRAWModel* model) {
elements_button_right(canvas, "Save");
break;
case SubGhzReadRAWStatusLoadKeyIDLE:
- elements_button_left(canvas, "New");
+ if(!model->raw_send_only) {
+ elements_button_left(canvas, "New");
+ elements_button_right(canvas, "More");
+ }
elements_button_center(canvas, "Send");
- elements_button_right(canvas, "More");
elements_text_box(
canvas,
4,
@@ -243,7 +246,7 @@ void subghz_read_raw_draw(Canvas* canvas, SubGhzReadRAWModel* model) {
30,
AlignCenter,
AlignCenter,
- string_get_cstr(model->file_name),
+ furi_string_get_cstr(model->file_name),
true);
break;
@@ -362,31 +365,35 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
} else if(event->key == InputKeyLeft && event->type == InputTypeShort) {
with_view_model(
instance->view, (SubGhzReadRAWModel * model) {
- if(model->status == SubGhzReadRAWStatusStart) {
- //Config
- instance->callback(SubGhzCustomEventViewReadRAWConfig, instance->context);
- } else if(
- (model->status == SubGhzReadRAWStatusIDLE) ||
- (model->status == SubGhzReadRAWStatusLoadKeyIDLE)) {
- //Erase
- model->status = SubGhzReadRAWStatusStart;
- model->rssi_history_end = false;
- model->ind_write = 0;
- string_set_str(model->sample_write, "0 spl.");
- string_reset(model->file_name);
- instance->callback(SubGhzCustomEventViewReadRAWErase, instance->context);
+ if(!model->raw_send_only) {
+ if(model->status == SubGhzReadRAWStatusStart) {
+ //Config
+ instance->callback(SubGhzCustomEventViewReadRAWConfig, instance->context);
+ } else if(
+ (model->status == SubGhzReadRAWStatusIDLE) ||
+ (model->status == SubGhzReadRAWStatusLoadKeyIDLE)) {
+ //Erase
+ model->status = SubGhzReadRAWStatusStart;
+ model->rssi_history_end = false;
+ model->ind_write = 0;
+ furi_string_set(model->sample_write, "0 spl.");
+ furi_string_reset(model->file_name);
+ instance->callback(SubGhzCustomEventViewReadRAWErase, instance->context);
+ }
}
return true;
});
} else if(event->key == InputKeyRight && event->type == InputTypeShort) {
with_view_model(
instance->view, (SubGhzReadRAWModel * model) {
- if(model->status == SubGhzReadRAWStatusIDLE) {
- //Save
- instance->callback(SubGhzCustomEventViewReadRAWSave, instance->context);
- } else if(model->status == SubGhzReadRAWStatusLoadKeyIDLE) {
- //More
- instance->callback(SubGhzCustomEventViewReadRAWMore, instance->context);
+ if(!model->raw_send_only) {
+ if(model->status == SubGhzReadRAWStatusIDLE) {
+ //Save
+ instance->callback(SubGhzCustomEventViewReadRAWSave, instance->context);
+ } else if(model->status == SubGhzReadRAWStatusLoadKeyIDLE) {
+ //More
+ instance->callback(SubGhzCustomEventViewReadRAWMore, instance->context);
+ }
}
return true;
});
@@ -423,8 +430,8 @@ void subghz_read_raw_set_status(
model->status = SubGhzReadRAWStatusStart;
model->rssi_history_end = false;
model->ind_write = 0;
- string_reset(model->file_name);
- string_set_str(model->sample_write, "0 spl.");
+ furi_string_reset(model->file_name);
+ furi_string_set(model->sample_write, "0 spl.");
return true;
});
break;
@@ -441,8 +448,8 @@ void subghz_read_raw_set_status(
model->status = SubGhzReadRAWStatusLoadKeyIDLE;
model->rssi_history_end = false;
model->ind_write = 0;
- string_set_str(model->file_name, file_name);
- string_set_str(model->sample_write, "RAW");
+ furi_string_set(model->file_name, file_name);
+ furi_string_set(model->sample_write, "RAW");
return true;
});
break;
@@ -451,10 +458,10 @@ void subghz_read_raw_set_status(
instance->view, (SubGhzReadRAWModel * model) {
model->status = SubGhzReadRAWStatusLoadKeyIDLE;
if(!model->ind_write) {
- string_set_str(model->file_name, file_name);
- string_set_str(model->sample_write, "RAW");
+ furi_string_set(model->file_name, file_name);
+ furi_string_set(model->sample_write, "RAW");
} else {
- string_reset(model->file_name);
+ furi_string_reset(model->file_name);
}
return true;
});
@@ -487,7 +494,7 @@ void subghz_read_raw_exit(void* context) {
});
}
-SubGhzReadRAW* subghz_read_raw_alloc() {
+SubGhzReadRAW* subghz_read_raw_alloc(bool raw_send_only) {
SubGhzReadRAW* instance = malloc(sizeof(SubGhzReadRAW));
// View allocation and configuration
@@ -501,10 +508,11 @@ SubGhzReadRAW* subghz_read_raw_alloc() {
with_view_model(
instance->view, (SubGhzReadRAWModel * model) {
- string_init(model->frequency_str);
- string_init(model->preset_str);
- string_init(model->sample_write);
- string_init(model->file_name);
+ model->frequency_str = furi_string_alloc();
+ model->preset_str = furi_string_alloc();
+ model->sample_write = furi_string_alloc();
+ model->file_name = furi_string_alloc();
+ model->raw_send_only = raw_send_only;
model->rssi_history = malloc(SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE * sizeof(uint8_t));
return true;
});
@@ -517,10 +525,10 @@ void subghz_read_raw_free(SubGhzReadRAW* instance) {
with_view_model(
instance->view, (SubGhzReadRAWModel * model) {
- string_clear(model->frequency_str);
- string_clear(model->preset_str);
- string_clear(model->sample_write);
- string_clear(model->file_name);
+ furi_string_free(model->frequency_str);
+ furi_string_free(model->preset_str);
+ furi_string_free(model->sample_write);
+ furi_string_free(model->file_name);
free(model->rssi_history);
return true;
});
diff --git a/applications/main/subghz/views/subghz_read_raw.h b/applications/main/subghz/views/subghz_read_raw.h
index 1d4bb7dc0..a4e16ca98 100644
--- a/applications/main/subghz/views/subghz_read_raw.h
+++ b/applications/main/subghz/views/subghz_read_raw.h
@@ -25,7 +25,7 @@ void subghz_read_raw_set_callback(
SubGhzReadRAWCallback callback,
void* context);
-SubGhzReadRAW* subghz_read_raw_alloc();
+SubGhzReadRAW* subghz_read_raw_alloc(bool raw_send_only);
void subghz_read_raw_free(SubGhzReadRAW* subghz_static);
diff --git a/applications/main/subghz/views/transmitter.c b/applications/main/subghz/views/transmitter.c
index 2055180a6..75828a13b 100644
--- a/applications/main/subghz/views/transmitter.c
+++ b/applications/main/subghz/views/transmitter.c
@@ -11,9 +11,9 @@ struct SubGhzViewTransmitter {
};
typedef struct {
- string_t frequency_str;
- string_t preset_str;
- string_t key_str;
+ FuriString* frequency_str;
+ FuriString* preset_str;
+ FuriString* key_str;
uint8_t show_button;
} SubGhzViewTransmitterModel;
@@ -36,9 +36,9 @@ void subghz_view_transmitter_add_data_to_show(
furi_assert(subghz_transmitter);
with_view_model(
subghz_transmitter->view, (SubGhzViewTransmitterModel * model) {
- string_set_str(model->key_str, key_str);
- string_set_str(model->frequency_str, frequency_str);
- string_set_str(model->preset_str, preset_str);
+ furi_string_set(model->key_str, key_str);
+ furi_string_set(model->frequency_str, frequency_str);
+ furi_string_set(model->preset_str, preset_str);
model->show_button = show_button;
return true;
});
@@ -82,9 +82,9 @@ void subghz_view_transmitter_draw(Canvas* canvas, SubGhzViewTransmitterModel* mo
canvas_clear(canvas);
canvas_set_color(canvas, ColorBlack);
canvas_set_font(canvas, FontSecondary);
- elements_multiline_text(canvas, 0, 7, string_get_cstr(model->key_str));
- canvas_draw_str(canvas, 78, 7, string_get_cstr(model->frequency_str));
- canvas_draw_str(canvas, 113, 7, string_get_cstr(model->preset_str));
+ elements_multiline_text(canvas, 0, 7, furi_string_get_cstr(model->key_str));
+ canvas_draw_str(canvas, 78, 7, furi_string_get_cstr(model->frequency_str));
+ canvas_draw_str(canvas, 113, 7, furi_string_get_cstr(model->preset_str));
if(model->show_button) subghz_view_transmitter_button_right(canvas, "Send");
}
@@ -96,9 +96,9 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) {
if(event->key == InputKeyBack && event->type == InputTypeShort) {
with_view_model(
subghz_transmitter->view, (SubGhzViewTransmitterModel * model) {
- string_reset(model->frequency_str);
- string_reset(model->preset_str);
- string_reset(model->key_str);
+ furi_string_reset(model->frequency_str);
+ furi_string_reset(model->preset_str);
+ furi_string_reset(model->key_str);
model->show_button = 0;
return false;
});
@@ -150,9 +150,9 @@ SubGhzViewTransmitter* subghz_view_transmitter_alloc() {
with_view_model(
subghz_transmitter->view, (SubGhzViewTransmitterModel * model) {
- string_init(model->frequency_str);
- string_init(model->preset_str);
- string_init(model->key_str);
+ model->frequency_str = furi_string_alloc();
+ model->preset_str = furi_string_alloc();
+ model->key_str = furi_string_alloc();
return true;
});
return subghz_transmitter;
@@ -163,9 +163,9 @@ void subghz_view_transmitter_free(SubGhzViewTransmitter* subghz_transmitter) {
with_view_model(
subghz_transmitter->view, (SubGhzViewTransmitterModel * model) {
- string_clear(model->frequency_str);
- string_clear(model->preset_str);
- string_clear(model->key_str);
+ furi_string_free(model->frequency_str);
+ furi_string_free(model->preset_str);
+ furi_string_free(model->key_str);
return true;
});
view_free(subghz_transmitter->view);
diff --git a/applications/main/u2f/u2f_data.c b/applications/main/u2f/u2f_data.c
index 117fbdbe3..900af462a 100644
--- a/applications/main/u2f/u2f_data.c
+++ b/applications/main/u2f/u2f_data.c
@@ -181,8 +181,8 @@ bool u2f_data_cert_key_load(uint8_t* cert_key) {
// Check if unique key exists in secure eclave and generate it if missing
if(!furi_hal_crypto_verify_key(U2F_DATA_FILE_ENCRYPTION_KEY_SLOT_UNIQUE)) return false;
- string_t filetype;
- string_init(filetype);
+ FuriString* filetype;
+ filetype = furi_string_alloc();
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* flipper_format = flipper_format_file_alloc(storage);
@@ -194,7 +194,7 @@ bool u2f_data_cert_key_load(uint8_t* cert_key) {
break;
}
- if(strcmp(string_get_cstr(filetype), U2F_CERT_KEY_FILE_TYPE) != 0 ||
+ if(strcmp(furi_string_get_cstr(filetype), U2F_CERT_KEY_FILE_TYPE) != 0 ||
version != U2F_CERT_KEY_VERSION) {
FURI_LOG_E(TAG, "Type or version mismatch");
break;
@@ -250,7 +250,7 @@ bool u2f_data_cert_key_load(uint8_t* cert_key) {
flipper_format_free(flipper_format);
furi_record_close(RECORD_STORAGE);
- string_clear(filetype);
+ furi_string_free(filetype);
if(cert_type == U2F_CERT_USER_UNENCRYPTED) {
return u2f_data_cert_key_encrypt(cert_key);
@@ -267,8 +267,8 @@ bool u2f_data_key_load(uint8_t* device_key) {
uint8_t key[48];
uint32_t version = 0;
- string_t filetype;
- string_init(filetype);
+ FuriString* filetype;
+ filetype = furi_string_alloc();
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* flipper_format = flipper_format_file_alloc(storage);
@@ -279,7 +279,7 @@ bool u2f_data_key_load(uint8_t* device_key) {
FURI_LOG_E(TAG, "Missing or incorrect header");
break;
}
- if(strcmp(string_get_cstr(filetype), U2F_DEVICE_KEY_FILE_TYPE) != 0 ||
+ if(strcmp(furi_string_get_cstr(filetype), U2F_DEVICE_KEY_FILE_TYPE) != 0 ||
version != U2F_DEVICE_KEY_VERSION) {
FURI_LOG_E(TAG, "Type or version mismatch");
break;
@@ -308,7 +308,7 @@ bool u2f_data_key_load(uint8_t* device_key) {
}
flipper_format_free(flipper_format);
furi_record_close(RECORD_STORAGE);
- string_clear(filetype);
+ furi_string_free(filetype);
return state;
}
@@ -366,8 +366,8 @@ bool u2f_data_cnt_read(uint32_t* cnt_val) {
uint8_t cnt_encr[48];
uint32_t version = 0;
- string_t filetype;
- string_init(filetype);
+ FuriString* filetype;
+ filetype = furi_string_alloc();
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* flipper_format = flipper_format_file_alloc(storage);
@@ -378,7 +378,7 @@ bool u2f_data_cnt_read(uint32_t* cnt_val) {
FURI_LOG_E(TAG, "Missing or incorrect header");
break;
}
- if(strcmp(string_get_cstr(filetype), U2F_COUNTER_FILE_TYPE) != 0) {
+ if(strcmp(furi_string_get_cstr(filetype), U2F_COUNTER_FILE_TYPE) != 0) {
FURI_LOG_E(TAG, "Type mismatch");
break;
}
@@ -417,7 +417,7 @@ bool u2f_data_cnt_read(uint32_t* cnt_val) {
}
flipper_format_free(flipper_format);
furi_record_close(RECORD_STORAGE);
- string_clear(filetype);
+ furi_string_free(filetype);
if(old_counter && state) {
// Change counter endianness and rewrite counter file
diff --git a/applications/main/unirfremix/unirfremix_app.c b/applications/main/unirfremix/unirfremix_app.c
index 7e6797fbd..6d0fa60b4 100644
--- a/applications/main/unirfremix/unirfremix_app.c
+++ b/applications/main/unirfremix/unirfremix_app.c
@@ -27,9 +27,9 @@
typedef struct {
uint32_t frequency;
- string_t name;
+ FuriString* name;
- string_t protocol;
+ FuriString* protocol;
uint32_t repeat;
uint8_t* data;
@@ -52,20 +52,19 @@ typedef struct {
NotificationApp* notification;
UniRFPreset* txpreset;
- string_t up_file;
- string_t down_file;
- string_t left_file;
- string_t right_file;
- string_t ok_file;
- string_t empty;
+ FuriString* up_file;
+ FuriString* down_file;
+ FuriString* left_file;
+ FuriString* right_file;
+ FuriString* ok_file;
- string_t up_l;
- string_t left_l;
- string_t right_l;
- string_t down_l;
- string_t ok_l;
+ FuriString* up_l;
+ FuriString* left_l;
+ FuriString* right_l;
+ FuriString* down_l;
+ FuriString* ok_l;
- string_t file_path;
+ FuriString* file_path;
char* up_label;
char* down_label;
@@ -92,20 +91,20 @@ typedef struct {
bool tx_not_allowed;
int file_blank;
- string_t signal;
+ FuriString* signal;
} UniRFRemix;
UniRFPreset* unirfremix_preset_alloc(void) {
UniRFPreset* preset = malloc(sizeof(UniRFPreset));
- string_init(preset->name);
- string_init(preset->protocol);
+ preset->name = furi_string_alloc();
+ preset->protocol = furi_string_alloc();
preset->repeat = 200;
return preset;
}
void unirfremix_preset_free(UniRFPreset* preset) {
- string_clear(preset->name);
- string_clear(preset->protocol);
+ furi_string_free(preset->name);
+ furi_string_free(preset->protocol);
free(preset);
}
@@ -147,13 +146,13 @@ static const char* int_to_char(int number) {
*/
//get filename without path
static char* extract_filename(const char* name, int len) {
- string_t tmp;
- string_init(tmp);
+ FuriString* tmp;
+ tmp = furi_string_alloc();
//remove path
path_extract_filename_no_ext(name, tmp);
- return char_to_str((char*)string_get_cstr(tmp), len);
+ return char_to_str((char*)furi_string_get_cstr(tmp), len);
}
/*
@@ -165,7 +164,7 @@ static char* extract_filename(const char* name, int len) {
* set error flag if missing map file
*/
-void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
+void unirfremix_cfg_set_check(UniRFRemix* app, FuriString* file_name) {
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
@@ -178,11 +177,11 @@ void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
app->right_enabled = 1;
app->ok_enabled = 1;
- int label_len = 12;
+ int label_len = 16;
//check that map file exists
- if(!flipper_format_file_open_existing(fff_data_file, string_get_cstr(file_name))) {
- FURI_LOG_E(TAG, "Could not open MAP file %s", string_get_cstr(file_name));
+ if(!flipper_format_file_open_existing(fff_data_file, furi_string_get_cstr(file_name))) {
+ FURI_LOG_E(TAG, "Could not open MAP file %s", furi_string_get_cstr(file_name));
} else {
//Filename Assignment/Check Start
@@ -199,8 +198,8 @@ void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
} else {
//check name length for proper screen fit
//then set filename as label. Might be replaced with defined label later on below.
- app->up_label = extract_filename(string_get_cstr(app->up_file), label_len);
- FURI_LOG_I(TAG, "UP file: %s", string_get_cstr(app->up_file));
+ app->up_label = extract_filename(furi_string_get_cstr(app->up_file), label_len);
+ FURI_LOG_I(TAG, "UP file: %s", furi_string_get_cstr(app->up_file));
}
//Repeat process for Down
@@ -210,8 +209,8 @@ void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
app->down_label = "N/A";
app->down_enabled = 0;
} else {
- app->down_label = extract_filename(string_get_cstr(app->down_file), label_len);
- FURI_LOG_I(TAG, "DOWN file: %s", string_get_cstr(app->down_file));
+ app->down_label = extract_filename(furi_string_get_cstr(app->down_file), label_len);
+ FURI_LOG_I(TAG, "DOWN file: %s", furi_string_get_cstr(app->down_file));
}
//Repeat process for Left
@@ -221,8 +220,8 @@ void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
app->left_label = "N/A";
app->left_enabled = 0;
} else {
- app->left_label = extract_filename(string_get_cstr(app->left_file), label_len);
- FURI_LOG_I(TAG, "LEFT file: %s", string_get_cstr(app->left_file));
+ app->left_label = extract_filename(furi_string_get_cstr(app->left_file), label_len);
+ FURI_LOG_I(TAG, "LEFT file: %s", furi_string_get_cstr(app->left_file));
}
//Repeat process for Right
@@ -232,8 +231,8 @@ void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
app->right_label = "N/A";
app->right_enabled = 0;
} else {
- app->right_label = extract_filename(string_get_cstr(app->right_file), label_len);
- FURI_LOG_I(TAG, "RIGHT file: %s", string_get_cstr(app->right_file));
+ app->right_label = extract_filename(furi_string_get_cstr(app->right_file), label_len);
+ FURI_LOG_I(TAG, "RIGHT file: %s", furi_string_get_cstr(app->right_file));
}
//Repeat process for Ok
@@ -243,8 +242,8 @@ void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
app->ok_label = "N/A";
app->ok_enabled = 0;
} else {
- app->ok_label = extract_filename(string_get_cstr(app->ok_file), label_len);
- FURI_LOG_I(TAG, "OK file: %s", string_get_cstr(app->ok_file));
+ app->ok_label = extract_filename(furi_string_get_cstr(app->ok_file), label_len);
+ FURI_LOG_I(TAG, "OK file: %s", furi_string_get_cstr(app->ok_file));
}
//File definitions are done.
@@ -265,7 +264,7 @@ void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
app->up_label = "N/A";
} else {
//set label from map to variable and shrink to fit screen
- app->up_label = char_to_str((char*)string_get_cstr(app->up_l), label_len);
+ app->up_label = char_to_str((char*)furi_string_get_cstr(app->up_l), label_len);
}
FURI_LOG_I(TAG, "UP label: %s", app->up_label);
}
@@ -279,7 +278,7 @@ void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
if(app->down_enabled == 0) {
app->down_label = "N/A";
} else {
- app->down_label = char_to_str((char*)string_get_cstr(app->down_l), label_len);
+ app->down_label = char_to_str((char*)furi_string_get_cstr(app->down_l), label_len);
}
FURI_LOG_I(TAG, "DOWN label: %s", app->down_label);
}
@@ -293,7 +292,7 @@ void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
if(app->left_enabled == 0) {
app->left_label = "N/A";
} else {
- app->left_label = char_to_str((char*)string_get_cstr(app->left_l), label_len);
+ app->left_label = char_to_str((char*)furi_string_get_cstr(app->left_l), label_len);
}
FURI_LOG_I(TAG, "LEFT label: %s", app->left_label);
}
@@ -307,7 +306,8 @@ void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
if(app->right_enabled == 0) {
app->right_label = "N/A";
} else {
- app->right_label = char_to_str((char*)string_get_cstr(app->right_l), label_len);
+ app->right_label =
+ char_to_str((char*)furi_string_get_cstr(app->right_l), label_len);
}
FURI_LOG_I(TAG, "RIGHT label: %s", app->right_label);
}
@@ -321,7 +321,7 @@ void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
if(app->ok_enabled == 0) {
app->ok_label = "N/A";
} else {
- app->ok_label = char_to_str((char*)string_get_cstr(app->ok_l), label_len);
+ app->ok_label = char_to_str((char*)furi_string_get_cstr(app->ok_l), label_len);
}
FURI_LOG_I(TAG, "OK label: %s", app->ok_label);
}
@@ -351,11 +351,11 @@ void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
//if button is still enabled, check that file exists
if(app->up_enabled == 1) {
- string_set(file_name, app->up_file);
+ furi_string_set(file_name, app->up_file);
fff_data_file = flipper_format_file_alloc(storage);
- if(!flipper_format_file_open_existing(fff_data_file, string_get_cstr(file_name))) {
- FURI_LOG_W(TAG, "Could not open UP file %s", string_get_cstr(file_name));
+ if(!flipper_format_file_open_existing(fff_data_file, furi_string_get_cstr(file_name))) {
+ FURI_LOG_W(TAG, "Could not open UP file %s", furi_string_get_cstr(file_name));
//disable button, and set label to "N/A"
app->up_enabled = 0;
@@ -369,11 +369,11 @@ void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
}
if(app->down_enabled == 1) {
- string_set(file_name, app->down_file);
+ furi_string_set(file_name, app->down_file);
fff_data_file = flipper_format_file_alloc(storage);
- if(!flipper_format_file_open_existing(fff_data_file, string_get_cstr(file_name))) {
- FURI_LOG_W(TAG, "Could not open DOWN file %s", string_get_cstr(file_name));
+ if(!flipper_format_file_open_existing(fff_data_file, furi_string_get_cstr(file_name))) {
+ FURI_LOG_W(TAG, "Could not open DOWN file %s", furi_string_get_cstr(file_name));
app->down_enabled = 0;
app->down_label = "N/A";
@@ -385,11 +385,11 @@ void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
}
if(app->left_enabled == 1) {
- string_set(file_name, app->left_file);
+ furi_string_set(file_name, app->left_file);
fff_data_file = flipper_format_file_alloc(storage);
- if(!flipper_format_file_open_existing(fff_data_file, string_get_cstr(file_name))) {
- FURI_LOG_W(TAG, "Could not open LEFT file %s", string_get_cstr(file_name));
+ if(!flipper_format_file_open_existing(fff_data_file, furi_string_get_cstr(file_name))) {
+ FURI_LOG_W(TAG, "Could not open LEFT file %s", furi_string_get_cstr(file_name));
app->left_enabled = 0;
app->left_label = "N/A";
@@ -401,11 +401,11 @@ void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
}
if(app->right_enabled == 1) {
- string_set(file_name, app->right_file);
+ furi_string_set(file_name, app->right_file);
fff_data_file = flipper_format_file_alloc(storage);
- if(!flipper_format_file_open_existing(fff_data_file, string_get_cstr(file_name))) {
- FURI_LOG_W(TAG, "Could not open RIGHT file %s", string_get_cstr(file_name));
+ if(!flipper_format_file_open_existing(fff_data_file, furi_string_get_cstr(file_name))) {
+ FURI_LOG_W(TAG, "Could not open RIGHT file %s", furi_string_get_cstr(file_name));
app->right_enabled = 0;
app->right_label = "N/A";
@@ -417,11 +417,11 @@ void unirfremix_cfg_set_check(UniRFRemix* app, string_t file_name) {
}
if(app->ok_enabled == 1) {
- string_set(file_name, app->ok_file);
+ furi_string_set(file_name, app->ok_file);
fff_data_file = flipper_format_file_alloc(storage);
- if(!flipper_format_file_open_existing(fff_data_file, string_get_cstr(file_name))) {
- FURI_LOG_W(TAG, "Could not open OK file %s", string_get_cstr(file_name));
+ if(!flipper_format_file_open_existing(fff_data_file, furi_string_get_cstr(file_name))) {
+ FURI_LOG_W(TAG, "Could not open OK file %s", furi_string_get_cstr(file_name));
app->ok_enabled = 0;
app->ok_label = "N/A";
@@ -448,17 +448,17 @@ static void unirfremix_end_send(UniRFRemix* app) {
bool unirfremix_set_preset(UniRFPreset* p, const char* preset) {
if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) {
- string_set(p->name, "AM270");
+ furi_string_set(p->name, "AM270");
} else if(!strcmp(preset, "FuriHalSubGhzPresetOok650Async")) {
- string_set(p->name, "AM650");
+ furi_string_set(p->name, "AM650");
} else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev238Async")) {
- string_set(p->name, "FM238");
+ furi_string_set(p->name, "FM238");
} else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev476Async")) {
- string_set(p->name, "FM476");
+ furi_string_set(p->name, "FM476");
} else if(!strcmp(preset, "FuriHalSubGhzPresetCustom")) {
FURI_LOG_E(TAG, "Custom preset unsupported now");
return false;
- // string_set(p->name, "CUSTOM");
+ // furi_string_set(p->name, "CUSTOM");
} else {
FURI_LOG_E(TAG, "Unsupported preset");
return false;
@@ -479,8 +479,8 @@ bool unirfremix_key_load(
return false;
}
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
bool res = false;
@@ -494,19 +494,19 @@ bool unirfremix_key_load(
// load preset from file
if(!flipper_format_read_string(fff_file, "Preset", temp_str)) {
FURI_LOG_W(TAG, "Could not read Preset. Defaulting to Ook650Async");
- string_set(temp_str, "FuriHalSubGhzPresetOok650Async");
+ furi_string_set(temp_str, "FuriHalSubGhzPresetOok650Async");
}
- if(!unirfremix_set_preset(preset, string_get_cstr(temp_str))) {
+ if(!unirfremix_set_preset(preset, furi_string_get_cstr(temp_str))) {
FURI_LOG_E(TAG, "Could not set preset");
break;
}
- if(!strcmp(string_get_cstr(temp_str), "FuriHalSubGhzPresetCustom")) {
+ if(!strcmp(furi_string_get_cstr(temp_str), "FuriHalSubGhzPresetCustom")) {
// TODO: check if preset is custom
FURI_LOG_E(TAG, "Could not use custom preset");
break;
}
size_t preset_index =
- subghz_setting_get_inx_preset_by_name(setting, string_get_cstr(preset->name));
+ subghz_setting_get_inx_preset_by_name(setting, furi_string_get_cstr(preset->name));
preset->data = subghz_setting_get_preset_data(setting, preset_index);
preset->data_size = subghz_setting_get_preset_data_size(setting, preset_index);
@@ -515,7 +515,7 @@ bool unirfremix_key_load(
FURI_LOG_E(TAG, "Could not read Protocol.");
break;
}
- if(!string_cmp_str(preset->protocol, "RAW")) {
+ if(!furi_string_cmp_str(preset->protocol, "RAW")) {
subghz_protocol_raw_gen_fff_data(fff_data, path);
} else {
stream_copy_full(
@@ -529,19 +529,19 @@ bool unirfremix_key_load(
}
preset->decoder = subghz_receiver_search_decoder_base_by_name(
- receiver, string_get_cstr(preset->protocol));
+ receiver, furi_string_get_cstr(preset->protocol));
if(preset->decoder) {
if(!subghz_protocol_decoder_base_deserialize(preset->decoder, fff_data)) {
break;
}
} else {
- FURI_LOG_E(TAG, "Protocol %s not found", string_get_cstr(temp_str));
+ FURI_LOG_E(TAG, "Protocol %s not found", furi_string_get_cstr(temp_str));
}
res = true;
} while(0);
- string_clear(temp_str);
+ furi_string_free(temp_str);
return res;
}
@@ -556,15 +556,15 @@ bool unirfremix_save_protocol_to_file(FlipperFormat* fff_file, const char* dev_f
Stream* flipper_format_stream = flipper_format_get_raw_stream(fff_file);
bool saved = false;
- string_t file_dir;
- string_init(file_dir);
+ FuriString* file_dir;
+ file_dir = furi_string_alloc();
path_extract_dirname(dev_file_name, file_dir);
do {
flipper_format_delete_key(fff_file, "Repeat");
flipper_format_delete_key(fff_file, "Manufacture");
- if(!storage_simply_mkdir(storage, string_get_cstr(file_dir))) {
+ if(!storage_simply_mkdir(storage, furi_string_get_cstr(file_dir))) {
FURI_LOG_E(TAG, "(save) Cannot mkdir");
break;
}
@@ -580,7 +580,7 @@ bool unirfremix_save_protocol_to_file(FlipperFormat* fff_file, const char* dev_f
saved = true;
FURI_LOG_D(TAG, "(save) OK Save");
} while(0);
- string_clear(file_dir);
+ furi_string_free(file_dir);
furi_record_close(RECORD_STORAGE);
return saved;
}
@@ -590,7 +590,7 @@ void unirfremix_tx_stop(UniRFRemix* app) {
return;
}
- if(!string_cmp_str(app->txpreset->protocol, "RAW")) {
+ if(!furi_string_cmp_str(app->txpreset->protocol, "RAW")) {
while(!furi_hal_subghz_is_async_tx_complete()) {
furi_delay_ms(15);
}
@@ -603,7 +603,7 @@ void unirfremix_tx_stop(UniRFRemix* app) {
FURI_LOG_D(TAG, "Checking if protocol is dynamic");
const SubGhzProtocol* registry =
- subghz_protocol_registry_get_by_name(string_get_cstr(app->txpreset->protocol));
+ subghz_protocol_registry_get_by_name(furi_string_get_cstr(app->txpreset->protocol));
FURI_LOG_D(TAG, "Protocol-TYPE %d", registry->type);
if(registry && registry->type == SubGhzProtocolTypeDynamic) {
FURI_LOG_D(TAG, "Protocol is dynamic. Saving key");
@@ -642,7 +642,7 @@ static bool unirfremix_send_sub(UniRFRemix* app, FlipperFormat* fff_data) {
}
app->tx_transmitter = subghz_transmitter_alloc_init(
- app->environment, string_get_cstr(app->txpreset->protocol));
+ app->environment, furi_string_get_cstr(app->txpreset->protocol));
if(!app->tx_transmitter) {
break;
}
@@ -713,16 +713,16 @@ static void unirfremix_send_signal(UniRFRemix* app, Storage* storage, const char
unirfremix_send_sub(app, app->tx_fff_data);
}
-static void unirfremix_process_signal(UniRFRemix* app, string_t signal) {
+static void unirfremix_process_signal(UniRFRemix* app, FuriString* signal) {
view_port_update(app->view_port);
- FURI_LOG_I(TAG, "signal = %s", string_get_cstr(signal));
+ FURI_LOG_I(TAG, "signal = %s", furi_string_get_cstr(signal));
- if(strlen(string_get_cstr(signal)) > 12) {
+ if(strlen(furi_string_get_cstr(signal)) > 12) {
Storage* storage = furi_record_open(RECORD_STORAGE);
- unirfremix_send_signal(app, storage, string_get_cstr(signal));
+ unirfremix_send_signal(app, storage, furi_string_get_cstr(signal));
furi_record_close(RECORD_STORAGE);
- } else if(strlen(string_get_cstr(signal)) < 10) {
+ } else if(strlen(furi_string_get_cstr(signal)) < 10) {
unirfremix_end_send(app);
}
}
@@ -827,7 +827,7 @@ static void input_callback(InputEvent* input_event, void* ctx) {
void unirfremix_subghz_alloc(UniRFRemix* app) {
// load subghz presets
app->setting = subghz_setting_alloc();
- subghz_setting_load(app->setting, EXT_PATH("subghz/assets/setting_user"));
+ subghz_setting_load(app->setting, EXT_PATH("subghz/assets/setting_user"), false);
// load mfcodes
app->environment = subghz_environment_alloc();
@@ -867,21 +867,20 @@ UniRFRemix* unirfremix_alloc(void) {
void unirfremix_free(UniRFRemix* app, bool with_subghz) {
furi_hal_power_suppress_charge_exit();
- string_clear(app->up_file);
- string_clear(app->down_file);
- string_clear(app->left_file);
- string_clear(app->right_file);
- string_clear(app->ok_file);
- string_clear(app->empty);
+ furi_string_free(app->up_file);
+ furi_string_free(app->down_file);
+ furi_string_free(app->left_file);
+ furi_string_free(app->right_file);
+ furi_string_free(app->ok_file);
- string_clear(app->up_l);
- string_clear(app->down_l);
- string_clear(app->left_l);
- string_clear(app->right_l);
- string_clear(app->ok_l);
+ furi_string_free(app->up_l);
+ furi_string_free(app->down_l);
+ furi_string_free(app->left_l);
+ furi_string_free(app->right_l);
+ furi_string_free(app->ok_l);
- string_clear(app->file_path);
- string_clear(app->signal);
+ furi_string_free(app->file_path);
+ furi_string_free(app->signal);
gui_remove_view_port(app->gui, app->view_port);
furi_record_close(RECORD_GUI);
@@ -909,21 +908,21 @@ int32_t unirfremix_app(void* p) {
UNUSED(p);
UniRFRemix* app = unirfremix_alloc();
- string_init(app->file_path);
+ app->file_path = furi_string_alloc();
+ app->signal = furi_string_alloc();
//setup variables before population
- string_init(app->up_file);
- string_init(app->down_file);
- string_init(app->left_file);
- string_init(app->right_file);
- string_init(app->ok_file);
- string_init(app->empty);
+ app->up_file = furi_string_alloc();
+ app->down_file = furi_string_alloc();
+ app->left_file = furi_string_alloc();
+ app->right_file = furi_string_alloc();
+ app->ok_file = furi_string_alloc();
- string_init(app->up_l);
- string_init(app->down_l);
- string_init(app->left_l);
- string_init(app->right_l);
- string_init(app->ok_l);
+ app->up_l = furi_string_alloc();
+ app->down_l = furi_string_alloc();
+ app->left_l = furi_string_alloc();
+ app->right_l = furi_string_alloc();
+ app->ok_l = furi_string_alloc();
app->file_result = 3;
@@ -933,7 +932,7 @@ int32_t unirfremix_app(void* p) {
}
furi_record_close(RECORD_STORAGE);
- string_set_str(app->file_path, UNIRFMAP_FOLDER);
+ furi_string_set(app->file_path, UNIRFMAP_FOLDER);
DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
@@ -961,11 +960,11 @@ int32_t unirfremix_app(void* p) {
FURI_LOG_D(
TAG,
"U: %s - D: %s - L: %s - R: %s - O: %s ",
- string_get_cstr(app->up_file),
- string_get_cstr(app->down_file),
- string_get_cstr(app->left_file),
- string_get_cstr(app->right_file),
- string_get_cstr(app->ok_file));
+ furi_string_get_cstr(app->up_file),
+ furi_string_get_cstr(app->down_file),
+ furi_string_get_cstr(app->left_file),
+ furi_string_get_cstr(app->right_file),
+ furi_string_get_cstr(app->ok_file));
//variables to control multiple button presses and status updates
app->send_status = "Idle";
@@ -994,8 +993,8 @@ int32_t unirfremix_app(void* p) {
if(input.type == InputTypePress) {
if(app->up_enabled) {
if(app->processing == 0) {
- *app->signal = *app->empty;
- *app->signal = *app->up_file;
+ furi_string_reset(app->signal);
+ furi_string_set(app->signal, app->up_file);
app->button = 1;
app->processing = 1;
}
@@ -1012,8 +1011,8 @@ int32_t unirfremix_app(void* p) {
if(input.type == InputTypePress) {
if(app->down_enabled) {
if(app->processing == 0) {
- *app->signal = *app->empty;
- *app->signal = *app->down_file;
+ furi_string_reset(app->signal);
+ furi_string_set(app->signal, app->down_file);
app->button = 2;
app->processing = 1;
}
@@ -1030,8 +1029,8 @@ int32_t unirfremix_app(void* p) {
if(input.type == InputTypePress) {
if(app->right_enabled) {
if(app->processing == 0) {
- *app->signal = *app->empty;
- *app->signal = *app->right_file;
+ furi_string_reset(app->signal);
+ furi_string_set(app->signal, app->right_file);
app->button = 3;
app->processing = 1;
}
@@ -1048,8 +1047,8 @@ int32_t unirfremix_app(void* p) {
if(input.type == InputTypePress) {
if(app->left_enabled) {
if(app->processing == 0) {
- *app->signal = *app->empty;
- *app->signal = *app->left_file;
+ furi_string_reset(app->signal);
+ furi_string_set(app->signal, app->left_file);
app->button = 4;
app->processing = 1;
}
@@ -1066,8 +1065,8 @@ int32_t unirfremix_app(void* p) {
if(input.type == InputTypePress) {
if(app->ok_enabled) {
if(app->processing == 0) {
- *app->signal = *app->empty;
- *app->signal = *app->ok_file;
+ furi_string_reset(app->signal);
+ furi_string_set(app->signal, app->ok_file);
app->button = 5;
app->processing = 1;
}
diff --git a/applications/plugins/arkanoid/application.fam b/applications/plugins/arkanoid/application.fam
index 99a2f10bc..05520b4bf 100644
--- a/applications/plugins/arkanoid/application.fam
+++ b/applications/plugins/arkanoid/application.fam
@@ -1,5 +1,5 @@
App(
- appid="arkanoid_game",
+ appid="Arkanoid",
name="Arkanoid",
apptype=FlipperAppType.EXTERNAL,
entry_point="arkanoid_game_app",
diff --git a/applications/plugins/barcode_generator/application.fam b/applications/plugins/barcode_generator/application.fam
index 05ddbae0f..0724fdfba 100644
--- a/applications/plugins/barcode_generator/application.fam
+++ b/applications/plugins/barcode_generator/application.fam
@@ -1,5 +1,5 @@
App(
- appid="barcode_generator",
+ appid="Barcode_Generator",
name="UPC-A Generator",
apptype=FlipperAppType.EXTERNAL,
entry_point="barcode_UPCA_generator_app",
diff --git a/applications/plugins/bt_hid_app/application.fam b/applications/plugins/bt_hid_app/application.fam
index e6a3b1752..e18783e9a 100644
--- a/applications/plugins/bt_hid_app/application.fam
+++ b/applications/plugins/bt_hid_app/application.fam
@@ -1,5 +1,5 @@
App(
- appid="bt_hid",
+ appid="Bluetooth_Remote",
name="Bluetooth Remote",
apptype=FlipperAppType.PLUGIN,
entry_point="bt_hid_app",
diff --git a/applications/plugins/bt_hid_app/views/bt_hid_keyboard.c b/applications/plugins/bt_hid_app/views/bt_hid_keyboard.c
index 3617dc0f1..8b9ae593a 100644
--- a/applications/plugins/bt_hid_app/views/bt_hid_keyboard.c
+++ b/applications/plugins/bt_hid_app/views/bt_hid_keyboard.c
@@ -209,6 +209,11 @@ static void bt_hid_keyboard_draw_callback(Canvas* canvas, void* context) {
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
canvas_set_font(canvas, FontPrimary);
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Keyboard");
+
+ canvas_draw_icon(canvas, 68, 3, &I_Pin_back_arrow_10x8);
+ canvas_set_font(canvas, FontSecondary);
+ elements_multiline_text_aligned(canvas, 127, 4, AlignRight, AlignTop, "Hold to exit");
+
elements_multiline_text_aligned(
canvas, 4, 60, AlignLeft, AlignBottom, "Waiting for Connection...");
return; // Dont render the keyboard if we are not yet connected
diff --git a/applications/plugins/doom/application.fam b/applications/plugins/doom/application.fam
index a032e14eb..d9ae4d67d 100644
--- a/applications/plugins/doom/application.fam
+++ b/applications/plugins/doom/application.fam
@@ -1,5 +1,5 @@
App(
- appid="game_doom",
+ appid="DOOM",
name="DOOM",
apptype=FlipperAppType.EXTERNAL,
entry_point="doom_app",
diff --git a/applications/plugins/doom/doom_music_player_worker.c b/applications/plugins/doom/doom_music_player_worker.c
index 406cf0576..d691f3cae 100644
--- a/applications/plugins/doom/doom_music_player_worker.c
+++ b/applications/plugins/doom/doom_music_player_worker.c
@@ -258,7 +258,7 @@ static bool music_player_worker_parse_notes(MusicPlayerWorker* instance, const c
if(!is_valid) {
FURI_LOG_E(
TAG,
- "Invalid note: %u%c%c%u.%u",
+ "Invalid note: %lu%c%c%lu.%lu",
duration,
note_char == '\0' ? '_' : note_char,
sharp_char == '\0' ? '_' : sharp_char,
@@ -281,7 +281,7 @@ static bool music_player_worker_parse_notes(MusicPlayerWorker* instance, const c
if(music_player_worker_add_note(instance, semitone, duration, dots)) {
FURI_LOG_D(
TAG,
- "Added note: %c%c%u.%u = %u %u",
+ "Added note: %c%c%lu.%lu = %u %lu",
note_char == '\0' ? '_' : note_char,
sharp_char == '\0' ? '_' : sharp_char,
octave,
@@ -291,7 +291,7 @@ static bool music_player_worker_parse_notes(MusicPlayerWorker* instance, const c
} else {
FURI_LOG_E(
TAG,
- "Invalid note: %c%c%u.%u = %u %u",
+ "Invalid note: %c%c%lu.%lu = %u %lu",
note_char == '\0' ? '_' : note_char,
sharp_char == '\0' ? '_' : sharp_char,
octave,
@@ -326,8 +326,8 @@ bool music_player_worker_load_fmf_from_file(MusicPlayerWorker* instance, const c
furi_assert(file_path);
bool result = false;
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* file = flipper_format_file_alloc(storage);
@@ -337,7 +337,8 @@ bool music_player_worker_load_fmf_from_file(MusicPlayerWorker* instance, const c
uint32_t version = 0;
if(!flipper_format_read_header(file, temp_str, &version)) break;
- if(string_cmp_str(temp_str, MUSIC_PLAYER_FILETYPE) || (version != MUSIC_PLAYER_VERSION)) {
+ if(furi_string_cmp_str(temp_str, MUSIC_PLAYER_FILETYPE) ||
+ (version != MUSIC_PLAYER_VERSION)) {
FURI_LOG_E(TAG, "Incorrect file format or version");
break;
}
@@ -360,7 +361,7 @@ bool music_player_worker_load_fmf_from_file(MusicPlayerWorker* instance, const c
break;
}
- if(!music_player_worker_parse_notes(instance, string_get_cstr(temp_str))) {
+ if(!music_player_worker_parse_notes(instance, furi_string_get_cstr(temp_str))) {
break;
}
@@ -369,7 +370,7 @@ bool music_player_worker_load_fmf_from_file(MusicPlayerWorker* instance, const c
furi_record_close(RECORD_STORAGE);
flipper_format_free(file);
- string_clear(temp_str);
+ furi_string_free(temp_str);
return result;
}
@@ -379,8 +380,8 @@ bool music_player_worker_load_rtttl_from_file(MusicPlayerWorker* instance, const
furi_assert(file_path);
bool result = false;
- string_t content;
- string_init(content);
+ FuriString* content;
+ content = furi_string_alloc();
Storage* storage = furi_record_open(RECORD_STORAGE);
File* file = storage_file_alloc(storage);
@@ -395,17 +396,17 @@ bool music_player_worker_load_rtttl_from_file(MusicPlayerWorker* instance, const
uint8_t buffer[65] = {0};
ret = storage_file_read(file, buffer, sizeof(buffer) - 1);
for(size_t i = 0; i < ret; i++) {
- string_push_back(content, buffer[i]);
+ furi_string_push_back(content, buffer[i]);
}
} while(ret > 0);
- string_strim(content);
- if(!string_size(content)) {
+ furi_string_trim(content);
+ if(!furi_string_size(content)) {
FURI_LOG_E(TAG, "Empty file");
break;
}
- if(!music_player_worker_load_rtttl_from_string(instance, string_get_cstr(content))) {
+ if(!music_player_worker_load_rtttl_from_string(instance, furi_string_get_cstr(content))) {
FURI_LOG_E(TAG, "Invalid file content");
break;
}
@@ -415,7 +416,7 @@ bool music_player_worker_load_rtttl_from_file(MusicPlayerWorker* instance, const
storage_file_free(file);
furi_record_close(RECORD_STORAGE);
- string_clear(content);
+ furi_string_free(content);
return result;
}
diff --git a/applications/plugins/doom/sound.h b/applications/plugins/doom/sound.h
index b33ac93c6..514381334 100644
--- a/applications/plugins/doom/sound.h
+++ b/applications/plugins/doom/sound.h
@@ -1,6 +1,5 @@
#ifndef sound_h
#define sound_h
-#include
#include
#include
#include
diff --git a/applications/plugins/esp8266_deauth/application.fam b/applications/plugins/esp8266_deauth/application.fam
index 8342edfba..0b305e1fb 100644
--- a/applications/plugins/esp8266_deauth/application.fam
+++ b/applications/plugins/esp8266_deauth/application.fam
@@ -1,5 +1,5 @@
App(
- appid="esp8266_deauth",
+ appid="ESP8266_Deauther",
name="[ESP8266] Deauther",
apptype=FlipperAppType.EXTERNAL,
entry_point="esp8266_deauth_app",
diff --git a/applications/plugins/esp8266_deauth/esp8266_deauth.c b/applications/plugins/esp8266_deauth/esp8266_deauth.c
index 253ad650f..8503ae65c 100644
--- a/applications/plugins/esp8266_deauth/esp8266_deauth.c
+++ b/applications/plugins/esp8266_deauth/esp8266_deauth.c
@@ -6,12 +6,11 @@
#include
#include
#include
-//#include
//#include
//#include
//#include
//#include
-#include
+
#include
#include "FlipperZeroWiFiDeauthModuleDefines.h"
@@ -66,7 +65,7 @@ typedef struct SWiFiDeauthApp {
Gui* m_gui;
FuriThread* m_worker_thread;
//NotificationApp* m_notification;
- StreamBufferHandle_t m_rx_stream;
+ FuriStreamBuffer* m_rx_stream;
SGpioButtons m_GpioButtons;
bool m_wifiDeauthModuleInitialized;
@@ -220,7 +219,6 @@ static void
static void uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
furi_assert(context);
- BaseType_t xHigherPriorityTaskWoken = pdFALSE;
SWiFiDeauthApp* app = context;
@@ -228,9 +226,8 @@ static void uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
if(ev == UartIrqEventRXNE) {
DEAUTH_APP_LOG_I("ev == UartIrqEventRXNE");
- xStreamBufferSendFromISR(app->m_rx_stream, &data, 1, &xHigherPriorityTaskWoken);
+ furi_stream_buffer_send(app->m_rx_stream, &data, 1, 0);
furi_thread_flags_set(furi_thread_get_id(app->m_worker_thread), WorkerEventRx);
- portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}
@@ -243,15 +240,15 @@ static int32_t uart_worker(void* context) {
return 1;
}
- StreamBufferHandle_t rx_stream = app->m_rx_stream;
+ FuriStreamBuffer* rx_stream = app->m_rx_stream;
release_mutex((ValueMutex*)context, app);
#if ENABLE_MODULE_POWER
bool initialized = false;
- string_t receivedString;
- string_init(receivedString);
+ FuriString* receivedString;
+ receivedString = furi_string_alloc();
#endif // ENABLE_MODULE_POWER
while(true) {
@@ -273,14 +270,14 @@ static int32_t uart_worker(void* context) {
const uint8_t dataBufferSize = 64;
uint8_t dataBuffer[dataBufferSize];
dataReceivedLength =
- xStreamBufferReceive(rx_stream, dataBuffer, dataBufferSize, 25);
+ furi_stream_buffer_receive(rx_stream, dataBuffer, dataBufferSize, 25);
if(dataReceivedLength > 0) {
#if ENABLE_MODULE_POWER
if(!initialized) {
if(!(dataReceivedLength > strlen(MODULE_CONTEXT_INITIALIZATION))) {
DEAUTH_APP_LOG_I("[UART] Found possible init candidate");
for(uint16_t i = 0; i < dataReceivedLength; i++) {
- string_push_back(receivedString, dataBuffer[i]);
+ furi_string_push_back(receivedString, dataBuffer[i]);
}
}
} else
@@ -297,15 +294,15 @@ static int32_t uart_worker(void* context) {
#if ENABLE_MODULE_POWER
if(!app->m_wifiDeauthModuleInitialized) {
- if(string_cmp_str(receivedString, MODULE_CONTEXT_INITIALIZATION) == 0) {
+ if(furi_string_cmp_str(receivedString, MODULE_CONTEXT_INITIALIZATION) == 0) {
DEAUTH_APP_LOG_I("[UART] Initialized");
initialized = true;
app->m_wifiDeauthModuleInitialized = true;
app->m_context = ModuleActive;
- string_clear(receivedString);
+ furi_string_free(receivedString);
} else {
DEAUTH_APP_LOG_I("[UART] Not an initialization command");
- string_reset(receivedString);
+ furi_string_reset(receivedString);
}
}
#endif // ENABLE_MODULE_POWER
@@ -368,7 +365,7 @@ int32_t esp8266_deauth_app(void* p) {
DEAUTH_APP_LOG_I("Mutex created");
- app->m_rx_stream = xStreamBufferCreate(1 * 1024, 1);
+ app->m_rx_stream = furi_stream_buffer_alloc(1 * 1024, 1);
//app->m_notification = furi_record_open("notification");
@@ -519,7 +516,7 @@ int32_t esp8266_deauth_app(void* p) {
furi_message_queue_free(event_queue);
- vStreamBufferDelete(app->m_rx_stream);
+ furi_stream_buffer_free(app->m_rx_stream);
delete_mutex(&app_data_mutex);
diff --git a/applications/plugins/flappy_bird/application.fam b/applications/plugins/flappy_bird/application.fam
index daee5791d..dd8c67e85 100644
--- a/applications/plugins/flappy_bird/application.fam
+++ b/applications/plugins/flappy_bird/application.fam
@@ -1,5 +1,5 @@
App(
- appid="game_flappybird",
+ appid="FlappyBird",
name="Flappy Bird",
apptype=FlipperAppType.EXTERNAL,
entry_point="flappy_game_app",
diff --git a/applications/plugins/flipfrid/application.fam b/applications/plugins/flipfrid/application.fam
index 77cfefbed..4a09f1064 100644
--- a/applications/plugins/flipfrid/application.fam
+++ b/applications/plugins/flipfrid/application.fam
@@ -1,5 +1,5 @@
App(
- appid="flipfrid",
+ appid="RFID_Fuzzer",
name="RFID Fuzzer",
apptype=FlipperAppType.EXTERNAL,
entry_point="flipfrid_start",
diff --git a/applications/plugins/flipfrid/flipfrid.c b/applications/plugins/flipfrid/flipfrid.c
index ba059ff7f..2c5d1201d 100644
--- a/applications/plugins/flipfrid/flipfrid.c
+++ b/applications/plugins/flipfrid/flipfrid.c
@@ -55,8 +55,10 @@ static void flipfrid_timer_callback(FuriMessageQueue* event_queue) {
FlipFridState* flipfrid_alloc() {
FlipFridState* flipfrid = malloc(sizeof(FlipFridState));
- string_init(flipfrid->notification_msg);
- string_init(flipfrid->attack_name);
+ flipfrid->notification_msg = furi_string_alloc();
+ flipfrid->attack_name = furi_string_alloc();
+ flipfrid->proto_name = furi_string_alloc();
+ flipfrid->data_str = furi_string_alloc();
flipfrid->previous_scene = NoneScene;
flipfrid->current_scene = SceneEntryPoint;
@@ -95,8 +97,10 @@ void flipfrid_free(FlipFridState* flipfrid) {
notification_message(flipfrid->notify, &sequence_blink_stop);
// Strings
- string_clear(flipfrid->notification_msg);
- string_clear(flipfrid->attack_name);
+ furi_string_free(flipfrid->notification_msg);
+ furi_string_free(flipfrid->attack_name);
+ furi_string_free(flipfrid->proto_name);
+ furi_string_free(flipfrid->data_str);
free(flipfrid->data);
free(flipfrid->payload);
@@ -120,8 +124,7 @@ int32_t flipfrid_start(void* p) {
FURI_LOG_E(TAG, "cannot create mutex\r\n");
furi_message_queue_free(event_queue);
furi_record_close(RECORD_NOTIFICATION);
- furi_record_close(RECORD_DIALOGS);
- free(flipfrid_state);
+ flipfrid_free(flipfrid_state);
return 255;
}
diff --git a/applications/plugins/flipfrid/flipfrid.h b/applications/plugins/flipfrid/flipfrid.h
index 5417817e9..248e2322e 100644
--- a/applications/plugins/flipfrid/flipfrid.h
+++ b/applications/plugins/flipfrid/flipfrid.h
@@ -4,7 +4,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -31,6 +30,8 @@ typedef enum {
typedef enum {
EM4100,
HIDProx,
+ PAC,
+ H10301,
} FlipFridProtos;
typedef enum {
@@ -63,22 +64,24 @@ typedef struct {
u_int8_t menu_index;
u_int8_t menu_proto_index;
- string_t data_str;
+ FuriString* data_str;
uint8_t data[6];
uint8_t payload[6];
uint8_t attack_step;
FlipFridAttacks attack;
FlipFridProtos proto;
- string_t attack_name;
- string_t proto_name;
+ FuriString* attack_name;
+ FuriString* proto_name;
DialogsApp* dialogs;
- string_t notification_msg;
+ FuriString* notification_msg;
uint8_t key_index;
LFRFIDWorker* worker;
ProtocolDict* dict;
ProtocolId protocol;
+ uint8_t time_between_cards;
+
// Used for custom dictionnary
Stream* uids_stream;
} FlipFridState;
\ No newline at end of file
diff --git a/applications/plugins/flipfrid/scene/flipfrid_scene_entrypoint.c b/applications/plugins/flipfrid/scene/flipfrid_scene_entrypoint.c
index c709572e3..3a1ce4951 100644
--- a/applications/plugins/flipfrid/scene/flipfrid_scene_entrypoint.c
+++ b/applications/plugins/flipfrid/scene/flipfrid_scene_entrypoint.c
@@ -1,7 +1,7 @@
#include "flipfrid_scene_entrypoint.h"
-string_t menu_items[4];
-string_t menu_proto_items[2];
+FuriString* main_menu_items[4];
+FuriString* main_menu_proto_items[4];
void flipfrid_scene_entrypoint_menu_callback(
FlipFridState* context,
@@ -11,22 +11,22 @@ void flipfrid_scene_entrypoint_menu_callback(
case FlipFridAttackDefaultValues:
context->attack = FlipFridAttackDefaultValues;
context->current_scene = SceneAttack;
- string_set_str(context->attack_name, "Default Values");
+ furi_string_set(context->attack_name, "Default Values");
break;
case FlipFridAttackBfCustomerId:
context->attack = FlipFridAttackBfCustomerId;
context->current_scene = SceneAttack;
- string_set_str(context->attack_name, "Bad Customer ID");
+ furi_string_set(context->attack_name, "Bad Customer ID");
break;
case FlipFridAttackLoadFile:
context->attack = FlipFridAttackLoadFile;
context->current_scene = SceneSelectFile;
- string_set_str(context->attack_name, "Load File");
+ furi_string_set(context->attack_name, "Load File");
break;
case FlipFridAttackLoadFileCustomUids:
context->attack = FlipFridAttackLoadFileCustomUids;
context->current_scene = SceneLoadCustomUids;
- string_set_str(context->attack_name, "Load Custom UIDs");
+ furi_string_set(context->attack_name, "Load Custom UIDs");
break;
default:
break;
@@ -35,11 +35,19 @@ void flipfrid_scene_entrypoint_menu_callback(
switch(proto_index) {
case EM4100:
context->proto = EM4100;
- string_set_str(context->proto_name, "EM4100");
+ furi_string_set(context->proto_name, "EM4100");
break;
case HIDProx:
context->proto = HIDProx;
- string_set_str(context->proto_name, "HIDProx");
+ furi_string_set(context->proto_name, "HIDProx");
+ break;
+ case PAC:
+ context->proto = PAC;
+ furi_string_set(context->proto_name, "PAC/Stanley");
+ break;
+ case H10301:
+ context->proto = H10301;
+ furi_string_set(context->proto_name, "H10301");
break;
default:
break;
@@ -56,32 +64,34 @@ void flipfrid_scene_entrypoint_on_enter(FlipFridState* context) {
context->payload[5] = 0x00;
context->menu_index = 0;
- for(uint32_t i = 0; i < 4; i++) {
- string_init(menu_items[i]);
- }
+ /*for(uint32_t i = 0; i < 4; i++) {
+ menu_items[i] = furi_string_alloc();
+ }*/
- string_set(menu_items[0], "Default Values");
- string_set(menu_items[1], "BF Customer ID");
- string_set(menu_items[2], "Load File");
- string_set(menu_items[3], "Load uids from file");
+ main_menu_items[0] = furi_string_alloc_set("Default Values");
+ main_menu_items[1] = furi_string_alloc_set("BF Customer ID");
+ main_menu_items[2] = furi_string_alloc_set("Load File");
+ main_menu_items[3] = furi_string_alloc_set("Load uids from file");
context->menu_proto_index = 0;
- for(uint32_t i = 0; i < 2; i++) {
- string_init(menu_proto_items[i]);
- }
+ /*for(uint32_t i = 0; i < 4; i++) {
+ menu_proto_items[i] = furi_string_alloc();
+ }*/
- string_set(menu_proto_items[0], "EM4100");
- string_set(menu_proto_items[1], "HIDProx");
+ main_menu_proto_items[0] = furi_string_alloc_set("EM4100");
+ main_menu_proto_items[1] = furi_string_alloc_set("HIDProx");
+ main_menu_proto_items[2] = furi_string_alloc_set("PAC/Stanley");
+ main_menu_proto_items[3] = furi_string_alloc_set("H10301");
}
void flipfrid_scene_entrypoint_on_exit(FlipFridState* context) {
UNUSED(context);
for(uint32_t i = 0; i < 4; i++) {
- string_clear(menu_items[i]);
+ furi_string_free(main_menu_items[i]);
}
- for(uint32_t i = 0; i < 2; i++) {
- string_clear(menu_proto_items[i]);
+ for(uint32_t i = 0; i < 4; i++) {
+ furi_string_free(main_menu_proto_items[i]);
}
}
@@ -106,11 +116,15 @@ void flipfrid_scene_entrypoint_on_event(FlipFridEvent event, FlipFridState* cont
case InputKeyLeft:
if(context->menu_proto_index > EM4100) {
context->menu_proto_index--;
+ } else if(context->menu_proto_index == EM4100) {
+ context->menu_proto_index = H10301;
}
break;
case InputKeyRight:
- if(context->menu_proto_index < HIDProx) {
+ if(context->menu_proto_index < H10301) {
context->menu_proto_index++;
+ } else if(context->menu_proto_index == H10301) {
+ context->menu_proto_index = EM4100;
}
break;
case InputKeyOk:
@@ -129,66 +143,73 @@ void flipfrid_scene_entrypoint_on_draw(Canvas* canvas, FlipFridState* context) {
canvas_clear(canvas);
canvas_set_color(canvas, ColorBlack);
- if(context->menu_index > FlipFridAttackDefaultValues) {
- canvas_set_font(canvas, FontSecondary);
+ if(main_menu_items[context->menu_index] != NULL) {
+ if(context->menu_index > FlipFridAttackDefaultValues) {
+ canvas_set_font(canvas, FontSecondary);
+ canvas_draw_str_aligned(
+ canvas,
+ 64,
+ 24,
+ AlignCenter,
+ AlignTop,
+ furi_string_get_cstr(main_menu_items[context->menu_index - 1]));
+ }
+
+ canvas_set_font(canvas, FontPrimary);
canvas_draw_str_aligned(
canvas,
64,
- 24,
+ 36,
AlignCenter,
AlignTop,
- string_get_cstr(menu_items[context->menu_index - 1]));
- }
+ furi_string_get_cstr(main_menu_items[context->menu_index]));
- canvas_set_font(canvas, FontPrimary);
- canvas_draw_str_aligned(
- canvas, 64, 36, AlignCenter, AlignTop, string_get_cstr(menu_items[context->menu_index]));
+ if(context->menu_index < FlipFridAttackLoadFileCustomUids) {
+ canvas_set_font(canvas, FontSecondary);
+ canvas_draw_str_aligned(
+ canvas,
+ 64,
+ 48,
+ AlignCenter,
+ AlignTop,
+ furi_string_get_cstr(main_menu_items[context->menu_index + 1]));
+ }
- if(context->menu_index < FlipFridAttackLoadFileCustomUids) {
- canvas_set_font(canvas, FontSecondary);
+ if(context->menu_proto_index > EM4100) {
+ canvas_set_font(canvas, FontSecondary);
+ canvas_draw_str_aligned(
+ canvas,
+ 64,
+ -12,
+ AlignCenter,
+ AlignTop,
+ furi_string_get_cstr(main_menu_proto_items[context->menu_proto_index - 1]));
+ }
+
+ canvas_set_font(canvas, FontPrimary);
+ canvas_draw_str_aligned(canvas, 27, 4, AlignCenter, AlignTop, "<");
+
+ canvas_set_font(canvas, FontPrimary);
canvas_draw_str_aligned(
canvas,
64,
- 48,
+ 4,
AlignCenter,
AlignTop,
- string_get_cstr(menu_items[context->menu_index + 1]));
- }
+ furi_string_get_cstr(main_menu_proto_items[context->menu_proto_index]));
- if(context->menu_proto_index > EM4100) {
- canvas_set_font(canvas, FontSecondary);
- canvas_draw_str_aligned(
- canvas,
- 64,
- -12,
- AlignCenter,
- AlignTop,
- string_get_cstr(menu_proto_items[context->menu_proto_index - 1]));
- }
+ canvas_set_font(canvas, FontPrimary);
+ canvas_draw_str_aligned(canvas, 101, 4, AlignCenter, AlignTop, ">");
- canvas_set_font(canvas, FontPrimary);
- canvas_draw_str_aligned(canvas, 34, 4, AlignCenter, AlignTop, "<");
-
- canvas_set_font(canvas, FontPrimary);
- canvas_draw_str_aligned(
- canvas,
- 64,
- 4,
- AlignCenter,
- AlignTop,
- string_get_cstr(menu_proto_items[context->menu_proto_index]));
-
- canvas_set_font(canvas, FontPrimary);
- canvas_draw_str_aligned(canvas, 94, 4, AlignCenter, AlignTop, ">");
-
- if(context->menu_proto_index < HIDProx) {
- canvas_set_font(canvas, FontSecondary);
- canvas_draw_str_aligned(
- canvas,
- 64,
- -12,
- AlignCenter,
- AlignTop,
- string_get_cstr(menu_proto_items[context->menu_proto_index + 1]));
+ if(context->menu_proto_index < H10301) {
+ canvas_set_font(canvas, FontSecondary);
+ canvas_draw_str_aligned(
+ canvas,
+ 64,
+ -12,
+ AlignCenter,
+ AlignTop,
+ furi_string_get_cstr(main_menu_proto_items[context->menu_proto_index + 1]));
+ }
}
}
\ No newline at end of file
diff --git a/applications/plugins/flipfrid/scene/flipfrid_scene_load_custom_uids.c b/applications/plugins/flipfrid/scene/flipfrid_scene_load_custom_uids.c
index d2e4ce136..cc9e9871d 100644
--- a/applications/plugins/flipfrid/scene/flipfrid_scene_load_custom_uids.c
+++ b/applications/plugins/flipfrid/scene/flipfrid_scene_load_custom_uids.c
@@ -21,9 +21,9 @@ bool flipfrid_load_uids(FlipFridState* context, const char* file_path) {
bool flipfrid_load_custom_uids_from_file(FlipFridState* context) {
// Input events and views are managed by file_select
- string_t uid_path;
- string_init(uid_path);
- string_set_str(uid_path, RFIDFUZZER_APP_PATH_FOLDER);
+ FuriString* uid_path;
+ uid_path = furi_string_alloc();
+ furi_string_set(uid_path, RFIDFUZZER_APP_PATH_FOLDER);
DialogsFileBrowserOptions browser_options;
dialog_file_browser_set_basic_options(&browser_options, LFRFID_UIDS_EXTENSION, &I_125_10px);
@@ -32,10 +32,10 @@ bool flipfrid_load_custom_uids_from_file(FlipFridState* context) {
bool res = dialog_file_browser_show(context->dialogs, uid_path, uid_path, &browser_options);
if(res) {
- res = flipfrid_load_uids(context, string_get_cstr(uid_path));
+ res = flipfrid_load_uids(context, furi_string_get_cstr(uid_path));
}
- string_clear(uid_path);
+ furi_string_free(uid_path);
return res;
}
diff --git a/applications/plugins/flipfrid/scene/flipfrid_scene_load_file.c b/applications/plugins/flipfrid/scene/flipfrid_scene_load_file.c
index 687a861c9..76864018b 100644
--- a/applications/plugins/flipfrid/scene/flipfrid_scene_load_file.c
+++ b/applications/plugins/flipfrid/scene/flipfrid_scene_load_file.c
@@ -8,47 +8,61 @@ bool flipfrid_load(FlipFridState* context, const char* file_path) {
bool result = false;
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
do {
if(!flipper_format_file_open_existing(fff_data_file, file_path)) {
FURI_LOG_E(TAG, "Error open file %s", file_path);
- string_reset(context->notification_msg);
- string_set_str(context->notification_msg, "Error open file");
+ furi_string_reset(context->notification_msg);
+ furi_string_set(context->notification_msg, "Error open file");
break;
}
// FileType
if(!flipper_format_read_string(fff_data_file, "Filetype", temp_str)) {
FURI_LOG_E(TAG, "Missing or incorrect Filetype");
- string_reset(context->notification_msg);
- string_set_str(context->notification_msg, "Missing or incorrect Filetypes");
+ furi_string_reset(context->notification_msg);
+ furi_string_set(context->notification_msg, "Missing or incorrect Filetypes");
break;
} else {
- FURI_LOG_I(TAG, "Filetype: %s", string_get_cstr(temp_str));
+ FURI_LOG_I(TAG, "Filetype: %s", furi_string_get_cstr(temp_str));
}
// Key type
if(!flipper_format_read_string(fff_data_file, "Key type", temp_str)) {
FURI_LOG_E(TAG, "Missing or incorrect Key type");
- string_reset(context->notification_msg);
- string_set_str(context->notification_msg, "Missing or incorrect Key type");
+ furi_string_reset(context->notification_msg);
+ furi_string_set(context->notification_msg, "Missing or incorrect Key type");
break;
} else {
- FURI_LOG_I(TAG, "Key type: %s", string_get_cstr(temp_str));
+ FURI_LOG_I(TAG, "Key type: %s", furi_string_get_cstr(temp_str));
if(context->proto == EM4100) {
- if(strcmp(string_get_cstr(temp_str), "EM4100") != 0) {
+ if(strcmp(furi_string_get_cstr(temp_str), "EM4100") != 0) {
FURI_LOG_E(TAG, "Unsupported Key type");
- string_reset(context->notification_msg);
- string_set_str(context->notification_msg, "Unsupported Key type");
+ furi_string_reset(context->notification_msg);
+ furi_string_set(context->notification_msg, "Unsupported Key type");
+ break;
+ }
+ } else if(context->proto == PAC) {
+ if(strcmp(furi_string_get_cstr(temp_str), "PAC/Stanley") != 0) {
+ FURI_LOG_E(TAG, "Unsupported Key type");
+ furi_string_reset(context->notification_msg);
+ furi_string_set(context->notification_msg, "Unsupported Key type");
+ break;
+ }
+ } else if(context->proto == H10301) {
+ if(strcmp(furi_string_get_cstr(temp_str), "H10301") != 0) {
+ FURI_LOG_E(TAG, "Unsupported Key type");
+ furi_string_reset(context->notification_msg);
+ furi_string_set(context->notification_msg, "Unsupported Key type");
break;
}
} else {
- if(strcmp(string_get_cstr(temp_str), "HIDProx") != 0) {
+ if(strcmp(furi_string_get_cstr(temp_str), "HIDProx") != 0) {
FURI_LOG_E(TAG, "Unsupported Key type");
- string_reset(context->notification_msg);
- string_set_str(context->notification_msg, "Unsupported Key type");
+ furi_string_reset(context->notification_msg);
+ furi_string_set(context->notification_msg, "Unsupported Key type");
break;
}
}
@@ -57,24 +71,38 @@ bool flipfrid_load(FlipFridState* context, const char* file_path) {
// Data
if(!flipper_format_read_string(fff_data_file, "Data", context->data_str)) {
FURI_LOG_E(TAG, "Missing or incorrect Data");
- string_reset(context->notification_msg);
- string_set_str(context->notification_msg, "Missing or incorrect Key");
+ furi_string_reset(context->notification_msg);
+ furi_string_set(context->notification_msg, "Missing or incorrect Key");
break;
} else {
- FURI_LOG_I(TAG, "Key: %s", string_get_cstr(context->data_str));
+ FURI_LOG_I(TAG, "Key: %s", furi_string_get_cstr(context->data_str));
if(context->proto == EM4100) {
- if(string_size(context->data_str) != 14) {
+ if(furi_string_size(context->data_str) != 14) {
FURI_LOG_E(TAG, "Incorrect Key length");
- string_reset(context->notification_msg);
- string_set_str(context->notification_msg, "Incorrect Key length");
+ furi_string_reset(context->notification_msg);
+ furi_string_set(context->notification_msg, "Incorrect Key length");
+ break;
+ }
+ } else if(context->proto == PAC) {
+ if(furi_string_size(context->data_str) != 11) {
+ FURI_LOG_E(TAG, "Incorrect Key length");
+ furi_string_reset(context->notification_msg);
+ furi_string_set(context->notification_msg, "Incorrect Key length");
+ break;
+ }
+ } else if(context->proto == H10301) {
+ if(furi_string_size(context->data_str) != 8) {
+ FURI_LOG_E(TAG, "Incorrect Key length");
+ furi_string_reset(context->notification_msg);
+ furi_string_set(context->notification_msg, "Incorrect Key length");
break;
}
} else {
- if(string_size(context->data_str) != 17) {
+ if(furi_string_size(context->data_str) != 17) {
FURI_LOG_E(TAG, "Incorrect Key length");
- string_reset(context->notification_msg);
- string_set_str(context->notification_msg, "Incorrect Key length");
+ furi_string_reset(context->notification_msg);
+ furi_string_set(context->notification_msg, "Incorrect Key length");
break;
}
}
@@ -82,8 +110,8 @@ bool flipfrid_load(FlipFridState* context, const char* file_path) {
// String to uint8_t
for(uint8_t i = 0; i < 6; i++) {
char temp_str2[3];
- temp_str2[0] = string_get_cstr(context->data_str)[i * 3];
- temp_str2[1] = string_get_cstr(context->data_str)[i * 3 + 1];
+ temp_str2[0] = furi_string_get_cstr(context->data_str)[i * 3];
+ temp_str2[1] = furi_string_get_cstr(context->data_str)[i * 3 + 1];
temp_str2[2] = '\0';
context->data[i] = (uint8_t)strtol(temp_str2, NULL, 16);
}
@@ -91,12 +119,12 @@ bool flipfrid_load(FlipFridState* context, const char* file_path) {
result = true;
} while(0);
- string_clear(temp_str);
+ furi_string_free(temp_str);
flipper_format_free(fff_data_file);
if(result) {
FURI_LOG_I(TAG, "Loaded successfully");
- string_reset(context->notification_msg);
- string_set_str(context->notification_msg, "Source loaded.");
+ furi_string_reset(context->notification_msg);
+ furi_string_set(context->notification_msg, "Source loaded.");
}
return result;
}
@@ -141,9 +169,9 @@ void flipfrid_scene_load_file_on_draw(Canvas* canvas, FlipFridState* context) {
}
bool flipfrid_load_protocol_from_file(FlipFridState* context) {
- string_t user_file_path;
- string_init(user_file_path);
- string_set_str(user_file_path, LFRFID_APP_PATH_FOLDER);
+ FuriString* user_file_path;
+ user_file_path = furi_string_alloc();
+ furi_string_set(user_file_path, LFRFID_APP_PATH_FOLDER);
DialogsFileBrowserOptions browser_options;
dialog_file_browser_set_basic_options(&browser_options, LFRFID_APP_EXTENSION, &I_125_10px);
@@ -153,10 +181,10 @@ bool flipfrid_load_protocol_from_file(FlipFridState* context) {
context->dialogs, user_file_path, user_file_path, &browser_options);
if(res) {
- res = flipfrid_load(context, string_get_cstr(user_file_path));
+ res = flipfrid_load(context, furi_string_get_cstr(user_file_path));
}
- string_clear(user_file_path);
+ furi_string_free(user_file_path);
return res;
}
\ No newline at end of file
diff --git a/applications/plugins/flipfrid/scene/flipfrid_scene_run_attack.c b/applications/plugins/flipfrid/scene/flipfrid_scene_run_attack.c
index 9d30f4faa..18e0d9c82 100644
--- a/applications/plugins/flipfrid/scene/flipfrid_scene_run_attack.c
+++ b/applications/plugins/flipfrid/scene/flipfrid_scene_run_attack.c
@@ -2,7 +2,7 @@
#include
uint8_t counter = 0;
-#define TIME_BETWEEN_CARDS 6
+
uint8_t id_list[17][5] = {
{0x00, 0x00, 0x00, 0x00, 0x00}, // Null bytes
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, // Only FF
@@ -40,12 +40,54 @@ uint8_t id_list_hid[14][6] = {
{0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA}, // From arha
};
+uint8_t id_list_pac[17][4] = {
+ {0x00, 0x00, 0x00, 0x00}, // Null bytes
+ {0xFF, 0xFF, 0xFF, 0xFF}, // Only FF
+ {0x11, 0x11, 0x11, 0x11}, // Only 11
+ {0x22, 0x22, 0x22, 0x22}, // Only 22
+ {0x33, 0x33, 0x33, 0x33}, // Only 33
+ {0x44, 0x44, 0x44, 0x44}, // Only 44
+ {0x55, 0x55, 0x55, 0x55}, // Only 55
+ {0x66, 0x66, 0x66, 0x66}, // Only 66
+ {0x77, 0x77, 0x77, 0x77}, // Only 77
+ {0x88, 0x88, 0x88, 0x88}, // Only 88
+ {0x99, 0x99, 0x99, 0x99}, // Only 99
+ {0x12, 0x34, 0x56, 0x78}, // Incremental UID
+ {0x9A, 0x78, 0x56, 0x34}, // Decremental UID
+ {0x04, 0xd0, 0x9b, 0x0d}, // From arha
+ {0x34, 0x00, 0x29, 0x3d}, // From arha
+ {0x04, 0xdf, 0x00, 0x00}, // From arha
+ {0xCA, 0xCA, 0xCA, 0xCA}, // From arha
+};
+
+uint8_t id_list_h[14][3] = {
+ {0x00, 0x00, 0x00}, // Null bytes
+ {0xFF, 0xFF, 0xFF}, // Only FF
+ {0x11, 0x11, 0x11}, // Only 11
+ {0x22, 0x22, 0x22}, // Only 22
+ {0x33, 0x33, 0x33}, // Only 33
+ {0x44, 0x44, 0x44}, // Only 44
+ {0x55, 0x55, 0x55}, // Only 55
+ {0x66, 0x66, 0x66}, // Only 66
+ {0x77, 0x77, 0x77}, // Only 77
+ {0x88, 0x88, 0x88}, // Only 88
+ {0x99, 0x99, 0x99}, // Only 99
+ {0x12, 0x34, 0x56}, // Incremental UID
+ {0x56, 0x34, 0x12}, // Decremental UID
+ {0xCA, 0xCA, 0xCA}, // From arha
+};
+
void flipfrid_scene_run_attack_on_enter(FlipFridState* context) {
+ context->time_between_cards = 10;
context->attack_step = 0;
context->dict = protocol_dict_alloc(lfrfid_protocols, LFRFIDProtocolMax);
context->worker = lfrfid_worker_alloc(context->dict);
if(context->proto == HIDProx) {
context->protocol = protocol_dict_get_protocol_by_name(context->dict, "HIDProx");
+ } else if(context->proto == PAC) {
+ context->protocol = protocol_dict_get_protocol_by_name(context->dict, "PAC/Stanley");
+ } else if(context->proto == H10301) {
+ context->protocol = protocol_dict_get_protocol_by_name(context->dict, "H10301");
} else {
context->protocol = protocol_dict_get_protocol_by_name(context->dict, "EM4100");
}
@@ -79,7 +121,38 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
context->payload[3] = id_list[context->attack_step][3];
context->payload[4] = id_list[context->attack_step][4];
- if(context->attack_step == 15) {
+ if(context->attack_step == 16) {
+ context->attack_step = 0;
+ counter = 0;
+ context->is_attacking = false;
+ notification_message(context->notify, &sequence_blink_stop);
+ notification_message(context->notify, &sequence_single_vibro);
+ } else {
+ context->attack_step++;
+ }
+ break;
+ } else if(context->proto == PAC) {
+ context->payload[0] = id_list_pac[context->attack_step][0];
+ context->payload[1] = id_list_pac[context->attack_step][1];
+ context->payload[2] = id_list_pac[context->attack_step][2];
+ context->payload[3] = id_list_pac[context->attack_step][3];
+
+ if(context->attack_step == 16) {
+ context->attack_step = 0;
+ counter = 0;
+ context->is_attacking = false;
+ notification_message(context->notify, &sequence_blink_stop);
+ notification_message(context->notify, &sequence_single_vibro);
+ } else {
+ context->attack_step++;
+ }
+ break;
+ } else if(context->proto == H10301) {
+ context->payload[0] = id_list_h[context->attack_step][0];
+ context->payload[1] = id_list_h[context->attack_step][1];
+ context->payload[2] = id_list_h[context->attack_step][2];
+
+ if(context->attack_step == 13) {
context->attack_step = 0;
counter = 0;
context->is_attacking = false;
@@ -97,7 +170,7 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
context->payload[4] = id_list_hid[context->attack_step][4];
context->payload[5] = id_list_hid[context->attack_step][5];
- if(context->attack_step == 15) {
+ if(context->attack_step == 13) {
context->attack_step = 0;
counter = 0;
context->is_attacking = false;
@@ -118,6 +191,37 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
context->payload[3] = 0x00;
context->payload[4] = 0x00;
+ if(context->attack_step == 255) {
+ context->attack_step = 0;
+ counter = 0;
+ context->is_attacking = false;
+ notification_message(context->notify, &sequence_blink_stop);
+ notification_message(context->notify, &sequence_single_vibro);
+ } else {
+ context->attack_step++;
+ }
+ break;
+ } else if(context->proto == PAC) {
+ context->payload[0] = context->attack_step;
+ context->payload[1] = 0x00;
+ context->payload[2] = 0x00;
+ context->payload[3] = 0x00;
+
+ if(context->attack_step == 255) {
+ context->attack_step = 0;
+ counter = 0;
+ context->is_attacking = false;
+ notification_message(context->notify, &sequence_blink_stop);
+ notification_message(context->notify, &sequence_single_vibro);
+ } else {
+ context->attack_step++;
+ }
+ break;
+ } else if(context->proto == H10301) {
+ context->payload[0] = context->attack_step;
+ context->payload[1] = 0x00;
+ context->payload[2] = 0x00;
+
if(context->attack_step == 255) {
context->attack_step = 0;
counter = 0;
@@ -158,6 +262,43 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
context->payload[context->key_index] = context->attack_step;
+ if(context->attack_step == 255) {
+ context->attack_step = 0;
+ counter = 0;
+ context->is_attacking = false;
+ notification_message(context->notify, &sequence_blink_stop);
+ notification_message(context->notify, &sequence_single_vibro);
+ break;
+ } else {
+ context->attack_step++;
+ }
+ break;
+ } else if(context->proto == PAC) {
+ context->payload[0] = context->data[0];
+ context->payload[1] = context->data[1];
+ context->payload[2] = context->data[2];
+ context->payload[3] = context->data[3];
+
+ context->payload[context->key_index] = context->attack_step;
+
+ if(context->attack_step == 255) {
+ context->attack_step = 0;
+ counter = 0;
+ context->is_attacking = false;
+ notification_message(context->notify, &sequence_blink_stop);
+ notification_message(context->notify, &sequence_single_vibro);
+ break;
+ } else {
+ context->attack_step++;
+ }
+ break;
+ } else if(context->proto == H10301) {
+ context->payload[0] = context->data[0];
+ context->payload[1] = context->data[1];
+ context->payload[2] = context->data[2];
+
+ context->payload[context->key_index] = context->attack_step;
+
if(context->attack_step == 255) {
context->attack_step = 0;
counter = 0;
@@ -194,53 +335,153 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
case FlipFridAttackLoadFileCustomUids:
if(context->proto == EM4100) {
+ bool end_of_list = false;
while(true) {
- string_reset(context->data_str);
+ furi_string_reset(context->data_str);
if(!stream_read_line(context->uids_stream, context->data_str)) {
context->attack_step = 0;
counter = 0;
context->is_attacking = false;
notification_message(context->notify, &sequence_blink_stop);
notification_message(context->notify, &sequence_single_vibro);
+ stream_rewind(context->uids_stream);
+ end_of_list = true;
break;
};
- if(string_get_char(context->data_str, 0) == '#') continue;
- if(string_size(context->data_str) != 11) continue;
+ if(furi_string_get_char(context->data_str, 0) == '#') continue;
+ if(furi_string_size(context->data_str) != 11) break;
break;
}
- FURI_LOG_D(TAG, string_get_cstr(context->data_str));
+ if(end_of_list) break;
+ FURI_LOG_D(TAG, furi_string_get_cstr(context->data_str));
+ if(furi_string_size(context->data_str) != 11) {
+ context->attack_step = 0;
+ counter = 0;
+ context->is_attacking = false;
+ notification_message(context->notify, &sequence_blink_stop);
+ notification_message(context->notify, &sequence_error);
+ break;
+ };
// string is valid, parse it in context->payload
for(uint8_t i = 0; i < 5; i++) {
char temp_str[3];
- temp_str[0] = string_get_cstr(context->data_str)[i * 2];
- temp_str[1] = string_get_cstr(context->data_str)[i * 2 + 1];
+ temp_str[0] = furi_string_get_cstr(context->data_str)[i * 2];
+ temp_str[1] = furi_string_get_cstr(context->data_str)[i * 2 + 1];
+ temp_str[2] = '\0';
+ context->payload[i] = (uint8_t)strtol(temp_str, NULL, 16);
+ }
+ break;
+ } else if(context->proto == PAC) {
+ bool end_of_list = false;
+ while(true) {
+ furi_string_reset(context->data_str);
+ if(!stream_read_line(context->uids_stream, context->data_str)) {
+ context->attack_step = 0;
+ counter = 0;
+ context->is_attacking = false;
+ notification_message(context->notify, &sequence_blink_stop);
+ notification_message(context->notify, &sequence_single_vibro);
+ stream_rewind(context->uids_stream);
+ end_of_list = true;
+ break;
+ };
+ if(furi_string_get_char(context->data_str, 0) == '#') continue;
+ if(furi_string_size(context->data_str) != 9) break;
+ break;
+ }
+ if(end_of_list) break;
+ FURI_LOG_D(TAG, furi_string_get_cstr(context->data_str));
+ if(furi_string_size(context->data_str) != 9) {
+ context->attack_step = 0;
+ counter = 0;
+ context->is_attacking = false;
+ notification_message(context->notify, &sequence_blink_stop);
+ notification_message(context->notify, &sequence_error);
+ break;
+ };
+
+ // string is valid, parse it in context->payload
+ for(uint8_t i = 0; i < 4; i++) {
+ char temp_str[3];
+ temp_str[0] = furi_string_get_cstr(context->data_str)[i * 2];
+ temp_str[1] = furi_string_get_cstr(context->data_str)[i * 2 + 1];
+ temp_str[2] = '\0';
+ context->payload[i] = (uint8_t)strtol(temp_str, NULL, 16);
+ }
+ break;
+ } else if(context->proto == H10301) {
+ bool end_of_list = false;
+ while(true) {
+ furi_string_reset(context->data_str);
+ if(!stream_read_line(context->uids_stream, context->data_str)) {
+ context->attack_step = 0;
+ counter = 0;
+ context->is_attacking = false;
+ notification_message(context->notify, &sequence_blink_stop);
+ notification_message(context->notify, &sequence_single_vibro);
+ stream_rewind(context->uids_stream);
+ end_of_list = true;
+ break;
+ };
+ if(furi_string_get_char(context->data_str, 0) == '#') continue;
+ if(furi_string_size(context->data_str) != 7) break;
+ break;
+ }
+ if(end_of_list) break;
+ FURI_LOG_D(TAG, furi_string_get_cstr(context->data_str));
+ if(furi_string_size(context->data_str) != 7) {
+ context->attack_step = 0;
+ counter = 0;
+ context->is_attacking = false;
+ notification_message(context->notify, &sequence_blink_stop);
+ notification_message(context->notify, &sequence_error);
+ break;
+ };
+
+ // string is valid, parse it in context->payload
+ for(uint8_t i = 0; i < 3; i++) {
+ char temp_str[3];
+ temp_str[0] = furi_string_get_cstr(context->data_str)[i * 2];
+ temp_str[1] = furi_string_get_cstr(context->data_str)[i * 2 + 1];
temp_str[2] = '\0';
context->payload[i] = (uint8_t)strtol(temp_str, NULL, 16);
}
break;
} else {
+ bool end_of_list = false;
while(true) {
- string_reset(context->data_str);
+ furi_string_reset(context->data_str);
if(!stream_read_line(context->uids_stream, context->data_str)) {
context->attack_step = 0;
counter = 0;
context->is_attacking = false;
notification_message(context->notify, &sequence_blink_stop);
notification_message(context->notify, &sequence_single_vibro);
+ stream_rewind(context->uids_stream);
+ end_of_list = true;
break;
};
- if(string_get_char(context->data_str, 0) == '#') continue;
- if(string_size(context->data_str) != 13) continue;
+ if(furi_string_get_char(context->data_str, 0) == '#') continue;
+ if(furi_string_size(context->data_str) != 13) break;
break;
}
- FURI_LOG_D(TAG, string_get_cstr(context->data_str));
+ FURI_LOG_D(TAG, furi_string_get_cstr(context->data_str));
+ if(end_of_list) break;
+ if(furi_string_size(context->data_str) != 13) {
+ context->attack_step = 0;
+ counter = 0;
+ context->is_attacking = false;
+ notification_message(context->notify, &sequence_blink_stop);
+ notification_message(context->notify, &sequence_error);
+ break;
+ };
// string is valid, parse it in context->payload
for(uint8_t i = 0; i < 6; i++) {
char temp_str[3];
- temp_str[0] = string_get_cstr(context->data_str)[i * 2];
- temp_str[1] = string_get_cstr(context->data_str)[i * 2 + 1];
+ temp_str[0] = furi_string_get_cstr(context->data_str)[i * 2];
+ temp_str[1] = furi_string_get_cstr(context->data_str)[i * 2 + 1];
temp_str[2] = '\0';
context->payload[i] = (uint8_t)strtol(temp_str, NULL, 16);
}
@@ -249,7 +490,7 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
}
}
- if(counter > TIME_BETWEEN_CARDS) {
+ if(counter > context->time_between_cards) {
counter = 0;
} else {
counter++;
@@ -262,9 +503,22 @@ void flipfrid_scene_run_attack_on_event(FlipFridEvent event, FlipFridState* cont
if(event.input_type == InputTypeShort) {
switch(event.key) {
case InputKeyDown:
+ break;
case InputKeyUp:
+ break;
case InputKeyLeft:
+ if(!context->is_attacking) {
+ if(context->time_between_cards > 0) {
+ context->time_between_cards--;
+ }
+ }
+ break;
case InputKeyRight:
+ if(!context->is_attacking) {
+ if(context->time_between_cards < 60) {
+ context->time_between_cards++;
+ }
+ }
break;
case InputKeyOk:
counter = 0;
@@ -284,7 +538,7 @@ void flipfrid_scene_run_attack_on_event(FlipFridEvent event, FlipFridState* cont
context->attack_step = 0;
context->is_attacking = false;
- string_reset(context->notification_msg);
+ furi_string_reset(context->notification_msg);
context->current_scene = SceneEntryPoint;
notification_message(context->notify, &sequence_blink_stop);
break;
@@ -303,9 +557,10 @@ void flipfrid_scene_run_attack_on_draw(Canvas* canvas, FlipFridState* context) {
// Title
canvas_set_font(canvas, FontPrimary);
canvas_draw_str_aligned(
- canvas, 64, 8, AlignCenter, AlignTop, string_get_cstr(context->attack_name));
+ canvas, 64, 2, AlignCenter, AlignTop, furi_string_get_cstr(context->attack_name));
char uid[18];
+ char speed[16];
if(context->proto == HIDProx) {
snprintf(
uid,
@@ -317,6 +572,23 @@ void flipfrid_scene_run_attack_on_draw(Canvas* canvas, FlipFridState* context) {
context->payload[3],
context->payload[4],
context->payload[5]);
+ } else if(context->proto == PAC) {
+ snprintf(
+ uid,
+ sizeof(uid),
+ "%02X:%02X:%02X:%02X",
+ context->payload[0],
+ context->payload[1],
+ context->payload[2],
+ context->payload[3]);
+ } else if(context->proto == H10301) {
+ snprintf(
+ uid,
+ sizeof(uid),
+ "%02X:%02X:%02X",
+ context->payload[0],
+ context->payload[1],
+ context->payload[2]);
} else {
snprintf(
uid,
@@ -329,15 +601,25 @@ void flipfrid_scene_run_attack_on_draw(Canvas* canvas, FlipFridState* context) {
context->payload[4]);
}
- canvas_draw_str_aligned(canvas, 64, 24, AlignCenter, AlignTop, uid);
+ canvas_draw_str_aligned(canvas, 64, 38, AlignCenter, AlignTop, uid);
canvas_set_font(canvas, FontSecondary);
+
+ canvas_draw_str_aligned(
+ canvas, 64, 26, AlignCenter, AlignTop, furi_string_get_cstr(context->proto_name));
+
+ snprintf(speed, sizeof(speed), "Time delay: %d", context->time_between_cards);
+
+ //canvas_draw_str_aligned(canvas, 0, 22, AlignLeft, AlignTop, "Speed:");
+ canvas_draw_str_aligned(canvas, 64, 14, AlignCenter, AlignTop, speed);
//char start_stop_msg[20];
if(context->is_attacking) {
elements_button_center(canvas, "Stop");
//snprintf(start_stop_msg, sizeof(start_stop_msg), " Press OK to stop ");
} else {
elements_button_center(canvas, "Start");
+ elements_button_left(canvas, "TD -");
+ elements_button_right(canvas, "+ TD");
}
//canvas_draw_str_aligned(canvas, 64, 44, AlignCenter, AlignTop, start_stop_msg);
}
diff --git a/applications/plugins/flipfrid/scene/flipfrid_scene_select_field.c b/applications/plugins/flipfrid/scene/flipfrid_scene_select_field.c
index 03411b2f4..79416d616 100644
--- a/applications/plugins/flipfrid/scene/flipfrid_scene_select_field.c
+++ b/applications/plugins/flipfrid/scene/flipfrid_scene_select_field.c
@@ -1,8 +1,31 @@
#include "flipfrid_scene_select_field.h"
void flipfrid_center_displayed_key(FlipFridState* context, uint8_t index) {
- const char* key_cstr = string_get_cstr(context->data_str);
+ char key_cstr[18];
+ uint8_t key_len = 18;
uint8_t str_index = (index * 3);
+ int data_len = sizeof(context->data) / sizeof(context->data[0]);
+ int key_index = 0;
+
+ if(context->proto == EM4100) {
+ key_len = 16;
+ }
+ if(context->proto == PAC) {
+ key_len = 13;
+ }
+ if(context->proto == H10301) {
+ key_len = 10;
+ }
+
+ for(uint8_t i = 0; i < data_len; i++) {
+ if(context->data[i] < 9) {
+ key_index +=
+ snprintf(&key_cstr[key_index], key_len - key_index, "0%X ", context->data[i]);
+ } else {
+ key_index +=
+ snprintf(&key_cstr[key_index], key_len - key_index, "%X ", context->data[i]);
+ }
+ }
char display_menu[17] = {
'X', 'X', ' ', 'X', 'X', ' ', '<', 'X', 'X', '>', ' ', 'X', 'X', ' ', 'X', 'X', '\0'};
@@ -42,12 +65,12 @@ void flipfrid_center_displayed_key(FlipFridState* context, uint8_t index) {
display_menu[15] = ' ';
}
- string_reset(context->notification_msg);
- string_set_str(context->notification_msg, display_menu);
+ furi_string_reset(context->notification_msg);
+ furi_string_set(context->notification_msg, display_menu);
}
void flipfrid_scene_select_field_on_enter(FlipFridState* context) {
- string_clear(context->notification_msg);
+ furi_string_reset(context->notification_msg);
}
void flipfrid_scene_select_field_on_exit(FlipFridState* context) {
@@ -61,7 +84,8 @@ void flipfrid_scene_select_field_on_tick(FlipFridState* context) {
void flipfrid_scene_select_field_on_event(FlipFridEvent event, FlipFridState* context) {
if(event.evt_type == EventTypeKey) {
if(event.input_type == InputTypeShort) {
- const char* key_cstr = string_get_cstr(context->data_str);
+ const char* key_cstr = furi_string_get_cstr(context->data_str);
+ int data_len = sizeof(context->data) / sizeof(context->data[0]);
// don't look, it's ugly but I'm a python dev so...
uint8_t nb_bytes = 0;
@@ -73,7 +97,18 @@ void flipfrid_scene_select_field_on_event(FlipFridEvent event, FlipFridState* co
switch(event.key) {
case InputKeyDown:
+ for(uint8_t i = 0; i < data_len; i++) {
+ if(context->key_index == i) {
+ context->data[i] = (context->data[i] - 1);
+ }
+ }
+ break;
case InputKeyUp:
+ for(uint8_t i = 0; i < data_len; i++) {
+ if(context->key_index == i) {
+ context->data[i] = (context->data[i] + 1);
+ }
+ }
break;
case InputKeyLeft:
if(context->key_index > 0) {
@@ -86,11 +121,12 @@ void flipfrid_scene_select_field_on_event(FlipFridEvent event, FlipFridState* co
}
break;
case InputKeyOk:
- string_reset(context->notification_msg);
+ furi_string_reset(context->notification_msg);
context->current_scene = SceneAttack;
break;
case InputKeyBack:
- string_reset(context->notification_msg);
+ context->key_index = 0;
+ furi_string_reset(context->notification_msg);
context->current_scene = SceneSelectFile;
break;
}
@@ -106,16 +142,17 @@ void flipfrid_scene_select_field_on_draw(Canvas* canvas, FlipFridState* context)
// Frame
//canvas_draw_frame(canvas, 0, 0, 128, 64);
- // Title
- canvas_set_font(canvas, FontPrimary);
- canvas_draw_str_aligned(canvas, 64, 10, AlignCenter, AlignTop, "Use < > to select byte.");
+ canvas_set_font(canvas, FontSecondary);
+ canvas_draw_str_aligned(canvas, 12, 5, AlignLeft, AlignTop, "Left and right: select byte");
+ canvas_draw_str_aligned(canvas, 12, 15, AlignLeft, AlignTop, "Up and down: adjust byte");
char msg_index[18];
+ canvas_set_font(canvas, FontPrimary);
snprintf(msg_index, sizeof(msg_index), "Field index : %d", context->key_index);
- canvas_draw_str_aligned(canvas, 64, 26, AlignCenter, AlignTop, msg_index);
+ canvas_draw_str_aligned(canvas, 64, 30, AlignCenter, AlignTop, msg_index);
flipfrid_center_displayed_key(context, context->key_index);
canvas_set_font(canvas, FontSecondary);
canvas_draw_str_aligned(
- canvas, 64, 40, AlignCenter, AlignTop, string_get_cstr(context->notification_msg));
+ canvas, 64, 45, AlignCenter, AlignTop, furi_string_get_cstr(context->notification_msg));
}
diff --git a/applications/plugins/mousejacker/application.fam b/applications/plugins/mousejacker/application.fam
index 9c71bf7a3..07ee51ae3 100644
--- a/applications/plugins/mousejacker/application.fam
+++ b/applications/plugins/mousejacker/application.fam
@@ -1,5 +1,5 @@
App(
- appid="mouse_jacker",
+ appid="NRF24_Mouse_Jacker",
name="[NRF24] Mouse Jacker",
apptype=FlipperAppType.EXTERNAL,
entry_point="mousejacker_app",
diff --git a/applications/plugins/mousejacker/mousejacker.c b/applications/plugins/mousejacker/mousejacker.c
index 99fade1c5..a0cf4845f 100644
--- a/applications/plugins/mousejacker/mousejacker.c
+++ b/applications/plugins/mousejacker/mousejacker.c
@@ -104,9 +104,9 @@ static void hexlify(uint8_t* in, uint8_t size, char* out) {
static bool open_ducky_script(Stream* stream, PluginState* plugin_state) {
DialogsApp* dialogs = furi_record_open("dialogs");
bool result = false;
- string_t path;
- string_init(path);
- string_set_str(path, MOUSEJACKER_APP_PATH_FOLDER);
+ FuriString* path;
+ path = furi_string_alloc();
+ furi_string_set(path, MOUSEJACKER_APP_PATH_FOLDER);
DialogsFileBrowserOptions browser_options;
dialog_file_browser_set_basic_options(
@@ -117,13 +117,13 @@ static bool open_ducky_script(Stream* stream, PluginState* plugin_state) {
furi_record_close("dialogs");
if(ret) {
- if(!file_stream_open(stream, string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
- FURI_LOG_D(TAG, "Cannot open file \"%s\"", (path));
+ if(!file_stream_open(stream, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
+ FURI_LOG_D(TAG, "Cannot open file \"%s\"", furi_string_get_cstr(path));
} else {
result = true;
}
}
- string_clear(path);
+ furi_string_free(path);
plugin_state->is_ducky_running = true;
@@ -133,9 +133,9 @@ static bool open_ducky_script(Stream* stream, PluginState* plugin_state) {
static bool open_addrs_file(Stream* stream) {
DialogsApp* dialogs = furi_record_open("dialogs");
bool result = false;
- string_t path;
- string_init(path);
- string_set_str(path, NRFSNIFF_APP_PATH_FOLDER);
+ FuriString* path;
+ path = furi_string_alloc();
+ furi_string_set(path, NRFSNIFF_APP_PATH_FOLDER);
DialogsFileBrowserOptions browser_options;
dialog_file_browser_set_basic_options(
@@ -146,13 +146,13 @@ static bool open_addrs_file(Stream* stream) {
furi_record_close("dialogs");
if(ret) {
- if(!file_stream_open(stream, string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
- FURI_LOG_D(TAG, "Cannot open file \"%s\"", (path));
+ if(!file_stream_open(stream, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
+ FURI_LOG_D(TAG, "Cannot open file \"%s\"", furi_string_get_cstr(path));
} else {
result = true;
}
}
- string_clear(path);
+ furi_string_free(path);
return result;
}
diff --git a/applications/plugins/mousejacker/mousejacker_ducky.c b/applications/plugins/mousejacker/mousejacker_ducky.c
index f323a93da..7a57856e1 100644
--- a/applications/plugins/mousejacker/mousejacker_ducky.c
+++ b/applications/plugins/mousejacker/mousejacker_ducky.c
@@ -261,7 +261,7 @@ static bool mj_process_ducky_line(
repeat_cnt = atoi(line_tmp);
if(repeat_cnt < 2) return false;
- FURI_LOG_D(TAG, "repeating %s %d times", prev_line, repeat_cnt);
+ FURI_LOG_D(TAG, "repeating %s %ld times", prev_line, repeat_cnt);
for(uint32_t i = 0; i < repeat_cnt; i++)
mj_process_ducky_line(handle, addr, addr_size, rate, prev_line, NULL, plugin_state);
diff --git a/applications/plugins/multi_converter/application.fam b/applications/plugins/multi_converter/application.fam
index 5da46e06b..b19bce895 100644
--- a/applications/plugins/multi_converter/application.fam
+++ b/applications/plugins/multi_converter/application.fam
@@ -1,5 +1,5 @@
App(
- appid="multi_converter",
+ appid="Multi_Converter",
name="Multi Converter",
apptype=FlipperAppType.EXTERNAL,
entry_point="multi_converter_app",
diff --git a/applications/plugins/music_player/application.fam b/applications/plugins/music_player/application.fam
index 30f2b9268..cfb50c451 100644
--- a/applications/plugins/music_player/application.fam
+++ b/applications/plugins/music_player/application.fam
@@ -1,5 +1,5 @@
App(
- appid="music_player",
+ appid="Music_Player",
name="Music Player",
apptype=FlipperAppType.PLUGIN,
entry_point="music_player_app",
diff --git a/applications/plugins/music_player/music_player.c b/applications/plugins/music_player/music_player.c
index 40e9085fb..6d3c4483e 100644
--- a/applications/plugins/music_player/music_player.c
+++ b/applications/plugins/music_player/music_player.c
@@ -8,8 +8,6 @@
#include
#include
-#include
-
#define TAG "MusicPlayer"
#define MUSIC_PLAYER_APP_PATH_FOLDER ANY_PATH("music_player")
@@ -296,14 +294,14 @@ void music_player_free(MusicPlayer* instance) {
int32_t music_player_app(void* p) {
MusicPlayer* music_player = music_player_alloc();
- string_t file_path;
- string_init(file_path);
+ FuriString* file_path;
+ file_path = furi_string_alloc();
do {
if(p && strlen(p)) {
- string_cat_str(file_path, p);
+ furi_string_cat(file_path, (const char*)p);
} else {
- string_set_str(file_path, MUSIC_PLAYER_APP_PATH_FOLDER);
+ furi_string_set(file_path, MUSIC_PLAYER_APP_PATH_FOLDER);
DialogsFileBrowserOptions browser_options;
dialog_file_browser_set_basic_options(
@@ -320,7 +318,7 @@ int32_t music_player_app(void* p) {
}
}
- if(!music_player_worker_load(music_player->worker, string_get_cstr(file_path))) {
+ if(!music_player_worker_load(music_player->worker, furi_string_get_cstr(file_path))) {
FURI_LOG_E(TAG, "Unable to load file");
break;
}
@@ -354,7 +352,7 @@ int32_t music_player_app(void* p) {
music_player_worker_stop(music_player->worker);
} while(0);
- string_clear(file_path);
+ furi_string_free(file_path);
music_player_free(music_player);
return 0;
diff --git a/applications/plugins/music_player/music_player_cli.c b/applications/plugins/music_player/music_player_cli.c
index 782004439..90060d7ee 100644
--- a/applications/plugins/music_player/music_player_cli.c
+++ b/applications/plugins/music_player/music_player_cli.c
@@ -3,20 +3,20 @@
#include
#include "music_player_worker.h"
-static void music_player_cli(Cli* cli, string_t args, void* context) {
+static void music_player_cli(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
MusicPlayerWorker* music_player_worker = music_player_worker_alloc();
Storage* storage = furi_record_open(RECORD_STORAGE);
do {
- if(storage_common_stat(storage, string_get_cstr(args), NULL) == FSE_OK) {
- if(!music_player_worker_load(music_player_worker, string_get_cstr(args))) {
- printf("Failed to open file %s\r\n", string_get_cstr(args));
+ if(storage_common_stat(storage, furi_string_get_cstr(args), NULL) == FSE_OK) {
+ if(!music_player_worker_load(music_player_worker, furi_string_get_cstr(args))) {
+ printf("Failed to open file %s\r\n", furi_string_get_cstr(args));
break;
}
} else {
if(!music_player_worker_load_rtttl_from_string(
- music_player_worker, string_get_cstr(args))) {
+ music_player_worker, furi_string_get_cstr(args))) {
printf("Argument is not a file or RTTTL\r\n");
break;
}
diff --git a/applications/plugins/music_player/music_player_worker.c b/applications/plugins/music_player/music_player_worker.c
index ca4f1d8c9..99f0ce1e5 100644
--- a/applications/plugins/music_player/music_player_worker.c
+++ b/applications/plugins/music_player/music_player_worker.c
@@ -258,7 +258,7 @@ static bool music_player_worker_parse_notes(MusicPlayerWorker* instance, const c
if(!is_valid) {
FURI_LOG_E(
TAG,
- "Invalid note: %u%c%c%u.%u",
+ "Invalid note: %lu%c%c%lu.%lu",
duration,
note_char == '\0' ? '_' : note_char,
sharp_char == '\0' ? '_' : sharp_char,
@@ -281,7 +281,7 @@ static bool music_player_worker_parse_notes(MusicPlayerWorker* instance, const c
if(music_player_worker_add_note(instance, semitone, duration, dots)) {
FURI_LOG_D(
TAG,
- "Added note: %c%c%u.%u = %u %u",
+ "Added note: %c%c%lu.%lu = %u %lu",
note_char == '\0' ? '_' : note_char,
sharp_char == '\0' ? '_' : sharp_char,
octave,
@@ -291,7 +291,7 @@ static bool music_player_worker_parse_notes(MusicPlayerWorker* instance, const c
} else {
FURI_LOG_E(
TAG,
- "Invalid note: %c%c%u.%u = %u %u",
+ "Invalid note: %c%c%lu.%lu = %u %lu",
note_char == '\0' ? '_' : note_char,
sharp_char == '\0' ? '_' : sharp_char,
octave,
@@ -326,8 +326,8 @@ bool music_player_worker_load_fmf_from_file(MusicPlayerWorker* instance, const c
furi_assert(file_path);
bool result = false;
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* file = flipper_format_file_alloc(storage);
@@ -337,7 +337,8 @@ bool music_player_worker_load_fmf_from_file(MusicPlayerWorker* instance, const c
uint32_t version = 0;
if(!flipper_format_read_header(file, temp_str, &version)) break;
- if(string_cmp_str(temp_str, MUSIC_PLAYER_FILETYPE) || (version != MUSIC_PLAYER_VERSION)) {
+ if(furi_string_cmp_str(temp_str, MUSIC_PLAYER_FILETYPE) ||
+ (version != MUSIC_PLAYER_VERSION)) {
FURI_LOG_E(TAG, "Incorrect file format or version");
break;
}
@@ -360,7 +361,7 @@ bool music_player_worker_load_fmf_from_file(MusicPlayerWorker* instance, const c
break;
}
- if(!music_player_worker_parse_notes(instance, string_get_cstr(temp_str))) {
+ if(!music_player_worker_parse_notes(instance, furi_string_get_cstr(temp_str))) {
break;
}
@@ -369,7 +370,7 @@ bool music_player_worker_load_fmf_from_file(MusicPlayerWorker* instance, const c
furi_record_close(RECORD_STORAGE);
flipper_format_free(file);
- string_clear(temp_str);
+ furi_string_free(temp_str);
return result;
}
@@ -379,8 +380,8 @@ bool music_player_worker_load_rtttl_from_file(MusicPlayerWorker* instance, const
furi_assert(file_path);
bool result = false;
- string_t content;
- string_init(content);
+ FuriString* content;
+ content = furi_string_alloc();
Storage* storage = furi_record_open(RECORD_STORAGE);
File* file = storage_file_alloc(storage);
@@ -395,17 +396,17 @@ bool music_player_worker_load_rtttl_from_file(MusicPlayerWorker* instance, const
uint8_t buffer[65] = {0};
ret = storage_file_read(file, buffer, sizeof(buffer) - 1);
for(size_t i = 0; i < ret; i++) {
- string_push_back(content, buffer[i]);
+ furi_string_push_back(content, buffer[i]);
}
} while(ret > 0);
- string_strim(content);
- if(!string_size(content)) {
+ furi_string_trim(content);
+ if(!furi_string_size(content)) {
FURI_LOG_E(TAG, "Empty file");
break;
}
- if(!music_player_worker_load_rtttl_from_string(instance, string_get_cstr(content))) {
+ if(!music_player_worker_load_rtttl_from_string(instance, furi_string_get_cstr(content))) {
FURI_LOG_E(TAG, "Invalid file content");
break;
}
@@ -415,7 +416,7 @@ bool music_player_worker_load_rtttl_from_file(MusicPlayerWorker* instance, const
storage_file_free(file);
furi_record_close(RECORD_STORAGE);
- string_clear(content);
+ furi_string_free(content);
return result;
}
diff --git a/applications/plugins/nrfsniff/application.fam b/applications/plugins/nrfsniff/application.fam
index 269f139a9..5caa945ee 100644
--- a/applications/plugins/nrfsniff/application.fam
+++ b/applications/plugins/nrfsniff/application.fam
@@ -1,5 +1,5 @@
App(
- appid="nrf_sniff",
+ appid="NRF24_Sniffer",
name="[NRF24] Sniffer",
apptype=FlipperAppType.EXTERNAL,
entry_point="nrfsniff_app",
diff --git a/applications/plugins/picopass/application.fam b/applications/plugins/picopass/application.fam
index 7a81e0804..88b5b4c3d 100644
--- a/applications/plugins/picopass/application.fam
+++ b/applications/plugins/picopass/application.fam
@@ -1,5 +1,5 @@
App(
- appid="picopass",
+ appid="Picopass",
name="PicoPass Reader",
apptype=FlipperAppType.EXTERNAL,
entry_point="picopass_app",
@@ -10,8 +10,11 @@ App(
stack_size=4 * 1024,
order=30,
fap_icon="../../../assets/icons/Archive/125_10px.png",
- fap_libs=[
- "mbedtls",
- ],
fap_category="Tools",
+ fap_libs=["mbedtls"],
+ fap_private_libs=[
+ Lib(
+ name="loclass",
+ ),
+ ],
)
diff --git a/applications/plugins/picopass/loclass/optimized_cipher.c b/applications/plugins/picopass/lib/loclass/optimized_cipher.c
similarity index 100%
rename from applications/plugins/picopass/loclass/optimized_cipher.c
rename to applications/plugins/picopass/lib/loclass/optimized_cipher.c
diff --git a/applications/plugins/picopass/loclass/optimized_cipher.h b/applications/plugins/picopass/lib/loclass/optimized_cipher.h
similarity index 100%
rename from applications/plugins/picopass/loclass/optimized_cipher.h
rename to applications/plugins/picopass/lib/loclass/optimized_cipher.h
diff --git a/applications/plugins/picopass/loclass/optimized_cipherutils.c b/applications/plugins/picopass/lib/loclass/optimized_cipherutils.c
similarity index 100%
rename from applications/plugins/picopass/loclass/optimized_cipherutils.c
rename to applications/plugins/picopass/lib/loclass/optimized_cipherutils.c
diff --git a/applications/plugins/picopass/loclass/optimized_cipherutils.h b/applications/plugins/picopass/lib/loclass/optimized_cipherutils.h
similarity index 100%
rename from applications/plugins/picopass/loclass/optimized_cipherutils.h
rename to applications/plugins/picopass/lib/loclass/optimized_cipherutils.h
diff --git a/applications/plugins/picopass/loclass/optimized_elite.c b/applications/plugins/picopass/lib/loclass/optimized_elite.c
similarity index 100%
rename from applications/plugins/picopass/loclass/optimized_elite.c
rename to applications/plugins/picopass/lib/loclass/optimized_elite.c
diff --git a/applications/plugins/picopass/loclass/optimized_elite.h b/applications/plugins/picopass/lib/loclass/optimized_elite.h
similarity index 100%
rename from applications/plugins/picopass/loclass/optimized_elite.h
rename to applications/plugins/picopass/lib/loclass/optimized_elite.h
diff --git a/applications/plugins/picopass/loclass/optimized_ikeys.c b/applications/plugins/picopass/lib/loclass/optimized_ikeys.c
similarity index 100%
rename from applications/plugins/picopass/loclass/optimized_ikeys.c
rename to applications/plugins/picopass/lib/loclass/optimized_ikeys.c
diff --git a/applications/plugins/picopass/loclass/optimized_ikeys.h b/applications/plugins/picopass/lib/loclass/optimized_ikeys.h
similarity index 100%
rename from applications/plugins/picopass/loclass/optimized_ikeys.h
rename to applications/plugins/picopass/lib/loclass/optimized_ikeys.h
diff --git a/applications/plugins/picopass/picopass_device.c b/applications/plugins/picopass/picopass_device.c
index e7f3e0bed..b6e69cc21 100644
--- a/applications/plugins/picopass/picopass_device.c
+++ b/applications/plugins/picopass/picopass_device.c
@@ -18,7 +18,7 @@ PicopassDevice* picopass_device_alloc() {
picopass_dev->dev_data.pacs.pin_length = 0;
picopass_dev->storage = furi_record_open(RECORD_STORAGE);
picopass_dev->dialogs = furi_record_open(RECORD_DIALOGS);
- string_init(picopass_dev->load_path);
+ picopass_dev->load_path = furi_string_alloc();
return picopass_dev;
}
@@ -40,25 +40,25 @@ static bool picopass_device_save_file(
FlipperFormat* file = flipper_format_file_alloc(dev->storage);
PicopassPacs* pacs = &dev->dev_data.pacs;
PicopassBlock* AA1 = dev->dev_data.AA1;
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
do {
- if(use_load_path && !string_empty_p(dev->load_path)) {
+ if(use_load_path && !furi_string_empty(dev->load_path)) {
// Get directory name
- path_extract_dirname(string_get_cstr(dev->load_path), temp_str);
+ path_extract_dirname(furi_string_get_cstr(dev->load_path), temp_str);
// Create picopass directory if necessary
- if(!storage_simply_mkdir(dev->storage, string_get_cstr(temp_str))) break;
+ if(!storage_simply_mkdir(dev->storage, furi_string_get_cstr(temp_str))) break;
// Make path to file to save
- string_cat_printf(temp_str, "/%s%s", dev_name, extension);
+ furi_string_cat_printf(temp_str, "/%s%s", dev_name, extension);
} else {
// Create picopass directory if necessary
if(!storage_simply_mkdir(dev->storage, PICOPASS_APP_FOLDER)) break;
// First remove picopass device file if it was saved
- string_printf(temp_str, "%s/%s%s", folder, dev_name, extension);
+ furi_string_printf(temp_str, "%s/%s%s", folder, dev_name, extension);
}
// Open file
- if(!flipper_format_file_open_always(file, string_get_cstr(temp_str))) break;
+ if(!flipper_format_file_open_always(file, furi_string_get_cstr(temp_str))) break;
if(dev->format == PicopassDeviceSaveFormatHF) {
uint32_t fc = pacs->record.FacilityCode;
@@ -87,9 +87,9 @@ static bool picopass_device_save_file(
AA1[PICOPASS_CONFIG_BLOCK_INDEX].data[0] :
PICOPASS_MAX_APP_LIMIT;
for(size_t i = 0; i < app_limit; i++) {
- string_printf(temp_str, "Block %d", i);
+ furi_string_printf(temp_str, "Block %d", i);
if(!flipper_format_write_hex(
- file, string_get_cstr(temp_str), AA1[i].data, PICOPASS_BLOCK_LEN)) {
+ file, furi_string_get_cstr(temp_str), AA1[i].data, PICOPASS_BLOCK_LEN)) {
block_saved = false;
break;
}
@@ -117,7 +117,7 @@ static bool picopass_device_save_file(
if(!saved) {
dialog_message_show_storage_error(dev->dialogs, "Can not save\nfile");
}
- string_clear(temp_str);
+ furi_string_free(temp_str);
flipper_format_free(file);
return saved;
}
@@ -132,13 +132,13 @@ bool picopass_device_save(PicopassDevice* dev, const char* dev_name) {
return false;
}
-static bool picopass_device_load_data(PicopassDevice* dev, string_t path, bool show_dialog) {
+static bool picopass_device_load_data(PicopassDevice* dev, FuriString* path, bool show_dialog) {
bool parsed = false;
FlipperFormat* file = flipper_format_file_alloc(dev->storage);
PicopassBlock* AA1 = dev->dev_data.AA1;
PicopassPacs* pacs = &dev->dev_data.pacs;
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
bool deprecated_version = false;
if(dev->loading_cb) {
@@ -146,12 +146,13 @@ static bool picopass_device_load_data(PicopassDevice* dev, string_t path, bool s
}
do {
- if(!flipper_format_file_open_existing(file, string_get_cstr(path))) break;
+ if(!flipper_format_file_open_existing(file, furi_string_get_cstr(path))) break;
// Read and verify file header
uint32_t version = 0;
if(!flipper_format_read_header(file, temp_str, &version)) break;
- if(string_cmp_str(temp_str, picopass_file_header) || (version != picopass_file_version)) {
+ if(furi_string_cmp_str(temp_str, picopass_file_header) ||
+ (version != picopass_file_version)) {
deprecated_version = true;
break;
}
@@ -159,9 +160,9 @@ static bool picopass_device_load_data(PicopassDevice* dev, string_t path, bool s
// Parse header blocks
bool block_read = true;
for(size_t i = 0; i < 6; i++) {
- string_printf(temp_str, "Block %d", i);
+ furi_string_printf(temp_str, "Block %d", i);
if(!flipper_format_read_hex(
- file, string_get_cstr(temp_str), AA1[i].data, PICOPASS_BLOCK_LEN)) {
+ file, furi_string_get_cstr(temp_str), AA1[i].data, PICOPASS_BLOCK_LEN)) {
block_read = false;
break;
}
@@ -169,9 +170,9 @@ static bool picopass_device_load_data(PicopassDevice* dev, string_t path, bool s
size_t app_limit = AA1[PICOPASS_CONFIG_BLOCK_INDEX].data[0];
for(size_t i = 6; i < app_limit; i++) {
- string_printf(temp_str, "Block %d", i);
+ furi_string_printf(temp_str, "Block %d", i);
if(!flipper_format_read_hex(
- file, string_get_cstr(temp_str), AA1[i].data, PICOPASS_BLOCK_LEN)) {
+ file, furi_string_get_cstr(temp_str), AA1[i].data, PICOPASS_BLOCK_LEN)) {
block_read = false;
break;
}
@@ -196,7 +197,7 @@ static bool picopass_device_load_data(PicopassDevice* dev, string_t path, bool s
}
}
- string_clear(temp_str);
+ furi_string_free(temp_str);
flipper_format_free(file);
return parsed;
@@ -208,7 +209,7 @@ void picopass_device_clear(PicopassDevice* dev) {
picopass_device_data_clear(&dev->dev_data);
memset(&dev->dev_data, 0, sizeof(dev->dev_data));
dev->format = PicopassDeviceSaveFormatHF;
- string_reset(dev->load_path);
+ furi_string_reset(dev->load_path);
}
void picopass_device_free(PicopassDevice* picopass_dev) {
@@ -216,7 +217,7 @@ void picopass_device_free(PicopassDevice* picopass_dev) {
picopass_device_clear(picopass_dev);
furi_record_close(RECORD_STORAGE);
furi_record_close(RECORD_DIALOGS);
- string_clear(picopass_dev->load_path);
+ furi_string_free(picopass_dev->load_path);
free(picopass_dev);
}
@@ -224,8 +225,8 @@ bool picopass_file_select(PicopassDevice* dev) {
furi_assert(dev);
// Input events and views are managed by file_browser
- string_t picopass_app_folder;
- string_init_set_str(picopass_app_folder, PICOPASS_APP_FOLDER);
+ FuriString* picopass_app_folder;
+ picopass_app_folder = furi_string_alloc_set(PICOPASS_APP_FOLDER);
DialogsFileBrowserOptions browser_options;
dialog_file_browser_set_basic_options(&browser_options, PICOPASS_APP_EXTENSION, &I_Nfc_10px);
@@ -233,17 +234,17 @@ bool picopass_file_select(PicopassDevice* dev) {
bool res = dialog_file_browser_show(
dev->dialogs, dev->load_path, picopass_app_folder, &browser_options);
- string_clear(picopass_app_folder);
+ furi_string_free(picopass_app_folder);
if(res) {
- string_t filename;
- string_init(filename);
+ FuriString* filename;
+ filename = furi_string_alloc();
path_extract_filename(dev->load_path, filename, true);
- strncpy(dev->dev_name, string_get_cstr(filename), PICOPASS_DEV_NAME_MAX_LEN);
+ strncpy(dev->dev_name, furi_string_get_cstr(filename), PICOPASS_DEV_NAME_MAX_LEN);
res = picopass_device_load_data(dev, dev->load_path, true);
if(res) {
picopass_device_set_name(dev, dev->dev_name);
}
- string_clear(filename);
+ furi_string_free(filename);
}
return res;
@@ -262,18 +263,18 @@ bool picopass_device_delete(PicopassDevice* dev, bool use_load_path) {
furi_assert(dev);
bool deleted = false;
- string_t file_path;
- string_init(file_path);
+ FuriString* file_path;
+ file_path = furi_string_alloc();
do {
// Delete original file
- if(use_load_path && !string_empty_p(dev->load_path)) {
- string_set(file_path, dev->load_path);
+ if(use_load_path && !furi_string_empty(dev->load_path)) {
+ furi_string_set(file_path, dev->load_path);
} else {
- string_printf(
+ furi_string_printf(
file_path, "%s/%s%s", PICOPASS_APP_FOLDER, dev->dev_name, PICOPASS_APP_EXTENSION);
}
- if(!storage_simply_remove(dev->storage, string_get_cstr(file_path))) break;
+ if(!storage_simply_remove(dev->storage, furi_string_get_cstr(file_path))) break;
deleted = true;
} while(0);
@@ -281,7 +282,7 @@ bool picopass_device_delete(PicopassDevice* dev, bool use_load_path) {
dialog_message_show_storage_error(dev->dialogs, "Can not remove file");
}
- string_clear(file_path);
+ furi_string_free(file_path);
return deleted;
}
diff --git a/applications/plugins/picopass/picopass_device.h b/applications/plugins/picopass/picopass_device.h
index 745b64bd5..ed6bb4781 100644
--- a/applications/plugins/picopass/picopass_device.h
+++ b/applications/plugins/picopass/picopass_device.h
@@ -7,8 +7,8 @@
#include
#include "rfal_picopass.h"
-#include "loclass/optimized_ikeys.h"
-#include "loclass/optimized_cipher.h"
+#include
+#include
#define PICOPASS_DEV_NAME_MAX_LEN 22
#define PICOPASS_READER_DATA_MAX_SIZE 64
@@ -71,7 +71,7 @@ typedef struct {
DialogsApp* dialogs;
PicopassDeviceData dev_data;
char dev_name[PICOPASS_DEV_NAME_MAX_LEN + 1];
- string_t load_path;
+ FuriString* load_path;
PicopassDeviceSaveFormat format;
PicopassLoadingCallback loading_cb;
void* loading_cb_ctx;
diff --git a/applications/plugins/picopass/picopass_i.h b/applications/plugins/picopass/picopass_i.h
index dec5a865f..8e011f222 100644
--- a/applications/plugins/picopass/picopass_i.h
+++ b/applications/plugins/picopass/picopass_i.h
@@ -51,7 +51,7 @@ struct Picopass {
PicopassDevice* dev;
char text_store[PICOPASS_TEXT_STORE_SIZE + 1];
- string_t text_box_store;
+ FuriString* text_box_store;
// Common Views
Submenu* submenu;
diff --git a/applications/plugins/picopass/scenes/picopass_scene_device_info.c b/applications/plugins/picopass/scenes/picopass_scene_device_info.c
index 38891b673..046e9c8e4 100644
--- a/applications/plugins/picopass/scenes/picopass_scene_device_info.c
+++ b/applications/plugins/picopass/scenes/picopass_scene_device_info.c
@@ -14,10 +14,10 @@ void picopass_scene_device_info_widget_callback(
void picopass_scene_device_info_on_enter(void* context) {
Picopass* picopass = context;
- string_t credential_str;
- string_t wiegand_str;
- string_init(credential_str);
- string_init(wiegand_str);
+ FuriString* credential_str;
+ FuriString* wiegand_str;
+ credential_str = furi_string_alloc();
+ wiegand_str = furi_string_alloc();
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
@@ -26,25 +26,31 @@ void picopass_scene_device_info_on_enter(void* context) {
Widget* widget = picopass->widget;
size_t bytesLength = 1 + pacs->record.bitLength / 8;
- string_set_str(credential_str, "");
+ furi_string_set(credential_str, "");
for(uint8_t i = PICOPASS_BLOCK_LEN - bytesLength; i < PICOPASS_BLOCK_LEN; i++) {
- string_cat_printf(credential_str, " %02X", pacs->credential[i]);
+ furi_string_cat_printf(credential_str, " %02X", pacs->credential[i]);
}
if(pacs->record.valid) {
- string_cat_printf(
+ furi_string_cat_printf(
wiegand_str, "FC: %u CN: %u", pacs->record.FacilityCode, pacs->record.CardNumber);
} else {
- string_cat_printf(wiegand_str, "%d bits", pacs->record.bitLength);
+ furi_string_cat_printf(wiegand_str, "%d bits", pacs->record.bitLength);
}
widget_add_string_element(
- widget, 64, 12, AlignCenter, AlignCenter, FontPrimary, string_get_cstr(wiegand_str));
+ widget, 64, 12, AlignCenter, AlignCenter, FontPrimary, furi_string_get_cstr(wiegand_str));
widget_add_string_element(
- widget, 64, 32, AlignCenter, AlignCenter, FontSecondary, string_get_cstr(credential_str));
+ widget,
+ 64,
+ 32,
+ AlignCenter,
+ AlignCenter,
+ FontSecondary,
+ furi_string_get_cstr(credential_str));
- string_clear(credential_str);
- string_clear(wiegand_str);
+ furi_string_free(credential_str);
+ furi_string_free(wiegand_str);
widget_add_button_element(
picopass->widget,
diff --git a/applications/plugins/picopass/scenes/picopass_scene_read_card_success.c b/applications/plugins/picopass/scenes/picopass_scene_read_card_success.c
index 785f3a7dd..37f1db4f2 100644
--- a/applications/plugins/picopass/scenes/picopass_scene_read_card_success.c
+++ b/applications/plugins/picopass/scenes/picopass_scene_read_card_success.c
@@ -15,12 +15,12 @@ void picopass_scene_read_card_success_widget_callback(
void picopass_scene_read_card_success_on_enter(void* context) {
Picopass* picopass = context;
- string_t credential_str;
- string_t wiegand_str;
- string_t sio_str;
- string_init(credential_str);
- string_init(wiegand_str);
- string_init(sio_str);
+ FuriString* credential_str;
+ FuriString* wiegand_str;
+ FuriString* sio_str;
+ credential_str = furi_string_alloc();
+ wiegand_str = furi_string_alloc();
+ sio_str = furi_string_alloc();
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
@@ -32,10 +32,10 @@ void picopass_scene_read_card_success_on_enter(void* context) {
Widget* widget = picopass->widget;
if(pacs->record.bitLength == 0) {
- string_cat_printf(wiegand_str, "Read Failed");
+ furi_string_cat_printf(wiegand_str, "Read Failed");
if(pacs->se_enabled) {
- string_cat_printf(credential_str, "SE enabled");
+ furi_string_cat_printf(credential_str, "SE enabled");
}
widget_add_button_element(
@@ -47,20 +47,20 @@ void picopass_scene_read_card_success_on_enter(void* context) {
} else {
size_t bytesLength = 1 + pacs->record.bitLength / 8;
- string_set_str(credential_str, "");
+ furi_string_set(credential_str, "");
for(uint8_t i = PICOPASS_BLOCK_LEN - bytesLength; i < PICOPASS_BLOCK_LEN; i++) {
- string_cat_printf(credential_str, " %02X", pacs->credential[i]);
+ furi_string_cat_printf(credential_str, " %02X", pacs->credential[i]);
}
if(pacs->record.valid) {
- string_cat_printf(
+ furi_string_cat_printf(
wiegand_str, "FC: %u CN: %u", pacs->record.FacilityCode, pacs->record.CardNumber);
} else {
- string_cat_printf(wiegand_str, "%d bits", pacs->record.bitLength);
+ furi_string_cat_printf(wiegand_str, "%d bits", pacs->record.bitLength);
}
if(pacs->sio) {
- string_cat_printf(sio_str, "+SIO");
+ furi_string_cat_printf(sio_str, "+SIO");
}
widget_add_button_element(
@@ -79,15 +79,21 @@ void picopass_scene_read_card_success_on_enter(void* context) {
}
widget_add_string_element(
- widget, 64, 12, AlignCenter, AlignCenter, FontPrimary, string_get_cstr(wiegand_str));
+ widget, 64, 12, AlignCenter, AlignCenter, FontPrimary, furi_string_get_cstr(wiegand_str));
widget_add_string_element(
- widget, 64, 32, AlignCenter, AlignCenter, FontSecondary, string_get_cstr(credential_str));
+ widget,
+ 64,
+ 32,
+ AlignCenter,
+ AlignCenter,
+ FontSecondary,
+ furi_string_get_cstr(credential_str));
widget_add_string_element(
- widget, 64, 42, AlignCenter, AlignCenter, FontSecondary, string_get_cstr(sio_str));
+ widget, 64, 42, AlignCenter, AlignCenter, FontSecondary, furi_string_get_cstr(sio_str));
- string_clear(credential_str);
- string_clear(wiegand_str);
- string_clear(sio_str);
+ furi_string_free(credential_str);
+ furi_string_free(wiegand_str);
+ furi_string_free(sio_str);
view_dispatcher_switch_to_view(picopass->view_dispatcher, PicopassViewWidget);
}
diff --git a/applications/plugins/picopass/scenes/picopass_scene_save_name.c b/applications/plugins/picopass/scenes/picopass_scene_save_name.c
index c5fa7dd1f..17ad5927a 100644
--- a/applications/plugins/picopass/scenes/picopass_scene_save_name.c
+++ b/applications/plugins/picopass/scenes/picopass_scene_save_name.c
@@ -1,5 +1,4 @@
#include "../picopass_i.h"
-#include "m-string.h"
#include
#include
#include
@@ -31,22 +30,22 @@ void picopass_scene_save_name_on_enter(void* context) {
PICOPASS_DEV_NAME_MAX_LEN,
dev_name_empty);
- string_t folder_path;
- string_init(folder_path);
+ FuriString* folder_path;
+ folder_path = furi_string_alloc();
- if(string_end_with_str_p(picopass->dev->load_path, PICOPASS_APP_EXTENSION)) {
- path_extract_dirname(string_get_cstr(picopass->dev->load_path), folder_path);
+ if(furi_string_end_with(picopass->dev->load_path, PICOPASS_APP_EXTENSION)) {
+ path_extract_dirname(furi_string_get_cstr(picopass->dev->load_path), folder_path);
} else {
- string_set_str(folder_path, PICOPASS_APP_FOLDER);
+ furi_string_set(folder_path, PICOPASS_APP_FOLDER);
}
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
- string_get_cstr(folder_path), PICOPASS_APP_EXTENSION, picopass->dev->dev_name);
+ furi_string_get_cstr(folder_path), PICOPASS_APP_EXTENSION, picopass->dev->dev_name);
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
view_dispatcher_switch_to_view(picopass->view_dispatcher, PicopassViewTextInput);
- string_clear(folder_path);
+ furi_string_free(folder_path);
}
bool picopass_scene_save_name_on_event(void* context, SceneManagerEvent event) {
diff --git a/applications/plugins/playlist/application.fam b/applications/plugins/playlist/application.fam
index 991809ae3..8be27aa6c 100644
--- a/applications/plugins/playlist/application.fam
+++ b/applications/plugins/playlist/application.fam
@@ -1,5 +1,5 @@
App(
- appid="sub_playlist",
+ appid="SubGHz_Playlist",
name="Sub-GHz Playlist",
apptype=FlipperAppType.EXTERNAL,
entry_point="playlist_app",
diff --git a/applications/plugins/playlist/playlist.c b/applications/plugins/playlist/playlist.c
index 33292a2fe..db03fadff 100644
--- a/applications/plugins/playlist/playlist.c
+++ b/applications/plugins/playlist/playlist.c
@@ -39,10 +39,10 @@ typedef struct {
int current_playlist_repetition; // current playlist repetition
// last 3 files
- string_t prev_0_path; // current file
- string_t prev_1_path; // previous file
- string_t prev_2_path; // previous previous file
- string_t prev_3_path; // you get the idea
+ FuriString* prev_0_path; // current file
+ FuriString* prev_1_path; // previous file
+ FuriString* prev_2_path; // previous previous file
+ FuriString* prev_3_path; // you get the idea
int state; // current state
@@ -56,7 +56,7 @@ typedef struct {
DisplayMeta* meta;
- string_t file_path; // path to the playlist file
+ FuriString* file_path; // path to the playlist file
bool ctl_request_exit; // can be set to true if the worker should exit
bool ctl_pause; // can be set to true if the worker should pause
@@ -73,7 +73,7 @@ typedef struct {
DisplayMeta* meta;
PlaylistWorker* worker;
- string_t file_path; // Path to the playlist file
+ FuriString* file_path; // Path to the playlist file
} Playlist;
////////////////////////////////////////////////////////////////////////////////
@@ -83,23 +83,23 @@ void meta_set_state(DisplayMeta* meta, int state) {
view_port_update(meta->view_port);
}
-static FuriHalSubGhzPreset str_to_preset(string_t preset) {
- if(string_cmp_str(preset, "FuriHalSubGhzPresetOok270Async") == 0) {
+static FuriHalSubGhzPreset str_to_preset(FuriString* preset) {
+ if(furi_string_cmp_str(preset, "FuriHalSubGhzPresetOok270Async") == 0) {
return FuriHalSubGhzPresetOok270Async;
}
- if(string_cmp_str(preset, "FuriHalSubGhzPresetOok650Async") == 0) {
+ if(furi_string_cmp_str(preset, "FuriHalSubGhzPresetOok650Async") == 0) {
return FuriHalSubGhzPresetOok650Async;
}
- if(string_cmp_str(preset, "FuriHalSubGhzPreset2FSKDev238Async") == 0) {
+ if(furi_string_cmp_str(preset, "FuriHalSubGhzPreset2FSKDev238Async") == 0) {
return FuriHalSubGhzPreset2FSKDev238Async;
}
- if(string_cmp_str(preset, "FuriHalSubGhzPreset2FSKDev476Async") == 0) {
+ if(furi_string_cmp_str(preset, "FuriHalSubGhzPreset2FSKDev476Async") == 0) {
return FuriHalSubGhzPreset2FSKDev476Async;
}
- if(string_cmp_str(preset, "FuriHalSubGhzPresetMSK99_97KbAsync") == 0) {
+ if(furi_string_cmp_str(preset, "FuriHalSubGhzPresetMSK99_97KbAsync") == 0) {
return FuriHalSubGhzPresetMSK99_97KbAsync;
}
- if(string_cmp_str(preset, "FuriHalSubGhzPresetMSK99_97KbAsync") == 0) {
+ if(furi_string_cmp_str(preset, "FuriHalSubGhzPresetMSK99_97KbAsync") == 0) {
return FuriHalSubGhzPresetMSK99_97KbAsync;
}
return FuriHalSubGhzPresetCustom;
@@ -117,8 +117,8 @@ static int playlist_worker_process(
FlipperFormat* fff_file,
FlipperFormat* fff_data,
const char* path,
- string_t preset,
- string_t protocol) {
+ FuriString* preset,
+ FuriString* protocol) {
// actual sending of .sub file
if(!flipper_format_file_open_existing(fff_file, path)) {
@@ -148,7 +148,7 @@ static int playlist_worker_process(
return -4;
}
- if(!string_cmp_str(protocol, "RAW")) {
+ if(!furi_string_cmp_str(protocol, "RAW")) {
subghz_protocol_raw_gen_fff_data(fff_data, path);
} else {
stream_copy_full(
@@ -159,7 +159,7 @@ static int playlist_worker_process(
// (try to) send file
SubGhzEnvironment* environment = subghz_environment_alloc();
SubGhzTransmitter* transmitter =
- subghz_transmitter_alloc_init(environment, string_get_cstr(protocol));
+ subghz_transmitter_alloc_init(environment, furi_string_get_cstr(protocol));
subghz_transmitter_deserialize(transmitter, fff_data);
@@ -216,9 +216,9 @@ static bool playlist_worker_play_playlist_once(
Storage* storage,
FlipperFormat* fff_head,
FlipperFormat* fff_data,
- string_t data,
- string_t preset,
- string_t protocol) {
+ FuriString* data,
+ FuriString* preset,
+ FuriString* protocol) {
//
if(!flipper_format_rewind(fff_head)) {
FURI_LOG_E(TAG, "Failed to rewind file");
@@ -233,17 +233,20 @@ static bool playlist_worker_play_playlist_once(
meta_set_state(worker->meta, STATE_SENDING);
++worker->meta->current_count;
- const char* str = string_get_cstr(data);
+ const char* str = furi_string_get_cstr(data);
// it's not fancy, but it works for now :)
- string_reset(worker->meta->prev_3_path);
- string_set_str(worker->meta->prev_3_path, string_get_cstr(worker->meta->prev_2_path));
- string_reset(worker->meta->prev_2_path);
- string_set_str(worker->meta->prev_2_path, string_get_cstr(worker->meta->prev_1_path));
- string_reset(worker->meta->prev_1_path);
- string_set_str(worker->meta->prev_1_path, string_get_cstr(worker->meta->prev_0_path));
- string_reset(worker->meta->prev_0_path);
- string_set_str(worker->meta->prev_0_path, str);
+ furi_string_reset(worker->meta->prev_3_path);
+ furi_string_set(
+ worker->meta->prev_3_path, furi_string_get_cstr(worker->meta->prev_2_path));
+ furi_string_reset(worker->meta->prev_2_path);
+ furi_string_set(
+ worker->meta->prev_2_path, furi_string_get_cstr(worker->meta->prev_1_path));
+ furi_string_reset(worker->meta->prev_1_path);
+ furi_string_set(
+ worker->meta->prev_1_path, furi_string_get_cstr(worker->meta->prev_0_path));
+ furi_string_reset(worker->meta->prev_0_path);
+ furi_string_set(worker->meta->prev_0_path, str);
view_port_update(worker->meta->view_port);
for(int i = 0; i < 1; i++) {
@@ -285,8 +288,8 @@ static int32_t playlist_worker_thread(void* ctx) {
FlipperFormat* fff_head = flipper_format_file_alloc(storage);
PlaylistWorker* worker = ctx;
- if(!flipper_format_file_open_existing(fff_head, string_get_cstr(worker->file_path))) {
- FURI_LOG_E(TAG, "Failed to open %s", string_get_cstr(worker->file_path));
+ if(!flipper_format_file_open_existing(fff_head, furi_string_get_cstr(worker->file_path))) {
+ FURI_LOG_E(TAG, "Failed to open %s", furi_string_get_cstr(worker->file_path));
worker->is_running = false;
furi_record_close(RECORD_STORAGE);
@@ -297,10 +300,12 @@ static int32_t playlist_worker_thread(void* ctx) {
playlist_worker_wait_pause(worker);
FlipperFormat* fff_data = flipper_format_string_alloc();
- string_t data, preset, protocol;
- string_init(data);
- string_init(preset);
- string_init(protocol);
+ FuriString* data;
+ FuriString* preset;
+ FuriString* protocol;
+ data = furi_string_alloc();
+ preset = furi_string_alloc();
+ protocol = furi_string_alloc();
for(int i = 0; i < MAX(1, worker->meta->playlist_repetitions); i++) {
// infinite repetitions if playlist_repetitions is 0
@@ -330,9 +335,9 @@ static int32_t playlist_worker_thread(void* ctx) {
furi_record_close(RECORD_STORAGE);
flipper_format_free(fff_head);
- string_clear(data);
- string_clear(preset);
- string_clear(protocol);
+ furi_string_free(data);
+ furi_string_free(preset);
+ furi_string_free(protocol);
flipper_format_free(fff_data);
@@ -351,18 +356,18 @@ void playlist_meta_reset(DisplayMeta* instance) {
instance->current_count = 0;
instance->current_playlist_repetition = 0;
- string_reset(instance->prev_0_path);
- string_reset(instance->prev_1_path);
- string_reset(instance->prev_2_path);
- string_reset(instance->prev_3_path);
+ furi_string_reset(instance->prev_0_path);
+ furi_string_reset(instance->prev_1_path);
+ furi_string_reset(instance->prev_2_path);
+ furi_string_reset(instance->prev_3_path);
}
DisplayMeta* playlist_meta_alloc() {
DisplayMeta* instance = malloc(sizeof(DisplayMeta));
- string_init(instance->prev_0_path);
- string_init(instance->prev_1_path);
- string_init(instance->prev_2_path);
- string_init(instance->prev_3_path);
+ instance->prev_0_path = furi_string_alloc();
+ instance->prev_1_path = furi_string_alloc();
+ instance->prev_2_path = furi_string_alloc();
+ instance->prev_3_path = furi_string_alloc();
playlist_meta_reset(instance);
instance->state = STATE_NONE;
instance->playlist_repetitions = 1;
@@ -370,10 +375,10 @@ DisplayMeta* playlist_meta_alloc() {
}
void playlist_meta_free(DisplayMeta* instance) {
- string_clear(instance->prev_0_path);
- string_clear(instance->prev_1_path);
- string_clear(instance->prev_2_path);
- string_clear(instance->prev_3_path);
+ furi_string_free(instance->prev_0_path);
+ furi_string_free(instance->prev_1_path);
+ furi_string_free(instance->prev_2_path);
+ furi_string_free(instance->prev_3_path);
free(instance);
}
@@ -391,7 +396,7 @@ PlaylistWorker* playlist_worker_alloc(DisplayMeta* meta) {
instance->meta = meta;
instance->ctl_pause = true; // require the user to manually start the worker
- string_init(instance->file_path);
+ instance->file_path = furi_string_alloc();
return instance;
}
@@ -399,7 +404,7 @@ PlaylistWorker* playlist_worker_alloc(DisplayMeta* meta) {
void playlist_worker_free(PlaylistWorker* instance) {
furi_assert(instance);
furi_thread_free(instance->thread);
- string_clear(instance->file_path);
+ furi_string_free(instance->file_path);
free(instance);
}
@@ -420,7 +425,7 @@ void playlist_worker_start(PlaylistWorker* instance, const char* file_path) {
furi_assert(instance);
furi_assert(!instance->is_running);
- string_set_str(instance->file_path, file_path);
+ furi_string_set(instance->file_path, file_path);
instance->is_running = true;
// reset meta (current/total)
@@ -440,8 +445,8 @@ static void render_callback(Canvas* canvas, void* ctx) {
canvas_set_color(canvas, ColorBlack);
canvas_set_font(canvas, FontSecondary);
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
switch(app->meta->state) {
case STATE_NONE:
@@ -456,24 +461,26 @@ static void render_callback(Canvas* canvas, void* ctx) {
path_extract_filename(app->file_path, temp_str, true);
canvas_set_font(canvas, FontPrimary);
- draw_centered_boxed_str(canvas, 1, 1, 15, 6, string_get_cstr(temp_str));
+ draw_centered_boxed_str(canvas, 1, 1, 15, 6, furi_string_get_cstr(temp_str));
}
canvas_set_font(canvas, FontSecondary);
// draw loaded count
{
- string_printf(temp_str, "%d Items in playlist", app->meta->total_count);
- canvas_draw_str_aligned(canvas, 1, 19, AlignLeft, AlignTop, string_get_cstr(temp_str));
+ furi_string_printf(temp_str, "%d Items in playlist", app->meta->total_count);
+ canvas_draw_str_aligned(
+ canvas, 1, 19, AlignLeft, AlignTop, furi_string_get_cstr(temp_str));
if(app->meta->playlist_repetitions <= 0) {
- string_printf(temp_str, "Repeat: inf", app->meta->playlist_repetitions);
+ furi_string_set(temp_str, "Repeat: inf");
} else if(app->meta->playlist_repetitions == 1) {
- string_printf(temp_str, "Repeat: no", app->meta->playlist_repetitions);
+ furi_string_set(temp_str, "Repeat: no");
} else {
- string_printf(temp_str, "Repeat: %dx", app->meta->playlist_repetitions);
+ furi_string_printf(temp_str, "Repeat: %dx", app->meta->playlist_repetitions);
}
- canvas_draw_str_aligned(canvas, 1, 29, AlignLeft, AlignTop, string_get_cstr(temp_str));
+ canvas_draw_str_aligned(
+ canvas, 1, 29, AlignLeft, AlignTop, furi_string_get_cstr(temp_str));
}
// draw buttons
@@ -511,11 +518,12 @@ static void render_callback(Canvas* canvas, void* ctx) {
// draw progress text
{
canvas_set_font(canvas, FontSecondary);
- string_printf(temp_str, "[%d/%d]", app->meta->current_count, app->meta->total_count);
+ furi_string_printf(
+ temp_str, "[%d/%d]", app->meta->current_count, app->meta->total_count);
canvas_draw_str_aligned(
- canvas, 11, HEIGHT - 8, AlignLeft, AlignTop, string_get_cstr(temp_str));
+ canvas, 11, HEIGHT - 8, AlignLeft, AlignTop, furi_string_get_cstr(temp_str));
- int h = canvas_string_width(canvas, string_get_cstr(temp_str));
+ int h = canvas_string_width(canvas, furi_string_get_cstr(temp_str));
int xs = 11 + h + 2;
int w = WIDTH - xs - 1;
canvas_draw_box(canvas, xs, HEIGHT - 5, w, 1);
@@ -527,20 +535,20 @@ static void render_callback(Canvas* canvas, void* ctx) {
{
if(app->meta->playlist_repetitions <= 0) {
- string_printf(temp_str, "[%d/Inf]", app->meta->current_playlist_repetition);
+ furi_string_printf(temp_str, "[%d/Inf]", app->meta->current_playlist_repetition);
} else {
- string_printf(
+ furi_string_printf(
temp_str,
"[%d/%d]",
app->meta->current_playlist_repetition,
app->meta->playlist_repetitions);
}
canvas_set_color(canvas, ColorBlack);
- int w = canvas_string_width(canvas, string_get_cstr(temp_str));
+ int w = canvas_string_width(canvas, furi_string_get_cstr(temp_str));
draw_corner_aligned(canvas, w + 6, 13, AlignRight, AlignTop);
canvas_set_color(canvas, ColorWhite);
canvas_draw_str_aligned(
- canvas, WIDTH - 3, 3, AlignRight, AlignTop, string_get_cstr(temp_str));
+ canvas, WIDTH - 3, 3, AlignRight, AlignTop, furi_string_get_cstr(temp_str));
}
// draw last and current file
@@ -549,41 +557,41 @@ static void render_callback(Canvas* canvas, void* ctx) {
canvas_set_font(canvas, FontSecondary);
// current
- if(!string_empty_p(app->meta->prev_0_path)) {
+ if(!furi_string_empty(app->meta->prev_0_path)) {
path_extract_filename(app->meta->prev_0_path, temp_str, true);
- int w = canvas_string_width(canvas, string_get_cstr(temp_str));
+ int w = canvas_string_width(canvas, furi_string_get_cstr(temp_str));
canvas_set_color(canvas, ColorBlack);
canvas_draw_rbox(canvas, 1, 1, w + 4, 12, 2);
canvas_set_color(canvas, ColorWhite);
canvas_draw_str_aligned(
- canvas, 3, 3, AlignLeft, AlignTop, string_get_cstr(temp_str));
+ canvas, 3, 3, AlignLeft, AlignTop, furi_string_get_cstr(temp_str));
}
// last 3
canvas_set_color(canvas, ColorBlack);
- if(!string_empty_p(app->meta->prev_1_path)) {
+ if(!furi_string_empty(app->meta->prev_1_path)) {
path_extract_filename(app->meta->prev_1_path, temp_str, true);
canvas_draw_str_aligned(
- canvas, 3, 15, AlignLeft, AlignTop, string_get_cstr(temp_str));
+ canvas, 3, 15, AlignLeft, AlignTop, furi_string_get_cstr(temp_str));
}
- if(!string_empty_p(app->meta->prev_2_path)) {
+ if(!furi_string_empty(app->meta->prev_2_path)) {
path_extract_filename(app->meta->prev_2_path, temp_str, true);
canvas_draw_str_aligned(
- canvas, 3, 26, AlignLeft, AlignTop, string_get_cstr(temp_str));
+ canvas, 3, 26, AlignLeft, AlignTop, furi_string_get_cstr(temp_str));
}
- if(!string_empty_p(app->meta->prev_3_path)) {
+ if(!furi_string_empty(app->meta->prev_3_path)) {
path_extract_filename(app->meta->prev_3_path, temp_str, true);
canvas_draw_str_aligned(
- canvas, 3, 37, AlignLeft, AlignTop, string_get_cstr(temp_str));
+ canvas, 3, 37, AlignLeft, AlignTop, furi_string_get_cstr(temp_str));
}
}
break;
}
- string_clear(temp_str);
+ furi_string_free(temp_str);
furi_mutex_release(app->mutex);
}
@@ -596,8 +604,8 @@ static void input_callback(InputEvent* event, void* ctx) {
Playlist* playlist_alloc(DisplayMeta* meta) {
Playlist* app = malloc(sizeof(Playlist));
- string_init(app->file_path);
- string_set_str(app->file_path, PLAYLIST_FOLDER);
+ app->file_path = furi_string_alloc();
+ furi_string_set(app->file_path, PLAYLIST_FOLDER);
app->meta = meta;
app->worker = NULL;
@@ -623,15 +631,15 @@ void playlist_start_worker(Playlist* app, DisplayMeta* meta) {
// count playlist items
Storage* storage = furi_record_open(RECORD_STORAGE);
app->meta->total_count =
- playlist_count_playlist_items(storage, string_get_cstr(app->file_path));
+ playlist_count_playlist_items(storage, furi_string_get_cstr(app->file_path));
furi_record_close(RECORD_STORAGE);
// start thread
- playlist_worker_start(app->worker, string_get_cstr(app->file_path));
+ playlist_worker_start(app->worker, furi_string_get_cstr(app->file_path));
}
void playlist_free(Playlist* app) {
- string_clear(app->file_path);
+ furi_string_free(app->file_path);
gui_remove_view_port(app->gui, app->view_port);
furi_record_close(RECORD_GUI);
@@ -715,7 +723,7 @@ int32_t playlist_app(void* p) {
if(!app->worker->is_running) {
app->worker->ctl_pause = false;
app->worker->ctl_request_exit = false;
- playlist_worker_start(app->worker, string_get_cstr(app->file_path));
+ playlist_worker_start(app->worker, furi_string_get_cstr(app->file_path));
} else {
app->worker->ctl_pause = !app->worker->ctl_pause;
}
diff --git a/applications/plugins/playlist/playlist_file.c b/applications/plugins/playlist/playlist_file.c
index 2faf02a3c..e3540648e 100644
--- a/applications/plugins/playlist/playlist_file.c
+++ b/applications/plugins/playlist/playlist_file.c
@@ -9,13 +9,13 @@ int playlist_count_playlist_items(Storage* storage, const char* file_path) {
return -1;
}
int count = 0;
- string_t data;
- string_init(data);
+ FuriString* data;
+ data = furi_string_alloc();
while(flipper_format_read_string(format, "sub", data)) {
++count;
}
flipper_format_file_close(format);
flipper_format_free(format);
- string_clear(data);
+ furi_string_free(data);
return count;
}
diff --git a/applications/plugins/sentry_safe/application.fam b/applications/plugins/sentry_safe/application.fam
index f409e0b06..070a677ba 100644
--- a/applications/plugins/sentry_safe/application.fam
+++ b/applications/plugins/sentry_safe/application.fam
@@ -1,5 +1,5 @@
App(
- appid="sentry_safe",
+ appid="GPIO_Sentry_Safe",
name="[GPIO] Sentry Safe",
apptype=FlipperAppType.EXTERNAL,
entry_point="sentry_safe_app",
diff --git a/applications/plugins/signal_generator/application.fam b/applications/plugins/signal_generator/application.fam
new file mode 100644
index 000000000..c2bb097a4
--- /dev/null
+++ b/applications/plugins/signal_generator/application.fam
@@ -0,0 +1,12 @@
+App(
+ appid="Signal_Generator",
+ name="Signal Generator",
+ apptype=FlipperAppType.PLUGIN,
+ entry_point="signal_gen_app",
+ cdefines=["APP_SIGNAL_GEN"],
+ requires=["gui"],
+ stack_size=1 * 1024,
+ order=50,
+ fap_icon="signal_gen_10px.png",
+ fap_category="Tools",
+)
diff --git a/applications/plugins/signal_generator/scenes/signal_gen_scene.c b/applications/plugins/signal_generator/scenes/signal_gen_scene.c
new file mode 100644
index 000000000..29b11ee3f
--- /dev/null
+++ b/applications/plugins/signal_generator/scenes/signal_gen_scene.c
@@ -0,0 +1,30 @@
+#include "../signal_gen_app_i.h"
+
+// Generate scene on_enter handlers array
+#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
+void (*const signal_gen_scene_on_enter_handlers[])(void*) = {
+#include "signal_gen_scene_config.h"
+};
+#undef ADD_SCENE
+
+// Generate scene on_event handlers array
+#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event,
+bool (*const signal_gen_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = {
+#include "signal_gen_scene_config.h"
+};
+#undef ADD_SCENE
+
+// Generate scene on_exit handlers array
+#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit,
+void (*const signal_gen_scene_on_exit_handlers[])(void* context) = {
+#include "signal_gen_scene_config.h"
+};
+#undef ADD_SCENE
+
+// Initialize scene handlers configuration structure
+const SceneManagerHandlers signal_gen_scene_handlers = {
+ .on_enter_handlers = signal_gen_scene_on_enter_handlers,
+ .on_event_handlers = signal_gen_scene_on_event_handlers,
+ .on_exit_handlers = signal_gen_scene_on_exit_handlers,
+ .scene_num = SignalGenSceneNum,
+};
diff --git a/applications/plugins/signal_generator/scenes/signal_gen_scene.h b/applications/plugins/signal_generator/scenes/signal_gen_scene.h
new file mode 100644
index 000000000..c139afa3b
--- /dev/null
+++ b/applications/plugins/signal_generator/scenes/signal_gen_scene.h
@@ -0,0 +1,29 @@
+#pragma once
+
+#include
+
+// Generate scene id and total number
+#define ADD_SCENE(prefix, name, id) SignalGenScene##id,
+typedef enum {
+#include "signal_gen_scene_config.h"
+ SignalGenSceneNum,
+} SignalGenScene;
+#undef ADD_SCENE
+
+extern const SceneManagerHandlers signal_gen_scene_handlers;
+
+// Generate scene on_enter handlers declaration
+#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
+#include "signal_gen_scene_config.h"
+#undef ADD_SCENE
+
+// Generate scene on_event handlers declaration
+#define ADD_SCENE(prefix, name, id) \
+ bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event);
+#include "signal_gen_scene_config.h"
+#undef ADD_SCENE
+
+// Generate scene on_exit handlers declaration
+#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context);
+#include "signal_gen_scene_config.h"
+#undef ADD_SCENE
diff --git a/applications/plugins/signal_generator/scenes/signal_gen_scene_config.h b/applications/plugins/signal_generator/scenes/signal_gen_scene_config.h
new file mode 100644
index 000000000..b6c750256
--- /dev/null
+++ b/applications/plugins/signal_generator/scenes/signal_gen_scene_config.h
@@ -0,0 +1,3 @@
+ADD_SCENE(signal_gen, start, Start)
+ADD_SCENE(signal_gen, pwm, Pwm)
+ADD_SCENE(signal_gen, mco, Mco)
diff --git a/applications/plugins/signal_generator/scenes/signal_gen_scene_mco.c b/applications/plugins/signal_generator/scenes/signal_gen_scene_mco.c
new file mode 100644
index 000000000..0855cde0a
--- /dev/null
+++ b/applications/plugins/signal_generator/scenes/signal_gen_scene_mco.c
@@ -0,0 +1,145 @@
+#include "../signal_gen_app_i.h"
+
+typedef enum {
+ LineIndexPin,
+ LineIndexSource,
+ LineIndexDivision,
+} LineIndex;
+
+static const char* const mco_pin_names[] = {
+ "13(Tx)",
+};
+
+static const char* const mco_source_names[] = {
+ "32768Hz",
+ "64MHz",
+ "~100K",
+ "~200K",
+ "~400K",
+ "~800K",
+ "~1MHz",
+ "~2MHz",
+ "~4MHz",
+ "~8MHz",
+ "~16MHz",
+ "~24MHz",
+ "~32MHz",
+ "~48MHz",
+};
+
+static const FuriHalClockMcoSourceId mco_sources[] = {
+ FuriHalClockMcoLse,
+ FuriHalClockMcoSysclk,
+ FuriHalClockMcoMsi100k,
+ FuriHalClockMcoMsi200k,
+ FuriHalClockMcoMsi400k,
+ FuriHalClockMcoMsi800k,
+ FuriHalClockMcoMsi1m,
+ FuriHalClockMcoMsi2m,
+ FuriHalClockMcoMsi4m,
+ FuriHalClockMcoMsi8m,
+ FuriHalClockMcoMsi16m,
+ FuriHalClockMcoMsi24m,
+ FuriHalClockMcoMsi32m,
+ FuriHalClockMcoMsi48m,
+};
+
+static const char* const mco_divisor_names[] = {
+ "1",
+ "2",
+ "4",
+ "8",
+ "16",
+};
+
+static const FuriHalClockMcoDivisorId mco_divisors[] = {
+ FuriHalClockMcoDiv1,
+ FuriHalClockMcoDiv2,
+ FuriHalClockMcoDiv4,
+ FuriHalClockMcoDiv8,
+ FuriHalClockMcoDiv16,
+};
+
+static void mco_source_list_change_callback(VariableItem* item) {
+ SignalGenApp* app = variable_item_get_context(item);
+ uint8_t index = variable_item_get_current_value_index(item);
+ variable_item_set_current_value_text(item, mco_source_names[index]);
+
+ app->mco_src = mco_sources[index];
+
+ view_dispatcher_send_custom_event(app->view_dispatcher, SignalGenMcoEventUpdate);
+}
+
+static void mco_divisor_list_change_callback(VariableItem* item) {
+ SignalGenApp* app = variable_item_get_context(item);
+ uint8_t index = variable_item_get_current_value_index(item);
+ variable_item_set_current_value_text(item, mco_divisor_names[index]);
+
+ app->mco_div = mco_divisors[index];
+
+ view_dispatcher_send_custom_event(app->view_dispatcher, SignalGenMcoEventUpdate);
+}
+
+void signal_gen_scene_mco_on_enter(void* context) {
+ SignalGenApp* app = context;
+ VariableItemList* var_item_list = app->var_item_list;
+
+ VariableItem* item;
+
+ item = variable_item_list_add(var_item_list, "GPIO Pin", COUNT_OF(mco_pin_names), NULL, NULL);
+ variable_item_set_current_value_index(item, 0);
+ variable_item_set_current_value_text(item, mco_pin_names[0]);
+
+ item = variable_item_list_add(
+ var_item_list,
+ "Frequency",
+ COUNT_OF(mco_source_names),
+ mco_source_list_change_callback,
+ app);
+ variable_item_set_current_value_index(item, 0);
+ variable_item_set_current_value_text(item, mco_source_names[0]);
+
+ item = variable_item_list_add(
+ var_item_list,
+ "Freq. divider",
+ COUNT_OF(mco_divisor_names),
+ mco_divisor_list_change_callback,
+ app);
+ variable_item_set_current_value_index(item, 0);
+ variable_item_set_current_value_text(item, mco_divisor_names[0]);
+
+ variable_item_list_set_selected_item(var_item_list, LineIndexSource);
+
+ view_dispatcher_switch_to_view(app->view_dispatcher, SignalGenViewVarItemList);
+
+ app->mco_src = FuriHalClockMcoLse;
+ app->mco_div = FuriHalClockMcoDiv1;
+ furi_hal_clock_mco_enable(app->mco_src, app->mco_div);
+ furi_hal_gpio_init_ex(
+ &gpio_usart_tx, GpioModeAltFunctionPushPull, GpioPullUp, GpioSpeedVeryHigh, GpioAltFn0MCO);
+}
+
+bool signal_gen_scene_mco_on_event(void* context, SceneManagerEvent event) {
+ SignalGenApp* app = context;
+ bool consumed = false;
+
+ if(event.type == SceneManagerEventTypeCustom) {
+ if(event.event == SignalGenMcoEventUpdate) {
+ consumed = true;
+ furi_hal_clock_mco_enable(app->mco_src, app->mco_div);
+ }
+ }
+ return consumed;
+}
+
+void signal_gen_scene_mco_on_exit(void* context) {
+ SignalGenApp* app = context;
+ variable_item_list_reset(app->var_item_list);
+ furi_hal_gpio_init_ex(
+ &gpio_usart_tx,
+ GpioModeAltFunctionPushPull,
+ GpioPullUp,
+ GpioSpeedVeryHigh,
+ GpioAltFn7USART1);
+ furi_hal_clock_mco_disable();
+}
diff --git a/applications/plugins/signal_generator/scenes/signal_gen_scene_pwm.c b/applications/plugins/signal_generator/scenes/signal_gen_scene_pwm.c
new file mode 100644
index 000000000..f302c0232
--- /dev/null
+++ b/applications/plugins/signal_generator/scenes/signal_gen_scene_pwm.c
@@ -0,0 +1,60 @@
+#include "../signal_gen_app_i.h"
+
+static const FuriHalPwmOutputId pwm_ch_id[] = {
+ FuriHalPwmOutputIdTim1PA7,
+ FuriHalPwmOutputIdLptim2PA4,
+};
+
+#define DEFAULT_FREQ 1000
+#define DEFAULT_DUTY 50
+
+static void
+ signal_gen_pwm_callback(uint8_t channel_id, uint32_t freq, uint8_t duty, void* context) {
+ SignalGenApp* app = context;
+
+ app->pwm_freq = freq;
+ app->pwm_duty = duty;
+
+ if(app->pwm_ch != pwm_ch_id[channel_id]) {
+ app->pwm_ch_prev = app->pwm_ch;
+ app->pwm_ch = pwm_ch_id[channel_id];
+ view_dispatcher_send_custom_event(app->view_dispatcher, SignalGenPwmEventChannelChange);
+ } else {
+ app->pwm_ch = pwm_ch_id[channel_id];
+ view_dispatcher_send_custom_event(app->view_dispatcher, SignalGenPwmEventUpdate);
+ }
+}
+
+void signal_gen_scene_pwm_on_enter(void* context) {
+ SignalGenApp* app = context;
+
+ view_dispatcher_switch_to_view(app->view_dispatcher, SignalGenViewPwm);
+
+ signal_gen_pwm_set_callback(app->pwm_view, signal_gen_pwm_callback, app);
+
+ signal_gen_pwm_set_params(app->pwm_view, 0, DEFAULT_FREQ, DEFAULT_DUTY);
+ furi_hal_pwm_start(pwm_ch_id[0], DEFAULT_FREQ, DEFAULT_DUTY);
+}
+
+bool signal_gen_scene_pwm_on_event(void* context, SceneManagerEvent event) {
+ SignalGenApp* app = context;
+ bool consumed = false;
+
+ if(event.type == SceneManagerEventTypeCustom) {
+ if(event.event == SignalGenPwmEventUpdate) {
+ consumed = true;
+ furi_hal_pwm_set_params(app->pwm_ch, app->pwm_freq, app->pwm_duty);
+ } else if(event.event == SignalGenPwmEventChannelChange) {
+ consumed = true;
+ furi_hal_pwm_stop(app->pwm_ch_prev);
+ furi_hal_pwm_start(app->pwm_ch, app->pwm_freq, app->pwm_duty);
+ }
+ }
+ return consumed;
+}
+
+void signal_gen_scene_pwm_on_exit(void* context) {
+ SignalGenApp* app = context;
+ variable_item_list_reset(app->var_item_list);
+ furi_hal_pwm_stop(app->pwm_ch);
+}
diff --git a/applications/plugins/signal_generator/scenes/signal_gen_scene_start.c b/applications/plugins/signal_generator/scenes/signal_gen_scene_start.c
new file mode 100644
index 000000000..3c7b9cc32
--- /dev/null
+++ b/applications/plugins/signal_generator/scenes/signal_gen_scene_start.c
@@ -0,0 +1,55 @@
+#include "../signal_gen_app_i.h"
+
+typedef enum {
+ SubmenuIndexPwm,
+ SubmenuIndexClockOutput,
+} SubmenuIndex;
+
+void signal_gen_scene_start_submenu_callback(void* context, uint32_t index) {
+ SignalGenApp* app = context;
+
+ view_dispatcher_send_custom_event(app->view_dispatcher, index);
+}
+
+void signal_gen_scene_start_on_enter(void* context) {
+ SignalGenApp* app = context;
+ Submenu* submenu = app->submenu;
+
+ submenu_add_item(
+ submenu, "PWM Generator", SubmenuIndexPwm, signal_gen_scene_start_submenu_callback, app);
+ submenu_add_item(
+ submenu,
+ "Clock Generator",
+ SubmenuIndexClockOutput,
+ signal_gen_scene_start_submenu_callback,
+ app);
+
+ submenu_set_selected_item(
+ submenu, scene_manager_get_scene_state(app->scene_manager, SignalGenSceneStart));
+
+ view_dispatcher_switch_to_view(app->view_dispatcher, SignalGenViewSubmenu);
+}
+
+bool signal_gen_scene_start_on_event(void* context, SceneManagerEvent event) {
+ SignalGenApp* app = context;
+ bool consumed = false;
+
+ if(event.type == SceneManagerEventTypeCustom) {
+ if(event.event == SubmenuIndexPwm) {
+ scene_manager_next_scene(app->scene_manager, SignalGenScenePwm);
+ consumed = true;
+ } else if(event.event == SubmenuIndexClockOutput) {
+ scene_manager_next_scene(app->scene_manager, SignalGenSceneMco);
+ consumed = true;
+ }
+ scene_manager_set_scene_state(app->scene_manager, SignalGenSceneStart, event.event);
+ }
+
+ return consumed;
+}
+
+void signal_gen_scene_start_on_exit(void* context) {
+ SignalGenApp* app = context;
+
+ submenu_reset(app->submenu);
+}
diff --git a/applications/plugins/signal_generator/signal_gen_10px.png b/applications/plugins/signal_generator/signal_gen_10px.png
new file mode 100644
index 000000000..9f6dcc5d0
Binary files /dev/null and b/applications/plugins/signal_generator/signal_gen_10px.png differ
diff --git a/applications/plugins/signal_generator/signal_gen_app.c b/applications/plugins/signal_generator/signal_gen_app.c
new file mode 100644
index 000000000..ca065d330
--- /dev/null
+++ b/applications/plugins/signal_generator/signal_gen_app.c
@@ -0,0 +1,93 @@
+#include "signal_gen_app_i.h"
+
+#include
+#include
+
+static bool signal_gen_app_custom_event_callback(void* context, uint32_t event) {
+ furi_assert(context);
+ SignalGenApp* app = context;
+ return scene_manager_handle_custom_event(app->scene_manager, event);
+}
+
+static bool signal_gen_app_back_event_callback(void* context) {
+ furi_assert(context);
+ SignalGenApp* app = context;
+ return scene_manager_handle_back_event(app->scene_manager);
+}
+
+static void signal_gen_app_tick_event_callback(void* context) {
+ furi_assert(context);
+ SignalGenApp* app = context;
+ scene_manager_handle_tick_event(app->scene_manager);
+}
+
+SignalGenApp* signal_gen_app_alloc() {
+ SignalGenApp* app = malloc(sizeof(SignalGenApp));
+
+ app->gui = furi_record_open(RECORD_GUI);
+
+ app->view_dispatcher = view_dispatcher_alloc();
+ app->scene_manager = scene_manager_alloc(&signal_gen_scene_handlers, app);
+ view_dispatcher_enable_queue(app->view_dispatcher);
+ view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
+
+ view_dispatcher_set_custom_event_callback(
+ app->view_dispatcher, signal_gen_app_custom_event_callback);
+ view_dispatcher_set_navigation_event_callback(
+ app->view_dispatcher, signal_gen_app_back_event_callback);
+ view_dispatcher_set_tick_event_callback(
+ app->view_dispatcher, signal_gen_app_tick_event_callback, 100);
+
+ view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
+
+ app->var_item_list = variable_item_list_alloc();
+ view_dispatcher_add_view(
+ app->view_dispatcher,
+ SignalGenViewVarItemList,
+ variable_item_list_get_view(app->var_item_list));
+
+ app->submenu = submenu_alloc();
+ view_dispatcher_add_view(
+ app->view_dispatcher, SignalGenViewSubmenu, submenu_get_view(app->submenu));
+
+ app->pwm_view = signal_gen_pwm_alloc();
+ view_dispatcher_add_view(
+ app->view_dispatcher, SignalGenViewPwm, signal_gen_pwm_get_view(app->pwm_view));
+
+ scene_manager_next_scene(app->scene_manager, SignalGenSceneStart);
+
+ return app;
+}
+
+void signal_gen_app_free(SignalGenApp* app) {
+ furi_assert(app);
+
+ // Views
+ view_dispatcher_remove_view(app->view_dispatcher, SignalGenViewVarItemList);
+ view_dispatcher_remove_view(app->view_dispatcher, SignalGenViewSubmenu);
+ view_dispatcher_remove_view(app->view_dispatcher, SignalGenViewPwm);
+
+ submenu_free(app->submenu);
+ variable_item_list_free(app->var_item_list);
+ signal_gen_pwm_free(app->pwm_view);
+
+ // View dispatcher
+ view_dispatcher_free(app->view_dispatcher);
+ scene_manager_free(app->scene_manager);
+
+ // Close records
+ furi_record_close(RECORD_GUI);
+
+ free(app);
+}
+
+int32_t signal_gen_app(void* p) {
+ UNUSED(p);
+ SignalGenApp* signal_gen_app = signal_gen_app_alloc();
+
+ view_dispatcher_run(signal_gen_app->view_dispatcher);
+
+ signal_gen_app_free(signal_gen_app);
+
+ return 0;
+}
diff --git a/applications/plugins/signal_generator/signal_gen_app_i.h b/applications/plugins/signal_generator/signal_gen_app_i.h
new file mode 100644
index 000000000..47c266475
--- /dev/null
+++ b/applications/plugins/signal_generator/signal_gen_app_i.h
@@ -0,0 +1,46 @@
+#pragma once
+
+#include "scenes/signal_gen_scene.h"
+
+#include "furi_hal_clock.h"
+#include "furi_hal_pwm.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include "views/signal_gen_pwm.h"
+
+typedef struct SignalGenApp SignalGenApp;
+
+struct SignalGenApp {
+ Gui* gui;
+ ViewDispatcher* view_dispatcher;
+ SceneManager* scene_manager;
+
+ VariableItemList* var_item_list;
+ Submenu* submenu;
+ SignalGenPwm* pwm_view;
+
+ FuriHalClockMcoSourceId mco_src;
+ FuriHalClockMcoDivisorId mco_div;
+
+ FuriHalPwmOutputId pwm_ch_prev;
+ FuriHalPwmOutputId pwm_ch;
+ uint32_t pwm_freq;
+ uint8_t pwm_duty;
+};
+
+typedef enum {
+ SignalGenViewVarItemList,
+ SignalGenViewSubmenu,
+ SignalGenViewPwm,
+} SignalGenAppView;
+
+typedef enum {
+ SignalGenMcoEventUpdate,
+ SignalGenPwmEventUpdate,
+ SignalGenPwmEventChannelChange,
+} SignalGenCustomEvent;
diff --git a/applications/plugins/signal_generator/views/signal_gen_pwm.c b/applications/plugins/signal_generator/views/signal_gen_pwm.c
new file mode 100644
index 000000000..4afed01a6
--- /dev/null
+++ b/applications/plugins/signal_generator/views/signal_gen_pwm.c
@@ -0,0 +1,301 @@
+#include "../signal_gen_app_i.h"
+#include "furi_hal.h"
+#include
+
+typedef enum {
+ LineIndexChannel,
+ LineIndexFrequency,
+ LineIndexDuty,
+ LineIndexTotalCount
+} LineIndex;
+
+static const char* const pwm_ch_names[] = {"2(A7)", "4(A4)"};
+
+struct SignalGenPwm {
+ View* view;
+ SignalGenPwmViewCallback callback;
+ void* context;
+};
+
+typedef struct {
+ LineIndex line_sel;
+ bool edit_mode;
+ uint8_t edit_digit;
+
+ uint8_t channel_id;
+ uint32_t freq;
+ uint8_t duty;
+
+} SignalGenPwmViewModel;
+
+#define ITEM_H 64 / 3
+#define ITEM_W 128
+
+#define VALUE_X 100
+#define VALUE_W 45
+
+#define FREQ_VALUE_X 62
+#define FREQ_MAX 1000000UL
+#define FREQ_DIGITS_NB 7
+
+static void pwm_set_config(SignalGenPwm* pwm) {
+ FuriHalPwmOutputId channel;
+ uint32_t freq;
+ uint8_t duty;
+
+ with_view_model(
+ pwm->view, (SignalGenPwmViewModel * model) {
+ channel = model->channel_id;
+ freq = model->freq;
+ duty = model->duty;
+ return false;
+ });
+
+ furi_assert(pwm->callback);
+ pwm->callback(channel, freq, duty, pwm->context);
+}
+
+static void pwm_channel_change(SignalGenPwmViewModel* model, InputEvent* event) {
+ if(event->key == InputKeyLeft) {
+ if(model->channel_id > 0) {
+ model->channel_id--;
+ }
+ } else if(event->key == InputKeyRight) {
+ if(model->channel_id < (COUNT_OF(pwm_ch_names) - 1)) {
+ model->channel_id++;
+ }
+ }
+}
+
+static void pwm_duty_change(SignalGenPwmViewModel* model, InputEvent* event) {
+ if(event->key == InputKeyLeft) {
+ if(model->duty > 0) {
+ model->duty--;
+ }
+ } else if(event->key == InputKeyRight) {
+ if(model->duty < 100) {
+ model->duty++;
+ }
+ }
+}
+
+static bool pwm_freq_edit(SignalGenPwmViewModel* model, InputEvent* event) {
+ bool consumed = false;
+ if((event->type == InputTypeShort) || (event->type == InputTypeRepeat)) {
+ if(event->key == InputKeyRight) {
+ if(model->edit_digit > 0) {
+ model->edit_digit--;
+ }
+ consumed = true;
+ } else if(event->key == InputKeyLeft) {
+ if(model->edit_digit < (FREQ_DIGITS_NB - 1)) {
+ model->edit_digit++;
+ }
+ consumed = true;
+ } else if(event->key == InputKeyUp) {
+ uint32_t step = 1;
+ for(uint8_t i = 0; i < model->edit_digit; i++) {
+ step *= 10;
+ }
+ if((model->freq + step) < FREQ_MAX) {
+ model->freq += step;
+ } else {
+ model->freq = FREQ_MAX;
+ }
+ consumed = true;
+ } else if(event->key == InputKeyDown) {
+ uint32_t step = 1;
+ for(uint8_t i = 0; i < model->edit_digit; i++) {
+ step *= 10;
+ }
+ if(model->freq > (step + 1)) {
+ model->freq -= step;
+ } else {
+ model->freq = 1;
+ }
+ consumed = true;
+ }
+ }
+ return consumed;
+}
+
+static void signal_gen_pwm_draw_callback(Canvas* canvas, void* _model) {
+ SignalGenPwmViewModel* model = _model;
+ char* line_label = NULL;
+ char val_text[16];
+
+ for(uint8_t line = 0; line < LineIndexTotalCount; line++) {
+ if(line == LineIndexChannel) {
+ line_label = "GPIO Pin";
+ } else if(line == LineIndexFrequency) {
+ line_label = "Frequency";
+ } else if(line == LineIndexDuty) {
+ line_label = "Pulse width";
+ }
+
+ canvas_set_color(canvas, ColorBlack);
+ if(line == model->line_sel) {
+ elements_slightly_rounded_box(canvas, 0, ITEM_H * line + 1, ITEM_W, ITEM_H - 1);
+ canvas_set_color(canvas, ColorWhite);
+ }
+
+ uint8_t text_y = ITEM_H * line + ITEM_H / 2 + 2;
+
+ canvas_draw_str_aligned(canvas, 6, text_y, AlignLeft, AlignCenter, line_label);
+
+ if(line == LineIndexChannel) {
+ snprintf(val_text, sizeof(val_text), "%s", pwm_ch_names[model->channel_id]);
+ canvas_draw_str_aligned(canvas, VALUE_X, text_y, AlignCenter, AlignCenter, val_text);
+ if(model->channel_id != 0) {
+ canvas_draw_str_aligned(
+ canvas, VALUE_X - VALUE_W / 2, text_y, AlignCenter, AlignCenter, "<");
+ }
+ if(model->channel_id != (COUNT_OF(pwm_ch_names) - 1)) {
+ canvas_draw_str_aligned(
+ canvas, VALUE_X + VALUE_W / 2, text_y, AlignCenter, AlignCenter, ">");
+ }
+ } else if(line == LineIndexFrequency) {
+ snprintf(val_text, sizeof(val_text), "%7lu Hz", model->freq);
+ canvas_set_font(canvas, FontKeyboard);
+ canvas_draw_str_aligned(
+ canvas, FREQ_VALUE_X, text_y, AlignLeft, AlignCenter, val_text);
+ canvas_set_font(canvas, FontSecondary);
+
+ if(model->edit_mode) {
+ uint8_t icon_x = (FREQ_VALUE_X) + (FREQ_DIGITS_NB - model->edit_digit - 1) * 6;
+ canvas_draw_icon(canvas, icon_x, text_y - 9, &I_SmallArrowUp_3x5);
+ canvas_draw_icon(canvas, icon_x, text_y + 5, &I_SmallArrowDown_3x5);
+ }
+ } else if(line == LineIndexDuty) {
+ snprintf(val_text, sizeof(val_text), "%d%%", model->duty);
+ canvas_draw_str_aligned(canvas, VALUE_X, text_y, AlignCenter, AlignCenter, val_text);
+ if(model->duty != 0) {
+ canvas_draw_str_aligned(
+ canvas, VALUE_X - VALUE_W / 2, text_y, AlignCenter, AlignCenter, "<");
+ }
+ if(model->duty != 100) {
+ canvas_draw_str_aligned(
+ canvas, VALUE_X + VALUE_W / 2, text_y, AlignCenter, AlignCenter, ">");
+ }
+ }
+ }
+}
+
+static bool signal_gen_pwm_input_callback(InputEvent* event, void* context) {
+ furi_assert(context);
+ SignalGenPwm* pwm = context;
+ bool consumed = false;
+ bool need_update = false;
+
+ with_view_model(
+ pwm->view, (SignalGenPwmViewModel * model) {
+ if(model->edit_mode == false) {
+ if((event->type == InputTypeShort) || (event->type == InputTypeRepeat)) {
+ if(event->key == InputKeyUp) {
+ if(model->line_sel == 0) {
+ model->line_sel = LineIndexTotalCount - 1;
+ } else {
+ model->line_sel =
+ CLAMP(model->line_sel - 1, LineIndexTotalCount - 1, 0);
+ }
+ consumed = true;
+ } else if(event->key == InputKeyDown) {
+ if(model->line_sel == LineIndexTotalCount - 1) {
+ model->line_sel = 0;
+ } else {
+ model->line_sel =
+ CLAMP(model->line_sel + 1, LineIndexTotalCount - 1, 0);
+ }
+ consumed = true;
+ } else if((event->key == InputKeyLeft) || (event->key == InputKeyRight)) {
+ if(model->line_sel == LineIndexChannel) {
+ pwm_channel_change(model, event);
+ need_update = true;
+ } else if(model->line_sel == LineIndexDuty) {
+ pwm_duty_change(model, event);
+ need_update = true;
+ } else if(model->line_sel == LineIndexFrequency) {
+ model->edit_mode = true;
+ }
+ consumed = true;
+ } else if(event->key == InputKeyOk) {
+ if(model->line_sel == LineIndexFrequency) {
+ model->edit_mode = true;
+ }
+ consumed = true;
+ }
+ }
+ } else {
+ if((event->key == InputKeyOk) || (event->key == InputKeyBack)) {
+ if(event->type == InputTypeShort) {
+ model->edit_mode = false;
+ consumed = true;
+ }
+ } else {
+ if(model->line_sel == LineIndexFrequency) {
+ consumed = pwm_freq_edit(model, event);
+ need_update = consumed;
+ }
+ }
+ }
+ return true;
+ });
+
+ if(need_update) {
+ pwm_set_config(pwm);
+ }
+
+ return consumed;
+}
+
+SignalGenPwm* signal_gen_pwm_alloc() {
+ SignalGenPwm* pwm = malloc(sizeof(SignalGenPwm));
+
+ pwm->view = view_alloc();
+ view_allocate_model(pwm->view, ViewModelTypeLocking, sizeof(SignalGenPwmViewModel));
+ view_set_context(pwm->view, pwm);
+ view_set_draw_callback(pwm->view, signal_gen_pwm_draw_callback);
+ view_set_input_callback(pwm->view, signal_gen_pwm_input_callback);
+
+ return pwm;
+}
+
+void signal_gen_pwm_free(SignalGenPwm* pwm) {
+ furi_assert(pwm);
+ view_free(pwm->view);
+ free(pwm);
+}
+
+View* signal_gen_pwm_get_view(SignalGenPwm* pwm) {
+ furi_assert(pwm);
+ return pwm->view;
+}
+
+void signal_gen_pwm_set_callback(
+ SignalGenPwm* pwm,
+ SignalGenPwmViewCallback callback,
+ void* context) {
+ furi_assert(pwm);
+ furi_assert(callback);
+
+ with_view_model(
+ pwm->view, (SignalGenPwmViewModel * model) {
+ UNUSED(model);
+ pwm->callback = callback;
+ pwm->context = context;
+ return false;
+ });
+}
+
+void signal_gen_pwm_set_params(SignalGenPwm* pwm, uint8_t channel_id, uint32_t freq, uint8_t duty) {
+ with_view_model(
+ pwm->view, (SignalGenPwmViewModel * model) {
+ model->channel_id = channel_id;
+ model->freq = freq;
+ model->duty = duty;
+ return true;
+ });
+
+ furi_assert(pwm->callback);
+ pwm->callback(channel_id, freq, duty, pwm->context);
+}
diff --git a/applications/plugins/signal_generator/views/signal_gen_pwm.h b/applications/plugins/signal_generator/views/signal_gen_pwm.h
new file mode 100644
index 000000000..986794e7a
--- /dev/null
+++ b/applications/plugins/signal_generator/views/signal_gen_pwm.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include
+#include "../signal_gen_app_i.h"
+
+typedef struct SignalGenPwm SignalGenPwm;
+typedef void (
+ *SignalGenPwmViewCallback)(uint8_t channel_id, uint32_t freq, uint8_t duty, void* context);
+
+SignalGenPwm* signal_gen_pwm_alloc();
+
+void signal_gen_pwm_free(SignalGenPwm* pwm);
+
+View* signal_gen_pwm_get_view(SignalGenPwm* pwm);
+
+void signal_gen_pwm_set_callback(
+ SignalGenPwm* pwm,
+ SignalGenPwmViewCallback callback,
+ void* context);
+
+void signal_gen_pwm_set_params(SignalGenPwm* pwm, uint8_t channel_id, uint32_t freq, uint8_t duty);
diff --git a/applications/plugins/snake_game/application.fam b/applications/plugins/snake_game/application.fam
index d55f53bb1..abf4f72c5 100644
--- a/applications/plugins/snake_game/application.fam
+++ b/applications/plugins/snake_game/application.fam
@@ -1,5 +1,5 @@
App(
- appid="snake_game",
+ appid="Snake",
name="Snake Game",
apptype=FlipperAppType.PLUGIN,
entry_point="snake_game_app",
diff --git a/applications/plugins/snake_game/snake_game.c b/applications/plugins/snake_game/snake_game.c
index 2aad952f0..74ce8d389 100644
--- a/applications/plugins/snake_game/snake_game.c
+++ b/applications/plugins/snake_game/snake_game.c
@@ -61,12 +61,32 @@ typedef struct {
InputEvent input;
} SnakeEvent;
-static const NotificationSequence sequence_short_vibro_and_sound = {
+const NotificationSequence sequence_fail = {
&message_vibro_on,
- &message_note_c5,
+
+ &message_note_ds4,
+ &message_delay_10,
+ &message_sound_off,
+ &message_delay_10,
+
+ &message_note_ds4,
+ &message_delay_10,
+ &message_sound_off,
+ &message_delay_10,
+
+ &message_note_ds4,
+ &message_delay_10,
+ &message_sound_off,
+ &message_delay_10,
+
+ &message_vibro_off,
+ NULL,
+};
+
+const NotificationSequence sequence_eat = {
+ &message_note_c7,
&message_delay_50,
&message_sound_off,
- &message_vibro_off,
NULL,
};
@@ -95,12 +115,6 @@ static void snake_game_render_callback(Canvas* const canvas, void* ctx) {
canvas_draw_box(canvas, p.x, p.y, 4, 4);
}
- // Show score on the game field
- if(snake_state->state != GameStateGameOver) {
- char buffer2[6];
- snprintf(buffer2, sizeof(buffer2), "%u", snake_state->len - 7);
- canvas_draw_str_aligned(canvas, 124, 10, AlignRight, AlignBottom, buffer2);
- }
// Game Over banner
if(snake_state->state == GameStateGameOver) {
// Screen is 128x64 px
@@ -247,7 +261,8 @@ static void snake_game_move_snake(SnakeState* const snake_state, Point const nex
snake_state->points[0] = next_step;
}
-static void snake_game_process_game_step(SnakeState* const snake_state, NotificationApp* notify) {
+static void
+ snake_game_process_game_step(SnakeState* const snake_state, NotificationApp* notification) {
if(snake_state->state == GameStateGameOver) {
return;
}
@@ -266,6 +281,7 @@ static void snake_game_process_game_step(SnakeState* const snake_state, Notifica
return;
} else if(snake_state->state == GameStateLastChance) {
snake_state->state = GameStateGameOver;
+ notification_message_block(notification, &sequence_fail);
return;
}
} else {
@@ -277,17 +293,16 @@ static void snake_game_process_game_step(SnakeState* const snake_state, Notifica
crush = snake_game_collision_with_tail(snake_state, next_step);
if(crush) {
snake_state->state = GameStateGameOver;
+ notification_message_block(notification, &sequence_fail);
return;
}
bool eatFruit = (next_step.x == snake_state->fruit.x) && (next_step.y == snake_state->fruit.y);
if(eatFruit) {
- notification_message(notify, &sequence_short_vibro_and_sound);
- //notification_message(notify, &sequence_blink_white_100);
-
snake_state->len++;
if(snake_state->len >= MAX_SNAKE_LEN) {
snake_state->state = GameStateGameOver;
+ notification_message_block(notification, &sequence_fail);
return;
}
}
@@ -296,6 +311,7 @@ static void snake_game_process_game_step(SnakeState* const snake_state, Notifica
if(eatFruit) {
snake_state->fruit = snake_game_get_new_fruit(snake_state);
+ notification_message(notification, &sequence_eat);
}
}
@@ -327,9 +343,10 @@ int32_t snake_game_app(void* p) {
// Open GUI and register view_port
Gui* gui = furi_record_open(RECORD_GUI);
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
-
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
+ notification_message_block(notification, &sequence_display_backlight_enforce_on);
+
SnakeEvent event;
for(bool processing = true; processing;) {
FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100);
@@ -374,6 +391,9 @@ int32_t snake_game_app(void* p) {
release_mutex(&state_mutex, snake_state);
}
+ // Wait for all notifications to be played and return backlight to normal state
+ notification_message_block(notification, &sequence_display_backlight_enforce_auto);
+
furi_timer_free(timer);
view_port_enabled_set(view_port, false);
gui_remove_view_port(gui, view_port);
diff --git a/applications/plugins/spectrum_analyzer/application.fam b/applications/plugins/spectrum_analyzer/application.fam
index 5028c999b..04bb946ee 100644
--- a/applications/plugins/spectrum_analyzer/application.fam
+++ b/applications/plugins/spectrum_analyzer/application.fam
@@ -1,5 +1,5 @@
App(
- appid="spectrum_analyzer",
+ appid="Spectrum_Analyzer",
name="Spectrum Analyzer",
apptype=FlipperAppType.EXTERNAL,
entry_point="spectrum_analyzer_app",
diff --git a/applications/plugins/spectrum_analyzer/spectrum_analyzer.c b/applications/plugins/spectrum_analyzer/spectrum_analyzer.c
index 5bc563451..d94739bc1 100644
--- a/applications/plugins/spectrum_analyzer/spectrum_analyzer.c
+++ b/applications/plugins/spectrum_analyzer/spectrum_analyzer.c
@@ -326,7 +326,7 @@ void spectrum_analyzer_calculate_frequencies(SpectrumAnalyzerModel* model) {
model->max_rssi = -200.0;
model->max_rssi_dec = 0;
- FURI_LOG_D("Spectrum", "setup_frequencies - max_hz: %u - min_hz: %u", max_hz, min_hz);
+ FURI_LOG_D("Spectrum", "setup_frequencies - max_hz: %lu - min_hz: %lu", max_hz, min_hz);
FURI_LOG_D("Spectrum", "center_freq: %u", model->center_freq);
FURI_LOG_D(
"Spectrum",
@@ -450,7 +450,7 @@ int32_t spectrum_analyzer_app(void* p) {
break;
case InputKeyRight:
model->center_freq += hstep;
- FURI_LOG_D("Spectrum", "center_freq: %lu", model->center_freq);
+ FURI_LOG_D("Spectrum", "center_freq: %u", model->center_freq);
spectrum_analyzer_calculate_frequencies(model);
spectrum_analyzer_worker_set_frequencies(
spectrum_analyzer->worker, model->channel0_frequency, model->spacing, model->width);
@@ -460,7 +460,7 @@ int32_t spectrum_analyzer_app(void* p) {
spectrum_analyzer_calculate_frequencies(model);
spectrum_analyzer_worker_set_frequencies(
spectrum_analyzer->worker, model->channel0_frequency, model->spacing, model->width);
- FURI_LOG_D("Spectrum", "center_freq: %lu", model->center_freq);
+ FURI_LOG_D("Spectrum", "center_freq: %u", model->center_freq);
break;
case InputKeyOk: {
switch(model->width) {
diff --git a/applications/plugins/spectrum_analyzer/spectrum_analyzer_worker.c b/applications/plugins/spectrum_analyzer/spectrum_analyzer_worker.c
index f4533f5d1..e670d2808 100644
--- a/applications/plugins/spectrum_analyzer/spectrum_analyzer_worker.c
+++ b/applications/plugins/spectrum_analyzer/spectrum_analyzer_worker.c
@@ -168,7 +168,7 @@ void spectrum_analyzer_worker_set_frequencies(
FURI_LOG_D(
"SpectrumWorker",
- "spectrum_analyzer_worker_set_frequencies - channel0_frequency= %u - spacing = %u - width = %u",
+ "spectrum_analyzer_worker_set_frequencies - channel0_frequency= %lu - spacing = %lu - width = %u",
channel0_frequency,
spacing,
width);
diff --git a/applications/plugins/subbrute/application.fam b/applications/plugins/subbrute/application.fam
index 1afdc539f..5e9dd9c8d 100644
--- a/applications/plugins/subbrute/application.fam
+++ b/applications/plugins/subbrute/application.fam
@@ -1,5 +1,5 @@
App(
- appid="subbrute",
+ appid="SubGHz_Bruteforcer",
name="Sub-GHz Bruteforcer",
apptype=FlipperAppType.EXTERNAL,
entry_point="subbrute_app",
diff --git a/applications/plugins/subbrute/scenes/subbrute_scene_load_file.c b/applications/plugins/subbrute/scenes/subbrute_scene_load_file.c
index c2572a24c..911dd21c4 100644
--- a/applications/plugins/subbrute/scenes/subbrute_scene_load_file.c
+++ b/applications/plugins/subbrute/scenes/subbrute_scene_load_file.c
@@ -15,10 +15,10 @@ void subbrute_scene_load_file_on_enter(void* context) {
SubBruteState* instance = (SubBruteState*)context;
// Input events and views are managed by file_browser
- string_t app_folder;
- string_t load_path;
- string_init(load_path);
- string_init_set_str(app_folder, SUBBRUTE_PATH);
+ FuriString* app_folder;
+ FuriString* load_path;
+ load_path = furi_string_alloc();
+ app_folder = furi_string_alloc_set(SUBBRUTE_PATH);
DialogsFileBrowserOptions browser_options;
dialog_file_browser_set_basic_options(&browser_options, SUBBRUTE_FILE_EXT, &I_sub1_10px);
@@ -30,8 +30,8 @@ void subbrute_scene_load_file_on_enter(void* context) {
FURI_LOG_D(
TAG,
"load_path: %s, app_folder: %s",
- string_get_cstr(load_path),
- string_get_cstr(app_folder));
+ furi_string_get_cstr(load_path),
+ furi_string_get_cstr(app_folder));
#endif
if(res) {
load_result = subbrute_device_load_from_file(instance->device, load_path);
@@ -49,12 +49,12 @@ void subbrute_scene_load_file_on_enter(void* context) {
} else {
FURI_LOG_E(TAG, "Returned error: %d", load_result);
- string_t dialog_msg;
- string_init(dialog_msg);
- string_cat_printf(
+ FuriString* dialog_msg;
+ dialog_msg = furi_string_alloc();
+ furi_string_cat_printf(
dialog_msg, "Cannot parse\nfile: %s", subbrute_device_error_get_desc(load_result));
- dialog_message_show_storage_error(instance->dialogs, string_get_cstr(dialog_msg));
- string_clear(dialog_msg);
+ dialog_message_show_storage_error(instance->dialogs, furi_string_get_cstr(dialog_msg));
+ furi_string_free(dialog_msg);
scene_manager_search_and_switch_to_previous_scene(
instance->scene_manager, SubBruteSceneStart);
}
@@ -63,8 +63,8 @@ void subbrute_scene_load_file_on_enter(void* context) {
instance->scene_manager, SubBruteSceneStart);
}
- string_clear(app_folder);
- string_clear(load_path);
+ furi_string_free(app_folder);
+ furi_string_free(load_path);
}
void subbrute_scene_load_file_on_exit(void* context) {
diff --git a/applications/plugins/subbrute/scenes/subbrute_scene_save_name.c b/applications/plugins/subbrute/scenes/subbrute_scene_save_name.c
index 8b38ac246..937bf52ae 100644
--- a/applications/plugins/subbrute/scenes/subbrute_scene_save_name.c
+++ b/applications/plugins/subbrute/scenes/subbrute_scene_save_name.c
@@ -44,7 +44,7 @@ bool subbrute_scene_save_name_on_event(void* context, SceneManagerEvent event) {
#endif
bool success = false;
if(strcmp(instance->text_store, "")) {
- string_cat_printf(
+ furi_string_cat_printf(
instance->file_path, "/%s%s", instance->text_store, SUBBRUTE_FILE_EXT);
if(subbrute_device_save_file(instance->device, string_get_cstr(instance->file_path))) {
diff --git a/applications/plugins/subbrute/scenes/subbrute_scene_start.c b/applications/plugins/subbrute/scenes/subbrute_scene_start.c
index 419fdc41c..38441ea30 100644
--- a/applications/plugins/subbrute/scenes/subbrute_scene_start.c
+++ b/applications/plugins/subbrute/scenes/subbrute_scene_start.c
@@ -41,7 +41,7 @@ bool subbrute_scene_start_on_event(void* context, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom) {
#ifdef FURI_DEBUG
- FURI_LOG_D(TAG, "Event: %d", event.event);
+ FURI_LOG_D(TAG, "Event: %ld", event.event);
#endif
if(event.event == SubBruteCustomEventTypeMenuSelected) {
SubBruteAttacks attack = subbrute_main_view_get_index(instance->view_main);
diff --git a/applications/plugins/subbrute/subbrute_device.c b/applications/plugins/subbrute/subbrute_device.c
index 82dccafbb..0be231cf7 100644
--- a/applications/plugins/subbrute/subbrute_device.c
+++ b/applications/plugins/subbrute/subbrute_device.c
@@ -351,41 +351,39 @@ bool subbrute_device_create_packet_parsed(
bool small) {
furi_assert(instance);
- string_t candidate;
- string_init(candidate);
+ FuriString* candidate = furi_string_alloc();
if(instance->attack == SubBruteAttackLoadFile) {
if(step >= sizeof(instance->file_key)) {
return false;
}
char subbrute_payload_byte[4];
- string_set_str(candidate, instance->file_key);
+ furi_string_set_str(candidate, instance->file_key);
snprintf(subbrute_payload_byte, 4, "%02X ", (uint8_t)step);
- string_replace_at(candidate, instance->load_index * 3, 3, subbrute_payload_byte);
+ furi_string_replace_at(candidate, instance->load_index * 3, 3, subbrute_payload_byte);
//snprintf(step_payload, sizeof(step_payload), "%02X", (uint8_t)instance->file_key[step]);
} else {
//snprintf(step_payload, sizeof(step_payload), "%16X", step);
//snprintf(step_payload, sizeof(step_payload), "%016llX", step);
- string_t buffer;
- string_init(buffer);
- string_init_printf(buffer, "%16X", step);
+ FuriString* buffer = furi_string_alloc();
+ furi_string_printf(buffer, "%16llX", step);
int j = 0;
- string_set_str(candidate, " ");
+ furi_string_set_str(candidate, " ");
for(uint8_t i = 0; i < 16; i++) {
- if(string_get_char(buffer, i) != ' ') {
- string_set_char(candidate, i + j, string_get_char(buffer, i));
+ if(furi_string_get_char(buffer, i) != ' ') {
+ furi_string_set_char(candidate, i + j, furi_string_get_char(buffer, i));
} else {
- string_set_char(candidate, i + j, '0');
+ furi_string_set_char(candidate, i + j, '0');
}
if(i % 2 != 0) {
j++;
}
}
- string_clear(buffer);
+ furi_string_free(buffer);
}
#ifdef FURI_DEBUG
- FURI_LOG_D(TAG, "candidate: %s, step: %d", string_get_cstr(candidate), step);
+ FURI_LOG_D(TAG, "candidate: %s, step: %lld", furi_string_get_cstr(candidate), step);
#endif
Stream* stream = flipper_format_get_raw_stream(flipper_format);
@@ -397,7 +395,7 @@ bool subbrute_device_create_packet_parsed(
stream,
subbrute_key_small_with_tail,
instance->protocol_info->bits,
- string_get_cstr(candidate),
+ furi_string_get_cstr(candidate),
instance->protocol_info->te,
instance->protocol_info->repeat);
} else {
@@ -414,7 +412,7 @@ bool subbrute_device_create_packet_parsed(
stream,
subbrute_key_file_key_with_tail,
instance->file_template,
- string_get_cstr(candidate),
+ furi_string_get_cstr(candidate),
instance->protocol_info->te,
instance->protocol_info->repeat);
} else {
@@ -430,7 +428,7 @@ bool subbrute_device_create_packet_parsed(
//FURI_LOG_D(TAG, "payload: %s", instance->payload);
#endif
- string_clear(candidate);
+ furi_string_free(candidate);
return true;
}
@@ -477,15 +475,15 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute
// Calc max value
if(instance->attack == SubBruteAttackLoadFile) {
- instance->max_value = 0xFF;
+ instance->max_value = 0x3F;
} else {
- string_t max_value_s;
- string_init(max_value_s);
+ FuriString* max_value_s;
+ max_value_s = furi_string_alloc();
for(uint8_t i = 0; i < instance->protocol_info->bits; i++) {
- string_cat_printf(max_value_s, "1");
+ furi_string_cat_printf(max_value_s, "1");
}
- instance->max_value = (uint64_t)strtol(string_get_cstr(max_value_s), NULL, 2);
- string_clear(max_value_s);
+ instance->max_value = (uint64_t)strtol(furi_string_get_cstr(max_value_s), NULL, 2);
+ furi_string_free(max_value_s);
}
// Now we are ready to set file template for using in the future with snprintf
@@ -514,18 +512,18 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute
return SubBruteFileResultOk;
}
-uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, string_t file_path) {
+uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, FuriString* file_path) {
furi_assert(instance);
#ifdef FURI_DEBUG
- FURI_LOG_D(TAG, "subbrute_device_load_from_file: %s", string_get_cstr(file_path));
+ FURI_LOG_D(TAG, "subbrute_device_load_from_file: %s", furi_string_get_cstr(file_path));
#endif
SubBruteFileResult result = SubBruteFileResultUnknown;
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
- string_t temp_str;
- string_init(temp_str);
+ FuriString* temp_str;
+ temp_str = furi_string_alloc();
uint32_t temp_data32;
instance->receiver = subghz_receiver_alloc_init(instance->environment);
@@ -533,8 +531,8 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, string_t file_p
furi_hal_subghz_reset();
do {
- if(!flipper_format_file_open_existing(fff_data_file, string_get_cstr(file_path))) {
- FURI_LOG_E(TAG, "Error open file %s", string_get_cstr(file_path));
+ if(!flipper_format_file_open_existing(fff_data_file, furi_string_get_cstr(file_path))) {
+ FURI_LOG_E(TAG, "Error open file %s", furi_string_get_cstr(file_path));
result = SubBruteFileResultErrorOpenFile;
break;
}
@@ -618,7 +616,10 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, string_t file_p
break;
} else {
snprintf(
- instance->file_key, sizeof(instance->file_key), "%s", string_get_cstr(temp_str));
+ instance->file_key,
+ sizeof(instance->file_key),
+ "%s",
+ furi_string_get_cstr(temp_str));
#ifdef FURI_DEBUG
FURI_LOG_D(TAG, "Key: %s", instance->file_key);
#endif
@@ -636,7 +637,7 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, string_t file_p
// Repeat
if(flipper_format_read_uint32(fff_data_file, "Repeat", &temp_data32, 1)) {
#ifdef FURI_DEBUG
- FURI_LOG_D(TAG, "Repeat: %d", temp_data32);
+ FURI_LOG_D(TAG, "Repeat: %ld", temp_data32);
#endif
instance->protocol_info->repeat = (uint8_t)temp_data32;
} else {
@@ -649,7 +650,7 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, string_t file_p
result = SubBruteFileResultOk;
} while(0);
- string_clear(temp_str);
+ furi_string_free(temp_str);
flipper_format_file_close(fff_data_file);
flipper_format_free(fff_data_file);
furi_record_close(RECORD_STORAGE);
diff --git a/applications/plugins/subbrute/subbrute_device.h b/applications/plugins/subbrute/subbrute_device.h
index f2f30d401..801b3f635 100644
--- a/applications/plugins/subbrute/subbrute_device.h
+++ b/applications/plugins/subbrute/subbrute_device.h
@@ -6,7 +6,56 @@
#include
#include
-struct SubBruteDevice {
+#define SUBBRUTE_TEXT_STORE_SIZE 256
+
+#define SUBBRUTE_MAX_LEN_NAME 64
+#define SUBBRUTE_PATH EXT_PATH("subghz")
+#define SUBBRUTE_FILE_EXT ".sub"
+
+#define SUBBRUTE_PAYLOAD_SIZE 16
+
+typedef enum {
+ SubBruteAttackCAME12bit303,
+ SubBruteAttackCAME12bit307,
+ SubBruteAttackCAME12bit433,
+ SubBruteAttackCAME12bit868,
+ SubBruteAttackNICE12bit433,
+ SubBruteAttackNICE12bit868,
+ SubBruteAttackChamberlain9bit300,
+ SubBruteAttackChamberlain9bit315,
+ SubBruteAttackChamberlain9bit390,
+ SubBruteAttackLinear10bit300,
+ SubBruteAttackLinear10bit310,
+ SubBruteAttackLoadFile,
+ SubBruteAttackTotalCount,
+} SubBruteAttacks;
+
+typedef enum {
+ SubBruteFileResultUnknown,
+ SubBruteFileResultOk,
+ SubBruteFileResultErrorOpenFile,
+ SubBruteFileResultMissingOrIncorrectHeader,
+ SubBruteFileResultFrequencyNotAllowed,
+ SubBruteFileResultMissingOrIncorrectFrequency,
+ SubBruteFileResultPresetInvalid,
+ SubBruteFileResultMissingProtocol,
+ SubBruteFileResultProtocolNotSupported,
+ SubBruteFileResultDynamicProtocolNotValid,
+ SubBruteFileResultProtocolNotFound,
+ SubBruteFileResultMissingOrIncorrectBit,
+ SubBruteFileResultMissingOrIncorrectKey,
+ SubBruteFileResultMissingOrIncorrectTe,
+ SubBruteFileResultBigBitSize,
+} SubBruteFileResult;
+
+typedef enum {
+ SubBruteDeviceStateIDLE,
+ SubBruteDeviceStateReady,
+ SubBruteDeviceStateTx,
+ SubBruteDeviceStateFinished,
+} SubBruteDeviceState;
+
+typedef struct {
SubBruteDeviceState state;
SubBruteProtocol* protocol_info;
volatile bool worker_running;
diff --git a/applications/plugins/subbrute/subbrute_i.h b/applications/plugins/subbrute/subbrute_i.h
index 1e6498c62..bf8ab7ebc 100644
--- a/applications/plugins/subbrute/subbrute_i.h
+++ b/applications/plugins/subbrute/subbrute_i.h
@@ -6,7 +6,6 @@
#include
#include
-#include
#include
#include
diff --git a/applications/plugins/subbrute/views/subbrute_attack_view.c b/applications/plugins/subbrute/views/subbrute_attack_view.c
index d3f618f5b..da333a9a2 100644
--- a/applications/plugins/subbrute/views/subbrute_attack_view.c
+++ b/applications/plugins/subbrute/views/subbrute_attack_view.c
@@ -249,7 +249,11 @@ void subbrute_attack_view_init_values(
bool is_attacking) {
#ifdef FURI_DEBUG
FURI_LOG_D(
- TAG, "init, index: %d, max_value: %d, current_step: %d", index, max_value, current_step);
+ TAG,
+ "init, index: %d, max_value: %lld, current_step: %lld",
+ index,
+ max_value,
+ current_step);
#endif
with_view_model(
instance->view, (SubBruteAttackViewModel * model) {
diff --git a/applications/plugins/subbrute/views/subbrute_main_view.c b/applications/plugins/subbrute/views/subbrute_main_view.c
index 32eeeabb7..e6a19d6f0 100644
--- a/applications/plugins/subbrute/views/subbrute_main_view.c
+++ b/applications/plugins/subbrute/views/subbrute_main_view.c
@@ -34,7 +34,7 @@ void subbrute_main_view_set_callback(
instance->context = context;
}
-void center_displayed_key(string_t result, const char* key_cstr, uint8_t index) {
+FuriString* center_displayed_key(const char* key_cstr, uint8_t index) {
uint8_t str_index = (index * 3);
char display_menu[] = {
@@ -76,7 +76,7 @@ void center_displayed_key(string_t result, const char* key_cstr, uint8_t index)
display_menu[15] = ' ';
}
}
- string_init_set_str(result, display_menu);
+ return furi_string_alloc_set(display_menu);
}
void subbrute_main_view_draw(Canvas* canvas, SubBruteMainViewModel* model) {
@@ -97,19 +97,19 @@ void subbrute_main_view_draw(Canvas* canvas, SubBruteMainViewModel* model) {
snprintf(msg_index, sizeof(msg_index), "Field index : %d", m->index);
canvas_draw_str_aligned(canvas, 64, 26, AlignCenter, AlignTop, msg_index);
- string_t menu_items;
- string_init(menu_items);
+ FuriString* menu_items;
- center_displayed_key(menu_items, m->key_field, m->index);
+ menu_items = center_displayed_key(m->key_field, m->index);
canvas_set_font(canvas, FontSecondary);
canvas_draw_str_aligned(
- canvas, 64, 40, AlignCenter, AlignTop, string_get_cstr(menu_items));
+ canvas, 64, 40, AlignCenter, AlignTop, furi_string_get_cstr(menu_items));
elements_button_center(canvas, "Select");
elements_button_left(canvas, "<");
elements_button_right(canvas, ">");
- string_reset(menu_items);
+ furi_string_reset(menu_items);
+ furi_string_free(menu_items);
} else {
// Menu
canvas_set_color(canvas, ColorBlack);
diff --git a/applications/plugins/tetris_game/application.fam b/applications/plugins/tetris_game/application.fam
index 9a298a3d5..69dda3297 100644
--- a/applications/plugins/tetris_game/application.fam
+++ b/applications/plugins/tetris_game/application.fam
@@ -1,5 +1,5 @@
App(
- appid="tetris_game",
+ appid="Tetris",
name="Tetris",
apptype=FlipperAppType.EXTERNAL,
entry_point="tetris_game_app",
diff --git a/applications/plugins/tictactoe_game/application.fam b/applications/plugins/tictactoe_game/application.fam
index 289f4f88d..2e769417e 100644
--- a/applications/plugins/tictactoe_game/application.fam
+++ b/applications/plugins/tictactoe_game/application.fam
@@ -1,5 +1,5 @@
App(
- appid="tictactoe_game",
+ appid="TicTacToe",
name="Tic Tac Toe",
apptype=FlipperAppType.EXTERNAL,
entry_point="tictactoe_game_app",
diff --git a/applications/plugins/wav_player/application.fam b/applications/plugins/wav_player/application.fam
index 4e8d81ab2..394e45d29 100644
--- a/applications/plugins/wav_player/application.fam
+++ b/applications/plugins/wav_player/application.fam
@@ -1,5 +1,5 @@
App(
- appid="wav_player",
+ appid="WAV_Player",
name="WAV Player",
apptype=FlipperAppType.EXTERNAL,
entry_point="wav_player_app",
diff --git a/applications/plugins/wav_player/wav_player.c b/applications/plugins/wav_player/wav_player.c
index 952a5b395..830e37dbf 100644
--- a/applications/plugins/wav_player/wav_player.c
+++ b/applications/plugins/wav_player/wav_player.c
@@ -19,9 +19,9 @@
static bool open_wav_stream(Stream* stream) {
DialogsApp* dialogs = furi_record_open("dialogs");
bool result = false;
- string_t path;
- string_init(path);
- string_set_str(path, WAVPLAYER_FOLDER);
+ FuriString* path;
+ path = furi_string_alloc();
+ furi_string_set(path, WAVPLAYER_FOLDER);
DialogsFileBrowserOptions browser_options;
dialog_file_browser_set_basic_options(&browser_options, ".wav", &I_music_10px);
@@ -31,13 +31,13 @@ static bool open_wav_stream(Stream* stream) {
furi_record_close("dialogs");
if(ret) {
- if(!file_stream_open(stream, string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
- FURI_LOG_E(TAG, "Cannot open file \"%s\"", string_get_cstr(path));
+ if(!file_stream_open(stream, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
+ FURI_LOG_E(TAG, "Cannot open file \"%s\"", furi_string_get_cstr(path));
} else {
result = true;
}
}
- string_clear(path);
+ furi_string_free(path);
return result;
}
diff --git a/applications/plugins/wifi_marauder_companion/application.fam b/applications/plugins/wifi_marauder_companion/application.fam
index 0548905d9..e3185d50a 100644
--- a/applications/plugins/wifi_marauder_companion/application.fam
+++ b/applications/plugins/wifi_marauder_companion/application.fam
@@ -1,5 +1,5 @@
App(
- appid="wifi_marauder",
+ appid="ESP32_WiFi_Marauder",
name="[ESP32] WiFi Marauder",
apptype=FlipperAppType.EXTERNAL,
entry_point="wifi_marauder_app",
diff --git a/applications/plugins/wifi_marauder_companion/scenes/wifi_marauder_scene_console_output.c b/applications/plugins/wifi_marauder_companion/scenes/wifi_marauder_scene_console_output.c
index be6c25fd4..c5afa6502 100644
--- a/applications/plugins/wifi_marauder_companion/scenes/wifi_marauder_scene_console_output.c
+++ b/applications/plugins/wifi_marauder_companion/scenes/wifi_marauder_scene_console_output.c
@@ -7,13 +7,13 @@ void wifi_marauder_console_output_handle_rx_data_cb(uint8_t* buf, size_t len, vo
// If text box store gets too big, then truncate it
app->text_box_store_strlen += len;
if(app->text_box_store_strlen >= WIFI_MARAUDER_TEXT_BOX_STORE_SIZE - 1) {
- string_right(app->text_box_store, app->text_box_store_strlen / 2);
- app->text_box_store_strlen = string_size(app->text_box_store) + len;
+ furi_string_right(app->text_box_store, app->text_box_store_strlen / 2);
+ app->text_box_store_strlen = furi_string_size(app->text_box_store) + len;
}
// Null-terminate buf and append to text box store
buf[len] = '\0';
- string_cat_printf(app->text_box_store, "%s", buf);
+ furi_string_cat_printf(app->text_box_store, "%s", buf);
view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventRefreshConsoleOutput);
}
@@ -30,24 +30,24 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
text_box_set_focus(text_box, TextBoxFocusEnd);
}
if(app->is_command) {
- string_reset(app->text_box_store);
+ furi_string_reset(app->text_box_store);
app->text_box_store_strlen = 0;
if(0 == strncmp("help", app->selected_tx_string, strlen("help"))) {
const char* help_msg =
"For app support/feedback,\nreach out to me:\n@cococode#6011 (discord)\n0xchocolate (github)\n";
- string_cat_str(app->text_box_store, help_msg);
+ furi_string_cat_str(app->text_box_store, help_msg);
app->text_box_store_strlen += strlen(help_msg);
}
if(app->show_stopscan_tip) {
const char* help_msg = "Press BACK to send stopscan\n";
- string_cat_str(app->text_box_store, help_msg);
+ furi_string_cat_str(app->text_box_store, help_msg);
app->text_box_store_strlen += strlen(help_msg);
}
}
// Set starting text - for "View Log", this will just be what was already in the text box store
- text_box_set_text(app->text_box, string_get_cstr(app->text_box_store));
+ text_box_set_text(app->text_box, furi_string_get_cstr(app->text_box_store));
scene_manager_set_scene_state(app->scene_manager, WifiMarauderSceneConsoleOutput, 0);
view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewConsoleOutput);
@@ -70,7 +70,7 @@ bool wifi_marauder_scene_console_output_on_event(void* context, SceneManagerEven
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
- text_box_set_text(app->text_box, string_get_cstr(app->text_box_store));
+ text_box_set_text(app->text_box, furi_string_get_cstr(app->text_box_store));
consumed = true;
} else if(event.type == SceneManagerEventTypeTick) {
consumed = true;
diff --git a/applications/plugins/wifi_marauder_companion/wifi_marauder_app.c b/applications/plugins/wifi_marauder_companion/wifi_marauder_app.c
index 59ca9edbe..2a4b23e8b 100644
--- a/applications/plugins/wifi_marauder_companion/wifi_marauder_app.c
+++ b/applications/plugins/wifi_marauder_companion/wifi_marauder_app.c
@@ -53,8 +53,8 @@ WifiMarauderApp* wifi_marauder_app_alloc() {
app->text_box = text_box_alloc();
view_dispatcher_add_view(
app->view_dispatcher, WifiMarauderAppViewConsoleOutput, text_box_get_view(app->text_box));
- string_init(app->text_box_store);
- string_reserve(app->text_box_store, WIFI_MARAUDER_TEXT_BOX_STORE_SIZE);
+ app->text_box_store = furi_string_alloc();
+ furi_string_reserve(app->text_box_store, WIFI_MARAUDER_TEXT_BOX_STORE_SIZE);
app->text_input = text_input_alloc();
view_dispatcher_add_view(
@@ -73,7 +73,7 @@ void wifi_marauder_app_free(WifiMarauderApp* app) {
view_dispatcher_remove_view(app->view_dispatcher, WifiMarauderAppViewConsoleOutput);
view_dispatcher_remove_view(app->view_dispatcher, WifiMarauderAppViewTextInput);
text_box_free(app->text_box);
- string_clear(app->text_box_store);
+ furi_string_free(app->text_box_store);
text_input_free(app->text_input);
// View dispatcher
diff --git a/applications/plugins/wifi_marauder_companion/wifi_marauder_app_i.h b/applications/plugins/wifi_marauder_companion/wifi_marauder_app_i.h
index a438e7fad..63d340bbc 100644
--- a/applications/plugins/wifi_marauder_companion/wifi_marauder_app_i.h
+++ b/applications/plugins/wifi_marauder_companion/wifi_marauder_app_i.h
@@ -23,7 +23,7 @@ struct WifiMarauderApp {
SceneManager* scene_manager;
char text_input_store[WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE + 1];
- string_t text_box_store;
+ FuriString* text_box_store;
size_t text_box_store_strlen;
TextBox* text_box;
TextInput* text_input;
diff --git a/applications/plugins/wifi_marauder_companion/wifi_marauder_uart.c b/applications/plugins/wifi_marauder_companion/wifi_marauder_uart.c
index a7dc26e8b..8c8d82eb6 100644
--- a/applications/plugins/wifi_marauder_companion/wifi_marauder_uart.c
+++ b/applications/plugins/wifi_marauder_companion/wifi_marauder_uart.c
@@ -1,15 +1,13 @@
#include "wifi_marauder_app_i.h"
#include "wifi_marauder_uart.h"
-#include
-
#define UART_CH (FuriHalUartIdUSART1)
#define BAUDRATE (115200)
struct WifiMarauderUart {
WifiMarauderApp* app;
FuriThread* rx_thread;
- StreamBufferHandle_t rx_stream;
+ FuriStreamBuffer* rx_stream;
uint8_t rx_buf[RX_BUF_SIZE + 1];
void (*handle_rx_data_cb)(uint8_t* buf, size_t len, void* context);
};
@@ -30,19 +28,17 @@ void wifi_marauder_uart_set_handle_rx_data_cb(
void wifi_marauder_uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
WifiMarauderUart* uart = (WifiMarauderUart*)context;
- BaseType_t xHigherPriorityTaskWoken = pdFALSE;
if(ev == UartIrqEventRXNE) {
- xStreamBufferSendFromISR(uart->rx_stream, &data, 1, &xHigherPriorityTaskWoken);
+ furi_stream_buffer_send(uart->rx_stream, &data, 1, 0);
furi_thread_flags_set(furi_thread_get_id(uart->rx_thread), WorkerEvtRxDone);
- portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}
static int32_t uart_worker(void* context) {
WifiMarauderUart* uart = (void*)context;
- uart->rx_stream = xStreamBufferCreate(RX_BUF_SIZE, 1);
+ uart->rx_stream = furi_stream_buffer_alloc(RX_BUF_SIZE, 1);
while(1) {
uint32_t events =
@@ -50,14 +46,14 @@ static int32_t uart_worker(void* context) {
furi_check((events & FuriFlagError) == 0);
if(events & WorkerEvtStop) break;
if(events & WorkerEvtRxDone) {
- size_t len = xStreamBufferReceive(uart->rx_stream, uart->rx_buf, RX_BUF_SIZE, 0);
+ size_t len = furi_stream_buffer_receive(uart->rx_stream, uart->rx_buf, RX_BUF_SIZE, 0);
if(len > 0) {
if(uart->handle_rx_data_cb) uart->handle_rx_data_cb(uart->rx_buf, len, uart->app);
}
}
}
- vStreamBufferDelete(uart->rx_stream);
+ furi_stream_buffer_free(uart->rx_stream);
return 0;
}
diff --git a/applications/plugins/wifi_scanner/application.fam b/applications/plugins/wifi_scanner/application.fam
index 22ca79673..dc229efc0 100644
--- a/applications/plugins/wifi_scanner/application.fam
+++ b/applications/plugins/wifi_scanner/application.fam
@@ -1,5 +1,5 @@
App(
- appid="wifi_scanner",
+ appid="WiFi_Scanner",
name="[WiFi] Scanner",
apptype=FlipperAppType.EXTERNAL,
entry_point="wifi_scanner_app",
diff --git a/applications/plugins/wifi_scanner/wifi_scanner.c b/applications/plugins/wifi_scanner/wifi_scanner.c
index 118bc5005..4de68ee58 100644
--- a/applications/plugins/wifi_scanner/wifi_scanner.c
+++ b/applications/plugins/wifi_scanner/wifi_scanner.c
@@ -6,12 +6,11 @@
#include
#include
#include
-#include
#include
#include
#include
#include
-#include
+
#include
#include "FlipperZeroWiFiModuleDefines.h"
@@ -59,10 +58,10 @@ typedef struct SPluginEvent {
} SPluginEvent;
typedef struct EAccessPointDesc {
- string_t m_accessPointName;
+ FuriString* m_accessPointName;
int16_t m_rssi;
- string_t m_secType;
- string_t m_bssid;
+ FuriString* m_secType;
+ FuriString* m_bssid;
unsigned short m_channel;
bool m_isHidden;
} EAccessPointDesc;
@@ -87,7 +86,7 @@ typedef struct SWiFiScannerApp {
Gui* m_gui;
FuriThread* m_worker_thread;
NotificationApp* m_notification;
- StreamBufferHandle_t m_rx_stream;
+ FuriStreamBuffer* m_rx_stream;
bool m_wifiModuleInitialized;
bool m_wifiModuleAttached;
@@ -111,13 +110,13 @@ static void wifi_scanner_app_init(SWiFiScannerApp* const app) {
app->m_totalAccessPoints = 0;
app->m_currentIndexAccessPoint = 0;
- string_init(app->m_currentAccesspointDescription.m_accessPointName);
- string_set_str(app->m_currentAccesspointDescription.m_accessPointName, "N/A\n");
+ app->m_currentAccesspointDescription.m_accessPointName = furi_string_alloc();
+ furi_string_set(app->m_currentAccesspointDescription.m_accessPointName, "N/A\n");
app->m_currentAccesspointDescription.m_channel = 0;
- string_init(app->m_currentAccesspointDescription.m_bssid);
- string_set_str(app->m_currentAccesspointDescription.m_bssid, "N/A\n");
- string_init(app->m_currentAccesspointDescription.m_secType);
- string_set_str(app->m_currentAccesspointDescription.m_secType, "N/A\n");
+ app->m_currentAccesspointDescription.m_bssid = furi_string_alloc();
+ furi_string_set(app->m_currentAccesspointDescription.m_bssid, "N/A\n");
+ app->m_currentAccesspointDescription.m_secType = furi_string_alloc();
+ furi_string_set(app->m_currentAccesspointDescription.m_secType, "N/A\n");
app->m_currentAccesspointDescription.m_rssi = 0;
app->m_currentAccesspointDescription.m_isHidden = false;
@@ -238,7 +237,7 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) {
offsetY,
app->m_currentAccesspointDescription.m_isHidden ?
"(Hidden SSID)" :
- string_get_cstr(app->m_currentAccesspointDescription.m_accessPointName));
+ furi_string_get_cstr(app->m_currentAccesspointDescription.m_accessPointName));
offsetY += fontHeight;
@@ -246,7 +245,7 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) {
canvas,
offsetX,
offsetY,
- string_get_cstr(app->m_currentAccesspointDescription.m_bssid));
+ furi_string_get_cstr(app->m_currentAccesspointDescription.m_bssid));
canvas_set_font(canvas, FontSecondary);
//u8g2_SetFont(&canvas->fb, u8g2_font_tinytim_tf);
@@ -271,7 +270,7 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) {
string,
sizeof(string),
"ENCR: %s",
- string_get_cstr(app->m_currentAccesspointDescription.m_secType));
+ furi_string_get_cstr(app->m_currentAccesspointDescription.m_secType));
canvas_draw_str(canvas, offsetX, offsetY, string);
offsetY += fontHeight;
@@ -346,7 +345,7 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) {
canvas,
offsetX,
offsetY,
- string_get_cstr(app->m_currentAccesspointDescription.m_accessPointName));
+ furi_string_get_cstr(app->m_currentAccesspointDescription.m_accessPointName));
offsetY += fontHeight + 2;
@@ -354,7 +353,7 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) {
canvas,
offsetX,
offsetY,
- string_get_cstr(app->m_currentAccesspointDescription.m_bssid));
+ furi_string_get_cstr(app->m_currentAccesspointDescription.m_bssid));
DrawSignalStrengthBar(
canvas, app->m_currentAccesspointDescription.m_rssi, 5, 5, 12, 25);
@@ -446,7 +445,6 @@ static void wifi_module_input_callback(InputEvent* input_event, FuriMessageQueue
static void uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
furi_assert(context);
- BaseType_t xHigherPriorityTaskWoken = pdFALSE;
SWiFiScannerApp* app = context;
@@ -454,9 +452,8 @@ static void uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
if(ev == UartIrqEventRXNE) {
WIFI_APP_LOG_I("ev == UartIrqEventRXNE");
- xStreamBufferSendFromISR(app->m_rx_stream, &data, 1, &xHigherPriorityTaskWoken);
+ furi_stream_buffer_send(app->m_rx_stream, &data, 1, 0);
furi_thread_flags_set(furi_thread_get_id(app->m_worker_thread), WorkerEventRx);
- portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}
@@ -468,7 +465,7 @@ static int32_t uart_worker(void* context) {
return 1;
}
- StreamBufferHandle_t rx_stream = app->m_rx_stream;
+ FuriStreamBuffer* rx_stream = app->m_rx_stream;
release_mutex((ValueMutex*)context, app);
@@ -480,54 +477,55 @@ static int32_t uart_worker(void* context) {
if(events & WorkerEventStop) break;
if(events & WorkerEventRx) {
size_t length = 0;
- string_t receivedString;
- string_init(receivedString);
+ FuriString* receivedString;
+ receivedString = furi_string_alloc();
do {
uint8_t data[64];
- length = xStreamBufferReceive(rx_stream, data, 64, 25);
+ length = furi_stream_buffer_receive(rx_stream, data, 64, 25);
if(length > 0) {
WIFI_APP_LOG_I("Received Data - length: %i", length);
for(uint16_t i = 0; i < length; i++) {
- string_push_back(receivedString, data[i]);
+ furi_string_push_back(receivedString, data[i]);
}
//notification_message(app->notification, &sequence_set_only_red_255);
}
} while(length > 0);
- if(string_size(receivedString) > 0) {
- string_t chunk;
- string_init(chunk);
+ if(furi_string_size(receivedString) > 0) {
+ FuriString* chunk;
+ chunk = furi_string_alloc();
size_t begin = 0;
size_t end = 0;
- size_t stringSize = string_size(receivedString);
+ size_t stringSize = furi_string_size(receivedString);
- WIFI_APP_LOG_I("Received string: %s", string_get_cstr(receivedString));
+ WIFI_APP_LOG_I("Received string: %s", furi_string_get_cstr(receivedString));
- string_t chunksArray[EChunkArrayData_ENUM_MAX];
+ FuriString* chunksArray[EChunkArrayData_ENUM_MAX];
for(uint8_t i = 0; i < EChunkArrayData_ENUM_MAX; ++i) {
- string_init(chunksArray[i]);
+ chunksArray[i] = furi_string_alloc();
}
uint8_t index = 0;
do {
- end = string_search_char(receivedString, '+', begin);
+ end = furi_string_search_char(receivedString, '+', begin);
- if(end == STRING_FAILURE) {
+ if(end == FURI_STRING_FAILURE) {
end = stringSize;
}
WIFI_APP_LOG_I("size: %i, begin: %i, end: %i", stringSize, begin, end);
- string_set_strn(chunk, &string_get_cstr(receivedString)[begin], end - begin);
+ furi_string_set_strn(
+ chunk, &furi_string_get_cstr(receivedString)[begin], end - begin);
- WIFI_APP_LOG_I("String chunk: %s", string_get_cstr(chunk));
+ WIFI_APP_LOG_I("String chunk: %s", furi_string_get_cstr(chunk));
- string_set(chunksArray[index++], chunk);
+ furi_string_set(chunksArray[index++], chunk);
begin = end + 1;
} while(end < stringSize);
- string_clear(chunk);
+ furi_string_free(chunk);
app = acquire_mutex((ValueMutex*)context, 25);
if(app == NULL) {
@@ -535,7 +533,7 @@ static int32_t uart_worker(void* context) {
}
if(!app->m_wifiModuleInitialized) {
- if(string_cmp_str(
+ if(furi_string_cmp_str(
chunksArray[EChunkArrayData_Context], MODULE_CONTEXT_INITIALIZATION) ==
0) {
app->m_wifiModuleInitialized = true;
@@ -543,46 +541,46 @@ static int32_t uart_worker(void* context) {
}
} else {
- if(string_cmp_str(
+ if(furi_string_cmp_str(
chunksArray[EChunkArrayData_Context], MODULE_CONTEXT_MONITOR) == 0) {
app->m_context = MonitorMode;
} else if(
- string_cmp_str(
+ furi_string_cmp_str(
chunksArray[EChunkArrayData_Context], MODULE_CONTEXT_SCAN) == 0) {
app->m_context = ScanMode;
} else if(
- string_cmp_str(
+ furi_string_cmp_str(
chunksArray[EChunkArrayData_Context], MODULE_CONTEXT_SCAN_ANIMATION) ==
0) {
app->m_context = ScanAnimation;
} else if(
- string_cmp_str(
+ furi_string_cmp_str(
chunksArray[EChunkArrayData_Context],
MODULE_CONTEXT_MONITOR_ANIMATION) == 0) {
app->m_context = MonitorAnimation;
}
if(app->m_context == MonitorMode || app->m_context == ScanMode) {
- string_set(
+ furi_string_set(
app->m_currentAccesspointDescription.m_accessPointName,
chunksArray[EChunkArrayData_SSID]);
- string_set(
+ furi_string_set(
app->m_currentAccesspointDescription.m_secType,
chunksArray[EChunkArrayData_EncryptionType]);
app->m_currentAccesspointDescription.m_rssi =
- atoi(string_get_cstr(chunksArray[EChunkArrayData_RSSI]));
- string_set(
+ atoi(furi_string_get_cstr(chunksArray[EChunkArrayData_RSSI]));
+ furi_string_set(
app->m_currentAccesspointDescription.m_bssid,
chunksArray[EChunkArrayData_BSSID]);
app->m_currentAccesspointDescription.m_channel =
- atoi(string_get_cstr(chunksArray[EChunkArrayData_Channel]));
+ atoi(furi_string_get_cstr(chunksArray[EChunkArrayData_Channel]));
app->m_currentAccesspointDescription.m_isHidden =
- atoi(string_get_cstr(chunksArray[EChunkArrayData_IsHidden]));
+ atoi(furi_string_get_cstr(chunksArray[EChunkArrayData_IsHidden]));
- app->m_currentIndexAccessPoint =
- atoi(string_get_cstr(chunksArray[EChunkArrayData_CurrentAPIndex]));
+ app->m_currentIndexAccessPoint = atoi(
+ furi_string_get_cstr(chunksArray[EChunkArrayData_CurrentAPIndex]));
app->m_totalAccessPoints =
- atoi(string_get_cstr(chunksArray[EChunkArrayData_TotalAps]));
+ atoi(furi_string_get_cstr(chunksArray[EChunkArrayData_TotalAps]));
}
}
@@ -590,10 +588,10 @@ static int32_t uart_worker(void* context) {
// Clear string array
for(index = 0; index < EChunkArrayData_ENUM_MAX; ++index) {
- string_clear(chunksArray[index]);
+ furi_string_free(chunksArray[index]);
}
}
- string_clear(receivedString);
+ furi_string_free(receivedString);
}
}
@@ -676,7 +674,7 @@ int32_t wifi_scanner_app(void* p) {
WIFI_APP_LOG_I("Mutex created");
- app->m_rx_stream = xStreamBufferCreate(1 * 1024, 1);
+ app->m_rx_stream = furi_stream_buffer_alloc(1 * 1024, 1);
app->m_notification = furi_record_open("notification");
@@ -839,7 +837,7 @@ int32_t wifi_scanner_app(void* p) {
furi_message_queue_free(event_queue);
- vStreamBufferDelete(app->m_rx_stream);
+ furi_stream_buffer_free(app->m_rx_stream);
delete_mutex(&app_data_mutex);
diff --git a/applications/plugins/zombiez/application.fam b/applications/plugins/zombiez/application.fam
index 14cad08ce..3245187d2 100644
--- a/applications/plugins/zombiez/application.fam
+++ b/applications/plugins/zombiez/application.fam
@@ -1,5 +1,5 @@
App(
- appid="game_zombiez",
+ appid="Zombiez",
name="Zombiez",
apptype=FlipperAppType.EXTERNAL,
entry_point="zombiez_game_app",
diff --git a/applications/services/bt/bt_cli.c b/applications/services/bt/bt_cli.c
index ff5ebb448..02bf6cee4 100644
--- a/applications/services/bt/bt_cli.c
+++ b/applications/services/bt/bt_cli.c
@@ -7,18 +7,18 @@
#include "bt_settings.h"
#include "bt_service/bt.h"
-static void bt_cli_command_hci_info(Cli* cli, string_t args, void* context) {
+static void bt_cli_command_hci_info(Cli* cli, FuriString* args, void* context) {
UNUSED(cli);
UNUSED(args);
UNUSED(context);
- string_t buffer;
- string_init(buffer);
+ FuriString* buffer;
+ buffer = furi_string_alloc();
furi_hal_bt_dump_state(buffer);
- printf("%s", string_get_cstr(buffer));
- string_clear(buffer);
+ printf("%s", furi_string_get_cstr(buffer));
+ furi_string_free(buffer);
}
-static void bt_cli_command_carrier_tx(Cli* cli, string_t args, void* context) {
+static void bt_cli_command_carrier_tx(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
int channel = 0;
int power = 0;
@@ -50,7 +50,7 @@ static void bt_cli_command_carrier_tx(Cli* cli, string_t args, void* context) {
} while(false);
}
-static void bt_cli_command_carrier_rx(Cli* cli, string_t args, void* context) {
+static void bt_cli_command_carrier_rx(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
int channel = 0;
@@ -81,7 +81,7 @@ static void bt_cli_command_carrier_rx(Cli* cli, string_t args, void* context) {
} while(false);
}
-static void bt_cli_command_packet_tx(Cli* cli, string_t args, void* context) {
+static void bt_cli_command_packet_tx(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
int channel = 0;
int pattern = 0;
@@ -129,7 +129,7 @@ static void bt_cli_command_packet_tx(Cli* cli, string_t args, void* context) {
} while(false);
}
-static void bt_cli_command_packet_rx(Cli* cli, string_t args, void* context) {
+static void bt_cli_command_packet_rx(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
int channel = 0;
int datarate = 1;
@@ -178,12 +178,12 @@ static void bt_cli_print_usage() {
}
}
-static void bt_cli(Cli* cli, string_t args, void* context) {
+static void bt_cli(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
furi_record_open(RECORD_BT);
- string_t cmd;
- string_init(cmd);
+ FuriString* cmd;
+ cmd = furi_string_alloc();
BtSettings bt_settings;
bt_settings_load(&bt_settings);
@@ -192,24 +192,24 @@ static void bt_cli(Cli* cli, string_t args, void* context) {
bt_cli_print_usage();
break;
}
- if(string_cmp_str(cmd, "hci_info") == 0) {
+ if(furi_string_cmp_str(cmd, "hci_info") == 0) {
bt_cli_command_hci_info(cli, args, NULL);
break;
}
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug) && furi_hal_bt_is_testing_supported()) {
- if(string_cmp_str(cmd, "tx_carrier") == 0) {
+ if(furi_string_cmp_str(cmd, "tx_carrier") == 0) {
bt_cli_command_carrier_tx(cli, args, NULL);
break;
}
- if(string_cmp_str(cmd, "rx_carrier") == 0) {
+ if(furi_string_cmp_str(cmd, "rx_carrier") == 0) {
bt_cli_command_carrier_rx(cli, args, NULL);
break;
}
- if(string_cmp_str(cmd, "tx_packet") == 0) {
+ if(furi_string_cmp_str(cmd, "tx_packet") == 0) {
bt_cli_command_packet_tx(cli, args, NULL);
break;
}
- if(string_cmp_str(cmd, "rx_packet") == 0) {
+ if(furi_string_cmp_str(cmd, "rx_packet") == 0) {
bt_cli_command_packet_rx(cli, args, NULL);
break;
}
@@ -222,7 +222,7 @@ static void bt_cli(Cli* cli, string_t args, void* context) {
furi_hal_bt_start_advertising();
}
- string_clear(cmd);
+ furi_string_free(cmd);
furi_record_close(RECORD_BT);
}
diff --git a/applications/services/bt/bt_service/bt.c b/applications/services/bt/bt_service/bt.c
index bc80acc15..aeb2beec9 100644
--- a/applications/services/bt/bt_service/bt.c
+++ b/applications/services/bt/bt_service/bt.c
@@ -75,14 +75,14 @@ static void bt_pin_code_hide(Bt* bt) {
static bool bt_pin_code_verify_event_handler(Bt* bt, uint32_t pin) {
furi_assert(bt);
notification_message(bt->notification, &sequence_display_backlight_on);
- string_t pin_str;
+ FuriString* pin_str;
dialog_message_set_icon(bt->dialog_message, &I_BLE_Pairing_128x64, 0, 0);
- string_init_printf(pin_str, "Verify code\n%06d", pin);
+ pin_str = furi_string_alloc_printf("Verify code\n%06ld", pin);
dialog_message_set_text(
- bt->dialog_message, string_get_cstr(pin_str), 64, 4, AlignCenter, AlignTop);
+ bt->dialog_message, furi_string_get_cstr(pin_str), 64, 4, AlignCenter, AlignTop);
dialog_message_set_buttons(bt->dialog_message, "Cancel", "OK", NULL);
DialogMessageButton button = dialog_message_show(bt->dialogs, bt->dialog_message);
- string_clear(pin_str);
+ furi_string_free(pin_str);
return button == DialogMessageButtonCenter;
}
@@ -277,7 +277,7 @@ static bool bt_on_gap_event_callback(GapEvent event, void* context) {
static void bt_on_key_storage_change_callback(uint8_t* addr, uint16_t size, void* context) {
furi_assert(context);
Bt* bt = context;
- FURI_LOG_I(TAG, "Changed addr start: %08lX, size changed: %d", addr, size);
+ FURI_LOG_I(TAG, "Changed addr start: %p, size changed: %d", addr, size);
BtMessage message = {.type = BtMessageTypeKeysStorageUpdated};
furi_check(
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
diff --git a/applications/services/cli/cli.c b/applications/services/cli/cli.c
index e554ac898..f29dca9ce 100644
--- a/applications/services/cli/cli.c
+++ b/applications/services/cli/cli.c
@@ -11,8 +11,8 @@ Cli* cli_alloc() {
CliCommandTree_init(cli->commands);
- string_init(cli->last_line);
- string_init(cli->line);
+ cli->last_line = furi_string_alloc();
+ cli->line = furi_string_alloc();
cli->session = NULL;
@@ -138,34 +138,26 @@ void cli_nl(Cli* cli) {
void cli_prompt(Cli* cli) {
UNUSED(cli);
- printf("\r\n>: %s", string_get_cstr(cli->line));
+ printf("\r\n>: %s", furi_string_get_cstr(cli->line));
fflush(stdout);
}
void cli_reset(Cli* cli) {
// cli->last_line is cleared and cli->line's buffer moved to cli->last_line
- string_move(cli->last_line, cli->line);
+ furi_string_move(cli->last_line, cli->line);
// Reiniting cli->line
- string_init(cli->line);
+ cli->line = furi_string_alloc();
cli->cursor_position = 0;
}
static void cli_handle_backspace(Cli* cli) {
if(cli->cursor_position > 0) {
- furi_assert(string_size(cli->line) > 0);
+ furi_assert(furi_string_size(cli->line) > 0);
// Other side
printf("\e[D\e[1P");
fflush(stdout);
// Our side
- string_t temp;
- string_init(temp);
- string_reserve(temp, string_size(cli->line) - 1);
- string_set_strn(temp, string_get_cstr(cli->line), cli->cursor_position - 1);
- string_cat_str(temp, string_get_cstr(cli->line) + cli->cursor_position);
-
- // cli->line is cleared and temp's buffer moved to cli->line
- string_move(cli->line, temp);
- // NO MEMORY LEAK, STOP REPORTING IT
+ furi_string_replace_at(cli->line, cli->cursor_position - 1, 1, "");
cli->cursor_position--;
} else {
@@ -174,11 +166,11 @@ static void cli_handle_backspace(Cli* cli) {
}
static void cli_normalize_line(Cli* cli) {
- string_strim(cli->line);
- cli->cursor_position = string_size(cli->line);
+ furi_string_trim(cli->line);
+ cli->cursor_position = furi_string_size(cli->line);
}
-static void cli_execute_command(Cli* cli, CliCommand* command, string_t args) {
+static void cli_execute_command(Cli* cli, CliCommand* command, FuriString* args) {
if(!(command->flags & CliCommandFlagInsomniaSafe)) {
furi_hal_power_insomnia_enter();
}
@@ -208,25 +200,25 @@ static void cli_execute_command(Cli* cli, CliCommand* command, string_t args) {
static void cli_handle_enter(Cli* cli) {
cli_normalize_line(cli);
- if(string_size(cli->line) == 0) {
+ if(furi_string_size(cli->line) == 0) {
cli_prompt(cli);
return;
}
// Command and args container
- string_t command;
- string_init(command);
- string_t args;
- string_init(args);
+ FuriString* command;
+ command = furi_string_alloc();
+ FuriString* args;
+ args = furi_string_alloc();
// Split command and args
- size_t ws = string_search_char(cli->line, ' ');
- if(ws == STRING_FAILURE) {
- string_set(command, cli->line);
+ size_t ws = furi_string_search_char(cli->line, ' ');
+ if(ws == FURI_STRING_FAILURE) {
+ furi_string_set(command, cli->line);
} else {
- string_set_n(command, cli->line, 0, ws);
- string_set_n(args, cli->line, ws, string_size(cli->line));
- string_strim(args);
+ furi_string_set_n(command, cli->line, 0, ws);
+ furi_string_set_n(args, cli->line, ws, furi_string_size(cli->line));
+ furi_string_trim(args);
}
// Search for command
@@ -244,7 +236,7 @@ static void cli_handle_enter(Cli* cli) {
cli_nl(cli);
printf(
"`%s` command not found, use `help` or `?` to list all available commands",
- string_get_cstr(command));
+ furi_string_get_cstr(command));
cli_putc(cli, CliSymbolAsciiBell);
}
@@ -252,59 +244,59 @@ static void cli_handle_enter(Cli* cli) {
cli_prompt(cli);
// Cleanup command and args
- string_clear(command);
- string_clear(args);
+ furi_string_free(command);
+ furi_string_free(args);
}
static void cli_handle_autocomplete(Cli* cli) {
cli_normalize_line(cli);
- if(string_size(cli->line) == 0) {
+ if(furi_string_size(cli->line) == 0) {
return;
}
cli_nl(cli);
// Prepare common base for autocomplete
- string_t common;
- string_init(common);
+ FuriString* common;
+ common = furi_string_alloc();
// Iterate throw commands
for
M_EACH(cli_command, cli->commands, CliCommandTree_t) {
// Process only if starts with line buffer
- if(string_start_with_string_p(*cli_command->key_ptr, cli->line)) {
+ if(furi_string_start_with(*cli_command->key_ptr, cli->line)) {
// Show autocomplete option
- printf("%s\r\n", string_get_cstr(*cli_command->key_ptr));
+ printf("%s\r\n", furi_string_get_cstr(*cli_command->key_ptr));
// Process common base for autocomplete
- if(string_size(common) > 0) {
+ if(furi_string_size(common) > 0) {
// Choose shortest string
- const size_t key_size = string_size(*cli_command->key_ptr);
- const size_t common_size = string_size(common);
+ const size_t key_size = furi_string_size(*cli_command->key_ptr);
+ const size_t common_size = furi_string_size(common);
const size_t min_size = key_size > common_size ? common_size : key_size;
size_t i = 0;
while(i < min_size) {
// Stop when do not match
- if(string_get_char(*cli_command->key_ptr, i) !=
- string_get_char(common, i)) {
+ if(furi_string_get_char(*cli_command->key_ptr, i) !=
+ furi_string_get_char(common, i)) {
break;
}
i++;
}
// Cut right part if any
- string_left(common, i);
+ furi_string_left(common, i);
} else {
// Start with something
- string_set(common, *cli_command->key_ptr);
+ furi_string_set(common, *cli_command->key_ptr);
}
}
}
// Replace line buffer if autocomplete better
- if(string_size(common) > string_size(cli->line)) {
- string_set(cli->line, common);
- cli->cursor_position = string_size(cli->line);
+ if(furi_string_size(common) > furi_string_size(cli->line)) {
+ furi_string_set(cli->line, common);
+ cli->cursor_position = furi_string_size(cli->line);
}
// Cleanup
- string_clear(common);
+ furi_string_free(common);
// Show prompt
cli_prompt(cli);
}
@@ -312,16 +304,16 @@ static void cli_handle_autocomplete(Cli* cli) {
static void cli_handle_escape(Cli* cli, char c) {
if(c == 'A') {
// Use previous command if line buffer is empty
- if(string_size(cli->line) == 0 && string_cmp(cli->line, cli->last_line) != 0) {
+ if(furi_string_size(cli->line) == 0 && furi_string_cmp(cli->line, cli->last_line) != 0) {
// Set line buffer and cursor position
- string_set(cli->line, cli->last_line);
- cli->cursor_position = string_size(cli->line);
+ furi_string_set(cli->line, cli->last_line);
+ cli->cursor_position = furi_string_size(cli->line);
// Show new line to user
- printf("%s", string_get_cstr(cli->line));
+ printf("%s", furi_string_get_cstr(cli->line));
}
} else if(c == 'B') {
} else if(c == 'C') {
- if(cli->cursor_position < string_size(cli->line)) {
+ if(cli->cursor_position < furi_string_size(cli->line)) {
cli->cursor_position++;
printf("\e[C");
}
@@ -362,21 +354,13 @@ void cli_process_input(Cli* cli) {
} else if(in_chr == CliSymbolAsciiCR) {
cli_handle_enter(cli);
} else if(in_chr >= 0x20 && in_chr < 0x7F) {
- if(cli->cursor_position == string_size(cli->line)) {
- string_push_back(cli->line, in_chr);
+ if(cli->cursor_position == furi_string_size(cli->line)) {
+ furi_string_push_back(cli->line, in_chr);
cli_putc(cli, in_chr);
} else {
- // ToDo: better way?
- string_t temp;
- string_init(temp);
- string_reserve(temp, string_size(cli->line) + 1);
- string_set_strn(temp, string_get_cstr(cli->line), cli->cursor_position);
- string_push_back(temp, in_chr);
- string_cat_str(temp, string_get_cstr(cli->line) + cli->cursor_position);
-
- // cli->line is cleared and temp's buffer moved to cli->line
- string_move(cli->line, temp);
- // NO MEMORY LEAK, STOP REPORTING IT
+ // Insert character to line buffer
+ const char in_str[2] = {in_chr, 0};
+ furi_string_replace_at(cli->line, cli->cursor_position, 0, in_str);
// Print character in replace mode
printf("\e[4h%c\e[4l", in_chr);
@@ -394,14 +378,14 @@ void cli_add_command(
CliCommandFlag flags,
CliCallback callback,
void* context) {
- string_t name_str;
- string_init_set_str(name_str, name);
- string_strim(name_str);
+ FuriString* name_str;
+ name_str = furi_string_alloc_set(name);
+ furi_string_trim(name_str);
size_t name_replace;
do {
- name_replace = string_replace_str(name_str, " ", "_");
- } while(name_replace != STRING_FAILURE);
+ name_replace = furi_string_replace(name_str, " ", "_");
+ } while(name_replace != FURI_STRING_FAILURE);
CliCommand c;
c.callback = callback;
@@ -412,24 +396,24 @@ void cli_add_command(
CliCommandTree_set_at(cli->commands, name_str, c);
furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
- string_clear(name_str);
+ furi_string_free(name_str);
}
void cli_delete_command(Cli* cli, const char* name) {
- string_t name_str;
- string_init_set_str(name_str, name);
- string_strim(name_str);
+ FuriString* name_str;
+ name_str = furi_string_alloc_set(name);
+ furi_string_trim(name_str);
size_t name_replace;
do {
- name_replace = string_replace_str(name_str, " ", "_");
- } while(name_replace != STRING_FAILURE);
+ name_replace = furi_string_replace(name_str, " ", "_");
+ } while(name_replace != FURI_STRING_FAILURE);
furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
CliCommandTree_erase(cli->commands, name_str);
furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
- string_clear(name_str);
+ furi_string_free(name_str);
}
void cli_session_open(Cli* cli, void* session) {
diff --git a/applications/services/cli/cli.h b/applications/services/cli/cli.h
index 549e72cc5..09f54f056 100644
--- a/applications/services/cli/cli.h
+++ b/applications/services/cli/cli.h
@@ -4,8 +4,7 @@
*/
#pragma once
-
-#include
+#include
#ifdef __cplusplus
extern "C" {
@@ -43,7 +42,7 @@ typedef struct Cli Cli;
* @param args string with what was passed after command
* @param context pointer to whatever you gave us on cli_add_command
*/
-typedef void (*CliCallback)(Cli* cli, string_t args, void* context);
+typedef void (*CliCallback)(Cli* cli, FuriString* args, void* context);
/** Add cli command Registers you command callback
*
diff --git a/applications/services/cli/cli_command_gpio.c b/applications/services/cli/cli_command_gpio.c
index d5ec8d654..54671eda4 100644
--- a/applications/services/cli/cli_command_gpio.c
+++ b/applications/services/cli/cli_command_gpio.c
@@ -35,11 +35,11 @@ void cli_command_gpio_print_usage() {
printf("\tread \t - Read gpio value\r\n");
}
-static bool pin_name_to_int(string_t pin_name, size_t* result) {
+static bool pin_name_to_int(FuriString* pin_name, size_t* result) {
bool found = false;
bool debug = furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug);
for(size_t i = 0; i < COUNT_OF(cli_command_gpio_pins); i++) {
- if(!string_cmp(pin_name, cli_command_gpio_pins[i].name)) {
+ if(!furi_string_cmp(pin_name, cli_command_gpio_pins[i].name)) {
if(!cli_command_gpio_pins[i].debug || (cli_command_gpio_pins[i].debug && debug)) {
*result = i;
found = true;
@@ -63,29 +63,29 @@ static void gpio_print_pins(void) {
typedef enum { OK, ERR_CMD_SYNTAX, ERR_PIN, ERR_VALUE } GpioParseError;
-static GpioParseError gpio_command_parse(string_t args, size_t* pin_num, uint8_t* value) {
- string_t pin_name;
- string_init(pin_name);
+static GpioParseError gpio_command_parse(FuriString* args, size_t* pin_num, uint8_t* value) {
+ FuriString* pin_name;
+ pin_name = furi_string_alloc();
- size_t ws = string_search_char(args, ' ');
- if(ws == STRING_FAILURE) {
+ size_t ws = furi_string_search_char(args, ' ');
+ if(ws == FURI_STRING_FAILURE) {
return ERR_CMD_SYNTAX;
}
- string_set_n(pin_name, args, 0, ws);
- string_right(args, ws);
- string_strim(args);
+ furi_string_set_n(pin_name, args, 0, ws);
+ furi_string_right(args, ws);
+ furi_string_trim(args);
if(!pin_name_to_int(pin_name, pin_num)) {
- string_clear(pin_name);
+ furi_string_free(pin_name);
return ERR_PIN;
}
- string_clear(pin_name);
+ furi_string_free(pin_name);
- if(!string_cmp(args, "0")) {
+ if(!furi_string_cmp(args, "0")) {
*value = 0;
- } else if(!string_cmp(args, "1")) {
+ } else if(!furi_string_cmp(args, "1")) {
*value = 1;
} else {
return ERR_VALUE;
@@ -94,7 +94,7 @@ static GpioParseError gpio_command_parse(string_t args, size_t* pin_num, uint8_t
return OK;
}
-void cli_command_gpio_mode(Cli* cli, string_t args, void* context) {
+void cli_command_gpio_mode(Cli* cli, FuriString* args, void* context) {
UNUSED(cli);
UNUSED(context);
@@ -104,7 +104,7 @@ void cli_command_gpio_mode(Cli* cli, string_t args, void* context) {
GpioParseError err = gpio_command_parse(args, &num, &value);
if(ERR_CMD_SYNTAX == err) {
- cli_print_usage("gpio mode", " <0|1>", string_get_cstr(args));
+ cli_print_usage("gpio mode", " <0|1>", furi_string_get_cstr(args));
return;
} else if(ERR_PIN == err) {
gpio_print_pins();
@@ -134,7 +134,7 @@ void cli_command_gpio_mode(Cli* cli, string_t args, void* context) {
}
}
-void cli_command_gpio_read(Cli* cli, string_t args, void* context) {
+void cli_command_gpio_read(Cli* cli, FuriString* args, void* context) {
UNUSED(cli);
UNUSED(context);
@@ -156,7 +156,7 @@ void cli_command_gpio_read(Cli* cli, string_t args, void* context) {
printf("Pin %s <= %u", cli_command_gpio_pins[num].name, val);
}
-void cli_command_gpio_set(Cli* cli, string_t args, void* context) {
+void cli_command_gpio_set(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
size_t num = 0;
@@ -164,7 +164,7 @@ void cli_command_gpio_set(Cli* cli, string_t args, void* context) {
GpioParseError err = gpio_command_parse(args, &num, &value);
if(ERR_CMD_SYNTAX == err) {
- cli_print_usage("gpio set", " <0|1>", string_get_cstr(args));
+ cli_print_usage("gpio set", " <0|1>", furi_string_get_cstr(args));
return;
} else if(ERR_PIN == err) {
gpio_print_pins();
@@ -196,9 +196,9 @@ void cli_command_gpio_set(Cli* cli, string_t args, void* context) {
printf("Pin %s => %u", cli_command_gpio_pins[num].name, !!value);
}
-void cli_command_gpio(Cli* cli, string_t args, void* context) {
- string_t cmd;
- string_init(cmd);
+void cli_command_gpio(Cli* cli, FuriString* args, void* context) {
+ FuriString* cmd;
+ cmd = furi_string_alloc();
do {
if(!args_read_string_and_trim(args, cmd)) {
@@ -206,17 +206,17 @@ void cli_command_gpio(Cli* cli, string_t args, void* context) {
break;
}
- if(string_cmp_str(cmd, "mode") == 0) {
+ if(furi_string_cmp_str(cmd, "mode") == 0) {
cli_command_gpio_mode(cli, args, context);
break;
}
- if(string_cmp_str(cmd, "set") == 0) {
+ if(furi_string_cmp_str(cmd, "set") == 0) {
cli_command_gpio_set(cli, args, context);
break;
}
- if(string_cmp_str(cmd, "read") == 0) {
+ if(furi_string_cmp_str(cmd, "read") == 0) {
cli_command_gpio_read(cli, args, context);
break;
}
@@ -224,5 +224,5 @@ void cli_command_gpio(Cli* cli, string_t args, void* context) {
cli_command_gpio_print_usage();
} while(false);
- string_clear(cmd);
+ furi_string_free(cmd);
}
diff --git a/applications/services/cli/cli_command_gpio.h b/applications/services/cli/cli_command_gpio.h
index c9b908a08..7ae5aa625 100644
--- a/applications/services/cli/cli_command_gpio.h
+++ b/applications/services/cli/cli_command_gpio.h
@@ -2,4 +2,4 @@
#include "cli_i.h"
-void cli_command_gpio(Cli* cli, string_t args, void* context);
+void cli_command_gpio(Cli* cli, FuriString* args, void* context);
diff --git a/applications/services/cli/cli_commands.c b/applications/services/cli/cli_commands.c
index a6dd672fc..239434b7a 100644
--- a/applications/services/cli/cli_commands.c
+++ b/applications/services/cli/cli_commands.c
@@ -7,7 +7,6 @@
#include
#include
#include
-#include
// Close to ISO, `date +'%Y-%m-%d %H:%M:%S %u'`
#define CLI_DATE_FORMAT "%.4d-%.2d-%.2d %.2d:%.2d:%.2d %d"
@@ -22,13 +21,13 @@ void cli_command_device_info_callback(const char* key, const char* value, bool l
* Device Info Command
* This command is intended to be used by humans
*/
-void cli_command_device_info(Cli* cli, string_t args, void* context) {
+void cli_command_device_info(Cli* cli, FuriString* args, void* context) {
UNUSED(cli);
UNUSED(args);
furi_hal_info_get(cli_command_device_info_callback, context);
}
-void cli_command_help(Cli* cli, string_t args, void* context) {
+void cli_command_help(Cli* cli, FuriString* args, void* context) {
UNUSED(args);
UNUSED(context);
printf("Commands we have:");
@@ -49,34 +48,34 @@ void cli_command_help(Cli* cli, string_t args, void* context) {
printf("\r\n");
// Left Column
if(!CliCommandTree_end_p(it_left)) {
- printf("%-30s", string_get_cstr(*CliCommandTree_ref(it_left)->key_ptr));
+ printf("%-30s", furi_string_get_cstr(*CliCommandTree_ref(it_left)->key_ptr));
CliCommandTree_next(it_left);
}
// Right Column
if(!CliCommandTree_end_p(it_right)) {
- printf("%s", string_get_cstr(*CliCommandTree_ref(it_right)->key_ptr));
+ printf("%s", furi_string_get_cstr(*CliCommandTree_ref(it_right)->key_ptr));
CliCommandTree_next(it_right);
}
};
- if(string_size(args) > 0) {
+ if(furi_string_size(args) > 0) {
cli_nl();
printf("Also I have no clue what '");
- printf("%s", string_get_cstr(args));
+ printf("%s", furi_string_get_cstr(args));
printf("' is.");
}
}
-void cli_command_date(Cli* cli, string_t args, void* context) {
+void cli_command_date(Cli* cli, FuriString* args, void* context) {
UNUSED(cli);
UNUSED(context);
FuriHalRtcDateTime datetime = {0};
- if(string_size(args) > 0) {
+ if(furi_string_size(args) > 0) {
uint16_t hours, minutes, seconds, month, day, year, weekday;
int ret = sscanf(
- string_get_cstr(args),
+ furi_string_get_cstr(args),
"%hu-%hu-%hu %hu:%hu:%hu %hu",
&year,
&month,
@@ -101,7 +100,7 @@ void cli_command_date(Cli* cli, string_t args, void* context) {
"Invalid datetime format, use `%s`. sscanf %d %s",
"%Y-%m-%d %H:%M:%S %u",
ret,
- string_get_cstr(args));
+ furi_string_get_cstr(args));
return;
}
@@ -140,97 +139,128 @@ void cli_command_date(Cli* cli, string_t args, void* context) {
#define CLI_COMMAND_LOG_BUFFER_SIZE 64
void cli_command_log_tx_callback(const uint8_t* buffer, size_t size, void* context) {
- xStreamBufferSend(context, buffer, size, 0);
+ furi_stream_buffer_send(context, buffer, size, 0);
}
-void cli_command_log(Cli* cli, string_t args, void* context) {
- UNUSED(args);
+void cli_command_log_level_set_from_string(FuriString* level) {
+ if(furi_string_cmpi_str(level, "default") == 0) {
+ furi_log_set_level(FuriLogLevelDefault);
+ } else if(furi_string_cmpi_str(level, "none") == 0) {
+ furi_log_set_level(FuriLogLevelNone);
+ } else if(furi_string_cmpi_str(level, "error") == 0) {
+ furi_log_set_level(FuriLogLevelError);
+ } else if(furi_string_cmpi_str(level, "warn") == 0) {
+ furi_log_set_level(FuriLogLevelWarn);
+ } else if(furi_string_cmpi_str(level, "info") == 0) {
+ furi_log_set_level(FuriLogLevelInfo);
+ } else if(furi_string_cmpi_str(level, "debug") == 0) {
+ furi_log_set_level(FuriLogLevelDebug);
+ } else if(furi_string_cmpi_str(level, "trace") == 0) {
+ furi_log_set_level(FuriLogLevelTrace);
+ } else {
+ printf("Unknown log level\r\n");
+ }
+}
+
+void cli_command_log(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
- StreamBufferHandle_t ring = xStreamBufferCreate(CLI_COMMAND_LOG_RING_SIZE, 1);
+ FuriStreamBuffer* ring = furi_stream_buffer_alloc(CLI_COMMAND_LOG_RING_SIZE, 1);
uint8_t buffer[CLI_COMMAND_LOG_BUFFER_SIZE];
+ FuriLogLevel previous_level = furi_log_get_level();
+ bool restore_log_level = false;
+
+ if(furi_string_size(args) > 0) {
+ cli_command_log_level_set_from_string(args);
+ restore_log_level = true;
+ }
furi_hal_console_set_tx_callback(cli_command_log_tx_callback, ring);
printf("Press CTRL+C to stop...\r\n");
while(!cli_cmd_interrupt_received(cli)) {
- size_t ret = xStreamBufferReceive(ring, buffer, CLI_COMMAND_LOG_BUFFER_SIZE, 50);
+ size_t ret = furi_stream_buffer_receive(ring, buffer, CLI_COMMAND_LOG_BUFFER_SIZE, 50);
cli_write(cli, buffer, ret);
}
furi_hal_console_set_tx_callback(NULL, NULL);
- vStreamBufferDelete(ring);
+ if(restore_log_level) {
+ // There will be strange behaviour if log level is set from settings while log command is running
+ furi_log_set_level(previous_level);
+ }
+
+ furi_stream_buffer_free(ring);
}
-void cli_command_vibro(Cli* cli, string_t args, void* context) {
+void cli_command_vibro(Cli* cli, FuriString* args, void* context) {
UNUSED(cli);
UNUSED(context);
- if(!string_cmp(args, "0")) {
+ if(!furi_string_cmp(args, "0")) {
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
notification_message_block(notification, &sequence_reset_vibro);
furi_record_close(RECORD_NOTIFICATION);
- } else if(!string_cmp(args, "1")) {
+ } else if(!furi_string_cmp(args, "1")) {
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
notification_message_block(notification, &sequence_set_vibro_on);
furi_record_close(RECORD_NOTIFICATION);
} else {
- cli_print_usage("vibro", "<1|0>", string_get_cstr(args));
+ cli_print_usage("vibro", "<1|0>", furi_string_get_cstr(args));
}
}
-void cli_command_debug(Cli* cli, string_t args, void* context) {
+void cli_command_debug(Cli* cli, FuriString* args, void* context) {
UNUSED(cli);
UNUSED(context);
- if(!string_cmp(args, "0")) {
+ if(!furi_string_cmp(args, "0")) {
furi_hal_rtc_reset_flag(FuriHalRtcFlagDebug);
loader_update_menu();
printf("Debug disabled.");
- } else if(!string_cmp(args, "1")) {
+ } else if(!furi_string_cmp(args, "1")) {
furi_hal_rtc_set_flag(FuriHalRtcFlagDebug);
loader_update_menu();
printf("Debug enabled.");
} else {
- cli_print_usage("debug", "<1|0>", string_get_cstr(args));
+ cli_print_usage("debug", "<1|0>", furi_string_get_cstr(args));
}
}
-void cli_command_led(Cli* cli, string_t args, void* context) {
+void cli_command_led(Cli* cli, FuriString* args, void* context) {
UNUSED(cli);
UNUSED(context);
// Get first word as light name
NotificationMessage notification_led_message;
- string_t light_name;
- string_init(light_name);
- size_t ws = string_search_char(args, ' ');
- if(ws == STRING_FAILURE) {
- cli_print_usage("led", " <0-255>", string_get_cstr(args));
- string_clear(light_name);
+ FuriString* light_name;
+ light_name = furi_string_alloc();
+ size_t ws = furi_string_search_char(args, ' ');
+ if(ws == FURI_STRING_FAILURE) {
+ cli_print_usage("led", " <0-255>", furi_string_get_cstr(args));
+ furi_string_free(light_name);
return;
} else {
- string_set_n(light_name, args, 0, ws);
- string_right(args, ws);
- string_strim(args);
+ furi_string_set_n(light_name, args, 0, ws);
+ furi_string_right(args, ws);
+ furi_string_trim(args);
}
// Check light name
- if(!string_cmp(light_name, "r")) {
+ if(!furi_string_cmp(light_name, "r")) {
notification_led_message.type = NotificationMessageTypeLedRed;
- } else if(!string_cmp(light_name, "g")) {
+ } else if(!furi_string_cmp(light_name, "g")) {
notification_led_message.type = NotificationMessageTypeLedGreen;
- } else if(!string_cmp(light_name, "b")) {
+ } else if(!furi_string_cmp(light_name, "b")) {
notification_led_message.type = NotificationMessageTypeLedBlue;
- } else if(!string_cmp(light_name, "bl")) {
+ } else if(!furi_string_cmp(light_name, "bl")) {
notification_led_message.type = NotificationMessageTypeLedDisplayBacklight;
} else {
- cli_print_usage("led", " <0-255>", string_get_cstr(args));
- string_clear(light_name);
+ cli_print_usage("led", " <0-255>", furi_string_get_cstr(args));
+ furi_string_free(light_name);
return;
}
- string_clear(light_name);
+ furi_string_free(light_name);
// Read light value from the rest of the string
char* end_ptr;
- uint32_t value = strtoul(string_get_cstr(args), &end_ptr, 0);
+ uint32_t value = strtoul(furi_string_get_cstr(args), &end_ptr, 0);
if(!(value < 256 && *end_ptr == '\0')) {
- cli_print_usage("led", " <0-255>", string_get_cstr(args));
+ cli_print_usage("led", " <0-255>", furi_string_get_cstr(args));
return;
}
@@ -249,7 +279,7 @@ void cli_command_led(Cli* cli, string_t args, void* context) {
furi_record_close(RECORD_NOTIFICATION);
}
-void cli_command_ps(Cli* cli, string_t args, void* context) {
+void cli_command_ps(Cli* cli, FuriString* args, void* context) {
UNUSED(cli);
UNUSED(args);
UNUSED(context);
@@ -272,7 +302,7 @@ void cli_command_ps(Cli* cli, string_t args, void* context) {
printf("\r\nTotal: %d", thread_num);
}
-void cli_command_free(Cli* cli, string_t args, void* context) {
+void cli_command_free(Cli* cli, FuriString* args, void* context) {
UNUSED(cli);
UNUSED(args);
UNUSED(context);
@@ -286,7 +316,7 @@ void cli_command_free(Cli* cli, string_t args, void* context) {
printf("Maximum pool block: %d\r\n", memmgr_pool_get_max_block());
}
-void cli_command_free_blocks(Cli* cli, string_t args, void* context) {
+void cli_command_free_blocks(Cli* cli, FuriString* args, void* context) {
UNUSED(cli);
UNUSED(args);
UNUSED(context);
@@ -294,7 +324,7 @@ void cli_command_free_blocks(Cli* cli, string_t args, void* context) {
memmgr_heap_printf_free_blocks();
}
-void cli_command_i2c(Cli* cli, string_t args, void* context) {
+void cli_command_i2c(Cli* cli, FuriString* args, void* context) {
UNUSED(cli);
UNUSED(args);
UNUSED(context);
diff --git a/applications/services/cli/cli_i.h b/applications/services/cli/cli_i.h
index ba4582d0d..858cd0c8f 100644
--- a/applications/services/cli/cli_i.h
+++ b/applications/services/cli/cli_i.h
@@ -36,8 +36,8 @@ struct CliSession {
BPTREE_DEF2(
CliCommandTree,
CLI_COMMANDS_TREE_RANK,
- string_t,
- STRING_OPLIST,
+ FuriString*,
+ FURI_STRING_OPLIST,
CliCommand,
M_POD_OPLIST)
@@ -47,8 +47,8 @@ struct Cli {
CliCommandTree_t commands;
FuriMutex* mutex;
FuriSemaphore* idle_sem;
- string_t last_line;
- string_t line;
+ FuriString* last_line;
+ FuriString* line;
CliSession* session;
size_t cursor_position;
diff --git a/applications/services/cli/cli_vcp.c b/applications/services/cli/cli_vcp.c
index f2893a48b..1e27e185b 100644
--- a/applications/services/cli/cli_vcp.c
+++ b/applications/services/cli/cli_vcp.c
@@ -1,7 +1,6 @@
#include
#include
#include
-#include
#include "cli_i.h"
#define TAG "CliVcp"
@@ -29,8 +28,8 @@ typedef enum {
typedef struct {
FuriThread* thread;
- StreamBufferHandle_t tx_stream;
- StreamBufferHandle_t rx_stream;
+ FuriStreamBuffer* tx_stream;
+ FuriStreamBuffer* rx_stream;
volatile bool connected;
volatile bool running;
@@ -62,8 +61,8 @@ static const uint8_t ascii_eot = 0x04;
static void cli_vcp_init() {
if(vcp == NULL) {
vcp = malloc(sizeof(CliVcp));
- vcp->tx_stream = xStreamBufferCreate(VCP_TX_BUF_SIZE, 1);
- vcp->rx_stream = xStreamBufferCreate(VCP_RX_BUF_SIZE, 1);
+ vcp->tx_stream = furi_stream_buffer_alloc(VCP_TX_BUF_SIZE, 1);
+ vcp->rx_stream = furi_stream_buffer_alloc(VCP_RX_BUF_SIZE, 1);
}
furi_assert(vcp->thread == NULL);
@@ -113,7 +112,7 @@ static int32_t vcp_worker(void* context) {
#endif
if(vcp->connected == false) {
vcp->connected = true;
- xStreamBufferSend(vcp->rx_stream, &ascii_soh, 1, FuriWaitForever);
+ furi_stream_buffer_send(vcp->rx_stream, &ascii_soh, 1, FuriWaitForever);
}
}
@@ -124,8 +123,8 @@ static int32_t vcp_worker(void* context) {
#endif
if(vcp->connected == true) {
vcp->connected = false;
- xStreamBufferReceive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0);
- xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, FuriWaitForever);
+ furi_stream_buffer_receive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0);
+ furi_stream_buffer_send(vcp->rx_stream, &ascii_eot, 1, FuriWaitForever);
}
}
@@ -134,7 +133,7 @@ static int32_t vcp_worker(void* context) {
#ifdef CLI_VCP_DEBUG
FURI_LOG_D(TAG, "StreamRx");
#endif
- if(xStreamBufferSpacesAvailable(vcp->rx_stream) >= USB_CDC_PKT_LEN) {
+ if(furi_stream_buffer_spaces_available(vcp->rx_stream) >= USB_CDC_PKT_LEN) {
flags |= VcpEvtRx;
missed_rx--;
}
@@ -142,14 +141,15 @@ static int32_t vcp_worker(void* context) {
// New data received
if(flags & VcpEvtRx) {
- if(xStreamBufferSpacesAvailable(vcp->rx_stream) >= USB_CDC_PKT_LEN) {
+ if(furi_stream_buffer_spaces_available(vcp->rx_stream) >= USB_CDC_PKT_LEN) {
int32_t len = furi_hal_cdc_receive(VCP_IF_NUM, vcp->data_buffer, USB_CDC_PKT_LEN);
#ifdef CLI_VCP_DEBUG
FURI_LOG_D(TAG, "Rx %d", len);
#endif
if(len > 0) {
furi_check(
- xStreamBufferSend(vcp->rx_stream, vcp->data_buffer, len, FuriWaitForever) ==
+ furi_stream_buffer_send(
+ vcp->rx_stream, vcp->data_buffer, len, FuriWaitForever) ==
(size_t)len);
}
} else {
@@ -173,7 +173,7 @@ static int32_t vcp_worker(void* context) {
// CDC write transfer done
if(flags & VcpEvtTx) {
size_t len =
- xStreamBufferReceive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0);
+ furi_stream_buffer_receive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0);
#ifdef CLI_VCP_DEBUG
FURI_LOG_D(TAG, "Tx %d", len);
#endif
@@ -202,8 +202,8 @@ static int32_t vcp_worker(void* context) {
furi_hal_usb_unlock();
furi_hal_usb_set_config(vcp->usb_if_prev, NULL);
}
- xStreamBufferReceive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0);
- xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, FuriWaitForever);
+ furi_stream_buffer_receive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0);
+ furi_stream_buffer_send(vcp->rx_stream, &ascii_eot, 1, FuriWaitForever);
break;
}
}
@@ -229,7 +229,7 @@ static size_t cli_vcp_rx(uint8_t* buffer, size_t size, uint32_t timeout) {
size_t batch_size = size;
if(batch_size > VCP_RX_BUF_SIZE) batch_size = VCP_RX_BUF_SIZE;
- size_t len = xStreamBufferReceive(vcp->rx_stream, buffer, batch_size, timeout);
+ size_t len = furi_stream_buffer_receive(vcp->rx_stream, buffer, batch_size, timeout);
#ifdef CLI_VCP_DEBUG
FURI_LOG_D(TAG, "rx %u ", batch_size);
#endif
@@ -262,7 +262,7 @@ static void cli_vcp_tx(const uint8_t* buffer, size_t size) {
size_t batch_size = size;
if(batch_size > USB_CDC_PKT_LEN) batch_size = USB_CDC_PKT_LEN;
- xStreamBufferSend(vcp->tx_stream, buffer, batch_size, FuriWaitForever);
+ furi_stream_buffer_send(vcp->tx_stream, buffer, batch_size, FuriWaitForever);
furi_thread_flags_set(furi_thread_get_id(vcp->thread), VcpEvtStreamTx);
#ifdef CLI_VCP_DEBUG
FURI_LOG_D(TAG, "tx %u", batch_size);
diff --git a/applications/services/crypto/crypto_cli.c b/applications/services/crypto/crypto_cli.c
index 26e1fb9c0..a64a3ad0b 100644
--- a/applications/services/crypto/crypto_cli.c
+++ b/applications/services/crypto/crypto_cli.c
@@ -17,7 +17,7 @@ void crypto_cli_print_usage() {
"\tstore_key \t - Store key in secure enclave. !!! NON-REVERSABLE OPERATION - READ MANUAL FIRST !!!\r\n");
};
-void crypto_cli_encrypt(Cli* cli, string_t args) {
+void crypto_cli_encrypt(Cli* cli, FuriString* args) {
int key_slot = 0;
bool key_loaded = false;
uint8_t iv[16];
@@ -41,8 +41,8 @@ void crypto_cli_encrypt(Cli* cli, string_t args) {
printf("Enter plain text and press Ctrl+C to complete encryption:\r\n");
- string_t input;
- string_init(input);
+ FuriString* input;
+ input = furi_string_alloc();
char c;
while(cli_read(cli, (uint8_t*)&c, 1) == 1) {
if(c == CliSymbolAsciiETX) {
@@ -51,14 +51,14 @@ void crypto_cli_encrypt(Cli* cli, string_t args) {
} else if(c >= 0x20 && c < 0x7F) {
putc(c, stdout);
fflush(stdout);
- string_push_back(input, c);
+ furi_string_push_back(input, c);
} else if(c == CliSymbolAsciiCR) {
printf("\r\n");
- string_cat_str(input, "\r\n");
+ furi_string_cat(input, "\r\n");
}
}
- size_t size = string_size(input);
+ size_t size = furi_string_size(input);
if(size > 0) {
// C-string null termination and block alignments
size++;
@@ -66,9 +66,10 @@ void crypto_cli_encrypt(Cli* cli, string_t args) {
if(remain) {
size = size - remain + 16;
}
- string_reserve(input, size);
+ furi_string_reserve(input, size);
uint8_t* output = malloc(size);
- if(!furi_hal_crypto_encrypt((const uint8_t*)string_get_cstr(input), output, size)) {
+ if(!furi_hal_crypto_encrypt(
+ (const uint8_t*)furi_string_get_cstr(input), output, size)) {
printf("Failed to encrypt input");
} else {
printf("Hex-encoded encrypted data:\r\n");
@@ -83,7 +84,7 @@ void crypto_cli_encrypt(Cli* cli, string_t args) {
printf("No input");
}
- string_clear(input);
+ furi_string_free(input);
} while(0);
if(key_loaded) {
@@ -91,7 +92,7 @@ void crypto_cli_encrypt(Cli* cli, string_t args) {
}
}
-void crypto_cli_decrypt(Cli* cli, string_t args) {
+void crypto_cli_decrypt(Cli* cli, FuriString* args) {
int key_slot = 0;
bool key_loaded = false;
uint8_t iv[16];
@@ -115,8 +116,8 @@ void crypto_cli_decrypt(Cli* cli, string_t args) {
printf("Enter Hex-encoded data and press Ctrl+C to complete decryption:\r\n");
- string_t hex_input;
- string_init(hex_input);
+ FuriString* hex_input;
+ hex_input = furi_string_alloc();
char c;
while(cli_read(cli, (uint8_t*)&c, 1) == 1) {
if(c == CliSymbolAsciiETX) {
@@ -125,14 +126,14 @@ void crypto_cli_decrypt(Cli* cli, string_t args) {
} else if(c >= 0x20 && c < 0x7F) {
putc(c, stdout);
fflush(stdout);
- string_push_back(hex_input, c);
+ furi_string_push_back(hex_input, c);
} else if(c == CliSymbolAsciiCR) {
printf("\r\n");
}
}
- string_strim(hex_input);
- size_t hex_size = string_size(hex_input);
+ furi_string_trim(hex_input);
+ size_t hex_size = furi_string_size(hex_input);
if(hex_size > 0 && hex_size % 2 == 0) {
size_t size = hex_size / 2;
uint8_t* input = malloc(size);
@@ -155,7 +156,7 @@ void crypto_cli_decrypt(Cli* cli, string_t args) {
printf("Invalid or empty input");
}
- string_clear(hex_input);
+ furi_string_free(hex_input);
} while(0);
if(key_loaded) {
@@ -163,7 +164,7 @@ void crypto_cli_decrypt(Cli* cli, string_t args) {
}
}
-void crypto_cli_has_key(Cli* cli, string_t args) {
+void crypto_cli_has_key(Cli* cli, FuriString* args) {
UNUSED(cli);
int key_slot = 0;
uint8_t iv[16];
@@ -185,12 +186,12 @@ void crypto_cli_has_key(Cli* cli, string_t args) {
} while(0);
}
-void crypto_cli_store_key(Cli* cli, string_t args) {
+void crypto_cli_store_key(Cli* cli, FuriString* args) {
UNUSED(cli);
int key_slot = 0;
int key_size = 0;
- string_t key_type;
- string_init(key_type);
+ FuriString* key_type;
+ key_type = furi_string_alloc();
uint8_t data[32 + 12] = {};
FuriHalCryptoKey key;
@@ -207,19 +208,19 @@ void crypto_cli_store_key(Cli* cli, string_t args) {
break;
}
- if(string_cmp_str(key_type, "master") == 0) {
+ if(furi_string_cmp_str(key_type, "master") == 0) {
if(key_slot != 0) {
printf("Master keyslot must be is 0");
break;
}
key.type = FuriHalCryptoKeyTypeMaster;
- } else if(string_cmp_str(key_type, "simple") == 0) {
+ } else if(furi_string_cmp_str(key_type, "simple") == 0) {
if(key_slot < 1 || key_slot > 99) {
printf("Simple keyslot must be in range");
break;
}
key.type = FuriHalCryptoKeyTypeSimple;
- } else if(string_cmp_str(key_type, "encrypted") == 0) {
+ } else if(furi_string_cmp_str(key_type, "encrypted") == 0) {
key.type = FuriHalCryptoKeyTypeEncrypted;
data_size += 12;
} else {
@@ -275,13 +276,13 @@ void crypto_cli_store_key(Cli* cli, string_t args) {
}
} while(0);
- string_clear(key_type);
+ furi_string_free(key_type);
}
-static void crypto_cli(Cli* cli, string_t args, void* context) {
+static void crypto_cli(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
- string_t cmd;
- string_init(cmd);
+ FuriString* cmd;
+ cmd = furi_string_alloc();
do {
if(!args_read_string_and_trim(args, cmd)) {
@@ -289,22 +290,22 @@ static void crypto_cli(Cli* cli, string_t args, void* context) {
break;
}
- if(string_cmp_str(cmd, "encrypt") == 0) {
+ if(furi_string_cmp_str(cmd, "encrypt") == 0) {
crypto_cli_encrypt(cli, args);
break;
}
- if(string_cmp_str(cmd, "decrypt") == 0) {
+ if(furi_string_cmp_str(cmd, "decrypt") == 0) {
crypto_cli_decrypt(cli, args);
break;
}
- if(string_cmp_str(cmd, "has_key") == 0) {
+ if(furi_string_cmp_str(cmd, "has_key") == 0) {
crypto_cli_has_key(cli, args);
break;
}
- if(string_cmp_str(cmd, "store_key") == 0) {
+ if(furi_string_cmp_str(cmd, "store_key") == 0) {
crypto_cli_store_key(cli, args);
break;
}
@@ -312,7 +313,7 @@ static void crypto_cli(Cli* cli, string_t args, void* context) {
crypto_cli_print_usage();
} while(false);
- string_clear(cmd);
+ furi_string_free(cmd);
}
void crypto_on_system_start() {
diff --git a/applications/services/desktop/animations/animation_manager.c b/applications/services/desktop/animations/animation_manager.c
index 1e2a521e1..36c5b3975 100644
--- a/applications/services/desktop/animations/animation_manager.c
+++ b/applications/services/desktop/animations/animation_manager.c
@@ -2,7 +2,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -50,7 +49,7 @@ struct AnimationManager {
AnimationManagerSetNewIdleAnimationCallback new_idle_callback;
AnimationManagerSetNewIdleAnimationCallback check_blocking_callback;
void* context;
- string_t freezed_animation_name;
+ FuriString* freezed_animation_name;
int32_t freezed_animation_time_left;
ViewStack* view_stack;
};
@@ -279,7 +278,7 @@ AnimationManager* animation_manager_alloc(void) {
animation_manager->view_stack = view_stack_alloc();
View* animation_view = bubble_animation_get_view(animation_manager->animation_view);
view_stack_add_view(animation_manager->view_stack, animation_view);
- string_init(animation_manager->freezed_animation_name);
+ animation_manager->freezed_animation_name = furi_string_alloc();
animation_manager->idle_animation_timer =
furi_timer_alloc(animation_manager_timer_callback, FuriTimerTypeOnce, animation_manager);
@@ -317,7 +316,7 @@ void animation_manager_free(AnimationManager* animation_manager) {
storage_get_pubsub(storage), animation_manager->pubsub_subscription_storage);
furi_record_close(RECORD_STORAGE);
- string_clear(animation_manager->freezed_animation_name);
+ furi_string_free(animation_manager->freezed_animation_name);
View* animation_view = bubble_animation_get_view(animation_manager->animation_view);
view_stack_remove_view(animation_manager->view_stack, animation_view);
bubble_animation_view_free(animation_manager->animation_view);
@@ -433,7 +432,7 @@ bool animation_manager_is_animation_loaded(AnimationManager* animation_manager)
void animation_manager_unload_and_stall_animation(AnimationManager* animation_manager) {
furi_assert(animation_manager);
furi_assert(animation_manager->current_animation);
- furi_assert(!string_size(animation_manager->freezed_animation_name));
+ furi_assert(!furi_string_size(animation_manager->freezed_animation_name));
furi_assert(
(animation_manager->state == AnimationManagerStateIdle) ||
(animation_manager->state == AnimationManagerStateBlocked));
@@ -461,7 +460,7 @@ void animation_manager_unload_and_stall_animation(AnimationManager* animation_ma
StorageAnimationManifestInfo* meta =
animation_storage_get_meta(animation_manager->current_animation);
/* copy str, not move, because it can be internal animation */
- string_set_str(animation_manager->freezed_animation_name, meta->name);
+ furi_string_set(animation_manager->freezed_animation_name, meta->name);
bubble_animation_freeze(animation_manager->animation_view);
animation_storage_free_storage_animation(&animation_manager->current_animation);
@@ -470,14 +469,14 @@ void animation_manager_unload_and_stall_animation(AnimationManager* animation_ma
void animation_manager_load_and_continue_animation(AnimationManager* animation_manager) {
furi_assert(animation_manager);
furi_assert(!animation_manager->current_animation);
- furi_assert(string_size(animation_manager->freezed_animation_name));
+ furi_assert(furi_string_size(animation_manager->freezed_animation_name));
furi_assert(
(animation_manager->state == AnimationManagerStateFreezedIdle) ||
(animation_manager->state == AnimationManagerStateFreezedBlocked));
if(animation_manager->state == AnimationManagerStateFreezedBlocked) {
StorageAnimation* restore_animation = animation_storage_find_animation(
- string_get_cstr(animation_manager->freezed_animation_name));
+ furi_string_get_cstr(animation_manager->freezed_animation_name));
/* all blocked animations must be in flipper -> we can
* always find blocking animation */
furi_assert(restore_animation);
@@ -489,7 +488,7 @@ void animation_manager_load_and_continue_animation(AnimationManager* animation_m
if(!blocked) {
/* if no blocking - try restore last one idle */
StorageAnimation* restore_animation = animation_storage_find_animation(
- string_get_cstr(animation_manager->freezed_animation_name));
+ furi_string_get_cstr(animation_manager->freezed_animation_name));
if(restore_animation) {
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
DolphinStats stats = dolphin_stats(dolphin);
@@ -517,7 +516,7 @@ void animation_manager_load_and_continue_animation(AnimationManager* animation_m
FURI_LOG_E(
TAG,
"Failed to restore \'%s\'",
- string_get_cstr(animation_manager->freezed_animation_name));
+ furi_string_get_cstr(animation_manager->freezed_animation_name));
}
}
} else {
@@ -535,7 +534,7 @@ void animation_manager_load_and_continue_animation(AnimationManager* animation_m
animation_storage_get_meta(animation_manager->current_animation)->name);
bubble_animation_unfreeze(animation_manager->animation_view);
- string_reset(animation_manager->freezed_animation_name);
+ furi_string_reset(animation_manager->freezed_animation_name);
furi_assert(animation_manager->current_animation);
}
diff --git a/applications/services/desktop/animations/animation_storage.c b/applications/services/desktop/animations/animation_storage.c
index e0c6bf411..0727fd6ae 100644
--- a/applications/services/desktop/animations/animation_storage.c
+++ b/applications/services/desktop/animations/animation_storage.c
@@ -5,7 +5,6 @@
#include
#include
#include
-#include
#include "animation_manager.h"
#include "animation_storage.h"
@@ -32,8 +31,8 @@ static bool animation_storage_load_single_manifest_info(
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* file = flipper_format_file_alloc(storage);
flipper_format_set_strict_mode(file, true);
- string_t read_string;
- string_init(read_string);
+ FuriString* read_string;
+ read_string = furi_string_alloc();
do {
uint32_t u32value;
@@ -41,20 +40,20 @@ static bool animation_storage_load_single_manifest_info(
if(!flipper_format_file_open_existing(file, ANIMATION_MANIFEST_FILE)) break;
if(!flipper_format_read_header(file, read_string, &u32value)) break;
- if(string_cmp_str(read_string, "Flipper Animation Manifest")) break;
+ if(furi_string_cmp_str(read_string, "Flipper Animation Manifest")) break;
manifest_info->name = NULL;
/* skip other animation names */
flipper_format_set_strict_mode(file, false);
while(flipper_format_read_string(file, "Name", read_string) &&
- string_cmp_str(read_string, name))
+ furi_string_cmp_str(read_string, name))
;
- if(string_cmp_str(read_string, name)) break;
+ if(furi_string_cmp_str(read_string, name)) break;
flipper_format_set_strict_mode(file, true);
- manifest_info->name = malloc(string_size(read_string) + 1);
- strcpy((char*)manifest_info->name, string_get_cstr(read_string));
+ manifest_info->name = malloc(furi_string_size(read_string) + 1);
+ strcpy((char*)manifest_info->name, furi_string_get_cstr(read_string));
if(!flipper_format_read_uint32(file, "Min butthurt", &u32value, 1)) break;
manifest_info->min_butthurt = u32value;
@@ -72,7 +71,7 @@ static bool animation_storage_load_single_manifest_info(
if(!result && manifest_info->name) {
free((void*)manifest_info->name);
}
- string_clear(read_string);
+ furi_string_free(read_string);
flipper_format_free(file);
furi_record_close(RECORD_STORAGE);
@@ -88,8 +87,8 @@ void animation_storage_fill_animation_list(StorageAnimationList_t* animation_lis
FlipperFormat* file = flipper_format_file_alloc(storage);
/* Forbid skipping fields */
flipper_format_set_strict_mode(file, true);
- string_t read_string;
- string_init(read_string);
+ FuriString* read_string;
+ read_string = furi_string_alloc();
do {
uint32_t u32value;
@@ -98,7 +97,7 @@ void animation_storage_fill_animation_list(StorageAnimationList_t* animation_lis
if(FSE_OK != storage_sd_status(storage)) break;
if(!flipper_format_file_open_existing(file, ANIMATION_MANIFEST_FILE)) break;
if(!flipper_format_read_header(file, read_string, &u32value)) break;
- if(string_cmp_str(read_string, "Flipper Animation Manifest")) break;
+ if(furi_string_cmp_str(read_string, "Flipper Animation Manifest")) break;
do {
storage_animation = malloc(sizeof(StorageAnimation));
storage_animation->external = true;
@@ -106,8 +105,9 @@ void animation_storage_fill_animation_list(StorageAnimationList_t* animation_lis
storage_animation->manifest_info.name = NULL;
if(!flipper_format_read_string(file, "Name", read_string)) break;
- storage_animation->manifest_info.name = malloc(string_size(read_string) + 1);
- strcpy((char*)storage_animation->manifest_info.name, string_get_cstr(read_string));
+ storage_animation->manifest_info.name = malloc(furi_string_size(read_string) + 1);
+ strcpy(
+ (char*)storage_animation->manifest_info.name, furi_string_get_cstr(read_string));
if(!flipper_format_read_uint32(file, "Min butthurt", &u32value, 1)) break;
storage_animation->manifest_info.min_butthurt = u32value;
@@ -126,7 +126,7 @@ void animation_storage_fill_animation_list(StorageAnimationList_t* animation_lis
animation_storage_free_storage_animation(&storage_animation);
} while(0);
- string_clear(read_string);
+ furi_string_free(read_string);
flipper_format_free(file);
// add hard-coded animations
@@ -231,16 +231,16 @@ void animation_storage_free_storage_animation(StorageAnimation** storage_animati
*storage_animation = NULL;
}
-static bool animation_storage_cast_align(string_t align_str, Align* align) {
- if(!string_cmp_str(align_str, "Bottom")) {
+static bool animation_storage_cast_align(FuriString* align_str, Align* align) {
+ if(!furi_string_cmp(align_str, "Bottom")) {
*align = AlignBottom;
- } else if(!string_cmp_str(align_str, "Top")) {
+ } else if(!furi_string_cmp(align_str, "Top")) {
*align = AlignTop;
- } else if(!string_cmp_str(align_str, "Left")) {
+ } else if(!furi_string_cmp(align_str, "Left")) {
*align = AlignLeft;
- } else if(!string_cmp_str(align_str, "Right")) {
+ } else if(!furi_string_cmp(align_str, "Right")) {
*align = AlignRight;
- } else if(!string_cmp_str(align_str, "Center")) {
+ } else if(!furi_string_cmp(align_str, "Center")) {
*align = AlignCenter;
} else {
return false;
@@ -291,33 +291,35 @@ static bool animation_storage_load_frames(
bool frames_ok = false;
File* file = storage_file_alloc(storage);
FileInfo file_info;
- string_t filename;
- string_init(filename);
+ FuriString* filename;
+ filename = furi_string_alloc();
size_t max_filesize = ROUND_UP_TO(width, 8) * height + 1;
for(int i = 0; i < icon->frame_count; ++i) {
frames_ok = false;
- string_printf(filename, ANIMATION_DIR "/%s/frame_%d.bm", name, i);
+ furi_string_printf(filename, ANIMATION_DIR "/%s/frame_%d.bm", name, i);
- if(storage_common_stat(storage, string_get_cstr(filename), &file_info) != FSE_OK) break;
+ if(storage_common_stat(storage, furi_string_get_cstr(filename), &file_info) != FSE_OK)
+ break;
if(file_info.size > max_filesize) {
FURI_LOG_E(
TAG,
- "Filesize %d, max: %d (width %d, height %d)",
+ "Filesize %lld, max: %d (width %d, height %d)",
file_info.size,
max_filesize,
width,
height);
break;
}
- if(!storage_file_open(file, string_get_cstr(filename), FSAM_READ, FSOM_OPEN_EXISTING)) {
- FURI_LOG_E(TAG, "Can't open file \'%s\'", string_get_cstr(filename));
+ if(!storage_file_open(
+ file, furi_string_get_cstr(filename), FSAM_READ, FSOM_OPEN_EXISTING)) {
+ FURI_LOG_E(TAG, "Can't open file \'%s\'", furi_string_get_cstr(filename));
break;
}
FURI_CONST_ASSIGN_PTR(icon->frames[i], malloc(file_info.size));
if(storage_file_read(file, (void*)icon->frames[i], file_info.size) != file_info.size) {
- FURI_LOG_E(TAG, "Read failed: \'%s\'", string_get_cstr(filename));
+ FURI_LOG_E(TAG, "Read failed: \'%s\'", furi_string_get_cstr(filename));
break;
}
storage_file_close(file);
@@ -327,8 +329,8 @@ static bool animation_storage_load_frames(
if(!frames_ok) {
FURI_LOG_E(
TAG,
- "Load \'%s\' failed, %dx%d, size: %d",
- string_get_cstr(filename),
+ "Load \'%s\' failed, %dx%d, size: %lld",
+ furi_string_get_cstr(filename),
width,
height,
file_info.size);
@@ -341,15 +343,15 @@ static bool animation_storage_load_frames(
}
storage_file_free(file);
- string_clear(filename);
+ furi_string_free(filename);
return frames_ok;
}
static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFormat* ff) {
uint32_t u32value;
- string_t str;
- string_init(str);
+ FuriString* str;
+ str = furi_string_alloc();
bool success = false;
furi_assert(!animation->frame_bubble_sequences);
@@ -396,12 +398,12 @@ static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFo
FURI_CONST_ASSIGN(bubble->bubble.y, u32value);
if(!flipper_format_read_string(ff, "Text", str)) break;
- if(string_size(str) > 100) break;
+ if(furi_string_size(str) > 100) break;
- string_replace_all_str(str, "\\n", "\n");
+ furi_string_replace_all(str, "\\n", "\n");
- FURI_CONST_ASSIGN_PTR(bubble->bubble.text, malloc(string_size(str) + 1));
- strcpy((char*)bubble->bubble.text, string_get_cstr(str));
+ FURI_CONST_ASSIGN_PTR(bubble->bubble.text, malloc(furi_string_size(str) + 1));
+ strcpy((char*)bubble->bubble.text, furi_string_get_cstr(str));
if(!flipper_format_read_string(ff, "AlignH", str)) break;
if(!animation_storage_cast_align(str, (Align*)&bubble->bubble.align_h)) break;
@@ -423,7 +425,7 @@ static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFo
}
}
- string_clear(str);
+ furi_string_free(str);
return success;
}
@@ -438,8 +440,8 @@ static BubbleAnimation* animation_storage_load_animation(const char* name) {
FlipperFormat* ff = flipper_format_file_alloc(storage);
/* Forbid skipping fields */
flipper_format_set_strict_mode(ff, true);
- string_t str;
- string_init(str);
+ FuriString* str;
+ str = furi_string_alloc();
animation->frame_bubble_sequences = NULL;
bool success = false;
@@ -448,10 +450,10 @@ static BubbleAnimation* animation_storage_load_animation(const char* name) {
if(FSE_OK != storage_sd_status(storage)) break;
- string_printf(str, ANIMATION_DIR "/%s/" ANIMATION_META_FILE, name);
- if(!flipper_format_file_open_existing(ff, string_get_cstr(str))) break;
+ furi_string_printf(str, ANIMATION_DIR "/%s/" ANIMATION_META_FILE, name);
+ if(!flipper_format_file_open_existing(ff, furi_string_get_cstr(str))) break;
if(!flipper_format_read_header(ff, str, &u32value)) break;
- if(string_cmp_str(str, "Flipper Animation")) break;
+ if(furi_string_cmp_str(str, "Flipper Animation")) break;
if(!flipper_format_read_uint32(ff, "Width", &width, 1)) break;
if(!flipper_format_read_uint32(ff, "Height", &height, 1)) break;
@@ -492,7 +494,7 @@ static BubbleAnimation* animation_storage_load_animation(const char* name) {
success = true;
} while(0);
- string_clear(str);
+ furi_string_free(str);
flipper_format_free(ff);
if(u32array) {
free(u32array);
diff --git a/applications/services/desktop/animations/animation_storage.h b/applications/services/desktop/animations/animation_storage.h
index e53c1133f..16c0feab4 100644
--- a/applications/services/desktop/animations/animation_storage.h
+++ b/applications/services/desktop/animations/animation_storage.h
@@ -2,7 +2,6 @@
#include
#include
#include "views/bubble_animation_view.h"
-#include
/** Main structure to handle animation data.
* Contains all, including animation playing data (BubbleAnimation),
diff --git a/applications/services/desktop/scenes/desktop_scene_main.c b/applications/services/desktop/scenes/desktop_scene_main.c
index dc9ac04d0..c66ada158 100644
--- a/applications/services/desktop/scenes/desktop_scene_main.c
+++ b/applications/services/desktop/scenes/desktop_scene_main.c
@@ -165,8 +165,8 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
break;
}
case DesktopMainEventOpenGameMenu: {
- LoaderStatus status = loader_start(
- desktop->loader, "Applications", EXT_PATH("/apps/Games/snake_game.fap"));
+ LoaderStatus status =
+ loader_start(desktop->loader, "Applications", EXT_PATH("/apps/Games/Snake.fap"));
if(status != LoaderStatusOk) {
FURI_LOG_E(TAG, "loader_start failed: %d", status);
}
diff --git a/applications/services/dialogs/dialogs.h b/applications/services/dialogs/dialogs.h
index 2522c8b54..4e836e365 100644
--- a/applications/services/dialogs/dialogs.h
+++ b/applications/services/dialogs/dialogs.h
@@ -1,7 +1,6 @@
#pragma once
#include
#include
-#include "m-string.h"
#include
#ifdef __cplusplus
@@ -56,8 +55,8 @@ void dialog_file_browser_set_basic_options(
*/
bool dialog_file_browser_show(
DialogsApp* context,
- string_ptr result_path,
- string_ptr path,
+ FuriString* result_path,
+ FuriString* path,
const DialogsFileBrowserOptions* options);
/****************** MESSAGE ******************/
diff --git a/applications/services/dialogs/dialogs_api.c b/applications/services/dialogs/dialogs_api.c
index fd3b2e961..6fd51782d 100644
--- a/applications/services/dialogs/dialogs_api.c
+++ b/applications/services/dialogs/dialogs_api.c
@@ -1,14 +1,13 @@
#include "dialogs/dialogs_message.h"
#include "dialogs_i.h"
#include "dialogs_api_lock.h"
-#include "m-string.h"
/****************** File browser ******************/
bool dialog_file_browser_show(
DialogsApp* context,
- string_ptr result_path,
- string_ptr path,
+ FuriString* result_path,
+ FuriString* path,
const DialogsFileBrowserOptions* options) {
FuriApiLock lock = API_LOCK_INIT_LOCKED();
furi_check(lock != NULL);
diff --git a/applications/services/dialogs/dialogs_message.h b/applications/services/dialogs/dialogs_message.h
index 2dc66f133..91e040ce4 100644
--- a/applications/services/dialogs/dialogs_message.h
+++ b/applications/services/dialogs/dialogs_message.h
@@ -2,7 +2,6 @@
#include
#include "dialogs_i.h"
#include "dialogs_api_lock.h"
-#include "m-string.h"
#ifdef __cplusplus
extern "C" {
@@ -13,8 +12,8 @@ typedef struct {
bool skip_assets;
bool hide_ext;
const Icon* file_icon;
- string_ptr result_path;
- string_ptr preselected_filename;
+ FuriString* result_path;
+ FuriString* preselected_filename;
FileBrowserLoadItemCallback item_callback;
void* item_callback_context;
} DialogsAppMessageDataFileBrowser;
diff --git a/applications/services/dolphin/helpers/dolphin_state.c b/applications/services/dolphin/helpers/dolphin_state.c
index 95e2f42f4..10cb85c28 100644
--- a/applications/services/dolphin/helpers/dolphin_state.c
+++ b/applications/services/dolphin/helpers/dolphin_state.c
@@ -171,7 +171,7 @@ void dolphin_state_on_deed(DolphinState* dolphin_state, DolphinDeed deed) {
FURI_LOG_D(
TAG,
- "icounter %d, butthurt %d",
+ "icounter %ld, butthurt %ld",
dolphin_state->data.icounter,
dolphin_state->data.butthurt);
}
diff --git a/applications/services/gui/canvas.h b/applications/services/gui/canvas.h
index ccb8dc523..07ebe8960 100644
--- a/applications/services/gui/canvas.h
+++ b/applications/services/gui/canvas.h
@@ -62,7 +62,7 @@ typedef struct {
uint8_t descender;
} CanvasFontParameters;
-/** Canvas anonymouse structure */
+/** Canvas anonymous structure */
typedef struct Canvas Canvas;
/** Get Canvas width
@@ -298,7 +298,7 @@ void canvas_draw_disc(Canvas* canvas, uint8_t x, uint8_t y, uint8_t r);
* @param y y coordinate of base and height intersection
* @param base length of triangle side
* @param height length of triangle height
- * @param dir CanvasDirection triangle orientaion
+ * @param dir CanvasDirection triangle orientation
*/
void canvas_draw_triangle(
Canvas* canvas,
@@ -324,7 +324,7 @@ void canvas_draw_glyph(Canvas* canvas, uint8_t x, uint8_t y, uint16_t ch);
*/
void canvas_set_bitmap_mode(Canvas* canvas, bool alpha);
-/** Draw rounded-corner frame of width, height at x,y, with round value raduis
+/** Draw rounded-corner frame of width, height at x,y, with round value radius
*
* @param canvas Canvas instance
* @param x x coordinate
diff --git a/applications/services/gui/elements.c b/applications/services/gui/elements.c
index 58b446038..0f7cf73f4 100644
--- a/applications/services/gui/elements.c
+++ b/applications/services/gui/elements.c
@@ -8,7 +8,6 @@
#include
#include