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

unify sensor parameter names

This commit is contained in:
andreas
2023-10-31 15:32:08 +01:00
parent f606b78929
commit 9d3390b086
3 changed files with 169 additions and 116 deletions

View File

@@ -41,6 +41,52 @@ class GwConfigHandler: public GwConfigDefinitions{
unsigned long getSaltBase(){return saltBase;}
~GwConfigHandler();
bool userChangesAllowed(){return allowChanges;}
template <typename T>
bool getValue(T & target, const String &name, int defaultv=0){
GwConfigInterface *i=getConfigItem(name);
if (!i){
target=(T)defaultv;
return false;
}
target=(T)(i->asInt());
return true;
}
bool getValue(int &target, const String &name, int defaultv=0){
GwConfigInterface *i=getConfigItem(name);
if (!i){
target=defaultv;
return false;
}
target=i->asInt();
return true;
}
bool getValue(long &target, const String &name, long defaultv=0){
GwConfigInterface *i=getConfigItem(name);
if (!i){
target=defaultv;
return false;
}
target=i->asInt();
return true;
}
bool getValue(bool &target, const String name, bool defaultv=false){
GwConfigInterface *i=getConfigItem(name);
if (!i){
target=defaultv;
return false;
}
target=i->asBoolean();
return true;
}
bool getValue(String &target, const String name, const String &defaultv=""){
GwConfigInterface *i=getConfigItem(name);
if (!i){
target=defaultv;
return false;
}
target=i->asString();
return true;
}
private:
unsigned long saltBase=0;
void populateConfigs(GwConfigInterface **);