Sending SMS from Huawei E1752

Having my own server I occasionally have the need for sending out SMS messages to my users. I have tried different online solutions, but in the end I decided that I would like my own terminal. For this purpose I bought a Huawei E1752 3G dongle. The server is running Debian as operating system and for API for the dongle I use Gnokii.

The first thing to do is to install some prerequisites

apt-get install gnokii usb-modeswitch

Now we are ready to insert the dongle. Seeing in /var/log/messages we see that the dongle is recognized as a USB Mass Storage devices. This we need to fix. For this purpose we use usb_modeswitch. This program can switch modes in the dongle, but first we need to configure usb_modeswitch for this specific dongle. Therefor insert the below lines in /etc/usb_modeswitch.conf

########################################################
# Huawei E1752
#
# Contributor:

DefaultVendor=  0x12d1
DefaultProduct= 0x1446

TargetVendor=   0x12d1
TargetProdct=   0x1001

MessageEndpoint=        0x01

MessageContent= "55534243000000000000000000000011060000000000000000000000000000"

The next thing to do is to create the file /etc/udev/rules.d/10-huawei-e1752.rules and paste the following lines.

ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1446",
RUN+="/usr/sbin/usb_modeswitch"

Before running usb_modeswitch try to do a lsusb command, and then run the following and see how the dongle changes mode.

# usb_modeswitch -c /etc/usb_modeswitch.conf

Now we are able to send a SMS. We need to make a config file first. Under /home/user/.config/gnokii/config paste the following

[global]
model = AT
port = /dev/ttyUSB2
connection = serial

Now we must enter the PIN code

echo [pin] | /usr/bin/gnokii --entersecuritycode PIN

To send an SMS do

echo "message" | /usr/bin/gnokii --sendsms [phonenumber]

To receive a message do

/usr/bin/gnokii --getsms SM 0 29 -d

The command shows the messages in slots 0 to 29. The output lookes like this

GNOKII Version 0.6.29
Getting SMS failed (location 0 from SM memory)! (The given location is empty.)
Getting SMS failed (location 1 from SM memory)! (The given location is empty.)
Getting SMS failed (location 2 from SM memory)! (The given location is empty.)
Getting SMS failed (location 3 from SM memory)! (The given location is empty.)
Getting SMS failed (location 4 from SM memory)! (The given location is empty.)
Getting SMS failed (location 5 from SM memory)! (The given location is empty.)
Getting SMS failed (location 6 from SM memory)! (The given location is empty.)
Getting SMS failed (location 7 from SM memory)! (The given location is empty.)
Getting SMS failed (location 8 from SM memory)! (The given location is empty.)
Getting SMS failed (location 9 from SM memory)! (The given location is empty.)
Getting SMS failed (location 10 from SM memory)! (The given location is empty.)
Getting SMS failed (location 11 from SM memory)! (The given location is empty.)
Getting SMS failed (location 12 from SM memory)! (The given location is empty.)
Getting SMS failed (location 13 from SM memory)! (The given location is empty.)
Getting SMS failed (location 14 from SM memory)! (The given location is empty.)
Getting SMS failed (location 15 from SM memory)! (The given location is empty.)
Getting SMS failed (location 16 from SM memory)! (The given location is empty.)
Getting SMS failed (location 17 from SM memory)! (The given location is empty.)
Getting SMS failed (location 18 from SM memory)! (The given location is empty.)
Getting SMS failed (location 19 from SM memory)! (The given location is empty.)
Getting SMS failed (location 20 from SM memory)! (The given location is empty.)
Getting SMS failed (location 21 from SM memory)! (The given location is empty.)
Getting SMS failed (location 22 from SM memory)! (The given location is empty.)
Getting SMS failed (location 23 from SM memory)! (The given location is empty.)
Getting SMS failed (location 24 from SM memory)! (The given location is empty.)
Getting SMS failed (location 25 from SM memory)! (The given location is empty.)
Getting SMS failed (location 26 from SM memory)! (The given location is empty.)
Getting SMS failed (location 27 from SM memory)! (The given location is empty.)
Getting SMS failed (location 28 from SM memory)! (The given location is empty.)
Getting SMS failed (location 29 from SM memory)! (The given location is empty.)

The -d parameter indicates that the messages are deleted when shown by gnokii.

– Thats it!

Comments are closed.