[refactor](workspace): split soapysdr demod and dsp modules
Split the SoapySDR backend demod and dsp code into focused modules while keeping behavior stable, and include the resulting formatting updates. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -337,7 +337,9 @@ impl ClientConfig {
|
||||
}
|
||||
if let Some(rig_id) = &self.frontends.http.default_rig_id {
|
||||
if rig_id.trim().is_empty() {
|
||||
return Err("[frontends.http].default_rig_id must not be empty when set".to_string());
|
||||
return Err(
|
||||
"[frontends.http].default_rig_id must not be empty when set".to_string()
|
||||
);
|
||||
}
|
||||
}
|
||||
if self.frontends.rigctl.enabled && self.frontends.rigctl.rig_ports.is_empty() {
|
||||
|
||||
@@ -353,8 +353,7 @@ async fn async_init() -> DynResult<AppState> {
|
||||
first = false;
|
||||
}
|
||||
// Proxy channel: inject rig_id_override before forwarding to main tx.
|
||||
let (proxy_tx, mut proxy_rx) =
|
||||
mpsc::channel::<RigRequest>(RIG_TASK_CHANNEL_BUFFER);
|
||||
let (proxy_tx, mut proxy_rx) = mpsc::channel::<RigRequest>(RIG_TASK_CHANNEL_BUFFER);
|
||||
let main_tx = tx.clone();
|
||||
let rig_id_owned = rig_id.clone();
|
||||
tokio::spawn(async move {
|
||||
|
||||
@@ -250,16 +250,25 @@ async fn send_command_no_state_update(
|
||||
writer.write_all(format!("{}\n", payload).as_bytes()),
|
||||
)
|
||||
.await
|
||||
.map_err(|_| RigError::communication(format!("write timed out after {:?}", SPECTRUM_IO_TIMEOUT)))?
|
||||
.map_err(|_| {
|
||||
RigError::communication(format!("write timed out after {:?}", SPECTRUM_IO_TIMEOUT))
|
||||
})?
|
||||
.map_err(|e| RigError::communication(format!("write failed: {e}")))?;
|
||||
time::timeout(SPECTRUM_IO_TIMEOUT, writer.flush())
|
||||
.await
|
||||
.map_err(|_| RigError::communication(format!("flush timed out after {:?}", SPECTRUM_IO_TIMEOUT)))?
|
||||
.map_err(|_| {
|
||||
RigError::communication(format!("flush timed out after {:?}", SPECTRUM_IO_TIMEOUT))
|
||||
})?
|
||||
.map_err(|e| RigError::communication(format!("flush failed: {e}")))?;
|
||||
let line = time::timeout(SPECTRUM_IO_TIMEOUT, read_limited_line(reader, MAX_JSON_LINE_BYTES))
|
||||
.await
|
||||
.map_err(|_| RigError::communication(format!("read timed out after {:?}", SPECTRUM_IO_TIMEOUT)))?
|
||||
.map_err(|e| RigError::communication(format!("read failed: {e}")))?;
|
||||
let line = time::timeout(
|
||||
SPECTRUM_IO_TIMEOUT,
|
||||
read_limited_line(reader, MAX_JSON_LINE_BYTES),
|
||||
)
|
||||
.await
|
||||
.map_err(|_| {
|
||||
RigError::communication(format!("read timed out after {:?}", SPECTRUM_IO_TIMEOUT))
|
||||
})?
|
||||
.map_err(|e| RigError::communication(format!("read failed: {e}")))?;
|
||||
let line = line.ok_or_else(|| RigError::communication("connection closed by remote"))?;
|
||||
let resp: ClientResponse = serde_json::from_str(line.trim_end())
|
||||
.map_err(|e| RigError::communication(format!("invalid response: {e}")))?;
|
||||
@@ -386,7 +395,12 @@ fn should_poll_spectrum(config: &RemoteClientConfig) -> bool {
|
||||
.known_rigs
|
||||
.lock()
|
||||
.ok()
|
||||
.and_then(|entries| entries.iter().find(|entry| entry.rig_id == selected).cloned())
|
||||
.and_then(|entries| {
|
||||
entries
|
||||
.iter()
|
||||
.find(|entry| entry.rig_id == selected)
|
||||
.cloned()
|
||||
})
|
||||
.map(|entry| entry.state.initialized)
|
||||
.unwrap_or(true)
|
||||
}
|
||||
|
||||
@@ -89,7 +89,10 @@ fn inject_frontend_meta(json: &str, meta: FrontendMeta) -> String {
|
||||
serde_json::to_string(&value).unwrap_or_else(|_| json.to_string())
|
||||
}
|
||||
|
||||
fn frontend_meta_from_context(http_clients: usize, context: &FrontendRuntimeContext) -> FrontendMeta {
|
||||
fn frontend_meta_from_context(
|
||||
http_clients: usize,
|
||||
context: &FrontendRuntimeContext,
|
||||
) -> FrontendMeta {
|
||||
FrontendMeta {
|
||||
http_clients,
|
||||
rigctl_clients: context.rigctl_clients.load(Ordering::Relaxed),
|
||||
@@ -314,11 +317,7 @@ pub async fn spectrum(
|
||||
IntervalStream::new(time::interval(Duration::from_millis(40))).filter_map(move |_| {
|
||||
let context = context_updates.clone();
|
||||
std::future::ready({
|
||||
let next = context
|
||||
.spectrum
|
||||
.lock()
|
||||
.ok()
|
||||
.map(|g| g.snapshot());
|
||||
let next = context.spectrum.lock().ok().map(|g| g.snapshot());
|
||||
|
||||
let payload = match next {
|
||||
Some((revision, _frame)) if last_revision == Some(revision) => None,
|
||||
|
||||
Reference in New Issue
Block a user