mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
WIP
This commit is contained in:
parent
2d6af962b5
commit
e8a2a5d12a
2 changed files with 29 additions and 17 deletions
|
@ -1,27 +1,39 @@
|
|||
from data_frame_factory import DataFrameFactory
|
||||
from modem.modem import RF
|
||||
import queue
|
||||
from codec2 import FREEDV_MODE
|
||||
|
||||
class TxCommand():
|
||||
|
||||
def __init__(self, apiParams):
|
||||
self.setParamsFromApi(apiParams)
|
||||
self.frame_factory = DataFrameFactory(modem)
|
||||
def __init__(self, config, logger, apiParams):
|
||||
self.config = config
|
||||
self.logger = logger
|
||||
self.set_params_from_api(apiParams)
|
||||
self.frame_factory = DataFrameFactory()
|
||||
|
||||
def setParamsFromApi(self, apiParams):
|
||||
def set_params_from_api(self, apiParams):
|
||||
pass
|
||||
|
||||
def getName(self):
|
||||
def get_name(self):
|
||||
return type(self).__name__
|
||||
|
||||
def getPayload(self):
|
||||
def emit_event(self):
|
||||
pass
|
||||
|
||||
def execute(self, modem_state, tx_frame_queue):
|
||||
def log_message(self):
|
||||
return f"TX Command {self.get_name()}"
|
||||
|
||||
def build_frame(self):
|
||||
pass
|
||||
|
||||
def transmit(self, frame):
|
||||
# MODEM_TRANSMIT_QUEUE.put([c2_mode, copies, repeat_delay, frame_to_tx])
|
||||
def transmit(self, tx_frame_queue):
|
||||
frame = self.build_frame()
|
||||
c2_mode = FREEDV_MODE.fsk_ldpc_0.value if self.config.enable_fsk else FREEDV_MODE.sig0.value
|
||||
tx_queue_item = [c2_mode, 1, 0, frame]
|
||||
tx_frame_queue.put(tx_queue_item)
|
||||
|
||||
self.modem.modem_transmit_queue.put(
|
||||
|
||||
)
|
||||
def run(self, tx_frame_queue: queue.Queue):
|
||||
self.emit_event()
|
||||
self.logger.info(self.log_message)
|
||||
self.transmit(tx_frame_queue)
|
||||
pass
|
||||
|
|
|
@ -12,8 +12,8 @@ import state_manager
|
|||
import ujson as json
|
||||
import websocket_manager as wsm
|
||||
import api_validations as validations
|
||||
from tx_command.tx_command import TxCommand
|
||||
from tx_command.ping_command import PingCommand
|
||||
from command import TxCommand
|
||||
from command_ping import PingCommand
|
||||
from queues import DATA_QUEUE_TRANSMIT as tx_cmd_queue
|
||||
|
||||
app = Flask(__name__)
|
||||
|
@ -77,9 +77,9 @@ def validate(req, param, validator, isRequired = True):
|
|||
|
||||
# Takes a transmit command and puts it in the transmit command queue
|
||||
def enqueue_tx_command(cmd_class, params = {}):
|
||||
command = cmd_class(service_manager.modem, params)
|
||||
command = cmd_class(app.config, app.logger, params)
|
||||
tx_cmd_queue.put(command)
|
||||
app.logger.info(f"Command {type(command).__name__} enqueued.")
|
||||
app.logger.info(f"Command {command.get_name()} enqueued.")
|
||||
|
||||
## REST API
|
||||
@app.route('/', methods=['GET'])
|
||||
|
|
Loading…
Reference in a new issue