Commit Graph

3183 Commits

Author SHA1 Message Date
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
Maxim Prokhorov
84a7f6337f webui: comments & event handling fixes 2021-07-19 23:14:38 +03:00
Maxim Prokhorov
fa3deeffbf webui: remove jquery dependencies and clean-up websocket API
Refactor WebUI:
- remove jquery dependency from the base custom.js and use vanilla JS
- remove jquery + jquery-datatables dependency from the RFM69 module
- replace jquery-datatables handlers with pure-css table + some basic cell filtering
  (may be incomplete, but tbh it is not worth additional 50Kb to the .bin size)
- introduce a common way to notify about the app errors, show small text notification
  at the top of the page instead of relying on user to find out about errors by using the Web Developer Tools
- replace <span name=...> with <span data-settings-key=...>
- replace <div> templates with <template>, disallowing modification
  without an explicit DOM clone
- run `eslint` on html/custom.js and `html-validate` on html/index.html,
  and fix issues detected by both tools

Streamline settings group handling in custom.js & index.html
- drop module-specific button-add-... in favour of button-add-settings-group
- only enforce data-settings-max requirement when the property actually exists
- re-create label for=... and input id=... when settings group is
  modified, so checkboxes refer to the correct element
- introduce additional data-... properties to generalize settings group additions
- introduce Enumerable object to track some common list elements for
  <select>, allow to re-create <option> list when messages come in
  different order

Minor fixes that also came with this:
- fix relay code incorrectly parsing the payload, causing no relay names
  to be displayed in the SWITCHES panel
- fix scheduler code accidentally combining keys b/c of the way C parses
  string literals on separate lines, without any commas in-between
- thermostat should not reference tmpUnit directly in the webui, replace with
  module-specific thermostatUnit that is handled on the device itself
- fix index.html initial setup invalid adminPass ids
- fix index.html layout when removing specific schedules
2021-07-18 23:30:32 +03:00
Maxim Prokhorov
256e790e4d webui: make sure the pointer data is set to null, otherwise the webserver will try to free() it 2021-07-18 22:41:51 +03:00
Maxim Prokhorov
6b2c34eaae alexa: display the used name in the webui 2021-07-18 22:41:50 +03:00
Maxim Prokhorov
658ce1056e rpn: make sure loop is actually reached after mqtt updates variables list 2021-07-06 09:19:05 +03:00
Maxim Prokhorov
50f247bd18 webui: fix scheduler template layout
Additional div made the mutator think we still have some active elements.
Also, small clean-up for type consistency in the WS part.
2021-07-05 03:26:38 +03:00
Maxim Prokhorov
526a5dd239 webui: always initialize checkbox with the unique id
even when the cfg object does not list it, like with scheduler button
trying to fix #2459
2021-07-04 22:55:48 +03:00
Maxim Prokhorov
32b864c563 rpn: apply mqtt variables before running rules
since some of them are allowed to yeild(), don't change things while it is already running
2021-07-04 22:55:48 +03:00
Maxim Prokhorov
68436f1e72 pio: update platform_latest
Build with Core 3.0.1 release and update the git toolchain to match the upstream
2021-06-29 23:25:24 +03:00
Max Prokhorov
e6b6a69157 mqtt: do not compose will topic twice
fix #2457
2021-06-27 19:26:14 +03:00
Maxim Prokhorov
44298d4077 terminal: +OK instead of just OK
Amends 7ea73554
2021-06-23 20:30:38 +03:00
Maxim Prokhorov
33032f0ebe mdns: no need to track services when starting the server 2021-06-23 20:29:32 +03:00
Maxim Prokhorov
06fa5b1c6d mqtt: refactoring & mdns autoconnect tweaks
- generic mdns query function so we don't forget about the removeQuery()
- full handle mdns logic in the mqtt module, check for running mdns
instance and periodically poll for _mqtt._tcp service
- autoconnect only when MQTT is enabled *and* there is no server
- use mqtt::settings and mqtt::build namespaces for settings
- some refactoring for topic <-> setting application
- prefer const String& to const char* in topic generation
2021-06-23 20:12:28 +03:00
Maxim Prokhorov
19f3214578 i2c: amend 2be8d10601 and at least make brzo buildable 2021-06-23 00:42:32 +03:00