I'm working with the CC3000 and have encountered a problem where the CC3000 sends unexpected command completion events. The specific case is a SOCKET_CONNECT command completion; the status code is -1. This appears to always happen in response to a SOCKET_ACCEPT command. Generally speaking, simply ignoring the unexpected SOCKET_CONNECT completion results in a SOCKET_ACCEPT completion with an error status, and the next SOCKET_ACCEPT works as expected.
However, I am also seeing unexpected TCP_CLOSE_WAIT events, apparently always after SOCKET_RECV. In this case, the SOCKET_RECV does not complete.
Sample code looks like this - I know it's ugly :-) Taken from a hacked MSP430G2553 demo app
i = wlan_connect(WLAN_SEC_WPA2, "ssid", strlen("ssid"), NULL, "password", strlen("password")); while (ulCC3000DHCP == 0) ; s1 = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); memset(&sa, 0, sizeof(sa)); sa.sin_family = htons(AF_INET); sa.sin_port = htons(80); sa.sin_addr.s_addr = htonl(0); j = bind(s1, (const sockaddr *)&sa, sizeof(sa)); while (1) { k = listen(s1, 10); do { salen = sizeof(si); } while ((s2 = accept(s1, (sockaddr *) &si, &salen)) == -2); if (s2 < 0) { continue; } do { k = recv(s2, &recv_buf, 10, 0); // eat up the HTTP request header } while (k == 10); j = send(s2, &send_buf, strlen(send_buf), 0); // send "test" as a response closesocket(s2); }
The test system does "while true ; do ; wget http://<ipaddr> ; done" and proceeds as normal for some time until it hangs as mentioned below.
My question is - the 1.11.1 release notes indicate unsolicited connect is handled in the host driver. Yet I do not see an SDK 1.11.1 version with an updated host driver, which may at least resolve the unsolicited connects I'm seeing. I vaguely suspect the unexpected TCP_CLOSE_WAIT event is the result of the CC3000 being confused about the state of an incoming connection - I would only expect to see TCP_CLOSE_WAIT in response to an outbound connection initiated by the CC3000.
I am running 1.24 of the firmware from the 1.11.1 patch programmer.
Is there an updated SDK 1.11.1 host driver source I should try?