From 12f7efed326d4a5ab5356906ce1b425dc09d245a Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Thu, 4 Apr 2024 19:25:02 +0200 Subject: [PATCH] Switch spectran http source module to use the remoteconfig endpoint as per #1354 --- .../spectran_http_source/src/main.cpp | 10 ++++++--- .../src/spectran_http_client.cpp | 22 ++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/source_modules/spectran_http_source/src/main.cpp b/source_modules/spectran_http_source/src/main.cpp index 8ec621311..b9b7212f2 100644 --- a/source_modules/spectran_http_source/src/main.cpp +++ b/source_modules/spectran_http_source/src/main.cpp @@ -144,9 +144,7 @@ class SpectranHTTPSourceModule : public ModuleManager::Instance { _this->tryConnect(); } else if (connected && SmGui::Button("Disconnect##spectran_http_source")) { - _this->client->onCenterFrequencyChanged.unbind(_this->onFreqChangedId); - _this->client->onCenterFrequencyChanged.unbind(_this->onSamplerateChangedId); - _this->client->close(); + _this->disconnect(); } if (_this->running) { style::endDisabled(); } @@ -173,6 +171,12 @@ class SpectranHTTPSourceModule : public ModuleManager::Instance { } } + void disconnect() { + client->onCenterFrequencyChanged.unbind(onFreqChangedId); + client->onSamplerateChanged.unbind(onSamplerateChangedId); + client->close(); + } + void onFreqChanged(double newFreq) { if (lastReportedFreq == newFreq) { return; } lastReportedFreq = newFreq; diff --git a/source_modules/spectran_http_source/src/spectran_http_client.cpp b/source_modules/spectran_http_source/src/spectran_http_client.cpp index 3b51f2d01..323336ada 100644 --- a/source_modules/spectran_http_source/src/spectran_http_client.cpp +++ b/source_modules/spectran_http_source/src/spectran_http_client.cpp @@ -11,12 +11,15 @@ SpectranHTTPClient::SpectranHTTPClient(std::string host, int port, dsp::streamsendstr(data); + + // Receive response net::http::ResponseHeader rshdr; controlHttp.recvResponseHeader(rshdr, 5000); - flog::debug("Response: {}", rshdr.getStatusString()); + // Log error if there is one + if (rshdr.getStatusCode() < 200 || rshdr.getStatusCode() >= 300) { + flog::debug("Response: {}", rshdr.getStatusString()); + } } void SpectranHTTPClient::worker() {