Remotely restarting E3372 LTE modem by SMS command

I have a place somewhere, in the area where no wired internet connection is available and everybody's using mobile internet. I'm no exception here so I set up Huawei E3372 LTE modem. I also have some remote access (of sorts) to LAN at the place, to be able to access some stuff when I'm away. It generally works fine, but sometimes the internet just dies completely, for no apparent reason. The modem is still alive though, I can tell it because if I call the number of the SIM card in it, it's rejecting my calls. The easiest way to fix it is by restarting it, but it's not that easy when you're a hundred or so miles away. I haven't had a chance to debug what's actually going on with it just yet.

So I needed an option to reboot it remotely, and I figured out I can try rebooting it via SMS command. My modem has hilink firmware, which has a web interface and, as a part of this interface, an XML API available over HTTP. This API has lots of commands, basically everything that you see or can configure in the interface, you can do by sending the API commands (it's how the interface itself works).

So I wrote a tool that runs every N minutes by cron, reads last SMS messages, and if there are new messages from a trusted phone number, does something, depending on the message text. The tool is running on a device in LAN, in my case it's an ARM development board.

Of course this won't help in case if modem dies completely, to the state it's unresponsible. But it wasn't my case, so I gave it a shot.

Long story short, it works, and if you're like me and want something weird, you can try it too: https://github.com/gch1p/e3372-sms-handler/

Another possible use case could be, for instance, re-sending received messages to an email. It all depends on your imagination (and Python skills, probably).

If you have any comments, contact me by email.
powered by OpenBSD
© ch1p 2021