Formatting & New updated IR

This commit is contained in:
VerstreuteSeele
2023-01-14 08:44:32 +01:00
parent 7385a28ddd
commit 905bb23fdf
216 changed files with 6455 additions and 5877 deletions

View File

@@ -4,12 +4,9 @@
#include <flipper_format/flipper_format.h>
void namechanger_on_system_start() {
if (furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal)
{
if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) {
FURI_LOG_W(TAG, "NameChangerSRV load skipped. Device is in special startup mode.");
}
else
{
} else {
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* file = flipper_format_file_alloc(storage);
@@ -25,36 +22,36 @@ void namechanger_on_system_start() {
data = furi_string_alloc();
do {
if (!flipper_format_file_open_existing(file, furi_string_get_cstr(filepath))) {
if(!flipper_format_file_open_existing(file, furi_string_get_cstr(filepath))) {
break;
}
// header
uint32_t version;
if (!flipper_format_read_header(file, data, &version)) {
if(!flipper_format_read_header(file, data, &version)) {
break;
}
if (furi_string_cmp_str(data, furi_string_get_cstr(NAMEHEADER)) != 0) {
if(furi_string_cmp_str(data, furi_string_get_cstr(NAMEHEADER)) != 0) {
break;
}
if (version != 1) {
if(version != 1) {
break;
}
// get Name
if (!flipper_format_read_string(file, "Name", data)) {
if(!flipper_format_read_string(file, "Name", data)) {
break;
}
result = true;
} while (false);
} while(false);
flipper_format_free(file);
if (!result) {
if(!result) {
//file not good - write new one
FlipperFormat* file = flipper_format_file_alloc(storage);
@@ -62,49 +59,49 @@ void namechanger_on_system_start() {
do {
// Open file for write
if (!flipper_format_file_open_always(file, furi_string_get_cstr(filepath))) {
if(!flipper_format_file_open_always(file, furi_string_get_cstr(filepath))) {
break;
}
// Write header
if (!flipper_format_write_header_cstr(file, furi_string_get_cstr(NAMEHEADER), 1)) {
if(!flipper_format_write_header_cstr(file, furi_string_get_cstr(NAMEHEADER), 1)) {
break;
}
// Write comments
if (!flipper_format_write_comment_cstr(
file,
"Changing the value below will change your FlipperZero device name.")) {
if(!flipper_format_write_comment_cstr(
file,
"Changing the value below will change your FlipperZero device name.")) {
break;
}
if (!flipper_format_write_comment_cstr(
file,
"Note: This is limited to 8 characters using the following: a-z, A-Z, 0-9, and _")) {
if(!flipper_format_write_comment_cstr(
file,
"Note: This is limited to 8 characters using the following: a-z, A-Z, 0-9, and _")) {
break;
}
if (!flipper_format_write_comment_cstr(
file, "It can contain other characters but use at your own risk.")) {
if(!flipper_format_write_comment_cstr(
file, "It can contain other characters but use at your own risk.")) {
break;
}
//Write name
if (!flipper_format_write_string_cstr(file, "Name", furi_hal_version_get_name_ptr())) {
if(!flipper_format_write_string_cstr(
file, "Name", furi_hal_version_get_name_ptr())) {
break;
}
res = true;
} while (false);
} while(false);
flipper_format_free(file);
if (!res) {
if(!res) {
FURI_LOG_E(TAG, "Save failed.");
}
}
else {
if (!furi_string_size(data)) {
} else {
if(!furi_string_size(data)) {
//Empty file - get default name and write to file.
FlipperFormat* file = flipper_format_file_alloc(storage);
@@ -112,50 +109,49 @@ void namechanger_on_system_start() {
do {
// Open file for write
if (!flipper_format_file_open_always(file, furi_string_get_cstr(filepath))) {
if(!flipper_format_file_open_always(file, furi_string_get_cstr(filepath))) {
break;
}
// Write header
if (!flipper_format_write_header_cstr(
file, furi_string_get_cstr(NAMEHEADER), 1)) {
if(!flipper_format_write_header_cstr(
file, furi_string_get_cstr(NAMEHEADER), 1)) {
break;
}
// Write comments
if (!flipper_format_write_comment_cstr(
file,
"Changing the value below will change your FlipperZero device name.")) {
if(!flipper_format_write_comment_cstr(
file,
"Changing the value below will change your FlipperZero device name.")) {
break;
}
if (!flipper_format_write_comment_cstr(
file,
"Note: This is limited to 8 characters using the following: a-z, A-Z, 0-9, and _")) {
if(!flipper_format_write_comment_cstr(
file,
"Note: This is limited to 8 characters using the following: a-z, A-Z, 0-9, and _")) {
break;
}
if (!flipper_format_write_comment_cstr(
file, "It cannot contain any other characters.")) {
if(!flipper_format_write_comment_cstr(
file, "It cannot contain any other characters.")) {
break;
}
//Write name
if (!flipper_format_write_string_cstr(
file, "Name", furi_hal_version_get_name_ptr())) {
if(!flipper_format_write_string_cstr(
file, "Name", furi_hal_version_get_name_ptr())) {
break;
}
res = true;
} while (false);
} while(false);
flipper_format_free(file);
if (!res) {
if(!res) {
FURI_LOG_E(TAG, "Save failed.");
}
}
else {
} else {
char newdata[9];
snprintf(newdata, 9, "%s", furi_string_get_cstr(data));
//set name from file