send
Enqueue an outbound packet for transmission.
Returns immediately with a MessageHandle tracking the packet's lifecycle. The engine assigns id and from from the local node's info; callers may override these if needed.
Payload size: enforced client-side against DATA_PAYLOAD_LEN (233 bytes). Oversized payloads throw MeshtasticException.PayloadTooLarge before enqueue — no handle is returned.
Return
a handle tracking delivery state
Parameters
the packet to send
Throws
if not currently connected
if the payload exceeds the device limit
if the packet is malformed
Convenience: build a MeshPacket for the given portnum with payload and enqueue it.
Constructs a packet with decoded = Data(portnum, payload, want_response = false) and forwards to send. Exists so callers do not need to import org.meshtastic.proto.Data to send a typed application payload.
hopLimit = null (the default) leaves the field at the proto-default 0, which the firmware interprets as "use the device's configured default hop limit". Set it explicitly only when you need to override that default for a single packet.
Example:
client.send(
portnum = PortNum.TEXT_MESSAGE_APP,
payload = "ack".encodeToByteArray(),
to = NodeId(0xa1b2c3d4.toInt()),
wantAck = true,
)Suspend-safe but does not actually suspend — it delegates to the non-suspending send entry point. The suspend modifier is reserved so future versions can apply back-pressure on the engine inbox without a source-incompatible signature change.
Return
a MessageHandle tracking delivery state
Since
0.1.0
Parameters
the application port number (PortNum.TEXT_MESSAGE_APP, PortNum.POSITION_APP, …)
the wire-encoded payload bytes (must be ≤ DATA_PAYLOAD_LEN)
destination NodeId; defaults to NodeId.BROADCAST
ChannelIndex to send on; defaults to channel 0 (primary)
request a reliable delivery ACK (firmware-side ACK, not end-to-end)
explicit hop limit override; null keeps the device default
Throws
if not currently connected
if payload exceeds the device limit
Convenience: build a MeshPacket for the given portnum from a kotlinx.io.Buffer payload.
Identical to the ByteArray-accepting send overload but reads from a kotlinx.io.Buffer, allowing callers to compose payloads with the kotlinx-io sink/source API instead of raw byte arrays. The buffer is consumed (read fully) on invocation.
Return
a MessageHandle tracking delivery state
Since
0.1.0
Parameters
the application port number
a kotlinx.io.Buffer containing the wire-encoded payload (≤ DATA_PAYLOAD_LEN)
destination NodeId; defaults to NodeId.BROADCAST
ChannelIndex to send on; defaults to channel 0 (primary)
request a reliable delivery ACK
explicit hop limit override; null keeps the device default
Throws
if not currently connected
if the buffer content exceeds the device limit