Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove input_channel argument from ValueConsumer #706

Closed
wants to merge 103 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
6c806cc
Remove WiFiManager for good
mairas Apr 25, 2023
3ebd8e6
Replace old Async web server with esp-idf httpd
mairas Sep 26, 2023
eb516bd
Use esp-idf websockets library
mairas Sep 28, 2023
7d13ded
Remove the leftover AsyncTCP libraries
mairas Sep 28, 2023
0f649e9
Fix issues brought up by static analysis tools
mairas Nov 26, 2023
fcd3709
Remove the RemoteDebug dependency
mairas Sep 28, 2023
06c1534
Fix a typo in analogvoltage
mairas Oct 4, 2023
fb5694c
Fix editor indentation
mairas Oct 2, 2023
64ca988
Delete old web tree
mairas Sep 28, 2023
323bd39
Add an .eslintrc file
mairas Oct 10, 2023
4a6bd16
Implement new config UI
mairas Sep 28, 2023
bd9f4c3
Add backend API mocking
mairas Oct 1, 2023
7295780
Add SensESP logo
mairas Oct 1, 2023
e32fbd3
Add generated Bootstrap CSS files to .gitignore
mairas Nov 14, 2023
28a5a64
Add a plugin template
mairas Oct 12, 2023
ffe1f7a
Implement dynamic plugin loading
mairas Nov 14, 2023
fa95276
Add "mocked" remote plugin serving
mairas Nov 14, 2023
bbdaefd
Convert frontend dist files to C++ headers
mairas Sep 27, 2023
4e62782
Split the different API handlers into classes of their own
mairas Nov 19, 2023
50d552b
Decode URLs before matching to paths
mairas Feb 7, 2024
62e9901
Fix hostname UIOutput
mairas Feb 5, 2024
1bcda9b
Change UIOutput Json formatting semantics
mairas Nov 26, 2023
32d052c
Implement Configurable::clear_configuration
mairas Jan 5, 2024
6cc7dd7
Implement /api/routes endpoint
mairas Nov 26, 2023
cf6bbf2
Fix config schema handling
mairas Feb 6, 2024
8a7da88
Reimplement WiFi configuration and connection logic
mairas Jan 31, 2024
793e076
Connect all dynamic routes to the default root page
mairas Feb 5, 2024
9a2ff9b
Make hostname a persisting observable
mairas Feb 1, 2024
a63f09f
Fix task queue producer set signature
mairas Feb 2, 2024
7748654
Implement HTTP Digest Authentication
mairas Feb 5, 2024
9bb1d51
Provide SK delta TX and RX counters
mairas Feb 5, 2024
c8417a9
Fix ArduinoJson 7 deprecations
mairas Feb 5, 2024
50bab13
Lock dependency versions; refactor platformio.ini
mairas Feb 7, 2024
c3cfd29
Remove Startable class
mairas Feb 7, 2024
b64f6b9
Rename ValueConsumer::set_input to set
mairas Feb 7, 2024
f9fa536
Bump version: 2.7.1-alpha → 3.0.0-alpha1
mairas Feb 7, 2024
48e0031
Fix ws_client polling memory leak
mairas Feb 7, 2024
50ce192
Make Integrator emit its initial value
mairas Feb 7, 2024
8127bff
Update the examples
mairas Feb 7, 2024
7644575
Rename HTTPServerHandler to HTTPRequestHandler
mairas Feb 8, 2024
6711dd6
Implement a captive portal for the access point
mairas Feb 8, 2024
6579276
Implement Signal K setting UI
mairas Feb 13, 2024
c7d7a5c
Sort configurables properly
mairas Feb 27, 2024
952d381
Add customizable UI controls
mairas Feb 27, 2024
184b867
Fix editing JSON in textareas
mairas Feb 27, 2024
5174667
Fix RepeatSensor
mairas Feb 29, 2024
b04796c
Only list config items with a schema
mairas Feb 29, 2024
da6aabd
Remove debugging
mairas Feb 29, 2024
1963a72
Grow LambdaTransform schema buffer size
mairas Feb 29, 2024
05fabcd
Remove Configurable description and sort order constructor args
mairas Feb 29, 2024
3285c8c
Fix checkbox form items
mairas Feb 29, 2024
0f65c2f
Get default SSID from hostname. Also reformat.
mairas Mar 8, 2024
0695d50
Lower minimal encryption requirement. Clean up connection logic.
mairas Mar 8, 2024
f70d4ed
Increase config string buffer size
mairas Mar 8, 2024
22a2d47
Move WiFi watchdog to builder
mairas Mar 8, 2024
3f2faab
Use /dev/tty in sample platformio.ini
mairas Mar 8, 2024
31954c1
Allow setting admin username and password in the builder
mairas Mar 8, 2024
279de71
Don't use authentication for the soft AP interface
mairas Mar 8, 2024
bdbf7b6
Never provide configurable description or sort order in arguments
mairas Mar 8, 2024
050a81e
Rename redundant *T and *Template classes
mairas Mar 8, 2024
c8d7fb2
Fix constant sensor configuration schema typing
mairas Mar 8, 2024
398a696
Merge pull request #684 from SignalK/constant_sensor_config
mairas Mar 10, 2024
fbe2d86
Remove the obsolete and broken ts sample plugin code
mairas Mar 15, 2024
aa8a343
Merge pull request #685 from SignalK/remove_old_sample_plugin
mairas Mar 15, 2024
faea9b3
Breaking change: rename WSClient to SKWSClient
mairas Apr 16, 2024
8672fa2
Merge pull request #690 from SignalK/rename_wsclient
mairas Apr 16, 2024
f6f6c07
Pass received Json objects always by value
mairas Apr 16, 2024
cba868d
Merge pull request #691 from SignalK/sklistener
mairas Apr 16, 2024
b116f43
Remove ConstantSensor::get_value
mairas Apr 29, 2024
08c1ce3
Make ConstantSensor emit its value without delay to initialize the ou…
mairas Apr 29, 2024
60b49e2
Rename ConstantSensor::set_value to set for consistency
mairas Apr 29, 2024
e86c06f
Add the run script
mairas Apr 30, 2024
c184a19
Merge pull request #695 from SignalK/add_run_script
mairas Apr 30, 2024
662788e
Compile css files automatically as part of "run build-frontend"
mairas May 5, 2024
e195a0b
Merge pull request #696 from SignalK/run_script_fix_css
mairas May 5, 2024
697da4f
Ensure that the local logging libraries are at front
mairas May 25, 2024
7bfae34
Remove crud
mairas May 25, 2024
be7b248
Migrate to ESP-IDF logging facilities
mairas May 25, 2024
cc71419
Change deprecated ADC enum value
mairas May 25, 2024
f821a6e
Throw an error if CORE_DEBUG_LEVEL is not defined
mairas May 25, 2024
ccda8ea
Document the logging changes
mairas May 26, 2024
683f233
Update the default platformio.ini file
mairas May 26, 2024
3746425
Merge pull request #694 from SignalK/constantsensor_get
mairas Jun 1, 2024
a6d4706
Remove non-existent include
mairas Jun 1, 2024
17ccf34
Update examples
mairas Jun 1, 2024
80c922f
Also update test builds
mairas Jun 1, 2024
f41631c
Remove EDSP8266 CI platformio.ini
mairas Jun 1, 2024
8868449
Update GitHub Actions file
mairas Jun 1, 2024
a760b21
Merge pull request #699 from SignalK/esp_log
mairas Jun 1, 2024
7859ceb
Let the card list be empty
mairas May 26, 2024
a020cfd
Fix Position serialization
mairas Jun 1, 2024
01d0db7
Merge pull request #701 from SignalK/fix_empty_config_list
mairas Jun 1, 2024
62ee197
Add a convenience function to return the board serial number
mairas Jun 3, 2024
c7e1969
Add support for expiring values
mairas Jun 3, 2024
fd25416
Add new observers to the end of the observer list
mairas Jun 6, 2024
231d699
Implement different Repeat transforms
mairas Jun 6, 2024
f5a4e10
Implement join and zip "transforms"
mairas Jun 6, 2024
ead67b7
Implement a throttle transform
mairas Jun 6, 2024
dacc3c1
Make ObservableValue inherit from ValueConsumer
mairas Jun 13, 2024
a8c69ab
TaskQueueProducer set is missing input_channel
mairas Jun 13, 2024
6cf9348
Implement async configuration setting in Configurable
mairas Jun 13, 2024
fc17f83
Allow calling connect_to using a producer reference
mairas Jun 13, 2024
95557d2
Remove input_channel feature altogether
mairas Jun 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.7.1-alpha
current_version = 3.0.0-alpha1
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?
Expand Down
6 changes: 6 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
BasedOnStyle: Google
IndentWidth: 2
IncludeBlocksStyle: Regroup
IncludeCategories:
- Regex: '"sensesp\.h"'
Priority: -1000
- Regex: '"esp32-hal-log\.h"'
Priority: -900
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ insert_final_newline = true
[Makefile]
indent_style = tab

