|
| 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) |
0 commit comments