Created 2019-11-14
Modified 2019-11-15
- Amateur Radio
- Pager
- DAPNET
A little while ago SP6MR pointed out that Pi-Star now supports POCSAG, a pager standard. I know pagers are basically dead, but who cares, this is Amateur Radio!
So, after a couple of false starts with pagers bought off eBay that I couldn't modify, I bit the bullet and ordered a new pager from China π¨π³ which was suitable for use on the 70cm amateur radio band. Easy!
I'll spare you the details of getting it coded up, the software isn't great, only works on Windows, and the drivers aren't signed.
So, now I have a pager, it's registered on DAPNET, and my Pi-Star is too. I can send and receive pages!
What now?
Mastodon.Radio notifications!
Obviously (it's not obvious, is it?) I want to get notifications of things happening on Mastodon.Radio via my new pager!
The following code is hacked together, basic, has no error handling, and will break. Do not use it in production. It uses Python3 and is based on https://github.com/DL7FL/DAPNET/tree/master/DAPNET
You will need to setup an app on your mastodon server, and grab the access_token
to put into your config file.
It uses the streaming API of Mastodon, so often the pager get's a notification faster than Tusky on my phone!
Main file
#!/usr/bin/env python3
# --------------------------------------
# Mastodon Notifications -> DAPNET Pager
# Maybe.
#
# M0YNG 2019
# --------------------------------------
# Requirements
import dapnet
import configparser
from mastodon import Mastodon
from mastodon.streaming import StreamListener
# Load the config
config = configparser.ConfigParser()
config.read('config.ini')
# Setup logging
import sys
import logging
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s;%(levelname)s;%(message)s")
logger = logging.getLogger(sys.argv[0])
# Connect to mastodon server
mastodon = Mastodon(
access_token = config['mastodon']['access_token'],
api_base_url = config['mastodon']['api_base_url']
)
# Setup what to do with streams
class myListener(StreamListener):
def on_notification(self, notification):
# Construct a message to send
message = 'New ' + notification['type'] + ' from ' + notification['account']['acct']
print(message)
# Send it
dapnet.send(message, config['dapnet']['callsign_list'].split(','), config['dapnet']['username'], config['dapnet']['password'], config['dapnet']['serverURL'], config['dapnet']['txgroup'])
# Connect the listener to the stream
listener = myListener()
mastodon.stream_user(listener)
config.ini
; Your Mastodon account credentials
[mastodon]
access_token = token_here
api_base_url = https://mastodon.radio
; Your DAPNET account credentials
[dapnet]
username = callsign
password = password
serverURL = http://www.hampager.de:8080/calls
txgroup = uk-all
callsign_list = M0YNG
Like I said, entirely pointless, but maybe you find the idea amusing enough to try yourself? If you do, please light my pager up by sending me a toot! @[email protected]