Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LMqttsnClient.h
00001 /************************************************************************************** 00002 * Copyright (c) 2016, Tomoaki Yamaguchi 00003 * 00004 * All rights reserved. This program and the accompanying materials 00005 * are made available under the terms of the Eclipse Public License v1.0 00006 * and Eclipse Distribution License v1.0 which accompany this distribution. 00007 * 00008 * The Eclipse Public License is available at 00009 * http://www.eclipse.org/legal/epl-v10.html 00010 * and the Eclipse Distribution License is available at 00011 * http://www.eclipse.org/org/documents/edl-v10.php. 00012 * 00013 * Contributors: 00014 * Tomoaki Yamaguchi - initial API and implementation and/or initial documentation 00015 **************************************************************************************/ 00016 00017 #ifndef MQTTSNCLIENT_H_ 00018 #define MQTTSNCLIENT_H_ 00019 00020 #include <stdio.h> 00021 #include <string.h> 00022 00023 #include "LGwProxy.h" 00024 #include "LMqttsnClientApp.h" 00025 #include "LTimer.h" 00026 #include "Payload.h" 00027 #include "LPublishManager.h" 00028 #include "LSubscribeManager.h" 00029 #include "LTaskManager.h" 00030 00031 using namespace std; 00032 00033 namespace linuxAsyncClient { 00034 00035 struct OnPublishList 00036 { 00037 MQTTSN_topicTypes type; 00038 const char* topic; 00039 uint16_t id; 00040 int (*pubCallback)(uint8_t* payload, uint16_t payloadlen); 00041 uint8_t qos; 00042 }; 00043 00044 /*======================================== 00045 Class LMqttsnClient 00046 =======================================*/ 00047 class LMqttsnClient{ 00048 public: 00049 LMqttsnClient(); 00050 ~LMqttsnClient(); 00051 void onConnect(void); 00052 void publish(const char* topicName, Payload* payload, uint8_t qos, bool retain = false); 00053 void publish(const char* topicName, uint8_t* payload, uint16_t len, uint8_t qos, bool retain = false); 00054 void publish(uint16_t topicId, Payload* payload, uint8_t qos, bool retain = false); 00055 void publish(uint16_t topicId, uint8_t* payload, uint16_t len, uint8_t qos, bool retain = false); 00056 void subscribe(const char* topicName, TopicCallback onPublish, uint8_t qos); 00057 void subscribe(uint16_t topicId, TopicCallback onPublish, uint8_t qos); 00058 void unsubscribe(const char* topicName); 00059 void unsubscribe(const uint16_t topicId); 00060 void disconnect(uint16_t sleepInSecs); 00061 void initialize(LUdpConfig netconf, LMqttsnConfig mqconf); 00062 void run(void); 00063 void addTask(bool test); 00064 void setSleepDuration(uint32_t duration); 00065 void setSleepMode(uint32_t duration); 00066 void sleep(void); 00067 const char* getClientId(void); 00068 uint16_t getTopicId(const char* topicName); 00069 LGwProxy* getGwProxy(void); 00070 LPublishManager* getPublishManager(void); 00071 LSubscribeManager* getSubscribeManager(void); 00072 LRegisterManager* getRegisterManager(void); 00073 LTaskManager* getTaskManager(void); 00074 LTopicTable* getTopicTable(void); 00075 private: 00076 LTaskManager _taskMgr; 00077 LPublishManager _pubMgr; 00078 LSubscribeManager _subMgr; 00079 LGwProxy _gwProxy; 00080 uint32_t _sleepDuration; 00081 }; 00082 00083 00084 } /* end of namespace */ 00085 #endif /* MQTTSNCLIENT_H_ */
Generated on Wed Jul 13 2022 10:46:02 by
1.7.2