RPC: Add Virtual Display & Unify log tags (#814)

* RPC: Update protobuf sources
* RPC: Add Virtual Display
* Unify log tags
* RPC: Virtual Display placeholder
* Rpc: clear frame buffer callback before confirm.
* Firmware: full assert for hal, move fatfs initialization to furi hal.
* FuriHal: VCP optimizations, thread safe console. Rpc: adjust buffer sizes.

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
Anna Prosvetova
2021-11-12 16:04:35 +03:00
committed by GitHub
parent b564e8eb38
commit 558fa5670b
123 changed files with 1050 additions and 694 deletions

View File

@@ -5,6 +5,8 @@
#include <furi-hal-delay.h>
#include <stdbool.h>
#define TAG "Gauge"
uint16_t bq27220_read_word(uint8_t address) {
uint8_t buffer[2] = {address};
uint16_t ret;
@@ -70,13 +72,13 @@ bool bq27220_init(const ParamCEDV* cedv) {
uint32_t timeout = 100;
uint16_t design_cap = bq27220_get_design_capacity();
if(cedv->design_cap == design_cap) {
FURI_LOG_I("gauge", "Skip battery profile update");
FURI_LOG_I(TAG, "Skip battery profile update");
return true;
}
FURI_LOG_I("gauge", "Start updating battery profile");
FURI_LOG_I(TAG, "Start updating battery profile");
OperationStatus status = {};
if(!bq27220_control(Control_ENTER_CFG_UPDATE)) {
FURI_LOG_E("gauge", "Can't configure update");
FURI_LOG_E(TAG, "Can't configure update");
return false;
};
@@ -111,10 +113,10 @@ bool bq27220_init(const ParamCEDV* cedv) {
delay_us(10000);
design_cap = bq27220_get_design_capacity();
if(cedv->design_cap == design_cap) {
FURI_LOG_I("gauge", "Battery profile update success");
FURI_LOG_I(TAG, "Battery profile update success");
return true;
} else {
FURI_LOG_E("gauge", "Battery profile update failed");
FURI_LOG_E(TAG, "Battery profile update failed");
return false;
}
}

View File

@@ -3,6 +3,8 @@
#include <lib/toolbox/manchester-decoder.h>
#include "../subghz_keystore.h"
#define TAG "SubGhzCameAtomo"
#define SUBGHZ_NO_CAME_ATOMO_RAINBOW_TABLE 0xFFFFFFFFFFFFFFFF
struct SubGhzProtocolCameAtomo {
@@ -39,7 +41,7 @@ void subghz_protocol_came_atomo_free(SubGhzProtocolCameAtomo* instance) {
void subghz_protocol_came_atomo_name_file(SubGhzProtocolCameAtomo* instance, const char* name) {
instance->rainbow_table_file_name = name;
printf("Loading CAME Atomo rainbow table %s\r\n", name);
FURI_LOG_I(TAG, "Loading rainbow table from %s", name);
}
/** Read bytes from rainbow table

View File

@@ -175,12 +175,12 @@ bool subghz_protocol_common_to_save_file(SubGhzProtocolCommon* instance, Flipper
bool res = false;
do {
if(!flipper_file_write_string_cstr(flipper_file, "Protocol", instance->name)) {
FURI_LOG_E(SUBGHZ_KEY_TAG, "Unable to add Protocol");
FURI_LOG_E(SUBGHZ_PARSER_TAG, "Unable to add Protocol");
break;
}
if(!flipper_file_write_uint32(
flipper_file, "Bit", (uint32_t*)&instance->code_last_count_bit, 1)) {
FURI_LOG_E(SUBGHZ_KEY_TAG, "Unable to add Bit");
FURI_LOG_E(SUBGHZ_PARSER_TAG, "Unable to add Bit");
break;
}
@@ -190,7 +190,7 @@ bool subghz_protocol_common_to_save_file(SubGhzProtocolCommon* instance, Flipper
}
if(!flipper_file_write_hex(flipper_file, "Key", key_data, sizeof(uint64_t))) {
FURI_LOG_E(SUBGHZ_KEY_TAG, "Unable to add Key");
FURI_LOG_E(SUBGHZ_PARSER_TAG, "Unable to add Key");
break;
}
res = true;
@@ -211,14 +211,14 @@ bool subghz_protocol_common_to_load_protocol_from_file(
do {
if(!flipper_file_read_uint32(flipper_file, "Bit", (uint32_t*)&temp_data, 1)) {
FURI_LOG_E(SUBGHZ_KEY_TAG, "Missing Bit");
FURI_LOG_E(SUBGHZ_PARSER_TAG, "Missing Bit");
break;
}
instance->code_last_count_bit = (uint8_t)temp_data;
uint8_t key_data[sizeof(uint64_t)] = {0};
if(!flipper_file_read_hex(flipper_file, "Key", key_data, sizeof(uint64_t))) {
FURI_LOG_E(SUBGHZ_KEY_TAG, "Missing Key");
FURI_LOG_E(SUBGHZ_PARSER_TAG, "Missing Key");
break;
}
for(uint8_t i = 0; i < sizeof(uint64_t); i++) {

View File

@@ -21,11 +21,10 @@
#define SUBGHZ_APP_EXTENSION ".sub"
#define SUBGHZ_ENCODER_UPLOAD_MAX_SIZE 2048
#define SUBGHZ_KEY_TAG "SubGhzParser"
#define SUBGHZ_PARSER_TAG "SubGhzParser"
#define SUBGHZ_KEY_FILE_VERSION 1
#define SUBGHZ_KEY_FILE_TYPE "Flipper SubGhz Key File"
#define SUBGHZ_RAW_TAG "SubGhzRAW"
#define SUBGHZ_RAW_FILE_VERSION 1
#define SUBGHZ_RAW_FILE_TYPE "Flipper SubGhz RAW File"

View File

@@ -9,6 +9,8 @@
* https://vrtp.ru/index.php?showtopic=27867
*/
#define TAG "SubGhzNiceFlorS"
struct SubGhzProtocolNiceFlorS {
SubGhzProtocolCommon common;
const char* rainbow_table_file_name;
@@ -45,7 +47,7 @@ void subghz_protocol_nice_flor_s_free(SubGhzProtocolNiceFlorS* instance) {
void subghz_protocol_nice_flor_s_name_file(SubGhzProtocolNiceFlorS* instance, const char* name) {
instance->rainbow_table_file_name = name;
printf("Loading Nice FloR S rainbow table %s\r\n", name);
FURI_LOG_I(TAG, "Loading rainbow table from %s", name);
}
/** Send bit

View File

@@ -11,6 +11,8 @@
#define SUBGHZ_PT_COUNT_KEY 5
#define SUBGHZ_PT_TIMEOUT 320
#define TAG "SubghzPrinceton"
struct SubGhzEncoderPrinceton {
uint32_t key;
uint16_t te;
@@ -67,7 +69,7 @@ void subghz_encoder_princeton_print_log(void* context) {
float duty_cycle =
((float)instance->time_high / (instance->time_high + instance->time_low)) * 100;
FURI_LOG_I(
"EncoderPrinceton",
TAG "Encoder",
"Radio ON=%dus, OFF=%dus, DutyCycle=%d,%d%%",
instance->time_high,
instance->time_low,
@@ -297,7 +299,7 @@ bool subghz_decoder_princeton_to_save_file(
bool res = subghz_protocol_common_to_save_file((SubGhzProtocolCommon*)instance, flipper_file);
if(res) {
res = flipper_file_write_uint32(flipper_file, "TE", (uint32_t*)&instance->te, 1);
if(!res) FURI_LOG_E(SUBGHZ_KEY_TAG, "Unable to add Te");
if(!res) FURI_LOG_E(SUBGHZ_PARSER_TAG, "Unable to add Te");
}
return res;
}
@@ -310,7 +312,7 @@ bool subghz_decoder_princeton_to_load_protocol_from_file(
(SubGhzProtocolCommon*)instance, flipper_file);
if(loaded) {
loaded = flipper_file_read_uint32(flipper_file, "TE", (uint32_t*)&instance->te, 1);
if(!loaded) FURI_LOG_E(SUBGHZ_KEY_TAG, "Missing TE");
if(!loaded) FURI_LOG_E(SUBGHZ_PARSER_TAG, "Missing TE");
}
return loaded;
}

View File

@@ -1,6 +1,8 @@
#include "subghz_protocol_raw.h"
#include "../subghz_file_encoder_worker.h"
#define TAG "SubGhzRaw"
#define SUBGHZ_DOWNLOAD_MAX_SIZE 512
struct SubGhzProtocolRAW {
@@ -165,28 +167,28 @@ bool subghz_protocol_raw_save_to_file_init(
// Open file
if(!flipper_file_open_always(instance->flipper_file, string_get_cstr(dev_file_name))) {
FURI_LOG_E(SUBGHZ_RAW_TAG, "Unable to open file for write: %s", dev_file_name);
FURI_LOG_E(TAG, "Unable to open file for write: %s", dev_file_name);
break;
}
if(!flipper_file_write_header_cstr(
instance->flipper_file, SUBGHZ_RAW_FILE_TYPE, SUBGHZ_RAW_FILE_VERSION)) {
FURI_LOG_E(SUBGHZ_RAW_TAG, "Unable to add header");
FURI_LOG_E(TAG, "Unable to add header");
break;
}
if(!flipper_file_write_uint32(instance->flipper_file, "Frequency", (uint32_t*)&frequency, 1)) {
FURI_LOG_E(SUBGHZ_RAW_TAG, "Unable to add Frequency");
FURI_LOG_E(TAG, "Unable to add Frequency");
break;
}
if(!flipper_file_write_string_cstr(instance->flipper_file, "Preset", preset)) {
FURI_LOG_E(SUBGHZ_RAW_TAG, "Unable to add Preset");
FURI_LOG_E(TAG, "Unable to add Preset");
break;
}
if(!flipper_file_write_string_cstr(instance->flipper_file, "Protocol", instance->common.name)) {
FURI_LOG_E(SUBGHZ_RAW_TAG, "Unable to add Protocol");
FURI_LOG_E(TAG, "Unable to add Protocol");
break;
}
@@ -222,7 +224,7 @@ bool subghz_protocol_raw_save_to_file_write(SubGhzProtocolRAW* instance) {
if(instance->file_is_open == RAWFileIsOpenWrite) {
if(!flipper_file_write_int32(
instance->flipper_file, "RAW_Data", instance->upload_raw, instance->ind_write)) {
FURI_LOG_E(SUBGHZ_RAW_TAG, "Unable to add RAW_Data");
FURI_LOG_E(TAG, "Unable to add RAW_Data");
} else {
instance->sample_write += instance->ind_write;
instance->ind_write = 0;

View File

@@ -4,6 +4,8 @@
#include <lib/flipper_file/flipper_file.h>
#include <lib/flipper_file/file_helper.h>
#define TAG "SubGhzFileEncoderWorker"
#define SUBGHZ_FILE_ENCODER_LOAD 512
struct SubGhzFileEncoderWorker {
@@ -86,11 +88,11 @@ LevelDuration subghz_file_encoder_worker_get_level_duration(void* context) {
level_duration = level_duration_make(true, duration);
} else if(duration == 0) {
level_duration = level_duration_reset();
FURI_LOG_I("SubGhzFileEncoderWorker", "Stop transmission");
FURI_LOG_I(TAG, "Stop transmission");
}
return level_duration;
} else {
FURI_LOG_E("SubGhzFileEncoderWorker", "Slow flash read");
FURI_LOG_E(TAG, "Slow flash read");
return level_duration_wait();
}
}
@@ -102,27 +104,27 @@ LevelDuration subghz_file_encoder_worker_get_level_duration(void* context) {
*/
static int32_t subghz_file_encoder_worker_thread(void* context) {
SubGhzFileEncoderWorker* instance = context;
FURI_LOG_I("SubGhzFileEncoderWorker", "Worker start");
FURI_LOG_I(TAG, "Worker start");
bool res = false;
File* file = flipper_file_get_file(instance->flipper_file);
do {
if(!flipper_file_open_existing(
instance->flipper_file, string_get_cstr(instance->file_path))) {
FURI_LOG_E(
"SubGhzFileEncoderWorker",
TAG,
"Unable to open file for read: %s",
string_get_cstr(instance->file_path));
break;
}
if(!flipper_file_read_string(instance->flipper_file, "Protocol", instance->str_data)) {
FURI_LOG_E("SubGhzFileEncoderWorker", "Missing Protocol");
FURI_LOG_E(TAG, "Missing Protocol");
break;
}
//skip the end of the previous line "\n"
storage_file_seek(file, 1, false);
res = true;
FURI_LOG_I("SubGhzFileEncoderWorker", "Start transmission");
FURI_LOG_I(TAG, "Start transmission");
} while(0);
while(res && instance->worker_running) {
@@ -149,13 +151,13 @@ static int32_t subghz_file_encoder_worker_thread(void* context) {
}
}
//waiting for the end of the transfer
FURI_LOG_I("SubGhzFileEncoderWorker", "End read file");
FURI_LOG_I(TAG, "End read file");
while(instance->worker_running) {
osDelay(50);
}
flipper_file_close(instance->flipper_file);
FURI_LOG_I("SubGhzFileEncoderWorker", "Worker stop");
FURI_LOG_I(TAG, "Worker stop");
return 0;
}

View File

@@ -7,7 +7,7 @@
#include <toolbox/hex.h>
#include <flipper_file/flipper_file.h>
#define SUBGHZ_KEYSTORE_TAG "SubGhzParser"
#define TAG "SubGhzKeystore"
#define FILE_BUFFER_SIZE 64
@@ -71,7 +71,7 @@ static bool subghz_keystore_process_line(SubGhzKeystore* instance, char* line) {
subghz_keystore_add_key(instance, name, key, type);
return true;
} else {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Failed to load line: %s\r\n", line);
FURI_LOG_E(TAG, "Failed to load line: %s\r\n", line);
return false;
}
}
@@ -133,13 +133,13 @@ static bool subghz_keystore_read_file(SubGhzKeystore* instance, File* file, uint
(uint8_t*)encrypted_line, (uint8_t*)decrypted_line, len)) {
subghz_keystore_process_line(instance, decrypted_line);
} else {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Decryption failed");
FURI_LOG_E(TAG, "Decryption failed");
result = false;
break;
}
} else {
FURI_LOG_E(
SUBGHZ_KEYSTORE_TAG, "Invalid encrypted data: %s", encrypted_line);
TAG, "Invalid encrypted data: %s", encrypted_line);
}
} else {
subghz_keystore_process_line(instance, encrypted_line);
@@ -155,7 +155,7 @@ static bool subghz_keystore_read_file(SubGhzKeystore* instance, File* file, uint
encrypted_line[encrypted_line_cursor] = buffer[i];
encrypted_line_cursor++;
} else {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Malformed file");
FURI_LOG_E(TAG, "Malformed file");
result = false;
break;
}
@@ -186,21 +186,21 @@ bool subghz_keystore_load(SubGhzKeystore* instance, const char* file_name) {
FlipperFile* flipper_file = flipper_file_alloc(storage);
do {
if(!flipper_file_open_existing(flipper_file, file_name)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unable to open file for read: %s", file_name);
FURI_LOG_E(TAG, "Unable to open file for read: %s", file_name);
break;
}
if(!flipper_file_read_header(flipper_file, filetype, &version)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Missing or incorrect header");
FURI_LOG_E(TAG, "Missing or incorrect header");
break;
}
if(!flipper_file_read_uint32(flipper_file, "Encryption", (uint32_t*)&encryption, 1)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Missing encryption type");
FURI_LOG_E(TAG, "Missing encryption type");
break;
}
if(strcmp(string_get_cstr(filetype), SUBGHZ_KEYSTORE_FILE_TYPE) != 0 ||
version != SUBGHZ_KEYSTORE_FILE_VERSION) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Type or version mismatch");
FURI_LOG_E(TAG, "Type or version mismatch");
break;
}
@@ -209,13 +209,13 @@ bool subghz_keystore_load(SubGhzKeystore* instance, const char* file_name) {
result = subghz_keystore_read_file(instance, file, NULL);
} else if(encryption == SubGhzKeystoreEncryptionAES256) {
if(!flipper_file_read_hex(flipper_file, "IV", iv, 16)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Missing IV");
FURI_LOG_E(TAG, "Missing IV");
break;
}
subghz_keystore_mess_with_iv(iv);
result = subghz_keystore_read_file(instance, file, iv);
} else {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unknown encryption");
FURI_LOG_E(TAG, "Unknown encryption");
break;
}
} while(0);
@@ -240,28 +240,28 @@ bool subghz_keystore_save(SubGhzKeystore* instance, const char* file_name, uint8
FlipperFile* flipper_file = flipper_file_alloc(storage);
do {
if(!flipper_file_open_always(flipper_file, file_name)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unable to open file for write: %s", file_name);
FURI_LOG_E(TAG, "Unable to open file for write: %s", file_name);
break;
}
if(!flipper_file_write_header_cstr(
flipper_file, SUBGHZ_KEYSTORE_FILE_TYPE, SUBGHZ_KEYSTORE_FILE_VERSION)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unable to add header");
FURI_LOG_E(TAG, "Unable to add header");
break;
}
SubGhzKeystoreEncryption encryption = SubGhzKeystoreEncryptionAES256;
if(!flipper_file_write_uint32(flipper_file, "Encryption", (uint32_t*)&encryption, 1)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unable to add Encryption");
FURI_LOG_E(TAG, "Unable to add Encryption");
break;
}
if(!flipper_file_write_hex(flipper_file, "IV", iv, 16)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unable to add IV");
FURI_LOG_E(TAG, "Unable to add IV");
break;
}
subghz_keystore_mess_with_iv(iv);
if(!furi_hal_crypto_store_load_key(SUBGHZ_KEYSTORE_FILE_ENCRYPTION_KEY_SLOT, iv)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unable to load encryption key");
FURI_LOG_E(TAG, "Unable to load encryption key");
break;
}
@@ -291,7 +291,7 @@ bool subghz_keystore_save(SubGhzKeystore* instance, const char* file_name, uint8
// Form encrypted line
if(!furi_hal_crypto_encrypt(
(uint8_t*)decrypted_line, (uint8_t*)encrypted_line, len)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Encryption failed");
FURI_LOG_E(TAG, "Encryption failed");
break;
}
// HEX Encode encrypted line
@@ -307,7 +307,7 @@ bool subghz_keystore_save(SubGhzKeystore* instance, const char* file_name, uint8
encrypted_line_count++;
FURI_LOG_I(
SUBGHZ_KEYSTORE_TAG, "Encrypted: `%s` -> `%s`", decrypted_line, encrypted_line);
TAG, "Encrypted: `%s` -> `%s`", decrypted_line, encrypted_line);
}
furi_hal_crypto_store_unload_key(SUBGHZ_KEYSTORE_FILE_ENCRYPTION_KEY_SLOT);
result = encrypted_line_count == SubGhzKeyArray_size(instance->data);
@@ -344,26 +344,26 @@ bool subghz_keystore_raw_encrypted_save(
FlipperFile* input_flipper_file = flipper_file_alloc(storage);
do {
if(!flipper_file_open_existing(input_flipper_file, input_file_name)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unable to open file for read: %s", input_file_name);
FURI_LOG_E(TAG, "Unable to open file for read: %s", input_file_name);
break;
}
if(!flipper_file_read_header(input_flipper_file, filetype, &version)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Missing or incorrect header");
FURI_LOG_E(TAG, "Missing or incorrect header");
break;
}
if(!flipper_file_read_uint32(input_flipper_file, "Encryption", (uint32_t*)&encryption, 1)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Missing encryption type");
FURI_LOG_E(TAG, "Missing encryption type");
break;
}
if(strcmp(string_get_cstr(filetype), SUBGHZ_KEYSTORE_FILE_RAW_TYPE) != 0 ||
version != SUBGHZ_KEYSTORE_FILE_VERSION) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Type or version mismatch");
FURI_LOG_E(TAG, "Type or version mismatch");
break;
}
if(encryption != SubGhzKeystoreEncryptionNone) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Already encryption");
FURI_LOG_E(TAG, "Already encryption");
break;
}
File* input_file = flipper_file_get_file(input_flipper_file);
@@ -371,34 +371,34 @@ bool subghz_keystore_raw_encrypted_save(
FlipperFile* output_flipper_file = flipper_file_alloc(storage);
if(!flipper_file_open_always(output_flipper_file, output_file_name)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unable to open file for write: %s", output_file_name);
FURI_LOG_E(TAG, "Unable to open file for write: %s", output_file_name);
break;
}
if(!flipper_file_write_header_cstr(
output_flipper_file, string_get_cstr(filetype), SUBGHZ_KEYSTORE_FILE_VERSION)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unable to add header");
FURI_LOG_E(TAG, "Unable to add header");
break;
}
SubGhzKeystoreEncryption tmp_encryption = SubGhzKeystoreEncryptionAES256;
if(!flipper_file_write_uint32(
output_flipper_file, "Encryption", (uint32_t*)&tmp_encryption, 1)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unable to add Encryption");
FURI_LOG_E(TAG, "Unable to add Encryption");
break;
}
if(!flipper_file_write_hex(output_flipper_file, "IV", iv, 16)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unable to add IV");
FURI_LOG_E(TAG, "Unable to add IV");
break;
}
if(!flipper_file_write_string_cstr(output_flipper_file, "Encrypt_data", "RAW")) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unable to add Encrypt_data");
FURI_LOG_E(TAG, "Unable to add Encrypt_data");
break;
}
subghz_keystore_mess_with_iv(iv);
if(!furi_hal_crypto_store_load_key(SUBGHZ_KEYSTORE_FILE_ENCRYPTION_KEY_SLOT, iv)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unable to load encryption key");
FURI_LOG_E(TAG, "Unable to load encryption key");
break;
}
@@ -431,7 +431,7 @@ bool subghz_keystore_raw_encrypted_save(
// Form encrypted line
if(!furi_hal_crypto_encrypt(
(uint8_t*)buffer, (uint8_t*)encrypted_line, FILE_BUFFER_SIZE / 2)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Encryption failed");
FURI_LOG_E(TAG, "Encryption failed");
result = false;
break;
}
@@ -483,40 +483,40 @@ bool subghz_keystore_raw_get_data(const char* file_name, size_t offset, uint8_t*
FlipperFile* flipper_file = flipper_file_alloc(storage);
do {
if(!flipper_file_open_existing(flipper_file, file_name)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unable to open file for read: %s", file_name);
FURI_LOG_E(TAG, "Unable to open file for read: %s", file_name);
break;
}
if(!flipper_file_read_header(flipper_file, str_temp, &version)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Missing or incorrect header");
FURI_LOG_E(TAG, "Missing or incorrect header");
break;
}
if(!flipper_file_read_uint32(flipper_file, "Encryption", (uint32_t*)&encryption, 1)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Missing encryption type");
FURI_LOG_E(TAG, "Missing encryption type");
break;
}
if(strcmp(string_get_cstr(str_temp), SUBGHZ_KEYSTORE_FILE_RAW_TYPE) != 0 ||
version != SUBGHZ_KEYSTORE_FILE_VERSION) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Type or version mismatch");
FURI_LOG_E(TAG, "Type or version mismatch");
break;
}
File* file = flipper_file_get_file(flipper_file);
if(encryption != SubGhzKeystoreEncryptionAES256) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unknown encryption");
FURI_LOG_E(TAG, "Unknown encryption");
break;
}
if(offset < 16) {
if(!flipper_file_read_hex(flipper_file, "IV", iv, 16)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Missing IV");
FURI_LOG_E(TAG, "Missing IV");
break;
}
subghz_keystore_mess_with_iv(iv);
}
if(!flipper_file_read_string(flipper_file, "Encrypt_data", str_temp)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Missing Encrypt_data");
FURI_LOG_E(TAG, "Missing Encrypt_data");
break;
}
@@ -537,7 +537,7 @@ bool subghz_keystore_raw_get_data(const char* file_name, size_t offset, uint8_t*
size_t size = storage_file_size(file);
size -= storage_file_tell(file);
if(size < (offset * 2 + len * 2)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Seek position exceeds file size");
FURI_LOG_E(TAG, "Seek position exceeds file size");
break;
}
@@ -555,7 +555,7 @@ bool subghz_keystore_raw_get_data(const char* file_name, size_t offset, uint8_t*
}
if(!furi_hal_crypto_store_load_key(SUBGHZ_KEYSTORE_FILE_ENCRYPTION_KEY_SLOT, iv)) {
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Unable to load encryption key");
FURI_LOG_E(TAG, "Unable to load encryption key");
break;
}
@@ -576,7 +576,7 @@ bool subghz_keystore_raw_get_data(const char* file_name, size_t offset, uint8_t*
if(!furi_hal_crypto_decrypt(
(uint8_t*)buffer, (uint8_t*)decrypted_line, bufer_size / 2)) {
decrypted = false;
FURI_LOG_E(SUBGHZ_KEYSTORE_TAG, "Decryption failed");
FURI_LOG_E(TAG, "Decryption failed");
break;
}
memcpy(data, (uint8_t*)decrypted_line + (offset - (offset / 16) * 16), len);

View File

@@ -3,6 +3,8 @@
#include <stream_buffer.h>
#include <furi.h>
#define TAG "SubGhzWorker"
struct SubGhzWorker {
FuriThread* thread;
StreamBufferHandle_t stream;
@@ -54,7 +56,7 @@ static int32_t subghz_worker_thread_callback(void* context) {
xStreamBufferReceive(instance->stream, &level_duration, sizeof(LevelDuration), 10);
if(ret == sizeof(LevelDuration)) {
if(level_duration_is_reset(level_duration)) {
FURI_LOG_E("SubGhzWorker", "Overrun buffer");;
FURI_LOG_E(TAG, "Overrun buffer");;
if(instance->overrun_callback) instance->overrun_callback(instance->context);
} else {
bool level = level_duration_get_level(level_duration);

View File

@@ -3,7 +3,7 @@
#include <stdint.h>
#include <storage/storage.h>
#define SAVED_STRUCT_TAG "SAVED_STRUCT"
#define TAG "SavedStruct"
typedef struct {
uint8_t magic;
@@ -23,7 +23,7 @@ bool saved_struct_save(const char* path,
furi_assert(size);
SavedStructHeader header;
FURI_LOG_I(SAVED_STRUCT_TAG, "Saving \"%s\"", path);
FURI_LOG_I(TAG, "Saving \"%s\"", path);
// Store
Storage* storage = furi_record_open("storage");
@@ -32,7 +32,7 @@ bool saved_struct_save(const char* path,
bool saved = storage_file_open(file, path, FSAM_WRITE, FSOM_CREATE_ALWAYS);
if(!saved) {
FURI_LOG_E(
SAVED_STRUCT_TAG,
TAG,
"Open failed \"%s\". Error: \'%s\'",
path,
storage_file_get_error_desc(file));
@@ -58,7 +58,7 @@ bool saved_struct_save(const char* path,
if(bytes_count != (size + sizeof(header))) {
FURI_LOG_E(
SAVED_STRUCT_TAG,
TAG,
"Write failed \"%s\". Error: \'%s\'",
path,
storage_file_get_error_desc(file));
@@ -77,7 +77,7 @@ bool saved_struct_load(const char* path,
size_t size,
uint8_t magic,
uint8_t version) {
FURI_LOG_I(SAVED_STRUCT_TAG, "Loading \"%s\"", path);
FURI_LOG_I(TAG, "Loading \"%s\"", path);
SavedStructHeader header;
@@ -88,7 +88,7 @@ bool saved_struct_load(const char* path,
bool loaded = storage_file_open(file, path, FSAM_READ, FSOM_OPEN_EXISTING);
if (!loaded) {
FURI_LOG_E(
SAVED_STRUCT_TAG,
TAG,
"Failed to read \"%s\". Error: %s",
path,
storage_file_get_error_desc(file));
@@ -100,14 +100,14 @@ bool saved_struct_load(const char* path,
bytes_count += storage_file_read(file, data_read, size);
if(bytes_count != (sizeof(SavedStructHeader) + size)) {
FURI_LOG_E(SAVED_STRUCT_TAG, "Size mismatch of file \"%s\"", path);
FURI_LOG_E(TAG, "Size mismatch of file \"%s\"", path);
result = false;
}
}
if(result && (header.magic != magic || header.version != version)) {
FURI_LOG_E(
SAVED_STRUCT_TAG,
TAG,
"Magic(%d != %d) or Version(%d != %d) mismatch of file \"%s\"",
header.magic,
magic,
@@ -126,7 +126,7 @@ bool saved_struct_load(const char* path,
if(header.checksum != checksum) {
FURI_LOG_E(
SAVED_STRUCT_TAG,
TAG,
"Checksum(%d != %d) mismatch of file \"%s\"",
header.checksum,
checksum,