Customized SNICInterface

Committer:
komoritan
Date:
Tue Feb 10 12:22:17 2015 +0000
Revision:
0:7251441ac366
Customized

Who changed what in which revision?

UserRevisionLine numberNew contents of line
komoritan 0:7251441ac366 1 /* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
komoritan 0:7251441ac366 2 * muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
komoritan 0:7251441ac366 3 *
komoritan 0:7251441ac366 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
komoritan 0:7251441ac366 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
komoritan 0:7251441ac366 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
komoritan 0:7251441ac366 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
komoritan 0:7251441ac366 8 * furnished to do so, subject to the following conditions:
komoritan 0:7251441ac366 9 *
komoritan 0:7251441ac366 10 * The above copyright notice and this permission notice shall be included in all copies or
komoritan 0:7251441ac366 11 * substantial portions of the Software.
komoritan 0:7251441ac366 12 *
komoritan 0:7251441ac366 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
komoritan 0:7251441ac366 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
komoritan 0:7251441ac366 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
komoritan 0:7251441ac366 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
komoritan 0:7251441ac366 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
komoritan 0:7251441ac366 18 */
komoritan 0:7251441ac366 19 #include "SNIC_WifiInterface.h"
komoritan 0:7251441ac366 20 #include "SNIC_UartMsgUtil.h"
komoritan 0:7251441ac366 21
komoritan 0:7251441ac366 22 #define UART_CONNECT_BUF_SIZE 512
komoritan 0:7251441ac366 23 unsigned char gCONNECT_BUF[UART_CONNECT_BUF_SIZE];
komoritan 0:7251441ac366 24
komoritan 0:7251441ac366 25 C_SNIC_WifiInterface::C_SNIC_WifiInterface( PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm, int baud)
komoritan 0:7251441ac366 26 {
komoritan 0:7251441ac366 27 mUART_tx = tx;
komoritan 0:7251441ac366 28 mUART_rx = rx;
komoritan 0:7251441ac366 29 mUART_cts = cts;
komoritan 0:7251441ac366 30 mUART_rts = rts;;
komoritan 0:7251441ac366 31 mUART_baud = baud;
komoritan 0:7251441ac366 32 mModuleReset = reset;
komoritan 0:7251441ac366 33 }
komoritan 0:7251441ac366 34
komoritan 0:7251441ac366 35 C_SNIC_WifiInterface::~C_SNIC_WifiInterface()
komoritan 0:7251441ac366 36 {
komoritan 0:7251441ac366 37 }
komoritan 0:7251441ac366 38
komoritan 0:7251441ac366 39 int C_SNIC_WifiInterface::init()
komoritan 0:7251441ac366 40 {
komoritan 0:7251441ac366 41 C_SNIC_Core *snic_core_p = C_SNIC_Core::getInstance();
komoritan 0:7251441ac366 42 C_SNIC_UartCommandManager *uartCmdMgr_p = snic_core_p->getUartCommand();
komoritan 0:7251441ac366 43
komoritan 0:7251441ac366 44 /* Initialize UART */
komoritan 0:7251441ac366 45 snic_core_p->initUart( mUART_tx, mUART_rx, mUART_baud );
komoritan 0:7251441ac366 46
komoritan 0:7251441ac366 47 /* Module reset */
komoritan 0:7251441ac366 48 snic_core_p->resetModule( mModuleReset );
komoritan 0:7251441ac366 49
komoritan 0:7251441ac366 50 wait(1);
komoritan 0:7251441ac366 51 /* Initialize SNIC API */
komoritan 0:7251441ac366 52 // Get buffer for response payload from MemoryPool
komoritan 0:7251441ac366 53 tagMEMPOOL_BLOCK_T *payload_buf_p = snic_core_p->allocCmdBuf();
komoritan 0:7251441ac366 54 if( payload_buf_p == NULL )
komoritan 0:7251441ac366 55 {
komoritan 0:7251441ac366 56 DEBUG_PRINT("snic_init payload_buf_p NULL\r\n");
komoritan 0:7251441ac366 57 return -1;
komoritan 0:7251441ac366 58 }
komoritan 0:7251441ac366 59
komoritan 0:7251441ac366 60 C_SNIC_Core::tagSNIC_INIT_REQ_T req;
komoritan 0:7251441ac366 61 // Make request
komoritan 0:7251441ac366 62 req.cmd_sid = UART_CMD_SID_SNIC_INIT_REQ;
komoritan 0:7251441ac366 63 req.seq = mUartRequestSeq++;
komoritan 0:7251441ac366 64 req.buf_size[0] = 0x08;
komoritan 0:7251441ac366 65 req.buf_size[1] = 0x00;
komoritan 0:7251441ac366 66
komoritan 0:7251441ac366 67 unsigned char *command_array_p = snic_core_p->getCommandBuf();
komoritan 0:7251441ac366 68 unsigned int command_len;
komoritan 0:7251441ac366 69 // Preparation of command
komoritan 0:7251441ac366 70 command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_SNIC, req.cmd_sid, (unsigned char *)&req
komoritan 0:7251441ac366 71 , sizeof(C_SNIC_Core::tagSNIC_INIT_REQ_T), payload_buf_p->buf, command_array_p );
komoritan 0:7251441ac366 72
komoritan 0:7251441ac366 73 // Send uart command request
komoritan 0:7251441ac366 74 snic_core_p->sendUart( command_len, command_array_p );
komoritan 0:7251441ac366 75
komoritan 0:7251441ac366 76 int ret;
komoritan 0:7251441ac366 77 // Wait UART response
komoritan 0:7251441ac366 78 ret = uartCmdMgr_p->wait();
komoritan 0:7251441ac366 79 if( ret != 0 )
komoritan 0:7251441ac366 80 {
komoritan 0:7251441ac366 81 DEBUG_PRINT( "snic_init failed\r\n" );
komoritan 0:7251441ac366 82 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 83 return -1;
komoritan 0:7251441ac366 84 }
komoritan 0:7251441ac366 85
komoritan 0:7251441ac366 86 if( uartCmdMgr_p->getCommandStatus() != 0 )
komoritan 0:7251441ac366 87 {
komoritan 0:7251441ac366 88 DEBUG_PRINT("snic_init status:%02x\r\n", uartCmdMgr_p->getCommandStatus());
komoritan 0:7251441ac366 89 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 90 return -1;
komoritan 0:7251441ac366 91 }
komoritan 0:7251441ac366 92 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 93
komoritan 0:7251441ac366 94 return ret;
komoritan 0:7251441ac366 95 }
komoritan 0:7251441ac366 96
komoritan 0:7251441ac366 97 int C_SNIC_WifiInterface::getFWVersion( unsigned char *version_p )
komoritan 0:7251441ac366 98 {
komoritan 0:7251441ac366 99 C_SNIC_Core *snic_core_p = C_SNIC_Core::getInstance();
komoritan 0:7251441ac366 100 C_SNIC_UartCommandManager *uartCmdMgr_p = snic_core_p->getUartCommand();
komoritan 0:7251441ac366 101
komoritan 0:7251441ac366 102 // Get buffer for response payload from MemoryPool
komoritan 0:7251441ac366 103 tagMEMPOOL_BLOCK_T *payload_buf_p = snic_core_p->allocCmdBuf();
komoritan 0:7251441ac366 104 if( payload_buf_p == NULL )
komoritan 0:7251441ac366 105 {
komoritan 0:7251441ac366 106 DEBUG_PRINT("getFWVersion payload_buf_p NULL\r\n");
komoritan 0:7251441ac366 107 return -1;
komoritan 0:7251441ac366 108 }
komoritan 0:7251441ac366 109
komoritan 0:7251441ac366 110 C_SNIC_Core::tagGEN_FW_VER_GET_REQ_T req;
komoritan 0:7251441ac366 111 // Make request
komoritan 0:7251441ac366 112 req.cmd_sid = UART_CMD_SID_GEN_FW_VER_GET_REQ;
komoritan 0:7251441ac366 113 req.seq = mUartRequestSeq++;
komoritan 0:7251441ac366 114
komoritan 0:7251441ac366 115 unsigned char *command_array_p = snic_core_p->getCommandBuf();
komoritan 0:7251441ac366 116 unsigned int command_len;
komoritan 0:7251441ac366 117 // Preparation of command
komoritan 0:7251441ac366 118 command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_GEN, req.cmd_sid, (unsigned char *)&req
komoritan 0:7251441ac366 119 , sizeof(C_SNIC_Core::tagGEN_FW_VER_GET_REQ_T), payload_buf_p->buf, command_array_p );
komoritan 0:7251441ac366 120
komoritan 0:7251441ac366 121 int ret;
komoritan 0:7251441ac366 122
komoritan 0:7251441ac366 123 // Send uart command request
komoritan 0:7251441ac366 124 snic_core_p->sendUart( command_len, command_array_p );
komoritan 0:7251441ac366 125
komoritan 0:7251441ac366 126 // Wait UART response
komoritan 0:7251441ac366 127 ret = uartCmdMgr_p->wait();
komoritan 0:7251441ac366 128 if( ret != 0 )
komoritan 0:7251441ac366 129 {
komoritan 0:7251441ac366 130 DEBUG_PRINT( "getFWversion failed\r\n" );
komoritan 0:7251441ac366 131 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 132 return -1;
komoritan 0:7251441ac366 133 }
komoritan 0:7251441ac366 134
komoritan 0:7251441ac366 135 if( uartCmdMgr_p->getCommandStatus() == 0 )
komoritan 0:7251441ac366 136 {
komoritan 0:7251441ac366 137 unsigned char version_len = payload_buf_p->buf[3];
komoritan 0:7251441ac366 138 memcpy( version_p, &payload_buf_p->buf[4], version_len );
komoritan 0:7251441ac366 139 }
komoritan 0:7251441ac366 140 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 141 return 0;
komoritan 0:7251441ac366 142 }
komoritan 0:7251441ac366 143
komoritan 0:7251441ac366 144 int C_SNIC_WifiInterface::connect(const char *ssid_p, unsigned char ssid_len, E_SECURITY sec_type
komoritan 0:7251441ac366 145 , const char *sec_key_p, unsigned char sec_key_len)
komoritan 0:7251441ac366 146 {
komoritan 0:7251441ac366 147 C_SNIC_Core *snic_core_p = C_SNIC_Core::getInstance();
komoritan 0:7251441ac366 148 C_SNIC_UartCommandManager *uartCmdMgr_p = snic_core_p->getUartCommand();
komoritan 0:7251441ac366 149
komoritan 0:7251441ac366 150 // Parameter check(SSID)
komoritan 0:7251441ac366 151 if( (ssid_p == NULL) || (ssid_len == 0) )
komoritan 0:7251441ac366 152 {
komoritan 0:7251441ac366 153 DEBUG_PRINT( "connect failed [ parameter NG:SSID ]\r\n" );
komoritan 0:7251441ac366 154 return -1;
komoritan 0:7251441ac366 155 }
komoritan 0:7251441ac366 156
komoritan 0:7251441ac366 157 // Parameter check(Security key)
komoritan 0:7251441ac366 158 if( (sec_type != e_SEC_OPEN) && ( (sec_key_len == 0) || (sec_key_p == NULL) ) )
komoritan 0:7251441ac366 159 {
komoritan 0:7251441ac366 160 DEBUG_PRINT( "connect failed [ parameter NG:Security key ]\r\n" );
komoritan 0:7251441ac366 161 return -1;
komoritan 0:7251441ac366 162 }
komoritan 0:7251441ac366 163
komoritan 0:7251441ac366 164 // Get buffer for response payload from MemoryPool
komoritan 0:7251441ac366 165 tagMEMPOOL_BLOCK_T *payload_buf_p = snic_core_p->allocCmdBuf();
komoritan 0:7251441ac366 166 if( payload_buf_p == NULL )
komoritan 0:7251441ac366 167 {
komoritan 0:7251441ac366 168 DEBUG_PRINT("connect payload_buf_p NULL\r\n");
komoritan 0:7251441ac366 169 return -1;
komoritan 0:7251441ac366 170 }
komoritan 0:7251441ac366 171
komoritan 0:7251441ac366 172 unsigned char *buf = &gCONNECT_BUF[0];
komoritan 0:7251441ac366 173 unsigned int buf_len = 0;
komoritan 0:7251441ac366 174 unsigned int command_len;
komoritan 0:7251441ac366 175
komoritan 0:7251441ac366 176 memset( buf, 0, UART_CONNECT_BUF_SIZE );
komoritan 0:7251441ac366 177 // Make request
komoritan 0:7251441ac366 178 buf[0] = UART_CMD_SID_WIFI_JOIN_REQ;
komoritan 0:7251441ac366 179 buf_len++;
komoritan 0:7251441ac366 180 buf[1] = mUartRequestSeq++;
komoritan 0:7251441ac366 181 buf_len++;
komoritan 0:7251441ac366 182 // SSID
komoritan 0:7251441ac366 183 memcpy( &buf[2], ssid_p, ssid_len );
komoritan 0:7251441ac366 184 buf_len += ssid_len;
komoritan 0:7251441ac366 185 buf_len++;
komoritan 0:7251441ac366 186
komoritan 0:7251441ac366 187 // Security mode
komoritan 0:7251441ac366 188 buf[ buf_len ] = (unsigned char)sec_type;
komoritan 0:7251441ac366 189 buf_len++;
komoritan 0:7251441ac366 190
komoritan 0:7251441ac366 191 // Security key
komoritan 0:7251441ac366 192 if( sec_type != e_SEC_OPEN )
komoritan 0:7251441ac366 193 {
komoritan 0:7251441ac366 194 buf[ buf_len ] = sec_key_len;
komoritan 0:7251441ac366 195 buf_len++;
komoritan 0:7251441ac366 196 if( sec_key_len > 0 )
komoritan 0:7251441ac366 197 {
komoritan 0:7251441ac366 198 memcpy( &buf[buf_len], sec_key_p, sec_key_len );
komoritan 0:7251441ac366 199 buf_len += sec_key_len;
komoritan 0:7251441ac366 200 }
komoritan 0:7251441ac366 201 }
komoritan 0:7251441ac366 202
komoritan 0:7251441ac366 203 unsigned char *command_array_p = snic_core_p->getCommandBuf();
komoritan 0:7251441ac366 204 // Preparation of command
komoritan 0:7251441ac366 205 command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_WIFI, UART_CMD_SID_WIFI_JOIN_REQ, buf
komoritan 0:7251441ac366 206 , buf_len, payload_buf_p->buf, command_array_p );
komoritan 0:7251441ac366 207
komoritan 0:7251441ac366 208 // Send uart command request
komoritan 0:7251441ac366 209 snic_core_p->sendUart( command_len, command_array_p );
komoritan 0:7251441ac366 210
komoritan 0:7251441ac366 211 int ret;
komoritan 0:7251441ac366 212 // Wait UART response
komoritan 0:7251441ac366 213 ret = uartCmdMgr_p->wait();
komoritan 0:7251441ac366 214 if(uartCmdMgr_p->getCommandStatus() != UART_CMD_RES_WIFI_ERR_ALREADY_JOINED)
komoritan 0:7251441ac366 215 {
komoritan 0:7251441ac366 216 DEBUG_PRINT( "Already connected\r\n" );
komoritan 0:7251441ac366 217 }
komoritan 0:7251441ac366 218 else
komoritan 0:7251441ac366 219 {
komoritan 0:7251441ac366 220 if( ret != 0 )
komoritan 0:7251441ac366 221 {
komoritan 0:7251441ac366 222 DEBUG_PRINT( "join failed\r\n" );
komoritan 0:7251441ac366 223 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 224 return -1;
komoritan 0:7251441ac366 225 }
komoritan 0:7251441ac366 226 }
komoritan 0:7251441ac366 227
komoritan 0:7251441ac366 228 if(uartCmdMgr_p->getCommandStatus() != 0)
komoritan 0:7251441ac366 229 {
komoritan 0:7251441ac366 230 DEBUG_PRINT("join status:%02x\r\n", uartCmdMgr_p->getCommandStatus());
komoritan 0:7251441ac366 231 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 232 return -1;
komoritan 0:7251441ac366 233 }
komoritan 0:7251441ac366 234 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 235
komoritan 0:7251441ac366 236 return ret;
komoritan 0:7251441ac366 237 }
komoritan 0:7251441ac366 238
komoritan 0:7251441ac366 239 int C_SNIC_WifiInterface::disconnect()
komoritan 0:7251441ac366 240 {
komoritan 0:7251441ac366 241 C_SNIC_Core *snic_core_p = C_SNIC_Core::getInstance();
komoritan 0:7251441ac366 242 C_SNIC_UartCommandManager *uartCmdMgr_p = snic_core_p->getUartCommand();
komoritan 0:7251441ac366 243
komoritan 0:7251441ac366 244 // Get buffer for response payload from MemoryPool
komoritan 0:7251441ac366 245 tagMEMPOOL_BLOCK_T *payload_buf_p = snic_core_p->allocCmdBuf();
komoritan 0:7251441ac366 246 if( payload_buf_p == NULL )
komoritan 0:7251441ac366 247 {
komoritan 0:7251441ac366 248 DEBUG_PRINT("disconnect payload_buf_p NULL\r\n");
komoritan 0:7251441ac366 249 return -1;
komoritan 0:7251441ac366 250 }
komoritan 0:7251441ac366 251
komoritan 0:7251441ac366 252 C_SNIC_Core::tagWIFI_DISCONNECT_REQ_T req;
komoritan 0:7251441ac366 253 // Make request
komoritan 0:7251441ac366 254 req.cmd_sid = UART_CMD_SID_WIFI_DISCONNECT_REQ;
komoritan 0:7251441ac366 255 req.seq = mUartRequestSeq++;
komoritan 0:7251441ac366 256
komoritan 0:7251441ac366 257 unsigned char *command_array_p = snic_core_p->getCommandBuf();
komoritan 0:7251441ac366 258 unsigned int command_len;
komoritan 0:7251441ac366 259 // Preparation of command
komoritan 0:7251441ac366 260 command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_WIFI, req.cmd_sid, (unsigned char *)&req
komoritan 0:7251441ac366 261 , sizeof(C_SNIC_Core::tagWIFI_DISCONNECT_REQ_T), payload_buf_p->buf, command_array_p );
komoritan 0:7251441ac366 262
komoritan 0:7251441ac366 263 // Send uart command request
komoritan 0:7251441ac366 264 snic_core_p->sendUart( command_len, command_array_p );
komoritan 0:7251441ac366 265
komoritan 0:7251441ac366 266 int ret;
komoritan 0:7251441ac366 267 // Wait UART response
komoritan 0:7251441ac366 268 ret = uartCmdMgr_p->wait();
komoritan 0:7251441ac366 269 if( ret != 0 )
komoritan 0:7251441ac366 270 {
komoritan 0:7251441ac366 271 DEBUG_PRINT( "disconnect failed\r\n" );
komoritan 0:7251441ac366 272 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 273 return -1;
komoritan 0:7251441ac366 274 }
komoritan 0:7251441ac366 275
komoritan 0:7251441ac366 276 if( uartCmdMgr_p->getCommandStatus() != 0 )
komoritan 0:7251441ac366 277 {
komoritan 0:7251441ac366 278 DEBUG_PRINT("disconnect status:%02x\r\n", uartCmdMgr_p->getCommandStatus());
komoritan 0:7251441ac366 279 ret = -1;
komoritan 0:7251441ac366 280 }
komoritan 0:7251441ac366 281 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 282 return ret;
komoritan 0:7251441ac366 283 }
komoritan 0:7251441ac366 284
komoritan 0:7251441ac366 285 int C_SNIC_WifiInterface::scan( const char *ssid_p, unsigned char *bssid_p
komoritan 0:7251441ac366 286 , void (*result_handler_p)(tagSCAN_RESULT_T *scan_result) )
komoritan 0:7251441ac366 287 {
komoritan 0:7251441ac366 288 C_SNIC_Core *snic_core_p = C_SNIC_Core::getInstance();
komoritan 0:7251441ac366 289 C_SNIC_UartCommandManager *uartCmdMgr_p = snic_core_p->getUartCommand();
komoritan 0:7251441ac366 290
komoritan 0:7251441ac366 291 // Get buffer for response payload from MemoryPool
komoritan 0:7251441ac366 292 tagMEMPOOL_BLOCK_T *payload_buf_p = snic_core_p->allocCmdBuf();
komoritan 0:7251441ac366 293 if( payload_buf_p == NULL )
komoritan 0:7251441ac366 294 {
komoritan 0:7251441ac366 295 DEBUG_PRINT("scan payload_buf_p NULL\r\n");
komoritan 0:7251441ac366 296 return -1;
komoritan 0:7251441ac366 297 }
komoritan 0:7251441ac366 298
komoritan 0:7251441ac366 299 C_SNIC_Core::tagWIFI_SCAN_REQ_T req;
komoritan 0:7251441ac366 300 unsigned int buf_len = 0;
komoritan 0:7251441ac366 301
komoritan 0:7251441ac366 302 memset( &req, 0, sizeof(C_SNIC_Core::tagWIFI_SCAN_REQ_T) );
komoritan 0:7251441ac366 303 // Make request
komoritan 0:7251441ac366 304 req.cmd_sid = UART_CMD_SID_WIFI_SCAN_REQ;
komoritan 0:7251441ac366 305 buf_len++;
komoritan 0:7251441ac366 306 req.seq = mUartRequestSeq++;
komoritan 0:7251441ac366 307 buf_len++;
komoritan 0:7251441ac366 308
komoritan 0:7251441ac366 309 // Set scan type(Active scan)
komoritan 0:7251441ac366 310 req.scan_type = 0;
komoritan 0:7251441ac366 311 buf_len++;
komoritan 0:7251441ac366 312 // Set bss type(any)
komoritan 0:7251441ac366 313 req.bss_type = 2;
komoritan 0:7251441ac366 314 buf_len++;
komoritan 0:7251441ac366 315 // Set BSSID
komoritan 0:7251441ac366 316 if( bssid_p != NULL )
komoritan 0:7251441ac366 317 {
komoritan 0:7251441ac366 318 memcpy( req.bssid, bssid_p, BSSID_MAC_LENTH );
komoritan 0:7251441ac366 319 }
komoritan 0:7251441ac366 320 buf_len += BSSID_MAC_LENTH;
komoritan 0:7251441ac366 321 // Set channel list(0)
komoritan 0:7251441ac366 322 req.chan_list = 0;
komoritan 0:7251441ac366 323 buf_len++;
komoritan 0:7251441ac366 324 //Set SSID
komoritan 0:7251441ac366 325 if( ssid_p != NULL )
komoritan 0:7251441ac366 326 {
komoritan 0:7251441ac366 327 strcpy( (char *)req.ssid, ssid_p );
komoritan 0:7251441ac366 328 buf_len += strlen(ssid_p);
komoritan 0:7251441ac366 329 }
komoritan 0:7251441ac366 330 buf_len++;
komoritan 0:7251441ac366 331
komoritan 0:7251441ac366 332 unsigned char *command_array_p = snic_core_p->getCommandBuf();
komoritan 0:7251441ac366 333 unsigned int command_len;
komoritan 0:7251441ac366 334 // Preparation of command
komoritan 0:7251441ac366 335 command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_WIFI, req.cmd_sid, (unsigned char *)&req
komoritan 0:7251441ac366 336 , buf_len, payload_buf_p->buf, command_array_p );
komoritan 0:7251441ac366 337
komoritan 0:7251441ac366 338 // Set scan result callback
komoritan 0:7251441ac366 339 uartCmdMgr_p->setScanResultHandler( result_handler_p );
komoritan 0:7251441ac366 340
komoritan 0:7251441ac366 341 // Send uart command request
komoritan 0:7251441ac366 342 snic_core_p->sendUart( command_len, command_array_p );
komoritan 0:7251441ac366 343
komoritan 0:7251441ac366 344 int ret;
komoritan 0:7251441ac366 345 // Wait UART response
komoritan 0:7251441ac366 346 ret = uartCmdMgr_p->wait();
komoritan 0:7251441ac366 347 DEBUG_PRINT( "scan wait:%d\r\n", ret );
komoritan 0:7251441ac366 348 if( ret != 0 )
komoritan 0:7251441ac366 349 {
komoritan 0:7251441ac366 350 DEBUG_PRINT( "scan failed\r\n" );
komoritan 0:7251441ac366 351 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 352 return -1;
komoritan 0:7251441ac366 353 }
komoritan 0:7251441ac366 354
komoritan 0:7251441ac366 355 if( uartCmdMgr_p->getCommandStatus() != 0 )
komoritan 0:7251441ac366 356 {
komoritan 0:7251441ac366 357 DEBUG_PRINT("scan status:%02x\r\n", uartCmdMgr_p->getCommandStatus());
komoritan 0:7251441ac366 358 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 359 return -1;
komoritan 0:7251441ac366 360 }
komoritan 0:7251441ac366 361
komoritan 0:7251441ac366 362 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 363
komoritan 0:7251441ac366 364 return ret;
komoritan 0:7251441ac366 365 }
komoritan 0:7251441ac366 366
komoritan 0:7251441ac366 367 int C_SNIC_WifiInterface::wifi_on( const char *country_p )
komoritan 0:7251441ac366 368 {
komoritan 0:7251441ac366 369 C_SNIC_Core *snic_core_p = C_SNIC_Core::getInstance();
komoritan 0:7251441ac366 370 C_SNIC_UartCommandManager *uartCmdMgr_p = snic_core_p->getUartCommand();
komoritan 0:7251441ac366 371
komoritan 0:7251441ac366 372 // Parameter check
komoritan 0:7251441ac366 373 if( country_p == NULL )
komoritan 0:7251441ac366 374 {
komoritan 0:7251441ac366 375 DEBUG_PRINT("wifi_on parameter error\r\n");
komoritan 0:7251441ac366 376 return -1;
komoritan 0:7251441ac366 377 }
komoritan 0:7251441ac366 378
komoritan 0:7251441ac366 379 // Get buffer for response payload from MemoryPool
komoritan 0:7251441ac366 380 tagMEMPOOL_BLOCK_T *payload_buf_p = snic_core_p->allocCmdBuf();
komoritan 0:7251441ac366 381 if( payload_buf_p == NULL )
komoritan 0:7251441ac366 382 {
komoritan 0:7251441ac366 383 DEBUG_PRINT("wifi_on payload_buf_p NULL\r\n");
komoritan 0:7251441ac366 384 return -1;
komoritan 0:7251441ac366 385 }
komoritan 0:7251441ac366 386
komoritan 0:7251441ac366 387 C_SNIC_Core::tagWIFI_ON_REQ_T req;
komoritan 0:7251441ac366 388 // Make request
komoritan 0:7251441ac366 389 req.cmd_sid = UART_CMD_SID_WIFI_ON_REQ;
komoritan 0:7251441ac366 390 req.seq = mUartRequestSeq++;
komoritan 0:7251441ac366 391 memcpy( req.country, country_p, COUNTRYC_CODE_LENTH );
komoritan 0:7251441ac366 392
komoritan 0:7251441ac366 393 unsigned char *command_array_p = snic_core_p->getCommandBuf();
komoritan 0:7251441ac366 394 unsigned int command_len;
komoritan 0:7251441ac366 395 // Preparation of command
komoritan 0:7251441ac366 396 command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_WIFI, req.cmd_sid, (unsigned char *)&req
komoritan 0:7251441ac366 397 , sizeof(C_SNIC_Core::tagWIFI_ON_REQ_T), payload_buf_p->buf, command_array_p );
komoritan 0:7251441ac366 398
komoritan 0:7251441ac366 399 // Send uart command request
komoritan 0:7251441ac366 400 snic_core_p->sendUart( command_len, command_array_p );
komoritan 0:7251441ac366 401
komoritan 0:7251441ac366 402 int ret;
komoritan 0:7251441ac366 403 // Wait UART response
komoritan 0:7251441ac366 404 ret = uartCmdMgr_p->wait();
komoritan 0:7251441ac366 405 if( ret != 0 )
komoritan 0:7251441ac366 406 {
komoritan 0:7251441ac366 407 DEBUG_PRINT( "wifi_on failed\r\n" );
komoritan 0:7251441ac366 408 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 409 return -1;
komoritan 0:7251441ac366 410 }
komoritan 0:7251441ac366 411
komoritan 0:7251441ac366 412 if( uartCmdMgr_p->getCommandStatus() != 0 )
komoritan 0:7251441ac366 413 {
komoritan 0:7251441ac366 414 DEBUG_PRINT("wifi_on status:%02x\r\n", uartCmdMgr_p->getCommandStatus());
komoritan 0:7251441ac366 415 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 416 return -1;
komoritan 0:7251441ac366 417 }
komoritan 0:7251441ac366 418 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 419
komoritan 0:7251441ac366 420 return ret;
komoritan 0:7251441ac366 421 }
komoritan 0:7251441ac366 422
komoritan 0:7251441ac366 423 int C_SNIC_WifiInterface::wifi_off()
komoritan 0:7251441ac366 424 {
komoritan 0:7251441ac366 425 C_SNIC_Core *snic_core_p = C_SNIC_Core::getInstance();
komoritan 0:7251441ac366 426 C_SNIC_UartCommandManager *uartCmdMgr_p = snic_core_p->getUartCommand();
komoritan 0:7251441ac366 427
komoritan 0:7251441ac366 428 // Get buffer for response payload from MemoryPool
komoritan 0:7251441ac366 429 tagMEMPOOL_BLOCK_T *payload_buf_p = snic_core_p->allocCmdBuf();
komoritan 0:7251441ac366 430 if( payload_buf_p == NULL )
komoritan 0:7251441ac366 431 {
komoritan 0:7251441ac366 432 DEBUG_PRINT("wifi_off payload_buf_p NULL\r\n");
komoritan 0:7251441ac366 433 return -1;
komoritan 0:7251441ac366 434 }
komoritan 0:7251441ac366 435
komoritan 0:7251441ac366 436 C_SNIC_Core::tagWIFI_OFF_REQ_T req;
komoritan 0:7251441ac366 437 // Make request
komoritan 0:7251441ac366 438 req.cmd_sid = UART_CMD_SID_WIFI_OFF_REQ;
komoritan 0:7251441ac366 439 req.seq = mUartRequestSeq++;
komoritan 0:7251441ac366 440
komoritan 0:7251441ac366 441 unsigned char *command_array_p = snic_core_p->getCommandBuf();
komoritan 0:7251441ac366 442 unsigned int command_len;
komoritan 0:7251441ac366 443 // Preparation of command
komoritan 0:7251441ac366 444 command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_WIFI, req.cmd_sid, (unsigned char *)&req
komoritan 0:7251441ac366 445 , sizeof(C_SNIC_Core::tagWIFI_OFF_REQ_T), payload_buf_p->buf, command_array_p );
komoritan 0:7251441ac366 446
komoritan 0:7251441ac366 447 // Send uart command request
komoritan 0:7251441ac366 448 snic_core_p->sendUart( command_len, command_array_p );
komoritan 0:7251441ac366 449
komoritan 0:7251441ac366 450 int ret;
komoritan 0:7251441ac366 451 // Wait UART response
komoritan 0:7251441ac366 452 ret = uartCmdMgr_p->wait();
komoritan 0:7251441ac366 453 if( ret != 0 )
komoritan 0:7251441ac366 454 {
komoritan 0:7251441ac366 455 DEBUG_PRINT( "wifi_off failed\r\n" );
komoritan 0:7251441ac366 456 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 457 return -1;
komoritan 0:7251441ac366 458 }
komoritan 0:7251441ac366 459
komoritan 0:7251441ac366 460 if( uartCmdMgr_p->getCommandStatus() != 0 )
komoritan 0:7251441ac366 461 {
komoritan 0:7251441ac366 462 DEBUG_PRINT("wifi_off status:%02x\r\n", uartCmdMgr_p->getCommandStatus());
komoritan 0:7251441ac366 463 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 464 return -1;
komoritan 0:7251441ac366 465 }
komoritan 0:7251441ac366 466 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 467
komoritan 0:7251441ac366 468 return ret;
komoritan 0:7251441ac366 469 }
komoritan 0:7251441ac366 470
komoritan 0:7251441ac366 471 int C_SNIC_WifiInterface::getRssi( signed char *rssi_p )
komoritan 0:7251441ac366 472 {
komoritan 0:7251441ac366 473 C_SNIC_Core *snic_core_p = C_SNIC_Core::getInstance();
komoritan 0:7251441ac366 474 C_SNIC_UartCommandManager *uartCmdMgr_p = snic_core_p->getUartCommand();
komoritan 0:7251441ac366 475 if( rssi_p == NULL )
komoritan 0:7251441ac366 476 {
komoritan 0:7251441ac366 477 DEBUG_PRINT("getRssi parameter error\r\n");
komoritan 0:7251441ac366 478 return -1;
komoritan 0:7251441ac366 479 }
komoritan 0:7251441ac366 480
komoritan 0:7251441ac366 481 // Get buffer for response payload from MemoryPool
komoritan 0:7251441ac366 482 tagMEMPOOL_BLOCK_T *payload_buf_p = snic_core_p->allocCmdBuf();
komoritan 0:7251441ac366 483 if( payload_buf_p == NULL )
komoritan 0:7251441ac366 484 {
komoritan 0:7251441ac366 485 DEBUG_PRINT("getRssi payload_buf_p NULL\r\n");
komoritan 0:7251441ac366 486 return -1;
komoritan 0:7251441ac366 487 }
komoritan 0:7251441ac366 488
komoritan 0:7251441ac366 489 C_SNIC_Core::tagWIFI_GET_STA_RSSI_REQ_T req;
komoritan 0:7251441ac366 490
komoritan 0:7251441ac366 491 // Make request
komoritan 0:7251441ac366 492 req.cmd_sid = UART_CMD_SID_WIFI_GET_STA_RSSI_REQ;
komoritan 0:7251441ac366 493 req.seq = mUartRequestSeq++;
komoritan 0:7251441ac366 494
komoritan 0:7251441ac366 495 unsigned char *command_array_p = snic_core_p->getCommandBuf();
komoritan 0:7251441ac366 496 unsigned int command_len;
komoritan 0:7251441ac366 497 command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_WIFI, req.cmd_sid, (unsigned char *)&req
komoritan 0:7251441ac366 498 , sizeof(C_SNIC_Core::tagWIFI_GET_STA_RSSI_REQ_T), payload_buf_p->buf, command_array_p );
komoritan 0:7251441ac366 499
komoritan 0:7251441ac366 500 int ret;
komoritan 0:7251441ac366 501 // Send uart command request
komoritan 0:7251441ac366 502 snic_core_p->sendUart( command_len, command_array_p );
komoritan 0:7251441ac366 503
komoritan 0:7251441ac366 504 // Wait UART response
komoritan 0:7251441ac366 505 ret = uartCmdMgr_p->wait();
komoritan 0:7251441ac366 506 if( ret != 0 )
komoritan 0:7251441ac366 507 {
komoritan 0:7251441ac366 508 DEBUG_PRINT( "getRssi failed\r\n" );
komoritan 0:7251441ac366 509 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 510 return -1;
komoritan 0:7251441ac366 511 }
komoritan 0:7251441ac366 512
komoritan 0:7251441ac366 513 *rssi_p = (signed char)payload_buf_p->buf[2];
komoritan 0:7251441ac366 514
komoritan 0:7251441ac366 515 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 516 return 0;
komoritan 0:7251441ac366 517 }
komoritan 0:7251441ac366 518
komoritan 0:7251441ac366 519 int C_SNIC_WifiInterface::getWifiStatus( tagWIFI_STATUS_T *status_p)
komoritan 0:7251441ac366 520 {
komoritan 0:7251441ac366 521 C_SNIC_Core *snic_core_p = C_SNIC_Core::getInstance();
komoritan 0:7251441ac366 522 C_SNIC_UartCommandManager *uartCmdMgr_p = snic_core_p->getUartCommand();
komoritan 0:7251441ac366 523
komoritan 0:7251441ac366 524 if( status_p == NULL )
komoritan 0:7251441ac366 525 {
komoritan 0:7251441ac366 526 DEBUG_PRINT("getWifiStatus parameter error\r\n");
komoritan 0:7251441ac366 527 return -1;
komoritan 0:7251441ac366 528 }
komoritan 0:7251441ac366 529
komoritan 0:7251441ac366 530 // Get buffer for response payload from MemoryPool
komoritan 0:7251441ac366 531 tagMEMPOOL_BLOCK_T *payload_buf_p = snic_core_p->allocCmdBuf();
komoritan 0:7251441ac366 532 if( payload_buf_p == NULL )
komoritan 0:7251441ac366 533 {
komoritan 0:7251441ac366 534 DEBUG_PRINT("getWifiStatus payload_buf_p NULL\r\n");
komoritan 0:7251441ac366 535 return -1;
komoritan 0:7251441ac366 536 }
komoritan 0:7251441ac366 537
komoritan 0:7251441ac366 538 C_SNIC_Core::tagWIFI_GET_STATUS_REQ_T req;
komoritan 0:7251441ac366 539 // Make request
komoritan 0:7251441ac366 540 req.cmd_sid = UART_CMD_SID_WIFI_GET_STATUS_REQ;
komoritan 0:7251441ac366 541 req.seq = mUartRequestSeq++;
komoritan 0:7251441ac366 542 req.interface = 0;
komoritan 0:7251441ac366 543
komoritan 0:7251441ac366 544 unsigned char *command_array_p = snic_core_p->getCommandBuf();
komoritan 0:7251441ac366 545 unsigned int command_len;
komoritan 0:7251441ac366 546 command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_WIFI, req.cmd_sid, (unsigned char *)&req
komoritan 0:7251441ac366 547 , sizeof(C_SNIC_Core::tagWIFI_GET_STATUS_REQ_T), payload_buf_p->buf, command_array_p );
komoritan 0:7251441ac366 548
komoritan 0:7251441ac366 549 // Send uart command request
komoritan 0:7251441ac366 550 snic_core_p->sendUart( command_len, command_array_p );
komoritan 0:7251441ac366 551
komoritan 0:7251441ac366 552 int ret;
komoritan 0:7251441ac366 553 // Wait UART response
komoritan 0:7251441ac366 554 ret = uartCmdMgr_p->wait();
komoritan 0:7251441ac366 555 if( ret != 0 )
komoritan 0:7251441ac366 556 {
komoritan 0:7251441ac366 557 DEBUG_PRINT( "getWifiStatus failed\r\n" );
komoritan 0:7251441ac366 558 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 559 return -1;
komoritan 0:7251441ac366 560 }
komoritan 0:7251441ac366 561
komoritan 0:7251441ac366 562 // set status
komoritan 0:7251441ac366 563 status_p->status = (E_WIFI_STATUS)payload_buf_p->buf[2];
komoritan 0:7251441ac366 564
komoritan 0:7251441ac366 565 // set Mac address
komoritan 0:7251441ac366 566 if( status_p->status != e_STATUS_OFF )
komoritan 0:7251441ac366 567 {
komoritan 0:7251441ac366 568 memcpy( status_p->mac_address, &payload_buf_p->buf[3], BSSID_MAC_LENTH );
komoritan 0:7251441ac366 569 }
komoritan 0:7251441ac366 570
komoritan 0:7251441ac366 571 // set SSID
komoritan 0:7251441ac366 572 if( ( status_p->status == e_STA_JOINED ) || ( status_p->status == e_AP_STARTED ) )
komoritan 0:7251441ac366 573 {
komoritan 0:7251441ac366 574 memcpy( status_p->ssid, &payload_buf_p->buf[9], strlen( (char *)&payload_buf_p->buf[9]) );
komoritan 0:7251441ac366 575 }
komoritan 0:7251441ac366 576
komoritan 0:7251441ac366 577 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 578 return 0;
komoritan 0:7251441ac366 579 }
komoritan 0:7251441ac366 580
komoritan 0:7251441ac366 581 int C_SNIC_WifiInterface::setIPConfig( bool is_DHCP
komoritan 0:7251441ac366 582 , const char *ip_p, const char *mask_p, const char *gateway_p )
komoritan 0:7251441ac366 583 {
komoritan 0:7251441ac366 584 // Parameter check
komoritan 0:7251441ac366 585 if( is_DHCP == false )
komoritan 0:7251441ac366 586 {
komoritan 0:7251441ac366 587 if( (ip_p == NULL) || (mask_p == NULL) ||(gateway_p == NULL) )
komoritan 0:7251441ac366 588 {
komoritan 0:7251441ac366 589 DEBUG_PRINT("setIPConfig parameter error\r\n");
komoritan 0:7251441ac366 590 return -1;
komoritan 0:7251441ac366 591 }
komoritan 0:7251441ac366 592 }
komoritan 0:7251441ac366 593
komoritan 0:7251441ac366 594 C_SNIC_Core *snic_core_p = C_SNIC_Core::getInstance();
komoritan 0:7251441ac366 595 C_SNIC_UartCommandManager *uartCmdMgr_p = snic_core_p->getUartCommand();
komoritan 0:7251441ac366 596
komoritan 0:7251441ac366 597 // Get buffer for response payload from MemoryPool
komoritan 0:7251441ac366 598 tagMEMPOOL_BLOCK_T *payload_buf_p = snic_core_p->allocCmdBuf();
komoritan 0:7251441ac366 599 if( payload_buf_p == NULL )
komoritan 0:7251441ac366 600 {
komoritan 0:7251441ac366 601 DEBUG_PRINT("setIPConfig payload_buf_p NULL\r\n");
komoritan 0:7251441ac366 602 return -1;
komoritan 0:7251441ac366 603 }
komoritan 0:7251441ac366 604
komoritan 0:7251441ac366 605 unsigned char *command_array_p = snic_core_p->getCommandBuf();
komoritan 0:7251441ac366 606 unsigned int command_len;
komoritan 0:7251441ac366 607 if( is_DHCP == true )
komoritan 0:7251441ac366 608 {
komoritan 0:7251441ac366 609 C_SNIC_Core::tagSNIC_IP_CONFIG_REQ_DHCP_T req;
komoritan 0:7251441ac366 610 // Make request
komoritan 0:7251441ac366 611 req.cmd_sid = UART_CMD_SID_SNIC_IP_CONFIG_REQ;
komoritan 0:7251441ac366 612 req.seq = mUartRequestSeq++;
komoritan 0:7251441ac366 613 req.interface = 0;
komoritan 0:7251441ac366 614 req.dhcp = 1;
komoritan 0:7251441ac366 615
komoritan 0:7251441ac366 616 // Preparation of command
komoritan 0:7251441ac366 617 command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_SNIC, req.cmd_sid, (unsigned char *)&req
komoritan 0:7251441ac366 618 , sizeof(C_SNIC_Core::tagSNIC_IP_CONFIG_REQ_DHCP_T), payload_buf_p->buf, command_array_p );
komoritan 0:7251441ac366 619 }
komoritan 0:7251441ac366 620 else
komoritan 0:7251441ac366 621 {
komoritan 0:7251441ac366 622 C_SNIC_Core::tagSNIC_IP_CONFIG_REQ_STATIC_T req;
komoritan 0:7251441ac366 623 // Make request
komoritan 0:7251441ac366 624 req.cmd_sid = UART_CMD_SID_SNIC_IP_CONFIG_REQ;
komoritan 0:7251441ac366 625 req.seq = mUartRequestSeq++;
komoritan 0:7251441ac366 626 req.interface = 0;
komoritan 0:7251441ac366 627 req.dhcp = 0;
komoritan 0:7251441ac366 628
komoritan 0:7251441ac366 629 // Set paramter of address
komoritan 0:7251441ac366 630 int addr_temp;
komoritan 0:7251441ac366 631 addr_temp = C_SNIC_UartMsgUtil::addrToInteger( ip_p );
komoritan 0:7251441ac366 632 C_SNIC_UartMsgUtil::convertIntToByteAdday( addr_temp, (char *)req.ip_addr );
komoritan 0:7251441ac366 633 addr_temp = C_SNIC_UartMsgUtil::addrToInteger( mask_p );
komoritan 0:7251441ac366 634 C_SNIC_UartMsgUtil::convertIntToByteAdday( addr_temp, (char *)req.netmask );
komoritan 0:7251441ac366 635 addr_temp = C_SNIC_UartMsgUtil::addrToInteger( gateway_p );
komoritan 0:7251441ac366 636 C_SNIC_UartMsgUtil::convertIntToByteAdday( addr_temp, (char *)req.gateway );
komoritan 0:7251441ac366 637
komoritan 0:7251441ac366 638 // Preparation of command
komoritan 0:7251441ac366 639 command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_SNIC, req.cmd_sid, (unsigned char *)&req
komoritan 0:7251441ac366 640 , sizeof(C_SNIC_Core::tagSNIC_IP_CONFIG_REQ_STATIC_T), payload_buf_p->buf, command_array_p );
komoritan 0:7251441ac366 641 }
komoritan 0:7251441ac366 642 // Send uart command request
komoritan 0:7251441ac366 643 snic_core_p->sendUart( command_len, command_array_p );
komoritan 0:7251441ac366 644
komoritan 0:7251441ac366 645 int ret;
komoritan 0:7251441ac366 646 // Wait UART response
komoritan 0:7251441ac366 647 ret = uartCmdMgr_p->wait();
komoritan 0:7251441ac366 648 if( ret != 0 )
komoritan 0:7251441ac366 649 {
komoritan 0:7251441ac366 650 DEBUG_PRINT( "setIPConfig failed\r\n" );
komoritan 0:7251441ac366 651 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 652 return -1;
komoritan 0:7251441ac366 653 }
komoritan 0:7251441ac366 654
komoritan 0:7251441ac366 655 if( uartCmdMgr_p->getCommandStatus() != 0 )
komoritan 0:7251441ac366 656 {
komoritan 0:7251441ac366 657 DEBUG_PRINT("setIPConfig status:%02x\r\n", uartCmdMgr_p->getCommandStatus());
komoritan 0:7251441ac366 658 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 659 return -1;
komoritan 0:7251441ac366 660 }
komoritan 0:7251441ac366 661
komoritan 0:7251441ac366 662 snic_core_p->freeCmdBuf( payload_buf_p );
komoritan 0:7251441ac366 663 return ret;
komoritan 0:7251441ac366 664 }