PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

RHTcpProtocol.h 2.4KB

hace 3 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. /// This file contains the definitions of message structures passed between
  7. /// RH_TCP and the etherSimulator
  8. #ifndef RH_TcpProtocol_h
  9. #define RH_TcpProtocol_h
  10. #define RH_TCP_MESSAGE_TYPE_NOP 0
  11. #define RH_TCP_MESSAGE_TYPE_THISADDRESS 1
  12. #define RH_TCP_MESSAGE_TYPE_PACKET 2
  13. // Maximum message length (including the headers) we are willing to support
  14. #define RH_TCP_MAX_PAYLOAD_LEN 255
  15. // The length of the headers we add.
  16. // The headers are inside the RF69's payload and are therefore encrypted if encryption is enabled
  17. #define RH_TCP_HEADER_LEN 4
  18. // This is the maximum message length that can be supported by this protocol.
  19. #define RH_TCP_MAX_MESSAGE_LEN (RH_TCP_MAX_PAYLOAD_LEN - RH_TCP_HEADER_LEN)
  20. #pragma pack(push, 1) // No padding
  21. /// \brief Generic RH_TCP simulator message structure
  22. typedef struct
  23. {
  24. uint32_t length; ///< Number of octets following, in network byte order
  25. uint8_t payload[RH_TCP_MAX_PAYLOAD_LEN + 1]; ///< Payload
  26. } RHTcpMessage;
  27. /// \brief Generic RH_TCP message structure with message type
  28. typedef struct
  29. {
  30. uint32_t length; ///< Number of octets following, in network byte order
  31. uint8_t type; ///< One of RH_TCP_MESSAGE_TYPE_*
  32. uint8_t payload[RH_TCP_MAX_PAYLOAD_LEN]; ///< Payload
  33. } RHTcpTypeMessage;
  34. /// \brief RH_TCP message Notifies the server of thisAddress of this client
  35. typedef struct
  36. {
  37. uint32_t length; ///< Number of octets following, in network byte order
  38. uint8_t type; ///< == RH_TCP_MESSAGE_TYPE_THISADDRESS
  39. uint8_t thisAddress; ///< Node address
  40. } RHTcpThisAddress;
  41. /// \brief RH_TCP radio message passed to or from the simulator
  42. typedef struct
  43. {
  44. uint32_t length; ///< Number of octets following, in network byte order
  45. uint8_t type; ///< == RH_TCP_MESSAGE_TYPE_PACKET
  46. uint8_t to; ///< Node address of the recipient
  47. uint8_t from; ///< Node address of the sender
  48. uint8_t id; ///< Message sequence number
  49. uint8_t flags; ///< Message flags
  50. uint8_t payload[RH_TCP_MAX_MESSAGE_LEN]; ///< 0 or more, length deduced from length above
  51. } RHTcpPacket;
  52. #pragma pack(pop)
  53. #endif