From e4ee392c279076b8e0b0ab15a79e303f5afb090a Mon Sep 17 00:00:00 2001 From: Clayton Sims Date: Thu, 22 Jun 2023 04:06:19 -0400 Subject: [PATCH] Support for ESP-NOW Wireless Remote Control (#3237) * Initial checkin for ESP-NOW remote feature * cleanup irrelevant comment * don't bring in espnow package includes when feature disabled * Formatting and removing inaccurate call mode hardcoding * Fork ESP Now code by platform (8266 v. esp32) * compiled html update * Disable ESP-NOW remote by default on ESP32 until tested * Enable ESP-NOW remote for ESP32 * Rename ESP NOW define --------- Co-authored-by: cschwinne --- wled00/cfg.cpp | 14 ++ wled00/data/settings_wifi.htm | 11 ++ wled00/fcn_declare.h | 4 + wled00/html_settings.h | 316 +++++++++++++++++----------------- wled00/ir.cpp | 6 +- wled00/presets.cpp | 9 + wled00/remote.cpp | 200 +++++++++++++++++++++ wled00/set.cpp | 8 + wled00/wled.cpp | 1 + wled00/wled.h | 15 ++ wled00/xml.cpp | 21 +++ 11 files changed, 446 insertions(+), 159 deletions(-) create mode 100644 wled00/remote.cpp diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 0bdf5032..15ef0e1f 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -443,6 +443,13 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(retainMqttMsg, if_mqtt[F("rtn")]); #endif +#ifndef WLED_DISABLE_ESPNOW + JsonObject remote = doc["remote"]; + CJSON(enable_espnow_remote, remote[F("remote_enabled")]); + getStringFromJson(linked_remote, remote[F("linked_remote")], 13); +#endif + + #ifndef WLED_DISABLE_HUESYNC JsonObject if_hue = interfaces["hue"]; CJSON(huePollingEnabled, if_hue["en"]); @@ -895,6 +902,13 @@ void serializeConfig() { if_mqtt_topics[F("group")] = mqttGroupTopic; #endif +#ifndef WLED_DISABLE_ESPNOW + JsonObject remote = doc.createNestedObject(F("remote")); + remote[F("remote_enabled")] = enable_espnow_remote; + remote[F("linked_remote")] = linked_remote; +#endif + + #ifndef WLED_DISABLE_HUESYNC JsonObject if_hue = interfaces.createNestedObject("hue"); if_hue["en"] = huePollingEnabled; diff --git a/wled00/data/settings_wifi.htm b/wled00/data/settings_wifi.htm index 1ad0be6c..1021dfd8 100644 --- a/wled00/data/settings_wifi.htm +++ b/wled00/data/settings_wifi.htm @@ -193,6 +193,17 @@ Disable WiFi sleep:
Can help with connectivity issues.
Do not enable if WiFi is working correctly, increases power consumption.
+ +
+

Wireless Remote

+ Listen for events over ESP-NOW
+ Keep disabled if not using a remote, increases power consumption.
+ + Enable Remote:
+ Hardware MAC:
+ Last Seen: None
+
+

Ethernet Type