-
-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BME WebSocket telmetry submitter
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
1 parent
a34ed29
commit f912372
Showing
14 changed files
with
111 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |
This file contains 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 contains 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 contains 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 contains 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 contains 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 contains 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 contains 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
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 |
This file contains 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 contains 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 contains 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
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}') |
This file contains 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
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 | ||
# | ||
|
@@ -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 | ||
|
||
|
||
|
@@ -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) | ||
|
@@ -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( | ||
|
This file contains 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
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 | ||
|
This file contains 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