2020-03-26 20:52:34 +00:00
|
|
|
from .admin import AdminController
|
2020-03-26 21:08:24 +00:00
|
|
|
from owrx.config import Config
|
2020-03-26 22:04:02 +00:00
|
|
|
from urllib.parse import parse_qs
|
2020-03-29 18:14:34 +00:00
|
|
|
from owrx.form import (
|
|
|
|
TextInput,
|
|
|
|
NumberInput,
|
|
|
|
FloatInput,
|
|
|
|
LocationInput,
|
|
|
|
TextAreaInput,
|
|
|
|
CheckboxInput,
|
|
|
|
DropdownInput,
|
|
|
|
Option,
|
|
|
|
ServicesCheckboxInput,
|
2020-04-25 15:33:30 +00:00
|
|
|
Js8ProfileCheckboxInput,
|
2020-03-29 18:14:34 +00:00
|
|
|
)
|
2020-05-10 18:18:42 +00:00
|
|
|
from urllib.parse import quote
|
|
|
|
import json
|
2020-03-26 22:04:02 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
2020-03-26 20:52:34 +00:00
|
|
|
|
|
|
|
|
2020-03-27 00:14:38 +00:00
|
|
|
class Section(object):
|
|
|
|
def __init__(self, title, *inputs):
|
|
|
|
self.title = title
|
|
|
|
self.inputs = inputs
|
|
|
|
|
|
|
|
def render_inputs(self):
|
2020-03-26 21:08:24 +00:00
|
|
|
config = Config.get()
|
2020-03-27 00:14:38 +00:00
|
|
|
return "".join([i.render(config) for i in self.inputs])
|
|
|
|
|
|
|
|
def render(self):
|
2020-03-26 22:04:02 +00:00
|
|
|
return """
|
2020-03-27 00:14:38 +00:00
|
|
|
<div class="col-12 settings-category">
|
|
|
|
<h3 class="settings-header">
|
|
|
|
{title}
|
|
|
|
</h3>
|
2020-03-26 22:04:02 +00:00
|
|
|
{inputs}
|
2020-03-27 00:14:38 +00:00
|
|
|
</div>
|
2020-03-27 20:11:33 +00:00
|
|
|
""".format(
|
|
|
|
title=self.title, inputs=self.render_inputs()
|
|
|
|
)
|
2020-03-27 00:14:38 +00:00
|
|
|
|
|
|
|
def parse(self, data):
|
|
|
|
return {k: v for i in self.inputs for k, v in i.parse(data).items()}
|
|
|
|
|
|
|
|
|
|
|
|
class SettingsController(AdminController):
|
2020-04-25 19:42:00 +00:00
|
|
|
def indexAction(self):
|
|
|
|
self.serve_template("settings.html", **self.template_variables())
|
|
|
|
|
|
|
|
|
2020-04-25 19:55:52 +00:00
|
|
|
class SdrSettingsController(AdminController):
|
2020-04-26 00:15:19 +00:00
|
|
|
def template_variables(self):
|
|
|
|
variables = super().template_variables()
|
|
|
|
variables["devices"] = self.render_devices()
|
|
|
|
return variables
|
|
|
|
|
|
|
|
def render_devices(self):
|
2020-05-10 18:18:42 +00:00
|
|
|
return "".join(self.render_device(key, value) for key, value in Config.get()["sdrs"].items())
|
|
|
|
|
|
|
|
def render_device(self, device_id, config):
|
|
|
|
return """
|
|
|
|
<div class="card device bg-dark text-white">
|
|
|
|
<div class="card-header">
|
|
|
|
{device_name}
|
|
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
|
|
{form}
|
2020-04-26 00:15:19 +00:00
|
|
|
</div>
|
2020-05-10 18:18:42 +00:00
|
|
|
</div>
|
2021-01-20 16:01:46 +00:00
|
|
|
""".format(
|
|
|
|
device_name=config["name"], form=self.render_form(device_id, config)
|
|
|
|
)
|
2020-05-10 18:18:42 +00:00
|
|
|
|
|
|
|
def render_form(self, device_id, config):
|
|
|
|
return """
|
|
|
|
<form class="sdrdevice" data-config="{formdata}"></form>
|
2021-01-20 16:01:46 +00:00
|
|
|
""".format(
|
|
|
|
device_id=device_id, formdata=quote(json.dumps(config))
|
|
|
|
)
|
2020-04-26 00:15:19 +00:00
|
|
|
|
2020-04-25 19:55:52 +00:00
|
|
|
def indexAction(self):
|
|
|
|
self.serve_template("sdrsettings.html", **self.template_variables())
|
|
|
|
|
|
|
|
|
2020-04-25 19:42:00 +00:00
|
|
|
class GeneralSettingsController(AdminController):
|
2020-03-27 00:14:38 +00:00
|
|
|
sections = [
|
|
|
|
Section(
|
2020-03-27 20:11:33 +00:00
|
|
|
"General settings",
|
2020-03-27 00:14:38 +00:00
|
|
|
TextInput("receiver_name", "Receiver name"),
|
|
|
|
TextInput("receiver_location", "Receiver location"),
|
2020-03-29 18:14:34 +00:00
|
|
|
NumberInput(
|
|
|
|
"receiver_asl",
|
|
|
|
"Receiver elevation",
|
|
|
|
infotext="Elevation in meters above mean see level",
|
|
|
|
),
|
2020-03-27 00:14:38 +00:00
|
|
|
TextInput("receiver_admin", "Receiver admin"),
|
|
|
|
LocationInput("receiver_gps", "Receiver coordinates"),
|
|
|
|
TextInput("photo_title", "Photo title"),
|
|
|
|
TextAreaInput("photo_desc", "Photo description"),
|
|
|
|
),
|
2020-03-27 20:11:33 +00:00
|
|
|
Section(
|
|
|
|
"Waterfall settings",
|
2020-03-27 21:00:10 +00:00
|
|
|
NumberInput(
|
2020-03-27 20:11:33 +00:00
|
|
|
"fft_fps",
|
|
|
|
"FFT frames per second",
|
|
|
|
infotext="This setting specifies how many lines are being added to the waterfall per second. "
|
|
|
|
+ "Higher values will give you a faster waterfall, but will also use more CPU.",
|
|
|
|
),
|
2020-03-27 21:00:10 +00:00
|
|
|
NumberInput("fft_size", "FFT size"),
|
|
|
|
FloatInput(
|
2020-03-27 20:11:33 +00:00
|
|
|
"fft_voverlap_factor",
|
|
|
|
"FFT vertical overlap factor",
|
|
|
|
infotext="If fft_voverlap_factor is above 0, multiple FFTs will be used for creating a line on the "
|
|
|
|
+ "diagram.",
|
|
|
|
),
|
2020-03-27 21:00:10 +00:00
|
|
|
NumberInput("waterfall_min_level", "Lowest waterfall level"),
|
|
|
|
NumberInput("waterfall_max_level", "Highest waterfall level"),
|
2020-03-27 20:11:33 +00:00
|
|
|
),
|
|
|
|
Section(
|
|
|
|
"Compression",
|
2020-03-29 18:14:34 +00:00
|
|
|
DropdownInput(
|
|
|
|
"audio_compression",
|
|
|
|
"Audio compression",
|
2021-01-20 16:01:46 +00:00
|
|
|
options=[
|
|
|
|
Option("adpcm", "ADPCM"),
|
|
|
|
Option("none", "None"),
|
|
|
|
],
|
2020-03-29 18:14:34 +00:00
|
|
|
),
|
|
|
|
DropdownInput(
|
|
|
|
"fft_compression",
|
|
|
|
"Waterfall compression",
|
2021-01-20 16:01:46 +00:00
|
|
|
options=[
|
|
|
|
Option("adpcm", "ADPCM"),
|
|
|
|
Option("none", "None"),
|
|
|
|
],
|
2020-03-29 18:14:34 +00:00
|
|
|
),
|
2020-03-27 20:11:33 +00:00
|
|
|
),
|
|
|
|
Section(
|
|
|
|
"Digimodes",
|
|
|
|
CheckboxInput("digimodes_enable", "", checkboxText="Enable Digimodes"),
|
2020-03-27 21:00:10 +00:00
|
|
|
NumberInput("digimodes_fft_size", "Digimodes FFT size"),
|
2020-03-27 20:11:33 +00:00
|
|
|
),
|
|
|
|
Section(
|
|
|
|
"Digital voice",
|
2020-03-27 21:00:10 +00:00
|
|
|
NumberInput(
|
2020-03-27 20:11:33 +00:00
|
|
|
"digital_voice_unvoiced_quality",
|
|
|
|
"Quality of unvoiced sounds in synthesized voice",
|
|
|
|
infotext="Determines the quality, and thus the cpu usage, for the ambe codec used by digital voice"
|
2020-03-29 18:14:34 +00:00
|
|
|
+ "modes.<br />If you're running on a Raspi (up to 3B+) you should leave this set at 1",
|
2020-03-27 20:11:33 +00:00
|
|
|
),
|
|
|
|
CheckboxInput(
|
|
|
|
"digital_voice_dmr_id_lookup",
|
|
|
|
"DMR id lookup",
|
2020-03-29 18:14:34 +00:00
|
|
|
checkboxText="Enable lookup of DMR ids in the radioid database to show callsigns and names",
|
2020-03-27 20:11:33 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
Section(
|
|
|
|
"Experimental pipe settings",
|
|
|
|
CheckboxInput(
|
|
|
|
"csdr_dynamic_bufsize",
|
|
|
|
"",
|
|
|
|
checkboxText="Enable dynamic buffer sizes",
|
2020-03-29 18:14:34 +00:00
|
|
|
infotext="This allows you to change the buffering mode of csdr.",
|
2020-03-27 20:11:33 +00:00
|
|
|
),
|
|
|
|
CheckboxInput(
|
|
|
|
"csdr_print_bufsizes",
|
|
|
|
"",
|
|
|
|
checkboxText="Print buffer sizez",
|
2020-03-29 18:14:34 +00:00
|
|
|
infotext="This prints the buffer sizes used for csdr processes.",
|
2020-03-27 20:11:33 +00:00
|
|
|
),
|
|
|
|
CheckboxInput(
|
|
|
|
"csdr_through",
|
|
|
|
"",
|
|
|
|
checkboxText="Print throughput",
|
2020-03-29 18:14:34 +00:00
|
|
|
infotext="Enabling this will print out how much data is going into the DSP chains.",
|
2020-03-27 20:11:33 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
Section(
|
|
|
|
"Map settings",
|
|
|
|
TextInput(
|
|
|
|
"google_maps_api_key",
|
|
|
|
"Google Maps API key",
|
|
|
|
infotext="Google Maps requires an API key, check out "
|
|
|
|
+ '<a href="https://developers.google.com/maps/documentation/embed/get-api-key" target="_blank">'
|
2020-03-29 18:14:34 +00:00
|
|
|
+ "their documentation</a> on how to obtain one.",
|
2020-03-27 20:11:33 +00:00
|
|
|
),
|
2020-03-27 21:00:10 +00:00
|
|
|
NumberInput(
|
2020-03-27 20:11:33 +00:00
|
|
|
"map_position_retention_time",
|
|
|
|
"Map retention time",
|
2020-03-29 18:14:34 +00:00
|
|
|
infotext="Unit is seconds<br/>Specifies how log markers / grids will remain visible on the map",
|
2020-03-27 20:11:33 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
Section(
|
2020-04-25 15:33:30 +00:00
|
|
|
"Decoding settings",
|
2020-04-25 14:22:40 +00:00
|
|
|
NumberInput("decoding_queue_workers", "Number of decoding workers"),
|
|
|
|
NumberInput("decoding_queue_length", "Maximum length of decoding job queue"),
|
2020-03-27 21:00:10 +00:00
|
|
|
NumberInput(
|
2020-03-27 20:11:33 +00:00
|
|
|
"wsjt_decoding_depth",
|
2020-04-25 15:33:30 +00:00
|
|
|
"Default WSJT decoding depth",
|
2020-03-29 18:14:34 +00:00
|
|
|
infotext="A higher decoding depth will allow more results, but will also consume more cpu",
|
|
|
|
),
|
2020-04-25 15:33:30 +00:00
|
|
|
NumberInput(
|
|
|
|
"js8_decoding_depth",
|
|
|
|
"Js8Call decoding depth",
|
|
|
|
infotext="A higher decoding depth will allow more results, but will also consume more cpu",
|
|
|
|
),
|
2021-01-20 16:01:46 +00:00
|
|
|
Js8ProfileCheckboxInput("js8_enabled_profiles", "Js8Call enabled modes"),
|
2020-03-27 20:11:33 +00:00
|
|
|
),
|
|
|
|
Section(
|
|
|
|
"Background decoding",
|
2020-03-29 18:14:34 +00:00
|
|
|
CheckboxInput(
|
|
|
|
"services_enabled",
|
|
|
|
"Service",
|
|
|
|
checkboxText="Enable background decoding services",
|
|
|
|
),
|
|
|
|
ServicesCheckboxInput("services_decoders", "Enabled services"),
|
2020-03-27 20:11:33 +00:00
|
|
|
),
|
|
|
|
Section(
|
|
|
|
"APRS settings",
|
|
|
|
TextInput(
|
|
|
|
"aprs_callsign",
|
|
|
|
"APRS callsign",
|
2020-03-29 18:14:34 +00:00
|
|
|
infotext="This callsign will be used to send data to the APRS-IS network",
|
2020-03-27 20:11:33 +00:00
|
|
|
),
|
|
|
|
CheckboxInput(
|
|
|
|
"aprs_igate_enabled",
|
|
|
|
"APRS I-Gate",
|
2020-03-29 18:14:34 +00:00
|
|
|
checkboxText="Enable APRS receive-only I-Gate",
|
2020-03-27 20:11:33 +00:00
|
|
|
),
|
|
|
|
TextInput("aprs_igate_server", "APRS-IS server"),
|
|
|
|
TextInput("aprs_igate_password", "APRS-IS network password"),
|
|
|
|
CheckboxInput(
|
|
|
|
"aprs_igate_beacon",
|
|
|
|
"APRS beacon",
|
|
|
|
checkboxText="Send the receiver position to the APRS-IS network",
|
2020-03-29 18:14:34 +00:00
|
|
|
infotext="Please check that your receiver location is setup correctly",
|
2020-03-27 20:11:33 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
Section(
|
|
|
|
"pskreporter settings",
|
2020-03-29 18:14:34 +00:00
|
|
|
CheckboxInput(
|
|
|
|
"pskreporter_enabled",
|
|
|
|
"Reporting",
|
|
|
|
checkboxText="Enable sending spots to pskreporter.info",
|
|
|
|
),
|
2020-03-27 20:11:33 +00:00
|
|
|
TextInput(
|
|
|
|
"pskreporter_callsign",
|
|
|
|
"pskreporter callsign",
|
2020-03-29 18:14:34 +00:00
|
|
|
infotext="This callsign will be used to send spots to pskreporter.info",
|
2020-03-27 20:11:33 +00:00
|
|
|
),
|
|
|
|
),
|
2021-02-06 20:01:59 +00:00
|
|
|
Section(
|
|
|
|
"WSPRnet settings",
|
|
|
|
CheckboxInput(
|
|
|
|
"wsprnet_enabled",
|
|
|
|
"Reporting",
|
|
|
|
checkboxText="Enable sending spots to wsprnet.org",
|
|
|
|
),
|
|
|
|
TextInput(
|
|
|
|
"wsprnet_callsign",
|
|
|
|
"wsprnet callsign",
|
|
|
|
infotext="This callsign will be used to send spots to pskreporter.info",
|
|
|
|
),
|
|
|
|
),
|
2020-03-27 00:14:38 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def render_sections(self):
|
2020-04-25 19:42:00 +00:00
|
|
|
sections = "".join(section.render() for section in GeneralSettingsController.sections)
|
2020-03-27 00:14:38 +00:00
|
|
|
return """
|
|
|
|
<form class="settings-body" method="POST">
|
|
|
|
{sections}
|
2020-03-26 22:04:02 +00:00
|
|
|
<div class="buttons">
|
|
|
|
<button type="submit" class="btn btn-primary">Apply</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
2020-03-27 20:11:33 +00:00
|
|
|
""".format(
|
|
|
|
sections=sections
|
|
|
|
)
|
2020-03-27 00:14:38 +00:00
|
|
|
|
|
|
|
def indexAction(self):
|
2020-04-25 19:42:00 +00:00
|
|
|
self.serve_template("generalsettings.html", **self.template_variables())
|
2020-03-26 20:52:34 +00:00
|
|
|
|
|
|
|
def template_variables(self):
|
|
|
|
variables = super().template_variables()
|
2020-03-27 00:14:38 +00:00
|
|
|
variables["sections"] = self.render_sections()
|
2020-03-26 20:52:34 +00:00
|
|
|
return variables
|
2020-03-26 22:04:02 +00:00
|
|
|
|
|
|
|
def processFormData(self):
|
|
|
|
data = parse_qs(self.get_body().decode("utf-8"))
|
2021-01-20 16:01:46 +00:00
|
|
|
data = {k: v for i in GeneralSettingsController.sections for k, v in i.parse(data).items()}
|
2020-03-26 22:04:02 +00:00
|
|
|
config = Config.get()
|
|
|
|
for k, v in data.items():
|
|
|
|
config[k] = v
|
2020-03-27 22:44:03 +00:00
|
|
|
Config.store()
|
2020-03-26 22:04:02 +00:00
|
|
|
self.send_redirect("/admin")
|