[*.{c,h,cpp,hpp}]
[*.{c,h,cpp,hpp,js,ts,jsx,tsx,css,scss,html,xml,json,yml,md}]
indent_size = 2
17 changes: 11 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -26,13 +25,19 @@ jobs:
target_device:
- esp32dev
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install platformio
pip install --upgrade platformio
- name: Run PlatformIO
run: ci/run-ci.sh
env:
Expand Down
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = SensESP
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 2.7.1-alpha
PROJECT_NUMBER = 3.0.0-alpha

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.1-alpha
3.0.0-alpha
18 changes: 0 additions & 18 deletions ci/platformio-d1_mini.ini

This file was deleted.

6 changes: 6 additions & 0 deletions ci/platformio-esp32dev.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ board_build.partitions = min_spiffs.csv
monitor_filters = esp32_exception_decoder
build_flags =
-D LED_BUILTIN=2
-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
; Arduino Core bug workaround: define the log tag for the Arduino
; logging macros.
-D TAG='"Arduino"'
; Use the ESP-IDF logging library - required by SensESP.
-D USE_ESP_IDF_LOG
85 changes: 74 additions & 11 deletions docs/pages/migration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,77 @@ title: Migrating From Version 1
nav_order: 70
---

# Migrating SensESP Version 1 Projects to Version 2
# Migration Guides for SensESP Major Versions

