Monday, January 04, 2016

Remote GSM SIM Management with Raspberry Pi

Remote management of a GSM SIM card using a Raspberry Pi B+ and a Huawei E173 USB 3G modem. The RBox chat-bot connects to an XMPP/Jabber server and lets you send/receive SMS, make voice calls, and dial USSD codes — all from your phone's chat app, anywhere in the world.

Raspberry Pi B+ with Huawei E173 USB 3G modem

Raspberry Pi B+ with Huawei E173 USB 3G stick — the complete RBox GSM gateway.

Why remote SIM management?

  • Your SIM card has no roaming and you're travelling internationally
  • You're outside GSM coverage but have internet access and need SMS functionality
  • You manage multiple SIM cards and want centralized access
  • You need a self-hosted SMS gateway for sending/receiving over the internet
  • You have remote sensors that report data via SMS and want a central collection point

Ensure your SIM card is deployed at a safe and secure location to avoid possible misuse.

Items needed

  • Raspberry Pi B+
  • Micro or full-size SD card
  • Huawei E173 USB 3G stick
  • SIM card (PIN lock must be disabled)
  • 5 V / 2 A power supply
  • Two Google or Jabber accounts (one for you, one for the Raspberry Pi)
  • RBox SD card image

Setup

Setup diagram — Raspberry Pi with USB 3G modem connected to home router

Setup diagram — Huawei E173 plugged into the Raspberry Pi, which connects to the internet through a home router.

  1. Flash the RBox SD card image (see the RBox setup guide for details)
  2. Insert the PIN-unlocked SIM card into the Huawei E173 and plug it into the Raspberry Pi
  3. Connect the Raspberry Pi to your home router via Ethernet and power on with a 2 A supply
  4. On your phone's XMPP client (Xabber, Conversations, etc.), check that the Raspberry Pi account is online
  5. Send Help — the bot replies with the list of supported commands

Both XMPP accounts must be authorized as contacts before the Raspberry Pi is powered on — do this from a PC first.

When RBox boots without the USB 3G stick connected, SMS/SIM-related commands will not appear in the help list.

Reading SMS

  1. Send Smsupdate — immediate reply: InProgress : taskID=1
  2. Wait 3–5 seconds for the modem to read the SIM
  3. Reply Success : taskID=1 confirms messages are cached
  4. Send Smstotal — reply shows the count (e.g. Success : 2)
  5. Send Smsget 0 to read the first message, Smsget 1 for the second, etc.

Deleting SMS

  1. Send Smsdeleteall — immediate reply: InProgress : taskID=2
  2. Wait 3–5 seconds
  3. Reply Success : taskID=2 confirms deletion
  4. Verify with Smsupdate followed by Smstotal — if messages remain, repeat the delete

Sending SMS

  1. Send Smssend 009198xxxxxxxx hello this is a test message
  2. Immediate reply: InProgress : taskID=3
  3. Wait 3–5 seconds — reply Success : taskID=3 confirms the SMS was sent
  4. If sending fails, try omitting the international/country code prefix (0091)

Voice dialling

  1. Send Dialvoice 009198xxxxxxxx
  2. Immediate reply: InProgress : taskID=4
  3. The modem dials and rings for 20–25 seconds, then disconnects automatically
  4. Reply Success : taskID=4 confirms the call completed

Voice dialling currently places a silent call (no audio playback). Future RBox releases may support playing a recorded message for automation use cases.

USSD codes

USSD codes like *101# are useful for checking prepaid balance and other carrier queries.

  1. Send Dialussd *101# (the code varies by carrier)
  2. Immediate reply: InProgress : taskID=5
  3. Wait 3–5 seconds — reply Success : taskID=5 confirms the USSD response was received
  4. Send Readussd to read the carrier's response text

SOURCE CODE

github.com/hackboxguy/brbox — RBox sources and build instructions

Control Home Devices via XMPP Chat with Raspberry Pi

Control your home devices from anywhere using a Raspberry Pi running the RBox Linux distribution. The RBox chat-bot connects to a public XMPP/Jabber server, so you can toggle GPIO pins from your phone's chat app — no port forwarding, no dynamic DNS, no paid cloud services.

How it works

