2020-12-23 16:48:54 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Created on Wed Dec 23 11:13:57 2020
|
|
|
|
|
2021-01-06 12:17:17 +00:00
|
|
|
@author: DJ2LS
|
2021-09-27 15:33:59 +00:00
|
|
|
Here we are saving application wide variables and stats, which have to be accessed everywhere.
|
2020-12-23 16:48:54 +00:00
|
|
|
"""
|
2022-02-08 14:27:34 +00:00
|
|
|
|
2023-04-26 16:23:49 +00:00
|
|
|
from dataclasses import dataclass, field
|
|
|
|
from typing import List
|
2022-05-28 02:17:15 +00:00
|
|
|
import subprocess
|
2022-06-19 12:33:10 +00:00
|
|
|
from enum import Enum
|
2023-04-27 19:43:56 +00:00
|
|
|
|
2021-02-24 15:47:52 +00:00
|
|
|
|
2022-05-23 11:11:16 +00:00
|
|
|
# CHANNEL_STATE = 'RECEIVING_SIGNALLING'
|
2022-05-28 02:17:15 +00:00
|
|
|
# disconnected, connecting, connected, disconnecting, failed
|
2023-04-27 19:43:56 +00:00
|
|
|
# ------- RX BUFFER
|
2021-09-27 15:33:59 +00:00
|
|
|
|
2023-04-27 19:43:56 +00:00
|
|
|
@dataclass
|
|
|
|
class ARQ:
|
|
|
|
bytes_per_minute: int = 0
|
|
|
|
arq_transmission_percent: int = 0
|
|
|
|
arq_compression_factor: int = 0
|
|
|
|
arq_speed_level: int = 0
|
|
|
|
arq_bits_per_second_burst: int = 0
|
|
|
|
arq_bits_per_second: int = 0
|
|
|
|
arq_seconds_until_finish: int = 0
|
2023-09-30 18:29:55 +00:00
|
|
|
arq_seconds_until_timeout: int = 0
|
2023-04-27 19:43:56 +00:00
|
|
|
rx_buffer_size: int = 16
|
|
|
|
rx_frame_buffer: bytes = b""
|
2023-05-07 08:50:59 +00:00
|
|
|
rx_burst_buffer = []
|
|
|
|
arq_session_state: str = "disconnected" # can be: disconnected, disconnecting, connected, connecting, failed
|
2023-04-27 19:43:56 +00:00
|
|
|
arq_session: bool = False
|
|
|
|
arq_state: bool = False
|
|
|
|
# ARQ PROTOCOL VERSION
|
|
|
|
# v.5 - signalling frame uses datac0
|
|
|
|
# v.6 - signalling frame uses datac13
|
2023-10-08 19:09:30 +00:00
|
|
|
# v.7 - adjusting ARQ timeouts, not done yet
|
2023-09-30 18:29:55 +00:00
|
|
|
arq_protocol_version: int = 7
|
2023-04-27 19:43:56 +00:00
|
|
|
total_bytes: int = 0
|
|
|
|
speed_list = []
|
|
|
|
# set save to folder state for allowing downloading files to local file system
|
|
|
|
arq_save_to_folder: bool = False
|
|
|
|
bytes_per_minute_burst: int = 0
|
|
|
|
rx_msg_buffer = []
|
2021-09-26 15:51:11 +00:00
|
|
|
|
2020-12-26 10:02:14 +00:00
|
|
|
|
2023-04-27 19:43:56 +00:00
|
|
|
@dataclass
|
|
|
|
class AudioParam:
|
|
|
|
tx_audio_level: int = 50
|
|
|
|
audio_input_devices = []
|
|
|
|
audio_output_devices = []
|
|
|
|
audio_input_device: int = -2
|
|
|
|
audio_output_device: int = -2
|
|
|
|
audio_record: bool = False
|
|
|
|
audio_record_file = ''
|
2023-05-04 16:56:36 +00:00
|
|
|
buffer_overflow_counter = [0, 0, 0, 0, 0]
|
2023-04-27 19:43:56 +00:00
|
|
|
audio_auto_tune: bool = False
|
|
|
|
audio_dbfs: int = 0
|
|
|
|
fft = []
|
|
|
|
enable_fft: bool = True
|
2021-10-07 19:04:23 +00:00
|
|
|
|
2022-03-19 11:42:10 +00:00
|
|
|
|
2023-04-27 19:43:56 +00:00
|
|
|
@dataclass
|
|
|
|
class Beacon:
|
|
|
|
beacon_state: bool = False
|
|
|
|
beacon_pause: bool = False
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Channel:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Daemon:
|
2023-10-20 12:12:20 +00:00
|
|
|
modemprocess: subprocess.Popen
|
2023-10-08 19:09:30 +00:00
|
|
|
rigctldprocess: subprocess.Popen
|
2023-10-20 12:12:20 +00:00
|
|
|
modemstarted: bool = False
|
2023-10-08 19:09:30 +00:00
|
|
|
rigctldstarted: bool = False
|
2023-04-27 19:43:56 +00:00
|
|
|
port: int = 3001
|
|
|
|
serial_devices = []
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class HamlibParam:
|
|
|
|
alc: int = 0
|
|
|
|
hamlib_frequency: int = 0
|
|
|
|
hamlib_strength: int = 0
|
|
|
|
hamlib_radiocontrol: str = "disabled"
|
|
|
|
hamlib_rigctld_ip: str = "127.0.0.1"
|
|
|
|
hamlib_rigctld_port: str = "4532"
|
|
|
|
ptt_state: bool = False
|
|
|
|
hamlib_bandwidth: int = 0
|
|
|
|
hamlib_status: str = "unknown/disconnected"
|
|
|
|
hamlib_mode: str = ""
|
|
|
|
hamlib_rf: int = 0
|
|
|
|
|
2023-05-24 07:00:54 +00:00
|
|
|
@dataclass
|
|
|
|
class MeshParam:
|
|
|
|
routing_table = []
|
2023-05-28 15:33:24 +00:00
|
|
|
enable_protocol = False
|
2023-05-24 07:00:54 +00:00
|
|
|
@dataclass
|
2023-04-27 19:43:56 +00:00
|
|
|
class ModemParam:
|
|
|
|
tuning_range_fmin: float = -50.0
|
|
|
|
tuning_range_fmax: float = 50.0
|
|
|
|
channel_busy: bool = False
|
|
|
|
channel_busy_slot = [False] * 5
|
|
|
|
snr: float = 0
|
|
|
|
is_codec2_traffic: bool = False # true if we have codec2 signalling mode traffic on channel
|
|
|
|
frequency_offset: float = 0
|
|
|
|
tx_delay: int = 0 # delay in ms before sending modulation for triggering VOX for example or slow PTT radios
|
|
|
|
enable_scatter: bool = False
|
|
|
|
scatter = []
|
2023-08-27 03:15:22 +00:00
|
|
|
channel_busy_delay = 0
|
2023-04-27 19:43:56 +00:00
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Station:
|
|
|
|
mycallsign: bytes = b"AA0AA"
|
|
|
|
mycallsign_crc: bytes = b"A"
|
|
|
|
dxcallsign: bytes = b"ZZ9YY"
|
|
|
|
dxcallsign_crc: bytes = b"A"
|
|
|
|
mygrid: bytes = b""
|
|
|
|
dxgrid: bytes = b""
|
2023-04-28 10:40:33 +00:00
|
|
|
ssid_list = [] # ssid list we are responding to
|
2023-04-27 19:43:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Statistics:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class TCIParam:
|
|
|
|
ip: str = '127.0.0.1'
|
|
|
|
port: int = '9000'
|
|
|
|
|
|
|
|
@dataclass
|
2023-10-20 12:12:20 +00:00
|
|
|
class Modem:
|
2023-09-05 17:35:54 +00:00
|
|
|
version = "0.11.0-alpha.1-vuejs"
|
2023-04-27 19:43:56 +00:00
|
|
|
host: str = "0.0.0.0"
|
|
|
|
port: int = 3000
|
|
|
|
SOCKET_TIMEOUT: int = 1 # seconds
|
2023-10-20 12:12:20 +00:00
|
|
|
modem_state: str = "IDLE"
|
2023-04-27 19:43:56 +00:00
|
|
|
enable_explorer = False
|
|
|
|
enable_stats = False
|
|
|
|
transmitting: bool = False
|
|
|
|
low_bandwidth_mode: bool = False
|
|
|
|
enable_fsk: bool = False
|
2023-05-04 13:57:20 +00:00
|
|
|
respond_to_cq: bool = True
|
2023-04-27 19:43:56 +00:00
|
|
|
respond_to_call: bool = True # respond to cq, ping, connection request, file request if not in session
|
|
|
|
heard_stations = []
|
|
|
|
listen: bool = True
|
2023-08-19 08:42:53 +00:00
|
|
|
enable_hmac: bool = True
|
2023-04-27 19:43:56 +00:00
|
|
|
|
|
|
|
# ------------
|
2023-04-26 13:25:33 +00:00
|
|
|
|
2022-06-19 12:33:10 +00:00
|
|
|
|
|
|
|
class FRAME_TYPE(Enum):
|
|
|
|
"""Lookup for frame types"""
|
|
|
|
|
|
|
|
BURST_01 = 10
|
2023-04-25 13:46:17 +00:00
|
|
|
BURST_02 = 11
|
|
|
|
BURST_03 = 12
|
|
|
|
BURST_04 = 13
|
2022-06-21 22:33:55 +00:00
|
|
|
# ...
|
|
|
|
BURST_51 = 50
|
2022-06-24 13:48:50 +00:00
|
|
|
BURST_ACK = 60
|
2022-06-19 12:33:10 +00:00
|
|
|
FR_ACK = 61
|
|
|
|
FR_REPEAT = 62
|
|
|
|
FR_NACK = 63
|
|
|
|
BURST_NACK = 64
|
2023-05-26 12:25:48 +00:00
|
|
|
MESH_BROADCAST = 100
|
2023-06-11 07:12:40 +00:00
|
|
|
MESH_SIGNALLING_PING = 101
|
2023-06-13 12:03:36 +00:00
|
|
|
MESH_SIGNALLING_PING_ACK = 102
|
2022-06-19 12:33:10 +00:00
|
|
|
CQ = 200
|
|
|
|
QRV = 201
|
|
|
|
PING = 210
|
|
|
|
PING_ACK = 211
|
2023-02-12 17:24:42 +00:00
|
|
|
IS_WRITING = 215
|
2022-06-19 12:33:10 +00:00
|
|
|
ARQ_SESSION_OPEN = 221
|
|
|
|
ARQ_SESSION_HB = 222
|
|
|
|
ARQ_SESSION_CLOSE = 223
|
|
|
|
ARQ_DC_OPEN_W = 225
|
|
|
|
ARQ_DC_OPEN_ACK_W = 226
|
|
|
|
ARQ_DC_OPEN_N = 227
|
|
|
|
ARQ_DC_OPEN_ACK_N = 228
|
|
|
|
ARQ_STOP = 249
|
|
|
|
BEACON = 250
|
2023-02-12 16:39:13 +00:00
|
|
|
FEC = 251
|
2023-05-14 16:05:47 +00:00
|
|
|
FEC_WAKEUP = 252
|
2022-10-21 19:59:26 +00:00
|
|
|
IDENT = 254
|
2023-10-17 12:30:34 +00:00
|
|
|
TEST_FRAME = 255
|