I'm using the CC3000 and trying to receive a small bit of data from a linux machine. Here's the code that I'm using inside the main():
// Set up listener on inport
int sr = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
tRemoteAddrRecv.sa_family = AF_INET;
tRemoteAddrRecv.sa_data[0] = (inport & 0xFF00) >> 8;
tRemoteAddrRecv.sa_data[1] = (inport & 0x00FF);
tRemoteAddrRecv.sa_data[2] = 192;
tRemoteAddrRecv.sa_data[3] = 168;
tRemoteAddrRecv.sa_data[4] = 2;
tRemoteAddrRecv.sa_data[5] = 15; //IP addr of the client that will connect to CC3000
bind(sr, &tRemoteAddrRecv, sizeof(sockaddr));
__delay_cycles(100000);
listen(sr,0);
socklen_t addrlength = sizeof(tRemoteAddrRecv);
while (1)
{
__bis_SR_register(LPM2_bits + GIE);
__no_operation();
//
// Handle any un-solicited event if required - the function shall be triggered
// few times in a second
//
hci_unsolicited_event_handler();
long acceptresult = accept(sr,&tRemoteAddrRecv, &addrlength);
if(acceptresult >= 0)
{
//have a connection
turnLedOn(3);
}
else if(acceptresult == -2)
{
//connection pending
turnLedOn(2);
}
else if(acceptresult == -1)
{
//socket error
turnLedOn(1);
}
}
The CC3000 module connects to my AP, and it will also send data. Also, I can see LED 2 turn on, so it seems to want to allow something to connect, it just doesn't for some reason. Any thoughts or advice? Thanks!