customized SNICInterface

Dependents:   MurataTypeYD_Ping

Fork of NySNICInterface by Ryo Iizuka

Committer:
kishino
Date:
Tue Mar 25 01:42:25 2014 +0000
Revision:
12:0254eaccfda2
Child:
14:54378c96d285
Refactoring of the class name

Who changed what in which revision?

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