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