Skip to content

FirmwareWebsite

brian-r-calder edited this page Aug 24, 2026 · 7 revisions

Logger Firmware Management Website

Introduction

The logger's firmware provides (if enabled) a web server implementation that is used to provide a command API using the command set also provided on the serial interface. So that the logger's management can be conducted without any specialist software, the web server also provides a website that uses a combination of HTML, CSS, and JavaScript to provide a graphical interface for the core facilities of the logger (configuration, status, and data transfer) along with a general command interface that allows the user to send any valid command to the logger.

The website is defined in the directory tree rooted at LoggerFirmware/website, with directories for HTML (actions), CSS (css), JavaScript (js), and core assets (images). Due to a limitation of the web server implementation in the current Arduino stack, pages that require multiple loads (e.g., for a linked CSS and/or JavaScript) can fail randomly (specifically, if the server is still writing the output for one request when the second arrives). If you have Google's Closure Compiler (and a Java runtime) installed, you can use the shell script in LoggerFirmware/website/compile_website.sh to automatically minify the JavaScript before embedding it into the HTML document (this has the advantage of also copying over required images). This is the strongly recommended solution, since it leads to much smaller website components, which is very important for resource-limited storage (here, about 1.0MB available in the flash).

Alternatively, the Python script in LoggerFirmware/website/inline_flatten.py can be used to inline all of the resources required for each page, minimise the included files, and then re-write them in the PlatformIO staging directory (LoggerFirmware/data/website) used to make the flash filesystem image that's written to the logger on setup. This script should be executed after each change to the website; see the installation instructions for more information.

The website's default index page provides quick-link buttons for the various actions that can be taken in management of the logger, along with quick status information (versions, uptime, total file size, etc.). This index page, and the sub-pages are described following.

Main Page

The main index page (index.htm) provides shortcuts for the most commonly used functionality, and then core status information on versions, uptime, total file space being used, etc.

Firmware website index page

The status information is generated dynamically by the JavaScript for the page (js/status.js) based on sending a status command to the logger and interpreting the resulting JSON. Note that like all of the other command-sending code in the website, there is a 0.5s delay (js/common.js, using after(delay, callable)) between the page loading and the command being sent. This allows the webserver to complete the page (and potentially a load for the icon) before the command is sent, avoiding overlaps in requests which have the potential to fail in the current implementation of the Arduino webserver.

Configuration

The configuration page provides access to all of the key parameters associated with the real-time running of the logger (e.g., WiFi parameters, unique identifier, ship name, etc.)

Firmware website configuration page

The parameters shown are those returned by a setup command sent to the logger, and therefore reflect the current configuration. Command buttons at the bottom of the screen provide the means to load a JSON configuration from local storage, and to write the configuration on screen to the logger either as the running configuration ("Set Working Config") or as the "lab default" configuration ("Set Default Config") that can be used as backup if the current configuration fails for some reason. The "Download Working Config" and "Download Default Config" buttons can be used to snapshot the current configurations, and automatically download them to the browser's download cache directory (in JSON format). Details of the configuration parameters and process can be found here.

Firmware website configuration page

Status and Data Transfer

The logger maintains a real-time update of the current status, including the elapsed runtime (in milliseconds), the file information for the current log files that have been completed (the currently open file is not reflected), and the versions of the various components of the logger. The file ID numbers shown in the last table are hyper-links to the log files; clicking on the link will cause the file to be downloaded to the browser's download cache directory.

The buttons across the centre of the window allow:

  • Refresh Statistics: Send another status message to the logger and update results shown on the page.
  • Download Catalog: Generate a catalogue of all of the files on the logger, their length, checksums, size, and the URL at which to find them, in JSON format, and then trigger a download to local storage (controlled by the browser).
  • Download All Log Files: This triggers the re-generation of all of the configuration and catalogue information (using the snapshot archive command) and then triggers a download of a Tar/GZip archive of all of the log files and auxiliary information. This allows the user to download all of the log files in one step, as one file (and gains perhaps 3:1 compression), making it easier to manage files. Note, however, that the system does not remove the files from the logger (e.g., using erase all in the command interface), since there is no guarantee that the files were successfully transferred.

Firmware website status information

When the system is observing data on NMEA0183 and NMEA2000 interfaces, information on the critical data sentences on each interface, including what was observed and how long ago is shown in the "Latest NMEAxxxx Data" tables. This is current at the time the page is generated (i.e., when the automatic status command is sent to the logger), but can be updated manually using the button in the middle of the page. (Note, in the example here, the data is being generated by the hardware data simulator and therefore is at an odd time, and inconsistent between NMEA0183 and NMEA2000.)

Metadata Management

In addition to the basic metadata on the logger (unique identifier string and ship name), the logger can also store arbitrary JSON-format metadata that will be included in the header of every log file generated by the system. In post-processing, this information is merged into the converted GeoJSON format file, and therefore can provide all of the IHO B.12 metadata for the host ship. Note that the logger does not mandate any particular format for the file provided, but stores and reproduces whatever the user provides. This might result in bad metadata being generated, and the use of the CSBSchema Validator is recommended. This is an automatic part of the cloud processing. As of firmware 1.5.5, in order to support interaction with the OpenVBI Project, there is an expectation in later processing that the metadata meets the full requirements of the B.12 recommendations, so previous versions with only partial metadata might not work well with later releases of the software.

Firmware website metadata management

Algorithm Requests

In order to allow each logger to maintain information on specific processing steps that might be required for its data, each logger can store a list of algorithm names and parameters that should ideally be applied in post-processing. The logger does not check the validity of the algorithms or their parameters, storing only what the user provides. These values are stored in each log file when it is created.

