Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wifi.connect() fails after reset() #2295

Closed
MaBecker opened this issue Nov 25, 2022 · 12 comments
Closed

wifi.connect() fails after reset() #2295

MaBecker opened this issue Nov 25, 2022 · 12 comments
Labels
ESP32 This is only a problem on ESP32-based devices

Comments

@MaBecker
Copy link
Contributor

Running test wifiEvents.js

|  __|___ ___ ___ _ _|_|___ ___
|  __|_ -| . |  _| | | |   | . |
|____|___|  _|_| |___|_|_|_|___|
         |_| espruino.com
 2v16.10 (c) 2021 G.Williams
Espruino is Open Source. Our work is supported
only by sales of official boards and donations:
http://espruino.com/Donate
E (392022) wifi:sta is connecting, return error
>E (395163) event: post event to user fail!
E (398303) event: post event to user fail!
E (401443) event: post event to user fail!
E (404584) event: post event to user fail!
Event-> disconnected: {"ssid":"RASPI3","mac":"00:00:00:00:00:00","reason":"201"}
>WARNING: Scan stop failed
WARNING: set rssi scan not implemeted yet
 ____                 _
|  __|___ ___ ___ _ _|_|___ ___
|  __|_ -| . |  _| | | |   | . |
|____|___|  _|_| |___|_|_|_|___|
         |_| espruino.com
 2v16.10 (c) 2021 G.Williams
Espruino is Open Source. Our work is supported
only by sales of official boards and donations:
http://espruino.com/Donate
>
WARNING: Scan stop failed
WARNING: set rssi scan not implemeted yet
 ____                 _
|  __|___ ___ ___ _ _|_|___ ___
|  __|_ -| . |  _| | | |   | . |
|____|___|  _|_| |___|_|_|_|___|
         |_| espruino.com
 2v16.10 (c) 2021 G.Williams
Espruino is Open Source. Our work is supported
only by sales of official boards and donations:
http://espruino.com/Donate
Execution Interrupted
New interpreter error: LOW_MEMORY,MEMORY
> 
@MaBecker MaBecker added the ESP32 This is only a problem on ESP32-based devices label Nov 25, 2022
@gfwilliams
Copy link
Member

Ouch - is this new in 3.3.6?

@MaBecker
Copy link
Contributor Author

No, just tested a 2v09 version

 ____                 _
|  __|___ ___ ___ _ _|_|___ ___
|  __|_ -| . |  _| | | |   | . |
|____|___|  _|_| |___|_|_|_|___|
         |_| espruino.com
 2v09.11 (c) 2021 G.Williams
Espruino is Open Source. Our work is supported
only by sales of official boards and donations:
http://espruino.com/Donate
Execution Interrupted
New interpreter error: LOW_MEMORY,MEMORY
> 

@MaBecker
Copy link
Contributor Author

MaBecker commented Dec 8, 2022

Not sure what causes this?!

ESP32 is calling many times esp_wifi_connect()

esp_err_t err = esp_wifi_connect();

err = esp_wifi_connect();

ESP8266 is just calling it in jswrap_wifi_connect()

The ESP32 is calling it additionally in event_handler()

@gfwilliams
Copy link
Member

I think there is a way of turning on some extra debug logging for ESP32? Memory errors are frustrating to debug because as there's no memory left a stack trace can't be stored.

Is it reproducible every time with that code you added?

@MaBecker
Copy link
Contributor Author

MaBecker commented Dec 9, 2022

Just build new app and esp-ifd files and the error disappeared ....... will run some more tests

@MaBecker
Copy link
Contributor Author

MaBecker commented Dec 9, 2022

Ok, it still happens ....

>
Execution Interrupted
New interpreter error: LOW_MEMORY,MEMORY
{ "free": 4036, "usage": 59, "total": 4095, "history": 0,
  "gc": 0, "gctime": 16.768, "blocksize": 13 }
{
  "sdkVersion": "v3.3.6",
  "freeHeap": 2876068, "BLE": true, "Wifi": true, "minHeap": 2874536 }
>
>
>
>console.log(wifi.getIP());
{
  "ip": "192.168.101.103",
  "netmask": "255.255.255.0",
  "gw": "192.168.101.1",
  "mac": "34:94:54:c0:bd:f0"
 }
=undefined

@jumjum123
Copy link
Contributor

jumjum123 commented Dec 9, 2022 via email

@MaBecker
Copy link
Contributor Author

MaBecker commented May 23, 2024

workaround is call to E.reboot() and than upload the code

Edit: Do not connect if already connected

var ssid="SSID";
var password="password";

var wifi=require("Wifi");
wifi.stopAP(()=> {
  print(wifi.getStatus());
  var status = wifi.getStatus();
  if (status.ssid == ssid && status.station == "connected"){
    print(wifi.getIP());
  } else {
    wifi.connect(ssid, {password: password}, function() {
      print(wifi.getIP());
    });
  }
});

@MaBecker
Copy link
Contributor Author

@gfwilliams: Should this be handle internaly by the wifi.connect() function? Or is handling it in JS good enough?

@gfwilliams
Copy link
Member

The wifi.connect function should really handle this, yes. I think if it's already connected it should probably attempt to stop the connection first, as in some cases a user might want to force a reconnect to an existing AP.

You mentioned in https://forum.espruino.com/conversations/395499/?offset=125#17501763 that it might be 'broken again' so do you still think this is the issue?

When I tested here I enabled all the wifi debug messages and I didn't see any sign that the C3 had even managed to get a wifi connection before .connect was called.

@MaBecker
Copy link
Contributor Author

MaBecker commented Aug 31, 2024

fixed in the latest build.

@MaBecker
Copy link
Contributor Author

The wifi.connect function should really handle this, yes. I think if it's already connected it should probably attempt to stop the connection first, as in some cases a user might want to force a reconnect to an existing AP.

You mentioned in https://forum.espruino.com/conversations/395499/?offset=125#17501763 that it might be 'broken again' so do you still think this is the issue?

When I tested here I enabled all the wifi debug messages and I didn't see any sign that the C3 had even managed to get a wifi connection before .connect was called.

We can use disconnect or connect with different setting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ESP32 This is only a problem on ESP32-based devices
Projects
None yet
Development

No branches or pull requests

3 participants