rllib  1
rlmqtt.h
Go to the documentation of this file.
1 /***************************************************************************
2  rlmqtt.h - description
3  -------------------
4  begin : Sun Dec 17 2017
5  copyright : (C) 2017 by R. Lehrig
6  email : lehrig@t-online.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as *
13  * published by the Free Software Foundation *
14  * *
15  ***************************************************************************/
16 #ifndef _RL_MQTT_TCP_H_
17 #define _RL_MQTT_TCP_H_
18 
19 #include "rldefine.h"
20 #include "rlsocket.h"
21 
32 class rlMQTT : public rlSocket
33 {
34 public:
36  {
37  Reserved0 = 0, // Forbidden Reserved
38  CONNECT = 1, // Client to Server Client request to connect to Server
39  CONNACK = 2, // Server to Client Connect acknowledgment
40  PUBLISH = 3, // Client to Server or Server to Client / Publish message
41  PUBACK = 4, // Client to Server or Server to Client / Publish acknowledgment
42  PUBREC = 5, // Client to Server or Server to Client / Publish received (assured delivery part 1)
43  PUBREL = 6, // Client to Server or Server to Client / Publish release (assured delivery part 2)
44  PUBCOMP = 7, // Client to Server or Server to Client / Publish complete (assured delivery part 3)
45  SUBSCRIBE = 8, // Client to Server Client subscribe request
46  SUBACK = 9, // Server to Client Subscribe acknowledgment
47  UNSUBSCRIBE = 10, // Client to Server Unsubscribe request
48  UNSUBACK = 11, // Server to Client Unsubscribe acknowledgment
49  PINGREQ = 12, // Client to Server PING request
50  PINGRESP = 13, // Server to Client PING response
51  DISCONNECT = 14, // Client to Server Client is disconnecting
52  Reserved15 = 15 // Forbidden Reserved
53  };
54  rlMQTT(const char *adr);
55  virtual ~rlMQTT();
56 
59  int sendCONNECT (int connect_flags=0);
60  int sendCONNACK ();
61  int sendPUBLISH ();
62  int sendPUBACK ();
63  int sendPUBREC ();
64  int sendPUBREL ();
65  int sendPUBCOMP ();
66  int sendSUBSCRIBE ();
67  int sendSUBACK ();
68  int sendUNSUBSCRIBE ();
69  int sendUNSUBACK ();
70  int sendPINGREQ ();
71  int sendPINGRESP ();
72  int sendDISCONNECT ();
73 
74  int receivePacket(); // return ControlPacketType or -1 in case of error
75 
76 private:
77  int sendFixedHeader(int control_packet_type, int remaining_length=0, int flags=0);
78  int sendString(const char *text); // send as MQTT string with string length as header
79 
81 };
82 
83 #endif
int receivePacket()
int sendPUBACK()
int sendUNSUBACK()
Definition: rlmqtt.h:32
int sendPUBREL()
int sendCONNECT(int connect_flags=0)
int sendFixedHeader(int control_packet_type, int remaining_length=0, int flags=0)
int last_send_packet_identifier
Definition: rlmqtt.h:80
int sendPUBLISH()
char adr[132]
Definition: rlsocket.h:261
int sendCONNACK()
int sendDISCONNECT()
int sendPUBCOMP()
int sendSUBSCRIBE()
virtual ~rlMQTT()
rlMQTT(const char *adr)
ControlPacketType
Definition: rlmqtt.h:35
int sendSUBACK()
int last_send_flags
Definition: rlmqtt.h:80
int sendString(const char *text)
int sendUNSUBSCRIBE()
int sendPUBREC()
int sendPINGREQ()
int last_send_control_packet_type
Definition: rlmqtt.h:80
int sendPINGRESP()