34#ifndef _OPENLCB_STREAMDEFS_HXX_
35#define _OPENLCB_STREAMDEFS_HXX_
55 FLAG_CARRIES_ID = 0x01,
56 FLAG_REJECT_OUT_OF_ORDER = 0x02,
60 FLAG_TEMPORARY_ERROR = 0x20,
66 REJECT_INFO_LOGGED = 0x01,
67 REJECT_PERMANENT_INVALID_REQUEST = 0x20,
68 REJECT_PERMANENT_SRC_NOT_PERMITTED = 0x40,
69 REJECT_PERMANENT_STREAMS_NOT_ACCEPTED = 0x80,
70 REJECT_TEMPORARY_BUFFER_FULL = 0x20,
71 REJECT_TEMPORARY_OUT_OF_ORDER = 0x40,
82 REJECT_PERMANENT_INVALID_REQUEST;
94 bool has_ident, uint8_t src_stream_id,
98 p[0] = max_buffer_size >> 8;
99 p[1] = max_buffer_size & 0xff;
100 p[2] = has_ident ? FLAG_CARRIES_ID : 0;
102 p[4] = src_stream_id;
103 p[5] = dst_stream_id;
118 uint8_t src_stream_id, uint8_t dst_stream_id,
122 p[0] = max_buffer_size >> 8;
123 p[1] = max_buffer_size & 0xff;
124 p[2] = error_code >> 8;
125 p[3] = error_code & 0xff;
126 p[4] = src_stream_id;
127 p[5] = dst_stream_id;
139 uint8_t src_stream_id, uint8_t dst_stream_id)
142 p[0] = src_stream_id;
143 p[1] = dst_stream_id;
160 p[0] = src_stream_id;
161 p[1] = dst_stream_id;
164 p[2] = (total_bytes >> 24) & 0xff;
165 p[3] = (total_bytes >> 16) & 0xff;
166 p[4] = (total_bytes >> 8) & 0xff;
167 p[5] = (total_bytes >> 0) & 0xff;
string Payload
Container that carries the data bytes in an NMRAnet message.
Static constants and helper functions for the OpenLCB streaming protocol.
static constexpr uint16_t STREAM_ACCEPT
This code is sent back in the error code field in the stream initiate reply if the stream is accepted...
static constexpr uint8_t INVALID_STREAM_ID
This value is invalid as a source or destination stream ID.
static Payload create_close_request(uint8_t src_stream_id, uint8_t dst_stream_id, uint32_t total_bytes=INVALID_TOTAL_BYTE_COUNT)
Creates the payload for a stream close message.
static constexpr uint16_t STREAM_ERROR_INVALID_ARGS
This code is sent back in the error code field in the stream initiate reply if the stream is rejected...
static constexpr uint32_t INVALID_TOTAL_BYTE_COUNT
Supply this value to the total byte count in stream close to mark it as invalid.
static Payload create_initiate_response(uint16_t max_buffer_size, uint8_t src_stream_id, uint8_t dst_stream_id, uint16_t error_code=STREAM_ACCEPT)
Creates a Stream Initiate Reply message payload.
static Payload create_initiate_request(uint16_t max_buffer_size, bool has_ident, uint8_t src_stream_id, uint8_t dst_stream_id=INVALID_STREAM_ID)
Creates a Stream Initiate Request message payload.
static constexpr uint16_t MAX_PAYLOAD
Maximum window size for stream send.
static Payload create_data_proceed(uint8_t src_stream_id, uint8_t dst_stream_id)
Creates a Stream Data Proceed message payload.