I am having trouble connecting reliably using wlan_connect(). My use case is simple: apply power to the CC3000, connect to first AP that matches some criteria, remove power from CC3000.
When I call wlan_connect() immediately after starting the CC3000, it returns 0 but never gets a DHCP IP address. If I insert some delay between wlan_start() and wlan_connect(), it returns 0 and most of the time gets a DHCP IP address. Is there some minimum delay that is required after a boot before connecting to an AP?
All connection policies are set to disabled, and even if I have connected to the AP previously it still has problems connecting.
Using unsecured security mode, the delay between wlan_start() and wlan_connect() must be about 1-2 seconds. If I use WPA2 security, it appears that the delay between wlan_start() and wlan_connect() has to be at least about 6 seconds.
I have captured the SPI commands/events and the only difference between the SPI sequences is the timing between the HCI_CMND_EVENT_MASK event and the HCI_CMND_WLAN_CONNECT command. If the connect command is issued immediately after the event mask event, there will never be subsequent HCI_EVNT_WLAN_UNSOL_CONNECT and HCI_EVNT_WLAN_UNSOL_DHCP events. If I insert the delay, the unsolicited connect and DHCP events occur and I get an IP address.
I am running the latest patch version.
Any thoughts would be appreciated.