Skip to content

Commit 0e530c0

Browse files
committed
Initial release
0 parents  commit 0e530c0

File tree

8 files changed

+1099
-0
lines changed

8 files changed

+1099
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.pyc
2+
build/
3+
dist/
4+
gsmmodem_manager.egg-info/

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
gsmmodem-manager (0.1)
2+
3+
* Initial release
4+
5+
-- J. Félix Ontañón <felixonta@podgroup.com> Tue, 20 Nov 2018 18:00:00 +0100

LICENSE

Lines changed: 457 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# python-gsmmodem-manager
2+
3+
Framework for communicating and interacting with 2G/3G/4G usb modems
4+
5+
## Table of Contents
6+
7+
- [Description](#description)
8+
- [Hardware supported](#hardware)
9+
- [Installation](#installation)
10+
- [Usage](#usage)
11+
- [Contributing](#contributing)
12+
- [To Do](#todo)
13+
- [Standards](#standards)
14+
15+
16+
## Description
17+
18+
Modems usually offer an interface via AT commands. A serial protocol originally developed by [Dennis Hayes](https://en.wikipedia.org/wiki/Hayes_command_set). There's a basic set of AT commands almost all modems support, and an extended set only some support. Every single manufacturer adds their extended set of commands to provide with vendor specific functionallity.
19+
20+
This python library is aimed to encapsulate all complicated vendor specific logic of USB modems and serving a common library to perform typical operations like:
21+
22+
- Selecting a network operator.
23+
- Choosing an access technology (2G/3G/4G).
24+
- Registering in the network.
25+
- Activating/deactivating a PDP context.
26+
- Get IMEI from device. Get IMSI from SIM card.
27+
- etc.
28+
29+
## Hardware
30+
31+
So far, the list of supported modems are:
32+
33+
- Huawei MS2131
34+
- Huawei MS2372h
35+
- Huawei E3372
36+
37+
Plese have a look the [Contributing](#contributing) section to extend support for other modems.
38+
Let's join efforts!
39+
40+
## Installation
41+
42+
You can install via pip from our Github repository directly (pending to submit to [pypi](https://pypi.org))
43+
44+
```shell
45+
pip install https://github.com/PodgroupConnectivity/python-gsmmodem-manager
46+
```
47+
48+
## Usage
49+
50+
```python
51+
# Lets use a generic modem and test some basic AT commands
52+
from gsmmodem_manager import GSMModem, signal_quality
53+
54+
# The USB modem is attached to /dev/ttyUSB0. Let's communicate with 9600 baud.
55+
modem = GSMModem("/dev/ttyUSB0", "9600")
56+
57+
modem.get_imei() # (True, 'AT+GSN', '{IMEI CODE GOES HERE}')
58+
modem.get_imsi() # (True, 'AT+CIMI', '{IMSI CODE GOES HERE}')
59+
modem.set_operator('21401') # (True, 'AT+COPS=1,2,"21401"', None)
60+
sq = modem.get_signal_quality() # (True, 'AT+CSQ', '11,99')
61+
signal_quality(sq[2]) # 'Excellent'
62+
63+
# Let's use a specific Huawei MS2131 modem now
64+
from gsmmodem_manager import HuaweiMS2131
65+
modem = GSMModem("/dev/ttyUSB0", "9600")
66+
67+
# The following snipped selects Spain Vodafone 4G, registers and acquire data.
68+
# Please note this does not generate a PPP interface, but establish the session.
69+
modem.set_operator('21401') # Selects Spain Vodafone
70+
modem.set_access_technology(HuaweiMS2131.ACT_UMTS) # Choses 4G. Each modem has its own codes.
71+
modem.register() # Registers in the network
72+
modem.activate_pdp_context() # Acquires PDP Context (data session)
73+
modem.deactivate_pdp_context() # Closes PDP Context (data session)
74+
```
75+
76+
## Contributing
77+
78+
Please contribute using [Github Flow](https://guides.github.com/introduction/flow/). Create a branch, add commits, and [open a pull request](https://github.com/fraction/readme-boilerplate/compare/).
79+
80+
Please note this source code has been released under the GPLv3 terms and all contributions will be considered under the same license. Have a look at the LICENSE file distributed with this code.
81+
82+
## TODO
83+
84+
The following is a non-comprehensive list of pending developments to add.
85+
We're happy to accept any contribution :)
86+
87+
- Hot-detecting the USB modem and determine whether it is compatible or not. Via UDEV.
88+
- Listen to udev events when USB modem is available or not to pause/resume any activity.
89+
- Finish compatibility with K3765 HSPA
90+
91+
## Standards
92+
93+
[AT command set for User Equipment](https://www.etsi.org/deliver/etsi_ts/127000_127099/127007/10.03.00_60/ts_127007v100300p.pdf)

gsmmodem_manager/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# vim: ts=4
4+
###
5+
#
6+
# Copyright (c) 2016-2018 Pod Group Ltd
7+
# Authors : J. Félix Ontañón <felix.ontanon@podgroup.com>
8+
9+
from lib import signal_quality, GSMModem, HuaweiModem, HuaweiMS2131, HuaweiMS2372h, HuaweiE3372

0 commit comments

Comments
 (0)