V148

Fork of RadioHead-148 by David Rimer

Committer:
ilkaykozak
Date:
Wed Oct 25 05:14:09 2017 +0000
Revision:
1:b7641da2b203
Parent:
0:ab4e012489ef
V148

Who changed what in which revision?

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