- Debugger (Allowed to use API Test UI in the Web UI)
- Secure, Role based Rest API for all functions
- API functions access can be configured either as "Public" or a user role can be assigned to determine access (only users who have the corresponding rolle can call that API).
- User authentication needs to return a token that is needed to be passed into all rest API requests (unless the called API endpoint is public)
- All admin functions (including HTTPS configuration, logs, password changes, ...) are available in the API by default
- All API calls will return a JSON that returns
- Result of the last call (either success or detailed error description)
- If applicable, the result of the call
- There are 3 boilerplate APIs that are available publicly by default
- Control the on-board LED (set brightness; 0-> off; 100->full brightness)
- Ping (that returns the current uptime as JSON)
- Add (takes 2 integers and returns the result of adding those integers)
- Check URL for new firmware button (this will reach out to a configurable (in the code) URL to to try and find new firmware. If new firmware is available it offers to install.)
### Technical details
- The target platform is ESP32-C3 with Arduino Framework
- Memory is to be treated as a sparse resource, so the size of the code must be kept small
- The API layer exclusively uses JSON messages to communicate in both direcitons
- The Web UI is to be implemented as a Vanilla JS single page web site UI that communicates with the backend via the REST API.
- All documentation goes into the README.md file
- The Admin UI is implemented in an extendable way, so that developers can easily use the same mechnism to implement their own UIs
- The "factory reset" function should execute when a definable PIN (choose a good default) is pulled high- or low on boot and held that way for 10 seconds.
- When starting after initial flashing or factory reset, the device needs to act as an unsecured access point with a defined SSID .
- The user can then connect to that AP and is presented with a basic user interface (setup screen) where the user can
- Choose their WIFI
- Enter the password of their WIFI (can be left empty for unsecuried wifi)
- Change the admin useranme (defaults to "admin")
- Enter an Admin password (can be left empty)
- A submit button that submits the entered information
- Once the user entered submitted information, the information is stored in non volatile memory, and the device is restarted.
- On subsequent startups, the device looks for configuraiton stored in non volatile memory
- The factory reset functionality deletes the information from the non volatile memory, which will lead to the setup screen.
- Log levels are `Error`, `Warn`, `SecurityAudit`, `Info`, and `Debug`; `SecurityAudit` records security-relevant events such as login/logout, invalid bearer tokens, authorization failures, unknown API URLs/methods, and security configuration changes.
- Custom role management. System roles are protected and cannot be deleted.
- Active/inactive user accounts with role checkboxes in the Admin UI.
- API security management through a list/detail UI with a role dropdown per API.
- Ring-buffer logging in LittleFS with default maximum size of 50 KiB.
- Firmware and LittleFS filesystem upload OTA and update-from-URL hooks.
- HTTPS certificate storage API. The default Arduino `WebServer` runs HTTP; stored certificate material is available for applications that add TLS termination.
In the PlatformIO UI, use the `Upload Firmware and Filesystem` project task when you want one action to upload both firmware and the LittleFS image that contains the web UI.
Uploading the filesystem image replaces the LittleFS contents, including stored log files. WiFi configuration, users, roles, and settings are stored in NVS preferences and are not part of that filesystem image.
### Provisioning
After initial flashing or factory reset, the device starts an unsecured access point:
```text
TSL-Embedded-XXXXXX
```
Connect to the access point and open:
```text
http://192.168.1.1/
```
While in setup mode, the device also runs a captive-portal DNS responder. Most phones and laptops will automatically open or suggest the setup page after joining the AP; unknown HTTP requests are redirected to `http://192.168.1.1/`.
The setup page lets you choose WiFi, set the WiFi password, set the admin username, and set the admin password. The default admin username is `admin`; the password may be empty. After submit, the device stores the configuration in non-volatile memory and restarts.
The default project name is `TSL-Embedded`. The firmware combines the project name with the chip suffix to form the device name, for example `TSL-Embedded-BDF5F0`. That name is used as the setup AP SSID, the station-mode WiFi hostname, and the mDNS hostname. Override the project name at compile time if needed:
```cpp
#define PROJECT_NAME "MyProject"
```
On normal boot, the device connects to the configured WiFi and serves the Admin UI at the IP printed to serial.
Open `Networking` in the Admin UI to configure the station-mode host name and IP parameters.
The host name field is optional. If it is empty, the firmware uses the generated default host name based on `PROJECT_NAME` and the chip suffix, for example `TSL-Embedded-BDF5F0`. A custom host name must be 1-31 characters and may contain only letters, digits, and hyphens. It cannot start or end with a hyphen.
Address mode defaults to DHCP. To use a static IPv4 address, select `Static IPv4` and provide:
| Field | Required | Example |
| --- | --- | --- |
| Static IP | Yes | `192.168.1.50` |
| Gateway | Yes | `192.168.1.1` |
| Subnet mask | Yes | `255.255.255.0` |
| DNS 1 | No | `192.168.1.1` |
| DNS 2 | No | `8.8.8.8` |
Networking changes are stored immediately, but they apply on the next WiFi reconnect or reboot.
The default reset pin is GPIO4. Hold GPIO4 LOW during boot for 10 seconds to clear stored configuration and logs, then the device restarts into setup mode.
The defaults can be changed at compile time:
```cpp
#define FACTORY_RESET_PIN 4
#define FACTORY_RESET_ACTIVE_LEVEL LOW
```
### Authentication
Login:
```http
POST /api/login
Content-Type: application/json
{"username":"admin","password":""}
```
The response contains a bearer token. Pass it to protected APIs:
The Admin UI stores HTTPS certificate material so applications built on this boilerplate can use it when adding TLS termination. The default Arduino `WebServer` used by this project serves HTTP only; uploading a certificate stores the material in NVS preferences but does not by itself switch the built-in web server to HTTPS.
3. Select a certificate file and click `Save certificate`.
4. Use `Load current` to verify what is currently stored.
The upload file must be a plain text PEM-style file. Use UTF-8 or ASCII text and preserve the PEM block line breaks exactly. The file may use `.pem`, `.cer`, `.crt`, or `.txt`.
Valid content is one or more PEM blocks, for example a certificate chain:
```text
-----BEGIN CERTIFICATE-----
...base64 certificate data...
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
...base64 intermediate certificate data...
-----END CERTIFICATE-----
```
If your TLS integration expects both the certificate and private key from this stored value, put both PEM blocks in the same text file:
```text
-----BEGIN CERTIFICATE-----
...base64 certificate data...
-----END CERTIFICATE-----
-----BEGIN PRIVATE KEY-----
...base64 private key data...
-----END PRIVATE KEY-----
```
Do not upload binary DER, PKCS#12/PFX, or password-protected keystore files directly. Convert those to PEM text first. The equivalent API is:
Because the Admin UI is stored in LittleFS, OTA releases are distributed as one combined update package. The package contains both the LittleFS filesystem image and the firmware image, so UI and firmware changes cannot drift apart during an update.
Upload an update package from the Admin UI or post multipart form data to:
```http
POST /api/update
```
`/api/ota/check` checks reachability and content length for the configured package URL. `/api/ota/run` streams the package from the URL, applies the LittleFS image first, applies the firmware image second, and restarts.
Installing an update package replaces the LittleFS partition, including stored log files. WiFi configuration, users, roles, API ACLs, and settings are stored in NVS preferences and are not part of the LittleFS image.