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.
LPublishManager.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 #ifndef PUBLISHMANAGER_H_ 00017 #define PUBLISHMANAGER_H_ 00018 00019 #include <time.h> 00020 #include "LMqttsnClientApp.h" 00021 #include "LTimer.h" 00022 #include "LTopicTable.h" 00023 #include "Payload.h" 00024 00025 using namespace std; 00026 00027 namespace linuxAsyncClient { 00028 00029 #define TOPICID_IS_SUSPEND 0 00030 #define TOPICID_IS_READY 1 00031 #define WAIT_PUBACK 2 00032 #define WAIT_PUBREC 3 00033 #define WAIT_PUBREL 4 00034 #define WAIT_PUBCOMP 5 00035 00036 #define SAVE_TASK_INDEX 1 00037 #define NEG_TASK_INDEX 0 00038 00039 00040 typedef struct PubElement{ 00041 uint16_t msgId; 00042 uint16_t topicId; 00043 const char* topicName; 00044 uint8_t* payload; 00045 uint16_t payloadlen; 00046 time_t sendUTC; 00047 int (*callback)(void); 00048 int retryCount; 00049 int taskIndex; 00050 PubElement* prev; 00051 PubElement* next; 00052 uint8_t flag; 00053 uint8_t status; // 0:SUSPEND, 1:READY 00054 } PubElement; 00055 00056 /*======================================== 00057 Class LPublishManager 00058 =======================================*/ 00059 class LPublishManager{ 00060 public: 00061 LPublishManager(); 00062 ~LPublishManager(); 00063 void publish(const char* topicName, Payload* payload, uint8_t qos, bool retain = false); 00064 void publish(const char* topicName, uint8_t* payload, uint16_t len, uint8_t qos, bool retain = false); 00065 void publish(uint16_t topicId, Payload* payload, uint8_t qos, bool retain = false); 00066 void publish(uint16_t topicId, uint8_t* payload, uint16_t len, uint8_t qos, bool retain = false); 00067 void responce(const uint8_t* msg, uint16_t msglen); 00068 void published(uint8_t* msg, uint16_t msglen); 00069 void checkTimeout(void); 00070 void sendSuspend(const char* topicName, uint16_t topicId, uint8_t topicType); 00071 bool isDone(void); 00072 bool isMaxFlight(void); 00073 private: 00074 PubElement* getElement(uint16_t msgId); 00075 PubElement* getElement(const char* topicName); 00076 PubElement* add(const char* topicName, uint16_t topicId, uint8_t* payload, uint16_t len, 00077 uint8_t qos, uint8_t retain, uint16_t msgId, uint8_t topicType); 00078 void remove(PubElement* elm); 00079 void sendPublish(PubElement* elm); 00080 void sendPubAck(uint16_t topicId, uint16_t msgId, uint8_t rc); 00081 void sendPubRel(PubElement* elm); 00082 void delElement(PubElement* elm); 00083 PubElement* _first; 00084 PubElement* _last; 00085 uint8_t _elmCnt; 00086 uint8_t _publishedFlg; 00087 }; 00088 00089 } /* tomyAsyncClient */ 00090 #endif /* PUBLISHMANAGER_H_ */
Generated on Wed Jul 13 2022 10:46:02 by
1.7.2