## Migrating SensESP Version 2 Projects to Version 3



### Logging

Previous SensESP versions logged to the serial port using the `debugX` functions, where `X` is the log level.
This pattern was inherited from the RemoteDebug library.
SensESP v3 has switched to using standard ESP-IDF logging functions.
They allow redirecting log messages to different outputs, which will be used in future SensESP versions to provide logging to the web interface.

To enable logging in SensESP v3, change the `build_flags` in your `platformio.ini` file to include the following:

```ini
build_flags =
-D LED_BUILTIN=2
; Max (and default) debugging level in Arduino ESP32 Core
-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
; Arduino Core bug workaround: define the log tag for the Arduino
; logging macros.
-D TAG='"ARDUINO"'
; Use the ESP-IDF logging library - required by SensESP.
-D USE_ESP_IDF_LOG
```

The `debugX` functions are still available, but they are now just wrappers around the ESP-IDF logging functions.
In any new code, use the `ESP_LOGX` functions, where `X` is the log level.
These require a tag argument, which is a string that identifies the source of the log message.
You can use any tag you like, but for simple programs, you can use the `__FILE__` macro, which expands to the name of the current file.

The allowed log levels are:

- `NONE`: No log output
- `ERROR`: Critical errors, software module can not recover on its own
- `WARN`: Error conditions from which recovery measures have been taken
- `INFO`: Information messages which describe normal flow of events
- `DEBUG`: Extra information which is not necessary for normal use (values, pointers, sizes, etc).
- `VERBOSE`: Bigger chunks of debugging information, or frequent messages which can potentially flood the output.

Here is an example of how to use the `ESP_LOGX` functions:

```c++
ESP_LOGI(__FILE__, "Initializing NMEA2000");
...
ESP_LOGD(__FILE__, "Sending value %d to fobulator %s", value, fobulator_name);
...
ESP_LOGE(__FILE__, "Failed to initialize NMEA2000");
```

To enable logging in previous SensESP versions, you had to call `SetupSerialDebug(115200)` as the first line in your `setup()` function.
In new SensESP versions, replace this with the new `SetupLogging()` function call to set logging defaults.
The old `SetupSerialDebug` function is still available, but it is now just a wrapper around `SetupLogging`.

It is possible to change the log level for individual tags.
Here is an example of how to set the overall log level to `INFO` and the log level for the `main.cpp` tag to `DEBUG`:

```c++
esp_log_level_set("*", ESP_LOG_INFO);
esp_log_level_set("main.cpp", ESP_LOG_DEBUG);
```

## Migrating SensESP Version 1 Projects to Version 2

SensESP version 2 has a number of backwards-incompatible changes compared to the previous version.
Most of the changes are trivial, while some others require a bit of more work to update the code.

This document walks through the most important changes, and explains how to update your project to the new version.

