4365 Commits

Author SHA1 Message Date
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
Maxim Prokhorov
c056c54db4 sns: amend ADS1X115 I2CPort to use common gain & datarate settings
ref. #1033, this could be used as-is with a generic analog sensor code
by substituting ::analogRead(channel) with I2CPort::read(channel)
2021-06-23 00:42:16 +03:00
Maxim Prokhorov
bacff3102d pio: make sure "y" for shared libs still works
And update other options to support y, yes and true
2021-06-20 17:41:46 +03:00
Maxim Prokhorov
c34acf1748 ci: latest Core and split webui test into a separate job 2021-06-20 17:25:20 +03:00
Maxim Prokhorov
f18f128e4b pio: consistent shared libs location
Do not install libraries globally in CI, use the specified PIO .ini option.
Similar to the other package installers, prefer package cache to the actual library storage contents.
2021-06-19 12:52:10 +03:00
Maxim Prokhorov
1600fcc133 settings: hide kv_store from the public header
More concise foreach, generic template code also no longer expands down to ::_read_kv
Also helps with needless inlining happening with recent gcc versions
2021-06-18 17:27:49 +03:00
Maxim Prokhorov
c51b6e99f1 curtain: add missing flags & fix typos when module is active 2021-06-18 12:31:18 +03:00
Maxim Prokhorov
a9220ec2b2 pio: pin lib_deps versions and owners 2021-06-18 12:12:09 +03:00
Maxim Prokhorov
310b063eb1 sns: basesensor methods do not qualify for constexpr
Quoting gcc-4.8.2

> espurna/sensors/BaseAnalogEmonSensor.h:19:7: note: 'BaseAnalogEmonSensor' is not literal because:
> class BaseAnalogEmonSensor : public BaseEmonSensor {
>       ^
> espurna/sensors/BaseAnalogEmonSensor.h:19:7: note:   'BaseAnalogEmonSensor' has a non-trivial destructor
2021-06-18 12:12:09 +03:00
Maxim Prokhorov
1a36efb8f2 sns: rename generic pwr keys with a typed prefix
Ratio, Mains are specific to a magnitude type.
Make keys use global index, and do a (temporary) WebUI workaround
to use 0 index instead of the global key.
Migrate to the new settings keys.

Local magnitude-specific index is still in play, pending changes in the rest of sensors
(ADE7953, PZEM004T{,V30}, ...) to remove it completely.

Local sensor index could still be useful though, to help out with some settings
in the future as we don't really enforce magnitude type uniqueness within sensors.
2021-06-18 12:12:09 +03:00
Maxim Prokhorov
23da0b74d4 pio: use swserial from the Core 2021-06-18 12:12:09 +03:00
Maxim Prokhorov
c136678a4f sns: tweak analogRead frequency
Locks the value to the latest one for a bit. Another option would be
to yield() / delay(...) to spend the time somewhere else.
2021-06-18 12:12:09 +03:00
Maxim Prokhorov
b19905a306 sns: EmonSensor fixes and refactoring
- fix dubious pinMode(0, INPUT), which does not work with esp8266 as A0 != GPIO0
- I2C sensor locking code can now exist separately from the base class
- EmonSensor -> BaseAnalogEmonSensor
- move AnalogEmon-specific methods from BaseEmonSensor to BaseAnalogEmonSensor
- clean-up protected member usage across the base, force the class to implement certain methods instead
- more code reuse between sensor versions
- drop local magnitude indexes & shared arrays of values in favour of separate
class instances, refactor ADS1X115 to the new model
- (techically) allow ADS1X115 code to be used with more than one i2c address
by having a shared port instance
2021-06-18 12:12:09 +03:00
Maxim Prokhorov
ff11e5814f sns: A0 is not GPIO0 2021-06-18 12:12:09 +03:00
Maxim Prokhorov
6ba5f95e87 sns: typo when getting local index for Nth magnitude 2021-06-18 12:12:08 +03:00
Maxim Prokhorov
a1e7941fa6 scripts: some more Core version fixes
Remove 2.3.0 code for ldscripts
Update
2021-06-18 12:12:08 +03:00
Maxim Prokhorov
939f4afa0a sns: ICACHE_RAM_ATTR -> IRAM_ATTR
3.0.0 now uses macro from esp-idf
avoid deprecation warnings for the source here
(still shows it with the libs though, when building without -w)
2021-06-17 16:41:38 +03:00
Maxim Prokhorov
d36127963c scripts: comments 2021-06-09 12:45:14 +03:00
Maxim Prokhorov
0422d61c69 nofuss: bump to the forked 0.4.0
Make sure it does not have global flags related to the HTTPCLIENT
Use generic ::updateFS with updater, and also support generic "fs" key
in the server response
2021-06-09 12:42:32 +03:00