mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-22 12:33:11 +00:00
Merge remote-tracking branch 'OFW/dev' into dev
This commit is contained in:
commit
7711b2daae
4 changed files with 31 additions and 26 deletions
|
@ -117,7 +117,7 @@ static void nfc_scene_read_menu_on_enter_mf_classic(NfcApp* instance) {
|
|||
if(!mf_classic_is_card_read(data)) {
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Detect Reader",
|
||||
"Extract MF Keys",
|
||||
SubmenuIndexDetectReader,
|
||||
nfc_protocol_support_common_submenu_callback,
|
||||
instance);
|
||||
|
@ -155,7 +155,7 @@ static void nfc_scene_saved_menu_on_enter_mf_classic(NfcApp* instance) {
|
|||
if(!mf_classic_is_card_read(data)) {
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Detect Reader",
|
||||
"Extract MF Keys",
|
||||
SubmenuIndexDetectReader,
|
||||
nfc_protocol_support_common_submenu_callback,
|
||||
instance);
|
||||
|
|
|
@ -29,7 +29,11 @@ void nfc_scene_start_on_enter(void* context) {
|
|||
|
||||
submenu_add_item(submenu, "Read", SubmenuIndexRead, nfc_scene_start_submenu_callback, nfc);
|
||||
submenu_add_item(
|
||||
submenu, "Detect Reader", SubmenuIndexDetectReader, nfc_scene_start_submenu_callback, nfc);
|
||||
submenu,
|
||||
"Extract MF Keys",
|
||||
SubmenuIndexDetectReader,
|
||||
nfc_scene_start_submenu_callback,
|
||||
nfc);
|
||||
submenu_add_item(submenu, "Saved", SubmenuIndexSaved, nfc_scene_start_submenu_callback, nfc);
|
||||
submenu_add_item(
|
||||
submenu, "Extra Actions", SubmenuIndexExtraAction, nfc_scene_start_submenu_callback, nfc);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "kernel.h"
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <event_groups.h>
|
||||
#include <timers.h>
|
||||
|
||||
struct FuriTimer {
|
||||
|
@ -14,6 +15,8 @@ struct FuriTimer {
|
|||
// IMPORTANT: container MUST be the FIRST struct member
|
||||
static_assert(offsetof(FuriTimer, container) == 0);
|
||||
|
||||
#define TIMER_DELETED_EVENT (1U << 0)
|
||||
|
||||
static void TimerCallback(TimerHandle_t hTimer) {
|
||||
FuriTimer* instance = pvTimerGetTimerID(hTimer);
|
||||
furi_check(instance);
|
||||
|
@ -41,8 +44,8 @@ static void furi_timer_epilogue(void* context, uint32_t arg) {
|
|||
furi_assert(context);
|
||||
UNUSED(arg);
|
||||
|
||||
volatile bool* can_be_removed = context;
|
||||
*can_be_removed = true;
|
||||
EventGroupHandle_t hEvent = context;
|
||||
xEventGroupSetBits(hEvent, TIMER_DELETED_EVENT);
|
||||
}
|
||||
|
||||
void furi_timer_free(FuriTimer* instance) {
|
||||
|
@ -52,14 +55,12 @@ void furi_timer_free(FuriTimer* instance) {
|
|||
TimerHandle_t hTimer = (TimerHandle_t)instance;
|
||||
furi_check(xTimerDelete(hTimer, portMAX_DELAY) == pdPASS);
|
||||
|
||||
volatile bool can_be_removed = false;
|
||||
furi_check(
|
||||
xTimerPendFunctionCall(furi_timer_epilogue, (void*)&can_be_removed, 0, portMAX_DELAY) ==
|
||||
pdPASS);
|
||||
StaticEventGroup_t event_container;
|
||||
EventGroupHandle_t hEvent = xEventGroupCreateStatic(&event_container);
|
||||
furi_check(xTimerPendFunctionCall(furi_timer_epilogue, hEvent, 0, portMAX_DELAY) == pdPASS);
|
||||
|
||||
while(!can_be_removed) {
|
||||
furi_delay_tick(2);
|
||||
}
|
||||
xEventGroupWaitBits(hEvent, TIMER_DELETED_EVENT, 0, pdTRUE, portMAX_DELAY);
|
||||
vEventGroupDelete(hEvent);
|
||||
|
||||
free(instance);
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ bool wiegand_check(uint64_t fc_and_card, bool even_parity, bool odd_parity, int
|
|||
if(odd_parity_sum % 2 != odd_parity) return false;
|
||||
break;
|
||||
default:
|
||||
furi_crash();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -150,23 +151,22 @@ static bool protocol_gproxii_can_be_decoded(ProtocolGProxII* protocol) {
|
|||
// Check card length is either 26 or 36
|
||||
int card_len = bit_lib_get_bits(protocol->decoded_data, 8, 6);
|
||||
|
||||
if(card_len == 26 || card_len == 36) {
|
||||
// wiegand parity
|
||||
if(card_len == 26) {
|
||||
uint64_t fc_and_card = bit_lib_get_bits_64(protocol->decoded_data, 33, 24);
|
||||
bool even_parity = bit_lib_get_bits(protocol->decoded_data, 32, 1);
|
||||
bool odd_parity = bit_lib_get_bits(protocol->decoded_data, 57, 1);
|
||||
if(!wiegand_check(fc_and_card, even_parity, odd_parity, card_len)) return false;
|
||||
} else if(card_len == 36) {
|
||||
uint64_t fc_and_card = bit_lib_get_bits_64(protocol->decoded_data, 33, 34);
|
||||
uint8_t even_parity = bit_lib_get_bits(protocol->decoded_data, 32, 1);
|
||||
uint8_t odd_parity = bit_lib_get_bits(protocol->decoded_data, 67, 1);
|
||||
if(!wiegand_check(fc_and_card, even_parity, odd_parity, card_len)) return false;
|
||||
}
|
||||
return true;
|
||||
// wiegand parity
|
||||
if(card_len == 26) {
|
||||
uint64_t fc_and_card = bit_lib_get_bits_64(protocol->decoded_data, 33, 24);
|
||||
bool even_parity = bit_lib_get_bits(protocol->decoded_data, 32, 1);
|
||||
bool odd_parity = bit_lib_get_bits(protocol->decoded_data, 57, 1);
|
||||
if(!wiegand_check(fc_and_card, even_parity, odd_parity, card_len)) return false;
|
||||
} else if(card_len == 36) {
|
||||
uint64_t fc_and_card = bit_lib_get_bits_64(protocol->decoded_data, 33, 34);
|
||||
uint8_t even_parity = bit_lib_get_bits(protocol->decoded_data, 32, 1);
|
||||
uint8_t odd_parity = bit_lib_get_bits(protocol->decoded_data, 67, 1);
|
||||
if(!wiegand_check(fc_and_card, even_parity, odd_parity, card_len)) return false;
|
||||
} else {
|
||||
return false; // If we don't get a 26 or 36 it's not a known card type
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool protocol_gproxii_decoder_feed(ProtocolGProxII* protocol, bool level, uint32_t duration) {
|
||||
|
|
Loading…
Reference in a new issue