Browse Source

Server: web API: implemented /sdrangel/location

chirpmodem-v8.0.0
f4exb 9 years ago
parent
commit
8aeb28f637
  1. 30
      sdrsrv/webapi/webapiadaptersrv.cpp
  2. 8
      sdrsrv/webapi/webapiadaptersrv.h

30
sdrsrv/webapi/webapiadaptersrv.cpp

@ -27,6 +27,7 @@ @@ -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( @@ -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();

8
sdrsrv/webapi/webapiadaptersrv.h

@ -66,6 +66,14 @@ public: @@ -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;

Loading…
Cancel
Save