Skip to content

Commit

Permalink
Merge pull request letscontrolit#4831 from TD-er/bugfix/RTTTL_arg_par…
Browse files Browse the repository at this point in the history
…sing

[RTTTL] Fix stupid mix-up of old/new command argument parsing
  • Loading branch information
TD-er authored Sep 28, 2023
2 parents 982df8d + 068d0ec commit d125cd3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/src/Commands/GPIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,<gpio><rtttl string>
// 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,<gpio>,<rtttl string>
melody = parseStringToEndKeepCase(Line, 3);
// First assume 'new' syntax: rtttl,<gpio>,<rtttl string>
// 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,<gpio><rtttl string>
melody = parseStringToEndKeepCase(Line, 2);
}
melody.replace('-', '#');
melody.replace('_', '#');
Expand Down

0 comments on commit d125cd3

Please sign in to comment.