Porównaj commity

...

4 Commity

5 zmienionych plików z 34 dodań i 18 usunięć

Wyświetl plik

@ -36,7 +36,7 @@ public:
// Define protocols // Define protocols
protocols.define("POCSAG", PROTOCOL_POCSAG); protocols.define("POCSAG", PROTOCOL_POCSAG);
protocols.define("FLEX", PROTOCOL_FLEX); //protocols.define("FLEX", PROTOCOL_FLEX);
// Initialize VFO with default values // Initialize VFO with default values
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 12500, 24000, 12500, 12500, true); vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 12500, 24000, 12500, 12500, true);

Wyświetl plik

@ -45,10 +45,6 @@ public:
// TODO // TODO
} }
if (ImGui::Button("Detune")) {
dsp.detune();
}
ImGui::FillWidth(); ImGui::FillWidth();
diag.draw(); diag.draw();
} }

Wyświetl plik

@ -19,7 +19,7 @@ public:
void init(dsp::stream<dsp::complex_t>* in, double samplerate, double baudrate) { void init(dsp::stream<dsp::complex_t>* in, double samplerate, double baudrate) {
// Save settings // Save settings
// TODO _samplerate = samplerate;
// Configure blocks // Configure blocks
demod.init(NULL, -4500.0, samplerate); demod.init(NULL, -4500.0, samplerate);
@ -44,8 +44,12 @@ public:
return count; return count;
} }
void detune() { void setBaudrate(double baudrate) {
recov.setOmega(9.99); assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
base_type::tempStop();
base_type::tempStart();
} }
int run() { int run() {
@ -68,4 +72,5 @@ private:
dsp::filter::FIR<float, float> fir; dsp::filter::FIR<float, float> fir;
dsp::clock_recovery::MM<float> recov; dsp::clock_recovery::MM<float> recov;
double _samplerate;
}; };

Wyświetl plik

@ -144,9 +144,7 @@ private:
_this->tryConnect(); _this->tryConnect();
} }
else if (connected && SmGui::Button("Disconnect##spectran_http_source")) { else if (connected && SmGui::Button("Disconnect##spectran_http_source")) {
_this->client->onCenterFrequencyChanged.unbind(_this->onFreqChangedId); _this->disconnect();
_this->client->onCenterFrequencyChanged.unbind(_this->onSamplerateChangedId);
_this->client->close();
} }
if (_this->running) { style::endDisabled(); } if (_this->running) { style::endDisabled(); }
@ -173,6 +171,12 @@ private:
} }
} }
void disconnect() {
client->onCenterFrequencyChanged.unbind(onFreqChangedId);
client->onSamplerateChanged.unbind(onSamplerateChangedId);
client->close();
}
void onFreqChanged(double newFreq) { void onFreqChanged(double newFreq) {
if (lastReportedFreq == newFreq) { return; } if (lastReportedFreq == newFreq) { return; }
lastReportedFreq = newFreq; lastReportedFreq = newFreq;

Wyświetl plik

@ -11,12 +11,15 @@ SpectranHTTPClient::SpectranHTTPClient(std::string host, int port, dsp::stream<d
sock = net::connect(host, port); sock = net::connect(host, port);
http = net::http::Client(sock); http = net::http::Client(sock);
// Make request // Send sttream request
net::http::RequestHeader rqhdr(net::http::METHOD_GET, "/stream?format=float32", host); net::http::RequestHeader rqhdr(net::http::METHOD_GET, "/stream?format=float32", host);
http.sendRequestHeader(rqhdr); http.sendRequestHeader(rqhdr);
// Receive for response
net::http::ResponseHeader rshdr; net::http::ResponseHeader rshdr;
http.recvResponseHeader(rshdr, 5000); http.recvResponseHeader(rshdr, 5000);
// Check the status
if (rshdr.getStatusCode() != net::http::STATUS_CODE_OK) { if (rshdr.getStatusCode() != net::http::STATUS_CODE_OK) {
flog::error("HTTP request did not return ok: {}", rshdr.getStatusString()); flog::error("HTTP request did not return ok: {}", rshdr.getStatusString());
throw std::runtime_error("HTTP request did not return ok"); throw std::runtime_error("HTTP request did not return ok");
@ -48,20 +51,29 @@ void SpectranHTTPClient::setCenterFrequency(uint64_t freq) {
auto controlSock = net::connect(host, port); auto controlSock = net::connect(host, port);
auto controlHttp = net::http::Client(controlSock); auto controlHttp = net::http::Client(controlSock);
// Make request // Encode request body
net::http::RequestHeader rqhdr(net::http::METHOD_PUT, "/control", host); net::http::RequestHeader rqhdr(net::http::METHOD_PUT, "/remoteconfig", host);
char buf[1024]; char buf[1024];
sprintf(buf, "{\"frequencyCenter\":%" PRIu64 ",\"frequencySpan\":%" PRIu64 ",\"type\":\"capture\"}", freq, _samplerate); sprintf(buf, "{\"receiverName\": \"Block_IQDemodulator_0\", \"simpleconfig\": {\"main\": {\"centerfreq\": %" PRIu64 ", \"samplerate\": %" PRIu64 ", \"spanfreq\": %" PRIu64 "}}}", freq, _samplerate, _samplerate);
std::string data = buf; std::string data = buf;
char lenBuf[16]; char lenBuf[16];
sprintf(lenBuf, "%" PRIu64, (uint64_t)data.size()); sprintf(lenBuf, "%" PRIu64, (uint64_t)data.size());
// Setup request headers
rqhdr.setField("Content-Length", lenBuf); rqhdr.setField("Content-Length", lenBuf);
// Send request
controlHttp.sendRequestHeader(rqhdr); controlHttp.sendRequestHeader(rqhdr);
controlSock->sendstr(data); controlSock->sendstr(data);
// Receive response
net::http::ResponseHeader rshdr; net::http::ResponseHeader rshdr;
controlHttp.recvResponseHeader(rshdr, 5000); 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() { void SpectranHTTPClient::worker() {
@ -101,11 +113,10 @@ void SpectranHTTPClient::worker() {
auto sampleFreqEnd = jsonData.find(',', sampleFreqBegin); auto sampleFreqEnd = jsonData.find(',', sampleFreqBegin);
std::string sampleFreqStr = jsonData.substr(sampleFreqBegin + 18, sampleFreqEnd - sampleFreqBegin - 18); std::string sampleFreqStr = jsonData.substr(sampleFreqBegin + 18, sampleFreqEnd - sampleFreqBegin - 18);
sampleFreq = std::stoll(sampleFreqStr); sampleFreq = std::stoll(sampleFreqStr);
//flog::debug("{}", jsonData);
} }
// Calculate and update center freq // Calculate and update center freq
int64_t samplerate = /* sampleFreqReceived ? sampleFreq : */(endFreq - startFreq); int64_t samplerate = sampleFreqReceived ? sampleFreq : (endFreq - startFreq);
int64_t centerFreq = round(((double)endFreq + (double)startFreq) / 2.0); int64_t centerFreq = round(((double)endFreq + (double)startFreq) / 2.0);
if (centerFreq != _centerFreq) { if (centerFreq != _centerFreq) {
flog::debug("New center freq: {}", centerFreq); flog::debug("New center freq: {}", centerFreq);