Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

mmrs πŸ¦€

Crates.io Documentation CI License

An async-first Rust API for ModemManager over D-Bus. The goal is to provide a safe and simple high-level API for managing cellular modems on Linux systems, built on zbus for reliable D-Bus communication.

mmrs is the ModemManager counterpart to nmrs (NetworkManager) β€” same author, same design philosophy: typed errors, async throughout, no leaking of raw D-Bus internals into the public API.

Sample usage

Listing modems

use mmrs::ModemManager;

#[tokio::main]
async fn main() -> mmrs::Result<()> {
    let mm = ModemManager::new().await?;

    for modem in mm.list_modems().await? {
        println!(
            "{} {} β€” {} ({}%, {})",
            modem.manufacturer, modem.model, modem.access_technologies,
            modem.signal_quality, modem.state,
        );
    }

    Ok(())
}

Connecting the primary modem

use mmrs::{BearerConfig, IpType, ModemManager};

#[tokio::main]
async fn main() -> mmrs::Result<()> {
    let mm = ModemManager::new().await?;

    // Quick path: just an APN
    let bearer = mm.connect_simple("internet").await?;
    println!("connected on {}", bearer.interface);

    // Or a full bearer configuration
    let cfg = BearerConfig::new("internet")
        .with_ip_type(IpType::Ipv4v6)
        .with_user("user")
        .with_password("hunter2");
    mm.connect(&cfg).await?;

    Ok(())
}

SIM PIN handling

use mmrs::{ModemError, ModemManager};

#[tokio::main]
async fn main() -> mmrs::Result<()> {
    let mm = ModemManager::new().await?;

    match mm.unlock_pin("1234").await {
        Ok(()) => println!("SIM unlocked"),
        Err(ModemError::WrongPin) => eprintln!("incorrect PIN"),
        Err(ModemError::WrongPuk) => eprintln!("incorrect PUK, SIM may now require PUK"),
        Err(e) => eprintln!("error: {e}"),
    }

    Ok(())
}

Multi-modem systems

use mmrs::ModemManager;

#[tokio::main]
async fn main() -> mmrs::Result<()> {
    let mm = ModemManager::new().await?;

    for modem in mm.list_modems().await? {
        let scope = mm.modem(&modem.path);
        let status = scope.status().await?;
        println!("{}: connected = {}", modem.path, status.connected);
    }

    Ok(())
}

Documentation

Complete API documentation: docs.rs/mmrs

Roadmap / Implementation Status

If something is missing that you'd like to see, please file a PR or issue, adding it to this roadmap.

Modem

  • Modem enumeration and lookup by IMEI
  • Primary-modem convenience helpers (enable, disable, connect, status, ...)
  • Per-modem scoping via mm.modem(path)
  • Signal quality and access technology (2G–5G, CDMA) queries
  • Real-time modem/bearer state monitoring
  • Location (GPS/cell-tower) support
  • USSD support
  • Firmware/carrier configuration management

SIM

  • PIN unlock, PUK unlock, PIN enable/disable, PIN change
  • Active SIM snapshot (ICCID, IMSI, operator name)
  • Multi-SIM slot switching

Bearers

  • Simple connect via APN
  • Full BearerConfig (IP type, credentials, roaming)
  • Bearer snapshot with IPv4 config and stats
  • IPv6 config decoding
  • Manual bearer create/delete (outside Simple.Connect)

Contributing

Contributions are welcome. Please read CONTRIBUTING.md for guidelines.

Requirements

  • Rust: 1.90.0+
  • ModemManager: Running and accessible via D-Bus
  • Linux: This library is Linux-specific

License

This project is dual-licensed under either of the following licenses, at your option:

  • MIT License
  • Apache License, Version 2.0

You may use, copy, modify, and distribute this software under the terms of either license.

See the following files for full license texts:

About

A Rust library for ModemManager over D-Bus

Resources

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages