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 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.3.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.3-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sim-modem-1.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 7099ca4c860be756096db17248803a7b07ef587dfc6521084a16828a4fc9c3e1
MD5 f004a89227bf1e18bd4e07416c22375f
BLAKE2b-256 eaa8a5a2cc543a88679a61ef44a2052e79def06fdf5e00e584e47b2ea8796c6c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sim_modem-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.1 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 54f989ce56a21bda7ff5c5f427be6693c89a1298e4b778198f4e70d9b80fb7a2
MD5 073308262c65d5b4e9636e3d95236b61
BLAKE2b-256 6c95e464685c00c2144f03df00d146784e0bbe53619dcafce02e88cb546955dd

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