WendyOS Docs
Detailed referenceWendy Lite

WendyCom Protocol

WendyCom is a lightweight request-response protocol used to control Wendy Lite devices.

WendyCom Protocol

Basics

WendyCom is a lightweight request-response protocol used to control Wendy Lite devices. It runs over two transports: USB (via the ESP32 USB Serial JTAG peripheral) and mTLS (over the network).

The host sends a WendyComCommand and the device replies with a WendyComResponse. Each command carries a request_id that the response echoes back, allowing the host to match replies to outstanding requests. The command type is encoded as a oneof field in the protobuf message.

In addition to the request-response exchange, either side can send unsolicited WendyComEvent messages at any time. Events are not tied to a request: they carry an event_id instead of a request_id and receive no reply. The device uses them, for example, to stream console output after a ConsoleAttach command (the event_id given in the attach params tags the resulting events).

Each message consists of an 8-byte header followed by a protobuf-encoded body.

Message Header

OffsetFieldTypeDescription
0magicuint8_tFixed sync byte 0xA5, used to detect framing errors
1versionuint8_tProtocol version, currently always 2
2categoryuint8_tMessage category; only 0 is accepted (non-zero triggers a receive reset)
3channeluint8_tSub-channel within the link — see WendyCom via Cloud
4–5reserveduint16_tUnused, set to 0 on send
6–7body_sizeuint16_tLength of the body that follows, in network byte order

WendyCom over TLS

The device listens on TCP port 5054 and advertises itself via mDNS as _wendy-lite._tcp. Every connection is TLS-encrypted. The device operates in one of two modes depending on whether it has been enrolled in Wendy Cloud:

  • Unauthenticated TLS — When not enrolled, the device uses a built-in default certificate; client identity is not verified. This is the factory default. The mDNS TXT record advertises mtls=false.
  • mTLS — When enrolled, the device uses a provisioned certificate and requires the client to present a certificate signed by the configured chain of trust. The mDNS TXT record advertises mtls=true.

Connection liveness

WendyCom has no heartbeat over TCP. Instead, the device enables TCP keepalive on every connection, so it can clean up a connection when the client is lost without closing it, for example when the host loses power or the network path drops. After 15 seconds without incoming data the device sends a TCP keepalive probe, then another one every 15 seconds. If no probe is answered, the device closes the connection 45 seconds after it last received data, and frees its link slot. The host's TCP stack answers the probes, so the client does not need to send anything, and an idle client that is still reachable stays connected.

WendyCom over USB Serial JTAG

WendyCom runs over the ESP32 USB Serial JTAG peripheral. This link supports several modes, WendyCom being one of them; the host switches between them by sending escape sequences.

Modes

USJ_MODE_OFF (0) — USB input is silently discarded. No data is written to the channel.

USJ_MODE_CONSOLE (1) — ESP log output is mirrored to the USB channel (the vprintf-hook forwards every log line). wendy_usj_write() is active. This is the startup default.

USJ_MODE_ECHO (2) — Every received byte is immediately echoed back. Useful for connectivity checks.

USJ_MODE_COM (3) — The channel is handed to the wendy_com stack, enabling WendyCom message exchange over USB as we do over mTLS.

Escape sequences

DLE (0x10) characters in the data stream are interpreted as commands. Each DLE is followed by a command byte:

DLE c  →  switch to console mode
DLE e  →  switch to echo mode
DLE m  →  switch to com mode
DLE o  →  switch to off mode

In USJ_MODE_COM, the wendy_com_uart layer intercepts escape sequences before data reaches the wendy_com stack:

DLE _    →  pass a literal DLE byte through to the `wendy_com` stack
DLE k    →  keep-alive, sent every 6 seconds
DLE <x>  →  disconnect the `wendy_com` link, then switch to mode <x>

Two consecutive DLE characters are considered like one. Therefore, you can put as many DLE as you want in front of a command byte.

Establishing a WendyCom connection

Before entering USJ_MODE_COM, the host must flush any stale data buffered in the USB layer on both sides. The handshake uses echo mode for this:

  1. Open the USB channel.
  2. Send DLE e to switch to echo mode.
  3. Verify the link: send a few bytes and confirm that data flows back.
  4. Drain the channel: read until no data arrives within a timeout.
  5. Send a unique sentinel byte sequence and wait until it is echoed back — this confirms the channel is fully flushed and both sides are in sync.
  6. Send DLE m to switch to USJ_MODE_COM.

The channel is now in USJ_MODE_COM with no stale data in either buffer.

Implementation notes

A board that has just rebooted is a hostile environment for this sequence: boot logs keep the stream continuously readable so it never goes quiet, bytes can be dropped, and the device is not ready to serve WendyCom for some time after USB comes up. The CLI's implementation (serialHandshake, in go/internal/cli/liteclient/link_direct.go) is therefore more aggressive than the steps above, collapsing 2-5 into a single retry loop:

  • Steps 2 and 5 go out as one write. Each attempt sends DLE DLE DLE DLE e immediately followed by 16 spaces of padding and a fresh 32-character random sentinel, as a single payload.
  • The echo mode command is repeated with every attempt. The device refuses DLE e until its WendyCom agent is running, and the window between USB initialization and that point is wide enough to swallow the first attempt. Applying the command is a plain mode assignment, so re-issuing it is idempotent. Escape sequences are consumed by the mode parser and never echoed, so the prefix cannot show up in the echoed stream.
  • Every attempt carries a fresh sentinel. The sentinel is a stream position marker, not a liveness probe: because the echo is FIFO, seeing the latest one come back proves nothing the host wrote earlier is still in flight, which is what step 4 is really after. Matching an older sentinel would leave the later echoes queued, and the WendyCom framer reads their leading padding as a frame header.
  • The padding is 16 spaces. A DLE whose command byte is lost stays latched and consumes the byte after it, so a run of expendable bytes ahead of the sentinel keeps a dropped byte from corrupting it.
  • Matching uses a rolling window. The host reads one byte at a time, keeping the last 32, and compares that window to the sentinel just sent. Draining the channel (step 4) falls out of this for free, without the stream ever having to go quiet.
  • Retries widen. The first attempt goes out immediately, then the host waits 100 ms before retrying, then 200, 300, 400 and 500 ms, holding at 500 ms, within a total budget of 3 seconds — about eight attempts. Widening keeps probing a device that is still booting without pushing a kilobyte of sentinels at it.

Switching to program mode

In addition to the modes described above, the host can reset the device into program mode via the DTR and RTS signals exposed by the USB Serial JTAG peripheral. The wendy os install command uses this to flash the firmware. See wendy os install

Caveat

USB Serial JTAG currently has no flow control. If the host sends data faster than the device can consume it, bytes may be silently dropped. To avoid this, messages must be kept below 1024 bytes, and the host must wait for a response before sending the next message.

WendyCom via Cloud

An enrolled board can be selected through wendy cloud discover without a direct USB or LAN connection. The CLI opens an encrypted connection through Wendy Cloud; WendyCom commands and replies remain encrypted between the CLI and board. See connect through Cloud for setup and troubleshooting.

The board maintains an outbound control connection, so its network does not need an inbound port. After handing a client connection over to the relay, it reconnects to Cloud so it can continue reporting presence. The relayed WendyCom connection then uses the same TCP keepalive as a LAN connection (see Connection liveness).

Time synchronization for enrollment

The CLI obtains signed time for the board automatically. Firmware verifies the reply before accepting it; your computer does not simply set the board's clock. The default enrollment flow uses Sigstore's signed-time service. Firmware that supports Roughtime can use that mode in a compatible custom deployment.

Channel multiplexing

The channel byte supports multiple logical channels within a WendyCom link. The Cloud relay uses channel 0 inside end-to-end TLS.

  • Channel 0 is open by default. It is created implicitly when a link connects and can never be opened or closed explicitly. Direct connections (USB, local TLS) always use channel 0.
  • The device currently supports up to 4 channels per link, including channel 0.

Data received on a channel that has not been opened is reported with a channel_state error (see below).

Channel open/close service messages

A WendyCom host can manage nonzero channels using WendyComService messages:

message WendyComOpenChannel {}
message WendyComCloseChannel {}

message WendyComChannelOpen  {}
message WendyComChannelClose {}

enum WendyComChannelErrorReason {
    WENDY_COM_CHANNEL_ERROR_REASON_NOT_OPEN = 0;
    WENDY_COM_CHANNEL_ERROR_REASON_REJECTED = 1;
}

message WendyComChannelError {
    WendyComChannelErrorReason reason = 1;
}

message WendyComChannelState {
    oneof state {
        WendyComChannelOpen  open  = 1;
        WendyComChannelClose close = 2;
        WendyComChannelError error = 3;
    }
}

message WendyComService {
    oneof cmd {
        WendyComOpenChannel  open_channel  = 1;
        WendyComCloseChannel close_channel = 2;
        WendyComChannelState channel_state = 3;
    }
}

A host opening a nonzero channel sends open_channel and waits for confirmation before sending payload. It sends close_channel when finished. The Cloud broker does not perform these operations.

The device answers channel management with a WendyComChannelState message, sent device → host on the channel concerned:

  • open_channel → the device replies with channel_state open on success, or error with reason REJECTED if the channel cannot be opened (all channel slots in use, or the channel is already open — including channel 0).
  • close_channel → the device replies with channel_state close, or error with reason REJECTED if the channel cannot be closed (channel 0) or is not open. The device may also send channel_state close unsolicited when it closes a channel on its own.
  • Any other (disallowed) service message → the device replies with channel_state error with reason REJECTED.
  • A command received on a channel that is not open → the device reports channel_state error with reason NOT_OPEN.

channel_state reports reach the WendyCom host inside the encrypted stream.

WendyCom Handshake

A handshake message is sent automatically when a connection is established. The host sends the protocol version it supports (e.g. major=1, minor=0) along with a fresh handshake_id; the device replies with the same kind of message, echoing the handshake_id and carrying its own protocol version. The major version must match on both sides — the device closes the connection if the host's major version is unsupported. Commands sent before the handshake completes are rejected.

WendyCom Commands

Ping

Checks that the device is reachable and responsive. The device replies with OK and no payload.

Reboot

Asks the device to reboot. The device replies with OK before resetting.

App Download

Transfers a WASM application binary to the device in three steps:

  1. AppPushBegin — opens a transfer session and tells the device the total file size in bytes.
  2. AppPushData — sends the binary in chunks, each carrying its byte offset within the file. The host sends one command per chunk and waits for OK before sending the next.
  3. AppPushEnd — closes the transfer session, signalling that all chunks have been delivered.

AppStart

Starts the previously downloaded WASM application on the device.

AppStop

Stops the currently running application.

GetDeviceIdentity

Queries the device for its identity. The device responds with a WendyComDeviceIdentity message containing three fields:

  • id — a unique identifier for the device (e.g. a serial number or hardware ID).
  • name — a short machine-readable name.
  • display_name — a human-readable display name.

If the device cannot provide an identity, it returns an error result and the host discards the device from its list of reachable devices.

GetDeviceInfo

Queries the device for information about its hardware and software. The device responds with a WendyComDeviceInfo message containing:

  • os — the operating system name, typically wendy-lite.
  • os_version — the operating system version.
  • cpu_architecture — the CPU architecture.
  • target — the SoC name (e.g. esp32c6 or esp32s3).
  • wasm_app_support — whether the device can run WASM applications.
  • native_app_support — whether the device can run native applications.
  • board — the board identifier (e.g. esp32c6_generic or esp32s3_seeed_xiao_native). Empty when the board is not known.

NetGet

Queries the board's saved Wendy Net policy and runtime status. The command's net_get parameter is field 22; a successful response carries net_status (field 8 of WendyComResponse). These commands require firmware with Wendy Net management support.

WendyComNetStatus separates desired, the saved policy, from applied, the current runtime policy when available. An absent applied policy is unavailable, not an all-false configuration. It also reports:

  • state: off, starting, running, stopping or failed (the corresponding WendyComNetState enum values).
  • ble_supported, wifi_supported and nan_supported: the board's carrier capabilities, rather than proof that any carrier is connected.
  • psram and memory_limit_bytes: resource profile information.
  • Optional allocated_bytes and internal_bytes: current network allocation measurements. An absent measurement is unknown, not zero.
  • active_links: the number of active mesh carriers.
  • error_code: a firmware diagnostic code, including when a configuration request is rejected.
  • restarting: a saved carrier change has scheduled a board restart.

NetSet

Applies the complete WendyComNetConfig supplied in net_set.config (command field 23). The policy contains enabled, ble, infrastructure_wifi and nan, plus max_links, ble_links, wifi_links and nan_links. Firmware validates carrier support and profile limits before saving the policy. The response's net_status distinguishes the saved policy from the currently applied policy.

A direct protocol client must read the current desired policy with NetGet and preserve options it is not changing. NetSet is a complete configuration, not a partial update. The CLI's wendy net configure command performs this read-modify-write step so omitted flags retain their saved values.

OK means the request completed. APPLIED_RESTARTING also means the settings were accepted, but changing the selected carrier requires a board restart. The response is sent before the restart; reconnect after boot and check status and functional traffic. A restart warning is not a failed write.

The Wendy Net management result codes supplement the general command results:

ResultMeaning
WENDY_COM_RESULT_APPLIED_RESTARTING (8)Settings accepted; a board restart is scheduled for the carrier change. The response includes net_status.
WENDY_COM_RESULT_NET_NO_WIFI (9)The requested Wi-Fi carrier is unsupported.
WENDY_COM_RESULT_NET_NO_BLE (10)The requested Bluetooth carrier is unsupported.
WENDY_COM_RESULT_NET_NO_NAN (11)The requested NAN carrier is unsupported.
WENDY_COM_RESULT_NET_ONE_CARRIER_ONLY (12)The configuration exceeds a single-carrier profile's supported carriers or link limits.

On this page