Simplify device class files

This commit is contained in:
fvanroie 2021-05-29 15:15:57 +02:00
parent 0350f86c35
commit b7a2103899
2 changed files with 22 additions and 39 deletions

View File

@ -1,35 +0,0 @@
/* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#include "device.h"
#define Q(x) #x
#define QUOTE(x) Q(x)
namespace dev {
const char* BaseDevice::get_model()
{
#ifdef HASP_MODEL
return QUOTE(HASP_MODEL);
#else
return PIOENV;
#endif
}
const char* BaseDevice::get_version()
{
return (QUOTE(HASP_VER_MAJ) "." QUOTE(HASP_VER_MIN) "." QUOTE(HASP_VER_REV));
}
const char* BaseDevice::get_hostname()
{
return _hostname; //.c_str();
}
void BaseDevice::set_hostname(const char* hostname)
{
strncpy(_hostname, hostname, STR_LEN_HOSTNAME);
}
} // namespace dev

View File

@ -21,6 +21,8 @@
#include "ArduinoJson.h"
#define STR_LEN_HOSTNAME 64
#define Q(x) #x
#define QUOTE(x) Q(x)
namespace dev {
@ -31,8 +33,14 @@ class BaseDevice {
virtual void reboot()
{}
const char* get_hostname();
void set_hostname(const char*);
const char* get_hostname()
{
return _hostname; //.c_str();
}
void set_hostname(const char* hostname)
{
strncpy(_hostname, hostname, STR_LEN_HOSTNAME);
}
const char* get_core_version()
{
return "";
@ -41,8 +49,18 @@ class BaseDevice {
{
return "";
}
virtual const char* get_model();
virtual const char* get_version();
const char* get_model()
{
#ifdef HASP_MODEL
return QUOTE(HASP_MODEL);
#else
return PIOENV;
#endif
}
const char* get_version()
{
return (QUOTE(HASP_VER_MAJ) "." QUOTE(HASP_VER_MIN) "." QUOTE(HASP_VER_REV));
}
virtual const char* get_hardware_id()
{
return "";