Datastream Types

Datastreams are named, typed values declared in firmware and exchanged between device and host.

Type Codes

CodeNameSize (bytes)RangeConstant
0x01BOOL10 or 1CONDUYT_TYPE_BOOL
0x02INT81-128 to 127CONDUYT_TYPE_INT8
0x03UINT810 to 255CONDUYT_TYPE_UINT8
0x04INT162-32768 to 32767CONDUYT_TYPE_INT16
0x05UINT1620 to 65535CONDUYT_TYPE_UINT16
0x06INT324-2^31 to 2^31-1CONDUYT_TYPE_INT32
0x07FLOAT324IEEE 754 floatCONDUYT_TYPE_FLOAT32
0x08STRINGvarUTF-8 null-terminatedCONDUYT_TYPE_STRING
0x09BYTESvarRaw binaryCONDUYT_TYPE_BYTES

All multi-byte numeric values are little-endian.

Wire Format

DS_EVENT (0xD1):Device to Host

Device pushes a datastream value to the host.

ds_index(u8) + value(N bytes)

The value encoding matches the declared type code. A FLOAT32 datastream sends 4 bytes in IEEE 754 little-endian format.

DS_WRITE (0x60):Host to Device

Host writes a value to a writable datastream.

ds_index(u8) + value(N bytes)

The device responds with ACK on success, or NAK with DATASTREAM_READONLY (0x0E) or UNKNOWN_DATASTREAM (0x0D).

DS_READ (0x61):Host to Device

Host requests the current value of a datastream.

ds_index(u8)

The device responds with DS_READ_RESP (0xD2):

ds_index(u8) + value(N bytes)

DS_SUBSCRIBE (0x62):Host to Device

Host subscribes to periodic updates.

ds_index(u8) + interval_ms(u16)

The device responds with ACK. Subsequent updates arrive as DS_EVENT packets.

Datastream Descriptor

Declared in the HELLO_RESP payload. Each descriptor is 28 bytes:

FieldSizeDescription
name16Null-padded UTF-8 name
type1CONDUYT_TYPE_* code
unit8Null-padded unit string (e.g., "celsius", "rpm")
writable10x01 if host can write
pin_ref1Associated pin number (0xFF if none)
retain10x01 if value is retained across reconnect

Firmware Declaration

device.addDatastream("temperature", CONDUYT_TYPE_FLOAT32, "celsius", false);  // read-only
device.addDatastream("setpoint",    CONDUYT_TYPE_FLOAT32, "celsius", true);   // writable