mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-13 05:53:06 +01:00
introduce channel config abstraction
This commit is contained in:
@@ -140,18 +140,21 @@ void GwNmeaFilter::parseFilter(){
|
||||
// "0:1:RMB,RMC"
|
||||
// 0: AIS off, 1:whitelist, list of sentences
|
||||
if (isReady) return;
|
||||
if (config.isEmpty()){
|
||||
isReady=true;
|
||||
return;
|
||||
}
|
||||
int found=0;
|
||||
int last=0;
|
||||
int index=0;
|
||||
String data=config->asString();
|
||||
while ((found = data.indexOf(':',last)) >= 0){
|
||||
String tok=data.substring(last,found);
|
||||
while ((found = config.indexOf(':',last)) >= 0){
|
||||
String tok=config.substring(last,found);
|
||||
handleToken(tok,index);
|
||||
last=found+1;
|
||||
index++;
|
||||
}
|
||||
if (last < data.length()){
|
||||
String tok=data.substring(last);
|
||||
if (last < config.length()){
|
||||
String tok=config.substring(last);
|
||||
handleToken(tok,index);
|
||||
}
|
||||
isReady=true;
|
||||
|
||||
@@ -46,7 +46,7 @@ class GwConfigInterface{
|
||||
|
||||
class GwNmeaFilter{
|
||||
private:
|
||||
GwConfigInterface *config=NULL;
|
||||
String config;
|
||||
bool isReady=false;
|
||||
bool ais=true;
|
||||
bool blacklist=true;
|
||||
@@ -54,7 +54,7 @@ class GwNmeaFilter{
|
||||
void handleToken(String token, int index);
|
||||
void parseFilter();
|
||||
public:
|
||||
GwNmeaFilter(GwConfigInterface *config){
|
||||
GwNmeaFilter(String config){
|
||||
this->config=config;
|
||||
isReady=false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user