AP_Common: AP_FWVersion: create singleton

This commit is contained in:
Peter Barker 2018-06-13 20:28:40 +10:00 committed by Francisco Ferreira
parent e9a07bdd6f
commit 6ba1678c5e
2 changed files with 27 additions and 2 deletions

View File

@ -0,0 +1,10 @@
#include "AP_FWVersion.h"
namespace AP {
const AP_FWVersion &fwversion()
{
return AP_FWVersion::get_fwverz();
}
}

View File

@ -3,13 +3,28 @@
#include <stdint.h> #include <stdint.h>
#include <GCS_MAVLink/GCS_MAVLink.h> #include <GCS_MAVLink/GCS_MAVLink.h>
typedef struct { class AP_FWVersion {
public:
uint8_t major; uint8_t major;
uint8_t minor; uint8_t minor;
uint8_t patch; uint8_t patch;
FIRMWARE_VERSION_TYPE fw_type; FIRMWARE_VERSION_TYPE fw_type;
const char *fw_string; const char *fw_string;
const char *fw_hash_str; const char *fw_hash_str;
const char *middleware_name;
const char *middleware_hash_str; const char *middleware_hash_str;
const char *os_name;
const char *os_hash_str; 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();
};