๐พ Archived View for m0yng.uk โบ 2019 โบ 11 โบ %F0%9F%93%9F-Pager-notifications-from-Mastodon-%F0%9F%90%โฆ captured on 2022-04-28 at 17:45:31. Gemini links have been rewritten to link to archived content
โฌ ๏ธ Previous capture (2022-03-01)
โก๏ธ Next capture (2022-06-03)
-=-=-=-=-=-=-
Created 2019-11-14
Modified 2019-11-15
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[1], and my Pi-Star is too. I can send and receive pages!
What now?
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[2][3]
2: https://github.com/DL7FL/DAPNET/tree/master/DAPNET
3: 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!
#!/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)
; 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
-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-
๐ค Black Lives Matter
๐๐ค๐ Trans Rights are Human Rights
โค๏ธ๐งก๐๐๐๐ Love is Love
Copyright ยฉ 2022 Christopher M0YNG
Code snippets are licenced under the Hippocratic License 3.0 (or later.)
Page generated 2022-04-27 by Complex 19