Skip to main content

Easy library for interfacing with mobile modems

Project description

sim-modem

Easy library for interfacing with mobile modems. Tested with Simcom SIM7600G-H on Raspberry PI Zero W. The commands could be different for other modems.

Installation

pip install sim-modem

Usage

from sim_modem import Modem

modem = Modem('/dev/ttyUSB2')

signal_quality = modem.get_signal_quality()
print(signal_quality)

modem.send_sms('+393383928434', 'Hello World!')

API

Modem (Class)

Main class for interfacing with the modem. Each method raise an exception if the modem returns an error. If the command is successful, the function returns the response from the modem.

Modem(        
    address, # Address of the device tty (e.g. "/dev/ttyUSB2")
    baudrate=460800, # Baudrate of the device. Default: 460800
    timeout=5, # Timeout for the serial connection. Default: 5
    at_cmd_delay=0.1, # Delay between AT commands. Default: 0.1
    debug=False # Log commands and responses from modem, test command support before executing them. Default: False
)
Method Description
reconnect() -> str Reconnect to serial
close() -> str Close the serial connection
Hardware related methods
get_model_identification() -> str Get the model identification
get_manufacturer_identification() -> str Get the manufacturer identification
get_serial_number() -> str Get the serial number
get_firmware_version() -> str Get the firmware version
get_volume() -> str Get the volume. The volume range is between 0 and 5
set_volume(index: int) # 0-5 Set the volume. The volume range must be between 0 and 5
improve_tdd() -> str Decrease TDD Noise effect
enable_echo_suppression() -> str Enable echo suppression
disable_echo_suppression() -> str Disable echo suppression
Network related methods
get_network_registration_status() -> str Get the network registration status
get_network_mode() -> NetworkMode Get the network mode
get_network_name() -> str Get the network name
get_network_operator() -> str Get the network operator
get_signal_quality() -> str Get the signal quality
get_signal_quality_db() -> int Get the signal quality in dB
get_signal_quality_range() -> SignalQuality Get the signal quality as a range (see SignalQuality)
get_phone_number() -> str Get the phone number
get_sim_status() -> str Get the SIM status
set_network_mode(mode: NetworkMode) -> str Set the network mode
Calls related methods
call(number: str) -> str Call a number
answer() -> str Answer a call
hangup() -> str Hangup a call
SMS related methods
get_sms_list() -> list Get the list of SMS
empty_sms() -> str Empty the SMS storage
send_sms(number: str, message: str) -> str Send an SMS
get_sms(index: int) -> dict Get an SMS by ID
delete_sms(index: int) -> str Delete an SMS by ID
GPS related methods
get_gps_status() -> str Get the GPS status
start_gps() -> str Start the GPS
stop_gps() -> str Stop the GPS
get_gps_coordinates() -> dict Get the GPS coordinates

SignalQuality (enum)

Signal quality expressed as ranges

Key Description
SignalQuality.LOW Signal is under 7
SignalQuality.FAIR Signal is between 7 and 15
SignalQuality.GOOD Signal is between 15 and 20
SignalQuality.EXCELLENT Signal is over 20

NetworkMode (enum)

Network mode of the modem (get/set)

Key Description
NetworkMode.AUTOMATIC Automatic
NetworkMode.GSM_ONLY GSM only
NetworkMode.LTE_ONLY LTE only
NetworkMode.ANY_BUT_LTE Any but LTE

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sim-modem-1.0.1.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sim_modem-1.0.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file sim-modem-1.0.1.tar.gz.

File metadata

  • Download URL: sim-modem-1.0.1.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.15

File hashes

Hashes for sim-modem-1.0.1.tar.gz
Algorithm Hash digest
SHA256 359c07adf339d45320dd3667377fa8142f533fd4e40628231a5554fd8ce2001d
MD5 bc9109f3f8992756f1ed677b8abf9a51
BLAKE2b-256 543abf302b6bd71f56f1db4a6a1c95bdbcae6e19d09cf487f822bd389dc38e36

See more details on using hashes here.

File details

Details for the file sim_modem-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: sim_modem-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.15

File hashes

Hashes for sim_modem-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6e79a7abc8fda8bb11570b66704a833eef5246c2b7d89b1ba40bee9bf2bcb111
MD5 ffceb86abf7d4255b012d245c2b484f2
BLAKE2b-256 a4f2c4397953edbc9527b1a3cc1d0099e064b1e4ab8418188ca3df0796796b72

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page