Skip to content

mmrs: high-level api (ModemManager struct) #402

@cachebag

Description

@cachebag

implement the main ModemManager entry point and ergonomic api.

core struct

pub struct ModemManager {
    conn: Connection,
}

impl ModemManager {
    pub async fn new() -> Result<Self>;
    pub async fn with_connection(conn: Connection) -> Result<Self>;
    pub fn connection(&self) -> &Connection;
}

modem enumeration

impl ModemManager {
    pub async fn list_modems(&self) -> Result<Vec<Modem>>;
    pub async fn modem_by_imei(&self, imei: &str) -> Result<Modem>;
    pub async fn primary_modem(&self) -> Result<Modem>;
    pub fn modem(&self, path: &str) -> ModemScope<'_>;
}

use ObjectManager.GetManagedObjects() to enumerate, same pattern as nmrs bluez adapter enumeration.

simple operations

impl ModemManager {
    pub async fn enable(&self) -> Result<()>;
    pub async fn disable(&self) -> Result<()>;
    pub async fn connect_simple(&self, apn: &str) -> Result<Bearer>;
    pub async fn connect(&self, config: &BearerConfig) -> Result<Bearer>;
    pub async fn disconnect(&self) -> Result<()>;
    pub async fn status(&self) -> Result<ConnectionStatus>;
}

connect_simple uses Modem.Simple.Connect for one-shot enable+register+connect.

sim operations

impl ModemManager {
    pub async fn sim(&self) -> Result<Option<Sim>>;
    pub async fn unlock_pin(&self, pin: &str) -> Result<()>;
    pub async fn unlock_puk(&self, puk: &str, new_pin: &str) -> Result<()>;
    pub async fn set_pin_enabled(&self, pin: &str, enabled: bool) -> Result<()>;
    pub async fn change_pin(&self, old: &str, new: &str) -> Result<()>;
}

signal / registration

impl ModemManager {
    pub async fn signal_quality(&self) -> Result<u32>;
    pub async fn access_technology(&self) -> Result<AccessTechnology>;
}

per-modem scope

pub struct ModemScope<'a> {
    mm: &'a ModemManager,
    path: String,
}

impl<'a> ModemScope<'a> {
    pub async fn info(&self) -> Result<Modem>;
    pub async fn enable(&self) -> Result<()>;
    pub async fn connect_simple(&self, apn: &str) -> Result<Bearer>;
    // mirrors ModemManager methods, scoped to this modem
}

for multi-modem systems (vehicle gateways, dual-sim devices).

files

mmrs/src/api/
├── mod.rs
├── modem_manager.rs
└── modem_scope.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-surfacePublic API design, re-exports, and semver-relevant changesfeatureNew feature or requestmmrsmodemmanager bindings crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions