mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-29 00:09:19 +03:00
Merge branch 'dev'
This commit is contained in:
commit
1ea99d119b
@ -16,6 +16,35 @@ static bool mykey_has_lockid(const St25tbData* data) {
|
|||||||
return (data->blocks[5] & 0xFF) == 0x7F;
|
return (data->blocks[5] & 0xFF) == 0x7F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool check_invalid_low_nibble(uint8_t value) {
|
||||||
|
uint8_t value_lo = value & 0xF;
|
||||||
|
return value_lo >= 0xA;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool mykey_get_production_date(
|
||||||
|
const St25tbData* data,
|
||||||
|
uint16_t* year_ptr,
|
||||||
|
uint8_t* month_ptr,
|
||||||
|
uint8_t* day_ptr) {
|
||||||
|
uint32_t date_block = data->blocks[8];
|
||||||
|
uint8_t year = date_block >> 16 & 0xFF;
|
||||||
|
uint8_t month = date_block >> 8 & 0xFF;
|
||||||
|
uint8_t day = date_block & 0xFF;
|
||||||
|
// dates are coded in a peculiar way, the hexadecimal value should in fact be interpreted as a decimal value
|
||||||
|
// so anything in range A-F is invalid.
|
||||||
|
if(day > 0x31 || month > 0x12 || day == 0 || month == 0 || year == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(check_invalid_low_nibble(day) || check_invalid_low_nibble(month) ||
|
||||||
|
check_invalid_low_nibble(year) || check_invalid_low_nibble(year >> 4)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*year_ptr = year + 0x2000;
|
||||||
|
*month_ptr = month;
|
||||||
|
*day_ptr = day;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool mykey_parse(const NfcDevice* device, FuriString* parsed_data) {
|
static bool mykey_parse(const NfcDevice* device, FuriString* parsed_data) {
|
||||||
furi_assert(device);
|
furi_assert(device);
|
||||||
furi_assert(parsed_data);
|
furi_assert(parsed_data);
|
||||||
@ -34,7 +63,10 @@ static bool mykey_parse(const NfcDevice* device, FuriString* parsed_data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((data->blocks[8] >> 16 & 0xFF) > 0x31 || (data->blocks[8] >> 8 & 0xFF) > 0x12) {
|
uint16_t mfg_year;
|
||||||
|
uint8_t mfg_month, mfg_day;
|
||||||
|
|
||||||
|
if(!mykey_get_production_date(data, &mfg_year, &mfg_month, &mfg_day)) {
|
||||||
FURI_LOG_D(TAG, "bad mfg date");
|
FURI_LOG_D(TAG, "bad mfg date");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -56,13 +88,8 @@ static bool mykey_parse(const NfcDevice* device, FuriString* parsed_data) {
|
|||||||
furi_string_cat_printf(parsed_data, "Blank: %s\n", is_blank ? "yes" : "no");
|
furi_string_cat_printf(parsed_data, "Blank: %s\n", is_blank ? "yes" : "no");
|
||||||
furi_string_cat_printf(parsed_data, "LockID: %s\n", mykey_has_lockid(data) ? "maybe" : "no");
|
furi_string_cat_printf(parsed_data, "LockID: %s\n", mykey_has_lockid(data) ? "maybe" : "no");
|
||||||
|
|
||||||
uint32_t block8 = data->blocks[8];
|
|
||||||
furi_string_cat_printf(
|
furi_string_cat_printf(
|
||||||
parsed_data,
|
parsed_data, "Prod. date: %02X/%02X/%04X", mfg_day, mfg_month, mfg_year);
|
||||||
"Prod. date: %02lX/%02lX/%04lX",
|
|
||||||
block8 >> 16 & 0xFF,
|
|
||||||
block8 >> 8 & 0xFF,
|
|
||||||
0x2000 + (block8 & 0xFF));
|
|
||||||
|
|
||||||
if(!is_blank) {
|
if(!is_blank) {
|
||||||
furi_string_cat_printf(
|
furi_string_cat_printf(
|
||||||
|
@ -32,8 +32,7 @@
|
|||||||
#include <nfc/nfc_device.h>
|
#include <nfc/nfc_device.h>
|
||||||
#include <nfc/helpers/nfc_util.h>
|
#include <nfc/helpers/nfc_util.h>
|
||||||
#include <nfc/protocols/mf_classic/mf_classic_poller_sync.h>
|
#include <nfc/protocols/mf_classic/mf_classic_poller_sync.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <furi_hal_rtc.h>
|
#include <furi_hal_rtc.h>
|
||||||
|
|
||||||
#define TAG "Umarsh"
|
#define TAG "Umarsh"
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <nfc/nfc_device.h>
|
#include <nfc/nfc_device.h>
|
||||||
#include <nfc/helpers/nfc_util.h>
|
#include <nfc/helpers/nfc_util.h>
|
||||||
#include <nfc/protocols/mf_classic/mf_classic_poller_sync.h>
|
#include <nfc/protocols/mf_classic/mf_classic_poller_sync.h>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#define TAG "WashCity"
|
#define TAG "WashCity"
|
||||||
|
|
||||||
@ -158,18 +157,12 @@ static bool washcity_parse(const NfcDevice* device, FuriString* parsed_data) {
|
|||||||
const uint8_t* uid = mf_classic_get_uid(data, &uid_len);
|
const uint8_t* uid = mf_classic_get_uid(data, &uid_len);
|
||||||
|
|
||||||
// Card Number is printed in HEX (equal to UID)
|
// Card Number is printed in HEX (equal to UID)
|
||||||
char card_number[2 * uid_len + 1];
|
uint64_t card_number = nfc_util_bytes2num(uid, uid_len);
|
||||||
|
|
||||||
for(size_t i = 0; i < uid_len; ++i) {
|
|
||||||
card_number[2 * i] = "0123456789ABCDEF"[uid[i] >> 4];
|
|
||||||
card_number[2 * i + 1] = "0123456789ABCDEF"[uid[i] & 0xF];
|
|
||||||
}
|
|
||||||
|
|
||||||
card_number[2 * uid_len] = '\0';
|
|
||||||
|
|
||||||
furi_string_printf(
|
furi_string_printf(
|
||||||
parsed_data,
|
parsed_data,
|
||||||
"\e#WashCity\nCard number: %s\nBalance: %lu.%02u EUR",
|
"\e#WashCity\nCard number: %0*llX\nBalance: %lu.%02u EUR",
|
||||||
|
uid_len * 2,
|
||||||
card_number,
|
card_number,
|
||||||
balance_eur,
|
balance_eur,
|
||||||
balance_cents);
|
balance_cents);
|
||||||
|
@ -28,8 +28,11 @@ bool nfc_scene_mf_ultralight_write_success_on_event(void* context, SceneManagerE
|
|||||||
|
|
||||||
if(event.type == SceneManagerEventTypeCustom) {
|
if(event.type == SceneManagerEventTypeCustom) {
|
||||||
if(event.event == NfcCustomEventViewExit) {
|
if(event.event == NfcCustomEventViewExit) {
|
||||||
|
bool was_saved =
|
||||||
|
scene_manager_has_previous_scene(instance->scene_manager, NfcSceneSavedMenu);
|
||||||
|
|
||||||
consumed = scene_manager_search_and_switch_to_previous_scene(
|
consumed = scene_manager_search_and_switch_to_previous_scene(
|
||||||
instance->scene_manager, NfcSceneSavedMenu);
|
instance->scene_manager, was_saved ? NfcSceneSavedMenu : NfcSceneReadSuccess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return consumed;
|
return consumed;
|
||||||
|
@ -365,7 +365,7 @@ for template_file in project_template_dir.Dir(".vscode").glob("*"):
|
|||||||
"@UFBT_TOOLCHAIN_OPENOCD@": _path_as_posix(dist_env.WhereIs("openocd")),
|
"@UFBT_TOOLCHAIN_OPENOCD@": _path_as_posix(dist_env.WhereIs("openocd")),
|
||||||
"@UFBT_APP_DIR@": _path_as_posix(original_app_dir.abspath),
|
"@UFBT_APP_DIR@": _path_as_posix(original_app_dir.abspath),
|
||||||
"@UFBT_ROOT_DIR@": _path_as_posix(Dir("#").abspath),
|
"@UFBT_ROOT_DIR@": _path_as_posix(Dir("#").abspath),
|
||||||
"@UFBT_DEBUG_DIR@": dist_env["FBT_DEBUG_DIR"],
|
"@UFBT_DEBUG_DIR@": _path_as_posix(dist_env["FBT_DEBUG_DIR"].abspath),
|
||||||
"@UFBT_DEBUG_ELF_DIR@": _path_as_posix(
|
"@UFBT_DEBUG_ELF_DIR@": _path_as_posix(
|
||||||
dist_env["FBT_FAP_DEBUG_ELF_ROOT"].abspath
|
dist_env["FBT_FAP_DEBUG_ELF_ROOT"].abspath
|
||||||
),
|
),
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
"configurationProvider": "ms-vscode.cpptools",
|
"configurationProvider": "ms-vscode.cpptools",
|
||||||
"cStandard": "gnu17",
|
"cStandard": "gnu17",
|
||||||
"cppStandard": "c++17"
|
"cppStandard": "c++17"
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
"version": 4
|
"version": 4
|
||||||
}
|
}
|
@ -1,3 +1,7 @@
|
|||||||
|
// This file is autogeneated by the ufbt.
|
||||||
|
// You can modify it, and it will not be overwritten if exists.
|
||||||
|
// Some paths are absolute, and will need to be updated if you move the project.
|
||||||
|
// To regenerate the file, delete it and run `ufbt vscode_dist` again.
|
||||||
{
|
{
|
||||||
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
|
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
|
||||||
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
|
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// This file is autogeneated by the ufbt.
|
||||||
|
// You can modify it, and it will not be overwritten if exists.
|
||||||
|
// Some paths are absolute, and will need to be updated if you move the project.
|
||||||
|
// To regenerate the file, delete it and run `ufbt vscode_dist` again.
|
||||||
{
|
{
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// This file is autogeneated by the ufbt.
|
||||||
|
// You can modify it, and it will not be overwritten if exists.
|
||||||
|
// Some paths are absolute, and will need to be updated if you move the project.
|
||||||
|
// To regenerate the file, delete it and run `ufbt vscode_dist` again.
|
||||||
{
|
{
|
||||||
"cortex-debug.enableTelemetry": false,
|
"cortex-debug.enableTelemetry": false,
|
||||||
"cortex-debug.variableUseNaturalFormat": false,
|
"cortex-debug.variableUseNaturalFormat": false,
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// This file is autogeneated by the ufbt.
|
||||||
|
// You can modify it, and it will not be overwritten if exists.
|
||||||
|
// Some paths are absolute, and will need to be updated if you move the project.
|
||||||
|
// To regenerate the file, delete it and run `ufbt vscode_dist` again.
|
||||||
{
|
{
|
||||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
// for the documentation about the tasks.json format
|
// for the documentation about the tasks.json format
|
||||||
|
Loading…
Reference in New Issue
Block a user