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