AP_Notify: pass mavlink_message_t by const reference

This commit is contained in:
Pierre Kancir 2019-04-30 12:22:48 +02:00 committed by Peter Barker
parent f3e40b4906
commit ad4563df2d
9 changed files with 16 additions and 16 deletions

View File

@ -331,7 +331,7 @@ void AP_Notify::update(void)
} }
// handle a LED_CONTROL message // handle a LED_CONTROL message
void AP_Notify::handle_led_control(mavlink_message_t *msg) void AP_Notify::handle_led_control(const mavlink_message_t &msg)
{ {
for (uint8_t i = 0; i < _num_devices; i++) { for (uint8_t i = 0; i < _num_devices; i++) {
if (_devices[i] != nullptr) { if (_devices[i] != nullptr) {
@ -341,7 +341,7 @@ void AP_Notify::handle_led_control(mavlink_message_t *msg)
} }
// handle a PLAY_TUNE message // handle a PLAY_TUNE message
void AP_Notify::handle_play_tune(mavlink_message_t *msg) void AP_Notify::handle_play_tune(const mavlink_message_t &msg)
{ {
for (uint8_t i = 0; i < _num_devices; i++) { for (uint8_t i = 0; i < _num_devices; i++) {
if (_devices[i] != nullptr) { if (_devices[i] != nullptr) {

View File

@ -135,10 +135,10 @@ public:
void update(void); void update(void);
// handle a LED_CONTROL message // handle a LED_CONTROL message
static void handle_led_control(mavlink_message_t* msg); static void handle_led_control(const mavlink_message_t &msg);
// handle a PLAY_TUNE message // handle a PLAY_TUNE message
static void handle_play_tune(mavlink_message_t* msg); static void handle_play_tune(const mavlink_message_t &msg);
// play a tune string // play a tune string
static void play_tune(const char *tune); static void play_tune(const char *tune);

View File

@ -15,10 +15,10 @@ public:
virtual void update() = 0; virtual void update() = 0;
// handle a LED_CONTROL message, by default device ignore message // handle a LED_CONTROL message, by default device ignore message
virtual void handle_led_control(mavlink_message_t *msg) {} virtual void handle_led_control(const mavlink_message_t &msg) {}
// handle a PLAY_TUNE message, by default device ignore message // handle a PLAY_TUNE message, by default device ignore message
virtual void handle_play_tune(mavlink_message_t *msg) {} virtual void handle_play_tune(const mavlink_message_t &msg) {}
// play a MML tune // play a MML tune
virtual void play_tune(const char *tune) {} virtual void play_tune(const char *tune) {}

View File

@ -544,11 +544,11 @@ void OreoLED_I2C::send_sync(void)
// Handle an LED_CONTROL mavlink message // Handle an LED_CONTROL mavlink message
void OreoLED_I2C::handle_led_control(mavlink_message_t *msg) void OreoLED_I2C::handle_led_control(const mavlink_message_t &msg)
{ {
// decode mavlink message // decode mavlink message
mavlink_led_control_t packet; mavlink_led_control_t packet;
mavlink_msg_led_control_decode(msg, &packet); mavlink_msg_led_control_decode(&msg, &packet);
// exit immediately if instance is invalid // exit immediately if instance is invalid
if (packet.instance >= OREOLED_NUM_LEDS && packet.instance != OREOLED_INSTANCE_ALL) { if (packet.instance >= OREOLED_NUM_LEDS && packet.instance != OREOLED_INSTANCE_ALL) {

View File

@ -38,7 +38,7 @@ public:
void update() override; void update() override;
// handle a LED_CONTROL message, by default device ignore message // handle a LED_CONTROL message, by default device ignore message
void handle_led_control(mavlink_message_t *msg) override; void handle_led_control(const mavlink_message_t &msg) override;
private: private:
enum oreoled_pattern { enum oreoled_pattern {

View File

@ -202,7 +202,7 @@ void RGBLed::update()
/* /*
handle LED control, only used when LED_OVERRIDE=1 handle LED control, only used when LED_OVERRIDE=1
*/ */
void RGBLed::handle_led_control(mavlink_message_t *msg) void RGBLed::handle_led_control(const mavlink_message_t &msg)
{ {
if (rgb_source() != mavlink) { if (rgb_source() != mavlink) {
// ignore LED_CONTROL commands if not in LED_OVERRIDE mode // ignore LED_CONTROL commands if not in LED_OVERRIDE mode
@ -211,7 +211,7 @@ void RGBLed::handle_led_control(mavlink_message_t *msg)
// decode mavlink message // decode mavlink message
mavlink_led_control_t packet; mavlink_led_control_t packet;
mavlink_msg_led_control_decode(msg, &packet); mavlink_msg_led_control_decode(&msg, &packet);
_led_override.start_ms = AP_HAL::millis(); _led_override.start_ms = AP_HAL::millis();

View File

@ -37,7 +37,7 @@ public:
virtual void update() override; virtual void update() override;
// handle LED control, only used when LED_OVERRIDE=1 // handle LED control, only used when LED_OVERRIDE=1
virtual void handle_led_control(mavlink_message_t *msg) override; virtual void handle_led_control(const mavlink_message_t &msg) override;
protected: protected:
// methods implemented in hardware specific classes // methods implemented in hardware specific classes

View File

@ -402,12 +402,12 @@ void AP_ToneAlarm::update()
/* /*
* handle a PLAY_TUNE message * handle a PLAY_TUNE message
*/ */
void AP_ToneAlarm::handle_play_tune(mavlink_message_t *msg) void AP_ToneAlarm::handle_play_tune(const mavlink_message_t &msg)
{ {
// decode mavlink message // decode mavlink message
mavlink_play_tune_t packet; mavlink_play_tune_t packet;
mavlink_msg_play_tune_decode(msg, &packet); mavlink_msg_play_tune_decode(&msg, &packet);
WITH_SEMAPHORE(_sem); WITH_SEMAPHORE(_sem);

View File

@ -33,7 +33,7 @@ public:
void update() override; void update() override;
// handle a PLAY_TUNE message // handle a PLAY_TUNE message
void handle_play_tune(mavlink_message_t *msg) override; void handle_play_tune(const mavlink_message_t &msg) override;
// play_tune - play tone specified by the provided string of notes // play_tune - play tone specified by the provided string of notes
void play_tune(const char *tune) override; void play_tune(const char *tune) override;