LoRaMesher Library
0.0.5
A LoRa Mesh library for the IoT
Packet.h
1
#ifndef _LORAMESHER_PACKET_H
2
#define _LORAMESHER_PACKET_H
3
4
#include <Arduino.h>
5
6
#include <ArduinoLog.h>
7
8
#include "BuildOptions.h"
9
#include "PacketHeader.h"
10
11
12
#pragma pack(1)
13
template
<
typename
T>
14
class
Packet final :
public
PacketHeader {
15
public
:
16
17
T payload[];
18
26
size_t
getPacketLength() {
return
sizeof
(Packet<T>) + this->payloadSize; }
27
33
size_t
getPayloadLength() {
return
this->payloadSize /
sizeof
(T); }
34
35
36
T* getPayload() {
return
(T*) (&
this
+
sizeof
(Packet)); }
37
43
void
operator
delete
(
void
* p) {
44
Log.traceln(F(
"Deleting packet"
));
45
free(p);
46
}
47
48
};
49
#pragma pack()
50
51
#endif
LoRaMesher
src
entities
packets
Packet.h
Generated by
1.9.3