goTenna Mesh community

Building a stand alone RPi based goTenna to SMS gateway

There’s a hidden gem in the goTenna Python SDK I haven’t seen anyone talk about yet.

The SDK has functionality to support creating a low cost, low power Raspberry Pi gateway between the goTenna mesh network and, for example, the mobile SMS network. In particular, the SDK developers have included functionality that enables gateway nodes to advertise an external address (eg. an SMS phone number) over the mesh network.

A set of gateway nodes located in different locations can share a common mesh GID and advertise the same set of external SMS numbers that they will forward to. You may originally get the advertisement from one gateway, but a message forwarded to that gateway’s GID will be relayed through whichever gateway with the same GID happens to be closest.

A RPi based gateway can use a GSM dongle and a Twilio Programmable SIM (as described here) to create an SMS gateway that does not require internet connectivity. The goTenna gateway functionality is demonstrated by the sampleGateway.py file included with the goTenna Python SDK.

Some examples of how a low cost, and potentially even battery powered mesh-to-SMS gateway might be used:

  • Operated at the edge of a wildfire area to allow people to connect with family and friends when centralized infrastructure is down or overloaded.
  • Allow people to subscribe to news and weather updates during a hurricane.
  • Provide a simple private email remailing service.

I don’t have time to build this project myself, but I’d love to assist someone interested in taking it on. I’ve written up some notes from my testing of the sampleGateway.py code below. Hopefully this can help everyone get started playing with gateway functionality. In my example below I have created a hypothetical “Crisis Response Network” or “CRN” service with the phone number (123) 456-7890.

Computer

  1. Connect a powered off goTenna Mesh device to your computer via USB
  2. Remove .goTenna storage file if present from a previous run
  3. Verify that the latest version of the Python SDK whl file is installed:

> python -m pip list

  1. Run gateway sample app (prefix with ‘sudo’ if on RPi).

> python sampleGateway.py [Your Token]

  1. Turn on goTenna Mesh, you will see “device_present” message and show connected COM port (eg. COM7 on Windows 10 or /dev/ttyACM0 on RPi).
  2. Register an external service that this gateway will advertise:

>>> g.register_external(1234567890, “CRN Service”)

  1. Verify list of contacts supported by the gateway:

>>> d._storage.get([“external_contacts”])

  1. Connect to goTenna Mesh, you will see “Connected to device” message

>>> d.connect(“COM7”)

or on RPi:

>>> d.connect("/dev/ttyACM0")

  1. Advertise the gateway’s external address to nearby goTenna Mesh devices. You should see lights blink on both gateway goTenna and then on the nearby goTenna devices.

>>> g.advertise()

  1. Check contacts on phone running the beta goTenna app or an instance of sample.py to confirm contact service has been added. Eg. ‘CRN Service’

  1. Broadcast a message from the gateway, should see ‘Broadcast forwarded’ message and goTenna Mesh lights should blink.

>>> p=goTenna.payload.TextPayload("first broadcast")

>>> ext_gid=goTenna.settings.GID(1234567890, goTenna.settings.GID.PRIVATE)

>>> g.forward_broadcast(p, ext_gid)

INFO:main.Gateway:Broadcast forwarded

  1. The message should appear as a Shout chat on the phone and be from the gateway:

  1. Long press on the message and send a private reply back to the gateway.

image5

  1. On the gateway device you should see the reply.

image6

  1. Send a private message from the gateway device to the phone

>>> ext_gid=goTenna.settings.GID(1234567890, goTenna.settings.GID.PRIVATE)

>>> ext_gid_dst=goTenna.settings.GID( 90180116423811 , goTenna.settings.GID.PRIVATE)

>>> p=goTenna.payload.TextPayload("private reply from gateway")

>>> g.forward_private(p, ext_gid, ext_gid_dst)

image7

  1. The message should appear as a private chat from the CRN service:

  1. Test also that you can edit and delete the contact information.
  2. Disconnect and wait for goTenna device to be unpaired and start blinking before quitting.

>>> d.disconnect()

  1. Wait until disconnected and then quit python

>>> quit()

9 Likes

SUPER idea. I don’t have the skills to build this but I sure hope it gets done.

1 Like

I have an update on progress toward the RPi based personal goTenna to SMS gateway project. :tada:

@Tourmaline_Wireless has volunteered to help push this idea forward and we have worked together to refine the code for both the mobile SMS client and RPi gateway code. We also have a low-power hardware specification and have tested with a low cost SMS backend.

Mobile App

There is now a new version of the Mesh fork of the Signal App (gotenna branch) that I described earlier. When you have a goTenna connected and there is no mobile connectivity then this version of the app automatically sends SMS messages to the SMS Gateway GID (eg. 555555555) over the goTenna mesh.

