Files
paho.mqtt-sn.embedded-c/MQTTSNGateway/GatewayTester/src/LMqttsnClient.h
tomoaki bc731210ae BugFix of #76 and #77
1.Return CONNACK instead of the broker when the gateway receives CONNECT
while the client is Sleep or Awake mode.

2.Define the max size of a que for PUBLISH while the client state is
Asleep mode.  Despose packets when the que is full of packets.

3.Return PUBACK or PUBREL to the broker when the client is Asleep or
Awake.


Signed-off-by: tomoaki <tomoaki@tomy-tech.com>



Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
2017-08-27 16:39:29 +09:00

82 lines
2.8 KiB
C++

/**************************************************************************************
* Copyright (c) 2016, Tomoaki Yamaguchi
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Tomoaki Yamaguchi - initial API and implementation and/or initial documentation
**************************************************************************************/
#ifndef MQTTSNCLIENT_H_
#define MQTTSNCLIENT_H_
#include <stdio.h>
#include <string.h>
#include "LGwProxy.h"
#include "LMqttsnClientApp.h"
#include "LTimer.h"
#include "Payload.h"
#include "LPublishManager.h"
#include "LSubscribeManager.h"
#include "LTaskManager.h"
using namespace std;
namespace linuxAsyncClient {
struct OnPublishList
{
const char* topic;
int (*pubCallback)(uint8_t* payload, uint16_t payloadlen);
uint8_t qos;
};
/*========================================
Class LMqttsnClient
=======================================*/
class LMqttsnClient{
public:
LMqttsnClient();
~LMqttsnClient();
void onConnect(void);
void publish(const char* topicName, Payload* payload, uint8_t qos, bool retain = false);
void publish(const char* topicName, uint8_t* payload, uint16_t len, uint8_t qos, bool retain = false);
void publish(uint16_t topicId, Payload* payload, uint8_t qos, bool retain = false);
void publish(uint16_t topicId, uint8_t* payload, uint16_t len, uint8_t qos, bool retain = false);
void subscribe(const char* topicName, TopicCallback onPublish, uint8_t qos);
void subscribe(uint16_t topicId, TopicCallback onPublish, uint8_t qos, uint8_t topicType);
void unsubscribe(const char* topicName);
void disconnect(uint16_t sleepInSecs);
void initialize(LUdpConfig netconf, LMqttsnConfig mqconf);
void run(void);
void addTask(bool test);
void setSleepDuration(uint32_t duration);
void setSleepMode(uint32_t duration);
void sleep(void);
const char* getClientId(void);
LGwProxy* getGwProxy(void);
LPublishManager* getPublishManager(void);
LSubscribeManager* getSubscribeManager(void);
LRegisterManager* getRegisterManager(void);
LTaskManager* getTaskManager(void);
LTopicTable* getTopicTable(void);
private:
LTaskManager _taskMgr;
LPublishManager _pubMgr;
LSubscribeManager _subMgr;
LGwProxy _gwProxy;
uint32_t _sleepDuration;
};
} /* end of namespace */
#endif /* MQTTSNCLIENT_H_ */