mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +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:
@@ -11,9 +11,9 @@ AlignConsecutiveAssignments:
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: true
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
Enabled: true
|
||||
AcrossEmptyLines: true
|
||||
AcrossComments: true
|
||||
AlignCompound: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: true
|
||||
@@ -25,10 +25,10 @@ AlignConsecutiveDeclarations:
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: true
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AcrossComments: true
|
||||
AlignCompound: true
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: true
|
||||
AlignConsecutiveShortCaseStatements:
|
||||
@@ -47,7 +47,7 @@ AllowBreakBeforeNoexceptSpecifier: Never
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortCompoundRequirementOnASingleLine: true
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
@@ -108,6 +108,7 @@ ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
- M_EACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Preserve
|
||||
@@ -136,7 +137,7 @@ IndentRequiresClause: false
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: true
|
||||
InsertBraces: false
|
||||
InsertNewlineAtEOF: false
|
||||
InsertNewlineAtEOF: true
|
||||
InsertTrailingCommas: None
|
||||
IntegerLiteralSeparator:
|
||||
Binary: 0
|
||||
@@ -179,7 +180,7 @@ ReferenceAlignment: Pointer
|
||||
ReflowComments: false
|
||||
RemoveBracesLLVM: false
|
||||
RemoveParentheses: Leave
|
||||
RemoveSemicolon: false
|
||||
RemoveSemicolon: true
|
||||
RequiresClausePosition: OwnLine
|
||||
RequiresExpressionIndentation: OuterScope
|
||||
SeparateDefinitionBlocks: Leave
|
||||
@@ -226,7 +227,7 @@ SpacesInParensOptions:
|
||||
InEmptyParentheses: false
|
||||
Other: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: c++03
|
||||
Standard: c++20
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
|
||||
@@ -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_set_color(canvas, ColorBlack);
|
||||
canvas_draw_str_aligned(canvas, x + 8, y + 22, AlignCenter, AlignBottom, val);
|
||||
};
|
||||
}
|
||||
|
||||
static void draw_battery(Canvas* canvas, BatteryInfoModel* data, int x, int y) {
|
||||
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 + 15, AlignCenter, AlignCenter, header);
|
||||
canvas_draw_str_aligned(canvas, 92, y + 27, AlignCenter, AlignCenter, value);
|
||||
};
|
||||
}
|
||||
|
||||
static void battery_info_draw_callback(Canvas* canvas, void* context) {
|
||||
furi_assert(context);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <toolbox/args.h>
|
||||
|
||||
#define TAG "SpeakerDebug"
|
||||
|
||||
#define CLI_COMMAND "speaker_debug"
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -9,9 +9,10 @@
|
||||
#include <notification/notification.h>
|
||||
#include <notification/notification_messages.h>
|
||||
|
||||
#define TAG "UartEcho"
|
||||
|
||||
#define LINES_ON_SCREEN 6
|
||||
#define COLUMNS_ON_SCREEN 21
|
||||
#define TAG "UartEcho"
|
||||
#define DEFAULT_BAUD_RATE 230400
|
||||
|
||||
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;
|
||||
if(furi_string_size(model->list[model->line]->text) >= COLUMNS_ON_SCREEN) {
|
||||
new_string_needed = true;
|
||||
} else if((data == '\n' || data == '\r')) {
|
||||
} else if(data == '\n' || data == '\r') {
|
||||
// pack line breaks
|
||||
if(model->last_char != '\n' && model->last_char != '\r') {
|
||||
new_string_needed = true;
|
||||
|
||||
@@ -43,6 +43,7 @@ typedef struct {
|
||||
static RpcSessionContext rpc_session[TEST_RPC_SESSIONS];
|
||||
|
||||
#define TAG "UnitTestsRpc"
|
||||
|
||||
#define MAX_RECEIVE_OUTPUT_TIMEOUT 3000
|
||||
#define MAX_NAME_LENGTH 255
|
||||
#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);
|
||||
bytes_received =
|
||||
furi_stream_buffer_receive(session_context->output_stream, buf, count, time_left);
|
||||
return (count == bytes_received);
|
||||
return count == bytes_received;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <lib/subghz/devices/cc1101_configs.h>
|
||||
|
||||
#define TAG "SubGhzTest"
|
||||
|
||||
#define KEYSTORE_DIR_NAME EXT_PATH("subghz/assets/keeloq_mfcodes")
|
||||
#define CAME_ATOMO_DIR_NAME EXT_PATH("subghz/assets/came_atomo")
|
||||
#define NICE_FLOR_S_DIR_NAME EXT_PATH("subghz/assets/nice_flor_s")
|
||||
|
||||
@@ -365,7 +365,7 @@ bool subghz_device_cc1101_ext_is_rx_data_crc_valid(void) {
|
||||
cc1101_read_reg(
|
||||
subghz_device_cc1101_ext->spi_bus_handle, CC1101_STATUS_LQI | CC1101_BURST, data);
|
||||
furi_hal_spi_release(subghz_device_cc1101_ext->spi_bus_handle);
|
||||
if(((data[0] >> 7) & 0x01)) {
|
||||
if((data[0] >> 7) & 0x01) {
|
||||
return true;
|
||||
} else {
|
||||
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) {
|
||||
return (
|
||||
(subghz_device_cc1101_ext->state == SubGhzDeviceCC1101ExtStateAsyncTx) &&
|
||||
(LL_TIM_GetAutoReload(TIM17) == 0));
|
||||
return (subghz_device_cc1101_ext->state == SubGhzDeviceCC1101ExtStateAsyncTx) &&
|
||||
(LL_TIM_GetAutoReload(TIM17) == 0);
|
||||
}
|
||||
|
||||
void subghz_device_cc1101_ext_stop_async_tx(void) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define TAG "ble_beacon_app"
|
||||
#define TAG "BleBeaconApp"
|
||||
|
||||
static bool ble_beacon_app_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
|
||||
@@ -360,7 +360,7 @@ bool archive_is_home(ArchiveBrowserView* 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) {
|
||||
|
||||
@@ -62,7 +62,7 @@ static inline const char* archive_get_default_path(ArchiveTabEnum tab) {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
#define TAG "BadUsb"
|
||||
|
||||
#define WORKER_TAG TAG "Worker"
|
||||
|
||||
#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) {
|
||||
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) {
|
||||
@@ -56,7 +57,7 @@ uint16_t ducky_get_keycode(BadUsbScript* bad_usb, const char* param, bool accept
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -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);
|
||||
return SCRIPT_STATE_ERROR;
|
||||
} 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);
|
||||
return SCRIPT_STATE_ERROR;
|
||||
} else {
|
||||
return (delay_val + bad_usb->defdelay);
|
||||
return delay_val + bad_usb->defdelay;
|
||||
}
|
||||
} else {
|
||||
furi_string_push_back(bad_usb->line, bad_usb->file_buf[i]);
|
||||
|
||||
@@ -216,6 +216,7 @@ static const DuckyCmd ducky_commands[] = {
|
||||
};
|
||||
|
||||
#define TAG "BadUsb"
|
||||
|
||||
#define WORKER_TAG TAG "Worker"
|
||||
|
||||
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) {
|
||||
return 0;
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ static void ibutton_cli_print_usage(void) {
|
||||
printf("\tCyfral (2 bytes key_data)\r\n");
|
||||
printf("\tMetakom (4 bytes key_data), must contain correct parity\r\n");
|
||||
printf("\t<key_data> are hex-formatted\r\n");
|
||||
};
|
||||
}
|
||||
|
||||
static bool ibutton_cli_parse_key(iButtonProtocols* protocols, iButtonKey* key, FuriString* args) {
|
||||
bool result = false;
|
||||
@@ -124,7 +124,7 @@ static void ibutton_cli_read(Cli* cli) {
|
||||
ibutton_protocols_free(protocols);
|
||||
|
||||
furi_event_flag_free(event);
|
||||
};
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
FuriEventFlag* event;
|
||||
@@ -226,7 +226,7 @@ void ibutton_cli_emulate(Cli* cli, FuriString* args) {
|
||||
ibutton_key_free(key);
|
||||
ibutton_worker_free(worker);
|
||||
ibutton_protocols_free(protocols);
|
||||
};
|
||||
}
|
||||
|
||||
void ibutton_cli(Cli* cli, FuriString* args, void* context) {
|
||||
UNUSED(cli);
|
||||
|
||||
@@ -98,7 +98,7 @@ static bool infrared_move_view_input_callback(InputEvent* event, void* context)
|
||||
|
||||
bool consumed = false;
|
||||
|
||||
if(((event->type == InputTypeShort || event->type == InputTypeRepeat)) &&
|
||||
if((event->type == InputTypeShort || event->type == InputTypeRepeat) &&
|
||||
((event->key == InputKeyUp) || (event->key == InputKeyDown))) {
|
||||
with_view_model(
|
||||
move_view->view,
|
||||
|
||||
@@ -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");
|
||||
printf(
|
||||
"rfid raw_analyze <filename> - outputs raw data to the cli and tries to decode it (useful for protocol development)\r\n");
|
||||
};
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
ProtocolId protocol;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <nfc/protocols/mf_classic/mf_classic_poller_sync.h>
|
||||
|
||||
#define TAG "HI!"
|
||||
|
||||
#define KEY_LENGTH 6
|
||||
#define HI_KEY_TO_GEN 5
|
||||
#define UID_LENGTH 7
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <nfc/protocols/mf_classic/mf_classic_poller_sync.h>
|
||||
|
||||
#define TAG "Microel"
|
||||
|
||||
#define KEY_LENGTH 6
|
||||
#define UID_LENGTH 4
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <nfc/protocols/mf_classic/mf_classic_poller_sync.h>
|
||||
|
||||
#define TAG "MiZIP"
|
||||
|
||||
#define KEY_LENGTH 6
|
||||
#define MIZIP_KEY_TO_GEN 5
|
||||
#define UID_LENGTH 4
|
||||
|
||||
@@ -40,7 +40,7 @@ bool parse_datetime(uint16_t date, DateTime* result) {
|
||||
result->year = 2000 + (date >> 9);
|
||||
result->month = date >> 5 & 0x0F;
|
||||
result->day = date & 0x1F;
|
||||
return (date != 0);
|
||||
return date != 0;
|
||||
}
|
||||
|
||||
static bool umarsh_parse(const NfcDevice* device, FuriString* parsed_data) {
|
||||
|
||||
@@ -21,7 +21,7 @@ void onewire_on_system_start(void) {
|
||||
static void onewire_cli_print_usage(void) {
|
||||
printf("Usage:\r\n");
|
||||
printf("onewire search\r\n");
|
||||
};
|
||||
}
|
||||
|
||||
static void onewire_cli_search(Cli* cli) {
|
||||
UNUSED(cli);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <lib/subghz/subghz_tx_rx_worker.h>
|
||||
|
||||
#define TAG "SubGhzChat"
|
||||
|
||||
#define SUBGHZ_CHAT_WORKER_TIMEOUT_BETWEEN_MESSAGES 500
|
||||
|
||||
struct SubGhzChatWorker {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <float_tools.h>
|
||||
|
||||
#define TAG "SubGhzThresholdRssi"
|
||||
|
||||
#define THRESHOLD_RSSI_LOW_COUNT 10
|
||||
|
||||
struct SubGhzThresholdRssi {
|
||||
|
||||
@@ -508,22 +508,19 @@ SubGhzProtocolDecoderBase* subghz_txrx_get_decoder(SubGhzTxRx* instance) {
|
||||
|
||||
bool subghz_txrx_protocol_is_serializable(SubGhzTxRx* instance) {
|
||||
furi_assert(instance);
|
||||
return (
|
||||
(instance->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) ==
|
||||
SubGhzProtocolFlag_Save);
|
||||
return (instance->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) ==
|
||||
SubGhzProtocolFlag_Save;
|
||||
}
|
||||
|
||||
bool subghz_txrx_protocol_is_transmittable(SubGhzTxRx* instance, bool check_type) {
|
||||
furi_assert(instance);
|
||||
const SubGhzProtocol* protocol = instance->decoder_result->protocol;
|
||||
if(check_type) {
|
||||
return (
|
||||
((protocol->flag & SubGhzProtocolFlag_Send) == SubGhzProtocolFlag_Send) &&
|
||||
protocol->encoder->deserialize && protocol->type == SubGhzProtocolTypeStatic);
|
||||
return ((protocol->flag & SubGhzProtocolFlag_Send) == SubGhzProtocolFlag_Send) &&
|
||||
protocol->encoder->deserialize && protocol->type == SubGhzProtocolTypeStatic;
|
||||
}
|
||||
return (
|
||||
((protocol->flag & SubGhzProtocolFlag_Send) == SubGhzProtocolFlag_Send) &&
|
||||
protocol->encoder->deserialize);
|
||||
return ((protocol->flag & SubGhzProtocolFlag_Send) == SubGhzProtocolFlag_Send) &&
|
||||
protocol->encoder->deserialize;
|
||||
}
|
||||
|
||||
void subghz_txrx_receiver_set_filter(SubGhzTxRx* instance, SubGhzProtocolFlag filter) {
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
#include <lib/subghz/protocols/raw.h>
|
||||
#include <toolbox/path.h>
|
||||
|
||||
#define RAW_FILE_NAME "Raw_signal_"
|
||||
#define TAG "SubGhzSceneReadRaw"
|
||||
|
||||
#define RAW_FILE_NAME "Raw_signal_"
|
||||
|
||||
bool subghz_scene_read_raw_update_filename(SubGhz* subghz) {
|
||||
bool ret = false;
|
||||
//set the path to read the file
|
||||
|
||||
@@ -1203,7 +1203,7 @@ static bool
|
||||
subghz_on_system_start_istream_read(pb_istream_t* istream, pb_byte_t* buf, size_t count) {
|
||||
File* file = istream->state;
|
||||
size_t ret = storage_file_read(file, buf, count);
|
||||
return (count == ret);
|
||||
return count == ret;
|
||||
}
|
||||
|
||||
static bool subghz_on_system_start_istream_decode_band(
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#define SUBGHZ_HISTORY_MAX 50
|
||||
#define SUBGHZ_HISTORY_FREE_HEAP 20480
|
||||
|
||||
#define TAG "SubGhzHistory"
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -408,7 +408,7 @@ void subghz_unlock(SubGhz* subghz) {
|
||||
|
||||
bool subghz_is_locked(SubGhz* subghz) {
|
||||
furi_assert(subghz);
|
||||
return (subghz->lock == SubGhzLockOn);
|
||||
return subghz->lock == SubGhzLockOn;
|
||||
}
|
||||
|
||||
void subghz_rx_key_state_set(SubGhz* subghz, SubGhzRxKeyState state) {
|
||||
|
||||
@@ -145,7 +145,7 @@ void subghz_view_receiver_add_item_to_menu(
|
||||
SubGhzReceiverMenuItemArray_push_raw(model->history->data);
|
||||
item_menu->item_str = furi_string_alloc_set(name);
|
||||
item_menu->type = type;
|
||||
if((model->idx == model->history_item - 1)) {
|
||||
if(model->idx == model->history_item - 1) {
|
||||
model->history_item++;
|
||||
model->idx++;
|
||||
} else {
|
||||
|
||||
@@ -46,8 +46,7 @@ typedef struct {
|
||||
} SubGhzFrequencyAnalyzerModel;
|
||||
|
||||
static inline uint8_t rssi_sanitize(float rssi) {
|
||||
return (
|
||||
!float_is_equal(rssi, 0.f) ? (uint8_t)(rssi - SUBGHZ_FREQUENCY_ANALYZER_THRESHOLD) : 0);
|
||||
return !float_is_equal(rssi, 0.f) ? (uint8_t)(rssi - SUBGHZ_FREQUENCY_ANALYZER_THRESHOLD) : 0;
|
||||
}
|
||||
|
||||
void subghz_frequency_analyzer_set_callback(
|
||||
|
||||
@@ -6,9 +6,11 @@
|
||||
#include <gui/elements.h>
|
||||
|
||||
#include <assets_icons.h>
|
||||
#define SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE 100
|
||||
|
||||
#define TAG "SubGhzReadRaw"
|
||||
|
||||
#define SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE 100
|
||||
|
||||
struct SubGhzReadRAW {
|
||||
View* view;
|
||||
SubGhzReadRAWCallback callback;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <mbedtls/error.h>
|
||||
|
||||
#define TAG "U2f"
|
||||
|
||||
#define WORKER_TAG TAG "Worker"
|
||||
|
||||
#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);
|
||||
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) {
|
||||
@@ -410,7 +411,7 @@ static uint16_t u2f_authenticate(U2fData* U2F, uint8_t* buf) {
|
||||
|
||||
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) {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <storage/storage.h>
|
||||
|
||||
#define TAG "U2fHid"
|
||||
|
||||
#define WORKER_TAG TAG "Worker"
|
||||
|
||||
#define U2F_HID_MAX_PAYLOAD_LEN ((HID_U2F_PACKET_LEN - 7) + 128 * (HID_U2F_PACKET_LEN - 5))
|
||||
|
||||
@@ -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) {
|
||||
furi_check(cli);
|
||||
if(cli->session != NULL) {
|
||||
return (cli->session->is_connected());
|
||||
return cli->session->is_connected();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
"\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) {
|
||||
int key_slot = 0;
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
#include <assets_dolphin_internal.h>
|
||||
#include <assets_dolphin_blocking.h>
|
||||
|
||||
#define TAG "AnimationStorage"
|
||||
|
||||
#define ANIMATION_META_FILE "meta.txt"
|
||||
#define ANIMATION_DIR EXT_PATH("dolphin")
|
||||
#define ANIMATION_MANIFEST_FILE ANIMATION_DIR "/manifest.txt"
|
||||
#define TAG "AnimationStorage"
|
||||
|
||||
static void animation_storage_free_bubbles(BubbleAnimation* animation);
|
||||
static void animation_storage_free_frames(BubbleAnimation* animation);
|
||||
|
||||
@@ -117,7 +117,7 @@ static bool browser_filter_by_name(BrowserWorker* browser, FuriString* name, boo
|
||||
if(is_folder) {
|
||||
// Skip assets folders (if enabled)
|
||||
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 {
|
||||
return true;
|
||||
}
|
||||
@@ -295,7 +295,7 @@ static bool
|
||||
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return (items_cnt == count);
|
||||
return items_cnt == count;
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
|
||||
@@ -157,7 +157,7 @@ void menu_free(Menu* menu) {
|
||||
|
||||
View* menu_get_view(Menu* menu) {
|
||||
furi_check(menu);
|
||||
return (menu->view);
|
||||
return menu->view;
|
||||
}
|
||||
|
||||
void menu_add_item(
|
||||
|
||||
@@ -132,14 +132,14 @@ static char get_selected_char(TextInputModel* model) {
|
||||
}
|
||||
|
||||
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) {
|
||||
if(letter == '_') {
|
||||
return 0x20;
|
||||
} else if(islower(letter)) {
|
||||
return (letter - 0x20);
|
||||
return letter - 0x20;
|
||||
} else {
|
||||
return letter;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <loader/firmware_api/firmware_api.h>
|
||||
|
||||
#define TAG "Loader"
|
||||
|
||||
#define LOADER_MAGIC_THREAD_VALUE 0xDEADBEEF
|
||||
|
||||
// helpers
|
||||
|
||||
@@ -124,7 +124,7 @@ static void loader_menu_build_menu(LoaderMenuApp* app, LoaderMenu* menu) {
|
||||
i++,
|
||||
loader_menu_applications_callback,
|
||||
(void*)menu);
|
||||
};
|
||||
}
|
||||
|
||||
static void loader_menu_build_submenu(LoaderMenuApp* app, LoaderMenu* loader_menu) {
|
||||
for(size_t i = 0; i < FLIPPER_SETTINGS_APPS_COUNT; i++) {
|
||||
|
||||
@@ -31,7 +31,7 @@ float locale_fahrenheit_to_celsius(float temp_f) {
|
||||
}
|
||||
|
||||
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(
|
||||
|
||||
@@ -39,7 +39,7 @@ void notification_message_save_settings(NotificationApp* app) {
|
||||
furi_event_flag_wait(
|
||||
m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_event_flag_free(m.back_event);
|
||||
};
|
||||
}
|
||||
|
||||
// internal layer
|
||||
static void
|
||||
@@ -143,17 +143,16 @@ static void notification_apply_notification_leds(NotificationApp* app, const uin
|
||||
|
||||
// settings
|
||||
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) {
|
||||
return (value * app->settings.led_brightness);
|
||||
return value * app->settings.led_brightness;
|
||||
}
|
||||
|
||||
static uint32_t notification_settings_display_off_delay_ticks(NotificationApp* app) {
|
||||
return (
|
||||
(float)(app->settings.display_off_delay_ms) /
|
||||
(1000.0f / furi_kernel_get_tick_frequency()));
|
||||
return (float)(app->settings.display_off_delay_ms) /
|
||||
(1000.0f / furi_kernel_get_tick_frequency());
|
||||
}
|
||||
|
||||
// generics
|
||||
@@ -471,7 +470,7 @@ static bool notification_load_settings(NotificationApp* app) {
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return fs_result;
|
||||
};
|
||||
}
|
||||
|
||||
static bool notification_save_settings(NotificationApp* app) {
|
||||
NotificationSettings settings;
|
||||
@@ -506,7 +505,7 @@ static bool notification_save_settings(NotificationApp* app) {
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return fs_result;
|
||||
};
|
||||
}
|
||||
|
||||
static void input_event_callback(const void* value, void* context) {
|
||||
furi_assert(value);
|
||||
@@ -555,7 +554,7 @@ static NotificationApp* notification_app_alloc(void) {
|
||||
notification_message(app, &sequence_display_backlight_on);
|
||||
|
||||
return app;
|
||||
};
|
||||
}
|
||||
|
||||
// App
|
||||
int32_t notification_srv(void* p) {
|
||||
@@ -598,4 +597,4 @@ int32_t notification_srv(void* p) {
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ void notification_message(NotificationApp* app, const NotificationSequence* sequ
|
||||
NotificationAppMessage m = {
|
||||
.type = NotificationLayerMessage, .sequence = sequence, .back_event = NULL};
|
||||
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
|
||||
};
|
||||
}
|
||||
|
||||
void notification_internal_message(NotificationApp* app, const NotificationSequence* sequence) {
|
||||
furi_check(app);
|
||||
@@ -19,7 +19,7 @@ void notification_internal_message(NotificationApp* app, const NotificationSeque
|
||||
NotificationAppMessage m = {
|
||||
.type = InternalLayerMessage, .sequence = sequence, .back_event = NULL};
|
||||
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
|
||||
};
|
||||
}
|
||||
|
||||
void notification_message_block(NotificationApp* app, const NotificationSequence* sequence) {
|
||||
furi_check(app);
|
||||
@@ -33,7 +33,7 @@ void notification_message_block(NotificationApp* app, const NotificationSequence
|
||||
furi_event_flag_wait(
|
||||
m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_event_flag_free(m.back_event);
|
||||
};
|
||||
}
|
||||
|
||||
void notification_internal_message_block(
|
||||
NotificationApp* app,
|
||||
@@ -47,4 +47,4 @@ void notification_internal_message_block(
|
||||
furi_event_flag_wait(
|
||||
m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_event_flag_free(m.back_event);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
#define POWER_OFF_TIMEOUT 90
|
||||
#define TAG "Power"
|
||||
|
||||
#define POWER_OFF_TIMEOUT 90
|
||||
|
||||
void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||
furi_assert(context);
|
||||
Power* power = context;
|
||||
|
||||
@@ -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);
|
||||
#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) {
|
||||
|
||||
@@ -40,5 +40,5 @@ const char* filesystem_api_error_get_desc(FS_Error error_id) {
|
||||
|
||||
bool file_info_is_dir(const FileInfo* file_info) {
|
||||
furi_check(file_info);
|
||||
return (file_info->flags & FSF_DIRECTORY);
|
||||
return file_info->flags & FSF_DIRECTORY;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ static void storage_cli_info(Cli* cli, FuriString* path, FuriString* args) {
|
||||
}
|
||||
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
};
|
||||
}
|
||||
|
||||
static void storage_cli_format(Cli* cli, FuriString* path, FuriString* args) {
|
||||
UNUSED(args);
|
||||
@@ -93,7 +93,7 @@ static void storage_cli_format(Cli* cli, FuriString* path, FuriString* args) {
|
||||
} else {
|
||||
storage_cli_print_usage();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void storage_cli_list(Cli* cli, FuriString* path, FuriString* args) {
|
||||
UNUSED(cli);
|
||||
@@ -241,7 +241,7 @@ static void storage_cli_write(Cli* cli, FuriString* path, FuriString* args) {
|
||||
fflush(stdout);
|
||||
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);
|
||||
|
||||
if(written_size != buffer_size) {
|
||||
@@ -630,7 +630,7 @@ static void storage_cli_print_usage(void) {
|
||||
printf(
|
||||
"\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) {
|
||||
UNUSED(context);
|
||||
|
||||
@@ -929,12 +929,12 @@ File* storage_file_alloc(Storage* storage) {
|
||||
|
||||
bool storage_file_is_open(File* file) {
|
||||
furi_check(file);
|
||||
return (file->type != FileTypeClosed);
|
||||
return file->type != FileTypeClosed;
|
||||
}
|
||||
|
||||
bool storage_file_is_dir(File* file) {
|
||||
furi_check(file);
|
||||
return (file->type == FileTypeOpenDir);
|
||||
return file->type == FileTypeOpenDir;
|
||||
}
|
||||
|
||||
void storage_file_free(File* file) {
|
||||
|
||||
@@ -8,7 +8,12 @@
|
||||
extern "C" {
|
||||
#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;
|
||||
|
||||
|
||||
@@ -337,7 +337,7 @@ static bool storage_ext_file_open(
|
||||
|
||||
file->internal_error_id = f_open(file_data, path, _mode);
|
||||
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) {
|
||||
@@ -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);
|
||||
free(file_data);
|
||||
storage_set_storage_file_data(file, NULL, storage);
|
||||
return (file->error_id == FSE_OK);
|
||||
return file->error_id == FSE_OK;
|
||||
}
|
||||
|
||||
static uint16_t
|
||||
@@ -392,7 +392,7 @@ static bool
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -416,7 +416,7 @@ static bool storage_ext_file_truncate(void* ctx, File* file) {
|
||||
|
||||
file->internal_error_id = f_truncate(file_data);
|
||||
file->error_id = storage_ext_parse_error(file->internal_error_id);
|
||||
return (file->error_id == FSE_OK);
|
||||
return file->error_id == FSE_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ static bool storage_ext_file_sync(void* ctx, File* file) {
|
||||
|
||||
file->internal_error_id = f_sync(file_data);
|
||||
file->error_id = storage_ext_parse_error(file->internal_error_id);
|
||||
return (file->error_id == FSE_OK);
|
||||
return file->error_id == FSE_OK;
|
||||
#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);
|
||||
file->internal_error_id = f_opendir(file_data, path);
|
||||
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) {
|
||||
@@ -474,7 +474,7 @@ static bool storage_ext_dir_close(void* ctx, File* file) {
|
||||
file->internal_error_id = f_closedir(file_data);
|
||||
file->error_id = storage_ext_parse_error(file->internal_error_id);
|
||||
free(file_data);
|
||||
return (file->error_id == FSE_OK);
|
||||
return file->error_id == FSE_OK;
|
||||
}
|
||||
|
||||
static bool storage_ext_dir_read(
|
||||
@@ -505,7 +505,7 @@ static bool storage_ext_dir_read(
|
||||
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) {
|
||||
@@ -514,7 +514,7 @@ static bool storage_ext_dir_rewind(void* ctx, File* file) {
|
||||
|
||||
file->internal_error_id = f_readdir(file_data, NULL);
|
||||
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 *******************/
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <toolbox/path.h>
|
||||
|
||||
#define TAG "StorageInt"
|
||||
|
||||
#define STORAGE_PATH STORAGE_INT_PATH_PREFIX
|
||||
#define LFS_CLEAN_FINGERPRINT 0
|
||||
|
||||
@@ -160,7 +161,7 @@ static LFSData* storage_int_lfs_data_alloc(void) {
|
||||
lfs_data->config.lookahead_size = 16;
|
||||
|
||||
return lfs_data;
|
||||
};
|
||||
}
|
||||
|
||||
// Returns true if fingerprint was invalid and LFS reformatting is needed
|
||||
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_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;
|
||||
@@ -344,7 +345,7 @@ static bool storage_int_file_open(
|
||||
|
||||
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) {
|
||||
@@ -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);
|
||||
lfs_handle_free(handle);
|
||||
return (file->error_id == FSE_OK);
|
||||
return file->error_id == FSE_OK;
|
||||
}
|
||||
|
||||
static uint16_t
|
||||
@@ -430,7 +431,7 @@ static bool
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
return (file->error_id == FSE_OK);
|
||||
return file->error_id == FSE_OK;
|
||||
}
|
||||
|
||||
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);
|
||||
return (file->error_id == FSE_OK);
|
||||
return file->error_id == FSE_OK;
|
||||
}
|
||||
|
||||
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);
|
||||
return (file->error_id == FSE_OK);
|
||||
return file->error_id == FSE_OK;
|
||||
}
|
||||
|
||||
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);
|
||||
lfs_handle_free(handle);
|
||||
return (file->error_id == FSE_OK);
|
||||
return file->error_id == FSE_OK;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
return (file->error_id == FSE_OK);
|
||||
return file->error_id == FSE_OK;
|
||||
}
|
||||
|
||||
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);
|
||||
return (file->error_id == FSE_OK);
|
||||
return file->error_id == FSE_OK;
|
||||
}
|
||||
|
||||
/******************* Common FS Functions *******************/
|
||||
|
||||
@@ -31,4 +31,7 @@ typedef enum {
|
||||
PowerSettingsAppViewDialog,
|
||||
} PowerSettingsAppView;
|
||||
|
||||
typedef enum { RebootTypeDFU, RebootTypeNormal } RebootType;
|
||||
typedef enum {
|
||||
RebootTypeDFU,
|
||||
RebootTypeNormal
|
||||
} RebootType;
|
||||
|
||||
@@ -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_set_color(canvas, ColorBlack);
|
||||
canvas_draw_str_aligned(canvas, x + 8, y + 22, AlignCenter, AlignBottom, val);
|
||||
};
|
||||
}
|
||||
|
||||
static void draw_battery(Canvas* canvas, BatteryInfoModel* data, int x, int y) {
|
||||
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 + 15, AlignCenter, AlignCenter, header);
|
||||
canvas_draw_str_aligned(canvas, 92, y + 27, AlignCenter, AlignCenter, value);
|
||||
};
|
||||
}
|
||||
|
||||
static void battery_info_draw_callback(Canvas* canvas, void* context) {
|
||||
furi_assert(context);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "hid_icons.h"
|
||||
|
||||
#define TAG "HidMouseClicker"
|
||||
|
||||
#define DEFAULT_CLICK_RATE 1
|
||||
#define MAXIMUM_CLICK_RATE 60
|
||||
|
||||
|
||||
@@ -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) {
|
||||
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++) {
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
#include "../js_modules.h"
|
||||
#include <m-array.h>
|
||||
|
||||
#define TAG "js_serial"
|
||||
#define TAG "JsSerial"
|
||||
|
||||
#define RX_BUF_LEN 2048
|
||||
|
||||
typedef struct {
|
||||
@@ -444,14 +445,14 @@ static int32_t js_serial_expect_check_pattern_start(
|
||||
int32_t pattern_last) {
|
||||
size_t array_len = PatternArray_size(patterns);
|
||||
if((pattern_last + 1) >= (int32_t)array_len) {
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
for(size_t i = pattern_last + 1; i < array_len; i++) {
|
||||
if(PatternArray_get(patterns, i)->data[0] == value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void js_serial_expect(struct mjs* mjs) {
|
||||
|
||||
@@ -17,7 +17,7 @@ static bool storage_move_to_sd_check_entry(const char* name, FileInfo* fileinfo,
|
||||
return true;
|
||||
}
|
||||
|
||||
return (name && (*name != '.'));
|
||||
return name && (*name != '.');
|
||||
}
|
||||
|
||||
bool storage_move_to_sd_perform(void) {
|
||||
|
||||
@@ -36,7 +36,7 @@ static bool page_task_compare_flash(
|
||||
const uint8_t* update_block,
|
||||
uint16_t update_block_len) {
|
||||
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
|
||||
@@ -44,7 +44,7 @@ static bool page_task_compare_flash(
|
||||
static bool check_address_boundaries(const size_t address) {
|
||||
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();
|
||||
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(
|
||||
|
||||
@@ -29,7 +29,7 @@ bool furi_kernel_is_irq_or_masked(void) {
|
||||
}
|
||||
|
||||
/* Return context, 0: thread context, 1: IRQ context */
|
||||
return (irq);
|
||||
return irq;
|
||||
}
|
||||
|
||||
bool furi_kernel_is_running(void) {
|
||||
@@ -58,7 +58,7 @@ int32_t furi_kernel_lock(void) {
|
||||
}
|
||||
|
||||
/* Return previous lock state */
|
||||
return (lock);
|
||||
return lock;
|
||||
}
|
||||
|
||||
int32_t furi_kernel_unlock(void) {
|
||||
@@ -88,7 +88,7 @@ int32_t furi_kernel_unlock(void) {
|
||||
}
|
||||
|
||||
/* Return previous lock state */
|
||||
return (lock);
|
||||
return 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 (lock);
|
||||
return lock;
|
||||
}
|
||||
|
||||
uint32_t furi_kernel_get_tick_frequency(void) {
|
||||
/* Return frequency in hertz */
|
||||
return (configTICK_RATE_HZ_RAW);
|
||||
return configTICK_RATE_HZ_RAW;
|
||||
}
|
||||
|
||||
void furi_delay_tick(uint32_t ticks) {
|
||||
@@ -160,7 +160,7 @@ FuriStatus furi_delay_until_tick(uint32_t tick) {
|
||||
}
|
||||
|
||||
/* Return execution status */
|
||||
return (stat);
|
||||
return stat;
|
||||
}
|
||||
|
||||
uint32_t furi_get_tick(void) {
|
||||
|
||||
@@ -528,7 +528,7 @@ void vPortFree(void* pv) {
|
||||
xFreeBytesRemaining += pxLink->xBlockSize;
|
||||
traceFREE(pv, pxLink->xBlockSize);
|
||||
memset(pv, 0, pxLink->xBlockSize - xHeapStructSize);
|
||||
prvInsertBlockIntoFreeList(((BlockLink_t*)pxLink));
|
||||
prvInsertBlockIntoFreeList((BlockLink_t*)pxLink);
|
||||
}
|
||||
(void)xTaskResumeAll();
|
||||
} else {
|
||||
|
||||
@@ -29,20 +29,20 @@ FuriStreamBuffer* furi_stream_buffer_alloc(size_t size, size_t trigger_level) {
|
||||
furi_check(hStreamBuffer == (StreamBufferHandle_t)stream_buffer);
|
||||
|
||||
return stream_buffer;
|
||||
};
|
||||
}
|
||||
|
||||
void furi_stream_buffer_free(FuriStreamBuffer* stream_buffer) {
|
||||
furi_check(stream_buffer);
|
||||
|
||||
vStreamBufferDelete((StreamBufferHandle_t)stream_buffer);
|
||||
free(stream_buffer);
|
||||
};
|
||||
}
|
||||
|
||||
bool furi_stream_set_trigger_level(FuriStreamBuffer* stream_buffer, size_t trigger_level) {
|
||||
furi_check(stream_buffer);
|
||||
return xStreamBufferSetTriggerLevel((StreamBufferHandle_t)stream_buffer, trigger_level) ==
|
||||
pdTRUE;
|
||||
};
|
||||
}
|
||||
|
||||
size_t furi_stream_buffer_send(
|
||||
FuriStreamBuffer* stream_buffer,
|
||||
@@ -62,7 +62,7 @@ size_t furi_stream_buffer_send(
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
size_t furi_stream_buffer_receive(
|
||||
FuriStreamBuffer* stream_buffer,
|
||||
@@ -89,25 +89,25 @@ size_t furi_stream_buffer_bytes_available(FuriStreamBuffer* stream_buffer) {
|
||||
furi_check(stream_buffer);
|
||||
|
||||
return xStreamBufferBytesAvailable((StreamBufferHandle_t)stream_buffer);
|
||||
};
|
||||
}
|
||||
|
||||
size_t furi_stream_buffer_spaces_available(FuriStreamBuffer* stream_buffer) {
|
||||
furi_check(stream_buffer);
|
||||
|
||||
return xStreamBufferSpacesAvailable((StreamBufferHandle_t)stream_buffer);
|
||||
};
|
||||
}
|
||||
|
||||
bool furi_stream_buffer_is_full(FuriStreamBuffer* stream_buffer) {
|
||||
furi_check(stream_buffer);
|
||||
|
||||
return xStreamBufferIsFull((StreamBufferHandle_t)stream_buffer) == pdTRUE;
|
||||
};
|
||||
}
|
||||
|
||||
bool furi_stream_buffer_is_empty(FuriStreamBuffer* 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) {
|
||||
furi_check(stream_buffer);
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
RecordController(const char* record_name) {
|
||||
name = record_name;
|
||||
value = static_cast<TRecordClass*>(furi_record_open(name));
|
||||
};
|
||||
}
|
||||
|
||||
~RecordController() {
|
||||
furi_record_close(name);
|
||||
|
||||
@@ -50,7 +50,8 @@ struct type_index {
|
||||
* Creates a type_index object for the specified type.
|
||||
*/
|
||||
template <typename T>
|
||||
type_index(tag_type<T>) noexcept : hash_code_{index<T>} {
|
||||
type_index(tag_type<T>) noexcept
|
||||
: hash_code_{index<T>} {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
0)...);
|
||||
|
||||
gui = static_cast<Gui*>(furi_record_open("gui"));
|
||||
};
|
||||
}
|
||||
|
||||
~ViewController() {
|
||||
for(auto& it : holder) {
|
||||
|
||||
@@ -253,5 +253,5 @@ bool st25r3916_check_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t mask,
|
||||
|
||||
uint8_t reg_val = 0;
|
||||
st25r3916_read_reg(handle, reg, ®_val);
|
||||
return ((reg_val & mask) == val);
|
||||
return (reg_val & mask) == val;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
enum { LeadingSpace, ReadValue, TrailingSpace } state = LeadingSpace;
|
||||
enum {
|
||||
LeadingSpace,
|
||||
ReadValue,
|
||||
TrailingSpace
|
||||
} state = LeadingSpace;
|
||||
const size_t buffer_size = 32;
|
||||
uint8_t buffer[buffer_size];
|
||||
bool result = false;
|
||||
|
||||
@@ -71,7 +71,7 @@ bool lfrfid_raw_file_write_header(
|
||||
.max_buffer_size = max_buffer_size};
|
||||
|
||||
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) {
|
||||
|
||||
@@ -141,7 +141,7 @@ void lfrfid_worker_stop_thread(LFRFIDWorker* worker) {
|
||||
bool lfrfid_worker_check_for_stop(LFRFIDWorker* worker) {
|
||||
UNUSED(worker);
|
||||
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) {
|
||||
|
||||
@@ -37,21 +37,21 @@ ProtocolAwid* protocol_awid_alloc(void) {
|
||||
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
|
||||
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_awid_free(ProtocolAwid* protocol) {
|
||||
fsk_demod_free(protocol->decoder.fsk_demod);
|
||||
fsk_osc_free(protocol->encoder.fsk_osc);
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_awid_get_data(ProtocolAwid* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_awid_decoder_start(ProtocolAwid* protocol) {
|
||||
memset(protocol->encoded_data, 0, AWID_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_awid_can_be_decoded(uint8_t* data) {
|
||||
bool result = false;
|
||||
@@ -112,7 +112,7 @@ bool protocol_awid_decoder_feed(ProtocolAwid* protocol, bool level, uint32_t dur
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_awid_encode(const uint8_t* decoded_data, uint8_t* encoded_data) {
|
||||
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);
|
||||
bit_lib_set_bits(encoded_data, 8 + i * 4, value, 4);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_awid_encoder_start(ProtocolAwid* protocol) {
|
||||
protocol_awid_encode(protocol->data, (uint8_t*)protocol->encoded_data);
|
||||
protocol->encoder.encoded_index = 0;
|
||||
fsk_osc_reset(protocol->encoder.fsk_osc);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_awid_encoder_yield(ProtocolAwid* protocol) {
|
||||
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);
|
||||
}
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_awid_render_data(ProtocolAwid* protocol, FuriString* result) {
|
||||
// Index map
|
||||
@@ -186,7 +186,7 @@ void protocol_awid_render_data(ProtocolAwid* protocol, FuriString* result) {
|
||||
furi_string_cat_printf(result, "%02hhX", decoded_data[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_awid_render_brief_data(ProtocolAwid* protocol, FuriString* result) {
|
||||
uint8_t* decoded_data = protocol->data;
|
||||
@@ -210,7 +210,7 @@ void protocol_awid_render_brief_data(ProtocolAwid* protocol, FuriString* result)
|
||||
} else {
|
||||
furi_string_cat(result, "\nData: Unknown");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_awid_write_data(ProtocolAwid* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -239,7 +239,7 @@ bool protocol_awid_write_data(ProtocolAwid* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_awid = {
|
||||
.name = "AWID",
|
||||
|
||||
@@ -116,15 +116,15 @@ typedef struct {
|
||||
ProtocolElectra* protocol_electra_alloc(void) {
|
||||
ProtocolElectra* proto = malloc(sizeof(ProtocolElectra));
|
||||
return (void*)proto;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_electra_free(ProtocolElectra* proto) {
|
||||
free(proto);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_electra_get_data(ProtocolElectra* proto) {
|
||||
return proto->data;
|
||||
};
|
||||
}
|
||||
|
||||
static void electra_decode(
|
||||
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;
|
||||
}
|
||||
|
||||
if((parity_sum % 2)) {
|
||||
if(parity_sum % 2) {
|
||||
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;
|
||||
}
|
||||
|
||||
if((parity_sum % 2)) {
|
||||
if(parity_sum % 2) {
|
||||
FURI_LOG_D(
|
||||
TAG,
|
||||
"Unexpected column parity found. EM4100 data: %016llX",
|
||||
@@ -242,7 +242,7 @@ void protocol_electra_decoder_start(ProtocolElectra* proto) {
|
||||
ManchesterEventReset,
|
||||
&proto->decoder_manchester_state,
|
||||
NULL);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_electra_decoder_feed(ProtocolElectra* proto, bool level, uint32_t duration) {
|
||||
bool result = false;
|
||||
@@ -299,7 +299,7 @@ bool protocol_electra_decoder_feed(ProtocolElectra* proto, bool level, uint32_t
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void em_write_nibble(bool low_nibble, uint8_t data, ElectraDecodedData* encoded_base_data) {
|
||||
uint8_t parity_sum = 0;
|
||||
@@ -354,7 +354,7 @@ bool protocol_electra_encoder_start(ProtocolElectra* proto) {
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_electra_encoder_yield(ProtocolElectra* proto) {
|
||||
bool level;
|
||||
@@ -378,7 +378,7 @@ LevelDuration protocol_electra_encoder_yield(ProtocolElectra* proto) {
|
||||
}
|
||||
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_electra_write_data(ProtocolElectra* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -408,12 +408,12 @@ bool protocol_electra_write_data(ProtocolElectra* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_electra_render_data(ProtocolElectra* protocol, FuriString* result) {
|
||||
protocol_electra_encoder_start(protocol);
|
||||
furi_string_printf(result, "Epilogue: %016llX", protocol->encoded_epilogue);
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_electra = {
|
||||
.name = "Electra",
|
||||
|
||||
@@ -93,27 +93,27 @@ ProtocolEM4100* protocol_em4100_alloc(void) {
|
||||
ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100));
|
||||
proto->clock_per_bit = 64;
|
||||
return (void*)proto;
|
||||
};
|
||||
}
|
||||
|
||||
ProtocolEM4100* protocol_em4100_16_alloc(void) {
|
||||
ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100));
|
||||
proto->clock_per_bit = 16;
|
||||
return (void*)proto;
|
||||
};
|
||||
}
|
||||
|
||||
ProtocolEM4100* protocol_em4100_32_alloc(void) {
|
||||
ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100));
|
||||
proto->clock_per_bit = 32;
|
||||
return (void*)proto;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_em4100_free(ProtocolEM4100* proto) {
|
||||
free(proto);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_em4100_get_data(ProtocolEM4100* proto) {
|
||||
return proto->data;
|
||||
};
|
||||
}
|
||||
|
||||
static void em4100_decode(
|
||||
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;
|
||||
}
|
||||
|
||||
if((parity_sum % 2)) {
|
||||
if(parity_sum % 2) {
|
||||
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;
|
||||
}
|
||||
|
||||
if((parity_sum % 2)) {
|
||||
if(parity_sum % 2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,7 @@ void protocol_em4100_decoder_start(ProtocolEM4100* proto) {
|
||||
ManchesterEventReset,
|
||||
&proto->decoder_manchester_state,
|
||||
NULL);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_em4100_decoder_feed(ProtocolEM4100* proto, bool level, uint32_t duration) {
|
||||
bool result = false;
|
||||
@@ -252,7 +252,7 @@ bool protocol_em4100_decoder_feed(ProtocolEM4100* proto, bool level, uint32_t du
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void em4100_write_nibble(bool low_nibble, uint8_t data, EM4100DecodedData* encoded_data) {
|
||||
uint8_t parity_sum = 0;
|
||||
@@ -296,7 +296,7 @@ bool protocol_em4100_encoder_start(ProtocolEM4100* proto) {
|
||||
proto->encoded_polarity = true;
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_em4100_encoder_yield(ProtocolEM4100* proto) {
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_em4100_write_data(ProtocolEM4100* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -341,7 +341,7 @@ bool protocol_em4100_write_data(ProtocolEM4100* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_em4100_render_data(ProtocolEM4100* protocol, FuriString* result) {
|
||||
uint8_t* data = protocol->data;
|
||||
@@ -352,7 +352,7 @@ void protocol_em4100_render_data(ProtocolEM4100* protocol, FuriString* result) {
|
||||
data[2],
|
||||
(uint16_t)((data[3] << 8) | (data[4])),
|
||||
protocol->clock_per_bit);
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_em4100 = {
|
||||
.name = "EM4100",
|
||||
|
||||
@@ -44,21 +44,21 @@ ProtocolFDXA* protocol_fdx_a_alloc(void) {
|
||||
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
|
||||
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_fdx_a_free(ProtocolFDXA* protocol) {
|
||||
fsk_demod_free(protocol->decoder.fsk_demod);
|
||||
fsk_osc_free(protocol->encoder.fsk_osc);
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_fdx_a_get_data(ProtocolFDXA* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_fdx_a_decoder_start(ProtocolFDXA* protocol) {
|
||||
memset(protocol->encoded_data, 0, FDXA_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_fdx_a_decode(const uint8_t* from, uint8_t* to) {
|
||||
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;
|
||||
}
|
||||
|
||||
return (parity_sum == 0);
|
||||
return parity_sum == 0;
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_fdx_a_encode(ProtocolFDXA* protocol) {
|
||||
protocol->encoded_data[0] = FDXA_PREAMBLE_0;
|
||||
@@ -150,7 +150,7 @@ bool protocol_fdx_a_encoder_start(ProtocolFDXA* protocol) {
|
||||
protocol_fdx_a_encode(protocol);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_fdx_a_encoder_yield(ProtocolFDXA* protocol) {
|
||||
bool level = 0;
|
||||
@@ -180,7 +180,7 @@ LevelDuration protocol_fdx_a_encoder_yield(ProtocolFDXA* protocol) {
|
||||
}
|
||||
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_fdx_a_write_data(ProtocolFDXA* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -203,7 +203,7 @@ bool protocol_fdx_a_write_data(ProtocolFDXA* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_fdx_a_render_data(ProtocolFDXA* protocol, FuriString* result) {
|
||||
uint8_t data[FDXA_DECODED_DATA_SIZE];
|
||||
@@ -221,7 +221,7 @@ void protocol_fdx_a_render_data(ProtocolFDXA* protocol, FuriString* result) {
|
||||
"Parity: %c",
|
||||
bit_lib_get_bits_64(data, 0, 40),
|
||||
parity_sum == 0 ? '+' : '-');
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_fdx_a = {
|
||||
.name = "FDX-A",
|
||||
|
||||
@@ -34,20 +34,20 @@ typedef struct {
|
||||
ProtocolFDXB* protocol_fdx_b_alloc(void) {
|
||||
ProtocolFDXB* protocol = malloc(sizeof(ProtocolFDXB));
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_fdx_b_free(ProtocolFDXB* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_fdx_b_get_data(ProtocolFDXB* proto) {
|
||||
return proto->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_fdx_b_decoder_start(ProtocolFDXB* protocol) {
|
||||
memset(protocol->encoded_data, 0, FDX_B_ENCODED_BYTE_FULL_SIZE);
|
||||
protocol->last_short = false;
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_fdx_b_can_be_decoded(ProtocolFDXB* protocol) {
|
||||
bool result = false;
|
||||
@@ -179,7 +179,7 @@ bool protocol_fdx_b_decoder_feed(ProtocolFDXB* protocol, bool level, uint32_t du
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_fdx_b_encoder_start(ProtocolFDXB* protocol) {
|
||||
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_level = false;
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_fdx_b_encoder_yield(ProtocolFDXB* protocol) {
|
||||
uint32_t duration;
|
||||
@@ -228,7 +228,7 @@ LevelDuration protocol_fdx_b_encoder_yield(ProtocolFDXB* protocol) {
|
||||
}
|
||||
|
||||
return level_duration_make(protocol->last_level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
// 0 nnnnnnnn
|
||||
// 8 nnnnnnnn 38 bit (12 digit) National code.
|
||||
@@ -320,7 +320,7 @@ void protocol_fdx_b_render_data(ProtocolFDXB* protocol, FuriString* result) {
|
||||
reserved,
|
||||
user_info,
|
||||
replacement_number);
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_fdx_b_render_brief_data(ProtocolFDXB* protocol, FuriString* result) {
|
||||
// 38 bits of national code
|
||||
@@ -348,7 +348,7 @@ void protocol_fdx_b_render_brief_data(ProtocolFDXB* protocol, FuriString* result
|
||||
} else {
|
||||
furi_string_cat(result, "---");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_fdx_b_write_data(ProtocolFDXB* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -371,7 +371,7 @@ bool protocol_fdx_b_write_data(ProtocolFDXB* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_fdx_b = {
|
||||
.name = "FDX-B",
|
||||
|
||||
@@ -36,15 +36,15 @@ typedef struct {
|
||||
ProtocolGallagher* protocol_gallagher_alloc(void) {
|
||||
ProtocolGallagher* proto = malloc(sizeof(ProtocolGallagher));
|
||||
return (void*)proto;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_gallagher_free(ProtocolGallagher* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_gallagher_get_data(ProtocolGallagher* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_gallagher_scramble(uint8_t* data, size_t length) {
|
||||
const uint8_t lut[] = {
|
||||
@@ -152,7 +152,7 @@ void protocol_gallagher_decoder_start(ProtocolGallagher* protocol) {
|
||||
ManchesterEventReset,
|
||||
&protocol->decoder_manchester_state,
|
||||
NULL);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_gallagher_decoder_feed(ProtocolGallagher* protocol, bool level, uint32_t duration) {
|
||||
bool result = false;
|
||||
@@ -189,7 +189,7 @@ bool protocol_gallagher_decoder_feed(ProtocolGallagher* protocol, bool level, ui
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_gallagher_encoder_start(ProtocolGallagher* protocol) {
|
||||
// Preamble
|
||||
@@ -227,7 +227,7 @@ bool protocol_gallagher_encoder_start(ProtocolGallagher* protocol) {
|
||||
bit_lib_set_bits(protocol->encoded_data, 16 + (9 * 8), crc, 8);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_gallagher_encoder_yield(ProtocolGallagher* protocol) {
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_gallagher_write_data(ProtocolGallagher* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -266,7 +266,7 @@ bool protocol_gallagher_write_data(ProtocolGallagher* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_gallagher_render_data_internal(
|
||||
ProtocolGallagher* protocol,
|
||||
@@ -296,7 +296,7 @@ static void protocol_gallagher_render_data_internal(
|
||||
region,
|
||||
issue_level);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_gallagher_render_data(ProtocolGallagher* protocol, FuriString* result) {
|
||||
protocol_gallagher_render_data_internal(protocol, result, false);
|
||||
|
||||
@@ -38,21 +38,21 @@ ProtocolH10301* protocol_h10301_alloc(void) {
|
||||
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
|
||||
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_h10301_free(ProtocolH10301* protocol) {
|
||||
fsk_demod_free(protocol->decoder.fsk_demod);
|
||||
fsk_osc_free(protocol->encoder.fsk_osc);
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_h10301_get_data(ProtocolH10301* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_h10301_decoder_start(ProtocolH10301* protocol) {
|
||||
memset(protocol->encoded_data, 0, sizeof(uint32_t) * 3);
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_h10301_decoder_store_data(ProtocolH10301* protocol, bool data) {
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_h10301_write_raw_bit(bool bit, uint8_t position, uint32_t* card_data) {
|
||||
if(bit) {
|
||||
@@ -295,7 +295,7 @@ bool protocol_h10301_encoder_start(ProtocolH10301* protocol) {
|
||||
protocol->encoder.pulse = 0;
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_h10301_encoder_yield(ProtocolH10301* protocol) {
|
||||
bool level = 0;
|
||||
@@ -331,7 +331,7 @@ LevelDuration protocol_h10301_encoder_yield(ProtocolH10301* protocol) {
|
||||
}
|
||||
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_h10301_write_data(ProtocolH10301* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -353,7 +353,7 @@ bool protocol_h10301_write_data(ProtocolH10301* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_h10301_render_data(ProtocolH10301* protocol, FuriString* result) {
|
||||
uint8_t* data = protocol->data;
|
||||
@@ -363,7 +363,7 @@ void protocol_h10301_render_data(ProtocolH10301* protocol, FuriString* result) {
|
||||
"Card: %hu",
|
||||
data[0],
|
||||
(uint16_t)((data[1] << 8) | (data[2])));
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_h10301 = {
|
||||
.name = "H10301",
|
||||
|
||||
@@ -43,21 +43,21 @@ ProtocolHIDEx* protocol_hid_ex_generic_alloc(void) {
|
||||
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
|
||||
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_hid_ex_generic_free(ProtocolHIDEx* protocol) {
|
||||
fsk_demod_free(protocol->decoder.fsk_demod);
|
||||
fsk_osc_free(protocol->encoder.fsk_osc);
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_hid_ex_generic_get_data(ProtocolHIDEx* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_hid_ex_generic_decoder_start(ProtocolHIDEx* protocol) {
|
||||
memset(protocol->encoded_data, 0, HID_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_hid_ex_generic_can_be_decoded(const uint8_t* data) {
|
||||
// check preamble
|
||||
@@ -110,7 +110,7 @@ bool protocol_hid_ex_generic_decoder_feed(ProtocolHIDEx* protocol, bool level, u
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_hid_ex_generic_encode(ProtocolHIDEx* protocol) {
|
||||
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);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_hid_ex_generic_encoder_yield(ProtocolHIDEx* protocol) {
|
||||
bool level = 0;
|
||||
@@ -165,7 +165,7 @@ LevelDuration protocol_hid_ex_generic_encoder_yield(ProtocolHIDEx* protocol) {
|
||||
}
|
||||
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_hid_ex_generic_write_data(ProtocolHIDEx* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -190,7 +190,7 @@ bool protocol_hid_ex_generic_write_data(ProtocolHIDEx* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_hid_ex_generic_render_data(ProtocolHIDEx* protocol, FuriString* result) {
|
||||
UNUSED(protocol);
|
||||
@@ -200,7 +200,7 @@ void protocol_hid_ex_generic_render_data(ProtocolHIDEx* protocol, FuriString* re
|
||||
result,
|
||||
"Type: Generic HID Extended\n"
|
||||
"Data: Unknown");
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_hid_ex_generic = {
|
||||
.name = "HIDExt",
|
||||
|
||||
@@ -43,21 +43,21 @@ ProtocolHID* protocol_hid_generic_alloc(void) {
|
||||
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
|
||||
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_hid_generic_free(ProtocolHID* protocol) {
|
||||
fsk_demod_free(protocol->decoder.fsk_demod);
|
||||
fsk_osc_free(protocol->encoder.fsk_osc);
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_hid_generic_get_data(ProtocolHID* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_hid_generic_decoder_start(ProtocolHID* protocol) {
|
||||
memset(protocol->encoded_data, 0, HID_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_hid_generic_can_be_decoded(const uint8_t* data) {
|
||||
// check preamble
|
||||
@@ -142,7 +142,7 @@ bool protocol_hid_generic_decoder_feed(ProtocolHID* protocol, bool level, uint32
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_hid_generic_encode(ProtocolHID* protocol) {
|
||||
protocol->encoded_data[0] = HID_PREAMBLE;
|
||||
@@ -167,7 +167,7 @@ bool protocol_hid_generic_encoder_start(ProtocolHID* protocol) {
|
||||
protocol_hid_generic_encode(protocol);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_hid_generic_encoder_yield(ProtocolHID* protocol) {
|
||||
bool level = 0;
|
||||
@@ -197,7 +197,7 @@ LevelDuration protocol_hid_generic_encoder_yield(ProtocolHID* protocol) {
|
||||
}
|
||||
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_hid_generic_write_data(ProtocolHID* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -219,7 +219,7 @@ bool protocol_hid_generic_write_data(ProtocolHID* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_hid_generic_string_cat_protocol_bits(
|
||||
ProtocolHID* protocol,
|
||||
@@ -261,7 +261,7 @@ void protocol_hid_generic_render_data(ProtocolHID* protocol, FuriString* result)
|
||||
protocol_size);
|
||||
protocol_hid_generic_string_cat_protocol_bits(protocol, protocol_size, result);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_hid_generic = {
|
||||
.name = "HIDProx",
|
||||
|
||||
@@ -42,22 +42,22 @@ typedef struct {
|
||||
ProtocolIdteck* protocol_idteck_alloc(void) {
|
||||
ProtocolIdteck* protocol = malloc(sizeof(ProtocolIdteck));
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_idteck_free(ProtocolIdteck* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_idteck_get_data(ProtocolIdteck* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_idteck_decoder_start(ProtocolIdteck* protocol) {
|
||||
memset(protocol->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_negative_encoded_data, 0, IDTECK_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_idteck_check_preamble(uint8_t* data, size_t bit_index) {
|
||||
// Preamble 01001001 01000100 01010100 01001011
|
||||
@@ -144,7 +144,7 @@ bool protocol_idteck_decoder_feed(ProtocolIdteck* protocol, bool level, uint32_t
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_idteck_encoder_start(ProtocolIdteck* protocol) {
|
||||
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;
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_idteck_encoder_yield(ProtocolIdteck* protocol) {
|
||||
LevelDuration level_duration;
|
||||
@@ -189,7 +189,7 @@ LevelDuration protocol_idteck_encoder_yield(ProtocolIdteck* protocol) {
|
||||
}
|
||||
|
||||
return level_duration;
|
||||
};
|
||||
}
|
||||
|
||||
// factory code
|
||||
static uint32_t get_fc(const uint8_t* data) {
|
||||
@@ -232,7 +232,7 @@ bool protocol_idteck_write_data(ProtocolIdteck* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_idteck = {
|
||||
.name = "Idteck",
|
||||
|
||||
@@ -38,22 +38,22 @@ typedef struct {
|
||||
ProtocolIndala* protocol_indala26_alloc(void) {
|
||||
ProtocolIndala* protocol = malloc(sizeof(ProtocolIndala));
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_indala26_free(ProtocolIndala* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_indala26_get_data(ProtocolIndala* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_indala26_decoder_start(ProtocolIndala* protocol) {
|
||||
memset(protocol->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_negative_encoded_data, 0, INDALA26_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_indala26_check_preamble(uint8_t* data, size_t bit_index) {
|
||||
// Preamble 10100000 00000000 00000000 00000000 1
|
||||
@@ -146,7 +146,7 @@ bool protocol_indala26_decoder_feed(ProtocolIndala* protocol, bool level, uint32
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_indala26_encoder_start(ProtocolIndala* protocol) {
|
||||
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;
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_indala26_encoder_yield(ProtocolIndala* protocol) {
|
||||
LevelDuration level_duration;
|
||||
@@ -194,7 +194,7 @@ LevelDuration protocol_indala26_encoder_yield(ProtocolIndala* protocol) {
|
||||
}
|
||||
|
||||
return level_duration;
|
||||
};
|
||||
}
|
||||
|
||||
// factory code
|
||||
static uint8_t get_fc(const uint8_t* data) {
|
||||
@@ -328,7 +328,7 @@ bool protocol_indala26_write_data(ProtocolIndala* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_indala26 = {
|
||||
.name = "Indala26",
|
||||
|
||||
@@ -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->encoder.fsk_osc = fsk_osc_alloc(8, 10, 64);
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_io_prox_xsf_free(ProtocolIOProxXSF* protocol) {
|
||||
fsk_demod_free(protocol->decoder.fsk_demod);
|
||||
fsk_osc_free(protocol->encoder.fsk_osc);
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_io_prox_xsf_get_data(ProtocolIOProxXSF* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_io_prox_xsf_decoder_start(ProtocolIOProxXSF* protocol) {
|
||||
memset(protocol->encoded_data, 0, IOPROXXSF_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static uint8_t protocol_io_prox_xsf_compute_checksum(const uint8_t* data) {
|
||||
// Packet structure:
|
||||
@@ -172,7 +172,7 @@ bool protocol_io_prox_xsf_decoder_feed(ProtocolIOProxXSF* protocol, bool level,
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_io_prox_xsf_encode(const uint8_t* decoded_data, uint8_t* encoded_data) {
|
||||
// Packet to transmit:
|
||||
@@ -217,7 +217,7 @@ bool protocol_io_prox_xsf_encoder_start(ProtocolIOProxXSF* protocol) {
|
||||
protocol->encoder.encoded_index = 0;
|
||||
fsk_osc_reset(protocol->encoder.fsk_osc);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_io_prox_xsf_encoder_yield(ProtocolIOProxXSF* protocol) {
|
||||
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);
|
||||
}
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_io_prox_xsf_render_data(ProtocolIOProxXSF* protocol, FuriString* result) {
|
||||
uint8_t* data = protocol->data;
|
||||
@@ -274,7 +274,7 @@ bool protocol_io_prox_xsf_write_data(ProtocolIOProxXSF* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_io_prox_xsf = {
|
||||
.name = "IoProxXSF",
|
||||
|
||||
@@ -34,20 +34,20 @@ typedef struct {
|
||||
ProtocolJablotron* protocol_jablotron_alloc(void) {
|
||||
ProtocolJablotron* protocol = malloc(sizeof(ProtocolJablotron));
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_jablotron_free(ProtocolJablotron* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_jablotron_get_data(ProtocolJablotron* proto) {
|
||||
return proto->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_jablotron_decoder_start(ProtocolJablotron* protocol) {
|
||||
memset(protocol->encoded_data, 0, JABLOTRON_ENCODED_BYTE_FULL_SIZE);
|
||||
protocol->last_short = false;
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t protocol_jablotron_checksum(uint8_t* bits) {
|
||||
uint8_t chksum = 0;
|
||||
@@ -115,7 +115,7 @@ bool protocol_jablotron_decoder_feed(ProtocolJablotron* protocol, bool level, ui
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_jablotron_encoder_start(ProtocolJablotron* protocol) {
|
||||
// preamble
|
||||
@@ -133,7 +133,7 @@ bool protocol_jablotron_encoder_start(ProtocolJablotron* protocol) {
|
||||
protocol->last_short = false;
|
||||
protocol->last_level = false;
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_jablotron_encoder_yield(ProtocolJablotron* protocol) {
|
||||
uint32_t duration;
|
||||
@@ -158,12 +158,12 @@ LevelDuration protocol_jablotron_encoder_yield(ProtocolJablotron* protocol) {
|
||||
}
|
||||
|
||||
return level_duration_make(protocol->last_level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_jablotron_render_data(ProtocolJablotron* protocol, FuriString* result) {
|
||||
uint64_t id = protocol_jablotron_card_id(protocol->data);
|
||||
furi_string_printf(result, "Card: %llX", id);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_jablotron_write_data(ProtocolJablotron* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -184,7 +184,7 @@ bool protocol_jablotron_write_data(ProtocolJablotron* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_jablotron = {
|
||||
.name = "Jablotron",
|
||||
|
||||
@@ -37,22 +37,22 @@ typedef struct {
|
||||
ProtocolKeri* protocol_keri_alloc(void) {
|
||||
ProtocolKeri* protocol = malloc(sizeof(ProtocolKeri));
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_keri_free(ProtocolKeri* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_keri_get_data(ProtocolKeri* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_keri_decoder_start(ProtocolKeri* protocol) {
|
||||
memset(protocol->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_negative_encoded_data, 0, KERI_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_keri_check_preamble(uint8_t* data, size_t bit_index) {
|
||||
// Preamble 11100000 00000000 00000000 00000000 1
|
||||
@@ -164,7 +164,7 @@ bool protocol_keri_decoder_feed(ProtocolKeri* protocol, bool level, uint32_t dur
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_keri_encoder_start(ProtocolKeri* protocol) {
|
||||
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;
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_keri_encoder_yield(ProtocolKeri* protocol) {
|
||||
LevelDuration level_duration;
|
||||
@@ -210,7 +210,7 @@ LevelDuration protocol_keri_encoder_yield(ProtocolKeri* protocol) {
|
||||
}
|
||||
|
||||
return level_duration;
|
||||
};
|
||||
}
|
||||
|
||||
static void
|
||||
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;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_keri = {
|
||||
.name = "Keri",
|
||||
|
||||
@@ -47,22 +47,22 @@ typedef struct {
|
||||
ProtocolNexwatch* protocol_nexwatch_alloc(void) {
|
||||
ProtocolNexwatch* protocol = malloc(sizeof(ProtocolNexwatch));
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_nexwatch_free(ProtocolNexwatch* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_nexwatch_get_data(ProtocolNexwatch* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_nexwatch_decoder_start(ProtocolNexwatch* protocol) {
|
||||
memset(protocol->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_negative_encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_nexwatch_check_preamble(uint8_t* data, size_t bit_index) {
|
||||
// 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) {
|
||||
uint8_t a = (((parity >> 3) & 1));
|
||||
uint8_t a = ((parity >> 3) & 1);
|
||||
a |= (((parity >> 1) & 1) << 1);
|
||||
a |= (((parity >> 2) & 1) << 2);
|
||||
a |= ((parity & 1) << 3);
|
||||
@@ -215,7 +215,7 @@ bool protocol_nexwatch_decoder_feed(ProtocolNexwatch* protocol, bool level, uint
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_nexwatch_encoder_start(ProtocolNexwatch* protocol) {
|
||||
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;
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_nexwatch_encoder_yield(ProtocolNexwatch* protocol) {
|
||||
LevelDuration level_duration;
|
||||
@@ -261,7 +261,7 @@ LevelDuration protocol_nexwatch_encoder_yield(ProtocolNexwatch* protocol) {
|
||||
}
|
||||
|
||||
return level_duration;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_nexwatch_render_data_internal(
|
||||
ProtocolNexwatch* protocol,
|
||||
@@ -328,7 +328,7 @@ bool protocol_nexwatch_write_data(ProtocolNexwatch* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_nexwatch = {
|
||||
.name = "Nexwatch",
|
||||
|
||||
@@ -38,21 +38,21 @@ ProtocolParadox* protocol_paradox_alloc(void) {
|
||||
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
|
||||
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_paradox_free(ProtocolParadox* protocol) {
|
||||
fsk_demod_free(protocol->decoder.fsk_demod);
|
||||
fsk_osc_free(protocol->encoder.fsk_osc);
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_paradox_get_data(ProtocolParadox* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_paradox_decoder_start(ProtocolParadox* protocol) {
|
||||
memset(protocol->encoded_data, 0, PARADOX_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_paradox_can_be_decoded(ProtocolParadox* protocol) {
|
||||
// check preamble
|
||||
@@ -101,7 +101,7 @@ bool protocol_paradox_decoder_feed(ProtocolParadox* protocol, bool level, uint32
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_paradox_encode(const uint8_t* decoded_data, uint8_t* encoded_data) {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_paradox_encoder_start(ProtocolParadox* protocol) {
|
||||
protocol_paradox_encode(protocol->data, (uint8_t*)protocol->encoded_data);
|
||||
protocol->encoder.encoded_index = 0;
|
||||
fsk_osc_reset(protocol->encoder.fsk_osc);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_paradox_encoder_yield(ProtocolParadox* protocol) {
|
||||
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);
|
||||
}
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
static uint8_t protocol_paradox_calculate_checksum(uint8_t fc, uint16_t card_id) {
|
||||
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) {
|
||||
furi_string_cat(result, "\nCRC Mismatch, Invalid Card!");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_paradox_render_brief_data(ProtocolParadox* protocol, FuriString* result) {
|
||||
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) {
|
||||
furi_string_cat(result, "\nCRC Mismatch, Invalid Card!");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_paradox_write_data(ProtocolParadox* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -222,7 +222,7 @@ bool protocol_paradox_write_data(ProtocolParadox* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_paradox = {
|
||||
.name = "Paradox",
|
||||
|
||||
@@ -41,21 +41,21 @@ ProtocolPyramid* protocol_pyramid_alloc(void) {
|
||||
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
|
||||
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_pyramid_free(ProtocolPyramid* protocol) {
|
||||
fsk_demod_free(protocol->decoder.fsk_demod);
|
||||
fsk_osc_free(protocol->encoder.fsk_osc);
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_pyramid_get_data(ProtocolPyramid* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_pyramid_decoder_start(ProtocolPyramid* protocol) {
|
||||
memset(protocol->encoded_data, 0, PYRAMID_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_pyramid_can_be_decoded(uint8_t* data) {
|
||||
// check preamble
|
||||
@@ -122,7 +122,7 @@ bool protocol_pyramid_decoder_feed(ProtocolPyramid* protocol, bool level, uint32
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_pyramid_get_parity(const uint8_t* bits, uint8_t type, int length) {
|
||||
int x;
|
||||
@@ -184,7 +184,7 @@ bool protocol_pyramid_encoder_start(ProtocolPyramid* protocol) {
|
||||
protocol_pyramid_encode(protocol);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_pyramid_encoder_yield(ProtocolPyramid* protocol) {
|
||||
bool level = 0;
|
||||
@@ -214,7 +214,7 @@ LevelDuration protocol_pyramid_encoder_yield(ProtocolPyramid* protocol) {
|
||||
}
|
||||
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_pyramid_write_data(ProtocolPyramid* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -238,7 +238,7 @@ bool protocol_pyramid_write_data(ProtocolPyramid* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_pyramid_render_data(ProtocolPyramid* protocol, FuriString* result) {
|
||||
uint8_t* decoded_data = protocol->data;
|
||||
@@ -256,7 +256,7 @@ void protocol_pyramid_render_data(ProtocolPyramid* protocol, FuriString* result)
|
||||
} else {
|
||||
furi_string_cat_printf(result, "Data: Unknown");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_pyramid = {
|
||||
.name = "Pyramid",
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <toolbox/manchester_decoder.h>
|
||||
|
||||
#define TAG "SECURAKEY"
|
||||
|
||||
#define SECURAKEY_RKKT_ENCODED_FULL_SIZE_BITS (96)
|
||||
#define SECURAKEY_RKKT_ENCODED_FULL_SIZE_BYTE (12)
|
||||
|
||||
@@ -47,15 +48,15 @@ typedef struct {
|
||||
ProtocolSecurakey* protocol_securakey_alloc(void) {
|
||||
ProtocolSecurakey* protocol = malloc(sizeof(ProtocolSecurakey));
|
||||
return (void*)protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_securakey_free(ProtocolSecurakey* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_securakey_get_data(ProtocolSecurakey* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_securakey_can_be_decoded(ProtocolSecurakey* protocol) {
|
||||
// check 19 bits preamble + format flag
|
||||
@@ -71,7 +72,7 @@ static bool protocol_securakey_can_be_decoded(ProtocolSecurakey* protocol) {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_securakey_decode(ProtocolSecurakey* protocol) {
|
||||
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)
|
||||
// pppppppp pppppppp cccccccc cccccccc cccccccc cccccccc
|
||||
// 00000000 00000000 00101011 00011101 00000100 01001010
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_securakey_decoder_start(ProtocolSecurakey* protocol) {
|
||||
// always takes in encoded data as RKKT for simplicity
|
||||
@@ -153,7 +154,7 @@ void protocol_securakey_decoder_start(ProtocolSecurakey* protocol) {
|
||||
ManchesterEventReset,
|
||||
&protocol->decoder_manchester_state,
|
||||
NULL);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_securakey_decoder_feed(ProtocolSecurakey* protocol, bool level, uint32_t duration) {
|
||||
bool result = false;
|
||||
@@ -187,7 +188,7 @@ bool protocol_securakey_decoder_feed(ProtocolSecurakey* protocol, bool level, ui
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_securakey_render_data(ProtocolSecurakey* protocol, FuriString* result) {
|
||||
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, 16, 16));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_securakey_encoder_start(ProtocolSecurakey* protocol) {
|
||||
// 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_polarity = true;
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_securakey_encoder_yield(ProtocolSecurakey* protocol) {
|
||||
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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_securakey_write_data(ProtocolSecurakey* protocol, void* data) {
|
||||
protocol_securakey_encoder_start(protocol);
|
||||
@@ -337,7 +338,7 @@ bool protocol_securakey_write_data(ProtocolSecurakey* protocol, void* data) {
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_securakey = {
|
||||
.name = "Radio Key",
|
||||
|
||||
@@ -35,15 +35,15 @@ typedef struct {
|
||||
ProtocolViking* protocol_viking_alloc(void) {
|
||||
ProtocolViking* proto = malloc(sizeof(ProtocolViking));
|
||||
return (void*)proto;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_viking_free(ProtocolViking* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_viking_get_data(ProtocolViking* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_viking_decode(ProtocolViking* protocol) {
|
||||
// Copy Card ID
|
||||
@@ -80,7 +80,7 @@ void protocol_viking_decoder_start(ProtocolViking* protocol) {
|
||||
ManchesterEventReset,
|
||||
&protocol->decoder_manchester_state,
|
||||
NULL);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_viking_decoder_feed(ProtocolViking* protocol, bool level, uint32_t duration) {
|
||||
bool result = false;
|
||||
@@ -117,7 +117,7 @@ bool protocol_viking_decoder_feed(ProtocolViking* protocol, bool level, uint32_t
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_viking_encoder_start(ProtocolViking* protocol) {
|
||||
// Preamble
|
||||
@@ -135,7 +135,7 @@ bool protocol_viking_encoder_start(ProtocolViking* protocol) {
|
||||
bit_lib_set_bits(protocol->encoded_data, 56, checksum, 8);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_viking_encoder_yield(ProtocolViking* protocol) {
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_viking_write_data(ProtocolViking* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -173,11 +173,11 @@ bool protocol_viking_write_data(ProtocolViking* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return 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));
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_viking = {
|
||||
.name = "Viking",
|
||||
|
||||
@@ -45,7 +45,7 @@ bool felica_crc_check(const BitBuffer* buf) {
|
||||
const uint8_t* data = bit_buffer_get_data(buf);
|
||||
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) {
|
||||
|
||||
@@ -55,7 +55,7 @@ bool iso13239_crc_check(Iso13239CrcType type, const BitBuffer* 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);
|
||||
|
||||
return (crc_calc == crc_received);
|
||||
return crc_calc == crc_received;
|
||||
}
|
||||
|
||||
void iso13239_crc_trim(BitBuffer* buf) {
|
||||
|
||||
@@ -50,7 +50,7 @@ bool iso14443_crc_check(Iso14443CrcType type, const BitBuffer* 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);
|
||||
|
||||
return (crc_calc == crc_received);
|
||||
return crc_calc == crc_received;
|
||||
}
|
||||
|
||||
void iso14443_crc_trim(BitBuffer* buf) {
|
||||
|
||||
@@ -17,7 +17,7 @@ uint8_t nfc_util_even_parity32(uint32_t data) {
|
||||
// data ^= data >> 16;
|
||||
// data ^= data >> 8;
|
||||
// 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) {
|
||||
|
||||
@@ -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) {
|
||||
const uint32_t* wcnt_ptr = (uint32_t*)data->data.fs.wcnt.data;
|
||||
return (
|
||||
FELICA_SYSTEM_BLOCK_RO_ACCESS(data) &&
|
||||
return FELICA_SYSTEM_BLOCK_RO_ACCESS(data) &&
|
||||
((*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) {
|
||||
@@ -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 fact_data_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) {
|
||||
|
||||
@@ -47,7 +47,7 @@ Iso14443_3aError iso14443_3a_listener_tx_with_custom_parity(
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
Iso14443_3aError iso14443_3a_listener_send_standard_frame(
|
||||
Iso14443_3aListener* instance,
|
||||
|
||||
@@ -546,7 +546,7 @@ void mf_classic_set_key_not_found(
|
||||
bool mf_classic_is_block_read(const MfClassicData* data, uint8_t block_num) {
|
||||
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) {
|
||||
@@ -661,22 +661,20 @@ static bool mf_classic_is_allowed_access_sector_trailer(
|
||||
}
|
||||
case MfClassicActionKeyAWrite:
|
||||
case MfClassicActionKeyBWrite: {
|
||||
return (
|
||||
(key_type == MfClassicKeyTypeA && (AC == 0x00 || AC == 0x01)) ||
|
||||
return (key_type == MfClassicKeyTypeA && (AC == 0x00 || AC == 0x01)) ||
|
||||
(key_type == MfClassicKeyTypeB &&
|
||||
(AC == 0x00 || AC == 0x04 || AC == 0x03 || AC == 0x01)));
|
||||
(AC == 0x00 || AC == 0x04 || AC == 0x03 || AC == 0x01));
|
||||
}
|
||||
case MfClassicActionKeyBRead: {
|
||||
return (key_type == MfClassicKeyTypeA && (AC == 0x00 || AC == 0x02 || AC == 0x01)) ||
|
||||
(key_type == MfClassicKeyTypeB && (AC == 0x00 || AC == 0x02 || AC == 0x01));
|
||||
}
|
||||
case MfClassicActionACRead: {
|
||||
return ((key_type == MfClassicKeyTypeA) || (key_type == MfClassicKeyTypeB));
|
||||
return (key_type == MfClassicKeyTypeA) || (key_type == MfClassicKeyTypeB);
|
||||
}
|
||||
case MfClassicActionACWrite: {
|
||||
return (
|
||||
(key_type == MfClassicKeyTypeA && (AC == 0x01)) ||
|
||||
(key_type == MfClassicKeyTypeB && (AC == 0x01 || AC == 0x03 || AC == 0x05)));
|
||||
return (key_type == MfClassicKeyTypeA && (AC == 0x01)) ||
|
||||
(key_type == MfClassicKeyTypeB && (AC == 0x01 || AC == 0x03 || AC == 0x05));
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
@@ -727,25 +725,21 @@ bool mf_classic_is_allowed_access_data_block(
|
||||
|
||||
switch(action) {
|
||||
case MfClassicActionDataRead: {
|
||||
return (
|
||||
(key_type == MfClassicKeyTypeA && !(AC == 0x03 || AC == 0x05 || AC == 0x07)) ||
|
||||
(key_type == MfClassicKeyTypeB && !(AC == 0x07)));
|
||||
return (key_type == MfClassicKeyTypeA && !(AC == 0x03 || AC == 0x05 || AC == 0x07)) ||
|
||||
(key_type == MfClassicKeyTypeB && !(AC == 0x07));
|
||||
}
|
||||
case MfClassicActionDataWrite: {
|
||||
return (
|
||||
(key_type == MfClassicKeyTypeA && (AC == 0x00)) ||
|
||||
return (key_type == MfClassicKeyTypeA && (AC == 0x00)) ||
|
||||
(key_type == MfClassicKeyTypeB &&
|
||||
(AC == 0x00 || AC == 0x04 || AC == 0x06 || AC == 0x03)));
|
||||
(AC == 0x00 || AC == 0x04 || AC == 0x06 || AC == 0x03));
|
||||
}
|
||||
case MfClassicActionDataInc: {
|
||||
return (
|
||||
(key_type == MfClassicKeyTypeA && (AC == 0x00)) ||
|
||||
(key_type == MfClassicKeyTypeB && (AC == 0x00 || AC == 0x06)));
|
||||
return (key_type == MfClassicKeyTypeA && (AC == 0x00)) ||
|
||||
(key_type == MfClassicKeyTypeB && (AC == 0x00 || AC == 0x06));
|
||||
}
|
||||
case MfClassicActionDataDec: {
|
||||
return (
|
||||
(key_type == MfClassicKeyTypeA && (AC == 0x00 || AC == 0x06 || AC == 0x01)) ||
|
||||
(key_type == MfClassicKeyTypeB && (AC == 0x00 || AC == 0x06 || AC == 0x01)));
|
||||
return (key_type == MfClassicKeyTypeA && (AC == 0x00 || AC == 0x06 || AC == 0x01)) ||
|
||||
(key_type == MfClassicKeyTypeB && (AC == 0x00 || AC == 0x06 || AC == 0x01));
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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) {
|
||||
uint8_t pwd_page = mf_ultralight_get_pwd_page_num(type);
|
||||
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) {
|
||||
|
||||
@@ -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_byte(instance->tx_buffer, 0, data);
|
||||
iso14443_3a_listener_tx(instance->iso14443_3a_listener, instance->tx_buffer);
|
||||
};
|
||||
}
|
||||
|
||||
static void mf_ultralight_listener_perform_read(
|
||||
MfUltralightPage* pages,
|
||||
|
||||
@@ -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) {
|
||||
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) {
|
||||
@@ -207,7 +207,7 @@ void mf_ultraligt_mirror_format_counter(MfUltralightListener* instance) {
|
||||
}
|
||||
|
||||
bool mf_ultralight_composite_command_in_progress(MfUltralightListener* instance) {
|
||||
return (instance->composite_cmd.callback != NULL);
|
||||
return instance->composite_cmd.callback != NULL;
|
||||
}
|
||||
|
||||
MfUltralightCommand
|
||||
@@ -550,7 +550,7 @@ static bool mf_ultralight_auth_check_attempts(const MfUltralightListener* instan
|
||||
(1U << 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) {
|
||||
|
||||
@@ -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;
|
||||
@@ -204,7 +204,7 @@ static void onewire_slave_exti_callback(void* context) {
|
||||
} else {
|
||||
pulse_start = DWT->CYCCNT;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/*********************** PUBLIC ***********************/
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ static uint16_t subghz_protocol_bin_raw_get_full_byte(uint16_t bit_count) {
|
||||
if(bit_count & 0x7) {
|
||||
return (bit_count >> 3) + 1;
|
||||
} 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
Reference in New Issue
Block a user