From 6a8cdba186de0850118c2c4200c2b5be272d1393 Mon Sep 17 00:00:00 2001 From: tomoaki Date: Sun, 23 Feb 2020 17:35:06 +0900 Subject: [PATCH] Bugfix can't read PredefinedTopicList file Signed-off-by: tomoaki --- MQTTSNGateway/src/MQTTSNGWClientList.cpp | 15 ++------------- MQTTSNGateway/src/MQTTSNGateway.cpp | 14 ++++++++++++++ MQTTSNGateway/src/MQTTSNGateway.h | 5 ++++- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/MQTTSNGateway/src/MQTTSNGWClientList.cpp b/MQTTSNGateway/src/MQTTSNGWClientList.cpp index 80bdfa6..dfe32a2 100644 --- a/MQTTSNGateway/src/MQTTSNGWClientList.cpp +++ b/MQTTSNGateway/src/MQTTSNGWClientList.cpp @@ -65,12 +65,8 @@ void ClientList::initialize(bool aggregate) 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."); } @@ -78,14 +74,7 @@ void ClientList::setClientList(int type) void ClientList::setPredefinedTopics(bool aggrecate) { - char param[MQTTSNGW_PARAM_MAX]; - - string fileName; - - theGateway->getParam("PredefinedTopicList", param); - fileName = string(param); - - readPredefinedList(fileName.c_str(), aggrecate); + readPredefinedList(theGateway->getPredefinedTopicFileName(), aggrecate); } /** diff --git a/MQTTSNGateway/src/MQTTSNGateway.cpp b/MQTTSNGateway/src/MQTTSNGateway.cpp index 1d074fb..bb86d14 100644 --- a/MQTTSNGateway/src/MQTTSNGateway.cpp +++ b/MQTTSNGateway/src/MQTTSNGateway.cpp @@ -86,6 +86,10 @@ Gateway::~Gateway() { free(_params.clientListName); } + if ( _params.predefinedTopicFileName ) + { + free( _params.predefinedTopicFileName); + } if ( _params.configName ) { free(_params.configName); @@ -116,6 +120,16 @@ int Gateway::getParam(const char* parameter, char* 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) { char param[MQTTSNGW_PARAM_MAX]; diff --git a/MQTTSNGateway/src/MQTTSNGateway.h b/MQTTSNGateway/src/MQTTSNGateway.h index d9b4857..0053219 100644 --- a/MQTTSNGateway/src/MQTTSNGateway.h +++ b/MQTTSNGateway/src/MQTTSNGateway.h @@ -160,8 +160,8 @@ public: char* rootCApath {nullptr}; char* rootCAfile {nullptr}; char* certKey {nullptr}; - char* privateKey {nullptr}; char* predefinedTopicFileName {nullptr}; + char* privateKey {nullptr}; char* qosMinusClientListName {nullptr}; bool clientAuthentication {false}; }; @@ -190,6 +190,9 @@ public: GatewayParams* getGWParams(void); AdapterManager* getAdapterManager(void); int getParam(const char* parameter, char* value); + char* getClientListFileName(void); + char* getPredefinedTopicFileName(void); + bool hasSecureConnection(void); Topics* getTopics(void);