2023-01-03 05:35:53 +01:00
|
|
|
#pragma once
|
|
|
|
#include <windows.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
struct bpreader_config {
|
|
|
|
bool enable;
|
2023-03-16 06:45:39 +01:00
|
|
|
uint16_t port;
|
2023-09-25 09:16:26 +02:00
|
|
|
uint8_t insert_card;
|
2023-03-16 06:45:39 +01:00
|
|
|
wchar_t access_code[21];
|
2023-04-13 08:30:56 +02:00
|
|
|
uint8_t access_code_bytes[10];
|
2023-01-03 05:35:53 +01:00
|
|
|
};
|
|
|
|
|
2023-03-16 06:45:39 +01:00
|
|
|
HRESULT bpreader_init(struct bpreader_config *cfg, uint16_t port);
|
2023-03-24 07:46:38 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
bpreader packet format WIP
|
2023-09-25 09:16:26 +02:00
|
|
|
maybe rcs956?
|
|
|
|
Response packet
|
2023-03-24 07:46:38 +01:00
|
|
|
| Offset | Meaning |
|
|
|
|
|--------|--------------------------------------------------------------------|
|
2023-09-25 09:16:26 +02:00
|
|
|
| 0 | Preamble, Always 00 |
|
|
|
|
| 1 | Packet start, Always 00 |
|
2023-03-24 07:46:38 +01:00
|
|
|
| 2 | Always FF | Header
|
|
|
|
| 3 | len(Data), 0 means no data |
|
2023-09-25 09:16:26 +02:00
|
|
|
| 4 | (0x100 - data_len) & FF if data is present |
|
2023-03-24 07:46:38 +01:00
|
|
|
|--------|--------------------------------------------------------------------|
|
2023-09-25 09:16:26 +02:00
|
|
|
| 5 | Always 0xD5 (success) or 0x7F (failure) |
|
2023-03-24 07:46:38 +01:00
|
|
|
| 6 | Command if data is present | Data
|
|
|
|
| 7..n-2 | Data if data is present |
|
|
|
|
|--------|--------------------------------------------------------------------|
|
2023-09-25 09:16:26 +02:00
|
|
|
| n-1 | (FF - sum of data bytes) & FF if data is present, else FF | Footer
|
|
|
|
| n | Postamble, Always 00 |
|
2023-03-24 07:46:38 +01:00
|
|
|
*/
|
|
|
|
|
2023-07-22 05:44:59 +02:00
|
|
|
#pragma pack(push, 1)
|
2023-03-24 07:46:38 +01:00
|
|
|
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;
|
|
|
|
};
|
2023-04-13 08:30:56 +02:00
|
|
|
|
2023-09-25 09:16:26 +02:00
|
|
|
struct bpreader_read_mifare_req {
|
|
|
|
uint8_t unk0;
|
|
|
|
uint8_t subcmd; // 0x30 for read, 0x60/61 for write?
|
|
|
|
uint8_t block;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bpreader_read_mifare_resp_data {
|
|
|
|
uint8_t padding;
|
|
|
|
uint8_t block[16];
|
|
|
|
};
|
|
|
|
|
2023-04-13 08:30:56 +02:00
|
|
|
struct bpreader_poll_banapass_data {
|
|
|
|
uint8_t card_present;
|
|
|
|
uint8_t unknown1; // 0x01
|
|
|
|
uint8_t atqa[2];
|
|
|
|
uint8_t sak;
|
|
|
|
uint8_t unknown5; // 0x04
|
|
|
|
uint8_t serial_number[4]; // first 4 bytes of Chip ID
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bpreader_poll_felica_data {
|
|
|
|
uint8_t card_present;
|
|
|
|
uint8_t unknown1; // 0x01
|
|
|
|
uint8_t unknown2[2]; // 0x14, 0x01
|
|
|
|
uint8_t idm[8];
|
|
|
|
uint8_t pmm[8];
|
|
|
|
uint8_t system_code[2];
|
|
|
|
};
|
2023-07-22 05:44:59 +02:00
|
|
|
#pragma pack(pop)
|