Hi Everyone,
I am currently using Basic WiFi Application project based on CC3000 + Host MCU(MSP430F5232), and it did the smartconfig, DHCP, TCP socket connection with no problem. Then I add select(), recv() and send() functions in a while(1) loop, trying to communicate with the sever setup in my PC. What I found is the Host MCU is able to receive and send the data from/to the server, but only one time. I mean once the server sends the data again, the Host MCU can not recevie any more.
After checking further, I found, during the period of send() function, it got stuck in hci_event_handler() waiting for tSLInformation.usEventOrDataReceived to be true. I also checked the IRQ line, finding that, before the first loop of receiving and sending, I can see the IRQ line going dow periodicaly, which i believe triggerred due to the select() function, but after first loop of receiving and sending, the IRQ did not goes down any more, that's why the interrupt routine can not be excuted any more.
The code I am using has actually been verified in Home Automation project, because previously, I was using the CC3000 + MSP430FR5736, due to it's limited resource, I changed to MSP430F5232. For that configuration, the code was running very well. It was able to communicate with the server continuously without any problem. And then I compared the very detailed spi buffer between the HA and BWA, no matter spi tx buffer or spi rx buffer, I did not find any thing defferent. This issue has troubled me 2 days, anyone has any suggestion will be highly apprecaited! Thank you very much!
here is the code i am using:
unsigned char setupSocketConnection(void)
{
int ret, i;
long maxFD;
fd_set readsds;
timeval timeout;
memset(&timeout, 0, sizeof(timeval));
timeout.tv_sec = 1;
timeout.tv_usec = 0; //50*100;
volatile int bytesRecvd = 0;
volatile long bytesSent = 0;
RSCSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (RSCSocket == EFAIL)
{
wlan_stop();
return EFAIL;
}
RSCSocketAddr.sa_family = AF_INET;
RSCSocketAddr.sa_data[0] = (RSCServerPort & 0xFF00) >> 8;
RSCSocketAddr.sa_data[1] = (RSCServerPort & 0x00FF);
//correcting the endianess
RSCSocketAddr.sa_data[2] = RSCServerIP[0]; // First octet of destination IP
RSCSocketAddr.sa_data[3] = RSCServerIP[1]; // Second Octet of destination IP
RSCSocketAddr.sa_data[4] = RSCServerIP[2]; // Third Octet of destination IP
RSCSocketAddr.sa_data[5] = RSCServerIP[3]; // Fourth Octet of destination IP
//Connect the CC3000 WiFi module to the RSC server...by Andy 20140627
RSCServerFlag = connect(RSCSocket, &RSCSocketAddr, sizeof(RSCSocketAddr));
if (RSCServerFlag < 0)
{
// Unable to connect
return EFAIL;
}
else
{
RSCServerFlag = 1;
//setCC3000MachineState(CC3000_CONNECTED_WITH_SERVER);
while(1)
{
//Add client socket ID to to the read set
FD_SET(RSCSocket, &readsds);
maxFD = RSCSocket + 1;
ret = select(maxFD, &readsds, NULL, NULL, &timeout);
if(ret > 0)
{
memset(RxBuf, 0, CLIENT_RECV_BUF_SIZE);
bytesRecvd = recv(RSCSocket, RxBuf, CLIENT_RECV_BUF_SIZE, 0);
if(bytesRecvd > 0)
turnLedOn(LED1);
else
turnLedOff(LED1);
}
else
{
turnLedOff(LED1);
}
__no_operation();
__delay_cycles(10000);
ret = select(maxFD, NULL, &readsds, NULL, &timeout);
if(ret > 0)
{
bytesSent = send(RSCSocket, TxBuf, sizeof(TxBuf), 0);
if (bytesSent != sizeof(TxBuf))
{
turnLedOff(LED1);
}
else
turnLedOn(LED1);
}
else
{
turnLedOff(LED1);
// Here needs to check if connection is closed
// ...
}
}
//success
}
//return 0;
}

