Skip to content

Commit

Permalink
Add BME WebSocket telmetry submitter
Browse files Browse the repository at this point in the history
This adds support for sending telemetry to the BME WebSocket server,
which is used by MRC-100.

The implementation uses the Python websocket-client package (Debian
/Ubuntu package python3-websocket), which has been added as a dependency
in the installation instructions in the documentation and in the
debian package control file. The build-ubuntu CI action has been updated
to include python3-websocket in the Docker image.

The older BME HTTP telemetry server has been marked as deprecated,
since it is no longer operational.
  • Loading branch information
daniestevez committed Jul 5, 2023
1 parent a34ed29 commit f912372
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: daniestevez/[email protected].5
- uses: daniestevez/[email protected].6
6 changes: 4 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Build-Depends: cmake,
python3-construct,
python3-dev,
python3-requests,
python3-six
python3-six,
python3-websocket
Standards-Version: 4.5.0
Homepage: http://github.com/daniestevez/gr-satellites
Vcs-Git: git://github.com/daniestevez/gr-satellites.git
Expand All @@ -26,7 +27,8 @@ Pre-Depends: ${misc:Pre-Depends}
Depends: ${misc:Depends}, ${python3:Depends}, ${shlibs:Depends},
gnuradio,
python3-construct,
python3-requests
python3-requests,
python3-websocket
Recommends: feh
Description:GNU Radio out-of-tree module with Amateur satellite decoders.
gr-satellites is a GNU Radio out-of-tree module that contains a collection of
Expand Down
9 changes: 8 additions & 1 deletion docs/source/command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,10 @@ certain satellite projects:

* `PW-Sat2 Groundstation`_, which is used by PW-Sat2.

* The `BME telemetry server`_, which is used by SMOG-P, ATL-1 and SMOG-1.
* The `BME telemetry server`_, which is used by SMOG-P, ATL-1 and SMOG-1. (This
server is deprecated, since it is not used anymore by BME).

* The `BME telemetry server (WebSocket)`_, which is used by MRC-100.

* `Harbin Institute of Technology`_, which connects to the telemetry proxy included in
`gr-lilacsat`_ and `gr-dslwp`_.
Expand Down Expand Up @@ -553,6 +556,9 @@ To enable telemetry submission to the BME server, it is necessary to
`register an account in the BME server`_. The user and password should be
entered into the gr-satellites ``.ini`` file.

The BME server (WebSocket) does not require any registration or additional
configuration.

To use the Harbin Institute of Technology proxy to submit telemetry, the proxy
needs to be run and started in the local computer before running
``gr_satellites``. The command line tool will connect to the correct port where
Expand Down Expand Up @@ -779,6 +785,7 @@ Example:
.. _FUNcube Warehouse: http://warehouse.funcube.org.uk/
.. _PW-Sat2 Groundstation: https://radio.pw-sat.pl/
.. _BME telemetry server: https://gnd.bme.hu:8080/
.. _BME telemetry server (WebSocket): https://gnd.bme.hu/
.. _registering in the warehouse: http://warehouse.funcube.org.uk/registration
.. _Your credentials: https://radio.pw-sat.pl/communication/yourcredentials
.. _register an account in the BME server: https://gnd.bme.hu:8080/auth/register
Expand Down
2 changes: 2 additions & 0 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Additionally, the following Python packages are required:

* `construct`_, at least version 2.9.
* `requests`_
* `websocket-client`_

.. note::
construct and requests can be installed with `pip`_
Expand All @@ -49,6 +50,7 @@ Additionally, the following Python packages are required:
.. _GNU Radio: https://gnuradio.org/
.. _construct: https://construct.readthedocs.io/en/latest/
.. _requests: https://pypi.org/project/requests/
.. _websocket-client: https://pypi.org/project/websocket-client/
.. _pip: https://pypi.org/project/pip/
.. _gr-satellites README: https://github.com/daniestevez/gr-satellites/blob/main/README.md

