How to add the device token without the mos tool

Hi!

My name is Arturo from Madrid, Spain :slight_smile:

I checked the documentation and GitHub to see if I could find any examples but I couldn’t find anything about adding the token to the ESP8266 device with Mongoose OS to link it to mDash.
I explain the steps:

  • The user plugs in the ESP8266 by usb
  • Select your wifi from your phone and open a landing. Connects it to the Internet.
  • At this point from a request from the app created by me the user can create the device in mDash and receives the token in the response. But now how can I send it to the real device?
    I see this point something is blocking or I don’t raise it well.
    Any advice?

Thank you very much!

Regards, Arturo.

Run mos config-set dash.enable=true dash.token=DEVICE_TOKEN.

Thanks nliviu!

But as I say I can’t use the mos tools because this is for a non-technical user.

regards, Arturo.

AFAIK, that’s the only way.
Or you can configure it before sending the device to the user.

Okay, I figured that when I didn’t find anything.

Thanks nliviu!

Regards, Arturo.

Unconfigured device creates a WiFi access point.

Your phone app should join that AP and send a HTTP request to 192.168.4.1 to configure a device. See https://github.com/mongoose-os-libs/wifi-setup-web-ui/blob/master/fs/index.html for an example.

Thanks Ism.

For wifi I have it covered but to create a device in mDash, receive a token in response and assign it automatically I have not seen how to do it.
I understand that I could modify wifi-setup-web-ui or create a similar one for this…

Thank you!

Both wifi settings and dash token settings can be changed via the same API - see example.

Thank you very much Ism :slight_smile:

Hi I implemeted this API and is working well to connect to wifi, but what to do if the costumer entered a wrong wifi network or password. Can we reset this to default settings to get the wifi 192.168.4.1 back to work?

Your device should have some sort of “factory reset” button, that clears off all settings.

Hi,

I found this on the website to clear the wifi settings:

“provision”: {
“btn”: {
“pin”: 0,
“pull_up”: true,
“hold_ms”: 0,
“inhibit_after_s”: 0
},
“led”: {
“pin”: -1,
“active_high”: true
},
“stable_state”: 3,
“timeout”: 300,
“max_state”: 3

After connecting pin0 to ground the following error is displayed:

Update result: NOT_FOUND: UpdateFromManifest : failed to read /data/ccm_manifest.json

When changing this setting to another pin and hold_ms to a value >0 then the board is resetting to factory settings: For example:
“pin”: 15,
“pull_up”: true,
“hold_ms”: 300,

message in console: mgos_provision_btn.c:90 Factory reset button: pin 15, pull up, hold_ms 300 (long press)

However after this reset the reset pin goes back to zero (0) ( “pin”: 0) and you can not reset the board a second time because of the error “Update result: NOT_FOUND: UpdateFromManifest : failed to read /data/ccm_manifest.json”

Those settings you don’t want to be reset, store in conf5.json