zongqiang.zhang | 0c6a088 | 2019-08-07 14:48:21 +0800 | [diff] [blame] | 1 | #ifndef _SP_COMMUNICATE_H_ |
| 2 | #define _SP_COMMUNICATE_H_ |
| 3 | |
| 4 | #include "sp_config.h" |
| 5 | |
| 6 | #define PROTOCOL_COMMAND_V2 0x80 |
| 7 | #define PROTOCOL_WITH_MAC(x) ((x) | 0x80) |
| 8 | #define PROTOCOL_WITHOUT_MAC(x) ((x) & 0x7F) |
| 9 | #define PROTOCOL_FLAG_PACK(x) ((x) | 0x01) |
| 10 | #define PROTOCOL_FLAG_DES_PACK(x) ((x) & 0xFE) |
| 11 | |
| 12 | #define PK_BIN_DEVPHYID "a" |
| 13 | #define PK_INT_CARDNO "b" |
| 14 | #define PK_BIN_CARDVERNO "c" |
| 15 | #define PK_INT_DEVSEQNO "d" |
| 16 | #define PK_STR_VERSION "e" |
| 17 | #define PK_INT_BLKINDEX "f" |
| 18 | #define PK_BIN_TRANSDATE "g" |
| 19 | #define PK_BIN_TRANSTIME "h" |
| 20 | #define PK_INT_PAYAMT "i" |
| 21 | #define PK_INT_AMOUNT "j" |
| 22 | #define PK_INT_FLAG "k" |
| 23 | #define PK_STR_AVAIABLE "l" |
| 24 | #define PK_BIN_SYSTIME "m" |
| 25 | #define PK_STR_UPGRADE "n" |
| 26 | #define PK_BIN_BLKBITMAP "o" |
| 27 | #define PK_BIN_FILECRC "p" |
| 28 | #define PK_INT_FILESIZE "q" |
| 29 | #define PK_INT_SEQNO "r" |
| 30 | #define PK_BIN_FILEDATA "s" |
| 31 | #define PK_INT_MAXSEQNO "t" |
| 32 | #define PK_INT_SECONDS "u" |
| 33 | #define PK_INT_CREDIT_TOTAL "v" |
| 34 | #define PK_INT_CREDIT_PAYCNT "w" |
| 35 | #define PK_INT_CREDIT_AVAILABAL "x" |
| 36 | #define PK_INT_CREDIT_NO "y" |
| 37 | #define PK_BIN_EXPIRE "z" |
| 38 | #define PK_INT_FEETYPE "A" |
| 39 | #define PK_BIN_CARDPHYID "B" |
| 40 | #define PK_STR_STATUS "C" |
| 41 | #define PK_INT_BALANCE "D" |
| 42 | #define PK_INT_OFFLINE_FORBID_FLAG "E" |
| 43 | #define PK_INT_CREDIT_PAYCNT_LACK "F" |
| 44 | #define PK_INT_ONCETIME_LIMIT "G" |
| 45 | #define PK_INT_DAYTOTAL_LIMIT "H" |
| 46 | #define PK_INT_COUNT "J" |
| 47 | #define PK_BIN_BLKLIST "K" |
| 48 | #define PK_INT_CREDIT_NEXT_NO "L" |
| 49 | #define PK_BIN_RANDOM "M" |
| 50 | #define PK_INT_DEVICENO "N" |
| 51 | #define PK_BIN_DEVTIME "O" |
| 52 | #define PK_STR_DEVTYPE "P" |
| 53 | #define PK_BIN_SAMNO "Q" |
| 54 | #define PK_INT_PARAVERNO "R" |
| 55 | #define PK_INT_PARA_GROUPID "S" |
| 56 | #define PK_INT_FEEVERNO "T" |
| 57 | #define PK_INT_FEE_CFGID "U" |
| 58 | #define PK_BIN_WSCLIENT_ID "V" |
| 59 | #define PK_INT_WSCLIENT_STATUS "W" |
| 60 | #define PK_INT_FLOWSENSORS "X" |
| 61 | #define PK_BIN_SOFT_MD5 "Y" |
| 62 | #define PK_INT_CUSTID "Z" |
| 63 | #define PK_STR_SHORT_URL "0" |
| 64 | #define PK_INT_WATERSTATUS "1" |
| 65 | #define PK_INT_WATERMUCH "2" |
| 66 | |
guangcheng.qin | 0066884 | 2019-08-19 09:45:25 +0800 | [diff] [blame] | 67 | #define PK_INT_COBILLNO "3" |
zongqiang.zhang | 0c6a088 | 2019-08-07 14:48:21 +0800 | [diff] [blame] | 68 | #define PK_INT_TRANSWAY "4" |
| 69 | #define PK_INT_UNTRANSCONST "5" |
| 70 | #define PK_BIN_DEVICEKEY "6" |
| 71 | #define PK_INT_WORKMODE "7" |
| 72 | #define PK_INT_OFFLINEMAXHOUR "8" |
| 73 | #define PK_INT_PULSEINHML "9" |
| 74 | #define PK_BIN_CITIZEN_CARDNO "10" |
| 75 | #define PK_INT_WATERLIMIT "11" |
| 76 | #define PK_INT_FEEAMOUNT "12" |
| 77 | #define PK_INT_FEEUNIT "13" |
| 78 | #define PK_INT_VAILDTIME "14" |
| 79 | #define PK_INT_AUTHSTATUS "15" |
| 80 | #define PK_INT_PAYSTATUS "16" |
| 81 | #define PK_INT_FEESTART "17" |
guangcheng.qin | 2d6738c | 2019-09-25 17:38:15 +0800 | [diff] [blame] | 82 | #define PK_INT_PERMIT "18" |
| 83 | #define PK_STR_LIMITMSG "19" |
zongqiang.zhang | db84c85 | 2019-12-09 10:18:01 +0800 | [diff] [blame^] | 84 | #define PK_INT_AMOUNT_LIMIT "20" |
zongqiang.zhang | 0c6a088 | 2019-08-07 14:48:21 +0800 | [diff] [blame] | 85 | |
| 86 | #define SP_CMD_UPGRADE 0x20 //ÔÚÏßÉý¼¶ |
| 87 | #define SP_CMD_TRANSDTL_ACCOUNT 0x22 //¼ÇÕËÁ÷Ë® |
| 88 | #define SP_CMD_HEARTBEAT 0x24 //ÐÄÌø |
| 89 | #define SP_CMD_CARD_AUTHENTICATION 0x26 //¿¨ÔÚÏßÈÏÖ¤ |
| 90 | #define SP_CMD_LOGIN 0x2C //怬 |
| 91 | #define SP_CMD_FACTORY_LINK_TEST 0x2E //¹¤³§Á´Â·²âÊÔ |
| 92 | #define SP_CMD_SHORTURL 0x28 //»ñÈ¡¶þάÂë¶ÌµØÖ· |
| 93 | #define SP_CMD_QRCODE_PAY_QUERY 0x2A //¶þάÂëÏû·ÑÈ·ÈÏ |
| 94 | |
| 95 | #define IS_PUSH_FLOW(cmd) (0x1&(cmd)) |
| 96 | |
| 97 | #pragma pack(push) |
| 98 | #pragma pack(1) |
| 99 | |
| 100 | typedef struct |
| 101 | { |
| 102 | uint16 datalen; |
| 103 | uint8 command; |
| 104 | uint8 excmd; // ÇëÇóÃüÁîÒªÇóżÊý |
| 105 | uint8 flag; |
| 106 | uint8 data[256]; |
| 107 | } sp_protocol_request_t; |
| 108 | |
| 109 | typedef struct |
| 110 | { |
| 111 | uint16 datalen; |
| 112 | uint8 command; |
| 113 | uint8 excmd; // ÇëÇóÃüÁîÒªÇóżÊý |
| 114 | uint8 flag; |
| 115 | uint8 retcode; |
| 116 | uint8 data[256]; |
| 117 | } sp_protocol_response_t; |
| 118 | |
| 119 | #pragma pack(pop) |
| 120 | |
| 121 | typedef uint8(* protocol_cmd_func_t)(sp_protocol_response_t* resp, sp_pos_t* pos); |
| 122 | |
| 123 | typedef struct |
| 124 | { |
| 125 | uint8 cmd; |
| 126 | protocol_cmd_func_t func; |
| 127 | } protocol_cmd_t; |
| 128 | |
| 129 | void sp_communicate(sp_pos_t* pos); |
| 130 | uint16 sp_card_authentication(sp_pos_t* pos, sp_card_t* card); |
| 131 | uint16 sp_async_equipment_login(sp_pos_t* pos); |
| 132 | uint16 sp_async_heartbeat(sp_pos_t* pos); |
| 133 | uint16 sp_async_upload_transdtl(sp_pos_t* pos, sp_transdtl_t* dtl); |
| 134 | uint16 sp_qrcode_init(sp_pos_t* pos, sp_card_t* card); |
| 135 | uint16 sp_qrcode_query(sp_pos_t* pos, sp_card_t* card); |
zongqiang.zhang | 10678fd | 2019-11-25 13:37:03 +0800 | [diff] [blame] | 136 | void sp_login(sp_pos_t* pos); |
zongqiang.zhang | 0c6a088 | 2019-08-07 14:48:21 +0800 | [diff] [blame] | 137 | |
| 138 | //ͨѶ |
| 139 | uint8 sp_comm_call(sp_pos_t* pos, sp_protocol_request_t* req, |
zongqiang.zhang | 10678fd | 2019-11-25 13:37:03 +0800 | [diff] [blame] | 140 | sp_protocol_response_t* resp, uint32 timeout_ms); |
zongqiang.zhang | 0c6a088 | 2019-08-07 14:48:21 +0800 | [diff] [blame] | 141 | void sp_protocol_req_init(sp_protocol_request_t* req, uint8 command); |
| 142 | #endif |
| 143 | |