beacon away from key flag on server layer

This commit is contained in:
DJ2LS 2024-04-13 10:56:11 +02:00
parent 1ac3185ad3
commit 2c331ecaa4
8 changed files with 75 additions and 12 deletions

View file

@ -105,6 +105,8 @@ Spectrum.prototype.drawSpectrum = function () {
var linePositionHigh = 178.4; //150 + bandwidth/20 var linePositionHigh = 178.4; //150 + bandwidth/20
var linePositionLow2 = 65; //150 - bandwith/20 var linePositionLow2 = 65; //150 - bandwith/20
var linePositionHigh2 = 235; //150 + bandwith/20 var linePositionHigh2 = 235; //150 + bandwith/20
var linePositionLow3 = 28.1; //150 - bandwith/20
var linePositionHigh3 = 271.9; //150 + bandwith/20
this.ctx_wf.beginPath(); this.ctx_wf.beginPath();
this.ctx_wf.moveTo(linePositionLow, 0); this.ctx_wf.moveTo(linePositionLow, 0);
this.ctx_wf.lineTo(linePositionLow, height); this.ctx_wf.lineTo(linePositionLow, height);
@ -114,6 +116,10 @@ Spectrum.prototype.drawSpectrum = function () {
this.ctx_wf.lineTo(linePositionLow2, height); this.ctx_wf.lineTo(linePositionLow2, height);
this.ctx_wf.moveTo(linePositionHigh2, 0); this.ctx_wf.moveTo(linePositionHigh2, 0);
this.ctx_wf.lineTo(linePositionHigh2, height); this.ctx_wf.lineTo(linePositionHigh2, height);
this.ctx_wf.moveTo(linePositionLow3, 0);
this.ctx_wf.lineTo(linePositionLow3, height);
this.ctx_wf.moveTo(linePositionHigh3, 0);
this.ctx_wf.lineTo(linePositionHigh3, height);
this.ctx_wf.lineWidth = 1; this.ctx_wf.lineWidth = 1;
this.ctx_wf.strokeStyle = "#C3C3C3"; this.ctx_wf.strokeStyle = "#C3C3C3";
this.ctx_wf.stroke(); this.ctx_wf.stroke();

View file

@ -15,11 +15,22 @@ function transmitPing() {
function startStopBeacon() { function startStopBeacon() {
if (state.beacon_state === true) { if (state.beacon_state === true) {
setModemBeacon(false); setModemBeacon(false, state.away_from_key);
} else { } else {
setModemBeacon(true); setModemBeacon(true, state.away_from_key);
} }
} }
function setAwayFromKey(){
if (state.away_from_key === true) {
setModemBeacon(state.beacon_state, false);
} else {
setModemBeacon(state.beacon_state, true);
}
}
var dxcallPing = ref(""); var dxcallPing = ref("");
window.addEventListener( window.addEventListener(
"stationSelected", "stationSelected",
@ -84,6 +95,22 @@ window.addEventListener(
> >
</div> </div>
</div> </div>
<div class="col">
<div class="form-check form-switch">
<input
class="form-check-input"
type="checkbox"
role="switch"
id="flexSwitchAFK"
v-model="state.away_from_key"
@click="setAwayFromKey()"
/>
<label class="form-check-label" for="flexSwitchAFK"
>AFK</label
>
</div>
</div>
</div> </div>
<div class="row"> <div class="row">

View file

@ -92,8 +92,8 @@ export async function getSerialDevices() {
return await apiGet("/devices/serial"); return await apiGet("/devices/serial");
} }
export async function setModemBeacon(enabled = false) { export async function setModemBeacon(enabled = false, afk = false) {
return await apiPost("/modem/beacon", { enabled: enabled }); return await apiPost("/modem/beacon", { enabled: enabled, afk: afk});
} }
export async function sendModemCQ() { export async function sendModemCQ() {

View file

@ -30,8 +30,11 @@ import {
getRemote, getRemote,
} from "../store/settingsStore.js"; } from "../store/settingsStore.js";
export function loadAllData() { export async function loadAllData() {
getModemState(); // TODO: Make this working
let stateData = await getModemState();
console.log(stateData)
getRemote(); getRemote();
getOverallHealth(); getOverallHealth();
audioStore.loadAudioDevices(); audioStore.loadAudioDevices();
@ -67,7 +70,10 @@ export function stateDispatcher(data) {
); );
stateStore.channel_busy_slot = data["channel_busy_slot"]; stateStore.channel_busy_slot = data["channel_busy_slot"];
stateStore.beacon_state = data["is_beacon_running"]; stateStore.beacon_state = data["is_beacon_running"];
stateStore.is_away_from_key = data["is_away_from_key"];
stateStore.radio_status = data["radio_status"]; stateStore.radio_status = data["radio_status"];
stateStore.frequency = data["radio_frequency"]; stateStore.frequency = data["radio_frequency"];
stateStore.mode = data["radio_mode"]; stateStore.mode = data["radio_mode"];

View file

@ -38,6 +38,7 @@ export const useStateStore = defineStore("stateStore", () => {
var arq_session_state = ref(""); var arq_session_state = ref("");
var arq_state = ref(""); var arq_state = ref("");
var beacon_state = ref(false); var beacon_state = ref(false);
var away_from_key = ref(false);
var audio_recording = ref(false); var audio_recording = ref(false);

View file

@ -18,6 +18,10 @@ class DataFrameFactory:
'CHECKSUM': 2, # Bit-position for indicating the CHECKSUM is correct or not 'CHECKSUM': 2, # Bit-position for indicating the CHECKSUM is correct or not
} }
BEACON_FLAGS = {
'AWAY_FROM_KEY': 0, # Bit-position for indicating the AWAY FROM KEY state
}
def __init__(self, config): def __init__(self, config):
self.myfullcall = f"{config['STATION']['mycall']}-{config['STATION']['myssid']}" self.myfullcall = f"{config['STATION']['mycall']}-{config['STATION']['myssid']}"
@ -51,7 +55,8 @@ class DataFrameFactory:
self.template_list[FR_TYPE.BEACON.value] = { self.template_list[FR_TYPE.BEACON.value] = {
"frame_length": self.LENGTH_SIG0_FRAME, "frame_length": self.LENGTH_SIG0_FRAME,
"origin": 6, "origin": 6,
"gridsquare": 4 "gridsquare": 4,
"flag": 1
} }
def _load_ping_templates(self): def _load_ping_templates(self):
@ -287,6 +292,15 @@ class DataFrameFactory:
# Update extracted_data with the status of each flag # Update extracted_data with the status of each flag
# get_flag returns True or False based on the bit value at the flag's position # get_flag returns True or False based on the bit value at the flag's position
extracted_data[key][flag] = helpers.get_flag(data, flag, flag_dict) extracted_data[key][flag] = helpers.get_flag(data, flag, flag_dict)
if frametype in [FR_TYPE.BEACON]:
flag_dict = self.BEACON_FLAGS
for flag in flag_dict:
# Update extracted_data with the status of each flag
# get_flag returns True or False based on the bit value at the flag's position
extracted_data[key][flag] = helpers.get_flag(data, flag, flag_dict)
else: else:
extracted_data[key] = data extracted_data[key] = data
@ -342,10 +356,16 @@ class DataFrameFactory:
} }
return self.construct(FR_TYPE.QRV, payload) return self.construct(FR_TYPE.QRV, payload)
def build_beacon(self): def build_beacon(self, flag_away_from_key = False):
flag = 0b00000000
if flag_away_from_key:
flag = helpers.set_flag(flag, 'AWAY_FROM_KEY', True, self.BEACON_FLAGS)
payload = { payload = {
"origin": helpers.callsign_to_bytes(self.myfullcall), "origin": helpers.callsign_to_bytes(self.myfullcall),
"gridsquare": helpers.encode_grid(self.mygrid) "gridsquare": helpers.encode_grid(self.mygrid),
"flag": flag.to_bytes(1, 'big'),
} }
return self.construct(FR_TYPE.BEACON, payload) return self.construct(FR_TYPE.BEACON, payload)

View file

@ -33,7 +33,7 @@ from schedule_manager import ScheduleManager
app = Flask(__name__) app = Flask(__name__)
CORS(app, resources={r"/*": {"origins": "*"}}) CORS(app, resources={r"/*": {"origins": "*"}})
sock = Sock(app) sock = Sock(app)
MODEM_VERSION = "0.15.1-alpha" MODEM_VERSION = "0.15.2-alpha"
# set config file to use # set config file to use
def set_config(): def set_config():
@ -146,14 +146,15 @@ def post_cqcqcq():
def post_beacon(): def post_beacon():
if request.method not in ['POST']: if request.method not in ['POST']:
return api_response({"info": "endpoint for controlling BEACON STATE via POST"}) return api_response({"info": "endpoint for controlling BEACON STATE via POST"})
if not isinstance(request.json['enabled'], bool) or not isinstance(request.json['afk'], bool):
if not isinstance(request.json['enabled'], bool):
api_abort(f"Incorrect value for 'enabled'. Shoud be bool.") api_abort(f"Incorrect value for 'enabled'. Shoud be bool.")
if not app.state_manager.is_modem_running: if not app.state_manager.is_modem_running:
api_abort('Modem not running', 503) api_abort('Modem not running', 503)
if not app.state_manager.is_beacon_running: if not app.state_manager.is_beacon_running:
app.state_manager.set('is_beacon_running', request.json['enabled']) app.state_manager.set('is_beacon_running', request.json['enabled'])
app.state_manager.set('is_away_from_key', request.json['afk'])
if not app.state_manager.getARQ(): if not app.state_manager.getARQ():
enqueue_tx_command(command_beacon.BeaconCommand, request.json) enqueue_tx_command(command_beacon.BeaconCommand, request.json)
else: else:

View file

@ -23,6 +23,7 @@ class StateManager:
self.setARQ(False) self.setARQ(False)
self.is_beacon_running = False self.is_beacon_running = False
self.is_away_from_key = False
# If true, any wait() call is blocking # If true, any wait() call is blocking
self.transmitting_event = threading.Event() self.transmitting_event = threading.Event()
@ -84,6 +85,7 @@ class StateManager:
"type": msgtype, "type": msgtype,
"is_modem_running": self.is_modem_running, "is_modem_running": self.is_modem_running,
"is_beacon_running": self.is_beacon_running, "is_beacon_running": self.is_beacon_running,
"is_away_from_key": self.is_away_from_key,
"radio_status": self.radio_status, "radio_status": self.radio_status,
"radio_frequency": self.radio_frequency, "radio_frequency": self.radio_frequency,
"radio_mode": self.radio_mode, "radio_mode": self.radio_mode,