1
0
mirror of synced 2024-11-27 17:11:01 +01:00

格式调整

This commit is contained in:
Sucareto 2023-07-02 02:40:19 +08:00
parent 7622d91901
commit cc3d09256e
2 changed files with 97 additions and 104 deletions

View File

@ -58,14 +58,12 @@ uint8_t KeyA[6], KeyB[6];
enum { enum {
CMD_GET_FW_VERSION = 0x30, CMD_GET_FW_VERSION = 0x30,
CMD_GET_HW_VERSION = 0x32, CMD_GET_HW_VERSION = 0x32,
// Card read // Card read
CMD_START_POLLING = 0x40, CMD_START_POLLING = 0x40,
CMD_STOP_POLLING = 0x41, CMD_STOP_POLLING = 0x41,
CMD_CARD_DETECT = 0x42, CMD_CARD_DETECT = 0x42,
CMD_CARD_SELECT = 0x43, CMD_CARD_SELECT = 0x43,
CMD_CARD_HALT = 0x44, CMD_CARD_HALT = 0x44,
// MIFARE // MIFARE
CMD_MIFARE_KEY_SET_A = 0x50, CMD_MIFARE_KEY_SET_A = 0x50,
CMD_MIFARE_AUTHORIZE_A = 0x51, CMD_MIFARE_AUTHORIZE_A = 0x51,
@ -73,24 +71,20 @@ enum {
CMD_MIFARE_WRITE = 0x53, CMD_MIFARE_WRITE = 0x53,
CMD_MIFARE_KEY_SET_B = 0x54, CMD_MIFARE_KEY_SET_B = 0x54,
CMD_MIFARE_AUTHORIZE_B = 0x55, CMD_MIFARE_AUTHORIZE_B = 0x55,
// Boot,update // Boot,update
CMD_TO_UPDATER_MODE = 0x60, CMD_TO_UPDATER_MODE = 0x60,
CMD_SEND_HEX_DATA = 0x61, CMD_SEND_HEX_DATA = 0x61,
CMD_TO_NORMAL_MODE = 0x62, CMD_TO_NORMAL_MODE = 0x62,
CMD_SEND_BINDATA_INIT = 0x63, CMD_SEND_BINDATA_INIT = 0x63,
CMD_SEND_BINDATA_EXEC = 0x64, CMD_SEND_BINDATA_EXEC = 0x64,
// FeliCa // FeliCa
CMD_FELICA_PUSH = 0x70, CMD_FELICA_PUSH = 0x70,
CMD_FELICA_THROUGH = 0x71, CMD_FELICA_THROUGH = 0x71,
CMD_FELICA_THROUGH_POLL = 0x00, CMD_FELICA_THROUGH_POLL = 0x00,
CMD_FELICA_THROUGH_READ = 0x06, CMD_FELICA_THROUGH_READ = 0x06,
CMD_FELICA_THROUGH_WRITE = 0x08, CMD_FELICA_THROUGH_WRITE = 0x08,
CMD_FELICA_THROUGH_GET_SYSTEM_CODE = 0x0C, CMD_FELICA_THROUGH_GET_SYSTEM_CODE = 0x0C,
CMD_FELICA_THROUGH_NDA_A4 = 0xA4, CMD_FELICA_THROUGH_NDA_A4 = 0xA4,
// LED board // LED board
CMD_EXT_BOARD_LED = 0x80, CMD_EXT_BOARD_LED = 0x80,
CMD_EXT_BOARD_LED_RGB = 0x81, CMD_EXT_BOARD_LED_RGB = 0x81,
@ -142,8 +136,8 @@ typedef union {
uint8_t numService; uint8_t numService;
uint8_t serviceCodeList[2]; uint8_t serviceCodeList[2];
uint8_t numBlock; uint8_t numBlock;
uint8_t blockList[1][2]; // CMD_FELICA_THROUGH_READ uint8_t blockList[1][2]; // CMD_FELICA_THROUGH_READ
uint8_t blockData[16]; // CMD_FELICA_THROUGH_WRITE uint8_t blockData[16]; // CMD_FELICA_THROUGH_WRITE
}; };
uint8_t felica_payload[1]; uint8_t felica_payload[1];
}; };
@ -340,7 +334,7 @@ void nfc_mifare_read() {
res_init(0x10); res_init(0x10);
if (!nfc.mifareclassic_ReadDataBlock(req.block_no, res.block)) { if (!nfc.mifareclassic_ReadDataBlock(req.block_no, res.block)) {
res_init(); res_init();
res.status = ERROR_CARD_DETECT_TIMEOUT; // TODO res.status = ERROR_CARD_DETECT_TIMEOUT;
} }
} }

