1
0
mirror of synced 2024-11-23 21:40:58 +01:00
bananatools/board/bpreader.h
2023-09-25 03:16:26 -04:00

80 lines
2.4 KiB
C

#pragma once
#include <windows.h>
#include <stdint.h>
#include <stdbool.h>
struct bpreader_config {
bool enable;
uint16_t port;
uint8_t insert_card;
wchar_t access_code[21];
uint8_t access_code_bytes[10];
};
HRESULT bpreader_init(struct bpreader_config *cfg, uint16_t port);
/*
bpreader packet format WIP
maybe rcs956?
Response packet
| Offset | Meaning |
|--------|--------------------------------------------------------------------|
| 0 | Preamble, Always 00 |
| 1 | Packet start, Always 00 |
| 2 | Always FF | Header
| 3 | len(Data), 0 means no data |
| 4 | (0x100 - data_len) & FF if data is present |
|--------|--------------------------------------------------------------------|
| 5 | Always 0xD5 (success) or 0x7F (failure) |
| 6 | Command if data is present | Data
| 7..n-2 | Data if data is present |
|--------|--------------------------------------------------------------------|
| n-1 | (FF - sum of data bytes) & FF if data is present, else FF | Footer
| n | Postamble, Always 00 |
*/
#pragma pack(push, 1)
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;
};
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];
};
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];
};
#pragma pack(pop)