Device Management via IoT or Embedded Web Server?

IoT and Embedded Web Server technologies both have their plusses and minuses. In this hands on article, we will show how it is possible to re-use the device management application for both solutions. You may compile the code we present below and connect to the IoT testing server we have setup.

Increase your customer's confidence in your product by providing a dual IoT solution that assures your product never ends up as explained in the EE Journal article RIP, Cloud-Connected Devices.

Why use an Embedded Web Server ?

Embedded Web Servers have been used for device management long before IoT was coined, and it is still very popular due to its simplicity. Just take your home router as an example, which provides a web interface for all the router settings.

The benefit with using an Embedded Web Server is that it does not rely on any third party products that may fail, thus making it more reliable and always available on the local network where the device is deployed.

The negative with an Embedded Web Server powered device is that it is not easy to control the device outside of the local network where the device is deployed. Technically challenging solutions such as setting up a pinhole (port forwarding) in the router is possible, but it is not an ideal solution.

Why use IoT?

IoT has many benefits such as being able to manage and supervise multiple devices in multiple locations. With IoT, the devices typically act as a network client and connect to an online IoT cloud server. A user does not directly control a device, but must first navigate to the cloud solution for getting access to the device(s).

The negative with an IoT solution is for devices that are more often controlled from the network where they are deployed. The IoT round-trip slows down communication, making some real time applications too slow. Should the IoT cloud server or its network infrastructure go down, the devices become impossible to control.

Combining IoT and Embedded Web Server

Reaping the benefits of both solutions and eliminating the negatives is to design a device that can both provide a local web interface via an embedded web server and be controlled via an IoT cloud server. However, doing so has traditionally incurred extra complexity and development time.

Is it possible to provide both solutions and re-use the device management application for both solutions?

Yes it is possible, but doing so requires re-thinking the traditional way of designing web based device management applications. Instead of using the standard HTTP GET/POST for performing the actual commands, a persistent WebSocket connection is used. For this to work, the HTML application must be designed as what is known as a Single Page Application (SPA).

See the end of this article for how to provide a similar solution for standard HTTP servers.

Proof of Concept

To show that it is indeed possible to re-use an SPA for both local management directly via an embedded web server and remotely via IoT, we created an online testing server you may use. The testing server is available at the following URL:

IoT Testing Server:

The simulated device code can be downloaded to your computer and compiled as follows:

git clone git clone git clone cd MinnowServer/example/make make packwww minnow IOT=true ./minnow

The above commands download the Minnow Server (WebSocket server) from GitHub and compile the Minnow Server reference example in IoT mode by the make command IOT=true.

The above commands require that you have git make gcc zip, and curl installed on your host computer. You may install the required tools as follows:

sudo apt-get -y install git make gcc zip curl

If you are using Windows, use the Windows 10 Linux subsystem or use the online C compiler we have setup by navigating to:

Online C compiler and IoT testing server:

When the Minnow Server runs, the server connects to the online IoT server after 3 seconds if the Minnow Server is not controlled locally.

When the Minnow Server runs, use your browser and navigate to http://localhost:#, where # is the port number the server is listening on. You may then control the device using a local connection. The default credentials are user "root" and password "password.

You may also control the device using the online server, but make sure to close the local connection first. After closing the connection, the server will connect to the online IoT server after 3 seconds. You may then click the link presented on the online IoT server. Click this link and login.

See the article Creating Single-Page Apps with the Minnow Server for details on how the reference example works.

The following video, starting at 4:20, shows an ESP8266 microcontroller being controlled via the online IoT server. See the Minnow Server's GitHub documentation for details on installing the software on a microcontroller.

How to Provide External Access to Standard HTTP Servers

What if you do not want to limit your design to WebSockets, but also want to use standard HTTP, including all standard services provided via HTTP? This is possible, but it gets more complicated and is best solved by a product designed specifically for this purpose.

External Access for Standard HTTP Server

The Barracuda App Server includes a reverse HTTP(S) connection bridge designed for a free product called SharkTrustX. The Barracuda App Server, when embedded in a product, runs on the local (LAN) network and SharkTrustX runs as an online connection bridge portal. See SharkTrustX for additional information.

Posted in Whitepapers