mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-16 08:56:51 +01:00
Add: Two Gateway Test programs
BugFix: invalid pointer Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
@@ -57,6 +57,7 @@ LGwProxy::LGwProxy(){
|
||||
_connectRetry = MQTTSN_RETRY_COUNT;
|
||||
_tSleep = 0;
|
||||
_tWake = 0;
|
||||
_initialized = 0;
|
||||
}
|
||||
|
||||
LGwProxy::~LGwProxy(){
|
||||
@@ -72,6 +73,7 @@ void LGwProxy::initialize(LUdpConfig netconf, LMqttsnConfig mqconf){
|
||||
_retainWill = mqconf.willRetain;
|
||||
_cleanSession = mqconf.cleanSession;
|
||||
_tkeepAlive = mqconf.keepAlive;
|
||||
_initialized = 1;
|
||||
}
|
||||
|
||||
void LGwProxy::connect(){
|
||||
@@ -170,8 +172,13 @@ int LGwProxy::getConnectResponce(void){
|
||||
_tSleep = 0;
|
||||
}else{
|
||||
DISPLAY("\033[0m\033[0;32m\n\n Connected to the Broker\033[0m\033[0;37m\n\n");
|
||||
_topicTbl.clearTopic();
|
||||
theClient->onConnect(); // SUBSCRIBEs are conducted
|
||||
|
||||
if ( _cleanSession || _initialized == 1 )
|
||||
{
|
||||
_topicTbl.clearTopic();
|
||||
_initialized = 0;
|
||||
theClient->onConnect(); // SUBSCRIBEs are conducted
|
||||
}
|
||||
}
|
||||
}else{
|
||||
_status = GW_CONNECTING;
|
||||
@@ -483,3 +490,5 @@ void LGwProxy::setPingReqTimer(void){
|
||||
const char* LGwProxy::getClientId(void) {
|
||||
return _clientId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ private:
|
||||
const char* _willTopic;
|
||||
const char* _willMsg;
|
||||
uint8_t _cleanSession;
|
||||
uint8_t _initialized;
|
||||
uint8_t _retainWill;
|
||||
uint8_t _qosWill;
|
||||
uint8_t _gwId;
|
||||
|
||||
@@ -222,7 +222,7 @@ void LMqttsnClient::setSleepDuration(uint32_t duration)
|
||||
|
||||
void LMqttsnClient::onConnect(void)
|
||||
{
|
||||
_subMgr.onConnect();
|
||||
_subMgr.onConnect();
|
||||
}
|
||||
|
||||
const char* LMqttsnClient::getClientId(void)
|
||||
@@ -230,6 +230,8 @@ const char* LMqttsnClient::getClientId(void)
|
||||
return _gwProxy.getClientId();
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t LMqttsnClient::getTopicId(const char* topicName)
|
||||
{
|
||||
return _gwProxy.getTopicTable()->getTopicId(topicName);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ public:
|
||||
void setSleepMode(uint32_t duration);
|
||||
void sleep(void);
|
||||
const char* getClientId(void);
|
||||
uint16_t getTopicId(const char* topicName);
|
||||
LGwProxy* getGwProxy(void);
|
||||
LPublishManager* getPublishManager(void);
|
||||
LSubscribeManager* getSubscribeManager(void);
|
||||
|
||||
@@ -79,6 +79,7 @@ struct LUdpConfig{
|
||||
#define MQTTSN_CONFIG MqttsnConfig theMqttsnConfig
|
||||
#define NETWORK_CONFIG UdpConfig theNetworkConfig
|
||||
|
||||
#define CONNECT(...) theClient->getGwProxy()->connect(__VA_ARGS__)
|
||||
#define PUBLISH(...) theClient->publish(__VA_ARGS__)
|
||||
#define SUBSCRIBE(...) theClient->subscribe(__VA_ARGS__)
|
||||
#define UNSUBSCRIBE(...) theClient->unsubscribe(__VA_ARGS__)
|
||||
|
||||
@@ -441,6 +441,15 @@ PubElement* LPublishManager::add(const char* topicName, uint16_t topicId, uint8_
|
||||
elm->status = TOPICID_IS_READY;
|
||||
elm->topicId = topicId;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint16_t id = theClient->getTopicId(topicName);
|
||||
if ( id )
|
||||
{
|
||||
elm->status = TOPICID_IS_READY;
|
||||
elm->topicId = id;
|
||||
}
|
||||
}
|
||||
|
||||
elm->payloadlen = len;
|
||||
elm->msgId = msgId;
|
||||
|
||||
Reference in New Issue
Block a user