Commit Graph

3324 Commits

Author SHA1 Message Date
Maxim Prokhorov
b2c900b799 ntp: fix terminal newlines 2021-12-19 17:48:40 +03:00
Maxim Prokhorov
64d70b1324 utils: mode is always null 2021-12-19 17:48:40 +03:00
Maxim Prokhorov
907cba1518 utils: comments 2021-12-19 17:48:40 +03:00
Maxim Prokhorov
bffc484c47 relay: comments 2021-12-19 17:48:40 +03:00
Maxim Prokhorov
3f2d2308f8 relay: set initial status for pulse 2021-12-19 17:48:40 +03:00
Maxim Prokhorov
ba90b76020 relay: pulse api returns seconds 2021-12-19 17:48:40 +03:00
Maxim Prokhorov
e271eaa019 sensor: fix crash when trying to read ratio settings 2021-12-18 23:47:20 +03:00
Maxim Prokhorov
a5bb8e457a system: fix ticker arg cast
Don't introduce our callback to the type system, continue to bind the
ticker instance as the timer's arg and just use the lambda to pass the
argument to the reset function

```
libraries/Ticker/src/Ticker.h:136:41: warning: cast between incompatible function types from 'void (*)(CustomResetReason)' to 'Ticker::callback_with_arg_t' {aka 'void (*)(void*)'} [-Wcast-function-type]
  136 |         _attach_ms(milliseconds, false, reinterpret_cast<callback_with_arg_t>(callback), reinterpret_cast<void*>(arg));
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
2021-12-18 23:47:20 +03:00
Maxim Prokhorov
19963fb8ce system: some unused params 2021-12-18 23:47:20 +03:00
Maxim Prokhorov
20fc3a655c system: clean-up types 2021-12-18 23:46:37 +03:00
Maxim Prokhorov
81862e420a api: check content-type detected by the server
Don't fail when the header also has charset=...
Also, fallback to text/plain when there's no Accept
2021-12-18 23:46:37 +03:00
Maxim Prokhorov
493bbcfa2a relay: accept {hh}h{mm}m{ss}s syntax for pulse
Attempt to either parse with newer syntax, or fallback to the floating
point seconds as default. Settings also return a 'result' instead of the
default zero, fallback to build value otherwise (which is still floating point, though)

Update /pulse API endpoint to report the actual pulse timer value that
is active right now, not just the value attached via the setting
2021-12-18 23:40:53 +03:00
Maxim Prokhorov
f4813fe303 api: fix warnings
Unused variables, bogus const-qualifiers and some strict switch-case rules with -Wextra
2021-12-18 23:40:53 +03:00
Maxim Prokhorov
5940f0aa8c alexa: always read the specified length of the payload
Make sure we don't try to strlen some empty space or neighbouring
segments, that may or may not contain nulls

Also tweak the function to warn about large messages, since it is not
(yet) clear whether we actually want those. At least something to log.
2021-12-18 23:40:53 +03:00
Maxim Prokhorov
79e4fac010 wifi: make sure settings are in namespaces
Localize build constants & settings use, no need to prefix where
namespacing already does this (and also removes some duplicates)
2021-12-18 23:40:53 +03:00
Maxim Prokhorov
202243dc0f rfbridge: don't printf without any args
Also calm down clangd, mark template specializations as unused
2021-12-18 23:40:53 +03:00
Maxim Prokhorov
d788e04616 relay: pulse as terminal command 2021-12-18 23:40:53 +03:00
Maxim Prokhorov
6bce23d23c ntp: rework internals and use namespacing
Make sure to properly clamp delay times, as the recent issue had shown
it is possible to go below the update limit. SNTP app does not do any
runtime checks, so it's up to us to enforce these limits

Update internal random number generator from raw `secureRandom()` to a custom
'std::random_device'-look-alike, where we could also use it with STL functions
(current implementation is `os_random()` aka `esp_random()`)
2021-12-18 23:40:53 +03:00
Maxim Prokhorov
2f0b8e47bc ws: localize info access 2021-12-14 17:43:53 +03:00
m-kozlowski
21a8c2678f ntp: use milliseconds in sntp_*_delay functions (#2490) 2021-12-12 12:25:05 +03:00
Maxim Prokhorov
26d28db0ef relay: fixup stm relay change delay 2021-12-09 03:16:13 +03:00
Maxim Prokhorov
1b27fa5316 relay: preliminary support for internal duration types
Not as clean as other modules, but at least prepare for the further changes.
Implement settings for float duration conversion, and test it out with pulse
and flood window time values.

More safe-guards for an externally-defined pulse time, make sure it is
not either inf or nan and is an actual finite number

Also use EnumerableConfig for the WebUI output, and make sure to use
internal _relays.size() instead of doing a function call
2021-12-09 03:07:57 +03:00
Maxim Prokhorov
67d4463652 ota: last remaining un-typed deferredReset 2021-12-09 01:57:03 +03:00
Maxim Prokhorov
f881b83ea8 hass: flash-strings for json keys
Saves ~100bytes in RAM
2021-12-09 01:24:17 +03:00
Maxim Prokhorov
de35f9bfe1 light: use internal duration type(s)
Get rid of 'assumed' units and use strong types instead
Also update HomeAssistant conversion code as float -> uint durations
2021-12-09 01:15:11 +03:00
Maxim Prokhorov
ac9806c9e5 system: use internal duration types with nice_delay 2021-12-09 01:15:11 +03:00
Maxim Prokhorov
f44aab5fdb system: simple deferred reset function
No need for specific delay for each instance, just use a shared one
2021-12-09 01:15:11 +03:00
Maxim Prokhorov
f9ad9d44e1 webui: find all span elements, not just one 2021-12-09 01:15:11 +03:00
Maxim Prokhorov
2f580a37a2 terminal: context is a temporary
Make sure it could be moved further along, and the values inside of it
can be safely moved as well.

Also fixup commands that were missing ctx in OK / Error.
2021-12-08 18:05:25 +03:00
Maxim Prokhorov
a0e090489b terminal: get rid of ctx.argc
No need to duplicate argv::size()
2021-12-08 17:42:12 +03:00
Maxim Prokhorov
f2a7dcffe1 ntp: fix terminal ntp.settime and implement ntp.sync
Use internal duration types, store time in seconds and propogate as
uint32_t when it is necessary. Update tick values as well.

Instead of generic `toInt(), overload between `strtol` and `strtoll`.
Current implementation of `settimeofday` rejects `struct tz` pointer,
make sure it's nullptr.

