Gsm modem and sms sending in OpenWrt
On the stage of configuration OpenWrt the following modules are to be selected:
I had a problem with the installation of the module kmod-usb-serial-wwan. mesg gave out the following after downloading:
option: Unknown symbol usb_wwan_write (err 0)
option: Unknown symbol usb_wwan_close (err 0)
option: Unknown symbol usb_wwan_release (err 0)
option: Unknown symbol usb_wwan_tiocmget (err 0)
option: Unknown symbol usb_wwan_chars_in_buffer (err 0)
option: Unknown symbol usb_wwan_write_room (err 0)
option: Unknown symbol usb_wwan_disconnect (err 0)
option: Unknown symbol usb_wwan_startup (err 0)
option: Unknown symbol usb_wwan_set_termios (err 0)
option: Unknown symbol usb_wwan_dtr_rts (err 0)
option: Unknown symbol usb_wwan_open (err 0)
option: Unknown symbol usb_wwan_tiocmset (err 0)
It can be solved by editing the file 'package/kernel/modules/usb.mk'.
Add the section 'kmod-usb-serial-wwan'
TITLE:=Support for GSM and CDMA modems
$(eval $(call KernelPackage,usb-serial-wwan))
All this are described here: https://dev.openwrt.org/ticket/7731. Thanks a lot to the author.
root@OpenWrt:/# opkg install kmod-usb-serial kmod-usb-serial-wwan kmod-usb-serial-option
Installing kmod-usb-serial-wwan (2.6.36-1) to root...
Installing kmod-usb-serial (2.6.36-1) to root...
Installing kmod-usb-serial-option (2.6.36-1) to root...
Connect the modem and check the output dmesg:
usbcore: registered new interface driver usbserial
USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
USB Serial support registered for GSM modem (1-port)
option 1-1.2:1.0: GSM modem (1-port) converter detected
usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB0
option 1-1.2:1.1: GSM modem (1-port) converter detected
usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB1
option 1-1.2:1.3: GSM modem (1-port) converter detected
usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB2
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
The modem has been detected. We can start to use it. As we can see from the log 3 devices ttyUSB were created: interface for working with sd-card, interface to configure of device, interface of data communication. We need the interface of data communication, I have ttyUSB1.
It’s easy to detect what from 3 interfaces we need. Connect the modem to the computer, start the terminal on speed of 19200 and put in the command ati. The modem should respond.
Manufacturer: ZTE INCORPORATED
For sms sending we use the utility smstools. At the moment of writing of this article it isn’t included in the standard utilities of openwrt. Therefore we download the sources from:
It should be compiled by using a cross-compiler from openwrt. For this we should add in the file smstools3/src/Makefile нужно добавить строчку:
It means to show the path to the cross-compiler.
Start make. In smstools3/src/ we find a demon file of sms-server smsd, which we copy to the file system in /usr/sbin. At the same time we put into the directory /etc the configuration file smsd.conf which is necessary for the start of smsd.
devices = GSM1
logfile = /var/log/smstools/smsd.log
loglevel = 7
device = /dev/ttyUSB1
incoming = no
# Service Center Address
smsc = 79168960220
send_delay = 10
baudrate = 19200
rtscts = no
Downloading. For the operation of smsd we need to create the following directories (we create them using mkdir):
|# smsd -c /etc/smsd.conf &|
Check the log and see that the modem has been initiated:
|tail -f /var/log/smstools/smsd.log|
We can send sms. Sms are sending automatically after the file with sms will be placed into the directory /var/spool/sms/outgoing/
Create the file send_sms.sms and place it into this directory:
Hello from OpenWrt!
Check the log and see that the server detected a new sms which wasn’t sent, begun with its sending and after sending deleted the file:
tail -f /var/log/smstools/smsd.log
1970-01-01 00:03:54,5, GSM1: Waiting for messages to send...
1970-01-01 00:05:23,5, smsd: Moved file /var/spool/sms/outgoing/send_sms.sms to /var/spool/sms/checked
1970-01-01 00:05:23,6, GSM1: I have to send 1 short message for /var/spool/sms/checked/send_sms.sms
1970-01-01 00:05:23,6, GSM1: Sending SMS from to 79161737465
1970-01-01 00:05:23,6, GSM1: Checking if modem is ready
1970-01-01 00:05:24,7, GSM1: -> AT
1970-01-01 00:05:24,7, GSM1: Command is sent, waiting for the answer
1970-01-01 00:05:24,7, GSM1: <- OK
1970-01-01 00:05:24,6, GSM1: Pre-initializing modem
1970-01-01 00:05:24,7, GSM1: -> ATE0+CMEE=1;+CREG=2
1970-01-01 00:05:27,6, GSM1: Signal Strength Indicator: (13,99) -87 dBm (Workable), Bit Error Rate: not known or not detectable
1970-01-01 00:05:27,6, GSM1: Checking if Modem is registered to the network
1970-01-01 00:05:27,7, GSM1: -> AT+CREG?
1970-01-01 00:05:28,7, GSM1: Command is sent, waiting for the answer
1970-01-01 00:05:28,7, GSM1: <- +CREG: 0,1 OK
1970-01-01 00:05:28,6, GSM1: Modem is registered to the network
1970-01-01 00:05:28,6, GSM1: Selecting PDU mode
1970-01-01 00:05:29,7, GSM1: -> AT+CMGF=0
1970-01-01 00:05:29,7, GSM1: Command is sent, waiting for the answer
1970-01-01 00:05:30,7, GSM1: <- +ZUSIMR:2 OK
1970-01-01 00:05:30,6, GSM1: Changing SMSC
1970-01-01 00:05:30,7, GSM1: -> AT+CSCA="+79168960220"
1970-01-01 00:05:32,7, GSM1: Command is sent, waiting for the answer
1970-01-01 00:05:32,7, GSM1: <- +ZUSIMR:2 OK
1970-01-01 00:05:32,7, GSM1: -> AT+CMGS=29
1970-01-01 00:05:33,7, GSM1: Command is sent, waiting for the answer
1970-01-01 00:05:33,7, GSM1: <- >
1970-01-01 00:05:33,7, GSM1: -> 0011000B919711257733F30000FF115079DA5EA683D27A50FB4D2EB7C321#
1970-01-01 00:05:38,7, GSM1: Command is sent, waiting for the answer
1970-01-01 00:05:42,7, GSM1: <- +ZUSIMR:2 +ZUSIMR:2 +ZUSIMR:2 +ZUSIMR:2 +CMGS: 174 OK
1970-01-01 00:05:42,5, GSM1: SMS sent, Message_id: 174, To: 79161737465, sending time 19 sec.
1970-01-01 00:05:42,6, GSM1: Deleted file /var/spool/sms/checked/send_sms.sms