From 6ba1678c5ea8d84d0cf9f1820e6b3dc57d08194b Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 13 Jun 2018 20:28:40 +1000 Subject: [PATCH] AP_Common: AP_FWVersion: create singleton --- libraries/AP_Common/AP_FWVersion.cpp | 10 ++++++++++ libraries/AP_Common/AP_FWVersion.h | 19 +++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 libraries/AP_Common/AP_FWVersion.cpp diff --git a/libraries/AP_Common/AP_FWVersion.cpp b/libraries/AP_Common/AP_FWVersion.cpp new file mode 100644 index 0000000000..82ce117718 --- /dev/null +++ b/libraries/AP_Common/AP_FWVersion.cpp @@ -0,0 +1,10 @@ +#include "AP_FWVersion.h" + +namespace AP { + +const AP_FWVersion &fwversion() +{ + return AP_FWVersion::get_fwverz(); +} + +} diff --git a/libraries/AP_Common/AP_FWVersion.h b/libraries/AP_Common/AP_FWVersion.h index 7ec8905831..f191a57592 100644 --- a/libraries/AP_Common/AP_FWVersion.h +++ b/libraries/AP_Common/AP_FWVersion.h @@ -3,13 +3,28 @@ #include #include -typedef struct { +class AP_FWVersion { + +public: + uint8_t major; uint8_t minor; uint8_t patch; FIRMWARE_VERSION_TYPE fw_type; const char *fw_string; const char *fw_hash_str; + const char *middleware_name; const char *middleware_hash_str; + const char *os_name; const char *os_hash_str; -} AP_FWVersion; + + static const AP_FWVersion &get_fwverz() { return fwver; } + +private: + + static const AP_FWVersion fwver; +}; + +namespace AP { + const AP_FWVersion &fwversion(); +};