OK, we've covered how to use the RockBLOCK to send messages from anywhere on Earth. But how do you get those messages to your final destination? That is, how do you forward them from the Rock Sever server to your specific end application, like so:
Rock Seven only provides a very basic functionality here. Once a message is received on their server, it can be forwarded to a location you specify. There are only two options:
- Email - You'll receive an email at the supplied address(es).
- HTTP - An HTTP POST request will be made to the supplied URL(s)
Rock Seven has documentation on this here:
The HTTP API is documented here:
Delivery Groups
You configure message forwarding using the web based Management System. Once logged in, click Delivery Groups in the left hand navigation.
It's a fairly simple idea. Each Delivery Group is associated with one or more RockBLOCK devices. Then, for each group, you can specify one or more delivery destinations in the Delivery Addresses. It's a simple forwarding scheme. Any messages received from the RockBLOCK devices in the Delivery Group will be forwarded to the destinations in the Delivery Addresses.
The following is an HTTP POST example for forwarding Mobile Originated messages.
Adafruit IO
There is a way to get your RockBLOCK message to Adafruit IO, however it has some limitations. Rock Seven doesn't allow for any special formatting of the out going HTTP POST message. So we can't interface it directly with the AIO API. However, we can use the webhook feature of AIO to provide an endpoint destination for the HTTP POST data.
Start by following this guide for how to create a webhook for your AIO feed:
When creating the webhook URL on Adafruit IO, enable the feature to send the whole contents of the webhook event. This can be done by clicking the option in the webhook creation dialog:
You will end up with a URL for the feed's webhook.
Now log in to your Rock Seven account and go to Delivery Groups. Add a new Delivery Address for your RockBLOCK.
- Add the URL for the AIO feed's webhook into the Address field.
- Select HTTP_JSON from the Format drop down.
Now when you transmit a message from your RockBLOCK it will be forwarded as JSON data to your feed. It will show up as something like this:
It's not super useful. All you get is a raw blob of JSON text. You will have to do further processing. But that actual data is there in the aptly named data field.
Here's an example of how you could grab that JSON data, process it to get actual values in CPython (desktop, Raspberry Pi, etc), and then send those values back to the AIO feeds of interest. The data used is based on the CircuitPython example from this guide.
import struct from Adafruit_IO import Client from secrets import secrets aio = Client(secrets['aio_username'], secrets['aio_key']) # get the raw data raw_feed = aio.feeds('test-feed') raw_data = aio.receive(raw_feed.key).value # the JSON blob is truncated, so just parse manually print("Getting raw data...") data = bytes.fromhex(raw_data.split(',')[2].split(':')[1].strip('"')) values = struct.unpack("<6fB5f", data) print(values) # send parsed data back to specific feeds print("Sending to AIO...") aio.append(aio.feeds('rock-block.rb-humidity').key, values[7]) aio.append(aio.feeds('rock-block.rb-temperature1').key, values[8]) aio.append(aio.feeds('rock-block.rb-pressure').key, values[9]) aio.append(aio.feeds('rock-block.rb-temperature2').key, values[11]) print("DONE.")
Page last edited June 14, 2024
Text editor powered by tinymce.