Wifi configuration failed

#1
  1. My goal is: Configure wifi for my device successfully

  2. My actions are:
    just following the “Mongoose OS quick start guide”,when I try to connect to wifi,
    I found that it unable to synchronise time with SNTP server.

  3. The result I see is
    It can connect to the wifi ,but cannot synchronise time with SNTP server.
    In my country, time.google.com is not available.
    as a result , the “wifi status” is “disconnected”.

here is the console:

...
[Jul 18 13:37:04.829] connected with N****01, channel 1
[Jul 18 13:37:04.832] dhcp client start...
[Jul 18 13:37:04.834] mgos_wifi.c:136         WiFi STA: Connected, BSSID 8c:a6:df:05:**:** ch 1 RSSI -62
[Jul 18 13:37:04.843] mgos_net.c:89           WiFi STA: connected
[Jul 18 13:37:05.106] online: false {"ram_free":32264,"uptime":5.245260,"btnCount":0,"on":false} 
[Jul 18 13:37:05.481] ip:192.168.0.100,mask:255.255.255.0,gw:192.168.0.1
[Jul 18 13:37:05.486] mgos_net.c:101          WiFi STA: ready, IP 192.168.0.100, GW 192.168.0.1, DNS 61.***.***.***
[Jul 18 13:37:05.495] mgos_provision_state:43 Current state: 1 -> 2
[Jul 18 13:37:05.499] mgos_provision_state:72 Setting provisioning timeout for 300 seconds
[Jul 18 13:37:06.106] online: false {"ram_free":32196,"uptime":6.245148,"btnCount":0,"on":false}     
[Jul 18 13:37:06.493] mgos_sntp.c:95          SNTP query to time.google.com
[Jul 18 13:37:12.822] mgos_sntp.c:95          SNTP query to time.google.com
[Jul 18 13:37:37.321] mgos_sntp.c:95          SNTP query to time.google.com
[Jul 18 13:38:36.010] mgos_sntp.c:95          SNTP query to time.google.com
...
[Jul 18 13:40:26.577] mgos_provision_state:53 Provisioning timeout, resetting device

my platform is esp8266

Is there any solution?

#2

The provision library resets the configuration.
You have 2 options. Either set

- ["provision.stable_state", 0]

in mos.yml config_schema: section and build + flash, or run
mos config-set provision.stable_state=0

There is no problem if time.google.com is not available. The time will not be synchronized.
There must be a time server for your country. When you know its “name”, you can add it in your mos.yml

#SNTP
 - ["sntp.server", "pool.ntp.org"]
#3

thanks a lot!It works! It can synchronise time with SNTP server now.
But the problem is still exist.
The status of wifi is always “connecting”

