crockedile
05/15/2025, 5:30 PMcrockedile
05/15/2025, 5:31 PMjag, device has version
******************************************************************************
EXCEPTION error.
wifi already connected with different credentials
0: WifiServiceProvider.connect. /home/runner/work/envelopes/envelopes/toit/system/extensions/esp32/wifi.toit:97:9
1: WifiServiceProvider.connect /home/runner/work/envelopes/envelopes/toit/system/extensions/esp32/wifi.toit:74:3
2: WifiServiceProvider.connect /home/runner/work/envelopes/envelopes/toit/system/extensions/esp32/wifi.toit:72:12
3: NetworkServiceProviderBase.handle /home/runner/work/envelopes/envelopes/toit/system/extensions/shared/network_base.toit:27:14
4: WifiServiceProvider.handle /home/runner/work/envelopes/envelopes/toit/system/extensions/esp32/wifi.toit:69:12
5: ServiceManager_. /system/services.toit:643:15
6: RpcRequest_.process. /rpc/broker.toit:98:26
7: RpcRequest_.process /rpc/broker.toit:95:3
8: RpcRequestQueue_.ensure-processing-task_... /rpc/broker.toit:214:20
9: RpcRequestQueue_.ensure-processing-task_.. /rpc/broker.toit:209:9
10: RpcRequestQueue_.ensure-processing-task_. /rpc/broker.toit:204:85
******************************************************************************
[wifi] DEBUG: closing
E (370311) wifi:NAN WiFi stop
[jaguar] ERROR: program f04d6fd8-af2e-e652-a2b2-b7af575d2312 stopped - exit code 1
[wifi] DEBUG: connecting
[wifi] DEBUG: connected
[wifi] INFO: network address dynamically assigned through dhcp {ip: 192.168.137.216}
[wifi] INFO: dns server address dynamically assigned through dhcp {ip: [192.168.137.1]}floitsch
05/16/2025, 12:49 PMwifi.open.
The mqtt client then tries to open the same WiFi, but this time through the system service.
A few ways to solve this:
- close the network you received with wifi.open and let the the system open the same network again. (basically: connection.close). Note that you can save the WiFi credentials with wifi.open ... --save)
- use the network you received from wifi.open for the MQTT connection.
In the latter case you would set the --net-open lambda of the client:
client := mqtt.Client --net-open=(:: connection) --host=HOST --port=PORT
Note that this isn't completely correct, as net-open can be called multiple times. In theory you would need to track whether this was the first call, and if not, establish a new connection.
Something like:
client := mqtt.Client --host=HOST --port=PORT --net-open=::
if connection.is-closed:
connection = wifi.open ...
connectioncrockedile
05/16/2025, 8:30 PMkasperl
05/17/2025, 3:14 PMntp.synchronize like this ntp.synchronize --network=connection.nas2011
05/20/2025, 4:59 PMkasperl
05/20/2025, 5:00 PMkasperl
05/20/2025, 5:01 PMnas2011
05/20/2025, 5:33 PMfloitsch
05/20/2025, 5:35 PM--net-open lambda where you can provide the code of how to open the network.
If you don't want to reflash, you can also have a small container installed, that just looks at a specific pin, and opens (with --save) on network1, when the pin is pulled to ground. That should make development much easier.nas2011
05/20/2025, 5:38 PM