| #ifndef _SP_COMMUNICATE_H_ |
| #define _SP_COMMUNICATE_H_ |
| |
| #include "sp_config.h" |
| |
| #define PROTOCOL_COMMAND_V2 0x80 |
| #define PROTOCOL_WITH_MAC(x) ((x) | 0x80) |
| #define PROTOCOL_WITHOUT_MAC(x) ((x) & 0x7F) |
| #define PROTOCOL_FLAG_PACK(x) ((x) | 0x01) |
| #define PROTOCOL_FLAG_DES_PACK(x) ((x) & 0xFE) |
| |
| #define PK_BIN_DEVPHYID "a" |
| #define PK_INT_CARDNO "b" |
| #define PK_BIN_CARDVERNO "c" |
| #define PK_INT_DEVSEQNO "d" |
| #define PK_STR_VERSION "e" |
| #define PK_INT_BLKINDEX "f" |
| #define PK_BIN_TRANSDATE "g" |
| #define PK_BIN_TRANSTIME "h" |
| #define PK_INT_PAYAMT "i" |
| #define PK_INT_AMOUNT "j" |
| #define PK_INT_FLAG "k" |
| #define PK_STR_AVAIABLE "l" |
| #define PK_BIN_SYSTIME "m" |
| #define PK_STR_UPGRADE "n" |
| #define PK_BIN_BLKBITMAP "o" |
| #define PK_BIN_FILECRC "p" |
| #define PK_INT_FILESIZE "q" |
| #define PK_INT_SEQNO "r" |
| #define PK_BIN_FILEDATA "s" |
| #define PK_INT_MAXSEQNO "t" |
| #define PK_INT_SECONDS "u" |
| #define PK_INT_CREDIT_TOTAL "v" |
| #define PK_INT_CREDIT_PAYCNT "w" |
| #define PK_INT_CREDIT_AVAILABAL "x" |
| #define PK_INT_CREDIT_NO "y" |
| #define PK_BIN_EXPIRE "z" |
| #define PK_INT_FEETYPE "A" |
| #define PK_BIN_CARDPHYID "B" |
| #define PK_STR_STATUS "C" |
| #define PK_INT_BALANCE "D" |
| #define PK_INT_OFFLINE_FORBID_FLAG "E" |
| #define PK_INT_CREDIT_PAYCNT_LACK "F" |
| #define PK_INT_ONCETIME_LIMIT "G" |
| #define PK_INT_DAYTOTAL_LIMIT "H" |
| #define PK_INT_COUNT "J" |
| #define PK_BIN_BLKLIST "K" |
| #define PK_INT_CREDIT_NEXT_NO "L" |
| #define PK_BIN_RANDOM "M" |
| #define PK_INT_DEVICENO "N" |
| #define PK_BIN_DEVTIME "O" |
| #define PK_STR_DEVTYPE "P" |
| #define PK_BIN_SAMNO "Q" |
| #define PK_INT_PARAVERNO "R" |
| #define PK_INT_PARA_GROUPID "S" |
| #define PK_INT_FEEVERNO "T" |
| #define PK_INT_FEE_CFGID "U" |
| #define PK_BIN_WSCLIENT_ID "V" |
| #define PK_INT_WSCLIENT_STATUS "W" |
| #define PK_INT_FLOWSENSORS "X" |
| #define PK_BIN_SOFT_MD5 "Y" |
| #define PK_INT_CUSTID "Z" |
| #define PK_STR_SHORT_URL "0" |
| #define PK_INT_WATERSTATUS "1" |
| #define PK_INT_WATERMUCH "2" |
| |
| #define PK_INT_COBILLNO "3" |
| #define PK_INT_TRANSWAY "4" |
| #define PK_INT_UNTRANSCONST "5" |
| #define PK_BIN_DEVICEKEY "6" |
| #define PK_INT_WORKMODE "7" |
| #define PK_INT_OFFLINEMAXHOUR "8" |
| #define PK_INT_PULSEINHML "9" |
| #define PK_BIN_CITIZEN_CARDNO "10" |
| #define PK_INT_WATERLIMIT "11" |
| #define PK_INT_FEEAMOUNT "12" |
| #define PK_INT_FEEUNIT "13" |
| #define PK_INT_VAILDTIME "14" |
| #define PK_INT_AUTHSTATUS "15" |
| #define PK_INT_PAYSTATUS "16" |
| #define PK_INT_FEESTART "17" |
| #define PK_INT_PERMIT "18" |
| #define PK_STR_LIMITMSG "19" |
| #define PK_INT_AMOUNT_LIMIT "20" |
| |
| #define SP_CMD_UPGRADE 0x20 //ÔÚÏßÉý¼¶ |
| #define SP_CMD_TRANSDTL_ACCOUNT 0x22 //¼ÇÕËÁ÷Ë® |
| #define SP_CMD_HEARTBEAT 0x24 //ÐÄÌø |
| #define SP_CMD_CARD_AUTHENTICATION 0x26 //¿¨ÔÚÏßÈÏÖ¤ |
| #define SP_CMD_LOGIN 0x2C //怬 |
| #define SP_CMD_FACTORY_LINK_TEST 0x2E //¹¤³§Á´Â·²âÊÔ |
| #define SP_CMD_SHORTURL 0x28 //»ñÈ¡¶þάÂë¶ÌµØÖ· |
| #define SP_CMD_QRCODE_PAY_QUERY 0x2A //¶þάÂëÏû·ÑÈ·ÈÏ |
| |
| #define IS_PUSH_FLOW(cmd) (0x1&(cmd)) |
| |
| #pragma pack(push) |
| #pragma pack(1) |
| |
| typedef struct |
| { |
| uint16 datalen; |
| uint8 command; |
| uint8 excmd; // ÇëÇóÃüÁîÒªÇóżÊý |
| uint8 flag; |
| uint8 data[256]; |
| } sp_protocol_request_t; |
| |
| typedef struct |
| { |
| uint16 datalen; |
| uint8 command; |
| uint8 excmd; // ÇëÇóÃüÁîÒªÇóżÊý |
| uint8 flag; |
| uint8 retcode; |
| uint8 data[256]; |
| } sp_protocol_response_t; |
| |
| #pragma pack(pop) |
| |
| typedef uint8(* protocol_cmd_func_t)(sp_protocol_response_t* resp, sp_pos_t* pos); |
| |
| typedef struct |
| { |
| uint8 cmd; |
| protocol_cmd_func_t func; |
| } protocol_cmd_t; |
| |
| void sp_communicate(sp_pos_t* pos); |
| uint16 sp_card_authentication(sp_pos_t* pos, sp_card_t* card); |
| uint16 sp_async_equipment_login(sp_pos_t* pos); |
| uint16 sp_async_heartbeat(sp_pos_t* pos); |
| uint16 sp_async_upload_transdtl(sp_pos_t* pos, sp_transdtl_t* dtl); |
| uint16 sp_qrcode_init(sp_pos_t* pos, sp_card_t* card); |
| uint16 sp_qrcode_query(sp_pos_t* pos, sp_card_t* card); |
| void sp_login(sp_pos_t* pos); |
| |
| //ͨѶ |
| uint8 sp_comm_call(sp_pos_t* pos, sp_protocol_request_t* req, |
| sp_protocol_response_t* resp, uint32 timeout_ms); |
| void sp_protocol_req_init(sp_protocol_request_t* req, uint8 command); |
| #endif |
| |