Messages sent to the gateway are prepended with the phone number of the destination. When the gateway receives the message, it sends the original message via SMS to the pre-pended phone number. If someone replies via SMS to the gateway from a phone number that the gateway delivered a message to from the mesh, then the gateway can lookup the mesh GID and forward the reply to the original mesh message sender (see the diagram above).

Gateway

The gateway server code (sms_gateway.py) is a modification of sample.py from the USB SDK which runs on an RPi with an GSM modem attached. You run it with the following parameters:

  • app token for goTenna SDK.
  • geo region number you are in.
  • serial port of the GSM modem
  • speed of the serial port of the GSM modem.

For example:

$ ./sms_gateway.py <your SDK Token> 1 /dev/ttyS0 115200
Welcome to the SMS Mesh Gateway API sample! Press ? for a command list.

SMS Gateway> ?

Notice the three added commands: send_sms, read_sms and delete_sms. You can use these commands to test connectivity with your attached GSM modem.

SMS Gateway> send_sms 2125551212 hello GSM user!

The gateway forwards messages it receives over the mesh to the phone number prepended to each mesh message by the Mesh Signal App. When the gateway receives an SMS, if the SMS came from a phone number the gateway previously sent a message to, then the gateway knows to forward it back to the mesh GID that sent the original message.

Hardware

I’ll let @Tourmaline_Wireless talk more about the hardware side of it, but I have done my testing on a RPi 3 with a goTenna Mesh and a DLink DWM-157 USB Dongle GSM Modem attached. Each of these items costs around $30. I used a Twilio Programmable SIM card for the GSM subscription. The SIMs cost around $3 each and maintaining a phone number costs $1 a month plus usage.

Trouble Shooting

  • You can type AT commands directly to your GSM Modem using the screen command. You can use this to confirm you have the right serial port and that the modem is responding.

$ screen /dev/ttyS0 115200
AT
OK

  • Make sure that the Mesh Signal App project uses the same goTenna SDK token as you use when you launch sms_gateway.py
  • You might need to put your GSM modem and/or goTenna on a powered USB hub if the USB ports are not supplying enough power.

Future

We’d love to see more people testing and eventually building on what we have done so far. Some next steps for the software development are :

  • The app should try to send messages first over the mesh network before sending to the SMS gateway
  • Instead of prepending the remote phone number, add it as a new TLV
  • After messages have been delivered, delete them from the GSM device
  • End to end encryption when both ends of the conversation are using the Mesh Signal App.

I’d also like to have a map where people can register their SMS gateway locations and perhaps map out it’s coverage. If gateways and mobile apps all used the same SDK application token then people could use whichever gateway they were nearest too.

To help subsidize and encourage people to run gateways that other people can use, I would ultimately like to have them support messages that include Lot49 based micropayments. This would lay the groundwork to build a sustainable bottom up mesh network.

3 Likes

Thanks Richard! Impressive write-up! Thanks for putting this together and for working with me over the past few months to bring this concept to reality. As you mentioned, at this point in time, we are ready to share the progress we’ve made even though it’s not a finished product by any means. We are hopeful that the community will have interest in getting involved with this project, whether it be as a friendly tester or writing code to help advance and improve the stability of the SMS Gateway. In the coming weeks, be on the lookout for an In The Mesh article discussing this project in more detail. Also, we will link a survey to gather feedback on features that potential customers are most interested in. Finally, we will be looking to identify a few friendly users who would be interested in testing a finished prototype version of the gateway in exchange for sharing your experiences using the gateway.

For our prototype build, we used the following hardware components:

I will post a few pictures of the SMS Gateway prototype and would be more than happy to answer questions regarding the build process. If there in interest, I can create a step-by-step document, as its a fairly involved process from start to finish.

As Richard alluded to and you can probably ascertain from the parts list, the SMS Gateway will have the ability to provide GPS coordinates, so we envision having a map layer which allows for dynamic location mapping of gateway units. There are many potential build scenarios for this gateway and one that we are most excited about is using an Iridium satellite modem to relay goTenna Mesh messages from rural locations that have no cellular coverage. Ultimately, we envision the SMS Gateway as an incentivized node running Global Mesh Labs Lot49 protocol… allowing gateway hosts to earn Bitcoin Lightning micropayments for relaying messages.

5 Likes

Here are photos of the prototype SMS Gateway:

The last two photos include: a low-power “eco” version, using an RPI Zero W and Narrowband NB-IoT modem; and then a Iridium satellite modem version.

4 Likes