mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-25 03:29:58 -07:00
[FL-3677, FL-3798] RFID Improvements (#3524)
* Update saved_info and read_success scenes * Update EM4100 rendering * Update HIDExt rendering * Update Gallagher rendering * Update HidProx rendering * Update IOProx rendering * Update H10301 rendering * Update PAC/Stanley rendering * Add strcasecmp() to API, better manufacturer/name handling * Update Viking rendering * Update FDX-A rendering * Update Pyramid rendering * Update Indala26 rendering * Update Idteck rendering * Update Keri rendering * Update Nexwatch rendering * Update Jablotron rendering * Update Paradox rendering * Truncate long Hex string on scene_read_suceess * Fix formatting * Update AWID rendering * Update FDX-B rendering * Tweak string formatting in various screens * More read_success view tweaks * Fix formatting * Fix Pyramid brief rendering * Reset saved key menu when going back * Reset other menus on back where applicable * Update confirmation scenes * Update emulation scene * Update delete scene * Update raw read info screen * Update raw read scene, fix crash * Update raw read success scene * Update write scene * Always return to SceneSelectKey after saving * Update SceneWriteSuccess and SceneDeleteSuccess * Replace closing parens with dots * FL-3798: Fix special formatting in text_box * Simplify SceneReadSuccess * Fix crash when having a trailing newline in text_box * Bump API symbols version * Make PVS happy * Format sources Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -330,7 +330,8 @@ void protocol_em4100_render_data(ProtocolEM4100* protocol, FuriString* result) {
|
||||
uint8_t* data = protocol->data;
|
||||
furi_string_printf(
|
||||
result,
|
||||
"FC: %03u, Card: %05u (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,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user