From c0becf9f7896dc4a82edd1251db89af45ef0ebcc Mon Sep 17 00:00:00 2001 From: Sen Morgan Date: Wed, 7 Feb 2024 00:06:56 +0100 Subject: [PATCH] feat: emergency stop and power off during OTA --- CommandStation-EX.ino | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CommandStation-EX.ino b/CommandStation-EX.ino index ea917b1..020fc58 100644 --- a/CommandStation-EX.ino +++ b/CommandStation-EX.ino @@ -163,6 +163,16 @@ void loop() // Initialise OTA if not already done if (!otaInitialised) { ArduinoOTA.setHostname(WIFI_HOSTNAME); + // Prevent locos from moving during OTA + ArduinoOTA.onStart([]() { + // Emergency stop all locos + DCC::setThrottle(0,1,1); + // Disable tracks power + TrackManager::setMainPower(POWERMODE::OFF); + TrackManager::setProgPower(POWERMODE::OFF); + // Broadcast power status + CommandDistributor::broadcastPower(); + }); // Set OTA password if defined #ifdef OTA_AUTH ArduinoOTA.setPassword(OTA_AUTH);