soypat / seqs

seqs: the hottest, most idiomatic userspace TCP/IP implementation on the internet. lwip in go basically
BSD 3-Clause "New" or "Revised" License
46 stars 5 forks source link

Fix for bug in wait_for_join - makes joining WIFI very flaky #34

Closed nickaxgit closed 1 month ago

nickaxgit commented 1 month ago

Hi Patricio

I was having very unreliable initial connection to WIFI networks

Fairly sure this is the fix:- (last line) - it certainly works a lot better

In wifi.go

func (d *Device) wait_for_join(ssid string) (err error) { d.eventmask.Enable(whd.EvSET_SSID) d.eventmask.Enable(whd.EvAUTH)

err = d.setSSID(ssid)
if err != nil {
    return err
}
// Poll for async events.
deadline := time.Now().Add(20 * time.Second)
keepGoing := true
for keepGoing {
    time.Sleep(270 * time.Millisecond) //was 270
    err = d.check_status(d._sendIoctlBuf[:])
    if err != nil {
        return err
    }
    // Keep trying until we get a link up/auth failed/timeout.
    //OLD - keepGoing = d.state == linkStateDown && d.state != linkStateUpWaitForSSID && time.Until(deadline) > 0
    keepGoing = (d.state == linkStateDown || d.state == linkStateUpWaitForSSID) && time.Now().Before(deadline)
}
soypat commented 1 month ago

Nick! Neat find. The condition as is d.state == linkStateDown && d.state != linkStateUpWaitForSSID does not make a lot of sense really, if the first condition is true the second is always true as well. Your change makes much more sense since the connection process should wait until the auth is done.

Will make change!

soypat commented 1 month ago

Fixed in https://github.com/soypat/cyw43439/commit/a40e87e292b55477e07559fb93ad1ea63a3411a5

nickaxgit commented 1 month ago

Thanks

Wish I could contribute more/better but the necessity to earn a living gets in the way. best of luck with the project I would love to see TinyGo flourish

On Sun, 27 Oct 2024 at 22:56, Patricio Whittingslow < @.***> wrote:

Nick! Neat find. The condition as is d.state == linkStateDown && d.state != linkStateUpWaitForSSID does not make a lot of sense really, if the first condition is true the second is always true as well. Your change makes much more sense since the connection process should wait until the auth is done.

Will make change!

— Reply to this email directly, view it on GitHub https://github.com/soypat/seqs/issues/34#issuecomment-2440206849, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALR2VA5REQAEORVRATMPAC3Z5VVSLAVCNFSM6AAAAABQQVTJTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBQGIYDMOBUHE . You are receiving this because you authored the thread.Message ID: @.***>