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
30typedef 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
35
36/// \brief Generic RH_TCP message structure with message type
37typedef 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
45typedef 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
53typedef struct
54{
55 uint32_t length; ///< Number of octets following, in network byte order
56 // 5 octets of header to follow for total of 9 octets
57 uint8_t type; ///< == RH_TCP_MESSAGE_TYPE_PACKET
58 uint8_t to; ///< Node address of the recipient
59 uint8_t from; ///< Node address of the sender
60 uint8_t id; ///< Message sequence number
61 uint8_t flags; ///< Message flags
62 uint8_t payload[RH_TCP_MAX_MESSAGE_LEN]; ///< 0 or more, length deduced from length above
64
65#pragma pack(pop)
66
67#endif
Generic RH_TCP simulator message structure.
Definition RHTcpProtocol.h:31
uint32_t length
Number of octets following, in network byte order.
Definition RHTcpProtocol.h:32
RH_TCP radio message passed to or from the simulator.
Definition RHTcpProtocol.h:54
uint8_t id
Message sequence number.
Definition RHTcpProtocol.h:60
uint8_t from
Node address of the sender.
Definition RHTcpProtocol.h:59
uint32_t length
Number of octets following, in network byte order.
Definition RHTcpProtocol.h:55
uint8_t to
Node address of the recipient.
Definition RHTcpProtocol.h:58
uint8_t flags
Message flags.
Definition RHTcpProtocol.h:61
uint8_t type
== RH_TCP_MESSAGE_TYPE_PACKET
Definition RHTcpProtocol.h:57
RH_TCP message Notifies the server of thisAddress of this client.
Definition RHTcpProtocol.h:46
uint32_t length
Number of octets following, in network byte order.
Definition RHTcpProtocol.h:47
uint8_t type
== RH_TCP_MESSAGE_TYPE_THISADDRESS
Definition RHTcpProtocol.h:48
uint8_t thisAddress
Node address.
Definition RHTcpProtocol.h:49
Generic RH_TCP message structure with message type.
Definition RHTcpProtocol.h:38
uint8_t type
One of RH_TCP_MESSAGE_TYPE_*.
Definition RHTcpProtocol.h:40
uint32_t length
Number of octets following, in network byte order.
Definition RHTcpProtocol.h:39