Commit Graph

3197 Commits

Author SHA1 Message Date
Maxim Prokhorov
efcb863ca2 debug: fix off-by-one error when formatting to allocated buffer 2021-08-17 01:11:56 +03:00
Maxim Prokhorov
d9662bd66a debug: don't show timestamps for terminal outputs
Previous version used add_timestamp=false for outputs, this one
accidentally used const char*, size_t overload in place of const char*, boolean

Make sure this can't happen by using a stronger constexpr boolean
specifically for the timestamp conversion.

Also, naming clean-up and making sure raw bytes sender does not enable
already disabled debugging output.
2021-08-16 17:46:56 +03:00
Maxim Prokhorov
1ca8d5e7a0 pio: update platform_latest
Build with Core 3.0.2 release
2021-08-16 17:00:57 +03:00
Maxim Prokhorov
5aa43d4bf1 all: suppress -Wunused-function for serialization helpers 2021-08-16 07:31:00 +03:00
Maxim Prokhorov
ba69eba460 all: suppress BasePin copies and moves
ref. https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-copy-virtual
2021-08-16 04:31:37 +03:00
Maxim Prokhorov
8bcac5f6ec gpio: clean-up
Clarify vtable anchoring, move the comment to the .cpp (near the anchor itself)
Use constexpr instead of preprocessor for GPIO_NONE
2021-08-16 04:31:37 +03:00
Maxim Prokhorov
aa5e0d46b1 led: refactor module to use namespace(s)
As well as previous commits, remove ..._config.h header in favour of .cpp

Refactor loop to only use the `Led` instance, without needing to know
it's ID. Link relay<->led on demand instead of using a flat list.

Import LedPattern implementation into the .cpp, preserve existing .in
file to generate the constructor code (when needed).
Use accessor methods instead of plain members where possible, try to
hide the actual implementation details behind some common ones.

Introduce default settings query for `led` prefix. Setting function
reworked to use common string `prefix` checker instead of requiring the
consumer to provide a onKeyCheck-like lambda / standalone function.
2021-08-16 04:31:36 +03:00
Maxim Prokhorov
2ad187e529 mdns: do not use espurna.h include in the header 2021-08-16 04:31:36 +03:00
Maxim Prokhorov
d482baa725 light: refactor to use namespace(s)
Also clamp the value in setters / getters.
2021-08-16 04:31:36 +03:00
Maxim Prokhorov
ef9b95b68e button: refactor inline getSetting into functions 2021-08-16 04:17:13 +03:00
Maxim Prokhorov
1522087112 relay: refactor inline getSetting into functions 2021-08-16 04:16:30 +03:00
Maxim Prokhorov
7d7bbef2d1 wifi: clean-up
Value init Mac array, both compiler versions support this.
Named constants for conversion function lengths / sizes.
2021-08-12 17:26:48 +03:00
Maxim Prokhorov
921bf08483 settings: no need to test ::keys() 2021-08-12 10:49:09 +03:00
Maxim Prokhorov
85184db09c ota: fix invalid ::update args and tweak ns nesting 2021-08-12 10:48:25 +03:00
Maxim Prokhorov
1aa4e2fed4 rpn: simplify the handler of expiring runners 2021-08-11 18:50:34 +03:00
Maxim Prokhorov
144fbe9b89 settings: no need for vector in the base class 2021-08-11 18:50:34 +03:00
Maxim Prokhorov
11f06cf0a5 ota: fix the build without both flags 2021-08-11 18:50:34 +03:00
Maxim Prokhorov
85e70d8a07 relay: workaround for gcc4.8 single-source build
Resolve the code generation issue with vector methods being unable to
store the exception info string in the same elf section
(which apparently becomes duplicated, somehow, when building single .cpp)

Error messages look like something like this:
```
vector.tcc:405
error: __c causes a section type conflict with __c
    _M_check_len(size_type(1), __EXCSTR("vector::_M_emplace_back_aux"));

vector.tcc:71
note: '__c' was declared here
  __throw_length_error(__EXCSTR(__N("vector::reserve")));
```
2021-08-11 18:45:55 +03:00
Maxim Prokhorov
37b46a040f domoticz: update changelog and webui 2021-08-11 14:25:12 +03:00
Maxim Prokhorov
94f31241dc domoticz: refactoring
Common functions moved into namespace domoticz { ... }
Module functions moved into namespace { ... }

