debug version
Dependents: HTTPClient_WiFi_HelloWorld_src
Fork of SNICInterface by
SNIC/SNIC_UartMsgUtil.h@14:54378c96d285, 2014-03-26 (annotated)
- Committer:
- kishino
- Date:
- Wed Mar 26 04:38:12 2014 +0000
- Revision:
- 14:54378c96d285
- Parent:
- 12:0254eaccfda2
Added a comment of copyright.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kishino | 14:54378c96d285 | 1 | /******************* Murata Manufacturing Co.,Ltd. 2014 ***************** |
kishino | 14:54378c96d285 | 2 | * |
kishino | 14:54378c96d285 | 3 | * Filename: SNIC_UartMsgUtil.h |
kishino | 14:54378c96d285 | 4 | * |
kishino | 14:54378c96d285 | 5 | * Purpose: This module has define of function for utilities |
kishino | 14:54378c96d285 | 6 | * of SNIC UART Command. |
kishino | 14:54378c96d285 | 7 | * |
kishino | 14:54378c96d285 | 8 | * $Author: kishino $ |
kishino | 14:54378c96d285 | 9 | * |
kishino | 14:54378c96d285 | 10 | * $Date: 2014/03/26 $ |
kishino | 14:54378c96d285 | 11 | * |
kishino | 14:54378c96d285 | 12 | * $Revision: 0.0.0.1 $ |
kishino | 14:54378c96d285 | 13 | * ***********************************************************************/ |
kishino | 12:0254eaccfda2 | 14 | #ifndef _SNIC_WIFI_UART_MSG_UTIL_H_ |
kishino | 12:0254eaccfda2 | 15 | #define _SNIC_WIFI_UART_MSG_UTILH_ |
kishino | 12:0254eaccfda2 | 16 | |
kishino | 12:0254eaccfda2 | 17 | #include "mbed.h" |
kishino | 12:0254eaccfda2 | 18 | #include "rtos.h" |
kishino | 12:0254eaccfda2 | 19 | #include "RawSerial.h" |
kishino | 12:0254eaccfda2 | 20 | |
kishino | 12:0254eaccfda2 | 21 | namespace murata_wifi |
kishino | 12:0254eaccfda2 | 22 | { |
kishino | 12:0254eaccfda2 | 23 | |
kishino | 12:0254eaccfda2 | 24 | #define UART_CMD_SOM 0x02 |
kishino | 12:0254eaccfda2 | 25 | #define UART_CMD_EOM 0x04 |
kishino | 12:0254eaccfda2 | 26 | #define UART_CMD_ESC 0x10 |
kishino | 12:0254eaccfda2 | 27 | |
kishino | 12:0254eaccfda2 | 28 | /* SNIC UART Command ID */ |
kishino | 12:0254eaccfda2 | 29 | #define UART_CMD_ID_GEN 0x01 //General command |
kishino | 12:0254eaccfda2 | 30 | #define UART_CMD_ID_SNIC 0x70 //SNIC command |
kishino | 12:0254eaccfda2 | 31 | #define UART_CMD_ID_WIFI 0x50 //Wi-Fi command |
kishino | 12:0254eaccfda2 | 32 | |
kishino | 12:0254eaccfda2 | 33 | /* SNIC UART Subcommand ID */ |
kishino | 12:0254eaccfda2 | 34 | #define UART_CMD_SID_GEN_PWR_UP_IND 0x00 //Power up indication |
kishino | 12:0254eaccfda2 | 35 | #define UART_CMD_SID_GEN_FW_VER_GET_REQ 0x08 //Get firmware version string |
kishino | 12:0254eaccfda2 | 36 | |
kishino | 12:0254eaccfda2 | 37 | #define UART_CMD_SID_SNIC_INIT_REQ 0x00 // SNIC API initialization |
kishino | 12:0254eaccfda2 | 38 | #define UART_CMD_SID_SNIC_CLEANUP_REQ 0x01 // SNIC API cleanup |
kishino | 12:0254eaccfda2 | 39 | #define UART_CMD_SID_SNIC_SEND_FROM_SOCKET_REQ 0x02 // Send from socket |
kishino | 12:0254eaccfda2 | 40 | #define UART_CMD_SID_SNIC_CLOSE_SOCKET_REQ 0x03 // Close socket |
kishino | 12:0254eaccfda2 | 41 | #define UART_CMD_SID_SNIC_ SOCKET _PARTIAL_CLOSE_ REQ 0x04 // Socket partial close |
kishino | 12:0254eaccfda2 | 42 | #define UART_CMD_SID_SNIC_GETSOCKOPT_REQ 0x05 // Get socket option |
kishino | 12:0254eaccfda2 | 43 | #define UART_CMD_SID_SNIC_SETSOCKOPT_REQ 0x06 // Set socket option |
kishino | 12:0254eaccfda2 | 44 | #define UART_CMD_SID_SNIC_SOCKET_GETNAME_REQ 0x07 // Get name or peer name |
kishino | 12:0254eaccfda2 | 45 | #define UART_CMD_SID_SNIC_SEND_ARP_REQ 0x08 // Send ARP request |
kishino | 12:0254eaccfda2 | 46 | #define UART_CMD_SID_SNIC_GET_DHCP_INFO_REQ 0x09 // Get DHCP info |
kishino | 12:0254eaccfda2 | 47 | #define UART_CMD_SID_SNIC_RESOLVE_NAME_REQ 0x0A // Resolve a host name to IP address |
kishino | 12:0254eaccfda2 | 48 | #define UART_CMD_SID_SNIC_IP_CONFIG_REQ 0x0B // Configure DHCP or static IP |
kishino | 12:0254eaccfda2 | 49 | #define UART_CMD_SID_SNIC_DATA_IND_ACK_CONFIG_REQ 0x0C // ACK configuration for data indications |
kishino | 12:0254eaccfda2 | 50 | #define UART_CMD_SID_SNIC_TCP_CREATE_SOCKET_REQ 0x10 // Create TCP socket |
kishino | 12:0254eaccfda2 | 51 | #define UART_CMD_SID_SNIC_TCP_CREATE_CONNECTION_REQ 0x11 // Create TCP connection server |
kishino | 12:0254eaccfda2 | 52 | #define UART_CMD_SID_SNIC_TCP_CONNECT_TO_SERVER_REQ 0x12 // Connect to TCP server |
kishino | 12:0254eaccfda2 | 53 | #define UART_CMD_SID_SNIC_UDP_CREATE_SOCKET_REQ 0x13 // Create UDP socket |
kishino | 12:0254eaccfda2 | 54 | #define UART_CMD_SID_SNIC_UDP_START_RECV_REQ 0x14 // Start UDP receive on socket |
kishino | 12:0254eaccfda2 | 55 | #define UART_CMD_SID_SNIC_UDP_SIMPLE_SEND_REQ 0x15 // Send UDP packet |
kishino | 12:0254eaccfda2 | 56 | #define UART_CMD_SID_SNIC_UDP_SEND_ FROM_SOCKET_REQ 0x16 // Send UDP packet from socket |
kishino | 12:0254eaccfda2 | 57 | #define UART_CMD_SID_SNIC_HTTP_REQ 0x17 // Send HTTP request |
kishino | 12:0254eaccfda2 | 58 | #define UART_CMD_SID_SNIC_HTTP_MORE_REQ 0x18 // Send HTTP more data request |
kishino | 12:0254eaccfda2 | 59 | #define UART_CMD_SID_SNIC_HTTPS_REQ 0x19 // Send HTTPS request |
kishino | 12:0254eaccfda2 | 60 | #define UART_CMD_SID_SNIC_TCP_CREATE_ADV_TLS_SOCKET_REQ 0x1A // Create advanced TLS TCP socket |
kishino | 12:0254eaccfda2 | 61 | #define UART_CMD_SID_SNIC_TCP_CREAET_SIMPLE_TLS_SOCKET_REQ 0x1B // Create simple TLS TCP socket |
kishino | 12:0254eaccfda2 | 62 | #define UART_CMD_SID_SNIC_TCP_CONNECTION_STATUS_IND 0x20 // Connection status indication |
kishino | 12:0254eaccfda2 | 63 | #define UART_CMD_SID_SNIC_TCP_CLIENT_SOCKET_IND 0x21 // TCP client socket indication |
kishino | 12:0254eaccfda2 | 64 | #define UART_CMD_SID_SNIC_CONNECTION_RECV_IND 0x22 // TCP or connected UDP packet received indication |
kishino | 12:0254eaccfda2 | 65 | #define UART_CMD_SID_SNIC_UDP_RECV_IND 0x23 // UCP packet received indication |
kishino | 12:0254eaccfda2 | 66 | #define UART_CMD_SID_SNIC_ARP_REPLY_IND 0x24 // ARP reply indication |
kishino | 12:0254eaccfda2 | 67 | #define UART_CMD_SID_SNIC_HTTP_RSP_IND 0x25 // HTTP response indication |
kishino | 12:0254eaccfda2 | 68 | |
kishino | 12:0254eaccfda2 | 69 | #define UART_CMD_SID_WIFI_ON_REQ 0x00 // Turn on Wifi |
kishino | 12:0254eaccfda2 | 70 | #define UART_CMD_SID_WIFI_OFF_REQ 0x01 // Turn off Wifi |
kishino | 12:0254eaccfda2 | 71 | #define UART_CMD_SID_WIFI_JOIN_REQ 0x02 // Associate to a network |
kishino | 12:0254eaccfda2 | 72 | #define UART_CMD_SID_WIFI_DISCONNECT_REQ 0x03 // Disconnect from a network |
kishino | 12:0254eaccfda2 | 73 | #define UART_CMD_SID_WIFI_GET_STATUS_REQ 0x04 // Get WiFi status |
kishino | 12:0254eaccfda2 | 74 | #define UART_CMD_SID_WIFI_SCAN_REQ 0x05 // Scan WiFi networks |
kishino | 12:0254eaccfda2 | 75 | #define UART_CMD_SID_WIFI_GET_STA_RSSI_REQ 0x06 // Get STA signal strength (RSSI) |
kishino | 12:0254eaccfda2 | 76 | #define UART_CMD_SID_WIFI_AP_CTRL_REQ 0x07 // Soft AP on-off control |
kishino | 12:0254eaccfda2 | 77 | #define UART_CMD_SID_WIFI_WPS_REQ 0x08 // Start WPS process |
kishino | 12:0254eaccfda2 | 78 | #define UART_CMD_SID_WIFI_AP_GET_CLIENT_REQ 0x0A // Get clients that are associated to the soft AP. |
kishino | 12:0254eaccfda2 | 79 | #define UART_CMD_SID_WIFI_NETWORK_STATUS_IND 0x10 // Network status indication |
kishino | 12:0254eaccfda2 | 80 | #define UART_CMD_SID_WIFI_SCAN_RESULT_IND 0x11 // Scan result indication |
kishino | 12:0254eaccfda2 | 81 | |
kishino | 12:0254eaccfda2 | 82 | /* SNIC UART Command response status code */ |
kishino | 12:0254eaccfda2 | 83 | #define UART_CMD_RES_SNIC_SUCCESS 0x00 |
kishino | 12:0254eaccfda2 | 84 | #define UART_CMD_RES_SNIC_FAIL 0x01 |
kishino | 12:0254eaccfda2 | 85 | #define UART_CMD_RES_SNIC_INIT_FAIL 0x02 |
kishino | 12:0254eaccfda2 | 86 | #define UART_CMD_RES_SNIC_CLEANUP_FAIL 0x03 |
kishino | 12:0254eaccfda2 | 87 | #define UART_CMD_RES_SNIC_GETADDRINFO_FAIL 0x04 |
kishino | 12:0254eaccfda2 | 88 | #define UART_CMD_RES_SNIC_CREATE_SOCKET_FAIL 0x05 |
kishino | 12:0254eaccfda2 | 89 | #define UART_CMD_RES_SNIC_BIND_SOCKET_FAIL 0x06 |
kishino | 12:0254eaccfda2 | 90 | #define UART_CMD_RES_SNIC_LISTEN_SOCKET_FAIL 0x07 |
kishino | 12:0254eaccfda2 | 91 | #define UART_CMD_RES_SNIC_ACCEPT_SOCKET_FAIL 0x08 |
kishino | 12:0254eaccfda2 | 92 | #define UART_CMD_RES_SNIC_PARTIAL_CLOSE_FAIL 0x09 |
kishino | 12:0254eaccfda2 | 93 | #define UART_CMD_RES_SNIC_SOCKET_PARTIALLY_CLOSED 0x0A |
kishino | 12:0254eaccfda2 | 94 | #define UART_CMD_RES_SNIC_SOCKET_CLOSED 0x0B |
kishino | 12:0254eaccfda2 | 95 | #define UART_CMD_RES_SNIC_CLOSE_SOCKET_FAIL 0x0C |
kishino | 12:0254eaccfda2 | 96 | #define UART_CMD_RES_SNIC_PACKET_TOO_LARGE 0x0D |
kishino | 12:0254eaccfda2 | 97 | #define UART_CMD_RES_SNIC_SEND_FAIL 0x0E |
kishino | 12:0254eaccfda2 | 98 | #define UART_CMD_RES_SNIC_CONNECT_TO_SERVER_FAIL 0x0F |
kishino | 12:0254eaccfda2 | 99 | #define UART_CMD_RES_SNIC_NOT_ENOUGH_MEMORY 0x10 |
kishino | 12:0254eaccfda2 | 100 | #define UART_CMD_RES_SNIC_TIMEOUT 0x11 |
kishino | 12:0254eaccfda2 | 101 | #define UART_CMD_RES_SNIC_CONNECTION_UP 0x12 |
kishino | 12:0254eaccfda2 | 102 | #define UART_CMD_RES_SNIC_GETSOCKOPT_FAIL 0x13 |
kishino | 12:0254eaccfda2 | 103 | #define UART_CMD_RES_SNIC_SETSOCKOPT_FAIL 0x14 |
kishino | 12:0254eaccfda2 | 104 | #define UART_CMD_RES_SNIC_INVALID_ARGUMENT 0x15 |
kishino | 12:0254eaccfda2 | 105 | #define UART_CMD_RES_SNIC_SEND_ARP_FAIL 0x16 |
kishino | 12:0254eaccfda2 | 106 | #define UART_CMD_RES_SNIC_INVALID_SOCKET 0x17 |
kishino | 12:0254eaccfda2 | 107 | #define UART_CMD_RES_SNIC_COMMAND_PENDING 0x18 |
kishino | 12:0254eaccfda2 | 108 | #define UART_CMD_RES_SNIC_SOCKET_NOT_BOUND 0x19 |
kishino | 12:0254eaccfda2 | 109 | #define UART_CMD_RES_SNIC_SOCKET_NOT_CONNECTED 0x1A |
kishino | 12:0254eaccfda2 | 110 | #define UART_CMD_RES_SNIC_NO_NETWORK 0x20 |
kishino | 12:0254eaccfda2 | 111 | #define UART_CMD_RES_SNIC_INIT_NOT_DONE 0x21 |
kishino | 12:0254eaccfda2 | 112 | #define UART_CMD_RES_SNIC_NET_IF_FAIL 0x22 |
kishino | 12:0254eaccfda2 | 113 | #define UART_CMD_RES_SNIC_NET_IF_NOT_UP 0x23 |
kishino | 12:0254eaccfda2 | 114 | #define UART_CMD_RES_SNIC_DHCP_START_FAIL 0x24 |
kishino | 12:0254eaccfda2 | 115 | |
kishino | 12:0254eaccfda2 | 116 | #define UART_CMD_RES_WIFI_SUCCESS 0x00 |
kishino | 12:0254eaccfda2 | 117 | #define UART_CMD_RES_WIFI_ERR_UNKNOWN_COUNTRY 0x01 |
kishino | 12:0254eaccfda2 | 118 | #define UART_CMD_RES_WIFI_ERR_INIT_FAIL 0x02 |
kishino | 12:0254eaccfda2 | 119 | #define UART_CMD_RES_WIFI_ERR_ALREADY_JOINED 0x03 |
kishino | 12:0254eaccfda2 | 120 | #define UART_CMD_RES_WIFI_ERR_AUTH_TYPE 0x04 |
kishino | 12:0254eaccfda2 | 121 | #define UART_CMD_RES_WIFI_ERR_JOIN_FAIL 0x05 |
kishino | 12:0254eaccfda2 | 122 | #define UART_CMD_RES_WIFI_ERR_NOT_JOINED 0x06 |
kishino | 12:0254eaccfda2 | 123 | #define UART_CMD_RES_WIFI_ERR_LEAVE_FAILED 0x07 |
kishino | 12:0254eaccfda2 | 124 | #define UART_CMD_RES_WIFI_COMMAND_PENDING 0x08 |
kishino | 12:0254eaccfda2 | 125 | #define UART_CMD_RES_WIFI_WPS_NO_CONFIG 0x09 |
kishino | 12:0254eaccfda2 | 126 | #define UART_CMD_RES_WIFI_NETWORK_UP 0x10 |
kishino | 12:0254eaccfda2 | 127 | #define UART_CMD_RES_WIFI_NETWORK_DOWN 0x11 |
kishino | 12:0254eaccfda2 | 128 | #define UART_CMD_RES_WIFI_FAIL 0xFF |
kishino | 12:0254eaccfda2 | 129 | |
kishino | 12:0254eaccfda2 | 130 | /** UART Command sequence number |
kishino | 12:0254eaccfda2 | 131 | */ |
kishino | 12:0254eaccfda2 | 132 | static unsigned char mUartRequestSeq; |
kishino | 12:0254eaccfda2 | 133 | |
kishino | 12:0254eaccfda2 | 134 | /** C_SNIC_UartMsgUtil class |
kishino | 12:0254eaccfda2 | 135 | */ |
kishino | 12:0254eaccfda2 | 136 | class C_SNIC_UartMsgUtil |
kishino | 12:0254eaccfda2 | 137 | { |
kishino | 12:0254eaccfda2 | 138 | |
kishino | 12:0254eaccfda2 | 139 | public: |
kishino | 12:0254eaccfda2 | 140 | C_SNIC_UartMsgUtil(); |
kishino | 12:0254eaccfda2 | 141 | |
kishino | 12:0254eaccfda2 | 142 | /** Make SNIC UART command payload. |
kishino | 12:0254eaccfda2 | 143 | @param cmd_len Command length |
kishino | 12:0254eaccfda2 | 144 | @param cmd_p Command pointer |
kishino | 12:0254eaccfda2 | 145 | @param payload_p Payload pointer[output] |
kishino | 12:0254eaccfda2 | 146 | @return payload length |
kishino | 12:0254eaccfda2 | 147 | */ |
kishino | 12:0254eaccfda2 | 148 | static unsigned short makePayload( unsigned int cmd_len, unsigned char *cmd_p, unsigned char *payload_p ); |
kishino | 12:0254eaccfda2 | 149 | |
kishino | 12:0254eaccfda2 | 150 | /** Make SNIC UART command. |
kishino | 12:0254eaccfda2 | 151 | @param cmd_id Command ID |
kishino | 12:0254eaccfda2 | 152 | @param payload_p Payload pointer |
kishino | 12:0254eaccfda2 | 153 | @param uart_command_p UART Command pointer [output] |
kishino | 12:0254eaccfda2 | 154 | @return UART Command length |
kishino | 12:0254eaccfda2 | 155 | */ |
kishino | 12:0254eaccfda2 | 156 | static unsigned int makeRequest( unsigned char cmd_id, unsigned char *payload_p, unsigned short payload_len, unsigned char *uart_command_p ); |
kishino | 12:0254eaccfda2 | 157 | |
kishino | 12:0254eaccfda2 | 158 | |
kishino | 12:0254eaccfda2 | 159 | /** Get uart command from receive data. |
kishino | 12:0254eaccfda2 | 160 | @param recvdata_len Receive data length |
kishino | 12:0254eaccfda2 | 161 | @param recvdata_p Pointer of received data from UART |
kishino | 12:0254eaccfda2 | 162 | @param command_id_p Pointer of command ID[output] |
kishino | 12:0254eaccfda2 | 163 | @param payload_p Pointer of payload[output] |
kishino | 12:0254eaccfda2 | 164 | @return Payload length |
kishino | 12:0254eaccfda2 | 165 | */ |
kishino | 12:0254eaccfda2 | 166 | static unsigned int getResponsePayload( unsigned int recvdata_len, unsigned char *recvdata_p |
kishino | 12:0254eaccfda2 | 167 | , unsigned char *command_id_p, unsigned char *payload_p ); |
kishino | 12:0254eaccfda2 | 168 | protected: |
kishino | 12:0254eaccfda2 | 169 | |
kishino | 12:0254eaccfda2 | 170 | }; |
kishino | 12:0254eaccfda2 | 171 | } |
kishino | 12:0254eaccfda2 | 172 | #endif /* _YD_WIFI_UART_MSG_H_ */ |