Skip to content

Commit

Permalink
Several small changes and improvements (#10)
Browse files Browse the repository at this point in the history
* Added core temp

* added mDNS service and recovery mode

* Final touch recovery mode incl. docs

* Updated to Svelte 4

* Revert back to Svelte 3, CHANGELOG and push notifications

* Fixed drawer issue introduced with DaisyUI 3.1.6

* Added telemetry via SSE for RSSI

* FT_PROJECT feature flag removed

* fimware version in factory_settings.ini and SystemStatus API

* Deep Sleep Service API

* Added battery indicator & service

* Restructured OTA

* Improvements System Status

* WIP github update

* Github Release OTA

* Update documentation for github updates

* Refactor WebSocket Server Code

* Error messages for SSE and WS

* Mark 53.33 degC als invalid

* Generate SSL Root CA Store

* build script for ssl certificate store

* different ssl build config

* Version updates

* default env S3

* Update CHANGELOG.md

* WebSocketClient Trials

* WebSocketTrials

* Learnings from other projects

* Fixes for platformio issue

* fixes for Arduino 6.4.0

* updated docs

* hard fork ESPAsyncWebserver + System Metrics

* Update docs
  • Loading branch information
theelims authored Oct 8, 2023
1 parent bca085c commit c90a429
Show file tree
Hide file tree
Showing 68 changed files with 9,961 additions and 540 deletions.
22 changes: 18 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

All notable changes to this project will be documented in this file.

## [0.2.2]

### Added

- Status reports reset-reason & uptime.
- AnalyticsService to draw graphs about heap usage and other time dependent values
- Added ping to WebSocket Server
- Use telemetry store with RSSI messages to gauge health of connection. Automatic reconnect for SSE and WS.
- Added user supplied features to FeatureService
- Compiler flag to let it serve the config JSONs for debug purposes
- Hard fork of ESPAsyncWebserver as it is unmaintained to fix bugs and add features

### Changed

- Changed JSON format for websocket server and removed "payload" property. JSON is the same as for MQTT or HTTP now.
- Changed features.ini to default `FT_SLEEP=0`
- Updated dependencies to latest version.

## [0.2.1] - 2023-09-11

### Fixed
Expand Down Expand Up @@ -46,10 +64,6 @@ All notable changes to this project will be documented in this file.

- `FT_PROJECT` feature flag removed.

### Fixed

### Security

## [0.1.0] - 2023-05-18

This is the initial release of ESP32-sveltekit. With this it is feature complete to [rjwats/esp8266-react](https://github.com/rjwats/esp8266-react), where it forked from.
Expand Down
12 changes: 12 additions & 0 deletions docs/buildprocess.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Customize the settings as you see fit. A value of 0 will disable the specified f
| FT_SLEEP | Controls whether the deep sleep feature is enabled. Disable this if your device is not battery operated or you don't need to place it in deep sleep to save energy. |
| FT_BATTERY | Controls whether the battery state of charge shall be reported to the clients. Disable this if your device is not battery operated. |

In addition custom features might be added or removed at runtime. See [Custom Features](statefulservice.md#custom-features) on how to use this in your application.

## Factory Settings

The framework has built-in factory settings which act as default values for the various configurable services where settings are not saved on the file system. These settings can be overridden using the build flags defined in [factory_settings.ini](https://github.com/theelims/ESP32-sveltekit/blob/main/factory_settings.ini).
Expand Down Expand Up @@ -127,6 +129,16 @@ build_flags =

It accepts values from 1 (Verbose) to 5 (Errors) for different information depths to be logged on the serial terminal.

### Serve Config Files

By enabling this build flag the ESP32 will serve all config files stored on the LittleFS flash partition under `http:\\[IP]\config\[filename].json`. This can be helpful to troubleshoot problems. However, it is strongly advised to disable this for production builds.

```ini
build_flags =
...
-D SERVE_CONFIG_FILES
```

## SSL Root Certificate Store

Some features like firmware download require a SSL connection. For that the SSL Root CA certificate must be known to the ESP32. The build system contains a python script derived from Espressif ESP-IDF building a certificate store containing one or more certificates. In order to create the store you must uncomment the three lines below in `platformio.ini`.
Expand Down
6 changes: 5 additions & 1 deletion docs/gettingstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pip install mkdocs-material
```ini
[platformio]
...
default_envs = adafruit_feather_esp32_v2
default_envs = esp32-s3-devkitc-1
...

[env:adafruit_feather_esp32_v2]
Expand All @@ -76,6 +76,10 @@ board_build.mcu = esp32s3

If your board is not listed in the platformio.ini you may look in the [official board list](https://docs.platformio.org/en/latest/boards/index.html#espressif-32) for supported boards and add their information accordingly. Either delete the obsolete `[env:...]` sections, or change your board as `default_envs = ...`.

!!! info "Default setup is for an ESP32-S3-DevKitC/M board"

The projects platformio.ini defaults for an ESP32-S3-DevKitC/M board by Espressif connected to the UART USB port. If you use an other board and the projects shows undesired a behavior it is likely that some parts do not match with pin definitions.

### Build & Upload Process

After you've changed [platformio.ini](https://github.com/theelims/ESP32-sveltekit/blob/main/platformio.ini) to suit your board you can upload the sample code to your board. This will download all ESP32 libraries and execute `node install` to install all node packages as well. Select your board's environment under the PlatformIO tab and hit `Upload and Monitor`.
Expand Down
17 changes: 8 additions & 9 deletions docs/statefulservice.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ void setup() {
}
```

Finally the loop calls the framework's loop function to service the frameworks features.

```cpp
void loop() {
// run the framework's loop function
esp32sveltekit.loop();
}
```

## Stateful Service

The framework promotes a modular design and exposes features you may re-use to speed up the development of your project. Where possible it is recommended that you use the features the frameworks supplies. These are documented in this section and a comprehensive example is provided by the demo project.
Expand Down Expand Up @@ -426,6 +417,14 @@ esp32sveltekit.getBatteryService()->updateSOC(float stateOfCharge); // update st
esp32sveltekit.getBatteryService()->setCharging(boolean isCharging); // notify the client that the device is charging
```
### Custom Features
You may use the compile time feature service also to enable or disable custom features at runtime and thus control the frontend. A custom feature can only be added during initializing the ESP32 and ESP32-SvelteKit. A feature can't be updated on runtime once it is set once.
```cpp
esp32sveltekit.getFeatureService()->addFeature("custom_feature", true); // or false to disable it
```

## OTA Firmware Updates

ESP32-SvelteKit offers three different ways to roll out firmware updates to field devices. Except for ArduinoOTA all other OTA possibilities cannot update the file system. If the frontend should be updated as well it is necessary to serve it from PROGMEM by activating `-D PROGMEM_WWW`.
Expand Down
23 changes: 23 additions & 0 deletions docs/stores.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,26 @@ It exposes the following properties you can subscribe to:
| `$telemetry.download_ota.status` | `String` | Status of OTA |
| `$telemetry.download_ota.progress` | `Number` | Progress of OTA |
| `$telemetry.download_ota.error` | `String` | Error Message of OTA |

## Analytics

The analytics store holds a log of heap and other debug information via Server-Sent Events. The corresponding `eventListener` functions are located in `+layout.svelte`.

```ts
import { analytics } from "$lib/stores/analytics";
```

It exposes an array of the following properties you can subscribe to:

| Property | Type | Description |
| --------------------------- | -------- | ---------------------------------------------- |
| `$analytics.uptime` | `Number` | Uptime of the chip in seconds since last reset |
| `$analytics.free_heap` | `Number` | Current free heap |
| `$analytics.min_free_heap` | `Number` | Minimum free heap that has been |
| `$analytics.max_alloc_heap` | `Number` | Biggest continues free chunk of heap |
| `$analytics.fs_used` | `Number` | Bytes used on the file system |
| `$analytics.fs_total` | `Number` | Total bytes of the file system |
| `$analytics.core_temp` | `Number` | Core temperature (on some chips) |

By default there is one data point every 2 seconds.

2 changes: 1 addition & 1 deletion factory_settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[factory_settings]
build_flags =
; Global Settings
-D FIRMWARE_VERSION=\"0.2.1\"
-D FIRMWARE_VERSION=\"0.2.2\"

; WiFi settings
-D FACTORY_WIFI_SSID=\"\"
Expand Down
6 changes: 3 additions & 3 deletions features.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ build_flags =
-D FT_OTA=0 ; Not recommended, will be deprectiated in an upcomming release
-D FT_UPLOAD_FIRMWARE=1
-D FT_DOWNLOAD_FIRMWARE=1 ; requires FT_NTP=1
-D FT_SLEEP=1
-D FT_BATTERY=1

-D FT_SLEEP=0
-D FT_BATTERY=0
-D FT_ANALYTICS=1
Loading

0 comments on commit c90a429

Please sign in to comment.