From 2c72e885ec8c51623a57211a7eba02e006f98a7e Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 30 Jul 2019 13:12:15 +0200 Subject: [PATCH] CW keyer keyboard input: REST API updates. Make sure that in iambic mode complete dots and dashes are generated --- plugins/channeltx/modam/ammod.cpp | 41 +------ plugins/channeltx/modfreedv/freedvmod.cpp | 41 +------ plugins/channeltx/modnfm/nfmmod.cpp | 39 +------ plugins/channeltx/modssb/ssbmod.cpp | 41 +------ plugins/channeltx/modwfm/wfmmod.cpp | 41 +------ sdrbase/dsp/cwkeyer.cpp | 64 ++++++++++- sdrbase/dsp/cwkeyer.h | 12 ++ sdrbase/resources/webapi/doc/html2/index.html | 31 +++++- .../webapi/doc/swagger/include/CWKeyer.yaml | 18 +++ .../sdrangel/api/swagger/include/CWKeyer.yaml | 18 +++ swagger/sdrangel/code/html2/index.html | 31 +++++- .../code/qt5/client/SWGCWKeyerSettings.cpp | 105 ++++++++++++++++++ .../code/qt5/client/SWGCWKeyerSettings.h | 30 +++++ 13 files changed, 319 insertions(+), 193 deletions(-) diff --git a/plugins/channeltx/modam/ammod.cpp b/plugins/channeltx/modam/ammod.cpp index 7642227b6..25ef96453 100644 --- a/plugins/channeltx/modam/ammod.cpp +++ b/plugins/channeltx/modam/ammod.cpp @@ -648,22 +648,7 @@ int AMMod::webapiSettingsPutPatch( { SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getAmModSettings()->getCwKeyer(); CWKeyerSettings cwKeyerSettings = m_cwKeyer.getSettings(); - - if (channelSettingsKeys.contains("cwKeyer.loop")) { - cwKeyerSettings.m_loop = apiCwKeyerSettings->getLoop() != 0; - } - if (channelSettingsKeys.contains("cwKeyer.mode")) { - cwKeyerSettings.m_mode = (CWKeyerSettings::CWMode) apiCwKeyerSettings->getMode(); - } - if (channelSettingsKeys.contains("cwKeyer.text")) { - cwKeyerSettings.m_text = *apiCwKeyerSettings->getText(); - } - if (channelSettingsKeys.contains("cwKeyer.sampleRate")) { - cwKeyerSettings.m_sampleRate = apiCwKeyerSettings->getSampleRate(); - } - if (channelSettingsKeys.contains("cwKeyer.wpm")) { - cwKeyerSettings.m_wpm = apiCwKeyerSettings->getWpm(); - } + m_cwKeyer.webapiSettingsPutPatch(channelSettingsKeys, cwKeyerSettings, apiCwKeyerSettings); CWKeyer::MsgConfigureCWKeyer *msgCwKeyer = CWKeyer::MsgConfigureCWKeyer::create(cwKeyerSettings, force); m_cwKeyer.getInputMessageQueue()->push(msgCwKeyer); @@ -732,17 +717,7 @@ void AMMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respons SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getAmModSettings()->getCwKeyer(); const CWKeyerSettings& cwKeyerSettings = m_cwKeyer.getSettings(); - apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0); - apiCwKeyerSettings->setMode((int) cwKeyerSettings.m_mode); - apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate); - - if (apiCwKeyerSettings->getText()) { - *apiCwKeyerSettings->getText() = cwKeyerSettings.m_text; - } else { - apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text)); - } - - apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm); + m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings); if (response.getAmModSettings()->getAudioDeviceName()) { *response.getAmModSettings()->getAudioDeviceName() = settings.m_audioDeviceName; @@ -821,11 +796,7 @@ void AMMod::webapiReverseSendSettings(QList& channelSettingsKeys, const const CWKeyerSettings& cwKeyerSettings = m_cwKeyer.getSettings(); swgAMModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings()); SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgAMModSettings->getCwKeyer(); - apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0); - apiCwKeyerSettings->setMode(cwKeyerSettings.m_mode); - apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate); - apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text)); - apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm); + m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings); } QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings") @@ -857,11 +828,7 @@ void AMMod::webapiReverseSendCWSettings(const CWKeyerSettings& cwKeyerSettings) swgAMModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings()); SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgAMModSettings->getCwKeyer(); - apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0); - apiCwKeyerSettings->setMode(cwKeyerSettings.m_mode); - apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate); - apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text)); - apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm); + m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings); QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings") .arg(m_settings.m_reverseAPIAddress) diff --git a/plugins/channeltx/modfreedv/freedvmod.cpp b/plugins/channeltx/modfreedv/freedvmod.cpp index 4e5f86e36..1dcf66394 100644 --- a/plugins/channeltx/modfreedv/freedvmod.cpp +++ b/plugins/channeltx/modfreedv/freedvmod.cpp @@ -913,22 +913,7 @@ int FreeDVMod::webapiSettingsPutPatch( { SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getFreeDvModSettings()->getCwKeyer(); CWKeyerSettings cwKeyerSettings = m_cwKeyer.getSettings(); - - if (channelSettingsKeys.contains("cwKeyer.loop")) { - cwKeyerSettings.m_loop = apiCwKeyerSettings->getLoop() != 0; - } - if (channelSettingsKeys.contains("cwKeyer.mode")) { - cwKeyerSettings.m_mode = (CWKeyerSettings::CWMode) apiCwKeyerSettings->getMode(); - } - if (channelSettingsKeys.contains("cwKeyer.text")) { - cwKeyerSettings.m_text = *apiCwKeyerSettings->getText(); - } - if (channelSettingsKeys.contains("cwKeyer.sampleRate")) { - cwKeyerSettings.m_sampleRate = apiCwKeyerSettings->getSampleRate(); - } - if (channelSettingsKeys.contains("cwKeyer.wpm")) { - cwKeyerSettings.m_wpm = apiCwKeyerSettings->getWpm(); - } + m_cwKeyer.webapiSettingsPutPatch(channelSettingsKeys, cwKeyerSettings, apiCwKeyerSettings); CWKeyer::MsgConfigureCWKeyer *msgCwKeyer = CWKeyer::MsgConfigureCWKeyer::create(cwKeyerSettings, force); m_cwKeyer.getInputMessageQueue()->push(msgCwKeyer); @@ -1004,17 +989,7 @@ void FreeDVMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& res SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getFreeDvModSettings()->getCwKeyer(); const CWKeyerSettings& cwKeyerSettings = m_cwKeyer.getSettings(); - apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0); - apiCwKeyerSettings->setMode((int) cwKeyerSettings.m_mode); - apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate); - - if (apiCwKeyerSettings->getText()) { - *apiCwKeyerSettings->getText() = cwKeyerSettings.m_text; - } else { - apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text)); - } - - apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm); + m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings); response.getFreeDvModSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0); @@ -1090,11 +1065,7 @@ void FreeDVMod::webapiReverseSendSettings(QList& channelSettingsKeys, c const CWKeyerSettings& cwKeyerSettings = m_cwKeyer.getSettings(); swgFreeDVModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings()); SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgFreeDVModSettings->getCwKeyer(); - apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0); - apiCwKeyerSettings->setMode(cwKeyerSettings.m_mode); - apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate); - apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text)); - apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm); + m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings); } QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings") @@ -1126,11 +1097,7 @@ void FreeDVMod::webapiReverseSendCWSettings(const CWKeyerSettings& cwKeyerSettin swgFreeDVModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings()); SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgFreeDVModSettings->getCwKeyer(); - apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0); - apiCwKeyerSettings->setMode(cwKeyerSettings.m_mode); - apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate); - apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text)); - apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm); + m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings); QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings") .arg(m_settings.m_reverseAPIAddress) diff --git a/plugins/channeltx/modnfm/nfmmod.cpp b/plugins/channeltx/modnfm/nfmmod.cpp index 0de76052b..775517504 100644 --- a/plugins/channeltx/modnfm/nfmmod.cpp +++ b/plugins/channeltx/modnfm/nfmmod.cpp @@ -704,22 +704,7 @@ int NFMMod::webapiSettingsPutPatch( { SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getNfmModSettings()->getCwKeyer(); CWKeyerSettings cwKeyerSettings = m_cwKeyer.getSettings(); - - if (channelSettingsKeys.contains("cwKeyer.loop")) { - cwKeyerSettings.m_loop = apiCwKeyerSettings->getLoop() != 0; - } - if (channelSettingsKeys.contains("cwKeyer.mode")) { - cwKeyerSettings.m_mode = (CWKeyerSettings::CWMode) apiCwKeyerSettings->getMode(); - } - if (channelSettingsKeys.contains("cwKeyer.text")) { - cwKeyerSettings.m_text = *apiCwKeyerSettings->getText(); - } - if (channelSettingsKeys.contains("cwKeyer.sampleRate")) { - cwKeyerSettings.m_sampleRate = apiCwKeyerSettings->getSampleRate(); - } - if (channelSettingsKeys.contains("cwKeyer.wpm")) { - cwKeyerSettings.m_wpm = apiCwKeyerSettings->getWpm(); - } + m_cwKeyer.webapiSettingsPutPatch(channelSettingsKeys, cwKeyerSettings, apiCwKeyerSettings); CWKeyer::MsgConfigureCWKeyer *msgCwKeyer = CWKeyer::MsgConfigureCWKeyer::create(cwKeyerSettings, force); m_cwKeyer.getInputMessageQueue()->push(msgCwKeyer); @@ -791,15 +776,7 @@ void NFMMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getNfmModSettings()->getCwKeyer(); const CWKeyerSettings& cwKeyerSettings = m_cwKeyer.getSettings(); - apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0); - apiCwKeyerSettings->setMode((int) cwKeyerSettings.m_mode); - apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate); - - if (apiCwKeyerSettings->getText()) { - *apiCwKeyerSettings->getText() = cwKeyerSettings.m_text; - } else { - apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text)); - } + m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings); if (response.getNfmModSettings()->getAudioDeviceName()) { *response.getNfmModSettings()->getAudioDeviceName() = settings.m_audioDeviceName; @@ -889,11 +866,7 @@ void NFMMod::webapiReverseSendSettings(QList& channelSettingsKeys, cons const CWKeyerSettings& cwKeyerSettings = m_cwKeyer.getSettings(); swgNFMModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings()); SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgNFMModSettings->getCwKeyer(); - apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0); - apiCwKeyerSettings->setMode(cwKeyerSettings.m_mode); - apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate); - apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text)); - apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm); + m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings); } QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings") @@ -925,11 +898,7 @@ void NFMMod::webapiReverseSendCWSettings(const CWKeyerSettings& cwKeyerSettings) swgNFModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings()); SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgNFModSettings->getCwKeyer(); - apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0); - apiCwKeyerSettings->setMode(cwKeyerSettings.m_mode); - apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate); - apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text)); - apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm); + m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings); QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings") .arg(m_settings.m_reverseAPIAddress) diff --git a/plugins/channeltx/modssb/ssbmod.cpp b/plugins/channeltx/modssb/ssbmod.cpp index 919d8fcb3..b5d04d7ef 100644 --- a/plugins/channeltx/modssb/ssbmod.cpp +++ b/plugins/channeltx/modssb/ssbmod.cpp @@ -1000,22 +1000,7 @@ int SSBMod::webapiSettingsPutPatch( { SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getSsbModSettings()->getCwKeyer(); CWKeyerSettings cwKeyerSettings = m_cwKeyer.getSettings(); - - if (channelSettingsKeys.contains("cwKeyer.loop")) { - cwKeyerSettings.m_loop = apiCwKeyerSettings->getLoop() != 0; - } - if (channelSettingsKeys.contains("cwKeyer.mode")) { - cwKeyerSettings.m_mode = (CWKeyerSettings::CWMode) apiCwKeyerSettings->getMode(); - } - if (channelSettingsKeys.contains("cwKeyer.text")) { - cwKeyerSettings.m_text = *apiCwKeyerSettings->getText(); - } - if (channelSettingsKeys.contains("cwKeyer.sampleRate")) { - cwKeyerSettings.m_sampleRate = apiCwKeyerSettings->getSampleRate(); - } - if (channelSettingsKeys.contains("cwKeyer.wpm")) { - cwKeyerSettings.m_wpm = apiCwKeyerSettings->getWpm(); - } + m_cwKeyer.webapiSettingsPutPatch(channelSettingsKeys, cwKeyerSettings, apiCwKeyerSettings); CWKeyer::MsgConfigureCWKeyer *msgCwKeyer = CWKeyer::MsgConfigureCWKeyer::create(cwKeyerSettings, force); m_cwKeyer.getInputMessageQueue()->push(msgCwKeyer); @@ -1096,17 +1081,7 @@ void SSBMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getSsbModSettings()->getCwKeyer(); const CWKeyerSettings& cwKeyerSettings = m_cwKeyer.getSettings(); - apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0); - apiCwKeyerSettings->setMode((int) cwKeyerSettings.m_mode); - apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate); - - if (apiCwKeyerSettings->getText()) { - *apiCwKeyerSettings->getText() = cwKeyerSettings.m_text; - } else { - apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text)); - } - - apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm); + m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings); response.getSsbModSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0); @@ -1197,11 +1172,7 @@ void SSBMod::webapiReverseSendSettings(QList& channelSettingsKeys, cons const CWKeyerSettings& cwKeyerSettings = m_cwKeyer.getSettings(); swgSSBModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings()); SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgSSBModSettings->getCwKeyer(); - apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0); - apiCwKeyerSettings->setMode(cwKeyerSettings.m_mode); - apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate); - apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text)); - apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm); + m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings); } QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings") @@ -1233,11 +1204,7 @@ void SSBMod::webapiReverseSendCWSettings(const CWKeyerSettings& cwKeyerSettings) swgSSBModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings()); SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgSSBModSettings->getCwKeyer(); - apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0); - apiCwKeyerSettings->setMode(cwKeyerSettings.m_mode); - apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate); - apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text)); - apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm); + m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings); QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings") .arg(m_settings.m_reverseAPIAddress) diff --git a/plugins/channeltx/modwfm/wfmmod.cpp b/plugins/channeltx/modwfm/wfmmod.cpp index 76c9c9d78..868b7a029 100644 --- a/plugins/channeltx/modwfm/wfmmod.cpp +++ b/plugins/channeltx/modwfm/wfmmod.cpp @@ -677,22 +677,7 @@ int WFMMod::webapiSettingsPutPatch( { SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getWfmModSettings()->getCwKeyer(); CWKeyerSettings cwKeyerSettings = m_cwKeyer.getSettings(); - - if (channelSettingsKeys.contains("cwKeyer.loop")) { - cwKeyerSettings.m_loop = apiCwKeyerSettings->getLoop() != 0; - } - if (channelSettingsKeys.contains("cwKeyer.mode")) { - cwKeyerSettings.m_mode = (CWKeyerSettings::CWMode) apiCwKeyerSettings->getMode(); - } - if (channelSettingsKeys.contains("cwKeyer.text")) { - cwKeyerSettings.m_text = *apiCwKeyerSettings->getText(); - } - if (channelSettingsKeys.contains("cwKeyer.sampleRate")) { - cwKeyerSettings.m_sampleRate = apiCwKeyerSettings->getSampleRate(); - } - if (channelSettingsKeys.contains("cwKeyer.wpm")) { - cwKeyerSettings.m_wpm = apiCwKeyerSettings->getWpm(); - } + m_cwKeyer.webapiSettingsPutPatch(channelSettingsKeys, cwKeyerSettings, apiCwKeyerSettings); CWKeyer::MsgConfigureCWKeyer *msgCwKeyer = CWKeyer::MsgConfigureCWKeyer::create(cwKeyerSettings, force); m_cwKeyer.getInputMessageQueue()->push(msgCwKeyer); @@ -762,17 +747,7 @@ void WFMMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getWfmModSettings()->getCwKeyer(); const CWKeyerSettings& cwKeyerSettings = m_cwKeyer.getSettings(); - apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0); - apiCwKeyerSettings->setMode((int) cwKeyerSettings.m_mode); - apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate); - - if (apiCwKeyerSettings->getText()) { - *apiCwKeyerSettings->getText() = cwKeyerSettings.m_text; - } else { - apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text)); - } - - apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm); + m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings); if (response.getWfmModSettings()->getAudioDeviceName()) { *response.getWfmModSettings()->getAudioDeviceName() = settings.m_audioDeviceName; @@ -854,11 +829,7 @@ void WFMMod::webapiReverseSendSettings(QList& channelSettingsKeys, cons const CWKeyerSettings& cwKeyerSettings = m_cwKeyer.getSettings(); swgWFMModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings()); SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgWFMModSettings->getCwKeyer(); - apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0); - apiCwKeyerSettings->setMode(cwKeyerSettings.m_mode); - apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate); - apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text)); - apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm); + m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings); } QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings") @@ -890,11 +861,7 @@ void WFMMod::webapiReverseSendCWSettings(const CWKeyerSettings& cwKeyerSettings) swgWFMModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings()); SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgWFMModSettings->getCwKeyer(); - apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0); - apiCwKeyerSettings->setMode(cwKeyerSettings.m_mode); - apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate); - apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text)); - apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm); + m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings); QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings") .arg(m_settings.m_reverseAPIAddress) diff --git a/sdrbase/dsp/cwkeyer.cpp b/sdrbase/dsp/cwkeyer.cpp index 89f63869e..dcbc12b5b 100644 --- a/sdrbase/dsp/cwkeyer.cpp +++ b/sdrbase/dsp/cwkeyer.cpp @@ -438,7 +438,6 @@ void CWKeyer::setKeyboardSilence() { m_dot = false; m_dash = false; - m_keyIambicState = KeySilent; } CWSmoother::CWSmoother() : @@ -595,4 +594,65 @@ void CWKeyer::applySettings(const CWKeyerSettings& settings, bool force) } m_settings = settings; -} \ No newline at end of file +} + +void CWKeyer::webapiSettingsPutPatch( + const QStringList& channelSettingsKeys, + CWKeyerSettings& cwKeyerSettings, + SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings +) +{ + if (channelSettingsKeys.contains("cwKeyer.loop")) { + cwKeyerSettings.m_loop = apiCwKeyerSettings->getLoop() != 0; + } + if (channelSettingsKeys.contains("cwKeyer.mode")) { + cwKeyerSettings.m_mode = (CWKeyerSettings::CWMode) apiCwKeyerSettings->getMode(); + } + if (channelSettingsKeys.contains("cwKeyer.text")) { + cwKeyerSettings.m_text = *apiCwKeyerSettings->getText(); + } + if (channelSettingsKeys.contains("cwKeyer.sampleRate")) { + cwKeyerSettings.m_sampleRate = apiCwKeyerSettings->getSampleRate(); + } + if (channelSettingsKeys.contains("cwKeyer.wpm")) { + cwKeyerSettings.m_wpm = apiCwKeyerSettings->getWpm(); + } + if (channelSettingsKeys.contains("cwKeyer.keyboardIambic")) { + cwKeyerSettings.m_wpm = apiCwKeyerSettings->getKeyboardIambic() != 0; + } + if (channelSettingsKeys.contains("cwKeyer.dotKey")) { + cwKeyerSettings.m_dotKey = (Qt::Key) apiCwKeyerSettings->getDotKey(); + } + if (channelSettingsKeys.contains("cwKeyer.dotKeyModifiers")) { + cwKeyerSettings.m_dotKeyModifiers = (Qt::KeyboardModifiers) apiCwKeyerSettings->getDotKeyModifiers(); + } + if (channelSettingsKeys.contains("cwKeyer.dashKey")) { + cwKeyerSettings.m_dashKey = (Qt::Key) apiCwKeyerSettings->getDashKey(); + } + if (channelSettingsKeys.contains("cwKeyer.dashKeyModifiers")) { + cwKeyerSettings.m_dashKeyModifiers = (Qt::KeyboardModifiers) apiCwKeyerSettings->getDashKeyModifiers(); + } +} + +void CWKeyer::webapiFormatChannelSettings( + SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings, + const CWKeyerSettings& cwKeyerSettings +) +{ + apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0); + apiCwKeyerSettings->setMode((int) cwKeyerSettings.m_mode); + apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate); + + if (apiCwKeyerSettings->getText()) { + *apiCwKeyerSettings->getText() = cwKeyerSettings.m_text; + } else { + apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text)); + } + + apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm); + apiCwKeyerSettings->setKeyboardIambic(cwKeyerSettings.m_keyboardIambic ? 1 : 0); + apiCwKeyerSettings->setDotKey((int) cwKeyerSettings.m_dotKey); + apiCwKeyerSettings->setDotKeyModifiers((unsigned int) cwKeyerSettings.m_dotKeyModifiers); + apiCwKeyerSettings->setDashKey((int) cwKeyerSettings.m_dashKey); + apiCwKeyerSettings->setDashKeyModifiers((unsigned int) cwKeyerSettings.m_dashKeyModifiers); +} diff --git a/sdrbase/dsp/cwkeyer.h b/sdrbase/dsp/cwkeyer.h index 743e686ad..1e56dfcd7 100644 --- a/sdrbase/dsp/cwkeyer.h +++ b/sdrbase/dsp/cwkeyer.h @@ -26,6 +26,7 @@ #include "util/message.h" #include "util/messagequeue.h" #include "cwkeyersettings.h" +#include "SWGChannelSettings.h" /** * Ancillary class to smooth out CW transitions with a sine shape @@ -116,6 +117,17 @@ public: void setKeyboardDashes(); void setKeyboardSilence(); + void webapiSettingsPutPatch( + const QStringList& channelSettingsKeys, + CWKeyerSettings& cwKeyerSettings, + SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings + ); + + void webapiFormatChannelSettings( + SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings, + const CWKeyerSettings& cwKeyerSettings + ); + private: QMutex m_mutex; CWKeyerSettings m_settings; diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index a9b44b534..da5f3e609 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -1693,16 +1693,39 @@ margin-bottom: 20px; "type" : "integer" }, "wpm" : { - "type" : "integer" + "type" : "integer", + "description" : "Words Per Minute keying speed" }, "mode" : { - "type" : "integer" + "type" : "integer", + "description" : "see enum CWKeyerSettings::CWMode" }, "text" : { "type" : "string" }, "loop" : { - "type" : "integer" + "type" : "integer", + "description" : "1 to loop on text keying" + }, + "keyboardIambic" : { + "type" : "integer", + "description" : "1 for iambic input 0 for straight input using the keyboard" + }, + "dotKey" : { + "type" : "integer", + "description" : "key for dots keyboard input. See enum Qt::Key" + }, + "dotKeyModifiers" : { + "type" : "integer", + "description" : "key modifier for dots keyboard input. See flags Qt::KeyboardModifiers" + }, + "dashKey" : { + "type" : "integer", + "description" : "key for dashes keyboard input. See enum Qt::Key" + }, + "dashKeyModifiers" : { + "type" : "integer", + "description" : "key modifier for dashes keyboard input. See flags Qt::KeyboardModifiers" } } }; @@ -26341,7 +26364,7 @@ except ApiException as e:
- Generated 2019-07-25T13:46:45.997+02:00 + Generated 2019-07-30T10:33:29.454+02:00
diff --git a/sdrbase/resources/webapi/doc/swagger/include/CWKeyer.yaml b/sdrbase/resources/webapi/doc/swagger/include/CWKeyer.yaml index 62a91c792..73c98ceee 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/CWKeyer.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/CWKeyer.yaml @@ -3,10 +3,28 @@ CWKeyerSettings: sampleRate: type: integer wpm: + description: Words Per Minute keying speed type: integer mode: + description: see enum CWKeyerSettings::CWMode type: integer text: type: string loop: + description: 1 to loop on text keying + type: integer + keyboardIambic: + description: 1 for iambic input 0 for straight input using the keyboard + type: integer + dotKey: + description: key for dots keyboard input. See enum Qt::Key + type: integer + dotKeyModifiers: + description: key modifier for dots keyboard input. See flags Qt::KeyboardModifiers + type: integer + dashKey: + description: key for dashes keyboard input. See enum Qt::Key + type: integer + dashKeyModifiers: + description: key modifier for dashes keyboard input. See flags Qt::KeyboardModifiers type: integer \ No newline at end of file diff --git a/swagger/sdrangel/api/swagger/include/CWKeyer.yaml b/swagger/sdrangel/api/swagger/include/CWKeyer.yaml index 62a91c792..73c98ceee 100644 --- a/swagger/sdrangel/api/swagger/include/CWKeyer.yaml +++ b/swagger/sdrangel/api/swagger/include/CWKeyer.yaml @@ -3,10 +3,28 @@ CWKeyerSettings: sampleRate: type: integer wpm: + description: Words Per Minute keying speed type: integer mode: + description: see enum CWKeyerSettings::CWMode type: integer text: type: string loop: + description: 1 to loop on text keying + type: integer + keyboardIambic: + description: 1 for iambic input 0 for straight input using the keyboard + type: integer + dotKey: + description: key for dots keyboard input. See enum Qt::Key + type: integer + dotKeyModifiers: + description: key modifier for dots keyboard input. See flags Qt::KeyboardModifiers + type: integer + dashKey: + description: key for dashes keyboard input. See enum Qt::Key + type: integer + dashKeyModifiers: + description: key modifier for dashes keyboard input. See flags Qt::KeyboardModifiers type: integer \ No newline at end of file diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index a9b44b534..da5f3e609 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -1693,16 +1693,39 @@ margin-bottom: 20px; "type" : "integer" }, "wpm" : { - "type" : "integer" + "type" : "integer", + "description" : "Words Per Minute keying speed" }, "mode" : { - "type" : "integer" + "type" : "integer", + "description" : "see enum CWKeyerSettings::CWMode" }, "text" : { "type" : "string" }, "loop" : { - "type" : "integer" + "type" : "integer", + "description" : "1 to loop on text keying" + }, + "keyboardIambic" : { + "type" : "integer", + "description" : "1 for iambic input 0 for straight input using the keyboard" + }, + "dotKey" : { + "type" : "integer", + "description" : "key for dots keyboard input. See enum Qt::Key" + }, + "dotKeyModifiers" : { + "type" : "integer", + "description" : "key modifier for dots keyboard input. See flags Qt::KeyboardModifiers" + }, + "dashKey" : { + "type" : "integer", + "description" : "key for dashes keyboard input. See enum Qt::Key" + }, + "dashKeyModifiers" : { + "type" : "integer", + "description" : "key modifier for dashes keyboard input. See flags Qt::KeyboardModifiers" } } }; @@ -26341,7 +26364,7 @@ except ApiException as e:
- Generated 2019-07-25T13:46:45.997+02:00 + Generated 2019-07-30T10:33:29.454+02:00
diff --git a/swagger/sdrangel/code/qt5/client/SWGCWKeyerSettings.cpp b/swagger/sdrangel/code/qt5/client/SWGCWKeyerSettings.cpp index fff124070..b669dc1c7 100644 --- a/swagger/sdrangel/code/qt5/client/SWGCWKeyerSettings.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGCWKeyerSettings.cpp @@ -38,6 +38,16 @@ SWGCWKeyerSettings::SWGCWKeyerSettings() { m_text_isSet = false; loop = 0; m_loop_isSet = false; + keyboard_iambic = 0; + m_keyboard_iambic_isSet = false; + dot_key = 0; + m_dot_key_isSet = false; + dot_key_modifiers = 0; + m_dot_key_modifiers_isSet = false; + dash_key = 0; + m_dash_key_isSet = false; + dash_key_modifiers = 0; + m_dash_key_modifiers_isSet = false; } SWGCWKeyerSettings::~SWGCWKeyerSettings() { @@ -56,6 +66,16 @@ SWGCWKeyerSettings::init() { m_text_isSet = false; loop = 0; m_loop_isSet = false; + keyboard_iambic = 0; + m_keyboard_iambic_isSet = false; + dot_key = 0; + m_dot_key_isSet = false; + dot_key_modifiers = 0; + m_dot_key_modifiers_isSet = false; + dash_key = 0; + m_dash_key_isSet = false; + dash_key_modifiers = 0; + m_dash_key_modifiers_isSet = false; } void @@ -67,6 +87,11 @@ SWGCWKeyerSettings::cleanup() { delete text; } + + + + + } SWGCWKeyerSettings* @@ -90,6 +115,16 @@ SWGCWKeyerSettings::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&loop, pJson["loop"], "qint32", ""); + ::SWGSDRangel::setValue(&keyboard_iambic, pJson["keyboardIambic"], "qint32", ""); + + ::SWGSDRangel::setValue(&dot_key, pJson["dotKey"], "qint32", ""); + + ::SWGSDRangel::setValue(&dot_key_modifiers, pJson["dotKeyModifiers"], "qint32", ""); + + ::SWGSDRangel::setValue(&dash_key, pJson["dashKey"], "qint32", ""); + + ::SWGSDRangel::setValue(&dash_key_modifiers, pJson["dashKeyModifiers"], "qint32", ""); + } QString @@ -121,6 +156,21 @@ SWGCWKeyerSettings::asJsonObject() { if(m_loop_isSet){ obj->insert("loop", QJsonValue(loop)); } + if(m_keyboard_iambic_isSet){ + obj->insert("keyboardIambic", QJsonValue(keyboard_iambic)); + } + if(m_dot_key_isSet){ + obj->insert("dotKey", QJsonValue(dot_key)); + } + if(m_dot_key_modifiers_isSet){ + obj->insert("dotKeyModifiers", QJsonValue(dot_key_modifiers)); + } + if(m_dash_key_isSet){ + obj->insert("dashKey", QJsonValue(dash_key)); + } + if(m_dash_key_modifiers_isSet){ + obj->insert("dashKeyModifiers", QJsonValue(dash_key_modifiers)); + } return obj; } @@ -175,6 +225,56 @@ SWGCWKeyerSettings::setLoop(qint32 loop) { this->m_loop_isSet = true; } +qint32 +SWGCWKeyerSettings::getKeyboardIambic() { + return keyboard_iambic; +} +void +SWGCWKeyerSettings::setKeyboardIambic(qint32 keyboard_iambic) { + this->keyboard_iambic = keyboard_iambic; + this->m_keyboard_iambic_isSet = true; +} + +qint32 +SWGCWKeyerSettings::getDotKey() { + return dot_key; +} +void +SWGCWKeyerSettings::setDotKey(qint32 dot_key) { + this->dot_key = dot_key; + this->m_dot_key_isSet = true; +} + +qint32 +SWGCWKeyerSettings::getDotKeyModifiers() { + return dot_key_modifiers; +} +void +SWGCWKeyerSettings::setDotKeyModifiers(qint32 dot_key_modifiers) { + this->dot_key_modifiers = dot_key_modifiers; + this->m_dot_key_modifiers_isSet = true; +} + +qint32 +SWGCWKeyerSettings::getDashKey() { + return dash_key; +} +void +SWGCWKeyerSettings::setDashKey(qint32 dash_key) { + this->dash_key = dash_key; + this->m_dash_key_isSet = true; +} + +qint32 +SWGCWKeyerSettings::getDashKeyModifiers() { + return dash_key_modifiers; +} +void +SWGCWKeyerSettings::setDashKeyModifiers(qint32 dash_key_modifiers) { + this->dash_key_modifiers = dash_key_modifiers; + this->m_dash_key_modifiers_isSet = true; +} + bool SWGCWKeyerSettings::isSet(){ @@ -185,6 +285,11 @@ SWGCWKeyerSettings::isSet(){ if(m_mode_isSet){ isObjectUpdated = true; break;} if(text != nullptr && *text != QString("")){ isObjectUpdated = true; break;} if(m_loop_isSet){ isObjectUpdated = true; break;} + if(m_keyboard_iambic_isSet){ isObjectUpdated = true; break;} + if(m_dot_key_isSet){ isObjectUpdated = true; break;} + if(m_dot_key_modifiers_isSet){ isObjectUpdated = true; break;} + if(m_dash_key_isSet){ isObjectUpdated = true; break;} + if(m_dash_key_modifiers_isSet){ isObjectUpdated = true; break;} }while(false); return isObjectUpdated; } diff --git a/swagger/sdrangel/code/qt5/client/SWGCWKeyerSettings.h b/swagger/sdrangel/code/qt5/client/SWGCWKeyerSettings.h index f5ad3df0e..ebd298565 100644 --- a/swagger/sdrangel/code/qt5/client/SWGCWKeyerSettings.h +++ b/swagger/sdrangel/code/qt5/client/SWGCWKeyerSettings.h @@ -57,6 +57,21 @@ public: qint32 getLoop(); void setLoop(qint32 loop); + qint32 getKeyboardIambic(); + void setKeyboardIambic(qint32 keyboard_iambic); + + qint32 getDotKey(); + void setDotKey(qint32 dot_key); + + qint32 getDotKeyModifiers(); + void setDotKeyModifiers(qint32 dot_key_modifiers); + + qint32 getDashKey(); + void setDashKey(qint32 dash_key); + + qint32 getDashKeyModifiers(); + void setDashKeyModifiers(qint32 dash_key_modifiers); + virtual bool isSet() override; @@ -76,6 +91,21 @@ private: qint32 loop; bool m_loop_isSet; + qint32 keyboard_iambic; + bool m_keyboard_iambic_isSet; + + qint32 dot_key; + bool m_dot_key_isSet; + + qint32 dot_key_modifiers; + bool m_dot_key_modifiers_isSet; + + qint32 dash_key; + bool m_dash_key_isSet; + + qint32 dash_key_modifiers; + bool m_dash_key_modifiers_isSet; + }; }