diff --git a/source/app/app_config.h b/source/app/app_config.h index c4d1c04..55b855c 100644 --- a/source/app/app_config.h +++ b/source/app/app_config.h @@ -28,7 +28,7 @@ #define POWER_NORMAL 0 #define POWER_LOW 1 -#define RFID_BUF_NUM 4 +#define RFID_BUF_NUM 4 typedef struct global_register { diff --git a/source/app/task_rfid.c b/source/app/task_rfid.c index 71a899e..bc2975c 100644 --- a/source/app/task_rfid.c +++ b/source/app/task_rfid.c @@ -18,6 +18,9 @@ S_TASK_RFID _s_task_rfid; +// U8 RFID_READ_MASK[] = {'Y','F','R','S', 0x00, 0xAA}; +U8 RFID_READ_MASK[] = {'Y','F','R','S', 0x00, 0xAA}; //59 46 52 53 00 AA + //4通道,读取次数 3 3 3 3 U8 rfidSetChannelCmd[] = {0xBB,0x00,0x1B,0x00,0x05,0x02,0x03,0x03,0x03,0x03,0x2E,0x7E}; //设置功率 26dBm @@ -81,6 +84,18 @@ void L3_task_rfid_handler(S_TASK_RFID *s) TTSS_Task_end(); } +U8 verify_mask(U8 *rfid) +{ + int i; + for(i=0;i<6;i++) + { + if(rfid[i] != RFID_READ_MASK[i]){ + return 0; + } + } + return 1; +} + //RFID协议:BB 02 22 00 11 D5 30 00 E2 00 10 71 00 00 52 9B 09 40 B4 02 EB 98 0C 7E //帧头:BB //Type:00命令帧 /01响应帧 /02通知帧 @@ -104,6 +119,16 @@ void parse_rfid_pkg() U8 rssi = p->buf[0]; U8 ant = p->buf[num-1]; + //5.打印日志 + print_rfid_pkg(p); + + //校验RFID掩码 + if(!verify_mask(&p->buf[num-11])) + { + L0_uart0_sendstr("RFID ERR..."); + return; + } + //1.判定RFID卡号是否符合规则 //2.保存RFID卡号到寄存器 L3_new_rfid(rfidno, rssi, ant); @@ -114,8 +139,6 @@ void parse_rfid_pkg() if(index < LED_BTN_NUM){ R.led_status[index] = 1; } - //5.打印日志 - print_rfid_pkg(p); } } }