mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
RADIO MANAGER - WIP added radio api endpoints
This commit is contained in:
parent
543cbbdff8
commit
baae3a5bb4
7 changed files with 58 additions and 48 deletions
|
@ -8,7 +8,7 @@ import "../../node_modules/gridstack/dist/gridstack.min.css";
|
||||||
import { GridStack } from "gridstack";
|
import { GridStack } from "gridstack";
|
||||||
import { useStateStore } from "../store/stateStore.js";
|
import { useStateStore } from "../store/stateStore.js";
|
||||||
const state = useStateStore(pinia);
|
const state = useStateStore(pinia);
|
||||||
import { setModemFrequency } from "../js/api";
|
import { setRadioParameters } from "../js/api";
|
||||||
import { saveLocalSettingsToConfig, settingsStore } from "../store/settingsStore";
|
import { saveLocalSettingsToConfig, settingsStore } from "../store/settingsStore";
|
||||||
|
|
||||||
import active_heard_stations from "./grid/grid_active_heard_stations.vue";
|
import active_heard_stations from "./grid/grid_active_heard_stations.vue";
|
||||||
|
@ -233,12 +233,20 @@ new gridWidget(
|
||||||
|
|
||||||
function updateFrequencyAndApply(frequency) {
|
function updateFrequencyAndApply(frequency) {
|
||||||
state.new_frequency = frequency;
|
state.new_frequency = frequency;
|
||||||
setModemFrequency(state.new_frequency);
|
set_radio_parameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_hamlib_frequency_manually() {
|
function set_radio_parameters(){
|
||||||
setModemFrequency(state.new_frequency);
|
setRadioParameters(state.new_frequency, state.mode, state.rf_level);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function savePreset()
|
function savePreset()
|
||||||
{
|
{
|
||||||
settingsStore.local.grid_preset=settingsStore.local.grid_layout;
|
settingsStore.local.grid_preset=settingsStore.local.grid_layout;
|
||||||
|
@ -707,7 +715,6 @@ function quickfill() {
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm btn-outline-success"
|
class="btn btn-sm btn-outline-success"
|
||||||
type="button"
|
type="button"
|
||||||
@click="set_hamlib_frequency_manually"
|
|
||||||
v-bind:class="{
|
v-bind:class="{
|
||||||
disabled: state.hamlib_status === 'disconnected',
|
disabled: state.hamlib_status === 'disconnected',
|
||||||
}"
|
}"
|
||||||
|
|
|
@ -1,18 +1,15 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { setActivePinia } from "pinia";
|
import { setActivePinia } from "pinia";
|
||||||
import pinia from "../../store/index";
|
import pinia from "../../store/index";
|
||||||
import { setModemRigMode, setModemRigPowerLvl } from "../../js/api";
|
import { setRadioParameters} from "../../js/api";
|
||||||
setActivePinia(pinia);
|
setActivePinia(pinia);
|
||||||
|
|
||||||
import { useStateStore } from "../../store/stateStore.js";
|
import { useStateStore } from "../../store/stateStore.js";
|
||||||
const state = useStateStore(pinia);
|
const state = useStateStore(pinia);
|
||||||
|
|
||||||
function set_hamlib_mode() {
|
function set_radio_parameters(){
|
||||||
setModemRigMode(state.mode);
|
setRadioParameters(state.frequency, state.mode, state.rf_level);
|
||||||
}
|
|
||||||
|
|
||||||
function set_hamlib_rf_level() {
|
|
||||||
setModemRigPowerLvl(state.rf_level);
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -6,24 +6,19 @@ setActivePinia(pinia);
|
||||||
import { useStateStore } from "../store/stateStore.js";
|
import { useStateStore } from "../store/stateStore.js";
|
||||||
const state = useStateStore(pinia);
|
const state = useStateStore(pinia);
|
||||||
|
|
||||||
import { setModemRigMode, setModemRigPowerLvl } from "../js/api";
|
import { setRadioParameters} from "../js/api";
|
||||||
|
|
||||||
function updateFrequencyAndApply(frequency) {
|
function updateFrequencyAndApply(frequency) {
|
||||||
//state.new_frequency = frequency;
|
state.new_frequency = frequency;
|
||||||
//set_frequency(state.new_frequency);
|
set_radio_parameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_hamlib_frequency_manually() {
|
|
||||||
//set_frequency(state.new_frequency);
|
function set_radio_parameters(){
|
||||||
|
setRadioParameters(state.new_frequency, state.mode, state.rf_level);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_hamlib_mode() {
|
|
||||||
setModemRigMode(state.mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
function set_hamlib_rf_level() {
|
|
||||||
setModemRigPowerLvl(state.rf_level);
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -102,7 +97,7 @@ function set_hamlib_rf_level() {
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm btn-outline-success"
|
class="btn btn-sm btn-outline-success"
|
||||||
type="button"
|
type="button"
|
||||||
@click="set_hamlib_frequency_manually"
|
@click="set_radio_parameters"
|
||||||
v-bind:class="{
|
v-bind:class="{
|
||||||
disabled: state.hamlib_status === 'disconnected',
|
disabled: state.hamlib_status === 'disconnected',
|
||||||
}"
|
}"
|
||||||
|
@ -215,7 +210,7 @@ function set_hamlib_rf_level() {
|
||||||
<select
|
<select
|
||||||
class="form-control"
|
class="form-control"
|
||||||
v-model="state.mode"
|
v-model="state.mode"
|
||||||
@click="set_hamlib_mode()"
|
@click="set_radio_parameters()"
|
||||||
v-bind:class="{
|
v-bind:class="{
|
||||||
disabled: state.hamlib_status === 'disconnected',
|
disabled: state.hamlib_status === 'disconnected',
|
||||||
}"
|
}"
|
||||||
|
@ -237,7 +232,7 @@ function set_hamlib_rf_level() {
|
||||||
<select
|
<select
|
||||||
class="form-control"
|
class="form-control"
|
||||||
v-model="state.rf_level"
|
v-model="state.rf_level"
|
||||||
@click="set_hamlib_rf_level()"
|
@click="set_radio_parameters()"
|
||||||
v-bind:class="{
|
v-bind:class="{
|
||||||
disabled: state.hamlib_status === 'disconnected',
|
disabled: state.hamlib_status === 'disconnected',
|
||||||
}"
|
}"
|
||||||
|
|
|
@ -117,12 +117,12 @@ export function getModemState() {
|
||||||
return apiGet("/modem/state");
|
return apiGet("/modem/state");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setModemFrequency(newFrequency) {
|
export function setRadioParameters(frequency, mode, rf_level){
|
||||||
console.error("setModemFrequency needs implemented");
|
return apiPost("/radio", {
|
||||||
|
radio_frequency: frequency,
|
||||||
|
radio_mode: mode,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
export function setModemRigMode(mode) {
|
export function getRadioStatus() {
|
||||||
console.error("setModemRigMode needs implemented");
|
return apiGet("/radio");
|
||||||
}
|
|
||||||
export function setModemRigPowerLvl(power) {
|
|
||||||
console.error("setModemRigPowerLvl needs implemented");
|
|
||||||
}
|
}
|
|
@ -242,15 +242,20 @@ def post_modem_send_raw_stop():
|
||||||
|
|
||||||
return api_response(request.json)
|
return api_response(request.json)
|
||||||
|
|
||||||
|
@app.route('/radio', methods=['GET', 'POST'])
|
||||||
|
def get_post_radio():
|
||||||
|
if request.method in ['POST']:
|
||||||
|
app.radio_manager.set_frequency(request.json['radio_frequency'])
|
||||||
|
app.radio_manager.set_mode(request.json['radio_mode'])
|
||||||
|
|
||||||
|
return api_response(request.json)
|
||||||
|
elif request.method == 'GET':
|
||||||
|
return api_response(app.state_manager.get_radio_status())
|
||||||
|
|
||||||
# @app.route('/modem/arq_connect', methods=['POST'])
|
# @app.route('/modem/arq_connect', methods=['POST'])
|
||||||
# @app.route('/modem/arq_disconnect', methods=['POST'])
|
# @app.route('/modem/arq_disconnect', methods=['POST'])
|
||||||
# @app.route('/modem/send_raw', methods=['POST'])
|
# @app.route('/modem/send_raw', methods=['POST'])
|
||||||
# @app.route('/modem/stop_transmission', methods=['POST'])
|
|
||||||
# @app.route('/modem/listen', methods=['POST']) # not needed if we are restarting modem on changing settings
|
|
||||||
# @app.route('/modem/record_audio', methods=['POST'])
|
# @app.route('/modem/record_audio', methods=['POST'])
|
||||||
# @app.route('/modem/responde_to_call', methods=['POST']) # not needed if we are restarting modem on changing settings
|
|
||||||
# @app.route('/modem/responde_to_cq', methods=['POST']) # not needed if we are restarting modem on changing settings
|
|
||||||
# @app.route('/modem/audio_levels', methods=['POST']) # tx and rx # not needed if we are restarting modem on changing settings
|
# @app.route('/modem/audio_levels', methods=['POST']) # tx and rx # not needed if we are restarting modem on changing settings
|
||||||
# @app.route('/modem/mesh_ping', methods=['POST'])
|
# @app.route('/modem/mesh_ping', methods=['POST'])
|
||||||
# @app.route('/mesh/routing_table', methods=['GET'])
|
# @app.route('/mesh/routing_table', methods=['GET'])
|
||||||
|
|
|
@ -12,12 +12,11 @@ import radio_manager
|
||||||
class SM:
|
class SM:
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
self.log = structlog.get_logger("service")
|
self.log = structlog.get_logger("service")
|
||||||
|
self.app = app
|
||||||
self.modem = False
|
self.modem = False
|
||||||
self.beacon = False
|
self.beacon = False
|
||||||
self.explorer = False
|
self.explorer = False
|
||||||
self.radio = False
|
self.app.radio_manager = False
|
||||||
self.app = app
|
|
||||||
self.config = self.app.config_manager.read()
|
self.config = self.app.config_manager.read()
|
||||||
self.modem_fft = app.modem_fft
|
self.modem_fft = app.modem_fft
|
||||||
self.modem_service = app.modem_service
|
self.modem_service = app.modem_service
|
||||||
|
@ -88,7 +87,7 @@ class SM:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.log.info("starting modem....")
|
self.log.info("starting modem....")
|
||||||
self.modem = modem.RF(self.config, self.event_manager, self.modem_fft, self.modem_service, self.state_manager, self.radio)
|
self.modem = modem.RF(self.config, self.event_manager, self.modem_fft, self.modem_service, self.state_manager, self.app.radio_manager)
|
||||||
|
|
||||||
self.frame_dispatcher = frame_dispatcher.DISPATCHER(self.config,
|
self.frame_dispatcher = frame_dispatcher.DISPATCHER(self.config,
|
||||||
self.event_manager,
|
self.event_manager,
|
||||||
|
@ -140,8 +139,8 @@ class SM:
|
||||||
del self.explorer
|
del self.explorer
|
||||||
|
|
||||||
def start_radio_manager(self):
|
def start_radio_manager(self):
|
||||||
self.radio = radio_manager.RadioManager(self.config, self.state_manager, self.event_manager)
|
self.app.radio_manager = radio_manager.RadioManager(self.config, self.state_manager, self.event_manager)
|
||||||
|
|
||||||
def stop_radio_manager(self):
|
def stop_radio_manager(self):
|
||||||
self.radio.stop()
|
self.app.radio_manager.stop()
|
||||||
del self.radio
|
del self.app.radio_manager
|
|
@ -177,3 +177,10 @@ class StateManager:
|
||||||
else:
|
else:
|
||||||
self.channel_busy_condition_codec2 = threading.Event()
|
self.channel_busy_condition_codec2 = threading.Event()
|
||||||
self.calculate_channel_busy_state()
|
self.calculate_channel_busy_state()
|
||||||
|
|
||||||
|
def get_radio_status(self):
|
||||||
|
return {
|
||||||
|
"radio_status": self.radio_status,
|
||||||
|
"radio_frequency": self.radio_frequency,
|
||||||
|
"radio_mode": self.radio_mode,
|
||||||
|
}
|
Loading…
Reference in a new issue