Författare:
Per Stenebo
Skapad:
2014-01-06 13:47:23
Ändrad:
2021-01-10 10:19:03
en

gnokii

Install, configure and test of gnokii on Ubuntu with a regular cell phone. First test in Ubuntu 13.10, GNOKII Version 0.6.31, via Sony Ericsson G900 and Sony Ericsson K660i. Also tested 2021-01 in Debian 10 Buster, gnokii version 0.6.30 (!) together with a Huawei Hilink E3276S modem.

Start and connect phone with USB cable, select normal phone mode (not file transfer or flight mode or similar). Check where it was mounted with (more info about serial devices here):

ls -l /dev/ttyA* or ls -l /dev/ttyUSB*

Install gnokii

sudo apt install gnokii

If you want a GUI, install xgnokii too.

Copy configuration file, please note the leading dot:

sudo cp /etc/xdg/gnokii/config ~/.gnokiirc

or create configuration file from sample. Unpack /usr/share/doc/gnokii-common/sample/gnokiirc.gz to ~/.gnokiirc

or simply stick with the original file.

Edit the selected configuration file. I edited the following lines:

port = /dev/ttyACM1
model = AT
serial_baudrate = 115200

Check settings and connected phone. gnokii need to be run with root privileges to be allowed access to the serial port.

sudo gnokii --identify

Send SMS

Send test SMS, edit the receiving phone number. 

echo "This is a test message" | sudo gnokii --sendsms +46709123456

Send succeeded with reference 0!

If SMS are sent from a script executed as root (like cron), you should omit the sudo, remember to use a config file in roots path (like the original file in /etc/xdg/gnokii/config).

 

Read SMS

Check wich memory types exist on the connected device:

gnokii --showsmsfolderstatus

No. Name                                       Id #Msg
==================================
  0 Internminne                              ME    1
  1 SIM-kort                                    SM    1

 

Read SMS syntax:

gnokii --getsms MemoryType Start [end]

FIXME: Read all SMS from internal memory:

gnokii --getsms ME 1 end

Getting SMS failed (location 1 from ME memory)! (Den angivna platsen är tom.)
Getting SMS failed (location 2 from ME memory)! (Okänt fel - bättre än inget!!)

Read last SMS:

 

Background

I wanted to send SMS from a script in my server. There are plenty of on-line services to do this with but I wanted full control of both data (messages) and cost. I therefore ended up using an old cell phone with a prepaid SIM card connected to my server with a USB cable.

If the phone supports SMS text mode a SMS can be sent fairly easily with simple AT commands. If not (only PDU mode) some amount of not-so-easy scripting needs to be done to build the AT commands. Or you can use gnokii or similar program that do the low level stuff for you.

If you really want to build and send SMS in PDU mode, here are some hints:

Internal page about AT-commands and SMS PDU-mode.

More information

gnokii website: http://gnokii.org/

Ubuntu man page: http://manpages.ubuntu.com/manpages/bionic/en/man1/gnokii.1.html

Linux Gazette HowTo: http://linuxgazette.net/164/tomar.html

 

Kommentarer till sidan gnokii