1
mirror of https://github.com/flipperdevices/flipperzero-firmware.git synced 2025-12-12 12:51:22 +04:00

[FL-3867] Code formatting update (#3765)

* clang-format: AllowShortEnumsOnASingleLine: false
* clang-format: InsertNewlineAtEOF: true
* clang-format: Standard:        c++20
* clang-format: AlignConsecutiveBitFields
* clang-format: AlignConsecutiveMacros
* clang-format: RemoveParentheses: ReturnStatement
* clang-format: RemoveSemicolon: true
* Restored RemoveParentheses: Leave, retained general changes for it
* formatting: fixed logging TAGs
* Formatting update for dev

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
hedger
2024-07-15 07:38:49 +03:00
committed by GitHub
parent a5e89315ae
commit ffa3996a5e
475 changed files with 3187 additions and 3159 deletions

View File

@@ -11,9 +11,9 @@ AlignConsecutiveAssignments:
AlignFunctionPointers: false AlignFunctionPointers: false
PadOperators: true PadOperators: true
AlignConsecutiveBitFields: AlignConsecutiveBitFields:
Enabled: false Enabled: true
AcrossEmptyLines: false AcrossEmptyLines: true
AcrossComments: false AcrossComments: true
AlignCompound: false AlignCompound: false
AlignFunctionPointers: false AlignFunctionPointers: false
PadOperators: true PadOperators: true
@@ -25,10 +25,10 @@ AlignConsecutiveDeclarations:
AlignFunctionPointers: false AlignFunctionPointers: false
PadOperators: true PadOperators: true
AlignConsecutiveMacros: AlignConsecutiveMacros:
Enabled: false Enabled: true
AcrossEmptyLines: false AcrossEmptyLines: false
AcrossComments: false AcrossComments: true
AlignCompound: false AlignCompound: true
AlignFunctionPointers: false AlignFunctionPointers: false
PadOperators: true PadOperators: true
AlignConsecutiveShortCaseStatements: AlignConsecutiveShortCaseStatements:
@@ -47,7 +47,7 @@ AllowBreakBeforeNoexceptSpecifier: Never
AllowShortBlocksOnASingleLine: Never AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: true AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: true AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: WithoutElse AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLambdasOnASingleLine: All AllowShortLambdasOnASingleLine: All
@@ -108,6 +108,7 @@ ForEachMacros:
- foreach - foreach
- Q_FOREACH - Q_FOREACH
- BOOST_FOREACH - BOOST_FOREACH
- M_EACH
IfMacros: IfMacros:
- KJ_IF_MAYBE - KJ_IF_MAYBE
IncludeBlocks: Preserve IncludeBlocks: Preserve
@@ -136,7 +137,7 @@ IndentRequiresClause: false
IndentWidth: 4 IndentWidth: 4
IndentWrappedFunctionNames: true IndentWrappedFunctionNames: true
InsertBraces: false InsertBraces: false
InsertNewlineAtEOF: false InsertNewlineAtEOF: true
InsertTrailingCommas: None InsertTrailingCommas: None
IntegerLiteralSeparator: IntegerLiteralSeparator:
Binary: 0 Binary: 0
@@ -179,7 +180,7 @@ ReferenceAlignment: Pointer
ReflowComments: false ReflowComments: false
RemoveBracesLLVM: false RemoveBracesLLVM: false
RemoveParentheses: Leave RemoveParentheses: Leave
RemoveSemicolon: false RemoveSemicolon: true
RequiresClausePosition: OwnLine RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave SeparateDefinitionBlocks: Leave
@@ -226,7 +227,7 @@ SpacesInParensOptions:
InEmptyParentheses: false InEmptyParentheses: false
Other: false Other: false
SpacesInSquareBrackets: false SpacesInSquareBrackets: false
Standard: c++03 Standard: c++20
StatementAttributeLikeMacros: StatementAttributeLikeMacros:
- Q_EMIT - Q_EMIT
StatementMacros: StatementMacros:

View File

@@ -17,7 +17,7 @@ static void draw_stat(Canvas* canvas, int x, int y, const Icon* icon, char* val)
canvas_draw_box(canvas, x - 4, y + 16, 24, 6); canvas_draw_box(canvas, x - 4, y + 16, 24, 6);
canvas_set_color(canvas, ColorBlack); canvas_set_color(canvas, ColorBlack);
canvas_draw_str_aligned(canvas, x + 8, y + 22, AlignCenter, AlignBottom, val); canvas_draw_str_aligned(canvas, x + 8, y + 22, AlignCenter, AlignBottom, val);
}; }
static void draw_battery(Canvas* canvas, BatteryInfoModel* data, int x, int y) { static void draw_battery(Canvas* canvas, BatteryInfoModel* data, int x, int y) {
char emote[20] = {}; char emote[20] = {};
@@ -85,7 +85,7 @@ static void draw_battery(Canvas* canvas, BatteryInfoModel* data, int x, int y) {
canvas_draw_str_aligned(canvas, 92, y + 3, AlignCenter, AlignCenter, emote); canvas_draw_str_aligned(canvas, 92, y + 3, AlignCenter, AlignCenter, emote);
canvas_draw_str_aligned(canvas, 92, y + 15, AlignCenter, AlignCenter, header); canvas_draw_str_aligned(canvas, 92, y + 15, AlignCenter, AlignCenter, header);
canvas_draw_str_aligned(canvas, 92, y + 27, AlignCenter, AlignCenter, value); canvas_draw_str_aligned(canvas, 92, y + 27, AlignCenter, AlignCenter, value);
}; }
static void battery_info_draw_callback(Canvas* canvas, void* context) { static void battery_info_draw_callback(Canvas* canvas, void* context) {
furi_assert(context); furi_assert(context);

View File

@@ -5,6 +5,7 @@
#include <toolbox/args.h> #include <toolbox/args.h>
#define TAG "SpeakerDebug" #define TAG "SpeakerDebug"
#define CLI_COMMAND "speaker_debug" #define CLI_COMMAND "speaker_debug"
typedef enum { typedef enum {

View File

@@ -9,9 +9,10 @@
#include <notification/notification.h> #include <notification/notification.h>
#include <notification/notification_messages.h> #include <notification/notification_messages.h>
#define TAG "UartEcho"
#define LINES_ON_SCREEN 6 #define LINES_ON_SCREEN 6
#define COLUMNS_ON_SCREEN 21 #define COLUMNS_ON_SCREEN 21
#define TAG "UartEcho"
#define DEFAULT_BAUD_RATE 230400 #define DEFAULT_BAUD_RATE 230400
typedef struct UartDumpModel UartDumpModel; typedef struct UartDumpModel UartDumpModel;
@@ -147,7 +148,7 @@ static void uart_echo_push_to_list(UartDumpModel* model, const char data) {
bool new_string_needed = false; bool new_string_needed = false;
if(furi_string_size(model->list[model->line]->text) >= COLUMNS_ON_SCREEN) { if(furi_string_size(model->list[model->line]->text) >= COLUMNS_ON_SCREEN) {
new_string_needed = true; new_string_needed = true;
} else if((data == '\n' || data == '\r')) { } else if(data == '\n' || data == '\r') {
// pack line breaks // pack line breaks
if(model->last_char != '\n' && model->last_char != '\r') { if(model->last_char != '\n' && model->last_char != '\r') {
new_string_needed = true; new_string_needed = true;

View File

@@ -43,6 +43,7 @@ typedef struct {
static RpcSessionContext rpc_session[TEST_RPC_SESSIONS]; static RpcSessionContext rpc_session[TEST_RPC_SESSIONS];
#define TAG "UnitTestsRpc" #define TAG "UnitTestsRpc"
#define MAX_RECEIVE_OUTPUT_TIMEOUT 3000 #define MAX_RECEIVE_OUTPUT_TIMEOUT 3000
#define MAX_NAME_LENGTH 255 #define MAX_NAME_LENGTH 255
#define MAX_DATA_SIZE 512u // have to be exact as in rpc_storage.c #define MAX_DATA_SIZE 512u // have to be exact as in rpc_storage.c
@@ -554,7 +555,7 @@ static bool test_rpc_pb_stream_read(pb_istream_t* istream, pb_byte_t* buf, size_
time_left = MAX(time_left, 0); time_left = MAX(time_left, 0);
bytes_received = bytes_received =
furi_stream_buffer_receive(session_context->output_stream, buf, count, time_left); furi_stream_buffer_receive(session_context->output_stream, buf, count, time_left);
return (count == bytes_received); return count == bytes_received;
} }
static void static void

View File

@@ -11,6 +11,7 @@
#include <lib/subghz/devices/cc1101_configs.h> #include <lib/subghz/devices/cc1101_configs.h>
#define TAG "SubGhzTest" #define TAG "SubGhzTest"
#define KEYSTORE_DIR_NAME EXT_PATH("subghz/assets/keeloq_mfcodes") #define KEYSTORE_DIR_NAME EXT_PATH("subghz/assets/keeloq_mfcodes")
#define CAME_ATOMO_DIR_NAME EXT_PATH("subghz/assets/came_atomo") #define CAME_ATOMO_DIR_NAME EXT_PATH("subghz/assets/came_atomo")
#define NICE_FLOR_S_DIR_NAME EXT_PATH("subghz/assets/nice_flor_s") #define NICE_FLOR_S_DIR_NAME EXT_PATH("subghz/assets/nice_flor_s")

View File

@@ -365,7 +365,7 @@ bool subghz_device_cc1101_ext_is_rx_data_crc_valid(void) {
cc1101_read_reg( cc1101_read_reg(
subghz_device_cc1101_ext->spi_bus_handle, CC1101_STATUS_LQI | CC1101_BURST, data); subghz_device_cc1101_ext->spi_bus_handle, CC1101_STATUS_LQI | CC1101_BURST, data);
furi_hal_spi_release(subghz_device_cc1101_ext->spi_bus_handle); furi_hal_spi_release(subghz_device_cc1101_ext->spi_bus_handle);
if(((data[0] >> 7) & 0x01)) { if((data[0] >> 7) & 0x01) {
return true; return true;
} else { } else {
return false; return false;
@@ -826,9 +826,8 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb
} }
bool subghz_device_cc1101_ext_is_async_tx_complete(void) { bool subghz_device_cc1101_ext_is_async_tx_complete(void) {
return ( return (subghz_device_cc1101_ext->state == SubGhzDeviceCC1101ExtStateAsyncTx) &&
(subghz_device_cc1101_ext->state == SubGhzDeviceCC1101ExtStateAsyncTx) && (LL_TIM_GetAutoReload(TIM17) == 0);
(LL_TIM_GetAutoReload(TIM17) == 0));
} }
void subghz_device_cc1101_ext_stop_async_tx(void) { void subghz_device_cc1101_ext_stop_async_tx(void) {

View File

@@ -5,7 +5,7 @@
#include <string.h> #include <string.h>
#define TAG "ble_beacon_app" #define TAG "BleBeaconApp"
static bool ble_beacon_app_custom_event_callback(void* context, uint32_t event) { static bool ble_beacon_app_custom_event_callback(void* context, uint32_t event) {
furi_assert(context); furi_assert(context);

View File

@@ -360,7 +360,7 @@ bool archive_is_home(ArchiveBrowserView* browser) {
} }
const char* default_path = archive_get_default_path(archive_get_tab(browser)); const char* default_path = archive_get_default_path(archive_get_tab(browser));
return (furi_string_cmp_str(browser->path, default_path) == 0); return furi_string_cmp_str(browser->path, default_path) == 0;
} }
const char* archive_get_name(ArchiveBrowserView* browser) { const char* archive_get_name(ArchiveBrowserView* browser) {

View File

@@ -62,7 +62,7 @@ static inline const char* archive_get_default_path(ArchiveTabEnum tab) {
} }
inline bool archive_is_known_app(ArchiveFileTypeEnum type) { inline bool archive_is_known_app(ArchiveFileTypeEnum type) {
return (type != ArchiveFileTypeFolder && type != ArchiveFileTypeUnknown); return type != ArchiveFileTypeFolder && type != ArchiveFileTypeUnknown;
} }
bool archive_is_item_in_array(ArchiveBrowserViewModel* model, uint32_t idx); bool archive_is_item_in_array(ArchiveBrowserViewModel* model, uint32_t idx);

View File

@@ -9,6 +9,7 @@
#include <dolphin/dolphin.h> #include <dolphin/dolphin.h>
#define TAG "BadUsb" #define TAG "BadUsb"
#define WORKER_TAG TAG "Worker" #define WORKER_TAG TAG "Worker"
#define BADUSB_ASCII_TO_KEY(script, x) \ #define BADUSB_ASCII_TO_KEY(script, x) \
@@ -46,7 +47,7 @@ uint32_t ducky_get_command_len(const char* line) {
} }
bool ducky_is_line_end(const char chr) { bool ducky_is_line_end(const char chr) {
return ((chr == ' ') || (chr == '\0') || (chr == '\r') || (chr == '\n')); return (chr == ' ') || (chr == '\0') || (chr == '\r') || (chr == '\n');
} }
uint16_t ducky_get_keycode(BadUsbScript* bad_usb, const char* param, bool accept_chars) { uint16_t ducky_get_keycode(BadUsbScript* bad_usb, const char* param, bool accept_chars) {
@@ -56,7 +57,7 @@ uint16_t ducky_get_keycode(BadUsbScript* bad_usb, const char* param, bool accept
} }
if((accept_chars) && (strlen(param) > 0)) { if((accept_chars) && (strlen(param) > 0)) {
return (BADUSB_ASCII_TO_KEY(bad_usb, param[0]) & 0xFF); return BADUSB_ASCII_TO_KEY(bad_usb, param[0]) & 0xFF;
} }
return 0; return 0;
} }
@@ -305,7 +306,7 @@ static int32_t ducky_script_execute_next(BadUsbScript* bad_usb, File* script_fil
FURI_LOG_E(WORKER_TAG, "Unknown command at line %zu", bad_usb->st.line_cur - 1U); FURI_LOG_E(WORKER_TAG, "Unknown command at line %zu", bad_usb->st.line_cur - 1U);
return SCRIPT_STATE_ERROR; return SCRIPT_STATE_ERROR;
} else { } else {
return (delay_val + bad_usb->defdelay); return delay_val + bad_usb->defdelay;
} }
} }
@@ -344,7 +345,7 @@ static int32_t ducky_script_execute_next(BadUsbScript* bad_usb, File* script_fil
FURI_LOG_E(WORKER_TAG, "Unknown command at line %zu", bad_usb->st.line_cur); FURI_LOG_E(WORKER_TAG, "Unknown command at line %zu", bad_usb->st.line_cur);
return SCRIPT_STATE_ERROR; return SCRIPT_STATE_ERROR;
} else { } else {
return (delay_val + bad_usb->defdelay); return delay_val + bad_usb->defdelay;
} }
} else { } else {
furi_string_push_back(bad_usb->line, bad_usb->file_buf[i]); furi_string_push_back(bad_usb->line, bad_usb->file_buf[i]);

View File

@@ -216,6 +216,7 @@ static const DuckyCmd ducky_commands[] = {
}; };
#define TAG "BadUsb" #define TAG "BadUsb"
#define WORKER_TAG TAG "Worker" #define WORKER_TAG TAG "Worker"
int32_t ducky_execute_cmd(BadUsbScript* bad_usb, const char* line) { int32_t ducky_execute_cmd(BadUsbScript* bad_usb, const char* line) {
@@ -231,7 +232,7 @@ int32_t ducky_execute_cmd(BadUsbScript* bad_usb, const char* line) {
if(ducky_commands[i].callback == NULL) { if(ducky_commands[i].callback == NULL) {
return 0; return 0;
} else { } else {
return ((ducky_commands[i].callback)(bad_usb, line, ducky_commands[i].param)); return (ducky_commands[i].callback)(bad_usb, line, ducky_commands[i].param);
} }
} }
} }

View File

@@ -31,7 +31,7 @@ static void ibutton_cli_print_usage(void) {
printf("\tCyfral (2 bytes key_data)\r\n"); printf("\tCyfral (2 bytes key_data)\r\n");
printf("\tMetakom (4 bytes key_data), must contain correct parity\r\n"); printf("\tMetakom (4 bytes key_data), must contain correct parity\r\n");
printf("\t<key_data> are hex-formatted\r\n"); printf("\t<key_data> are hex-formatted\r\n");
}; }
static bool ibutton_cli_parse_key(iButtonProtocols* protocols, iButtonKey* key, FuriString* args) { static bool ibutton_cli_parse_key(iButtonProtocols* protocols, iButtonKey* key, FuriString* args) {
bool result = false; bool result = false;
@@ -124,7 +124,7 @@ static void ibutton_cli_read(Cli* cli) {
ibutton_protocols_free(protocols); ibutton_protocols_free(protocols);
furi_event_flag_free(event); furi_event_flag_free(event);
}; }
typedef struct { typedef struct {
FuriEventFlag* event; FuriEventFlag* event;
@@ -226,7 +226,7 @@ void ibutton_cli_emulate(Cli* cli, FuriString* args) {
ibutton_key_free(key); ibutton_key_free(key);
ibutton_worker_free(worker); ibutton_worker_free(worker);
ibutton_protocols_free(protocols); ibutton_protocols_free(protocols);
}; }
void ibutton_cli(Cli* cli, FuriString* args, void* context) { void ibutton_cli(Cli* cli, FuriString* args, void* context) {
UNUSED(cli); UNUSED(cli);

View File

@@ -98,7 +98,7 @@ static bool infrared_move_view_input_callback(InputEvent* event, void* context)
bool consumed = false; bool consumed = false;
if(((event->type == InputTypeShort || event->type == InputTypeRepeat)) && if((event->type == InputTypeShort || event->type == InputTypeRepeat) &&
((event->key == InputKeyUp) || (event->key == InputKeyDown))) { ((event->key == InputKeyUp) || (event->key == InputKeyDown))) {
with_view_model( with_view_model(
move_view->view, move_view->view,

View File

@@ -32,7 +32,7 @@ static void lfrfid_cli_print_usage(void) {
"rfid raw_emulate <filename> - emulate raw data (not very useful, but helps debug protocols)\r\n"); "rfid raw_emulate <filename> - emulate raw data (not very useful, but helps debug protocols)\r\n");
printf( printf(
"rfid raw_analyze <filename> - outputs raw data to the cli and tries to decode it (useful for protocol development)\r\n"); "rfid raw_analyze <filename> - outputs raw data to the cli and tries to decode it (useful for protocol development)\r\n");
}; }
typedef struct { typedef struct {
ProtocolId protocol; ProtocolId protocol;

View File

@@ -5,6 +5,7 @@
#include <nfc/protocols/mf_classic/mf_classic_poller_sync.h> #include <nfc/protocols/mf_classic/mf_classic_poller_sync.h>
#define TAG "HI!" #define TAG "HI!"
#define KEY_LENGTH 6 #define KEY_LENGTH 6
#define HI_KEY_TO_GEN 5 #define HI_KEY_TO_GEN 5
#define UID_LENGTH 7 #define UID_LENGTH 7

View File

@@ -5,6 +5,7 @@
#include <nfc/protocols/mf_classic/mf_classic_poller_sync.h> #include <nfc/protocols/mf_classic/mf_classic_poller_sync.h>
#define TAG "Microel" #define TAG "Microel"
#define KEY_LENGTH 6 #define KEY_LENGTH 6
#define UID_LENGTH 4 #define UID_LENGTH 4

View File

@@ -5,6 +5,7 @@
#include <nfc/protocols/mf_classic/mf_classic_poller_sync.h> #include <nfc/protocols/mf_classic/mf_classic_poller_sync.h>
#define TAG "MiZIP" #define TAG "MiZIP"
#define KEY_LENGTH 6 #define KEY_LENGTH 6
#define MIZIP_KEY_TO_GEN 5 #define MIZIP_KEY_TO_GEN 5
#define UID_LENGTH 4 #define UID_LENGTH 4

View File

@@ -40,7 +40,7 @@ bool parse_datetime(uint16_t date, DateTime* result) {
result->year = 2000 + (date >> 9); result->year = 2000 + (date >> 9);
result->month = date >> 5 & 0x0F; result->month = date >> 5 & 0x0F;
result->day = date & 0x1F; result->day = date & 0x1F;
return (date != 0); return date != 0;
} }
static bool umarsh_parse(const NfcDevice* device, FuriString* parsed_data) { static bool umarsh_parse(const NfcDevice* device, FuriString* parsed_data) {

View File

@@ -21,7 +21,7 @@ void onewire_on_system_start(void) {
static void onewire_cli_print_usage(void) { static void onewire_cli_print_usage(void) {
printf("Usage:\r\n"); printf("Usage:\r\n");
printf("onewire search\r\n"); printf("onewire search\r\n");
}; }
static void onewire_cli_search(Cli* cli) { static void onewire_cli_search(Cli* cli) {
UNUSED(cli); UNUSED(cli);

View File

@@ -2,6 +2,7 @@
#include <lib/subghz/subghz_tx_rx_worker.h> #include <lib/subghz/subghz_tx_rx_worker.h>
#define TAG "SubGhzChat" #define TAG "SubGhzChat"
#define SUBGHZ_CHAT_WORKER_TIMEOUT_BETWEEN_MESSAGES 500 #define SUBGHZ_CHAT_WORKER_TIMEOUT_BETWEEN_MESSAGES 500
struct SubGhzChatWorker { struct SubGhzChatWorker {

View File

@@ -3,6 +3,7 @@
#include <float_tools.h> #include <float_tools.h>
#define TAG "SubGhzThresholdRssi" #define TAG "SubGhzThresholdRssi"
#define THRESHOLD_RSSI_LOW_COUNT 10 #define THRESHOLD_RSSI_LOW_COUNT 10
struct SubGhzThresholdRssi { struct SubGhzThresholdRssi {

View File

@@ -508,22 +508,19 @@ SubGhzProtocolDecoderBase* subghz_txrx_get_decoder(SubGhzTxRx* instance) {
bool subghz_txrx_protocol_is_serializable(SubGhzTxRx* instance) { bool subghz_txrx_protocol_is_serializable(SubGhzTxRx* instance) {
furi_assert(instance); furi_assert(instance);
return ( return (instance->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) ==
(instance->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) == SubGhzProtocolFlag_Save;
SubGhzProtocolFlag_Save);
} }
bool subghz_txrx_protocol_is_transmittable(SubGhzTxRx* instance, bool check_type) { bool subghz_txrx_protocol_is_transmittable(SubGhzTxRx* instance, bool check_type) {
furi_assert(instance); furi_assert(instance);
const SubGhzProtocol* protocol = instance->decoder_result->protocol; const SubGhzProtocol* protocol = instance->decoder_result->protocol;
if(check_type) { if(check_type) {
return ( return ((protocol->flag & SubGhzProtocolFlag_Send) == SubGhzProtocolFlag_Send) &&
((protocol->flag & SubGhzProtocolFlag_Send) == SubGhzProtocolFlag_Send) && protocol->encoder->deserialize && protocol->type == SubGhzProtocolTypeStatic;
protocol->encoder->deserialize && protocol->type == SubGhzProtocolTypeStatic);
} }
return ( return ((protocol->flag & SubGhzProtocolFlag_Send) == SubGhzProtocolFlag_Send) &&
((protocol->flag & SubGhzProtocolFlag_Send) == SubGhzProtocolFlag_Send) && protocol->encoder->deserialize;
protocol->encoder->deserialize);
} }
void subghz_txrx_receiver_set_filter(SubGhzTxRx* instance, SubGhzProtocolFlag filter) { void subghz_txrx_receiver_set_filter(SubGhzTxRx* instance, SubGhzProtocolFlag filter) {

View File

@@ -4,9 +4,10 @@
#include <lib/subghz/protocols/raw.h> #include <lib/subghz/protocols/raw.h>
#include <toolbox/path.h> #include <toolbox/path.h>
#define RAW_FILE_NAME "Raw_signal_"
#define TAG "SubGhzSceneReadRaw" #define TAG "SubGhzSceneReadRaw"
#define RAW_FILE_NAME "Raw_signal_"
bool subghz_scene_read_raw_update_filename(SubGhz* subghz) { bool subghz_scene_read_raw_update_filename(SubGhz* subghz) {
bool ret = false; bool ret = false;
//set the path to read the file //set the path to read the file

View File

@@ -1203,7 +1203,7 @@ static bool
subghz_on_system_start_istream_read(pb_istream_t* istream, pb_byte_t* buf, size_t count) { subghz_on_system_start_istream_read(pb_istream_t* istream, pb_byte_t* buf, size_t count) {
File* file = istream->state; File* file = istream->state;
size_t ret = storage_file_read(file, buf, count); size_t ret = storage_file_read(file, buf, count);
return (count == ret); return count == ret;
} }
static bool subghz_on_system_start_istream_decode_band( static bool subghz_on_system_start_istream_decode_band(

View File

@@ -6,6 +6,7 @@
#define SUBGHZ_HISTORY_MAX 50 #define SUBGHZ_HISTORY_MAX 50
#define SUBGHZ_HISTORY_FREE_HEAP 20480 #define SUBGHZ_HISTORY_FREE_HEAP 20480
#define TAG "SubGhzHistory" #define TAG "SubGhzHistory"
typedef struct { typedef struct {

View File

@@ -408,7 +408,7 @@ void subghz_unlock(SubGhz* subghz) {
bool subghz_is_locked(SubGhz* subghz) { bool subghz_is_locked(SubGhz* subghz) {
furi_assert(subghz); furi_assert(subghz);
return (subghz->lock == SubGhzLockOn); return subghz->lock == SubGhzLockOn;
} }
void subghz_rx_key_state_set(SubGhz* subghz, SubGhzRxKeyState state) { void subghz_rx_key_state_set(SubGhz* subghz, SubGhzRxKeyState state) {

View File

@@ -145,7 +145,7 @@ void subghz_view_receiver_add_item_to_menu(
SubGhzReceiverMenuItemArray_push_raw(model->history->data); SubGhzReceiverMenuItemArray_push_raw(model->history->data);
item_menu->item_str = furi_string_alloc_set(name); item_menu->item_str = furi_string_alloc_set(name);
item_menu->type = type; item_menu->type = type;
if((model->idx == model->history_item - 1)) { if(model->idx == model->history_item - 1) {
model->history_item++; model->history_item++;
model->idx++; model->idx++;
} else { } else {

View File

@@ -46,8 +46,7 @@ typedef struct {
} SubGhzFrequencyAnalyzerModel; } SubGhzFrequencyAnalyzerModel;
static inline uint8_t rssi_sanitize(float rssi) { static inline uint8_t rssi_sanitize(float rssi) {
return ( return !float_is_equal(rssi, 0.f) ? (uint8_t)(rssi - SUBGHZ_FREQUENCY_ANALYZER_THRESHOLD) : 0;
!float_is_equal(rssi, 0.f) ? (uint8_t)(rssi - SUBGHZ_FREQUENCY_ANALYZER_THRESHOLD) : 0);
} }
void subghz_frequency_analyzer_set_callback( void subghz_frequency_analyzer_set_callback(

View File

@@ -6,9 +6,11 @@
#include <gui/elements.h> #include <gui/elements.h>
#include <assets_icons.h> #include <assets_icons.h>
#define SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE 100
#define TAG "SubGhzReadRaw" #define TAG "SubGhzReadRaw"
#define SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE 100
struct SubGhzReadRAW { struct SubGhzReadRAW {
View* view; View* view;
SubGhzReadRAWCallback callback; SubGhzReadRAWCallback callback;

View File

@@ -12,6 +12,7 @@
#include <mbedtls/error.h> #include <mbedtls/error.h>
#define TAG "U2f" #define TAG "U2f"
#define WORKER_TAG TAG "Worker" #define WORKER_TAG TAG "Worker"
#define MCHECK(expr) furi_check((expr) == 0) #define MCHECK(expr) furi_check((expr) == 0)
@@ -315,7 +316,7 @@ static uint16_t u2f_register(U2fData* U2F, uint8_t* buf) {
uint8_t signature_len = u2f_der_encode_signature(resp->cert + cert_len, signature); uint8_t signature_len = u2f_der_encode_signature(resp->cert + cert_len, signature);
memcpy(resp->cert + cert_len + signature_len, state_no_error, 2); memcpy(resp->cert + cert_len + signature_len, state_no_error, 2);
return (sizeof(U2fRegisterResp) + cert_len + signature_len + 2); return sizeof(U2fRegisterResp) + cert_len + signature_len + 2;
} }
static uint16_t u2f_authenticate(U2fData* U2F, uint8_t* buf) { static uint16_t u2f_authenticate(U2fData* U2F, uint8_t* buf) {
@@ -410,7 +411,7 @@ static uint16_t u2f_authenticate(U2fData* U2F, uint8_t* buf) {
if(U2F->callback != NULL) U2F->callback(U2fNotifyAuthSuccess, U2F->context); if(U2F->callback != NULL) U2F->callback(U2fNotifyAuthSuccess, U2F->context);
return (sizeof(U2fAuthResp) + signature_len + 2); return sizeof(U2fAuthResp) + signature_len + 2;
} }
uint16_t u2f_msg_parse(U2fData* U2F, uint8_t* buf, uint16_t len) { uint16_t u2f_msg_parse(U2fData* U2F, uint8_t* buf, uint16_t len) {

View File

@@ -9,6 +9,7 @@
#include <storage/storage.h> #include <storage/storage.h>
#define TAG "U2fHid" #define TAG "U2fHid"
#define WORKER_TAG TAG "Worker" #define WORKER_TAG TAG "Worker"
#define U2F_HID_MAX_PAYLOAD_LEN ((HID_U2F_PACKET_LEN - 7) + 128 * (HID_U2F_PACKET_LEN - 5)) #define U2F_HID_MAX_PAYLOAD_LEN ((HID_U2F_PACKET_LEN - 7) + 128 * (HID_U2F_PACKET_LEN - 5))

View File

@@ -75,7 +75,7 @@ size_t cli_read_timeout(Cli* cli, uint8_t* buffer, size_t size, uint32_t timeout
bool cli_is_connected(Cli* cli) { bool cli_is_connected(Cli* cli) {
furi_check(cli); furi_check(cli);
if(cli->session != NULL) { if(cli->session != NULL) {
return (cli->session->is_connected()); return cli->session->is_connected();
} }
return false; return false;
} }

View File

@@ -15,7 +15,7 @@ void crypto_cli_print_usage(void) {
printf("\thas_key <key_slot:int>\t - Check if secure enclave has key in slot\r\n"); printf("\thas_key <key_slot:int>\t - Check if secure enclave has key in slot\r\n");
printf( printf(
"\tstore_key <key_slot:int> <key_type:str> <key_size:int> <key_data:hex>\t - Store key in secure enclave. !!! NON-REVERSABLE OPERATION - READ MANUAL FIRST !!!\r\n"); "\tstore_key <key_slot:int> <key_type:str> <key_size:int> <key_data:hex>\t - Store key in secure enclave. !!! NON-REVERSABLE OPERATION - READ MANUAL FIRST !!!\r\n");
}; }
void crypto_cli_encrypt(Cli* cli, FuriString* args) { void crypto_cli_encrypt(Cli* cli, FuriString* args) {
int key_slot = 0; int key_slot = 0;

View File

@@ -11,10 +11,11 @@
#include <assets_dolphin_internal.h> #include <assets_dolphin_internal.h>
#include <assets_dolphin_blocking.h> #include <assets_dolphin_blocking.h>
#define TAG "AnimationStorage"
#define ANIMATION_META_FILE "meta.txt" #define ANIMATION_META_FILE "meta.txt"
#define ANIMATION_DIR EXT_PATH("dolphin") #define ANIMATION_DIR EXT_PATH("dolphin")
#define ANIMATION_MANIFEST_FILE ANIMATION_DIR "/manifest.txt" #define ANIMATION_MANIFEST_FILE ANIMATION_DIR "/manifest.txt"
#define TAG "AnimationStorage"
static void animation_storage_free_bubbles(BubbleAnimation* animation); static void animation_storage_free_bubbles(BubbleAnimation* animation);
static void animation_storage_free_frames(BubbleAnimation* animation); static void animation_storage_free_frames(BubbleAnimation* animation);

View File

@@ -117,7 +117,7 @@ static bool browser_filter_by_name(BrowserWorker* browser, FuriString* name, boo
if(is_folder) { if(is_folder) {
// Skip assets folders (if enabled) // Skip assets folders (if enabled)
if(browser->skip_assets) { if(browser->skip_assets) {
return ((furi_string_cmp_str(name, ASSETS_DIR) == 0) ? (false) : (true)); return (furi_string_cmp_str(name, ASSETS_DIR) == 0) ? (false) : (true);
} else { } else {
return true; return true;
} }
@@ -295,7 +295,7 @@ static bool
furi_record_close(RECORD_STORAGE); furi_record_close(RECORD_STORAGE);
return (items_cnt == count); return items_cnt == count;
} }
static int32_t browser_worker(void* context) { static int32_t browser_worker(void* context) {
@@ -509,7 +509,7 @@ void file_browser_worker_folder_enter(BrowserWorker* browser, FuriString* path,
bool file_browser_worker_is_in_start_folder(BrowserWorker* browser) { bool file_browser_worker_is_in_start_folder(BrowserWorker* browser) {
furi_check(browser); furi_check(browser);
return (furi_string_cmp(browser->path_start, browser->path_current) == 0); return furi_string_cmp(browser->path_start, browser->path_current) == 0;
} }
void file_browser_worker_folder_exit(BrowserWorker* browser) { void file_browser_worker_folder_exit(BrowserWorker* browser) {

View File

@@ -157,7 +157,7 @@ void menu_free(Menu* menu) {
View* menu_get_view(Menu* menu) { View* menu_get_view(Menu* menu) {
furi_check(menu); furi_check(menu);
return (menu->view); return menu->view;
} }
void menu_add_item( void menu_add_item(

View File

@@ -132,14 +132,14 @@ static char get_selected_char(TextInputModel* model) {
} }
static bool char_is_lowercase(char letter) { static bool char_is_lowercase(char letter) {
return (letter >= 0x61 && letter <= 0x7A); return letter >= 0x61 && letter <= 0x7A;
} }
static char char_to_uppercase(const char letter) { static char char_to_uppercase(const char letter) {
if(letter == '_') { if(letter == '_') {
return 0x20; return 0x20;
} else if(islower(letter)) { } else if(islower(letter)) {
return (letter - 0x20); return letter - 0x20;
} else { } else {
return letter; return letter;
} }

View File

@@ -11,6 +11,7 @@
#include <loader/firmware_api/firmware_api.h> #include <loader/firmware_api/firmware_api.h>
#define TAG "Loader" #define TAG "Loader"
#define LOADER_MAGIC_THREAD_VALUE 0xDEADBEEF #define LOADER_MAGIC_THREAD_VALUE 0xDEADBEEF
// helpers // helpers

View File

@@ -124,7 +124,7 @@ static void loader_menu_build_menu(LoaderMenuApp* app, LoaderMenu* menu) {
i++, i++,
loader_menu_applications_callback, loader_menu_applications_callback,
(void*)menu); (void*)menu);
}; }
static void loader_menu_build_submenu(LoaderMenuApp* app, LoaderMenu* loader_menu) { static void loader_menu_build_submenu(LoaderMenuApp* app, LoaderMenu* loader_menu) {
for(size_t i = 0; i < FLIPPER_SETTINGS_APPS_COUNT; i++) { for(size_t i = 0; i < FLIPPER_SETTINGS_APPS_COUNT; i++) {

View File

@@ -31,7 +31,7 @@ float locale_fahrenheit_to_celsius(float temp_f) {
} }
float locale_celsius_to_fahrenheit(float temp_c) { float locale_celsius_to_fahrenheit(float temp_c) {
return (temp_c * 1.8f + 32.f); return temp_c * 1.8f + 32.f;
} }
void locale_format_time( void locale_format_time(

View File

@@ -39,7 +39,7 @@ void notification_message_save_settings(NotificationApp* app) {
furi_event_flag_wait( furi_event_flag_wait(
m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever); m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever);
furi_event_flag_free(m.back_event); furi_event_flag_free(m.back_event);
}; }
// internal layer // internal layer
static void static void
@@ -143,17 +143,16 @@ static void notification_apply_notification_leds(NotificationApp* app, const uin
// settings // settings
uint8_t notification_settings_get_display_brightness(NotificationApp* app, uint8_t value) { uint8_t notification_settings_get_display_brightness(NotificationApp* app, uint8_t value) {
return (value * app->settings.display_brightness); return value * app->settings.display_brightness;
} }
static uint8_t notification_settings_get_rgb_led_brightness(NotificationApp* app, uint8_t value) { static uint8_t notification_settings_get_rgb_led_brightness(NotificationApp* app, uint8_t value) {
return (value * app->settings.led_brightness); return value * app->settings.led_brightness;
} }
static uint32_t notification_settings_display_off_delay_ticks(NotificationApp* app) { static uint32_t notification_settings_display_off_delay_ticks(NotificationApp* app) {
return ( return (float)(app->settings.display_off_delay_ms) /
(float)(app->settings.display_off_delay_ms) / (1000.0f / furi_kernel_get_tick_frequency());
(1000.0f / furi_kernel_get_tick_frequency()));
} }
// generics // generics
@@ -471,7 +470,7 @@ static bool notification_load_settings(NotificationApp* app) {
furi_record_close(RECORD_STORAGE); furi_record_close(RECORD_STORAGE);
return fs_result; return fs_result;
}; }
static bool notification_save_settings(NotificationApp* app) { static bool notification_save_settings(NotificationApp* app) {
NotificationSettings settings; NotificationSettings settings;
@@ -506,7 +505,7 @@ static bool notification_save_settings(NotificationApp* app) {
furi_record_close(RECORD_STORAGE); furi_record_close(RECORD_STORAGE);
return fs_result; return fs_result;
}; }
static void input_event_callback(const void* value, void* context) { static void input_event_callback(const void* value, void* context) {
furi_assert(value); furi_assert(value);
@@ -555,7 +554,7 @@ static NotificationApp* notification_app_alloc(void) {
notification_message(app, &sequence_display_backlight_on); notification_message(app, &sequence_display_backlight_on);
return app; return app;
}; }
// App // App
int32_t notification_srv(void* p) { int32_t notification_srv(void* p) {
@@ -598,4 +597,4 @@ int32_t notification_srv(void* p) {
} }
return 0; return 0;
}; }

View File

@@ -10,7 +10,7 @@ void notification_message(NotificationApp* app, const NotificationSequence* sequ
NotificationAppMessage m = { NotificationAppMessage m = {
.type = NotificationLayerMessage, .sequence = sequence, .back_event = NULL}; .type = NotificationLayerMessage, .sequence = sequence, .back_event = NULL};
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk); furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
}; }
void notification_internal_message(NotificationApp* app, const NotificationSequence* sequence) { void notification_internal_message(NotificationApp* app, const NotificationSequence* sequence) {
furi_check(app); furi_check(app);
@@ -19,7 +19,7 @@ void notification_internal_message(NotificationApp* app, const NotificationSeque
NotificationAppMessage m = { NotificationAppMessage m = {
.type = InternalLayerMessage, .sequence = sequence, .back_event = NULL}; .type = InternalLayerMessage, .sequence = sequence, .back_event = NULL};
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk); furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
}; }
void notification_message_block(NotificationApp* app, const NotificationSequence* sequence) { void notification_message_block(NotificationApp* app, const NotificationSequence* sequence) {
furi_check(app); furi_check(app);
@@ -33,7 +33,7 @@ void notification_message_block(NotificationApp* app, const NotificationSequence
furi_event_flag_wait( furi_event_flag_wait(
m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever); m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever);
furi_event_flag_free(m.back_event); furi_event_flag_free(m.back_event);
}; }
void notification_internal_message_block( void notification_internal_message_block(
NotificationApp* app, NotificationApp* app,
@@ -47,4 +47,4 @@ void notification_internal_message_block(
furi_event_flag_wait( furi_event_flag_wait(
m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever); m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever);
furi_event_flag_free(m.back_event); furi_event_flag_free(m.back_event);
}; }

View File

@@ -3,9 +3,10 @@
#include <furi.h> #include <furi.h>
#include <furi_hal.h> #include <furi_hal.h>
#define POWER_OFF_TIMEOUT 90
#define TAG "Power" #define TAG "Power"
#define POWER_OFF_TIMEOUT 90
void power_draw_battery_callback(Canvas* canvas, void* context) { void power_draw_battery_callback(Canvas* canvas, void* context) {
furi_assert(context); furi_assert(context);
Power* power = context; Power* power = context;

View File

@@ -232,7 +232,7 @@ bool rpc_pb_stream_read(pb_istream_t* istream, pb_byte_t* buf, size_t count) {
rpc_debug_print_data("INPUT", buf, bytes_received); rpc_debug_print_data("INPUT", buf, bytes_received);
#endif #endif
return (count == bytes_received); return count == bytes_received;
} }
static bool rpc_pb_content_callback(pb_istream_t* stream, const pb_field_t* field, void** arg) { static bool rpc_pb_content_callback(pb_istream_t* stream, const pb_field_t* field, void** arg) {

View File

@@ -40,5 +40,5 @@ const char* filesystem_api_error_get_desc(FS_Error error_id) {
bool file_info_is_dir(const FileInfo* file_info) { bool file_info_is_dir(const FileInfo* file_info) {
furi_check(file_info); furi_check(file_info);
return (file_info->flags & FSF_DIRECTORY); return file_info->flags & FSF_DIRECTORY;
} }

View File

@@ -66,7 +66,7 @@ static void storage_cli_info(Cli* cli, FuriString* path, FuriString* args) {
} }
furi_record_close(RECORD_STORAGE); furi_record_close(RECORD_STORAGE);
}; }
static void storage_cli_format(Cli* cli, FuriString* path, FuriString* args) { static void storage_cli_format(Cli* cli, FuriString* path, FuriString* args) {
UNUSED(args); UNUSED(args);
@@ -93,7 +93,7 @@ static void storage_cli_format(Cli* cli, FuriString* path, FuriString* args) {
} else { } else {
storage_cli_print_usage(); storage_cli_print_usage();
} }
}; }
static void storage_cli_list(Cli* cli, FuriString* path, FuriString* args) { static void storage_cli_list(Cli* cli, FuriString* path, FuriString* args) {
UNUSED(cli); UNUSED(cli);
@@ -241,7 +241,7 @@ static void storage_cli_write(Cli* cli, FuriString* path, FuriString* args) {
fflush(stdout); fflush(stdout);
read_index++; read_index++;
if(((read_index % buffer_size) == 0)) { if((read_index % buffer_size) == 0) {
size_t written_size = storage_file_write(file, buffer, buffer_size); size_t written_size = storage_file_write(file, buffer, buffer_size);
if(written_size != buffer_size) { if(written_size != buffer_size) {
@@ -630,7 +630,7 @@ static void storage_cli_print_usage(void) {
printf( printf(
"\t%s%s - %s\r\n", cli_cmd, strlen(cli_cmd) > 8 ? "\t" : "\t\t", command_descr->help); "\t%s%s - %s\r\n", cli_cmd, strlen(cli_cmd) > 8 ? "\t" : "\t\t", command_descr->help);
} }
}; }
void storage_cli(Cli* cli, FuriString* args, void* context) { void storage_cli(Cli* cli, FuriString* args, void* context) {
UNUSED(context); UNUSED(context);

View File

@@ -929,12 +929,12 @@ File* storage_file_alloc(Storage* storage) {
bool storage_file_is_open(File* file) { bool storage_file_is_open(File* file) {
furi_check(file); furi_check(file);
return (file->type != FileTypeClosed); return file->type != FileTypeClosed;
} }
bool storage_file_is_dir(File* file) { bool storage_file_is_dir(File* file) {
furi_check(file); furi_check(file);
return (file->type == FileTypeOpenDir); return file->type == FileTypeOpenDir;
} }
void storage_file_free(File* file) { void storage_file_free(File* file) {

View File

@@ -8,7 +8,12 @@
extern "C" { extern "C" {
#endif #endif
typedef enum { ST_EXT = 0, ST_INT = 1, ST_ANY, ST_ERROR } StorageType; typedef enum {
ST_EXT = 0,
ST_INT = 1,
ST_ANY,
ST_ERROR
} StorageType;
typedef struct StorageData StorageData; typedef struct StorageData StorageData;

View File

@@ -337,7 +337,7 @@ static bool storage_ext_file_open(
file->internal_error_id = f_open(file_data, path, _mode); file->internal_error_id = f_open(file_data, path, _mode);
file->error_id = storage_ext_parse_error(file->internal_error_id); file->error_id = storage_ext_parse_error(file->internal_error_id);
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
} }
static bool storage_ext_file_close(void* ctx, File* file) { static bool storage_ext_file_close(void* ctx, File* file) {
@@ -347,7 +347,7 @@ static bool storage_ext_file_close(void* ctx, File* file) {
file->error_id = storage_ext_parse_error(file->internal_error_id); file->error_id = storage_ext_parse_error(file->internal_error_id);
free(file_data); free(file_data);
storage_set_storage_file_data(file, NULL, storage); storage_set_storage_file_data(file, NULL, storage);
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
} }
static uint16_t static uint16_t
@@ -392,7 +392,7 @@ static bool
} }
file->error_id = storage_ext_parse_error(file->internal_error_id); file->error_id = storage_ext_parse_error(file->internal_error_id);
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
} }
static uint64_t storage_ext_file_tell(void* ctx, File* file) { static uint64_t storage_ext_file_tell(void* ctx, File* file) {
@@ -416,7 +416,7 @@ static bool storage_ext_file_truncate(void* ctx, File* file) {
file->internal_error_id = f_truncate(file_data); file->internal_error_id = f_truncate(file_data);
file->error_id = storage_ext_parse_error(file->internal_error_id); file->error_id = storage_ext_parse_error(file->internal_error_id);
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
#endif #endif
} }
@@ -431,7 +431,7 @@ static bool storage_ext_file_sync(void* ctx, File* file) {
file->internal_error_id = f_sync(file_data); file->internal_error_id = f_sync(file_data);
file->error_id = storage_ext_parse_error(file->internal_error_id); file->error_id = storage_ext_parse_error(file->internal_error_id);
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
#endif #endif
} }
@@ -464,7 +464,7 @@ static bool storage_ext_dir_open(void* ctx, File* file, const char* path) {
storage_set_storage_file_data(file, file_data, storage); storage_set_storage_file_data(file, file_data, storage);
file->internal_error_id = f_opendir(file_data, path); file->internal_error_id = f_opendir(file_data, path);
file->error_id = storage_ext_parse_error(file->internal_error_id); file->error_id = storage_ext_parse_error(file->internal_error_id);
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
} }
static bool storage_ext_dir_close(void* ctx, File* file) { static bool storage_ext_dir_close(void* ctx, File* file) {
@@ -474,7 +474,7 @@ static bool storage_ext_dir_close(void* ctx, File* file) {
file->internal_error_id = f_closedir(file_data); file->internal_error_id = f_closedir(file_data);
file->error_id = storage_ext_parse_error(file->internal_error_id); file->error_id = storage_ext_parse_error(file->internal_error_id);
free(file_data); free(file_data);
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
} }
static bool storage_ext_dir_read( static bool storage_ext_dir_read(
@@ -505,7 +505,7 @@ static bool storage_ext_dir_read(
file->error_id = FSE_NOT_EXIST; file->error_id = FSE_NOT_EXIST;
} }
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
} }
static bool storage_ext_dir_rewind(void* ctx, File* file) { static bool storage_ext_dir_rewind(void* ctx, File* file) {
@@ -514,7 +514,7 @@ static bool storage_ext_dir_rewind(void* ctx, File* file) {
file->internal_error_id = f_readdir(file_data, NULL); file->internal_error_id = f_readdir(file_data, NULL);
file->error_id = storage_ext_parse_error(file->internal_error_id); file->error_id = storage_ext_parse_error(file->internal_error_id);
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
} }
/******************* Common FS Functions *******************/ /******************* Common FS Functions *******************/

View File

@@ -4,6 +4,7 @@
#include <toolbox/path.h> #include <toolbox/path.h>
#define TAG "StorageInt" #define TAG "StorageInt"
#define STORAGE_PATH STORAGE_INT_PATH_PREFIX #define STORAGE_PATH STORAGE_INT_PATH_PREFIX
#define LFS_CLEAN_FINGERPRINT 0 #define LFS_CLEAN_FINGERPRINT 0
@@ -160,7 +161,7 @@ static LFSData* storage_int_lfs_data_alloc(void) {
lfs_data->config.lookahead_size = 16; lfs_data->config.lookahead_size = 16;
return lfs_data; return lfs_data;
}; }
// Returns true if fingerprint was invalid and LFS reformatting is needed // Returns true if fingerprint was invalid and LFS reformatting is needed
static bool storage_int_check_and_set_fingerprint(LFSData* lfs_data) { static bool storage_int_check_and_set_fingerprint(LFSData* lfs_data) {
@@ -287,7 +288,7 @@ static bool storage_int_check_for_free_space(StorageData* storage) {
lfs_size_t free_space = lfs_size_t free_space =
(lfs_data->config.block_count - result) * lfs_data->config.block_size; (lfs_data->config.block_count - result) * lfs_data->config.block_size;
return (free_space > LFS_RESERVED_PAGES_COUNT * furi_hal_flash_get_page_size()); return free_space > LFS_RESERVED_PAGES_COUNT * furi_hal_flash_get_page_size();
} }
return false; return false;
@@ -344,7 +345,7 @@ static bool storage_int_file_open(
file->error_id = storage_int_parse_error(file->internal_error_id); file->error_id = storage_int_parse_error(file->internal_error_id);
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
} }
static bool storage_int_file_close(void* ctx, File* file) { static bool storage_int_file_close(void* ctx, File* file) {
@@ -360,7 +361,7 @@ static bool storage_int_file_close(void* ctx, File* file) {
file->error_id = storage_int_parse_error(file->internal_error_id); file->error_id = storage_int_parse_error(file->internal_error_id);
lfs_handle_free(handle); lfs_handle_free(handle);
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
} }
static uint16_t static uint16_t
@@ -430,7 +431,7 @@ static bool
} }
file->error_id = storage_int_parse_error(file->internal_error_id); file->error_id = storage_int_parse_error(file->internal_error_id);
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
} }
static uint64_t storage_int_file_tell(void* ctx, File* file) { static uint64_t storage_int_file_tell(void* ctx, File* file) {
@@ -475,7 +476,7 @@ static bool storage_int_file_truncate(void* ctx, File* file) {
file->error_id = storage_int_parse_error(file->internal_error_id); file->error_id = storage_int_parse_error(file->internal_error_id);
} }
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
} }
static bool storage_int_file_sync(void* ctx, File* file) { static bool storage_int_file_sync(void* ctx, File* file) {
@@ -490,7 +491,7 @@ static bool storage_int_file_sync(void* ctx, File* file) {
} }
file->error_id = storage_int_parse_error(file->internal_error_id); file->error_id = storage_int_parse_error(file->internal_error_id);
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
} }
static uint64_t storage_int_file_size(void* ctx, File* file) { static uint64_t storage_int_file_size(void* ctx, File* file) {
@@ -557,7 +558,7 @@ static bool storage_int_dir_open(void* ctx, File* file, const char* path) {
} }
file->error_id = storage_int_parse_error(file->internal_error_id); file->error_id = storage_int_parse_error(file->internal_error_id);
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
} }
static bool storage_int_dir_close(void* ctx, File* file) { static bool storage_int_dir_close(void* ctx, File* file) {
@@ -573,7 +574,7 @@ static bool storage_int_dir_close(void* ctx, File* file) {
file->error_id = storage_int_parse_error(file->internal_error_id); file->error_id = storage_int_parse_error(file->internal_error_id);
lfs_handle_free(handle); lfs_handle_free(handle);
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
} }
static bool storage_int_dir_read( static bool storage_int_dir_read(
@@ -614,7 +615,7 @@ static bool storage_int_dir_read(
file->error_id = storage_int_parse_error(file->internal_error_id); file->error_id = storage_int_parse_error(file->internal_error_id);
} }
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
} }
static bool storage_int_dir_rewind(void* ctx, File* file) { static bool storage_int_dir_rewind(void* ctx, File* file) {
@@ -629,7 +630,7 @@ static bool storage_int_dir_rewind(void* ctx, File* file) {
} }
file->error_id = storage_int_parse_error(file->internal_error_id); file->error_id = storage_int_parse_error(file->internal_error_id);
return (file->error_id == FSE_OK); return file->error_id == FSE_OK;
} }
/******************* Common FS Functions *******************/ /******************* Common FS Functions *******************/

View File

@@ -31,4 +31,7 @@ typedef enum {
PowerSettingsAppViewDialog, PowerSettingsAppViewDialog,
} PowerSettingsAppView; } PowerSettingsAppView;
typedef enum { RebootTypeDFU, RebootTypeNormal } RebootType; typedef enum {
RebootTypeDFU,
RebootTypeNormal
} RebootType;

View File

@@ -18,7 +18,7 @@ static void draw_stat(Canvas* canvas, int x, int y, const Icon* icon, char* val)
canvas_draw_box(canvas, x - 4, y + 16, 24, 6); canvas_draw_box(canvas, x - 4, y + 16, 24, 6);
canvas_set_color(canvas, ColorBlack); canvas_set_color(canvas, ColorBlack);
canvas_draw_str_aligned(canvas, x + 8, y + 22, AlignCenter, AlignBottom, val); canvas_draw_str_aligned(canvas, x + 8, y + 22, AlignCenter, AlignBottom, val);
}; }
static void draw_battery(Canvas* canvas, BatteryInfoModel* data, int x, int y) { static void draw_battery(Canvas* canvas, BatteryInfoModel* data, int x, int y) {
char emote[20] = {}; char emote[20] = {};
@@ -88,7 +88,7 @@ static void draw_battery(Canvas* canvas, BatteryInfoModel* data, int x, int y) {
canvas_draw_str_aligned(canvas, 92, y + 3, AlignCenter, AlignCenter, emote); canvas_draw_str_aligned(canvas, 92, y + 3, AlignCenter, AlignCenter, emote);
canvas_draw_str_aligned(canvas, 92, y + 15, AlignCenter, AlignCenter, header); canvas_draw_str_aligned(canvas, 92, y + 15, AlignCenter, AlignCenter, header);
canvas_draw_str_aligned(canvas, 92, y + 27, AlignCenter, AlignCenter, value); canvas_draw_str_aligned(canvas, 92, y + 27, AlignCenter, AlignCenter, value);
}; }
static void battery_info_draw_callback(Canvas* canvas, void* context) { static void battery_info_draw_callback(Canvas* canvas, void* context) {
furi_assert(context); furi_assert(context);

View File

@@ -5,6 +5,7 @@
#include "hid_icons.h" #include "hid_icons.h"
#define TAG "HidMouseClicker" #define TAG "HidMouseClicker"
#define DEFAULT_CLICK_RATE 1 #define DEFAULT_CLICK_RATE 1
#define MAXIMUM_CLICK_RATE 60 #define MAXIMUM_CLICK_RATE 60

View File

@@ -159,7 +159,7 @@ static void js_badusb_is_connected(struct mjs* mjs) {
uint16_t get_keycode_by_name(const char* key_name, size_t name_len) { uint16_t get_keycode_by_name(const char* key_name, size_t name_len) {
if(name_len == 1) { // Single char if(name_len == 1) { // Single char
return (HID_ASCII_TO_KEY(key_name[0])); return HID_ASCII_TO_KEY(key_name[0]);
} }
for(size_t i = 0; i < COUNT_OF(key_codes); i++) { for(size_t i = 0; i < COUNT_OF(key_codes); i++) {

View File

@@ -3,7 +3,8 @@
#include "../js_modules.h" #include "../js_modules.h"
#include <m-array.h> #include <m-array.h>
#define TAG "js_serial" #define TAG "JsSerial"
#define RX_BUF_LEN 2048 #define RX_BUF_LEN 2048
typedef struct { typedef struct {
@@ -444,14 +445,14 @@ static int32_t js_serial_expect_check_pattern_start(
int32_t pattern_last) { int32_t pattern_last) {
size_t array_len = PatternArray_size(patterns); size_t array_len = PatternArray_size(patterns);
if((pattern_last + 1) >= (int32_t)array_len) { if((pattern_last + 1) >= (int32_t)array_len) {
return (-1); return -1;
} }
for(size_t i = pattern_last + 1; i < array_len; i++) { for(size_t i = pattern_last + 1; i < array_len; i++) {
if(PatternArray_get(patterns, i)->data[0] == value) { if(PatternArray_get(patterns, i)->data[0] == value) {
return i; return i;
} }
} }
return (-1); return -1;
} }
static void js_serial_expect(struct mjs* mjs) { static void js_serial_expect(struct mjs* mjs) {

View File

@@ -17,7 +17,7 @@ static bool storage_move_to_sd_check_entry(const char* name, FileInfo* fileinfo,
return true; return true;
} }
return (name && (*name != '.')); return name && (*name != '.');
} }
bool storage_move_to_sd_perform(void) { bool storage_move_to_sd_perform(void) {

View File

@@ -36,7 +36,7 @@ static bool page_task_compare_flash(
const uint8_t* update_block, const uint8_t* update_block,
uint16_t update_block_len) { uint16_t update_block_len) {
const size_t page_addr = furi_hal_flash_get_base() + furi_hal_flash_get_page_size() * i_page; const size_t page_addr = furi_hal_flash_get_base() + furi_hal_flash_get_page_size() * i_page;
return (memcmp(update_block, (void*)page_addr, update_block_len) == 0); return memcmp(update_block, (void*)page_addr, update_block_len) == 0;
} }
/* Verifies a flash operation address for fitting into writable memory /* Verifies a flash operation address for fitting into writable memory
@@ -44,7 +44,7 @@ static bool page_task_compare_flash(
static bool check_address_boundaries(const size_t address) { static bool check_address_boundaries(const size_t address) {
const size_t min_allowed_address = furi_hal_flash_get_base(); const size_t min_allowed_address = furi_hal_flash_get_base();
const size_t max_allowed_address = (size_t)furi_hal_flash_get_free_end_address(); const size_t max_allowed_address = (size_t)furi_hal_flash_get_free_end_address();
return ((address >= min_allowed_address) && (address < max_allowed_address)); return (address >= min_allowed_address) && (address < max_allowed_address);
} }
static bool update_task_flash_program_page( static bool update_task_flash_program_page(

View File

@@ -29,7 +29,7 @@ bool furi_kernel_is_irq_or_masked(void) {
} }
/* Return context, 0: thread context, 1: IRQ context */ /* Return context, 0: thread context, 1: IRQ context */
return (irq); return irq;
} }
bool furi_kernel_is_running(void) { bool furi_kernel_is_running(void) {
@@ -58,7 +58,7 @@ int32_t furi_kernel_lock(void) {
} }
/* Return previous lock state */ /* Return previous lock state */
return (lock); return lock;
} }
int32_t furi_kernel_unlock(void) { int32_t furi_kernel_unlock(void) {
@@ -88,7 +88,7 @@ int32_t furi_kernel_unlock(void) {
} }
/* Return previous lock state */ /* Return previous lock state */
return (lock); return lock;
} }
int32_t furi_kernel_restore_lock(int32_t lock) { int32_t furi_kernel_restore_lock(int32_t lock) {
@@ -119,12 +119,12 @@ int32_t furi_kernel_restore_lock(int32_t lock) {
} }
/* Return new lock state */ /* Return new lock state */
return (lock); return lock;
} }
uint32_t furi_kernel_get_tick_frequency(void) { uint32_t furi_kernel_get_tick_frequency(void) {
/* Return frequency in hertz */ /* Return frequency in hertz */
return (configTICK_RATE_HZ_RAW); return configTICK_RATE_HZ_RAW;
} }
void furi_delay_tick(uint32_t ticks) { void furi_delay_tick(uint32_t ticks) {
@@ -160,7 +160,7 @@ FuriStatus furi_delay_until_tick(uint32_t tick) {
} }
/* Return execution status */ /* Return execution status */
return (stat); return stat;
} }
uint32_t furi_get_tick(void) { uint32_t furi_get_tick(void) {

View File

@@ -528,7 +528,7 @@ void vPortFree(void* pv) {
xFreeBytesRemaining += pxLink->xBlockSize; xFreeBytesRemaining += pxLink->xBlockSize;
traceFREE(pv, pxLink->xBlockSize); traceFREE(pv, pxLink->xBlockSize);
memset(pv, 0, pxLink->xBlockSize - xHeapStructSize); memset(pv, 0, pxLink->xBlockSize - xHeapStructSize);
prvInsertBlockIntoFreeList(((BlockLink_t*)pxLink)); prvInsertBlockIntoFreeList((BlockLink_t*)pxLink);
} }
(void)xTaskResumeAll(); (void)xTaskResumeAll();
} else { } else {

View File

@@ -29,20 +29,20 @@ FuriStreamBuffer* furi_stream_buffer_alloc(size_t size, size_t trigger_level) {
furi_check(hStreamBuffer == (StreamBufferHandle_t)stream_buffer); furi_check(hStreamBuffer == (StreamBufferHandle_t)stream_buffer);
return stream_buffer; return stream_buffer;
}; }
void furi_stream_buffer_free(FuriStreamBuffer* stream_buffer) { void furi_stream_buffer_free(FuriStreamBuffer* stream_buffer) {
furi_check(stream_buffer); furi_check(stream_buffer);
vStreamBufferDelete((StreamBufferHandle_t)stream_buffer); vStreamBufferDelete((StreamBufferHandle_t)stream_buffer);
free(stream_buffer); free(stream_buffer);
}; }
bool furi_stream_set_trigger_level(FuriStreamBuffer* stream_buffer, size_t trigger_level) { bool furi_stream_set_trigger_level(FuriStreamBuffer* stream_buffer, size_t trigger_level) {
furi_check(stream_buffer); furi_check(stream_buffer);
return xStreamBufferSetTriggerLevel((StreamBufferHandle_t)stream_buffer, trigger_level) == return xStreamBufferSetTriggerLevel((StreamBufferHandle_t)stream_buffer, trigger_level) ==
pdTRUE; pdTRUE;
}; }
size_t furi_stream_buffer_send( size_t furi_stream_buffer_send(
FuriStreamBuffer* stream_buffer, FuriStreamBuffer* stream_buffer,
@@ -62,7 +62,7 @@ size_t furi_stream_buffer_send(
} }
return ret; return ret;
}; }
size_t furi_stream_buffer_receive( size_t furi_stream_buffer_receive(
FuriStreamBuffer* stream_buffer, FuriStreamBuffer* stream_buffer,
@@ -89,25 +89,25 @@ size_t furi_stream_buffer_bytes_available(FuriStreamBuffer* stream_buffer) {
furi_check(stream_buffer); furi_check(stream_buffer);
return xStreamBufferBytesAvailable((StreamBufferHandle_t)stream_buffer); return xStreamBufferBytesAvailable((StreamBufferHandle_t)stream_buffer);
}; }
size_t furi_stream_buffer_spaces_available(FuriStreamBuffer* stream_buffer) { size_t furi_stream_buffer_spaces_available(FuriStreamBuffer* stream_buffer) {
furi_check(stream_buffer); furi_check(stream_buffer);
return xStreamBufferSpacesAvailable((StreamBufferHandle_t)stream_buffer); return xStreamBufferSpacesAvailable((StreamBufferHandle_t)stream_buffer);
}; }
bool furi_stream_buffer_is_full(FuriStreamBuffer* stream_buffer) { bool furi_stream_buffer_is_full(FuriStreamBuffer* stream_buffer) {
furi_check(stream_buffer); furi_check(stream_buffer);
return xStreamBufferIsFull((StreamBufferHandle_t)stream_buffer) == pdTRUE; return xStreamBufferIsFull((StreamBufferHandle_t)stream_buffer) == pdTRUE;
}; }
bool furi_stream_buffer_is_empty(FuriStreamBuffer* stream_buffer) { bool furi_stream_buffer_is_empty(FuriStreamBuffer* stream_buffer) {
furi_check(stream_buffer); furi_check(stream_buffer);
return (xStreamBufferIsEmpty((StreamBufferHandle_t)stream_buffer) == pdTRUE); return xStreamBufferIsEmpty((StreamBufferHandle_t)stream_buffer) == pdTRUE;
}; }
FuriStatus furi_stream_buffer_reset(FuriStreamBuffer* stream_buffer) { FuriStatus furi_stream_buffer_reset(FuriStreamBuffer* stream_buffer) {
furi_check(stream_buffer); furi_check(stream_buffer);

View File

@@ -17,7 +17,7 @@ public:
RecordController(const char* record_name) { RecordController(const char* record_name) {
name = record_name; name = record_name;
value = static_cast<TRecordClass*>(furi_record_open(name)); value = static_cast<TRecordClass*>(furi_record_open(name));
}; }
~RecordController() { ~RecordController() {
furi_record_close(name); furi_record_close(name);

View File

@@ -50,7 +50,8 @@ struct type_index {
* Creates a type_index object for the specified type. * Creates a type_index object for the specified type.
*/ */
template <typename T> template <typename T>
type_index(tag_type<T>) noexcept : hash_code_{index<T>} { type_index(tag_type<T>) noexcept
: hash_code_{index<T>} {
} }
/** /**

View File

@@ -27,7 +27,7 @@ public:
0)...); 0)...);
gui = static_cast<Gui*>(furi_record_open("gui")); gui = static_cast<Gui*>(furi_record_open("gui"));
}; }
~ViewController() { ~ViewController() {
for(auto& it : holder) { for(auto& it : holder) {

View File

@@ -253,5 +253,5 @@ bool st25r3916_check_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t mask,
uint8_t reg_val = 0; uint8_t reg_val = 0;
st25r3916_read_reg(handle, reg, &reg_val); st25r3916_read_reg(handle, reg, &reg_val);
return ((reg_val & mask) == val); return (reg_val & mask) == val;
} }

View File

@@ -122,7 +122,11 @@ bool flipper_format_stream_seek_to_key(Stream* stream, const char* key, bool str
} }
static bool flipper_format_stream_read_value(Stream* stream, FuriString* value, bool* last) { static bool flipper_format_stream_read_value(Stream* stream, FuriString* value, bool* last) {
enum { LeadingSpace, ReadValue, TrailingSpace } state = LeadingSpace; enum {
LeadingSpace,
ReadValue,
TrailingSpace
} state = LeadingSpace;
const size_t buffer_size = 32; const size_t buffer_size = 32;
uint8_t buffer[buffer_size]; uint8_t buffer[buffer_size];
bool result = false; bool result = false;

View File

@@ -71,7 +71,7 @@ bool lfrfid_raw_file_write_header(
.max_buffer_size = max_buffer_size}; .max_buffer_size = max_buffer_size};
size_t size = stream_write(file->stream, (uint8_t*)&header, sizeof(LFRFIDRawFileHeader)); size_t size = stream_write(file->stream, (uint8_t*)&header, sizeof(LFRFIDRawFileHeader));
return (size == sizeof(LFRFIDRawFileHeader)); return size == sizeof(LFRFIDRawFileHeader);
} }
bool lfrfid_raw_file_write_buffer(LFRFIDRawFile* file, uint8_t* buffer_data, size_t buffer_size) { bool lfrfid_raw_file_write_buffer(LFRFIDRawFile* file, uint8_t* buffer_data, size_t buffer_size) {

View File

@@ -141,7 +141,7 @@ void lfrfid_worker_stop_thread(LFRFIDWorker* worker) {
bool lfrfid_worker_check_for_stop(LFRFIDWorker* worker) { bool lfrfid_worker_check_for_stop(LFRFIDWorker* worker) {
UNUSED(worker); UNUSED(worker);
uint32_t flags = furi_thread_flags_get(); uint32_t flags = furi_thread_flags_get();
return (flags & LFRFIDEventStopMode); return flags & LFRFIDEventStopMode;
} }
size_t lfrfid_worker_dict_get_data_size(LFRFIDWorker* worker, LFRFIDProtocol protocol) { size_t lfrfid_worker_dict_get_data_size(LFRFIDWorker* worker, LFRFIDProtocol protocol) {

View File

@@ -37,21 +37,21 @@ ProtocolAwid* protocol_awid_alloc(void) {
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50); protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
return protocol; return protocol;
}; }
void protocol_awid_free(ProtocolAwid* protocol) { void protocol_awid_free(ProtocolAwid* protocol) {
fsk_demod_free(protocol->decoder.fsk_demod); fsk_demod_free(protocol->decoder.fsk_demod);
fsk_osc_free(protocol->encoder.fsk_osc); fsk_osc_free(protocol->encoder.fsk_osc);
free(protocol); free(protocol);
}; }
uint8_t* protocol_awid_get_data(ProtocolAwid* protocol) { uint8_t* protocol_awid_get_data(ProtocolAwid* protocol) {
return protocol->data; return protocol->data;
}; }
void protocol_awid_decoder_start(ProtocolAwid* protocol) { void protocol_awid_decoder_start(ProtocolAwid* protocol) {
memset(protocol->encoded_data, 0, AWID_ENCODED_DATA_SIZE); memset(protocol->encoded_data, 0, AWID_ENCODED_DATA_SIZE);
}; }
static bool protocol_awid_can_be_decoded(uint8_t* data) { static bool protocol_awid_can_be_decoded(uint8_t* data) {
bool result = false; bool result = false;
@@ -112,7 +112,7 @@ bool protocol_awid_decoder_feed(ProtocolAwid* protocol, bool level, uint32_t dur
} }
return result; return result;
}; }
static void protocol_awid_encode(const uint8_t* decoded_data, uint8_t* encoded_data) { static void protocol_awid_encode(const uint8_t* decoded_data, uint8_t* encoded_data) {
memset(encoded_data, 0, AWID_ENCODED_DATA_SIZE); memset(encoded_data, 0, AWID_ENCODED_DATA_SIZE);
@@ -125,14 +125,14 @@ static void protocol_awid_encode(const uint8_t* decoded_data, uint8_t* encoded_d
value |= bit_lib_test_parity_32(value, BitLibParityOdd); value |= bit_lib_test_parity_32(value, BitLibParityOdd);
bit_lib_set_bits(encoded_data, 8 + i * 4, value, 4); bit_lib_set_bits(encoded_data, 8 + i * 4, value, 4);
} }
}; }
bool protocol_awid_encoder_start(ProtocolAwid* protocol) { bool protocol_awid_encoder_start(ProtocolAwid* protocol) {
protocol_awid_encode(protocol->data, (uint8_t*)protocol->encoded_data); protocol_awid_encode(protocol->data, (uint8_t*)protocol->encoded_data);
protocol->encoder.encoded_index = 0; protocol->encoder.encoded_index = 0;
fsk_osc_reset(protocol->encoder.fsk_osc); fsk_osc_reset(protocol->encoder.fsk_osc);
return true; return true;
}; }
LevelDuration protocol_awid_encoder_yield(ProtocolAwid* protocol) { LevelDuration protocol_awid_encoder_yield(ProtocolAwid* protocol) {
bool level; bool level;
@@ -145,7 +145,7 @@ LevelDuration protocol_awid_encoder_yield(ProtocolAwid* protocol) {
bit_lib_increment_index(protocol->encoder.encoded_index, AWID_ENCODED_BIT_SIZE); bit_lib_increment_index(protocol->encoder.encoded_index, AWID_ENCODED_BIT_SIZE);
} }
return level_duration_make(level, duration); return level_duration_make(level, duration);
}; }
void protocol_awid_render_data(ProtocolAwid* protocol, FuriString* result) { void protocol_awid_render_data(ProtocolAwid* protocol, FuriString* result) {
// Index map // Index map
@@ -186,7 +186,7 @@ void protocol_awid_render_data(ProtocolAwid* protocol, FuriString* result) {
furi_string_cat_printf(result, "%02hhX", decoded_data[i]); furi_string_cat_printf(result, "%02hhX", decoded_data[i]);
} }
} }
}; }
void protocol_awid_render_brief_data(ProtocolAwid* protocol, FuriString* result) { void protocol_awid_render_brief_data(ProtocolAwid* protocol, FuriString* result) {
uint8_t* decoded_data = protocol->data; uint8_t* decoded_data = protocol->data;
@@ -210,7 +210,7 @@ void protocol_awid_render_brief_data(ProtocolAwid* protocol, FuriString* result)
} else { } else {
furi_string_cat(result, "\nData: Unknown"); furi_string_cat(result, "\nData: Unknown");
} }
}; }
bool protocol_awid_write_data(ProtocolAwid* protocol, void* data) { bool protocol_awid_write_data(ProtocolAwid* protocol, void* data) {
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data; LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
@@ -239,7 +239,7 @@ bool protocol_awid_write_data(ProtocolAwid* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
const ProtocolBase protocol_awid = { const ProtocolBase protocol_awid = {
.name = "AWID", .name = "AWID",

View File

@@ -116,15 +116,15 @@ typedef struct {
ProtocolElectra* protocol_electra_alloc(void) { ProtocolElectra* protocol_electra_alloc(void) {
ProtocolElectra* proto = malloc(sizeof(ProtocolElectra)); ProtocolElectra* proto = malloc(sizeof(ProtocolElectra));
return (void*)proto; return (void*)proto;
}; }
void protocol_electra_free(ProtocolElectra* proto) { void protocol_electra_free(ProtocolElectra* proto) {
free(proto); free(proto);
}; }
uint8_t* protocol_electra_get_data(ProtocolElectra* proto) { uint8_t* protocol_electra_get_data(ProtocolElectra* proto) {
return proto->data; return proto->data;
}; }
static void electra_decode( static void electra_decode(
const uint8_t* encoded_base_data, const uint8_t* encoded_base_data,
@@ -198,7 +198,7 @@ static bool electra_can_be_decoded(
parity_sum += (*base_data >> (EM_FIRST_ROW_POS - i * EM_BITS_PER_ROW_COUNT + j)) & 1; parity_sum += (*base_data >> (EM_FIRST_ROW_POS - i * EM_BITS_PER_ROW_COUNT + j)) & 1;
} }
if((parity_sum % 2)) { if(parity_sum % 2) {
return false; return false;
} }
} }
@@ -211,7 +211,7 @@ static bool electra_can_be_decoded(
parity_sum += (*base_data >> (EM_COLUMN_POS - i + j * EM_BITS_PER_ROW_COUNT)) & 1; parity_sum += (*base_data >> (EM_COLUMN_POS - i + j * EM_BITS_PER_ROW_COUNT)) & 1;
} }
if((parity_sum % 2)) { if(parity_sum % 2) {
FURI_LOG_D( FURI_LOG_D(
TAG, TAG,
"Unexpected column parity found. EM4100 data: %016llX", "Unexpected column parity found. EM4100 data: %016llX",
@@ -242,7 +242,7 @@ void protocol_electra_decoder_start(ProtocolElectra* proto) {
ManchesterEventReset, ManchesterEventReset,
&proto->decoder_manchester_state, &proto->decoder_manchester_state,
NULL); NULL);
}; }
bool protocol_electra_decoder_feed(ProtocolElectra* proto, bool level, uint32_t duration) { bool protocol_electra_decoder_feed(ProtocolElectra* proto, bool level, uint32_t duration) {
bool result = false; bool result = false;
@@ -299,7 +299,7 @@ bool protocol_electra_decoder_feed(ProtocolElectra* proto, bool level, uint32_t
} }
return result; return result;
}; }
static void em_write_nibble(bool low_nibble, uint8_t data, ElectraDecodedData* encoded_base_data) { static void em_write_nibble(bool low_nibble, uint8_t data, ElectraDecodedData* encoded_base_data) {
uint8_t parity_sum = 0; uint8_t parity_sum = 0;
@@ -354,7 +354,7 @@ bool protocol_electra_encoder_start(ProtocolElectra* proto) {
} }
return true; return true;
}; }
LevelDuration protocol_electra_encoder_yield(ProtocolElectra* proto) { LevelDuration protocol_electra_encoder_yield(ProtocolElectra* proto) {
bool level; bool level;
@@ -378,7 +378,7 @@ LevelDuration protocol_electra_encoder_yield(ProtocolElectra* proto) {
} }
return level_duration_make(level, duration); return level_duration_make(level, duration);
}; }
bool protocol_electra_write_data(ProtocolElectra* protocol, void* data) { bool protocol_electra_write_data(ProtocolElectra* protocol, void* data) {
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data; LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
@@ -408,12 +408,12 @@ bool protocol_electra_write_data(ProtocolElectra* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
void protocol_electra_render_data(ProtocolElectra* protocol, FuriString* result) { void protocol_electra_render_data(ProtocolElectra* protocol, FuriString* result) {
protocol_electra_encoder_start(protocol); protocol_electra_encoder_start(protocol);
furi_string_printf(result, "Epilogue: %016llX", protocol->encoded_epilogue); furi_string_printf(result, "Epilogue: %016llX", protocol->encoded_epilogue);
}; }
const ProtocolBase protocol_electra = { const ProtocolBase protocol_electra = {
.name = "Electra", .name = "Electra",

View File

@@ -93,27 +93,27 @@ ProtocolEM4100* protocol_em4100_alloc(void) {
ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100)); ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100));
proto->clock_per_bit = 64; proto->clock_per_bit = 64;
return (void*)proto; return (void*)proto;
}; }
ProtocolEM4100* protocol_em4100_16_alloc(void) { ProtocolEM4100* protocol_em4100_16_alloc(void) {
ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100)); ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100));
proto->clock_per_bit = 16; proto->clock_per_bit = 16;
return (void*)proto; return (void*)proto;
}; }
ProtocolEM4100* protocol_em4100_32_alloc(void) { ProtocolEM4100* protocol_em4100_32_alloc(void) {
ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100)); ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100));
proto->clock_per_bit = 32; proto->clock_per_bit = 32;
return (void*)proto; return (void*)proto;
}; }
void protocol_em4100_free(ProtocolEM4100* proto) { void protocol_em4100_free(ProtocolEM4100* proto) {
free(proto); free(proto);
}; }
uint8_t* protocol_em4100_get_data(ProtocolEM4100* proto) { uint8_t* protocol_em4100_get_data(ProtocolEM4100* proto) {
return proto->data; return proto->data;
}; }
static void em4100_decode( static void em4100_decode(
const uint8_t* encoded_data, const uint8_t* encoded_data,
@@ -173,7 +173,7 @@ static bool em4100_can_be_decoded(
parity_sum += (*card_data >> (EM_FIRST_ROW_POS - i * EM_BITS_PER_ROW_COUNT + j)) & 1; parity_sum += (*card_data >> (EM_FIRST_ROW_POS - i * EM_BITS_PER_ROW_COUNT + j)) & 1;
} }
if((parity_sum % 2)) { if(parity_sum % 2) {
return false; return false;
} }
} }
@@ -186,7 +186,7 @@ static bool em4100_can_be_decoded(
parity_sum += (*card_data >> (EM_COLUMN_POS - i + j * EM_BITS_PER_ROW_COUNT)) & 1; parity_sum += (*card_data >> (EM_COLUMN_POS - i + j * EM_BITS_PER_ROW_COUNT)) & 1;
} }
if((parity_sum % 2)) { if(parity_sum % 2) {
return false; return false;
} }
} }
@@ -202,7 +202,7 @@ void protocol_em4100_decoder_start(ProtocolEM4100* proto) {
ManchesterEventReset, ManchesterEventReset,
&proto->decoder_manchester_state, &proto->decoder_manchester_state,
NULL); NULL);
}; }
bool protocol_em4100_decoder_feed(ProtocolEM4100* proto, bool level, uint32_t duration) { bool protocol_em4100_decoder_feed(ProtocolEM4100* proto, bool level, uint32_t duration) {
bool result = false; bool result = false;
@@ -252,7 +252,7 @@ bool protocol_em4100_decoder_feed(ProtocolEM4100* proto, bool level, uint32_t du
} }
return result; return result;
}; }
static void em4100_write_nibble(bool low_nibble, uint8_t data, EM4100DecodedData* encoded_data) { static void em4100_write_nibble(bool low_nibble, uint8_t data, EM4100DecodedData* encoded_data) {
uint8_t parity_sum = 0; uint8_t parity_sum = 0;
@@ -296,7 +296,7 @@ bool protocol_em4100_encoder_start(ProtocolEM4100* proto) {
proto->encoded_polarity = true; proto->encoded_polarity = true;
return true; return true;
}; }
LevelDuration protocol_em4100_encoder_yield(ProtocolEM4100* proto) { LevelDuration protocol_em4100_encoder_yield(ProtocolEM4100* proto) {
bool level = (proto->encoded_data >> (63 - proto->encoded_data_index)) & 1; bool level = (proto->encoded_data >> (63 - proto->encoded_data_index)) & 1;
@@ -315,7 +315,7 @@ LevelDuration protocol_em4100_encoder_yield(ProtocolEM4100* proto) {
} }
return level_duration_make(level, duration); return level_duration_make(level, duration);
}; }
bool protocol_em4100_write_data(ProtocolEM4100* protocol, void* data) { bool protocol_em4100_write_data(ProtocolEM4100* protocol, void* data) {
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data; LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
@@ -341,7 +341,7 @@ bool protocol_em4100_write_data(ProtocolEM4100* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
void protocol_em4100_render_data(ProtocolEM4100* protocol, FuriString* result) { void protocol_em4100_render_data(ProtocolEM4100* protocol, FuriString* result) {
uint8_t* data = protocol->data; uint8_t* data = protocol->data;
@@ -352,7 +352,7 @@ void protocol_em4100_render_data(ProtocolEM4100* protocol, FuriString* result) {
data[2], data[2],
(uint16_t)((data[3] << 8) | (data[4])), (uint16_t)((data[3] << 8) | (data[4])),
protocol->clock_per_bit); protocol->clock_per_bit);
}; }
const ProtocolBase protocol_em4100 = { const ProtocolBase protocol_em4100 = {
.name = "EM4100", .name = "EM4100",

View File

@@ -44,21 +44,21 @@ ProtocolFDXA* protocol_fdx_a_alloc(void) {
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50); protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
return protocol; return protocol;
}; }
void protocol_fdx_a_free(ProtocolFDXA* protocol) { void protocol_fdx_a_free(ProtocolFDXA* protocol) {
fsk_demod_free(protocol->decoder.fsk_demod); fsk_demod_free(protocol->decoder.fsk_demod);
fsk_osc_free(protocol->encoder.fsk_osc); fsk_osc_free(protocol->encoder.fsk_osc);
free(protocol); free(protocol);
}; }
uint8_t* protocol_fdx_a_get_data(ProtocolFDXA* protocol) { uint8_t* protocol_fdx_a_get_data(ProtocolFDXA* protocol) {
return protocol->data; return protocol->data;
}; }
void protocol_fdx_a_decoder_start(ProtocolFDXA* protocol) { void protocol_fdx_a_decoder_start(ProtocolFDXA* protocol) {
memset(protocol->encoded_data, 0, FDXA_ENCODED_DATA_SIZE); memset(protocol->encoded_data, 0, FDXA_ENCODED_DATA_SIZE);
}; }
static bool protocol_fdx_a_decode(const uint8_t* from, uint8_t* to) { static bool protocol_fdx_a_decode(const uint8_t* from, uint8_t* to) {
size_t bit_index = 0; size_t bit_index = 0;
@@ -104,7 +104,7 @@ static bool protocol_fdx_a_can_be_decoded(const uint8_t* data) {
decoded_data[i] &= 0x7F; decoded_data[i] &= 0x7F;
} }
return (parity_sum == 0); return parity_sum == 0;
} }
bool protocol_fdx_a_decoder_feed(ProtocolFDXA* protocol, bool level, uint32_t duration) { bool protocol_fdx_a_decoder_feed(ProtocolFDXA* protocol, bool level, uint32_t duration) {
@@ -124,7 +124,7 @@ bool protocol_fdx_a_decoder_feed(ProtocolFDXA* protocol, bool level, uint32_t du
} }
return result; return result;
}; }
static void protocol_fdx_a_encode(ProtocolFDXA* protocol) { static void protocol_fdx_a_encode(ProtocolFDXA* protocol) {
protocol->encoded_data[0] = FDXA_PREAMBLE_0; protocol->encoded_data[0] = FDXA_PREAMBLE_0;
@@ -150,7 +150,7 @@ bool protocol_fdx_a_encoder_start(ProtocolFDXA* protocol) {
protocol_fdx_a_encode(protocol); protocol_fdx_a_encode(protocol);
return true; return true;
}; }
LevelDuration protocol_fdx_a_encoder_yield(ProtocolFDXA* protocol) { LevelDuration protocol_fdx_a_encoder_yield(ProtocolFDXA* protocol) {
bool level = 0; bool level = 0;
@@ -180,7 +180,7 @@ LevelDuration protocol_fdx_a_encoder_yield(ProtocolFDXA* protocol) {
} }
return level_duration_make(level, duration); return level_duration_make(level, duration);
}; }
bool protocol_fdx_a_write_data(ProtocolFDXA* protocol, void* data) { bool protocol_fdx_a_write_data(ProtocolFDXA* protocol, void* data) {
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data; LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
@@ -203,7 +203,7 @@ bool protocol_fdx_a_write_data(ProtocolFDXA* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
void protocol_fdx_a_render_data(ProtocolFDXA* protocol, FuriString* result) { void protocol_fdx_a_render_data(ProtocolFDXA* protocol, FuriString* result) {
uint8_t data[FDXA_DECODED_DATA_SIZE]; uint8_t data[FDXA_DECODED_DATA_SIZE];
@@ -221,7 +221,7 @@ void protocol_fdx_a_render_data(ProtocolFDXA* protocol, FuriString* result) {
"Parity: %c", "Parity: %c",
bit_lib_get_bits_64(data, 0, 40), bit_lib_get_bits_64(data, 0, 40),
parity_sum == 0 ? '+' : '-'); parity_sum == 0 ? '+' : '-');
}; }
const ProtocolBase protocol_fdx_a = { const ProtocolBase protocol_fdx_a = {
.name = "FDX-A", .name = "FDX-A",

View File

@@ -34,20 +34,20 @@ typedef struct {
ProtocolFDXB* protocol_fdx_b_alloc(void) { ProtocolFDXB* protocol_fdx_b_alloc(void) {
ProtocolFDXB* protocol = malloc(sizeof(ProtocolFDXB)); ProtocolFDXB* protocol = malloc(sizeof(ProtocolFDXB));
return protocol; return protocol;
}; }
void protocol_fdx_b_free(ProtocolFDXB* protocol) { void protocol_fdx_b_free(ProtocolFDXB* protocol) {
free(protocol); free(protocol);
}; }
uint8_t* protocol_fdx_b_get_data(ProtocolFDXB* proto) { uint8_t* protocol_fdx_b_get_data(ProtocolFDXB* proto) {
return proto->data; return proto->data;
}; }
void protocol_fdx_b_decoder_start(ProtocolFDXB* protocol) { void protocol_fdx_b_decoder_start(ProtocolFDXB* protocol) {
memset(protocol->encoded_data, 0, FDX_B_ENCODED_BYTE_FULL_SIZE); memset(protocol->encoded_data, 0, FDX_B_ENCODED_BYTE_FULL_SIZE);
protocol->last_short = false; protocol->last_short = false;
}; }
static bool protocol_fdx_b_can_be_decoded(ProtocolFDXB* protocol) { static bool protocol_fdx_b_can_be_decoded(ProtocolFDXB* protocol) {
bool result = false; bool result = false;
@@ -179,7 +179,7 @@ bool protocol_fdx_b_decoder_feed(ProtocolFDXB* protocol, bool level, uint32_t du
} }
return result; return result;
}; }
bool protocol_fdx_b_encoder_start(ProtocolFDXB* protocol) { bool protocol_fdx_b_encoder_start(ProtocolFDXB* protocol) {
memset(protocol->encoded_data, 0, FDX_B_ENCODED_BYTE_FULL_SIZE); memset(protocol->encoded_data, 0, FDX_B_ENCODED_BYTE_FULL_SIZE);
@@ -203,7 +203,7 @@ bool protocol_fdx_b_encoder_start(ProtocolFDXB* protocol) {
protocol->last_short = false; protocol->last_short = false;
protocol->last_level = false; protocol->last_level = false;
return true; return true;
}; }
LevelDuration protocol_fdx_b_encoder_yield(ProtocolFDXB* protocol) { LevelDuration protocol_fdx_b_encoder_yield(ProtocolFDXB* protocol) {
uint32_t duration; uint32_t duration;
@@ -228,7 +228,7 @@ LevelDuration protocol_fdx_b_encoder_yield(ProtocolFDXB* protocol) {
} }
return level_duration_make(protocol->last_level, duration); return level_duration_make(protocol->last_level, duration);
}; }
// 0 nnnnnnnn // 0 nnnnnnnn
// 8 nnnnnnnn 38 bit (12 digit) National code. // 8 nnnnnnnn 38 bit (12 digit) National code.
@@ -320,7 +320,7 @@ void protocol_fdx_b_render_data(ProtocolFDXB* protocol, FuriString* result) {
reserved, reserved,
user_info, user_info,
replacement_number); replacement_number);
}; }
void protocol_fdx_b_render_brief_data(ProtocolFDXB* protocol, FuriString* result) { void protocol_fdx_b_render_brief_data(ProtocolFDXB* protocol, FuriString* result) {
// 38 bits of national code // 38 bits of national code
@@ -348,7 +348,7 @@ void protocol_fdx_b_render_brief_data(ProtocolFDXB* protocol, FuriString* result
} else { } else {
furi_string_cat(result, "---"); furi_string_cat(result, "---");
} }
}; }
bool protocol_fdx_b_write_data(ProtocolFDXB* protocol, void* data) { bool protocol_fdx_b_write_data(ProtocolFDXB* protocol, void* data) {
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data; LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
@@ -371,7 +371,7 @@ bool protocol_fdx_b_write_data(ProtocolFDXB* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
const ProtocolBase protocol_fdx_b = { const ProtocolBase protocol_fdx_b = {
.name = "FDX-B", .name = "FDX-B",

View File

@@ -36,15 +36,15 @@ typedef struct {
ProtocolGallagher* protocol_gallagher_alloc(void) { ProtocolGallagher* protocol_gallagher_alloc(void) {
ProtocolGallagher* proto = malloc(sizeof(ProtocolGallagher)); ProtocolGallagher* proto = malloc(sizeof(ProtocolGallagher));
return (void*)proto; return (void*)proto;
}; }
void protocol_gallagher_free(ProtocolGallagher* protocol) { void protocol_gallagher_free(ProtocolGallagher* protocol) {
free(protocol); free(protocol);
}; }
uint8_t* protocol_gallagher_get_data(ProtocolGallagher* protocol) { uint8_t* protocol_gallagher_get_data(ProtocolGallagher* protocol) {
return protocol->data; return protocol->data;
}; }
static void protocol_gallagher_scramble(uint8_t* data, size_t length) { static void protocol_gallagher_scramble(uint8_t* data, size_t length) {
const uint8_t lut[] = { const uint8_t lut[] = {
@@ -152,7 +152,7 @@ void protocol_gallagher_decoder_start(ProtocolGallagher* protocol) {
ManchesterEventReset, ManchesterEventReset,
&protocol->decoder_manchester_state, &protocol->decoder_manchester_state,
NULL); NULL);
}; }
bool protocol_gallagher_decoder_feed(ProtocolGallagher* protocol, bool level, uint32_t duration) { bool protocol_gallagher_decoder_feed(ProtocolGallagher* protocol, bool level, uint32_t duration) {
bool result = false; bool result = false;
@@ -189,7 +189,7 @@ bool protocol_gallagher_decoder_feed(ProtocolGallagher* protocol, bool level, ui
} }
return result; return result;
}; }
bool protocol_gallagher_encoder_start(ProtocolGallagher* protocol) { bool protocol_gallagher_encoder_start(ProtocolGallagher* protocol) {
// Preamble // Preamble
@@ -227,7 +227,7 @@ bool protocol_gallagher_encoder_start(ProtocolGallagher* protocol) {
bit_lib_set_bits(protocol->encoded_data, 16 + (9 * 8), crc, 8); bit_lib_set_bits(protocol->encoded_data, 16 + (9 * 8), crc, 8);
return true; return true;
}; }
LevelDuration protocol_gallagher_encoder_yield(ProtocolGallagher* protocol) { LevelDuration protocol_gallagher_encoder_yield(ProtocolGallagher* protocol) {
bool level = bit_lib_get_bit(protocol->encoded_data, protocol->encoded_data_index); bool level = bit_lib_get_bit(protocol->encoded_data, protocol->encoded_data_index);
@@ -243,7 +243,7 @@ LevelDuration protocol_gallagher_encoder_yield(ProtocolGallagher* protocol) {
} }
return level_duration_make(level, duration); return level_duration_make(level, duration);
}; }
bool protocol_gallagher_write_data(ProtocolGallagher* protocol, void* data) { bool protocol_gallagher_write_data(ProtocolGallagher* protocol, void* data) {
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data; LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
@@ -266,7 +266,7 @@ bool protocol_gallagher_write_data(ProtocolGallagher* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
static void protocol_gallagher_render_data_internal( static void protocol_gallagher_render_data_internal(
ProtocolGallagher* protocol, ProtocolGallagher* protocol,
@@ -296,7 +296,7 @@ static void protocol_gallagher_render_data_internal(
region, region,
issue_level); issue_level);
} }
}; }
void protocol_gallagher_render_data(ProtocolGallagher* protocol, FuriString* result) { void protocol_gallagher_render_data(ProtocolGallagher* protocol, FuriString* result) {
protocol_gallagher_render_data_internal(protocol, result, false); protocol_gallagher_render_data_internal(protocol, result, false);

View File

@@ -38,21 +38,21 @@ ProtocolH10301* protocol_h10301_alloc(void) {
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50); protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
return protocol; return protocol;
}; }
void protocol_h10301_free(ProtocolH10301* protocol) { void protocol_h10301_free(ProtocolH10301* protocol) {
fsk_demod_free(protocol->decoder.fsk_demod); fsk_demod_free(protocol->decoder.fsk_demod);
fsk_osc_free(protocol->encoder.fsk_osc); fsk_osc_free(protocol->encoder.fsk_osc);
free(protocol); free(protocol);
}; }
uint8_t* protocol_h10301_get_data(ProtocolH10301* protocol) { uint8_t* protocol_h10301_get_data(ProtocolH10301* protocol) {
return protocol->data; return protocol->data;
}; }
void protocol_h10301_decoder_start(ProtocolH10301* protocol) { void protocol_h10301_decoder_start(ProtocolH10301* protocol) {
memset(protocol->encoded_data, 0, sizeof(uint32_t) * 3); memset(protocol->encoded_data, 0, sizeof(uint32_t) * 3);
}; }
static void protocol_h10301_decoder_store_data(ProtocolH10301* protocol, bool data) { static void protocol_h10301_decoder_store_data(ProtocolH10301* protocol, bool data) {
protocol->encoded_data[0] = (protocol->encoded_data[0] << 1) | protocol->encoded_data[0] = (protocol->encoded_data[0] << 1) |
@@ -205,7 +205,7 @@ bool protocol_h10301_decoder_feed(ProtocolH10301* protocol, bool level, uint32_t
} }
return result; return result;
}; }
static void protocol_h10301_write_raw_bit(bool bit, uint8_t position, uint32_t* card_data) { static void protocol_h10301_write_raw_bit(bool bit, uint8_t position, uint32_t* card_data) {
if(bit) { if(bit) {
@@ -295,7 +295,7 @@ bool protocol_h10301_encoder_start(ProtocolH10301* protocol) {
protocol->encoder.pulse = 0; protocol->encoder.pulse = 0;
return true; return true;
}; }
LevelDuration protocol_h10301_encoder_yield(ProtocolH10301* protocol) { LevelDuration protocol_h10301_encoder_yield(ProtocolH10301* protocol) {
bool level = 0; bool level = 0;
@@ -331,7 +331,7 @@ LevelDuration protocol_h10301_encoder_yield(ProtocolH10301* protocol) {
} }
return level_duration_make(level, duration); return level_duration_make(level, duration);
}; }
bool protocol_h10301_write_data(ProtocolH10301* protocol, void* data) { bool protocol_h10301_write_data(ProtocolH10301* protocol, void* data) {
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data; LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
@@ -353,7 +353,7 @@ bool protocol_h10301_write_data(ProtocolH10301* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
void protocol_h10301_render_data(ProtocolH10301* protocol, FuriString* result) { void protocol_h10301_render_data(ProtocolH10301* protocol, FuriString* result) {
uint8_t* data = protocol->data; uint8_t* data = protocol->data;
@@ -363,7 +363,7 @@ void protocol_h10301_render_data(ProtocolH10301* protocol, FuriString* result) {
"Card: %hu", "Card: %hu",
data[0], data[0],
(uint16_t)((data[1] << 8) | (data[2]))); (uint16_t)((data[1] << 8) | (data[2])));
}; }
const ProtocolBase protocol_h10301 = { const ProtocolBase protocol_h10301 = {
.name = "H10301", .name = "H10301",

View File

@@ -43,21 +43,21 @@ ProtocolHIDEx* protocol_hid_ex_generic_alloc(void) {
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50); protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
return protocol; return protocol;
}; }
void protocol_hid_ex_generic_free(ProtocolHIDEx* protocol) { void protocol_hid_ex_generic_free(ProtocolHIDEx* protocol) {
fsk_demod_free(protocol->decoder.fsk_demod); fsk_demod_free(protocol->decoder.fsk_demod);
fsk_osc_free(protocol->encoder.fsk_osc); fsk_osc_free(protocol->encoder.fsk_osc);
free(protocol); free(protocol);
}; }
uint8_t* protocol_hid_ex_generic_get_data(ProtocolHIDEx* protocol) { uint8_t* protocol_hid_ex_generic_get_data(ProtocolHIDEx* protocol) {
return protocol->data; return protocol->data;
}; }
void protocol_hid_ex_generic_decoder_start(ProtocolHIDEx* protocol) { void protocol_hid_ex_generic_decoder_start(ProtocolHIDEx* protocol) {
memset(protocol->encoded_data, 0, HID_ENCODED_DATA_SIZE); memset(protocol->encoded_data, 0, HID_ENCODED_DATA_SIZE);
}; }
static bool protocol_hid_ex_generic_can_be_decoded(const uint8_t* data) { static bool protocol_hid_ex_generic_can_be_decoded(const uint8_t* data) {
// check preamble // check preamble
@@ -110,7 +110,7 @@ bool protocol_hid_ex_generic_decoder_feed(ProtocolHIDEx* protocol, bool level, u
} }
return result; return result;
}; }
static void protocol_hid_ex_generic_encode(ProtocolHIDEx* protocol) { static void protocol_hid_ex_generic_encode(ProtocolHIDEx* protocol) {
protocol->encoded_data[0] = HID_PREAMBLE; protocol->encoded_data[0] = HID_PREAMBLE;
@@ -135,7 +135,7 @@ bool protocol_hid_ex_generic_encoder_start(ProtocolHIDEx* protocol) {
protocol_hid_ex_generic_encode(protocol); protocol_hid_ex_generic_encode(protocol);
return true; return true;
}; }
LevelDuration protocol_hid_ex_generic_encoder_yield(ProtocolHIDEx* protocol) { LevelDuration protocol_hid_ex_generic_encoder_yield(ProtocolHIDEx* protocol) {
bool level = 0; bool level = 0;
@@ -165,7 +165,7 @@ LevelDuration protocol_hid_ex_generic_encoder_yield(ProtocolHIDEx* protocol) {
} }
return level_duration_make(level, duration); return level_duration_make(level, duration);
}; }
bool protocol_hid_ex_generic_write_data(ProtocolHIDEx* protocol, void* data) { bool protocol_hid_ex_generic_write_data(ProtocolHIDEx* protocol, void* data) {
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data; LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
@@ -190,7 +190,7 @@ bool protocol_hid_ex_generic_write_data(ProtocolHIDEx* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
void protocol_hid_ex_generic_render_data(ProtocolHIDEx* protocol, FuriString* result) { void protocol_hid_ex_generic_render_data(ProtocolHIDEx* protocol, FuriString* result) {
UNUSED(protocol); UNUSED(protocol);
@@ -200,7 +200,7 @@ void protocol_hid_ex_generic_render_data(ProtocolHIDEx* protocol, FuriString* re
result, result,
"Type: Generic HID Extended\n" "Type: Generic HID Extended\n"
"Data: Unknown"); "Data: Unknown");
}; }
const ProtocolBase protocol_hid_ex_generic = { const ProtocolBase protocol_hid_ex_generic = {
.name = "HIDExt", .name = "HIDExt",

View File

@@ -43,21 +43,21 @@ ProtocolHID* protocol_hid_generic_alloc(void) {
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50); protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
return protocol; return protocol;
}; }
void protocol_hid_generic_free(ProtocolHID* protocol) { void protocol_hid_generic_free(ProtocolHID* protocol) {
fsk_demod_free(protocol->decoder.fsk_demod); fsk_demod_free(protocol->decoder.fsk_demod);
fsk_osc_free(protocol->encoder.fsk_osc); fsk_osc_free(protocol->encoder.fsk_osc);
free(protocol); free(protocol);
}; }
uint8_t* protocol_hid_generic_get_data(ProtocolHID* protocol) { uint8_t* protocol_hid_generic_get_data(ProtocolHID* protocol) {
return protocol->data; return protocol->data;
}; }
void protocol_hid_generic_decoder_start(ProtocolHID* protocol) { void protocol_hid_generic_decoder_start(ProtocolHID* protocol) {
memset(protocol->encoded_data, 0, HID_ENCODED_DATA_SIZE); memset(protocol->encoded_data, 0, HID_ENCODED_DATA_SIZE);
}; }
static bool protocol_hid_generic_can_be_decoded(const uint8_t* data) { static bool protocol_hid_generic_can_be_decoded(const uint8_t* data) {
// check preamble // check preamble
@@ -142,7 +142,7 @@ bool protocol_hid_generic_decoder_feed(ProtocolHID* protocol, bool level, uint32
} }
return result; return result;
}; }
static void protocol_hid_generic_encode(ProtocolHID* protocol) { static void protocol_hid_generic_encode(ProtocolHID* protocol) {
protocol->encoded_data[0] = HID_PREAMBLE; protocol->encoded_data[0] = HID_PREAMBLE;
@@ -167,7 +167,7 @@ bool protocol_hid_generic_encoder_start(ProtocolHID* protocol) {
protocol_hid_generic_encode(protocol); protocol_hid_generic_encode(protocol);
return true; return true;
}; }
LevelDuration protocol_hid_generic_encoder_yield(ProtocolHID* protocol) { LevelDuration protocol_hid_generic_encoder_yield(ProtocolHID* protocol) {
bool level = 0; bool level = 0;
@@ -197,7 +197,7 @@ LevelDuration protocol_hid_generic_encoder_yield(ProtocolHID* protocol) {
} }
return level_duration_make(level, duration); return level_duration_make(level, duration);
}; }
bool protocol_hid_generic_write_data(ProtocolHID* protocol, void* data) { bool protocol_hid_generic_write_data(ProtocolHID* protocol, void* data) {
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data; LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
@@ -219,7 +219,7 @@ bool protocol_hid_generic_write_data(ProtocolHID* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
static void protocol_hid_generic_string_cat_protocol_bits( static void protocol_hid_generic_string_cat_protocol_bits(
ProtocolHID* protocol, ProtocolHID* protocol,
@@ -261,7 +261,7 @@ void protocol_hid_generic_render_data(ProtocolHID* protocol, FuriString* result)
protocol_size); protocol_size);
protocol_hid_generic_string_cat_protocol_bits(protocol, protocol_size, result); protocol_hid_generic_string_cat_protocol_bits(protocol, protocol_size, result);
} }
}; }
const ProtocolBase protocol_hid_generic = { const ProtocolBase protocol_hid_generic = {
.name = "HIDProx", .name = "HIDProx",

View File

@@ -42,22 +42,22 @@ typedef struct {
ProtocolIdteck* protocol_idteck_alloc(void) { ProtocolIdteck* protocol_idteck_alloc(void) {
ProtocolIdteck* protocol = malloc(sizeof(ProtocolIdteck)); ProtocolIdteck* protocol = malloc(sizeof(ProtocolIdteck));
return protocol; return protocol;
}; }
void protocol_idteck_free(ProtocolIdteck* protocol) { void protocol_idteck_free(ProtocolIdteck* protocol) {
free(protocol); free(protocol);
}; }
uint8_t* protocol_idteck_get_data(ProtocolIdteck* protocol) { uint8_t* protocol_idteck_get_data(ProtocolIdteck* protocol) {
return protocol->data; return protocol->data;
}; }
void protocol_idteck_decoder_start(ProtocolIdteck* protocol) { void protocol_idteck_decoder_start(ProtocolIdteck* protocol) {
memset(protocol->encoded_data, 0, IDTECK_ENCODED_DATA_SIZE); memset(protocol->encoded_data, 0, IDTECK_ENCODED_DATA_SIZE);
memset(protocol->negative_encoded_data, 0, IDTECK_ENCODED_DATA_SIZE); memset(protocol->negative_encoded_data, 0, IDTECK_ENCODED_DATA_SIZE);
memset(protocol->corrupted_encoded_data, 0, IDTECK_ENCODED_DATA_SIZE); memset(protocol->corrupted_encoded_data, 0, IDTECK_ENCODED_DATA_SIZE);
memset(protocol->corrupted_negative_encoded_data, 0, IDTECK_ENCODED_DATA_SIZE); memset(protocol->corrupted_negative_encoded_data, 0, IDTECK_ENCODED_DATA_SIZE);
}; }
static bool protocol_idteck_check_preamble(uint8_t* data, size_t bit_index) { static bool protocol_idteck_check_preamble(uint8_t* data, size_t bit_index) {
// Preamble 01001001 01000100 01010100 01001011 // Preamble 01001001 01000100 01010100 01001011
@@ -144,7 +144,7 @@ bool protocol_idteck_decoder_feed(ProtocolIdteck* protocol, bool level, uint32_t
} }
return result; return result;
}; }
bool protocol_idteck_encoder_start(ProtocolIdteck* protocol) { bool protocol_idteck_encoder_start(ProtocolIdteck* protocol) {
memset(protocol->encoded_data, 0, IDTECK_ENCODED_DATA_SIZE); memset(protocol->encoded_data, 0, IDTECK_ENCODED_DATA_SIZE);
@@ -159,7 +159,7 @@ bool protocol_idteck_encoder_start(ProtocolIdteck* protocol) {
protocol->encoder.bit_clock_index = 0; protocol->encoder.bit_clock_index = 0;
return true; return true;
}; }
LevelDuration protocol_idteck_encoder_yield(ProtocolIdteck* protocol) { LevelDuration protocol_idteck_encoder_yield(ProtocolIdteck* protocol) {
LevelDuration level_duration; LevelDuration level_duration;
@@ -189,7 +189,7 @@ LevelDuration protocol_idteck_encoder_yield(ProtocolIdteck* protocol) {
} }
return level_duration; return level_duration;
}; }
// factory code // factory code
static uint32_t get_fc(const uint8_t* data) { static uint32_t get_fc(const uint8_t* data) {
@@ -232,7 +232,7 @@ bool protocol_idteck_write_data(ProtocolIdteck* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
const ProtocolBase protocol_idteck = { const ProtocolBase protocol_idteck = {
.name = "Idteck", .name = "Idteck",

View File

@@ -38,22 +38,22 @@ typedef struct {
ProtocolIndala* protocol_indala26_alloc(void) { ProtocolIndala* protocol_indala26_alloc(void) {
ProtocolIndala* protocol = malloc(sizeof(ProtocolIndala)); ProtocolIndala* protocol = malloc(sizeof(ProtocolIndala));
return protocol; return protocol;
}; }
void protocol_indala26_free(ProtocolIndala* protocol) { void protocol_indala26_free(ProtocolIndala* protocol) {
free(protocol); free(protocol);
}; }
uint8_t* protocol_indala26_get_data(ProtocolIndala* protocol) { uint8_t* protocol_indala26_get_data(ProtocolIndala* protocol) {
return protocol->data; return protocol->data;
}; }
void protocol_indala26_decoder_start(ProtocolIndala* protocol) { void protocol_indala26_decoder_start(ProtocolIndala* protocol) {
memset(protocol->encoded_data, 0, INDALA26_ENCODED_DATA_SIZE); memset(protocol->encoded_data, 0, INDALA26_ENCODED_DATA_SIZE);
memset(protocol->negative_encoded_data, 0, INDALA26_ENCODED_DATA_SIZE); memset(protocol->negative_encoded_data, 0, INDALA26_ENCODED_DATA_SIZE);
memset(protocol->corrupted_encoded_data, 0, INDALA26_ENCODED_DATA_SIZE); memset(protocol->corrupted_encoded_data, 0, INDALA26_ENCODED_DATA_SIZE);
memset(protocol->corrupted_negative_encoded_data, 0, INDALA26_ENCODED_DATA_SIZE); memset(protocol->corrupted_negative_encoded_data, 0, INDALA26_ENCODED_DATA_SIZE);
}; }
static bool protocol_indala26_check_preamble(uint8_t* data, size_t bit_index) { static bool protocol_indala26_check_preamble(uint8_t* data, size_t bit_index) {
// Preamble 10100000 00000000 00000000 00000000 1 // Preamble 10100000 00000000 00000000 00000000 1
@@ -146,7 +146,7 @@ bool protocol_indala26_decoder_feed(ProtocolIndala* protocol, bool level, uint32
} }
return result; return result;
}; }
bool protocol_indala26_encoder_start(ProtocolIndala* protocol) { bool protocol_indala26_encoder_start(ProtocolIndala* protocol) {
memset(protocol->encoded_data, 0, INDALA26_ENCODED_DATA_SIZE); memset(protocol->encoded_data, 0, INDALA26_ENCODED_DATA_SIZE);
@@ -164,7 +164,7 @@ bool protocol_indala26_encoder_start(ProtocolIndala* protocol) {
protocol->encoder.bit_clock_index = 0; protocol->encoder.bit_clock_index = 0;
return true; return true;
}; }
LevelDuration protocol_indala26_encoder_yield(ProtocolIndala* protocol) { LevelDuration protocol_indala26_encoder_yield(ProtocolIndala* protocol) {
LevelDuration level_duration; LevelDuration level_duration;
@@ -194,7 +194,7 @@ LevelDuration protocol_indala26_encoder_yield(ProtocolIndala* protocol) {
} }
return level_duration; return level_duration;
}; }
// factory code // factory code
static uint8_t get_fc(const uint8_t* data) { static uint8_t get_fc(const uint8_t* data) {
@@ -328,7 +328,7 @@ bool protocol_indala26_write_data(ProtocolIndala* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
const ProtocolBase protocol_indala26 = { const ProtocolBase protocol_indala26 = {
.name = "Indala26", .name = "Indala26",

View File

@@ -36,21 +36,21 @@ ProtocolIOProxXSF* protocol_io_prox_xsf_alloc(void) {
protocol->decoder.fsk_demod = fsk_demod_alloc(MIN_TIME, 8, MAX_TIME, 6); protocol->decoder.fsk_demod = fsk_demod_alloc(MIN_TIME, 8, MAX_TIME, 6);
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 64); protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 64);
return protocol; return protocol;
}; }
void protocol_io_prox_xsf_free(ProtocolIOProxXSF* protocol) { void protocol_io_prox_xsf_free(ProtocolIOProxXSF* protocol) {
fsk_demod_free(protocol->decoder.fsk_demod); fsk_demod_free(protocol->decoder.fsk_demod);
fsk_osc_free(protocol->encoder.fsk_osc); fsk_osc_free(protocol->encoder.fsk_osc);
free(protocol); free(protocol);
}; }
uint8_t* protocol_io_prox_xsf_get_data(ProtocolIOProxXSF* protocol) { uint8_t* protocol_io_prox_xsf_get_data(ProtocolIOProxXSF* protocol) {
return protocol->data; return protocol->data;
}; }
void protocol_io_prox_xsf_decoder_start(ProtocolIOProxXSF* protocol) { void protocol_io_prox_xsf_decoder_start(ProtocolIOProxXSF* protocol) {
memset(protocol->encoded_data, 0, IOPROXXSF_ENCODED_DATA_SIZE); memset(protocol->encoded_data, 0, IOPROXXSF_ENCODED_DATA_SIZE);
}; }
static uint8_t protocol_io_prox_xsf_compute_checksum(const uint8_t* data) { static uint8_t protocol_io_prox_xsf_compute_checksum(const uint8_t* data) {
// Packet structure: // Packet structure:
@@ -172,7 +172,7 @@ bool protocol_io_prox_xsf_decoder_feed(ProtocolIOProxXSF* protocol, bool level,
} }
return result; return result;
}; }
static void protocol_io_prox_xsf_encode(const uint8_t* decoded_data, uint8_t* encoded_data) { static void protocol_io_prox_xsf_encode(const uint8_t* decoded_data, uint8_t* encoded_data) {
// Packet to transmit: // Packet to transmit:
@@ -217,7 +217,7 @@ bool protocol_io_prox_xsf_encoder_start(ProtocolIOProxXSF* protocol) {
protocol->encoder.encoded_index = 0; protocol->encoder.encoded_index = 0;
fsk_osc_reset(protocol->encoder.fsk_osc); fsk_osc_reset(protocol->encoder.fsk_osc);
return true; return true;
}; }
LevelDuration protocol_io_prox_xsf_encoder_yield(ProtocolIOProxXSF* protocol) { LevelDuration protocol_io_prox_xsf_encoder_yield(ProtocolIOProxXSF* protocol) {
bool level; bool level;
@@ -230,7 +230,7 @@ LevelDuration protocol_io_prox_xsf_encoder_yield(ProtocolIOProxXSF* protocol) {
bit_lib_increment_index(protocol->encoder.encoded_index, IOPROXXSF_BIT_MAX_SIZE); bit_lib_increment_index(protocol->encoder.encoded_index, IOPROXXSF_BIT_MAX_SIZE);
} }
return level_duration_make(level, duration); return level_duration_make(level, duration);
}; }
void protocol_io_prox_xsf_render_data(ProtocolIOProxXSF* protocol, FuriString* result) { void protocol_io_prox_xsf_render_data(ProtocolIOProxXSF* protocol, FuriString* result) {
uint8_t* data = protocol->data; uint8_t* data = protocol->data;
@@ -274,7 +274,7 @@ bool protocol_io_prox_xsf_write_data(ProtocolIOProxXSF* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
const ProtocolBase protocol_io_prox_xsf = { const ProtocolBase protocol_io_prox_xsf = {
.name = "IoProxXSF", .name = "IoProxXSF",

View File

@@ -34,20 +34,20 @@ typedef struct {
ProtocolJablotron* protocol_jablotron_alloc(void) { ProtocolJablotron* protocol_jablotron_alloc(void) {
ProtocolJablotron* protocol = malloc(sizeof(ProtocolJablotron)); ProtocolJablotron* protocol = malloc(sizeof(ProtocolJablotron));
return protocol; return protocol;
}; }
void protocol_jablotron_free(ProtocolJablotron* protocol) { void protocol_jablotron_free(ProtocolJablotron* protocol) {
free(protocol); free(protocol);
}; }
uint8_t* protocol_jablotron_get_data(ProtocolJablotron* proto) { uint8_t* protocol_jablotron_get_data(ProtocolJablotron* proto) {
return proto->data; return proto->data;
}; }
void protocol_jablotron_decoder_start(ProtocolJablotron* protocol) { void protocol_jablotron_decoder_start(ProtocolJablotron* protocol) {
memset(protocol->encoded_data, 0, JABLOTRON_ENCODED_BYTE_FULL_SIZE); memset(protocol->encoded_data, 0, JABLOTRON_ENCODED_BYTE_FULL_SIZE);
protocol->last_short = false; protocol->last_short = false;
}; }
uint8_t protocol_jablotron_checksum(uint8_t* bits) { uint8_t protocol_jablotron_checksum(uint8_t* bits) {
uint8_t chksum = 0; uint8_t chksum = 0;
@@ -115,7 +115,7 @@ bool protocol_jablotron_decoder_feed(ProtocolJablotron* protocol, bool level, ui
} }
return false; return false;
}; }
bool protocol_jablotron_encoder_start(ProtocolJablotron* protocol) { bool protocol_jablotron_encoder_start(ProtocolJablotron* protocol) {
// preamble // preamble
@@ -133,7 +133,7 @@ bool protocol_jablotron_encoder_start(ProtocolJablotron* protocol) {
protocol->last_short = false; protocol->last_short = false;
protocol->last_level = false; protocol->last_level = false;
return true; return true;
}; }
LevelDuration protocol_jablotron_encoder_yield(ProtocolJablotron* protocol) { LevelDuration protocol_jablotron_encoder_yield(ProtocolJablotron* protocol) {
uint32_t duration; uint32_t duration;
@@ -158,12 +158,12 @@ LevelDuration protocol_jablotron_encoder_yield(ProtocolJablotron* protocol) {
} }
return level_duration_make(protocol->last_level, duration); return level_duration_make(protocol->last_level, duration);
}; }
void protocol_jablotron_render_data(ProtocolJablotron* protocol, FuriString* result) { void protocol_jablotron_render_data(ProtocolJablotron* protocol, FuriString* result) {
uint64_t id = protocol_jablotron_card_id(protocol->data); uint64_t id = protocol_jablotron_card_id(protocol->data);
furi_string_printf(result, "Card: %llX", id); furi_string_printf(result, "Card: %llX", id);
}; }
bool protocol_jablotron_write_data(ProtocolJablotron* protocol, void* data) { bool protocol_jablotron_write_data(ProtocolJablotron* protocol, void* data) {
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data; LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
@@ -184,7 +184,7 @@ bool protocol_jablotron_write_data(ProtocolJablotron* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
const ProtocolBase protocol_jablotron = { const ProtocolBase protocol_jablotron = {
.name = "Jablotron", .name = "Jablotron",

View File

@@ -37,22 +37,22 @@ typedef struct {
ProtocolKeri* protocol_keri_alloc(void) { ProtocolKeri* protocol_keri_alloc(void) {
ProtocolKeri* protocol = malloc(sizeof(ProtocolKeri)); ProtocolKeri* protocol = malloc(sizeof(ProtocolKeri));
return protocol; return protocol;
}; }
void protocol_keri_free(ProtocolKeri* protocol) { void protocol_keri_free(ProtocolKeri* protocol) {
free(protocol); free(protocol);
}; }
uint8_t* protocol_keri_get_data(ProtocolKeri* protocol) { uint8_t* protocol_keri_get_data(ProtocolKeri* protocol) {
return protocol->data; return protocol->data;
}; }
void protocol_keri_decoder_start(ProtocolKeri* protocol) { void protocol_keri_decoder_start(ProtocolKeri* protocol) {
memset(protocol->encoded_data, 0, KERI_ENCODED_DATA_SIZE); memset(protocol->encoded_data, 0, KERI_ENCODED_DATA_SIZE);
memset(protocol->negative_encoded_data, 0, KERI_ENCODED_DATA_SIZE); memset(protocol->negative_encoded_data, 0, KERI_ENCODED_DATA_SIZE);
memset(protocol->corrupted_encoded_data, 0, KERI_ENCODED_DATA_SIZE); memset(protocol->corrupted_encoded_data, 0, KERI_ENCODED_DATA_SIZE);
memset(protocol->corrupted_negative_encoded_data, 0, KERI_ENCODED_DATA_SIZE); memset(protocol->corrupted_negative_encoded_data, 0, KERI_ENCODED_DATA_SIZE);
}; }
static bool protocol_keri_check_preamble(uint8_t* data, size_t bit_index) { static bool protocol_keri_check_preamble(uint8_t* data, size_t bit_index) {
// Preamble 11100000 00000000 00000000 00000000 1 // Preamble 11100000 00000000 00000000 00000000 1
@@ -164,7 +164,7 @@ bool protocol_keri_decoder_feed(ProtocolKeri* protocol, bool level, uint32_t dur
} }
return result; return result;
}; }
bool protocol_keri_encoder_start(ProtocolKeri* protocol) { bool protocol_keri_encoder_start(ProtocolKeri* protocol) {
memset(protocol->encoded_data, 0, KERI_ENCODED_DATA_SIZE); memset(protocol->encoded_data, 0, KERI_ENCODED_DATA_SIZE);
@@ -180,7 +180,7 @@ bool protocol_keri_encoder_start(ProtocolKeri* protocol) {
protocol->encoder.bit_clock_index = 0; protocol->encoder.bit_clock_index = 0;
return true; return true;
}; }
LevelDuration protocol_keri_encoder_yield(ProtocolKeri* protocol) { LevelDuration protocol_keri_encoder_yield(ProtocolKeri* protocol) {
LevelDuration level_duration; LevelDuration level_duration;
@@ -210,7 +210,7 @@ LevelDuration protocol_keri_encoder_yield(ProtocolKeri* protocol) {
} }
return level_duration; return level_duration;
}; }
static void static void
protocol_keri_render_data_internal(ProtocolKeri* protocol, FuriString* result, bool brief) { protocol_keri_render_data_internal(ProtocolKeri* protocol, FuriString* result, bool brief) {
@@ -267,7 +267,7 @@ bool protocol_keri_write_data(ProtocolKeri* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
const ProtocolBase protocol_keri = { const ProtocolBase protocol_keri = {
.name = "Keri", .name = "Keri",

View File

@@ -47,22 +47,22 @@ typedef struct {
ProtocolNexwatch* protocol_nexwatch_alloc(void) { ProtocolNexwatch* protocol_nexwatch_alloc(void) {
ProtocolNexwatch* protocol = malloc(sizeof(ProtocolNexwatch)); ProtocolNexwatch* protocol = malloc(sizeof(ProtocolNexwatch));
return protocol; return protocol;
}; }
void protocol_nexwatch_free(ProtocolNexwatch* protocol) { void protocol_nexwatch_free(ProtocolNexwatch* protocol) {
free(protocol); free(protocol);
}; }
uint8_t* protocol_nexwatch_get_data(ProtocolNexwatch* protocol) { uint8_t* protocol_nexwatch_get_data(ProtocolNexwatch* protocol) {
return protocol->data; return protocol->data;
}; }
void protocol_nexwatch_decoder_start(ProtocolNexwatch* protocol) { void protocol_nexwatch_decoder_start(ProtocolNexwatch* protocol) {
memset(protocol->encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE); memset(protocol->encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE);
memset(protocol->negative_encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE); memset(protocol->negative_encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE);
memset(protocol->corrupted_encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE); memset(protocol->corrupted_encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE);
memset(protocol->corrupted_negative_encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE); memset(protocol->corrupted_negative_encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE);
}; }
static bool protocol_nexwatch_check_preamble(uint8_t* data, size_t bit_index) { static bool protocol_nexwatch_check_preamble(uint8_t* data, size_t bit_index) {
// 01010110 // 01010110
@@ -71,7 +71,7 @@ static bool protocol_nexwatch_check_preamble(uint8_t* data, size_t bit_index) {
} }
static uint8_t protocol_nexwatch_parity_swap(uint8_t parity) { static uint8_t protocol_nexwatch_parity_swap(uint8_t parity) {
uint8_t a = (((parity >> 3) & 1)); uint8_t a = ((parity >> 3) & 1);
a |= (((parity >> 1) & 1) << 1); a |= (((parity >> 1) & 1) << 1);
a |= (((parity >> 2) & 1) << 2); a |= (((parity >> 2) & 1) << 2);
a |= ((parity & 1) << 3); a |= ((parity & 1) << 3);
@@ -215,7 +215,7 @@ bool protocol_nexwatch_decoder_feed(ProtocolNexwatch* protocol, bool level, uint
} }
return result; return result;
}; }
bool protocol_nexwatch_encoder_start(ProtocolNexwatch* protocol) { bool protocol_nexwatch_encoder_start(ProtocolNexwatch* protocol) {
memset(protocol->encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE); memset(protocol->encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE);
@@ -231,7 +231,7 @@ bool protocol_nexwatch_encoder_start(ProtocolNexwatch* protocol) {
protocol->encoder.bit_clock_index = 0; protocol->encoder.bit_clock_index = 0;
return true; return true;
}; }
LevelDuration protocol_nexwatch_encoder_yield(ProtocolNexwatch* protocol) { LevelDuration protocol_nexwatch_encoder_yield(ProtocolNexwatch* protocol) {
LevelDuration level_duration; LevelDuration level_duration;
@@ -261,7 +261,7 @@ LevelDuration protocol_nexwatch_encoder_yield(ProtocolNexwatch* protocol) {
} }
return level_duration; return level_duration;
}; }
static void protocol_nexwatch_render_data_internal( static void protocol_nexwatch_render_data_internal(
ProtocolNexwatch* protocol, ProtocolNexwatch* protocol,
@@ -328,7 +328,7 @@ bool protocol_nexwatch_write_data(ProtocolNexwatch* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
const ProtocolBase protocol_nexwatch = { const ProtocolBase protocol_nexwatch = {
.name = "Nexwatch", .name = "Nexwatch",

View File

@@ -38,21 +38,21 @@ ProtocolParadox* protocol_paradox_alloc(void) {
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50); protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
return protocol; return protocol;
}; }
void protocol_paradox_free(ProtocolParadox* protocol) { void protocol_paradox_free(ProtocolParadox* protocol) {
fsk_demod_free(protocol->decoder.fsk_demod); fsk_demod_free(protocol->decoder.fsk_demod);
fsk_osc_free(protocol->encoder.fsk_osc); fsk_osc_free(protocol->encoder.fsk_osc);
free(protocol); free(protocol);
}; }
uint8_t* protocol_paradox_get_data(ProtocolParadox* protocol) { uint8_t* protocol_paradox_get_data(ProtocolParadox* protocol) {
return protocol->data; return protocol->data;
}; }
void protocol_paradox_decoder_start(ProtocolParadox* protocol) { void protocol_paradox_decoder_start(ProtocolParadox* protocol) {
memset(protocol->encoded_data, 0, PARADOX_ENCODED_DATA_SIZE); memset(protocol->encoded_data, 0, PARADOX_ENCODED_DATA_SIZE);
}; }
static bool protocol_paradox_can_be_decoded(ProtocolParadox* protocol) { static bool protocol_paradox_can_be_decoded(ProtocolParadox* protocol) {
// check preamble // check preamble
@@ -101,7 +101,7 @@ bool protocol_paradox_decoder_feed(ProtocolParadox* protocol, bool level, uint32
} }
return false; return false;
}; }
static void protocol_paradox_encode(const uint8_t* decoded_data, uint8_t* encoded_data) { static void protocol_paradox_encode(const uint8_t* decoded_data, uint8_t* encoded_data) {
// preamble // preamble
@@ -114,14 +114,14 @@ static void protocol_paradox_encode(const uint8_t* decoded_data, uint8_t* encode
bit_lib_set_bits(encoded_data, PARADOX_PREAMBLE_LENGTH + i * 2, 0b01, 2); bit_lib_set_bits(encoded_data, PARADOX_PREAMBLE_LENGTH + i * 2, 0b01, 2);
} }
} }
}; }
bool protocol_paradox_encoder_start(ProtocolParadox* protocol) { bool protocol_paradox_encoder_start(ProtocolParadox* protocol) {
protocol_paradox_encode(protocol->data, (uint8_t*)protocol->encoded_data); protocol_paradox_encode(protocol->data, (uint8_t*)protocol->encoded_data);
protocol->encoder.encoded_index = 0; protocol->encoder.encoded_index = 0;
fsk_osc_reset(protocol->encoder.fsk_osc); fsk_osc_reset(protocol->encoder.fsk_osc);
return true; return true;
}; }
LevelDuration protocol_paradox_encoder_yield(ProtocolParadox* protocol) { LevelDuration protocol_paradox_encoder_yield(ProtocolParadox* protocol) {
bool level; bool level;
@@ -134,7 +134,7 @@ LevelDuration protocol_paradox_encoder_yield(ProtocolParadox* protocol) {
bit_lib_increment_index(protocol->encoder.encoded_index, PARADOX_ENCODED_BIT_SIZE); bit_lib_increment_index(protocol->encoder.encoded_index, PARADOX_ENCODED_BIT_SIZE);
} }
return level_duration_make(level, duration); return level_duration_make(level, duration);
}; }
static uint8_t protocol_paradox_calculate_checksum(uint8_t fc, uint16_t card_id) { static uint8_t protocol_paradox_calculate_checksum(uint8_t fc, uint16_t card_id) {
uint8_t card_hi = (card_id >> 8) & 0xff; uint8_t card_hi = (card_id >> 8) & 0xff;
@@ -185,7 +185,7 @@ void protocol_paradox_render_data(ProtocolParadox* protocol, FuriString* result)
if(card_crc != calc_crc) { if(card_crc != calc_crc) {
furi_string_cat(result, "\nCRC Mismatch, Invalid Card!"); furi_string_cat(result, "\nCRC Mismatch, Invalid Card!");
} }
}; }
void protocol_paradox_render_brief_data(ProtocolParadox* protocol, FuriString* result) { void protocol_paradox_render_brief_data(ProtocolParadox* protocol, FuriString* result) {
uint8_t* decoded_data = protocol->data; uint8_t* decoded_data = protocol->data;
@@ -200,7 +200,7 @@ void protocol_paradox_render_brief_data(ProtocolParadox* protocol, FuriString* r
if(calc_crc != card_crc) { if(calc_crc != card_crc) {
furi_string_cat(result, "\nCRC Mismatch, Invalid Card!"); furi_string_cat(result, "\nCRC Mismatch, Invalid Card!");
} }
}; }
bool protocol_paradox_write_data(ProtocolParadox* protocol, void* data) { bool protocol_paradox_write_data(ProtocolParadox* protocol, void* data) {
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data; LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
@@ -222,7 +222,7 @@ bool protocol_paradox_write_data(ProtocolParadox* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
const ProtocolBase protocol_paradox = { const ProtocolBase protocol_paradox = {
.name = "Paradox", .name = "Paradox",

View File

@@ -41,21 +41,21 @@ ProtocolPyramid* protocol_pyramid_alloc(void) {
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50); protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
return protocol; return protocol;
}; }
void protocol_pyramid_free(ProtocolPyramid* protocol) { void protocol_pyramid_free(ProtocolPyramid* protocol) {
fsk_demod_free(protocol->decoder.fsk_demod); fsk_demod_free(protocol->decoder.fsk_demod);
fsk_osc_free(protocol->encoder.fsk_osc); fsk_osc_free(protocol->encoder.fsk_osc);
free(protocol); free(protocol);
}; }
uint8_t* protocol_pyramid_get_data(ProtocolPyramid* protocol) { uint8_t* protocol_pyramid_get_data(ProtocolPyramid* protocol) {
return protocol->data; return protocol->data;
}; }
void protocol_pyramid_decoder_start(ProtocolPyramid* protocol) { void protocol_pyramid_decoder_start(ProtocolPyramid* protocol) {
memset(protocol->encoded_data, 0, PYRAMID_ENCODED_DATA_SIZE); memset(protocol->encoded_data, 0, PYRAMID_ENCODED_DATA_SIZE);
}; }
static bool protocol_pyramid_can_be_decoded(uint8_t* data) { static bool protocol_pyramid_can_be_decoded(uint8_t* data) {
// check preamble // check preamble
@@ -122,7 +122,7 @@ bool protocol_pyramid_decoder_feed(ProtocolPyramid* protocol, bool level, uint32
} }
return result; return result;
}; }
bool protocol_pyramid_get_parity(const uint8_t* bits, uint8_t type, int length) { bool protocol_pyramid_get_parity(const uint8_t* bits, uint8_t type, int length) {
int x; int x;
@@ -184,7 +184,7 @@ bool protocol_pyramid_encoder_start(ProtocolPyramid* protocol) {
protocol_pyramid_encode(protocol); protocol_pyramid_encode(protocol);
return true; return true;
}; }
LevelDuration protocol_pyramid_encoder_yield(ProtocolPyramid* protocol) { LevelDuration protocol_pyramid_encoder_yield(ProtocolPyramid* protocol) {
bool level = 0; bool level = 0;
@@ -214,7 +214,7 @@ LevelDuration protocol_pyramid_encoder_yield(ProtocolPyramid* protocol) {
} }
return level_duration_make(level, duration); return level_duration_make(level, duration);
}; }
bool protocol_pyramid_write_data(ProtocolPyramid* protocol, void* data) { bool protocol_pyramid_write_data(ProtocolPyramid* protocol, void* data) {
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data; LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
@@ -238,7 +238,7 @@ bool protocol_pyramid_write_data(ProtocolPyramid* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
void protocol_pyramid_render_data(ProtocolPyramid* protocol, FuriString* result) { void protocol_pyramid_render_data(ProtocolPyramid* protocol, FuriString* result) {
uint8_t* decoded_data = protocol->data; uint8_t* decoded_data = protocol->data;
@@ -256,7 +256,7 @@ void protocol_pyramid_render_data(ProtocolPyramid* protocol, FuriString* result)
} else { } else {
furi_string_cat_printf(result, "Data: Unknown"); furi_string_cat_printf(result, "Data: Unknown");
} }
}; }
const ProtocolBase protocol_pyramid = { const ProtocolBase protocol_pyramid = {
.name = "Pyramid", .name = "Pyramid",

View File

@@ -11,6 +11,7 @@
#include <toolbox/manchester_decoder.h> #include <toolbox/manchester_decoder.h>
#define TAG "SECURAKEY" #define TAG "SECURAKEY"
#define SECURAKEY_RKKT_ENCODED_FULL_SIZE_BITS (96) #define SECURAKEY_RKKT_ENCODED_FULL_SIZE_BITS (96)
#define SECURAKEY_RKKT_ENCODED_FULL_SIZE_BYTE (12) #define SECURAKEY_RKKT_ENCODED_FULL_SIZE_BYTE (12)
@@ -47,15 +48,15 @@ typedef struct {
ProtocolSecurakey* protocol_securakey_alloc(void) { ProtocolSecurakey* protocol_securakey_alloc(void) {
ProtocolSecurakey* protocol = malloc(sizeof(ProtocolSecurakey)); ProtocolSecurakey* protocol = malloc(sizeof(ProtocolSecurakey));
return (void*)protocol; return (void*)protocol;
}; }
void protocol_securakey_free(ProtocolSecurakey* protocol) { void protocol_securakey_free(ProtocolSecurakey* protocol) {
free(protocol); free(protocol);
}; }
uint8_t* protocol_securakey_get_data(ProtocolSecurakey* protocol) { uint8_t* protocol_securakey_get_data(ProtocolSecurakey* protocol) {
return protocol->data; return protocol->data;
}; }
static bool protocol_securakey_can_be_decoded(ProtocolSecurakey* protocol) { static bool protocol_securakey_can_be_decoded(ProtocolSecurakey* protocol) {
// check 19 bits preamble + format flag // check 19 bits preamble + format flag
@@ -71,7 +72,7 @@ static bool protocol_securakey_can_be_decoded(ProtocolSecurakey* protocol) {
} else { } else {
return false; return false;
} }
}; }
static void protocol_securakey_decode(ProtocolSecurakey* protocol) { static void protocol_securakey_decode(ProtocolSecurakey* protocol) {
memset(protocol->data, 0, SECURAKEY_DECODED_DATA_SIZE_BYTES); memset(protocol->data, 0, SECURAKEY_DECODED_DATA_SIZE_BYTES);
@@ -142,7 +143,7 @@ static void protocol_securakey_decode(ProtocolSecurakey* protocol) {
// plaintext format (preamble and 32-bit? card number) // plaintext format (preamble and 32-bit? card number)
// pppppppp pppppppp cccccccc cccccccc cccccccc cccccccc // pppppppp pppppppp cccccccc cccccccc cccccccc cccccccc
// 00000000 00000000 00101011 00011101 00000100 01001010 // 00000000 00000000 00101011 00011101 00000100 01001010
}; }
void protocol_securakey_decoder_start(ProtocolSecurakey* protocol) { void protocol_securakey_decoder_start(ProtocolSecurakey* protocol) {
// always takes in encoded data as RKKT for simplicity // always takes in encoded data as RKKT for simplicity
@@ -153,7 +154,7 @@ void protocol_securakey_decoder_start(ProtocolSecurakey* protocol) {
ManchesterEventReset, ManchesterEventReset,
&protocol->decoder_manchester_state, &protocol->decoder_manchester_state,
NULL); NULL);
}; }
bool protocol_securakey_decoder_feed(ProtocolSecurakey* protocol, bool level, uint32_t duration) { bool protocol_securakey_decoder_feed(ProtocolSecurakey* protocol, bool level, uint32_t duration) {
bool result = false; bool result = false;
@@ -187,7 +188,7 @@ bool protocol_securakey_decoder_feed(ProtocolSecurakey* protocol, bool level, ui
} }
} }
return result; return result;
}; }
void protocol_securakey_render_data(ProtocolSecurakey* protocol, FuriString* result) { void protocol_securakey_render_data(ProtocolSecurakey* protocol, FuriString* result) {
if(bit_lib_get_bits_16(protocol->data, 0, 16) == 0) { if(bit_lib_get_bits_16(protocol->data, 0, 16) == 0) {
@@ -209,7 +210,7 @@ void protocol_securakey_render_data(ProtocolSecurakey* protocol, FuriString* res
bit_lib_get_bits_16(protocol->data, 0, 16), bit_lib_get_bits_16(protocol->data, 0, 16),
bit_lib_get_bits_16(protocol->data, 16, 16)); bit_lib_get_bits_16(protocol->data, 16, 16));
} }
}; }
bool protocol_securakey_encoder_start(ProtocolSecurakey* protocol) { bool protocol_securakey_encoder_start(ProtocolSecurakey* protocol) {
// set all of our encoded_data bits to zeros. // set all of our encoded_data bits to zeros.
@@ -277,7 +278,7 @@ bool protocol_securakey_encoder_start(ProtocolSecurakey* protocol) {
protocol->encoded_data_index = 0; protocol->encoded_data_index = 0;
protocol->encoded_polarity = true; protocol->encoded_polarity = true;
return true; return true;
}; }
LevelDuration protocol_securakey_encoder_yield(ProtocolSecurakey* protocol) { LevelDuration protocol_securakey_encoder_yield(ProtocolSecurakey* protocol) {
if(bit_lib_get_bits_16(protocol->data, 0, 16) == 0) { if(bit_lib_get_bits_16(protocol->data, 0, 16) == 0) {
@@ -305,7 +306,7 @@ LevelDuration protocol_securakey_encoder_yield(ProtocolSecurakey* protocol) {
} }
return level_duration_make(level, duration); return level_duration_make(level, duration);
} }
}; }
bool protocol_securakey_write_data(ProtocolSecurakey* protocol, void* data) { bool protocol_securakey_write_data(ProtocolSecurakey* protocol, void* data) {
protocol_securakey_encoder_start(protocol); protocol_securakey_encoder_start(protocol);
@@ -337,7 +338,7 @@ bool protocol_securakey_write_data(ProtocolSecurakey* protocol, void* data) {
} }
} }
return result; return result;
}; }
const ProtocolBase protocol_securakey = { const ProtocolBase protocol_securakey = {
.name = "Radio Key", .name = "Radio Key",

View File

@@ -35,15 +35,15 @@ typedef struct {
ProtocolViking* protocol_viking_alloc(void) { ProtocolViking* protocol_viking_alloc(void) {
ProtocolViking* proto = malloc(sizeof(ProtocolViking)); ProtocolViking* proto = malloc(sizeof(ProtocolViking));
return (void*)proto; return (void*)proto;
}; }
void protocol_viking_free(ProtocolViking* protocol) { void protocol_viking_free(ProtocolViking* protocol) {
free(protocol); free(protocol);
}; }
uint8_t* protocol_viking_get_data(ProtocolViking* protocol) { uint8_t* protocol_viking_get_data(ProtocolViking* protocol) {
return protocol->data; return protocol->data;
}; }
static void protocol_viking_decode(ProtocolViking* protocol) { static void protocol_viking_decode(ProtocolViking* protocol) {
// Copy Card ID // Copy Card ID
@@ -80,7 +80,7 @@ void protocol_viking_decoder_start(ProtocolViking* protocol) {
ManchesterEventReset, ManchesterEventReset,
&protocol->decoder_manchester_state, &protocol->decoder_manchester_state,
NULL); NULL);
}; }
bool protocol_viking_decoder_feed(ProtocolViking* protocol, bool level, uint32_t duration) { bool protocol_viking_decoder_feed(ProtocolViking* protocol, bool level, uint32_t duration) {
bool result = false; bool result = false;
@@ -117,7 +117,7 @@ bool protocol_viking_decoder_feed(ProtocolViking* protocol, bool level, uint32_t
} }
return result; return result;
}; }
bool protocol_viking_encoder_start(ProtocolViking* protocol) { bool protocol_viking_encoder_start(ProtocolViking* protocol) {
// Preamble // Preamble
@@ -135,7 +135,7 @@ bool protocol_viking_encoder_start(ProtocolViking* protocol) {
bit_lib_set_bits(protocol->encoded_data, 56, checksum, 8); bit_lib_set_bits(protocol->encoded_data, 56, checksum, 8);
return true; return true;
}; }
LevelDuration protocol_viking_encoder_yield(ProtocolViking* protocol) { LevelDuration protocol_viking_encoder_yield(ProtocolViking* protocol) {
bool level = bit_lib_get_bit(protocol->encoded_data, protocol->encoded_data_index); bool level = bit_lib_get_bit(protocol->encoded_data, protocol->encoded_data_index);
@@ -151,7 +151,7 @@ LevelDuration protocol_viking_encoder_yield(ProtocolViking* protocol) {
} }
return level_duration_make(level, duration); return level_duration_make(level, duration);
}; }
bool protocol_viking_write_data(ProtocolViking* protocol, void* data) { bool protocol_viking_write_data(ProtocolViking* protocol, void* data) {
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data; LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
@@ -173,11 +173,11 @@ bool protocol_viking_write_data(ProtocolViking* protocol, void* data) {
result = true; result = true;
} }
return result; return result;
}; }
void protocol_viking_render_data(ProtocolViking* protocol, FuriString* result) { void protocol_viking_render_data(ProtocolViking* protocol, FuriString* result) {
furi_string_printf(result, "ID: %08lX", bit_lib_get_bits_32(protocol->data, 0, 32)); furi_string_printf(result, "ID: %08lX", bit_lib_get_bits_32(protocol->data, 0, 32));
}; }
const ProtocolBase protocol_viking = { const ProtocolBase protocol_viking = {
.name = "Viking", .name = "Viking",

View File

@@ -45,7 +45,7 @@ bool felica_crc_check(const BitBuffer* buf) {
const uint8_t* data = bit_buffer_get_data(buf); const uint8_t* data = bit_buffer_get_data(buf);
const uint16_t crc_calc = felica_crc_calculate(data, data_size - FELICA_CRC_SIZE); const uint16_t crc_calc = felica_crc_calculate(data, data_size - FELICA_CRC_SIZE);
return (crc_calc == crc_received); return crc_calc == crc_received;
} }
void felica_crc_trim(BitBuffer* buf) { void felica_crc_trim(BitBuffer* buf) {

View File

@@ -55,7 +55,7 @@ bool iso13239_crc_check(Iso13239CrcType type, const BitBuffer* buf) {
const uint8_t* data = bit_buffer_get_data(buf); const uint8_t* data = bit_buffer_get_data(buf);
const uint16_t crc_calc = iso13239_crc_calculate(type, data, data_size - ISO13239_CRC_SIZE); const uint16_t crc_calc = iso13239_crc_calculate(type, data, data_size - ISO13239_CRC_SIZE);
return (crc_calc == crc_received); return crc_calc == crc_received;
} }
void iso13239_crc_trim(BitBuffer* buf) { void iso13239_crc_trim(BitBuffer* buf) {

View File

@@ -50,7 +50,7 @@ bool iso14443_crc_check(Iso14443CrcType type, const BitBuffer* buf) {
const uint8_t* data = bit_buffer_get_data(buf); const uint8_t* data = bit_buffer_get_data(buf);
const uint16_t crc_calc = iso14443_crc_calculate(type, data, data_size - ISO14443_CRC_SIZE); const uint16_t crc_calc = iso14443_crc_calculate(type, data, data_size - ISO14443_CRC_SIZE);
return (crc_calc == crc_received); return crc_calc == crc_received;
} }
void iso14443_crc_trim(BitBuffer* buf) { void iso14443_crc_trim(BitBuffer* buf) {

View File

@@ -17,7 +17,7 @@ uint8_t nfc_util_even_parity32(uint32_t data) {
// data ^= data >> 16; // data ^= data >> 16;
// data ^= data >> 8; // data ^= data >> 8;
// return !nfc_util_odd_byte_parity[data]; // return !nfc_util_odd_byte_parity[data];
return (__builtin_parity(data) & 0xFF); return __builtin_parity(data) & 0xFF;
} }
uint8_t nfc_util_odd_parity8(uint8_t data) { uint8_t nfc_util_odd_parity8(uint8_t data) {

View File

@@ -39,10 +39,9 @@ static uint32_t felica_wcnt_get_max_value(const FelicaData* data) {
static bool felica_wcnt_check_warning_boundary(const FelicaData* data) { static bool felica_wcnt_check_warning_boundary(const FelicaData* data) {
const uint32_t* wcnt_ptr = (uint32_t*)data->data.fs.wcnt.data; const uint32_t* wcnt_ptr = (uint32_t*)data->data.fs.wcnt.data;
return ( return FELICA_SYSTEM_BLOCK_RO_ACCESS(data) &&
FELICA_SYSTEM_BLOCK_RO_ACCESS(data) &&
((*wcnt_ptr > FELICA_WCNT_MC2_00_WARNING_BEGIN_VALUE) && ((*wcnt_ptr > FELICA_WCNT_MC2_00_WARNING_BEGIN_VALUE) &&
(*wcnt_ptr < FELICA_WCNT_MC2_00_WARNING_END_VALUE))); (*wcnt_ptr < FELICA_WCNT_MC2_00_WARNING_END_VALUE));
} }
static bool felica_wcnt_check_error_boundary(const FelicaData* data) { static bool felica_wcnt_check_error_boundary(const FelicaData* data) {
@@ -138,7 +137,7 @@ static bool felica_listener_check_write_request_data_size(
uint8_t possible_data_size = fact_item_cnt * FELICA_DATA_BLOCK_SIZE; uint8_t possible_data_size = fact_item_cnt * FELICA_DATA_BLOCK_SIZE;
uint8_t fact_data_size = uint8_t fact_data_size =
request->base.length - sizeof(FelicaListenerGenericRequest) - instance->block_list_size; request->base.length - sizeof(FelicaListenerGenericRequest) - instance->block_list_size;
return (possible_data_size <= fact_data_size); return possible_data_size <= fact_data_size;
} }
static bool felica_listener_test_block_list_size_bounds(const FelicaListenerGenericRequest* req) { static bool felica_listener_test_block_list_size_bounds(const FelicaListenerGenericRequest* req) {

View File

@@ -47,7 +47,7 @@ Iso14443_3aError iso14443_3a_listener_tx_with_custom_parity(
} }
return ret; return ret;
}; }
Iso14443_3aError iso14443_3a_listener_send_standard_frame( Iso14443_3aError iso14443_3a_listener_send_standard_frame(
Iso14443_3aListener* instance, Iso14443_3aListener* instance,

View File

@@ -546,7 +546,7 @@ void mf_classic_set_key_not_found(
bool mf_classic_is_block_read(const MfClassicData* data, uint8_t block_num) { bool mf_classic_is_block_read(const MfClassicData* data, uint8_t block_num) {
furi_check(data); furi_check(data);
return (FURI_BIT(data->block_read_mask[block_num / 32], block_num % 32) == 1); return FURI_BIT(data->block_read_mask[block_num / 32], block_num % 32) == 1;
} }
void mf_classic_set_block_read(MfClassicData* data, uint8_t block_num, MfClassicBlock* block_data) { void mf_classic_set_block_read(MfClassicData* data, uint8_t block_num, MfClassicBlock* block_data) {
@@ -661,22 +661,20 @@ static bool mf_classic_is_allowed_access_sector_trailer(
} }
case MfClassicActionKeyAWrite: case MfClassicActionKeyAWrite:
case MfClassicActionKeyBWrite: { case MfClassicActionKeyBWrite: {
return ( return (key_type == MfClassicKeyTypeA && (AC == 0x00 || AC == 0x01)) ||
(key_type == MfClassicKeyTypeA && (AC == 0x00 || AC == 0x01)) ||
(key_type == MfClassicKeyTypeB && (key_type == MfClassicKeyTypeB &&
(AC == 0x00 || AC == 0x04 || AC == 0x03 || AC == 0x01))); (AC == 0x00 || AC == 0x04 || AC == 0x03 || AC == 0x01));
} }
case MfClassicActionKeyBRead: { case MfClassicActionKeyBRead: {
return (key_type == MfClassicKeyTypeA && (AC == 0x00 || AC == 0x02 || AC == 0x01)) || return (key_type == MfClassicKeyTypeA && (AC == 0x00 || AC == 0x02 || AC == 0x01)) ||
(key_type == MfClassicKeyTypeB && (AC == 0x00 || AC == 0x02 || AC == 0x01)); (key_type == MfClassicKeyTypeB && (AC == 0x00 || AC == 0x02 || AC == 0x01));
} }
case MfClassicActionACRead: { case MfClassicActionACRead: {
return ((key_type == MfClassicKeyTypeA) || (key_type == MfClassicKeyTypeB)); return (key_type == MfClassicKeyTypeA) || (key_type == MfClassicKeyTypeB);
} }
case MfClassicActionACWrite: { case MfClassicActionACWrite: {
return ( return (key_type == MfClassicKeyTypeA && (AC == 0x01)) ||
(key_type == MfClassicKeyTypeA && (AC == 0x01)) || (key_type == MfClassicKeyTypeB && (AC == 0x01 || AC == 0x03 || AC == 0x05));
(key_type == MfClassicKeyTypeB && (AC == 0x01 || AC == 0x03 || AC == 0x05)));
} }
default: default:
return false; return false;
@@ -727,25 +725,21 @@ bool mf_classic_is_allowed_access_data_block(
switch(action) { switch(action) {
case MfClassicActionDataRead: { case MfClassicActionDataRead: {
return ( return (key_type == MfClassicKeyTypeA && !(AC == 0x03 || AC == 0x05 || AC == 0x07)) ||
(key_type == MfClassicKeyTypeA && !(AC == 0x03 || AC == 0x05 || AC == 0x07)) || (key_type == MfClassicKeyTypeB && !(AC == 0x07));
(key_type == MfClassicKeyTypeB && !(AC == 0x07)));
} }
case MfClassicActionDataWrite: { case MfClassicActionDataWrite: {
return ( return (key_type == MfClassicKeyTypeA && (AC == 0x00)) ||
(key_type == MfClassicKeyTypeA && (AC == 0x00)) ||
(key_type == MfClassicKeyTypeB && (key_type == MfClassicKeyTypeB &&
(AC == 0x00 || AC == 0x04 || AC == 0x06 || AC == 0x03))); (AC == 0x00 || AC == 0x04 || AC == 0x06 || AC == 0x03));
} }
case MfClassicActionDataInc: { case MfClassicActionDataInc: {
return ( return (key_type == MfClassicKeyTypeA && (AC == 0x00)) ||
(key_type == MfClassicKeyTypeA && (AC == 0x00)) || (key_type == MfClassicKeyTypeB && (AC == 0x00 || AC == 0x06));
(key_type == MfClassicKeyTypeB && (AC == 0x00 || AC == 0x06)));
} }
case MfClassicActionDataDec: { case MfClassicActionDataDec: {
return ( return (key_type == MfClassicKeyTypeA && (AC == 0x00 || AC == 0x06 || AC == 0x01)) ||
(key_type == MfClassicKeyTypeA && (AC == 0x00 || AC == 0x06 || AC == 0x01)) || (key_type == MfClassicKeyTypeB && (AC == 0x00 || AC == 0x06 || AC == 0x01));
(key_type == MfClassicKeyTypeB && (AC == 0x00 || AC == 0x06 || AC == 0x01)));
} }
default: default:
return false; return false;

View File

@@ -197,7 +197,7 @@ static bool mf_plus_poller_detect(NfcGenericEvent event, void* context) {
} }
} }
return (error == MfPlusErrorNone); return error == MfPlusErrorNone;
} }
const NfcPollerBase mf_plus_poller = { const NfcPollerBase mf_plus_poller = {

View File

@@ -598,7 +598,7 @@ uint8_t mf_ultralight_get_pwd_page_num(MfUltralightType type) {
bool mf_ultralight_is_page_pwd_or_pack(MfUltralightType type, uint16_t page) { bool mf_ultralight_is_page_pwd_or_pack(MfUltralightType type, uint16_t page) {
uint8_t pwd_page = mf_ultralight_get_pwd_page_num(type); uint8_t pwd_page = mf_ultralight_get_pwd_page_num(type);
uint8_t pack_page = pwd_page + 1; uint8_t pack_page = pwd_page + 1;
return ((pwd_page != 0) && (page == pwd_page || page == pack_page)); return (pwd_page != 0) && (page == pwd_page || page == pack_page);
} }
bool mf_ultralight_support_feature(const uint32_t feature_set, const uint32_t features_to_check) { bool mf_ultralight_support_feature(const uint32_t feature_set, const uint32_t features_to_check) {

View File

@@ -38,7 +38,7 @@ static void mf_ultralight_listener_send_short_resp(MfUltralightListener* instanc
bit_buffer_set_size(instance->tx_buffer, 4); bit_buffer_set_size(instance->tx_buffer, 4);
bit_buffer_set_byte(instance->tx_buffer, 0, data); bit_buffer_set_byte(instance->tx_buffer, 0, data);
iso14443_3a_listener_tx(instance->iso14443_3a_listener, instance->tx_buffer); iso14443_3a_listener_tx(instance->iso14443_3a_listener, instance->tx_buffer);
}; }
static void mf_ultralight_listener_perform_read( static void mf_ultralight_listener_perform_read(
MfUltralightPage* pages, MfUltralightPage* pages,

View File

@@ -125,7 +125,7 @@ static uint8_t mf_ultralight_get_mirror_data_size(MfUltralightMirrorConf mode) {
static uint8_t mf_ultralight_get_mirror_last_page(MfUltralightListener* instance) { static uint8_t mf_ultralight_get_mirror_last_page(MfUltralightListener* instance) {
uint8_t strSize = mf_ultralight_get_mirror_data_size(instance->mirror.actual_mode); uint8_t strSize = mf_ultralight_get_mirror_data_size(instance->mirror.actual_mode);
return (instance->config->mirror_page + 1U + strSize / 4); return instance->config->mirror_page + 1U + strSize / 4;
} }
static uint8_t mf_ultralight_get_ascii_offset(uint8_t start_page, MfUltralightListener* instance) { static uint8_t mf_ultralight_get_ascii_offset(uint8_t start_page, MfUltralightListener* instance) {
@@ -207,7 +207,7 @@ void mf_ultraligt_mirror_format_counter(MfUltralightListener* instance) {
} }
bool mf_ultralight_composite_command_in_progress(MfUltralightListener* instance) { bool mf_ultralight_composite_command_in_progress(MfUltralightListener* instance) {
return (instance->composite_cmd.callback != NULL); return instance->composite_cmd.callback != NULL;
} }
MfUltralightCommand MfUltralightCommand
@@ -550,7 +550,7 @@ static bool mf_ultralight_auth_check_attempts(const MfUltralightListener* instan
(1U << instance->config->access.authlim) : (1U << instance->config->access.authlim) :
instance->config->access.authlim; instance->config->access.authlim;
return (instance->data->auth_attempts >= authlim); return instance->data->auth_attempts >= authlim;
} }
bool mf_ultralight_auth_limit_check_and_update(MfUltralightListener* instance, bool auth_success) { bool mf_ultralight_auth_limit_check_and_update(MfUltralightListener* instance, bool auth_success) {

View File

@@ -150,7 +150,7 @@ static inline bool onewire_slave_receive_and_process_command(OneWireSlave* bus)
} }
} }
return (bus->error == OneWireSlaveErrorResetInProgress); return bus->error == OneWireSlaveErrorResetInProgress;
} }
return false; return false;
@@ -204,7 +204,7 @@ static void onewire_slave_exti_callback(void* context) {
} else { } else {
pulse_start = DWT->CYCCNT; pulse_start = DWT->CYCCNT;
} }
}; }
/*********************** PUBLIC ***********************/ /*********************** PUBLIC ***********************/

View File

@@ -131,7 +131,7 @@ static uint16_t subghz_protocol_bin_raw_get_full_byte(uint16_t bit_count) {
if(bit_count & 0x7) { if(bit_count & 0x7) {
return (bit_count >> 3) + 1; return (bit_count >> 3) + 1;
} else { } else {
return (bit_count >> 3); return bit_count >> 3;
} }
} }

Some files were not shown because too many files have changed in this diff Show More