From ae462989ecaf7d18694aca1e1a8227cda344031f Mon Sep 17 00:00:00 2001 From: tomoaki Date: Fri, 21 Feb 2020 11:29:37 +0900 Subject: [PATCH] BugFix ClientList file name is not shown Signed-off-by: tomoaki --- MQTTSNGateway/src/MQTTSNGWClientList.cpp | 42 ++++++------------------ MQTTSNGateway/src/MQTTSNGateway.cpp | 20 +++++++++++ 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/MQTTSNGateway/src/MQTTSNGWClientList.cpp b/MQTTSNGateway/src/MQTTSNGWClientList.cpp index 776c23e..80bdfa6 100644 --- a/MQTTSNGateway/src/MQTTSNGWClientList.cpp +++ b/MQTTSNGateway/src/MQTTSNGWClientList.cpp @@ -67,25 +67,13 @@ void ClientList::setClientList(int type) { char param[MQTTSNGW_PARAM_MAX]; string fileName; - GatewayParams* params = theGateway->getGWParams(); - if (theGateway->getParam("ClientsList", param) == 0) - { - fileName = string(param); - } - else - { - fileName = params->configDir + string(CLIENT_LIST); - } + theGateway->getParam("ClientsList", param); + fileName = string(param); if (!createList(fileName.c_str(), type)) { throw Exception("ClientList::initialize(): No client list defined by the configuration."); } - - if ( params->clientListName == nullptr ) - { - params->clientListName = strdup(fileName.c_str()); - } } void ClientList::setPredefinedTopics(bool aggrecate) @@ -93,21 +81,11 @@ void ClientList::setPredefinedTopics(bool aggrecate) char param[MQTTSNGW_PARAM_MAX]; string fileName; - GatewayParams* params = theGateway->getGWParams(); - if (theGateway->getParam("PredefinedTopicList", param) == 0) - { - fileName = string(param); - } - else - { - fileName = params->configDir + string(PREDEFINEDTOPIC_FILE); - } + theGateway->getParam("PredefinedTopicList", param); + fileName = string(param); - if ( readPredefinedList(fileName.c_str(), aggrecate) ) - { - params->predefinedTopicFileName = strdup(fileName.c_str()); - } + readPredefinedList(fileName.c_str(), aggrecate); } /** @@ -125,11 +103,11 @@ void ClientList::setPredefinedTopics(bool aggrecate) * * Ex: * #Client List - * ClientId1,11200@192.168.10.10 - * ClientID2,35000@192.168.50.200,unstableLine - * ClientID3,40000@192.168.200.50,secureConnection - * ClientID4,41000@192.168.200.51,unstableLine,secureConnection - * ClientID5,41000@192.168.200.51,unstableLine,secureConnection,QoS-1 + * ClientId1,192.168.10.10:11200 + * ClientID2,192.168.50.200:35000,unstableLine + * ClientID3,192.168.200.50:40000,secureConnection + * ClientID4,192.168.200.51:41000,unstableLine,secureConnection + * ClientID5,192.168.200.51:41000,unstableLine,secureConnection,QoS-1 */ bool ClientList::createList(const char* fileName, int type) diff --git a/MQTTSNGateway/src/MQTTSNGateway.cpp b/MQTTSNGateway/src/MQTTSNGateway.cpp index c5894ce..487e745 100644 --- a/MQTTSNGateway/src/MQTTSNGateway.cpp +++ b/MQTTSNGateway/src/MQTTSNGateway.cpp @@ -215,6 +215,26 @@ void Gateway::initialize(int argc, char** argv) } } + if (getParam("ClientsList", param) == 0) + { + _params.clientListName = strdup(param); + } + + if (getParam("PredefinedTopicList", param) == 0) + { + _params.predefinedTopicFileName = strdup(param); + } + + if ( _params.clientListName == nullptr ) + { + _params.clientListName = strdup(( _params.configDir + string(CLIENT_LIST) ).c_str()); + } + + if ( _params.predefinedTopicFileName == nullptr ) + { + _params.predefinedTopicFileName = strdup(( _params.configDir + string(PREDEFINEDTOPIC_FILE) ).c_str()); + } + /* ClientList and Adapters Initialize */ _adapterManager->initialize();