A Python package for interacting with GSM modems
Project description
GSM Modem
GSM Modem is a powerful and user-friendly Python package designed for seamless interaction with GSM modems. Whether you're building an IoT project, developing a SMS gateway, or simply need to integrate GSM functionality into your Python application, GSM Modem has got you covered!
🚀 Features
- 📤 Send SMS messages with ease
- 📥 Receive and process incoming SMS
- 📊 Monitor modem status and signal strength
- 🔄 Real-time SMS notifications
- 🛡️ Robust error handling and diagnostics
📦 Installation
Install GSM Modem with pip:
pip install pygsmmodem
🏁 Quick Start
Here's a simple example to get you started:
from pygsmmodem import GSMModem, SMSListener
def sms_received_callback(notification):
print(f"New SMS received: {notification}")
# Initialize the modem
modem = GSMModem('COM5') # Replace 'COM5' with your serial port
# Set up SMS listener
listener = SMSListener(modem)
listener.set_callback(sms_received_callback)
listener.start()
# Send an SMS
modem.send_sms("+1234567890", "Hello from GSM Modem!")
# Your main program logic here
# Clean up
listener.stop()
modem.close()
📚 API Reference
GSMModem Class
The main class for interacting with the GSM modem.
Methods:
send_sms(number: str, message: str) -> bool: Send an SMS message.read_sms(index: int) -> Optional[SMS]: Read an SMS by index.list_sms(status: SMSStatus = SMSStatus.ALL) -> List[SMS]: List SMS messages.check_sim_status() -> SIMStatus: Check the status of the SIM card.check_signal_strength() -> SignalStrength: Get the current signal strength.get_modem_info() -> ModemInfo: Retrieve modem information.run_diagnostics(): Run a diagnostic check on the modem.
SMSListener Class
A class for listening to incoming SMS notifications.
Methods:
set_callback(callback: Callable[[SMSNotification], None]): Set the callback for SMS notifications.start(): Start listening for SMS notifications.stop(): Stop listening for SMS notifications.
Other Classes
SMS: Represents an SMS message.SMSStatus: Enum for SMS statuses.SIMStatus: Represents SIM card status.SignalStrength: Represents signal strength.ModemInfo: Contains modem information.
🛠️ Advanced Usage
Handling Different SMS Statuses
from gsm_modem import GSMModem, SMSStatus
modem = GSMModem('COM5')
unread_sms = modem.list_sms(SMSStatus.REC_UNREAD)
for sms in unread_sms:
print(f"Unread SMS: {sms}")
Running Diagnostics
modem = GSMModem('COM5')
modem.run_diagnostics()
🤝 Contributing
We welcome contributions! Please see our CONTRIBUTING.md for details on how to submit pull requests, report issues, or request features.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
📬 Contact
For support or queries, please open an issue on our GitHub repository or contact us at support@gsmmodem.com.
Happy coding with GSM Modem! 🎉📱💻
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygsmmodem-0.1.0.tar.gz.
File metadata
- Download URL: pygsmmodem-0.1.0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
228319ac89ae57038349ed6881224e29fb89972c9902290b5c7e60b10113c924
|
|
| MD5 |
9aa34052f5f7713025a001af9439e180
|
|
| BLAKE2b-256 |
0b35b970419cc727c6127d96f8d5b1f0b5c1b37d91caa0b01ce040ed4a4c72fb
|
File details
Details for the file pygsmmodem-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pygsmmodem-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f94bd81d7b19ae7f7f63b77e348d41ce25c3d4216288a4f6eac7503ce8ef3658
|
|
| MD5 |
f9d999b0a4f4a43cbf1b89bc26da8fcf
|
|
| BLAKE2b-256 |
b7b894f47e19057c77fc5d918dfa6fca4fc8bd4801139dd7192e4d8c1eed45f6
|