Compare commits

..

No commits in common. "main" and "1.4.0" have entirely different histories.
main ... 1.4.0

25 changed files with 225 additions and 2040 deletions

2
.gitignore vendored
View file

@ -6,7 +6,6 @@ sbapp/bin
sbapp/app_storage sbapp/app_storage
sbapp/RNS sbapp/RNS
sbapp/LXMF sbapp/LXMF
sbapp/LXST
sbapp/precompiled sbapp/precompiled
sbapp/*.DS_Store sbapp/*.DS_Store
sbapp/*.pyc sbapp/*.pyc
@ -33,4 +32,3 @@ dist
docs/build docs/build
sideband*.egg-info sideband*.egg-info
sbapp*.egg-info sbapp*.egg-info
LXST

View file

@ -1,3 +0,0 @@
liberapay: Reticulum
ko_fi: markqvist
custom: "https://unsigned.io/donate"

View file

@ -1,7 +1,7 @@
Sideband <img align="right" src="https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg"/> 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.
![Screenshot](https://github.com/markqvist/Sideband/raw/main/docs/screenshots/devices_small.webp) ![Screenshot](https://github.com/markqvist/Sideband/raw/main/docs/screenshots/devices_small.webp)
@ -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: 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. - **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. - **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. - 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**. - Situation display on both online and **locally stored offline maps**.
- Geospatial awareness calculations. - Geospatial awareness calculations.
- Exchanging messages through **encrypted QR-codes on paper**, or through messages embedded directly in **lxm://** links. - 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 ## 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. 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. 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 **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 voice calls, audio messaging and Codec2 support to work:
You will first need to install a few dependencies for audio messaging and Codec2 support to work:
```bash ```bash
# For Debian (12+), Ubuntu (22.04+) and derivatives # For Debian (12+), Ubuntu (22.04+) and derivatives
@ -68,6 +68,10 @@ Once those are installed, install the Sideband application itself:
```bash ```bash
# Finally, install Sideband using pipx: # Finally, install Sideband using pipx:
pipx install sbapp 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: 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 pipx ensurepath
# The first time you run Sideband, you will need to do it # The first time you run Sideband, you will need to do it
# from the terminal, for the application launcher item to # from the terminal:
# 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.
sideband sideband
# At the first launch, it will add an application icon # At the first launch, it will add an application icon
@ -100,9 +101,6 @@ sideband --daemon
sideband -v 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: You can also install Sideband in various alternative ways:
```bash ```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). 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 ```bash
# First of all, install the required dependencies: # 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 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, # 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 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 pip install ./pycodec2-3.0.1-cp311-cp311-linux_aarch64.whl --break-system-packages
# You can now install Sideband # You can now install Sideband
@ -161,8 +159,6 @@ sudo reboot
sideband 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 ## On macOS
To install Sideband on macOS, you have two options available: 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 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 #### 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. 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). 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. 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`: **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. 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 # 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: 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:
@ -315,21 +285,38 @@ You can help support the continued development of open, free and private communi
``` ```
84FpY1QbxHcgdseePYNmhTHcrgMX4nFfBYtz2GKYToqHVVhJp8Eaw1Z1EedRnKD19b3B8NiLCGVxzKV17UMmmeEsCrPyA5w 84FpY1QbxHcgdseePYNmhTHcrgMX4nFfBYtz2GKYToqHVVhJp8Eaw1Z1EedRnKD19b3B8NiLCGVxzKV17UMmmeEsCrPyA5w
``` ```
- Bitcoin
```
bc1p4a6axuvl7n9hpapfj8sv5reqj8kz6uxa67d5en70vzrttj0fmcusgxsfk5
```
- Ethereum - Ethereum
``` ```
0xae89F3B94fC4AD6563F0864a55F9a697a90261ff 0xFDabC71AC4c0C78C95aDDDe3B4FA19d6273c5E73
```
- Bitcoin
```
35G9uWVzrpJJibzUwpNUQGQNFzLirhrYAH
``` ```
- Liberapay: https://liberapay.com/Reticulum/
- Ko-Fi: https://ko-fi.com/markqvist - Ko-Fi: https://ko-fi.com/markqvist
<br/> <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 # License
Unless otherwise noted, this work is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa]. Unless otherwise noted, this work is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa].

View file

@ -1,67 +0,0 @@
# This plugin provides temperature, humidity
# and pressure data via a BME280 sensor
# connected over I2C. The plugin requires
# the "smbus2" and "RPi.bme280" modules to
# be available on your system. These can be
# installed with:
#
# pip install smbus2 RPi.bme280
import os
import RNS
from importlib.util import find_spec
class BME280Plugin(SidebandTelemetryPlugin):
plugin_name = "telemetry_bme280"
I2C_ADDRESS = 0x76
I2C_BUS = 1
# If your BME280 has an offset from the true
# temperature, you can compensate for this
# by modifying this parameter.
TEMPERATURE_CORRECTION = 0.0
def start(self):
RNS.log("BME280 telemetry plugin starting...")
if find_spec("smbus2"): import smbus2
else: raise OSError(f"No smbus2 module available, cannot start BME280 telemetry plugin")
if find_spec("bme280"): import bme280
else: raise OSError(f"No bme280 module available, cannot start BME280 telemetry plugin")
self.sensor_connected = False
try:
self.bme280 = bme280
self.address = self.I2C_ADDRESS
self.bus = smbus2.SMBus(self.I2C_BUS)
self.calibration = self.bme280.load_calibration_params(self.bus, self.address)
self.sensor_connected = True
self.tc = self.TEMPERATURE_CORRECTION
except Exception as e:
RNS.log(f"Could not connect to I2C device while starting BME280 telemetry plugin", RNS.LOG_ERROR)
RNS.log(f"The contained exception was: {e}", RNS.LOG_ERROR)
super().start()
def stop(self):
self.bus.close()
super().stop()
def update_telemetry(self, telemeter):
if telemeter != None:
if self.sensor_connected:
try:
sample = self.bme280.sample(self.bus, self.address, self.calibration); ts = telemeter.sensors
telemeter.synthesize("temperature"); ts["temperature"].data = {"c": round(sample.temperature+self.tc,1)}
telemeter.synthesize("humidity"); ts["humidity"].data = {"percent_relative": round(sample.humidity,1)}
telemeter.synthesize("pressure"); ts["pressure"].data = {"mbar": round(sample.pressure,1)}
except Exception as e:
RNS.log("An error occurred while updating BME280 sensor data", RNS.LOG_ERROR)
RNS.log(f"The contained exception was: {e}", RNS.LOG_ERROR)
plugin_class = BME280Plugin

View file

@ -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

View file

@ -97,11 +97,7 @@ getrns:
-(rm ./RNS/__pycache__ -r) -(rm ./RNS/__pycache__ -r)
(cp -rv ../../LXMF/LXMF ./;rm ./LXMF/Utilities/LXMF) (cp -rv ../../LXMF/LXMF ./;rm ./LXMF/Utilities/LXMF)
-(rm ./LXMF/__pycache__ -r) -(rm ./LXMF/__pycache__ -r)
(cp -rv ../../LXST/LXST ./;rm ./LXST/Utilities/LXST)
-(rm ./LXST/__pycache__ -r)
-(rm ./LXST/Utilities/__pycache__ -r)
cleanrns: cleanrns:
-(rm ./RNS -r) -(rm ./RNS -r)
-(rm ./LXMF -r) -(rm ./LXMF -r)
-(rm ./LXST -r)

View file

@ -10,7 +10,7 @@ source.exclude_patterns = app_storage/*,venv/*,Makefile,./Makefil*,requirements,
version.regex = __version__ = ['"](.*)['"] version.regex = __version__ = ['"](.*)['"]
version.filename = %(source.dir)s/main.py version.filename = %(source.dir)s/main.py
android.numeric_version = 20250327 android.numeric_version = 20250126
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 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

View file

@ -1,6 +1,6 @@
__debug_build__ = False __debug_build__ = False
__disable_shaders__ = False __disable_shaders__ = False
__version__ = "1.7.0" __version__ = "1.4.0"
__variant__ = "" __variant__ = ""
import sys import sys
@ -8,9 +8,7 @@ import argparse
parser = argparse.ArgumentParser(description="Sideband LXMF Client") parser = argparse.ArgumentParser(description="Sideband LXMF Client")
parser.add_argument("-v", "--verbose", action='store_true', default=False, help="increase logging verbosity") parser.add_argument("-v", "--verbose", action='store_true', default=False, help="increase logging verbosity")
parser.add_argument("-c", "--config", action='store', default=None, help="specify path of config directory") parser.add_argument("-c", "--config", action='store', default=None, help="specify path of config directory")
parser.add_argument("-r", "--rnsconfig", action='store', default=None, help="specify path of RNS config directory")
parser.add_argument("-d", "--daemon", action='store_true', default=False, help="run as a daemon, without user interface") parser.add_argument("-d", "--daemon", action='store_true', default=False, help="run as a daemon, without user interface")
parser.add_argument("-i", "--interactive", action='store_true', default=False, help="connect interactive console after daemon init")
parser.add_argument("--export-settings", action='store', default=None, help="export application settings to file") parser.add_argument("--export-settings", action='store', default=None, help="export application settings to file")
parser.add_argument("--import-settings", action='store', default=None, help="import application settings from file") parser.add_argument("--import-settings", action='store', default=None, help="import application settings from file")
parser.add_argument("--version", action="version", version="sideband {version}".format(version=__version__)) parser.add_argument("--version", action="version", version="sideband {version}".format(version=__version__))
@ -27,8 +25,8 @@ import base64
import threading import threading
import RNS.vendor.umsgpack as msgpack import RNS.vendor.umsgpack as msgpack
WINDOW_DEFAULT_WIDTH = 494 WINDOW_DEFAULT_WIDTH = "494"
WINDOW_DEFAULT_HEIGHT = 800 WINDOW_DEFAULT_HEIGHT = "800"
app_ui_scaling_path = None app_ui_scaling_path = None
def apply_ui_scale(): def apply_ui_scale():
@ -178,25 +176,9 @@ if not args.daemon:
sys.path.append(local) sys.path.append(local)
if not RNS.vendor.platformutils.is_android(): if not RNS.vendor.platformutils.is_android():
model = None
max_width = WINDOW_DEFAULT_WIDTH
max_height = WINDOW_DEFAULT_HEIGHT
try:
if os.path.isfile("/sys/firmware/devicetree/base/model"):
with open("/sys/firmware/devicetree/base/model", "r") as mf:
model = mf.read()
except: pass
if model:
if model.startswith("Raspberry Pi "): max_height = 625
window_width = min(WINDOW_DEFAULT_WIDTH, max_width)
window_height = min(WINDOW_DEFAULT_HEIGHT, max_height)
from kivy.config import Config from kivy.config import Config
Config.set("graphics", "width", str(window_width)) Config.set("graphics", "width", WINDOW_DEFAULT_WIDTH)
Config.set("graphics", "height", str(window_height)) Config.set("graphics", "height", WINDOW_DEFAULT_HEIGHT)
if args.daemon: if args.daemon:
from .sideband.core import SidebandCore from .sideband.core import SidebandCore
@ -257,7 +239,6 @@ else:
from ui.conversations import Conversations, MsgSync, NewConv from ui.conversations import Conversations, MsgSync, NewConv
from ui.telemetry import Telemetry from ui.telemetry import Telemetry
from ui.utilities import Utilities from ui.utilities import Utilities
from ui.voice import Voice
from ui.objectdetails import ObjectDetails from ui.objectdetails import ObjectDetails
from ui.announces import Announces from ui.announces import Announces
from ui.messages import Messages, ts_format, messages_screen_kv from ui.messages import Messages, ts_format, messages_screen_kv
@ -277,9 +258,6 @@ else:
from kivymd.utils.set_bars_colors import set_bars_colors from kivymd.utils.set_bars_colors import set_bars_colors
android_api_version = autoclass('android.os.Build$VERSION').SDK_INT android_api_version = autoclass('android.os.Build$VERSION').SDK_INT
from android.broadcast import BroadcastReceiver
BluetoothAdapter = autoclass('android.bluetooth.BluetoothAdapter')
else: else:
from .sideband.core import SidebandCore from .sideband.core import SidebandCore
import sbapp.plyer as plyer import sbapp.plyer as plyer
@ -289,7 +267,6 @@ else:
from .ui.announces import Announces from .ui.announces import Announces
from .ui.telemetry import Telemetry from .ui.telemetry import Telemetry
from .ui.utilities import Utilities from .ui.utilities import Utilities
from .ui.voice import Voice
from .ui.objectdetails import ObjectDetails from .ui.objectdetails import ObjectDetails
from .ui.messages import Messages, ts_format, messages_screen_kv from .ui.messages import Messages, ts_format, messages_screen_kv
from .ui.helpers import ContentNavigationDrawer, DrawerList, IconListItem from .ui.helpers import ContentNavigationDrawer, DrawerList, IconListItem
@ -350,7 +327,7 @@ class SidebandApp(MDApp):
if RNS.vendor.platformutils.get_platform() == "android": if RNS.vendor.platformutils.get_platform() == "android":
self.sideband = SidebandCore(self, config_path=self.config_path, is_client=True, android_app_dir=self.app_dir, verbose=__debug_build__) self.sideband = SidebandCore(self, config_path=self.config_path, is_client=True, android_app_dir=self.app_dir, verbose=__debug_build__)
else: else:
self.sideband = SidebandCore(self, config_path=self.config_path, is_client=False, verbose=(args.verbose or __debug_build__),rns_config_path=args.rnsconfig) self.sideband = SidebandCore(self, config_path=self.config_path, is_client=False, verbose=(args.verbose or __debug_build__))
self.sideband.version_str = "v"+__version__+" "+__variant__ self.sideband.version_str = "v"+__version__+" "+__variant__
@ -375,7 +352,6 @@ class SidebandApp(MDApp):
self.settings_ready = False self.settings_ready = False
self.telemetry_ready = False self.telemetry_ready = False
self.utilities_ready = False self.utilities_ready = False
self.voice_ready = False
self.connectivity_ready = False self.connectivity_ready = False
self.hardware_ready = False self.hardware_ready = False
self.repository_ready = False self.repository_ready = False
@ -411,9 +387,6 @@ class SidebandApp(MDApp):
self.repository_url = None self.repository_url = None
self.rnode_flasher_url = None self.rnode_flasher_url = None
self.bt_adapter = None
self.discovered_bt_devices = {}
self.bt_bonded_devices = []
################################################# #################################################
# Application Startup # # Application Startup #
@ -467,67 +440,6 @@ class SidebandApp(MDApp):
argument = self.app_dir argument = self.app_dir
self.android_service.start(mActivity, argument) self.android_service.start(mActivity, argument)
def stop_service(self):
RNS.log("Stopping service...")
self.sideband.setstate("wants.service_stop", True)
while self.sideband.service_available(): time.sleep(0.2)
RNS.log("Service stopped")
def restart_service_action(self, sender):
if hasattr(self, "service_restarting") and self.service_restarting == True:
toast(f"Service restart already in progress")
else:
toast(f"Restarting RNS service...")
if hasattr(self, "connectivity_screen") and self.connectivity_screen != None:
self.connectivity_screen.ids.button_service_restart.disabled = True
def job():
if self.restart_service():
def tj(delta_time):
toast(f"Service restarted successfully!")
if hasattr(self, "connectivity_screen") and self.connectivity_screen != None:
self.connectivity_screen.ids.button_service_restart.disabled = False
Clock.schedule_once(tj, 0.1)
else:
def tj(delta_time):
toast(f"Service restart failed")
if hasattr(self, "connectivity_screen") and self.connectivity_screen != None:
self.connectivity_screen.ids.button_service_restart.disabled = False
Clock.schedule_once(tj, 0.1)
threading.Thread(target=job, daemon=True).start()
def restart_service(self):
if hasattr(self, "service_restarting") and self.service_restarting == True:
return False
else:
self.service_restarting = True
self.stop_service()
RNS.log("Waiting for service shutdown", RNS.LOG_DEBUG)
while self.sideband.service_rpc_request({"getstate": "service.heartbeat"}):
time.sleep(1)
time.sleep(4)
self.final_load_completed = False
self.sideband.service_stopped = True
RNS.log("Starting service...", RNS.LOG_DEBUG)
self.start_service()
RNS.log("Waiting for service restart...", RNS.LOG_DEBUG)
restart_timeout = time.time() + 45
while not self.sideband.service_rpc_request({"getstate": "service.heartbeat"}):
self.sideband.rpc_connection = None
time.sleep(1)
if time.time() > restart_timeout:
service_restarting = False
return False
RNS.log("Service restarted", RNS.LOG_DEBUG)
self.sideband.service_stopped = False
self.final_load_completed = True
self.service_restarting = False
return True
def start_final(self): def start_final(self):
# Start local core instance # Start local core instance
self.sideband.start() self.sideband.start()
@ -1014,66 +926,6 @@ class SidebandApp(MDApp):
self.check_bluetooth_permissions() self.check_bluetooth_permissions()
def bluetooth_update_bonded_devices(self, sender=None):
if self.bt_adapter == None: self.bt_adapter = BluetoothAdapter.getDefaultAdapter()
self.bt_bonded_devices = []
for device in self.bt_adapter.getBondedDevices():
device_addr = device.getAddress()
self.bt_bonded_devices.append(device_addr)
RNS.log(f"Updated bonded devices: {self.bt_bonded_devices}", RNS.LOG_DEBUG)
def bluetooth_scan_action(self, sender=None):
toast("Starting Bluetooth scan...")
self.start_bluetooth_scan()
def start_bluetooth_scan(self):
self.check_bluetooth_permissions()
if not self.sideband.getpersistent("permissions.bluetooth"):
self.request_bluetooth_permissions()
else:
RNS.log("Starting bluetooth scan", RNS.LOG_DEBUG)
self.discovered_bt_devices = {}
BluetoothDevice = autoclass('android.bluetooth.BluetoothDevice')
self.bt_found_action = BluetoothDevice.ACTION_FOUND
self.broadcast_receiver = BroadcastReceiver(self.on_broadcast, actions=[self.bt_found_action])
self.broadcast_receiver.start()
self.bt_adapter = BluetoothAdapter.getDefaultAdapter()
self.bluetooth_update_bonded_devices()
self.bt_adapter.startDiscovery()
def stop_bluetooth_scan(self):
RNS.log("Stopping bluetooth scan", RNS.LOG_DEBUG)
self.check_bluetooth_permissions()
if not self.sideband.getpersistent("permissions.bluetooth"):
self.request_bluetooth_permissions()
else:
self.bt_adapter = BluetoothAdapter.getDefaultAdapter()
self.bt_adapter.cancelDiscovery()
def on_broadcast(self, context, intent):
BluetoothDevice = autoclass('android.bluetooth.BluetoothDevice')
action = intent.getAction()
extras = intent.getExtras()
if str(action) == "android.bluetooth.device.action.FOUND":
if extras:
try:
if android_api_version < 33: device = intent.getParcelableExtra("android.bluetooth.device.extra.DEVICE")
else: device = intent.getParcelableExtra("android.bluetooth.device.extra.DEVICE", BluetoothDevice)
dev_name = device.getName()
dev_addr = device.getAddress()
if dev_name.startswith("RNode "):
dev_rssi = extras.getShort("android.bluetooth.device.extra.RSSI", -9999)
discovered_device = {"name": dev_name, "address": dev_addr, "rssi": dev_rssi, "discovered": time.time()}
self.discovered_bt_devices[dev_addr] = discovered_device
RNS.log(f"Discovered RNode: {discovered_device}", RNS.LOG_DEBUG)
except Exception as e:
RNS.log(f"Error while mapping discovered device: {e}", RNS.LOG_ERROR)
def on_new_intent(self, intent): def on_new_intent(self, intent):
intent_action = intent.getAction() intent_action = intent.getAction()
action = None action = None
@ -1225,35 +1077,22 @@ class SidebandApp(MDApp):
description = rnode_errors["description"] description = rnode_errors["description"]
self.sideband.setpersistent("runtime.errors.rnode", None) self.sideband.setpersistent("runtime.errors.rnode", None)
yes_button = MDRectangleFlatButton( yes_button = MDRectangleFlatButton(
text="Ignore", text="OK",
font_size=dp(18),
)
restart_button = MDRectangleFlatButton(
text="Restart RNS",
font_size=dp(18), font_size=dp(18),
) )
self.hw_error_dialog = MDDialog( self.hw_error_dialog = MDDialog(
title="Hardware Error", title="Hardware Error",
text="While communicating with an RNode, Reticulum reported the following error:\n\n[i]"+str(description)+"[/i]", text="While communicating with an RNode, Reticulum reported the following error:\n\n[i]"+str(description)+"[/i]",
buttons=[ yes_button, restart_button ], buttons=[ yes_button ],
# elevation=0, # elevation=0,
) )
def dl_yes(s): def dl_yes(s):
self.hw_error_dialog.dismiss() self.hw_error_dialog.dismiss()
self.hw_error_dialog.is_open = False self.hw_error_dialog.is_open = False
def dl_restart(s):
self.hw_error_dialog.dismiss()
self.hw_error_dialog.is_open = False
self.restart_service_action(None)
yes_button.bind(on_release=dl_yes) yes_button.bind(on_release=dl_yes)
restart_button.bind(on_release=dl_restart)
self.hw_error_dialog.open() self.hw_error_dialog.open()
self.hw_error_dialog.is_open = True self.hw_error_dialog.is_open = True
incoming_call = self.sideband.getstate("voice.incoming_call")
if incoming_call:
self.sideband.setstate("voice.incoming_call", None)
toast(f"Call from {incoming_call}", duration=7)
if self.root.ids.screen_manager.current == "messages_screen": if self.root.ids.screen_manager.current == "messages_screen":
self.messages_view.update() self.messages_view.update()
@ -1427,13 +1266,13 @@ class SidebandApp(MDApp):
self.messages_view.ids.message_text.write_tab = True self.messages_view.ids.message_text.write_tab = True
Clock.schedule_once(tab_job, 0.15) Clock.schedule_once(tab_job, 0.15)
elif len(modifiers) == 0 and self.rec_dialog != None and self.rec_dialog_is_open: elif self.rec_dialog != None and self.rec_dialog_is_open:
if text == " ": if text == " ":
self.msg_rec_a_rec(None) self.msg_rec_a_rec(None)
elif keycode == 40: elif keycode == 40:
self.msg_rec_a_save(None) self.msg_rec_a_save(None)
elif len(modifiers) == 0 and not self.rec_dialog_is_open and not self.messages_view.ids.message_text.focus and self.messages_view.ptt_enabled and keycode == 44: elif not self.rec_dialog_is_open and not self.messages_view.ids.message_text.focus and self.messages_view.ptt_enabled and keycode == 44:
if not self.key_ptt_down: if not self.key_ptt_down:
self.key_ptt_down = True self.key_ptt_down = True
self.message_ptt_down_action() self.message_ptt_down_action()
@ -1528,15 +1367,6 @@ class SidebandApp(MDApp):
if text == "o": if text == "o":
self.objects_action() self.objects_action()
if text == "e":
self.voice_action()
if text == " ":
self.voice_answer_action()
if text == ".":
self.voice_reject_action()
if text == "r": if text == "r":
if self.root.ids.screen_manager.current == "conversations_screen": if self.root.ids.screen_manager.current == "conversations_screen":
if self.include_objects: if self.include_objects:
@ -1595,8 +1425,6 @@ class SidebandApp(MDApp):
self.close_sub_utilities_action() self.close_sub_utilities_action()
elif self.root.ids.screen_manager.current == "logviewer_screen": elif self.root.ids.screen_manager.current == "logviewer_screen":
self.close_sub_utilities_action() self.close_sub_utilities_action()
elif self.root.ids.screen_manager.current == "voice_settings_screen":
self.close_sub_voice_action()
else: else:
self.open_conversations(direction="right") self.open_conversations(direction="right")
@ -1674,7 +1502,6 @@ class SidebandApp(MDApp):
def announce_now_action(self, sender=None): def announce_now_action(self, sender=None):
self.sideband.lxmf_announce() self.sideband.lxmf_announce()
if self.sideband.telephone: self.sideband.telephone.announce()
yes_button = MDRectangleFlatButton(text="OK",font_size=dp(18)) yes_button = MDRectangleFlatButton(text="OK",font_size=dp(18))
@ -1767,17 +1594,13 @@ class SidebandApp(MDApp):
self.conversation_action(item) self.conversation_action(item)
def conversation_action(self, sender): def conversation_action(self, sender):
if sender.conv_type == self.sideband.CONV_P2P: context_dest = sender.sb_uid
context_dest = sender.sb_uid def cb(dt):
def cb(dt): self.open_conversation(context_dest) self.open_conversation(context_dest)
def cbu(dt): self.conversations_view.update() def cbu(dt):
Clock.schedule_once(cb, 0.15) self.conversations_view.update()
Clock.schedule_once(cbu, 0.15+0.25) Clock.schedule_once(cb, 0.15)
Clock.schedule_once(cbu, 0.15+0.25)
elif sender.conv_type == self.sideband.CONV_VOICE:
identity_hash = sender.sb_uid
def cb(dt): self.dial_action(identity_hash)
Clock.schedule_once(cb, 0.15)
def open_conversation(self, context_dest, direction="left"): def open_conversation(self, context_dest, direction="left"):
self.rec_dialog_is_open = False self.rec_dialog_is_open = False
@ -1839,12 +1662,14 @@ class SidebandApp(MDApp):
if self.outbound_mode_command: if self.outbound_mode_command:
return return
def cb(dt): self.message_send_dispatch(sender) def cb(dt):
self.message_send_dispatch(sender)
Clock.schedule_once(cb, 0.20) Clock.schedule_once(cb, 0.20)
def message_send_dispatch(self, sender=None): def message_send_dispatch(self, sender=None):
self.messages_view.ids.message_send_button.disabled = True self.messages_view.ids.message_send_button.disabled = True
def cb(dt): self.messages_view.ids.message_send_button.disabled = False def cb(dt):
self.messages_view.ids.message_send_button.disabled = False
Clock.schedule_once(cb, 0.5) Clock.schedule_once(cb, 0.5)
if self.root.ids.screen_manager.current == "messages_screen": if self.root.ids.screen_manager.current == "messages_screen":
@ -2740,27 +2565,21 @@ class SidebandApp(MDApp):
if RNS.vendor.platformutils.is_android(): if RNS.vendor.platformutils.is_android():
hs = dp(22) hs = dp(22)
yes_button = MDRectangleFlatButton(text="OK",font_size=dp(18)) yes_button = MDRectangleFlatButton(text="OK",font_size=dp(18))
full_button = MDRectangleFlatButton(text="Full RNS Status",font_size=dp(18), theme_text_color="Custom", line_color=self.color_accept, text_color=self.color_accept)
dialog = MDDialog( dialog = MDDialog(
title="Connectivity Status", title="Connectivity Status",
text=str(self.get_connectivity_text()), text=str(self.get_connectivity_text()),
buttons=[full_button, yes_button], buttons=[ yes_button ],
# elevation=0, # elevation=0,
) )
def cs_updater(dt): def cs_updater(dt):
dialog.text = str(self.get_connectivity_text()) dialog.text = str(self.get_connectivity_text())
def dl_yes(s): def dl_yes(s):
self.connectivity_updater.cancel()
dialog.dismiss() dialog.dismiss()
if self.connectivity_updater != None: if self.connectivity_updater != None:
self.connectivity_updater.cancel() self.connectivity_updater.cancel()
def cb_rns(sender):
dialog.dismiss()
if self.connectivity_updater != None:
self.connectivity_updater.cancel()
self.rnstatus_action()
yes_button.bind(on_release=dl_yes) yes_button.bind(on_release=dl_yes)
full_button.bind(on_release=cb_rns)
dialog.open() dialog.open()
if self.connectivity_updater != None: if self.connectivity_updater != None:
@ -2769,12 +2588,9 @@ class SidebandApp(MDApp):
self.connectivity_updater = Clock.schedule_interval(cs_updater, 2.0) self.connectivity_updater = Clock.schedule_interval(cs_updater, 2.0)
else: else:
self.rnstatus_action() if not self.utilities_ready:
self.utilities_init()
def rnstatus_action(self, sender=None): self.utilities_screen.rnstatus_action()
if not self.utilities_ready:
self.utilities_init()
self.utilities_screen.rnstatus_action()
def ingest_lxm_action(self, sender): def ingest_lxm_action(self, sender):
def cb(dt): def cb(dt):
@ -2931,8 +2747,7 @@ class SidebandApp(MDApp):
n_address = dialog.d_content.ids["n_address_field"].text n_address = dialog.d_content.ids["n_address_field"].text
n_name = dialog.d_content.ids["n_name_field"].text n_name = dialog.d_content.ids["n_name_field"].text
n_trusted = dialog.d_content.ids["n_trusted"].active n_trusted = dialog.d_content.ids["n_trusted"].active
n_voice_only = dialog.d_content.ids["n_voice_only"].active new_result = self.sideband.new_conversation(n_address, n_name, n_trusted)
new_result = self.sideband.new_conversation(n_address, n_name, n_trusted, n_voice_only)
except Exception as e: except Exception as e:
RNS.log("Error while creating conversation: "+str(e), RNS.LOG_ERROR) RNS.log("Error while creating conversation: "+str(e), RNS.LOG_ERROR)
@ -2994,7 +2809,7 @@ class SidebandApp(MDApp):
self.information_screen.ids.information_scrollview.effect_cls = ScrollEffect self.information_screen.ids.information_scrollview.effect_cls = ScrollEffect
self.information_screen.ids.information_logo.icon = self.sideband.asset_dir+"/rns_256.png" self.information_screen.ids.information_logo.icon = self.sideband.asset_dir+"/rns_256.png"
str_comps = " - [b]Reticulum[/b] (Reticulum License)\n - [b]LXMF[/b] (Reticulum License)\n - [b]KivyMD[/b] (MIT License)" str_comps = " - [b]Reticulum[/b] (MIT License)\n - [b]LXMF[/b] (MIT License)\n - [b]KivyMD[/b] (MIT License)"
str_comps += "\n - [b]Kivy[/b] (MIT License)\n - [b]Codec2[/b] (LGPL License)\n - [b]PyCodec2[/b] (BSD-3 License)" str_comps += "\n - [b]Kivy[/b] (MIT License)\n - [b]Codec2[/b] (LGPL License)\n - [b]PyCodec2[/b] (BSD-3 License)"
str_comps += "\n - [b]PyDub[/b] (MIT License)\n - [b]PyOgg[/b] (Public Domain)\n - [b]FFmpeg[/b] (GPL3 License)" str_comps += "\n - [b]PyDub[/b] (MIT License)\n - [b]PyOgg[/b] (Public Domain)\n - [b]FFmpeg[/b] (GPL3 License)"
str_comps += "\n - [b]GeoidHeight[/b] (LGPL License)\n - [b]Paho MQTT[/b] (EPL2 License)\n - [b]Python[/b] (PSF License)" str_comps += "\n - [b]GeoidHeight[/b] (LGPL License)\n - [b]Paho MQTT[/b] (EPL2 License)\n - [b]Python[/b] (PSF License)"
@ -3333,15 +3148,6 @@ class SidebandApp(MDApp):
self.sideband.config["hq_ptt"] = self.settings_screen.ids.settings_hq_ptt.active self.sideband.config["hq_ptt"] = self.settings_screen.ids.settings_hq_ptt.active
self.sideband.save_configuration() self.sideband.save_configuration()
def save_voice_enabled(sender=None, event=None):
self.sideband.config["voice_enabled"] = self.settings_screen.ids.settings_voice_enabled.active
self.sideband.save_configuration()
if self.sideband.config["voice_enabled"] == True:
self.sideband.start_voice()
else:
self.sideband.stop_voice()
def save_print_command(sender=None, event=None): def save_print_command(sender=None, event=None):
if not sender.focus: if not sender.focus:
in_cmd = self.settings_screen.ids.settings_print_command.text in_cmd = self.settings_screen.ids.settings_print_command.text
@ -3517,10 +3323,6 @@ class SidebandApp(MDApp):
self.settings_screen.ids.settings_hq_ptt.active = self.sideband.config["hq_ptt"] self.settings_screen.ids.settings_hq_ptt.active = self.sideband.config["hq_ptt"]
self.settings_screen.ids.settings_hq_ptt.bind(active=save_hq_ptt) self.settings_screen.ids.settings_hq_ptt.bind(active=save_hq_ptt)
self.settings_screen.ids.settings_voice_enabled.active = self.sideband.config["voice_enabled"]
self.settings_screen.ids.settings_voice_enabled.bind(active=save_voice_enabled)
if RNS.vendor.platformutils.is_android(): self.settings_screen.ids.settings_voice_enabled.disabled = True
self.settings_screen.ids.settings_debug.active = self.sideband.config["debug"] self.settings_screen.ids.settings_debug.active = self.sideband.config["debug"]
self.settings_screen.ids.settings_debug.bind(active=save_debug) self.settings_screen.ids.settings_debug.bind(active=save_debug)
@ -3634,7 +3436,6 @@ class SidebandApp(MDApp):
self.widget_hide(self.connectivity_screen.ids.connectivity_serial_label) self.widget_hide(self.connectivity_screen.ids.connectivity_serial_label)
self.widget_hide(self.connectivity_screen.ids.connectivity_use_serial) self.widget_hide(self.connectivity_screen.ids.connectivity_use_serial)
self.widget_hide(self.connectivity_screen.ids.connectivity_serial_fields) self.widget_hide(self.connectivity_screen.ids.connectivity_serial_fields)
self.widget_hide(self.connectivity_screen.ids.connectivity_share_instance)
self.widget_hide(self.connectivity_screen.ids.connectivity_shared_access) self.widget_hide(self.connectivity_screen.ids.connectivity_shared_access)
self.widget_hide(self.connectivity_screen.ids.connectivity_shared_access_label) self.widget_hide(self.connectivity_screen.ids.connectivity_shared_access_label)
self.widget_hide(self.connectivity_screen.ids.connectivity_shared_access_fields) self.widget_hide(self.connectivity_screen.ids.connectivity_shared_access_fields)
@ -3642,7 +3443,6 @@ class SidebandApp(MDApp):
self.widget_hide(self.connectivity_screen.ids.connectivity_enable_transport) self.widget_hide(self.connectivity_screen.ids.connectivity_enable_transport)
self.widget_hide(self.connectivity_screen.ids.connectivity_transport_info) self.widget_hide(self.connectivity_screen.ids.connectivity_transport_info)
self.widget_hide(self.connectivity_screen.ids.connectivity_transport_fields) self.widget_hide(self.connectivity_screen.ids.connectivity_transport_fields)
self.widget_hide(self.connectivity_screen.ids.connectivity_service_restart_fields)
def con_collapse_local(collapse=True): def con_collapse_local(collapse=True):
# self.widget_hide(self.connectivity_screen.ids.connectivity_local_fields, collapse) # self.widget_hide(self.connectivity_screen.ids.connectivity_local_fields, collapse)
@ -3678,7 +3478,6 @@ class SidebandApp(MDApp):
def save_connectivity(sender=None, event=None): def save_connectivity(sender=None, event=None):
self.sideband.config["connect_transport"] = self.connectivity_screen.ids.connectivity_enable_transport.active self.sideband.config["connect_transport"] = self.connectivity_screen.ids.connectivity_enable_transport.active
self.sideband.config["connect_share_instance"] = self.connectivity_screen.ids.connectivity_share_instance.active
self.sideband.config["connect_local"] = self.connectivity_screen.ids.connectivity_use_local.active self.sideband.config["connect_local"] = self.connectivity_screen.ids.connectivity_use_local.active
self.sideband.config["connect_local_groupid"] = self.connectivity_screen.ids.connectivity_local_groupid.text self.sideband.config["connect_local_groupid"] = self.connectivity_screen.ids.connectivity_local_groupid.text
self.sideband.config["connect_local_ifac_netname"] = self.connectivity_screen.ids.connectivity_local_ifac_netname.text self.sideband.config["connect_local_ifac_netname"] = self.connectivity_screen.ids.connectivity_local_ifac_netname.text
@ -3796,7 +3595,7 @@ class SidebandApp(MDApp):
else: else:
info = "By default, Sideband will try to discover and connect to any available Reticulum networks via active WiFi and/or Ethernet interfaces. If any Reticulum Transport Instances are found, Sideband will use these to connect to wider Reticulum networks. You can disable this behaviour if you don't want it.\n\n" info = "By default, Sideband will try to discover and connect to any available Reticulum networks via active WiFi and/or Ethernet interfaces. If any Reticulum Transport Instances are found, Sideband will use these to connect to wider Reticulum networks. You can disable this behaviour if you don't want it.\n\n"
info += "You can also connect to a network via a remote or local Reticulum instance using TCP or I2P. [b]Please Note![/b] Connecting via I2P requires that you already have I2P running on your device, and that the SAM API is enabled.\n\n" info += "You can also connect to a network via a remote or local Reticulum instance using TCP or I2P. [b]Please Note![/b] Connecting via I2P requires that you already have I2P running on your device, and that the SAM API is enabled.\n\n"
info += "For changes to connectivity to take effect, you must either restart the RNS service, or completely shut down and restart Sideband.\n" info += "For changes to connectivity to take effect, you must shut down and restart Sideband.\n"
self.connectivity_screen.ids.connectivity_info.text = info self.connectivity_screen.ids.connectivity_info.text = info
self.connectivity_screen.ids.connectivity_use_local.active = self.sideband.config["connect_local"] self.connectivity_screen.ids.connectivity_use_local.active = self.sideband.config["connect_local"]
@ -3836,10 +3635,6 @@ class SidebandApp(MDApp):
self.connectivity_screen.ids.connectivity_enable_transport.active = self.sideband.config["connect_transport"] self.connectivity_screen.ids.connectivity_enable_transport.active = self.sideband.config["connect_transport"]
con_collapse_transport(collapse=not self.sideband.config["connect_transport"]) con_collapse_transport(collapse=not self.sideband.config["connect_transport"])
self.connectivity_screen.ids.connectivity_enable_transport.bind(active=save_connectivity) self.connectivity_screen.ids.connectivity_enable_transport.bind(active=save_connectivity)
self.connectivity_screen.ids.connectivity_share_instance.active = self.sideband.config["connect_share_instance"]
self.connectivity_screen.ids.connectivity_share_instance.bind(active=save_connectivity)
self.connectivity_screen.ids.connectivity_local_ifmode.text = self.sideband.config["connect_ifmode_local"].capitalize() self.connectivity_screen.ids.connectivity_local_ifmode.text = self.sideband.config["connect_ifmode_local"].capitalize()
self.connectivity_screen.ids.connectivity_tcp_ifmode.text = self.sideband.config["connect_ifmode_tcp"].capitalize() self.connectivity_screen.ids.connectivity_tcp_ifmode.text = self.sideband.config["connect_ifmode_tcp"].capitalize()
self.connectivity_screen.ids.connectivity_i2p_ifmode.text = self.sideband.config["connect_ifmode_i2p"].capitalize() self.connectivity_screen.ids.connectivity_i2p_ifmode.text = self.sideband.config["connect_ifmode_i2p"].capitalize()
@ -3919,8 +3714,7 @@ class SidebandApp(MDApp):
dialog.dismiss() dialog.dismiss()
yes_button.bind(on_release=dl_yes) yes_button.bind(on_release=dl_yes)
rpc_string = "shared_instance_type = tcp\n" rpc_string = "rpc_key = "+RNS.hexrep(self.sideband.reticulum.rpc_key, delimit=False)
rpc_string += "rpc_key = "+RNS.hexrep(self.sideband.reticulum.rpc_key, delimit=False)
Clipboard.copy(rpc_string) Clipboard.copy(rpc_string)
dialog.open() dialog.open()
@ -4317,63 +4111,6 @@ class SidebandApp(MDApp):
self.sideband.save_configuration() self.sideband.save_configuration()
def hardware_rnode_scan_job(self):
time.sleep(1.25)
added_devices = []
scan_timeout = time.time()+16
while time.time() < scan_timeout:
RNS.log("Scanning...", RNS.LOG_DEBUG)
for device_addr in self.discovered_bt_devices:
if device_addr not in added_devices and not device_addr in self.bt_bonded_devices:
new_device = self.discovered_bt_devices[device_addr]
added_devices.append(device_addr)
RNS.log(f"Adding device: {new_device}")
def add_factory(add_device):
def add_job(dt):
pair_addr = add_device["address"]
btn_text = "Pair "+add_device["name"]
def run_pair(sender): self.hardware_rnode_pair_device_action(pair_addr)
# device_button = MDRectangleFlatButton(text=btn_text,font_size=dp(16))
device_button = MDRectangleFlatButton(text=btn_text, font_size=dp(16), padding=[dp(0), dp(14), dp(0), dp(14)], size_hint=[1.0, None])
device_button.bind(on_release=run_pair)
self.hardware_rnode_screen.ids.rnode_scan_results.add_widget(device_button)
return add_job
Clock.schedule_once(add_factory(new_device), 0.1)
time.sleep(2)
def job(dt):
self.hardware_rnode_screen.ids.hardware_rnode_bt_scan_button.disabled = False
self.hardware_rnode_screen.ids.hardware_rnode_bt_scan_button.text = "Pair New Device"
Clock.schedule_once(job, 0.2)
if len(added_devices) == 0:
def job(dt): toast("No unpaired RNodes discovered")
Clock.schedule_once(job, 0.2)
def hardware_rnode_pair_device_action(self, pair_addr):
RNS.log(f"Pair action for {pair_addr}", RNS.LOG_DEBUG)
self.stop_bluetooth_scan()
BluetoothSocket = autoclass('android.bluetooth.BluetoothSocket')
if self.bt_adapter == None: self.bt_adapter = BluetoothAdapter.getDefaultAdapter()
addr_bytes = bytes.fromhex(pair_addr.replace(":", ""))
remote_device = self.bt_adapter.getRemoteDevice(addr_bytes)
RNS.log(f"Remote device: {remote_device}", RNS.LOG_DEBUG)
remote_device.createBond()
RNS.log("Create bond call returned", RNS.LOG_DEBUG)
def hardware_rnode_bt_scan_action(self, sender=None):
self.discovered_bt_devices = {}
self.hardware_rnode_screen.ids.hardware_rnode_bt_scan_button.disabled = True
self.hardware_rnode_screen.ids.hardware_rnode_bt_scan_button.text = "Scanning..."
rw = []
for child in self.hardware_rnode_screen.ids.rnode_scan_results.children: rw.append(child)
for w in rw: self.hardware_rnode_screen.ids.rnode_scan_results.remove_widget(w)
Clock.schedule_once(self.bluetooth_scan_action, 0.5)
threading.Thread(target=self.hardware_rnode_scan_job, daemon=True).start()
def hardware_rnode_bt_on_action(self, sender=None): def hardware_rnode_bt_on_action(self, sender=None):
self.hardware_rnode_screen.ids.hardware_rnode_bt_pair_button.disabled = True self.hardware_rnode_screen.ids.hardware_rnode_bt_pair_button.disabled = True
self.hardware_rnode_screen.ids.hardware_rnode_bt_on_button.disabled = True self.hardware_rnode_screen.ids.hardware_rnode_bt_on_button.disabled = True
@ -5497,62 +5234,6 @@ class SidebandApp(MDApp):
self.utilities_action(direction="right") self.utilities_action(direction="right")
### voice Screen
######################################
def voice_init(self):
if not self.voice_ready:
self.voice_screen = Voice(self)
self.voice_ready = True
def voice_open(self, sender=None, direction="left", no_transition=False, dial_on_complete=None):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
self.root.ids.screen_manager.current = "voice_screen"
self.root.ids.nav_drawer.set_state("closed")
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
self.voice_screen.update_call_status()
if dial_on_complete:
self.voice_screen.dial_target = dial_on_complete
self.voice_screen.screen.ids.identity_hash.text = RNS.hexrep(dial_on_complete, delimit=False)
Clock.schedule_once(self.voice_screen.dial_action, 0.25)
def voice_action(self, sender=None, direction="left", dial_on_complete=None):
if self.voice_ready:
self.voice_open(direction=direction, dial_on_complete=dial_on_complete)
else:
self.loader_action(direction=direction)
def final(dt):
self.voice_init()
def o(dt):
self.voice_open(no_transition=True, dial_on_complete=dial_on_complete)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def close_sub_voice_action(self, sender=None):
self.voice_action(direction="right")
def dial_action(self, identity_hash):
self.voice_action(dial_on_complete=identity_hash)
def voice_answer_action(self, sender=None):
if self.sideband.voice_running:
if self.sideband.telephone.is_ringing: self.sideband.telephone.answer()
def voice_reject_action(self, sender=None):
if self.sideband.voice_running:
if self.sideband.telephone.is_ringing or self.sideband.telephone.is_in_call:
self.sideband.telephone.hangup()
toast("Call ended")
### Telemetry Screen ### Telemetry Screen
###################################### ######################################
@ -5665,7 +5346,7 @@ class SidebandApp(MDApp):
self.telemetry_info_dialog.dismiss() self.telemetry_info_dialog.dismiss()
ok_button.bind(on_release=dl_ok) ok_button.bind(on_release=dl_ok)
result = self.sideband.request_latest_telemetry(from_addr=self.sideband.config["telemetry_collector"], is_collector_request=True) result = self.sideband.request_latest_telemetry(from_addr=self.sideband.config["telemetry_collector"])
if result == "no_address": if result == "no_address":
title_str = "Invalid Address" title_str = "Invalid Address"
@ -5675,10 +5356,10 @@ class SidebandApp(MDApp):
info_str = "No keys known for the destination. Connected reticules have been queried for the keys. Try again when an announce for the destination has arrived." info_str = "No keys known for the destination. Connected reticules have been queried for the keys. Try again when an announce for the destination has arrived."
elif result == "in_progress": elif result == "in_progress":
title_str = "Transfer In Progress" title_str = "Transfer In Progress"
info_str = "There is already a telemetry request transfer in progress to the collector." info_str = "There is already a telemetry request transfer in progress for this peer."
elif result == "sent": elif result == "sent":
title_str = "Request Sent" title_str = "Request Sent"
info_str = "A telemetry request was sent to the collector. The collector should send any available telemetry shortly." info_str = "A telemetry request was sent to the peer. The peer should send any available telemetry shortly."
elif result == "not_sent": elif result == "not_sent":
title_str = "Not Sent" title_str = "Not Sent"
info_str = "A telemetry request could not be sent." info_str = "A telemetry request could not be sent."
@ -6357,7 +6038,7 @@ class SidebandApp(MDApp):
latest_viewable = None latest_viewable = None
if not skip: if not skip:
for telemetry_entry in sorted(telemetry_entries[telemetry_source], key=lambda t: t[0], reverse=True): for telemetry_entry in telemetry_entries[telemetry_source]:
telemetry_timestamp = telemetry_entry[0] telemetry_timestamp = telemetry_entry[0]
telemetry_data = telemetry_entry[1] telemetry_data = telemetry_entry[1]
t = Telemeter.from_packed(telemetry_data) t = Telemeter.from_packed(telemetry_data)
@ -6366,10 +6047,6 @@ class SidebandApp(MDApp):
if "location" in telemetry and telemetry["location"] != None and telemetry["location"]["latitude"] != None and telemetry["location"]["longitude"] != None: if "location" in telemetry and telemetry["location"] != None and telemetry["location"]["latitude"] != None and telemetry["location"]["longitude"] != None:
latest_viewable = telemetry latest_viewable = telemetry
break break
elif "connection_map" in telemetry:
# TODO: Telemetry entries with connection map sensor types are skipped for now,
# until a proper rendering mechanism is implemented
break
if latest_viewable != None: if latest_viewable != None:
l = latest_viewable["location"] l = latest_viewable["location"]
@ -6489,21 +6166,15 @@ If you use Reticulum and LXMF on hardware that does not carry any identifiers ti
- [b]Ctrl-Shift-F[/b] add file - [b]Ctrl-Shift-F[/b] add file
- [b]Ctrl-D[/b] or [b]Ctrl-S[/b] Send message - [b]Ctrl-D[/b] or [b]Ctrl-S[/b] Send message
[b]Voice & PTT Messages[/b] [b]Voice & PTT[/b]
- [b]Space[/b] Start/stop recording - [b]Space[/b] Start/stop recording
- [b]Enter[/b] Save recording to message - [b]Enter[/b] Save recording to message
- With PTT enabled, hold [b]Space[/b] to talk - With PTT enabled, hold [b]Space[/b] to talk
[b]Voice Calls[/b]
- [b]Ctrl-Space[/b] Answer incoming call
- [b]Ctrl-.[/b] Reject incoming call
- [b]Ctrl-.[/b] Hang up active call
[b]Navigation[/b] [b]Navigation[/b]
- [b]Ctrl-[i]n[/i][/b] Go to conversation number [i]n[/i] - [b]Ctrl-[i]n[/i][/b] Go to conversation number [i]n[/i]
- [b]Ctrl-R[/b] Go to Conversations - [b]Ctrl-R[/b] Go to Conversations
- [b]Ctrl-O[/b] Go to Objects & Devices - [b]Ctrl-O[/b] Go to Objects & Devices
- [b]Ctrl-E[/b] Go to Voice
- [b]Ctrl-L[/b] Go to Announce Stream - [b]Ctrl-L[/b] Go to Announce Stream
- [b]Ctrl-M[/b] Go to Situation Map - [b]Ctrl-M[/b] Go to Situation Map
- [b]Ctrl-U[/b] Go to Utilities - [b]Ctrl-U[/b] Go to Utilities
@ -6644,21 +6315,13 @@ def run():
config_path=args.config, config_path=args.config,
is_client=False, is_client=False,
verbose=(args.verbose or __debug_build__), verbose=(args.verbose or __debug_build__),
quiet=(args.interactive and not args.verbose), is_daemon=True
is_daemon=True,
rns_config_path=args.rnsconfig,
) )
sideband.version_str = "v"+__version__+" "+__variant__ sideband.version_str = "v"+__version__+" "+__variant__
sideband.start() sideband.start()
while True:
if args.interactive: time.sleep(5)
while not sideband.getstate("core.started") == True: time.sleep(0.1)
from .sideband import console
console.attach(sideband)
else:
while True: time.sleep(5)
else: else:
ExceptionManager.add_handler(SidebandExceptionHandler()) ExceptionManager.add_handler(SidebandExceptionHandler())
SidebandApp().run() SidebandApp().run()

View file

@ -28,10 +28,6 @@
<action android:name="android.intent.action.SEND" /> <action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" /> <data android:mimeType="image/*" />
<data android:mimeType="video/*" />
<data android:mimeType="audio/*" />
<data android:mimeType="text/*" />
<data android:mimeType="application/*" />
</intent-filter> </intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"

View file

@ -481,9 +481,6 @@ class SidebandService():
self.sideband.cleanup() self.sideband.cleanup()
self.release_locks() self.release_locks()
# TODO: Check if this works in all cases
self.android_service.stopSelf()
def handle_exception(exc_type, exc_value, exc_traceback): def handle_exception(exc_type, exc_value, exc_traceback):
if issubclass(exc_type, KeyboardInterrupt): if issubclass(exc_type, KeyboardInterrupt):
sys.__excepthook__(exc_type, exc_value, exc_traceback) sys.__excepthook__(exc_type, exc_value, exc_traceback)

View file

@ -1,103 +0,0 @@
import os
import RNS
import threading
from prompt_toolkit.application import Application
from prompt_toolkit.document import Document
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.layout.containers import HSplit, Window
from prompt_toolkit.layout.layout import Layout
from prompt_toolkit.styles import Style
from prompt_toolkit.widgets import SearchToolbar, TextArea
sideband = None
application = None
output_document = Document(text="", cursor_position=0)
output_field = None
def attach(target_core):
global sideband
sideband = target_core
RNS.logdest = RNS.LOG_CALLBACK
RNS.logcall = receive_output
console()
def parse(uin):
args = uin.split(" ")
cmd = args[0]
if cmd == "q" or cmd == "quit": quit_action()
elif cmd == "clear": cmd_clear(args)
elif cmd == "raw": cmd_raw(args, uin.replace("raw ", ""))
elif cmd == "log": cmd_log(args)
else: receive_output(f"Unknown command: {cmd}")
def cmd_clear(args):
output_document = output_document = Document(text="", cursor_position=0)
output_field.buffer.document = output_document
def cmd_raw(args, expr):
if expr != "" and expr != "raw":
try: receive_output(eval(expr))
except Exception as e: receive_output(str(e))
def cmd_log(args):
try:
if len(args) == 1: receive_output(f"Current loglevel is {RNS.loglevel}")
else: RNS.loglevel = int(args[1]); receive_output(f"Loglevel set to {RNS.loglevel}")
except Exception as e:
receive_output("Invalid loglevel: {e}")
def set_log(level=None):
if level: RNS.loglevel = level
if RNS.loglevel == 0: receive_output("Logging squelched. Use log command to print output to console.")
def quit_action():
receive_output("Shutting down Sideband...")
sideband.should_persist_data()
application.exit()
def receive_output(msg):
global output_document, output_field
content = f"{output_field.text}\n{msg}"
output_document = output_document = Document(text=content, cursor_position=len(content))
output_field.buffer.document = output_document
def console():
global output_document, output_field, application
search_field = SearchToolbar()
output_field = TextArea(style="class:output-field", text="Sideband console ready")
input_field = TextArea(
height=1,
prompt="> ",
style="class:input-field",
multiline=False,
wrap_lines=False,
search_field=search_field)
container = HSplit([
output_field,
Window(height=1, char="-", style="class:line"),
input_field,
search_field])
def accept(buff): parse(input_field.text)
input_field.accept_handler = accept
kb = KeyBindings()
@kb.add("c-c")
@kb.add("c-q")
def _(event): quit_action()
style = Style([
("line", "#004444"),
])
application = Application(
layout=Layout(container, focused_element=input_field),
key_bindings=kb,
style=style,
mouse_support=True,
full_screen=False)
set_log()
application.run()

View file

@ -8,7 +8,6 @@ import sqlite3
import random import random
import shlex import shlex
import re import re
import gc
import RNS.vendor.umsgpack as msgpack import RNS.vendor.umsgpack as msgpack
import RNS.Interfaces.Interface as Interface import RNS.Interfaces.Interface as Interface
@ -108,7 +107,6 @@ class SidebandCore():
CONV_P2P = 0x01 CONV_P2P = 0x01
CONV_GROUP = 0x02 CONV_GROUP = 0x02
CONV_BROADCAST = 0x03 CONV_BROADCAST = 0x03
CONV_VOICE = 0x04
MAX_ANNOUNCES = 24 MAX_ANNOUNCES = 24
@ -148,7 +146,7 @@ class SidebandCore():
self.log_announce(destination_hash, app_data, dest_type=SidebandCore.aspect_filter, stamp_cost=sc, link_stats=link_stats) self.log_announce(destination_hash, app_data, dest_type=SidebandCore.aspect_filter, stamp_cost=sc, link_stats=link_stats)
def __init__(self, owner_app, config_path = None, is_service=False, is_client=False, android_app_dir=None, verbose=False, quiet=False, owner_service=None, service_context=None, is_daemon=False, load_config_only=False, rns_config_path=None): def __init__(self, owner_app, config_path = None, is_service=False, is_client=False, android_app_dir=None, verbose=False, owner_service=None, service_context=None, is_daemon=False, load_config_only=False):
self.is_service = is_service self.is_service = is_service
self.is_client = is_client self.is_client = is_client
self.is_daemon = is_daemon self.is_daemon = is_daemon
@ -164,20 +162,16 @@ class SidebandCore():
else: else:
self.is_standalone = False self.is_standalone = False
self.log_verbose = (verbose and not quiet) self.log_verbose = verbose
self.log_quiet = quiet
self.log_deque = deque(maxlen=self.LOG_DEQUE_MAXLEN) self.log_deque = deque(maxlen=self.LOG_DEQUE_MAXLEN)
self.owner_app = owner_app self.owner_app = owner_app
self.reticulum = None self.reticulum = None
self.webshare_server = None self.webshare_server = None
self.voice_running = False
self.telephone = None
self.telemeter = None self.telemeter = None
self.telemetry_running = False self.telemetry_running = False
self.latest_telemetry = None self.latest_telemetry = None
self.latest_packed_telemetry = None self.latest_packed_telemetry = None
self.telemetry_changes = 0 self.telemetry_changes = 0
self.telemetry_response_excluded = []
self.pending_telemetry_send = False self.pending_telemetry_send = False
self.pending_telemetry_send_try = 0 self.pending_telemetry_send_try = 0
self.pending_telemetry_send_maxtries = 2 self.pending_telemetry_send_maxtries = 2
@ -210,7 +204,7 @@ class SidebandCore():
self.cache_dir = self.app_dir+"/cache" self.cache_dir = self.app_dir+"/cache"
self.rns_configdir = rns_config_path self.rns_configdir = None
core_path = os.path.abspath(__file__) core_path = os.path.abspath(__file__)
if "core.pyc" in core_path: if "core.pyc" in core_path:
@ -254,15 +248,13 @@ class SidebandCore():
if not os.path.isdir(self.app_dir+"/app_storage"): if not os.path.isdir(self.app_dir+"/app_storage"):
os.makedirs(self.app_dir+"/app_storage") os.makedirs(self.app_dir+"/app_storage")
self.config_path = self.app_dir+"/app_storage/sideband_config" self.config_path = self.app_dir+"/app_storage/sideband_config"
self.identity_path = self.app_dir+"/app_storage/primary_identity" self.identity_path = self.app_dir+"/app_storage/primary_identity"
self.db_path = self.app_dir+"/app_storage/sideband.db" self.db_path = self.app_dir+"/app_storage/sideband.db"
self.lxmf_storage = self.app_dir+"/app_storage/" self.lxmf_storage = self.app_dir+"/app_storage/"
self.log_dir = self.app_dir+"/app_storage/" self.log_dir = self.app_dir+"/app_storage/"
self.tmp_dir = self.app_dir+"/app_storage/tmp" self.tmp_dir = self.app_dir+"/app_storage/tmp"
self.exports_dir = self.app_dir+"/exports" self.exports_dir = self.app_dir+"/exports"
self.telemetry_exclude_path = self.app_dir+"/app_storage/collector_response_excluded"
if RNS.vendor.platformutils.is_android(): if RNS.vendor.platformutils.is_android():
self.webshare_dir = "./share/" self.webshare_dir = "./share/"
else: else:
@ -273,7 +265,6 @@ class SidebandCore():
self.webshare_ssl_cert_path = self.app_dir+"/app_storage/ssl_cert.pem" self.webshare_ssl_cert_path = self.app_dir+"/app_storage/ssl_cert.pem"
self.mqtt = None self.mqtt = None
self.mqtt_handle_lock = threading.Lock()
self.first_run = True self.first_run = True
self.saving_configuration = False self.saving_configuration = False
@ -540,12 +531,6 @@ class SidebandCore():
self.config["telemetry_send_to_trusted"] = False self.config["telemetry_send_to_trusted"] = False
self.config["telemetry_send_to_collector"] = False self.config["telemetry_send_to_collector"] = False
# Voice
self.config["voice_enabled"] = False
self.config["voice_output"] = None
self.config["voice_input"] = None
self.config["voice_ringer"] = None
if not os.path.isfile(self.db_path): if not os.path.isfile(self.db_path):
self.__db_init() self.__db_init()
else: else:
@ -575,36 +560,11 @@ class SidebandCore():
self.save_configuration() self.save_configuration()
def __load_telemetry_collector_excluded(self):
if not os.path.isfile(self.telemetry_exclude_path):
try:
file = open(self.telemetry_exclude_path, "wb")
file.write("# To exclude destinations from telemetry\n# collector responses, add them to this\n# file with one destination hash per line\n".encode("utf-8"))
file.close()
except Exception as e:
RNS.log(f"Could not create telemetry collector exclude file at {self.telemetry_exclude_path}", RNS.LOG_ERROR)
try:
with open(self.telemetry_exclude_path, "rb") as file:
data = file.read().decode("utf-8")
for line in data.splitlines():
if not line.startswith("#"):
if len(line) >= RNS.Reticulum.TRUNCATED_HASHLENGTH//8*2:
try:
destination_hash = bytes.fromhex(line[:RNS.Reticulum.TRUNCATED_HASHLENGTH//8*2])
self.telemetry_response_excluded.append(destination_hash)
except Exception as e:
RNS.log(f"Invalid destination hash {line} in telemetry response exclude file: {e}", RNS.LOG_ERROR)
except Exception as e:
RNS.log(f"Error while loading telemetry collector response excludes: {e}", RNS.LOG_ERROR)
def __load_config(self): def __load_config(self):
RNS.log("Loading Sideband identity...", RNS.LOG_DEBUG) RNS.log("Loading Sideband identity...", RNS.LOG_DEBUG)
self.identity = RNS.Identity.from_file(self.identity_path) 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()) self.rpc_key = RNS.Identity.full_hash(self.identity.get_private_key())
RNS.log("Loading Sideband configuration... "+str(self.config_path), RNS.LOG_DEBUG) RNS.log("Loading Sideband configuration... "+str(self.config_path), RNS.LOG_DEBUG)
@ -663,8 +623,6 @@ class SidebandCore():
self.config["config_template"] = None self.config["config_template"] = None
if not "connect_transport" in self.config: if not "connect_transport" in self.config:
self.config["connect_transport"] = False self.config["connect_transport"] = False
if not "connect_share_instance" in self.config:
self.config["connect_share_instance"] = False
if not "connect_rnode" in self.config: if not "connect_rnode" in self.config:
self.config["connect_rnode"] = False self.config["connect_rnode"] = False
if not "connect_rnode_ifac_netname" in self.config: if not "connect_rnode_ifac_netname" in self.config:
@ -879,17 +837,6 @@ class SidebandCore():
if not "map_storage_file" in self.config: if not "map_storage_file" in self.config:
self.config["map_storage_file"] = None self.config["map_storage_file"] = None
if not "voice_enabled" in self.config:
self.config["voice_enabled"] = False
if not "voice_output" in self.config:
self.config["voice_output"] = None
if not "voice_input" in self.config:
self.config["voice_input"] = None
if not "voice_ringer" in self.config:
self.config["voice_ringer"] = None
if not "voice_trusted_only" in self.config:
self.config["voice_trusted_only"] = False
# Make sure we have a database # Make sure we have a database
if not os.path.isfile(self.db_path): if not os.path.isfile(self.db_path):
self.__db_init() self.__db_init()
@ -900,8 +847,6 @@ class SidebandCore():
self._db_upgradetables() self._db_upgradetables()
self.__db_indices() self.__db_indices()
self.__load_telemetry_collector_excluded()
def __reload_config(self): def __reload_config(self):
RNS.log("Reloading Sideband configuration... ", RNS.LOG_DEBUG) RNS.log("Reloading Sideband configuration... ", RNS.LOG_DEBUG)
with open(self.config_path, "rb") as config_file: with open(self.config_path, "rb") as config_file:
@ -1048,16 +993,13 @@ class SidebandCore():
notifications_permitted = True notifications_permitted = True
if notifications_permitted: if notifications_permitted:
try: if RNS.vendor.platformutils.get_platform() == "android":
if RNS.vendor.platformutils.get_platform() == "android": if self.is_service:
if self.is_service: self.owner_service.android_notification(title, content, group=group, context_id=context_id)
self.owner_service.android_notification(title, content, group=group, context_id=context_id)
else:
plyer.notification.notify(title, content, notification_icon=self.notification_icon, context_override=None)
else: else:
plyer.notification.notify(title, content, app_icon=self.icon_32) plyer.notification.notify(title, content, notification_icon=self.notification_icon, context_override=None)
except Exception as e: else:
RNS.log("An error occurred while posting a notification to the operating system: {e}", RNS.LOG_ERROR) plyer.notification.notify(title, content, app_icon=self.icon_32)
def log_announce(self, dest, app_data, dest_type, stamp_cost=None, link_stats=None): def log_announce(self, dest, app_data, dest_type, stamp_cost=None, link_stats=None):
try: try:
@ -1112,20 +1054,6 @@ class SidebandCore():
RNS.log("Error while checking trust for "+RNS.prettyhexrep(context_dest)+": "+str(e), RNS.LOG_ERROR) RNS.log("Error while checking trust for "+RNS.prettyhexrep(context_dest)+": "+str(e), RNS.LOG_ERROR)
return False return False
def voice_is_trusted(self, identity_hash):
context_dest = identity_hash
try:
lxmf_destination_hash = RNS.Destination.hash_from_name_and_identity("lxmf.delivery", identity_hash)
existing_voice = self._db_conversation(context_dest)
existing_lxmf = self._db_conversation(lxmf_destination_hash)
if existing_lxmf: trust = existing_lxmf["trust"]
else: trust = existing_voice["trust"]
return trust == 1
except Exception as e:
RNS.log("Could not decode a valid peer name from data: "+str(e), RNS.LOG_DEBUG)
return False
def is_object(self, context_dest, conv_data = None): def is_object(self, context_dest, conv_data = None):
try: try:
if conv_data == None: if conv_data == None:
@ -1285,22 +1213,6 @@ class SidebandCore():
RNS.log("Could not decode a valid peer name from data: "+str(e), RNS.LOG_DEBUG) RNS.log("Could not decode a valid peer name from data: "+str(e), RNS.LOG_DEBUG)
return RNS.prettyhexrep(context_dest) return RNS.prettyhexrep(context_dest)
def voice_display_name(self, identity_hash):
context_dest = identity_hash
if context_dest == self.lxmf_destination.hash:
return self.config["display_name"]
try:
lxmf_destination_hash = RNS.Destination.hash_from_name_and_identity("lxmf.delivery", identity_hash)
existing_voice = self._db_conversation(context_dest)
existing_lxmf = self._db_conversation(lxmf_destination_hash)
if existing_lxmf: return self.peer_display_name(lxmf_destination_hash)
else: return self.peer_display_name(identity_hash)
except Exception as e:
RNS.log("Could not decode a valid peer name from data: "+str(e), RNS.LOG_DEBUG)
return RNS.prettyhexrep(context_dest)
def clear_conversation(self, context_dest): def clear_conversation(self, context_dest):
self._db_clear_conversation(context_dest) self._db_clear_conversation(context_dest)
@ -1403,13 +1315,13 @@ class SidebandCore():
else: else:
self.setstate(f"telemetry.{RNS.hexrep(message.destination_hash, delimit=False)}.request_sending", False) self.setstate(f"telemetry.{RNS.hexrep(message.destination_hash, delimit=False)}.request_sending", False)
def _service_request_latest_telemetry(self, from_addr=None, is_collector_request=False): def _service_request_latest_telemetry(self, from_addr=None):
if not RNS.vendor.platformutils.is_android(): if not RNS.vendor.platformutils.is_android():
return False return False
else: else:
if self.is_client: if self.is_client:
try: try:
return self.service_rpc_request({"request_latest_telemetry": {"from_addr": from_addr, "is_collector_request": is_collector_request}}) return self.service_rpc_request({"request_latest_telemetry": {"from_addr": from_addr}})
except Exception as e: except Exception as e:
RNS.log("Error while requesting latest telemetry over RPC: "+str(e), RNS.LOG_DEBUG) RNS.log("Error while requesting latest telemetry over RPC: "+str(e), RNS.LOG_DEBUG)
@ -1418,10 +1330,10 @@ class SidebandCore():
else: else:
return False return False
def request_latest_telemetry(self, from_addr=None, is_livetrack=False, is_collector_request=False): def request_latest_telemetry(self, from_addr=None, is_livetrack=False):
if self.allow_service_dispatch and self.is_client: if self.allow_service_dispatch and self.is_client:
try: try:
return self._service_request_latest_telemetry(from_addr, is_collector_request=is_collector_request) return self._service_request_latest_telemetry(from_addr)
except Exception as e: except Exception as e:
RNS.log("Error requesting latest telemetry: "+str(e), RNS.LOG_ERROR) RNS.log("Error requesting latest telemetry: "+str(e), RNS.LOG_ERROR)
@ -1460,7 +1372,7 @@ class SidebandCore():
request_timebase = self.getpersistent(f"telemetry.{RNS.hexrep(from_addr, delimit=False)}.timebase") or now - self.telemetry_request_max_history request_timebase = self.getpersistent(f"telemetry.{RNS.hexrep(from_addr, delimit=False)}.timebase") or now - self.telemetry_request_max_history
lxm_fields = { LXMF.FIELD_COMMANDS: [ lxm_fields = { LXMF.FIELD_COMMANDS: [
{Commands.TELEMETRY_REQUEST: [request_timebase, is_collector_request]}, {Commands.TELEMETRY_REQUEST: request_timebase},
]} ]}
lxm = LXMF.LXMessage(dest, source, "", desired_method=desired_method, fields = lxm_fields, include_ticket=True) lxm = LXMF.LXMessage(dest, source, "", desired_method=desired_method, fields = lxm_fields, include_ticket=True)
@ -1556,7 +1468,7 @@ class SidebandCore():
else: else:
return False return False
def send_latest_telemetry(self, to_addr=None, stream=None, is_authorized_telemetry_request=False, is_collector_response=False): def send_latest_telemetry(self, to_addr=None, stream=None, is_authorized_telemetry_request=False):
if self.allow_service_dispatch and self.is_client: if self.allow_service_dispatch and self.is_client:
try: try:
return self._service_send_latest_telemetry(to_addr, stream, is_authorized_telemetry_request) return self._service_send_latest_telemetry(to_addr, stream, is_authorized_telemetry_request)
@ -1598,7 +1510,7 @@ class SidebandCore():
else: else:
desired_method = LXMF.LXMessage.DIRECT desired_method = LXMF.LXMessage.DIRECT
lxm_fields = self.get_message_fields(to_addr, is_authorized_telemetry_request=is_authorized_telemetry_request, signal_already_sent=True, is_collector_response=is_collector_response) lxm_fields = self.get_message_fields(to_addr, is_authorized_telemetry_request=is_authorized_telemetry_request, signal_already_sent=True)
if lxm_fields == False and stream == None: if lxm_fields == False and stream == None:
return "already_sent" return "already_sent"
@ -1823,7 +1735,7 @@ class SidebandCore():
try: try:
with self.rpc_lock: with self.rpc_lock:
if self.rpc_connection == None: 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) self.rpc_connection.send(request)
response = self.rpc_connection.recv() response = self.rpc_connection.recv()
return response return response
@ -1896,12 +1808,12 @@ class SidebandCore():
mr = self.message_router mr = self.message_router
oh = destination_hash oh = destination_hash
ol = None ol = None
if oh in mr.direct_links and mr.direct_links[oh].status == RNS.Link.ACTIVE: if oh in mr.direct_links:
ol = mr.direct_links[oh] ol = mr.direct_links[oh]
elif oh in mr.backchannel_links: elif oh in mr.backchannel_links:
ol = mr.backchannel_links[oh] ol = mr.backchannel_links[oh]
if ol != None and ol.status == RNS.Link.ACTIVE: if ol != None:
ler = ol.get_establishment_rate() ler = ol.get_establishment_rate()
if ler: if ler:
return ler return ler
@ -1926,113 +1838,15 @@ class SidebandCore():
RNS.log(ed, RNS.LOG_DEBUG) RNS.log(ed, RNS.LOG_DEBUG)
return None return None
def _get_destination_mtu(self, destination_hash):
try:
mr = self.message_router
oh = destination_hash
ol = None
if oh in mr.direct_links and mr.direct_links[oh].status == RNS.Link.ACTIVE:
ol = mr.direct_links[oh]
elif oh in mr.backchannel_links:
ol = mr.backchannel_links[oh]
if ol != None and ol.status == RNS.Link.ACTIVE:
return ol.get_mtu()
return None
except Exception as e:
RNS.trace_exception(e)
return None
def get_destination_mtu(self, destination_hash):
if not RNS.vendor.platformutils.is_android():
return self._get_destination_mtu(destination_hash)
else:
if self.is_service:
return self._get_destination_mtu(destination_hash)
else:
try:
return self.service_rpc_request({"get_destination_mtu": destination_hash})
except Exception as e:
ed = "Error while getting destination link MTU over RPC: "+str(e)
RNS.log(ed, RNS.LOG_DEBUG)
return None
def _get_destination_edr(self, destination_hash):
try:
mr = self.message_router
oh = destination_hash
ol = None
if oh in mr.direct_links and mr.direct_links[oh].status == RNS.Link.ACTIVE:
ol = mr.direct_links[oh]
elif oh in mr.backchannel_links:
ol = mr.backchannel_links[oh]
if ol != None and ol.status == RNS.Link.ACTIVE:
return ol.get_expected_rate()
return None
except Exception as e:
RNS.trace_exception(e)
return None
def get_destination_edr(self, destination_hash):
if not RNS.vendor.platformutils.is_android():
return self._get_destination_edr(destination_hash)
else:
if self.is_service:
return self._get_destination_edr(destination_hash)
else:
try:
return self.service_rpc_request({"get_destination_edr": destination_hash})
except Exception as e:
ed = "Error while getting destination link EIFR over RPC: "+str(e)
RNS.log(ed, RNS.LOG_DEBUG)
return None
def _get_destination_lmd(self, destination_hash):
try:
mr = self.message_router
oh = destination_hash
ol = None
if oh in mr.direct_links and mr.direct_links[oh].status == RNS.Link.ACTIVE:
ol = mr.direct_links[oh]
elif oh in mr.backchannel_links:
ol = mr.backchannel_links[oh]
if ol != None and ol.status == RNS.Link.ACTIVE: return ol.get_mode()
return None
except Exception as e:
RNS.trace_exception(e)
return None
def get_destination_lmd(self, destination_hash):
if not RNS.vendor.platformutils.is_android():
return self._get_destination_lmd(destination_hash)
else:
if self.is_service:
return self._get_destination_lmd(destination_hash)
else:
try:
return self.service_rpc_request({"get_destination_lmd": destination_hash})
except Exception as e:
ed = "Error while getting destination link mode over RPC: "+str(e)
RNS.log(ed, RNS.LOG_DEBUG)
return None
def __start_rpc_listener(self): def __start_rpc_listener(self):
try: try:
RNS.log("Starting RPC listener", RNS.LOG_DEBUG) 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 = threading.Thread(target=self.__rpc_loop)
thread.daemon = True thread.daemon = True
thread.start() thread.start()
except Exception as e: 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() RNS.panic()
def __rpc_loop(self): def __rpc_loop(self):
@ -2068,12 +1882,6 @@ class SidebandCore():
connection.send(self._get_plugins_info()) connection.send(self._get_plugins_info())
elif "get_destination_establishment_rate" in call: elif "get_destination_establishment_rate" in call:
connection.send(self._get_destination_establishment_rate(call["get_destination_establishment_rate"])) connection.send(self._get_destination_establishment_rate(call["get_destination_establishment_rate"]))
elif "get_destination_mtu" in call:
connection.send(self._get_destination_mtu(call["get_destination_mtu"]))
elif "get_destination_edr" in call:
connection.send(self._get_destination_edr(call["get_destination_edr"]))
elif "get_destination_lmd" in call:
connection.send(self._get_destination_lmd(call["get_destination_lmd"]))
elif "send_message" in call: elif "send_message" in call:
args = call["send_message"] args = call["send_message"]
send_result = self.send_message( send_result = self.send_message(
@ -2099,7 +1907,7 @@ class SidebandCore():
connection.send(send_result) connection.send(send_result)
elif "request_latest_telemetry" in call: elif "request_latest_telemetry" in call:
args = call["request_latest_telemetry"] args = call["request_latest_telemetry"]
send_result = self.request_latest_telemetry(args["from_addr"], is_collector_request=args["is_collector_request"]) send_result = self.request_latest_telemetry(args["from_addr"])
connection.send(send_result) connection.send(send_result)
elif "send_latest_telemetry" in call: elif "send_latest_telemetry" in call:
args = call["send_latest_telemetry"] args = call["send_latest_telemetry"]
@ -2210,7 +2018,6 @@ class SidebandCore():
dbc = db.cursor() 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 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() db.commit()
def _db_upgradetables(self): def _db_upgradetables(self):
@ -2752,7 +2559,6 @@ class SidebandCore():
"last_rx": last_rx, "last_rx": last_rx,
"last_tx": last_tx, "last_tx": last_tx,
"last_activity": last_activity, "last_activity": last_activity,
"type": entry[4],
"trust": entry[5], "trust": entry[5],
"data": data, "data": data,
} }
@ -2904,27 +2710,6 @@ class SidebandCore():
self.__event_conversations_changed() self.__event_conversations_changed()
def _db_create_voice_object(self, identity_hash, name = None, trust = False):
RNS.log("Creating voice object for "+RNS.prettyhexrep(identity_hash), RNS.LOG_DEBUG)
with self.db_lock:
db = self.__db_connect()
dbc = db.cursor()
def_name = "".encode("utf-8")
query = "INSERT INTO conv (dest_context, last_tx, last_rx, unread, type, trust, name, data) values (?, ?, ?, ?, ?, ?, ?, ?)"
data = (identity_hash, 0, time.time(), 0, SidebandCore.CONV_VOICE, 0, def_name, msgpack.packb(None))
dbc.execute(query, data)
db.commit()
if trust:
self._db_conversation_set_trusted(identity_hash, True)
if name != None and name != "":
self._db_conversation_set_name(identity_hash, name)
self.__event_conversations_changed()
def _db_delete_message(self, msg_hash): def _db_delete_message(self, msg_hash):
RNS.log("Deleting message "+RNS.prettyhexrep(msg_hash)) RNS.log("Deleting message "+RNS.prettyhexrep(msg_hash))
with self.db_lock: with self.db_lock:
@ -3180,7 +2965,6 @@ class SidebandCore():
tpacked = telemetry_entry[2] tpacked = telemetry_entry[2]
appearance = telemetry_entry[3] appearance = telemetry_entry[3]
max_timebase = max(max_timebase, ttstamp) max_timebase = max(max_timebase, ttstamp)
if self._db_save_telemetry(tsource, tpacked, via = context_dest): if self._db_save_telemetry(tsource, tpacked, via = context_dest):
RNS.log("Saved telemetry stream entry from "+RNS.prettyhexrep(tsource), RNS.LOG_DEBUG) RNS.log("Saved telemetry stream entry from "+RNS.prettyhexrep(tsource), RNS.LOG_DEBUG)
if appearance != None: if appearance != None:
@ -3340,37 +3124,12 @@ class SidebandCore():
self.setstate("app.flags.last_telemetry", time.time()) self.setstate("app.flags.last_telemetry", time.time())
def mqtt_handle_telemetry(self, context_dest, telemetry): def mqtt_handle_telemetry(self, context_dest, telemetry):
with self.mqtt_handle_lock: if self.mqtt == None:
# TODO: Remove debug self.mqtt = MQTT()
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.set_server(self.config["telemetry_mqtt_host"], self.config["telemetry_mqtt_port"])
self.mqtt = MQTT() self.mqtt.set_auth(self.config["telemetry_mqtt_user"], self.config["telemetry_mqtt_pass"])
self.last_mqtt_recycle = time.time() self.mqtt.handle(context_dest, telemetry)
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)}")
def update_telemetry(self): def update_telemetry(self):
try: try:
@ -3455,7 +3214,7 @@ class SidebandCore():
else: else:
self.telemeter.disable(sensor) self.telemeter.disable(sensor)
for telemetry_plugin in self.active_telemetry_plugins.copy(): for telemetry_plugin in self.active_telemetry_plugins:
try: try:
plugin = self.active_telemetry_plugins[telemetry_plugin] plugin = self.active_telemetry_plugins[telemetry_plugin]
plugin.update_telemetry(self.telemeter) plugin.update_telemetry(self.telemeter)
@ -3575,7 +3334,6 @@ class SidebandCore():
if self.config["start_announce"] == True: if self.config["start_announce"] == True:
time.sleep(12) time.sleep(12)
self.lxmf_announce(attached_interface=self.interface_local) self.lxmf_announce(attached_interface=self.interface_local)
if self.telephone: self.telephone.announce(attached_interface=self.interface_local)
threading.Thread(target=job, daemon=True).start() threading.Thread(target=job, daemon=True).start()
if hasattr(self, "interface_rnode") and self.interface_rnode != None: if hasattr(self, "interface_rnode") and self.interface_rnode != None:
@ -3663,7 +3421,6 @@ class SidebandCore():
aif = announce_attached_interface aif = announce_attached_interface
time.sleep(delay) time.sleep(delay)
self.lxmf_announce(attached_interface=aif) self.lxmf_announce(attached_interface=aif)
if self.telephone: self.telephone.announce(attached_interface=aif)
return x return x
threading.Thread(target=gen_announce_job(announce_delay, announce_attached_interface), daemon=True).start() threading.Thread(target=gen_announce_job(announce_delay, announce_attached_interface), daemon=True).start()
@ -3839,7 +3596,7 @@ class SidebandCore():
if now > last_request_timebase+request_interval: if now > last_request_timebase+request_interval:
try: try:
RNS.log("Initiating telemetry request to collector", RNS.LOG_DEBUG) RNS.log("Initiating telemetry request to collector", RNS.LOG_DEBUG)
self.request_latest_telemetry(from_addr=self.config["telemetry_collector"], is_collector_request=True) self.request_latest_telemetry(from_addr=self.config["telemetry_collector"])
except Exception as e: except Exception as e:
RNS.log("An error occurred while requesting a telemetry update from collector. The contained exception was: "+str(e), RNS.LOG_ERROR) RNS.log("An error occurred while requesting a telemetry update from collector. The contained exception was: "+str(e), RNS.LOG_ERROR)
@ -3878,7 +3635,6 @@ class SidebandCore():
def da(): def da():
time.sleep(8) time.sleep(8)
self.lxmf_announce() self.lxmf_announce()
if self.telephone: self.telephone.announce()
self.last_if_change_announce = time.time() self.last_if_change_announce = time.time()
threading.Thread(target=da, daemon=True).start() threading.Thread(target=da, daemon=True).start()
@ -3886,8 +3642,8 @@ class SidebandCore():
self.periodic_thread.start() self.periodic_thread.start()
if self.is_standalone or self.is_client: if self.is_standalone or self.is_client:
if self.config["telemetry_enabled"]: self.run_telemetry() if self.config["telemetry_enabled"]:
if self.config["voice_enabled"]: self.start_voice() self.run_telemetry()
elif self.is_service: elif self.is_service:
self.run_service_telemetry() self.run_service_telemetry()
@ -4091,9 +3847,10 @@ class SidebandCore():
def _reticulum_log_debug(self, debug=False): def _reticulum_log_debug(self, debug=False):
self.log_verbose = debug self.log_verbose = debug
if self.log_quiet: selected_level = 0 if self.log_verbose:
elif self.log_verbose: selected_level = 6 selected_level = 6
else: selected_level = 2 else:
selected_level = 2
RNS.loglevel = selected_level RNS.loglevel = selected_level
if self.is_client: if self.is_client:
@ -4108,9 +3865,7 @@ class SidebandCore():
return "\n".join(self.log_deque) return "\n".join(self.log_deque)
def __start_jobs_immediate(self): def __start_jobs_immediate(self):
if self.log_quiet: if self.log_verbose:
selected_level = 0
elif self.log_verbose:
selected_level = 6 selected_level = 6
else: else:
selected_level = 2 selected_level = 2
@ -4118,11 +3873,7 @@ class SidebandCore():
self.setstate("init.loadingstate", "Substantiating Reticulum") self.setstate("init.loadingstate", "Substantiating Reticulum")
try: try:
if RNS.vendor.platformutils.is_android() and self.config["connect_share_instance"] == True: self.reticulum = RNS.Reticulum(configdir=self.rns_configdir, loglevel=selected_level, logdest=self._log_handler)
self.reticulum = RNS.Reticulum(configdir=self.rns_configdir, loglevel=selected_level, logdest=self._log_handler, shared_instance_type="tcp")
else:
self.reticulum = RNS.Reticulum(configdir=self.rns_configdir, loglevel=selected_level, logdest=self._log_handler)
if RNS.vendor.platformutils.is_android(): if RNS.vendor.platformutils.is_android():
if self.is_service: if self.is_service:
if os.path.isfile(self.rns_configdir+"/config_template_invalid"): if os.path.isfile(self.rns_configdir+"/config_template_invalid"):
@ -4188,13 +3939,13 @@ class SidebandCore():
ifac_size = None ifac_size = None
interface_config = { interface_config = {
"name": "TCP Client", "name": "TCPClientInterface",
"target_host": tcp_host, "target_host": tcp_host,
"target_port": tcp_port, "target_port": tcp_port,
"kiss_framing": False, "kiss_framing": False,
"i2p_tunneled": 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 tcpinterface.OUT = True
if RNS.Reticulum.transport_enabled(): if RNS.Reticulum.transport_enabled():
@ -4467,7 +4218,7 @@ class SidebandCore():
except Exception as e: except Exception as e:
RNS.log("Error while setting last successul telemetry timebase for "+RNS.prettyhexrep(message.destination_hash), RNS.LOG_DEBUG) RNS.log("Error while setting last successul telemetry timebase for "+RNS.prettyhexrep(message.destination_hash), RNS.LOG_DEBUG)
def get_message_fields(self, context_dest, telemetry_update=False, is_authorized_telemetry_request=False, signal_already_sent=False, is_collector_response=False): def get_message_fields(self, context_dest, telemetry_update=False, is_authorized_telemetry_request=False, signal_already_sent=False):
fields = {} fields = {}
send_telemetry = (telemetry_update == True) or (self.should_send_telemetry(context_dest) or is_authorized_telemetry_request) send_telemetry = (telemetry_update == True) or (self.should_send_telemetry(context_dest) or is_authorized_telemetry_request)
send_appearance = self.config["telemetry_send_appearance"] or send_telemetry send_appearance = self.config["telemetry_send_appearance"] or send_telemetry
@ -4476,10 +4227,7 @@ class SidebandCore():
telemeter = Telemeter.from_packed(self.latest_packed_telemetry) telemeter = Telemeter.from_packed(self.latest_packed_telemetry)
telemetry_timebase = telemeter.read_all()["time"]["utc"] telemetry_timebase = telemeter.read_all()["time"]["utc"]
last_success_tb = (self.getpersistent(f"telemetry.{RNS.hexrep(context_dest, delimit=False)}.last_send_success_timebase") or 0) last_success_tb = (self.getpersistent(f"telemetry.{RNS.hexrep(context_dest, delimit=False)}.last_send_success_timebase") or 0)
if is_collector_response and self.lxmf_destination.hash in self.telemetry_response_excluded: if telemetry_timebase > last_success_tb:
RNS.log("Not embedding own telemetry collector response since own destination hash is excluded", RNS.LOG_DEBUG)
send_telemetry = False
elif telemetry_timebase > last_success_tb:
RNS.log("Embedding own telemetry in message since current telemetry is newer than latest successful timebase", RNS.LOG_DEBUG) RNS.log("Embedding own telemetry in message since current telemetry is newer than latest successful timebase", RNS.LOG_DEBUG)
else: else:
RNS.log("Not embedding own telemetry in message since current telemetry timebase ("+str(telemetry_timebase)+") is not newer than latest successful timebase ("+str(last_success_tb)+")", RNS.LOG_DEBUG) RNS.log("Not embedding own telemetry in message since current telemetry timebase ("+str(telemetry_timebase)+") is not newer than latest successful timebase ("+str(last_success_tb)+")", RNS.LOG_DEBUG)
@ -4802,7 +4550,7 @@ class SidebandCore():
RNS.log("Error while sending message: "+str(e), RNS.LOG_ERROR) RNS.log("Error while sending message: "+str(e), RNS.LOG_ERROR)
return False return False
def new_conversation(self, dest_str, name = "", trusted = False, voice_only = False): def new_conversation(self, dest_str, name = "", trusted = False):
if len(dest_str) != RNS.Reticulum.TRUNCATED_HASHLENGTH//8*2: if len(dest_str) != RNS.Reticulum.TRUNCATED_HASHLENGTH//8*2:
return False return False
@ -4812,8 +4560,7 @@ class SidebandCore():
RNS.log("Cannot create conversation with own LXMF address", RNS.LOG_ERROR) RNS.log("Cannot create conversation with own LXMF address", RNS.LOG_ERROR)
return False return False
else: else:
if not voice_only: self._db_create_conversation(addr_b, name, trusted) self._db_create_conversation(addr_b, name, trusted)
else: self._db_create_voice_object(addr_b, name, trusted)
except Exception as e: except Exception as e:
RNS.log("Error while creating conversation: "+str(e), RNS.LOG_ERROR) RNS.log("Error while creating conversation: "+str(e), RNS.LOG_ERROR)
@ -5242,19 +4989,11 @@ class SidebandCore():
RNS.log("Handling commands from "+RNS.prettyhexrep(context_dest), RNS.LOG_DEBUG) RNS.log("Handling commands from "+RNS.prettyhexrep(context_dest), RNS.LOG_DEBUG)
for command in commands: for command in commands:
if Commands.TELEMETRY_REQUEST in command: if Commands.TELEMETRY_REQUEST in command:
if type(command[Commands.TELEMETRY_REQUEST]) == list: timebase = int(command[Commands.TELEMETRY_REQUEST])
command_timebase = command[Commands.TELEMETRY_REQUEST][0]
enable_collector_request = command[Commands.TELEMETRY_REQUEST][1]
else:
# Handle old request format
command_timebase = command[Commands.TELEMETRY_REQUEST]
enable_collector_request = True
timebase = int(command_timebase)
RNS.log("Handling telemetry request with timebase "+str(timebase), RNS.LOG_DEBUG) RNS.log("Handling telemetry request with timebase "+str(timebase), RNS.LOG_DEBUG)
if self.config["telemetry_collector_enabled"] and enable_collector_request: if self.config["telemetry_collector_enabled"]:
RNS.log(f"Collector requests enabled, returning complete telemetry response for all known objects since {timebase}", RNS.LOG_DEBUG) RNS.log(f"Collector requests enabled, returning complete telemetry response for all known objects since {timebase}", RNS.LOG_DEBUG)
self.create_telemetry_collector_response(to_addr=context_dest, timebase=timebase, is_authorized_telemetry_request=True, is_collector_response=True) self.create_telemetry_collector_response(to_addr=context_dest, timebase=timebase, is_authorized_telemetry_request=True)
else: else:
RNS.log("Responding with own latest telemetry", RNS.LOG_DEBUG) RNS.log("Responding with own latest telemetry", RNS.LOG_DEBUG)
self.send_latest_telemetry(to_addr=context_dest) self.send_latest_telemetry(to_addr=context_dest)
@ -5290,7 +5029,7 @@ class SidebandCore():
except Exception as e: except Exception as e:
RNS.log("Error while handling commands: "+str(e), RNS.LOG_ERROR) RNS.log("Error while handling commands: "+str(e), RNS.LOG_ERROR)
def create_telemetry_collector_response(self, to_addr, timebase, is_authorized_telemetry_request=False, is_collector_response=False): def create_telemetry_collector_response(self, to_addr, timebase, is_authorized_telemetry_request=False):
if self.getstate(f"telemetry.{RNS.hexrep(to_addr, delimit=False)}.update_sending") == True: if self.getstate(f"telemetry.{RNS.hexrep(to_addr, delimit=False)}.update_sending") == True:
RNS.log("Not sending new telemetry collector response, since an earlier transfer is already in progress", RNS.LOG_DEBUG) RNS.log("Not sending new telemetry collector response, since an earlier transfer is already in progress", RNS.LOG_DEBUG)
return "in_progress" return "in_progress"
@ -5302,23 +5041,20 @@ class SidebandCore():
elements = 0; added = 0 elements = 0; added = 0
telemetry_stream = [] telemetry_stream = []
for source in sources: for source in sources:
if source in self.telemetry_response_excluded: if source != to_addr:
RNS.log(f"Excluding {RNS.prettyhexrep(source)} from collector response", RNS.LOG_DEBUG) for entry in sources[source]:
else: elements += 1
if source != to_addr: timestamp = entry[0]; packed_telemetry = entry[1]
for entry in sources[source]: appearance = self._db_get_appearance(source, raw=True)
elements += 1 te = [source, timestamp, packed_telemetry, appearance]
timestamp = entry[0]; packed_telemetry = entry[1] if only_latest:
appearance = self._db_get_appearance(source, raw=True) if not source in added_sources:
te = [source, timestamp, packed_telemetry, appearance] added_sources[source] = True
if only_latest:
if not source in added_sources:
added_sources[source] = True
telemetry_stream.append(te)
added += 1
else:
telemetry_stream.append(te) telemetry_stream.append(te)
added += 1 added += 1
else:
telemetry_stream.append(te)
added += 1
if len(telemetry_stream) == 0: if len(telemetry_stream) == 0:
RNS.log(f"No new telemetry for request with timebase {timebase}", RNS.LOG_DEBUG) RNS.log(f"No new telemetry for request with timebase {timebase}", RNS.LOG_DEBUG)
@ -5326,8 +5062,7 @@ class SidebandCore():
return self.send_latest_telemetry( return self.send_latest_telemetry(
to_addr=to_addr, to_addr=to_addr,
stream=telemetry_stream, stream=telemetry_stream,
is_authorized_telemetry_request=is_authorized_telemetry_request, is_authorized_telemetry_request=is_authorized_telemetry_request
is_collector_response=is_collector_response,
) )
@ -5375,40 +5110,6 @@ class SidebandCore():
if not self.reticulum.is_connected_to_shared_instance: if not self.reticulum.is_connected_to_shared_instance:
RNS.Transport.detach_interfaces() RNS.Transport.detach_interfaces()
def start_voice(self):
try:
if not self.voice_running:
RNS.log("Starting voice service", RNS.LOG_DEBUG)
self.voice_running = True
from .voice import ReticulumTelephone
self.telephone = ReticulumTelephone(self.identity, owner=self, speaker=self.config["voice_output"], microphone=self.config["voice_input"], ringer=self.config["voice_ringer"])
ringtone_path = os.path.join(self.asset_dir, "audio", "notifications", "soft1.opus")
self.telephone.set_ringtone(ringtone_path)
except Exception as e:
self.voice_running = False
RNS.log(f"An error occurred while starting voice services, the contained exception was: {e}", RNS.LOG_ERROR)
RNS.trace_exception(e)
def stop_voice(self):
try:
if self.voice_running:
RNS.log("Stopping voice service", RNS.LOG_DEBUG)
if self.telephone:
self.telephone.stop()
del self.telephone
self.telephone = None
self.voice_running = False
except Exception as e:
RNS.log(f"An error occurred while stopping voice services, the contained exception was: {e}", RNS.LOG_ERROR)
RNS.trace_exception(e)
def incoming_call(self, remote_identity):
display_name = self.voice_display_name(remote_identity.hash)
self.setstate("voice.incoming_call", display_name)
rns_config = """# This template is used to generate a rns_config = """# This template is used to generate a
# running configuration for Sideband's # running configuration for Sideband's
# internal RNS instance. Incorrect changes # internal RNS instance. Incorrect changes

View file

@ -44,14 +44,11 @@ class MQTT():
RNS.log("All MQTT messages processed", RNS.LOG_DEBUG) RNS.log("All MQTT messages processed", RNS.LOG_DEBUG)
except Exception as e: 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) RNS.trace_exception(e)
time.sleep(MQTT.SCHEDULER_SLEEP) 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) RNS.log("Stopped MQTT scheduler", RNS.LOG_DEBUG)
def connect_failed(self, client, userdata): def connect_failed(self, client, userdata):

View file

@ -120,11 +120,9 @@ class Telemeter():
def stop_all(self): def stop_all(self):
if not self.from_packed: if not self.from_packed:
sensors = self.sensors.copy() for sensor in self.sensors:
for sensor in sensors:
if not sensor == "time": if not sensor == "time":
self.sensors[sensor].stop() self.sensors[sensor].stop()
del sensors
def read(self, sensor): def read(self, sensor):
if not self.from_packed: if not self.from_packed:
@ -139,38 +137,31 @@ class Telemeter():
def read_all(self): def read_all(self):
readings = {} readings = {}
sensors = self.sensors.copy() for sensor in self.sensors:
for sensor in sensors:
if self.sensors[sensor].active: if self.sensors[sensor].active:
if not self.from_packed: if not self.from_packed:
readings[sensor] = self.sensors[sensor].data readings[sensor] = self.sensors[sensor].data
else: else:
readings[sensor] = self.sensors[sensor]._data readings[sensor] = self.sensors[sensor]._data
del sensors
return readings return readings
def packed(self): def packed(self):
packed = {} packed = {}
packed[Sensor.SID_TIME] = int(time.time()) packed[Sensor.SID_TIME] = int(time.time())
sensors = self.sensors.copy() for sensor in self.sensors:
for sensor in sensors:
if self.sensors[sensor].active: if self.sensors[sensor].active:
packed[self.sensors[sensor].sid] = self.sensors[sensor].pack() packed[self.sensors[sensor].sid] = self.sensors[sensor].pack()
del sensors
return umsgpack.packb(packed) return umsgpack.packb(packed)
def render(self, relative_to=None): def render(self, relative_to=None):
rendered = [] rendered = []
sensors = self.sensors.copy() for sensor in self.sensors:
for sensor in sensors:
s = self.sensors[sensor] s = self.sensors[sensor]
if s.active: if s.active:
r = s.render(relative_to) r = s.render(relative_to)
if r: rendered.append(r) if r: rendered.append(r)
del sensors
return rendered return rendered
def check_permission(self, permission): def check_permission(self, permission):

View file

@ -1,171 +0,0 @@
import RNS
import os
import sys
import time
from LXST._version import __version__
from LXST.Primitives.Telephony import Telephone
from RNS.vendor.configobj import ConfigObj
class ReticulumTelephone():
STATE_AVAILABLE = 0x00
STATE_CONNECTING = 0x01
STATE_RINGING = 0x02
STATE_IN_CALL = 0x03
HW_SLEEP_TIMEOUT = 15
HW_STATE_IDLE = 0x00
HW_STATE_DIAL = 0x01
HW_STATE_SLEEP = 0xFF
RING_TIME = 30
WAIT_TIME = 60
PATH_TIME = 10
def __init__(self, identity, owner = None, service = False, speaker=None, microphone=None, ringer=None):
self.identity = identity
self.service = service
self.owner = owner
self.config = None
self.should_run = False
self.telephone = None
self.state = self.STATE_AVAILABLE
self.hw_state = self.HW_STATE_IDLE
self.hw_last_event = time.time()
self.hw_input = ""
self.direction = None
self.last_input = None
self.first_run = False
self.ringtone_path = None
self.speaker_device = speaker
self.microphone_device = microphone
self.ringer_device = ringer
self.phonebook = {}
self.aliases = {}
self.names = {}
self.telephone = Telephone(self.identity, ring_time=self.RING_TIME, wait_time=self.WAIT_TIME)
self.telephone.set_ringing_callback(self.ringing)
self.telephone.set_established_callback(self.call_established)
self.telephone.set_ended_callback(self.call_ended)
self.telephone.set_speaker(self.speaker_device)
self.telephone.set_microphone(self.microphone_device)
self.telephone.set_ringer(self.ringer_device)
self.telephone.set_allowed(self.__is_allowed)
RNS.log(f"{self} initialised", RNS.LOG_DEBUG)
def set_ringtone(self, ringtone_path):
if os.path.isfile(ringtone_path):
self.ringtone_path = ringtone_path
self.telephone.set_ringtone(self.ringtone_path)
def set_speaker(self, device):
self.speaker_device = device
self.telephone.set_speaker(self.speaker_device)
def set_microphone(self, device):
self.microphone_device = device
self.telephone.set_microphone(self.microphone_device)
def set_ringer(self, device):
self.ringer_device = device
self.telephone.set_ringer(self.ringer_device)
def announce(self, attached_interface=None):
self.telephone.announce(attached_interface=attached_interface)
@property
def is_available(self):
return self.state == self.STATE_AVAILABLE
@property
def is_in_call(self):
return self.state == self.STATE_IN_CALL
@property
def is_ringing(self):
return self.state == self.STATE_RINGING
@property
def call_is_connecting(self):
return self.state == self.STATE_CONNECTING
@property
def hw_is_idle(self):
return self.hw_state == self.HW_STATE_IDLE
@property
def hw_is_dialing(self):
return self.hw_state == self.HW_STATE_DIAL
def start(self):
if not self.should_run:
self.should_run = True
self.run()
def stop(self):
self.should_run = False
self.telephone.teardown()
self.telephone = None
def hangup(self): self.telephone.hangup()
def answer(self): self.telephone.answer(self.caller)
def set_busy(self, busy): self.telephone.set_busy(busy)
def dial(self, identity_hash):
self.last_dialled_identity_hash = identity_hash
destination_hash = RNS.Destination.hash_from_name_and_identity("lxst.telephony", identity_hash)
if RNS.Transport.has_path(destination_hash):
call_hops = RNS.Transport.hops_to(destination_hash)
cs = "" if call_hops == 1 else "s"
RNS.log(f"Connecting call over {call_hops} hop{cs}...", RNS.LOG_DEBUG)
identity = RNS.Identity.recall(destination_hash)
self.call(identity)
else:
return "no_path"
def redial(self, args=None):
if self.last_dialled_identity_hash: self.dial(self.last_dialled_identity_hash)
def call(self, remote_identity):
RNS.log(f"Calling {RNS.prettyhexrep(remote_identity.hash)}...", RNS.LOG_DEBUG)
self.state = self.STATE_CONNECTING
self.caller = remote_identity
self.direction = "to"
self.telephone.call(self.caller)
def ringing(self, remote_identity):
if self.hw_state == self.HW_STATE_SLEEP: self.hw_state = self.HW_STATE_IDLE
self.state = self.STATE_RINGING
self.caller = remote_identity
self.direction = "from" if self.direction == None else "to"
RNS.log(f"Incoming call from {RNS.prettyhexrep(self.caller.hash)}", RNS.LOG_DEBUG)
if self.owner:
self.owner.incoming_call(remote_identity)
def call_ended(self, remote_identity):
if self.is_in_call or self.is_ringing or self.call_is_connecting:
if self.is_in_call: RNS.log(f"Call with {RNS.prettyhexrep(self.caller.hash)} ended\n", RNS.LOG_DEBUG)
if self.is_ringing: RNS.log(f"Call {self.direction} {RNS.prettyhexrep(self.caller.hash)} was not answered\n", RNS.LOG_DEBUG)
if self.call_is_connecting: RNS.log(f"Call to {RNS.prettyhexrep(self.caller.hash)} could not be connected\n", RNS.LOG_DEBUG)
self.direction = None
self.state = self.STATE_AVAILABLE
def call_established(self, remote_identity):
if self.call_is_connecting or self.is_ringing:
self.state = self.STATE_IN_CALL
RNS.log(f"Call established with {RNS.prettyhexrep(self.caller.hash)}", RNS.LOG_DEBUG)
def __is_allowed(self, identity_hash):
if self.owner.config["voice_trusted_only"]:
return self.owner.voice_is_trusted(identity_hash)
else: return True
def __spin(self, until=None, msg=None, timeout=None):
if msg: RNS.log(msg, RNS.LOG_DEBUG)
if timeout != None: timeout = time.time()+timeout
while (timeout == None or time.time()<timeout) and not until(): time.sleep(0.1)
if timeout != None and time.time() > timeout:
return False
else:
return True

View file

@ -6,7 +6,6 @@ from kivy.uix.boxlayout import BoxLayout
from kivy.properties import StringProperty, BooleanProperty from kivy.properties import StringProperty, BooleanProperty
from kivymd.uix.list import MDList, IconLeftWidget, IconRightWidget, OneLineAvatarIconListItem from kivymd.uix.list import MDList, IconLeftWidget, IconRightWidget, OneLineAvatarIconListItem
from kivymd.uix.menu import MDDropdownMenu from kivymd.uix.menu import MDDropdownMenu
from kivymd.toast import toast
from kivy.uix.gridlayout import GridLayout from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout from kivy.uix.boxlayout import BoxLayout
from kivy.clock import Clock from kivy.clock import Clock
@ -54,7 +53,6 @@ class Conversations():
self.app.root.ids.screen_manager.add_widget(self.screen) self.app.root.ids.screen_manager.add_widget(self.screen)
self.conversation_dropdown = None self.conversation_dropdown = None
self.voice_dropdown = None
self.delete_dialog = None self.delete_dialog = None
self.clear_dialog = None self.clear_dialog = None
self.clear_telemetry_dialog = None self.clear_telemetry_dialog = None
@ -93,7 +91,6 @@ class Conversations():
self.app.sideband.setstate("wants.viewupdate.conversations", False) self.app.sideband.setstate("wants.viewupdate.conversations", False)
def trust_icon(self, conv): def trust_icon(self, conv):
conv_type = conv["type"]
context_dest = conv["dest"] context_dest = conv["dest"]
unread = conv["unread"] unread = conv["unread"]
appearance = self.app.sideband.peer_appearance(context_dest, conv=conv) appearance = self.app.sideband.peer_appearance(context_dest, conv=conv)
@ -109,28 +106,25 @@ class Conversations():
trust_icon = appearance[0] or da[0]; trust_icon = appearance[0] or da[0];
else: else:
if conv_type == self.app.sideband.CONV_VOICE: if self.app.sideband.requests_allowed_from(context_dest):
trust_icon = "phone" if unread:
else:
if self.app.sideband.requests_allowed_from(context_dest):
if unread:
if is_trusted:
trust_icon = "email-seal"
else:
trust_icon = "email"
else:
trust_icon = "account-lock-open"
else:
if is_trusted: if is_trusted:
if unread: trust_icon = "email-seal"
trust_icon = "email-seal"
else:
trust_icon = "account-check"
else: else:
if unread: trust_icon = "email"
trust_icon = "email" else:
else: trust_icon = "account-lock-open"
trust_icon = "account-question" else:
if is_trusted:
if unread:
trust_icon = "email-seal"
else:
trust_icon = "account-check"
else:
if unread:
trust_icon = "email"
else:
trust_icon = "account-question"
return trust_icon return trust_icon
@ -172,7 +166,6 @@ class Conversations():
iconl._default_icon_pad = dp(ic_p) iconl._default_icon_pad = dp(ic_p)
iconl.icon_size = dp(ic_s) iconl.icon_size = dp(ic_s)
iconl.conv_type = conv["type"]
return iconl return iconl
@ -194,7 +187,6 @@ class Conversations():
for conv in self.context_dests: for conv in self.context_dests:
context_dest = conv["dest"] context_dest = conv["dest"]
conv_type = conv["type"]
unread = conv["unread"] unread = conv["unread"]
last_activity = conv["last_activity"] last_activity = conv["last_activity"]
@ -211,7 +203,6 @@ class Conversations():
item.sb_uid = context_dest item.sb_uid = context_dest
item.sb_unread = unread item.sb_unread = unread
iconl.sb_uid = context_dest iconl.sb_uid = context_dest
item.conv_type = conv_type
def gen_edit(item): def gen_edit(item):
def x(): def x():
@ -292,7 +283,7 @@ class Conversations():
yes_button.bind(on_release=dl_yes) yes_button.bind(on_release=dl_yes)
no_button.bind(on_release=dl_no) no_button.bind(on_release=dl_no)
self.voice_dropdown.dismiss(); self.conversation_dropdown.dismiss() item.dmenu.dismiss()
dialog.open() dialog.open()
RNS.log("Generated edit dialog in "+str(RNS.prettytime(time.time()-t_s)), RNS.LOG_DEBUG) RNS.log("Generated edit dialog in "+str(RNS.prettytime(time.time()-t_s)), RNS.LOG_DEBUG)
@ -321,7 +312,7 @@ class Conversations():
yes_button.bind(on_release=dl_yes) yes_button.bind(on_release=dl_yes)
no_button.bind(on_release=dl_no) no_button.bind(on_release=dl_no)
self.voice_dropdown.dismiss(); self.conversation_dropdown.dismiss() item.dmenu.dismiss()
self.clear_dialog.open() self.clear_dialog.open()
return x return x
@ -345,7 +336,7 @@ class Conversations():
yes_button.bind(on_release=dl_yes) yes_button.bind(on_release=dl_yes)
no_button.bind(on_release=dl_no) no_button.bind(on_release=dl_no)
self.voice_dropdown.dismiss(); self.conversation_dropdown.dismiss() item.dmenu.dismiss()
self.clear_telemetry_dialog.open() self.clear_telemetry_dialog.open()
return x return x
@ -371,61 +362,27 @@ class Conversations():
yes_button.bind(on_release=dl_yes) yes_button.bind(on_release=dl_yes)
no_button.bind(on_release=dl_no) no_button.bind(on_release=dl_no)
self.voice_dropdown.dismiss(); self.conversation_dropdown.dismiss() item.dmenu.dismiss()
self.delete_dialog.open() self.delete_dialog.open()
return x return x
# def gen_move_to(item):
# def x():
# item.dmenu.dismiss()
# self.app.sideband.conversation_set_object(self.conversation_dropdown.context_dest, not self.app.sideband.is_object(self.conversation_dropdown.context_dest))
# self.app.conversations_view.update()
# return x
def gen_copy_addr(item): def gen_copy_addr(item):
def x(): def x():
Clipboard.copy(RNS.hexrep(self.conversation_dropdown.context_dest, delimit=False)) Clipboard.copy(RNS.hexrep(self.conversation_dropdown.context_dest, delimit=False))
self.voice_dropdown.dismiss(); self.conversation_dropdown.dismiss() item.dmenu.dismiss()
return x
def gen_call(item):
def x():
identity = RNS.Identity.recall(self.conversation_dropdown.context_dest)
if identity: self.app.dial_action(identity.hash)
else: toast("Can't call, identity unknown")
self.voice_dropdown.dismiss(); self.conversation_dropdown.dismiss()
return x return x
item.iconr = IconRightWidget(icon="dots-vertical"); item.iconr = IconRightWidget(icon="dots-vertical");
if self.voice_dropdown == None:
dmi_h = 40
dmv_items = [
{
"viewclass": "OneLineListItem",
"text": "Edit",
"height": dp(dmi_h),
"on_release": gen_edit(item)
},
{
"text": "Copy Identity Hash",
"viewclass": "OneLineListItem",
"height": dp(dmi_h),
"on_release": gen_copy_addr(item)
},
{
"text": "Delete",
"viewclass": "OneLineListItem",
"height": dp(dmi_h),
"on_release": gen_del(item)
}
]
self.voice_dropdown = MDDropdownMenu(
caller=item.iconr,
items=dmv_items,
position="auto",
width=dp(256),
elevation=0,
radius=dp(3),
)
self.voice_dropdown.effect_cls = ScrollEffect
self.voice_dropdown.md_bg_color = self.app.color_hover
if self.conversation_dropdown == None: if self.conversation_dropdown == None:
obj_str = "conversations" if is_object else "objects"
dmi_h = 40 dmi_h = 40
dm_items = [ dm_items = [
{ {
@ -434,18 +391,18 @@ class Conversations():
"height": dp(dmi_h), "height": dp(dmi_h),
"on_release": gen_edit(item) "on_release": gen_edit(item)
}, },
{
"viewclass": "OneLineListItem",
"text": "Call",
"height": dp(dmi_h),
"on_release": gen_call(item)
},
{ {
"text": "Copy Address", "text": "Copy Address",
"viewclass": "OneLineListItem", "viewclass": "OneLineListItem",
"height": dp(dmi_h), "height": dp(dmi_h),
"on_release": gen_copy_addr(item) "on_release": gen_copy_addr(item)
}, },
# {
# "text": "Move to objects",
# "viewclass": "OneLineListItem",
# "height": dp(dmi_h),
# "on_release": gen_move_to(item)
# },
{ {
"text": "Clear Messages", "text": "Clear Messages",
"viewclass": "OneLineListItem", "viewclass": "OneLineListItem",
@ -477,15 +434,11 @@ class Conversations():
self.conversation_dropdown.effect_cls = ScrollEffect self.conversation_dropdown.effect_cls = ScrollEffect
self.conversation_dropdown.md_bg_color = self.app.color_hover self.conversation_dropdown.md_bg_color = self.app.color_hover
if conv_type == self.app.sideband.CONV_VOICE: item.dmenu = self.conversation_dropdown
item.dmenu = self.voice_dropdown
else:
item.dmenu = self.conversation_dropdown
def callback_factory(ref, dest): def callback_factory(ref, dest):
def x(sender): def x(sender):
self.conversation_dropdown.context_dest = dest self.conversation_dropdown.context_dest = dest
self.voice_dropdown.context_dest = dest
ref.dmenu.caller = ref.iconr ref.dmenu.caller = ref.iconr
ref.dmenu.open() ref.dmenu.open()
return x return x
@ -495,7 +448,6 @@ class Conversations():
item.add_widget(item.iconr) item.add_widget(item.iconr)
item.trusted = self.app.sideband.is_trusted(context_dest, conv_data=existing_conv) item.trusted = self.app.sideband.is_trusted(context_dest, conv_data=existing_conv)
item.conv_type = conv_type
self.added_item_dests.append(context_dest) self.added_item_dests.append(context_dest)
self.list.add_widget(item) self.list.add_widget(item)
@ -567,7 +519,7 @@ Builder.load_string("""
orientation: "vertical" orientation: "vertical"
spacing: "24dp" spacing: "24dp"
size_hint_y: None size_hint_y: None
height: dp(260) height: dp(250)
MDTextField: MDTextField:
id: n_address_field id: n_address_field
@ -588,7 +540,7 @@ Builder.load_string("""
orientation: "horizontal" orientation: "horizontal"
size_hint_y: None size_hint_y: None
padding: [0,0,dp(8),dp(24)] padding: [0,0,dp(8),dp(24)]
height: dp(24) height: dp(48)
MDLabel: MDLabel:
id: "trusted_switch_label" id: "trusted_switch_label"
text: "Trusted" text: "Trusted"
@ -599,21 +551,6 @@ Builder.load_string("""
pos_hint: {"center_y": 0.3} pos_hint: {"center_y": 0.3}
active: False active: False
MDBoxLayout:
orientation: "horizontal"
size_hint_y: None
padding: [0,0,dp(8),dp(24)]
height: dp(24)
MDLabel:
id: "trusted_switch_label"
text: "Voice Only"
font_style: "H6"
MDSwitch:
id: n_voice_only
pos_hint: {"center_y": 0.3}
active: False
<ConvSettings> <ConvSettings>
orientation: "vertical" orientation: "vertical"
spacing: "16dp" spacing: "16dp"

View file

@ -98,16 +98,6 @@ MDNavigationLayout:
on_release: root.ids.screen_manager.app.announces_action(self) on_release: root.ids.screen_manager.app.announces_action(self)
OneLineIconListItem:
text: "Voice"
on_release: root.ids.screen_manager.app.voice_action(self)
# _no_ripple_effect: True
IconLeftWidget:
icon: "phone-in-talk"
on_release: root.ids.screen_manager.app.voice_action(self)
# OneLineIconListItem: # OneLineIconListItem:
# text: "Local Broadcasts" # text: "Local Broadcasts"
# on_release: root.ids.screen_manager.app.broadcasts_action(self) # on_release: root.ids.screen_manager.app.broadcasts_action(self)
@ -360,23 +350,6 @@ MDScreen:
text_size: self.width, None text_size: self.width, None
height: self.texture_size[1] height: self.texture_size[1]
MDBoxLayout:
id: connectivity_service_restart_fields
orientation: "vertical"
size_hint_y: None
height: self.minimum_height
padding: [0, 0, 0, dp(32)]
MDRectangleFlatIconButton:
id: button_service_restart
icon: "restart"
text: "Restart RNS Service"
padding: [dp(0), dp(14), dp(0), dp(14)]
icon_size: dp(24)
font_size: dp(16)
size_hint: [1.0, None]
on_release: root.app.restart_service_action(self)
MDBoxLayout: MDBoxLayout:
orientation: "horizontal" orientation: "horizontal"
padding: [0,0,dp(24),0] padding: [0,0,dp(24),0]
@ -658,33 +631,15 @@ MDScreen:
# font_size: dp(24) # font_size: dp(24)
# # disabled: True # # disabled: True
# MDLabel: MDLabel:
# text: "Shared Instance Access\\n" text: "Shared Instance Access\\n"
# id: connectivity_shared_access_label id: connectivity_shared_access_label
# font_style: "H5" font_style: "H5"
MDBoxLayout:
orientation: "horizontal"
padding: [0,0,dp(24),0]
size_hint_y: None
height: dp(24)
MDLabel:
id: connectivity_shared_access_label
text: "Share Reticulum Instance"
font_style: "H6"
# disabled: True
MDSwitch:
id: connectivity_share_instance
active: False
pos_hint: {"center_y": 0.3}
# disabled: True
MDLabel: MDLabel:
id: connectivity_shared_access id: connectivity_shared_access
markup: True markup: True
text: "You can make the Reticulum instance launched by Sideband available for other programs on this system. By default, this grants connectivity to other local Reticulum-based programs, but no access to management, interface status and path information.\\n\\nIf you want to allow full functionality and ability to manage the running instance, you will need to configure other programs to use the correct RPC key for this instance.\\n\\nThis can be very useful for using other tools related to Reticulum, for example via command-line programs running in Termux. To do this, use the button below to copy the RPC key configuration line, and paste it into the Reticulum configuration file within the Termux environment, or other program.\\n\\nPlease note! [b]It is not necessary[/b] to enable Reticulum Transport for this to work!\\n\\n" text: "The Reticulum instance launched by Sideband will be available for other programs on this system. By default, this grants connectivity to other local Reticulum-based programs, but no access to management, interface status and path information.\\n\\nIf you want to allow full functionality and ability to manage the running instance, you will need to configure other programs to use the correct RPC key for this instance.\\n\\nThis can be very useful for using other tools related to Reticulum, for example via command-line programs running in Termux. To do this, use the button below to copy the RPC key configuration line, and paste it into the Reticulum configuration file within the Termux environment, or other program.\\n\\nPlease note! [b]It is not necessary[/b] to enable Reticulum Transport for this to work!\\n\\n"
size_hint_y: None size_hint_y: None
text_size: self.width, None text_size: self.width, None
height: self.texture_size[1] height: self.texture_size[1]
@ -1835,7 +1790,7 @@ MDScreen:
height: dp(48) height: dp(48)
MDLabel: MDLabel:
text: "High-quality codec for LXMF PTT" text: "Use high-quality voice for PTT"
font_style: "H6" font_style: "H6"
MDSwitch: MDSwitch:
@ -1844,22 +1799,6 @@ MDScreen:
disabled: False disabled: False
active: False active: False
MDBoxLayout:
orientation: "horizontal"
size_hint_y: None
padding: [0,0,dp(24),dp(0)]
height: dp(48)
MDLabel:
text: "Enable voice calls"
font_style: "H6"
MDSwitch:
id: settings_voice_enabled
pos_hint: {"center_y": 0.3}
disabled: False
active: False
# MDBoxLayout: # MDBoxLayout:
# orientation: "horizontal" # orientation: "horizontal"
# size_hint_y: None # size_hint_y: None
@ -2400,7 +2339,7 @@ MDScreen:
spacing: "24dp" spacing: "24dp"
size_hint_y: None size_hint_y: None
height: self.minimum_height height: self.minimum_height
padding: [dp(0), dp(0), dp(0), dp(48)] padding: [dp(0), dp(0), dp(0), dp(35)]
MDRectangleFlatIconButton: MDRectangleFlatIconButton:
id: rnode_mote_export id: rnode_mote_export
@ -2423,7 +2362,7 @@ MDScreen:
on_release: root.app.hardware_rnode_import(self) on_release: root.app.hardware_rnode_import(self)
MDLabel: MDLabel:
text: "Radio Options\\n" text: "Radio Options"
font_style: "H6" font_style: "H6"
# MDTextField: # MDTextField:
@ -2522,8 +2461,8 @@ MDScreen:
MDBoxLayout: MDBoxLayout:
orientation: "horizontal" orientation: "horizontal"
size_hint_y: None size_hint_y: None
padding: [0,dp(14),dp(24),dp(48)] padding: [0,0,dp(24),dp(0)]
height: dp(86) height: dp(48)
MDLabel: MDLabel:
text: "Control RNode Display" text: "Control RNode Display"
@ -2534,18 +2473,6 @@ MDScreen:
pos_hint: {"center_y": 0.3} pos_hint: {"center_y": 0.3}
active: False active: False
MDLabel:
text: "Bluetooth Settings\\n"
font_style: "H6"
MDLabel:
id: hardware_rnode_info
markup: True
text: "If you enable connection via Bluetooth, Sideband will attempt to connect to any available and paired RNodes over Bluetooth. If your RNode uses BLE (ESP32-S3 and nRF devices) instead of classic Bluetooth, enable the [i]Device requires BLE[/i] option as well."
size_hint_y: None
text_size: self.width, None
height: self.texture_size[1]
MDBoxLayout: MDBoxLayout:
orientation: "horizontal" orientation: "horizontal"
size_hint_y: None size_hint_y: None
@ -2579,65 +2506,7 @@ MDScreen:
MDLabel: MDLabel:
id: hardware_rnode_info id: hardware_rnode_info
markup: True markup: True
text: "You must first pair the RNode with your device for this to work. To put an RNode into pairing mode, hold down the multi-function user button for more than 5 seconds, and release it. The display will indicate pairing mode.You can then pair the device using the Bluetooth settings of your device, or by pressing the pairing button below. The in-app scanning and pairing is supported on Android 12+. If it doesn't work, use the Bluetooth settings of your device to scan and pair.\\n" text: "If you enable connection via Bluetooth, Sideband will attempt to connect to any available and paired RNodes over Bluetooth.\\n\\nYou must first pair the RNode with your device for this to work. If your RNode does not have a physical pairing button, you can enable Bluetooth and put it into pairing mode by first connecting it via a USB cable, and using the buttons below. When plugging in the RNode over USB, you must grant Sideband permission to the USB device for this to work.\\n\\nYou can also change Bluetooth settings using the \\"rnodeconf\\" utility from a computer.\\n\\nBy default, Sideband will connect to the first available RNode that is paired. If you want to always use a specific RNode, you can enter its name in the Preferred RNode Device Name field below, for example \\"RNode A8EB\\".\\n"
size_hint_y: None
text_size: self.width, None
height: self.texture_size[1]
MDBoxLayout:
orientation: "vertical"
spacing: "24dp"
size_hint_y: None
height: self.minimum_height
padding: [dp(0), dp(0), dp(0), dp(12)]
MDRectangleFlatIconButton:
id: hardware_rnode_bt_scan_button
icon: "bluetooth-connect"
text: "Pair New Device"
padding: [dp(0), dp(14), dp(0), dp(14)]
icon_size: dp(24)
font_size: dp(16)
size_hint: [1.0, None]
on_release: root.app.hardware_rnode_bt_scan_action(self)
MDBoxLayout:
id: rnode_scan_results
orientation: "vertical"
spacing: "24dp"
size_hint_y: None
height: self.minimum_height
padding: [dp(0), dp(0), dp(0), dp(12)]
MDLabel:
id: hardware_rnode_info
markup: True
text: "By default, Sideband will connect to the first available RNode that is paired. If you want to always use a specific RNode, you can enter its name in the Preferred RNode Device Name field below, for example \\"RNode A8EB\\"."
size_hint_y: None
text_size: self.width, None
height: self.texture_size[1]
MDBoxLayout:
orientation: "vertical"
spacing: "24dp"
size_hint_y: None
height: self.minimum_height
# padding: [dp(0), dp(0), dp(0), dp(35)]
MDTextField:
id: hardware_rnode_bt_device
hint_text: "Preferred RNode Device Name"
text: ""
font_size: dp(24)
MDLabel:
text: "\\n\\nDevice Bluetooth Control\\n"
font_style: "H6"
MDLabel:
id: hardware_rnode_info
markup: True
text: "\\n\\nIf your RNode does not have a physical pairing button, you can enable Bluetooth and put it into pairing mode by first connecting it via a USB cable, and using the buttons below. When plugging in the RNode over USB, you must grant Sideband permission to the USB device for this to work.\\n\\nYou can also change Bluetooth settings using the \\"rnodeconf\\" utility from a computer.\\n"
size_hint_y: None size_hint_y: None
text_size: self.width, None text_size: self.width, None
height: self.texture_size[1] height: self.texture_size[1]
@ -2680,6 +2549,12 @@ MDScreen:
size_hint: [1.0, None] size_hint: [1.0, None]
on_release: root.app.hardware_rnode_bt_pair_action(self) on_release: root.app.hardware_rnode_bt_pair_action(self)
disabled: False disabled: False
MDTextField:
id: hardware_rnode_bt_device
hint_text: "Preferred RNode Device Name"
text: ""
font_size: dp(24)
""" """
layout_hardware_serial_screen = """ layout_hardware_serial_screen = """

View file

@ -319,19 +319,6 @@ class Messages():
prgstr = "" prgstr = ""
sphrase = "Sending" sphrase = "Sending"
prg = self.app.sideband.get_lxm_progress(msg["hash"]) prg = self.app.sideband.get_lxm_progress(msg["hash"])
if not hasattr(w, "last_prg_update"):
w.last_prg_update = time.time()
w.last_prg = prg
speed = None
else:
now = time.time()
size = msg["lxm"].packed_size
td = now - w.last_prg_update
if td == 0 or prg == None or w.last_prg == None: speed = None
else:
bd = prg*size - w.last_prg*size
speed = (bd/td)*8
if prg != None: if prg != None:
prgstr = ", "+str(round(prg*100, 1))+"% done" prgstr = ", "+str(round(prg*100, 1))+"% done"
if prg <= 0.00: if prg <= 0.00:
@ -349,7 +336,6 @@ class Messages():
sphrase = "Link established" sphrase = "Link established"
elif prg >= 0.05: elif prg >= 0.05:
sphrase = "Sending" sphrase = "Sending"
if speed != None: prgstr += f", {RNS.prettyspeed(speed)}"
if msg["title"]: if msg["title"]:
titlestr = "[b]Title[/b] "+msg["title"].decode("utf-8")+"\n" titlestr = "[b]Title[/b] "+msg["title"].decode("utf-8")+"\n"
@ -744,23 +730,16 @@ class Messages():
if has_audio: if has_audio:
def play_audio(sender): def play_audio(sender):
touch_event = None; block_play = False self.app.play_audio_field(sender.audio_field)
if sender and hasattr(sender, "last_touch"): touch_event = sender.last_touch stored_color = sender.md_bg_color
if touch_event and hasattr(touch_event, "dpos"): if sender.lsource == self.app.sideband.lxmf_destination.hash:
delta = abs(touch_event.dpos[0]) + abs(touch_event.dpos[1]) sender.md_bg_color = mdc(c_delivered, intensity_play)
if delta >= 2.0: block_play = True else:
sender.md_bg_color = mdc(c_received, intensity_play)
if not block_play: def cb(dt):
self.app.play_audio_field(sender.audio_field) sender.md_bg_color = stored_color
stored_color = sender.md_bg_color Clock.schedule_once(cb, 0.25)
if sender.lsource == self.app.sideband.lxmf_destination.hash:
sender.md_bg_color = mdc(c_delivered, intensity_play)
else:
sender.md_bg_color = mdc(c_received, intensity_play)
def cb(dt):
sender.md_bg_color = stored_color
Clock.schedule_once(cb, 0.25)
item.has_audio = True item.has_audio = True
item.audio_size = len(audio_field[1]) item.audio_size = len(audio_field[1])
@ -1464,10 +1443,7 @@ Builder.load_string("""
id: heading_text id: heading_text
markup: True markup: True
text: root.heading text: root.heading
size_hint_y: None adaptive_size: True
height: self.texture_size[1]
# adaptive_size: True
# theme_text_color: 'Custom' # theme_text_color: 'Custom'
# text_color: rgba(255,255,255,100) # text_color: rgba(255,255,255,100)
pos: 0, root.height - (self.height + root.padding[0] + dp(8)) pos: 0, root.height - (self.height + root.padding[0] + dp(8))

View file

@ -822,30 +822,17 @@ class RVDetails(MDRecycleView):
if nhi and nhi != "None": if nhi and nhi != "None":
self.entries.append({"icon": "routes", "text": f"Current path on [b]{nhi}[/b]", "on_release": pass_job}) self.entries.append({"icon": "routes", "text": f"Current path on [b]{nhi}[/b]", "on_release": pass_job})
if nh != RNS.Transport.PATHFINDER_M:
hs = "hop" if nh == 1 else "hops"
self.entries.append({"icon": "atom-variant", "text": f"Network distance is [b]{nh} {hs}[/b]", "on_release": pass_job})
try: try:
ler = self.delegate.app.sideband.get_destination_establishment_rate(self.delegate.object_hash) ler = self.delegate.app.sideband.get_destination_establishment_rate(self.delegate.object_hash)
mtu = self.delegate.app.sideband.get_destination_mtu(self.delegate.object_hash) or RNS.Reticulum.MTU
edr = self.delegate.app.sideband.get_destination_edr(self.delegate.object_hash)
lmd = self.delegate.app.sideband.get_destination_lmd(self.delegate.object_hash)
if ler: if ler:
lers = RNS.prettyspeed(ler, "b") lers = RNS.prettyspeed(ler, "b")
mtus = RNS.prettysize(mtu) self.entries.append({"icon": "lock-check-outline", "text": f"Direct link established, LER is [b]{lers}[/b]", "on_release": pass_job})
edrs = f"{RNS.prettyspeed(edr)}" if edr != None else ""
self.entries.append({"icon": "lock-check-outline", "text": f"Link established, LER is [b]{lers}[/b], MTU is [b]{mtus}[/b]", "on_release": pass_job})
if edr: self.entries.append({"icon": "approximately-equal", "text": f"Expected data rate is [b]{edrs}[/b]", "on_release": pass_job})
if lmd != None:
if lmd in RNS.Link.MODE_DESCRIPTIONS: lmds = RNS.Link.MODE_DESCRIPTIONS[lmd]
else: lmds = "unknown"
if lmds == "AES_128_CBC": lmds = "X25519/AES128"
elif lmds == "AES_256_CBC": lmds = "X25519/AES256"
self.entries.append({"icon": "link-lock", "text": f"Link mode is [b]{lmds}[/b]", "on_release": pass_job})
except Exception as e: except Exception as e:
RNS.trace_exception(e) RNS.trace_exception(e)
if nh != RNS.Transport.PATHFINDER_M:
hs = "hop" if nh == 1 else "hops"
self.entries.append({"icon": "atom-variant", "text": f"Network distance is [b]{nh} {hs}[/b]", "on_release": pass_job})
except Exception as e: except Exception as e:
RNS.trace_exception(e) RNS.trace_exception(e)

View file

@ -40,7 +40,7 @@ class Utilities():
self.screen.delegate = self self.screen.delegate = self
self.app.root.ids.screen_manager.add_widget(self.screen) self.app.root.ids.screen_manager.add_widget(self.screen)
self.screen.ids.utilities_scrollview.effect_cls = ScrollEffect self.screen.ids.telemetry_scrollview.effect_cls = ScrollEffect
info = "This section contains various utilities and diagnostics tools, " info = "This section contains various utilities and diagnostics tools, "
info += "that can be helpful while using Sideband and Reticulum." info += "that can be helpful while using Sideband and Reticulum."
@ -220,7 +220,7 @@ MDScreen:
] ]
ScrollView: ScrollView:
id: utilities_scrollview id: telemetry_scrollview
MDBoxLayout: MDBoxLayout:
orientation: "vertical" orientation: "vertical"

View file

@ -1,481 +0,0 @@
import time
import RNS
from typing import Union
from kivy.metrics import dp,sp
from kivy.lang.builder import Builder
from kivy.core.clipboard import Clipboard
from kivy.utils import escape_markup
from kivymd.uix.recycleview import MDRecycleView
from kivymd.uix.list import OneLineIconListItem
from kivymd.uix.pickers import MDColorPicker
from kivymd.uix.button import MDRectangleFlatButton
from kivymd.uix.button import MDRectangleFlatIconButton
from kivymd.uix.dialog import MDDialog
from kivymd.icon_definitions import md_icons
from kivymd.toast import toast
from kivy.properties import StringProperty, BooleanProperty
from kivy.effects.scroll import ScrollEffect
from kivy.clock import Clock
from sideband.sense import Telemeter
import threading
from datetime import datetime
if RNS.vendor.platformutils.get_platform() == "android":
from ui.helpers import ts_format
from android.permissions import request_permissions, check_permission
else:
from .helpers import ts_format
class Voice():
def __init__(self, app):
self.app = app
self.screen = None
self.settings_screen = None
self.dial_target = None
self.ui_updater = None
self.path_requesting = None
self.output_devices = []
self.input_devices = []
self.listed_output_devices = []
self.listed_input_devices = []
self.listed_ringer_devices = []
if not self.app.root.ids.screen_manager.has_screen("voice_screen"):
self.screen = Builder.load_string(layout_voice_screen)
self.screen.app = self.app
self.screen.delegate = self
self.app.root.ids.screen_manager.add_widget(self.screen)
self.screen.ids.voice_scrollview.effect_cls = ScrollEffect
def update_call_status(self, dt=None):
if self.app.root.ids.screen_manager.current == "voice_screen":
if self.ui_updater == None: self.ui_updater = Clock.schedule_interval(self.update_call_status, 0.5)
else:
if self.ui_updater:
self.ui_updater.cancel()
self.ui_updater = None
db = self.screen.ids.dial_button
ih = self.screen.ids.identity_hash
if self.app.sideband.voice_running:
telephone = self.app.sideband.telephone
if self.path_requesting:
db.disabled = True
ih.disabled = True
else:
if telephone.is_available:
ih.disabled = False
self.target_input_action(ih)
else:
ih.disabled = True
if telephone.is_in_call or telephone.call_is_connecting:
ih.disabled = True
db.disabled = False
db.text = "Hang up"
db.icon = "phone-hangup"
elif telephone.is_ringing:
ih.disabled = True
db.disabled = False
db.text = "Answer"
db.icon = "phone-ring"
if telephone.caller: ih.text = RNS.hexrep(telephone.caller.hash, delimit=False)
else:
db.disabled = True; db.text = "Voice calls disabled"
ih.disabled = True
def target_valid(self):
if self.app.sideband.voice_running:
db = self.screen.ids.dial_button
db.disabled = False; db.text = "Call"
db.icon = "phone-outgoing"
def target_invalid(self):
if self.app.sideband.voice_running:
db = self.screen.ids.dial_button
db.disabled = True; db.text = "Call"
db.icon = "phone-outgoing"
def target_input_action(self, sender):
if sender:
target_hash = sender.text
if len(target_hash) == RNS.Reticulum.TRUNCATED_HASHLENGTH//8*2:
try:
identity_hash = bytes.fromhex(target_hash)
self.dial_target = identity_hash
self.target_valid()
except Exception as e: self.target_invalid()
else: self.target_invalid()
def request_path(self, destination_hash):
if not self.path_requesting:
self.app.sideband.telephone.set_busy(True)
toast("Requesting path...")
self.screen.ids.dial_button.disabled = True
self.path_requesting = destination_hash
RNS.Transport.request_path(destination_hash)
threading.Thread(target=self._path_wait_job, daemon=True).start()
else:
toast("Waiting for path request answer...")
def _path_wait_job(self):
timeout = time.time()+self.app.sideband.telephone.PATH_TIME
while not RNS.Transport.has_path(self.path_requesting) and time.time() < timeout:
time.sleep(0.25)
self.app.sideband.telephone.set_busy(False)
if RNS.Transport.has_path(self.path_requesting):
RNS.log(f"Calling {RNS.prettyhexrep(self.dial_target)}...", RNS.LOG_DEBUG)
self.app.sideband.telephone.dial(self.dial_target)
Clock.schedule_once(self.update_call_status, 0.1)
else:
Clock.schedule_once(self._path_request_failed, 0.05)
Clock.schedule_once(self.update_call_status, 0.1)
self.path_requesting = None
self.update_call_status()
def _path_request_failed(self, dt):
toast("Path request timed out")
def dial_action(self, sender=None):
if self.app.sideband.voice_running:
if self.app.sideband.telephone.is_available:
destination_hash = RNS.Destination.hash_from_name_and_identity("lxst.telephony", self.dial_target)
if not RNS.Transport.has_path(destination_hash):
self.request_path(destination_hash)
else:
RNS.log(f"Calling {RNS.prettyhexrep(self.dial_target)}...", RNS.LOG_DEBUG)
self.app.sideband.telephone.dial(self.dial_target)
self.update_call_status()
elif self.app.sideband.telephone.is_in_call or self.app.sideband.telephone.call_is_connecting:
RNS.log(f"Hanging up", RNS.LOG_DEBUG)
self.app.sideband.telephone.hangup()
self.update_call_status()
elif self.app.sideband.telephone.is_ringing:
RNS.log(f"Answering", RNS.LOG_DEBUG)
self.app.sideband.telephone.answer()
self.update_call_status()
### settings screen
######################################
def settings_action(self, sender=None):
if not self.app.root.ids.screen_manager.has_screen("voice_settings_screen"):
self.voice_settings_screen = Builder.load_string(layout_voice_settings_screen)
self.voice_settings_screen.app = self.app
self.voice_settings_screen.delegate = self
self.app.root.ids.screen_manager.add_widget(self.voice_settings_screen)
self.app.root.ids.screen_manager.transition.direction = "left"
self.app.root.ids.screen_manager.current = "voice_settings_screen"
self.voice_settings_screen.ids.voice_settings_scrollview.effect_cls = ScrollEffect
self.app.sideband.setstate("app.displaying", self.app.root.ids.screen_manager.current)
self.update_settings_screen()
def update_devices(self):
import LXST
self.output_devices = []; self.input_devices = []
for device in LXST.Sources.Backend().soundcard.all_speakers(): self.output_devices.append(device.name)
for device in LXST.Sinks.Backend().soundcard.all_microphones(): self.input_devices.append(device.name)
if self.app.sideband.config["voice_output"] != None:
if not self.app.sideband.config["voice_output"] in self.output_devices: self.output_devices.append(self.app.sideband.config["voice_output"])
if self.app.sideband.config["voice_input"] != None:
if not self.app.sideband.config["voice_input"] in self.input_devices: self.input_devices.append(self.app.sideband.config["voice_input"])
if self.app.sideband.config["voice_ringer"] != None:
if not self.app.sideband.config["voice_ringer"] in self.output_devices: self.output_devices.append(self.app.sideband.config["voice_ringer"])
def update_settings_screen(self, sender=None):
self.voice_settings_screen.ids.voice_trusted_only.active = self.app.sideband.config["voice_trusted_only"]
self.voice_settings_screen.ids.voice_trusted_only.bind(active=self.settings_save_action)
bp = 6; ml = 45; fs = 16; ics = 14
self.update_devices()
# Output devices
if not "system_default" in self.listed_output_devices:
default_output_button = MDRectangleFlatIconButton(text="System Default", font_size=dp(fs), icon_size=dp(ics), on_release=self.output_device_action)
default_output_button.device = None; default_output_button.size_hint = [1.0, None]
if self.app.sideband.config["voice_output"] == None: default_output_button.icon = "check"
self.voice_settings_screen.ids.output_devices.add_widget(default_output_button)
self.listed_output_devices.append("system_default")
for device in self.output_devices:
if not device in self.listed_output_devices:
label = device if len(device) < ml else device[:ml-3]+"..."
device_button = MDRectangleFlatIconButton(text=label, font_size=dp(fs), icon_size=dp(ics), on_release=self.output_device_action)
device_button.padding = [dp(bp), dp(bp), dp(bp), dp(bp)]; device_button.size_hint = [1.0, None]
if self.app.sideband.config["voice_output"] == device: device_button.icon = "check"
device_button.device = device
self.voice_settings_screen.ids.output_devices.add_widget(device_button)
self.listed_output_devices.append(device)
# Input devices
if not "system_default" in self.listed_input_devices:
default_input_button = MDRectangleFlatIconButton(text="System Default", font_size=dp(fs), icon_size=dp(ics), on_release=self.input_device_action)
default_input_button.device = None; default_input_button.size_hint = [1.0, None]
if self.app.sideband.config["voice_output"] == None: default_input_button.icon = "check"
self.voice_settings_screen.ids.input_devices.add_widget(default_input_button)
self.listed_input_devices.append("system_default")
for device in self.input_devices:
if not device in self.listed_input_devices:
label = device if len(device) < ml else device[:ml-3]+"..."
device_button = MDRectangleFlatIconButton(text=label, font_size=dp(fs), icon_size=dp(ics), on_release=self.input_device_action)
device_button.padding = [dp(bp), dp(bp), dp(bp), dp(bp)]; device_button.size_hint = [1.0, None]
if self.app.sideband.config["voice_input"] == device: device_button.icon = "check"
device_button.device = device
self.voice_settings_screen.ids.input_devices.add_widget(device_button)
self.listed_input_devices.append(device)
# Ringer devices
if not "system_default" in self.listed_ringer_devices:
default_ringer_button = MDRectangleFlatIconButton(text="System Default", font_size=dp(fs), icon_size=dp(ics), on_release=self.ringer_device_action)
default_ringer_button.device = None; default_ringer_button.size_hint = [1.0, None]
if self.app.sideband.config["voice_ringer"] == None: default_ringer_button.icon = "check"
self.voice_settings_screen.ids.ringer_devices.add_widget(default_ringer_button)
self.listed_ringer_devices.append("system_default")
for device in self.output_devices:
if not device in self.listed_ringer_devices:
label = device if len(device) < ml else device[:ml-3]+"..."
device_button = MDRectangleFlatIconButton(text=label, font_size=dp(fs), icon_size=dp(ics), on_release=self.ringer_device_action)
device_button.padding = [dp(bp), dp(bp), dp(bp), dp(bp)]; device_button.size_hint = [1.0, None]
if self.app.sideband.config["voice_ringer"] == device: device_button.icon = "check"
device_button.device = device
self.voice_settings_screen.ids.ringer_devices.add_widget(device_button)
self.listed_ringer_devices.append(device)
def settings_save_action(self, sender=None, event=None):
self.app.sideband.config["voice_trusted_only"] = self.voice_settings_screen.ids.voice_trusted_only.active
self.app.sideband.save_configuration()
def output_device_action(self, sender=None):
self.app.sideband.config["voice_output"] = sender.device
self.app.sideband.save_configuration()
for w in self.voice_settings_screen.ids.output_devices.children: w.icon = ""
sender.icon = "check"
if self.app.sideband.telephone:
self.app.sideband.telephone.set_speaker(self.app.sideband.config["voice_output"])
def input_device_action(self, sender=None):
self.app.sideband.config["voice_input"] = sender.device
self.app.sideband.save_configuration()
for w in self.voice_settings_screen.ids.input_devices.children: w.icon = ""
sender.icon = "check"
if self.app.sideband.telephone:
self.app.sideband.telephone.set_microphone(self.app.sideband.config["voice_input"])
def ringer_device_action(self, sender=None):
self.app.sideband.config["voice_ringer"] = sender.device
self.app.sideband.save_configuration()
for w in self.voice_settings_screen.ids.ringer_devices.children: w.icon = ""
sender.icon = "check"
if self.app.sideband.telephone:
self.app.sideband.telephone.set_ringer(self.app.sideband.config["voice_ringer"])
layout_voice_screen = """
MDScreen:
name: "voice_screen"
BoxLayout:
orientation: "vertical"
MDTopAppBar:
title: "Voice"
anchor_title: "left"
elevation: 0
left_action_items:
[['menu', lambda x: root.app.nav_drawer.set_state("open")]]
right_action_items:
[
['wrench-cog', lambda x: root.delegate.settings_action(self)],
['close', lambda x: root.app.close_any_action(self)],
]
ScrollView:
id: voice_scrollview
MDBoxLayout:
orientation: "vertical"
size_hint_y: None
height: self.minimum_height
padding: [dp(28), dp(32), dp(28), dp(16)]
MDBoxLayout:
orientation: "vertical"
# spacing: "24dp"
size_hint_y: None
height: self.minimum_height
padding: [dp(0), dp(12), dp(0), dp(0)]
MDTextField:
id: identity_hash
hint_text: "Identity hash"
mode: "rectangle"
# size_hint: [1.0, None]
pos_hint: {"center_x": .5}
max_text_length: 32
on_text: root.delegate.target_input_action(self)
MDBoxLayout:
orientation: "vertical"
spacing: "24dp"
size_hint_y: None
height: self.minimum_height
padding: [dp(0), dp(35), dp(0), dp(35)]
MDRectangleFlatIconButton:
id: dial_button
icon: "phone-outgoing"
text: "Call"
padding: [dp(0), dp(14), dp(0), dp(14)]
icon_size: dp(24)
font_size: dp(16)
size_hint: [1.0, None]
on_release: root.delegate.dial_action(self)
disabled: True
"""
layout_voice_settings_screen = """
MDScreen:
name: "voice_settings_screen"
BoxLayout:
orientation: "vertical"
MDTopAppBar:
id: top_bar
title: "Voice Configuration"
anchor_title: "left"
elevation: 0
left_action_items:
[['menu', lambda x: root.app.nav_drawer.set_state("open")]]
right_action_items:
[
['close', lambda x: root.app.close_sub_voice_action(self)],
]
MDScrollView:
id: voice_settings_scrollview
size_hint_x: 1
size_hint_y: None
size: [root.width, root.height-root.ids.top_bar.height]
do_scroll_x: False
do_scroll_y: True
MDBoxLayout:
orientation: "vertical"
size_hint_y: None
height: self.minimum_height
padding: [dp(28), dp(48), dp(28), dp(16)]
MDLabel:
text: "Call Handling"
font_style: "H6"
height: self.texture_size[1]
padding: [dp(0), dp(0), dp(0), dp(12)]
MDLabel:
id: voice_settings_info
markup: True
text: "You can block calls from all other callers than contacts marked as trusted, by enabling the following option."
size_hint_y: None
text_size: self.width, None
height: self.texture_size[1]
padding: [dp(0), dp(16), dp(0), dp(16)]
MDBoxLayout:
orientation: "horizontal"
padding: [0,0,dp(24),0]
size_hint_y: None
height: dp(48)
MDLabel:
text: "Block non-trusted callers"
font_style: "H6"
MDSwitch:
id: voice_trusted_only
pos_hint: {"center_y": 0.3}
active: False
MDLabel:
text: "Audio Devices"
font_style: "H6"
padding: [dp(0), dp(96), dp(0), dp(12)]
MDLabel:
id: voice_settings_info
markup: True
text: "You can configure which audio devices Sideband will use for voice calls, by selecting either the system default device, or specific audio devices available."
size_hint_y: None
text_size: self.width, None
height: self.texture_size[1]
padding: [dp(0), dp(64), dp(0), dp(32)]
MDLabel:
text: "[b]Output[/b]"
font_size: dp(18)
markup: True
MDBoxLayout:
id: output_devices
orientation: "vertical"
spacing: "12dp"
size_hint_y: None
height: self.minimum_height
padding: [dp(0), dp(24), dp(0), dp(48)]
# MDRectangleFlatIconButton:
# id: output_default_button
# text: "System Default"
# padding: [dp(0), dp(14), dp(0), dp(14)]
# icon_size: dp(24)
# font_size: dp(16)
# size_hint: [1.0, None]
# on_release: root.delegate.output_device_action(self)
# disabled: False
MDLabel:
text: "[b]Input[/b]"
font_size: dp(18)
markup: True
MDBoxLayout:
id: input_devices
orientation: "vertical"
spacing: "12dp"
size_hint_y: None
height: self.minimum_height
padding: [dp(0), dp(24), dp(0), dp(48)]
MDLabel:
text: "[b]Ringer[/b]"
font_size: dp(18)
markup: True
MDBoxLayout:
id: ringer_devices
orientation: "vertical"
spacing: "12dp"
size_hint_y: None
height: self.minimum_height
padding: [dp(0), dp(24), dp(0), dp(48)]
"""

View file

@ -114,8 +114,8 @@ setuptools.setup(
] ]
}, },
install_requires=[ install_requires=[
"rns>=1.0.0", "rns>=0.9.2",
"lxmf>=0.8.0", "lxmf>=0.6.0",
"kivy>=2.3.0", "kivy>=2.3.0",
"pillow>=10.2.0", "pillow>=10.2.0",
"qrcode", "qrcode",
@ -123,14 +123,12 @@ setuptools.setup(
"ffpyplayer", "ffpyplayer",
"sh", "sh",
"numpy<=1.26.4", "numpy<=1.26.4",
"lxst>=0.3.0",
"mistune>=3.0.2", "mistune>=3.0.2",
"beautifulsoup4", "beautifulsoup4",
"pycodec2;sys.platform!='Windows' and sys.platform!='win32' and sys.platform!='darwin'", "pycodec2;sys.platform!='Windows' and sys.platform!='win32' and sys.platform!='darwin'",
"pyaudio;sys.platform=='linux'", "pyaudio;sys.platform=='linux'",
"pyobjus;sys.platform=='darwin'", "pyobjus;sys.platform=='darwin'",
"pyogg;sys.platform=='Windows' and sys.platform!='win32'", "pyogg;sys.platform=='Windows' and sys.platform!='win32'",
"audioop-lts>=0.2.1;python_version>='3.13'"
], ],
python_requires='>=3.7', python_requires='>=3.7',
) )

View file

@ -36,7 +36,6 @@ def extra_datas(mydir):
a.datas += extra_datas('sbapp') a.datas += extra_datas('sbapp')
a.datas += extra_datas('RNS') a.datas += extra_datas('RNS')
a.datas += extra_datas('LXMF') a.datas += extra_datas('LXMF')
a.datas += extra_datas('LXST')
exe = EXE( exe = EXE(
pyz, pyz,