Bluetooth: samples/mesh_demo: Fix tune generation with sharp notes

The parsing of strings with sharp notes (e.g. "100C#") was incorrectly
implemented. Now it should be correct. Additional benefit is that this
should fix Coverity CID 173632.

Jira: ZEP-2467

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2017-08-08 10:15:04 +03:00 committed by Johan Hedberg
parent f80b2ac865
commit 51252bdea4

View file

@ -179,7 +179,6 @@ void board_play_tune(const char *str)
{
while (*str) {
u32_t period, duration = 0;
bool sharp;
while (*str && !isdigit(*str)) {
str++;
@ -195,12 +194,14 @@ void board_play_tune(const char *str)
break;
}
if (str[0] && str[1] == '#') {
sharp = true;
if (str[1] == '#') {
period = get_period(*str, true);
str += 2;
} else {
period = get_period(*str, false);
str++;
}
period = get_period(*str, sharp);
if (period) {
pwm_pin_set_usec(pwm, BUZZER_PIN, period, period / 2);
}