Remove templates and favour simple function for nvalue & svalue formatting,
and also use ArduinoJson for the JSON serialization.

Detach lights from the 1st relay, introduce `dczLightIdx`
Use named channel functions instead of counting channels manually.
Try to migrate the old settings.

Introduce stronger type for Idx to avoid entity id vs. domoticz idx confusion in function arguments,
since both are numeric and there's no distinction besides the name itself.
2021-08-11 14:11:20 +03:00
Maxim Prokhorov
b167d61615 debug: refactoring & remove special case for PROGMEM
Don't use variable length array and remove `debugSend_P`, directly give the format to `vsnprintf_P`.

Common functions moved into namespace debug { ... }
Module functions moved into namespace { ... }

Provide len argument to most outputs, so it's calculated exactly once.
Early checks for nullptr and zero length.

Fix include order once again, try not to depend on config in header and
only use it in the actual .cpp code.

Still involves strlen for flash strings, but that needs to be addressed by using a custom type like:
```
struct PstrWithLength {
    const char* const ptr;
    size_t size;
};
```
And define PSTR macro to return:
```
PstrWithLength{&__pstr__[0], sizeof(__pstr__)};`
```
(and, probably, for any `const char (&fixed)[Size]` arrays as well)
2021-08-11 13:58:24 +03:00
Maxim Prokhorov
d3551ed169 mqtt: limit received messages in log 2021-08-11 12:31:31 +03:00
Maxim Prokhorov
401b678ec6 ota: refactoring & remove deprecated secure client
Remove AXTLS mentions from asynctcp and httpupdate
More namespace MODULE and namespace { ... }
2021-08-10 17:01:27 +03:00
Maxim Prokhorov
c3c929ea34 rpn: refactoring & initialization clean-up
Use namespace instead of custom prefix everywhere.
Multiple init() funcs per namespace, instead of one large one for all
of available operators

Continue to apply namespace { ... }
2021-08-07 16:50:30 +03:00
Maxim Prokhorov
453157c5db all: more static symbols 2021-08-07 16:49:07 +03:00
Maxim Prokhorov
658648d270 core: naming cleanup
Set -> On, when the handler could be added multiple times
Remove unused functions from the headers, and add correct names for the used ones.
2021-08-06 18:45:14 +03:00
Maxim Prokhorov
7a77d23bc5 pio: upstream toolchain
More strict than the current platform-espressif8266 and also prefer this version to for the release tag.
2021-08-06 15:07:43 +03:00
Maxim Prokhorov
cfb58a3f52 alexa: fix unused warning for relay vs. lights functions 2021-08-06 15:03:16 +03:00
Maxim Prokhorov
cf79259189 ci: release workflow 2021-08-06 14:45:52 +03:00
Maxim Prokhorov
814a708fdc config: comments and default(s) 2021-08-06 13:40:31 +03:00
Maxim Prokhorov
c5f70286d1 wifi: allow to set bssid and channel from settings
For when scanning is disabled. Remove uniqueness requirement, since
settings may contain multiple SSID with different BSSID values.

wifi::Mac conversion helpers for both xxxxxxxxxx and xx:xx:xx:xx:xx:xx
2021-08-06 13:21:39 +03:00
Maxim Prokhorov
4be2d370af garland: fixed-size LED arrays
Shuffle std::vector usage, trying out std::array for static data and
std::unique_ptr where common use-case is reserve / resize + emplace

Also try to workaroud exception string issue with gcc4.8, which should
not be a problem with gcc10.3 coming with Core 3.0.0, but... one solution at a time
2021-08-06 12:53:19 +03:00
Maxim Prokhorov
2012a90592 wifi: no need for template 2021-08-05 18:25:04 +03:00
Maxim Prokhorov
426b5bf4a5 garland: remove public includes from private namespace 2021-08-05 18:24:14 +03:00
Maxim Prokhorov
841e4f29d5 garland: correct header order and use namespace { ... }
Header exposes module functions, no need to check for config.
Hide module-local functions from the global namespace.
2021-08-05 18:07:17 +03:00
Maxim Prokhorov
d39aeb61a3 garland: fixup std::vector and std::swap usage
Initialize the vector with the values directly, ::reserve(len) instead of ::resize(len) (throught the ctor)
Use assignment when the intent is to replace the target value, not to exchange with something else.
2021-08-05 18:02:59 +03:00
Maxim Prokhorov
f71a9cc658 garland: fix fountain off-by-one for reverse direction 2021-08-05 17:59:40 +03:00
Maxim Prokhorov
caa7752daa ws: clean-up adminPass handler
- queue the actual response, as sending immediatly seems to have
  inconsistent results with the initial setup page
- allow single string password, just like a normal key
- provide default value for adminPass wsStore variant
- `reload` & `saved` are mutually exclusive
2021-08-05 17:54:15 +03:00
Maxim Prokhorov
f0f7dcc874 wifi: sort and filter by rssi only when actually connecting
Generate initial connection list with all suitable networks, not only the best ones.
When scanning for a better network, remove results with worse rssi.

Don't remove extra scan results in the delayed scan function,
allow consumer to filter by itself.
2021-08-05 17:46:51 +03:00
Maxim Prokhorov
27f701773f settings: simplify migrateVersion() checks in modules
Just `if (version < N)` instead of `if (version && (version < N))`
Fix existing functions that were not checking for `version > 0`
2021-08-02 07:50:52 +03:00
Maxim Prokhorov
dde5f374dd wifi: rework (re)connection and softAp logic
Immediatly try to connect when reloading settings and previous attempt
had failed. Because of locking, previously this caused a soft-lock of the
internal loop that required waiting for the long Reconnect timeout to
expire first.

Refactor the module to include namespace { ... } and move build settings into .cpp
Saves ~1.5Kb and also allows gcc to issue unused warnings for declared functions.

As a side-effect of refactoring, (temporarily?) remove softAp leases support.
Current Core moved dhcps support into a C++ code, forcing internal logic
to reference a specific object. Better to wait a bit until that
stabilizes and try again. Plus, it is not currently available in the esp-idf.
2021-08-02 07:14:19 +03:00
Maxim Prokhorov
f361fbc7ee tuya: led & btn are lowercase with new cfg version 2021-08-02 07:14:19 +03:00
Maxim Prokhorov
b0819fb7b2 light: more channel info in the terminal 2021-08-02 07:14:19 +03:00
Maxim Prokhorov
fa5e4f7d06 sns: shorter cfg keys for hlw8012
Also allow flashstringhelper -> settingskey conversion
2021-08-02 07:14:19 +03:00
Maxim Prokhorov
5c0d18807d i2c: rework internals to use namespace { ... }
Move settings & build flags into local namespace
Fix various functions referring to settings, when i2c is initialized once
Correctly use feature-flags in the .cpp instead of the .h
2021-08-02 01:30:38 +03:00
Maxim Prokhorov
2d1528d856 webui: fix password webMode
make sure the form name is used, not the panel one
also clean-up the api, so it's only mentioned once for both handlers
fix #2461
2021-08-01 07:02:07 +03:00
Maxim Prokhorov
527f911ffb light: provide correct data to the /ws API
RGB is a #RRGGBB hex string, not a R,G,B
Current ltSaveDelay missing from the LIGHTS page
2021-07-23 17:50:21 +03:00
Maxim Prokhorov
b71d384c26 light: allow transition values to be reset during the run()
resolve #2451

Paranoid locking doesn't really matter in the current setup (but, leave some comments about how to solve it when it actually does).
Also copy internal tuple of save+transition+report and give the copy to the callback. Thus, don't assume the consumer is always nice,
and does not declare refs to internal struct variables, making this kind of hard to track.

Refactor internal code so it does not export functions to the built .o
2021-07-23 17:50:21 +03:00
Maxim Prokhorov
eae37fbbc1 terminal: del can delete multiple keys 2021-07-23 17:47:05 +03:00
Maxim Prokhorov
8e5ab5c902 webui: once more tweak the page reload question
Rephrase a bit, since it is a yes / no question box.
Losing the connection triggers ping handlers anyway.
2021-07-20 00:21:10 +03:00