Customized

Dependents:   MurataTypeYD_RPC_Sample

Fork of SNICInterface_mod by Toyomasa Watarai

Revision:
13:53e6471d5753
Parent:
12:0254eaccfda2
Child:
14:54378c96d285
--- a/Socket/TCPSocketConnection.cpp	Tue Mar 25 01:42:25 2014 +0000
+++ b/Socket/TCPSocketConnection.cpp	Tue Mar 25 02:21:11 2014 +0000
@@ -108,8 +108,59 @@
     return con_info_p->is_connected;
 }
 
+unsigned char gTCP_SEND_BUF[2048];
 int TCPSocketConnection::send(unsigned char* data_p, int length)
 {
+    // Get buffer for response payload from MemoryPool
+    tagMEMPOOL_BLOCK_T *payload_buf = mSnicWifi_p->getAlocCmdBuf();
+    if( payload_buf == NULL )
+    {
+        printf("connect payload_buf NULL\r\n");
+        return -1;
+    }
+
+    tagSNIC_TCP_SEND_FROM_SOCKET_REQ_T req;
+    // Make request
+    req.cmd_sid       = UART_CMD_SID_SNIC_SEND_FROM_SOCKET_REQ;
+    req.seq           = mUartRequestSeq++;
+    req.socket_id     = mSocketID;
+    req.option        = 0;
+    req.payload_len[0]= ( (length & 0xFF00) >> 8 );
+    req.payload_len[1]= (length & 0xFF);
+    
+    int req_size = sizeof(tagSNIC_TCP_SEND_FROM_SOCKET_REQ_T);
+    memcpy( gTCP_SEND_BUF, &req, req_size );
+    memcpy( &gTCP_SEND_BUF[req_size], data_p, length );
+    
+    unsigned char command_array[UART_REQUEST_PAYLOAD_MAX];
+    unsigned int  command_len;
+    // Preparation of command
+    command_len = mSnicWifi_p->preparationSendCommand( UART_CMD_ID_SNIC, req.cmd_sid, gTCP_SEND_BUF
+                            , req_size + length, payload_buf->buf, command_array );
+
+    // Send uart command request
+    mSnicWifi_p->sendUart( command_len, command_array );
+
+//    mSnicWifi_p->mUartCommand.setCommandSID( req.cmd_sid );
+
+    // Wait UART response
+    int ret = mSnicWifi_p->mUartCommand.wait();
+    if( ret != 0 )
+    {
+        printf( "send failed\r\n" );
+        mSnicWifi_p->freeCmdBuf( payload_buf );
+        return -1;
+    }
+    
+    if( mSnicWifi_p->mUartCommand.getCommandStatus() != UART_CMD_RES_SNIC_SUCCESS )
+    {
+        printf("send status:%02x\r\n", mSnicWifi_p->mUartCommand.getCommandStatus());
+        mSnicWifi_p->freeCmdBuf( payload_buf );
+        return -1;
+    }
+    mSnicWifi_p->freeCmdBuf( payload_buf );
+
+    // SNIC_SEND_FROM_SOCKET_REQ
     return 0;
 }