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