Firmware website algorithm requests

The list of algorithms shown is updated live from the logger using the algorithm command; when changes are made, the logger responds with the current list of algorithms. Note that it is not possible to remove individual algorithms from the list; the "clear list" button removes all algorithm requests.

NMEA Filtering

NEMA0183

By default, the WIBL logger will store every NMEA0183 sentence provided to it on both channels. On a busy network, however, this can result in a lot of information being saved to the limited resources of the SD card. The logger can, therefore, limit the list of sentences being recorded to those specified by the user. This page provides an interface to this functionality.

Firmware website NMEA0183 filtering

The list of sentence identifiers is updated live from the logger using the accept command; when changes are made, the logger responds with the current list of sentence identifiers. Note that it is not possible to remove individual sentence identifiers from the list; the "clear list" button removes all identifiers. More than one sentence identifier can be specified in the input box if required.

NMEA2000

By default, the WIBL logger stores a subset of packets transmitted on the NMEA2000 interface, including the core set of Depth, SystemTime, and GNSS, and some auxiliary information such as temperature, humidity, pressure, COG, etc. These packets are parsed by the logger and converted into separate packets in the binary output file.

However, for certain applications it might be useful to record auxiliary information (e.g., wind speed and direction, heading, speed through water, etc.) that can be parsed and processed in post (rather than having to have a separate parsed packet in the output file for each PGN being recorded).

The interface therefore allows the user to specify a space-separated list of PGNs to preserve into the output in binary format, with the option to record all, or none.

General Command Interface

Any text entered into the "Command" input is passed to the logger as if it had been typed on the serial console connection; any output from the logger is displayed in the "Output" widget. The logger always provides output in JSON format over the WiFi interface, although the contents of the JSON can change depending on the command. On error, or if there is no formal JSON format for the output, a general JSON scructure with a "messages" array is provided.

Firmware website command interface

Upload Authentication Management

In order to allow for authentication and/or handshaking with an upload server (e.g., when the logger is attached to an Internet-connected network in Station mode and can auto-upload its files), the logger can store an arbitrary ASCII string in the logger, which is used as the password for HTTPS BasicAuth authentication (the logger's UUID is used as username). The authentication page allows the user to specify the plain text token to store. Note that the logger does not attempt to validate the contents of the string (and neither does the website); it is simply stored on the logger.

The logger also uses TLS to secure the connection to the upload server, and therefore needs to store the Certificate Authority (CA) certificate for the CA that signed the server's certificate. This can be uploaded from a simple ASCII file (typically a base-64 encoded version of the certificate in X.509 format). Details of how to generate a self-sign certificate can be found in the upload server description. Depending on the browser, you may have to rename the certificate to a .txt ending for it to be selectable in the file browser.

The state of the currently stored token and certificate can be determined by the auth command.

Firmware website upload authorisation information

Reboot

The "Reboot" page's button executes the restart command, rebooting the logger. Note that this will cut off the WiFi network that your development computer is attached to, and therefore you may need to rejoin the network once the logger has completed rebooting, depending on the settings of your system.

Firmware website reboot

Web Server Implementation

The standard web server for the Arduino stack has a number of limitations, in particular that it appears to only reliably handle a single request at a time. Another major difficulty is that it does not directly provide for streaming output, for example when sending all of the log files as a Tar/GZip file.

The implementation in WiFiAdapater.cpp therefore provides a ExtendedWebServer class with a StreamArchive() method to allow for this. The baseline WebServer has protected methods that generate the headers required for an HTTP response, and a link to the current client so that they can be written back; the extended method uses these to indicate that the data being returned is binary (MIME type application/tar+gzip) and to provide a recommended name for the download (header Content-Disposition: attachment; filename="UUID.tgz", where the module's UUID is used, if set). The ESP32WiFiAdapter class attaches endpoint http://wibl.local/archive to this method, but otherwise uses pass-through for the methods of the web server to implement the service.

A second issue is that the ESP32-targz library used to implement the archiving functionality has methods to stream the output (to anything that implements the Arduino Stream interface, which the WiFi client does), but since we're also compressing the output it's not known, when the headers are being sent at the start of the response, what the content length is going to be. Consequently, the only way to reliably send the data is to use "chunked" mode (assuming that the browser can manage at least HTTP/1.1, which should be more or less universal now). Unfortunately, however, this means that you have to format the chunks appropriately, which the library doesn't know how to do.

In order to make this work, the WiFiAdapter.cpp code provides a shim class, ChunkedStream, which provides enough of the Stream interface to be instantiated, and over-rides the write(const uint8_t *buf, size_t size) method to call the WebServer's sendContent() method, which knows how to format the chunks to manage the interface. It's a little clunky (the web server calls the library that calls the output stream, that calls the web server again ...), but short of modifying the support library to include the HTTP/1.1 chunking interface, it's a relatively clean way to implement the output required with static type safety.

Finally, note that there is a significant quirk in the implementation of the WebServer::_prepareHeader() method where the content length is not known. For reasons that are unclear, the content length provided is only used if another value has not been set using the public WebServer::setContentLength() method, rather than something more logical like using the length if it's provided and isn't some "unknown" value (CONTENT_LENGTH_NOT_SET for example). Therefore, even though the content length is not know when we're streaming the output (because of the GZip compression), we still need to call WebServer::setContentLength(CONTENT_LENGTH_UNKNOWN) prior to generating headers!

Clone this wiki locally