diff --git a/main/espnowfunctions.cpp b/main/espnowfunctions.cpp index c8310c2..083d2a4 100644 --- a/main/espnowfunctions.cpp +++ b/main/espnowfunctions.cpp @@ -105,6 +105,12 @@ extern "C" void onReceive(const uint8_t *mac_addr, const uint8_t *data, int len) ESP_LOGI(TAG, "ID: %s - Token: %s", stringSettings.esp_now_door_id.c_str(), stringSettings.esp_now_door_token.c_str()); + if (settings.repeatESPNow) + { + ESP_LOGI(TAG, "Repeat ESP-NOW message \"%s\"", message.c_str()); + send_espnow_message(message); + } + // Parse the message (msg format: "msg_type:msg_value:msg_token") via find and npos const size_t pos = message.find(":"); if (pos == std::string::npos) { @@ -240,7 +246,7 @@ void handle() digitalWrite(PIN_RELAY, LOW); } - if (!last_send_ms || espchrono::ago(*last_send_ms) > 1s) { + if (!last_send_ms || espchrono::ago(*last_send_ms) > 1s && !settings.repeatESPNow) { const auto message = fmt::format("T:{}", espchrono::utc_clock::now().time_since_epoch().count()); send_espnow_message(message); last_send_ms = espchrono::millis_clock::now(); diff --git a/main/presets.h b/main/presets.h index 4a2318c..5de9568 100644 --- a/main/presets.h +++ b/main/presets.h @@ -352,6 +352,7 @@ constexpr Settings defaultSettings { #ifdef FEATURE_ESPNOW .espnow = defaultEspNowSettings, #endif + .repeatESPNow = false, }; StringSettings makeDefaultStringSettings(); diff --git a/main/settings.h b/main/settings.h index 7949a3c..8205ddb 100644 --- a/main/settings.h +++ b/main/settings.h @@ -233,6 +233,7 @@ struct Settings bool syncBlink; } espnow; #endif + bool repeatESPNow; template void executeForEveryCommonSetting(T &&callable); @@ -379,6 +380,7 @@ void Settings::executeForEveryCommonSetting(T &&callable) callable("espnowSyncBl", espnow.syncBlink); #endif #endif + callable("repeat", repeatESPNow); } template