参考连接: Raspberry Pi 树莓派收短信,转发至Telegram
pi@ubuntu:~/gammu-sms $ lsusb
Bus 001 Device 003: ID 12d1:1436 Huawei Technologies Co., Ltd. Broadband stick # 华为网卡
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@ubuntu: ls /dev/ttyUSB*
/dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2 # 有的时候 1 2 3
设备号填/dev/ttyUSB1
port: at19200
还可以通过gammu identify
再次确认设备号。
# 如果需要存储短信,详见官方文档
# RunOnReceive定义收到短信后执行的脚本
# Configuration file for Gammu SMS Daemon
# Gammu library configuration, see gammurc(5)
[gammu]
# Please configure this!
port = /dev/ttyUSB0
connection = at19200
# Debugging
#logformat = textall
# SMSD configuration, see gammu-smsdrc(5)
[smsd]
RunOnReceive = /root/receive-sms.sh
service = files
logfile = /var/log/gammu-smsd.log
# Increase for debugging information
debuglevel = 255
# 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/
# Format, 否则inbox/下面的中文短信为乱码
InboxFormat = unicode
/home/pi/gammu-sms/receive-sms.sh
内容:
#!/bin/bash
DIR=$(dirname $0)
$DIR/venv/bin/python -u $DIR/main.py >> /var/log/recieve-sms.log
gammu detect
gammu identify
$ sudo vim /etc/usb_modeswitch.d/E173.conf
DefaultVendor=0x12d1
DefaultProduct=0x1446
CheckSuccess=20
MessageContent="55534243123456780000000000000011062000000100000000000000000000"
- Green (blinking twice every 3s): The USB Stick is powered on
- Green ( blinking once every 3s): The USB Stick is registering with a 2G - network.
- Blue (blinking once every 3s): The USB Stick is registering with a 3G/3G+ - network.
- Green (solid): The USB Stick is connected to a 2G network
- Blue (solid): The USB Stick is connected to a 3G network
- Cyan (solid): The USB Stick is connected to a 3G+ network
- Off: The USB Stick is removed