Sonntag, 12. Juli 2015

Sms from ubuntu with UMTS stick??

It is happened!!! Due to the terrible heat the clusters where overheated.
So I did not notified because of barbeque party. Nice weather, pool, friends..etc..

I did not have wifi on phone but GSM was there. Solution in this case is GSM connection from important services.
I got some telekom huawei stick with mobile data contract.
After plugging it to USB port Under ubuntu 14.04:  you should see something like this in lsusb:
lsusb
Bus 002 Device 006: ID 12d1:1001 Huawei Technologies Co., Ltd. E169/E620/E800 HSDPA Modem
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0c45:6409 Microdia Webcam
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Next step is Gammu
apt-get install gammu-smsd  

next configure it with correct ttyUSB:
/home/arm2arm# cat /etc/gammu-smsdrc
# Configuration file for Gammu SMS Daemon

# Gammu library configuration, see gammurc(5)
[gammu]
# Please configure this!
port = /dev/ttyUSB0
connection = at
# Debugging
#logformat = textall

# SMSD configuration, see gammu-smsdrc(5)
[smsd]
pin=1234
service = files
logfile = syslog
logfile = /var/log/gammu-smsd

# Increase for debugging information
debuglevel = 4
ReceiveFrequency = 300

# Paths where messages are stored
inboxpath = /var/spool/gammu/inbox/
outboxpath = /var/spool/gammu/outbox/
sentsmspath = /var/spool/gammu/sent/
errorsmspath = /var/spool/gammu/error/
 
 Warning: setup your PIN for the SIM card.
Restart the service and check the logs if it is ok:
/etc/init.d/gammu-smsd restart
If you get an error like this:
Sun 2015/07/12 20:29:23 gammu-smsd[4934]: Created POSIX RW shared memory at 0x7f6aff847000
Sun 2015/07/12 20:29:23 gammu-smsd[4934]: Starting phone communication...
Sun 2015/07/12 20:29:23 gammu-smsd[4934]: gammu: [Gammu            - 1.33.0 built 16:20:47 Aug  1 2013 using GCC 4.8]
Sun 2015/07/12 20:29:23 gammu-smsd[4934]: gammu: [Connection       - "at"]
Sun 2015/07/12 20:29:23 gammu-smsd[4934]: gammu: [Connection index - 0]
Sun 2015/07/12 20:29:23 gammu-smsd[4934]: gammu: [Model type       - ""]
Sun 2015/07/12 20:29:23 gammu-smsd[4934]: gammu: [Device           - "/dev/ttyUSB0"]
Sun 2015/07/12 20:29:23 gammu-smsd[4934]: gammu: [Running on       - Linux, kernel 3.13.0-57-generic (#95-Ubuntu SMP Fri Jun 19 09:28:15 UTC 2015)]
Sun 2015/07/12 20:29:23 gammu-smsd[4934]: gammu: [System error     - open in serial_open, 16, "Device or resource busy"]
Sun 2015/07/12 20:29:23 gammu-smsd[4934]: gammu: Init:GSM_TryGetModel failed with error DEVICEOPENERROR[2]: Error opening device. Unknown, busy or no permissions.

It is meaning some application holds your GSM stick.  
lsof  /dev/ttyUSB0 will shouw which program hold it.
WARNING: If you want to send SMS you should disable mobile data over the stick.
 

That's it you are done.
Let us test if we can send and recieve SMS:
from terminal try following:
echo "Test-SMS from ubuntu" | sudo gammu-smsd-inject TEXT "+49176xxxxxxxx"
Put your cell phone number and in a few second you will get the test SMS from laptop.