Created
July 25, 2023 21:14
-
-
Save a-a/4d589a3d7dd71230558e0f5b1d4a7861 to your computer and use it in GitHub Desktop.
rpitx pocsag - simple and dirty udp forwarder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=POCSAG UDP Relay | |
After=network-online.target | |
Wants=network-online.target systemd-networkd-wait-online.service | |
[Service] | |
Type=simple | |
ExecStart=/usr/bin/python3 /usr/local/bin/pocsag-udp-relay.py | |
StandardInput=tty-force | |
Restart=on-failure | |
RestartSec=5s | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This file MUST be edited with the 'visudo' command as root. | |
# | |
# Please consider adding local content in /etc/sudoers.d/ instead of | |
# directly modifying this file. | |
# | |
# See the man page for details on how to write a sudoers file. | |
# | |
Defaults env_reset | |
Defaults mail_badpass | |
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | |
# Host alias specification | |
# User alias specification | |
# Cmnd alias specification | |
# User privilege specification | |
root ALL=(ALL:ALL) ALL | |
# Allow members of group sudo to execute any command | |
%sudo ALL=(ALL:ALL) ALL | |
# Allow anybody to use the pocsag transmitter | |
ALL ALL=(root) NOPASSWD: /usr/local/sbin/pocsag | |
# See sudoers(5) for more information on "#include" directives: | |
#includedir /etc/sudoers.d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import socket | |
import subprocess | |
UDP_PORT = 42069 | |
RIC = b"1123079" | |
# ^ ^ ^ Here we are hardcoding the RIC. You can amend that and line 18 | |
# if you want to blindly trust the sender to pass RIC and colon character instead. | |
sock = socket.socket(socket.AF_INET, # Internet | |
socket.SOCK_DGRAM) # UDP | |
sock.bind(('', UDP_PORT)) | |
while True: | |
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes | |
print("received message: %s" % data) | |
msg = data[:80] | |
page = RIC + b":"+ msg | |
result = subprocess.run(['sudo', 'pocsag', '-f', '153225000'], input=page, capture_output=True) | |
print('stdout:', result.stdout) | |
print('stderr:', result.stderr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment