1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-28 07:46:37 -04:00

Server: web API: implemented /sdrangel/location

This commit is contained in:
f4exb 2017-12-18 22:35:48 +01:00
parent 4884a0d13c
commit 8aeb28f637
2 changed files with 38 additions and 0 deletions

View File

@ -27,6 +27,7 @@
#include "SWGLoggingInfo.h"
#include "SWGAudioDevices.h"
#include "SWGAudioDevicesSelect.h"
#include "SWGLocationInformation.h"
#include "SWGErrorResponse.h"
#include "maincore.h"
@ -261,6 +262,35 @@ int WebAPIAdapterSrv::instanceAudioPatch(
return 200;
}
int WebAPIAdapterSrv::instanceLocationGet(
SWGSDRangel::SWGLocationInformation& response,
SWGSDRangel::SWGErrorResponse& error __attribute__((unused)))
{
response.setLatitude(m_mainCore.m_settings.getLatitude());
response.setLongitude(m_mainCore.m_settings.getLongitude());
return 200;
}
int WebAPIAdapterSrv::instanceLocationPut(
SWGSDRangel::SWGLocationInformation& response,
SWGSDRangel::SWGErrorResponse& error __attribute__((unused)))
{
float latitude = response.getLatitude();
float longitude = response.getLongitude();
latitude = latitude < -90.0 ? -90.0 : latitude > 90.0 ? 90.0 : latitude;
longitude = longitude < -180.0 ? -180.0 : longitude > 180.0 ? 180.0 : longitude;
m_mainCore.m_settings.setLatitude(latitude);
m_mainCore.m_settings.setLongitude(longitude);
response.setLatitude(m_mainCore.m_settings.getLatitude());
response.setLongitude(m_mainCore.m_settings.getLongitude());
return 200;
}
void WebAPIAdapterSrv::getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList)
{
deviceSetList->init();

View File

@ -66,6 +66,14 @@ public:
SWGSDRangel::SWGAudioDevicesSelect& response,
SWGSDRangel::SWGErrorResponse& error);
virtual int instanceLocationGet(
SWGSDRangel::SWGLocationInformation& response,
SWGSDRangel::SWGErrorResponse& error);
virtual int instanceLocationPut(
SWGSDRangel::SWGLocationInformation& response,
SWGSDRangel::SWGErrorResponse& error);
private:
MainCore& m_mainCore;