View File

@ -1,95 +1,94 @@
#define high_baudrate #define high_baudrate
#include "Aime_Reader.h"
#include "Aime_Redaer.h"
void setup() {
void setup() { FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS); FastLED.setBrightness(50);
FastLED.setBrightness(50); FastLED.showColor(0);
FastLED.showColor(0); nfc.begin();
nfc.begin(); while (!nfc.getFirmwareVersion()) {
while (!nfc.getFirmwareVersion()) { FastLED.showColor(0xFF0000);
FastLED.showColor(0xFF0000); delay(500);
delay(500); FastLED.showColor(0);
FastLED.showColor(0); delay(500);
delay(500); }
} nfc.setPassiveActivationRetries(0x10);
nfc.setPassiveActivationRetries(0x10); nfc.SAMConfig();
nfc.SAMConfig(); memset(req.bytes, 0, sizeof(req.bytes));
memset(req.bytes, 0, sizeof(req.bytes)); memset(res.bytes, 0, sizeof(res.bytes));
memset(res.bytes, 0, sizeof(res.bytes));
SerialDevice.begin(baudrate);
SerialDevice.begin(baudrate); FastLED.showColor(BootColor);
FastLED.showColor(BootColor); }
}
void loop() {
void loop() { switch (packet_read()) {
switch (packet_read()) { case 0:
case 0: break;
break;
case CMD_TO_NORMAL_MODE:
case CMD_TO_NORMAL_MODE: sys_to_normal_mode();
sys_to_normal_mode(); break;
break; case CMD_GET_FW_VERSION:
case CMD_GET_FW_VERSION: sys_get_fw_version();
sys_get_fw_version(); break;
break; case CMD_GET_HW_VERSION:
case CMD_GET_HW_VERSION: sys_get_hw_version();
sys_get_hw_version(); break;
break;
// Card read
// Card read case CMD_START_POLLING:
case CMD_START_POLLING: nfc_start_polling();
nfc_start_polling(); break;
break; case CMD_STOP_POLLING:
case CMD_STOP_POLLING: nfc_stop_polling();
nfc_stop_polling(); break;
break; case CMD_CARD_DETECT:
case CMD_CARD_DETECT: nfc_card_detect();
nfc_card_detect(); break;
break;
// MIFARE
// MIFARE case CMD_MIFARE_KEY_SET_A:
case CMD_MIFARE_KEY_SET_A: memcpy(KeyA, req.key, 6);
memcpy(KeyA, req.key, 6); res_init();
res_init(); break;
break;
case CMD_MIFARE_KEY_SET_B:
case CMD_MIFARE_KEY_SET_B: res_init();
res_init(); memcpy(KeyB, req.key, 6);
memcpy(KeyB, req.key, 6); break;
break;
case CMD_MIFARE_AUTHORIZE_A:
case CMD_MIFARE_AUTHORIZE_A: nfc_mifare_authorize_a();
nfc_mifare_authorize_a(); break;
break;
case CMD_MIFARE_AUTHORIZE_B:
case CMD_MIFARE_AUTHORIZE_B: nfc_mifare_authorize_b();
nfc_mifare_authorize_b(); break;
break;
case CMD_MIFARE_READ:
case CMD_MIFARE_READ: nfc_mifare_read();
nfc_mifare_read(); break;
break;
// FeliCa
// FeliCa case CMD_FELICA_THROUGH:
case CMD_FELICA_THROUGH: nfc_felica_through();
nfc_felica_through(); break;
break;
// LED
// LED case CMD_EXT_BOARD_LED_RGB:
case CMD_EXT_BOARD_LED_RGB: FastLED.showColor(CRGB(req.color_payload[0], req.color_payload[1], req.color_payload[2]));
FastLED.showColor(CRGB(req.color_payload[0], req.color_payload[1], req.color_payload[2])); break;
break;
case CMD_EXT_BOARD_INFO:
case CMD_EXT_BOARD_INFO: sys_get_led_info();
sys_get_led_info(); break;
break;
case CMD_EXT_BOARD_LED_RGB_UNKNOWN:
case CMD_EXT_BOARD_LED_RGB_UNKNOWN: break;
break;
default:
default: res_init();
res_init(); }
} packet_write();
packet_write(); }
}