Bugfix can't read PredefinedTopicList file

Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
tomoaki
2020-02-23 17:35:06 +09:00
parent f57d391b16
commit 6a8cdba186
3 changed files with 20 additions and 14 deletions

View File

@@ -65,12 +65,8 @@ void ClientList::initialize(bool aggregate)
void ClientList::setClientList(int type) void ClientList::setClientList(int type)
{ {
char param[MQTTSNGW_PARAM_MAX];
string fileName;
theGateway->getParam("ClientsList", param);
fileName = string(param);
if (!createList(fileName.c_str(), type)) if (!createList(theGateway->getClientListFileName(), type))
{ {
throw Exception("ClientList::initialize(): No client list defined by the configuration."); throw Exception("ClientList::initialize(): No client list defined by the configuration.");
} }
@@ -78,14 +74,7 @@ void ClientList::setClientList(int type)
void ClientList::setPredefinedTopics(bool aggrecate) void ClientList::setPredefinedTopics(bool aggrecate)
{ {
char param[MQTTSNGW_PARAM_MAX]; readPredefinedList(theGateway->getPredefinedTopicFileName(), aggrecate);
string fileName;
theGateway->getParam("PredefinedTopicList", param);
fileName = string(param);
readPredefinedList(fileName.c_str(), aggrecate);
} }
/** /**

View File

@@ -86,6 +86,10 @@ Gateway::~Gateway()
{ {
free(_params.clientListName); free(_params.clientListName);
} }
if ( _params.predefinedTopicFileName )
{
free( _params.predefinedTopicFileName);
}
if ( _params.configName ) if ( _params.configName )
{ {
free(_params.configName); free(_params.configName);
@@ -116,6 +120,16 @@ int Gateway::getParam(const char* parameter, char* value)
return MultiTaskProcess::getParam(parameter, value); return MultiTaskProcess::getParam(parameter, value);
} }
char* Gateway::getClientListFileName(void)
{
return _params.clientListName;
}
char* Gateway::getPredefinedTopicFileName(void)
{
return _params.predefinedTopicFileName;
}
void Gateway::initialize(int argc, char** argv) void Gateway::initialize(int argc, char** argv)
{ {
char param[MQTTSNGW_PARAM_MAX]; char param[MQTTSNGW_PARAM_MAX];

View File

@@ -160,8 +160,8 @@ public:
char* rootCApath {nullptr}; char* rootCApath {nullptr};
char* rootCAfile {nullptr}; char* rootCAfile {nullptr};
char* certKey {nullptr}; char* certKey {nullptr};
char* privateKey {nullptr};
char* predefinedTopicFileName {nullptr}; char* predefinedTopicFileName {nullptr};
char* privateKey {nullptr};
char* qosMinusClientListName {nullptr}; char* qosMinusClientListName {nullptr};
bool clientAuthentication {false}; bool clientAuthentication {false};
}; };
@@ -190,6 +190,9 @@ public:
GatewayParams* getGWParams(void); GatewayParams* getGWParams(void);
AdapterManager* getAdapterManager(void); AdapterManager* getAdapterManager(void);
int getParam(const char* parameter, char* value); int getParam(const char* parameter, char* value);
char* getClientListFileName(void);
char* getPredefinedTopicFileName(void);
bool hasSecureConnection(void); bool hasSecureConnection(void);
Topics* getTopics(void); Topics* getTopics(void);