Setup diagram — Raspberry Pi at home communicating with smartphone via XMPP

Setup diagram — Raspberry Pi at home and your phone both connect to a public Jabber server. Chat messages carry GPIO commands.

Both the Raspberry Pi (running RBox) and your Android phone (running Xabber or any XMPP client) log in to a public Jabber server with their own credentials. Once the two accounts have authorized each other, they can exchange chat messages through the server.

Advantages

  • No router configuration or port forwarding needed — all incoming firewall ports can stay blocked
  • No dependency on paid cloud services — hundreds of free Jabber servers are available
  • Works from any location as long as your phone has internet access (Wi-Fi or mobile data)

Controlling GPIO

To toggle a GPIO pin, send a chat message from your XMPP client:

Gpio 2 1    # set GPIO2 high
Gpio 2 0    # set GPIO2 low

For full setup instructions (SD card preparation, XMPP account creation, first boot), see the RBox installation guide.

SOURCE CODE

github.com/hackboxguy/brbox — RBox sources and build instructions

Sunday, January 03, 2016

RBox XMPP Command Reference for IoT Control

Complete command reference for RBox. Send Help to your RBox device and it will reply with the full list of available commands. For background on RBox, see the introductory post.

RBox Help command output on Xabber

Help command output shown in the Xabber Android app.

Commands are not case-sensitive — they are converted to lowercase internally before processing.

System commands

Version — returns the RBox version in the format MJ.Mn.BUILD (major, minor, 5-digit SVN revision). Run this before and after Sysupdate to confirm the upgrade.

Sysupdate — downloads and installs the latest RBox release from GitHub onto the non-active boot partition. A reboot is required for changes to take effect. Tip: send Sysupdate;reboot to update and reboot in one step.

Reboot — gracefully shuts down all services and restarts the device.

Poweroff — gracefully shuts down and halts the system. Always use this before cutting power — a hard power-off leaves the XMPP session stale (the server shows the device as online but it is unresponsive).

Uptime — returns the device uptime in hours.

Network commands

Publicip — returns the public IP address assigned to the router. Useful when dynamic DNS is unavailable or not updating correctly.

Localip — returns the local LAN IP address of the RBox device. Useful for SSH access on the same network.

Hostname commands

Hostname [name] — with an argument, sets a new persistent hostname (takes effect after reboot). Without an argument, prints the current hostname. Useful when SSH-ing into RBox on the local network.

Resethostname — resets the hostname to the default format brbox-1A2B3C4D5E6F (where the last 12 characters are the MAC address). Requires a reboot.

GPIO commands

Gpio <address> [value] — reads or writes a GPIO pin. Examples:

Gpio 2 1    # set GPIO2 high
Gpio 2 0    # set GPIO2 low
Gpio 2      # read current state of GPIO2

GPIO pin values are not retained across reboots — they revert to defaults.

SOURCE CODE

github.com/hackboxguy/brbox — RBox sources and build instructions

RBox: Lightweight Linux Distro for IoT Devices

RBox (RemoteBox) is a lightweight Linux distribution built with Buildroot, designed for IoT devices that need reliable connectivity over the public internet. It runs on low-cost hardware and uses XMPP chat messaging for remote control — no cloud services, port forwarding, or dynamic DNS required.

The Raspberry Pi image provided here works only on Raspberry Pi B+.

Key features

  • Runs on Raspberry Pi B+, BeagleBone Black, and BeagleBone Green
  • Small update image — under 20 MB for Raspberry Pi, under 10 MB for BeagleBone
  • Over-the-air updates with dual-boot failsafe against power outage or network failure
  • Always-on XMPP chat-bot keeps the device accessible via any Jabber server
  • Remote GPIO read/write via chat messages
  • Health monitoring commands
  • GSM SIM management with Huawei E173 USB modem — read/send/delete SMS, dial USSD codes, voice dialling
  • Open source — hosted on GitHub

Applications

