From 1169d091b69fb8aafaa8f1cb555a6a7705b8d016 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Beat=20K=C3=BCng?= <beat-kueng@gmx.net>
Date: Wed, 8 May 2019 11:24:35 +0200
Subject: [PATCH] ToneAlarm: ignore topic updates with 0 timestamp

Commander initially publishes a tune_control topic set to 0, which can
interfere with the startup tone (as happening on the Pixhawk Cube).
---
 src/drivers/tone_alarm/ToneAlarm.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/drivers/tone_alarm/ToneAlarm.cpp b/src/drivers/tone_alarm/ToneAlarm.cpp
index 3a8094f75a..7acacf1845 100644
--- a/src/drivers/tone_alarm/ToneAlarm.cpp
+++ b/src/drivers/tone_alarm/ToneAlarm.cpp
@@ -139,7 +139,10 @@ void ToneAlarm::orb_update()
 
 	if (updated) {
 		orb_copy(ORB_ID(tune_control), _tune_control_sub, &_tune);
-		_play_tone = _tunes.set_control(_tune) == 0;
+
+		if (_tune.timestamp > 0) {
+			_play_tone = _tunes.set_control(_tune) == 0;
+		}
 	}
 }
 
-- 
GitLab