mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-12 23:16:51 +01:00
@@ -182,15 +182,14 @@ void Client::clearWaitedSubTopicId(void)
|
||||
_waitedSubTopicIdMap.clear();
|
||||
}
|
||||
|
||||
void Client::setWaitedPubTopicId(uint16_t msgId, uint16_t topicId,
|
||||
MQTTSN_topicTypes type)
|
||||
void Client::setWaitedPubTopicId(uint16_t msgId, uint16_t topicId, MQTTSN_topicid* topic)
|
||||
{
|
||||
_waitedPubTopicIdMap.add(msgId, topicId, type);
|
||||
_waitedPubTopicIdMap.add(msgId, topicId, topic);
|
||||
}
|
||||
void Client::setWaitedSubTopicId(uint16_t msgId, uint16_t topicId,
|
||||
MQTTSN_topicTypes type)
|
||||
|
||||
void Client::setWaitedSubTopicId(uint16_t msgId, uint16_t topicId, MQTTSN_topicid* topic)
|
||||
{
|
||||
_waitedSubTopicIdMap.add(msgId, topicId, type);
|
||||
_waitedSubTopicIdMap.add(msgId, topicId, topic);
|
||||
}
|
||||
|
||||
bool Client::checkTimeover(void)
|
||||
|
||||
@@ -198,10 +198,8 @@ public:
|
||||
|
||||
int setClientSleepPacket(MQTTGWPacket*);
|
||||
int setProxyPacket(MQTTSNPacket* packet);
|
||||
void setWaitedPubTopicId(uint16_t msgId, uint16_t topicId,
|
||||
MQTTSN_topicTypes type);
|
||||
void setWaitedSubTopicId(uint16_t msgId, uint16_t topicId,
|
||||
MQTTSN_topicTypes type);
|
||||
void setWaitedPubTopicId(uint16_t msgId, uint16_t topicId, MQTTSN_topicid* topic);
|
||||
void setWaitedSubTopicId(uint16_t msgId, uint16_t topicId, MQTTSN_topicid* topic);
|
||||
|
||||
bool checkTimeover(void);
|
||||
void updateStatus(MQTTSNPacket*);
|
||||
|
||||
@@ -126,7 +126,7 @@ MQTTGWPacket* MQTTSNPublishHandler::handlePublish(Client* client,
|
||||
/* Save a msgId & a TopicId pare for PUBACK */
|
||||
if (msgId && qos > 0 && qos < 3)
|
||||
{
|
||||
client->setWaitedPubTopicId(msgId, topicid.data.id, topicid.type);
|
||||
client->setWaitedPubTopicId(msgId, topicid.data.id, &topicid);
|
||||
}
|
||||
|
||||
pub.payload = (char*) payload;
|
||||
|
||||
@@ -111,7 +111,7 @@ MQTTGWPacket* MQTTSNSubscribeHandler::handleSubscribe(Client* client,
|
||||
subscribe->setSUBSCRIBE(topicstr, (uint8_t) qos, (uint16_t) msgId);
|
||||
}
|
||||
|
||||
client->setWaitedSubTopicId(msgId, topicId, topicFilter.type);
|
||||
client->setWaitedSubTopicId(msgId, topicId, &topicFilter);
|
||||
|
||||
if (!client->isAggregated())
|
||||
{
|
||||
|
||||
@@ -397,14 +397,22 @@ uint8_t Topics::getCount(void)
|
||||
/*=====================================
|
||||
Class TopicIdMap
|
||||
=====================================*/
|
||||
TopicIdMapElement::TopicIdMapElement(uint16_t msgId, uint16_t topicId,
|
||||
MQTTSN_topicTypes type)
|
||||
TopicIdMapElement::TopicIdMapElement(uint16_t msgId, uint16_t topicId, MQTTSN_topicid* topic)
|
||||
{
|
||||
_msgId = msgId;
|
||||
_topicId = topicId;
|
||||
_type = type;
|
||||
_type = topic->type;
|
||||
_wildcard = 0;
|
||||
_next = nullptr;
|
||||
_prev = nullptr;
|
||||
|
||||
if (_type == MQTTSN_TOPIC_TYPE_NORMAL)
|
||||
{
|
||||
if ( strchr(topic->data.long_.name, '*') != 0 || strchr(topic->data.long_.name, '+') != 0 )
|
||||
{
|
||||
_wildcard = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TopicIdMapElement::~TopicIdMapElement()
|
||||
@@ -419,7 +427,14 @@ MQTTSN_topicTypes TopicIdMapElement::getTopicType(void)
|
||||
|
||||
uint16_t TopicIdMapElement::getTopicId(void)
|
||||
{
|
||||
return _topicId;
|
||||
if (_wildcard > 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _topicId;
|
||||
}
|
||||
}
|
||||
|
||||
TopicIdMap::TopicIdMap()
|
||||
@@ -456,11 +471,10 @@ TopicIdMapElement* TopicIdMap::getElement(uint16_t msgId)
|
||||
return 0;
|
||||
}
|
||||
|
||||
TopicIdMapElement* TopicIdMap::add(uint16_t msgId, uint16_t topicId,
|
||||
MQTTSN_topicTypes type)
|
||||
TopicIdMapElement* TopicIdMap::add(uint16_t msgId, uint16_t topicId, MQTTSN_topicid* topic)
|
||||
{
|
||||
if (_cnt > _maxInflight * 2
|
||||
|| (topicId == 0 && type != MQTTSN_TOPIC_TYPE_SHORT))
|
||||
|| (topicId == 0 && topic->type != MQTTSN_TOPIC_TYPE_SHORT))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -469,7 +483,7 @@ TopicIdMapElement* TopicIdMap::add(uint16_t msgId, uint16_t topicId,
|
||||
erase(msgId);
|
||||
}
|
||||
|
||||
TopicIdMapElement* elm = new TopicIdMapElement(msgId, topicId, type);
|
||||
TopicIdMapElement* elm = new TopicIdMapElement(msgId, topicId, topic);
|
||||
if (elm == 0)
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -81,7 +81,7 @@ class TopicIdMapElement
|
||||
{
|
||||
friend class TopicIdMap;
|
||||
public:
|
||||
TopicIdMapElement(uint16_t msgId, uint16_t topicId, MQTTSN_topicTypes type);
|
||||
TopicIdMapElement(uint16_t msgId, uint16_t topicId, MQTTSN_topicid* topic);
|
||||
~TopicIdMapElement();
|
||||
MQTTSN_topicTypes getTopicType(void);
|
||||
uint16_t getTopicId(void);
|
||||
@@ -89,6 +89,7 @@ public:
|
||||
private:
|
||||
uint16_t _msgId;
|
||||
uint16_t _topicId;
|
||||
uint8_t _wildcard;
|
||||
MQTTSN_topicTypes _type;
|
||||
TopicIdMapElement* _next;
|
||||
TopicIdMapElement* _prev;
|
||||
@@ -100,8 +101,7 @@ public:
|
||||
TopicIdMap();
|
||||
~TopicIdMap();
|
||||
TopicIdMapElement* getElement(uint16_t msgId);
|
||||
TopicIdMapElement* add(uint16_t msgId, uint16_t topicId,
|
||||
MQTTSN_topicTypes type);
|
||||
TopicIdMapElement* add(uint16_t msgId, uint16_t topicId, MQTTSN_topicid* topic);
|
||||
void erase(uint16_t msgId);
|
||||
void clear(void);
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user