diff --git a/src/src/Commands/GPIO.cpp b/src/src/Commands/GPIO.cpp index 17c5319704..8efb853a45 100644 --- a/src/src/Commands/GPIO.cpp +++ b/src/src/Commands/GPIO.cpp @@ -385,13 +385,17 @@ const __FlashStringHelper * Command_GPIO_RTTTL(struct EventStruct *event, const // play a tune via a RTTTL string, look at https://www.letscontrolit.com/forum/viewtopic.php?f=4&t=343&hilit=speaker&start=10 for // more info. - // First assume 'old' syntax: rtttl, - // No comma between the GPIO argument and the melody - String melody = parseStringToEndKeepCase(Line, 2); - if (melody.indexOf(':') == -1) { - // Apparently this is now using the 'new' (correct) syntax: - // rtttl,, - melody = parseStringToEndKeepCase(Line, 3); + // First assume 'new' syntax: rtttl,, + // Difference between 'old' and 'new': + // Comma between the GPIO argument and the melody + String melody = parseStringToEndKeepCase(Line, 3); + + // The semicolon may appear several times in a RTTTL melody + // Thus only check if it is part of the 1st argument. + if (parseString(Line, 2).indexOf(':') != -1) { + // Apparently this is still using the 'old' (incorrect) syntax: + // rtttl, + melody = parseStringToEndKeepCase(Line, 2); } melody.replace('-', '#'); melody.replace('_', '#');