FakeRadioTransport

class FakeRadioTransport(val identity: TransportIdentity, frames: List<Frame> = emptyList(), val autoHandshake: Boolean = false, val nodeNum: Int = DEFAULT_FAKE_NODE_NUM) : RadioTransport(source)

In-memory, script-driven RadioTransport for testing.

Allows tests to replay captured frames and control connection state deterministically.

When autoHandshake is true, the transport automatically responds to the two-stage Meshtastic handshake (want_config_id 69420 / 69421) and the get_owner_request admin message, enabling RadioClient.connect to complete without a real radio. The synthesized MyNodeInfo.my_node_num defaults to 1; pass nodeNum to simulate a different identity (e.g. for identity-rebind tests).

Constructors

Link copied to clipboard
constructor(identity: TransportIdentity, frames: List<Frame> = emptyList(), autoHandshake: Boolean = false, nodeNum: Int = DEFAULT_FAKE_NODE_NUM)

Properties

Link copied to clipboard

When true, automatically responds to handshake ToRadio messages so RadioClient.connect can complete without a real radio.

Link copied to clipboard
open override val identity: TransportIdentity
Link copied to clipboard

MyNodeInfo.my_node_num to report during the auto-handshake.

Link copied to clipboard
open override val state: StateFlow<TransportState>

Functions

Link copied to clipboard
open suspend override fun connect()
Link copied to clipboard
open suspend override fun disconnect()
Link copied to clipboard
open override fun frames(): Flow<Frame>
Link copied to clipboard
fun injectAdminResponse(requestId: Int, response: AdminMessage, fromNode: Int = nodeNum)

Inject an admin response packet correlated to requestId. The packet is constructed with decoded.request_id = requestId so the engine's CommandDispatcher / processRoutingAck can match it against an outstanding request.

Link copied to clipboard
fun injectFrame(frame: Frame)

Inject an arbitrary frame as if received from the radio.

Link copied to clipboard
fun injectNeighborInfoResponse(requestId: Int, info: NeighborInfo, fromNode: Int = nodeNum)

Inject a NeighborInfo response correlated to requestId.

Link copied to clipboard
fun injectRouteReply(requestId: Int, reply: RouteDiscovery, fromNode: Int = nodeNum)

Inject a Routing.route_reply correlated to requestId.

Link copied to clipboard
fun injectRoutingAck(requestId: Int, fromNode: Int = nodeNum)

Inject a Routing.Ack correlated to requestId (setter ack-style tests).

Link copied to clipboard
fun injectRoutingError(requestId: Int, error: Routing.Error, fromNode: Int = nodeNum)

Inject a Routing error correlated to requestId (failure-mapping tests).

Link copied to clipboard
fun injectTelemetryResponse(requestId: Int, telemetry: Telemetry, fromNode: Int = nodeNum)

Inject a Telemetry response packet correlated to requestId.

Link copied to clipboard

Frames that were sent via send.

Link copied to clipboard
fun outboundPackets(): List<MeshPacket>

Decoded view of every outbound MeshPacket sent by the engine since connect. Strips the 4-byte stream-framing header and re-decodes each Frame into a ToRadio envelope, then surfaces packets that targeted ADMIN_APP / TELEMETRY_APP / ROUTING_APP / NEIGHBORINFO_APP.

Link copied to clipboard
open suspend override fun send(frame: Frame)
Link copied to clipboard
fun simulateError(cause: Throwable, recoverable: Boolean = true)

Transition to an error state.