#pragma once #include #include #include struct bpreader_config { bool enable; uint16_t port; wchar_t access_code[21]; }; HRESULT bpreader_init(struct bpreader_config *cfg, uint16_t port); void bpreader_congif_load(struct bpreader_config *cfg, const wchar_t *filename); /* bpreader packet format WIP n = final offset | Offset | Meaning | |--------|--------------------------------------------------------------------| | 0 | Always 00 | | 1 | Always 00 | | 2 | Always FF | Header | 3 | len(Data), 0 means no data | | 4 | FF - ((sum of header bytes) & FF) if data is present | |--------|--------------------------------------------------------------------| | 5 | Always D5 (resp) or D4 (req) if data is present, identifier? | | 6 | Command if data is present | Data | 7..n-2 | Data if data is present | |--------|--------------------------------------------------------------------| | n-1 | FF - ((sum of head + data bytes) & FF) if data is present, else FF | Footer | n | Always 00 | Commands | Command | Response | Meaning | Response Data (not including leading 0xD5) | |---------|----------|----------------------------------------------------|------------------------------------------------------------------------| | 0x00 | 0x00 | Wait Next Command | None | | 0x02 | 0x05 | Unknown | 0x0D, 0x00, 0x06, 0x00 | | 0x03 | 0x02 | Unknown, first command and then sent randomly | 0x19 | | 0x04 | 0x02 | Unknown, only command seen to change it's req data | 0x0F/0x33 | | 0x05 | 0x03 | Unknown | 0x09, 0x00 | | 0x06 | 0x02 | Unknown | 0x0F | | 0x09 | 0x18 | Poll for card | 0x4B, 0x01, 0x01, 0x14, 0x01, [IDm], [PMm], [Sys Code] | | 0x0E | 0x02 | Unknown | 0x33 | | 0x12 | 0x0A | Unknown | 0x07, 0xFF, 0x3F, 0x0E, 0xF1, 0xFF, 0x3F, 0x0E, 0xF1 | | 0x14 | 0x20 | Unknown | a lot, see bpreader.c | | 0x18 | 0x0D | Unknown | 0x07, 0xDC, 0xF4, 0x3F, 0x11, 0x4D, 0x85, 0x61, 0xF1, 0x26, 0x6A, 0x87 | */ struct bpreader_cmd_header { uint8_t padding0_00; uint8_t padding1_00; uint8_t padding2_ff; uint8_t data_len; uint8_t header_checksum; uint8_t d_identifier; uint8_t cmd; }; struct bpreader_cmd_footer { uint8_t checksum; uint8_t padding; };