From 47446397faa638eb217f4e2d4de2cd5ba63e1f3e Mon Sep 17 00:00:00 2001 From: Peter Akers Date: Sun, 11 Aug 2024 08:48:37 +1000 Subject: [PATCH] Fix for the original 'steal' code --- README.md | 10 ++++++++-- library.properties | 2 +- src/WiThrottleProtocol.cpp | 9 ++++----- src/WiThrottleProtocol.h | 1 + 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4fbf883..4e40b8a 100644 --- a/README.md +++ b/README.md @@ -85,13 +85,19 @@ see https://flash62au.github.io/WiThrottleProtocol/library.html ## Todos - Update the examples + - Add multithrottle examples + - Finish the in-code documentation - Write Tests - - More complete WiThrottle protocol parsing - Better Parser (Antlr?) + ## Usage Notes + + - When I added the multithrottle support I have done my best to maintain backwards compatibility. As a result if you use the non-multithrottle versions of any of the methods, the *default* multithrottle is now defunct 'T' rather than the now standard '0'.
That means that you ***cannot mix*** multithrottle and non-multithrottle versions of the methods in your code. -License ---- +---- + +# License Creative Commons [CC-BY-SA 4.0][CCBYSA] ![CCBYSA](https://i.creativecommons.org/l/by-sa/4.0/88x31.png) diff --git a/library.properties b/library.properties index a8cc3af..6b71f61 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=WiThrottleProtocol -version=1.1.21 +version=1.1.22 author=Peter Akers , David Zuhn , Luca Dentella maintainer=Peter Akers sentence=JMRI WiThrottle Protocol implementation for ESP32 diff --git a/src/WiThrottleProtocol.cpp b/src/WiThrottleProtocol.cpp index 4393ba3..adb56b9 100644 --- a/src/WiThrottleProtocol.cpp +++ b/src/WiThrottleProtocol.cpp @@ -1168,11 +1168,10 @@ bool WiThrottleProtocol::stealLocomotive(String address) { bool WiThrottleProtocol::stealLocomotive(char multiThrottle, String address) { if (logLevel>0) { console->print("WiT:: stealLocomotive(): "); console->print(multiThrottle); console->print(" : "); console->println(address); } - bool ok = false; - - if (releaseLocomotive(multiThrottle, address)) { - ok = addLocomotive(multiThrottle, address); - } + bool ok = true; + // MTSxxxx<;>xxxxx + String cmd = "M" + String(multiThrottle) + "S" +address + PROPERTY_SEPARATOR + address; + sendDelayedCommand(cmd); return ok; } diff --git a/src/WiThrottleProtocol.h b/src/WiThrottleProtocol.h index 68a8444..2648482 100644 --- a/src/WiThrottleProtocol.h +++ b/src/WiThrottleProtocol.h @@ -29,6 +29,7 @@ /* Version information: +1.1.22 - Fix for the original 'steal' code 1.1.21 - Add support for setting the Speed Step mode 28/128/14 etc. setSpeedSteps(), getSpeedSteps() 1.1.20 - Corrected the EStop for 'all' throttles 1.1.18/19- Added support for logLevel. Assigned levels to every log message