133 Commits

Author SHA1 Message Date
Maxim Prokhorov
697b8565c2 test(embedis): missing index asserts 2025-12-05 03:42:58 +03:00
Maxim Prokhorov
f24dd99ca4 settings(embedis): c++11-style static_assert for invalid implementations
disallow using toSpan() and toView() when storage does not implement data()

since overloading is used, stop building by simply not writing any function
otherwise, it is finicky w/ compiler support and / or selected -std=...
2025-12-05 03:42:58 +03:00
Maxim Prokhorov
75e48427a5 settings(embedis): sized reads & writes, function local state
reduce the number of times one byte read()s are used
since espXX implementation deals with memory blob most of the time,
just return the data pointer to the buffer position and work w/ that

internal rules for obj construction relaxed, fix implicit operator= deletion
by using pointers instead of references. allow more default output objs

prefer that reader / writer live only for the duration of the function
and are shared explicitly only when it is necessary
2025-12-05 03:31:48 +03:00
Maxim Prokhorov
245e456b44 settings(parse): force trailing suffix when already used it once
prevent ambiguous specs when parsing native durations, which
are implicitly used by default for numbers without suffixes
2025-11-20 23:45:21 +03:00
Maxim Prokhorov
9069546380 test(led): template for unchecked conversion test 2025-11-15 23:29:13 +03:00
Maxim Prokhorov
6093c17fea led: more refactoring
- correctly parse delays when 'repeats' is missing and avoid doing pointer math on nullptr
  empty pattern allowed in all cases, not just 0,0
- parse should signal about invalid inputs
- parse & serialize updated to support empty repeats
- [Rr] in addition to 0,0 as pattern repeat marker

also fixes led.h vs. led_internal.h usage in parser code
2025-11-15 23:04:08 +03:00
Maxim Prokhorov
2938029451 types(duration): micros & millis suffixes
since underlying struct should be able to hold both magnitudes
adjust tests & try to handle more cases
2025-11-15 22:46:05 +03:00
Maxim Prokhorov
bdf87e1a51 led(pattern): refactoring
w/ another -fsanitize=address hint, use separate objects instead of
relying on pattern itself holding everything api *may* need

combine pattern and preset patterns currently separate timers
pattern container reworked to allow small-size optimization

introduce a special '0,0' marker, repeating the whole pattern (instead
of just one delay at the end)

since pattern is part of the led struct proper, display it in settings query
update tests & reuse time parsing routines from utils
2025-11-10 02:53:35 +03:00
Maxim Prokhorov
bb7bd06d67 terminal(test): known memory leakage
allow -fsanitize=address without warnings

avoid extra attributes and just fix the usage in tests,
deprecate for everything else
2025-11-09 18:52:44 +03:00
Maxim Prokhorov
82feb95daa test(build): configurable paths & .gitignore test caches
add one more level of directories for build config & its cache
replace test/pio_cache w/ test/build/cache
2025-06-08 22:07:56 +03:00
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