Skip to content

v0.1.13

Choose a tag to compare

@QuiteYellow QuiteYellow released this 31 Aug 18:47
· 108 commits to main since this release
c4005f1

One change this release: the BLE framing layer that carries OCF PDUs over GATT (#72). It sits below the CoAP-over-TCP codec added in v0.1.12, since the BLE payload is the same reliable-transport CoAP message.

BLE OCF framing codec (#72)

Adds smartthings_local.protocol.ble_ocf. The two-byte IoTivity header carries a start flag, source and destination virtual ports, and a secure flag; a start frame then carries the PDU's total length as four big-endian bytes. fragment_pdu splits one PDU into frames, BleOcfReassembler reassembles at a known frame size, and AdaptiveBleOcfReassembler derives the peer's frame size from each start frame, which works on any GATT stack regardless of how it exposes the negotiated MTU.

Reassembly is strict. It enforces IoTivity's full-frame invariant on every non-final fragment, holds port and secure metadata constant across a PDU, bounds the declared length before allocating, and discards partial state after a malformed or interleaved frame. Result objects keep the PDU bytes out of repr.

mtu here means the complete characteristic-value frame size the IoTivity adapter uses. That sits below the raw ATT MTU: a default ATT MTU of 23 normally leaves 20 bytes for a characteristic value.

Boundary

The package is a wire codec. It opens no Bluetooth connection, selects no GATT characteristic, and performs no setup or ownership work. The secure bit is transport metadata, so a secure frame is not encrypted or authenticated by this code.

The two-byte header has no fragment sequence number. A duplicated or reordered full-size continuation with otherwise identical metadata cannot be told apart at this layer, and IoTivity itself relies on GATT's ordered delivery for that. Duplicate starts, orphan continuations, detectable missing or shortened fragments, and changed ports are all rejected.

Nothing in this repo calls the module yet.