Jack Hansdampf / mbed-mqtt-GSOE1

Dependents:   ESP8266MQTT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LRegisterManager.h Source File

LRegisterManager.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 REGISTERQUE_H_
00018 #define REGISTERQUE_H_
00019 
00020 #include <time.h>
00021 #include "LMqttsnClientApp.h"
00022 
00023 namespace linuxAsyncClient {
00024 /*======================================
00025       structure LRegisterQue
00026  ======================================*/
00027 typedef struct RegQueElement{
00028     const char* topicName;
00029     uint16_t msgId;
00030     int      retryCount;
00031     time_t   sendUTC;
00032     RegQueElement* prev;
00033     RegQueElement* next;
00034 }RegQueElement;
00035 
00036 class LRegisterManager{
00037 public:
00038     LRegisterManager();
00039     ~LRegisterManager();
00040     void registerTopic(char* topicName);
00041     void responceRegAck(uint16_t msgId, uint16_t topicId);
00042     void responceRegister(uint8_t* msg, uint16_t msglen);
00043     bool isDone(void);
00044     uint8_t checkTimeout();
00045     const char* getTopic(uint16_t msgId);
00046 private:
00047     RegQueElement* getElement(const char* topicName);
00048     RegQueElement* getElement(uint16_t msgId);
00049     RegQueElement* add(const char* topicName, uint16_t msgId);
00050     void remove(RegQueElement* elm);
00051     void send(RegQueElement* elm);
00052     RegQueElement* _first;
00053     RegQueElement* _last;
00054 };
00055 }
00056 
00057 #endif /* REGISTERQUE_H_ */