1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-15 23:13:07 +01:00

intermediate: restructure for sensors via API

This commit is contained in:
andreas
2024-11-16 20:15:09 +01:00
parent 56518d9309
commit f75f8033d1
15 changed files with 173 additions and 77 deletions

View File

@@ -14,9 +14,11 @@
*/
#ifndef _GWSENSORS_H
#define _GWSENSORS_H
#include "GwApi.h"
#include "GwLog.h"
#include <Arduino.h>
#include <memory>
#include <vector>
class GwApi;
class GwConfigHandler;
class SensorBase{
public:
using BusType=enum{
@@ -63,16 +65,13 @@ class SensorTemplate : public SensorBase{
class SensorList : public std::vector<SensorBase::Ptr>{
public:
void add(GwApi *api, SensorBase::Ptr sensor){
sensor->readConfig(api->getConfig());
api->getLogger()->logDebug(GwLog::LOG,"configured sensor %s, status %d",sensor->prefix.c_str(),(int)sensor->ok);
this->push_back(sensor);
}
void add(SensorBase::Ptr sensor);
using std::vector<SensorBase::Ptr>::vector;
};
#define CFG_GET(name,prefix) \
cfg->getValue(name, GwConfigDefinitions::prefix ## name)
#endif