diff --git a/extra_script.py b/extra_script.py index 8a50062..03ec16b 100644 --- a/extra_script.py +++ b/extra_script.py @@ -136,13 +136,27 @@ def generateCfg(inFile,outFile,addDirs=[]): data+=' GwConfigInterface *configs[%d]={\n'%(l) first=True for item in config: + name=item.get('name') + if name is None: + continue if not first: data+=',\n' first=False secret="false"; if item.get('type') == 'password': - secret="true" - data+=" new GwConfigInterface(%s,\"%s\",%s)"%(item.get('name'),item.get('default'),secret) + secret="true" + data+=" #undef __CFGHIDDEN\n" + data+=" #ifdef CFGHIDE_%s\n"%(name) + data+=" #define __CFGHIDDEN true\n" + data+=" #else\n" + data+=" #define __CFGHIDDEN false\n" + data+=" #endif\n" + data+=" #ifdef CFGDEFAULT_%s\n"%(name) + data+=" new GwConfigInterface(%s,CFGDEFAULT_%s,%s,__CFGHIDDEN)\n"%(name,name,secret) + data+=" #else\n" + data+=" new GwConfigInterface(%s,\"%s\",%s,__CFGHIDDEN)\n"%(name,item.get('default'),secret) + data+=" #endif\n" + data+='};\n' data+='};\n' writeFileIfChanged(outFile,data) diff --git a/lib/config/GWConfig.cpp b/lib/config/GWConfig.cpp index cdbfdbe..15ecc43 100644 --- a/lib/config/GWConfig.cpp +++ b/lib/config/GWConfig.cpp @@ -159,6 +159,24 @@ void GwConfigHandler::toHex(unsigned long v, char *buffer, size_t bsize) buffer[2 * i] = 0; } +std::vector GwConfigHandler::getHidden() const{ + std::vector rt; + rt.reserve(numHidden()); + for (int i=0L;iisHidden()){ + rt.push_back(configs[i]->getName()); + }; + } + return rt; +} +int GwConfigHandler::numHidden() const{ + int rt=0; + for (int i=0L;iisHidden()) rt++; + } + return rt; +} + void GwNmeaFilter::handleToken(String token, int index){ switch(index){ case 0: diff --git a/lib/config/GWConfig.h b/lib/config/GWConfig.h index 4d0b105..f6e1db2 100644 --- a/lib/config/GWConfig.h +++ b/lib/config/GWConfig.h @@ -4,8 +4,10 @@ #include #include "GwLog.h" #include "GwConfigItem.h" +#include "GwHardware.h" #include "GwConfigDefinitions.h" #include +#include class GwConfigHandler: public GwConfigDefinitions{ @@ -28,6 +30,8 @@ class GwConfigHandler: public GwConfigDefinitions{ int getInt(const String name,int defaultv=0) const; GwConfigInterface * getConfigItem(const String name, bool dummy=false) const; bool checkPass(String hash); + std::vector getHidden() const; + int numHidden() const; /** * change the value of a config item * will become a noop after stopChanges has been called diff --git a/lib/config/GwConfigItem.h b/lib/config/GwConfigItem.h index adfb161..a6d66cd 100644 --- a/lib/config/GwConfigItem.h +++ b/lib/config/GwConfigItem.h @@ -10,12 +10,14 @@ class GwConfigInterface{ const char * initialValue; String value; bool secret=false; + bool hidden=false; public: - GwConfigInterface(const String &name, const char * initialValue, bool secret=false){ + GwConfigInterface(const String &name, const char * initialValue, bool secret=false, bool hidden=false){ this->name=name; this->initialValue=initialValue; this->value=initialValue; this->secret=secret; + this->hidden=hidden; } virtual String asString() const{ return value; @@ -41,6 +43,9 @@ class GwConfigInterface{ String getDefault() const { return initialValue; } + bool isHidden() const { + return hidden; + } friend class GwConfigHandler; }; diff --git a/lib/hardware/GwHardware.h b/lib/hardware/GwHardware.h index 9e00ce8..5b7e278 100644 --- a/lib/hardware/GwHardware.h +++ b/lib/hardware/GwHardware.h @@ -144,6 +144,14 @@ #define GWSERIAL_TYPE GWSERIAL_TYPE_UNI #endif +//M5 GPS (Atomic GPS Base) +#ifdef M5_GPS_KIT + #define GWSERIAL_RX BOARD_LEFT1 + #define GWSERIAL_TYPE GWSERIAL_TYPE_RX + #define CFGGDEFAULT_serialBaud "9600" + #define CFGHIDE_serialBaud +#endif + //below we define the final device config based on the above //boards and peripherals //this allows us to easily also set them from outside diff --git a/src/main.cpp b/src/main.cpp index 09b1b03..0bc11ba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -430,11 +430,16 @@ class CapabilitiesRequest : public GwRequestMessage{ protected: virtual void processRequest(){ int numCapabilities=userCodeHandler.getCapabilities()->size(); - GwJsonDocument json(JSON_OBJECT_SIZE(numCapabilities*3+8)); + int numHidden=config.numHidden(); + GwJsonDocument json(JSON_OBJECT_SIZE(numCapabilities*3+numHidden*2+8)); for (auto it=userCodeHandler.getCapabilities()->begin(); it != userCodeHandler.getCapabilities()->end();it++){ json[it->first]=it->second; } + std::vector hiddenCfg=config.getHidden(); + for (auto it=hiddenCfg.begin();it != hiddenCfg.end();it++){ + json["HIDE"+*it]=true; + } json["serialmode"]=channels.getMode(SERIAL1_CHANNEL_ID); json["serial2mode"]=channels.getMode(SERIAL2_CHANNEL_ID); #ifdef GWBUTTON_PIN