Other Parts Discussed in Thread: CC3100
Hello,
I am able to open, connect, send and receive and then close tcp just fine. But I noticed that, whenever I do a consecutive write and read, it doesn't.. Even just a consecutive send won't work. The display on my packet sender program would just show one packet transmitted. I would have to close the socket first and then connect and then send and receive. Is there a way to keep the socket open and continuously send and receive until I decide to stop and close? What I am doing is sending commands to serial terminal UART that's why you see code divided by if statements. 0 - open and connect, 1- close, 2 - send and receive.
When I enter 0, the device connects and opens successfully. Then I enter 2. It sends and receives data ok. But when I enter 2 the second time, I don't get an error yet but the packet is not sent. I enter 2 the third time, no error on sl_Send but sl_Receive gives me an error. Thing is, I am not able to send a receive consecutively. I need to enter 1 to close and then repeat the process. Am I missing anything?
Thanks a lot
{
WriteUART0("\n\n\rOpen and Connect to Socket");
CC3100StatFlags.ErrorFlag = OpenTCPSocket();
if(CC3100StatFlags.ErrorFlag == CC3100_NO_ERROR)
{
WriteUART0("\n\rSocket Open");
else
{
WriteUART0("\n\rSocket Open and Connect ERROR");
} //end else
PrintCC3100Error();
}//end if(UART0RxBytes[0] == '0')//Open TCP socket
/***********************************************/
else if(UART0RxBytes[0] == '1')//Close TCP socket
{
WriteUART0("\n\n\rClose TCP Socket");
CC3100StatFlags.ErrorFlag = CloseTCPSocket();
if(CC3100StatFlags.ErrorFlag == CC3100_NO_ERROR)
{
WriteUART0("\n\rSocket Close");
else
{
WriteUART0("\n\rSocket Close ERROR");
} //end else
PrintCC3100Error();
}//end else if(UART0RxBytes[0] == '1')//Close TCP socket
/***********************************************/
else if(UART0RxBytes[0] == '2')//Send to TCP
{
WriteUART0("\n\n\rSend to TCP Socket");
CC3100StatFlags.ErrorFlag = SendToTCPSocket(SockID, "HELLO", 5, 0);
if(CC3100StatFlags.ErrorFlag == CC3100_NO_ERROR)
{
WriteUART0("\n\rSend to TCP OK");
CC3100StatFlags.ErrorFlag = RecvFromTCPSocket(SockID, integerArray, 5, 0);
WriteUART0("\n\r");
WriteUART0(integerArray);
}//end if(CC3100StatFlags.ErrorFlag == CC3100_NO_ERROR)
else
{
WriteUART0("\n\rSend to TCP ERROR");
} //end else
PrintCC3100Error();
}//end else if(UART0RxBytes[0] == '2')//Send to TCP