$ mos wifi NCC-1701 1******(there's my wifi ssid and passwd)
Getting configuration...
Setting new configuration...
Command completed.
[Jul 18 17:14:28.050] mgos_wifi.c:88          WiFi STA: Using config 0 (NCC-1701)
[Jul 18 17:14:28.055] mgos_wifi.c:468         WiFi mode: STA
[Jul 18 17:14:28.059] esp_wifi.c:106          WiFi mode: STA
[Jul 18 17:14:28.063] mode : sta(b4:e6:2d:70:43:63)
[Jul 18 17:14:28.065] add if0
[Jul 18 17:14:28.066] sleep disable
[Jul 18 17:14:28.067] WPA2 ENTERPRISE VERSION: [v2.0] disable
[Jul 18 17:14:28.071] mgos_wifi.c:270         WiFi STA: Connecting to NCC-1701
[Jul 18 17:14:28.077] mgos_http_server.c:282  HTTP server started on [80]
[Jul 18 17:14:28.085] mgos_provision_btn.c:75 Factory reset button: pin 0, pull up, hold_ms 0 (hold on boot)
[Jul 18 17:14:28.104] mgos_provision_stat:119 Max state: 2
[Jul 18 17:14:28.108] mgos_rpc_channel_mq:203 0x3fff0edc esp8266_704363/rpc
[Jul 18 17:14:28.116] mgos_rpc_channel_ua:313 0x3fff17bc UART0
[Jul 18 17:14:28.121] mgos_init.c:36          Init done, RAM: 51424 total, 41504 free, 41512 min free
[Jul 18 17:14:28.899] LED on -> false 
[Jul 18 17:14:28.984] mgos_mongoose.c:66      New heap free LWM: 27048
[Jul 18 17:14:28.990] mgos_ota_core.c:1308    UID: 036b725a80749b0b, license: none
[Jul 18 17:14:28.997] mgos_net.c:85           WiFi STA: connecting
[Jul 18 17:14:29.001] mgos_provision_state:43 Current state: 0 -> 1
[Jul 18 17:14:29.927] online: false {"ram_free":32732,"uptime":2.246798,"btnCount":0,"on":false} 
[Jul 18 17:14:30.926] online: false {"ram_free":32708,"uptime":3.246507,"btnCount":0,"on":false} 
[Jul 18 17:14:28.050] mgos_wifi.c:88          WiFi STA: Using config 0 (NCC-1701)
[Jul 18 17:14:28.055] mgos_wifi.c:468         WiFi mode: STA
[Jul 18 17:14:28.059] esp_wifi.c:106          WiFi mode: STA
[Jul 18 17:14:28.063] mode : sta(b4:e6:2d:70:43:63)
[Jul 18 17:14:28.065] add if0
[Jul 18 17:14:28.066] sleep disable
[Jul 18 17:14:28.067] WPA2 ENTERPRISE VERSION: [v2.0] disable
[Jul 18 17:14:28.071] mgos_wifi.c:270         WiFi STA: Connecting to NCC-1701
[Jul 18 17:14:28.077] mgos_http_server.c:282  HTTP server started on [80]
[Jul 18 17:14:28.085] mgos_provision_btn.c:75 Factory reset button: pin 0, pull up, hold_ms 0 (hold on boot)
[Jul 18 17:14:28.104] mgos_provision_stat:119 Max state: 2
[Jul 18 17:14:28.108] mgos_rpc_channel_mq:203 0x3fff0edc esp8266_704363/rpc
[Jul 18 17:14:28.116] mgos_rpc_channel_ua:313 0x3fff17bc UART0
[Jul 18 17:14:28.121] mgos_init.c:36          Init done, RAM: 51424 total, 41504 free, 41512 min free
[Jul 18 17:14:28.899] LED on -> false 
[Jul 18 17:14:28.984] mgos_mongoose.c:66      New heap free LWM: 27048
[Jul 18 17:14:28.990] mgos_ota_core.c:1308    UID: 036b725a80749b0b, license: none

[Jul 18 17:14:28.997] mgos_net.c:85           WiFi STA: connecting
[Jul 18 17:14:29.001] mgos_provision_state:43 Current state: 0 -> 1

[Jul 18 17:14:29.927] online: false {"ram_free":32732,"uptime":2.246798,"btnCount":0,"on":false} 
[Jul 18 17:14:30.926] online: false {"ram_free":32708,"uptime":3.246507,"btnCount":0,"on":false} 
[Jul 18 17:14:31.719] scandone
[Jul 18 17:14:32.601] state: 0 -> 2 (b0)
[Jul 18 17:14:32.624] online: false {"ram_free":32708,"uptime":4.944147,"btnCount":0,"on":false} 
[Jul 18 17:14:32.635] state: 2 -> 3 (0)
[Jul 18 17:14:32.640] state: 3 -> 5 (10)
[Jul 18 17:14:32.642] add 0
[Jul 18 17:14:32.642] aid 2
[Jul 18 17:14:32.643] cnt 
[Jul 18 17:14:32.651] 
[Jul 18 17:14:32.652] connected with NCC-1701, channel 1
[Jul 18 17:14:32.655] dhcp client start...


[Jul 18 17:14:32.656] mgos_wifi.c:136         WiFi STA: Connected, BSSID 8c:a6:df:05:a7:b0 ch 1 RSSI -49
[Jul 18 17:14:32.666] mgos_net.c:89           WiFi STA: connected


[Jul 18 17:14:32.927] online: false {"ram_free":32264,"uptime":5.246633,"btnCount":0,"on":false} 
[Jul 18 17:14:33.402] ip:192.168.0.100,mask:255.255.255.0,gw:192.168.0.1
[Jul 18 17:14:33.407] mgos_net.c:101          WiFi STA: ready, IP 192.168.0.100, GW 192.168.0.1, DNS 61.128.114.134
[Jul 18 17:14:33.417] mgos_provision_state:43 Current state: 1 -> 2
[Jul 18 17:14:33.927] online: false {"ram_free":32240,"uptime":6.246549,"btnCount":0,"on":false} 
[Jul 18 17:14:34.334] mgos_sntp.c:95          SNTP query to 1.cn.pool.ntp.org
[Jul 18 17:14:34.641] mgos_sntp.c:59          SNTP reply from 193.228.143.23: time 1563441275.468822, local 6.975318, delta 1563441268.493504
[Jul 18 17:14:34.927] online: false {"ram_free":31984,"uptime":7.246646,"btnCount":0,"on":false} 
[Jul 18 17:14:35.927] online: false {"ram_free":31984,"uptime":8.246459,"btnCount":0,"on":false} 
[Jul 18 17:14:36.926] online: false {"ram_free":31984,"uptime":9.246394,"btnCount":0,"on":false} 
[Jul 18 17:14:37.927] online: false {"ram_free":31984,"uptime":10.246379,"btnCount":0,"on":false} 
[Jul 18 17:14:38.926] online: false {"ram_free":31984,"uptime":11.246420,"btnCount":0,"on":false} 
[Jul 18 17:14:39.926] online: false {"ram_free":31984,"uptime":12.246404,"btnCount":0,"on":false} 
[Jul 18 17:14:40.926] online: false {"ram_free":31984,"uptime":13.246417,"btnCount":0,"on":false} 
[Jul 18 17:14:41.926] online: false {"ram_free":31984,"uptime":14.246375,"btnCount":0,"on":false} 
[Jul 18 17:14:42.641] pm open,type:0 0
[Jul 18 17:14:42.927] online: false {"ram_free":31480,"uptime":15.246446,"btnCount":0,"on":false} 

isnt it connected?
The manager of my wifi router shows that it is connected
but than:

$ mos call Sys.GetInfo
{
  "app": "app2",
  "fw_version": "1.0",
  "fw_id": "20190718-084152",
  "mg_version": "2.14.0",
  "mg_id": "20190718-084151/2.14.0-gce86552",
  "mac": "B6E62D704363",
  "arch": "esp8266",
  "uptime": 1,
  "ram_size": 51424,
  "ram_free": 32292,
  "ram_min_free": 27048,
  "fs_size": 233681,
  "fs_free": 102659,
  "wifi": {
    "sta_ip": "",
    "ap_ip": "",
    "status": "connecting",
    "ssid": ""
  }
}
Command completed.

The status of wifi is always “connecting”

#4
"uptime": 1

You called Sys.GetInfo very early after reset. The device didn’t have the time connect to wifi.

#5

Thanks a lot!problem solved!:smile: