https://github.com/benjamin-stefan/uqmi-client
UqmiClient is a Node.js library for managing network-related commands over SSH, specifically designed to work with UQMI-compatible devices.
https://github.com/benjamin-stefan/uqmi-client
lte lte-modem ssh uqmi
Last synced: 2 months ago
JSON representation
UqmiClient is a Node.js library for managing network-related commands over SSH, specifically designed to work with UQMI-compatible devices.
- Host: GitHub
- URL: https://github.com/benjamin-stefan/uqmi-client
- Owner: Benjamin-Stefan
- License: mit
- Created: 2024-09-27T15:04:08.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-19T15:12:29.000Z (5 months ago)
- Last Synced: 2025-05-29T10:41:29.600Z (5 months ago)
- Topics: lte, lte-modem, ssh, uqmi
- Language: TypeScript
- Homepage:
- Size: 1.17 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# UqmiClient
[](https://www.npmjs.com/package/uqmi-client)
[](https://github.com/Benjamin-Stefan/uqmi-client/actions/workflows/ci.yml)
[](https://opensource.org/licenses/MIT)**UqmiClient** is a Node.js library for managing network-related commands over SSH, specifically designed to work with UQMI-compatible devices.
## Table of Contents
- [UqmiClient](#uqmiclient)
- [Table of Contents](#table-of-contents)
- [π Installation](#-installation)
- [π Usage](#-usage)
- [SSH options](#ssh-options)
- [Default options](#default-options)
- [π Finding Device Name](#-finding-device-name)
- [π§ͺ Examples](#-examples)
- [βοΈ Supported Commands](#οΈ-supported-commands)
- [General Commands](#general-commands)
- [Network Management](#network-management)
- [SIM and PIN Management](#sim-and-pin-management)
- [Device and Signal Information](#device-and-signal-information)
- [SMS Management](#sms-management)
- [Data Format](#data-format)
- [Additional Operations](#additional-operations)
- [π€ Contributing](#-contributing)
- [π License](#-license)## π Installation
Install UqmiClient via npm:
```bash
npm install uqmi-client
```## π Usage
Hereβs an example of how to use the library to start a network session:
```javascript
import { UqmiClient } from "uqmi-client";const client = new UqmiClient("/dev/cdc-wdm0", {
host: "192.168.0.1",
port: 22,
username: "user",
password: "password",
});// Start a network session
(async () => {
try {
const versions = await uqmi.getVersions();
console.log("Device Versions:", versions);
} catch (error) {
console.error("Failed to get device versions:", error);
}
})();
```### SSH options
```typescript
/**
* SSH connection options for connecting to a remote device.
*
* @property {string} host - The SSH server hostname or IP address.
* @property {number} [port=22] - The port to connect to (default is 22).
* @property {string} username - The username to authenticate as on the SSH server.
* @property {string} [password] - The password for authentication (used if no private key is provided).
* @property {string} [privateKeyPath] - The path to the private key file for authentication (if password is not used).
* @property {string} [passphrase] - The passphrase to unlock the private key (if the key is encrypted).
*/
export interface SSHOptions {
host: string;
port?: number;
username: string;
password?: string;
privateKeyPath?: string;
passphrase?: string;
}
```### Default options
```typescript
/**
* Options for configuring the Uqmi client, allowing for optional settings like timeout.
*
* @property {number} [timeout] - The timeout period (in milliseconds) for operations performed by the uqmi cli.
*/
export interface UqmiClientOptions {
timeout?: number;
}
```## π Finding Device Name
To identify the device name, run the following command on the target device:
```bash
ls /dev
```Typically, the device name will be something like `cdc-wdm0`.
## π§ͺ Examples
Explore more examples in the [examples](./examples) folder.
## βοΈ Supported Commands
The `UqmiClient` class provides several commands to manage network-related operations via SSH. Each command is executed through the underlying `runCommand` function, which sends the appropriate command over SSH.
### General Commands
- **Get Service Versions:**
- `getVersions()`: Retrieves the service versions.
- **SSH Command:** `uqmi --device= --get-versions`- **Set and Get Client ID:**
- `setClientId(serviceName: string, clientId: string)`: Sets the client ID for a specific service.
- **SSH Command:** `uqmi --device= --set-client-id ,`
- `getClientId(serviceName: string)`: Retrieves the client ID for a specific service.
- **SSH Command:** `uqmi --device= --get-client-id `- **Synchronize Client IDs:**
- `sync()`: Synchronizes all client IDs.
- **SSH Command:** `uqmi --device= --sync`### Network Management
- **Start Network Connection:**
- `startNetwork(apn: string, authType: "pap" | "chap" | "both" | "none", username?: string, password?: string, ipFamily: "ipv4" | "ipv6" | "unspecified" = "unspecified")`: Starts a network connection using the specified parameters.
- **SSH Command:** `uqmi --device= --start-network --apn= --auth-type= --ip-family= [--username=] [--password=]`- **Stop Network Connection:**
- `stopNetwork(pdh: string, autoconnect: boolean = false)`: Stops the network connection.
- **SSH Command:** `uqmi --device= --stop-network [--autoconnect]`- **Get Data Status:**
- `getDataStatus()`: Retrieves the current data status.
- **SSH Command:** `uqmi --device= --get-data-status`- **Set IP Family:**
- `setIPFamily(ipFamily: "ipv4" | "ipv6" | "unspecified")`: Sets the IP family.
- **SSH Command:** `uqmi --device= --set-ip-family `- **Set Autoconnect:**
- `setAutoconnect(value: "disabled" | "enabled" | "paused")`: Configures autoconnect.
- **SSH Command:** `uqmi --device= --set-autoconnect `- **Get Current Network Settings:**
- `getCurrentSettings()`: Retrieves the current network settings.
- **SSH Command:** `uqmi --device= --get-current-settings`- **Set Network Modes:**
- `setNetworkModes(modes: string[])`: Sets the network configuration modes.
- **SSH Command:** `uqmi --device= --set-network-modes ,,...`- **Network Scanning and Registration:**
- `networkScan()`: Performs a network scan.
- **SSH Command:** `uqmi --device= --network-scan`
- `networkRegister()`: Registers the device on the network.
- **SSH Command:** `uqmi --device= --network-register`### SIM and PIN Management
- **Get SIM Card State:**
- `getSIMState()`: Retrieves the current SIM card state.
- **SSH Command:** `uqmi --device= --uim-get-sim-state`- **Get and Verify PIN Status:**
- `getPinStatus()`: Retrieves the current PIN status.
- **SSH Command:** `uqmi --device= --get-pin-status`
- `verifyPin1(pin: string)`: Verifies PIN1.
- **SSH Command:** `uqmi --device= --verify-pin1 `
- `verifyPin2(pin: string)`: Verifies PIN2.
- **SSH Command:** `uqmi --device= --verify-pin2 `- **Manage PIN Protection:**
- `setPin1Protection(state: "enabled" | "disabled", pin: string)`: Sets protection for PIN1.
- **SSH Command:** `uqmi --device= --set-pin1-protection --pin `
- `setPin2Protection(state: "enabled" | "disabled", pin2: string)`: Sets protection for PIN2.
- **SSH Command:** `uqmi --device= --set-pin2-protection --pin `- **Change and Unblock PIN:**
- `changePin1(oldPin: string, newPin: string)`: Changes PIN1.
- **SSH Command:** `uqmi --device= --change-pin1 --pin --new-pin `
- `unblockPin1(puk: string, newPin: string)`: Unblocks PIN1 using PUK.
- **SSH Command:** `uqmi --device= --unblock-pin1 --puk --new-pin `### Device and Signal Information
- **Retrieve Device Information:**
- `getICCID()`: Retrieves the ICCID.
- **SSH Command:** `uqmi --device= --get-iccid`
- `getIMSI()`: Retrieves the IMSI.
- **SSH Command:** `uqmi --device= --get-imsi`
- `getIMEI()`: Retrieves the IMEI.
- **SSH Command:** `uqmi --device= --get-imei`
- `getMSISDN()`: Retrieves the MSISDN.
- **SSH Command:** `uqmi --device= --get-msisdn`- **Manage Device Operating Modes:**
- `getDeviceOperatingMode()`: Retrieves the current device operating mode.
- **SSH Command:** `uqmi --device= --get-device-operating-mode`
- `setDeviceOperatingMode(mode: "online" | "low_power" | "factory_test" | "offline" | "reset" | "shutting_down" | "persistent_low_power" | "mode_only_low_power")`: Sets the device operating mode.
- **SSH Command:** `uqmi --device= --set-device-operating-mode `- **Get Signal Information:**
- `getSignalInfo()`: Retrieves signal information.
- **SSH Command:** `uqmi --device= --get-signal-info`
- `getServingSystem()`: Retrieves serving system information.
- **SSH Command:** `uqmi --device= --get-serving-system`### SMS Management
- **List, Retrieve, and Delete SMS Messages:**
- `listMessages(storage: "sim" | "me" = "sim")`: Lists SMS messages from the specified storage.
- **SSH Command:** `uqmi --device= --list-messages --storage `
- `deleteMessage(id: number, storage: "sim" | "me" = "sim")`: Deletes an SMS message.
- **SSH Command:** `uqmi --device= --delete-message --storage `
- `getMessage(id: number, storage: "sim" | "me" = "sim")`: Retrieves an SMS message.
- **SSH Command:** `uqmi --device= --get-message --storage `- **Send SMS:**
- `sendMessage(destinationNumber: string, message: string, flash: boolean = false, smsc?: string)`: Sends an SMS message.
- **SSH Command:** `uqmi --device= --send-message --send-message-target [--send-message-flash] [--send-message-smsc ]`### Data Format
- **Set and Get Data Format:**
- `setDataFormat(type: "802.3" | "raw-ip")`: Sets the data format.
- **SSH Command:** `uqmi --device= --wda-set-data-format `
- `getDataFormat()`: Retrieves the current data format.
- **SSH Command:** `uqmi --device= --wda-get-data-format`### Additional Operations
- **Reset DMS Service:**
- `resetDMS()`: Resets the DMS service.
- **SSH Command:** `uqmi --device= --reset-dms`- **FCC Authorization:**
- `setFCCAuth()`: Executes FCC authorization.
- **SSH Command:** `uqmi --device= --fcc-auth`## π€ Contributing
Contributions are welcome! Please check out the [CONTRIBUTING.md](/CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](/CODE_OF_CONDUCT.md) for details.
## π License
This project is licensed under the [MIT License](./LICENSE).