Customized SNICInterface
Fork of NySNICInterface by
Diff: SNIC/SNIC_Core.cpp
- Revision:
- 16:6100acfeb1f1
- Parent:
- 15:5eb637414df2
diff -r 5eb637414df2 -r 6100acfeb1f1 SNIC/SNIC_Core.cpp --- a/SNIC/SNIC_Core.cpp Thu Mar 27 05:12:22 2014 +0000 +++ b/SNIC/SNIC_Core.cpp Thu Mar 27 05:43:54 2014 +0000 @@ -33,7 +33,7 @@ { if( mInstance_p == NULL ) { - mInstance_p = new C_SNIC_Core(); + mInstance_p = new C_SNIC_Core(); } return mInstance_p; } @@ -42,6 +42,7 @@ { int i; + mUartCommand_p = new C_SNIC_UartCommandManager(); for( i = 0; i < MAX_SOCKET_ID+1; i++ ) { mConnectInfo[i].recvbuf_p = NULL; @@ -92,9 +93,9 @@ command_len = C_SNIC_UartMsgUtil::makeRequest( cmd_id, payload_array, payload_len, command_p ); // Set data for response - mUartCommand.setCommandID( cmd_id ); - mUartCommand.setCommandSID( cmd_sid | 0x80 ); - mUartCommand.setResponseBuf( response_buf_p ); + mUartCommand_p->setCommandID( cmd_id ); + mUartCommand_p->setCommandSID( cmd_sid | 0x80 ); + mUartCommand_p->setResponseBuf( response_buf_p ); return command_len; } @@ -138,6 +139,11 @@ return &mConnectInfo[socket_id]; } +C_SNIC_UartCommandManager *C_SNIC_Core::getUartCommand() +{ + return mUartCommand_p; +} + DigitalOut led1(LED1); void C_SNIC_Core::uartRecvThread (void const *args_p) { @@ -146,6 +152,7 @@ { printf("Socket constructor error: no wifly instance available!\r\n"); } + C_SNIC_UartCommandManager *uartCmdMgr_p = instance_p->getUartCommand(); int recvdata = 0; int i; @@ -186,29 +193,29 @@ if( (command_id == UART_CMD_ID_SNIC) && (gUART_TEMP_BUF[0] == UART_CMD_SID_SNIC_CONNECTION_RECV_IND) ) { // Packet buffering - instance_p->mUartCommand.bufferredPacket( gUART_TEMP_BUF, payload_len ); + uartCmdMgr_p->bufferredPacket( gUART_TEMP_BUF, payload_len ); } // Check scan results indication else if( (command_id == UART_CMD_ID_WIFI) && (gUART_TEMP_BUF[0] == UART_CMD_SID_WIFI_SCAN_RESULT_IND) ) { // Scan result indicate - instance_p->mUartCommand.scanResultIndicate( gUART_TEMP_BUF, payload_len ); + uartCmdMgr_p->scanResultIndicate( gUART_TEMP_BUF, payload_len ); } // Checks in the command which is waiting. - else if( instance_p->mUartCommand.isWaitingCommand(command_id, gUART_TEMP_BUF) ) + else if( uartCmdMgr_p->isWaitingCommand(command_id, gUART_TEMP_BUF) ) { // Get buffer for payload data - unsigned char *payload_buf_p = instance_p->mUartCommand.getResponseBuf(); + unsigned char *payload_buf_p = uartCmdMgr_p->getResponseBuf(); if( payload_buf_p != NULL ) { memcpy( payload_buf_p, gUART_TEMP_BUF, payload_len ); - instance_p->mUartCommand.setResponseBuf( NULL ); + uartCmdMgr_p->setResponseBuf( NULL ); } // Set status - instance_p->mUartCommand.setCommandStatus( gUART_TEMP_BUF[2] ); + uartCmdMgr_p->setCommandStatus( gUART_TEMP_BUF[2] ); // Set signal for command response wait. - instance_p->mUartCommand.signal(); + uartCmdMgr_p->signal(); } gUART_RCVBUF.size = 0;