WiFi setup via Web UI

This Mongoose OS app shows how to start a device in Access Point mode (AP) and configure Station mode via simple Web UI.

This page communicates with the device via Mongoose OS RPC mechanism using HTTP/RESTful as a transport protocol. A small JavaScript library, zepto, is used as a drop-in replacement for jQuery, for making AJAX calls to the device.

Open fs/index.html, or right-click on this page and choose "view source".

First, this web page makes a call to the http://DEVICE_IP/rpc/Config.Get RESTful endpoint, which triggers Config.Get RPC service and returns a large JSON object (click here to see) with full device configuration. From that object, we take WiFi SSID and password, and stick them into the text inputs.

Second, we install a button click handler, which grabs values from the text inputs, creates a JSON string with the device configuration subtree that Config.Set RPC call expects, and calls a /rpc/Config.Set endpoint.

Similarly, you can call any other RPC service that device has. Call RPC.List to get a list of all RPC services available.