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.
LGwProxy.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 GWPROXY_H_ 00018 #define GWPROXY_H_ 00019 00020 #include <stdio.h> 00021 #include <string.h> 00022 #include <time.h> 00023 00024 #include "LMqttsnClientApp.h" 00025 #include "LNetworkUdp.h" 00026 #include "LRegisterManager.h" 00027 #include "LTimer.h" 00028 #include "LTopicTable.h" 00029 00030 using namespace std; 00031 00032 #define GW_LOST 0 00033 #define GW_SEARCHING 1 00034 #define GW_CONNECTING 2 00035 #define GW_WAIT_WILLTOPICREQ 3 00036 #define GW_SEND_WILLTOPIC 4 00037 #define GW_WAIT_WILLMSGREQ 5 00038 #define GW_SEND_WILLMSG 6 00039 #define GW_WAIT_CONNACK 7 00040 #define GW_CONNECTED 8 00041 #define GW_DISCONNECTING 9 00042 #define GW_SLEEPING 10 00043 #define GW_DISCONNECTED 11 00044 #define GW_SLEPT 12 00045 00046 #define GW_WAIT_PINGRESP 1 00047 00048 namespace linuxAsyncClient { 00049 /*======================================== 00050 Class LGwProxy 00051 =======================================*/ 00052 class LGwProxy{ 00053 public: 00054 LGwProxy(); 00055 ~LGwProxy(); 00056 00057 void initialize(LUdpConfig netconf, LMqttsnConfig mqconf); 00058 void connect(void); 00059 void disconnect(uint16_t sec = 0); 00060 int getMessage(void); 00061 uint16_t registerTopic(char* topic, uint16_t toipcId); 00062 00063 void setWillTopic(const char* willTopic, uint8_t qos, bool retain = false); 00064 void setWillMsg(const char* willMsg); 00065 void setCleanSession(bool); 00066 void setKeepAliveDuration(uint16_t duration); 00067 void setAdvertiseDuration(uint16_t duration); 00068 void setForwarderMode(bool valid); 00069 void setQoSMinus1Mode(bool valid); 00070 void reconnect(void); 00071 int writeMsg(const uint8_t* msg); 00072 void setPingReqTimer(void); 00073 uint16_t getNextMsgId(); 00074 LTopicTable* getTopicTable(void); 00075 LRegisterManager* getRegisterManager(void); 00076 const char* getClientId(void); 00077 private: 00078 int readMsg(void); 00079 void writeGwMsg(void); 00080 void checkPingReq(void); 00081 void checkAdvertise(void); 00082 int getConnectResponce(void); 00083 int getDisconnectResponce(void); 00084 bool isPingReqRequired(void); 00085 00086 LNetwork _network; 00087 uint8_t* _mqttsnMsg; 00088 uint16_t _nextMsgId; 00089 const char* _clientId; 00090 const char* _willTopic; 00091 const char* _willMsg; 00092 uint8_t _cleanSession; 00093 uint8_t _initialized; 00094 uint8_t _retainWill; 00095 uint8_t _qosWill; 00096 uint8_t _gwId; 00097 uint16_t _tkeepAlive; 00098 uint32_t _tAdv; 00099 time_t _sendUTC; 00100 int _retryCount; 00101 int _connectRetry; 00102 uint8_t _status; 00103 time_t _pingSendUTC; 00104 uint8_t _pingRetryCount; 00105 uint8_t _pingStatus; 00106 LRegisterManager _regMgr; 00107 LTopicTable _topicTbl; 00108 LTimer _gwAliveTimer; 00109 LTimer _keepAliveTimer; 00110 uint16_t _tSleep; 00111 uint16_t _tWake; 00112 bool _isForwarderMode; 00113 bool _isQoSMinus1Mode; 00114 char _msg[MQTTSN_MAX_MSG_LENGTH + 1]; 00115 }; 00116 00117 } /* end of namespace */ 00118 #endif /* GWPROXY_H_ */
Generated on Wed Jul 13 2022 10:46:02 by
1.7.2