SNICInterface for ThingPlug Example
Dependents: ThingPlug_WiFi_Example ThingPlug_WiFi_Example_2
Fork of SNICInterface by
Diff: Socket/TCPSocketConnection.cpp
- Revision:
- 16:6100acfeb1f1
- Parent:
- 15:5eb637414df2
--- a/Socket/TCPSocketConnection.cpp Thu Mar 27 05:12:22 2014 +0000 +++ b/Socket/TCPSocketConnection.cpp Thu Mar 27 05:43:54 2014 +0000 @@ -39,7 +39,8 @@ int TCPSocketConnection::connect( unsigned int ip_addr, unsigned short port) { int ret; - + C_SNIC_UartCommandManager *uartCmdMgr_p = mSnicWifi_p->getUartCommand(); + // Socket create ret = createSocket(); if( ret != 0 ) @@ -82,10 +83,10 @@ // Send uart command request mSnicWifi_p->sendUart( command_len, command_array ); - mSnicWifi_p->mUartCommand.setCommandSID( UART_CMD_SID_SNIC_TCP_CONNECTION_STATUS_IND ); + uartCmdMgr_p->setCommandSID( UART_CMD_SID_SNIC_TCP_CONNECTION_STATUS_IND ); // Wait UART response - ret = mSnicWifi_p->mUartCommand.wait(); + ret = uartCmdMgr_p->wait(); if( ret != 0 ) { printf( "connect failed\r\n" ); @@ -93,9 +94,9 @@ return -1; } - if( mSnicWifi_p->mUartCommand.getCommandStatus() != UART_CMD_RES_SNIC_CONNECTION_UP ) + if( uartCmdMgr_p->getCommandStatus() != UART_CMD_RES_SNIC_CONNECTION_UP ) { - printf("connect status:%02x\r\n", mSnicWifi_p->mUartCommand.getCommandStatus()); + printf("connect status:%02x\r\n", uartCmdMgr_p->getCommandStatus()); mSnicWifi_p->freeCmdBuf( payload_buf ); return -1; } @@ -123,6 +124,8 @@ unsigned char gTCP_SEND_BUF[2048]; int TCPSocketConnection::send(unsigned char* data_p, int length) { + C_SNIC_UartCommandManager *uartCmdMgr_p = mSnicWifi_p->getUartCommand(); + // Get buffer for response payload from MemoryPool tagMEMPOOL_BLOCK_T *payload_buf = mSnicWifi_p->allocCmdBuf(); if( payload_buf == NULL ) @@ -156,7 +159,7 @@ // mSnicWifi_p->mUartCommand.setCommandSID( req.cmd_sid ); // Wait UART response - int ret = mSnicWifi_p->mUartCommand.wait(); + int ret = uartCmdMgr_p->wait(); if( ret != 0 ) { printf( "send failed\r\n" ); @@ -164,9 +167,9 @@ return -1; } - if( mSnicWifi_p->mUartCommand.getCommandStatus() != UART_CMD_RES_SNIC_SUCCESS ) + if( uartCmdMgr_p->getCommandStatus() != UART_CMD_RES_SNIC_SUCCESS ) { - printf("send status:%02x\r\n", mSnicWifi_p->mUartCommand.getCommandStatus()); + printf("send status:%02x\r\n", uartCmdMgr_p->getCommandStatus()); mSnicWifi_p->freeCmdBuf( payload_buf ); return -1; }