diff --git a/libraries/AP_Notify/AP_Notify.cpp b/libraries/AP_Notify/AP_Notify.cpp index 5fdbfd0689..49a455b5f7 100644 --- a/libraries/AP_Notify/AP_Notify.cpp +++ b/libraries/AP_Notify/AP_Notify.cpp @@ -82,3 +82,11 @@ void AP_Notify::update(void) //reset the events memset(&AP_Notify::events, 0, sizeof(AP_Notify::events)); } + +// handle a LED_CONTROL message +void AP_Notify::handle_led_control(mavlink_message_t *msg) +{ + for (int i = 0; i < CONFIG_NOTIFY_DEVICES_COUNT; i++) { + _devices[i]->handle_led_control(msg); + } +} diff --git a/libraries/AP_Notify/AP_Notify.h b/libraries/AP_Notify/AP_Notify.h index 4511c5d3d3..e3867658f2 100644 --- a/libraries/AP_Notify/AP_Notify.h +++ b/libraries/AP_Notify/AP_Notify.h @@ -19,6 +19,7 @@ #define __AP_NOTIFY_H__ #include +#include #include #include #include @@ -96,6 +97,9 @@ public: /// update - allow updates of leds that cannot be updated during a timed interrupt void update(void); + // handle a LED_CONTROL message + static void handle_led_control(mavlink_message_t* msg); + private: static NotifyDevice* _devices[CONFIG_NOTIFY_DEVICES_COUNT]; }; diff --git a/libraries/AP_Notify/NotifyDevice.h b/libraries/AP_Notify/NotifyDevice.h index 0264755c0c..9230d57704 100644 --- a/libraries/AP_Notify/NotifyDevice.h +++ b/libraries/AP_Notify/NotifyDevice.h @@ -1,6 +1,9 @@ #ifndef __NOTIFYDEVICE_H__ #define __NOTIFYDEVICE_H__ +#include +#include + class NotifyDevice { public: virtual ~NotifyDevice() {} @@ -9,6 +12,8 @@ public: // update - updates device according to timed_updated. Should be // called at 50Hz virtual void update() = 0; + // handle a LED_CONTROL message, by default device ignore message + virtual void handle_led_control(mavlink_message_t *msg) {} }; #endif