Warning: session_start(): open(/tmp/sess_0c2435df70cc711ab1a1f352751dc559, O_RDWR) failed: No space left on device (28) in /var/www/html/inc/init.php on line 265

Warning: session_start(): Failed to read session data: files (path: ) in /var/www/html/inc/init.php on line 265
Writing /var/www/html/data/log/error/2024-06-17.log failed

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/inc/init.php:265) in /var/www/html/inc/auth.php on line 432
Writing /var/www/html/data/log/error/2024-06-17.log failed

Warning: Trying to access array offset on value of type bool in /var/www/html/inc/parserutils.php on line 313
Writing /var/www/html/data/log/error/2024-06-17.log failed

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/inc/init.php:265) in /var/www/html/inc/actions.php on line 38
sms_gateway [Ben's notes]

Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


PC Engines APU - SMS Gateway

APU1 / GSM antenna



Prepare hardware

Install and configure CentOS 6.5

Note: i've had a problem with the stock 2.6 kernel and installed 3.14 kernel-ml from elrepo.

  • Connect via serial with screen (or minicom).
    screen /dev/cu.usbserial-A7022UE0 115200
  • Install CentOS 6.5 x86_64, using PXE and Kickstart.
  • Configure networking.
  • Configure hostname, mail relayhost and install k10temp module and lm_sensors: CentOS 6.5 on APU - post install.
  • Configure NTPd.
    yum install ntp
    # vi /etc/ntp.conf
    # update servers
    chkconfig ntpd on
    ntpdate ntp1.polaire.nl
    service ntpd start

Configure Huawei MU609 miniPCIe

  • Install minicom.
    yum install minicom
  • Check to see if device is recognized.
    # dmesg |grep -i huawei
    usb 1-2: Product: HUAWEI Mobile
    usb 1-2: Manufacturer: Huawei Technologies
    dmesg |grep CDC
    cdc_ether 2-1:2.0 eth3: register 'cdc_ether' at usb-0000:00:13.2-1, CDC Ethernet Device, 00:a0:c6:41:37:70
  • Determine USB tty's.
    # ls /dev |grep -i ttyusb
    • ttyUSB0: MODEM port: simulated using USB, for AT command interaction and establishing data connection.
    • ttyUSB1: DIAG port: simulated using USB, for DIAG (diagnostic) command interaction (mainly used to debug modules at present).
    • ttyUSB2: PCUI port: simulated using USB, for AT command interaction only.
    • ttyUSB3: GPS NMEA port: simulated using USB, sending unsolicited indications for NMEA positioning data only.
    • ttyUSB4: GPS Control port: simulated using USB, for GPS AT command interaction only.
    • eth3: ECM port: for establishing communication connection.
  • Connect to the gsm module.
    minicom -s
  • Go to 'Serial port setup' →
    • Serial Device: /dev/ttyUSB2
    • Bps/Par/Bits: 115200 8N1
  • Go back and then to 'Modem and dialing parameter setup'
    • Clear init string and reset string.
  • Select 'Save setup as dfl'.
  • Select 'Exit'.
  • Check SIM.
    +CME ERROR: SIM PIN required
  • If you see +CME ERROR: SIM failure check if the SIM card is inserted and the module is in mPCIe 2 slot.
  • enter SIM PIN.
    ^SIMST: 1
    ^SRVST: 2
  • Check status operator selection. In this case; 0=automatic, 0=long alfanumeric, string, 2=current.
    +COPS: 0,0,"simyo",2
  • Check network status. 0=report off, 1=registered
    +CREG: 0,1
  • Query signal strength. Good signal strength here: -79 dBm (17 * 2 – 113).
    +CSQ: 17,99

Install and configure SMS Server tools 3

  • Install smstools package.
    yum install smstools
  • Auto-start smsd.
    chkconfig smsd on
  • Edit /etc/smsd.conf.
    device = /dev/ttyUSB2
    incoming = yes
    pin = 1234
    # disable unsolicited results (like ^RSSI)
    init = AT^CURC=0
  • View log /var/log/smsd/.
    2014-05-30 10:27:23,2, smsd: Smsd v3.1.15 started.
    2014-05-30 10:27:23,2, smsd: Running as smstools:smstools.
    2014-05-30 10:27:23,7, smsd: Running startup_check (shell): /var/spool/sms/incoming/smsd_script.a7tj8n /tmp/smsd_data.4OfwfP
    2014-05-30 10:27:23,7, smsd: Done: startup_check (shell), execution time 0 sec., status: 0 (0)
    2014-05-30 10:27:23,4, smsd: File mode creation mask: 022 (0644, rw-r--r--).
    2014-05-30 10:27:23,5, smsd: Outgoing file checker has started. PID: 1273.
    2014-05-30 10:27:23,7, smsd: All PID's: 1273,1274
    2014-05-30 10:27:23,5, GSM1: Modem handler 0 has started. PID: 1274.
    2014-05-30 10:27:23,5, GSM1: Using check_memory_method 1: CPMS is used.
    2014-05-30 10:27:23,6, GSM1: Checking device for incoming SMS
    2014-05-30 10:27:23,6, GSM1: Checking if modem is ready
    2014-05-30 10:27:23,7, GSM1: -> AT
    2014-05-30 10:27:23,7, GSM1: Command is sent, waiting for the answer
    2014-05-30 10:27:23,7, GSM1: <- AT OK
    2014-05-30 10:27:23,6, GSM1: Pre-initializing modem
    2014-05-30 10:27:24,7, GSM1: -> ATE0+CMEE=1;+CREG=2
    2014-05-30 10:27:24,7, GSM1: Command is sent, waiting for the answer
    2014-05-30 10:27:24,7, GSM1: <- ATE0+CMEE=1;+CREG=2 OK
    2014-05-30 10:27:24,6, GSM1: Checking if modem needs PIN
    2014-05-30 10:27:24,7, GSM1: -> AT+CPIN?
    2014-05-30 10:27:24,7, GSM1: Command is sent, waiting for the answer
    2014-05-30 10:27:24,7, GSM1: <- +CPIN: READY OK
    2014-05-30 10:27:25,7, GSM1: -> AT+CSQ
  • Send test SMS
    • switch so smstools user.
      su - smstools
    • Create a script:
      OUT=$(mktemp /var/spool/sms/outgoing/sms.XXXXXXXXXX) || { echo "Failed to create temp file"; exit 1; }
      echo -n "To: 31612345678\n\nHello, this is the sms."  >> $OUT
    • chmod +x yourscript, and run it… The smsd.log will show:
      2014-05-30 10:44:55,6, GSM1: I have to send 1 short message for /var/spool/sms/checked/sms.XNBpdjgPIL
      2014-05-30 10:44:55,6, GSM1: Sending SMS from  to 31612345678
      2014-05-30 10:44:55,6, GSM1: Checking if modem is ready
  • Reduce logging, edit /etc/smsd.conf and reload.
    loglevel = 5
    service smsd restart
  • Received SMS's wil be placed in /var/spool/sms/incoming.

Example: execute script upon receiving SMS

If you want the APU speaker to beep, see: PC Engines APU - speaker CentOS 6.5 And if you want other users than root to use beep, set the setuid bit.

chmod 4755 /usr/bin/beep
  • Create /usr/local/bin/smsevent
    if [ "$1" == "RECEIVED" ]; then
      beep -f700 -l100 -d100 -r3 -n -f1 -l300 -n -f700 -l300 -r2 -n -f1 -l300 -n -f700 -l100 -d100 -r3
  • chmod +x /usr/local/bin/smsevent
  • Edit /etc/smsd.conf.
    eventhandler = /usr/local/bin/smsevent
  • Restart smsd.
    service smsd restart

AT Commands

AT Command Description
AT+CPIN=“1234” Enter PIN
AT+CPIN? Request PIN info
AT+COPS? Check status operator selection
AT+CREG? Check network status
AT+CSQ Query signal strength
ATI Information, manufacturer, product, version, etc..
AT+GMI Manufacturer
AT+GMM Product model
AT+GMR Software version
AT+GCAP Capability list
AT+CCLK=“2014/05/30,16:12:30” Set time/date
AT+CCLK? Read clock
sms_gateway.txt · Last modified: 2021/10/09 15:14 by