signalk-espos-manager
A Signal K plugin for the ESP32 devices on your boat. It finds them, keeps
their firmware up to date over the air, and puts firmware on a new board from
the browser.
The devices run firmware built on espOS,
a firmware base for ESP32 boards that talk to Signal K. The firmware you can
install comes from the signalk-espOS registry:
a touch-screen instrument panel, an NMEA 2000 gateway, a Bluetooth gateway,
relay switching, and whatever other developers add.
What it does
- Finds your devices. Browses
_espos._tcp on the local network and lists
every espOS device with its project, firmware version, chip and board.
Devices on another VLAN can be added by address.
- Mirrors firmware on the server. Downloads signed images while you have
internet and serves them locally, so an update works at anchor with no
connection at all.
- Updates devices. One at a time by default, watching progress and
confirming the new image only once the device comes back healthy. An image
that is never confirmed is rolled back by the device's own timer.
- A store of projects. Firmware projects (the P4 cockpit, the BLE gateway,
and anything other developers publish) with changelogs and per-board
compatibility.
- Flashes a new board over USB from the browser, for a board that has never
been on your network.
- Tells panels when it is night. Publishes
environment.mode (day or
night) from the boat's position, so a touch panel dims only at night. See
Day and night.
Requirements
- Signal K server 2.x on Node 24 or newer.
- espOS devices reachable on the local network.
Install
From the Signal K Appstore, or in the server's data directory:
npm install signalk-espos-manager
Then restart the server. The plugin enables itself on first start with the
default settings; you can still turn it off under Plugin Config.
Using it
The plugin adds an espOS Manager webapp to the Signal K server, with three
pages: Devices, Firmware and New board.
Devices names each board the way the flasher does: the product from the
registry's board catalogue, with its photo once the catalogue has one, and the
jobs its firmware does there, such as "Show instruments on a touch screen". A
device whose firmware does not report its board, or whose image runs on
several boards, is shown by its chip instead, since a wrong product name is
worse than none.
Installing firmware on a new board
For a board that has never been on your network.
- Plug the board into the computer running the browser by USB, open
New board and choose Open the flasher.
- Pick what the board should do, or the board you have. The flasher
connects to the board, reads its chip and flash size, and checks the image
fits before anything is written.
- Write it and wait for the progress bar to finish.
- Unplug the board and plug it back in. It is reset after writing, but a
full power cycle is what reliably starts the new firmware.
- Join the open WiFi network named
espOS- followed by four characters and
enter your boat's network at http://192.168.4.1/.
- Once it joins, it appears on the Devices page.
New board opens the flasher this plugin serves. Browsers only allow USB
access from a secure page, so when your server is on plain http it sends you
to the
hosted flasher
instead, which is the same page. New board also offers each image as a
download for writing with esptool.
The flasher starts by asking what the board should do: show
instruments on a touch screen, bring Bluetooth sensors into Signal K, switch
loads, or connect an NMEA 2000 network. Each job lists the boards that do it,
best first, as the registry ranks them, and each board leads to its firmware
and where to buy it. Someone who already has a board picks I already have
a board and finds it in the list, or plugs it in to filter by chip. The jobs
and boards come from the registry's usecases/ and boards/ catalogue.
Plugging a board in also reads, without changing anything, the USB chip it
connects through and the name and version of the firmware already on it. When
that points at one catalogue board (the maker's demo it shipped with, or an
espOS project made only for that board), the page says "This looks like…" and
lists that board first. A shared USB chip on its own is only a hint, because
one vendor puts the same chip on many boards.
Updating a device
- Open the device from Devices. Its Firmware updates card shows the
newest release for its project and board, with the release notes, and when
the firmware list was last checked. Check now reads it again; it is
also checked every hour.
- Choose Install update. The card follows the update as it downloads,
installs, restarts and is confirmed.
- Once the device comes back and reports the new version, the plugin waits
until it has looked healthy for a while (two minutes by default) and then
confirms the new image. If nothing confirms it, the device rolls back to
the previous firmware on its own.
A device running a build that is not a released version shows Install
anyway, since the release may be older than what it runs. A device that is
not pointed at this server for updates shows Not set up for updates with
a Fix this button. Updates run one device at a time unless you raise
Simultaneous updates in Plugin Config; the same place sets the update
channel, beta releases and the confirm timing. Advanced on the device page
can confirm or roll back the current image by hand.
A P4 board's radio co-processor (the chip that handles WiFi and Bluetooth)
runs firmware of its own. When it is older than the device's firmware expects,
the device page says so. Updating it from the manager needs device firmware
that supports it; until then the card says what to install first. While a
radio update runs, a firmware update waits for it to finish.
How updates reach a device
A device fetches its update manifest from the Signal K server it is already
connected to (ota.manifest_src = signalk), from this plugin's public webapp
path. It can't use /plugins/..., because that needs an administrator login
and a device has none. The plugin points each device at the right path for you.
Firmware images are signed. A device only accepts an image signed with the key
it was originally flashed with, so switching a device from one project to
another is a USB operation, not an over-the-air one. The plugin says so rather
than offering an update that would be refused after the download.
Two different keys
- The signing key belongs to whoever publishes a firmware project. They
sign each release with it, and a device only installs updates signed with
the key it was flashed with. Lose it and every device needs a USB reflash.
The registry only records its fingerprint (
signingKeyId). When both the
registry and the device report a fingerprint, the plugin can tell an update
the device would refuse; it never signs or checks firmware itself. A
developer's own build signs with a key generated in
their checkout, which only their own devices accept.
- The fleet API key (
auth.fleetKey) is the password this plugin uses
to talk to your devices' web API (httpd.api_key on the device). It has
nothing to do with firmware. Changing it only means telling the plugin and
the devices the new one. It is optional: with no key on your devices
there is nothing to enter. The Devices page can generate a key, set your
own, replace it or remove it. Replacing it writes the new key to every
online device that used the old one; a device that is offline keeps the
old key, which the plugin remembers for it, and gets the new one once it
answers again. Removing it never
opens a device: each one that used it keeps it as its own key.
Other plugins on the same server use these keys without seeing them. The
HMI designer, for one, sends its requests to a panel through the manager,
which adds the device's key, so a panel with a key needs nothing entered in
the designer. For plugin authors: while the manager runs,
globalThis.__signalk_esposManager.request(url, init) sends url to the
espOS device it names, by address or hostname, with that device's key, and
resolves to the fetch() Response, or to undefined for a host that is no
espOS device the manager knows (EsposDeviceBroker in src/broker/). A key
the device answered 401 to is not sent again until the manager's own probe
sees the device accept it or a different key is set, no key is sent while
the device throttles attempts (a 429 naming too_many_attempts), and the
broker sends a key that probe has not seen accepted yet with one of its
requests at a time. That probe keeps its own schedule, so it can try the
same key alongside. A device without a key gets none, and its requests do
not wait for each other.
Day and night
espOS touch panels dim their backlight only at night, and learn that from
environment.mode. The plugin works it out every minute from
navigation.position with Almanac
(@openwaters/almanac),
which computes the Sun's position offline. It is day while any part of the
Sun is above the horizon, from sunrise to sunset, and night otherwise, which
also covers the midnight sun and the polar night. Until the server has a
position nothing is published, and the panels stay bright. The mode is
published only when it changes, so a day/night switch made by hand, such as
App Dock's button, holds until the next sunrise or sunset. A restart of the
plugin or the server works the mode out afresh and publishes it once there is a
position, which ends a manual switch as soon as the server takes it. When a source priority ranks another publisher of environment.mode first, the
server drops the plugin's change while that source is within its fallback
timeout; the plugin sends it again every minute until the server takes it, or
until a newer value arrives from elsewhere.
signalk-derived-data is not needed for this. If it is installed with its Sun
calculation on, it publishes environment.mode too, switching to night a few
minutes earlier at sunset; turn off Publish day and night under Plugin
Config to leave it to derived-data.
Privacy and network use
The plugin talks to devices on your own network and fetches the project
registry and firmware from GitHub over HTTPS. Nothing about your boat is sent
anywhere. With the mirror enabled, devices never contact the internet at all.
Board photos are loaded by your browser from wherever the registry's catalogue
points, and simply do not appear without internet.
Demo mode
The demo setting is for a public showcase server. The manager then shows
three virtual devices (a P4 cockpit, a BLE gateway and a Zigbee coordinator)
instead of the boat's own, contacts no device and downloads no firmware. Their
versions follow the stable releases in the registry, and the BLE gateway runs
the one before the newest, so it shows an update whenever the registry lists
two.
Everything that would change something is disabled in the web app, and the
server refuses it with 403, so visitors with read-only access can look around
safely. The arrow next to a device opens espOS's demo build of the device web
UI, which runs against an in-browser mock, when the build includes it (pinned
under espos.uiDemo in package.json); otherwise it opens a placeholder page.
Licence
Apache-2.0. See LICENSE.