Copyright 2023, Moddable Tech, Inc. All rights reserved.
Peter Hoddie
Updated January 9, 2023
Mods are a Moddable SDK feature for adding JavaScript code into a firmware image. For Node-RED MCU Edition mods allow you to install most of the code once and then install your Node-RED flows on top of that. Building and installing the mod is considerably faster, making for much faster development turnaround. Mods are compiled to byte-code on your development computer before being installed.
To learn about Mods in-depth see the Mods documentation.
Node-RED MCU Edition provides a basic mod host. It is built and installed using mcconfig
:
cd $(PATH TO node-red-mcu)
mcconfig -d -m -p esp32 ./mods/host/manifest.json
Use mcrun
to install the flows. If your flows are located at (PATH to node-red-mcu)/flows.json
, do this:
cd $(PATH TO node-red-mcu)
mcrun -d -m -p esp32 ./mods/mod/manifest.json
There are two options for configuring Wi-Fi:
- Pass the ssid and password to
mcconfig
as usual. These will be the default credentials for any mod loaded - Pass the ssid and password to
mcrun
. These will be used in place of the default credentials
mcrun -d -m -p esp32 ssid="my wi-fi" password="secret" ./mods/mod/manifest.json
- It is important to use the correct platform identifier (
esp32
,esp32/moddable_two
, etc) for your target device. If there is a mismatch between the platform used to build the host and to build the mod, the mod may not work. - Not all hosts support mods. If the installed host does not support mods,
mcrun
reports an error. - Installing mods with
mcrun
requires a debug build. Instrumented and Release builds do not support mods in Node-RED MCU Edition at this time. - Using a Host plus Mod requires more flash storage and memory. As a result, Mods are not practical for all projects on all devices. For example, they are not recommended on ESP8266.
- Mods are supported in the
mcsim
simulator on macOS, Windows, and Linux.