How maltegrosse/go-modemmanager works
1) What this repository is
This is a Go library that provides D-Bus bindings for the Linux ModemManager service. It is not an application; it is an API layer that lets Go code inspect and control modems through the system D-Bus rather than talking to the modem hardware directly.
2) Main architectural boundary
The key boundary is between:
• Consumers of this Go package: your application code
• The external ModemManager daemon on the system D-Bus
• The modem hardware and transport modes underneath ModemManager (QMI, AT, etc.)
This repo mainly models the D-Bus API exposed by ModemManager and forwards method calls and property access across that boundary.
3) Central entry point
ModemManager.go is the top-level root of the API. It represents the ModemManager service itself and is the likely starting point for discovering modems and working with the service-wide interface.
4) Object model: one file per D-Bus interface
The repository is organized around ModemManager’s D-Bus interfaces, with a Go file per major interface:
• Modem.go
• ModemSimple.go
• Modem3gpp.go
• ModemCdma.go
• ModemMessaging.go
• ModemLocation.go
• ModemSignal.go
• ModemFirmware.go
• ModemUssd.go
• ModemVoice.go
• ModemOma.go
• ModemTime.go
• Sim.go
• Bearer.go
• Sms.go
• Call.go
This structure strongly mirrors the underlying D-Bus API, so the package architecture is interface-centric rather than layered around business logic.
5) How data flows through the library
The typical flow is:
1. Client code discovers a modem or related object through the ModemManager service
2. The code wraps that D-Bus object in the relevant Go type
3. Methods and property accessors on that wrapper translate Go calls into D-Bus requests
4. Replies, errors, and signals are converted back into Go values and enums
So the repo acts as a translation layer between typed Go code and untyped/loosely typed D-Bus messages.
6) Modem-related subsystems
The package splits modem functionality into functional subsystems:
• Connectivity and bearer management: Modem.go, Bearer.go, ModemSimple.go
• Cellular network registration and 3GPP/CDMA behavior: Modem3gpp.go, ModemCdma.go
• Messaging and voice: ModemMessaging.go, Sms.go, Call.go, ModemVoice.go
• Location and time: ModemLocation.go, ModemTime.go
• Radio state and signal quality: ModemSignal.go
• Firmware and provisioning: ModemFirmware.go, Sim.go
• USSD and OMA: ModemUssd.go, ModemOma.go
This separation is important for architecture diagrams because each subsystem maps to a distinct part of the ModemManager API and can be used independently.
7) Type safety and protocol modeling
enums.go plus the many *_string.go files define the package’s typed constants and string representations for ModemManager enums and error values. These files cover:
• modem state and reasons
• registration states
• signal and access technologies
• SMS, call, bearer, firmware, SIM, OMA, and error enums
This is a significant design point: the library tries to preserve ModemManager semantics in Go types instead of passing raw integers everywhere.
8) Shared plumbing
utils.go and the common Call.go/wrapper patterns likely hold reusable helpers for D-Bus interaction, type conversion, and signal/event handling. The repository appears to centralize repeated D-Bus marshaling logic so the per-interface files stay focused on interface-specific operations.
9) Examples and usage shape
The examples/ directory contains small programs like:
• check_interfaces.go
• test_listener.go
• test_run.go
These examples suggest the package supports both:
• synchronous API usage for querying/modifying modem state
• listener-style consumption of D-Bus signals/events
That implies the library is intended for long-running system software, service daemons, or CLI tools that need live modem state.
10) External dependencies and operating assumptions
The README makes the operational context clear:
• It targets the system D-Bus
• It depends on the ModemManager daemon being installed and running
• It was tested against ModemManager 1.12.8 and Go 1.13
• Real-world behavior depends on modem mode and capabilities: QMI vs AT, plus per-device feature support
So the architecture is not just “Go package internals”; it is a thin typed client layered over a specific Linux service and modem stack.
11) Repository infrastructure
.github/workflows/go.yml indicates CI is focused on Go build/test validation. There is no sign of a separate backend, database, or service deployment model here; the repo’s “runtime” is whatever Go program imports it, running on a Linux host with D-Bus access.
12) How to draw the architecture
A good diagram would show:
• a Go application using this package
• the go-modemmanager library as the adapter layer
• the system D-Bus
• the ModemManager daemon
• and below that, the modem hardware / radio stack
Inside the library box, group the interface wrappers by domain: core manager, modem/bearer, SIM/SMS/call, registration/network, location/time, signal, firmware, and USSD/OMA. That reflects the repo’s actual structure accurately.
Main entry points: Modem.go Modem core · ModemManager.go Manager root · ModemMessaging.go Messaging · ModemVoice.go Voice
Components 26
Library API
Typed Go wrappers around ModemManager D-Bus interfaces.
- go-modemmanager · This repository's typed client layer over the ModemManager D-Bus API.
- Manager root · Top-level ModemManager entry point for discovering and coordinating modem objects.
ModemManager.go - Modem core · Primary modem object for state, capabilities, ports, power, and object access.
Modem.go - Simple control · Convenience modem operations that bundle common setup and actions.
ModemSimple.go - Connectivity · Bearer creation and connection-related types and methods.
Bearer.go - Network reg · Network registration, operator, subscription, and attachment behavior.
Modem3gpp.go - CDMA mode · CDMA-specific activation and registration support.
ModemCdma.go - Messaging · SMS and messaging transport exposed by ModemManager.
ModemMessaging.go - SMS object · Individual SMS message wrapper and state handling.
Sms.go - Voice · Voice-call capabilities and call control on the modem.
ModemVoice.go - Call object · Individual call representation and state transitions.
Call.go - Location · Positioning and assistance-data access for supported modems.
ModemLocation.go - Time sync · Modem time and network time related accessors.
ModemTime.go - Signal · Signal quality and radio-property monitoring.
ModemSignal.go - Firmware · Firmware image and update support exposed by the modem.
ModemFirmware.go - SIM · SIM card and provisioning access.
Sim.go - USSD · USSD session handling and network service codes.
ModemUssd.go - OMA · OMA device management and session control.
ModemOma.go - Helpers · Shared D-Bus marshaling, conversion, and helper routines used by wrappers.
utils.go
Type Modeling
Enum and string helpers that preserve ModemManager semantics in Go.
- Enums · Strongly typed constants for modem state, registration, SMS, call, bearer, and error domains.
enums.go - String maps · Generated stringer-style helpers for ModemManager enum values and errors.
External Runtime
System dependencies the library talks to at runtime.
- Go app · Any Go program that imports this library and drives modem operations.
- System D-Bus · Runtime IPC channel used to reach ModemManager.
- ModemManager · External system service providing modem control and state over D-Bus.
- Modem stack · Underlying modem hardware and transport modes such as QMI or AT.
Examples
Small programs showing query and signal-listener usage.
- Examples · Usage examples for interface discovery, listeners, and running the library.
examples
Connections 26
- Go app → go-modemmanager: imports · Client code uses the library as its modem API.
- Examples → go-modemmanager: demonstrate · Examples show how to consume the package.
- go-modemmanager → System D-Bus: speaks over · All service calls go through the system bus.
- System D-Bus → ModemManager: routes to · D-Bus forwards requests to the ModemManager service.
- ModemManager → Modem stack: controls · ModemManager mediates access to the actual modem and radio stack.
- go-modemmanager → Manager root: exposes · Root service wrapper for discovery and global service operations.
- Manager root → Modem core: discovers · Manager yields modem objects and related interfaces.
- Modem core → Simple control: offers · Convenience API for common modem actions.
- Modem core → Connectivity: manages · Core modem state leads into bearer and connection control.
- Modem core → Network reg: reports · Registration and network access state are modeled here.
- Modem core → CDMA mode: specializes · CDMA-specific modem interface.
- Modem core → Messaging: exposes · Messaging interface hangs off the modem object.
- Messaging → SMS object: wraps · SMS objects are created and tracked through messaging.
- Modem core → Voice: exposes · Voice capabilities and call operations.
- Voice → Call object: wraps · Calls are represented as dedicated objects.
- Modem core → SIM: exposes · SIM/provisioning state is available from the modem path.
- Modem core → Location: exposes · Location and assistance-data support.
- Modem core → Time sync: exposes · Network and modem time accessors.
- Modem core → Signal: monitors · Radio-signal quality and metrics.
- Modem core → Firmware: exposes · Firmware update and image management.
- Modem core → USSD: exposes · USSD session control.
- Modem core → OMA: exposes · OMA session and device-management support.
- go-modemmanager → Enums: models · Typed enums define the package's protocol vocabulary.
- Enums → String maps: stringifies · Generated helpers convert enums and error codes to readable text.
- go-modemmanager → Helpers: shares · Common marshaling and conversion logic is reused across wrappers.
- Helpers → Manager root: supports · Shared plumbing underpins the interface wrappers.