Getting SMS messages from the Huawei E3372 LTE modem

Posted on Updated on

If you’ve bought a modem from Optus, here in Australia, you may be delighted – and disappointed that the SMSs that are received on the Modem, are now served through a web interface.

I wasn’t happy about this, as I wanted to interrogate the SMS database through the “Mobile Partner” program. So, because Optus have custom firmware it’s basically not possible to do this (Yes, I was on the phone to both parties), it has caused me to look elsewhere. If you wanted to use a custom firmware, go for it, but I couldn’t be bothered.

Specifically, I have an E3372 modem.

I came across this post and information, it got me thinking…

The same hackaround can be used to programatically send SMS from the LAN using the E3372 API, here’s a simple script that does just that:


SESSION_ID=`echo "$DATA" | grep "SessionID=" | cut -b 10-147`
TOKEN=`echo "$DATA" | grep "TokInfo" | cut -b 10-41`

curl -H "Cookie: $SESSION_ID" -H "__RequestVerificationToken: $TOKEN" --data "<?xml version='1.0' encoding='UTF-8'?><request><Index>-1</Index><Phones><Phone>$1</Phone></Phones><Sca></Sca><Content>$2</Content><Length>-1</Length><Reserved>1</Reserved><Date>-1</Date></request>"

Use it like this:

./ +1234567890 "Hello world!"


After studying the code a little, I’ve been able to discover that the SMS messages can easily be read from the stick, as XML.

Request URL:
Request method:POST
Remote address:
What it should do, is return an response of XML eg:
<?xml version="1.0" encoding="utf-8"?>
<Content>An SMS you tried to send or receive has failed as you are out of credit for that message type. Recharge now to allow future SMS messages to be sent or received.</Content>
<Date>2019-02-13 16:04:02</Date>
<Content>An SMS you tried to send or receive has failed as you are out of credit for that message type. Recharge now to allow future SMS messages to be sent or received.</Content>
<Date>2019-02-13 16:03:20</Date>


This should be enough to get me started, and once again (possibly) start to read SMS messages from my (new) USB Modem.

While I haven’t tried this method fully yet, but in theory this will be completely possible.

This may also remove the need for Gammu as well.

For other valuable information on these devices (which are all very similar)


Show a single WordPress article post in an Ionic Angular app.

Posted on Updated on

It took me a little while to do this nicely, but I’m happy with this version:    This will help you get a specific WP post with a wp_id.

This is not a full example, but close enough. If you know what you are doing, this should be easy for you.



I’m calling this code from another page which will link to the WP article.

<a style="width:100%"style="text-decoration:none;"class="item"href="#"(click)="OpenSinglePost(6872, 'Custom Article title ')">Show the Article</a>
The code behind on the .ts file:
OpenSinglePost(postid, pagetitle: string)
  this.navCtrl.push(WpArticleItemPage, {postId: postid, pagetitle: pagetitle });

Showing the actual WP article page:





import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, LoadingController, Loading } from 'ionic-angular';
import { ProgressHttp } from "angular-progress-http";

selector: 'page-wp-article-item',
templateUrl: 'wp-article-item.html',

export class WpArticleItemPage
postId: number;
loader: Loading;
post_title: string;
post_content: string;
url: string;

public navCtrl: NavController,
public navParams: NavParams,
public loadingCtrl: LoadingController,
private http: ProgressHttp)

this.postId = navParams.get('postId');
this.post_title = navParams.get('pagetitle');
console.log("this.postId: " + this.postId);
this.url =''+this.postId;
.get( this.url ) // The URL
.map( res => res.json()) // putting an async makes it get stuck forever.
.subscribe( data =>

//this.post_title = data.title.rendered;
this.post_content =this.striplinks(data.content.rendered);

// This currently solves the URL problem

var re = /<a\s.*?href=[\"\'](.*?)[\"\']*?>(.*?)<\/a>/g;
var str = text;
var subst ='$2';
var result = str.replace(re, subst);
return result;

presentLoading() {
this.loader =this.loadingCtrl.create({
content: "Retrieving data..."


Yes, WP doesn’t format code nicely – I know.

Now for the front-end and display the WP article.



<ion-navbar color="primary">
<ion-title>{{ post_title }}</ion-title>

<ion-content padding>
< d i v [innerHTML]="post_content"></ d i v >

(Just fix the div tags up. It's a WordPress thing)

Teamviewer not reloading after I quit it

Posted on

This has been an ongoing problem for a long time now. If I was to ever quit Teamviewer, it would cease to reopen, and instead, just give me a prompt saying “TeamViewer is trying to install a new helper tool”.

Today, I finally discovered the answer to my troubles, and hopefully a solution that will work.

I discovered it here.

What happening on my computer was that the launch daemon for the helper tool was not properly started.

So, to fix the problem, I ran this from the Mac terminal:

sudo launchctl load -w /Library/LaunchDaemons/com.teamviewer.Helper.plist

Teamviewer then finally loaded. I haven’t seen anyone else with this issue, so I don’t know why it is doing it, but, until the Teamviewer provide a proper solution, this work around will have to do.

Sadly, even with the latest version (14), this is still current.

Reading text Data from a USB Serial Device in Python on a raspberry pi.

Posted on Updated on

Programming in python is very new to me, and I’m only doing this out of necessity, as it appears it’s the most easy and common method on the raspberry pi. So, here goes…

This code reads data from a USB device which issues text on a serial port, where I can then disseminate the data.

And yes, this is initial version which hasn’t been tested 100% yet.


import serial
import time
import csv

port = '/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0'
#port = '/dev/ttyUSB0'
baud = 9600

ser = serial.Serial(port, baud, timeout=1)


oldline = []

while True:
        #ser_bytes = ser.readline()
        #decoded_bytes = float(ser_bytes[0:len(ser_bytes)-2].decode("utf-8"))
        line = ser.readline()                 # read bytes until line-ending
        line = line.decode(encoding='UTF-8')  # convert to string
        #line = line.rstrip('\r\n')            # remove line-ending characters
        split_line = line.splitlines()
        if oldline != split_line:      
            with open("test_data.csv","a") as f:
                for item in split_line:
                    writer = csv.writer(f,delimiter=",")
                    writer.writerow([time.time(), item])
        oldline = split_line
        #print("Keyboard Interrupt")

I have now added it here:

Retrieving Backups with Raspberry Pi and sftp

Posted on Updated on

Following on from my recent MYSQL DB, it’s one thing to back up the data, but you have to get the data off the server.

So, with my trusty Raspberry pi, that is going to use considerable less power than my NAS (which has been used for VMs to do this), it’s now time to get some scripts working on the pi to do the offline/off server backups.


The biggest problem is finding a solution to download the data securely. It’s easy to use plain FTP, which is not secure, but I need to have SFTP.

So, as it turns out, there is a program called sftp built in to the pi.

I went down the path of using sshpass. My FTP password has to be saved somewhere, and as it’s only for SQL backups, I’m not too concerned.


You have a few options other than using public key authentication. I have take this example from here.

  1. Use sshpass (less secured but probably that meets your requirement)

If you decide to give sshpass a chance here is a working script snippet to do so:

You should copy all of this in to a file.

export SSHPASS=your-password-here
sshpass -e sftp -P PORTNUMBER -oBatchMode=no -b - sftp-user@remote-host << !
   lcd local_backup_path1
   cd db_backup_path1 
   get *.gz
   lcd ..

   lcd local_backup_path2
   cd db_backup_path2 
   get *.gz
   cd ..
   lcd ..


Please note the PORTNUMBER there. It has also be a capital for it to work.

Then, run the script with sh ./

MYSQL Backups

Posted on

There are plenty of options to back up mysql DBs.

One method is the following:

Create a backup user in mysql/mariadb like the following:


# /usr/bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 253404
Server version: 5.1.54-1ubuntu4 (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> GRANT LOCK TABLES, SHOW VIEW, SELECT ON *.* TO 'backupsonly'@'%' IDENTIFIED BY 'P@$$w0RD';
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> Bye


Then, create a script “my_backup.conf” that has the following in it:


Then, run the following script to export the data.


mysqldump --defaults-extra-file=my_backup.conf -u backupsonly databasename --single-transaction --quick --lock-tables=false | gzip > databasename_full-backup-$(date +%F).sql.gz



Download a WordPress wp-content uploads folder

Posted on Updated on

There are times I work with groups and much of their online artwork is stored in a WordPress Upload folder.

There’s a few methods to get those images from that path. I like being able to use SiteSucker, but it often downloads the entire site.

The other easy option is to use wget.

Run this command in the path that you wish to save all the files to, and it’ll get everything in the upload path.

wget -r --no-parent

This is a single threaded command and will take a long time, so just be patient while it does its thing.