mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-28 01:58:11 -07:00
Merge remote-tracking branch 'origin/dev' into electra
This commit is contained in:
@@ -6,7 +6,10 @@
|
||||
#define LFRFID_DICT_FILETYPE "Flipper RFID key"
|
||||
|
||||
bool lfrfid_dict_file_save(ProtocolDict* dict, ProtocolId protocol, const char* filename) {
|
||||
furi_check(dict);
|
||||
furi_check(protocol != PROTOCOL_NO);
|
||||
furi_check(filename);
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
size_t data_size = protocol_dict_get_data_size(dict, protocol);
|
||||
@@ -139,6 +142,9 @@ static ProtocolId lfrfid_dict_protocol_fallback(
|
||||
}
|
||||
|
||||
ProtocolId lfrfid_dict_file_load(ProtocolDict* dict, const char* filename) {
|
||||
furi_check(dict);
|
||||
furi_check(filename);
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
ProtocolId result = PROTOCOL_NO;
|
||||
|
||||
@@ -26,6 +26,8 @@ struct LFRFIDRawFile {
|
||||
};
|
||||
|
||||
LFRFIDRawFile* lfrfid_raw_file_alloc(Storage* storage) {
|
||||
furi_check(storage);
|
||||
|
||||
LFRFIDRawFile* file = malloc(sizeof(LFRFIDRawFile));
|
||||
file->stream = file_stream_alloc(storage);
|
||||
file->buffer = NULL;
|
||||
@@ -33,16 +35,24 @@ LFRFIDRawFile* lfrfid_raw_file_alloc(Storage* storage) {
|
||||
}
|
||||
|
||||
void lfrfid_raw_file_free(LFRFIDRawFile* file) {
|
||||
furi_check(file);
|
||||
|
||||
if(file->buffer) free(file->buffer);
|
||||
stream_free(file->stream);
|
||||
free(file);
|
||||
}
|
||||
|
||||
bool lfrfid_raw_file_open_write(LFRFIDRawFile* file, const char* file_path) {
|
||||
furi_check(file);
|
||||
furi_check(file_path);
|
||||
|
||||
return file_stream_open(file->stream, file_path, FSAM_READ_WRITE, FSOM_CREATE_ALWAYS);
|
||||
}
|
||||
|
||||
bool lfrfid_raw_file_open_read(LFRFIDRawFile* file, const char* file_path) {
|
||||
furi_check(file);
|
||||
furi_check(file_path);
|
||||
|
||||
return file_stream_open(file->stream, file_path, FSAM_READ, FSOM_OPEN_EXISTING);
|
||||
}
|
||||
|
||||
@@ -51,6 +61,8 @@ bool lfrfid_raw_file_write_header(
|
||||
float frequency,
|
||||
float duty_cycle,
|
||||
uint32_t max_buffer_size) {
|
||||
furi_check(file);
|
||||
|
||||
LFRFIDRawFileHeader header = {
|
||||
.magic = LFRFID_RAW_FILE_MAGIC,
|
||||
.version = LFRFID_RAW_FILE_VERSION,
|
||||
@@ -63,6 +75,10 @@ bool lfrfid_raw_file_write_header(
|
||||
}
|
||||
|
||||
bool lfrfid_raw_file_write_buffer(LFRFIDRawFile* file, uint8_t* buffer_data, size_t buffer_size) {
|
||||
furi_check(file);
|
||||
furi_check(buffer_data);
|
||||
furi_check(buffer_size);
|
||||
|
||||
size_t size;
|
||||
size = stream_write(file->stream, (uint8_t*)&buffer_size, sizeof(size_t));
|
||||
if(size != sizeof(size_t)) return false;
|
||||
@@ -74,6 +90,10 @@ bool lfrfid_raw_file_write_buffer(LFRFIDRawFile* file, uint8_t* buffer_data, siz
|
||||
}
|
||||
|
||||
bool lfrfid_raw_file_read_header(LFRFIDRawFile* file, float* frequency, float* duty_cycle) {
|
||||
furi_check(file);
|
||||
furi_check(frequency);
|
||||
furi_check(duty_cycle);
|
||||
|
||||
LFRFIDRawFileHeader header;
|
||||
size_t size = stream_read(file->stream, (uint8_t*)&header, sizeof(LFRFIDRawFileHeader));
|
||||
if(size == sizeof(LFRFIDRawFileHeader)) {
|
||||
@@ -98,6 +118,10 @@ bool lfrfid_raw_file_read_pair(
|
||||
uint32_t* duration,
|
||||
uint32_t* pulse,
|
||||
bool* pass_end) {
|
||||
furi_check(file);
|
||||
furi_check(duration);
|
||||
furi_check(pulse);
|
||||
|
||||
size_t length = 0;
|
||||
if(file->buffer_counter >= file->buffer_size) {
|
||||
if(stream_eof(file->stream)) {
|
||||
|
||||
@@ -58,21 +58,23 @@ typedef enum {
|
||||
static int32_t lfrfid_raw_read_worker_thread(void* thread_context);
|
||||
static int32_t lfrfid_raw_emulate_worker_thread(void* thread_context);
|
||||
|
||||
LFRFIDRawWorker* lfrfid_raw_worker_alloc() {
|
||||
LFRFIDRawWorker* lfrfid_raw_worker_alloc(void) {
|
||||
LFRFIDRawWorker* worker = malloc(sizeof(LFRFIDRawWorker));
|
||||
|
||||
worker->thread = furi_thread_alloc_ex("LfrfidRawWorker", 2048, NULL, worker);
|
||||
|
||||
worker->events = furi_event_flag_alloc(NULL);
|
||||
|
||||
worker->events = furi_event_flag_alloc();
|
||||
worker->file_path = furi_string_alloc();
|
||||
|
||||
return worker;
|
||||
}
|
||||
|
||||
void lfrfid_raw_worker_free(LFRFIDRawWorker* worker) {
|
||||
furi_check(worker);
|
||||
|
||||
furi_thread_free(worker->thread);
|
||||
furi_event_flag_free(worker->events);
|
||||
furi_string_free(worker->file_path);
|
||||
|
||||
free(worker);
|
||||
}
|
||||
|
||||
@@ -83,6 +85,8 @@ void lfrfid_raw_worker_start_read(
|
||||
float duty_cycle,
|
||||
LFRFIDWorkerReadRawCallback callback,
|
||||
void* context) {
|
||||
furi_check(worker);
|
||||
furi_check(file_path);
|
||||
furi_check(furi_thread_get_state(worker->thread) == FuriThreadStateStopped);
|
||||
|
||||
furi_string_set(worker->file_path, file_path);
|
||||
@@ -102,7 +106,10 @@ void lfrfid_raw_worker_start_emulate(
|
||||
const char* file_path,
|
||||
LFRFIDWorkerEmulateRawCallback callback,
|
||||
void* context) {
|
||||
furi_check(worker);
|
||||
furi_check(file_path);
|
||||
furi_check(furi_thread_get_state(worker->thread) == FuriThreadStateStopped);
|
||||
|
||||
furi_string_set(worker->file_path, file_path);
|
||||
worker->emulate_callback = callback;
|
||||
worker->context = context;
|
||||
@@ -111,6 +118,8 @@ void lfrfid_raw_worker_start_emulate(
|
||||
}
|
||||
|
||||
void lfrfid_raw_worker_stop(LFRFIDRawWorker* worker) {
|
||||
furi_check(worker);
|
||||
|
||||
worker->emulate_callback = NULL;
|
||||
worker->context = NULL;
|
||||
worker->read_callback = NULL;
|
||||
|
||||
@@ -15,7 +15,7 @@ typedef struct LFRFIDRawWorker LFRFIDRawWorker;
|
||||
*
|
||||
* @return LFRFIDRawWorker*
|
||||
*/
|
||||
LFRFIDRawWorker* lfrfid_raw_worker_alloc();
|
||||
LFRFIDRawWorker* lfrfid_raw_worker_alloc(void);
|
||||
|
||||
/**
|
||||
* @brief Free a LFRFIDRawWorker instance
|
||||
|
||||
@@ -21,7 +21,7 @@ typedef enum {
|
||||
static int32_t lfrfid_worker_thread(void* thread_context);
|
||||
|
||||
LFRFIDWorker* lfrfid_worker_alloc(ProtocolDict* dict) {
|
||||
furi_assert(dict);
|
||||
furi_check(dict);
|
||||
|
||||
LFRFIDWorker* worker = malloc(sizeof(LFRFIDWorker));
|
||||
worker->mode_index = LFRFIDWorkerIdle;
|
||||
@@ -39,6 +39,8 @@ LFRFIDWorker* lfrfid_worker_alloc(ProtocolDict* dict) {
|
||||
}
|
||||
|
||||
void lfrfid_worker_free(LFRFIDWorker* worker) {
|
||||
furi_check(worker);
|
||||
|
||||
if(worker->raw_filename) {
|
||||
free(worker->raw_filename);
|
||||
}
|
||||
@@ -52,7 +54,9 @@ void lfrfid_worker_read_start(
|
||||
LFRFIDWorkerReadType type,
|
||||
LFRFIDWorkerReadCallback callback,
|
||||
void* context) {
|
||||
furi_assert(worker->mode_index == LFRFIDWorkerIdle);
|
||||
furi_check(worker);
|
||||
furi_check(worker->mode_index == LFRFIDWorkerIdle);
|
||||
|
||||
worker->read_type = type;
|
||||
worker->read_cb = callback;
|
||||
worker->cb_ctx = context;
|
||||
@@ -64,7 +68,7 @@ void lfrfid_worker_write_start(
|
||||
LFRFIDProtocol protocol,
|
||||
LFRFIDWorkerWriteCallback callback,
|
||||
void* context) {
|
||||
furi_assert(worker->mode_index == LFRFIDWorkerIdle);
|
||||
furi_check(worker->mode_index == LFRFIDWorkerIdle);
|
||||
worker->protocol = protocol;
|
||||
worker->write_cb = callback;
|
||||
worker->cb_ctx = context;
|
||||
@@ -84,7 +88,9 @@ void lfrfid_worker_write_and_set_pass_start(
|
||||
}
|
||||
|
||||
void lfrfid_worker_emulate_start(LFRFIDWorker* worker, LFRFIDProtocol protocol) {
|
||||
furi_assert(worker->mode_index == LFRFIDWorkerIdle);
|
||||
furi_check(worker);
|
||||
furi_check(worker->mode_index == LFRFIDWorkerIdle);
|
||||
|
||||
worker->protocol = protocol;
|
||||
furi_thread_flags_set(furi_thread_get_id(worker->thread), LFRFIDEventEmulate);
|
||||
}
|
||||
@@ -103,7 +109,9 @@ void lfrfid_worker_read_raw_start(
|
||||
LFRFIDWorkerReadType type,
|
||||
LFRFIDWorkerReadRawCallback callback,
|
||||
void* context) {
|
||||
furi_assert(worker->mode_index == LFRFIDWorkerIdle);
|
||||
furi_check(worker);
|
||||
furi_check(worker->mode_index == LFRFIDWorkerIdle);
|
||||
|
||||
worker->read_type = type;
|
||||
worker->read_raw_cb = callback;
|
||||
worker->cb_ctx = context;
|
||||
@@ -116,7 +124,9 @@ void lfrfid_worker_emulate_raw_start(
|
||||
const char* filename,
|
||||
LFRFIDWorkerEmulateRawCallback callback,
|
||||
void* context) {
|
||||
furi_assert(worker->mode_index == LFRFIDWorkerIdle);
|
||||
furi_check(worker);
|
||||
furi_check(worker->mode_index == LFRFIDWorkerIdle);
|
||||
|
||||
lfrfid_worker_set_filename(worker, filename);
|
||||
worker->emulate_raw_cb = callback;
|
||||
worker->cb_ctx = context;
|
||||
@@ -124,14 +134,20 @@ void lfrfid_worker_emulate_raw_start(
|
||||
}
|
||||
|
||||
void lfrfid_worker_stop(LFRFIDWorker* worker) {
|
||||
furi_check(worker);
|
||||
|
||||
furi_thread_flags_set(furi_thread_get_id(worker->thread), LFRFIDEventStopMode);
|
||||
}
|
||||
|
||||
void lfrfid_worker_start_thread(LFRFIDWorker* worker) {
|
||||
furi_check(worker);
|
||||
|
||||
furi_thread_start(worker->thread);
|
||||
}
|
||||
|
||||
void lfrfid_worker_stop_thread(LFRFIDWorker* worker) {
|
||||
furi_check(worker);
|
||||
|
||||
furi_thread_flags_set(furi_thread_get_id(worker->thread), LFRFIDEventStopThread);
|
||||
furi_thread_join(worker->thread);
|
||||
}
|
||||
|
||||
+39
-44
@@ -1,5 +1,4 @@
|
||||
/**
|
||||
* @file lfrfid_worker.h
|
||||
/** @file lfrfid_worker.h
|
||||
*
|
||||
* LFRFID worker
|
||||
*/
|
||||
@@ -54,37 +53,35 @@ typedef void (*LFRFIDWorkerEmulateRawCallback)(LFRFIDWorkerEmulateRawResult resu
|
||||
|
||||
typedef struct LFRFIDWorker LFRFIDWorker;
|
||||
|
||||
/**
|
||||
* Allocate LF-RFID worker
|
||||
/** Allocate LF-RFID worker
|
||||
* @return LFRFIDWorker*
|
||||
*/
|
||||
LFRFIDWorker* lfrfid_worker_alloc(ProtocolDict* dict);
|
||||
|
||||
/**
|
||||
* Free LF-RFID worker
|
||||
* @param worker
|
||||
/** Free LF-RFID worker
|
||||
*
|
||||
* @param worker The worker
|
||||
*/
|
||||
void lfrfid_worker_free(LFRFIDWorker* worker);
|
||||
|
||||
/**
|
||||
* Start LF-RFID worker thread
|
||||
* @param worker
|
||||
/** Start LF-RFID worker thread
|
||||
*
|
||||
* @param worker The worker
|
||||
*/
|
||||
void lfrfid_worker_start_thread(LFRFIDWorker* worker);
|
||||
|
||||
/**
|
||||
* Stop LF-RFID worker thread
|
||||
* @param worker
|
||||
/** Stop LF-RFID worker thread
|
||||
*
|
||||
* @param worker The worker
|
||||
*/
|
||||
void lfrfid_worker_stop_thread(LFRFIDWorker* worker);
|
||||
|
||||
/**
|
||||
* @brief Start read mode
|
||||
*
|
||||
* @param worker
|
||||
* @param type
|
||||
* @param callback
|
||||
* @param context
|
||||
/** Start read mode
|
||||
*
|
||||
* @param worker The worker
|
||||
* @param type The type
|
||||
* @param callback The callback
|
||||
* @param context The context
|
||||
*/
|
||||
void lfrfid_worker_read_start(
|
||||
LFRFIDWorker* worker,
|
||||
@@ -92,13 +89,12 @@ void lfrfid_worker_read_start(
|
||||
LFRFIDWorkerReadCallback callback,
|
||||
void* context);
|
||||
|
||||
/**
|
||||
* @brief Start write mode
|
||||
*
|
||||
* @param worker
|
||||
* @param protocol
|
||||
* @param callback
|
||||
* @param context
|
||||
/** Start write mode
|
||||
*
|
||||
* @param worker The worker
|
||||
* @param protocol The protocol
|
||||
* @param callback The callback
|
||||
* @param context The context
|
||||
*/
|
||||
void lfrfid_worker_write_start(
|
||||
LFRFIDWorker* worker,
|
||||
@@ -126,14 +122,13 @@ void lfrfid_worker_write_and_set_pass_start(
|
||||
*/
|
||||
void lfrfid_worker_emulate_start(LFRFIDWorker* worker, LFRFIDProtocol protocol);
|
||||
|
||||
/**
|
||||
* @brief Start raw read mode
|
||||
*
|
||||
* @param worker
|
||||
* @param filename
|
||||
* @param type
|
||||
* @param callback
|
||||
* @param context
|
||||
/** Start raw read mode
|
||||
*
|
||||
* @param worker The worker
|
||||
* @param filename The filename
|
||||
* @param type The type
|
||||
* @param callback The callback
|
||||
* @param context The context
|
||||
*/
|
||||
void lfrfid_worker_read_raw_start(
|
||||
LFRFIDWorker* worker,
|
||||
@@ -142,12 +137,12 @@ void lfrfid_worker_read_raw_start(
|
||||
LFRFIDWorkerReadRawCallback callback,
|
||||
void* context);
|
||||
|
||||
/**
|
||||
* Emulate raw read mode
|
||||
* @param worker
|
||||
* @param filename
|
||||
* @param callback
|
||||
* @param context
|
||||
/** Emulate raw read mode
|
||||
*
|
||||
* @param worker The worker
|
||||
* @param filename The filename
|
||||
* @param callback The callback
|
||||
* @param context The context
|
||||
*/
|
||||
void lfrfid_worker_emulate_raw_start(
|
||||
LFRFIDWorker* worker,
|
||||
@@ -155,9 +150,9 @@ void lfrfid_worker_emulate_raw_start(
|
||||
LFRFIDWorkerEmulateRawCallback callback,
|
||||
void* context);
|
||||
|
||||
/**
|
||||
* Stop all modes
|
||||
* @param worker
|
||||
/** Stop all modes
|
||||
*
|
||||
* @param worker The worker
|
||||
*/
|
||||
void lfrfid_worker_stop(LFRFIDWorker* worker);
|
||||
|
||||
|
||||
@@ -164,7 +164,8 @@ void protocol_awid_render_data(ProtocolAwid* protocol, FuriString* result) {
|
||||
uint8_t* decoded_data = protocol->data;
|
||||
uint8_t format_length = decoded_data[0];
|
||||
|
||||
furi_string_cat_printf(result, "Format: %d\r\n", format_length);
|
||||
furi_string_printf(result, "Format: %hhu\n", format_length);
|
||||
|
||||
if(format_length == 26) {
|
||||
uint8_t facility;
|
||||
bit_lib_copy_bits(&facility, 0, 8, decoded_data, 9);
|
||||
@@ -172,13 +173,17 @@ void protocol_awid_render_data(ProtocolAwid* protocol, FuriString* result) {
|
||||
uint16_t card_id;
|
||||
bit_lib_copy_bits((uint8_t*)&card_id, 8, 8, decoded_data, 17);
|
||||
bit_lib_copy_bits((uint8_t*)&card_id, 0, 8, decoded_data, 25);
|
||||
furi_string_cat_printf(result, "Facility: %d\r\n", facility);
|
||||
furi_string_cat_printf(result, "Card: %d", card_id);
|
||||
furi_string_cat_printf(
|
||||
result,
|
||||
"FC: %hhu\n"
|
||||
"Card: %hu",
|
||||
facility,
|
||||
card_id);
|
||||
} else {
|
||||
// print 66 bits as hex
|
||||
furi_string_cat_printf(result, "Data: ");
|
||||
for(size_t i = 0; i < AWID_DECODED_DATA_SIZE; i++) {
|
||||
furi_string_cat_printf(result, "%02X", decoded_data[i]);
|
||||
furi_string_cat_printf(result, "%02hhX", decoded_data[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -187,7 +192,8 @@ void protocol_awid_render_brief_data(ProtocolAwid* protocol, FuriString* result)
|
||||
uint8_t* decoded_data = protocol->data;
|
||||
uint8_t format_length = decoded_data[0];
|
||||
|
||||
furi_string_cat_printf(result, "Format: %d\r\n", format_length);
|
||||
furi_string_printf(result, "Format: %hhu", format_length);
|
||||
|
||||
if(format_length == 26) {
|
||||
uint8_t facility;
|
||||
bit_lib_copy_bits(&facility, 0, 8, decoded_data, 9);
|
||||
@@ -195,9 +201,14 @@ void protocol_awid_render_brief_data(ProtocolAwid* protocol, FuriString* result)
|
||||
uint16_t card_id;
|
||||
bit_lib_copy_bits((uint8_t*)&card_id, 8, 8, decoded_data, 17);
|
||||
bit_lib_copy_bits((uint8_t*)&card_id, 0, 8, decoded_data, 25);
|
||||
furi_string_cat_printf(result, "ID: %03u,%05u", facility, card_id);
|
||||
furi_string_cat_printf(
|
||||
result,
|
||||
"; FC: %hhu\n"
|
||||
"Card: %hu",
|
||||
facility,
|
||||
card_id);
|
||||
} else {
|
||||
furi_string_cat_printf(result, "Data: unknown");
|
||||
furi_string_cat(result, "\nData: Unknown");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -252,4 +263,4 @@ const ProtocolBase protocol_awid = {
|
||||
.render_data = (ProtocolRenderData)protocol_awid_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_awid_render_brief_data,
|
||||
.write_data = (ProtocolWriteData)protocol_awid_write_data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -335,8 +335,8 @@ bool protocol_em4100_write_data(ProtocolEM4100* protocol, void* data) {
|
||||
request->t5577.block[0] =
|
||||
(LFRFID_T5577_MODULATION_MANCHESTER | protocol_em4100_get_t5577_bitrate(protocol) |
|
||||
(2 << LFRFID_T5577_MAXBLOCK_SHIFT));
|
||||
request->t5577.block[1] = protocol->encoded_data;
|
||||
request->t5577.block[2] = protocol->encoded_data >> 32;
|
||||
request->t5577.block[1] = protocol->encoded_data >> 32;
|
||||
request->t5577.block[2] = protocol->encoded_data;
|
||||
request->t5577.blocks_to_write = 3;
|
||||
result = true;
|
||||
}
|
||||
@@ -347,7 +347,8 @@ void protocol_em4100_render_data(ProtocolEM4100* protocol, FuriString* result) {
|
||||
uint8_t* data = protocol->data;
|
||||
furi_string_printf(
|
||||
result,
|
||||
"FC: %03u, Card: %05u\n(RF/%u)",
|
||||
"FC: %03u\n"
|
||||
"Card: %05hu (RF/%hhu)",
|
||||
data[2],
|
||||
(uint16_t)((data[3] << 8) | (data[4])),
|
||||
protocol->clock_per_bit);
|
||||
|
||||
@@ -217,14 +217,10 @@ void protocol_fdx_a_render_data(ProtocolFDXA* protocol, FuriString* result) {
|
||||
|
||||
furi_string_printf(
|
||||
result,
|
||||
"ID: %02X%02X%02X%02X%02X\r\n"
|
||||
"Parity: %s",
|
||||
data[0],
|
||||
data[1],
|
||||
data[2],
|
||||
data[3],
|
||||
data[4],
|
||||
parity_sum == 0 ? "+" : "-");
|
||||
"ID: %010llX\n"
|
||||
"Parity: %c",
|
||||
bit_lib_get_bits_64(data, 0, 40),
|
||||
parity_sum == 0 ? '+' : '-');
|
||||
};
|
||||
|
||||
const ProtocolBase protocol_fdx_a = {
|
||||
@@ -249,4 +245,4 @@ const ProtocolBase protocol_fdx_a = {
|
||||
.render_data = (ProtocolRenderData)protocol_fdx_a_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_fdx_a_render_data,
|
||||
.write_data = (ProtocolWriteData)protocol_fdx_a_write_data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -288,21 +288,33 @@ void protocol_fdx_b_render_data(ProtocolFDXB* protocol, FuriString* result) {
|
||||
uint8_t replacement_number = bit_lib_get_bits(protocol->data, 60, 3);
|
||||
bool animal_flag = bit_lib_get_bit(protocol->data, 63);
|
||||
|
||||
furi_string_printf(result, "ID: %03u-%012llu\r\n", country_code, national_code);
|
||||
furi_string_cat_printf(result, "Animal: %s, ", animal_flag ? "Yes" : "No");
|
||||
furi_string_printf(
|
||||
result,
|
||||
"ID: %03hu-%012llu\n"
|
||||
"Country Code: %hu\n"
|
||||
"Temperature: ",
|
||||
country_code,
|
||||
national_code,
|
||||
country_code);
|
||||
|
||||
float temperature;
|
||||
if(protocol_fdx_b_get_temp(protocol->data, &temperature)) {
|
||||
float temperature_c = (temperature - 32) / 1.8;
|
||||
furi_string_cat_printf(
|
||||
result, "T: %.2fF, %.2fC\r\n", (double)temperature, (double)temperature_c);
|
||||
if(furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric) {
|
||||
float temperature_c = (temperature - 32.0f) / 1.8f;
|
||||
furi_string_cat_printf(result, "%.2fC", (double)temperature_c);
|
||||
} else {
|
||||
furi_string_cat_printf(result, "%.2fF", (double)temperature);
|
||||
}
|
||||
} else {
|
||||
furi_string_cat_printf(result, "T: ---\r\n");
|
||||
furi_string_cat(result, "---");
|
||||
}
|
||||
|
||||
furi_string_cat_printf(
|
||||
result,
|
||||
"Bits: %X-%X-%X-%X-%X",
|
||||
"\n"
|
||||
"Animal: %s\n"
|
||||
"Bits: %hhX-%hhX-%hhX-%hhX-%hhX",
|
||||
animal_flag ? "Yes" : "No",
|
||||
block_status,
|
||||
rudi_bit,
|
||||
reserved,
|
||||
@@ -317,21 +329,24 @@ void protocol_fdx_b_render_brief_data(ProtocolFDXB* protocol, FuriString* result
|
||||
// 10 bit of country code
|
||||
uint16_t country_code = protocol_fdx_b_get_country_code(protocol->data);
|
||||
|
||||
bool animal_flag = bit_lib_get_bit(protocol->data, 63);
|
||||
|
||||
furi_string_printf(result, "ID: %03u-%012llu\r\n", country_code, national_code);
|
||||
furi_string_cat_printf(result, "Animal: %s, ", animal_flag ? "Yes" : "No");
|
||||
furi_string_printf(
|
||||
result,
|
||||
"ID: %03hu-%012llu\n"
|
||||
"Country: %hu; Temp.: ",
|
||||
country_code,
|
||||
national_code,
|
||||
country_code);
|
||||
|
||||
float temperature;
|
||||
if(protocol_fdx_b_get_temp(protocol->data, &temperature)) {
|
||||
if(furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric) {
|
||||
float temperature_c = (temperature - 32.0f) / 1.8f;
|
||||
furi_string_cat_printf(result, "T: %.2fC", (double)temperature_c);
|
||||
furi_string_cat_printf(result, "%.2fC", (double)temperature_c);
|
||||
} else {
|
||||
furi_string_cat_printf(result, "T: %.2fF", (double)temperature);
|
||||
furi_string_cat_printf(result, "%.2fF", (double)temperature);
|
||||
}
|
||||
} else {
|
||||
furi_string_cat_printf(result, "T: ---");
|
||||
furi_string_cat(result, "---");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -380,4 +395,4 @@ const ProtocolBase protocol_fdx_b = {
|
||||
.render_data = (ProtocolRenderData)protocol_fdx_b_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_fdx_b_render_brief_data,
|
||||
.write_data = (ProtocolWriteData)protocol_fdx_b_write_data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -268,17 +268,44 @@ bool protocol_gallagher_write_data(ProtocolGallagher* protocol, void* data) {
|
||||
return result;
|
||||
};
|
||||
|
||||
void protocol_gallagher_render_data(ProtocolGallagher* protocol, FuriString* result) {
|
||||
UNUSED(protocol);
|
||||
uint8_t rc = bit_lib_get_bits(protocol->data, 0, 4);
|
||||
uint8_t il = bit_lib_get_bits(protocol->data, 4, 4);
|
||||
static void protocol_gallagher_render_data_internal(
|
||||
ProtocolGallagher* protocol,
|
||||
FuriString* result,
|
||||
bool brief) {
|
||||
uint8_t region = bit_lib_get_bits(protocol->data, 0, 4);
|
||||
uint8_t issue_level = bit_lib_get_bits(protocol->data, 4, 4);
|
||||
uint32_t fc = bit_lib_get_bits_32(protocol->data, 8, 24);
|
||||
uint32_t card_id = bit_lib_get_bits_32(protocol->data, 32, 32);
|
||||
|
||||
furi_string_cat_printf(result, "Region: %u, Issue Level: %u\r\n", rc, il);
|
||||
furi_string_cat_printf(result, "FC: %lu, C: %lu\r\n", fc, card_id);
|
||||
if(brief) {
|
||||
furi_string_printf(
|
||||
result,
|
||||
"FC: %lu\n"
|
||||
"Card: %lu",
|
||||
fc,
|
||||
card_id);
|
||||
} else {
|
||||
furi_string_printf(
|
||||
result,
|
||||
"FC: %lu\n"
|
||||
"Card: %lu\n"
|
||||
"Region: %u\n"
|
||||
"Issue Level: %u",
|
||||
fc,
|
||||
card_id,
|
||||
region,
|
||||
issue_level);
|
||||
}
|
||||
};
|
||||
|
||||
void protocol_gallagher_render_data(ProtocolGallagher* protocol, FuriString* result) {
|
||||
protocol_gallagher_render_data_internal(protocol, result, false);
|
||||
}
|
||||
|
||||
void protocol_gallagher_render_brief_data(ProtocolGallagher* protocol, FuriString* result) {
|
||||
protocol_gallagher_render_data_internal(protocol, result, true);
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_gallagher = {
|
||||
.name = "Gallagher",
|
||||
.manufacturer = "Gallagher",
|
||||
@@ -299,6 +326,6 @@ const ProtocolBase protocol_gallagher = {
|
||||
.yield = (ProtocolEncoderYield)protocol_gallagher_encoder_yield,
|
||||
},
|
||||
.render_data = (ProtocolRenderData)protocol_gallagher_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_gallagher_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_gallagher_render_brief_data,
|
||||
.write_data = (ProtocolWriteData)protocol_gallagher_write_data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -359,8 +359,8 @@ void protocol_h10301_render_data(ProtocolH10301* protocol, FuriString* result) {
|
||||
uint8_t* data = protocol->data;
|
||||
furi_string_printf(
|
||||
result,
|
||||
"FC: %u\r\n"
|
||||
"Card: %u",
|
||||
"FC: %hhu\n"
|
||||
"Card: %hu",
|
||||
data[0],
|
||||
(uint16_t)((data[1] << 8) | (data[2])));
|
||||
};
|
||||
@@ -387,4 +387,4 @@ const ProtocolBase protocol_h10301 = {
|
||||
.render_data = (ProtocolRenderData)protocol_h10301_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_h10301_render_data,
|
||||
.write_data = (ProtocolWriteData)protocol_h10301_write_data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -193,9 +193,13 @@ bool protocol_hid_ex_generic_write_data(ProtocolHIDEx* protocol, void* data) {
|
||||
};
|
||||
|
||||
void protocol_hid_ex_generic_render_data(ProtocolHIDEx* protocol, FuriString* result) {
|
||||
// TODO FL-3518: parser and render functions
|
||||
UNUSED(protocol);
|
||||
furi_string_printf(result, "Generic HID Extended\r\nData: Unknown");
|
||||
|
||||
// TODO FL-3518: parser and render functions
|
||||
furi_string_set(
|
||||
result,
|
||||
"Type: Generic HID Extended\n"
|
||||
"Data: Unknown");
|
||||
};
|
||||
|
||||
const ProtocolBase protocol_hid_ex_generic = {
|
||||
@@ -220,4 +224,4 @@ const ProtocolBase protocol_hid_ex_generic = {
|
||||
.render_data = (ProtocolRenderData)protocol_hid_ex_generic_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_hid_ex_generic_render_data,
|
||||
.write_data = (ProtocolWriteData)protocol_hid_ex_generic_write_data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -245,7 +245,7 @@ void protocol_hid_generic_render_data(ProtocolHID* protocol, FuriString* result)
|
||||
if(protocol_size == HID_PROTOCOL_SIZE_UNKNOWN) {
|
||||
furi_string_printf(
|
||||
result,
|
||||
"Generic HID Proximity\r\n"
|
||||
"Generic HID Proximity\n"
|
||||
"Data: %02X%02X%02X%02X%02X%X",
|
||||
protocol->data[0],
|
||||
protocol->data[1],
|
||||
@@ -256,7 +256,7 @@ void protocol_hid_generic_render_data(ProtocolHID* protocol, FuriString* result)
|
||||
} else {
|
||||
furi_string_printf(
|
||||
result,
|
||||
"%hhu-bit HID Proximity\r\n"
|
||||
"%hhu-bit HID Proximity\n"
|
||||
"Data: ",
|
||||
protocol_size);
|
||||
protocol_hid_generic_string_cat_protocol_bits(protocol, protocol_size, result);
|
||||
|
||||
@@ -205,26 +205,16 @@ static uint32_t get_card(const uint8_t* data) {
|
||||
return cn;
|
||||
}
|
||||
|
||||
void protocol_idteck_render_data_internal(ProtocolIdteck* protocol, FuriString* result, bool brief) {
|
||||
void protocol_idteck_render_data(ProtocolIdteck* protocol, FuriString* result) {
|
||||
const uint32_t fc = get_fc(protocol->data);
|
||||
const uint32_t card = get_card(protocol->data);
|
||||
|
||||
if(brief) {
|
||||
furi_string_printf(result, "FC: %08lX\r\nCard: %08lX", fc, card);
|
||||
} else {
|
||||
furi_string_printf(
|
||||
result,
|
||||
"FC: %08lX\r\n"
|
||||
"Card: %08lX\r\n",
|
||||
fc,
|
||||
card);
|
||||
}
|
||||
}
|
||||
void protocol_idteck_render_data(ProtocolIdteck* protocol, FuriString* result) {
|
||||
protocol_idteck_render_data_internal(protocol, result, false);
|
||||
}
|
||||
void protocol_idteck_render_brief_data(ProtocolIdteck* protocol, FuriString* result) {
|
||||
protocol_idteck_render_data_internal(protocol, result, true);
|
||||
furi_string_printf(
|
||||
result,
|
||||
"FC: %08lX\n"
|
||||
"Card: %08lX",
|
||||
fc,
|
||||
card);
|
||||
}
|
||||
|
||||
bool protocol_idteck_write_data(ProtocolIdteck* protocol, void* data) {
|
||||
@@ -264,6 +254,6 @@ const ProtocolBase protocol_idteck = {
|
||||
.yield = (ProtocolEncoderYield)protocol_idteck_encoder_yield,
|
||||
},
|
||||
.render_data = (ProtocolRenderData)protocol_idteck_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_idteck_render_brief_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_idteck_render_data,
|
||||
.write_data = (ProtocolWriteData)protocol_idteck_write_data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -289,22 +289,21 @@ void protocol_indala26_render_data_internal(
|
||||
if(brief) {
|
||||
furi_string_printf(
|
||||
result,
|
||||
"FC: %u\r\nCard: %u, Parity:%s%s",
|
||||
"FC: %u\n"
|
||||
"Card: %u",
|
||||
fc,
|
||||
card,
|
||||
(checksum_correct ? "+" : "-"),
|
||||
(wiegand_correct ? "+" : "-"));
|
||||
card);
|
||||
} else {
|
||||
furi_string_printf(
|
||||
result,
|
||||
"FC: %u\r\n"
|
||||
"Card: %u\r\n"
|
||||
"Checksum: %s\r\n"
|
||||
"W26 Parity: %s",
|
||||
"FC: %u\n"
|
||||
"Card: %u\n"
|
||||
"Parity: %c\n"
|
||||
"Checksum: %c",
|
||||
fc,
|
||||
card,
|
||||
(checksum_correct ? "+" : "-"),
|
||||
(wiegand_correct ? "+" : "-"));
|
||||
(wiegand_correct ? '+' : '-'),
|
||||
(checksum_correct ? '+' : '-'));
|
||||
}
|
||||
}
|
||||
void protocol_indala26_render_data(ProtocolIndala* protocol, FuriString* result) {
|
||||
|
||||
@@ -236,9 +236,9 @@ void protocol_io_prox_xsf_render_data(ProtocolIOProxXSF* protocol, FuriString* r
|
||||
uint8_t* data = protocol->data;
|
||||
furi_string_printf(
|
||||
result,
|
||||
"FC: %u\r\n"
|
||||
"VС: %u\r\n"
|
||||
"Card: %u",
|
||||
"FC: %hhu\n"
|
||||
"V: %hhu\n"
|
||||
"Card: %hu",
|
||||
data[0],
|
||||
data[1],
|
||||
(uint16_t)((data[2] << 8) | (data[3])));
|
||||
@@ -248,8 +248,8 @@ void protocol_io_prox_xsf_render_brief_data(ProtocolIOProxXSF* protocol, FuriStr
|
||||
uint8_t* data = protocol->data;
|
||||
furi_string_printf(
|
||||
result,
|
||||
"FC: %u, VС: %u\r\n"
|
||||
"Card: %u",
|
||||
"FC: %hhu, V: %hhu\n"
|
||||
"Card: %hu",
|
||||
data[0],
|
||||
data[1],
|
||||
(uint16_t)((data[2] << 8) | (data[3])));
|
||||
@@ -298,4 +298,4 @@ const ProtocolBase protocol_io_prox_xsf = {
|
||||
.render_data = (ProtocolRenderData)protocol_io_prox_xsf_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_io_prox_xsf_render_brief_data,
|
||||
.write_data = (ProtocolWriteData)protocol_io_prox_xsf_write_data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -162,7 +162,7 @@ LevelDuration protocol_jablotron_encoder_yield(ProtocolJablotron* protocol) {
|
||||
|
||||
void protocol_jablotron_render_data(ProtocolJablotron* protocol, FuriString* result) {
|
||||
uint64_t id = protocol_jablotron_card_id(protocol->data);
|
||||
furi_string_printf(result, "ID: %llX\r\n", id);
|
||||
furi_string_printf(result, "Card: %llX", id);
|
||||
};
|
||||
|
||||
bool protocol_jablotron_write_data(ProtocolJablotron* protocol, void* data) {
|
||||
@@ -208,4 +208,4 @@ const ProtocolBase protocol_jablotron = {
|
||||
.render_data = (ProtocolRenderData)protocol_jablotron_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_jablotron_render_data,
|
||||
.write_data = (ProtocolWriteData)protocol_jablotron_write_data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -212,13 +212,40 @@ LevelDuration protocol_keri_encoder_yield(ProtocolKeri* protocol) {
|
||||
return level_duration;
|
||||
};
|
||||
|
||||
void protocol_keri_render_data(ProtocolKeri* protocol, FuriString* result) {
|
||||
static void
|
||||
protocol_keri_render_data_internal(ProtocolKeri* protocol, FuriString* result, bool brief) {
|
||||
uint32_t data = bit_lib_get_bits_32(protocol->data, 0, 32);
|
||||
uint32_t internal_id = data & 0x7FFFFFFF;
|
||||
uint32_t fc = 0;
|
||||
uint32_t cn = 0;
|
||||
protocol_keri_descramble(&fc, &cn, &data);
|
||||
furi_string_printf(result, "Internal ID: %lu\r\nFC: %lu, Card: %lu\r\n", internal_id, fc, cn);
|
||||
|
||||
if(brief) {
|
||||
furi_string_printf(
|
||||
result,
|
||||
"Internal ID: %lu\n"
|
||||
"FC: %lu; Card: %lu",
|
||||
internal_id,
|
||||
fc,
|
||||
cn);
|
||||
} else {
|
||||
furi_string_printf(
|
||||
result,
|
||||
"Internal ID: %lu\n"
|
||||
"FC: %lu\n"
|
||||
"Card: %lu",
|
||||
internal_id,
|
||||
fc,
|
||||
cn);
|
||||
}
|
||||
}
|
||||
|
||||
void protocol_keri_render_data(ProtocolKeri* protocol, FuriString* result) {
|
||||
protocol_keri_render_data_internal(protocol, result, false);
|
||||
}
|
||||
|
||||
void protocol_keri_render_brief_data(ProtocolKeri* protocol, FuriString* result) {
|
||||
protocol_keri_render_data_internal(protocol, result, true);
|
||||
}
|
||||
|
||||
bool protocol_keri_write_data(ProtocolKeri* protocol, void* data) {
|
||||
@@ -262,6 +289,6 @@ const ProtocolBase protocol_keri = {
|
||||
.yield = (ProtocolEncoderYield)protocol_keri_encoder_yield,
|
||||
},
|
||||
.render_data = (ProtocolRenderData)protocol_keri_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_keri_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_keri_render_brief_data,
|
||||
.write_data = (ProtocolWriteData)protocol_keri_write_data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -263,7 +263,10 @@ LevelDuration protocol_nexwatch_encoder_yield(ProtocolNexwatch* protocol) {
|
||||
return level_duration;
|
||||
};
|
||||
|
||||
void protocol_nexwatch_render_data(ProtocolNexwatch* protocol, FuriString* result) {
|
||||
static void protocol_nexwatch_render_data_internal(
|
||||
ProtocolNexwatch* protocol,
|
||||
FuriString* result,
|
||||
bool brief) {
|
||||
uint32_t id = 0;
|
||||
uint32_t scrambled = bit_lib_get_bits_32(protocol->data, 8, 32);
|
||||
protocol_nexwatch_descramble(&id, &scrambled);
|
||||
@@ -272,13 +275,42 @@ void protocol_nexwatch_render_data(ProtocolNexwatch* protocol, FuriString* resul
|
||||
uint8_t mode = bit_lib_get_bits(protocol->data, 40, 4);
|
||||
uint8_t parity = bit_lib_get_bits(protocol->data, 44, 4);
|
||||
uint8_t chk = bit_lib_get_bits(protocol->data, 48, 8);
|
||||
for(m_idx = 0; m_idx < 3; m_idx++) {
|
||||
|
||||
for(m_idx = 0; m_idx < COUNT_OF(magic_items); m_idx++) {
|
||||
magic_items[m_idx].chk = protocol_nexwatch_checksum(magic_items[m_idx].magic, id, parity);
|
||||
if(magic_items[m_idx].chk == chk) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
furi_string_printf(result, "ID: %lu, M:%u\r\nType: %s\r\n", id, mode, magic_items[m_idx].desc);
|
||||
|
||||
const char* type = m_idx < COUNT_OF(magic_items) ? magic_items[m_idx].desc : "Unknown";
|
||||
|
||||
if(brief) {
|
||||
furi_string_printf(
|
||||
result,
|
||||
"ID: %lu\n"
|
||||
"Mode: %hhu; Type: %s",
|
||||
id,
|
||||
mode,
|
||||
type);
|
||||
} else {
|
||||
furi_string_printf(
|
||||
result,
|
||||
"ID: %lu\n"
|
||||
"Mode: %hhu\n"
|
||||
"Type: %s",
|
||||
id,
|
||||
mode,
|
||||
type);
|
||||
}
|
||||
}
|
||||
|
||||
void protocol_nexwatch_render_data(ProtocolNexwatch* protocol, FuriString* result) {
|
||||
protocol_nexwatch_render_data_internal(protocol, result, false);
|
||||
}
|
||||
|
||||
void protocol_nexwatch_render_brief_data(ProtocolNexwatch* protocol, FuriString* result) {
|
||||
protocol_nexwatch_render_data_internal(protocol, result, true);
|
||||
}
|
||||
|
||||
bool protocol_nexwatch_write_data(ProtocolNexwatch* protocol, void* data) {
|
||||
@@ -318,6 +350,6 @@ const ProtocolBase protocol_nexwatch = {
|
||||
.yield = (ProtocolEncoderYield)protocol_nexwatch_encoder_yield,
|
||||
},
|
||||
.render_data = (ProtocolRenderData)protocol_nexwatch_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_nexwatch_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_nexwatch_render_brief_data,
|
||||
.write_data = (ProtocolWriteData)protocol_nexwatch_write_data,
|
||||
};
|
||||
|
||||
@@ -202,8 +202,7 @@ bool protocol_pac_stanley_write_data(ProtocolPACStanley* protocol, void* data) {
|
||||
}
|
||||
|
||||
void protocol_pac_stanley_render_data(ProtocolPACStanley* protocol, FuriString* result) {
|
||||
uint8_t* data = protocol->data;
|
||||
furi_string_printf(result, "CIN: %02X%02X%02X%02X", data[0], data[1], data[2], data[3]);
|
||||
furi_string_printf(result, "CIN: %08lX", bit_lib_get_bits_32(protocol->data, 0, 32));
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_pac_stanley = {
|
||||
|
||||
@@ -171,10 +171,20 @@ void protocol_paradox_render_data(ProtocolParadox* protocol, FuriString* result)
|
||||
uint8_t card_crc = bit_lib_get_bits_16(decoded_data, 34, 8);
|
||||
uint8_t calc_crc = protocol_paradox_calculate_checksum(fc, card_id);
|
||||
|
||||
furi_string_cat_printf(result, "Facility: %u\r\n", fc);
|
||||
furi_string_cat_printf(result, "Card: %u\r\n", card_id);
|
||||
furi_string_cat_printf(result, "CRC: %u Calc CRC: %u\r\n", card_crc, calc_crc);
|
||||
if(card_crc != calc_crc) furi_string_cat_printf(result, "CRC Mismatch, Invalid Card!\r\n");
|
||||
furi_string_printf(
|
||||
result,
|
||||
"FC: %hhu\n"
|
||||
"Card: %hu\n"
|
||||
"CRC: %hhu\n"
|
||||
"Calc CRC: %hhu",
|
||||
fc,
|
||||
card_id,
|
||||
card_crc,
|
||||
calc_crc);
|
||||
|
||||
if(card_crc != calc_crc) {
|
||||
furi_string_cat(result, "\nCRC Mismatch, Invalid Card!");
|
||||
}
|
||||
};
|
||||
|
||||
void protocol_paradox_render_brief_data(ProtocolParadox* protocol, FuriString* result) {
|
||||
@@ -185,11 +195,10 @@ void protocol_paradox_render_brief_data(ProtocolParadox* protocol, FuriString* r
|
||||
uint8_t card_crc = bit_lib_get_bits_16(decoded_data, 34, 8);
|
||||
uint8_t calc_crc = protocol_paradox_calculate_checksum(fc, card_id);
|
||||
|
||||
furi_string_cat_printf(result, "FC: %03u, Card: %05u\r\n", fc, card_id);
|
||||
if(calc_crc == card_crc) {
|
||||
furi_string_cat_printf(result, "CRC : %03u", card_crc);
|
||||
} else {
|
||||
furi_string_cat_printf(result, "Card is Invalid!");
|
||||
furi_string_printf(result, "FC: %hhu; Card: %hu", fc, card_id);
|
||||
|
||||
if(calc_crc != card_crc) {
|
||||
furi_string_cat(result, "\nCRC Mismatch, Invalid Card!");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -237,4 +246,4 @@ const ProtocolBase protocol_paradox = {
|
||||
.render_data = (ProtocolRenderData)protocol_paradox_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_paradox_render_brief_data,
|
||||
.write_data = (ProtocolWriteData)protocol_paradox_write_data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -243,7 +243,7 @@ void protocol_pyramid_render_data(ProtocolPyramid* protocol, FuriString* result)
|
||||
uint8_t* decoded_data = protocol->data;
|
||||
uint8_t format_length = decoded_data[0];
|
||||
|
||||
furi_string_cat_printf(result, "Format: %d\r\n", format_length);
|
||||
furi_string_printf(result, "Format: %hhu\n", format_length);
|
||||
if(format_length == 26) {
|
||||
uint8_t facility;
|
||||
bit_lib_copy_bits(&facility, 0, 8, decoded_data, 8);
|
||||
@@ -251,9 +251,9 @@ void protocol_pyramid_render_data(ProtocolPyramid* protocol, FuriString* result)
|
||||
uint16_t card_id;
|
||||
bit_lib_copy_bits((uint8_t*)&card_id, 8, 8, decoded_data, 16);
|
||||
bit_lib_copy_bits((uint8_t*)&card_id, 0, 8, decoded_data, 24);
|
||||
furi_string_cat_printf(result, "FC: %03u, Card: %05u", facility, card_id);
|
||||
furi_string_cat_printf(result, "FC: %03hhu; Card: %05hu", facility, card_id);
|
||||
} else {
|
||||
furi_string_cat_printf(result, "Data: unknown");
|
||||
furi_string_cat_printf(result, "Data: Unknown");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -176,8 +176,7 @@ bool protocol_viking_write_data(ProtocolViking* protocol, void* data) {
|
||||
};
|
||||
|
||||
void protocol_viking_render_data(ProtocolViking* protocol, FuriString* result) {
|
||||
uint32_t id = bit_lib_get_bits_32(protocol->data, 0, 32);
|
||||
furi_string_printf(result, "ID: %08lX\r\n", id);
|
||||
furi_string_printf(result, "ID: %08lX", bit_lib_get_bits_32(protocol->data, 0, 32));
|
||||
};
|
||||
|
||||
const ProtocolBase protocol_viking = {
|
||||
@@ -202,4 +201,4 @@ const ProtocolBase protocol_viking = {
|
||||
.render_data = (ProtocolRenderData)protocol_viking_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_viking_render_data,
|
||||
.write_data = (ProtocolWriteData)protocol_viking_write_data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
#define T5577_BLOCKS_IN_PAGE_0 8
|
||||
#define T5577_BLOCKS_IN_PAGE_1 4
|
||||
|
||||
static void t5577_start() {
|
||||
static void t5577_start(void) {
|
||||
furi_hal_rfid_tim_read_start(125000, 0.5);
|
||||
|
||||
// do not ground the antenna
|
||||
furi_hal_rfid_pin_pull_release();
|
||||
}
|
||||
|
||||
static void t5577_stop() {
|
||||
static void t5577_stop(void) {
|
||||
furi_hal_rfid_tim_read_stop();
|
||||
furi_hal_rfid_pins_reset();
|
||||
}
|
||||
@@ -49,7 +49,7 @@ static void t5577_write_opcode(uint8_t value) {
|
||||
t5577_write_bit((value >> 0) & 1);
|
||||
}
|
||||
|
||||
static void t5577_write_reset() {
|
||||
static void t5577_write_reset(void) {
|
||||
t5577_write_gap(T5577_TIMING_START_GAP);
|
||||
t5577_write_bit(1);
|
||||
t5577_write_bit(0);
|
||||
|
||||
@@ -8,7 +8,7 @@ struct VarintPair {
|
||||
uint8_t data[VARINT_PAIR_SIZE];
|
||||
};
|
||||
|
||||
VarintPair* varint_pair_alloc() {
|
||||
VarintPair* varint_pair_alloc(void) {
|
||||
VarintPair* pair = malloc(sizeof(VarintPair));
|
||||
pair->data_length = 0;
|
||||
return pair;
|
||||
|
||||
@@ -15,7 +15,7 @@ typedef struct VarintPair VarintPair;
|
||||
* VarintPair is a buffer that holds pair of varint values
|
||||
* @return VarintPair*
|
||||
*/
|
||||
VarintPair* varint_pair_alloc();
|
||||
VarintPair* varint_pair_alloc(void);
|
||||
|
||||
/**
|
||||
* @brief Free a VarintPair instance
|
||||
|
||||
Reference in New Issue
Block a user