PHPackages                             iamgerwin/gsm-modem - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. iamgerwin/gsm-modem

ActiveLibrary[HTTP &amp; Networking](/categories/http)

iamgerwin/gsm-modem
===================

Laravel package for GSM modem communication - Send SMS, make calls, USSD and more

26[4 PRs](https://github.com/iamgerwin/gsm-modem-laravel-package/pulls)PHPCI passing

Since Oct 13Pushed 1mo agoCompare

[ Source](https://github.com/iamgerwin/gsm-modem-laravel-package)[ Packagist](https://packagist.org/packages/iamgerwin/gsm-modem)[ RSS](/packages/iamgerwin-gsm-modem/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (5)Used By (0)

Laravel GSM Modem Package
=========================

[](#laravel-gsm-modem-package)

A comprehensive Laravel package for GSM modem communication. Send SMS, make calls, handle USSD codes and more through AT commands. Perfect for IoT applications, SMS gateways, and telecommunication solutions.

Features
--------

[](#features)

- 📱 **SMS Management**: Send, receive, and delete SMS messages in both TEXT and PDU modes
- 📞 **Call Handling**: Make calls, answer incoming calls, and hangup
- 💬 **USSD Support**: Send and receive USSD codes
- 📡 **Network Information**: Get signal strength, network operator, and modem details
- 🔐 **SIM Management**: Check SIM status, unlock with PIN
- ⚡ **Serial Communication**: Robust serial port handling with configurable parameters
- 🎯 **Event System**: Listen for incoming messages and calls
- 🛠️ **Artisan Commands**: Test connection, send SMS, and monitor modem via CLI
- 🧪 **Well Tested**: Comprehensive test suite included

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- Laravel 11.0 or higher
- Access to serial/USB port for GSM modem connection

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require iamgerwin/gsm-modem
```

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag="gsm-modem-config"
```

This will create a `config/gsm-modem.php` configuration file. Configure your modem connection:

```
return [
    'default' => env('GSM_MODEM_CONNECTION', 'default'),

    'connections' => [
        'default' => [
            'port' => env('GSM_MODEM_PORT', '/dev/ttyUSB0'),
            'baud_rate' => env('GSM_MODEM_BAUD_RATE', 115200),
            'data_bits' => env('GSM_MODEM_DATA_BITS', 8),
            'parity' => env('GSM_MODEM_PARITY', 'none'),
            'stop_bits' => env('GSM_MODEM_STOP_BITS', 1),
            'flow_control' => env('GSM_MODEM_FLOW_CONTROL', 'none'),
        ],
    ],

    'sms_mode' => env('GSM_MODEM_SMS_MODE', 'TEXT'), // TEXT or PDU
    'pin' => env('GSM_MODEM_PIN', null),
    'auto_connect' => env('GSM_MODEM_AUTO_CONNECT', false),
    'debug' => env('GSM_MODEM_DEBUG', false),
];
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use Iamgerwin\GsmModem\GsmModem;

$modem = new GsmModem();

// Connect to modem
$modem->open('/dev/ttyUSB0', ['baudRate' => 115200]);

// Send SMS
$modem->sendSms('+1234567890', 'Hello from Laravel!');

// Get inbox messages
$messages = $modem->getInbox();
foreach ($messages as $message) {
    echo "From: {$message->sender}\n";
    echo "Message: {$message->message}\n";
    echo "Time: {$message->timestamp->format('Y-m-d H:i:s')}\n";
}

// Get signal strength
$signal = $modem->getSignalStrength(); // Returns percentage (0-100)

// Make a call
$modem->makeCall('+1234567890');

// Send USSD
$response = $modem->sendUssd('*123#');

// Close connection
$modem->close();
```

### Using the Facade

[](#using-the-facade)

```
use Iamgerwin\GsmModem\Facades\GsmModem;

// Send SMS
GsmModem::sendSms('+1234567890', 'Hello!');

// Get network info
$network = GsmModem::getNetworkInfo();
// Returns: ['operator' => 'Vodafone', 'mode' => '4G']

// Get modem info
$info = GsmModem::getModemInfo();
// Returns: ['manufacturer' => 'Huawei', 'model' => 'E3531', 'imei' => '...']
```

### Event Listeners

[](#event-listeners)

```
$modem = new GsmModem();

// Listen for new messages
$modem->on('new_message', function($message) {
    Log::info("New SMS from {$message->sender}: {$message->message}");
});

// Listen for incoming calls
$modem->on('incoming_call', function($number) {
    Log::info("Incoming call from: {$number}");
});
```

### Artisan Commands

[](#artisan-commands)

Test your modem connection:

```
php artisan gsm-modem:test /dev/ttyUSB0 --baudrate=115200
```

Send SMS via CLI:

```
php artisan gsm-modem:send-sms +1234567890 "Your message here"
```

Monitor modem for incoming messages:

```
php artisan gsm-modem:monitor --interval=5
```

Advanced Features
-----------------

[](#advanced-features)

### PDU Mode

[](#pdu-mode)

For broader modem compatibility, use PDU mode:

```
use Iamgerwin\GsmModem\Enums\SmsMode;

$modem = new GsmModem(['sms_mode' => 'PDU']);
$modem->setSmsMode(SmsMode::PDU);
$modem->sendSms('+1234567890', 'Unicode message: 你好');
```

### SIM Management

[](#sim-management)

```
// Check SIM status
$simInfo = $modem->getSimInfo();
if ($simInfo['status'] === 'PIN_REQUIRED') {
    $modem->unlockSim('1234');
}

// Get own number
$myNumber = $modem->getOwnNumber();
```

### Message Management

[](#message-management)

```
// Delete single message
$modem->deleteMessage(1); // Delete message at index 1

// Delete all messages
$modem->deleteAllMessages();

// Get messages by status
use Iamgerwin\GsmModem\Enums\MessageStatus;

$modem->executeCommand('AT+CMGL=' . MessageStatus::UNREAD->getAtCommand());
```

### Custom AT Commands

[](#custom-at-commands)

Execute any AT command directly:

```
$response = $modem->executeCommand('AT+COPS?', 10000);
```

Serial Port Configuration
-------------------------

[](#serial-port-configuration)

The package supports various serial port configurations:

- **Baud rates**: 9600, 19200, 38400, 57600, 115200, etc.
- **Data bits**: 5, 6, 7, 8
- **Parity**: none, even, odd
- **Stop bits**: 1, 2
- **Flow control**: none, hardware, software

Supported Modems
----------------

[](#supported-modems)

This package works with most GSM modems that support standard AT commands, including:

- Huawei E-series (E3531, E3372, etc.)
- ZTE modems
- Sierra Wireless modems
- Simcom modules (SIM800, SIM900, etc.)
- Quectel modules
- Any Hayes AT command compatible modem

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Run tests with coverage:

```
composer test-coverage
```

Troubleshooting
---------------

[](#troubleshooting)

### Common Issues

[](#common-issues)

1. **Permission denied on serial port**

    ```
    sudo chmod 666 /dev/ttyUSB0
    # Or add your user to the dialout group
    sudo usermod -a -G dialout $USER
    ```
2. **Port not found**

    - Check connected devices: `ls /dev/tty*`
    - Verify modem is connected: `lsusb`
3. **Commands timeout**

    - Increase timeout in config
    - Check baud rate matches your modem
    - Verify modem is powered on

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Gerwin](https://github.com/iamgerwin)
- Inspired by [serialport-gsm](https://github.com/zabsalahid/serialport-gsm) Node.js package

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance60

Regular maintenance activity

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 81.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8f6f1736b8e2833ccb6c4098e4ecb5081d9cd5db2af370fde0365d441fbfbf59?d=identicon)[iamgerwin](/maintainers/iamgerwin)

---

Top Contributors

[![iamgerwin](https://avatars.githubusercontent.com/u/1331683?v=4)](https://github.com/iamgerwin "iamgerwin (9 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

### Embed Badge

![Health badge](/badges/iamgerwin-gsm-modem/health.svg)

```
[![Health](https://phpackages.com/badges/iamgerwin-gsm-modem/health.svg)](https://phpackages.com/packages/iamgerwin-gsm-modem)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
