Can't configure wifi

#1

I’m trying to configure wifi for a simple app I wrote… From the mos tool (on a mac) I issue:

mos config-set wifi.sta.enable=true wifi.ap.enable=false wifi.sta.ssid='mylan' wifi.sta.pass=mypass

And the error I get is:

Getting configuration...
Error: /private/tmp/mos-20191002-29497-yt53zd/mos-b14a864da77d6f3b0b1ad591876b41cf06e70bab/src/cesanta.com/go/src/github.com/mongoose-os/mos/mos/dev/dev_conf.go:81: no config value at path "wifi.sta.enable"
/private/tmp/mos-20191002-29497-yt53zd/mos-b14a864da77d6f3b0b1ad591876b41cf06e70bab/src/cesanta.com/go/src/github.com/mongoose-os/mos/mos/config/config.go:98: 
/private/tmp/mos-20191002-29497-yt53zd/mos-b14a864da77d6f3b0b1ad591876b41cf06e70bab/src/cesanta.com/go/src/github.com/mongoose-os/mos/mos/main.go:196: config-set failed
exit status 1

I expect this is a simple issue but the error message has not been helpful, and I have not had luck searching and experimenting.

Basically the issue is:

no config value at path "wifi.sta.enable"

It’s the same if I issue:

mos wifi 'mylan' mypass

#2

It looks like - origin: https://github.com/mongoose-os-libs/wifi is not in your mos.yml libs section.

#3

It is actually…

# List of libraries used by this app, in order of initialisation
libs:
  - origin: https://github.com/mongoose-os-libs/wifi
  - origin: https://github.com/mongoose-os-libs/dash
  - origin: https://github.com/mongoose-os-libs/ca-bundle
  - origin: https://github.com/mongoose-os-libs/i2c
  - origin: https://github.com/mongoose-os-libs/rpc-service-config
  - origin: https://github.com/mongoose-os-libs/rpc-service-fs
  - origin: https://github.com/mongoose-os-libs/rpc-uart
  - origin: https://github.com/mongoose-os-libs/spi
#4

Somehow wifi is not included in the firmware. Or did not build and flash after including the library.
You didn’t mention what is your platform.

Without wifi (esp8266):

mos console
...
[Oct  3 07:47:53.932] rBoot v1.2.1-cesanta1 - richardaburton@gmail.com
[Oct  3 07:47:53.938] Flash Size:   32 Mbit
[Oct  3 07:47:53.938] Flash Mode:   DIO
[Oct  3 07:47:53.941] Flash Speed:  80 MHz
[Oct  3 07:47:53.945] rBoot Option: Big flash
[Oct  3 07:47:53.945] 
[Oct  3 07:47:53.981] Booting rom 0 (0x100000).
[Oct  3 07:47:54.032]     g  r  g|  l l$d`  c   < ;  $ g   o   l    { $ l[   : sta(2c:3a:e8:42:44:bd) + softAP(2e:3a:e8:
[Oct  3 07:47:54.042] esp_main.c:172          empty 1.0 (20191003-044325)
[Oct  3 07:47:54.045] esp_main.c:174          Mongoose OS 3029e19 (20191003-044325/g3029e19-master)
[Oct  3 07:47:54.053] esp_main.c:178          CPU: ESP8266EX, 160 MHz, RAM: 53224 total, 48576 free
[Oct  3 07:47:54.059] esp_main.c:180          SDK 2.2.1(1247cc5); flash: 4M
[Oct  3 07:47:54.064] esp_exc.c:211           Reset cause: 6 (sys reset)
[Oct  3 07:47:54.070] mg_lwip_ev_mgr.c:93     Mongoose 6.15, LwIP 1.4.1
[Oct  3 07:47:54.073] mg_ssl_if_mbedtls.c:57  mbed TLS 2.16.0-cesanta4
[Oct  3 07:47:54.079] mgos_vfs_dev.c:73       sfl0: sysflash (), size 4194304
[Oct  3 07:47:54.083] mgos_vfs_dev.c:73       root: part ({"dev": "sfl0", "offset": 32768, "size": 262144}), size 262144
[Oct  3 07:47:54.094] mgos_vfs.c:147          /: SPIFFS @ root, opts 
[Oct  3 07:47:54.142] mgos_vfs.c:320          /: size 233681, used: 29618, free: 204063
[Oct  3 07:47:54.242] mgos_sys_config.c:368   MAC: 2e:3a:e8:42:44:bd
[Oct  3 07:47:54.246] mgos_sys_config.c:376   WDT: 30 seconds
[Oct  3 07:47:54.249] mgos_ota_shadow_lib:102 OTA over shadow initialised
[Oct  3 07:47:54.257] mgos_rpc_channel_ua:313 0x3fff0ebc UART0
[Oct  3 07:47:54.261] mgos_init.c:36          Init done, RAM: 53224 total, 45204 free, 45208 min free
mos config-get wifi
Using port /dev/cu.usbserial-149220
Error: /Users/mos/mos/go/src/github.com/mongoose-os/mos/mos/dev/dev_conf.go:40: no config value at path "wifi"
/Users/mos/mos/go/src/github.com/mongoose-os/mos/mos/config/config.go:63: 
/Users/mos/mos/go/src/github.com/mongoose-os/mos/mos/main.go:196: config-get failed

With wifi:

mos console
...
[Oct  3 07:55:17.045] rBoot v1.2.1-cesanta1 - richardaburton@gmail.com
[Oct  3 07:55:17.050] Flash Size:   32 Mbit
[Oct  3 07:55:17.050] Flash Mode:   DIO
[Oct  3 07:55:17.053] Flash Speed:  80 MHz
[Oct  3 07:55:17.058] rBoot Option: Big flash
[Oct  3 07:55:17.058] 
[Oct  3 07:55:17.094] Booting rom 0 (0x100000).
[Oct  3 07:55:17.145]     n  {  '|  l dl$`  c   | {  d n   '   d`   ; l l  mode : sta(2c:3a:e8:42:44:bd) + softAP(2e:3a:e8:
[Oct  3 07:55:17.154] esp_main.c:172          empty 1.0 (20191003-045254)
[Oct  3 07:55:17.157] esp_main.c:174          Mongoose OS 3029e19 (20191003-045254/g3029e19-master)
[Oct  3 07:55:17.166] esp_main.c:178          CPU: ESP8266EX, 160 MHz, RAM: 52728 total, 48080 free
[Oct  3 07:55:17.172] esp_main.c:180          SDK 2.2.1(1247cc5); flash: 4M
[Oct  3 07:55:17.177] esp_exc.c:211           Reset cause: 6 (sys reset)
[Oct  3 07:55:17.183] mg_lwip_ev_mgr.c:93     Mongoose 6.15, LwIP 1.4.1
[Oct  3 07:55:17.185] mg_ssl_if_mbedtls.c:57  mbed TLS 2.16.0-cesanta4
[Oct  3 07:55:17.192] mgos_vfs_dev.c:73       sfl0: sysflash (), size 4194304
[Oct  3 07:55:17.196] mgos_vfs_dev.c:73       root: part ({"dev": "sfl0", "offset": 32768, "size": 262144}), size 262144
[Oct  3 07:55:17.207] mgos_vfs.c:147          /: SPIFFS @ root, opts 
[Oct  3 07:55:17.255] mgos_vfs.c:320          /: size 233681, used: 29618, free: 204063
[Oct  3 07:55:17.357] mgos_sys_config.c:368   MAC: 2e:3a:e8:42:44:bd
[Oct  3 07:55:17.361] mgos_sys_config.c:376   WDT: 30 seconds
[Oct  3 07:55:17.364] mgos_ota_shadow_lib:102 OTA over shadow initialised
[Oct  3 07:55:17.373] mgos_rpc_channel_ua:313 0x3fff10ac UART0
[Oct  3 07:55:17.377] bcn 0
[Oct  3 07:55:17.377] del if1
[Oct  3 07:55:17.377] del if0
[Oct  3 07:55:17.377] usl
[Oct  3 07:55:17.379] mode : null
[Oct  3 07:55:17.379] mgos_wifi.c:458         WiFi mode: AP
[Oct  3 07:55:17.383] esp_wifi.c:106          WiFi mode: AP
[Oct  3 07:55:17.386] mode : softAP(2e:3a:e8:42:44:bd)
[Oct  3 07:55:17.388] add if1
[Oct  3 07:55:17.391] dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
[Oct  3 07:55:17.397] bcn 100
[Oct  3 07:55:17.397] esp_wifi.c:298          WiFi AP: SSID Mongoose_4244BD, channel 6
[Oct  3 07:55:18.285] bcn 0
[Oct  3 07:55:18.285] del if1
[Oct  3 07:55:18.285] usl
[Oct  3 07:55:18.285] add if1
[Oct  3 07:55:18.285] dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
[Oct  3 07:55:18.291] bcn 100
[Oct  3 07:55:18.293] esp_wifi.c:344          WiFi AP IP: 192.168.4.1/255.255.255.0 gw 192.168.4.1, DHCP range 192.168.4.2 - 192.168.4.100
[Oct  3 07:55:18.302] mgos_init.c:36          Init done, RAM: 52728 total, 45468 free, 43544 min free
mos config-get wifi.sta.enable
Using port /dev/cu.usbserial-149220
false
#5

Thank you for the detailed reply. I’m using an ESP32. I got it working although I admit I don’t know how. I tried changing the order of the libraries thinking that perhaps there were dependencies, but that didn’t help. Eventually I restarted mos and then it started to work. Now I’m trying to make it talk to dash.