mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-27 03:49:58 -07:00
Kostyly for iso14443-4a poller (pwt_ext)
Co-authored-by: Nikita Vostokov <1042932+wosk@users.noreply.github.com>
This commit is contained in:
@@ -7,6 +7,18 @@
|
||||
#define ISO14443_4_BLOCK_PCB_R (5U << 5)
|
||||
#define ISO14443_4_BLOCK_PCB_S (3U << 6)
|
||||
|
||||
//KOSTYLY
|
||||
#define ISO14443_4_BLOCK_PCB_I_ (0U << 6)
|
||||
#define ISO14443_4_BLOCK_PCB_R_ (2U << 6)
|
||||
#define ISO14443_4_BLOCK_PCB_TYPE_MASK (3U << 6)
|
||||
#define ISO14443_4_BLOCK_PCB_S_DESELECT (0U << 4)
|
||||
#define ISO14443_4_BLOCK_PCB_S_WTX (3U << 4)
|
||||
#define ISO14443_4_BLOCK_PCB_BLOCK_NUMBER (1U << 0)
|
||||
#define ISO14443_4_BLOCK_PCB (1U << 1)
|
||||
#define ISO14443_4_BLOCK_PCB_NAD (1U << 2)
|
||||
#define ISO14443_4_BLOCK_PCB_CID (1U << 3)
|
||||
#define ISO14443_4_BLOCK_PCB_CHAINING (1U << 4)
|
||||
|
||||
struct Iso14443_4Layer {
|
||||
uint8_t pcb;
|
||||
uint8_t pcb_prev;
|
||||
@@ -62,3 +74,48 @@ bool iso14443_4_layer_decode_block(
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Iso14443_4aError iso14443_4_layer_decode_block_pwt_ext(
|
||||
Iso14443_4Layer* instance,
|
||||
BitBuffer* output_data,
|
||||
const BitBuffer* block_data) {
|
||||
furi_assert(instance);
|
||||
|
||||
Iso14443_4aError ret = Iso14443_4aErrorProtocol;
|
||||
|
||||
do {
|
||||
const uint8_t pcb_field = bit_buffer_get_byte(block_data, 0);
|
||||
const uint8_t block_type = pcb_field & ISO14443_4_BLOCK_PCB_TYPE_MASK;
|
||||
switch(block_type) {
|
||||
case ISO14443_4_BLOCK_PCB_I_:
|
||||
if(pcb_field == instance->pcb_prev) {
|
||||
bit_buffer_copy_right(output_data, block_data, 1);
|
||||
ret = Iso14443_4aErrorNone;
|
||||
} else {
|
||||
// TODO: Need send request again
|
||||
ret = Iso14443_4aErrorProtocol;
|
||||
}
|
||||
break;
|
||||
case ISO14443_4_BLOCK_PCB_R_:
|
||||
// TODO
|
||||
break;
|
||||
case ISO14443_4_BLOCK_PCB_S:
|
||||
if((pcb_field & ISO14443_4_BLOCK_PCB_S_WTX) == ISO14443_4_BLOCK_PCB_S_WTX) {
|
||||
const uint8_t inf_field = bit_buffer_get_byte(block_data, 1);
|
||||
//const uint8_t power_level = inf_field >> 6;
|
||||
const uint8_t wtxm = inf_field & 0b111111;
|
||||
//uint32_t fwt_temp = MIN((fwt * wtxm), fwt_max);
|
||||
|
||||
bit_buffer_reset(output_data);
|
||||
bit_buffer_append_byte(
|
||||
output_data,
|
||||
ISO14443_4_BLOCK_PCB_S | ISO14443_4_BLOCK_PCB_S_WTX | ISO14443_4_BLOCK_PCB);
|
||||
bit_buffer_append_byte(output_data, wtxm);
|
||||
ret = Iso14443_4aErrorSendCtrl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while(false);
|
||||
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user