Gammu und USSD codes

Ich bastel ja schon länger mit dem GSM USB Stick (Huawei E1750) am Rasperry Pi rum. Dabei sind mir ein paar Sachen wichtig und ein paar gar nicht.
Wichtig ist SMS senden und empfangen, Guthaben abfragen und aufladen. Das war es auch schon. Mehr brauche nicht nicht um Bob zu steuern. Der SMS versand funktioniert schon länger. Aber die USSD Codes habe ich nie hinbekommen. Hatte es am Anfang mal versucht, dann aber sein lassen, da es einfach nicht ging. Ich dachte schon das es am Stick liegt und er USSD einfach nicht unterstützt. Heute habe ich es dann doch endlich noch hinbekommen.

Woran lag es?
1) Der GSM USB Stick belegt gleich 2-3 Geräte. /ttyUSB0-2
2) Es gibt neben Gammu noch einen Service (gammu-smsd) der für den SMS Versand zuständig ist.

So, nun hat Gammu eine Config Datei (~/.gammurc). Logisch soweit. Der SMS Daemon hat aber auch noch mal eine eigene (/etc/gammu-smsdrc). Und genau hier lag der Hund begraben.

Ich hatte bei der Installation damals in die SMS Daemon Config den /ttyUSB2 angegeben. Den hat der Servie dann dauerhaft belegt (da der Service bei mir dauerhaft läuft), um auf eingehende SMS zu warten bzw. ausgehende zu versenden.
Wenn ich jetzt versucht habe einen USSD Code in der Shell auszuführen (z.B. gammu getussd *100#), hat Gammu versucht über /ttyUSB0 den USSD auszuführen. Dumm nur das dieser Port USSD nicht unterstützt. Das macht nämlich nur der ttyUSB2… der ja aber vom SMS Daemon belegt war.

Die Lösung ist so einfach, wenn man es weiß. Der SMS Versand geht problemlos auch über ttyUSB0… Also einmal genau umdrehen. Der SMS Daemon hat /ttyUSB0 bekommen und Gammu /ttyUSB2. Damit funktioniert das jetzt wunderbar. :)

Meine ~/.gammurc sieht jetzt so aus:

# This is a generated gammurc file.
# It was generated by Gammu configurator 0.4

# In Unix/Linux : copy it into your home directory and name it .gammurc
# or into /etc and name it gammurc
# In Win32 : copy it into directory with Gammu.exe and name gammurc

# Port : in Windows/DOS: "com*:",
# (instead of "*" please put "1", "2", etc.)
# in other (Linux/Unix) "/dev/ttyS%"
# or "/dev/ircomm%" ("irda" connection)
# (instead of "%" please put "0", "1", "2", etc.)
# Model : use only, when Gammu doesn't recognize your phone model.
# Put it here. Example values: "6110", "6150", "6210", "8210"
# Connection : type of connection. Use "fbus" or "mbus" or "dlr3" or
# "irda" (Infrared over sockets) or "infrared" (DirectIR)
# or "at19200" (AT commands on 19200, 8 bits, None parity,
# 1 stop bit, no flow control) or "at115200" (AT commands on
# 115200, 8 bits, None parity, 1 stop bit, no flow control)
# or "atblue" (AT over BlueTooth) or "dlr3blue" (FBUS
# over BlueTooth)
# SynchronizeTime: if you want to set time from computer to phone during
# starting connection. Do not rather use this option when want
# to reset phone during connection (in some phones need to
# set time again after restart)
# Logfile : Use, when want to have logfile from communication.
# Logformat : What debug info and format should be used:
# "nothing" - no debug level, "text" - transmission dump in
# text format, "textall" - all possible info in text format,
# "errors" - errors in text format, "binary" - transmission
# dump in binary format
# Use_Locking : under Unix/Linux use "yes", if want to lock used device
# to prevent using it by other applications
# GammuLoc : name of localisation file

[gammu]
port = /dev/ttyUSB2
model = auto
connection = at
synchronizetime = yes
logfile = /home/pi/gammu.log
logformat = textalldate
use_locking =
gammuloc =

[gammu1]
port=/dev/ttyUSB1
mode=auto
connection=at

Und meine /etc/gammu-smsdrc so:

# Configuration file for Gammu SMS Daemon

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

# SMSD configuration, see gammu-smsdrc(5)
[smsd]
service = SQL
driver = native_mysql
#logfile = syslog
# Increase for debugging information
debuglevel = 1
logfile = /home/pi/gammu.log
MaxRetries = 10
commtimeout = 30
sendtimeout = 30

user = ***
password = ***
host = localhost
database = gammu

runonreceive = sudo python /home/pi/bob/sms_dealing.py

# 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/

Jetzt kann ich endlich auch aus der Weboberfläche von Bob das Guthaben aufladen und besonders auch den aktuellen Guthabenstand einsehen. Ist ja nicht ganz unwichtig, wenn man Warnungen per SMS bekommen möchte.

0 Kommentare

Hinterlasse einen Kommentar

An der Diskussion beteiligen?
Hinterlasse uns deinen Kommentar!

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Ich stimme der Datenschutzerklärung zu