HeartbeatSender

Shared heartbeat sender for Meshtastic radio transports.

Constructs and sends a ToRadio(heartbeat = Heartbeat(nonce = ...)) message to keep the firmware's idle timer from expiring. Each call uses a monotonically increasing nonce to prevent the firmware's per-connection duplicate-write filter from silently dropping it. Nonce 1 is the firmware's NodeInfo-ping trigger since v2.7.23 (a mesh-wide NodeInfo broadcast with want_response), so keepalives must never use it: the counter starts at FIRST_NONCE and only counts up.

Parameters

sendToRadio

callback that reports whether the transport accepted the encoded heartbeat bytes

afterHeartbeat

optional suspend callback invoked after sending (e.g. to schedule a drain)

logTag

tag for log messages

Constructors

Link copied to clipboard
constructor(sendToRadio: (ByteArray) -> Boolean, afterHeartbeat: suspend () -> Unit? = null, logTag: String = "HeartbeatSender")

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
suspend fun sendHeartbeat(): Boolean

Sends a heartbeat to the radio.