Expand Down
1 change: 1 addition & 0 deletions grc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ install(FILES
satellites_ax100_decode.block.yml
satellites_beesat_classifier.block.yml
satellites_bme_submitter.block.yml
satellites_bme_ws_submitter.block.yml
satellites_cc11xx_packet_crop.block.yml
satellites_check_address.block.yml
satellites_check_ao40_uncoded_crc.block.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ parameters:
label: Server
dtype: enum
default: '"SatNOGS"'
options: ['"SatNOGS"', '"FUNcube"', '"PWSat"', '"BME"', '"HIT"', '"SIDS"']
option_labels: [SatNOGS DB, AMSAT-UK Data Warehouse, PW-Sat2 Ground Station, BME Ground Station, Harbin Institute of Technology, Custom SIDS server]
options: ['"SatNOGS"', '"FUNcube"', '"PWSat"', '"BME"', '"BMEWS"', '"HIT"', '"SIDS"']
option_labels: [SatNOGS DB, AMSAT-UK Data Warehouse, PW-Sat2 Ground Station, BME Ground Station (Deprecated), BME Ground Station (WebSocket), Harbin Institute of Technology, Custom SIDS server]
- id: url
label: URL
dtype: string
Expand Down
4 changes: 2 additions & 2 deletions grc/satellites_bme_submitter.block.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id: satellites_bme_submitter
label: BME Telemetry Forwarder
category: '[Satellites]/Misc'
label: BME Telemetry Forwarder (Deprecated)
category: '[Satellites]/Deprecated'

parameters:
- id: user
Expand Down
13 changes: 13 additions & 0 deletions grc/satellites_bme_ws_submitter.block.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
id: satellites_bme_ws_submitter
label: BME Telemetry Forwarder (WebSocket)
category: '[Satellites]/Misc'

inputs:
- domain: message
id: in

templates:
imports: import satellites
make: satellites.bme_submitter()

file_format: 1
1 change: 1 addition & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ GR_PYTHON_INSTALL(
bch15.py
beesat_classifier.py
bme_submitter.py
bme_ws_submitter.py
cc11xx_packet_crop.py
check_address.py
check_ao40_uncoded_crc.py
Expand Down
1 change: 1 addition & 0 deletions python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from .append_crc32c import append_crc32c
from .beesat_classifier import beesat_classifier
from .bme_submitter import bme_submitter
from .bme_ws_submitter import bme_ws_submitter
from .cc11xx_packet_crop import cc11xx_packet_crop
from .check_address import check_address
from .check_ao40_uncoded_crc import check_ao40_uncoded_crc
Expand Down
66 changes: 66 additions & 0 deletions python/bme_ws_submitter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright 2023 Daniel Estevez <[email protected]>
#
# This file is part of gr-satellites
#
# SPDX-License-Identifier: GPL-3.0-or-later

import json

from gnuradio import gr
import pmt
import websocket


class bme_ws_submitter(gr.basic_block):
"""
Submits telemetry to wss://gnd.bme.hu:8070/send
"""
def __init__(self):
gr.basic_block.__init__(
self,
name='bme_ws_submitter',
in_sig=[],
out_sig=[])

self.ws = websocket.WebSocket()
url = 'wss://gnd.bme.hu:8070/send'
try:
self.ws.connect(url)
except Exception:
print(f'could not connect to {url}; '
'disabling telemetry submission')
self.ws = None

self.message_port_register_in(pmt.intern('in'))
self.set_msg_handler(pmt.intern('in'), self.handle_msg)

def __del__(self):
if self.ws is not None:
self.ws.close()

def submit(self, frame):
if self.ws is None:
return
data = f'"data": "{frame.hex().upper()}"'
self.ws.send(data)
response = self.ws.recv()
response = json.loads('{' + response + '}')
error = any([v != 0 for k, v in response.items()
if 'error' in k])
if error:
print(f'server did not accept frame; returned: {response}')

def handle_msg(self, msg_pmt):
msg = pmt.cdr(msg_pmt)
if not pmt.is_u8vector(msg):
print('[ERROR] Received invalid message type. Expected u8vector')
return

frame = bytes(pmt.u8vector_elements(msg))
try:
self.submit(frame)
except Exception as e:
print(f'failed to submit frame: {e}')
9 changes: 6 additions & 3 deletions python/components/datasinks/telemetry_submit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright 2019 Daniel Estevez <[email protected]>
# Copyright 2019,2023 Daniel Estevez <[email protected]>
#
# This file is part of gr-satellites
#
Expand All @@ -11,7 +11,7 @@
from gnuradio import gr, blocks

from ... import submit, funcube_submit
from ... import pwsat2_submitter, bme_submitter, pdu_to_kiss
from ... import pwsat2_submitter, bme_submitter, bme_ws_submitter, pdu_to_kiss
from ...utils.options_block import options_block


Expand All @@ -24,7 +24,8 @@ class telemetry_submit(gr.hier_block2, options_block):
These are submitted to a telemetry server
Args:
server: 'SatNOGS', 'FUNcube', 'PWSat', 'BME' or 'SIDS' (string)
server: 'SatNOGS', 'FUNcube', 'PWSat', 'BME', 'BMEWS'
or 'SIDS' (string)
norad: NORAD ID (int)
port: TCP port to connect to (used by HIT) (str)
url: SIDS URL (used by SIDS) (str)
Expand Down Expand Up @@ -64,6 +65,8 @@ def __init__(self, server, norad=None, port=None, url=None,
satellite = satellites[norad]
self.submit = bme_submitter(
config['BME']['user'], config['BME']['password'], satellite)
elif server == 'BMEWS':
self.submit = bme_ws_submitter()
elif server == 'HIT':
try:
self.tcp = blocks.socket_pdu(
Expand Down
2 changes: 2 additions & 0 deletions python/satyaml/MRC-100.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: MRC-100
norad: 99182
telemetry_servers:
- BMEWS
data:
&tlm Telemetry:
unknown
Expand Down
3 changes: 2 additions & 1 deletion python/satyaml/satyaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def check_yaml(self, yml):
raise YAMLError(f'NORAD field does not contain a number in {yml}')
if 'telemetry_servers' in d:
for server in d['telemetry_servers']:
if (server not in ['SatNOGS', 'FUNcube', 'PWSat', 'BME']
if (server not in ['SatNOGS', 'FUNcube', 'PWSat', 'BME',
'BMEWS']
and not server.startswith('HIT ')
and not server.startswith('SIDS ')):
raise YAMLError(f'Unknown telemetry server {server}')
Expand Down

0 comments on commit f912372

Please sign in to comment.