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

intermediate: simplify task interfaces

This commit is contained in:
andreas
2024-11-16 17:43:21 +01:00
parent 85e1a0e5f0
commit 56518d9309
6 changed files with 31 additions and 105 deletions

View File

@@ -16,6 +16,7 @@
#define _GWSENSORS_H
#include "GwApi.h"
#include "GwLog.h"
#include <memory>
class SensorBase{
public:
using BusType=enum{
@@ -23,6 +24,7 @@ class SensorBase{
SPI=1,
UNKNOWN=-1
};
using Ptr=std::shared_ptr<SensorBase>;
BusType busType=BusType::UNKNOWN;
int busId=0;
int iid=99; //N2K instanceId
@@ -59,14 +61,14 @@ class SensorTemplate : public SensorBase{
};
class SensorList : public std::vector<SensorBase*>{
class SensorList : public std::vector<SensorBase::Ptr>{
public:
void add(GwApi *api, SensorBase *sensor){
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);
}
using std::vector<SensorBase*>::vector;
using std::vector<SensorBase::Ptr>::vector;
};