Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions firmware/application/src/rfid/nfctag/lf/protocols/wiegand.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define PREAMBLE_34BIT (0x009)
#define PREAMBLE_35BIT (0x005)
#define PREAMBLE_36BIT (0x003)
#define PREAMBLE_ACTP (0x095)

/**@brief Set a bit in the uint64 word.
*
Expand Down Expand Up @@ -548,6 +549,37 @@ static wiegand_card_t *unpack_c15001(uint64_t hi, uint64_t lo) {
return d;
}

static uint64_t pack_actprox(wiegand_card_t *card) {
if (card->oem == 0) {
card->oem = 900;
}
uint64_t bits = PREAMBLE_ACTP;
bits <<= 1;
bits = (bits << 10) | (card->oem & 0x3ff);
bits = (bits << 8) | (card->facility_code & 0xff);
bits = (bits << 16) | (card->card_number & 0xffff);
bits <<= 1;
if (evenparity32((bits >> 18) & 0x1ffff)) {
SET_BIT64(bits, 35);
}
if (oddparity32((bits >> 1) & 0x1ffff)) {
SET_BIT64(bits, 0);
}
return bits;
}

static wiegand_card_t *unpack_actprox(uint64_t hi, uint64_t lo) {
if (!(IS_SET(lo, 35) == evenparity32((lo >> 18) & 0x1ffff) &&
IS_SET(lo, 0) == oddparity32((lo >> 1) & 0x1ffff))) {
return NULL;
}
wiegand_card_t *d = wiegand_card_alloc();
d->oem = (lo >> 25) & 0x3ff;
d->facility_code = (lo >> 17) & 0xff;
d->card_number = (lo >> 1) & 0xffff;
return d;
}

static uint64_t pack_s12906(wiegand_card_t *card) {
uint64_t bits = PREAMBLE_36BIT;
bits <<= 1;
Expand Down Expand Up @@ -819,6 +851,7 @@ static const card_format_table_t formats[] = {
{P10004, pack_p10004, unpack_p10004, 37, {0, 0x1FFF, 0x3FFFF, 0, 0}}, // HID P10004 37-bit PCSC
{HGEN37, pack_hgeneric37, unpack_hgeneric37, 37, {1, 0, 0xFFFFFFFF, 0, 0}}, // HID Generic 37-bit
{MDI37, pack_mdi37, unpack_mdi37, 37, {1, 0xF, 0x1FFFFFFF, 0, 0}}, // PointGuard MDI 37-bit
{ACTPHID, pack_actprox, unpack_actprox, 36, {1, 0xFF, 0xFFFF, 0x3FF, 0}}, // HID ACTProx 36-bit
};

uint64_t pack(wiegand_card_t *card) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ typedef enum {
C1K48S,
AVIG56,
IR56,
ACTPHID,
} card_format_t;

// Structure for defined Wiegand card formats available for packing/unpacking
Expand Down
21 changes: 11 additions & 10 deletions software/script/chameleon_cli_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def before_exec(self, args: argparse.Namespace):
if ret:
return True
else:
print("Please connect to chameleon device first(use 'hw connect').")
print("Please connect to chameleon device first (use 'hw connect').")
return False


Expand Down Expand Up @@ -453,6 +453,7 @@ def check_limits(format: int, fc: Union[int, None], cn: Union[int, None], il: Un
HIDFormat.C1K35S: [0xFFF, 0xFFFFF, 0, 0],
HIDFormat.C15001: [0xFF, 0xFFFF, 0, 0x3FF],
HIDFormat.S12906: [0xFF, 0xFFFFFF, 0x3, 0],
HIDFormat.ACTPHID: [0xFF, 0xFFFFFF, 0, 0x3FF],
HIDFormat.SIE36: [0x3FFFF, 0xFFFF, 0, 0],
HIDFormat.H10320: [0, 99999999, 0, 0],
HIDFormat.H10302: [0, 0x7FFFFFFFF, 0, 0],
Expand Down Expand Up @@ -3678,19 +3679,19 @@ def on_exec(self, args: argparse.Namespace):
format = HIDFormat[args.format]
id = struct.pack(">BIBIBH", format.value, args.fc, (args.cn >> 32), args.cn & 0xffffffff, args.il, args.oem)
self.cmd.hidprox_set_emu_id(id)
print(' - Set hidprox tag id success.')
print(' - SET hidprox tag id success.')
else:
(format, fc, cn1, cn2, il, oem) = self.cmd.hidprox_get_emu_id()
cn = (cn1 << 32) + cn2
print(' - Get hidprox tag id success.')
print(' - GET hidprox tag id success.')
print(f" - HIDProx/{HIDFormat(format)}")
if fc > 0:
print(f" FC: {color_string((CG, fc))}")
if il > 0:
print(f" IL: {color_string((CG, il))}")
if oem > 0:
print(f" OEM: {color_string((CG, oem))}")
print(f" CN: {color_string((CG, cn))}")
if fc > 0:
print(f" FC: {color_string((CG, fc))}")
if il > 0:
print(f" IL: {color_string((CG, il))}")
if oem > 0:
print(f" OEM: {color_string((CG, oem))}")
print(f" CN: {color_string((CG, cn))}")

@lf_viking.command('read')
class LFVikingRead(ReaderRequiredUnit):
Expand Down
2 changes: 2 additions & 0 deletions software/script/chameleon_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ class HIDFormat(enum.IntEnum):
C1K35S = 21
C15001 = 22
S12906 = 23
ACTPHID = 42
SIE36 = 24
H10320 = 25
H10302 = 26
Expand Down Expand Up @@ -614,6 +615,7 @@ def __str__(self):
HIDFormat.C1K35S: "HID Corporate 1000 35-bit Std",
HIDFormat.C15001: "HID KeyScan 36-bit",
HIDFormat.S12906: "HID Simplex 36-bit",
HIDFormat.ACTPHID: "HID ACTProx 36-bit",
HIDFormat.SIE36: "HID 36-bit Siemens",
HIDFormat.H10320: "HID H10320 37-bit BCD",
HIDFormat.H10302: "HID H10302 37-bit huge ID",
Expand Down
Loading