diff --git a/plugins/samplesource/hackrfinput/hackrfinput.cpp b/plugins/samplesource/hackrfinput/hackrfinput.cpp index fbb0cdead..3966a2b4c 100644 --- a/plugins/samplesource/hackrfinput/hackrfinput.cpp +++ b/plugins/samplesource/hackrfinput/hackrfinput.cpp @@ -329,30 +329,27 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force) if ((m_settings.m_dcBlock != settings.m_dcBlock) || (m_settings.m_iqCorrection != settings.m_iqCorrection) || force) { - m_settings.m_dcBlock = settings.m_dcBlock; - m_settings.m_iqCorrection = settings.m_iqCorrection; - m_deviceAPI->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqCorrection); + m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection); } if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force) { - m_settings.m_devSampleRate = settings.m_devSampleRate; forwardChange = true; if (m_dev != 0) { - rc = (hackrf_error) hackrf_set_sample_rate_manual(m_dev, m_settings.m_devSampleRate, 1); + rc = (hackrf_error) hackrf_set_sample_rate_manual(m_dev, settings.m_devSampleRate, 1); if (rc != HACKRF_SUCCESS) { - qCritical("HackRFInput::applySettings: could not set sample rate TO %llu S/s: %s", m_settings.m_devSampleRate, hackrf_error_name(rc)); + qCritical("HackRFInput::applySettings: could not set sample rate TO %llu S/s: %s", settings.m_devSampleRate, hackrf_error_name(rc)); } else { if (m_hackRFThread != 0) { - qDebug("HackRFInput::applySettings: sample rate set to %llu S/s", m_settings.m_devSampleRate); - m_hackRFThread->setSamplerate(m_settings.m_devSampleRate); + qDebug("HackRFInput::applySettings: sample rate set to %llu S/s", settings.m_devSampleRate); + m_hackRFThread->setSamplerate(settings.m_devSampleRate); } } } @@ -360,19 +357,18 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force) if ((m_settings.m_log2Decim != settings.m_log2Decim) || force) { - m_settings.m_log2Decim = settings.m_log2Decim; forwardChange = true; if (m_hackRFThread != 0) { - m_hackRFThread->setLog2Decimation(m_settings.m_log2Decim); - qDebug() << "HackRFInput: set decimation to " << (1<setLog2Decimation(settings.m_log2Decim); + qDebug() << "HackRFInput: set decimation to " << (1<setFcPos((int) m_settings.m_fcPos); - qDebug() << "HackRFInput: set fc pos (enum) to " << (int) m_settings.m_fcPos; + m_hackRFThread->setFcPos((int) settings.m_fcPos); + qDebug() << "HackRFInput: set fc pos (enum) to " << (int) settings.m_fcPos; } } if ((m_settings.m_lnaGain != settings.m_lnaGain) || force) { - m_settings.m_lnaGain = settings.m_lnaGain; - if (m_dev != 0) { - rc = (hackrf_error) hackrf_set_lna_gain(m_dev, m_settings.m_lnaGain); + rc = (hackrf_error) hackrf_set_lna_gain(m_dev, settings.m_lnaGain); if(rc != HACKRF_SUCCESS) { @@ -457,18 +446,16 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force) } else { - qDebug() << "HackRFInput:applySettings: LNA gain set to " << m_settings.m_lnaGain; + qDebug() << "HackRFInput:applySettings: LNA gain set to " << settings.m_lnaGain; } } } if ((m_settings.m_vgaGain != settings.m_vgaGain) || force) { - m_settings.m_vgaGain = settings.m_vgaGain; - if (m_dev != 0) { - rc = (hackrf_error) hackrf_set_vga_gain(m_dev, m_settings.m_vgaGain); + rc = (hackrf_error) hackrf_set_vga_gain(m_dev, settings.m_vgaGain); if (rc != HACKRF_SUCCESS) { @@ -476,18 +463,16 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force) } else { - qDebug() << "HackRFInput:applySettings: VGA gain set to " << m_settings.m_vgaGain; + qDebug() << "HackRFInput:applySettings: VGA gain set to " << settings.m_vgaGain; } } } if ((m_settings.m_bandwidth != settings.m_bandwidth) || force) { - m_settings.m_bandwidth = settings.m_bandwidth; - if (m_dev != 0) { - uint32_t bw_index = hackrf_compute_baseband_filter_bw_round_down_lt(m_settings.m_bandwidth + 1); // +1 so the round down to lower than yields desired bandwidth + uint32_t bw_index = hackrf_compute_baseband_filter_bw_round_down_lt(settings.m_bandwidth + 1); // +1 so the round down to lower than yields desired bandwidth rc = (hackrf_error) hackrf_set_baseband_filter_bandwidth(m_dev, bw_index); if (rc != HACKRF_SUCCESS) @@ -496,18 +481,16 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force) } else { - qDebug() << "HackRFInput:applySettings: Baseband BW filter set to " << m_settings.m_bandwidth << " Hz"; + qDebug() << "HackRFInput:applySettings: Baseband BW filter set to " << settings.m_bandwidth << " Hz"; } } } if ((m_settings.m_biasT != settings.m_biasT) || force) { - m_settings.m_biasT = settings.m_biasT; - if (m_dev != 0) { - rc = (hackrf_error) hackrf_set_antenna_enable(m_dev, (m_settings.m_biasT ? 1 : 0)); + rc = (hackrf_error) hackrf_set_antenna_enable(m_dev, (settings.m_biasT ? 1 : 0)); if(rc != HACKRF_SUCCESS) { @@ -515,18 +498,16 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force) } else { - qDebug() << "HackRFInput:applySettings: bias tee set to " << m_settings.m_biasT; + qDebug() << "HackRFInput:applySettings: bias tee set to " << settings.m_biasT; } } } if ((m_settings.m_lnaExt != settings.m_lnaExt) || force) { - m_settings.m_lnaExt = settings.m_lnaExt; - if (m_dev != 0) { - rc = (hackrf_error) hackrf_set_amp_enable(m_dev, (m_settings.m_lnaExt ? 1 : 0)); + rc = (hackrf_error) hackrf_set_amp_enable(m_dev, (settings.m_lnaExt ? 1 : 0)); if(rc != HACKRF_SUCCESS) { @@ -534,25 +515,34 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force) } else { - qDebug() << "HackRFInput:applySettings: extra LNA set to " << m_settings.m_lnaExt; + qDebug() << "HackRFInput:applySettings: extra LNA set to " << settings.m_lnaExt; } } } if (forwardChange) { - int sampleRate = devSampleRate/(1<handleMessage(*notif); // forward to file sink m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif); } - m_settings.m_linkTxFrequency = settings.m_linkTxFrequency; + m_settings = settings; - qDebug() << "HackRFInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz" - << " device center freq: " << deviceCenterFrequency << " Hz" - << " device sample rate: " << m_settings.m_devSampleRate << "S/s" - << " Actual sample rate: " << m_settings.m_devSampleRate/(1<getVgaGain(); } - if (deviceSettingsKeys.contains("log2Interp")) { + if (deviceSettingsKeys.contains("log2Decim")) { settings.m_log2Decim = response.getHackRfInputSettings()->getLog2Decim(); } if (deviceSettingsKeys.contains("devSampleRate")) { diff --git a/sdrbase/webapi/webapirequestmapper.cpp b/sdrbase/webapi/webapirequestmapper.cpp index 4f63c2441..9f28c35e0 100644 --- a/sdrbase/webapi/webapirequestmapper.cpp +++ b/sdrbase/webapi/webapirequestmapper.cpp @@ -643,7 +643,7 @@ void WebAPIRequestMapper::instancePresetFileService(qtwebapp::HttpRequest& reque } else { - response.setStatus(400,"Invalid JSON query"); + response.setStatus(400,"Invalid JSON request"); errorResponse.init(); *errorResponse.getMessage() = "Invalid JSON request"; response.write(errorResponse.asJson().toUtf8()); @@ -653,7 +653,7 @@ void WebAPIRequestMapper::instancePresetFileService(qtwebapp::HttpRequest& reque { response.setStatus(400,"Invalid JSON format"); errorResponse.init(); - *errorResponse.getMessage() = "Invalid JSON request"; + *errorResponse.getMessage() = "Invalid JSON format"; response.write(errorResponse.asJson().toUtf8()); } } @@ -681,7 +681,7 @@ void WebAPIRequestMapper::instancePresetFileService(qtwebapp::HttpRequest& reque } else { - response.setStatus(400,"Invalid JSON query"); + response.setStatus(400,"Invalid JSON request"); errorResponse.init(); *errorResponse.getMessage() = "Invalid JSON request"; response.write(errorResponse.asJson().toUtf8()); @@ -691,7 +691,7 @@ void WebAPIRequestMapper::instancePresetFileService(qtwebapp::HttpRequest& reque { response.setStatus(400,"Invalid JSON format"); errorResponse.init(); - *errorResponse.getMessage() = "Invalid JSON request"; + *errorResponse.getMessage() = "Invalid JSON format"; response.write(errorResponse.asJson().toUtf8()); } } @@ -1389,9 +1389,9 @@ bool WebAPIRequestMapper::validateDeviceSettings( } else if ((*deviceHwType == "HackRF") && (deviceSettings.getTx() == 0)) { - if (jsonObject.contains("HackRFInputSettings") && jsonObject["HackRFInputSettings"].isObject()) + if (jsonObject.contains("hackRFInputSettings") && jsonObject["hackRFInputSettings"].isObject()) { - QJsonObject hackRFInputSettingsJsonObject = jsonObject["HackRFInputSettings"].toObject(); + QJsonObject hackRFInputSettingsJsonObject = jsonObject["hackRFInputSettings"].toObject(); deviceSettingsKeys = hackRFInputSettingsJsonObject.keys(); deviceSettings.setHackRfInputSettings(new SWGSDRangel::SWGHackRFInputSettings()); deviceSettings.getHackRfInputSettings()->fromJsonObject(hackRFInputSettingsJsonObject); @@ -1404,9 +1404,9 @@ bool WebAPIRequestMapper::validateDeviceSettings( } else if ((*deviceHwType == "HackRF") && (deviceSettings.getTx() != 0)) { - if (jsonObject.contains("HackRFOutputSettings") && jsonObject["HackRFOutputSettings"].isObject()) + if (jsonObject.contains("hackRFOutputSettings") && jsonObject["hackRFOutputSettings"].isObject()) { - QJsonObject hackRFOutputSettingsJsonObject = jsonObject["HackRFOutputSettings"].toObject(); + QJsonObject hackRFOutputSettingsJsonObject = jsonObject["hackRFOutputSettings"].toObject(); deviceSettingsKeys = hackRFOutputSettingsJsonObject.keys(); deviceSettings.setHackRfOutputSettings(new SWGSDRangel::SWGHackRFOutputSettings()); deviceSettings.getHackRfOutputSettings()->fromJsonObject(hackRFOutputSettingsJsonObject); @@ -1547,9 +1547,11 @@ void WebAPIRequestMapper::resetDeviceSettings(SWGSDRangel::SWGDeviceSettings& de deviceSettings.cleanup(); deviceSettings.setDeviceHwType(0); deviceSettings.setFileSourceSettings(0); - deviceSettings.setRtlSdrSettings(0); + deviceSettings.setHackRfInputSettings(0); + deviceSettings.setHackRfOutputSettings(0); deviceSettings.setLimeSdrInputSettings(0); deviceSettings.setLimeSdrOutputSettings(0); + deviceSettings.setRtlSdrSettings(0); } void WebAPIRequestMapper::resetChannelSettings(SWGSDRangel::SWGChannelSettings& channelSettings) diff --git a/swagger/sdrangel/examples/rx_test.py b/swagger/sdrangel/examples/rx_test.py index 76c86ff9c..31b68295f 100644 --- a/swagger/sdrangel/examples/rx_test.py +++ b/swagger/sdrangel/examples/rx_test.py @@ -107,6 +107,15 @@ def main(): settings['rtlSdrSettings']['log2Decim'] = 4 settings['rtlSdrSettings']['dcBlock'] = 1 settings['rtlSdrSettings']['agc'] = 1 + elif options.device_hwid == "HackRF": + settings['hackRFInputSettings']['LOppmTenths'] = -51 + settings['hackRFInputSettings']['centerFrequency'] = options.device_freq + settings['hackRFInputSettings']['dcBlock'] = 1 + settings['hackRFInputSettings']['devSampleRate'] = 2600000 + settings['hackRFInputSettings']['lnaExt'] = 1 + settings['hackRFInputSettings']['lnaGain'] = 32 + settings['hackRFInputSettings']['log2Decim'] = 4 + settings['hackRFInputSettings']['vgaGain'] = 24 r = callAPI(deviceset_url + "/device/settings", "PATCH", None, settings, "Patch device settings") if r is None: