mirror of
https://github.com/markqvist/Sideband.git
synced 2025-04-19 15:15:57 -04:00
Compare commits
No commits in common. "main" and "1.5.0" have entirely different histories.
78
README.md
78
README.md
@ -1,7 +1,7 @@
|
||||
Sideband <img align="right" src="https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg"/>
|
||||
=========
|
||||
|
||||
Sideband is an extensible LXMF messaging and LXST telephony client, situational awareness tracker and remote control and monitoring system for Android, Linux, macOS and Windows. It allows you to communicate with other people or LXMF-compatible systems over Reticulum networks using LoRa, Packet Radio, WiFi, I2P, Encrypted QR Paper Messages, or anything else Reticulum supports.
|
||||
Sideband is an extensible LXMF messaging client, situational awareness tracker and remote control and monitoring system for Android, Linux, macOS and Windows. It allows you to communicate with other people or LXMF-compatible systems over Reticulum networks using LoRa, Packet Radio, WiFi, I2P, Encrypted QR Paper Messages, or anything else Reticulum supports.
|
||||
|
||||

|
||||
|
||||
@ -13,11 +13,10 @@ This also means that Sideband operates differently than what you might be used t
|
||||
|
||||
Sideband provides many useful and interesting functions, such as:
|
||||
|
||||
- **Secure** and **self-sovereign** messaging and voice calls using the LXMF and LXST protocols over Reticulum.
|
||||
- **Secure** and **self-sovereign** messaging using the LXMF protocol over Reticulum.
|
||||
- **Image** and **file transfers** over all supported mediums.
|
||||
- **Audio messages** that work even over **LoRa** and **radio links**, thanks to [Codec2](https://github.com/drowe67/codec2/) and [Opus](https://github.com/xiph/opus) encoding.
|
||||
- Secure and direct P2P **telemetry and location sharing**. No third parties or servers ever have your data.
|
||||
- The telemetry system is **completely extensible** via [simple plugins](#creating-plugins).
|
||||
- Situation display on both online and **locally stored offline maps**.
|
||||
- Geospatial awareness calculations.
|
||||
- Exchanging messages through **encrypted QR-codes on paper**, or through messages embedded directly in **lxm://** links.
|
||||
@ -40,7 +39,7 @@ Sideband can run on most computing devices, but installation methods vary by dev
|
||||
|
||||
## On Android
|
||||
|
||||
For your Android devices, you can download an [APK on the latest release page](https://github.com/markqvist/Sideband/releases/latest).
|
||||
For your Android devices, you can install Sideband through F-Droid, by adding the [Between the Borders Repo](https://reticulum.betweentheborders.com/fdroid/repo/), or you can download an [APK on the latest release page](https://github.com/markqvist/Sideband/releases/latest). Both sources are signed with the same release keys, and can be used interchangably.
|
||||
|
||||
After the application is installed on your Android device, it is also possible to pull updates directly through the **Repository** section of the application.
|
||||
|
||||
@ -48,8 +47,9 @@ After the application is installed on your Android device, it is also possible t
|
||||
|
||||
On all Linux-based operating systems, Sideband is available as a `pipx`/`pip` package. This installation method **includes desktop integration**, so that Sideband will show up in your applications menu and launchers. Below are install steps for the most common recent Linux distros. For Debian 11, see the end of this section.
|
||||
|
||||
#### Basic Installation
|
||||
You will first need to install a few dependencies for voice calls, audio messaging and Codec2 support to work:
|
||||
**Please note!** The very latest Python release, Python 3.13 is currently **not** compatible with the Kivy framework, that Sideband uses to render its user interface. If your Linux distribution uses Python 3.13 as its default Python installation, you will need to install an earlier version as well. Using [the latest release of Python 3.12](https://www.python.org/downloads/release/python-3127/) is recommended.
|
||||
|
||||
You will first need to install a few dependencies for audio messaging and Codec2 support to work:
|
||||
|
||||
```bash
|
||||
# For Debian (12+), Ubuntu (22.04+) and derivatives
|
||||
@ -68,6 +68,10 @@ Once those are installed, install the Sideband application itself:
|
||||
```bash
|
||||
# Finally, install Sideband using pipx:
|
||||
pipx install sbapp
|
||||
|
||||
# If you need to specify a specific Python version,
|
||||
# use something like the following:
|
||||
pipx install sbapp --python python3.12
|
||||
```
|
||||
|
||||
After installation, you can now run Sideband in a number of different ways:
|
||||
@ -80,10 +84,7 @@ After installation, you can now run Sideband in a number of different ways:
|
||||
pipx ensurepath
|
||||
|
||||
# The first time you run Sideband, you will need to do it
|
||||
# from the terminal, for the application launcher item to
|
||||
# show up. On some distros you may also need to log out
|
||||
# and back in again, or simply reboot the machine for the
|
||||
# application entry to show up in your menu.
|
||||
# from the terminal:
|
||||
sideband
|
||||
|
||||
# At the first launch, it will add an application icon
|
||||
@ -100,9 +101,6 @@ sideband --daemon
|
||||
sideband -v
|
||||
```
|
||||
|
||||
If you do not already have Reticulum connectivity set up on your computer or local network, you will probably want to edit the Reticulum configuration file at `~/.reticulum/config` and [add any interfaces](https://reticulum.network/manual/interfaces.html) you need for connectivity.
|
||||
|
||||
#### Advanced Installation
|
||||
You can also install Sideband in various alternative ways:
|
||||
|
||||
```bash
|
||||
@ -137,17 +135,17 @@ You can install Sideband on all Raspberry Pi models that support 64-bit operatin
|
||||
|
||||
Aditionally, the `pycodec2` package needs to be installed manually. I have provided a pre-built version, that you can download and install with a single command, or if you don't want to trust my pre-built version, you can [build and install it from source yourself](https://github.com/gregorias/pycodec2/blob/main/DEV.md).
|
||||
|
||||
The install instructions below assume that you are installing Sideband on 64-bit Raspberry Pi OS (based on Debian Bookworm or later). If you're running something else on your Pi, you might need to modify some commands slightly. To install Sideband on Raspberry Pi with full support for voice calls, audio messages and Codec2, follow these steps:
|
||||
The install instructions below assume that you are installing Sideband on 64-bit Raspberry Pi OS (based on Debian Bookworm). If you're running something else on your Pi, you might need to modify some commands slightly. To install Sideband on Raspberry Pi, follow these steps:
|
||||
|
||||
```bash
|
||||
# First of all, install the required dependencies:
|
||||
sudo apt install python3-pip python3-pyaudio python3-dev python3-cryptography build-essential libopusfile0 libsdl2-dev libavcodec-dev libavdevice-dev libavfilter-dev portaudio19-dev codec2 libcodec2-1.0 xclip xsel
|
||||
|
||||
# If you don't want to compile pycodec2 yourself,
|
||||
# download the pre-compiled package provided here:
|
||||
# download the pre-compiled package provided here
|
||||
wget https://raw.githubusercontent.com/markqvist/Sideband/main/docs/utilities/pycodec2-3.0.1-cp311-cp311-linux_aarch64.whl
|
||||
|
||||
# And install it:
|
||||
# Install it:
|
||||
pip install ./pycodec2-3.0.1-cp311-cp311-linux_aarch64.whl --break-system-packages
|
||||
|
||||
# You can now install Sideband
|
||||
@ -161,8 +159,6 @@ sudo reboot
|
||||
sideband
|
||||
```
|
||||
|
||||
If you do not already have Reticulum connectivity set up on your computer or local network, you will probably want to edit the Reticulum configuration file at `~/.reticulum/config` and [add any interfaces](https://reticulum.network/manual/interfaces.html) you need for connectivity.
|
||||
|
||||
## On macOS
|
||||
|
||||
To install Sideband on macOS, you have two options available:
|
||||
@ -189,8 +185,6 @@ pip3 install rns --break-system-packages
|
||||
|
||||
If you do not have Python and `pip` available, [download and install it](https://www.python.org/downloads/) first.
|
||||
|
||||
If you do not already have Reticulum connectivity set up on your computer or local network, you will probably want to edit the Reticulum configuration file at `~/.reticulum/config` and [add any interfaces](https://reticulum.network/manual/interfaces.html) you need for connectivity.
|
||||
|
||||
#### Source Package Install
|
||||
|
||||
For more advanced setups, including the ability to run Sideband in headless daemon mode, enable debug logging output, configuration import and export and more, you may want to install it from the source package via `pip` instead.
|
||||
@ -244,8 +238,6 @@ Simply download the packaged Windows ZIP file from the [latest release page](htt
|
||||
|
||||
When running Sideband for the first time, a default Reticulum configuration file will be created, if you don't already have one. If you don't have any existing Reticulum connectivity available locally, you may want to edit the file, located at `C:\Users\USERNAME\.reticulum\config` and manually add an interface that provides connectivity to a wider network. If you just want to connect over the Internet, you can add one of the public hubs on the [Reticulum Testnet](https://reticulum.network/connect.html).
|
||||
|
||||
#### Installing Reticulum Utilities
|
||||
|
||||
Though the ZIP file contains everything necessary to run Sideband, it is also recommended to install the Reticulum command line utilities separately, so that you can use commands like `rnstatus` and `rnsd` from the command line. This will make it easier to manage Reticulum connectivity on your system. If you do not already have Python installed on your system, [download and install it](https://www.python.org/downloads/) first.
|
||||
|
||||
**Important!** When asked by the installer, make sure to add the Python program to your `PATH` environment variables. If you don't do this, you will not be able to use the `pip` installer, or run any of the installed commands. When Python has been installed, you can open a command prompt and install the Reticulum package via `pip`:
|
||||
@ -270,28 +262,6 @@ The Sideband application can now be launched by running the command `sideband` i
|
||||
|
||||
Since this installation method automatically installs the `rns` and `lxmf` packages as well, you will also have access to using all the included RNS and LXMF utilities like `rnstatus`, `rnsd` and `lxmd` on your system.
|
||||
|
||||
# Creating Plugins
|
||||
|
||||
Sideband features a flexible and extensible plugin system, that allows you to hook all kinds of control, status reporting, command execution and telemetry collection into the LXMF messaging system. Plugins can be created as either *Telemetry*, *Command* or *Service* plugins, for different use-cases.
|
||||
|
||||
To create plugins for Sideband, you can find a variety of [code examples](https://github.com/markqvist/Sideband/tree/main/docs/example_plugins) in this repository, that you can use as a basis for writing your own plugins. The example plugins include:
|
||||
|
||||
- [Custom telemetry](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/telemetry.py)
|
||||
- [Getting BME280 temperature, humidity and pressure](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/bme280_telemetry.py)
|
||||
- [Basic commands](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/basic.py)
|
||||
- [Location telemetry from GPSd on Linux](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/gpsd_location.py)
|
||||
- [Location telemetry from Windows Location Provider](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/windows_location.py)
|
||||
- [Getting statistics from your LXMF propagation node](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/lxmd_telemetry.py)
|
||||
- [Viewing cameras and streams](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/view.py)
|
||||
- [Fetching an XKCD comic](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/comic.py)
|
||||
- [Creating a service plugin](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/service.py)
|
||||
|
||||
For creating telemetry plugins, Sideband includes 20+ built-in sensor types to chose from, for representing all kinds telemetry data. If none of those fit your needs, there is a `Custom` sensor type, that can include any kind of data.
|
||||
|
||||
Command plugins allow you to define any kind of action or command to be run when receiving command messages from other LXMF clients. In the example directory, you will find various command plugin templates, for example for viewing security cameras or webcams through Sideband.
|
||||
|
||||
Service plugins allow you to integrate any kind of service, bridge or other system into Sideband, and have that react to events or state changes in Sideband itself.
|
||||
|
||||
# Paper Messaging Example
|
||||
|
||||
You can try out the paper messaging functionality by using the following QR-code. It is a paper message sent to the LXMF address `6b3362bd2c1dbf87b66a85f79a8d8c75`. To be able to decrypt and read the message, you will need to import the following base32-encoded Reticulum Identity into the app:
|
||||
@ -327,6 +297,26 @@ You can help support the continued development of open, free and private communi
|
||||
|
||||
<br/>
|
||||
|
||||
# Planned Features
|
||||
|
||||
- <s>Secure and private location and telemetry sharing</s>
|
||||
- <s>Including images in messages</s>
|
||||
- <s>Sending file attachments</s>
|
||||
- <s>Offline and online maps</s>
|
||||
- <s>Paper messages</s>
|
||||
- <s>Using Sideband as a Reticulum Transport Instance</s>
|
||||
- <s>Encryption keys export and import</s>
|
||||
- <s>Plugin support for commands, services and telemetry</s>
|
||||
- <s>Sending voice messages (using Codec2 and Opus)</s>
|
||||
- <s>Adding a Linux desktop integration</s>
|
||||
- <s>Adding prebuilt Windows binaries to the releases</s>
|
||||
- <s>Adding prebuilt macOS binaries to the releases</s>
|
||||
- <s>A debug log viewer</s>
|
||||
- Adding a Nomad Net page browser
|
||||
- LXMF sneakernet functionality
|
||||
- Network visualisation and test tools
|
||||
- Better message sorting mechanism
|
||||
|
||||
# License
|
||||
Unless otherwise noted, this work is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa].
|
||||
|
||||
|
@ -1,88 +0,0 @@
|
||||
# Windows Location Provider plugin example, provided by @haplo-dev
|
||||
|
||||
import RNS
|
||||
import time
|
||||
import threading
|
||||
import asyncio
|
||||
from winsdk.windows.devices import geolocation
|
||||
|
||||
class WindowsLocationPlugin(SidebandTelemetryPlugin):
|
||||
plugin_name = "windows_location"
|
||||
|
||||
def __init__(self, sideband_core):
|
||||
self.update_interval = 5.0
|
||||
self.should_run = False
|
||||
|
||||
self.latitude = None
|
||||
self.longitude = None
|
||||
self.altitude = None
|
||||
self.speed = None
|
||||
self.bearing = None
|
||||
self.accuracy = None
|
||||
self.last_update = None
|
||||
|
||||
super().__init__(sideband_core)
|
||||
|
||||
def start(self):
|
||||
RNS.log("Starting Windows Location provider plugin...")
|
||||
|
||||
self.should_run = True
|
||||
update_thread = threading.Thread(target=self.update_job, daemon=True)
|
||||
update_thread.start()
|
||||
|
||||
super().start()
|
||||
|
||||
def stop(self):
|
||||
self.should_run = False
|
||||
super().stop()
|
||||
|
||||
def update_job(self):
|
||||
while self.should_run:
|
||||
RNS.log("Updating location from Windows Geolocation...", RNS.LOG_DEBUG)
|
||||
try:
|
||||
asyncio.run(self.get_location())
|
||||
except Exception as e:
|
||||
RNS.log(f"Error getting location: {str(e)}", RNS.LOG_ERROR)
|
||||
|
||||
time.sleep(self.update_interval)
|
||||
|
||||
async def get_location(self):
|
||||
geolocator = geolocation.Geolocator()
|
||||
position = await geolocator.get_geoposition_async()
|
||||
|
||||
self.last_update = time.time()
|
||||
self.latitude = position.coordinate.latitude
|
||||
self.longitude = position.coordinate.longitude
|
||||
self.altitude = position.coordinate.altitude
|
||||
self.accuracy = position.coordinate.accuracy
|
||||
|
||||
# Note: Windows Geolocation doesn't provide speed and bearing directly
|
||||
# You might need to calculate these from successive position updates
|
||||
self.speed = None
|
||||
self.bearing = None
|
||||
|
||||
def has_location(self):
|
||||
return all([self.latitude, self.longitude, self.altitude, self.accuracy]) is not None
|
||||
|
||||
def update_telemetry(self, telemeter):
|
||||
if self.is_running() and telemeter is not None:
|
||||
if self.has_location():
|
||||
RNS.log("Updating location from Windows Geolocation", RNS.LOG_DEBUG)
|
||||
if "location" not in telemeter.sensors:
|
||||
telemeter.synthesize("location")
|
||||
|
||||
telemeter.sensors["location"].latitude = self.latitude
|
||||
telemeter.sensors["location"].longitude = self.longitude
|
||||
telemeter.sensors["location"].altitude = self.altitude
|
||||
telemeter.sensors["location"].speed = self.speed
|
||||
telemeter.sensors["location"].bearing = self.bearing
|
||||
telemeter.sensors["location"].accuracy = self.accuracy
|
||||
telemeter.sensors["location"].stale_time = 5
|
||||
telemeter.sensors["location"].set_update_time(self.last_update)
|
||||
|
||||
else:
|
||||
RNS.log("No location from Windows Geolocation yet", RNS.LOG_DEBUG)
|
||||
|
||||
# Finally, tell Sideband what class in this
|
||||
# file is the actual plugin class.
|
||||
plugin_class = WindowsLocationPlugin
|
@ -10,7 +10,7 @@ source.exclude_patterns = app_storage/*,venv/*,Makefile,./Makefil*,requirements,
|
||||
|
||||
version.regex = __version__ = ['"](.*)['"]
|
||||
version.filename = %(source.dir)s/main.py
|
||||
android.numeric_version = 20250327
|
||||
android.numeric_version = 20250220
|
||||
|
||||
requirements = kivy==2.3.0,libbz2,pillow==10.2.0,qrcode==7.3.1,usb4a,usbserial4a,able_recipe,libwebp,libogg,libopus,opusfile,numpy,cryptography,ffpyplayer,codec2,pycodec2,sh,pynacl,typing-extensions,mistune>=3.0.2,beautifulsoup4
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
__debug_build__ = False
|
||||
__disable_shaders__ = False
|
||||
__version__ = "1.5.1"
|
||||
__version__ = "1.5.0"
|
||||
__variant__ = ""
|
||||
|
||||
import sys
|
||||
|
@ -8,7 +8,6 @@ import sqlite3
|
||||
import random
|
||||
import shlex
|
||||
import re
|
||||
import gc
|
||||
|
||||
import RNS.vendor.umsgpack as msgpack
|
||||
import RNS.Interfaces.Interface as Interface
|
||||
@ -170,7 +169,6 @@ class SidebandCore():
|
||||
self.reticulum = None
|
||||
self.webshare_server = None
|
||||
self.voice_running = False
|
||||
self.telephone = None
|
||||
self.telemeter = None
|
||||
self.telemetry_running = False
|
||||
self.latest_telemetry = None
|
||||
@ -269,7 +267,6 @@ class SidebandCore():
|
||||
self.webshare_ssl_cert_path = self.app_dir+"/app_storage/ssl_cert.pem"
|
||||
|
||||
self.mqtt = None
|
||||
self.mqtt_handle_lock = threading.Lock()
|
||||
|
||||
self.first_run = True
|
||||
self.saving_configuration = False
|
||||
@ -575,7 +572,7 @@ class SidebandCore():
|
||||
RNS.log("Loading Sideband identity...", RNS.LOG_DEBUG)
|
||||
self.identity = RNS.Identity.from_file(self.identity_path)
|
||||
|
||||
self.rpc_addr = f"\0sideband/rpc"
|
||||
self.rpc_addr = ("127.0.0.1", 48165)
|
||||
self.rpc_key = RNS.Identity.full_hash(self.identity.get_private_key())
|
||||
|
||||
RNS.log("Loading Sideband configuration... "+str(self.config_path), RNS.LOG_DEBUG)
|
||||
@ -1790,7 +1787,7 @@ class SidebandCore():
|
||||
try:
|
||||
with self.rpc_lock:
|
||||
if self.rpc_connection == None:
|
||||
self.rpc_connection = multiprocessing.connection.Client(self.rpc_addr, family="AF_UNIX", authkey=self.rpc_key)
|
||||
self.rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key)
|
||||
self.rpc_connection.send(request)
|
||||
response = self.rpc_connection.recv()
|
||||
return response
|
||||
@ -1962,12 +1959,12 @@ class SidebandCore():
|
||||
def __start_rpc_listener(self):
|
||||
try:
|
||||
RNS.log("Starting RPC listener", RNS.LOG_DEBUG)
|
||||
self.rpc_listener = multiprocessing.connection.Listener(self.rpc_addr, family="AF_UNIX", authkey=self.rpc_key)
|
||||
self.rpc_listener = multiprocessing.connection.Listener(self.rpc_addr, authkey=self.rpc_key)
|
||||
thread = threading.Thread(target=self.__rpc_loop)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
except Exception as e:
|
||||
RNS.log("Could not start RPC listener on @"+str(self.rpc_addr[1:])+". Terminating now. Clear up anything using the port and try again.", RNS.LOG_ERROR)
|
||||
RNS.log("Could not start RPC listener on "+str(self.rpc_addr)+". Terminating now. Clear up anything using the port and try again.", RNS.LOG_ERROR)
|
||||
RNS.panic()
|
||||
|
||||
def __rpc_loop(self):
|
||||
@ -2143,7 +2140,6 @@ class SidebandCore():
|
||||
dbc = db.cursor()
|
||||
|
||||
dbc.execute("CREATE TABLE IF NOT EXISTS telemetry (id INTEGER PRIMARY KEY, dest_context BLOB, ts INTEGER, data BLOB)")
|
||||
dbc.execute("CREATE INDEX IF NOT EXISTS idx_telemetry_ts ON telemetry(ts)")
|
||||
db.commit()
|
||||
|
||||
def _db_upgradetables(self):
|
||||
@ -3272,37 +3268,12 @@ class SidebandCore():
|
||||
self.setstate("app.flags.last_telemetry", time.time())
|
||||
|
||||
def mqtt_handle_telemetry(self, context_dest, telemetry):
|
||||
with self.mqtt_handle_lock:
|
||||
# TODO: Remove debug
|
||||
if hasattr(self, "last_mqtt_recycle") and time.time() > self.last_mqtt_recycle + 60*4:
|
||||
# RNS.log("Recycling MQTT handler", RNS.LOG_DEBUG)
|
||||
self.mqtt.stop()
|
||||
self.mqtt.client = None
|
||||
self.mqtt = None
|
||||
gc.collect()
|
||||
if self.mqtt == None:
|
||||
self.mqtt = MQTT()
|
||||
|
||||
if self.mqtt == None:
|
||||
self.mqtt = MQTT()
|
||||
self.last_mqtt_recycle = time.time()
|
||||
|
||||
self.mqtt.set_server(self.config["telemetry_mqtt_host"], self.config["telemetry_mqtt_port"])
|
||||
self.mqtt.set_auth(self.config["telemetry_mqtt_user"], self.config["telemetry_mqtt_pass"])
|
||||
self.mqtt.handle(context_dest, telemetry)
|
||||
|
||||
# TODO: Remove debug
|
||||
# if not hasattr(self, "memtr"):
|
||||
# from pympler import muppy
|
||||
# from pympler import summary
|
||||
# import resource
|
||||
# self.res = resource
|
||||
# self.ms = summary; self.mp = muppy
|
||||
# self.memtr = self.ms.summarize(self.mp.get_objects())
|
||||
# RNS.log(f"RSS: {RNS.prettysize(self.res.getrusage(self.res.RUSAGE_SELF).ru_maxrss*1000)}")
|
||||
# else:
|
||||
# memsum = self.ms.summarize(self.mp.get_objects())
|
||||
# memdiff = self.ms.get_diff(self.memtr, memsum)
|
||||
# self.ms.print_(memdiff)
|
||||
# RNS.log(f"RSS: {RNS.prettysize(self.res.getrusage(self.res.RUSAGE_SELF).ru_maxrss*1000)}")
|
||||
self.mqtt.set_server(self.config["telemetry_mqtt_host"], self.config["telemetry_mqtt_port"])
|
||||
self.mqtt.set_auth(self.config["telemetry_mqtt_user"], self.config["telemetry_mqtt_pass"])
|
||||
self.mqtt.handle(context_dest, telemetry)
|
||||
|
||||
def update_telemetry(self):
|
||||
try:
|
||||
@ -4115,13 +4086,13 @@ class SidebandCore():
|
||||
ifac_size = None
|
||||
|
||||
interface_config = {
|
||||
"name": "TCP Client",
|
||||
"name": "TCPClientInterface",
|
||||
"target_host": tcp_host,
|
||||
"target_port": tcp_port,
|
||||
"kiss_framing": False,
|
||||
"i2p_tunneled": False,
|
||||
}
|
||||
tcpinterface = RNS.Interfaces.BackboneInterface.BackboneClientInterface(RNS.Transport, interface_config)
|
||||
tcpinterface = RNS.Interfaces.TCPInterface.TCPClientInterface(RNS.Transport, interface_config)
|
||||
tcpinterface.OUT = True
|
||||
|
||||
if RNS.Reticulum.transport_enabled():
|
||||
|
@ -44,14 +44,11 @@ class MQTT():
|
||||
RNS.log("All MQTT messages processed", RNS.LOG_DEBUG)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"An error occurred while running MQTT scheduler jobs: {e}", RNS.LOG_ERROR)
|
||||
RNS.log("An error occurred while running MQTT scheduler jobs: {e}", RNS.LOG_ERROR)
|
||||
RNS.trace_exception(e)
|
||||
|
||||
time.sleep(MQTT.SCHEDULER_SLEEP)
|
||||
|
||||
try: self.disconnect()
|
||||
except Exception as e: RNS.log(f"An error occurred while disconnecting MQTT server: {e}", RNS.LOG_ERROR)
|
||||
|
||||
RNS.log("Stopped MQTT scheduler", RNS.LOG_DEBUG)
|
||||
|
||||
def connect_failed(self, client, userdata):
|
||||
|
@ -120,11 +120,9 @@ class Telemeter():
|
||||
|
||||
def stop_all(self):
|
||||
if not self.from_packed:
|
||||
sensors = self.sensors.copy()
|
||||
for sensor in sensors:
|
||||
for sensor in self.sensors:
|
||||
if not sensor == "time":
|
||||
self.sensors[sensor].stop()
|
||||
del sensors
|
||||
|
||||
def read(self, sensor):
|
||||
if not self.from_packed:
|
||||
@ -139,38 +137,31 @@ class Telemeter():
|
||||
|
||||
def read_all(self):
|
||||
readings = {}
|
||||
sensors = self.sensors.copy()
|
||||
for sensor in sensors:
|
||||
for sensor in self.sensors:
|
||||
if self.sensors[sensor].active:
|
||||
if not self.from_packed:
|
||||
readings[sensor] = self.sensors[sensor].data
|
||||
else:
|
||||
readings[sensor] = self.sensors[sensor]._data
|
||||
|
||||
del sensors
|
||||
return readings
|
||||
|
||||
def packed(self):
|
||||
packed = {}
|
||||
packed[Sensor.SID_TIME] = int(time.time())
|
||||
sensors = self.sensors.copy()
|
||||
for sensor in sensors:
|
||||
for sensor in self.sensors:
|
||||
if self.sensors[sensor].active:
|
||||
packed[self.sensors[sensor].sid] = self.sensors[sensor].pack()
|
||||
|
||||
del sensors
|
||||
return umsgpack.packb(packed)
|
||||
|
||||
def render(self, relative_to=None):
|
||||
rendered = []
|
||||
sensors = self.sensors.copy()
|
||||
for sensor in sensors:
|
||||
for sensor in self.sensors:
|
||||
s = self.sensors[sensor]
|
||||
if s.active:
|
||||
r = s.render(relative_to)
|
||||
if r: rendered.append(r)
|
||||
|
||||
del sensors
|
||||
return rendered
|
||||
|
||||
def check_permission(self, permission):
|
||||
|
Loading…
x
Reference in New Issue
Block a user