Module protocol

Module protocol 

Source
Expand description

Wire protocol shared by the Enpose API and the on-device daemon.

All packets are exactly PACKET_SIZE bytes laid out big-endian on the wire so a packet capture shows the literal magic bytes EnpR regardless of host byte order.

Packet layout:

offset  size  field
0       4     MAGIC ("EnpR")
4       2     PROTOCOL_VERSION
6       4     serial number
10      1     has_extrinsics flag (0 or 1)
11      1     packet type (PKT_TYPE_*)

Structs§

ParsedPacket
Decoded contents of a packet that passed the magic-bytes check.

Constants§

BROADCAST_PORT
UDP port the Enpose role-negotiation and discovery protocol uses.
MAGIC
Magic prefix of every packet — the ASCII bytes EnpR interpreted as a big-endian u32. Distinguishes Enpose traffic from any other UDP datagram that happens to land on BROADCAST_PORT.
PACKET_SIZE
Fixed packet size across all packet types, so receivers can use a single recv_from buffer.
PKT_TYPE_DISCOVERY_REQUEST
Packet type: a client asks any reachable primary to identify itself. Only the cluster’s elected primary replies, with a PKT_TYPE_PEER_INFO packet sent unicast to the requester.
PKT_TYPE_PEER_INFO
Packet type: a device announces its own identity (serial, extrinsics-calibration state). Sent both as the 1 Hz cluster broadcast and as the unicast reply to a discovery request.
PKT_TYPE_POSE_DATA
Packet type: a pose-data datagram. The fixed PACKET_SIZE header is followed by a MessagePack-encoded Vec<MarkerPose> starting at offset PACKET_SIZE. One datagram carries all markers localized from a single camera frame. Sent device → client on POSE_PORT.
PKT_TYPE_POSE_SUBSCRIBE
Packet type: a client subscribes to the pose stream. The same packet doubles as the keep-alive — a client resends it at 1 Hz, and the device drops a client it has not heard from within POSE_KEEPALIVE_TIMEOUT_SECS. Sent client → device on POSE_PORT.
PKT_TYPE_POSE_UNSUBSCRIBE
Packet type: a client unsubscribes from the pose stream. Lets the device drop the client immediately instead of waiting for the keep-alive timeout. Sent client → device on POSE_PORT.
POSE_KEEPALIVE_INTERVAL_SECS
Interval at which a pose-stream client should resend its subscribe/keep-alive packet to stay connected.
POSE_KEEPALIVE_TIMEOUT_SECS
How long the device keeps a pose-stream client without hearing a subscribe/keep-alive packet from it before dropping the connection.
POSE_PORT
UDP port the pose-streaming protocol uses. Clients send subscribe / keep-alive packets to this port on the device’s primary, and the device unicasts PKT_TYPE_POSE_DATA packets back to each subscribed client. Separate from BROADCAST_PORT so discovery and streaming traffic never share a socket.
PROTOCOL_VERSION
Wire-protocol version this API was built against.

Functions§

encode_discovery_request
Build a discovery-request packet. Carries serial = 0 because the requester is anonymous — the replying device fills its own serial into the response.
encode_peer_info
Build a peer-info packet using this API’s current PROTOCOL_VERSION.
encode_pose_data_header
Build the fixed header of a PKT_TYPE_POSE_DATA packet. The caller appends the MessagePack-encoded pose payload after this header; the receiver decodes the payload from offset PACKET_SIZE. serial is the sending device’s factory serial.
encode_pose_subscribe
Build a pose-stream subscribe / keep-alive packet. Carries serial = 0 because the client is anonymous; the device identifies the client by its source address.
encode_pose_unsubscribe
Build a pose-stream unsubscribe packet.
parse_packet
Decode a packet.