| | |
| | | #define MSG_RW 3 |
| | | #define MSG_WTAG 6 |
| | | #define MSG_PWTAG 8 |
| | | #define MSG_REGTAGRESPONSE 0x0b |
| | | |
| | | #define CMD_READ 1 |
| | | #define CMD_WRITE 2 |
| | | #define CMD_REPLY 3 |
| | | #define EUART_RX_BUF_SIZE 100 |
| | | |
| | | struct pwtag_structure pwtag; |
| | | typedef enum{ UsartReceiveWaitHead0, |
| | | UsartReceiveWaitHead1, |
| | |
| | | |
| | | UART_PushFrame(send_frame, 12); |
| | | } |
| | | void SendAnchorState(uint16_t state) |
| | | { |
| | | uint16_t checksum = 0; |
| | | send_frame[0] = 0x55; |
| | | send_frame[1] = 0xAA; |
| | | send_frame[2] = 0x10; |
| | | send_frame[3] = 14; |
| | | memcpy(&send_frame[4],&dev_id,2); |
| | | send_frame[6] = state; |
| | | |
| | | |
| | | checksum = Checksum_u16(&send_frame[2],14); |
| | | memcpy(&send_frame[16],&checksum,2); |
| | | |
| | | USART_puts(send_frame, 17); |
| | | } |
| | | void SendComMap(uint8_t data_length, uint8_t index) |
| | | { |
| | | uint16_t checksum = 0; |
| | |
| | | u8 remotetag_para[30],remotetag_paralen; |
| | | u8 remotesend_state=0; |
| | | uint16_t configremotetagID; |
| | | struct regtag_structure regtag_map; |
| | | void UsartParseDataHandler(uint8_t data) |
| | | { |
| | | static UsartRecvPackState usart_receive_state = UsartReceiveWaitHead0; |
| | |
| | | case CMD_WRITE: |
| | | //ä»mUsartReceivePackä¸è¯»åpack_lengthé¿åº¦çåèï¼æ¾å°å
¨å±åéä¸ |
| | | memcpy((uint8_t*)&g_com_map + pack_index, &mUsartReceivePack[3], pack_datalen); |
| | | memcpy((uint8_t*)&g_com_map2 + pack_index, &mUsartReceivePack[3], pack_datalen); |
| | | //è¿åä¸ä¸ªerrorç¶æ |
| | | //SendComMap(pack_datalen,pack_index); |
| | | save_com_map_to_flash(); |
| | |
| | | break; |
| | | } |
| | | break; |
| | | case MSG_WTAG: |
| | | case MSG_WTAG: //ä¿®æ¹æ ç¾åæ° |
| | | remotesend_state=1; |
| | | memcpy(&configremotetagID,&mUsartReceivePack[0],2); |
| | | //configremotetagID = pack_cmd|pack_index<<8; |
| | |
| | | remotetag_paralen = mUsartReceivePack[4]+3; |
| | | memcpy(&remotetag_para[1],&mUsartReceivePack[3],remotetag_paralen); |
| | | break; |
| | | case MSG_PWTAG: |
| | | case MSG_PWTAG: //æ¹éä¿®æ¹æ ç¾åæ° |
| | | pwtag.groupnum = mUsartReceivePack[0]; |
| | | pwtag.index = mUsartReceivePack[1]; |
| | | pwtag.remain_time = 5; |
| | |
| | | memcpy(&pwtag.group_interval[i],&mUsartReceivePack[i*6+6],2); |
| | | } |
| | | break; |
| | | case MSG_REGTAGRESPONSE: |
| | | regtag_map.index++; |
| | | if(regtag_map.index==MAX_REGTAGNUM) |
| | | {regtag_map.index = 0;} |
| | | regtag_map.remain_time[regtag_map.index]=5; |
| | | memcpy(®tag_map.tagid[regtag_map.index],&mUsartReceivePack[0],2); |
| | | memcpy(®tag_map.tag_frequency[regtag_map.index],&mUsartReceivePack[2],2); |
| | | memcpy(®tag_map.tag_slotpos[regtag_map.index],&mUsartReceivePack[4],2); |
| | | break; |
| | | } |
| | | SendConfigConfirm(pack_msgtype,pack_length); |
| | | } |