LimeRFE USB support: REST API fixes

pull/480/head
f4exb 2020-01-14 01:11:31 +01:00
rodzic d83da57a1e
commit 17d109b78b
9 zmienionych plików z 37 dodań i 28 usunięć

Wyświetl plik

@ -93,10 +93,23 @@ int LimeRFEController::configure()
return -1;
}
qDebug() << "LimeRFEController::configure: "
<< "attValue: " << (int) m_rfeBoardState.attValue
<< "channelIDRX: " << (int) m_rfeBoardState.channelIDRX
<< "channelIDTX: " << (int) m_rfeBoardState.channelIDTX
<< "enableSWR: " << (int) m_rfeBoardState.enableSWR
<< "mode: " << (int) m_rfeBoardState.mode
<< "notchOnOff: " << (int) m_rfeBoardState.notchOnOff
<< "selPortRX: " << (int) m_rfeBoardState.selPortRX
<< "selPortTX: " << (int) m_rfeBoardState.selPortTX
<< "sourceSWR: " << (int) m_rfeBoardState.sourceSWR;
int rc = RFE_ConfigureState(m_rfeDevice, m_rfeBoardState);
if (rc != 0) {
qInfo("LimeRFEController::configure: %s", getError(rc).c_str());
} else {
qDebug() << "LimeRFEController::configure: done";
}
return rc;
@ -241,6 +254,11 @@ void LimeRFEController::settingsToState(const LimeRFESettings& settings)
}
else
{
m_rfeBoardState.mode = settings.m_rxOn && settings.m_txOn ?
RFE_MODE_TXRX : settings.m_rxOn ?
RFE_MODE_RX : settings.m_txOn ?
RFE_MODE_TX : RFE_MODE_NONE;
if (settings.m_rxChannels == ChannelsWideband)
{
if (settings.m_rxWidebandChannel == WidebandLow) {
@ -327,6 +345,8 @@ void LimeRFEController::settingsToState(const LimeRFESettings& settings)
m_rfeBoardState.attValue = settings.m_attenuationFactor < 0 ? 0 : settings.m_attenuationFactor > 7 ? 7 : settings.m_attenuationFactor;
m_rfeBoardState.notchOnOff = settings.m_amfmNotch;
m_rfeBoardState.enableSWR = 0; // TODO
m_rfeBoardState.sourceSWR = RFE_SWR_SRC_EXT; // TODO
}
void LimeRFEController::stateToSettings(LimeRFESettings& settings)

Wyświetl plik

@ -595,10 +595,6 @@ paths:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
"404":
description: LimeRFE device not found
schema:
$ref: "#/definitions/ErrorResponse"
"500":
$ref: "#/responses/Response_500"
"501":
@ -627,10 +623,6 @@ paths:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
"404":
description: LimeRFE device not found
schema:
$ref: "#/definitions/ErrorResponse"
"500":
$ref: "#/responses/Response_500"
"501":

Wyświetl plik

@ -461,7 +461,7 @@ public:
*/
virtual int instanceLimeRFEConfigPut(
SWGSDRangel::SWGLimeRFESettings& query,
SWGSDRangel::SWGLimeRFESettings& response,
SWGSDRangel::SWGSuccessResponse& response,
SWGSDRangel::SWGErrorResponse& error)
{
(void) query;

Wyświetl plik

@ -1011,7 +1011,7 @@ void WebAPIRequestMapper::instanceLimeRFEConfigService(qtwebapp::HttpRequest& re
else if (request.getMethod() == "PUT")
{
SWGSDRangel::SWGLimeRFESettings query;
SWGSDRangel::SWGLimeRFESettings normalResponse;
SWGSDRangel::SWGSuccessResponse normalResponse;
QString jsonStr = request.getBody();
QJsonObject jsonObject;

Wyświetl plik

@ -842,6 +842,7 @@ int WebAPIAdapterGUI::instanceLimeRFESerialGet(
SWGSDRangel::SWGErrorResponse& error)
{
(void) error;
response.init();
std::vector<std::string> comPorts;
SerialUtil::getComPorts(comPorts, "ttyUSB[0-9]+"); // regex is for Linux only
response.setNbDevices((int) comPorts.size());
@ -911,7 +912,7 @@ int WebAPIAdapterGUI::instanceLimeRFEConfigGet(
int WebAPIAdapterGUI::instanceLimeRFEConfigPut(
SWGSDRangel::SWGLimeRFESettings& query,
SWGSDRangel::SWGLimeRFESettings& response,
SWGSDRangel::SWGSuccessResponse& response,
SWGSDRangel::SWGErrorResponse& error)
{
LimeRFEController controller;
@ -931,6 +932,7 @@ int WebAPIAdapterGUI::instanceLimeRFEConfigPut(
settings.m_rxHAMChannel = (LimeRFEController::HAMChannel) query.getRxHamChannel();
settings.m_rxCellularChannel = (LimeRFEController::CellularChannel) query.getRxCellularChannel();
settings.m_rxPort = (LimeRFEController::RxPort) query.getRxPort();
settings.m_rxOn = query.getRxOn() != 0;
settings.m_amfmNotch = query.getAmfmNotch() != 0;
settings.m_attenuationFactor = query.getAttenuationFactor();
settings.m_txChannels = (LimeRFEController::ChannelGroups) query.getTxChannels();
@ -938,14 +940,12 @@ int WebAPIAdapterGUI::instanceLimeRFEConfigPut(
settings.m_txHAMChannel = (LimeRFEController::HAMChannel) query.getTxHamChannel();
settings.m_txCellularChannel = (LimeRFEController::CellularChannel) query.getTxCellularChannel();
settings.m_txPort = (LimeRFEController::TxPort) query.getTxPort();
settings.m_txOn = query.getTxOn() != 0;
controller.settingsToState(settings);
rc = controller.configure();
response.init();
response = query;
if (rc != 0)
{
error.init();
@ -954,6 +954,8 @@ int WebAPIAdapterGUI::instanceLimeRFEConfigPut(
return 500;
}
response.init();
*response.getMessage() = QString("LimeRFE device at %1 configuration updated successfully").arg(*query.getDevicePath());
return 200;
}
@ -988,6 +990,7 @@ int WebAPIAdapterGUI::instanceLimeRFERunPut(
}
response.init();
*response.getMessage() = QString("LimeRFE device at %1 mode updated successfully").arg(*query.getDevicePath());
return 200;
}
#endif

Wyświetl plik

@ -152,7 +152,7 @@ public:
virtual int instanceLimeRFEConfigPut(
SWGSDRangel::SWGLimeRFESettings& query,
SWGSDRangel::SWGLimeRFESettings& response,
SWGSDRangel::SWGSuccessResponse& response,
SWGSDRangel::SWGErrorResponse& error);
virtual int instanceLimeRFERunPut(

Wyświetl plik

@ -894,7 +894,7 @@ int WebAPIAdapterSrv::instanceLimeRFEConfigGet(
int WebAPIAdapterSrv::instanceLimeRFEConfigPut(
SWGSDRangel::SWGLimeRFESettings& query,
SWGSDRangel::SWGLimeRFESettings& response,
SWGSDRangel::SWGSuccessResponse& response,
SWGSDRangel::SWGErrorResponse& error)
{
LimeRFEController controller;
@ -914,6 +914,7 @@ int WebAPIAdapterSrv::instanceLimeRFEConfigPut(
settings.m_rxHAMChannel = (LimeRFEController::HAMChannel) query.getRxHamChannel();
settings.m_rxCellularChannel = (LimeRFEController::CellularChannel) query.getRxCellularChannel();
settings.m_rxPort = (LimeRFEController::RxPort) query.getRxPort();
settings.m_rxOn = query.getRxOn() != 0;
settings.m_amfmNotch = query.getAmfmNotch() != 0;
settings.m_attenuationFactor = query.getAttenuationFactor();
settings.m_txChannels = (LimeRFEController::ChannelGroups) query.getTxChannels();
@ -921,14 +922,12 @@ int WebAPIAdapterSrv::instanceLimeRFEConfigPut(
settings.m_txHAMChannel = (LimeRFEController::HAMChannel) query.getTxHamChannel();
settings.m_txCellularChannel = (LimeRFEController::CellularChannel) query.getTxCellularChannel();
settings.m_txPort = (LimeRFEController::TxPort) query.getTxPort();
settings.m_txOn = query.getTxOn() != 0;
controller.settingsToState(settings);
rc = controller.configure();
response.init();
response = query;
if (rc != 0)
{
error.init();
@ -937,6 +936,8 @@ int WebAPIAdapterSrv::instanceLimeRFEConfigPut(
return 500;
}
response.init();
*response.getMessage() = QString("LimeRFE device at %1 configuration updated successfully").arg(*query.getDevicePath());
return 200;
}
@ -971,6 +972,7 @@ int WebAPIAdapterSrv::instanceLimeRFERunPut(
}
response.init();
*response.getMessage() = QString("LimeRFE device at %1 mode updated successfully").arg(*query.getDevicePath());
return 200;
}
#endif

Wyświetl plik

@ -152,7 +152,7 @@ public:
virtual int instanceLimeRFEConfigPut(
SWGSDRangel::SWGLimeRFESettings& query,
SWGSDRangel::SWGLimeRFESettings& response,
SWGSDRangel::SWGSuccessResponse& response,
SWGSDRangel::SWGErrorResponse& error);
virtual int instanceLimeRFERunPut(

Wyświetl plik

@ -595,10 +595,6 @@ paths:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
"404":
description: LimeRFE device not found
schema:
$ref: "#/definitions/ErrorResponse"
"500":
$ref: "#/responses/Response_500"
"501":
@ -627,10 +623,6 @@ paths:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
"404":
description: LimeRFE device not found
schema:
$ref: "#/definitions/ErrorResponse"
"500":
$ref: "#/responses/Response_500"
"501":