tinygo-org / drivers

TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.
https://tinygo.org
BSD 3-Clause "New" or "Revised" License
599 stars 188 forks source link

wifinina: can't connect to AP 50% of the time #468

Closed scottfeldman closed 10 months ago

scottfeldman commented 1 year ago

I'm using drivers/examples/wifinina/tcpclient/main.go example on Arduino Nano33 IoT.

I'm seeing AP connect fail 50% of the time. In fact, it seems to toggle between pass and fail. Usually, after tinygo flash, the AP connect will fail. Pressing the hard reset button on the Nano33 will try the AP connect again. This time it will connect. Pressing the hard reset again, the AP connect will fail. And so on...

I logged the connection status during the AP connect to see what's going on:

[tinygo flash]                                                                                                                                        

Connecting to [my ssid]                                                                                                                                 
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS Connect Failed                         <-- failed                                                                                                      
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed                                                                                                                               
...                                                                                                                                                 

[HARD RESET]                                                                                                                                        

Connecting to [my ssid]                                                                                                                                 
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS Connected                            <-- success                                                                                                        
Connected.                                                                                                                                          
192.168.1.152                                                                                                                                       
---------------                                                                                                                                     
Dialing TCP connection                                                                                                                              
...                                                                                                                                                 

[HARD RESET]                                                                                                                                        

Connecting to [my ssid]                                                                                                                                 
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS No SSID Available                                                                                                                            
STATUS Connect Failed                     <-- failed                                                                                                          
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed                                                                                                                               
STATUS Connect Failed
STATUS Connect Failed
STATUS Connect Failed
STATUS Connect Failed
STATUS Connect Failed
STATUS Connect Failed
...

[HARD RESET]

Connecting to [my ssid]
STATUS No SSID Available
STATUS No SSID Available
STATUS No SSID Available
STATUS No SSID Available
STATUS No SSID Available
STATUS No SSID Available
STATUS No SSID Available
STATUS No SSID Available
STATUS No SSID Available
STATUS No SSID Available
STATUS No SSID Available
STATUS Connected                    <-- success
Connected.
192.168.1.152 
---------------
Dialing TCP connection 
...

I tried various delays after holding RESET low and high. No change.

I tried RESET twice (low/high/low/high). No change.

scottfeldman commented 1 year ago

I tried the same wifinina/tcpclient example on Arduino Nano RP2040 and get the same results. Connection attempts fails 50% of the time.

(wioterminal using rtl8720dn/tcpclient example connects 100% of the time, connecting the same AP as the Arduino Nano tests).

scottfeldman commented 1 year ago

I tried using a different Wifi router, and the issue goes away. The issue was first reported on a Starlink Wifi router, so maybe this is limited to connecting to Starlink router.

scottfeldman commented 1 year ago

Just a note for now: this issue is fixed with the netdev branch.

deadprogram commented 1 year ago

Also fixed by https://github.com/tinygo-org/drivers/pull/561 until that gets merged in TinyGo 0.29 release.

deadprogram commented 10 months ago

This was already released so now closing. Thanks!