Sync is a simple enough routine... But, expect an already synced system
before triggering the sntp restart.
2021-12-08 17:31:29 +03:00
Maxim Prokhorov
a8cf30832e wifi: use internal types for timeouts
For this, keep things as milliseconds (at least for now)

Make sure to use __builtin_strlen in constexpr context
Remove `has*()` functions that are no longer used

Update WebUI callback to use EnumerableConfig
2021-12-08 13:48:44 +03:00
Maxim Prokhorov
baac061d27 telnet: destroy the specific client when disconnecting 2021-12-08 13:48:44 +03:00
Maxim Prokhorov
a684348b17 system: instruct the compiler to crash instead of invoking undefined behaviour 2021-12-08 13:48:44 +03:00
Maxim Prokhorov
b05dcf6540 config: update comments, mention time units 2021-12-08 13:48:44 +03:00
Maxim Prokhorov
135c7b80ac ws: use internal types for timeouts 2021-12-08 13:48:44 +03:00
Maxim Prokhorov
5dc0908d8c ws: format with the actual type of the time_t
Don't assume the size <-> type, utilize type matching in the template
specialization to retrieve the actual type <-> format pair that we need
2021-12-08 13:48:44 +03:00
Maxim Prokhorov
0f34261fab web: use internal millis() call 2021-12-08 13:48:44 +03:00
Maxim Prokhorov
16960067d8 system: some refactoring
There's no need to move a temporary which is already an rvalue

Clean-up some redundant attributes and function in settings.
Make sure C types are proxied to fixed-sized ones, not the other way around.

Clean-up webprint implementation
- use typed duration for the backlog
- don't duplicate members and types for config, just re-use the struct as-is
- don't go over-the-top with const members, just proxy through a method
2021-12-08 13:48:40 +03:00
Maxim Prokhorov
4d04125eb6 pio: bump toolchain-xtensa for git environments
ref. https://github.com/esp8266/Arduino/pull/8393
2021-12-07 02:11:46 +03:00
Maxim Prokhorov
c33d9960b4 ir: bump IRremoteESP8266 to 2.8.0 2021-12-07 01:08:44 +03:00
Maxim Prokhorov
8312f27e4b pio: even shorter suffix for .ipp files
remove .cpp from the resulting suffix, since .ipp already implies it is c++
update comments once again
2021-12-07 01:06:18 +03:00
Maxim Prokhorov
4e4d75af63 rfbridge: fix efm8bb1 provider send & receive
(possibly) noticed in the gitter
https://gitter.im/tinkerman-cat/espurna?at=61abba5a76e37917551e4a2f

refactoring causality, as there's no longer an explicit Serial.begin
for RFB_PROVIDER_EFM8BB1 in the hardware setup in the system.cpp
(also, from not including wip serial changes that did serial port setup :/)
2021-12-06 18:55:11 +03:00
Maxim Prokhorov
c0c3dcdc1d ir: include typos 2021-11-30 03:20:13 +03:00
Maxim Prokhorov
d40322d98f ci: fix quoting for the test_build -include
amends 79321b6707
otherwise, env.ParseFlags never understands it
2021-11-30 03:17:33 +03:00
Maxim Prokhorov
d094283df2 pio: formatting 2021-11-30 01:28:09 +03:00
Maxim Prokhorov
a7a9c5045f pio: generate .cpp.ipp instead of .cpp.inc
fixes #2479
2021-11-30 00:15:52 +03:00
Maxim Prokhorov
c738b91b6a pio: simplify single-source builder
Generate resulting .cpp in the $BUILD_DIR, no need for atexit
Register middleware only once, there's no need to manually walk the
project directory since fnmatch.fnmatch(...) supports globs

Provide a SCons Action instead of simple function, so there's a way to
generate things on demand via command line
```
$ pio run -e $env -t .pio/build/$env/espurna_single_source/src/main.cpp
```
2021-11-30 00:06:24 +03:00
Maxim Prokhorov
ebc479f145 pio: fix indirect dependency on the build-and-copy .bin 2021-11-29 23:06:25 +03:00
Maxim Prokhorov
79321b6707 ci: directly use the test build headers
- just pass `-include ${cfg}` to the compiler instead of a
  temporary custom.h. also do `-DDEVICE=...` and `-DMANUFACTURER=...`
- rework test_build to print using `logging` module
- report leftover configurations, after the failed one exits
- prettify the output and highlight relevant info instead of the whole lines
2021-11-29 23:06:03 +03:00