Skip to content

Request Frames

Each Blecon request is broken down into frames (outgoing and incoming).

Protocol Overview

A new request is created by sending an Open Frame. Each endpoint can then send one Header Frame (differs on the outgoing and incoming directions) and one or more Data Frames.

Once an endpoint has no more data to send, it sends a Data Frame with its finished bit set. After that, the request is considered half-closed and the enpoint must not send further data frames. The request is considered fully closed when both endpoints have half-closed the request.

Additionally, at any point, either endpoint can send a Reset Frame to signal immediate termination of a request.

When flow control is enabled in an Open Frame, the device also sends Credit Frames to manage incoming flow control. The service will consume one available credit per Data Frame it sends back.

Each request is assigned a request ID which must be unique within a connection.

Frames

All data is encoded as little endian.

Frame Header

Each frame contain a three byte header.

FieldSize (bytes)Description
Request ID2A unique identifier for the request
Type1The frame type (see below)

Open Frame

Frame Type: 0

FieldSize (bytes)Description
Flow-Control enabled11 to enable flow control, 0 otherwise
Initial Credits2If flow control is enabled, the number of initial credits to give the service
MTU2The maximum size of data the device can receive in each data frame

Outgoing Header Frame

Frame Type: 1

FieldSize (bytes)Description
Header Bitmask4Bit 0: One-way request
Bit 1: Namespace header present
Bit 2: Method header present
Bit 3: Request content type present
Bit 4: Response content type present

This is followed by a series of length-prefixed strings for each of namespace, method, request and response content types when present:

FieldSize (bytes)Description
String Size2The size of the following string
StringString SizeAn UTF-8, non-zero terminated string

Incoming Header Frame

Frame Type: 2

FieldSize (bytes)Description
Status Code2A code signalling whether the request was successful

List of status codes:

Error CodeDescription
0x0OK
0x100Timeout
0x101Security Error
0x102Disconnection Error
0x200Handler not set
0x201Handler Timeout
0x202Handler Failed
0x203Network not set

Data Frame

Frame Type: 3

FieldSize (bytes)Description
Finished Byte11 if finished (the request becomes half-closed), 0 otherwise

Credit Frame

Frame Type: 4

FieldSize (bytes)Description
Credits2The number of additional credits to give the service

Reset Frame

Frame Type: 5

This frame has no payload.


Questions? Contact Blecon support — we're happy to help.