Professional Documents
Culture Documents
Setting Up SMS Sending and Receiving Using A USB GSM Dongle by ZTE - Selective Intellect
Setting Up SMS Sending and Receiving Using A USB GSM Dongle by ZTE - Selective Intellect
(/)
W H AT W E D O
CAPABILITIES
(/CAPABILITIES)
SELECT PROJECTS
(/SELECT-PROJECTS)
OPEN SOURCE PRODUCTS
(/OPEN-SOURCE-PRODUCTS)
B LO G
( / B LO G )
C O N TA C T U S
( / C O N TA C T - 1 )
Accept
The MF190 GSM Modem by ZTE
The GSM Modem cover can be opened to insert a microSD card and a full size SIM card. You can see the IMEI
number on the device here.
By using this website, you agree to our use of cookies. We use cookies to provide you with a great experience and to help
our website run effectively.
Accept
You need a 3-in-1 size SIM card for this project. The full size SIM is needed for the USB modem.
The USB modem now connected to the USB port of a laptop. The SIM card has been inserted and the LED on the
right will be red on start and green when connected to the GSM network.
Accept
$ sudo dmesg | tail -n 1000
You can also use lsusb to check that the device has been loaded.
Bus 001 Device 008: ID 19d2:0117 ZTE WCDMA Technologies MSM MF667
The device seems to show MF667 but the labeling says MF190. Either way, they support the same
commands for sending and receiving SMS.
For this post, we will disable both the CD-ROM and mass storage feature. It may so happen that you
may want to take advantage of the mass storage feature to save messages or to use the USB GSM
modem to receive files over GSM and that is out of the scope of this post.
First eject the CD-ROM from the host machine
By using this website, you agree to our use of cookies. We use cookies to provide you with a great experience and to help
our website run effectively.
AT+ZOPRT=5
AT+ZCDRUN=8
Now the device is ready for sending and receiving messages and phone calls. For this post, we will
not be making any phone calls.
Sending Messages
Sending messages can be done very easily using the Device::Gsm module as shown below in the
perl script. The $modem, $text and $recipient variables must be edited as per your needs. The
phone number must have no spaces, must include the country code and the + sign in front of it.
Once you create a Device::Gsm object, then you connect to the modem over the serial port
/dev/ttyUSB2 with a baud rate of 115200. Once that connection works, you can then send a
message using the send_sms function which is obvious in the below code.
By using this website, you agree to our use of cookies. We use cookies to provide you with a great experience and to help
our website run effectively.
Accept
use strict;
use warnings;
use Device::Gsm;
Receiving Messages
Receiving messages is similarly done. You must connect to the modem at a baud rate of 115200 and
then invoke the messages() function with the storage option defined as ME which stands for the
phone memory, which is where the messages are stored by default on this ZTE device.
If you have messages stored in memory, the for loop will get invoked and each message which is an
instance of Device::Gsm::Sms can then be handled or printed or processed or stored in a
database etc. In the code below, we delete the message if the status is UNREAD, but that is where
the processing by the user can be done.
By using this website, you agree to our use of cookies. We use cookies to provide you with a great experience and to help
our website run effectively.
Accept
use strict;
use warnings;
use Device::Gsm;
use Device::Gsm::Sms;
Accept
------------------------------------------------------------
MESSAGE N. 0
Type DELIVER
Status REC UNREAD
From LYCAMOBILE
To
Text [Dear customer ,Your $19 INTERNATIONAL PLAN has been renewed
succesfully.it is good through 09/16/2021. Visit
https://www.lycamobile.us/login for details.]
------------------------------------------------------------
MESSAGE N. 1
Type DELIVER
Status REC UNREAD
From LYCAMOBILE
To
Text [ Thank you for using Lycamobile.]
------------------------------------------------------------
------------------------------------------------------------
MESSAGE N. 2
Type DELIVER
Status REC UNREAD
From +12012012010
To
Text [Test]
------------------------------------------------------------
MESSAGE N. 3
Type DELIVER
Status REC UNREAD
From +12012012010
To
Text [Got it]
------------------------------------------------------------
By using this website, you agree to our use of cookies. We use cookies to provide you with a great experience and to help
our website run effectively.
Accept
#!/usr/bin/env perl
use strict;
use warnings;
use sigtrap qw/handler signal_handler normal-signals/;
use Device::Gsm;
use Device::Gsm::Sms;
use Data::Dumper;
sub usage {
die << "..."
Usage: $0 <phone number like +12125432109> <message>
Press Ctrl-C to exit program.
...
}
sub send_sms {
my ($gsm, $text, $recipient) = @_;
return unless length($text // '');
return unless $recipient;
my $sent = $gsm->send_sms(
content => substr($text, 0, 140),
recipient => $recipient,
);
die "Unable to send message to $recipient ", scalar localtime
unless $sent;
print "Sent message to $recipient at ", scalar localtime, "\n";
}
sub receive_messages {
my $gsm = shift;
my @messages = $gsm->messages('ME');
printf "You have %d messages\n", scalar(@messages);
my $idx = 0;
foreach my $msg (@messages) {
next unless defined $msg;
By using this website, you agree to our use of cookies. We use cookies to provide you with a great experience and to help
print '-' x 60, "\n", "MESSAGE N. $idx\n";
our website run effectively.
print 'Type ',($msg->type() eq
Accept
Device::Gsm::Sms::SMS_SUBMIT ? 'SUBMIT' : 'DELIVER'), "\n";
print 'Status ', $msg->status(), "\n";
print 'From ', $msg->sender(), "\n";
print 'To ', $msg->recipient(), "\n";
print 'Time ', $msg->time(), "\n";
print 'Text [', $msg->text(), "]\n";
if ($msg->status() =~ /UNREAD/) {
print "DELETING SMS FROM STORAGE!!\n";
$msg->delete();
}
$idx++;
}
}
sub signal_handler {
die "Signal caught: $!";
}
In a future post, we will show how to make a phone call and play a pre-recorded audio file using this
GSM modem.
We are a business that runs all their operations out of the United States of America.
© 2008-2020. Selective Intellect, LLC. All Rights Reserved.
By using this website, you agree to our use of cookies. We use cookies to provide you with a great experience and to help
our website run effectively.
CONNECT WITH (htt (ma (htt
US
Accept
By using this website, you agree to our use of cookies. We use cookies to provide you with a great experience and to help
our website run effectively.
Accept