Friendly LWM2M client
WppConnection.h
Go to the documentation of this file.
1 /*
2  * WppConnection.h
3  *
4  * Created on: 22 Jul 2023
5  * Author: valentin
6  */
7 
8 #ifndef I_WPP_CONNECTION_H_
9 #define I_WPP_CONNECTION_H_
10 
11 #include <string>
12 
13 #include "liblwm2m.h"
14 #include "SafeQueue.h"
15 
16 #define WPP_CONN_I_PACKETS_QUEUE_SIZE 10
17 
30 namespace wpp {
31 
32 class WppClient;
33 class Lwm2mSecurity;
34 
36 public:
37  using SESSION_T = void*;
38 
39  struct Packet {
41  size_t length;
42  uint8_t *buffer;
43  };
44 
45 public:
46  WppConnection();
47  virtual ~WppConnection();
48 
49  WppConnection(const WppConnection&) = delete;
53 
54  /* ------------- Connection abilities ------------- */
64  virtual SESSION_T connect(Lwm2mSecurity& security) = 0;
65 
73  virtual void disconnect(SESSION_T session) = 0;
74 
85  virtual bool sessionCmp(SESSION_T session1, SESSION_T session2) = 0;
86 
96  virtual bool sendPacket(const Packet &packet) = 0;
97 
107  bool addPacketToQueue(const Packet &packet);
108 
116  uint8_t getPacketQueueSize();
117 
123  void clearPacketQueue();
124 
133  bool setDataBlockSize(uint16_t size);
134 
142  uint16_t getDataBlockSize();
143 
153  void handlePacketsInQueue(WppClient &client);
154 
155 private:
157 };
158 
159 } /* namespace wpp */
160 
161 #endif /* I_WPP_CONNECTION_H_ */
SafeQueue is an implementation of the thread/IRQ safe queue that does not use dynamic memory,...
Definition: SafeQueue.h:99
Represents a client interface for Wpp library.
Definition: WppClient.h:37
virtual SESSION_T connect(Lwm2mSecurity &security)=0
Establishes a connection using the provided Lwm2mSecurity object.
uint16_t getDataBlockSize()
Retrieves the COAP block size.
virtual void disconnect(SESSION_T session)=0
Disconnects from the specified session.
virtual bool sendPacket(const Packet &packet)=0
Sends a packet over the connection.
WppConnection & operator=(WppConnection &&)=delete
void clearPacketQueue()
Clears the packet queue.
WppConnection & operator=(const WppConnection &)=delete
virtual bool sessionCmp(SESSION_T session1, SESSION_T session2)=0
Compares two session identifiers.
bool setDataBlockSize(uint16_t size)
Sets the COAP block size.
WppConnection(WppConnection &&)=delete
bool addPacketToQueue(const Packet &packet)
Adds a packet to the packet queue.
virtual ~WppConnection()
WppConnection(const WppConnection &)=delete
uint8_t getPacketQueueSize()
Retrieves the size of the packet queue.
void handlePacketsInQueue(WppClient &client)
Processes the packets in the packet queue.
The WppConnection class represents a connection interface for the Wpp library.
Definition: WppClient.cpp:14