Skip to main content

NodeStatus

Struct NodeStatus 

Source
pub struct NodeStatus {
Show 23 fields pub v: u8, pub id: String, pub sq: u32, pub up: Option<u32>, pub ver: Option<String>, pub bn: Option<String>, pub bs: Option<String>, pub bt: Option<u8>, pub fc: Option<bool>, pub fa: Option<bool>, pub fv: Option<String>, pub ff: Option<String>, pub sr: Option<u16>, pub sf: Option<u16>, pub so: Option<u16>, pub sn: Option<Vec<String>>, pub cp: Option<f32>, pub mp: Option<f32>, pub dp: Option<f32>, pub tc: Option<f32>, pub cs: Option<String>, pub vs: Option<String>, pub vn: Option<u8>,
}
Expand description

A compact projection of a node’s status, sized for one aux frame.

Field names are short because msgpack writes map keys verbatim; each is documented, and the with_* builders are the only way to put external data into one, so the bounds cannot be bypassed.

Fields§

§v: u8

Schema version (NODE_STATUS_VERSION).

§id: String

The device id this snapshot describes, so a receiver can key it without depending on an identity frame having arrived first.

§sq: u32

Monotonic sequence number. Lets a receiver spot loss and ignore a datagram that arrives out of order, which UDP permits even over loopback.

§up: Option<u32>

Agent uptime in seconds.

§ver: Option<String>

Agent version string.

§bn: Option<String>

Board name (rock-5c-lite, rpi4b, …).

§bs: Option<String>

Board SoC.

§bt: Option<u8>

Board capability tier.

§fc: Option<bool>

The honest connected-or-reachable verdict: true for a live MAVLink heartbeat, and also true for a healthy MSP flight controller (Betaflight/iNav), which never emits a MAVLink heartbeat but is reachable and drivable over the byte-transparent proxy. False only when no flight controller is evidenced at all.

§fa: Option<bool>

Whether MAVLink heartbeats are actually arriving. Distinct from Self::fc on purpose: an MSP flight controller is reachable but never sends a MAVLink heartbeat, and a serial port can be open with nothing behind it. Collapsing the two would report a silent link as a live one.

§fv: Option<String>

Firmware family from the USB descriptor (betaflight, inav).

§ff: Option<String>

Canonical firmware family (ardupilot, px4, betaflight, inav).

§sr: Option<u16>

Units in running.

§sf: Option<u16>

Units failed. This is the TRUE total even when Self::sn is clipped.

§so: Option<u16>

Units in any other state (dead, exited, inactive).

§sn: Option<Vec<String>>

Names of failed units, capped at MAX_FAILED_NAMES. Which service failed is the single most actionable fact a ground operator can have, so it is worth the bytes; the cap is what keeps it safe.

§cp: Option<f32>

CPU percent.

§mp: Option<f32>

Memory used percent.

§dp: Option<f32>

Root filesystem used percent.

§tc: Option<f32>

SoC temperature in Celsius.

§cs: Option<String>

Camera state (ready, recovering, …).

§vs: Option<String>

Video pipeline state.

§vn: Option<u8>

How many video legs the node is serving.

A ground station relays a drone it cannot otherwise interrogate — the radio carries no IP — so without this it cannot tell a single-camera drone from a pod shipping two concurrent legs, and any surface that needs to know has to assume. Absent means the drone did not say, which is deliberately distinct from a reported 1.

Implementations§

Source§

impl NodeStatus

Source

pub fn new(device_id: &str, seq: u32) -> Self

Start a snapshot with the always-present core. Optional fields are set by the caller through the with_* helpers, each of which clips its input.

Source

pub fn with_services( self, running: u16, failed: u16, other: u16, failed_names: &[String], ) -> Self

Set the service summary. failed_names is clipped to MAX_FAILED_NAMES entries of MAX_UNIT_NAME characters; failed stays the true total so a clipped list never understates the fault.

Source

pub fn with_board( self, name: Option<&str>, soc: Option<&str>, tier: Option<u8>, ) -> Self

Set the board descriptors, clipping each string.

Source

pub fn with_fc( self, connected: Option<bool>, alive: Option<bool>, variant: Option<&str>, firmware: Option<&str>, ) -> Self

Set the flight controller block, clipping each string.

Source

pub fn with_resources( self, cpu: Option<f32>, mem: Option<f32>, disk: Option<f32>, temp_c: Option<f32>, ) -> Self

Set the resource gauges.

Source

pub fn with_payload( self, camera: Option<&str>, video: Option<&str>, video_legs: Option<u8>, ) -> Self

Set the payload states, clipping each string.

video_legs is how many video legs the node serves. None when the node could not read its own stream list: a ground station reading this must show “unknown”, never assume one camera.

Source

pub fn with_agent(self, uptime_s: Option<u32>, version: Option<&str>) -> Self

Set uptime and agent version.

Source

pub fn encode(&self) -> Option<(Vec<u8>, usize)>

Encode to msgpack, shedding fields down TRIM_LADDER until the frame fits one aux payload.

Returns the bytes and how many ladder steps were applied, so a producer can log that it degraded rather than trimming invisibly. None only when even the fully-trimmed core does not fit, which the caps make unreachable; a producer that somehow hits it must send nothing rather than a truncated frame, because a truncated msgpack body decodes as garbage instead of failing cleanly.

Source

pub fn decode(bytes: &[u8]) -> Option<Self>

Decode a msgpack status frame, rejecting an unrecognised schema version and an empty device id.

Trait Implementations§

Source§

impl Clone for NodeStatus

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NodeStatus

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for NodeStatus

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for NodeStatus

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for NodeStatus

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for NodeStatus

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for NodeStatus

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more