forked from PaulStoffregen/RadioHead
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RHTcpProtocol.h
66 lines (53 loc) · 2.42 KB
/
RHTcpProtocol.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// RH_TcpProtocol.h
// Author: Mike McCauley ([email protected])
// Definition of protocol messages sent and received by RH_TCP
// Copyright (C) 2014 Mike McCauley
// $Id: RHTcpProtocol.h,v 1.3 2014/05/22 06:07:09 mikem Exp $
/// This file contains the definitions of message structures passed between
/// RH_TCP and the etherSimulator
#ifndef RH_TcpProtocol_h
#define RH_TcpProtocol_h
#define RH_TCP_MESSAGE_TYPE_NOP 0
#define RH_TCP_MESSAGE_TYPE_THISADDRESS 1
#define RH_TCP_MESSAGE_TYPE_PACKET 2
// Maximum message length (including the headers) we are willing to support
#define RH_TCP_MAX_PAYLOAD_LEN 255
// The length of the headers we add.
// The headers are inside the RF69's payload and are therefore encrypted if encryption is enabled
#define RH_TCP_HEADER_LEN 4
// This is the maximum message length that can be supported by this protocol.
#define RH_TCP_MAX_MESSAGE_LEN (RH_TCP_MAX_PAYLOAD_LEN - RH_TCP_HEADER_LEN)
#pragma pack(push, 1) // No padding
/// \brief Generic RH_TCP simulator message structure
typedef struct
{
uint32_t length; ///< Number of octets following, in network byte order
uint8_t payload[RH_TCP_MAX_PAYLOAD_LEN + 1]; ///< Payload
} RHTcpMessage;
/// \brief Generic RH_TCP message structure with message type
typedef struct
{
uint32_t length; ///< Number of octets following, in network byte order
uint8_t type; ///< One of RH_TCP_MESSAGE_TYPE_*
uint8_t payload[RH_TCP_MAX_PAYLOAD_LEN]; ///< Payload
} RHTcpTypeMessage;
/// \brief RH_TCP message Notifies the server of thisAddress of this client
typedef struct
{
uint32_t length; ///< Number of octets following, in network byte order
uint8_t type; ///< == RH_TCP_MESSAGE_TYPE_THISADDRESS
uint8_t thisAddress; ///< Node address
} RHTcpThisAddress;
/// \brief RH_TCP radio message passed to or from the simulator
typedef struct
{
uint32_t length; ///< Number of octets following, in network byte order
uint8_t type; ///< == RH_TCP_MESSAGE_TYPE_PACKET
uint8_t to; ///< Node address of the recipient
uint8_t from; ///< Node address of the sender
uint8_t id; ///< Message sequence number
uint8_t flags; ///< Message flags
uint8_t payload[RH_TCP_MAX_MESSAGE_LEN]; ///< 0 or more, length deduced from length above
} RHTcpPacket;
#pragma pack(pop)
#endif