From 0b1333404ccc0f9fba704ffd50548f63234ebe67 Mon Sep 17 00:00:00 2001 From: Tyler Payne Date: Wed, 10 Jun 2026 17:48:27 +0000 Subject: [PATCH 1/2] feat(core): add FeedHeartbeatWatchdog RPC Allow a client to keep MAVSDK's periodic heartbeats alive by feeding a deadman timer (configured in MAVSDK), so heartbeats stop when the client hangs or dies. --- protos/core/core.proto | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/protos/core/core.proto b/protos/core/core.proto index 3df5592be..a35994a10 100644 --- a/protos/core/core.proto +++ b/protos/core/core.proto @@ -20,6 +20,21 @@ service CoreService { * need to be increased to prevent timeouts. */ rpc SetMavlinkTimeout(SetMavlinkTimeoutRequest) returns(SetMavlinkTimeoutResponse) {} + /* + * Feed the heartbeat watchdog. + * + * MAVSDK can be configured with a heartbeat watchdog (deadman timer). + * While configured, the periodic heartbeats sent by MAVSDK are only sent + * as long as this is called at least once per timeout period. If the + * watchdog times out, heartbeats stop until it is fed again. + * + * This allows MAVSDK's heartbeats to reflect the liveness of the client: + * if the client hangs or dies, heartbeats stop. + * + * Has no effect if no watchdog is configured (e.g. with the + * --heartbeat-watchdog-timeout option of mavsdk_server). + */ + rpc FeedHeartbeatWatchdog(FeedHeartbeatWatchdogRequest) returns(FeedHeartbeatWatchdogResponse) {} } message SubscribeConnectionStateRequest {} @@ -32,6 +47,9 @@ message SetMavlinkTimeoutRequest { } message SetMavlinkTimeoutResponse {} +message FeedHeartbeatWatchdogRequest {} +message FeedHeartbeatWatchdogResponse {} + // Connection state type. message ConnectionState { bool is_connected = 2; // Whether the vehicle got connected or disconnected From d019861782e03586efd24de81bebf5c8f4d19c9c Mon Sep 17 00:00:00 2001 From: Tyler Payne Date: Wed, 8 Jul 2026 15:17:14 +0000 Subject: [PATCH 2/2] feat(core): add SetHeartbeatWatchdogTimeout RPC Add a gRPC path to enable or disable the heartbeat watchdog at runtime. timeout_s is a double in seconds: 0 disables the watchdog, and values greater than 0 must be at least 1 (timeouts between 0 and 1 are invalid). --- protos/core/core.proto | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/protos/core/core.proto b/protos/core/core.proto index a35994a10..2042d1b0c 100644 --- a/protos/core/core.proto +++ b/protos/core/core.proto @@ -32,9 +32,27 @@ service CoreService { * if the client hangs or dies, heartbeats stop. * * Has no effect if no watchdog is configured (e.g. with the - * --heartbeat-watchdog-timeout option of mavsdk_server). + * --heartbeat-watchdog-timeout option of mavsdk_server, or + * SetHeartbeatWatchdogTimeout). */ rpc FeedHeartbeatWatchdog(FeedHeartbeatWatchdogRequest) returns(FeedHeartbeatWatchdogResponse) {} + /* + * Set the heartbeat watchdog timeout. + * + * When timeout_s is greater than 0, the periodic heartbeats sent by MAVSDK + * are only sent as long as FeedHeartbeatWatchdog is called at least once + * per timeout period. If the watchdog times out, heartbeats stop until it + * is fed again. + * + * When timeout_s is 0, the watchdog is disabled and heartbeats follow the + * usual policy (always_send_heartbeats or a connected system). + * + * Values greater than 0 and less than 1 are rejected. + * + * This is an alternative to configuring the watchdog at mavsdk_server + * startup with the --heartbeat-watchdog-timeout option. + */ + rpc SetHeartbeatWatchdogTimeout(SetHeartbeatWatchdogTimeoutRequest) returns(SetHeartbeatWatchdogTimeoutResponse) {} } message SubscribeConnectionStateRequest {} @@ -50,6 +68,11 @@ message SetMavlinkTimeoutResponse {} message FeedHeartbeatWatchdogRequest {} message FeedHeartbeatWatchdogResponse {} +message SetHeartbeatWatchdogTimeoutRequest { + double timeout_s = 1; // Timeout in seconds. 0 disables the watchdog. Minimum 1 when enabled. +} +message SetHeartbeatWatchdogTimeoutResponse {} + // Connection state type. message ConnectionState { bool is_connected = 2; // Whether the vehicle got connected or disconnected