This commit is contained in:
MX
2022-10-05 21:27:13 +03:00
parent 0796263e81
commit c60bfbf271
75 changed files with 936 additions and 917 deletions
@@ -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;
}
-1
View File
@@ -1,6 +1,5 @@
#ifndef sound_h
#define sound_h
#include <m-string.h>
#include <furi.h>
#include <furi_hal.h>
#include <stdint.h>
@@ -6,7 +6,6 @@
#include <gui/canvas_i.h>
#include <gui/gui.h>
#include <input/input.h>
//#include <m-string.h>
//#include <math.h>
//#include <notification/notification.h>
//#include <notification/notification_messages.h>
@@ -250,8 +249,8 @@ static int32_t uart_worker(void* context) {
#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) {
@@ -280,7 +279,7 @@ static int32_t uart_worker(void* context) {
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 +296,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
+4 -4
View File
@@ -55,8 +55,8 @@ 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->previous_scene = NoneScene;
flipfrid->current_scene = SceneEntryPoint;
@@ -95,8 +95,8 @@ 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);
free(flipfrid->data);
free(flipfrid->payload);
+4 -5
View File
@@ -4,7 +4,6 @@
#include <input/input.h>
#include <gui/gui.h>
#include <gui/modules/submenu.h>
#include <m-string.h>
#include <dialogs/dialogs.h>
#include <notification/notification.h>
#include <notification/notification_messages.h>
@@ -65,17 +64,17 @@ 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;
@@ -1,7 +1,7 @@
#include "flipfrid_scene_entrypoint.h"
string_t menu_items[4];
string_t menu_proto_items[4];
FuriString* menu_items[4];
FuriString* 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,19 +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;
string_set_str(context->proto_name, "PAC/Stanley");
furi_string_set(context->proto_name, "PAC/Stanley");
break;
case H10301:
context->proto = H10301;
string_set_str(context->proto_name, "H10301");
furi_string_set(context->proto_name, "H10301");
break;
default:
break;
@@ -65,33 +65,33 @@ void flipfrid_scene_entrypoint_on_enter(FlipFridState* context) {
context->menu_index = 0;
for(uint32_t i = 0; i < 4; i++) {
string_init(menu_items[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");
furi_string_set(menu_items[0], "Default Values");
furi_string_set(menu_items[1], "BF Customer ID");
furi_string_set(menu_items[2], "Load File");
furi_string_set(menu_items[3], "Load uids from file");
context->menu_proto_index = 0;
for(uint32_t i = 0; i < 4; i++) {
string_init(menu_proto_items[i]);
menu_proto_items[i] = furi_string_alloc();
}
string_set(menu_proto_items[0], "EM4100");
string_set(menu_proto_items[1], "HIDProx");
string_set(menu_proto_items[2], "PAC/Stanley");
string_set(menu_proto_items[3], "H10301");
furi_string_set(menu_proto_items[0], "EM4100");
furi_string_set(menu_proto_items[1], "HIDProx");
furi_string_set(menu_proto_items[2], "PAC/Stanley");
furi_string_set(menu_proto_items[3], "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(menu_items[i]);
}
for(uint32_t i = 0; i < 4; i++) {
string_clear(menu_proto_items[i]);
furi_string_free(menu_proto_items[i]);
}
}
@@ -151,12 +151,17 @@ void flipfrid_scene_entrypoint_on_draw(Canvas* canvas, FlipFridState* context) {
24,
AlignCenter,
AlignTop,
string_get_cstr(menu_items[context->menu_index - 1]));
furi_string_get_cstr(menu_items[context->menu_index - 1]));
}
canvas_set_font(canvas, FontPrimary);
canvas_draw_str_aligned(
canvas, 64, 36, AlignCenter, AlignTop, string_get_cstr(menu_items[context->menu_index]));
canvas,
64,
36,
AlignCenter,
AlignTop,
furi_string_get_cstr(menu_items[context->menu_index]));
if(context->menu_index < FlipFridAttackLoadFileCustomUids) {
canvas_set_font(canvas, FontSecondary);
@@ -166,7 +171,7 @@ void flipfrid_scene_entrypoint_on_draw(Canvas* canvas, FlipFridState* context) {
48,
AlignCenter,
AlignTop,
string_get_cstr(menu_items[context->menu_index + 1]));
furi_string_get_cstr(menu_items[context->menu_index + 1]));
}
if(context->menu_proto_index > EM4100) {
@@ -177,7 +182,7 @@ void flipfrid_scene_entrypoint_on_draw(Canvas* canvas, FlipFridState* context) {
-12,
AlignCenter,
AlignTop,
string_get_cstr(menu_proto_items[context->menu_proto_index - 1]));
furi_string_get_cstr(menu_proto_items[context->menu_proto_index - 1]));
}
canvas_set_font(canvas, FontPrimary);
@@ -190,7 +195,7 @@ void flipfrid_scene_entrypoint_on_draw(Canvas* canvas, FlipFridState* context) {
4,
AlignCenter,
AlignTop,
string_get_cstr(menu_proto_items[context->menu_proto_index]));
furi_string_get_cstr(menu_proto_items[context->menu_proto_index]));
canvas_set_font(canvas, FontPrimary);
canvas_draw_str_aligned(canvas, 101, 4, AlignCenter, AlignTop, ">");
@@ -203,6 +208,6 @@ void flipfrid_scene_entrypoint_on_draw(Canvas* canvas, FlipFridState* context) {
-12,
AlignCenter,
AlignTop,
string_get_cstr(menu_proto_items[context->menu_proto_index + 1]));
furi_string_get_cstr(menu_proto_items[context->menu_proto_index + 1]));
}
}
@@ -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;
}
@@ -8,61 +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(string_get_cstr(temp_str), "PAC/Stanley") != 0) {
if(strcmp(furi_string_get_cstr(temp_str), "PAC/Stanley") != 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 == H10301) {
if(strcmp(string_get_cstr(temp_str), "H10301") != 0) {
if(strcmp(furi_string_get_cstr(temp_str), "H10301") != 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(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;
}
}
@@ -71,38 +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(string_size(context->data_str) != 11) {
if(furi_string_size(context->data_str) != 11) {
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 == H10301) {
if(string_size(context->data_str) != 8) {
if(furi_string_size(context->data_str) != 8) {
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(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;
}
}
@@ -110,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);
}
@@ -119,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;
}
@@ -169,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);
@@ -181,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;
}
@@ -337,7 +337,7 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
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;
@@ -348,13 +348,13 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
end_of_list = true;
break;
};
if(string_get_char(context->data_str, 0) == '#') continue;
if(string_size(context->data_str) != 11) break;
if(furi_string_get_char(context->data_str, 0) == '#') continue;
if(furi_string_size(context->data_str) != 11) break;
break;
}
if(end_of_list) break;
FURI_LOG_D(TAG, string_get_cstr(context->data_str));
if(string_size(context->data_str) != 11) {
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;
@@ -366,8 +366,8 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
// 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);
}
@@ -375,7 +375,7 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
} else if(context->proto == PAC) {
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;
@@ -386,13 +386,13 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
end_of_list = true;
break;
};
if(string_get_char(context->data_str, 0) == '#') continue;
if(string_size(context->data_str) != 9) 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, string_get_cstr(context->data_str));
if(string_size(context->data_str) != 9) {
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;
@@ -404,8 +404,8 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
// string is valid, parse it in context->payload
for(uint8_t i = 0; i < 4; 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);
}
@@ -413,7 +413,7 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
} else if(context->proto == H10301) {
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;
@@ -424,13 +424,13 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
end_of_list = true;
break;
};
if(string_get_char(context->data_str, 0) == '#') continue;
if(string_size(context->data_str) != 7) 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, string_get_cstr(context->data_str));
if(string_size(context->data_str) != 7) {
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;
@@ -442,8 +442,8 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
// string is valid, parse it in context->payload
for(uint8_t i = 0; i < 3; 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);
}
@@ -451,7 +451,7 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
} 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;
@@ -462,13 +462,13 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
end_of_list = true;
break;
};
if(string_get_char(context->data_str, 0) == '#') continue;
if(string_size(context->data_str) != 13) break;
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(string_size(context->data_str) != 13) {
if(furi_string_size(context->data_str) != 13) {
context->attack_step = 0;
counter = 0;
context->is_attacking = false;
@@ -480,8 +480,8 @@ void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
// 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);
}
@@ -538,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;
@@ -557,7 +557,7 @@ void flipfrid_scene_run_attack_on_draw(Canvas* canvas, FlipFridState* context) {
// Title
canvas_set_font(canvas, FontPrimary);
canvas_draw_str_aligned(
canvas, 64, 2, 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];
@@ -606,7 +606,7 @@ void flipfrid_scene_run_attack_on_draw(Canvas* canvas, FlipFridState* context) {
canvas_set_font(canvas, FontSecondary);
canvas_draw_str_aligned(
canvas, 64, 26, AlignCenter, AlignTop, string_get_cstr(context->proto_name));
canvas, 64, 26, AlignCenter, AlignTop, furi_string_get_cstr(context->proto_name));
snprintf(speed, sizeof(speed), "Time delay: %d", context->time_between_cards);
@@ -65,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_free(context->notification_msg);
}
void flipfrid_scene_select_field_on_exit(FlipFridState* context) {
@@ -84,7 +84,7 @@ 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...
@@ -121,12 +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:
context->key_index = 0;
string_reset(context->notification_msg);
furi_string_reset(context->notification_msg);
context->current_scene = SceneSelectFile;
break;
}
@@ -154,5 +154,5 @@ void flipfrid_scene_select_field_on_draw(Canvas* canvas, FlipFridState* context)
flipfrid_center_displayed_key(context, context->key_index);
canvas_set_font(canvas, FontSecondary);
canvas_draw_str_aligned(
canvas, 64, 45, AlignCenter, AlignTop, string_get_cstr(context->notification_msg));
canvas, 64, 45, AlignCenter, AlignTop, furi_string_get_cstr(context->notification_msg));
}
+10 -10
View File
@@ -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)) {
if(!file_stream_open(stream, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
FURI_LOG_D(TAG, "Cannot open file \"%s\"", (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)) {
if(!file_stream_open(stream, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
FURI_LOG_D(TAG, "Cannot open file \"%s\"", (path));
} else {
result = true;
}
}
string_clear(path);
furi_string_free(path);
return result;
}
+93 -85
View File
@@ -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_printf(temp_str, "Repeat: inf", app->meta->playlist_repetitions);
} else if(app->meta->playlist_repetitions == 1) {
string_printf(temp_str, "Repeat: no", app->meta->playlist_repetitions);
furi_string_printf(temp_str, "Repeat: no", app->meta->playlist_repetitions);
} 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;
}
@@ -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;
}
@@ -23,7 +23,7 @@ struct SubBruteWorker {
// Preset and frequency needed
FuriHalSubGhzPreset preset;
uint32_t frequency;
string_t protocol_name;
FuriString* protocol_name;
//SubBruteWorkerCallback callback;
//void* context;
@@ -47,7 +47,7 @@ SubBruteWorker* subbrute_worker_alloc() {
instance->transmitter = NULL;
instance->flipper_format = flipper_format_string_alloc();
string_init(instance->protocol_name);
instance->protocol_name = furi_string_alloc();
// SubGhzTxRxWorker
instance->subghz_txrx = subghz_tx_rx_worker_alloc();
@@ -71,7 +71,7 @@ void subbrute_worker_free(SubBruteWorker* instance) {
flipper_format_free(instance->flipper_format);
string_clear(instance->protocol_name);
furi_string_free(instance->protocol_name);
// SubGhzTxRxWorker
subghz_tx_rx_worker_free(instance->subghz_txrx);
@@ -94,8 +94,8 @@ bool subbrute_worker_start(
instance->frequency = frequency;
instance->preset = preset;
string_clear(instance->protocol_name);
string_init_printf(instance->protocol_name, "%s", protocol_name);
furi_string_free(instance->protocol_name);
instance->protocol_name = furi_string_alloc_printf("%s", protocol_name);
bool res = false;
@@ -235,8 +235,8 @@ bool subbrute_worker_init_manual_transmit(
instance->preset = preset;
instance->frequency = frequency;
string_clear(instance->protocol_name);
string_init_printf(instance->protocol_name, "%s", protocol_name);
furi_string_free(instance->protocol_name);
instance->protocol_name = furi_string_alloc_printf("%s", protocol_name);
furi_hal_subghz_reset();
furi_hal_subghz_idle();
@@ -258,7 +258,7 @@ bool subbrute_worker_init_manual_transmit(
#endif
instance->transmitter = subghz_transmitter_alloc_init(
instance->environment, string_get_cstr(instance->protocol_name));
instance->environment, furi_string_get_cstr(instance->protocol_name));
furi_hal_subghz_reset();
furi_hal_subghz_load_preset(instance->preset);
@@ -320,7 +320,7 @@ bool subbrute_worker_manual_transmit(SubBruteWorker* instance, const char* paylo
stream_write_cstring(stream, payload);
instance->transmitter = subghz_transmitter_alloc_init(
instance->environment, string_get_cstr(instance->protocol_name));
instance->environment, furi_string_get_cstr(instance->protocol_name));
subghz_transmitter_deserialize(instance->transmitter, instance->flipper_format);
furi_hal_subghz_reset();
furi_hal_subghz_load_preset(instance->preset);
@@ -16,10 +16,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);
@@ -31,8 +31,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);
@@ -51,12 +51,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);
}
@@ -65,8 +65,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) {
@@ -92,7 +92,7 @@ void subbrute_scene_run_attack_on_enter(void* context) {
instance->worker,
instance->device->frequency,
instance->device->preset,
string_get_cstr(instance->device->protocol_name))) {
furi_string_get_cstr(instance->device->protocol_name))) {
FURI_LOG_W(TAG, "Worker Continuous init failed!");
}
} else {
@@ -101,7 +101,7 @@ void subbrute_scene_run_attack_on_enter(void* context) {
instance->worker,
instance->device->frequency,
instance->device->preset,
string_get_cstr(instance->device->protocol_name))) {
furi_string_get_cstr(instance->device->protocol_name))) {
FURI_LOG_W(TAG, "Worker init failed!");
}
@@ -1,4 +1,3 @@
#include <m-string.h>
#include <subghz/types.h>
#include <lib/toolbox/random_name.h>
#include <gui/modules/validators.h>
@@ -26,10 +25,10 @@ void subbrute_scene_save_name_on_enter(void* context) {
SUBBRUTE_MAX_LEN_NAME,
true);
string_set_str(device->load_path, SUBBRUTE_PATH);
furi_string_set(device->load_path, SUBBRUTE_PATH);
ValidatorIsFile* validator_is_file =
validator_is_file_alloc_init(string_get_cstr(device->load_path), SUBBRUTE_FILE_EXT, "");
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
furi_string_get_cstr(device->load_path), SUBBRUTE_FILE_EXT, "");
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
view_dispatcher_switch_to_view(instance->view_dispatcher, SubBruteViewTextInput);
@@ -50,14 +49,14 @@ bool subbrute_scene_save_name_on_event(void* context, SceneManagerEvent event) {
#endif
bool success = false;
if(strcmp(instance->device->text_store, "")) {
string_cat_printf(
furi_string_cat_printf(
instance->device->load_path,
"/%s%s",
instance->device->text_store,
SUBBRUTE_FILE_EXT);
if(subbrute_device_save_file(
instance->device, string_get_cstr(instance->device->load_path))) {
instance->device, furi_string_get_cstr(instance->device->load_path))) {
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSaveSuccess);
success = true;
consumed = true;
@@ -83,5 +82,5 @@ void subbrute_scene_save_name_on_exit(void* context) {
text_input_reset(instance->text_input);
string_reset(instance->device->load_path);
furi_string_reset(instance->device->load_path);
}
@@ -31,7 +31,7 @@ void subbrute_scene_setup_attack_on_enter(void* context) {
instance->worker,
instance->device->frequency,
instance->device->preset,
string_get_cstr(instance->device->protocol_name))) {
furi_string_get_cstr(instance->device->protocol_name))) {
FURI_LOG_W(TAG, "Worker init failed!");
}
@@ -144,7 +144,7 @@ bool subbrute_scene_setup_attack_on_event(void* context, SceneManagerEvent event
// view,
// instance->device->frequency,
// instance->device->preset,
// string_get_cstr(instance->device->protocol_name));
// furi_string_get_cstr(instance->device->protocol_name));
// }
subbrute_device_create_packet_parsed(
instance->device, instance->device->key_index, false);
-1
View File
@@ -1,7 +1,6 @@
#include <furi.h>
#include <furi_hal.h>
#include <input/input.h>
#include <m-string.h>
#include <gui/gui.h>
#include <gui/view_dispatcher.h>
+80 -76
View File
@@ -54,9 +54,9 @@ SubBruteDevice* subbrute_device_alloc() {
instance->state = SubBruteDeviceStateIDLE;
instance->key_index = 0;
string_init(instance->load_path);
string_init(instance->preset_name);
string_init(instance->protocol_name);
instance->load_path = furi_string_alloc();
instance->preset_name = furi_string_alloc();
instance->protocol_name = furi_string_alloc();
instance->decoder_result = NULL;
instance->receiver = NULL;
@@ -91,9 +91,9 @@ void subbrute_device_free(SubBruteDevice* instance) {
FURI_LOG_D(TAG, "before free");
#endif
string_clear(instance->load_path);
string_clear(instance->preset_name);
string_clear(instance->protocol_name);
furi_string_free(instance->load_path);
furi_string_free(instance->preset_name);
furi_string_free(instance->protocol_name);
free(instance);
}
@@ -194,41 +194,41 @@ bool subbrute_device_create_packet_parsed(SubBruteDevice* instance, uint64_t ste
//char step_payload[32];
//memset(step_payload, '0', sizeof(step_payload));
memset(instance->payload, 0, sizeof(instance->payload));
string_t candidate;
string_init(candidate);
FuriString* candidate;
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(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;
buffer = furi_string_alloc();
buffer = furi_string_alloc_printf("%16X", step);
int j = 0;
string_set_str(candidate, " ");
furi_string_set(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: %d", furi_string_get_cstr(candidate), step);
#endif
if(small) {
@@ -238,7 +238,7 @@ bool subbrute_device_create_packet_parsed(SubBruteDevice* instance, uint64_t ste
sizeof(instance->payload),
subbrute_key_small_with_tail,
instance->bit,
string_get_cstr(candidate),
furi_string_get_cstr(candidate),
instance->te);
} else {
snprintf(
@@ -246,7 +246,7 @@ bool subbrute_device_create_packet_parsed(SubBruteDevice* instance, uint64_t ste
sizeof(instance->payload),
subbrute_key_small_no_tail,
instance->bit,
string_get_cstr(candidate));
furi_string_get_cstr(candidate));
}
} else {
if(instance->has_tail) {
@@ -255,7 +255,7 @@ bool subbrute_device_create_packet_parsed(SubBruteDevice* instance, uint64_t ste
sizeof(instance->payload),
subbrute_key_file_princeton_end,
instance->file_template,
string_get_cstr(candidate),
furi_string_get_cstr(candidate),
instance->te);
} else {
snprintf(
@@ -263,7 +263,7 @@ bool subbrute_device_create_packet_parsed(SubBruteDevice* instance, uint64_t ste
sizeof(instance->payload),
subbrute_key_file_key,
instance->file_template,
string_get_cstr(candidate));
furi_string_get_cstr(candidate));
}
}
@@ -271,7 +271,7 @@ bool subbrute_device_create_packet_parsed(SubBruteDevice* instance, uint64_t ste
//FURI_LOG_D(TAG, "payload: %s", instance->payload);
#endif
string_clear(candidate);
furi_string_free(candidate);
return true;
}
@@ -286,7 +286,7 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute
case SubBruteAttackLoadFile:
// In this case values must be already set
// file_result =
// subbrute_device_load_from_file(instance, string_get_cstr(instance->load_path));
// subbrute_device_load_from_file(instance, furi_string_get_cstr(instance->load_path));
// if(file_result != SubBruteFileResultOk) {
// // Failed load file so failed to set attack type
// return file_result; // RETURN
@@ -306,8 +306,8 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute
instance->frequency = 868350000;
}
instance->bit = 12;
string_set_str(instance->protocol_name, protocol_came);
string_set_str(instance->preset_name, preset_ook650_async);
furi_string_set(instance->protocol_name, protocol_came);
furi_string_set(instance->preset_name, preset_ook650_async);
break;
case SubBruteAttackChamberlain9bit300:
case SubBruteAttackChamberlain9bit315:
@@ -320,32 +320,32 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute
instance->frequency = 390000000;
}
instance->bit = 9;
string_set_str(instance->protocol_name, protocol_cham_code);
string_set_str(instance->preset_name, preset_ook650_async);
furi_string_set(instance->protocol_name, protocol_cham_code);
furi_string_set(instance->preset_name, preset_ook650_async);
break;
case SubBruteAttackLinear10bit300:
instance->frequency = 300000000;
instance->bit = 10;
string_set_str(instance->protocol_name, protocol_linear);
string_set_str(instance->preset_name, preset_ook650_async);
furi_string_set(instance->protocol_name, protocol_linear);
furi_string_set(instance->preset_name, preset_ook650_async);
break;
case SubBruteAttackLinear10bit310:
instance->frequency = 310000000;
instance->bit = 10;
string_set_str(instance->protocol_name, protocol_linear);
string_set_str(instance->preset_name, preset_ook650_async);
furi_string_set(instance->protocol_name, protocol_linear);
furi_string_set(instance->preset_name, preset_ook650_async);
break;
case SubBruteAttackNICE12bit433:
instance->frequency = 433920000;
instance->bit = 12;
string_set_str(instance->protocol_name, protocol_nice_flo);
string_set_str(instance->preset_name, preset_ook650_async);
furi_string_set(instance->protocol_name, protocol_nice_flo);
furi_string_set(instance->preset_name, preset_ook650_async);
break;
case SubBruteAttackNICE12bit868:
instance->frequency = 868350000;
instance->bit = 12;
string_set_str(instance->protocol_name, protocol_nice_flo);
string_set_str(instance->preset_name, preset_ook650_async);
furi_string_set(instance->protocol_name, protocol_nice_flo);
furi_string_set(instance->preset_name, preset_ook650_async);
break;
default:
FURI_LOG_E(TAG, "Unknown attack type: %d", type);
@@ -365,7 +365,7 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute
uint8_t protocol_check_result = SubBruteFileResultProtocolNotFound;
if(type != SubBruteAttackLoadFile) {
instance->decoder_result = subghz_receiver_search_decoder_base_by_name(
instance->receiver, string_get_cstr(instance->protocol_name));
instance->receiver, furi_string_get_cstr(instance->protocol_name));
if(!instance->decoder_result ||
instance->decoder_result->protocol->type == SubGhzProtocolTypeDynamic) {
@@ -375,7 +375,8 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute
}
} else {
// And here we need to set preset enum
instance->preset = subbrute_device_convert_preset(string_get_cstr(instance->preset_name));
instance->preset =
subbrute_device_convert_preset(furi_string_get_cstr(instance->preset_name));
protocol_check_result = SubBruteFileResultOk;
}
@@ -387,19 +388,19 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute
}
instance->has_tail =
(strcmp(string_get_cstr(instance->protocol_name), protocol_princeton) == 0);
(strcmp(furi_string_get_cstr(instance->protocol_name), protocol_princeton) == 0);
// Calc max value
if(instance->attack == SubBruteAttackLoadFile) {
instance->max_value = 0xFF;
} 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->bit; 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
@@ -409,8 +410,8 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute
sizeof(instance->file_template),
subbrute_key_file_start,
instance->frequency,
string_get_cstr(instance->preset_name),
string_get_cstr(instance->protocol_name),
furi_string_get_cstr(instance->preset_name),
furi_string_get_cstr(instance->protocol_name),
instance->bit);
// strncat(instance->file_template, "\n", sizeof(instance->file_template));
// strncat(instance->file_template, subbrute_key_file_key, sizeof(instance->file_template));
@@ -430,18 +431,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);
@@ -449,8 +450,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;
}
@@ -477,7 +478,7 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, string_t file_p
FURI_LOG_E(TAG, "Preset FAIL");
result = SubBruteFileResultPresetInvalid;
} else {
string_init_set_str(instance->preset_name, string_get_cstr(temp_str));
instance->preset_name = furi_string_alloc_set(furi_string_get_cstr(temp_str));
}
// Protocol
@@ -486,17 +487,17 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, string_t file_p
result = SubBruteFileResultMissingProtocol;
break;
} else {
string_init_set_str(instance->protocol_name, string_get_cstr(temp_str));
instance->protocol_name = furi_string_alloc_set(furi_string_get_cstr(temp_str));
#ifdef FURI_DEBUG
FURI_LOG_D(TAG, "Protocol: %s", string_get_cstr(instance->protocol_name));
FURI_LOG_D(TAG, "Protocol: %s", furi_string_get_cstr(instance->protocol_name));
#endif
}
instance->decoder_result = subghz_receiver_search_decoder_base_by_name(
instance->receiver, string_get_cstr(instance->protocol_name));
instance->receiver, furi_string_get_cstr(instance->protocol_name));
if(!instance->decoder_result ||
strcmp(string_get_cstr(instance->protocol_name), "RAW") == 0) {
strcmp(furi_string_get_cstr(instance->protocol_name), "RAW") == 0) {
FURI_LOG_E(TAG, "RAW unsupported");
result = SubBruteFileResultProtocolNotSupported;
break;
@@ -514,7 +515,7 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, string_t file_p
#endif
// instance->decoder_result = subghz_receiver_search_decoder_base_by_name(
// instance->receiver, string_get_cstr(instance->protocol_name));
// instance->receiver, furi_string_get_cstr(instance->protocol_name));
//
// if(!instance->decoder_result) {
// FURI_LOG_E(TAG, "Protocol not found");
@@ -541,7 +542,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
@@ -573,7 +577,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);
@@ -612,14 +616,14 @@ void subbrute_device_attack_set_default_values(
instance->max_value = (uint64_t)0x00;
string_clear(instance->protocol_name);
string_clear(instance->preset_name);
furi_string_free(instance->protocol_name);
furi_string_free(instance->preset_name);
string_clear(instance->load_path);
string_init(instance->load_path);
furi_string_free(instance->load_path);
instance->load_path = furi_string_alloc();
string_init_set_str(instance->protocol_name, protocol_raw);
string_init_set_str(instance->preset_name, preset_ook650_async);
instance->protocol_name = furi_string_alloc_set(protocol_raw);
instance->preset_name = furi_string_alloc_set(preset_ook650_async);
instance->preset = FuriHalSubGhzPresetOok650Async;
instance->repeat = 5;
@@ -634,25 +638,25 @@ void subbrute_device_attack_set_default_values(
}
FuriHalSubGhzPreset subbrute_device_convert_preset(const char* preset_name) {
string_t preset;
string_init_set_str(preset, preset_name);
FuriString* preset;
preset = furi_string_alloc_set(preset_name);
FuriHalSubGhzPreset preset_value;
if(string_cmp_str(preset, preset_ook270_async) == 0) {
if(furi_string_cmp_str(preset, preset_ook270_async) == 0) {
preset_value = FuriHalSubGhzPresetOok270Async;
} else if(string_cmp_str(preset, preset_ook650_async) == 0) {
} else if(furi_string_cmp_str(preset, preset_ook650_async) == 0) {
preset_value = FuriHalSubGhzPresetOok650Async;
} else if(string_cmp_str(preset, preset_2fsk_dev238_async) == 0) {
} else if(furi_string_cmp_str(preset, preset_2fsk_dev238_async) == 0) {
preset_value = FuriHalSubGhzPreset2FSKDev238Async;
} else if(string_cmp_str(preset, preset_2fsk_dev476_async) == 0) {
} else if(furi_string_cmp_str(preset, preset_2fsk_dev476_async) == 0) {
preset_value = FuriHalSubGhzPreset2FSKDev476Async;
} else if(string_cmp_str(preset, preset_msk99_97_kb_async) == 0) {
} else if(furi_string_cmp_str(preset, preset_msk99_97_kb_async) == 0) {
preset_value = FuriHalSubGhzPresetMSK99_97KbAsync;
} else if(string_cmp_str(preset, preset_gfs99_97_kb_async) == 0) {
} else if(furi_string_cmp_str(preset, preset_gfs99_97_kb_async) == 0) {
preset_value = FuriHalSubGhzPresetMSK99_97KbAsync;
} else {
preset_value = FuriHalSubGhzPresetCustom;
}
string_clear(preset);
furi_string_free(preset);
return preset_value;
}
@@ -61,7 +61,7 @@ typedef struct {
// Current step
uint64_t key_index;
string_t load_path;
FuriString* load_path;
// Index of group to bruteforce in loaded file
uint8_t load_index;
@@ -78,8 +78,8 @@ typedef struct {
// Loaded info for attack type
FuriHalSubGhzPreset preset;
string_t preset_name;
string_t protocol_name;
FuriString* preset_name;
FuriString* protocol_name;
uint32_t frequency;
uint32_t repeat;
uint32_t bit;
@@ -96,7 +96,7 @@ bool subbrute_device_save_file(SubBruteDevice* instance, const char* key_name);
const char* subbrute_device_error_get_desc(SubBruteFileResult error_id);
bool subbrute_device_create_packet_parsed(SubBruteDevice* context, uint64_t step, bool small);
SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* context, SubBruteAttacks type);
uint8_t subbrute_device_load_from_file(SubBruteDevice* context, string_t file_path);
uint8_t subbrute_device_load_from_file(SubBruteDevice* context, FuriString* file_path);
FuriHalSubGhzPreset subbrute_device_convert_preset(const char* preset);
void subbrute_device_attack_set_default_values(
SubBruteDevice* context,
@@ -7,7 +7,6 @@
#include "lib/toolbox/path.h"
#include <notification/notification.h>
#include <notification/notification_messages.h>
#include <m-string.h>
#include <lib/toolbox/stream/stream.h>
#include <stream_buffer.h>
@@ -33,7 +33,7 @@ void subbrute_main_view_set_callback(
instance->context = context;
}
void center_displayed_key(string_t result, const char* key_cstr, uint8_t index) {
void center_displayed_key(FuriString* result, const char* key_cstr, uint8_t index) {
uint8_t str_index = (index * 3);
char display_menu[] = {
@@ -75,7 +75,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);
result = furi_string_alloc_set(display_menu);
}
void subbrute_main_view_draw(Canvas* canvas, SubBruteMainViewModel* model) {
@@ -96,19 +96,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;
menu_items = furi_string_alloc();
center_displayed_key(menu_items, 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);
} else {
// Menu
canvas_set_color(canvas, ColorBlack);
+6 -6
View File
@@ -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;
}
@@ -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,7 +30,7 @@ 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 =
@@ -47,7 +47,7 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
}
// 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;
@@ -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
@@ -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;
@@ -6,7 +6,6 @@
#include <gui/canvas_i.h>
#include <gui/gui.h>
#include <input/input.h>
#include <m-string.h>
#include <math.h>
#include <notification/notification.h>
#include <notification/notification_messages.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;
@@ -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);
@@ -480,8 +479,8 @@ 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);
@@ -489,45 +488,46 @@ static int32_t uart_worker(void* context) {
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 +535,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 +543,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 +590,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);
}
}