mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-13 07:26:52 +01:00
@@ -133,7 +133,7 @@
|
||||
|
||||
<sourceEntries>
|
||||
|
||||
<entry excluding="MQTTSNGateway/src/linux/udp|MQTTSNGateway/GatewayTester|MQTTSNClient|MQTTSNGateway/src/MQTTSNGWProxy.cpp|MQTTSNPacket/test|MQTTSNPacket/samples|MQTTSNGateway/src/mainLogmonitor.cpp|MQTTSNGateway/src/linux/xbee|MQTTSNGateway/GatewayTester/samples/mainTemplate.cpp|MQTTSNGateway/src/tests|MQTTSNGateway/src/tests/mainTestProcessFramework.cpp|ClientPubQoS-1|MQTTSNGateway/GatewayTester/samples/mainOTA.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry excluding="MQTTSNGateway/src/linux/udp6|MQTTSNGateway/GatewayTester|MQTTSNClient|MQTTSNGateway/src/MQTTSNGWProxy.cpp|MQTTSNPacket/test|MQTTSNPacket/samples|MQTTSNGateway/src/mainLogmonitor.cpp|MQTTSNGateway/src/linux/xbee|MQTTSNGateway/GatewayTester/samples/mainTemplate.cpp|MQTTSNGateway/src/tests|MQTTSNGateway/src/tests/mainTestProcessFramework.cpp|ClientPubQoS-1|MQTTSNGateway/GatewayTester/samples/mainOTA.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
|
||||
</sourceEntries>
|
||||
|
||||
@@ -277,7 +277,7 @@
|
||||
|
||||
<entry excluding="MQTTSNGWProxy.cpp|mainLogmonitor.cpp|tests|tests/mainTestProcessFramework.cpp|linux|linux/udp" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="MQTTSNGateway/src"/>
|
||||
|
||||
<entry excluding="udp|xbee" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="MQTTSNGateway/src/linux"/>
|
||||
<entry excluding="udp6|xbee" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="MQTTSNGateway/src/linux"/>
|
||||
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="MQTTSNPacket/src"/>
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ void publishTopic1(void)
|
||||
PUBLISH(topic1,(uint8_t*)payload, strlen(payload), QoS0);
|
||||
}
|
||||
|
||||
void subscribeTopic2(void)
|
||||
void subscribeTopic10(void)
|
||||
{
|
||||
SUBSCRIBE(10, on_Topic02, QoS1);
|
||||
}
|
||||
@@ -190,7 +190,7 @@ TEST_LIST = {// e.g. TEST( Label, Test),
|
||||
TEST("Step0:Subscribe predef topic1", subscribePredefTopic1),
|
||||
TEST("Step1:Publish topic1", publishTopic1),
|
||||
TEST("Step2:Publish topic2", publishTopic2),
|
||||
TEST("Step3:Subscribe topic2", subscribeTopic2),
|
||||
TEST("Step3:Subscribe PreDefined topic10. ID is not defined.", subscribeTopic10),
|
||||
TEST("Step4:Publish topic2", publishTopic2),
|
||||
TEST("Step5:Unsubscribe topic2", unsubscribe),
|
||||
TEST("Step6:Publish topic2", publishTopic2),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#**************************************************************************
|
||||
# Copyright (c) 2016-2018, Tomoaki Yamaguchi
|
||||
# Copyright (c) 2016-2019, Tomoaki Yamaguchi
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
@@ -14,7 +14,7 @@
|
||||
# config file of MQTT-SN Gateway
|
||||
#
|
||||
|
||||
BrokerName=iot.eclipse.org
|
||||
BrokerName=mqtt.eclipse.org
|
||||
BrokerPortNo=1883
|
||||
BrokerSecurePortNo=8883
|
||||
|
||||
@@ -50,6 +50,12 @@ GatewayPortNo=10000
|
||||
MulticastIP=225.1.1.1
|
||||
MulticastPortNo=1883
|
||||
|
||||
# UDP6
|
||||
GatewayUDP6Bind=FFFF:FFFE::1
|
||||
GatewayUDP6Port=10000
|
||||
GatewayUDP6Broadcast=FF02::1
|
||||
GatewayUDP6If=wpan0
|
||||
|
||||
# XBee
|
||||
Baudrate=38400
|
||||
SerialDevice=/dev/ttyUSB0
|
||||
|
||||
@@ -416,9 +416,9 @@ Client* ClientList::createClient(SensorNetAddress* addr, MQTTSNString* clientId,
|
||||
|
||||
Client* ClientList::createPredefinedTopic( MQTTSNString* clientId, string topicName, uint16_t topicId, bool aggregate)
|
||||
{
|
||||
if ( clientId->cstring == common_topic )
|
||||
if ( strcmp(clientId->cstring, common_topic) == 0 )
|
||||
{
|
||||
_gateway->getTopics()->add((const char*)topicName.c_str(), topicId);
|
||||
theGateway->getTopics()->add((const char*)topicName.c_str(), topicId);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "MQTTSNGateway.h"
|
||||
#include "MQTTSNGWEncapsulatedPacket.h"
|
||||
#include "MQTTSNGWQoSm1Proxy.h"
|
||||
#include <errno.h>
|
||||
|
||||
using namespace MQTTSNGW;
|
||||
using namespace std;
|
||||
@@ -75,8 +76,8 @@ void ClientSendTask::run()
|
||||
|
||||
if ( rc < 0 )
|
||||
{
|
||||
WRITELOG("%s ClientSendTask can't send a packet to the client %s%s.\n",
|
||||
ERRMSG_HEADER, (client ? (const char*)client->getClientId() : UNKNOWNCL ), ERRMSG_FOOTER);
|
||||
WRITELOG("%s ClientSendTask can't send a packet to the client %s. Error=%d%s\n",
|
||||
ERRMSG_HEADER, (client ? (const char*)client->getClientId() : UNKNOWNCL ), errno, ERRMSG_FOOTER);
|
||||
}
|
||||
delete ev;
|
||||
}
|
||||
|
||||
@@ -60,17 +60,10 @@ MQTTGWPacket* MQTTSNSubscribeHandler::handleSubscribe(Client* client, MQTTSNPack
|
||||
{
|
||||
topic = client->getTopics()->getTopicById(&topicFilter);
|
||||
|
||||
|
||||
if ( topic )
|
||||
{
|
||||
topicId = topic->getTopicId();
|
||||
subscribe = new MQTTGWPacket();
|
||||
subscribe->setSUBSCRIBE((char*)topic->getTopicName()->c_str(), (uint8_t)qos, (uint16_t)msgId);
|
||||
}
|
||||
else
|
||||
if ( !topic )
|
||||
{
|
||||
topic = _gateway->getTopics()->getTopicById(&topicFilter);
|
||||
if ( !topic )
|
||||
if ( topic )
|
||||
{
|
||||
topic = client->getTopics()->add(topic->getTopicName()->c_str(), topic->getTopicId());
|
||||
}
|
||||
@@ -79,6 +72,10 @@ MQTTGWPacket* MQTTSNSubscribeHandler::handleSubscribe(Client* client, MQTTSNPack
|
||||
goto RespExit;
|
||||
}
|
||||
}
|
||||
topicId = topic->getTopicId();
|
||||
subscribe = new MQTTGWPacket();
|
||||
subscribe->setSUBSCRIBE((char*)topic->getTopicName()->c_str(), (uint8_t)qos, (uint16_t)msgId);
|
||||
|
||||
}
|
||||
else if (topicFilter.type == MQTTSN_TOPIC_TYPE_NORMAL)
|
||||
{
|
||||
@@ -148,7 +145,6 @@ MQTTGWPacket* MQTTSNSubscribeHandler::handleUnsubscribe(Client* client, MQTTSNPa
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Topic* topic = client->getTopics()->getTopicById(&topicFilter);
|
||||
|
||||
if (topicFilter.type == MQTTSN_TOPIC_TYPE_SHORT)
|
||||
{
|
||||
@@ -161,6 +157,17 @@ MQTTGWPacket* MQTTSNSubscribeHandler::handleUnsubscribe(Client* client, MQTTSNPa
|
||||
}
|
||||
else
|
||||
{
|
||||
Topic* topic = nullptr;
|
||||
|
||||
if (topicFilter.type == MQTTSN_TOPIC_TYPE_PREDEFINED)
|
||||
{
|
||||
topic = client->getTopics()->getTopicById(&topicFilter);
|
||||
}
|
||||
else
|
||||
{
|
||||
topic = client->getTopics()->getTopicByName(&topicFilter);
|
||||
}
|
||||
|
||||
if ( topic == nullptr )
|
||||
{
|
||||
MQTTSNPacket* sUnsuback = new MQTTSNPacket();
|
||||
|
||||
Reference in New Issue
Block a user