SNIC UART Interface library: Serial to Wi-Fi library for Murata TypeYD Wi-Fi module. For more information about TypeYD: http://www.murata.co.jp/products/microwave/module/lbwb1zzydz/index.html
Dependents: SNIC-xively-jumpstart-demo SNIC-FluentLogger-example TCPEchoServer murataDemo ... more
Fork of YDwifiInterface by
SNICwifiInterface.cpp@8:50d2509479cd, 2014-03-17 (annotated)
- Committer:
- kishino
- Date:
- Mon Mar 17 11:40:56 2014 +0000
- Revision:
- 8:50d2509479cd
- Child:
- 9:a98b45e766c8
Prefix of class name and file name was changed from 'YD' to 'SNIC'.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| kishino | 8:50d2509479cd | 1 | #include "SNICwifiInterface.h" |
| kishino | 8:50d2509479cd | 2 | #include "SNICwifi_uartmsg.h" |
| kishino | 8:50d2509479cd | 3 | |
| kishino | 8:50d2509479cd | 4 | using namespace murata_wifi; |
| kishino | 8:50d2509479cd | 5 | |
| kishino | 8:50d2509479cd | 6 | #define UART_REQUEST_PAYLOAD_MAX 256 |
| kishino | 8:50d2509479cd | 7 | |
| kishino | 8:50d2509479cd | 8 | #define MEMPOOL_BLOCK_SIZE 2048 |
| kishino | 8:50d2509479cd | 9 | typedef struct |
| kishino | 8:50d2509479cd | 10 | { |
| kishino | 8:50d2509479cd | 11 | unsigned char buf[MEMPOOL_BLOCK_SIZE]; |
| kishino | 8:50d2509479cd | 12 | }tagMEMPOOL_BLOCK_T; |
| kishino | 8:50d2509479cd | 13 | #define MEMPOOL_PAYLOAD_NUM 1 |
| kishino | 8:50d2509479cd | 14 | /** MemoryPool for payload of UART response */ |
| kishino | 8:50d2509479cd | 15 | MemoryPool<tagMEMPOOL_BLOCK_T, MEMPOOL_PAYLOAD_NUM> gMEMPOOL_PAYLOAD; |
| kishino | 8:50d2509479cd | 16 | |
| kishino | 8:50d2509479cd | 17 | C_SNICwifiInterface::C_SNICwifiInterface( PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm, int baud): |
| kishino | 8:50d2509479cd | 18 | C_SNICwifi(tx, rx, cts, rts, reset, alarm, baud) |
| kishino | 8:50d2509479cd | 19 | { |
| kishino | 8:50d2509479cd | 20 | } |
| kishino | 8:50d2509479cd | 21 | |
| kishino | 8:50d2509479cd | 22 | int C_SNICwifiInterface::init() |
| kishino | 8:50d2509479cd | 23 | { |
| kishino | 8:50d2509479cd | 24 | /* Initialize UART */ |
| kishino | 8:50d2509479cd | 25 | initUart(); |
| kishino | 8:50d2509479cd | 26 | |
| kishino | 8:50d2509479cd | 27 | /* Initialize SNIC API */ |
| kishino | 8:50d2509479cd | 28 | // Get buffer for response payloadfrom MemoryPool |
| kishino | 8:50d2509479cd | 29 | tagMEMPOOL_BLOCK_T *payload_buf = gMEMPOOL_PAYLOAD.alloc(); |
| kishino | 8:50d2509479cd | 30 | if( payload_buf == NULL ) |
| kishino | 8:50d2509479cd | 31 | { |
| kishino | 8:50d2509479cd | 32 | printf("snic_init payload_buf NULL\r\n"); |
| kishino | 8:50d2509479cd | 33 | return -1; |
| kishino | 8:50d2509479cd | 34 | } |
| kishino | 8:50d2509479cd | 35 | |
| kishino | 8:50d2509479cd | 36 | tagSNIC_INIT_REQ_T req; |
| kishino | 8:50d2509479cd | 37 | // Make request |
| kishino | 8:50d2509479cd | 38 | req.cmd_sid = UART_CMD_SID_SNIC_INIT_REQ; |
| kishino | 8:50d2509479cd | 39 | req.seq = mUartRequestSeq++; |
| kishino | 8:50d2509479cd | 40 | req.buf_size = 0x800; |
| kishino | 8:50d2509479cd | 41 | |
| kishino | 8:50d2509479cd | 42 | unsigned char payload_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 43 | unsigned char command_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 44 | unsigned short payload_len; |
| kishino | 8:50d2509479cd | 45 | unsigned int command_len; |
| kishino | 8:50d2509479cd | 46 | int ret; |
| kishino | 8:50d2509479cd | 47 | |
| kishino | 8:50d2509479cd | 48 | |
| kishino | 8:50d2509479cd | 49 | // Make command payload |
| kishino | 8:50d2509479cd | 50 | payload_len = C_SNIC_UartMsg::makePayload( sizeof(tagSNIC_INIT_REQ_T), (unsigned char *)&req, payload_array ); |
| kishino | 8:50d2509479cd | 51 | // Make all command request |
| kishino | 8:50d2509479cd | 52 | command_len = C_SNIC_UartMsg::makeRequest( UART_CMD_ID_SNIC, payload_array, payload_len, command_array ); |
| kishino | 8:50d2509479cd | 53 | |
| kishino | 8:50d2509479cd | 54 | // Set data for response |
| kishino | 8:50d2509479cd | 55 | mUartCommand.setCommandID( UART_CMD_ID_SNIC ); |
| kishino | 8:50d2509479cd | 56 | mUartCommand.setCommandSID( req.cmd_sid ); |
| kishino | 8:50d2509479cd | 57 | mUartCommand.setResponseBuf( payload_buf->buf ); |
| kishino | 8:50d2509479cd | 58 | |
| kishino | 8:50d2509479cd | 59 | // Send uart command request |
| kishino | 8:50d2509479cd | 60 | sendUart( command_len, command_array ); |
| kishino | 8:50d2509479cd | 61 | |
| kishino | 8:50d2509479cd | 62 | // Wait UART response |
| kishino | 8:50d2509479cd | 63 | ret = mUartCommand.wait(); |
| kishino | 8:50d2509479cd | 64 | if( ret != 0 ) |
| kishino | 8:50d2509479cd | 65 | { |
| kishino | 8:50d2509479cd | 66 | printf( "snic_init failed\r\n" ); |
| kishino | 8:50d2509479cd | 67 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 68 | return -1; |
| kishino | 8:50d2509479cd | 69 | } |
| kishino | 8:50d2509479cd | 70 | |
| kishino | 8:50d2509479cd | 71 | if( mUartCommand.getCommandStatus() != 0 ) |
| kishino | 8:50d2509479cd | 72 | { |
| kishino | 8:50d2509479cd | 73 | printf("snic_init status:%02x\r\n", mUartCommand.getCommandStatus()); |
| kishino | 8:50d2509479cd | 74 | ret = -1; |
| kishino | 8:50d2509479cd | 75 | } |
| kishino | 8:50d2509479cd | 76 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 77 | |
| kishino | 8:50d2509479cd | 78 | return ret; |
| kishino | 8:50d2509479cd | 79 | } |
| kishino | 8:50d2509479cd | 80 | |
| kishino | 8:50d2509479cd | 81 | int C_SNICwifiInterface::getFWVersion( unsigned char *version_p ) |
| kishino | 8:50d2509479cd | 82 | { |
| kishino | 8:50d2509479cd | 83 | // Get buffer for response payload from MemoryPool |
| kishino | 8:50d2509479cd | 84 | tagMEMPOOL_BLOCK_T *payload_buf = gMEMPOOL_PAYLOAD.alloc(); |
| kishino | 8:50d2509479cd | 85 | if( payload_buf == NULL ) |
| kishino | 8:50d2509479cd | 86 | { |
| kishino | 8:50d2509479cd | 87 | printf("getFWVersion payload_buf NULL\r\n"); |
| kishino | 8:50d2509479cd | 88 | return -1; |
| kishino | 8:50d2509479cd | 89 | } |
| kishino | 8:50d2509479cd | 90 | |
| kishino | 8:50d2509479cd | 91 | tagGEN_FW_VER_GET_REQ_T req; |
| kishino | 8:50d2509479cd | 92 | // Make request |
| kishino | 8:50d2509479cd | 93 | req.cmd_sid = UART_CMD_SID_GEN_FW_VER_GET_REQ; |
| kishino | 8:50d2509479cd | 94 | req.seq = mUartRequestSeq++; |
| kishino | 8:50d2509479cd | 95 | |
| kishino | 8:50d2509479cd | 96 | unsigned char payload_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 97 | unsigned char command_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 98 | unsigned short payload_len; |
| kishino | 8:50d2509479cd | 99 | unsigned int command_len; |
| kishino | 8:50d2509479cd | 100 | int ret; |
| kishino | 8:50d2509479cd | 101 | |
| kishino | 8:50d2509479cd | 102 | // Make command payload |
| kishino | 8:50d2509479cd | 103 | payload_len = C_SNIC_UartMsg::makePayload( sizeof(tagGEN_FW_VER_GET_REQ_T), (unsigned char *)&req, payload_array ); |
| kishino | 8:50d2509479cd | 104 | // Make all command request |
| kishino | 8:50d2509479cd | 105 | command_len = C_SNIC_UartMsg::makeRequest( UART_CMD_ID_GEN, payload_array, payload_len, command_array ); |
| kishino | 8:50d2509479cd | 106 | |
| kishino | 8:50d2509479cd | 107 | // Set data for response |
| kishino | 8:50d2509479cd | 108 | mUartCommand.setCommandID( UART_CMD_ID_GEN ); |
| kishino | 8:50d2509479cd | 109 | mUartCommand.setCommandSID( req.cmd_sid ); |
| kishino | 8:50d2509479cd | 110 | mUartCommand.setResponseBuf( payload_buf->buf ); |
| kishino | 8:50d2509479cd | 111 | |
| kishino | 8:50d2509479cd | 112 | // Send uart command request |
| kishino | 8:50d2509479cd | 113 | sendUart( command_len, command_array ); |
| kishino | 8:50d2509479cd | 114 | |
| kishino | 8:50d2509479cd | 115 | // Wait UART response |
| kishino | 8:50d2509479cd | 116 | ret = mUartCommand.wait(); |
| kishino | 8:50d2509479cd | 117 | if( ret != 0 ) |
| kishino | 8:50d2509479cd | 118 | { |
| kishino | 8:50d2509479cd | 119 | printf( "getFWversion failed\r\n" ); |
| kishino | 8:50d2509479cd | 120 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 121 | return -1; |
| kishino | 8:50d2509479cd | 122 | } |
| kishino | 8:50d2509479cd | 123 | |
| kishino | 8:50d2509479cd | 124 | if( mUartCommand.getCommandStatus() == 0 ) |
| kishino | 8:50d2509479cd | 125 | { |
| kishino | 8:50d2509479cd | 126 | unsigned char version_len = payload_buf->buf[3]; |
| kishino | 8:50d2509479cd | 127 | memcpy( version_p, &payload_buf->buf[4], version_len ); |
| kishino | 8:50d2509479cd | 128 | } |
| kishino | 8:50d2509479cd | 129 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 130 | return 0; |
| kishino | 8:50d2509479cd | 131 | } |
| kishino | 8:50d2509479cd | 132 | |
| kishino | 8:50d2509479cd | 133 | int C_SNICwifiInterface::connect(const char *ssid_p, unsigned char ssid_len, E_SECURITY sec_type |
| kishino | 8:50d2509479cd | 134 | , const char *sec_key_p, unsigned char sec_key_len) |
| kishino | 8:50d2509479cd | 135 | { |
| kishino | 8:50d2509479cd | 136 | // Parameter check(SSID) |
| kishino | 8:50d2509479cd | 137 | if( (ssid_p == NULL) || (ssid_len == 0) ) |
| kishino | 8:50d2509479cd | 138 | { |
| kishino | 8:50d2509479cd | 139 | printf( "connect failed [ parameter NG:SSID ]\r\n" ); |
| kishino | 8:50d2509479cd | 140 | return -1; |
| kishino | 8:50d2509479cd | 141 | } |
| kishino | 8:50d2509479cd | 142 | |
| kishino | 8:50d2509479cd | 143 | // Parameter check(Security key) |
| kishino | 8:50d2509479cd | 144 | if( (sec_type != e_SEC_OPEN) && ( (sec_key_len == 0) || (sec_key_p == NULL) ) ) |
| kishino | 8:50d2509479cd | 145 | { |
| kishino | 8:50d2509479cd | 146 | printf( "connect failed [ parameter NG:Security key ]\r\n" ); |
| kishino | 8:50d2509479cd | 147 | return -1; |
| kishino | 8:50d2509479cd | 148 | } |
| kishino | 8:50d2509479cd | 149 | |
| kishino | 8:50d2509479cd | 150 | // Get buffer for response payloadfrom MemoryPool |
| kishino | 8:50d2509479cd | 151 | tagMEMPOOL_BLOCK_T *payload_buf = gMEMPOOL_PAYLOAD.alloc(); |
| kishino | 8:50d2509479cd | 152 | if( payload_buf == NULL ) |
| kishino | 8:50d2509479cd | 153 | { |
| kishino | 8:50d2509479cd | 154 | printf("connect payload_buf NULL\r\n"); |
| kishino | 8:50d2509479cd | 155 | return -1; |
| kishino | 8:50d2509479cd | 156 | } |
| kishino | 8:50d2509479cd | 157 | |
| kishino | 8:50d2509479cd | 158 | unsigned char buf[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 159 | unsigned char payload_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 160 | unsigned char command_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 161 | unsigned int buf_len = 0; |
| kishino | 8:50d2509479cd | 162 | unsigned short payload_len; |
| kishino | 8:50d2509479cd | 163 | unsigned int command_len; |
| kishino | 8:50d2509479cd | 164 | int ret; |
| kishino | 8:50d2509479cd | 165 | |
| kishino | 8:50d2509479cd | 166 | memset( buf, 0, UART_REQUEST_PAYLOAD_MAX ); |
| kishino | 8:50d2509479cd | 167 | // Make request |
| kishino | 8:50d2509479cd | 168 | buf[0] = UART_CMD_SID_WIFI_JOIN_REQ; |
| kishino | 8:50d2509479cd | 169 | buf_len++; |
| kishino | 8:50d2509479cd | 170 | buf[1] = mUartRequestSeq++; |
| kishino | 8:50d2509479cd | 171 | buf_len++; |
| kishino | 8:50d2509479cd | 172 | // SSID |
| kishino | 8:50d2509479cd | 173 | memcpy( &buf[2], ssid_p, ssid_len ); |
| kishino | 8:50d2509479cd | 174 | buf_len += ssid_len; |
| kishino | 8:50d2509479cd | 175 | buf_len++; |
| kishino | 8:50d2509479cd | 176 | |
| kishino | 8:50d2509479cd | 177 | // Security mode |
| kishino | 8:50d2509479cd | 178 | buf[ buf_len ] = (unsigned char)sec_type; |
| kishino | 8:50d2509479cd | 179 | buf_len++; |
| kishino | 8:50d2509479cd | 180 | |
| kishino | 8:50d2509479cd | 181 | // Security key |
| kishino | 8:50d2509479cd | 182 | if( sec_type != e_SEC_OPEN ) |
| kishino | 8:50d2509479cd | 183 | { |
| kishino | 8:50d2509479cd | 184 | buf[ buf_len ] = sec_key_len; |
| kishino | 8:50d2509479cd | 185 | buf_len++; |
| kishino | 8:50d2509479cd | 186 | if( sec_key_len > 0 ) |
| kishino | 8:50d2509479cd | 187 | { |
| kishino | 8:50d2509479cd | 188 | memcpy( &buf[buf_len], sec_key_p, sec_key_len ); |
| kishino | 8:50d2509479cd | 189 | buf_len += sec_key_len; |
| kishino | 8:50d2509479cd | 190 | } |
| kishino | 8:50d2509479cd | 191 | } |
| kishino | 8:50d2509479cd | 192 | // Make command payload |
| kishino | 8:50d2509479cd | 193 | payload_len = C_SNIC_UartMsg::makePayload( buf_len, (unsigned char *)buf, payload_array ); |
| kishino | 8:50d2509479cd | 194 | // Make all command request |
| kishino | 8:50d2509479cd | 195 | command_len = C_SNIC_UartMsg::makeRequest( UART_CMD_ID_WIFI, payload_array, payload_len, command_array ); |
| kishino | 8:50d2509479cd | 196 | // Set data for response |
| kishino | 8:50d2509479cd | 197 | mUartCommand.setCommandID( UART_CMD_ID_WIFI ); |
| kishino | 8:50d2509479cd | 198 | mUartCommand.setCommandSID( UART_CMD_SID_WIFI_JOIN_REQ ); |
| kishino | 8:50d2509479cd | 199 | mUartCommand.setResponseBuf( payload_buf->buf ); |
| kishino | 8:50d2509479cd | 200 | |
| kishino | 8:50d2509479cd | 201 | // Send uart command request |
| kishino | 8:50d2509479cd | 202 | sendUart( command_len, command_array ); |
| kishino | 8:50d2509479cd | 203 | |
| kishino | 8:50d2509479cd | 204 | // Wait UART response |
| kishino | 8:50d2509479cd | 205 | ret = mUartCommand.wait(); |
| kishino | 8:50d2509479cd | 206 | if( ret != 0 ) |
| kishino | 8:50d2509479cd | 207 | { |
| kishino | 8:50d2509479cd | 208 | printf( "join failed\r\n" ); |
| kishino | 8:50d2509479cd | 209 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 210 | return -1; |
| kishino | 8:50d2509479cd | 211 | } |
| kishino | 8:50d2509479cd | 212 | |
| kishino | 8:50d2509479cd | 213 | if( mUartCommand.getCommandStatus() != 0 ) |
| kishino | 8:50d2509479cd | 214 | { |
| kishino | 8:50d2509479cd | 215 | printf("join status:%02x\r\n", mUartCommand.getCommandStatus()); |
| kishino | 8:50d2509479cd | 216 | ret = -1; |
| kishino | 8:50d2509479cd | 217 | } |
| kishino | 8:50d2509479cd | 218 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 219 | |
| kishino | 8:50d2509479cd | 220 | return ret; |
| kishino | 8:50d2509479cd | 221 | } |
| kishino | 8:50d2509479cd | 222 | |
| kishino | 8:50d2509479cd | 223 | int C_SNICwifiInterface::disconnect() |
| kishino | 8:50d2509479cd | 224 | { |
| kishino | 8:50d2509479cd | 225 | // Get buffer for response payloadfrom MemoryPool |
| kishino | 8:50d2509479cd | 226 | tagMEMPOOL_BLOCK_T *payload_buf = gMEMPOOL_PAYLOAD.alloc(); |
| kishino | 8:50d2509479cd | 227 | if( payload_buf == NULL ) |
| kishino | 8:50d2509479cd | 228 | { |
| kishino | 8:50d2509479cd | 229 | printf("disconnect payload_buf NULL\r\n"); |
| kishino | 8:50d2509479cd | 230 | return -1; |
| kishino | 8:50d2509479cd | 231 | } |
| kishino | 8:50d2509479cd | 232 | |
| kishino | 8:50d2509479cd | 233 | tagWIFI_DISCONNECT_REQ_T req; |
| kishino | 8:50d2509479cd | 234 | unsigned char payload_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 235 | unsigned char command_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 236 | unsigned short payload_len; |
| kishino | 8:50d2509479cd | 237 | unsigned int command_len; |
| kishino | 8:50d2509479cd | 238 | int ret; |
| kishino | 8:50d2509479cd | 239 | |
| kishino | 8:50d2509479cd | 240 | // Make request |
| kishino | 8:50d2509479cd | 241 | req.cmd_sid = UART_CMD_SID_WIFI_DISCONNECT_REQ; |
| kishino | 8:50d2509479cd | 242 | req.seq = mUartRequestSeq++; |
| kishino | 8:50d2509479cd | 243 | |
| kishino | 8:50d2509479cd | 244 | // Make command payload |
| kishino | 8:50d2509479cd | 245 | payload_len = C_SNIC_UartMsg::makePayload( sizeof(tagWIFI_DISCONNECT_REQ_T), (unsigned char *)&req, payload_array ); |
| kishino | 8:50d2509479cd | 246 | // Make all command request |
| kishino | 8:50d2509479cd | 247 | command_len = C_SNIC_UartMsg::makeRequest( UART_CMD_ID_WIFI, payload_array, payload_len, command_array ); |
| kishino | 8:50d2509479cd | 248 | |
| kishino | 8:50d2509479cd | 249 | // Set data for response |
| kishino | 8:50d2509479cd | 250 | mUartCommand.setCommandID( UART_CMD_ID_WIFI ); |
| kishino | 8:50d2509479cd | 251 | mUartCommand.setCommandSID( req.cmd_sid ); |
| kishino | 8:50d2509479cd | 252 | mUartCommand.setResponseBuf( payload_buf->buf ); |
| kishino | 8:50d2509479cd | 253 | |
| kishino | 8:50d2509479cd | 254 | // Send uart command request |
| kishino | 8:50d2509479cd | 255 | sendUart( command_len, command_array ); |
| kishino | 8:50d2509479cd | 256 | |
| kishino | 8:50d2509479cd | 257 | // Wait UART response |
| kishino | 8:50d2509479cd | 258 | ret = mUartCommand.wait(); |
| kishino | 8:50d2509479cd | 259 | if( ret != 0 ) |
| kishino | 8:50d2509479cd | 260 | { |
| kishino | 8:50d2509479cd | 261 | printf( "disconnect failed\r\n" ); |
| kishino | 8:50d2509479cd | 262 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 263 | return -1; |
| kishino | 8:50d2509479cd | 264 | } |
| kishino | 8:50d2509479cd | 265 | |
| kishino | 8:50d2509479cd | 266 | if( mUartCommand.getCommandStatus() != 0 ) |
| kishino | 8:50d2509479cd | 267 | { |
| kishino | 8:50d2509479cd | 268 | printf("disconnect status:%02x\r\n", mUartCommand.getCommandStatus()); |
| kishino | 8:50d2509479cd | 269 | ret = -1; |
| kishino | 8:50d2509479cd | 270 | } |
| kishino | 8:50d2509479cd | 271 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 272 | return ret; |
| kishino | 8:50d2509479cd | 273 | } |
| kishino | 8:50d2509479cd | 274 | |
| kishino | 8:50d2509479cd | 275 | int C_SNICwifiInterface::scan( const char *ssid_p, unsigned char *bssid_p |
| kishino | 8:50d2509479cd | 276 | , void (*result_handler_p)(tagSCAN_RESULT_T *scan_result) ) |
| kishino | 8:50d2509479cd | 277 | { |
| kishino | 8:50d2509479cd | 278 | // Get buffer for response payloadfrom MemoryPool |
| kishino | 8:50d2509479cd | 279 | tagMEMPOOL_BLOCK_T *payload_buf = gMEMPOOL_PAYLOAD.alloc(); |
| kishino | 8:50d2509479cd | 280 | if( payload_buf == NULL ) |
| kishino | 8:50d2509479cd | 281 | { |
| kishino | 8:50d2509479cd | 282 | printf("scan payload_buf NULL\r\n"); |
| kishino | 8:50d2509479cd | 283 | return -1; |
| kishino | 8:50d2509479cd | 284 | } |
| kishino | 8:50d2509479cd | 285 | |
| kishino | 8:50d2509479cd | 286 | tagWIFI_SCAN_REQ_T req; |
| kishino | 8:50d2509479cd | 287 | unsigned char payload_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 288 | unsigned char command_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 289 | unsigned short payload_len; |
| kishino | 8:50d2509479cd | 290 | unsigned int command_len; |
| kishino | 8:50d2509479cd | 291 | unsigned int buf_len = 0; |
| kishino | 8:50d2509479cd | 292 | int ret; |
| kishino | 8:50d2509479cd | 293 | |
| kishino | 8:50d2509479cd | 294 | memset( &req, 0, sizeof(tagWIFI_SCAN_REQ_T) ); |
| kishino | 8:50d2509479cd | 295 | // Make request |
| kishino | 8:50d2509479cd | 296 | req.cmd_sid = UART_CMD_SID_WIFI_SCAN_REQ; |
| kishino | 8:50d2509479cd | 297 | buf_len++; |
| kishino | 8:50d2509479cd | 298 | req.seq = mUartRequestSeq++; |
| kishino | 8:50d2509479cd | 299 | buf_len++; |
| kishino | 8:50d2509479cd | 300 | |
| kishino | 8:50d2509479cd | 301 | // Set scan type(Active scan) |
| kishino | 8:50d2509479cd | 302 | req.scan_type = 0; |
| kishino | 8:50d2509479cd | 303 | buf_len++; |
| kishino | 8:50d2509479cd | 304 | // Set bss type(any) |
| kishino | 8:50d2509479cd | 305 | req.bss_type = 2; |
| kishino | 8:50d2509479cd | 306 | buf_len++; |
| kishino | 8:50d2509479cd | 307 | // Set BSSID |
| kishino | 8:50d2509479cd | 308 | if( bssid_p != NULL ) |
| kishino | 8:50d2509479cd | 309 | { |
| kishino | 8:50d2509479cd | 310 | memcpy( req.bssid, bssid_p, BSSID_MAC_LENTH ); |
| kishino | 8:50d2509479cd | 311 | } |
| kishino | 8:50d2509479cd | 312 | buf_len += BSSID_MAC_LENTH; |
| kishino | 8:50d2509479cd | 313 | // Set channel list(0) |
| kishino | 8:50d2509479cd | 314 | req.chan_list = 0; |
| kishino | 8:50d2509479cd | 315 | buf_len++; |
| kishino | 8:50d2509479cd | 316 | //Set SSID |
| kishino | 8:50d2509479cd | 317 | if( ssid_p != NULL ) |
| kishino | 8:50d2509479cd | 318 | { |
| kishino | 8:50d2509479cd | 319 | strcpy( (char *)req.ssid, ssid_p ); |
| kishino | 8:50d2509479cd | 320 | buf_len += strlen(ssid_p); |
| kishino | 8:50d2509479cd | 321 | } |
| kishino | 8:50d2509479cd | 322 | buf_len++; |
| kishino | 8:50d2509479cd | 323 | |
| kishino | 8:50d2509479cd | 324 | // Make command payload |
| kishino | 8:50d2509479cd | 325 | payload_len = C_SNIC_UartMsg::makePayload( buf_len, (unsigned char *)&req, payload_array ); |
| kishino | 8:50d2509479cd | 326 | |
| kishino | 8:50d2509479cd | 327 | // Make all command request |
| kishino | 8:50d2509479cd | 328 | command_len = C_SNIC_UartMsg::makeRequest( UART_CMD_ID_WIFI, payload_array, payload_len, command_array ); |
| kishino | 8:50d2509479cd | 329 | |
| kishino | 8:50d2509479cd | 330 | // Set data for response |
| kishino | 8:50d2509479cd | 331 | mUartCommand.setCommandID( UART_CMD_ID_WIFI ); |
| kishino | 8:50d2509479cd | 332 | mUartCommand.setCommandSID( req.cmd_sid ); |
| kishino | 8:50d2509479cd | 333 | mUartCommand.setResponseBuf( payload_buf->buf ); |
| kishino | 8:50d2509479cd | 334 | // Set scan result callback |
| kishino | 8:50d2509479cd | 335 | mUartCommand.setScanResultHandler( result_handler_p ); |
| kishino | 8:50d2509479cd | 336 | |
| kishino | 8:50d2509479cd | 337 | // Send uart command request |
| kishino | 8:50d2509479cd | 338 | sendUart( command_len, command_array ); |
| kishino | 8:50d2509479cd | 339 | |
| kishino | 8:50d2509479cd | 340 | // Wait UART response |
| kishino | 8:50d2509479cd | 341 | ret = mUartCommand.wait(); |
| kishino | 8:50d2509479cd | 342 | printf( "scan wait:%d\r\n", ret ); |
| kishino | 8:50d2509479cd | 343 | if( ret != 0 ) |
| kishino | 8:50d2509479cd | 344 | { |
| kishino | 8:50d2509479cd | 345 | printf( "scan failed\r\n" ); |
| kishino | 8:50d2509479cd | 346 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 347 | return -1; |
| kishino | 8:50d2509479cd | 348 | } |
| kishino | 8:50d2509479cd | 349 | |
| kishino | 8:50d2509479cd | 350 | if( mUartCommand.getCommandStatus() != 0 ) |
| kishino | 8:50d2509479cd | 351 | { |
| kishino | 8:50d2509479cd | 352 | printf("scan status:%02x\r\n", mUartCommand.getCommandStatus()); |
| kishino | 8:50d2509479cd | 353 | ret = -1; |
| kishino | 8:50d2509479cd | 354 | } |
| kishino | 8:50d2509479cd | 355 | |
| kishino | 8:50d2509479cd | 356 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 357 | |
| kishino | 8:50d2509479cd | 358 | return ret; |
| kishino | 8:50d2509479cd | 359 | } |
| kishino | 8:50d2509479cd | 360 | |
| kishino | 8:50d2509479cd | 361 | int C_SNICwifiInterface::wifi_on( const char *country_p ) |
| kishino | 8:50d2509479cd | 362 | { |
| kishino | 8:50d2509479cd | 363 | // Parameter check |
| kishino | 8:50d2509479cd | 364 | if( country_p == NULL ) |
| kishino | 8:50d2509479cd | 365 | { |
| kishino | 8:50d2509479cd | 366 | printf("wifi_on parameter error\r\n"); |
| kishino | 8:50d2509479cd | 367 | return -1; |
| kishino | 8:50d2509479cd | 368 | } |
| kishino | 8:50d2509479cd | 369 | |
| kishino | 8:50d2509479cd | 370 | // Get buffer for response payloadfrom MemoryPool |
| kishino | 8:50d2509479cd | 371 | tagMEMPOOL_BLOCK_T *payload_buf = gMEMPOOL_PAYLOAD.alloc(); |
| kishino | 8:50d2509479cd | 372 | if( payload_buf == NULL ) |
| kishino | 8:50d2509479cd | 373 | { |
| kishino | 8:50d2509479cd | 374 | printf("wifi_on payload_buf NULL\r\n"); |
| kishino | 8:50d2509479cd | 375 | return -1; |
| kishino | 8:50d2509479cd | 376 | } |
| kishino | 8:50d2509479cd | 377 | |
| kishino | 8:50d2509479cd | 378 | tagWIFI_ON_REQ_T req; |
| kishino | 8:50d2509479cd | 379 | unsigned char payload_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 380 | unsigned char command_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 381 | unsigned short payload_len; |
| kishino | 8:50d2509479cd | 382 | unsigned int command_len; |
| kishino | 8:50d2509479cd | 383 | int ret; |
| kishino | 8:50d2509479cd | 384 | |
| kishino | 8:50d2509479cd | 385 | // Make request |
| kishino | 8:50d2509479cd | 386 | req.cmd_sid = UART_CMD_SID_WIFI_ON_REQ; |
| kishino | 8:50d2509479cd | 387 | req.seq = mUartRequestSeq++; |
| kishino | 8:50d2509479cd | 388 | memcpy( req.country, country_p, COUNTRYC_CODE_LENTH ); |
| kishino | 8:50d2509479cd | 389 | |
| kishino | 8:50d2509479cd | 390 | // Make command payload |
| kishino | 8:50d2509479cd | 391 | payload_len = C_SNIC_UartMsg::makePayload( sizeof(tagWIFI_ON_REQ_T), (unsigned char *)&req, payload_array ); |
| kishino | 8:50d2509479cd | 392 | // Make all command request |
| kishino | 8:50d2509479cd | 393 | command_len = C_SNIC_UartMsg::makeRequest( UART_CMD_ID_WIFI, payload_array, payload_len, command_array ); |
| kishino | 8:50d2509479cd | 394 | |
| kishino | 8:50d2509479cd | 395 | // Set data for response |
| kishino | 8:50d2509479cd | 396 | mUartCommand.setCommandID( UART_CMD_ID_WIFI ); |
| kishino | 8:50d2509479cd | 397 | mUartCommand.setCommandSID( req.cmd_sid ); |
| kishino | 8:50d2509479cd | 398 | mUartCommand.setResponseBuf( payload_buf->buf ); |
| kishino | 8:50d2509479cd | 399 | |
| kishino | 8:50d2509479cd | 400 | // Send uart command request |
| kishino | 8:50d2509479cd | 401 | sendUart( command_len, command_array ); |
| kishino | 8:50d2509479cd | 402 | |
| kishino | 8:50d2509479cd | 403 | // Wait UART response |
| kishino | 8:50d2509479cd | 404 | ret = mUartCommand.wait(); |
| kishino | 8:50d2509479cd | 405 | if( ret != 0 ) |
| kishino | 8:50d2509479cd | 406 | { |
| kishino | 8:50d2509479cd | 407 | printf( "wifi_on failed\r\n" ); |
| kishino | 8:50d2509479cd | 408 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 409 | return -1; |
| kishino | 8:50d2509479cd | 410 | } |
| kishino | 8:50d2509479cd | 411 | |
| kishino | 8:50d2509479cd | 412 | if( mUartCommand.getCommandStatus() != 0 ) |
| kishino | 8:50d2509479cd | 413 | { |
| kishino | 8:50d2509479cd | 414 | printf("wifi_on status:%02x\r\n", mUartCommand.getCommandStatus()); |
| kishino | 8:50d2509479cd | 415 | ret = -1; |
| kishino | 8:50d2509479cd | 416 | } |
| kishino | 8:50d2509479cd | 417 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 418 | |
| kishino | 8:50d2509479cd | 419 | return ret; |
| kishino | 8:50d2509479cd | 420 | } |
| kishino | 8:50d2509479cd | 421 | |
| kishino | 8:50d2509479cd | 422 | int C_SNICwifiInterface::wifi_off() |
| kishino | 8:50d2509479cd | 423 | { |
| kishino | 8:50d2509479cd | 424 | // Get buffer for response payloadfrom MemoryPool |
| kishino | 8:50d2509479cd | 425 | tagMEMPOOL_BLOCK_T *payload_buf = gMEMPOOL_PAYLOAD.alloc(); |
| kishino | 8:50d2509479cd | 426 | if( payload_buf == NULL ) |
| kishino | 8:50d2509479cd | 427 | { |
| kishino | 8:50d2509479cd | 428 | printf("wifi_off payload_buf NULL\r\n"); |
| kishino | 8:50d2509479cd | 429 | return -1; |
| kishino | 8:50d2509479cd | 430 | } |
| kishino | 8:50d2509479cd | 431 | |
| kishino | 8:50d2509479cd | 432 | tagWIFI_OFF_REQ_T req; |
| kishino | 8:50d2509479cd | 433 | unsigned char payload_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 434 | unsigned char command_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 435 | unsigned short payload_len; |
| kishino | 8:50d2509479cd | 436 | unsigned int command_len; |
| kishino | 8:50d2509479cd | 437 | int ret; |
| kishino | 8:50d2509479cd | 438 | |
| kishino | 8:50d2509479cd | 439 | // Make request |
| kishino | 8:50d2509479cd | 440 | req.cmd_sid = UART_CMD_SID_WIFI_OFF_REQ; |
| kishino | 8:50d2509479cd | 441 | req.seq = mUartRequestSeq++; |
| kishino | 8:50d2509479cd | 442 | |
| kishino | 8:50d2509479cd | 443 | // Make command payload |
| kishino | 8:50d2509479cd | 444 | payload_len = C_SNIC_UartMsg::makePayload( sizeof(tagWIFI_OFF_REQ_T), (unsigned char *)&req, payload_array ); |
| kishino | 8:50d2509479cd | 445 | // Make all command request |
| kishino | 8:50d2509479cd | 446 | command_len = C_SNIC_UartMsg::makeRequest( UART_CMD_ID_WIFI, payload_array, payload_len, command_array ); |
| kishino | 8:50d2509479cd | 447 | |
| kishino | 8:50d2509479cd | 448 | // Set data for response |
| kishino | 8:50d2509479cd | 449 | mUartCommand.setCommandID( UART_CMD_ID_WIFI ); |
| kishino | 8:50d2509479cd | 450 | mUartCommand.setCommandSID( req.cmd_sid ); |
| kishino | 8:50d2509479cd | 451 | mUartCommand.setResponseBuf( payload_buf->buf ); |
| kishino | 8:50d2509479cd | 452 | |
| kishino | 8:50d2509479cd | 453 | // Send uart command request |
| kishino | 8:50d2509479cd | 454 | sendUart( command_len, command_array ); |
| kishino | 8:50d2509479cd | 455 | |
| kishino | 8:50d2509479cd | 456 | // Wait UART response |
| kishino | 8:50d2509479cd | 457 | ret = mUartCommand.wait(); |
| kishino | 8:50d2509479cd | 458 | if( ret != 0 ) |
| kishino | 8:50d2509479cd | 459 | { |
| kishino | 8:50d2509479cd | 460 | printf( "wifi_off failed\r\n" ); |
| kishino | 8:50d2509479cd | 461 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 462 | return -1; |
| kishino | 8:50d2509479cd | 463 | } |
| kishino | 8:50d2509479cd | 464 | |
| kishino | 8:50d2509479cd | 465 | if( mUartCommand.getCommandStatus() != 0 ) |
| kishino | 8:50d2509479cd | 466 | { |
| kishino | 8:50d2509479cd | 467 | printf("wifi_off status:%02x\r\n", mUartCommand.getCommandStatus()); |
| kishino | 8:50d2509479cd | 468 | ret = -1; |
| kishino | 8:50d2509479cd | 469 | } |
| kishino | 8:50d2509479cd | 470 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 471 | |
| kishino | 8:50d2509479cd | 472 | return ret; |
| kishino | 8:50d2509479cd | 473 | } |
| kishino | 8:50d2509479cd | 474 | |
| kishino | 8:50d2509479cd | 475 | int C_SNICwifiInterface::getRssi( signed char *rssi_p ) |
| kishino | 8:50d2509479cd | 476 | { |
| kishino | 8:50d2509479cd | 477 | if( rssi_p == NULL ) |
| kishino | 8:50d2509479cd | 478 | { |
| kishino | 8:50d2509479cd | 479 | printf("getRssi parameter error\r\n"); |
| kishino | 8:50d2509479cd | 480 | return -1; |
| kishino | 8:50d2509479cd | 481 | } |
| kishino | 8:50d2509479cd | 482 | |
| kishino | 8:50d2509479cd | 483 | // Get buffer for response payload from MemoryPool |
| kishino | 8:50d2509479cd | 484 | tagMEMPOOL_BLOCK_T *payload_buf = gMEMPOOL_PAYLOAD.alloc(); |
| kishino | 8:50d2509479cd | 485 | if( payload_buf == NULL ) |
| kishino | 8:50d2509479cd | 486 | { |
| kishino | 8:50d2509479cd | 487 | printf("getRssi payload_buf NULL\r\n"); |
| kishino | 8:50d2509479cd | 488 | return -1; |
| kishino | 8:50d2509479cd | 489 | } |
| kishino | 8:50d2509479cd | 490 | |
| kishino | 8:50d2509479cd | 491 | tagWIFI_GET_STA_RSSI_REQ_T req; |
| kishino | 8:50d2509479cd | 492 | unsigned char payload_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 493 | unsigned char command_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 494 | unsigned short payload_len; |
| kishino | 8:50d2509479cd | 495 | unsigned int command_len; |
| kishino | 8:50d2509479cd | 496 | int ret; |
| kishino | 8:50d2509479cd | 497 | |
| kishino | 8:50d2509479cd | 498 | // Make request |
| kishino | 8:50d2509479cd | 499 | req.cmd_sid = UART_CMD_SID_WIFI_GET_STA_RSSI_REQ; |
| kishino | 8:50d2509479cd | 500 | req.seq = mUartRequestSeq++; |
| kishino | 8:50d2509479cd | 501 | |
| kishino | 8:50d2509479cd | 502 | // Make command payload |
| kishino | 8:50d2509479cd | 503 | payload_len = C_SNIC_UartMsg::makePayload( sizeof(tagWIFI_GET_STA_RSSI_REQ_T), (unsigned char *)&req, payload_array ); |
| kishino | 8:50d2509479cd | 504 | // Make all command request |
| kishino | 8:50d2509479cd | 505 | command_len = C_SNIC_UartMsg::makeRequest( UART_CMD_ID_WIFI, payload_array, payload_len, command_array ); |
| kishino | 8:50d2509479cd | 506 | |
| kishino | 8:50d2509479cd | 507 | // Set data for response |
| kishino | 8:50d2509479cd | 508 | mUartCommand.setCommandID( UART_CMD_ID_WIFI ); |
| kishino | 8:50d2509479cd | 509 | mUartCommand.setCommandSID( req.cmd_sid ); |
| kishino | 8:50d2509479cd | 510 | mUartCommand.setResponseBuf( payload_buf->buf ); |
| kishino | 8:50d2509479cd | 511 | |
| kishino | 8:50d2509479cd | 512 | // Send uart command request |
| kishino | 8:50d2509479cd | 513 | sendUart( command_len, command_array ); |
| kishino | 8:50d2509479cd | 514 | |
| kishino | 8:50d2509479cd | 515 | // Wait UART response |
| kishino | 8:50d2509479cd | 516 | ret = mUartCommand.wait(); |
| kishino | 8:50d2509479cd | 517 | if( ret != 0 ) |
| kishino | 8:50d2509479cd | 518 | { |
| kishino | 8:50d2509479cd | 519 | printf( "getRssi failed\r\n" ); |
| kishino | 8:50d2509479cd | 520 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 521 | return -1; |
| kishino | 8:50d2509479cd | 522 | } |
| kishino | 8:50d2509479cd | 523 | |
| kishino | 8:50d2509479cd | 524 | *rssi_p = (signed char)payload_buf->buf[2]; |
| kishino | 8:50d2509479cd | 525 | |
| kishino | 8:50d2509479cd | 526 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 527 | return 0; |
| kishino | 8:50d2509479cd | 528 | } |
| kishino | 8:50d2509479cd | 529 | |
| kishino | 8:50d2509479cd | 530 | int C_SNICwifiInterface::getWifiStatus( tagWIFI_STATUS_T *status_p) |
| kishino | 8:50d2509479cd | 531 | { |
| kishino | 8:50d2509479cd | 532 | if( status_p == NULL ) |
| kishino | 8:50d2509479cd | 533 | { |
| kishino | 8:50d2509479cd | 534 | printf("getWifiStatus parameter error\r\n"); |
| kishino | 8:50d2509479cd | 535 | return -1; |
| kishino | 8:50d2509479cd | 536 | } |
| kishino | 8:50d2509479cd | 537 | |
| kishino | 8:50d2509479cd | 538 | // Get buffer for response payload from MemoryPool |
| kishino | 8:50d2509479cd | 539 | tagMEMPOOL_BLOCK_T *payload_buf = gMEMPOOL_PAYLOAD.alloc(); |
| kishino | 8:50d2509479cd | 540 | if( payload_buf == NULL ) |
| kishino | 8:50d2509479cd | 541 | { |
| kishino | 8:50d2509479cd | 542 | printf("getWifiStatus payload_buf NULL\r\n"); |
| kishino | 8:50d2509479cd | 543 | return -1; |
| kishino | 8:50d2509479cd | 544 | } |
| kishino | 8:50d2509479cd | 545 | |
| kishino | 8:50d2509479cd | 546 | tagWIFI_GET_STATUS_REQ_T req; |
| kishino | 8:50d2509479cd | 547 | unsigned char payload_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 548 | unsigned char command_array[UART_REQUEST_PAYLOAD_MAX]; |
| kishino | 8:50d2509479cd | 549 | unsigned short payload_len; |
| kishino | 8:50d2509479cd | 550 | unsigned int command_len; |
| kishino | 8:50d2509479cd | 551 | int ret; |
| kishino | 8:50d2509479cd | 552 | |
| kishino | 8:50d2509479cd | 553 | // Make request |
| kishino | 8:50d2509479cd | 554 | req.cmd_sid = UART_CMD_SID_WIFI_GET_STATUS_REQ; |
| kishino | 8:50d2509479cd | 555 | req.seq = mUartRequestSeq++; |
| kishino | 8:50d2509479cd | 556 | req.interface = 0; |
| kishino | 8:50d2509479cd | 557 | |
| kishino | 8:50d2509479cd | 558 | // Make command payload |
| kishino | 8:50d2509479cd | 559 | payload_len = C_SNIC_UartMsg::makePayload( sizeof(tagWIFI_GET_STATUS_REQ_T), (unsigned char *)&req, payload_array ); |
| kishino | 8:50d2509479cd | 560 | // Make all command request |
| kishino | 8:50d2509479cd | 561 | command_len = C_SNIC_UartMsg::makeRequest( UART_CMD_ID_WIFI, payload_array, payload_len, command_array ); |
| kishino | 8:50d2509479cd | 562 | |
| kishino | 8:50d2509479cd | 563 | // Set data for response |
| kishino | 8:50d2509479cd | 564 | mUartCommand.setCommandID( UART_CMD_ID_WIFI ); |
| kishino | 8:50d2509479cd | 565 | mUartCommand.setCommandSID( req.cmd_sid ); |
| kishino | 8:50d2509479cd | 566 | mUartCommand.setResponseBuf( payload_buf->buf ); |
| kishino | 8:50d2509479cd | 567 | |
| kishino | 8:50d2509479cd | 568 | // Send uart command request |
| kishino | 8:50d2509479cd | 569 | sendUart( command_len, command_array ); |
| kishino | 8:50d2509479cd | 570 | |
| kishino | 8:50d2509479cd | 571 | // Wait UART response |
| kishino | 8:50d2509479cd | 572 | ret = mUartCommand.wait(); |
| kishino | 8:50d2509479cd | 573 | if( ret != 0 ) |
| kishino | 8:50d2509479cd | 574 | { |
| kishino | 8:50d2509479cd | 575 | printf( "getWifiStatus failed\r\n" ); |
| kishino | 8:50d2509479cd | 576 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 577 | return -1; |
| kishino | 8:50d2509479cd | 578 | } |
| kishino | 8:50d2509479cd | 579 | |
| kishino | 8:50d2509479cd | 580 | // set status |
| kishino | 8:50d2509479cd | 581 | status_p->status = (E_WIFI_STATUS)payload_buf->buf[2]; |
| kishino | 8:50d2509479cd | 582 | |
| kishino | 8:50d2509479cd | 583 | // set Mac address |
| kishino | 8:50d2509479cd | 584 | if( status_p->status != e_STATUS_OFF ) |
| kishino | 8:50d2509479cd | 585 | { |
| kishino | 8:50d2509479cd | 586 | memcpy( status_p->mac_address, &payload_buf->buf[3], BSSID_MAC_LENTH ); |
| kishino | 8:50d2509479cd | 587 | } |
| kishino | 8:50d2509479cd | 588 | |
| kishino | 8:50d2509479cd | 589 | // set SSID |
| kishino | 8:50d2509479cd | 590 | if( ( status_p->status == e_STA_JOINED ) == ( status_p->status == e_AP_STARTED ) ) |
| kishino | 8:50d2509479cd | 591 | { |
| kishino | 8:50d2509479cd | 592 | memcpy( status_p->ssid, &payload_buf->buf[9], strlen( (char *)&payload_buf->buf[9]) ); |
| kishino | 8:50d2509479cd | 593 | } |
| kishino | 8:50d2509479cd | 594 | |
| kishino | 8:50d2509479cd | 595 | gMEMPOOL_PAYLOAD.free( payload_buf ); |
| kishino | 8:50d2509479cd | 596 | return 0; |
| kishino | 8:50d2509479cd | 597 | } |
muRata

Murata TypeYD