Commit Graph

123 Commits

Author SHA1 Message Date
Maxim Prokhorov
e48dac27b5 test(a02yyu): sample data
https://github.com/xoseperez/espurna/pull/2622#issuecomment-2440181937
2025-03-07 15:08:03 +03:00
Maxim Prokhorov
f77544fbd8 test(dht): checksum and dht11 2025-03-06 00:40:00 +03:00
Maxim Prokhorov
4c3122c153 test: fix unused / uninitialized warnings 2025-03-05 23:23:10 +03:00
Maxim Prokhorov
40500b489f sns(dht): another dht22 variant w/ 12bit values 2025-03-05 23:02:13 +03:00
Maxim Prokhorov
93dbcb9e31 test(unity): unused function 2025-03-05 18:44:07 +03:00
Maxim Prokhorov
edb458fac6 test(sch): fix utc offset 2025-03-05 18:13:33 +03:00
Maxim Prokhorov
180361a89d test: expected vs. actual stringified 2025-03-05 18:13:33 +03:00
Maxim Prokhorov
824c527064 libs(delimiter): stateless and stateful splitview
reference, value, difference and tag metadata
std::find_if needs same type for begin() and end()
2025-03-05 18:13:33 +03:00
Maxim Prokhorov
91fa550018 libs(delimiter): iterate over split view
adjust internals to provide .begin(), .end(), and the iterator object itself
since the original class is only forward-going, iterator behaves the same
2025-03-05 18:13:33 +03:00
Maxim Prokhorov
4a4dcaeab5 sch(restore): avoid duplicate actions on matching schedule
skip restore::run when action was already executed at least once
(since restore search never returns offset==0 result)
2025-03-05 18:13:33 +03:00
Maxim Prokhorov
a189c5f33f test(delimiter): split and delimiter view
using comparison macro for tests referencing string views
move all local code related to unity to a separate object
2025-03-05 18:12:59 +03:00
Maxim Prokhorov
8e698ac28b util(stream): not all 3.x.x streams have peek api 2025-03-05 18:12:39 +03:00
Maxim Prokhorov
356fcc6555 terminal: semicolon as line break 2025-01-29 12:36:00 +03:00
Maxim Prokhorov
3970dfbbcc terminal: string delimiters and reworked line api
update string search logic to use brute-force for a full string, not just a single char
(ref. c++17/c++20 algorithm std::search defaults)

original code mixed lineview/buffer logic outside of the terminal parser
instead, make sure that delimited classes never return delimiter itself
line classes do so as well, equaly handling both '\n' and '\r\n'
existing terminal api now handles implicitly terminated strings by default

reworked linebuffer initialization order to use inheritance in place of
plain member init. as a bonus, its main methods are no longer templated
reducing the resulting code size per linebuffer specialization (not by very much, though)
2025-01-29 12:35:49 +03:00
Maxim Prokhorov
ab876d4ec8 terminal: report about remaining input and auto-inject line break at the end
- extra flag to include new-line after the input ends
- keep tokens sv to the original string.
  unless escaped characters appear, prefer to not make extra buffers
  (only matters for >12byte tokens; smaller strings do not allocate)
- keep remaining sv, after line break encountered by the parser.
  update api caller to re-use the parser, no need for a separate line delim class
2025-01-29 12:27:36 +03:00
Maxim Prokhorov
332d29bdf4 sch: keep sun .last from updating when .next stays the same
update tests & externalize event hanlding implementation
prevent spurious .last == .next when .next never did or cannot happen