## ESP8266 Support Removed
### ESP8266 Support Removed

If your project uses ESP8266 hardware, you will either have to update to an ESP32 device, *or* you can keep using SensESP version 1. To peg your project to SensESP v1, change the SensESP dependency in your project's `platformio.ini` file `lib_deps` section to this:

Expand All @@ -20,9 +83,9 @@ lib_deps =
SignalK/SensESP @ ^1.0.8
```

## Main Program Structure
### Main Program Structure

### Setup and Loop Functions
#### Setup and Loop Functions

SensESP builds on [ReactESP](https://github.com/mairas/ReactESP), which is an event-based framework for developing ESP32 firmware.
Previous versions of ReactESP defined the Arduino Framework default `setup()` and `loop()` functions internally and relied on a lambda function for initializing the program and defining the top-level functionality:
Expand Down Expand Up @@ -56,7 +119,7 @@ void setup() {
void loop() { app.tick(); }
```

### Namespace Usage
#### Namespace Usage

In projects with a lot of dependencies, it is common that some upstream library exports some very generic symbol names, which then causes conflicts or hard-to-debug issues in the code being developed. The standard C++ approach to mitigate these issues is to use a namespace.

Expand Down Expand Up @@ -87,7 +150,7 @@ namespace sensesp {
}
```

## External Sensors
### External Sensors

All Sensor classes requiring external libraries have been removed.
Reducing the number of external dependencies improves code stability and improves build times.
Expand All @@ -97,7 +160,7 @@ Most, however, have been removed in favor of a more generic approach, namely the
The `RepeatSensor` class allows you to easily interface any external hardware sensor libraries with SensESP.
See the `RepeatSensor` tutorials ([part 1](../tutorials/bmp280), [part 2](../tutorials/bmp280)) for more details.

## Renamed Classes and Types
### Renamed Classes and Types

Type-specific Consumer and Producer class names have been renamed to more closely match the native C++ types.

Expand All @@ -109,15 +172,15 @@ Similarly, names with other types have been renamed to more closely match the st

To better reflect the intent and the functionality, the `Enable` class has been renamed to `Startable`.

## Class Interface Changes
### Class Interface Changes

Some class public interfaces have been changed.

The [`DigitalInputState`](https://signalk.org/SensESP/generated/docs/classsensesp_1_1_digital_input_state.html) constructor no longer accepts the `interrupt_type` argument because that class never used interrupts.

The [`DigitalInputChange`](https://signalk.org/SensESP/generated/docs/classsensesp_1_1_digital_input_change.html) implementation has been simplified and the constructor no longer requres the `read_delay` argument.

## System Info Sensors
### System Info Sensors

SensESP v1 had so called "standard sensors" that transmit information on the operation of the device: free memory, number of event loop executions per second, device IP address, and so on.
The standard sensors were initialized using a SensESP constructor or builder bitfield argument:
Expand All @@ -135,7 +198,7 @@ sensesp_app = builder.enable_free_mem_sensor()
->get_app();
```

## Remote Debugger Disabled
### Remote Debugger Disabled

