mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
formatting
This commit is contained in:
@@ -185,4 +185,4 @@ ProtocolId lfrfid_dict_file_load(ProtocolDict* dict, const char* filename) {
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,4 +28,4 @@ ProtocolId lfrfid_dict_file_load(ProtocolDict* dict, const char* filename);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <toolbox/stream/file_stream.h>
|
||||
#include <toolbox/varint.h>
|
||||
|
||||
#define LFRFID_RAW_FILE_MAGIC 0x4C464952
|
||||
#define LFRFID_RAW_FILE_MAGIC 0x4C464952
|
||||
#define LFRFID_RAW_FILE_VERSION 1
|
||||
|
||||
#define TAG "LfRfidRawFile"
|
||||
@@ -166,4 +166,4 @@ bool lfrfid_raw_file_read_pair(
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include "lfrfid_raw_file.h"
|
||||
#include "tools/varint_pair.h"
|
||||
|
||||
#define EMULATE_BUFFER_SIZE 1024
|
||||
#define RFID_DATA_BUFFER_SIZE 2048
|
||||
#define EMULATE_BUFFER_SIZE 1024
|
||||
#define RFID_DATA_BUFFER_SIZE 2048
|
||||
#define READ_DATA_BUFFER_COUNT 4
|
||||
|
||||
#define TAG_EMULATE "RawEmulate"
|
||||
|
||||
@@ -65,4 +65,4 @@ void lfrfid_raw_worker_stop(LFRFIDRawWorker* worker);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -19,23 +19,23 @@
|
||||
|
||||
#ifdef LFRFID_WORKER_READ_DEBUG_GPIO
|
||||
#define LFRFID_WORKER_READ_DEBUG_GPIO_VALUE &gpio_ext_pa7
|
||||
#define LFRFID_WORKER_READ_DEBUG_GPIO_LOAD &gpio_ext_pa6
|
||||
#define LFRFID_WORKER_READ_DEBUG_GPIO_LOAD &gpio_ext_pa6
|
||||
#endif
|
||||
|
||||
#define LFRFID_WORKER_READ_AVERAGE_COUNT 64
|
||||
#define LFRFID_WORKER_READ_MIN_TIME_US 16
|
||||
#define LFRFID_WORKER_READ_MIN_TIME_US 16
|
||||
|
||||
#define LFRFID_WORKER_READ_DROP_TIME_MS 50
|
||||
#define LFRFID_WORKER_READ_DROP_TIME_MS 50
|
||||
#define LFRFID_WORKER_READ_STABILIZE_TIME_MS 450
|
||||
#define LFRFID_WORKER_READ_SWITCH_TIME_MS 2000
|
||||
#define LFRFID_WORKER_READ_SWITCH_TIME_MS 2000
|
||||
|
||||
#define LFRFID_WORKER_WRITE_VERIFY_TIME_MS 2000
|
||||
#define LFRFID_WORKER_WRITE_DROP_TIME_MS 50
|
||||
#define LFRFID_WORKER_WRITE_VERIFY_TIME_MS 2000
|
||||
#define LFRFID_WORKER_WRITE_DROP_TIME_MS 50
|
||||
#define LFRFID_WORKER_WRITE_TOO_LONG_TIME_MS 10000
|
||||
|
||||
#define LFRFID_WORKER_WRITE_MAX_UNSUCCESSFUL_READS 5
|
||||
|
||||
#define LFRFID_WORKER_READ_BUFFER_SIZE 512
|
||||
#define LFRFID_WORKER_READ_BUFFER_SIZE 512
|
||||
#define LFRFID_WORKER_READ_BUFFER_COUNT 16
|
||||
|
||||
#define LFRFID_WORKER_EMULATE_BUFFER_SIZE 1024
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define JITTER_TIME (20)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
|
||||
#define AWID_DECODED_DATA_SIZE (9)
|
||||
|
||||
#define AWID_ENCODED_BIT_SIZE (96)
|
||||
#define AWID_ENCODED_BIT_SIZE (96)
|
||||
#define AWID_ENCODED_DATA_SIZE (((AWID_ENCODED_BIT_SIZE) / 8) + 1)
|
||||
#define AWID_ENCODED_DATA_LAST (AWID_ENCODED_DATA_SIZE - 1)
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_awid;
|
||||
extern const ProtocolBase protocol_awid;
|
||||
|
||||
@@ -61,17 +61,17 @@
|
||||
|
||||
typedef uint64_t ElectraDecodedData;
|
||||
|
||||
#define EM_HEADER_POS (55)
|
||||
#define EM_HEADER_POS (55)
|
||||
#define EM_HEADER_MASK (0x1FFLLU << EM_HEADER_POS)
|
||||
|
||||
#define EM_FIRST_ROW_POS (50)
|
||||
|
||||
#define EM_ROW_COUNT (10)
|
||||
#define EM_COLUMN_COUNT (4)
|
||||
#define EM_ROW_COUNT (10)
|
||||
#define EM_COLUMN_COUNT (4)
|
||||
#define EM_BITS_PER_ROW_COUNT (EM_COLUMN_COUNT + 1)
|
||||
|
||||
#define EM_COLUMN_POS (4)
|
||||
#define ELECTRA_STOP_POS (0)
|
||||
#define EM_COLUMN_POS (4)
|
||||
#define ELECTRA_STOP_POS (0)
|
||||
#define ELECTRA_STOP_MASK (0x1LLU << ELECTRA_STOP_POS)
|
||||
|
||||
#define EM_HEADER_AND_STOP_MASK (EM_HEADER_MASK | ELECTRA_STOP_MASK)
|
||||
@@ -90,14 +90,14 @@ typedef uint64_t ElectraDecodedData;
|
||||
|
||||
#define ELECTRA_CLOCK_PER_BIT (64)
|
||||
|
||||
#define ELECTRA_READ_SHORT_TIME (256)
|
||||
#define ELECTRA_READ_LONG_TIME (512)
|
||||
#define ELECTRA_READ_SHORT_TIME (256)
|
||||
#define ELECTRA_READ_LONG_TIME (512)
|
||||
#define ELECTRA_READ_JITTER_TIME (100)
|
||||
|
||||
#define ELECTRA_READ_SHORT_TIME_LOW (ELECTRA_READ_SHORT_TIME - ELECTRA_READ_JITTER_TIME)
|
||||
#define ELECTRA_READ_SHORT_TIME_LOW (ELECTRA_READ_SHORT_TIME - ELECTRA_READ_JITTER_TIME)
|
||||
#define ELECTRA_READ_SHORT_TIME_HIGH (ELECTRA_READ_SHORT_TIME + ELECTRA_READ_JITTER_TIME)
|
||||
#define ELECTRA_READ_LONG_TIME_LOW (ELECTRA_READ_LONG_TIME - ELECTRA_READ_JITTER_TIME)
|
||||
#define ELECTRA_READ_LONG_TIME_HIGH (ELECTRA_READ_LONG_TIME + ELECTRA_READ_JITTER_TIME)
|
||||
#define ELECTRA_READ_LONG_TIME_LOW (ELECTRA_READ_LONG_TIME - ELECTRA_READ_JITTER_TIME)
|
||||
#define ELECTRA_READ_LONG_TIME_HIGH (ELECTRA_READ_LONG_TIME + ELECTRA_READ_JITTER_TIME)
|
||||
|
||||
#define EM_ENCODED_DATA_HEADER (0xFF80000000000000ULL)
|
||||
|
||||
@@ -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,
|
||||
@@ -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",
|
||||
@@ -437,4 +437,4 @@ const ProtocolBase protocol_electra = {
|
||||
.render_data = (ProtocolRenderData)protocol_electra_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_electra_render_data,
|
||||
.write_data = (ProtocolWriteData)protocol_electra_write_data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_electra;
|
||||
extern const ProtocolBase protocol_electra;
|
||||
|
||||
@@ -6,18 +6,18 @@
|
||||
typedef uint64_t EM4100DecodedData;
|
||||
typedef uint64_t EM4100Epilogue;
|
||||
|
||||
#define EM_HEADER_POS (55)
|
||||
#define EM_HEADER_POS (55)
|
||||
#define EM_HEADER_MASK (0x1FFLLU << EM_HEADER_POS)
|
||||
|
||||
#define EM_FIRST_ROW_POS (50)
|
||||
|
||||
#define EM_ROW_COUNT (10)
|
||||
#define EM_COLUMN_COUNT (4)
|
||||
#define EM_ROW_COUNT (10)
|
||||
#define EM_COLUMN_COUNT (4)
|
||||
#define EM_BITS_PER_ROW_COUNT (EM_COLUMN_COUNT + 1)
|
||||
|
||||
#define EM_COLUMN_POS (4)
|
||||
#define EM_STOP_POS (0)
|
||||
#define EM_STOP_MASK (0x1LLU << EM_STOP_POS)
|
||||
#define EM_STOP_POS (0)
|
||||
#define EM_STOP_MASK (0x1LLU << EM_STOP_POS)
|
||||
|
||||
#define EM_HEADER_AND_STOP_MASK (EM_HEADER_MASK | EM_STOP_MASK)
|
||||
#define EM_HEADER_AND_STOP_DATA (EM_HEADER_MASK)
|
||||
@@ -25,8 +25,8 @@ typedef uint64_t EM4100Epilogue;
|
||||
#define EM4100_DECODED_DATA_SIZE (5)
|
||||
#define EM4100_ENCODED_DATA_SIZE (sizeof(EM4100DecodedData))
|
||||
|
||||
#define EM_READ_SHORT_TIME_BASE (256)
|
||||
#define EM_READ_LONG_TIME_BASE (512)
|
||||
#define EM_READ_SHORT_TIME_BASE (256)
|
||||
#define EM_READ_LONG_TIME_BASE (512)
|
||||
#define EM_READ_JITTER_TIME_BASE (100)
|
||||
|
||||
#define EM_ENCODED_DATA_HEADER (0xFF80000000000000ULL)
|
||||
@@ -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,
|
||||
@@ -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;
|
||||
@@ -353,7 +353,7 @@ void protocol_em4100_render_data(ProtocolEM4100* protocol, FuriString* result) {
|
||||
(uint16_t)((data[3] << 8) | (data[4])),
|
||||
protocol->clock_per_bit,
|
||||
(uint32_t)((data[2] << 16) | (data[3] << 8) | (data[4])));
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_em4100 = {
|
||||
.name = "EM4100",
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
|
||||
#define JITTER_TIME (20)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
|
||||
#define FDXA_DATA_SIZE 10
|
||||
#define FDXA_DATA_SIZE 10
|
||||
#define FDXA_PREAMBLE_SIZE 2
|
||||
|
||||
#define FDXA_ENCODED_DATA_SIZE (FDXA_PREAMBLE_SIZE + FDXA_DATA_SIZE + FDXA_PREAMBLE_SIZE)
|
||||
#define FDXA_ENCODED_BIT_SIZE ((FDXA_PREAMBLE_SIZE + FDXA_DATA_SIZE) * 8)
|
||||
#define FDXA_ENCODED_BIT_SIZE ((FDXA_PREAMBLE_SIZE + FDXA_DATA_SIZE) * 8)
|
||||
#define FDXA_DECODED_DATA_SIZE (5)
|
||||
#define FDXA_DECODED_BIT_SIZE ((FDXA_ENCODED_BIT_SIZE - FDXA_PREAMBLE_SIZE * 8) / 2)
|
||||
#define FDXA_DECODED_BIT_SIZE ((FDXA_ENCODED_BIT_SIZE - FDXA_PREAMBLE_SIZE * 8) / 2)
|
||||
|
||||
#define FDXA_PREAMBLE_0 0x55
|
||||
#define FDXA_PREAMBLE_1 0x1D
|
||||
@@ -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;
|
||||
@@ -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",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_fdx_a;
|
||||
extern const ProtocolBase protocol_fdx_a;
|
||||
|
||||
@@ -6,22 +6,22 @@
|
||||
#include "lfrfid_protocols.h"
|
||||
#include <furi_hal_rtc.h>
|
||||
|
||||
#define FDX_B_ENCODED_BIT_SIZE (128)
|
||||
#define FDX_B_ENCODED_BYTE_SIZE (((FDX_B_ENCODED_BIT_SIZE) / 8))
|
||||
#define FDX_B_PREAMBLE_BIT_SIZE (11)
|
||||
#define FDX_B_PREAMBLE_BYTE_SIZE (2)
|
||||
#define FDX_B_ENCODED_BIT_SIZE (128)
|
||||
#define FDX_B_ENCODED_BYTE_SIZE (((FDX_B_ENCODED_BIT_SIZE) / 8))
|
||||
#define FDX_B_PREAMBLE_BIT_SIZE (11)
|
||||
#define FDX_B_PREAMBLE_BYTE_SIZE (2)
|
||||
#define FDX_B_ENCODED_BYTE_FULL_SIZE (FDX_B_ENCODED_BYTE_SIZE + FDX_B_PREAMBLE_BYTE_SIZE)
|
||||
|
||||
#define FDXB_DECODED_DATA_SIZE (11)
|
||||
|
||||
#define FDX_B_SHORT_TIME (128)
|
||||
#define FDX_B_LONG_TIME (256)
|
||||
#define FDX_B_SHORT_TIME (128)
|
||||
#define FDX_B_LONG_TIME (256)
|
||||
#define FDX_B_JITTER_TIME (60)
|
||||
|
||||
#define FDX_B_SHORT_TIME_LOW (FDX_B_SHORT_TIME - FDX_B_JITTER_TIME)
|
||||
#define FDX_B_SHORT_TIME_LOW (FDX_B_SHORT_TIME - FDX_B_JITTER_TIME)
|
||||
#define FDX_B_SHORT_TIME_HIGH (FDX_B_SHORT_TIME + FDX_B_JITTER_TIME)
|
||||
#define FDX_B_LONG_TIME_LOW (FDX_B_LONG_TIME - FDX_B_JITTER_TIME)
|
||||
#define FDX_B_LONG_TIME_HIGH (FDX_B_LONG_TIME + FDX_B_JITTER_TIME)
|
||||
#define FDX_B_LONG_TIME_LOW (FDX_B_LONG_TIME - FDX_B_JITTER_TIME)
|
||||
#define FDX_B_LONG_TIME_HIGH (FDX_B_LONG_TIME + FDX_B_JITTER_TIME)
|
||||
|
||||
typedef struct {
|
||||
bool last_short;
|
||||
@@ -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",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_fdx_b;
|
||||
extern const ProtocolBase protocol_fdx_b;
|
||||
|
||||
@@ -6,22 +6,22 @@
|
||||
|
||||
#define GALLAGHER_CLOCK_PER_BIT (32)
|
||||
|
||||
#define GALLAGHER_ENCODED_BIT_SIZE (96)
|
||||
#define GALLAGHER_ENCODED_BYTE_SIZE ((GALLAGHER_ENCODED_BIT_SIZE) / 8)
|
||||
#define GALLAGHER_PREAMBLE_BIT_SIZE (16)
|
||||
#define GALLAGHER_ENCODED_BIT_SIZE (96)
|
||||
#define GALLAGHER_ENCODED_BYTE_SIZE ((GALLAGHER_ENCODED_BIT_SIZE) / 8)
|
||||
#define GALLAGHER_PREAMBLE_BIT_SIZE (16)
|
||||
#define GALLAGHER_PREAMBLE_BYTE_SIZE ((GALLAGHER_PREAMBLE_BIT_SIZE) / 8)
|
||||
#define GALLAGHER_ENCODED_BYTE_FULL_SIZE \
|
||||
(GALLAGHER_ENCODED_BYTE_SIZE + GALLAGHER_PREAMBLE_BYTE_SIZE)
|
||||
#define GALLAGHER_DECODED_DATA_SIZE 8
|
||||
|
||||
#define GALLAGHER_READ_SHORT_TIME (128)
|
||||
#define GALLAGHER_READ_LONG_TIME (256)
|
||||
#define GALLAGHER_READ_SHORT_TIME (128)
|
||||
#define GALLAGHER_READ_LONG_TIME (256)
|
||||
#define GALLAGHER_READ_JITTER_TIME (60)
|
||||
|
||||
#define GALLAGHER_READ_SHORT_TIME_LOW (GALLAGHER_READ_SHORT_TIME - GALLAGHER_READ_JITTER_TIME)
|
||||
#define GALLAGHER_READ_SHORT_TIME_LOW (GALLAGHER_READ_SHORT_TIME - GALLAGHER_READ_JITTER_TIME)
|
||||
#define GALLAGHER_READ_SHORT_TIME_HIGH (GALLAGHER_READ_SHORT_TIME + GALLAGHER_READ_JITTER_TIME)
|
||||
#define GALLAGHER_READ_LONG_TIME_LOW (GALLAGHER_READ_LONG_TIME - GALLAGHER_READ_JITTER_TIME)
|
||||
#define GALLAGHER_READ_LONG_TIME_HIGH (GALLAGHER_READ_LONG_TIME + GALLAGHER_READ_JITTER_TIME)
|
||||
#define GALLAGHER_READ_LONG_TIME_LOW (GALLAGHER_READ_LONG_TIME - GALLAGHER_READ_JITTER_TIME)
|
||||
#define GALLAGHER_READ_LONG_TIME_HIGH (GALLAGHER_READ_LONG_TIME + GALLAGHER_READ_JITTER_TIME)
|
||||
|
||||
typedef struct {
|
||||
uint8_t data[GALLAGHER_DECODED_DATA_SIZE];
|
||||
@@ -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);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_gallagher;
|
||||
extern const ProtocolBase protocol_gallagher;
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define JITTER_TIME (20)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
|
||||
#define H10301_DECODED_DATA_SIZE (3)
|
||||
#define H10301_DECODED_DATA_SIZE (3)
|
||||
#define H10301_ENCODED_DATA_SIZE_U32 (3)
|
||||
#define H10301_ENCODED_DATA_SIZE (sizeof(uint32_t) * H10301_ENCODED_DATA_SIZE_U32)
|
||||
#define H10301_ENCODED_DATA_SIZE (sizeof(uint32_t) * H10301_ENCODED_DATA_SIZE_U32)
|
||||
|
||||
#define H10301_BIT_SIZE (sizeof(uint32_t) * 8)
|
||||
#define H10301_BIT_SIZE (sizeof(uint32_t) * 8)
|
||||
#define H10301_BIT_MAX_SIZE (H10301_BIT_SIZE * H10301_DECODED_DATA_SIZE)
|
||||
|
||||
typedef struct {
|
||||
@@ -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",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_h10301;
|
||||
extern const ProtocolBase protocol_h10301;
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
|
||||
#define JITTER_TIME (20)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
|
||||
#define HID_DATA_SIZE 23
|
||||
#define HID_DATA_SIZE 23
|
||||
#define HID_PREAMBLE_SIZE 1
|
||||
|
||||
#define HID_ENCODED_DATA_SIZE (HID_PREAMBLE_SIZE + HID_DATA_SIZE + HID_PREAMBLE_SIZE)
|
||||
#define HID_ENCODED_BIT_SIZE ((HID_PREAMBLE_SIZE + HID_DATA_SIZE) * 8)
|
||||
#define HID_ENCODED_BIT_SIZE ((HID_PREAMBLE_SIZE + HID_DATA_SIZE) * 8)
|
||||
#define HID_DECODED_DATA_SIZE (12)
|
||||
#define HID_DECODED_BIT_SIZE ((HID_ENCODED_BIT_SIZE - HID_PREAMBLE_SIZE * 8) / 2)
|
||||
#define HID_DECODED_BIT_SIZE ((HID_ENCODED_BIT_SIZE - HID_PREAMBLE_SIZE * 8) / 2)
|
||||
|
||||
#define HID_PREAMBLE 0x1D
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_hid_ex_generic;
|
||||
extern const ProtocolBase protocol_hid_ex_generic;
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
|
||||
#define JITTER_TIME (20)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
|
||||
#define HID_DATA_SIZE 11
|
||||
#define HID_PREAMBLE_SIZE 1
|
||||
#define HID_DATA_SIZE 11
|
||||
#define HID_PREAMBLE_SIZE 1
|
||||
#define HID_PROTOCOL_SIZE_UNKNOWN 0
|
||||
|
||||
#define HID_ENCODED_DATA_SIZE (HID_PREAMBLE_SIZE + HID_DATA_SIZE + HID_PREAMBLE_SIZE)
|
||||
#define HID_ENCODED_BIT_SIZE ((HID_PREAMBLE_SIZE + HID_DATA_SIZE) * 8)
|
||||
#define HID_ENCODED_BIT_SIZE ((HID_PREAMBLE_SIZE + HID_DATA_SIZE) * 8)
|
||||
#define HID_DECODED_DATA_SIZE (6)
|
||||
#define HID_DECODED_BIT_SIZE ((HID_ENCODED_BIT_SIZE - HID_PREAMBLE_SIZE * 8) / 2)
|
||||
#define HID_DECODED_BIT_SIZE ((HID_ENCODED_BIT_SIZE - HID_PREAMBLE_SIZE * 8) / 2)
|
||||
|
||||
#define HID_PREAMBLE 0x1D
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_hid_generic;
|
||||
extern const ProtocolBase protocol_hid_generic;
|
||||
|
||||
@@ -8,17 +8,17 @@
|
||||
// 4 9 4 4 5 4 4 B 3 5 1 F B E 4 B
|
||||
// 0100 1001 0100 0100 0101 0100 0100 1011 0011 0101 0001 1111 1011 1110 0100 1011
|
||||
|
||||
#define IDTECK_PREAMBLE_BIT_SIZE (32)
|
||||
#define IDTECK_PREAMBLE_BIT_SIZE (32)
|
||||
#define IDTECK_PREAMBLE_DATA_SIZE (8)
|
||||
|
||||
#define IDTECK_ENCODED_BIT_SIZE (64)
|
||||
#define IDTECK_ENCODED_BIT_SIZE (64)
|
||||
#define IDTECK_ENCODED_DATA_SIZE (((IDTECK_ENCODED_BIT_SIZE) / 8) + IDTECK_PREAMBLE_DATA_SIZE)
|
||||
#define IDTECK_ENCODED_DATA_LAST ((IDTECK_ENCODED_BIT_SIZE) / 8)
|
||||
|
||||
#define IDTECK_DECODED_BIT_SIZE (64)
|
||||
#define IDTECK_DECODED_BIT_SIZE (64)
|
||||
#define IDTECK_DECODED_DATA_SIZE (8)
|
||||
|
||||
#define IDTECK_US_PER_BIT (255)
|
||||
#define IDTECK_US_PER_BIT (255)
|
||||
#define IDTECK_ENCODER_PULSES_PER_BIT (16)
|
||||
|
||||
typedef struct {
|
||||
@@ -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",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define INDALA26_PREAMBLE_BIT_SIZE (33)
|
||||
#define INDALA26_PREAMBLE_BIT_SIZE (33)
|
||||
#define INDALA26_PREAMBLE_DATA_SIZE (5)
|
||||
|
||||
#define INDALA26_ENCODED_BIT_SIZE (64)
|
||||
@@ -11,10 +11,10 @@
|
||||
(((INDALA26_ENCODED_BIT_SIZE) / 8) + INDALA26_PREAMBLE_DATA_SIZE)
|
||||
#define INDALA26_ENCODED_DATA_LAST ((INDALA26_ENCODED_BIT_SIZE) / 8)
|
||||
|
||||
#define INDALA26_DECODED_BIT_SIZE (28)
|
||||
#define INDALA26_DECODED_BIT_SIZE (28)
|
||||
#define INDALA26_DECODED_DATA_SIZE (4)
|
||||
|
||||
#define INDALA26_US_PER_BIT (255)
|
||||
#define INDALA26_US_PER_BIT (255)
|
||||
#define INDALA26_ENCODER_PULSES_PER_BIT (16)
|
||||
|
||||
typedef struct {
|
||||
@@ -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",
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define JITTER_TIME (20)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
|
||||
#define IOPROXXSF_DECODED_DATA_SIZE (4)
|
||||
#define IOPROXXSF_ENCODED_DATA_SIZE (8)
|
||||
|
||||
#define IOPROXXSF_BIT_SIZE (8)
|
||||
#define IOPROXXSF_BIT_SIZE (8)
|
||||
#define IOPROXXSF_BIT_MAX_SIZE (IOPROXXSF_BIT_SIZE * IOPROXXSF_ENCODED_DATA_SIZE)
|
||||
|
||||
typedef struct {
|
||||
@@ -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",
|
||||
|
||||
@@ -5,23 +5,23 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define JABLOTRON_ENCODED_BIT_SIZE (64)
|
||||
#define JABLOTRON_ENCODED_BYTE_SIZE (((JABLOTRON_ENCODED_BIT_SIZE) / 8))
|
||||
#define JABLOTRON_PREAMBLE_BIT_SIZE (16)
|
||||
#define JABLOTRON_ENCODED_BIT_SIZE (64)
|
||||
#define JABLOTRON_ENCODED_BYTE_SIZE (((JABLOTRON_ENCODED_BIT_SIZE) / 8))
|
||||
#define JABLOTRON_PREAMBLE_BIT_SIZE (16)
|
||||
#define JABLOTRON_PREAMBLE_BYTE_SIZE (2)
|
||||
#define JABLOTRON_ENCODED_BYTE_FULL_SIZE \
|
||||
(JABLOTRON_ENCODED_BYTE_SIZE + JABLOTRON_PREAMBLE_BYTE_SIZE)
|
||||
|
||||
#define JABLOTRON_DECODED_DATA_SIZE (5)
|
||||
|
||||
#define JABLOTRON_SHORT_TIME (256)
|
||||
#define JABLOTRON_LONG_TIME (512)
|
||||
#define JABLOTRON_SHORT_TIME (256)
|
||||
#define JABLOTRON_LONG_TIME (512)
|
||||
#define JABLOTRON_JITTER_TIME (120)
|
||||
|
||||
#define JABLOTRON_SHORT_TIME_LOW (JABLOTRON_SHORT_TIME - JABLOTRON_JITTER_TIME)
|
||||
#define JABLOTRON_SHORT_TIME_LOW (JABLOTRON_SHORT_TIME - JABLOTRON_JITTER_TIME)
|
||||
#define JABLOTRON_SHORT_TIME_HIGH (JABLOTRON_SHORT_TIME + JABLOTRON_JITTER_TIME)
|
||||
#define JABLOTRON_LONG_TIME_LOW (JABLOTRON_LONG_TIME - JABLOTRON_JITTER_TIME)
|
||||
#define JABLOTRON_LONG_TIME_HIGH (JABLOTRON_LONG_TIME + JABLOTRON_JITTER_TIME)
|
||||
#define JABLOTRON_LONG_TIME_LOW (JABLOTRON_LONG_TIME - JABLOTRON_JITTER_TIME)
|
||||
#define JABLOTRON_LONG_TIME_HIGH (JABLOTRON_LONG_TIME + JABLOTRON_JITTER_TIME)
|
||||
|
||||
typedef struct {
|
||||
bool last_short;
|
||||
@@ -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",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_jablotron;
|
||||
extern const ProtocolBase protocol_jablotron;
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define KERI_PREAMBLE_BIT_SIZE (33)
|
||||
#define KERI_PREAMBLE_BIT_SIZE (33)
|
||||
#define KERI_PREAMBLE_DATA_SIZE (5)
|
||||
|
||||
#define KERI_ENCODED_BIT_SIZE (64)
|
||||
#define KERI_ENCODED_BIT_SIZE (64)
|
||||
#define KERI_ENCODED_DATA_SIZE (((KERI_ENCODED_BIT_SIZE) / 8) + KERI_PREAMBLE_DATA_SIZE)
|
||||
#define KERI_ENCODED_DATA_LAST ((KERI_ENCODED_BIT_SIZE) / 8)
|
||||
|
||||
#define KERI_DECODED_BIT_SIZE (28)
|
||||
#define KERI_DECODED_BIT_SIZE (28)
|
||||
#define KERI_DECODED_DATA_SIZE (4)
|
||||
|
||||
#define KERI_US_PER_BIT (255)
|
||||
#define KERI_US_PER_BIT (255)
|
||||
#define KERI_ENCODER_PULSES_PER_BIT (16)
|
||||
|
||||
typedef struct {
|
||||
@@ -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",
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define NEXWATCH_PREAMBLE_BIT_SIZE (8)
|
||||
#define NEXWATCH_PREAMBLE_BIT_SIZE (8)
|
||||
#define NEXWATCH_PREAMBLE_DATA_SIZE (1)
|
||||
|
||||
#define NEXWATCH_ENCODED_BIT_SIZE (96)
|
||||
#define NEXWATCH_ENCODED_BIT_SIZE (96)
|
||||
#define NEXWATCH_ENCODED_DATA_SIZE ((NEXWATCH_ENCODED_BIT_SIZE) / 8)
|
||||
|
||||
#define NEXWATCH_DECODED_BIT_SIZE (NEXWATCH_DECODED_DATA_SIZE * 8)
|
||||
#define NEXWATCH_DECODED_BIT_SIZE (NEXWATCH_DECODED_DATA_SIZE * 8)
|
||||
#define NEXWATCH_DECODED_DATA_SIZE (8)
|
||||
|
||||
#define NEXWATCH_US_PER_BIT (255)
|
||||
#define NEXWATCH_US_PER_BIT (255)
|
||||
#define NEXWATCH_ENCODER_PULSES_PER_BIT (16)
|
||||
|
||||
typedef struct {
|
||||
@@ -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
|
||||
@@ -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",
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define PAC_STANLEY_ENCODED_BIT_SIZE (128)
|
||||
#define PAC_STANLEY_ENCODED_BYTE_SIZE (((PAC_STANLEY_ENCODED_BIT_SIZE) / 8))
|
||||
#define PAC_STANLEY_PREAMBLE_BIT_SIZE (8)
|
||||
#define PAC_STANLEY_ENCODED_BIT_SIZE (128)
|
||||
#define PAC_STANLEY_ENCODED_BYTE_SIZE (((PAC_STANLEY_ENCODED_BIT_SIZE) / 8))
|
||||
#define PAC_STANLEY_PREAMBLE_BIT_SIZE (8)
|
||||
#define PAC_STANLEY_PREAMBLE_BYTE_SIZE (1)
|
||||
#define PAC_STANLEY_ENCODED_BYTE_FULL_SIZE \
|
||||
(PAC_STANLEY_ENCODED_BYTE_SIZE + PAC_STANLEY_PREAMBLE_BYTE_SIZE)
|
||||
#define PAC_STANLEY_BYTE_LENGTH (10) // start bit, 7 data bits, parity bit, stop bit
|
||||
#define PAC_STANLEY_BYTE_LENGTH (10) // start bit, 7 data bits, parity bit, stop bit
|
||||
#define PAC_STANLEY_DATA_START_INDEX (8 + (3 * PAC_STANLEY_BYTE_LENGTH) + 1)
|
||||
|
||||
#define PAC_STANLEY_DECODED_DATA_SIZE (4)
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
#define PAC_STANLEY_CLOCKS_IN_US (32)
|
||||
#define PAC_STANLEY_CYCLE_LENGTH (256)
|
||||
#define PAC_STANLEY_MIN_TIME (60)
|
||||
#define PAC_STANLEY_MAX_TIME (4000)
|
||||
#define PAC_STANLEY_MIN_TIME (60)
|
||||
#define PAC_STANLEY_MAX_TIME (4000)
|
||||
|
||||
typedef struct {
|
||||
bool inverted;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_pac_stanley;
|
||||
extern const ProtocolBase protocol_pac_stanley;
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define JITTER_TIME (20)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
|
||||
#define PARADOX_DECODED_DATA_SIZE (6)
|
||||
|
||||
#define PARADOX_PREAMBLE_LENGTH (8)
|
||||
#define PARADOX_ENCODED_BIT_SIZE (96)
|
||||
#define PARADOX_PREAMBLE_LENGTH (8)
|
||||
#define PARADOX_ENCODED_BIT_SIZE (96)
|
||||
#define PARADOX_ENCODED_DATA_SIZE (((PARADOX_ENCODED_BIT_SIZE) / 8) + 1)
|
||||
#define PARADOX_ENCODED_DATA_LAST (PARADOX_ENCODED_DATA_SIZE - 1)
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_paradox;
|
||||
extern const ProtocolBase protocol_paradox;
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
|
||||
#define JITTER_TIME (20)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
|
||||
#define PYRAMID_DATA_SIZE 13
|
||||
#define PYRAMID_DATA_SIZE 13
|
||||
#define PYRAMID_PREAMBLE_SIZE 3
|
||||
|
||||
#define PYRAMID_ENCODED_DATA_SIZE \
|
||||
(PYRAMID_PREAMBLE_SIZE + PYRAMID_DATA_SIZE + PYRAMID_PREAMBLE_SIZE)
|
||||
#define PYRAMID_ENCODED_BIT_SIZE ((PYRAMID_PREAMBLE_SIZE + PYRAMID_DATA_SIZE) * 8)
|
||||
#define PYRAMID_ENCODED_BIT_SIZE ((PYRAMID_PREAMBLE_SIZE + PYRAMID_DATA_SIZE) * 8)
|
||||
#define PYRAMID_DECODED_DATA_SIZE (4)
|
||||
#define PYRAMID_DECODED_BIT_SIZE ((PYRAMID_ENCODED_BIT_SIZE - PYRAMID_PREAMBLE_SIZE * 8) / 2)
|
||||
#define PYRAMID_DECODED_BIT_SIZE ((PYRAMID_ENCODED_BIT_SIZE - PYRAMID_PREAMBLE_SIZE * 8) / 2)
|
||||
|
||||
typedef struct {
|
||||
FSKDemod* fsk_demod;
|
||||
@@ -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",
|
||||
|
||||
@@ -10,29 +10,29 @@
|
||||
#include "lfrfid_protocols.h"
|
||||
#include <toolbox/manchester_decoder.h>
|
||||
|
||||
#define TAG "SECURAKEY"
|
||||
#define TAG "SECURAKEY"
|
||||
#define SECURAKEY_RKKT_ENCODED_FULL_SIZE_BITS (96)
|
||||
#define SECURAKEY_RKKT_ENCODED_FULL_SIZE_BYTE (12)
|
||||
|
||||
#define SECURAKEY_RKKTH_ENCODED_FULL_SIZE_BITS (64)
|
||||
#define SECURAKEY_RKKTH_ENCODED_FULL_SIZE_BYTE (8)
|
||||
|
||||
#define SECURAKEY_DECODED_DATA_SIZE_BITS (48)
|
||||
#define SECURAKEY_DECODED_DATA_SIZE_BITS (48)
|
||||
// RKKT: 16-bit for facility code/number, 16-bit for card number, 16-bit for two checksum
|
||||
// RKKTH: 16-bit zero padding, 32-bit card number
|
||||
#define SECURAKEY_DECODED_DATA_SIZE_BYTES (SECURAKEY_DECODED_DATA_SIZE_BITS / 8)
|
||||
#define LFRFID_FREQUENCY (125000)
|
||||
#define SECURAKEY_CLOCK_PER_BIT (40) // RF/40
|
||||
#define LFRFID_FREQUENCY (125000)
|
||||
#define SECURAKEY_CLOCK_PER_BIT (40) // RF/40
|
||||
#define SECURAKEY_READ_LONG_TIME \
|
||||
(1000000 / (LFRFID_FREQUENCY / SECURAKEY_CLOCK_PER_BIT)) // 1000000 micro sec / sec
|
||||
#define SECURAKEY_READ_SHORT_TIME (SECURAKEY_READ_LONG_TIME / 2)
|
||||
#define SECURAKEY_READ_SHORT_TIME (SECURAKEY_READ_LONG_TIME / 2)
|
||||
#define SECURAKEY_READ_JITTER_TIME (SECURAKEY_READ_SHORT_TIME * 40 / 100) // 40% jitter tolerance
|
||||
#define SECURAKEY_READ_SHORT_TIME_LOW \
|
||||
(SECURAKEY_READ_SHORT_TIME - \
|
||||
SECURAKEY_READ_JITTER_TIME) // these are used for manchester decoding
|
||||
#define SECURAKEY_READ_SHORT_TIME_HIGH (SECURAKEY_READ_SHORT_TIME + SECURAKEY_READ_JITTER_TIME)
|
||||
#define SECURAKEY_READ_LONG_TIME_LOW (SECURAKEY_READ_LONG_TIME - SECURAKEY_READ_JITTER_TIME)
|
||||
#define SECURAKEY_READ_LONG_TIME_HIGH (SECURAKEY_READ_LONG_TIME + SECURAKEY_READ_JITTER_TIME)
|
||||
#define SECURAKEY_READ_LONG_TIME_LOW (SECURAKEY_READ_LONG_TIME - SECURAKEY_READ_JITTER_TIME)
|
||||
#define SECURAKEY_READ_LONG_TIME_HIGH (SECURAKEY_READ_LONG_TIME + SECURAKEY_READ_JITTER_TIME)
|
||||
|
||||
typedef struct {
|
||||
uint8_t data[SECURAKEY_DECODED_DATA_SIZE_BYTES];
|
||||
@@ -47,15 +47,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 +71,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 +142,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 +153,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 +187,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 +209,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 +277,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 +305,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 +337,7 @@ bool protocol_securakey_write_data(ProtocolSecurakey* protocol, void* data) {
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_securakey = {
|
||||
.name = "Radio Key",
|
||||
@@ -361,4 +361,4 @@ const ProtocolBase protocol_securakey = {
|
||||
.render_data = (ProtocolRenderData)protocol_securakey_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_securakey_render_data,
|
||||
.write_data = (ProtocolWriteData)protocol_securakey_write_data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_securakey;
|
||||
extern const ProtocolBase protocol_securakey;
|
||||
|
||||
@@ -6,21 +6,21 @@
|
||||
|
||||
#define VIKING_CLOCK_PER_BIT (32)
|
||||
|
||||
#define VIKING_ENCODED_BIT_SIZE (64)
|
||||
#define VIKING_ENCODED_BYTE_SIZE (((VIKING_ENCODED_BIT_SIZE) / 8))
|
||||
#define VIKING_PREAMBLE_BIT_SIZE (24)
|
||||
#define VIKING_PREAMBLE_BYTE_SIZE (3)
|
||||
#define VIKING_ENCODED_BIT_SIZE (64)
|
||||
#define VIKING_ENCODED_BYTE_SIZE (((VIKING_ENCODED_BIT_SIZE) / 8))
|
||||
#define VIKING_PREAMBLE_BIT_SIZE (24)
|
||||
#define VIKING_PREAMBLE_BYTE_SIZE (3)
|
||||
#define VIKING_ENCODED_BYTE_FULL_SIZE (VIKING_ENCODED_BYTE_SIZE + VIKING_PREAMBLE_BYTE_SIZE)
|
||||
#define VIKING_DECODED_DATA_SIZE 4
|
||||
#define VIKING_DECODED_DATA_SIZE 4
|
||||
|
||||
#define VIKING_READ_SHORT_TIME (128)
|
||||
#define VIKING_READ_LONG_TIME (256)
|
||||
#define VIKING_READ_SHORT_TIME (128)
|
||||
#define VIKING_READ_LONG_TIME (256)
|
||||
#define VIKING_READ_JITTER_TIME (60)
|
||||
|
||||
#define VIKING_READ_SHORT_TIME_LOW (VIKING_READ_SHORT_TIME - VIKING_READ_JITTER_TIME)
|
||||
#define VIKING_READ_SHORT_TIME_LOW (VIKING_READ_SHORT_TIME - VIKING_READ_JITTER_TIME)
|
||||
#define VIKING_READ_SHORT_TIME_HIGH (VIKING_READ_SHORT_TIME + VIKING_READ_JITTER_TIME)
|
||||
#define VIKING_READ_LONG_TIME_LOW (VIKING_READ_LONG_TIME - VIKING_READ_JITTER_TIME)
|
||||
#define VIKING_READ_LONG_TIME_HIGH (VIKING_READ_LONG_TIME + VIKING_READ_JITTER_TIME)
|
||||
#define VIKING_READ_LONG_TIME_LOW (VIKING_READ_LONG_TIME - VIKING_READ_JITTER_TIME)
|
||||
#define VIKING_READ_LONG_TIME_HIGH (VIKING_READ_LONG_TIME + VIKING_READ_JITTER_TIME)
|
||||
|
||||
typedef struct {
|
||||
uint8_t data[VIKING_DECODED_DATA_SIZE];
|
||||
@@ -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",
|
||||
|
||||
@@ -59,4 +59,4 @@ bool fsk_osc_next_half(FSKOsc* osc, bool bit, bool* level, uint32_t* duration) {
|
||||
}
|
||||
|
||||
return advance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,4 +57,4 @@ bool fsk_osc_next_half(FSKOsc* osc, bool bit, bool* level, uint32_t* duration);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
#define T5577_TIMING_WAIT_TIME 400
|
||||
#define T5577_TIMING_START_GAP 30
|
||||
#define T5577_TIMING_WRITE_GAP 18
|
||||
#define T5577_TIMING_DATA_0 24
|
||||
#define T5577_TIMING_DATA_1 56
|
||||
#define T5577_TIMING_PROGRAM 700
|
||||
#define T5577_TIMING_DATA_0 24
|
||||
#define T5577_TIMING_DATA_1 56
|
||||
#define T5577_TIMING_PROGRAM 700
|
||||
|
||||
#define T5577_OPCODE_PAGE_0 0b10
|
||||
#define T5577_OPCODE_PAGE_1 0b11
|
||||
#define T5577_OPCODE_RESET 0b00
|
||||
#define T5577_OPCODE_RESET 0b00
|
||||
|
||||
#define T5577_BLOCKS_IN_PAGE_0 8
|
||||
#define T5577_BLOCKS_IN_PAGE_1 4
|
||||
|
||||
@@ -9,35 +9,35 @@ extern "C" {
|
||||
#define LFRFID_T5577_BLOCK_COUNT 8
|
||||
|
||||
// T5577 block 0 definitions, thanks proxmark3!
|
||||
#define LFRFID_T5577_POR_DELAY 0x00000001
|
||||
#define LFRFID_T5577_ST_TERMINATOR 0x00000008
|
||||
#define LFRFID_T5577_PWD 0x00000010
|
||||
#define LFRFID_T5577_MAXBLOCK_SHIFT 5
|
||||
#define LFRFID_T5577_AOR 0x00000200
|
||||
#define LFRFID_T5577_PSKCF_RF_2 0
|
||||
#define LFRFID_T5577_PSKCF_RF_4 0x00000400
|
||||
#define LFRFID_T5577_PSKCF_RF_8 0x00000800
|
||||
#define LFRFID_T5577_MODULATION_DIRECT 0
|
||||
#define LFRFID_T5577_MODULATION_PSK1 0x00001000
|
||||
#define LFRFID_T5577_MODULATION_PSK2 0x00002000
|
||||
#define LFRFID_T5577_MODULATION_PSK3 0x00003000
|
||||
#define LFRFID_T5577_MODULATION_FSK1 0x00004000
|
||||
#define LFRFID_T5577_MODULATION_FSK2 0x00005000
|
||||
#define LFRFID_T5577_MODULATION_FSK1a 0x00006000
|
||||
#define LFRFID_T5577_MODULATION_FSK2a 0x00007000
|
||||
#define LFRFID_T5577_POR_DELAY 0x00000001
|
||||
#define LFRFID_T5577_ST_TERMINATOR 0x00000008
|
||||
#define LFRFID_T5577_PWD 0x00000010
|
||||
#define LFRFID_T5577_MAXBLOCK_SHIFT 5
|
||||
#define LFRFID_T5577_AOR 0x00000200
|
||||
#define LFRFID_T5577_PSKCF_RF_2 0
|
||||
#define LFRFID_T5577_PSKCF_RF_4 0x00000400
|
||||
#define LFRFID_T5577_PSKCF_RF_8 0x00000800
|
||||
#define LFRFID_T5577_MODULATION_DIRECT 0
|
||||
#define LFRFID_T5577_MODULATION_PSK1 0x00001000
|
||||
#define LFRFID_T5577_MODULATION_PSK2 0x00002000
|
||||
#define LFRFID_T5577_MODULATION_PSK3 0x00003000
|
||||
#define LFRFID_T5577_MODULATION_FSK1 0x00004000
|
||||
#define LFRFID_T5577_MODULATION_FSK2 0x00005000
|
||||
#define LFRFID_T5577_MODULATION_FSK1a 0x00006000
|
||||
#define LFRFID_T5577_MODULATION_FSK2a 0x00007000
|
||||
#define LFRFID_T5577_MODULATION_MANCHESTER 0x00008000
|
||||
#define LFRFID_T5577_MODULATION_BIPHASE 0x00010000
|
||||
#define LFRFID_T5577_MODULATION_DIPHASE 0x00018000
|
||||
#define LFRFID_T5577_X_MODE 0x00020000
|
||||
#define LFRFID_T5577_BITRATE_RF_8 0
|
||||
#define LFRFID_T5577_BITRATE_RF_16 0x00040000
|
||||
#define LFRFID_T5577_BITRATE_RF_32 0x00080000
|
||||
#define LFRFID_T5577_BITRATE_RF_40 0x000C0000
|
||||
#define LFRFID_T5577_BITRATE_RF_50 0x00100000
|
||||
#define LFRFID_T5577_BITRATE_RF_64 0x00140000
|
||||
#define LFRFID_T5577_BITRATE_RF_100 0x00180000
|
||||
#define LFRFID_T5577_BITRATE_RF_128 0x001C0000
|
||||
#define LFRFID_T5577_TESTMODE_DISABLED 0x60000000
|
||||
#define LFRFID_T5577_MODULATION_BIPHASE 0x00010000
|
||||
#define LFRFID_T5577_MODULATION_DIPHASE 0x00018000
|
||||
#define LFRFID_T5577_X_MODE 0x00020000
|
||||
#define LFRFID_T5577_BITRATE_RF_8 0
|
||||
#define LFRFID_T5577_BITRATE_RF_16 0x00040000
|
||||
#define LFRFID_T5577_BITRATE_RF_32 0x00080000
|
||||
#define LFRFID_T5577_BITRATE_RF_40 0x000C0000
|
||||
#define LFRFID_T5577_BITRATE_RF_50 0x00100000
|
||||
#define LFRFID_T5577_BITRATE_RF_64 0x00140000
|
||||
#define LFRFID_T5577_BITRATE_RF_100 0x00180000
|
||||
#define LFRFID_T5577_BITRATE_RF_128 0x001C0000
|
||||
#define LFRFID_T5577_TESTMODE_DISABLED 0x60000000
|
||||
|
||||
typedef struct {
|
||||
uint32_t block[LFRFID_T5577_BLOCK_COUNT];
|
||||
@@ -58,4 +58,4 @@ void t5577_write_with_mask(LFRFIDT5577* data, uint8_t page, bool with_pass, uint
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -76,4 +76,4 @@ bool varint_pair_unpack(
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user