I always wanted to write a python text message platform and use the text message modem as an interface to achieve two-way communication and remote control with the mobile phone. Google recently discovered the RapidSMS framework, it is exactly what I think and need.
The RapidSMS framework mainly integrates Django as the implementation of the Web interface and the management of the background database. The underlying layer uses a library called pygsm to interact with the modem. This library can also be used independently, it is very convenient to send and receive text messages, and also supports the SMS gateway mode.
RapidSMS installation:
If pygsm is not installed, install pygsm, https://github.com/rapidsms/pygsm first
The simple easy_install RapidSMS will be OK, and the dependency will be automatically processed, and the dependent libraries and packages will be installed.
Install sms modem:
You can refer to the text in the text message development category. There is a lot of information on the Internet, so I will not go into details.
RapidSMS Getting Started:
RapidSMS directly imitates Django in many places, such as the command line.
1. Create a new project rapidsms-admin.py startproject myproject
2. You can see that the directory structure and generated file are similar to those of Django. Edit settings. py:
Configure the sms modem and enter "Port" in the connection port of the sms modem:
INSTALLED_BACKENDS = {
"att": {
"ENGINE": "rapidsms.backends.gsm",
"PORT": "com1"
},
#"verizon": {
# "ENGINE": "rapidsms.backends.gsm,
# "PORT": "/dev/ttyUSB1"
#},
"message_tester": {
"ENGINE": "rapidsms.backends.bucket",
}
}
3. Python manage. py syncdb. This is the same as Django. Synchronize the database and enter the user name and password.
4. Python manage. py runrouter starts the router and establishes an interactive loop with the SMS Server.
Python manage. py runserver 8080 starts Django's Web Service
After the above two services are started, the text message service and the Web service will be connected. By sending a text message to the phone number of the text message server, the information will be processed and saved to the database, access the web page to view the received and sent information.