The Remote Debugger allows you to connect to the device over telnet and view the log messages and even reset the device, all without a USB cable connection.
Even though this is a neat and useful feature, it was not widely known and uses *a lot* of memory.
Expand All @@ -161,7 +224,7 @@ build_flags =
-D DEBUG_DISABLED
```

## Over-The-Air (OTA) Firmware Updates
### Over-The-Air (OTA) Firmware Updates

OTA firmware updates have been supported already for a long time.
To improve security, OTA updates are now enabled only if an OTA password is defined in the App builder:
Expand Down
10 changes: 3 additions & 7 deletions examples/analog_input.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

#include "sensesp/sensors/analog_input.h"

#include <Arduino.h>

#include "sensesp/sensors/analog_input.h"
#include "sensesp/signalk/signalk_output.h"
#include "sensesp/transforms/linear.h"
#include "sensesp_app.h"
Expand All @@ -16,9 +17,7 @@ reactesp::ReactESP app;
// The setup function performs one-time application initialization.
void setup() {
// Some initialization boilerplate when in debug mode...
#ifndef SERIAL_DEBUG_DISABLED
SetupSerialDebug(115200);
#endif
SetupLogging();

// Create the global SensESPApp() object.
SensESPAppBuilder builder;
Expand Down Expand Up @@ -90,9 +89,6 @@ void setup() {
analog_input->connect_to(new Linear(multiplier, offset, linear_config_path))
->connect_to(new SKOutputFloat(sk_path, "",
new SKMetadata("ratio", "Indoor light")));

// Start the SensESP application running
sensesp_app->start();
}

// The loop function is called in an endless loop during program execution.
Expand Down
8 changes: 1 addition & 7 deletions examples/async_repeat_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ reactesp::ReactESP app;

// The setup function performs one-time application initialization.
void setup() {
// Some initialization boilerplate when in debug mode...
#ifndef SERIAL_DEBUG_DISABLED
SetupSerialDebug(115200);
#endif
SetupLogging();

// Create the global SensESPApp() object.
SensESPAppBuilder builder;
Expand Down Expand Up @@ -56,9 +53,6 @@ void setup() {
// Connect the output of the digital input to the SKOutput object which
// transmits the results to the Signal K server.
digital->connect_to(new SKOutputFloat(sk_path, ""));

// Start the SensESP application running
sensesp_app->start();
}

// The loop function is called in an endless loop during program execution.
Expand Down
19 changes: 8 additions & 11 deletions examples/chain_counter.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "sensesp_app.h"
#include "sensesp_app_builder.h"
#include "sensesp/sensors/digital_input.h"
#include "sensesp/signalk/signalk_output.h"
#include "sensesp/system/lambda_consumer.h"
#include "sensesp/transforms/debounce.h"
#include "sensesp/transforms/integrator.h"
#include "sensesp_app.h"
#include "sensesp_app_builder.h"

using namespace sensesp;

Expand All @@ -25,7 +25,7 @@ using namespace sensesp;
ReactESP app;

void setup() {
SetupSerialDebug(115200);
SetupLogging();

SensESPAppBuilder builder;
sensesp_app = builder.set_hostname("ChainCounter")
Expand All @@ -48,17 +48,17 @@ void setup() {
counter_read_delay, counter_config_path);

/**
* An IntegratorT<int, float> called "accumulator" adds up all the counts it
* An Integrator<int, float> called "accumulator" adds up all the counts it
* receives (which are ints) and multiplies each count by gypsy_circum, which
* is the amount of chain, in meters, that is moved by each revolution of the
* windlass. (Since gypsy_circum is a float, the output of this transform must
* be a float, which is why we use IntegratorT<int, float>). It can be
* be a float, which is why we use Integrator<int, float>). It can be
* configured in the Config UI at accum_config_path.
*/
float gypsy_circum = 0.32;
String accum_config_path = "/accumulator/circum";
auto* accumulator =
new IntegratorT<int, float>(gypsy_circum, 0.0, accum_config_path);
new Integrator<int, float>(gypsy_circum, 0.0, accum_config_path);

/**
* There is no path for the amount of anchor rode deployed in the current
Expand Down Expand Up @@ -96,8 +96,8 @@ void setup() {
*/
int read_delay = 10;
String read_delay_config_path = "/button_watcher/read_delay";
auto* button_watcher = new DigitalInputChange(
BUTTON_PIN, INPUT, read_delay, read_delay_config_path);
auto* button_watcher = new DigitalInputChange(BUTTON_PIN, INPUT, read_delay,
read_delay_config_path);

/**
* Create a DebounceInt to make sure we get a nice, clean signal from the
Expand Down Expand Up @@ -144,9 +144,6 @@ void setup() {

/* Connect the button_watcher to the debounce to the button_consumer. */
button_watcher->connect_to(debounce)->connect_to(button_consumer);

/* Finally, start the SensESPApp */
sensesp_app->start();
}

// The loop function is called in an endless loop during program execution.
Expand Down
9 changes: 2 additions & 7 deletions examples/constant_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@
*/

#include "sensesp/sensors/constant_sensor.h"

#include "sensesp_app_builder.h"

using namespace sensesp;

reactesp::ReactESP app;

void setup() {
// Some initialization boilerplate when in debug mode...
#ifndef SERIAL_DEBUG_DISABLED
SetupSerialDebug(115200);
#endif
SetupLogging();

// Create the builder object
SensESPAppBuilder builder;
Expand All @@ -37,9 +35,6 @@ void setup() {
constant_sensor->connect_to(
new SKOutputFloat("tanks.freshWater.capacity", "",
new SKMetadata("m3", "Fresh Water Tank Capacity")));

// Start the SensESP application running
sensesp_app->start();
}

void loop() { app.tick(); }
Loading
Loading