Updated the other classes accordingly to the changes made to the dictionary class
This commit is contained in:
parent
45fc1e468b
commit
1f7f198582
@ -1,6 +1,6 @@
|
|||||||
#include "CFGFileParser.h"
|
#include "CFGFileParser.h"
|
||||||
|
|
||||||
CFGFileParser::CFGFileParser(SDCardManager &sdCardManager, const char *file):AbstractParser(file), _state(INIT), _type(PARAMETER), _sdCardManager(sdCardManager)
|
CFGFileParser::CFGFileParser(SDCardManager &sdCardManager, const char *file):AbstractParser(file), _state(INIT), _type(PARAMETER), _quotedParameter(false), _quotedValue(false), _sdCardManager(sdCardManager)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -10,7 +10,7 @@ void *CFGFileParser::parseFile()
|
|||||||
//Here is the logic for the file parser
|
//Here is the logic for the file parser
|
||||||
File file;
|
File file;
|
||||||
|
|
||||||
CFGDictionary *dictioRef = new CFGDictionary;
|
CFGDictionary<CFGParameterValue> *dictioRef = new CFGDictionary<CFGParameterValue>;
|
||||||
char readChar(0), *parsedParameter(NULL), *parsedValue(NULL);
|
char readChar(0), *parsedParameter(NULL), *parsedValue(NULL);
|
||||||
|
|
||||||
file = _sdCardManager.open(_resource);
|
file = _sdCardManager.open(_resource);
|
||||||
@ -23,6 +23,7 @@ void *CFGFileParser::parseFile()
|
|||||||
while(file.available())
|
while(file.available())
|
||||||
{
|
{
|
||||||
readChar = (char)file.read();
|
readChar = (char)file.read();
|
||||||
|
|
||||||
//Do work
|
//Do work
|
||||||
switch(_state)
|
switch(_state)
|
||||||
{
|
{
|
||||||
@ -77,10 +78,11 @@ void *CFGFileParser::parseFile()
|
|||||||
if(parsedParameter != NULL)
|
if(parsedParameter != NULL)
|
||||||
{
|
{
|
||||||
//printf("%s --> %s\n", parsedParameter, parsedValue);
|
//printf("%s --> %s\n", parsedParameter, parsedValue);
|
||||||
dictioRef->addParameter(parsedParameter, parsedValue == NULL ? "":parsedValue);
|
dictioRef->addParameter(parsedParameter, new CFGParameterValue(parsedParameter, parsedValue == NULL ? "":parsedValue, _quotedParameter, _quotedValue));
|
||||||
free(parsedParameter);free(parsedValue);
|
free(parsedParameter);free(parsedValue);
|
||||||
parsedParameter = NULL;
|
parsedParameter = NULL;parsedValue = NULL;
|
||||||
parsedValue = NULL;
|
_quotedParameter = false;_quotedValue = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(readChar == ' ') _state = PARAM_SECTION;
|
else if(readChar == ' ') _state = PARAM_SECTION;
|
||||||
@ -104,7 +106,14 @@ void *CFGFileParser::parseFile()
|
|||||||
_state = ERROR;
|
_state = ERROR;
|
||||||
break;
|
break;
|
||||||
case OPENING_QUOTE:
|
case OPENING_QUOTE:
|
||||||
if(readChar == '\'') _state = PARAM_SECTION;
|
if(readChar == '\'')
|
||||||
|
{
|
||||||
|
_state = PARAM_SECTION;
|
||||||
|
if(_type == PARAMETER)
|
||||||
|
_quotedParameter = true;
|
||||||
|
else
|
||||||
|
_quotedValue = true;
|
||||||
|
}
|
||||||
else if((readChar >= 65 && readChar <= 90) || (readChar >= 97 && readChar <= 122) || readChar == ' ' || readChar == '_' || (readChar >= 48 && readChar <= 57))
|
else if((readChar >= 65 && readChar <= 90) || (readChar >= 97 && readChar <= 122) || readChar == ' ' || readChar == '_' || (readChar >= 48 && readChar <= 57))
|
||||||
{
|
{
|
||||||
//printf("%c",readChar);
|
//printf("%c",readChar);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "CFGDictionary.h"
|
#include "CFGDictionary.h"
|
||||||
#include "SDCardManager.h"
|
#include "SDCardManager.h"
|
||||||
#include "definition.h"
|
#include "definition.h"
|
||||||
|
#include "CFGParameterValue.h"
|
||||||
|
|
||||||
class CFGFileParser : public AbstractParser
|
class CFGFileParser : public AbstractParser
|
||||||
{
|
{
|
||||||
@ -21,6 +22,8 @@ private:
|
|||||||
enum Type {PARAMETER, VALUE};
|
enum Type {PARAMETER, VALUE};
|
||||||
State _state;
|
State _state;
|
||||||
Type _type;
|
Type _type;
|
||||||
|
boolean _quotedParameter;
|
||||||
|
boolean _quotedValue;
|
||||||
SDCardManager &_sdCardManager;
|
SDCardManager &_sdCardManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,22 +15,22 @@ ConnectivityManager::ConnectivityManager(SDCardManager *sdCardManager) : _error(
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
CFGFileParser cfgFileParser(*sdCardManager, AP_CFG_FILE);
|
CFGFileParser cfgFileParser(*sdCardManager, AP_CFG_FILE);
|
||||||
CFGDictionary *cfgDictionary = (CFGDictionary *) cfgFileParser.parseFile();
|
CFGDictionary<CFGParameterValue> *cfgDictionary = (CFGDictionary<CFGParameterValue> *) cfgFileParser.parseFile();
|
||||||
if(cfgDictionary == NULL)
|
if(cfgDictionary == NULL)
|
||||||
{
|
{
|
||||||
if(!softAP("ESP8266SwissArmyBoard", NULL, 1, false, 8))_error &= AP_SETUP_ERR;
|
if(!softAP("ESP8266SwissArmyBoard", NULL, 1, false, 8))_error &= AP_SETUP_ERR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!softAP((*cfgDictionary)("SSID").stringValue(), strcmp((*cfgDictionary)("PASSWORD").stringValue(),"") == 0 ? NULL:(*cfgDictionary)("PASSWORD").stringValue(), (*cfgDictionary)("CHANNEL").intValue(), (*cfgDictionary)("SSID_HIDDEN").booleanValue(), (*cfgDictionary)("AP_MAX_CONNECTION").intValue()))_error &= AP_SETUP_ERR;
|
if(!softAP((*cfgDictionary)("SSID").getValue().stringValue(), strcmp((*cfgDictionary)("PASSWORD").getValue().stringValue(),"") == 0 ? NULL:(*cfgDictionary)("PASSWORD").getValue().stringValue(), (*cfgDictionary)("CHANNEL").getValue().intValue(), (*cfgDictionary)("SSID_HIDDEN").getValue().booleanValue(), (*cfgDictionary)("AP_MAX_CONNECTION").getValue().intValue()))_error &= AP_SETUP_ERR;
|
||||||
delete cfgDictionary;
|
delete cfgDictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFGFileParser cfgFileParserSTA(*sdCardManager, STA_CFG_FILE);
|
CFGFileParser cfgFileParserSTA(*sdCardManager, STA_CFG_FILE);
|
||||||
cfgDictionary = (CFGDictionary *) cfgFileParserSTA.parseFile();
|
cfgDictionary = (CFGDictionary<CFGParameterValue> *) cfgFileParserSTA.parseFile();
|
||||||
if(cfgDictionary != NULL)
|
if(cfgDictionary != NULL)
|
||||||
{
|
{
|
||||||
if(!begin((*cfgDictionary)("SSID").stringValue(), (*cfgDictionary)("PASSWORD").stringValue()))_error &= AP_SETUP_ERR;
|
if(!begin((*cfgDictionary)("SSID").getValue().stringValue(), (*cfgDictionary)("PASSWORD").getValue().stringValue()))_error &= AP_SETUP_ERR;
|
||||||
delete cfgDictionary;
|
delete cfgDictionary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "SAB.h"
|
#include "SAB.h"
|
||||||
#include "views.h"
|
#include "views.h"
|
||||||
#include "CFGDictionary.h"
|
#include "CFGDictionary.h"
|
||||||
|
#include "CFGParameterValue.h"
|
||||||
|
|
||||||
SAB sab;
|
SAB sab;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user