add support for up to 10 ESPNow remotes (#4654)

* add support for up to 10 ESPNow remotes

* removed debug line

* changed todo comment

* fixed some issues, shortened html/java code

- reverting name to `linked_remote`
- ESPNow remote list is now hidden if unchecked
- shortened java script function names and variables to save flash
- removed now obsolete settings in xml.cpp
- correct checking of valid hex string for remote list in java script

* fixed indentation, using emplace_back instead of push_back, using JsonVariant, replaced buttons with +/-

* shortened java code

* updated java code, fixed bug

- element is now properly removed
- `+` button is hidden if list is full
- user needs to remove a remote, then reload the page to add it (workaround for edge case that needs more code to handle otherwise)

* add limit

* clearer usage description
This commit is contained in:
Damian Schneider
2025-05-19 20:34:27 +02:00
committed by GitHub
parent d9ad4ec743
commit 66ad27ad3a
7 changed files with 108 additions and 28 deletions

View File

@@ -959,14 +959,22 @@ void espNowReceiveCB(uint8_t* address, uint8_t* data, uint8_t len, signed int rs
// usermods hook can override processing
if (UsermodManager::onEspNowMessage(address, data, len)) return;
// handle WiZ Mote data
if (data[0] == 0x91 || data[0] == 0x81 || data[0] == 0x80) {
handleWiZdata(data, len);
bool knownRemote = false;
for (const auto& mac : linked_remotes) {
if (strlen(mac.data()) == 12 && strcmp(last_signal_src, mac.data()) == 0) {
knownRemote = true;
break;
}
}
if (!knownRemote) {
DEBUG_PRINT(F("ESP Now Message Received from Unlinked Sender: "));
DEBUG_PRINTLN(last_signal_src);
return;
}
if (strlen(linked_remote) == 12 && strcmp(last_signal_src, linked_remote) != 0) {
DEBUG_PRINTLN(F("ESP-NOW unpaired remote sender."));
// handle WiZ Mote data
if (data[0] == 0x91 || data[0] == 0x81 || data[0] == 0x80) {
handleWiZdata(data, len);
return;
}