Hi,
My cc3000 hung when receiving udp packets from my android phone, but not always, sometimes can receive successfully but even this I can not get the correct source IP address.
In my code, I can successfully open a socket by socket() and bind it to a port(36000) by:
ulSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
ret = setsockopt( ulSocket, SOL_SOCKET, SOCKOPT_RECV_TIMEOUT, &timeout, sizeof( timeout ) );
ret = setsockopt( ulSocket, SOL_SOCKET, SOCKOPT_NONBLOCK, &unblock_enable, sizeof( unblock_enable ) );
tSocketAddr.sa_family = AF_INET;
tSocketAddr.sa_data[0] = 0x8c;
tSocketAddr.sa_data[1] = 0xa0;
memset(&tSocketAddr.sa_data[2], 0, 4);
bind(ulSocket, &tSocketAddr, sizeof(sockaddr));
Then I keep using ret = recvfrom(ulSocket, pucCC3000_Rx_Buffer, CC3000_APP_BUFFER_SIZE, 0, (sockaddr*)&tSocketAddr, &tRxPacketLength);
to receive udp packet from my android phone in my local network.
Sometimes I can get my sending data in pucCC3000_Rx_Buffer successfully but sometimes hang in recvfrom function (still can ping to cc3000 during hanging). I has set the udp timeout value as 2s already. I also tried using both blocking and non-blocking mode, the situation did not change. Even when I got the udp packet successfully the source IP resided in tSocketAddr is wrong and the returned tRxPacketLength is 12, but the receive data in pucCC3000_Rx_Buffer is correct. If I send the udp data to my PC in the same way I can get the correct information in Wireshark. My sending data is small just 2 bytes and the pucCC3000_Rx_Buffer is large enough (228 bytes).
I set my socket timeout value as 0 and I can keep sending udp packet out if not receiving.
Host MCU: STM32F4
Host Driver version: 1.10.1
Service Pack version: 1.10
udp test app in android: UDP TCP Server Free, UDPTester
Thanks.