Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
sms_versand_mit_raspberry [2015/06/23 15:24] admin [SMS Versand mit Raspberry] |
sms_versand_mit_raspberry [2015/06/24 14:04] (aktuell) admin |
||
---|---|---|---|
Zeile 8: | Zeile 8: | ||
<code bash> | <code bash> | ||
apt-get install smstools | apt-get install smstools | ||
+ | #ggfls. z.B. für 1&1 Surfstick (19d2:0031 ZTE WCDMA Technologies MSM MF110/MF627/MF636) | ||
+ | apt-get install usb-modeswitch usb-modeswitch-data | ||
</code> | </code> | ||
Zeile 13: | Zeile 15: | ||
<code bash 99-gsm-usb.rules> | <code bash 99-gsm-usb.rules> | ||
- | # 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC | + | # TELTONIKA ModemUSB/E10 UM1000 (0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC) |
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="ttyUSB.GSM" | SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="ttyUSB.GSM" | ||
- | # CEP-CT63-USB | + | # CEP-CT63-USB (1e2d:004f) |
SUBSYSTEM=="tty", ATTRS{idVendor}=="1e2d", ATTRS{idProduct}=="004f", SYMLINK+="ttyUSB.GSM" | SUBSYSTEM=="tty", ATTRS{idVendor}=="1e2d", ATTRS{idProduct}=="004f", SYMLINK+="ttyUSB.GSM" | ||
- | # 0aeb:0040 TTP Communications, Ltd | + | # TELTONIKA ModemUSB/E10 UM1200 (0aeb:0040 TTP Communications, Ltd) |
SUBSYSTEM=="tty", ATTRS{idVendor}=="0aeb", ATTRS{idProduct}=="0040", SYMLINK+="ttyUSB.GSM" | SUBSYSTEM=="tty", ATTRS{idVendor}=="0aeb", ATTRS{idProduct}=="0040", SYMLINK+="ttyUSB.GSM" | ||
</code> | </code> | ||
Zeile 23: | Zeile 25: | ||
In der '/etc/smsd.conf' ist in erster Linie der Abschnitt "[GSM1]" anzupassen. Hier kommen je nach Modem möglicherweise auch unterschiedliche init-Strings zum Tragen. | In der '/etc/smsd.conf' ist in erster Linie der Abschnitt "[GSM1]" anzupassen. Hier kommen je nach Modem möglicherweise auch unterschiedliche init-Strings zum Tragen. | ||
<code bash> | <code bash> | ||
+ | # vi /etc/smsd.conf | ||
+ | # ... | ||
[GSM1] | [GSM1] | ||
- | # CEP-CT63-USB | + | # CEP-CT63-USB, 1&1 SURFSTICK (ZTE MF110) |
#init = AT+CMEE=2 | #init = AT+CMEE=2 | ||
# TELTONIKA | # TELTONIKA | ||
init = ATE0+CMEE=1;+CREG=2 | init = ATE0+CMEE=1;+CREG=2 | ||
device = /dev/ttyUSB.GSM | device = /dev/ttyUSB.GSM | ||
+ | # 1&1 SURFSTICK (ZTE MF110) | ||
+ | #device = /dev/ttyUSB1 | ||
+ | #device = /dev/ttyUSB2 | ||
incoming = yes | incoming = yes | ||
pin = 4711 | pin = 4711 | ||
baudrate = 115200 | baudrate = 115200 | ||
+ | </code> | ||
+ | |||
+ | Der 'smstools'-Daemon verschickt nun Dateien, die folgenenden Aufbau haben und unter '/var/spool/sms/outgoing' abgelegt werden. Nach dem Versand werden diese nach '/var/spool/sms/sent' verschoben. | ||
+ | |||
+ | <code text> | ||
+ | To: <Empängernummer> | ||
+ | |||
+ | Text der SMS | ||
+ | </code> | ||
+ | |||
+ | Hilfreich hierbei ist ein bash-Skript 'sendsms', dass die Empfänger-Rufnummer und den SMS-Text als Übergabeparameter erwartet. | ||
+ | |||
+ | <code bash> | ||
+ | /home/pi/sendsms 491775599001 "Test vom Pi" | ||
+ | </code> | ||
+ | |||
+ | <code bash sendsms> | ||
+ | #!/bin/bash | ||
+ | # This script send a text sms at the command line by creating | ||
+ | # a sms file in the outgoing queue. | ||
+ | |||
+ | # $1 is the destination phone number. | ||
+ | # $2 is the message text. | ||
+ | # If you leave $2 or both empty, the script will ask you. | ||
+ | # If you give more than 2 arguments, last is taken as a text and | ||
+ | # all other are taken as destination numbers. | ||
+ | # If a destination is asked, you can type multiple numbers | ||
+ | # delimited with spaces. | ||
+ | |||
+ | # Keys for example: "password" and "keke": | ||
+ | # KEYS="5f4dcc3b5aa765d61d8327deb882cf99 4a5ea11b030ec1cfbc8b9947fdf2c872 " | ||
+ | |||
+ | KEYS="" | ||
+ | |||
+ | # When creating keys, remember to use -n for echo: | ||
+ | # echo -n "key" | md5sum | ||
+ | |||
+ | smsd_user="smsd" | ||
+ | |||
+ | # Will need echo which accepts -n argument: | ||
+ | ECHO=echo | ||
+ | case `uname` in | ||
+ | SunOS) | ||
+ | ECHO=/usr/ucb/echo | ||
+ | ;; | ||
+ | esac | ||
+ | |||
+ | if ! [ -z "$KEYS" ]; then | ||
+ | printf "Key: " | ||
+ | read KEY | ||
+ | if [ -z "$KEY" ]; then | ||
+ | echo "Key required, stopping." | ||
+ | exit 1 | ||
+ | fi | ||
+ | KEY=`$ECHO -n "$KEY" | md5sum | awk '{print $1;}'` | ||
+ | if ! echo "$KEYS" | grep "$KEY" >/dev/null; then | ||
+ | echo "Incorrect key, stopping." | ||
+ | exit 1 | ||
+ | fi | ||
+ | fi | ||
+ | |||
+ | DEST=$1 | ||
+ | TEXT=$2 | ||
+ | |||
+ | if [ -z "$DEST" ]; then | ||
+ | printf "Destination(s): " | ||
+ | read DEST | ||
+ | if [ -z "$DEST" ]; then | ||
+ | echo "No destination, stopping." | ||
+ | exit 1 | ||
+ | fi | ||
+ | fi | ||
+ | |||
+ | if [ -z "$TEXT" ]; then | ||
+ | printf "Text: " | ||
+ | read TEXT | ||
+ | if [ -z "$TEXT" ]; then | ||
+ | echo "No text, stopping." | ||
+ | exit 1 | ||
+ | fi | ||
+ | fi | ||
+ | |||
+ | if [ $# -gt 2 ]; then | ||
+ | n=$# | ||
+ | while [ $n -gt 1 ]; do | ||
+ | destinations="$destinations $1" | ||
+ | shift | ||
+ | n=`expr $n - 1` | ||
+ | done | ||
+ | TEXT=$1 | ||
+ | else | ||
+ | destinations=$DEST | ||
+ | fi | ||
+ | |||
+ | echo "-- " | ||
+ | echo "Text: $TEXT" | ||
+ | |||
+ | ALPHABET="" | ||
+ | if which iconv > /dev/null 2>&1; then | ||
+ | if ! $ECHO -n "$TEXT" | iconv -t ISO-8859-15 >/dev/null 2>&1; then | ||
+ | ALPHABET="Alphabet: UCS" | ||
+ | fi | ||
+ | fi | ||
+ | |||
+ | owner="" | ||
+ | if [ -f /etc/passwd ]; then | ||
+ | if grep $smsd_user: /etc/passwd >/dev/null; then | ||
+ | owner=$smsd_user | ||
+ | fi | ||
+ | fi | ||
+ | |||
+ | for destination in $destinations | ||
+ | do | ||
+ | echo "To: $destination" | ||
+ | |||
+ | TMPFILE=`mktemp /tmp/smsd_XXXXXX` | ||
+ | |||
+ | $ECHO "To: $destination" >> $TMPFILE | ||
+ | [ -n "$ALPHABET" ] && $ECHO "$ALPHABET" >> $TMPFILE | ||
+ | $ECHO "" >> $TMPFILE | ||
+ | if [ -z "$ALPHABET" ]; then | ||
+ | $ECHO -n "$TEXT" >> $TMPFILE | ||
+ | else | ||
+ | $ECHO -n "$TEXT" | iconv -t UNICODEBIG >> $TMPFILE | ||
+ | fi | ||
+ | |||
+ | # if [ "x$owner" != x ]; then | ||
+ | # chown $owner $TMPFILE | ||
+ | # fi | ||
+ | |||
+ | FILE=`mktemp /var/spool/sms/outgoing/send_XXXXXX` | ||
+ | mv $TMPFILE $FILE | ||
+ | chmod 666 $FILE | ||
+ | done | ||
+ | |||
</code> | </code> | ||
===== Links / Quellen ===== | ===== Links / Quellen ===== | ||
* https://www.datenreise.de/raspberry-pi-sms-per-kommandozeile-versenden/ | * https://www.datenreise.de/raspberry-pi-sms-per-kommandozeile-versenden/ | ||
+ | * http://krausens-online.de/sms-via-raspberry-teil-2/ |