Deploying RBox on Raspberry Pi B+

  1. Create two XMPP accounts on a public Jabber server (tested with jabber.de, xabber.de, ubuntu-jabber.de) and authorize them to chat with each other
  2. Download the RBox SD card image
  3. Decompress with 7-Zip or your preferred tool
  4. Write the image to the SD card using Win32DiskImager
  5. Remove and re-insert the SD card — a boot drive appears
  6. Create xmpp-login.txt on the boot drive using this template — replace the sample credentials with your device's XMPP username and password
  7. Insert the SD card into the Raspberry Pi, connect an Ethernet cable, and power on
  8. On your phone, open Xabber and log in with the master XMPP account
  9. The Raspberry Pi should appear online — send Help to see the list of available commands
  10. Send Sysupdate;reboot to update to the latest RBox image — see the full command reference

RBox is in active development. Contributions and feedback are welcome — leave a comment or open an issue on GitHub.

SOURCE CODE

github.com/hackboxguy/brbox — RBox sources and build instructions

XMPP Account Setup Guide for IoT Remote Control

A step-by-step guide to creating XMPP master and slave accounts on a public server (tested with xabber.de, jabber.de, ubuntu-jabber.de) using the Psi desktop client. These accounts enable remote control of embedded Linux devices over the public internet via XMPP chat protocol.

Shortcut: If you have two Google accounts, you can skip this guide entirely — just authorize both accounts as contacts and use one as the master (your phone/PC) and the other as the slave (chat-bot). In the second account's Google security settings, set "Allow less secure apps: ON".

Why XMPP for IoT?

XMPP is widely used as a chat protocol between humans. The technique described here repurposes it for remotely accessing and controlling embedded devices over the public internet. XMPP was chosen for its wide adoption, built-in security, and ease of connectivity.

Typical client-server communication over the public internet requires exposing a server port through a firewall and registering a dynamic DNS name — a common challenge for home routers or 3G-connected devices with non-static IPs. Using existing public XMPP server infrastructure sidesteps these connectivity challenges entirely.

In this setup, the master account is for the person controlling the device (from a smartphone app like Xabber or a PC client like Psi), while the slave account runs on the remotely deployed Linux machine (Raspberry Pi, BeagleBone, etc.) as a chat bot. As long as both devices have internet access, they can communicate regardless of location.

Creating the master account

Step 1: Install Psi XMPP client on your Windows machine.

Step 2: Start Psi, go to General → Account Setup.

Psi Account Setup dialog

Step 3: Click on "Add".

Account list with Add button

Step 4: Follow the numbered fields as shown below.

New account dialog — follow fields 1 and 2

Step 5: Enter the public server as xabber.de and click "Next".

Server selection — entering xabber.de

Steps 6–10: After pressing "Next", wait for the registration form to load. Fill in the fields:

  • Field 1: Choose a username (e.g. "master")
  • Field 2: Enter your password
  • Field 3: Open the captcha link in a browser
  • Field 4: Enter the captcha number shown by the browser

Click "Next".

Registration form with username, password, and captcha fields

Step 11: If registration succeeds, click "Ok" on the confirmation dialog.

Registration success dialog

Step 12: Click "Save" on the account properties dialog.

Account properties — click Save

Step 13: Click "OK" on the next confirmation dialog.

Confirmation dialog — click OK

Step 14: Back in the Psi main window, right-click on the "Master" entry → Status → Online.

Setting master account status to Online

Step 15: Enter your full name and nickname, then click "Close".

Profile setup — enter name and nickname

Step 16: Master account creation is done. Log out by right-clicking on the "Master" entry → Status → Offline.

Setting master account status to Offline

Creating the slave account

Repeat steps 1–15 for the slave account. Pay attention to these differences:

  • Step 4: Use the string "Slave" instead of "Master"
  • Steps 7–8: Choose a different username and password
  • Step 15: Use "Slave" as the full name and nickname

Pairing master and slave accounts

Once both accounts are created, go to General → Account Setup. Enable both the Master and Slave account checkboxes, then click "Close".

Account Setup with both accounts enabled

Right-click on "Slave" → Status → Online (wait for the grey star to turn yellow). Repeat for "Master". When both stars are yellow, both accounts are online.

Both master and slave accounts online — yellow stars

The master and slave accounts now need to authorize each other — this is XMPP's standard mechanism to block unsolicited messages. Send a few test messages between the accounts to confirm bi-directional communication works.

Next step: Proceed to Rbox — A Lightweight Linux system for IoT to set up the slave device.