From e942ee451d19ffc18db189f1edf9bd07bb45293a Mon Sep 17 00:00:00 2001 From: tomoaki Date: Tue, 31 Jul 2018 06:57:13 +0900 Subject: [PATCH] BugFix of #126 and the content of the conf file matched with the sample program Signed-off-by: tomoaki --- .../GatewayTester/samples/ClientPub/mainPub.cpp | 6 +++--- .../samples/ClientPubQoS-1/mainPubQoS-1.cpp | 2 +- .../GatewayTester/samples/ClientSub/mainSub.cpp | 6 +++--- MQTTSNGateway/GatewayTester/samples/mainTest.cpp | 2 +- MQTTSNGateway/predefinedTopic.conf | 11 ++++++++++- MQTTSNGateway/qos-1clients.conf | 7 +++++-- MQTTSNGateway/src/MQTTSNGWClient.cpp | 3 +-- MQTTSNGateway/src/MQTTSNGWClient.h | 1 - MQTTSNGateway/src/MQTTSNGWClientProxy.cpp | 6 +++++- 9 files changed, 29 insertions(+), 15 deletions(-) diff --git a/MQTTSNGateway/GatewayTester/samples/ClientPub/mainPub.cpp b/MQTTSNGateway/GatewayTester/samples/ClientPub/mainPub.cpp index 816dba7..c9a571c 100644 --- a/MQTTSNGateway/GatewayTester/samples/ClientPub/mainPub.cpp +++ b/MQTTSNGateway/GatewayTester/samples/ClientPub/mainPub.cpp @@ -52,10 +52,10 @@ extern LScreen* theScreen; * UDP Configuration (theNetcon) *------------------------------------------------------*/ UDPCONF = { - "GatewayTestPubClient", // ClientId + "ClientPUB", // ClientId {225,1,1,1}, // Multicast group IP 1883, // Multicast group Port - 20001, // Local PortNo + 20010, // Local PortNo }; /*------------------------------------------------------ @@ -159,7 +159,7 @@ TASK_LIST = {// e.g. TASK( task, executing duration in second), *------------------------------------------------------*/ void setup(void) { - + SetForwarderMode(false); } diff --git a/MQTTSNGateway/GatewayTester/samples/ClientPubQoS-1/mainPubQoS-1.cpp b/MQTTSNGateway/GatewayTester/samples/ClientPubQoS-1/mainPubQoS-1.cpp index 8b72f53..34151ed 100644 --- a/MQTTSNGateway/GatewayTester/samples/ClientPubQoS-1/mainPubQoS-1.cpp +++ b/MQTTSNGateway/GatewayTester/samples/ClientPubQoS-1/mainPubQoS-1.cpp @@ -52,7 +52,7 @@ extern LScreen* theScreen; * UDP Configuration (theNetcon) *------------------------------------------------------*/ UDPCONF = { - "GatewayTestPubClient", // ClientId + "QoS-1_Client01", // ClientId {225,1,1,1}, // Multicast group IP 1883, // Multicast group Port 20001, // Local PortNo diff --git a/MQTTSNGateway/GatewayTester/samples/ClientSub/mainSub.cpp b/MQTTSNGateway/GatewayTester/samples/ClientSub/mainSub.cpp index 585c8ec..9bf8c1b 100644 --- a/MQTTSNGateway/GatewayTester/samples/ClientSub/mainSub.cpp +++ b/MQTTSNGateway/GatewayTester/samples/ClientSub/mainSub.cpp @@ -52,10 +52,10 @@ extern LScreen* theScreen; * UDP Configuration (theNetcon) *------------------------------------------------------*/ UDPCONF = { - "ty4twGatewaySubClient", // ClientId + "ClientSUB", // ClientId {225,1,1,1}, // Multicast group IP 1883, // Multicast group Port - 20002, // Local PortNo + 20011, // Local PortNo }; /*------------------------------------------------------ @@ -199,7 +199,7 @@ TASK_LIST = {// e.g. TASK( task, executing duration in second), *------------------------------------------------------*/ void setup(void) { - + SetForwarderMode(false); } diff --git a/MQTTSNGateway/GatewayTester/samples/mainTest.cpp b/MQTTSNGateway/GatewayTester/samples/mainTest.cpp index 6075ced..06aa565 100644 --- a/MQTTSNGateway/GatewayTester/samples/mainTest.cpp +++ b/MQTTSNGateway/GatewayTester/samples/mainTest.cpp @@ -55,7 +55,7 @@ UDPCONF = { "GatewayTestClient", // ClientId {225,1,1,1}, // Multicast group IP 1883, // Multicast group Port - 20001, // Local PortNo + 20020, // Local PortNo }; /*------------------------------------------------------ diff --git a/MQTTSNGateway/predefinedTopic.conf b/MQTTSNGateway/predefinedTopic.conf index 2ad779a..eec33f4 100644 --- a/MQTTSNGateway/predefinedTopic.conf +++ b/MQTTSNGateway/predefinedTopic.conf @@ -35,4 +35,13 @@ ClientProxy, ty4tw/proxy/predefTopic3, 3 GatewayTestClient,ty4tw/predefinedTopic1, 1 GatewayTestClient,ty4tw/predefinedTopic2, 2 -GatewayTestClient,ty4tw/predefinedTopic3, 3 \ No newline at end of file +GatewayTestClient,ty4tw/predefinedTopic3, 3 + +ClientPUB,ty4tw/predefinedTopic1, 1 +ClientPUB,ty4tw/predefinedTopic2, 2 +ClientPUB,ty4tw/predefinedTopic3, 3 + +ClientSUB,ty4tw/predefinedTopic1, 1 +ClientSUB,ty4tw/predefinedTopic2, 2 +ClientSUB,ty4tw/predefinedTopic3, 3 + diff --git a/MQTTSNGateway/qos-1clients.conf b/MQTTSNGateway/qos-1clients.conf index e21832a..58ed914 100644 --- a/MQTTSNGateway/qos-1clients.conf +++ b/MQTTSNGateway/qos-1clients.conf @@ -23,5 +23,8 @@ # # -QoS-1_Client,172.16.1.7:12002 - +QoS-1_Client01,172.16.1.11:20001 +QoS-1_Clien02t,172.16.1.11:20002 +QoS-1_Client03,172.16.1.11:20003 +QoS-1_Client04,172.16.1.11:20004 +QoS-1_Client05,172.16.1.11:20005 diff --git a/MQTTSNGateway/src/MQTTSNGWClient.cpp b/MQTTSNGateway/src/MQTTSNGWClient.cpp index 124ad58..deda727 100644 --- a/MQTTSNGateway/src/MQTTSNGWClient.cpp +++ b/MQTTSNGateway/src/MQTTSNGWClient.cpp @@ -402,7 +402,6 @@ Client::Client(bool secure) _connAck = 0; _waitWillMsgFlg = false; _sessionStatus = false; - _otaClient = 0; _prevClient = 0; _nextClient = 0; _clientSleepPacketQue.setMaxSize(MAX_SAVED_PUBLISH); @@ -570,7 +569,7 @@ void Client::setSessionStatus(bool status) bool Client::erasable(void) { - return _sessionStatus || !_hasPredefTopic; + return _sessionStatus && !_hasPredefTopic && _forwarder == 0; } void Client::updateStatus(MQTTSNPacket* packet) diff --git a/MQTTSNGateway/src/MQTTSNGWClient.h b/MQTTSNGateway/src/MQTTSNGWClient.h index ff67365..c4757e7 100644 --- a/MQTTSNGateway/src/MQTTSNGWClient.h +++ b/MQTTSNGateway/src/MQTTSNGWClient.h @@ -363,7 +363,6 @@ private: Client* _nextClient; Client* _prevClient; - Client* _otaClient; }; /*===================================== diff --git a/MQTTSNGateway/src/MQTTSNGWClientProxy.cpp b/MQTTSNGateway/src/MQTTSNGWClientProxy.cpp index aaf350e..cf430f0 100644 --- a/MQTTSNGateway/src/MQTTSNGWClientProxy.cpp +++ b/MQTTSNGateway/src/MQTTSNGWClientProxy.cpp @@ -227,7 +227,7 @@ void ClientProxy::resetPingTimer(void) void ClientProxy::send(MQTTSNPacket* packet) { - if ( packet->getType() == MQTTSN_CONNACK || packet->getType() == MQTTSN_PINGRESP ) + if ( packet->getType() == MQTTSN_CONNACK ) { resetPingTimer(); sendStoredPublish(); @@ -236,6 +236,10 @@ void ClientProxy::send(MQTTSNPacket* packet) { resetPingTimer(); } + else if ( packet->getType() == MQTTSN_DISCONNECT ) + { + // blank + } } void ClientProxy::sendStoredPublish(void)