AP_Notify: support extended PLAY_TUNE message

This commit is contained in:
Jonathan Challinger 2018-07-24 19:24:53 -07:00 committed by Andrew Tridgell
parent cba85eee7b
commit f4fc9249f7
1 changed files with 15 additions and 0 deletions

View File

@ -17,6 +17,7 @@
*/
#include <AP_HAL/AP_HAL.h>
#include <AP_Math/AP_Math.h>
#ifdef HAL_PWM_ALARM
#include "ToneAlarm.h"
@ -392,6 +393,20 @@ void ToneAlarm::handle_play_tune(mavlink_message_t *msg)
mavlink_msg_play_tune_decode(msg, &packet);
if (_sem) {
_sem->take(HAL_SEMAPHORE_BLOCK_FOREVER);
_mml_player.stop();
strncpy(_tone_buf, packet.tune, MIN(sizeof(packet.tune), sizeof(_tone_buf)-1));
_tone_buf[sizeof(_tone_buf)-1] = 0;
uint8_t len = strlen(_tone_buf);
uint8_t len2 = strnlen(packet.tune2, sizeof(packet.tune2));
len2 = MIN((sizeof(_tone_buf)-1)-len, len2);
strncpy(_tone_buf+len, packet.tune2, len2);
_tone_buf[sizeof(_tone_buf)-1] = 0;
_sem->give();
}
play_string(packet.tune);
}