This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3000 SimpleLink connect() timeout?

I want the CC3000 to attempt to connect to an IP on port 9000.  If that connect fails, try 9001, then 9002, etc.  However, the time out for connect() is about 1 minute.  Since the connect() timeout cannot be reduced via setsockopts(), I would like to implement a timed interrupt to stop the connection attempt, and try the next port. 

However, since the execution enters SimpleLinkWaitEvent(), it will not exit until it receives an event.  So, in an interrupt, I could toggle the PW_EN on the tiwi, to reboot it, and then start over, but execution will still be in SimpleLinkWaitEvent().  Is there any way I can trick the library into thinking that the TiWi timed out?  Can I then issue another connect() to the TiWi, or will it ignore it because it is still dealing with the previous attempt?

The best option would be to set a timeout on the connect, but that doesn't seem supported.

Thanks,
Nathan

  • Hi Nathan,

    You are right, the bsd connect API is blocking until an event is received. This is the current architecture. We will examine the option for non-blocking connect in next releases but i cannot commit on a schedule.

    There is an option to set the inactivity time for the socket via netapp_timeout_values() but the minimum time is set to 20 seconds inside CC3000 FW. This is the TCP spec. it means you would need to wait 20 seconds which is too long.

    Regarding your solution, it would not work since the event handler is probing a flag, tSLInformation.usEventOrDataReceived, and as long as it is 0, the event handler would not return. you can use wlan_stop and wlan_start or alternately twick this flag but it requires deep understanding of the code flow.

    BR,

    Shlomi