From ad4563df2d72a6b69e79bba053221a137e17b148 Mon Sep 17 00:00:00 2001 From: Pierre Kancir Date: Tue, 30 Apr 2019 12:22:48 +0200 Subject: [PATCH] AP_Notify: pass mavlink_message_t by const reference --- libraries/AP_Notify/AP_Notify.cpp | 4 ++-- libraries/AP_Notify/AP_Notify.h | 4 ++-- libraries/AP_Notify/NotifyDevice.h | 6 +++--- libraries/AP_Notify/OreoLED_I2C.cpp | 4 ++-- libraries/AP_Notify/OreoLED_I2C.h | 2 +- libraries/AP_Notify/RGBLed.cpp | 4 ++-- libraries/AP_Notify/RGBLed.h | 2 +- libraries/AP_Notify/ToneAlarm.cpp | 4 ++-- libraries/AP_Notify/ToneAlarm.h | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libraries/AP_Notify/AP_Notify.cpp b/libraries/AP_Notify/AP_Notify.cpp index d101a32509..231ca80660 100644 --- a/libraries/AP_Notify/AP_Notify.cpp +++ b/libraries/AP_Notify/AP_Notify.cpp @@ -331,7 +331,7 @@ void AP_Notify::update(void) } // 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++) { if (_devices[i] != nullptr) { @@ -341,7 +341,7 @@ void AP_Notify::handle_led_control(mavlink_message_t *msg) } // 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++) { if (_devices[i] != nullptr) { diff --git a/libraries/AP_Notify/AP_Notify.h b/libraries/AP_Notify/AP_Notify.h index 6c7ab725d6..93bf77ff24 100644 --- a/libraries/AP_Notify/AP_Notify.h +++ b/libraries/AP_Notify/AP_Notify.h @@ -135,10 +135,10 @@ public: void update(void); // 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 - static void handle_play_tune(mavlink_message_t* msg); + static void handle_play_tune(const mavlink_message_t &msg); // play a tune string static void play_tune(const char *tune); diff --git a/libraries/AP_Notify/NotifyDevice.h b/libraries/AP_Notify/NotifyDevice.h index 05dfd91688..090ac759f9 100644 --- a/libraries/AP_Notify/NotifyDevice.h +++ b/libraries/AP_Notify/NotifyDevice.h @@ -15,14 +15,14 @@ public: virtual void update() = 0; // 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 - virtual void handle_play_tune(mavlink_message_t *msg) {} + virtual void handle_play_tune(const mavlink_message_t &msg) {} // play a MML tune virtual void play_tune(const char *tune) {} - + // this pointer is used to read the parameters relative to devices const AP_Notify *pNotify; }; diff --git a/libraries/AP_Notify/OreoLED_I2C.cpp b/libraries/AP_Notify/OreoLED_I2C.cpp index c50428c371..af8622112c 100644 --- a/libraries/AP_Notify/OreoLED_I2C.cpp +++ b/libraries/AP_Notify/OreoLED_I2C.cpp @@ -544,11 +544,11 @@ void OreoLED_I2C::send_sync(void) // 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 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 if (packet.instance >= OREOLED_NUM_LEDS && packet.instance != OREOLED_INSTANCE_ALL) { diff --git a/libraries/AP_Notify/OreoLED_I2C.h b/libraries/AP_Notify/OreoLED_I2C.h index b97f64e20d..7a5ce60000 100644 --- a/libraries/AP_Notify/OreoLED_I2C.h +++ b/libraries/AP_Notify/OreoLED_I2C.h @@ -38,7 +38,7 @@ public: void update() override; // 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: enum oreoled_pattern { diff --git a/libraries/AP_Notify/RGBLed.cpp b/libraries/AP_Notify/RGBLed.cpp index cc1c2a170d..c0db86c674 100644 --- a/libraries/AP_Notify/RGBLed.cpp +++ b/libraries/AP_Notify/RGBLed.cpp @@ -202,7 +202,7 @@ void RGBLed::update() /* 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) { // 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 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(); diff --git a/libraries/AP_Notify/RGBLed.h b/libraries/AP_Notify/RGBLed.h index 66418cf9a4..e803a7cfa0 100644 --- a/libraries/AP_Notify/RGBLed.h +++ b/libraries/AP_Notify/RGBLed.h @@ -37,7 +37,7 @@ public: virtual void update() override; // 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: // methods implemented in hardware specific classes diff --git a/libraries/AP_Notify/ToneAlarm.cpp b/libraries/AP_Notify/ToneAlarm.cpp index b735789d3e..0211d13e3e 100644 --- a/libraries/AP_Notify/ToneAlarm.cpp +++ b/libraries/AP_Notify/ToneAlarm.cpp @@ -402,12 +402,12 @@ void AP_ToneAlarm::update() /* * 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 mavlink_play_tune_t packet; - mavlink_msg_play_tune_decode(msg, &packet); + mavlink_msg_play_tune_decode(&msg, &packet); WITH_SEMAPHORE(_sem); diff --git a/libraries/AP_Notify/ToneAlarm.h b/libraries/AP_Notify/ToneAlarm.h index 8dcde19b74..86d52b57c4 100644 --- a/libraries/AP_Notify/ToneAlarm.h +++ b/libraries/AP_Notify/ToneAlarm.h @@ -33,7 +33,7 @@ public: void update() override; // 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 void play_tune(const char *tune) override;