ref. 758ff844, in case update routine is called repeatedly
ref. #2629, 'event' should output coherent values
2024-12-07 18:08:44 +03:00
Maxim Prokhorov
e0db9fdbf7 types: delimiter scanner class
move generic code to a shared header (and not as part of terminal)
move core-specific code to the class itself
2024-11-29 20:05:30 +03:00
Maxim Prokhorov
2a40e505fc test: clean-up esp8266 repo & version bump 2024-11-29 20:04:09 +03:00
Maxim Prokhorov
3cdccfad8d test: parse one frame of a02yyu 2024-10-24 11:48:35 +03:00
toniSg
36e00df272 sns: DYP A02YYU ultrasonic sensor (#2622)
* a02yyu: add support for DYP-A02YYU ultrasonic sensor

* a02yyu: add missing defines

* a02yyu: fix type from char to uint8-t

* a02yyu: simplify read() implementation

* a02yyu: cosmetic reordering of sensor defines
2024-10-24 11:14:41 +03:00
Maxim Prokhorov
2611b6294f test: emon sensor parser test
sensor_emon .ipp for energy and kwh & ws objects
system_time .h for clock definitions. delay not implemented (yet)

ignoring energy calc for the current test, since samples are out-of-sync
also ignoring timeout state, as it syncs with the clock time
2024-10-22 09:28:42 +03:00
Maxim Prokhorov
6327fecfd7 test: stream echo class 2024-10-21 07:51:52 +03:00
Maxim Prokhorov
0b18a332a3 sch: prefer time point to seconds as time_t alternative 2024-09-16 00:43:46 +03:00
Maxim Prokhorov
fc998f97a2 sch: datetime context to time point and back 2024-09-16 00:36:35 +03:00
Maxim Prokhorov
d997cb2c20 sch: fix sun incompatible fmod arguments
use stdlib cmath when building on host
bump to unity 2.6.0 to fix isnan conflict with stdlib
2024-09-16 00:31:16 +03:00
Maxim Prokhorov
949611a47e sch: use native type for event time points
amends 8edb7b6333

- streamline event handling through time_point & to_minutes
  instead of sometimes seconds, sometimes minutes and sometimes both
- minor refactoring cref -> value for time point and durations function args
2024-09-16 00:28:28 +03:00
Maxim Prokhorov
ef7603db89 mqtt: settings topic
refactor mqtt root topic & topic handling, add external module for mqtt validation
check whether root topic contains #, error out when it is missing
check whether generic topics or suffixes contain # or +, error out when they are present

special handling for settings topic to pick a single level /+/ as a key and payload as a value
resolve #2617

tests for mqtt topic filtering and validation
2024-09-10 16:11:28 +03:00
Maxim Prokhorov
2dd05f2179 types: preserve existing sv pointer when slicing out-of-bounds
consistent with string_view::substr behaviour, without the 'throw'ing part
allow to distinguish sv pointing to nothing and sv originating from some
kind of string (here, result of a slice) by comparing its pointer with nullptr
2024-09-10 16:11:27 +03:00
Maxim Prokhorov
30ae346a19 sch: events in mqtt & api
also changes internal timestamp to minutes instead of seconds
no mqtt publish, though, w/ retain defaults and no settings back-up
2024-08-29 17:26:56 +03:00
Maxim Prokhorov
eea56d7a0c sch: inconsistent DST <-> SDT transition when searching
- probe for double and missing hours when daylight saving time happens
  this is specific to local time schedules, utc should remain unaffected
- try to stay consistent with current pattern matching happening in loop
  when an hour is missing, simply skip to the next schedule
  when hour is repeated, make sure to recheck 'earlier' matches
- clean-up tests previously using very-very internal structs
  try to handle everything (sic) using `handle_*` functions
  from the corresponding namespace
2024-08-29 17:18:31 +03:00
Maxim Prokhorov
37596eb436 sch: missing tests for zero offset 2024-08-23 21:30:20 +03:00
Maxim Prokhorov
8edb7b6333 sch: relative time spec for events
Reference calendar time of other schedules, user-created named events
or the sun{rise,set} (when enabled)

For example
- '15m before sunset'
- '30m after cal#0'
- '1h15m after "foobar"'

Empty time spec is allowed, defaults to '1m'
'before sunrise' is the same as '1m before sunrise'

Internals are reworked to handle a more generalized 'Event' type, based
on the 'time point' and 'event' base classes fron sunrise and sunset

Sunrise and sunset should also track 'last' event as well as 'next
(not currently displayed anywhere, though)
2024-08-22 23:40:31 +03:00
Maxim Prokhorov
868d4886ed sys: durations & parsing in the same namespace
not part of settings directly, move them some place else
types compilation unit grows, though...
2024-08-22 23:40:31 +03:00
Maxim Prokhorov
f82cd2211e sch: restore offset for closest, not earliest match in a day
ffs -> clz minus int size, otherwise multiple match order is broken
experiment with future masking, using ffs correctly this time
update tests to handle all branches of closest_delta, both future and past
2024-08-15 14:49:17 +03:00
Maxim Prokhorov
0c52a808cc sns: safeguard against size zero
probably would not happen b/c of config restrains, but...
2024-08-10 00:28:24 +03:00
Maxim Prokhorov
bd1f734494 sch: unused code 2024-08-09 15:03:59 +03:00
Maxim Prokhorov
2d3bba9e01 utils: more duration types and shorter uptime string 2024-08-09 12:46:10 +03:00
Maxim Prokhorov
9acc95e952 sns: update tests 2024-08-09 12:46:10 +03:00
Maxim Prokhorov
d6f807d68c scheduler: midnight as default HH:MM
allow just "UTC", "Monday", "05-01", etc.
clarify webui paragraph and mention KEYWORD as an element

ignore sunrise and sunset keywords when sun module is disabled

move all of parsing to time module, test whether combined match works
2024-05-27 19:10:25 +03:00
Maxim Prokhorov
17a599f91b test: leftover printf 2024-05-27 03:34:50 +03:00
Maxim Prokhorov
c8c9150b37 scheduler: test handle_today with a future date
github actions just happen to be in pacific time / utc-7 today
2024-05-23 01:40:30 +03:00
Maxim Prokhorov
f3f797f93b scheduler: refactor restore, proper sun state
certain actions need to happen when
- starting restore()
- switching date within restore()
- stopping restore()

pretty good fit for an object and raii. so, using context struct to handle
sun{rise,set} initialization and per-schedule time match updates

sun{rise,set} event happens on a specific date, make sure it is also checked
fix double action trigger by comparing minutes, not raw timestamp seconds

experimenting with 'invalid state' i.e. when timestamp was not generated

include restore logic in tests, as code now lives in .ipp
2024-05-23 00:58:36 +03:00
Maxim Prokhorov
d2e18744dc scheduler: backport remainder impl, fix ambiguous name 2024-05-16 01:25:50 +03:00
Maxim Prokhorov
b070b908a7 test: scheduler 2024-05-16 01:25:50 +03:00
Maxim Prokhorov
7152cc67a8 sns: BaseFilter::status()
no real reason to expose internal state, just report filter readiness
2024-02-08 22:17:38 +03:00
Maxim Prokhorov
a33c71b62b sns: special cases for median-average filter 2024-02-08 22:17:38 +03:00
Maxim Prokhorov
aa74de8843 sns: moving average should be an average
ref. #2543
2024-02-08 22:17:38 +03:00
Maxim Prokhorov
b44c293fca test: expected sensor filter values 2024-02-08 22:17:38 +03:00
Maxim Prokhorov
0f5fc5acc3 test: allow double comparison in tests 2024-02-08 22:17:38 +03:00
Maxim Prokhorov
5531b93269 terminal: fix linkage, printing cmd-not-found and add tests 2023-10-17 01:57:40 +03:00