Skip to main content

Module gbt

Module gbt 

Source
Expand description

General block transfer (IEC 62056-5-3, 7.3.13): a transport-independent mechanism that carries any (partial) xDLMS APDU in blocks.

E0 | block-control | block-number | block-number-ack | block-data
     ^ LB|ST|window   ^ u16           ^ u16 (acked)      ^ A-XDR octet-string

The block-control octet holds the last-block flag (bit 7), the streaming flag (bit 6) and the window size (bits 5..0).

send and receive drive this codec over any crate::transport::DataLinkLayer, transparently segmenting an oversized xDLMS APDU into blocks (and reassembling them on the other end) — an alternative to the service-specific WITH-DATABLOCK block transfer that also covers APDU types WITH-DATABLOCK does not, such as DataNotification and EventNotificationRequest.

Structs§

GeneralBlockTransfer
A general-block-transfer APDU.

Constants§

DEFAULT_BLOCK_SIZE
Default overall block size (including the header) used when a session enables GBT without specifying one explicitly.
GENERAL_BLOCK_TRANSFER
General-block-transfer APDU tag ([224]).
HEADER_MAX
Octets reserved for the GBT header (tag, control, block numbers, and a worst-case long-form length) when budgeting a block’s payload size from an overall frame-size limit.
LAST_BLOCK 🔒
STREAMING 🔒
WINDOW_MASK 🔒

Functions§

applies_to_apdu
Returns whether general block transfer applies to this APDU’s service (IEC 62056-5-3 §9.3, Table): GET/SET/ACTION requests and responses, plus DataNotification and EventNotificationRequest.
read_block 🔒
Reads one frame from link and decodes it as a general-block-transfer APDU.
receive
Reassembles a general-block-transfer sequence starting from first, the already-received first frame (typically the result of the caller’s own link.receive_apdu() used to detect the GENERAL_BLOCK_TRANSFER tag), reading further blocks from link as needed. Handles out-of-order and duplicate blocks by requesting retransmission / acking-and-discarding.
send
Segments apdu into general-block-transfer blocks of at most block_payload_max octets each and sends them over link. In confirmed mode (window > 0), waits for an ack-only GBT frame after each window of blocks and retransmits from the first block the peer has not acknowledged if it reports a gap; with window == 0 (unconfirmed) or streaming, no ack is awaited until the caller separately reads a reply.
send_ack 🔒
Sends an ack-only general-block-transfer frame (no payload): confirms receipt up to block_number_ack and grants window further blocks.