teractions take place wirelessly, i.e., OTA using
REST.
In preparation for thing mutation, some work
needs to be completed as per the following 2 steps:
1. First, the engineer installs from scratch (and so-
metimes customizes
5
), using certain tools such as
ESPlorer
6
for uploading scripts and esptool.py
7
for flashing firmware, some required software on
devices (1.1). This software includes a firm-
ware (NodeMCU
8
in our testbed) and a standalone
script interpreter (Lua
9
in our testbed). On the
one hand, NodeMCU firmware supports commu-
nication protocols (e.g., MQTT (Message Queuing
Telemetry Transport), HTTP (Hyper Text Trans-
fer Protocol), and COAP (Constrained Applica-
tion Protocol)) with third parties and includes
some built-in functions (e.g., file management,
GPIO (General Purpose Input/Output) usage, and
SJSON (Simplified JSON parser)). The engineer
selects the appropriate modules (e.g., MQTT) for
implementing the mutation scripts when building
the firmware. On the other hand, Lua script in-
terpreter is used for synchronizing devices with
the controller prior to hot-plugging
10
(Baker et al.,
2013) scripts, and interprets the new scripts after
being fully downloaded to the things. More de-
tails on NodeMCU firmware’s modules are availa-
ble at nodemcu-build.com..
2. Second, the engineer configures each device (1.2)
separately so, that, it communicates with the con-
trol application. After uploading the necessary
software onto the device as per the previous step,
the device is rebooted in the HTTP server mode
and proceeds with broadcasting its WiFi access
point. When the engineer connects to the same
access point, she accesses the device’s configura-
tion panel so, that, necessary parameters are set-
up such as wireless network name/password, pa-
nel access details (e.g., server IP, domain name,
and script path), and synchronization time. Upon
completing the configuration, the device restarts
and synchronizes with the controller checking if
5
In the case of customization, the engineer must flash
the device with fresh firmware containing the desired mo-
dules that are downloaded from NodeMCU cloud build tool.
6
esp8266.ru/esplorer.
7
nodemcu.readthedocs.io/en/master/en/flash.
8
github.com/nodemcu/nodemcu-firmware.
9
NodeMCU firmware is based on Lua. But, other opti-
ons, such as PJON (github.com/gioblu/PJON.) and Modu-
leInterface (github.com/fredilarsen/ModuleInterface.), are
available subject to the used firmware.
10
Hot-plugging means download, interpret, and re-
boot (MicroTCA and Specification, ).
it is subject to any mutation specified by the engi-
neer (using a flag).
4.2 Testbed Operation
The mutation control application is a Web application,
hosted on a Linux Apache server, developed in PHP,
JavaScript, HTML, and CSS, and uses MySQL data-
base. The application allows the engineer to add/drop
devices to/from the testbed whenever necessary using
add/delete buttons, describe existing and/or new devi-
ces (i.e., adding a new name, narration/commentary,
and chipID, which acts as an identifier) using the edit
button, and to develop scripts (2.1) that will be linked
to devices.
To run the testbed, the engineer registers the devi-
ces (2.2) in the thing repository using the dashboard
and proceeds with developing the necessary scripts in
Lua. The devices that exemplify things in our testbed
are equipped with an ESP8266 chip and have at le-
ast 4MB flash. This minimum flash requirement gua-
rantees 1MB space for the NodeMCU firmware. The
remaining space permits to store the interpreted mu-
tation scripts that are available for execution.
The tested devices include WemosD1, Wem-
osD1 mini, and NodeMCU. These are microcontrollers
equipped with wireless modules for communicating
with third parties like sensors and computers utilizing
protocols included in their firmwares. The engineer
also manages (2.2) the devices that will be subject to
mutation in compliance with the outer-control muta-
tion decision. In term of managing devices (2.2), the
engineer could consider different devices for mutation
and different mutation scripts, as she sees fit. After-
wards, the devices periodically send requests to the
controller to check whether there is some update. As a
result of these periodic requests, the controller screens
the thing repository to verify whether the device is lis-
ted/known and its corresponding mutation flag (true/-
false) is raised. If this is the case, the controller looks
for the corresponding script in the mutation-code re-
pository so the appropriate script is sent to the device.
This one hot-plugs the script after uploading 4 files:
init.lua (a file loaded every time the device boots it-
self and makes a decision should it boot in HTTP ser-
ver mode (via server.lua) or with mutation script (via
client.lua)), server.lua (for starting up the HTTP ser-
ver when the device is booted for first time), client.lua
(for synchronization with the control application and
interpreting new scripts), and config.htm (html con-
figuration form for storing parameters, where these
parameters are stored in a separate file hosted by the
device).
To further elaborate the mutation procedure, Al-