使用Nokia实现Linux Shell发送短信


Google了很久,终于找到了gnokii,这是为一些老式的NOKIA手机设计的Linux驱动与管理程序,但是也可以通过支持AT命令的SMS modem。E680i自带的USB模式支持Modem,只需要在连接之前更改为这种模式,然后连接USB接口,CentOS 会自动将其识别为/dev/ttyACM0。

使用minicom -s 设置好modem的连接参数:
- Bit per second: 9600kbps,
- Data bits: 8,
- Parity: None
- Stop bits: 1,
- Flow control: Hardware Flow control.

从这里下载gnokii,编译安装。由于涉及到系统设备操作,因此整个操作过程都需要root账户权限。

[root@wardking gnokii-0.6.27]# ./configure
[root@wardking gnokii-0.6.27]# gmake
[root@wardking gnokii-0.6.27]# gmake install
[root@wardking gnokii-0.6.27]# cp Docs/sample/gnokiirc ~/.gnokiirc

编辑.gnokiirc文件,注释掉port=/dev/ttyS0,启用port=/dev/ttyACM0,注释掉model=6510,启用model=AT。
初始化连接:
[root@wardking ~]# gnokii –identify
此时会显示一些测试信息,完成后就可以使用以下命令发短信:
[root@wardking ~]# echo “This is a SMS from Linux shell” | gnokii –sendsms 13000000000

后来我又找到一台NOKIA6310i,发现其带有蓝牙和红外线,也可以通过这种方式连接,只需要在.gnokiirc中进行相应的更改。

Tue Dec 23 补充:
由于普通用户无法访问设备文件,gnokii发送信息时默认使用锁定设备模式,所以普通用户在发送短信时将会导致没有权限。解决办法:
复制/root/.gnokiirc配置文件至/etc/gnokiirc,更改use_locking=no。允许普通用户访问/dev/ttyACM0
chmod 666 /dev/ttyACM0

相关内容

    暂无相关文章