Configure gammu to use a Huawei 3G modem

This is a very short helping tutorial explaining how to get gammu working with an USB 3G modem (in my case a Huawei K3565) in CentOS which will be used in sending out alert messages for critical events.

Start by connecting the modem and figuring out if it is recognised by the system:
# lsusb
Bus 001 Device 002: ID 045e:0779 Microsoft Corp. LifeCam HD-3000
Bus 003 Device 002: ID 04d9:1203 Holtek Semiconductor, Inc. Keyboard
Bus 004 Device 002: ID 12d1:1001 Huawei Technologies Co., Ltd. E169/E620/E800 HSDPA Modem
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

We can see the device correctly identified (it uses the same chip as several other Huawei models).

Next we figure out which ttyUSB device the modem shows up as. Looking at the list above it is on Bus 004, Device 002 with two other devices on precedent buses, so that would make it ttyUSB2 (with ttyUSB0 being the camera and ttyUSB1 the keyboard).

Install gammu (it is available via the RPMForge repository).

Open /etc/gammurc and change the settings to:

port = /dev/ttyUSB2
connection = at115200

Now run gammu –identify (this may take a while):

# gammu --identify
Manufacturer         : huawei
Model                : unknown (K3565)
Firmware             : 11.608.10.51.00
IMEI                 : phone_imei_number
SIM IMSI             : sim_imsi_number

Additional commands are available for more info:

# gammu --networkinfo
Network state        : home network
Network              : 226 03 (Cosmote), LAC 3A55, CID 4393

# gammu --monitor 1
Press Ctrl+C to break...
Entering monitor mode...
Enabling info about incoming SMS    : No error.
Enabling info about incoming CB     : No error.
Enabling info about calls           : No error.
Enabling info about USSD            : No error.
SIM phonebook        :   0 used, 250 free
Own numbers          :   0 used,   1 free
Battery level        : 0 percent
Charge state         : battery connected and is being charged
Signal strength      : -73 dBm
Network level        : 100 percent
SIM SMS status       : 6 used, 0 unread, 40 locations
Phone SMS status     : 0 used, 0 unread, 23 locations
Network state        : home network
Network              : 226 03 (Cosmote), LAC 3A55, CID 4393
Leaving monitor mode...

We can now send a test message:
# echo "Testing a test." | gammu --sendsms TEXT +123456789012
If you want break, press Ctrl+C...
Sending SMS 1/1....waiting for network answer..OK, message reference=9

If you want to check for received SMS messages, use
gammu --getallsms

If you’ve received the test message on your target number then gammu works and you can use the above command to programatically send SMS messages out of any other application or script.

Leave a Reply