Skip to content

mmrs: monitoring streams (state, signal) #405

@cachebag

Description

@cachebag

implement real-time d-bus signal subscriptions for modem state and signal quality.

modem state changes

subscribe to Modem.StateChanged(old: i32, new: i32, reason: u32) signal.

pub struct ModemStateChange {
    pub modem_path: String,
    pub old_state: ModemState,
    pub new_state: ModemState,
    pub reason: StateChangeReason,
}

pub async fn monitor_state(&self) -> Result<impl Stream<Item = ModemStateChange> + Send>;

follow the pattern in nmrs/src/monitoring/device.rs.

signal quality

poll SignalQuality property changes via PropertiesChanged signal, or use Modem.Signal interface if extended signal info is needed.

pub struct SignalUpdate {
    pub modem_path: String,
    pub quality: u32,
    pub recent: bool,
    pub access_technology: AccessTechnology,
}

pub async fn monitor_signal(&self) -> Result<impl Stream<Item = SignalUpdate> + Send>;

modem added/removed

subscribe to ObjectManager.InterfacesAdded / InterfacesRemoved on /org/freedesktop/ModemManager1 for hotplug detection.

pub enum ModemEvent {
    Added(String),   // modem path
    Removed(String),
}

pub async fn monitor_modems(&self) -> Result<impl Stream<Item = ModemEvent> + Send>;

stream trait bounds

ensure streams are Send so they work with tokio::spawn. same fix as nmrs #359.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or requestmmrsmodemmanager bindings cratemonitoringConnection monitoring and info

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions