Merge "SystemStatus - initial release"
This commit is contained in:
commit
adb88a7ffb
8 changed files with 1749 additions and 12 deletions
|
@ -30,7 +30,8 @@ LOCAL_SRC_FILES += \
|
|||
LocAdapterBase.cpp \
|
||||
ContextBase.cpp \
|
||||
LocDualContext.cpp \
|
||||
loc_core_log.cpp
|
||||
loc_core_log.cpp \
|
||||
SystemStatus.cpp
|
||||
|
||||
LOCAL_CFLAGS += \
|
||||
-fno-short-enums \
|
||||
|
@ -53,7 +54,8 @@ LOCAL_COPY_HEADERS:= \
|
|||
gps_extended_c.h \
|
||||
gps_extended.h \
|
||||
loc_core_log.h \
|
||||
LocAdapterProxyBase.h
|
||||
LocAdapterProxyBase.h \
|
||||
SystemStatus.h
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <msg_q.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <loc_log.h>
|
||||
#include <SystemStatus.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
||||
|
@ -56,6 +57,7 @@ const MsgTask* LocDualContext::mMsgTask = NULL;
|
|||
ContextBase* LocDualContext::mFgContext = NULL;
|
||||
ContextBase* LocDualContext::mBgContext = NULL;
|
||||
ContextBase* LocDualContext::mInjectContext = NULL;
|
||||
SystemStatus* LocDualContext::mSystemStatus = NULL;
|
||||
// the name must be shorter than 15 chars
|
||||
const char* LocDualContext::mLocationHalName = "Loc_hal_worker";
|
||||
#ifndef USE_GLIB
|
||||
|
@ -147,4 +149,14 @@ LocDualContext::LocDualContext(const MsgTask* msgTask,
|
|||
{
|
||||
}
|
||||
|
||||
SystemStatus* LocDualContext::getSystemStatus(void)
|
||||
{
|
||||
pthread_mutex_lock(&LocDualContext::mGetLocContextMutex);
|
||||
if (NULL == mSystemStatus) {
|
||||
mSystemStatus = new SystemStatus();
|
||||
}
|
||||
pthread_mutex_unlock(&LocDualContext::mGetLocContextMutex);
|
||||
return mSystemStatus;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2011-2014, 2017 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -36,6 +36,8 @@
|
|||
|
||||
namespace loc_core {
|
||||
|
||||
class SystemStatus;
|
||||
|
||||
class LocDualContext : public ContextBase {
|
||||
static const MsgTask* mMsgTask;
|
||||
static ContextBase* mFgContext;
|
||||
|
@ -45,6 +47,7 @@ class LocDualContext : public ContextBase {
|
|||
const char* name, bool joinable = true);
|
||||
static const MsgTask* getMsgTask(const char* name, bool joinable = true);
|
||||
static pthread_mutex_t mGetLocContextMutex;
|
||||
static SystemStatus* mSystemStatus;
|
||||
|
||||
protected:
|
||||
LocDualContext(const MsgTask* msgTask,
|
||||
|
@ -69,6 +72,7 @@ public:
|
|||
}
|
||||
|
||||
static void injectFeatureConfig(ContextBase *context);
|
||||
static SystemStatus* getSystemStatus(void);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -16,14 +16,16 @@ libloc_core_la_h_sources = \
|
|||
gps_extended_c.h \
|
||||
gps_extended.h \
|
||||
loc_core_log.h \
|
||||
LocAdapterProxyBase.h
|
||||
LocAdapterProxyBase.h \
|
||||
SystemStatus.h
|
||||
|
||||
libloc_core_la_c_sources = \
|
||||
LocApiBase.cpp \
|
||||
LocAdapterBase.cpp \
|
||||
ContextBase.cpp \
|
||||
LocDualContext.cpp \
|
||||
loc_core_log.cpp
|
||||
loc_core_log.cpp \
|
||||
SystemStatus.cpp
|
||||
|
||||
library_includedir = $(pkgincludedir)/core
|
||||
|
||||
|
|
1425
core/SystemStatus.cpp
Normal file
1425
core/SystemStatus.cpp
Normal file
File diff suppressed because it is too large
Load diff
275
core/SystemStatus.h
Normal file
275
core/SystemStatus.h
Normal file
|
@ -0,0 +1,275 @@
|
|||
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef __SYSTEM_STATUS__
|
||||
#define __SYSTEM_STATUS__
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
|
||||
/******************************************************************************
|
||||
SystemStatus report data structure
|
||||
******************************************************************************/
|
||||
class SystemStatusItemBase
|
||||
{
|
||||
public:
|
||||
timespec mUtcTime;
|
||||
SystemStatusItemBase(timespec utctime) : mUtcTime(utctime) { };
|
||||
virtual ~SystemStatusItemBase() { };
|
||||
virtual void dump(void) { };
|
||||
};
|
||||
|
||||
class SystemStatusPQWM1;
|
||||
class SystemStatusTimeAndClock : public SystemStatusItemBase
|
||||
{
|
||||
public:
|
||||
uint16_t mGpsWeek;
|
||||
uint32_t mGpsTowMs;
|
||||
uint8_t mTimeValid;
|
||||
uint8_t mTimeSource;
|
||||
int32_t mTimeUnc;
|
||||
int32_t mClockFreqBias;
|
||||
int32_t mClockFreqBiasUnc;
|
||||
SystemStatusTimeAndClock(const SystemStatusPQWM1& nmea);
|
||||
bool equals(SystemStatusTimeAndClock& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
class SystemStatusXoState : public SystemStatusItemBase
|
||||
{
|
||||
public:
|
||||
uint8_t mXoState;
|
||||
SystemStatusXoState(const SystemStatusPQWM1& nmea);
|
||||
bool equals(SystemStatusXoState& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
class SystemStatusRfAndParams : public SystemStatusItemBase
|
||||
{
|
||||
public:
|
||||
int32_t mPgaGain;
|
||||
uint32_t mGpsBpAmpI;
|
||||
uint32_t mGpsBpAmpQ;
|
||||
uint32_t mAdcI;
|
||||
uint32_t mAdcQ;
|
||||
uint32_t mJammerGps;
|
||||
uint32_t mJammerGlo;
|
||||
uint32_t mJammerBds;
|
||||
uint32_t mJammerGal;
|
||||
SystemStatusRfAndParams(const SystemStatusPQWM1& nmea);
|
||||
bool equals(SystemStatusRfAndParams& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
class SystemStatusErrRecovery : public SystemStatusItemBase
|
||||
{
|
||||
public:
|
||||
uint32_t mRecErrorRecovery;
|
||||
SystemStatusErrRecovery(const SystemStatusPQWM1& nmea);
|
||||
bool equals(SystemStatusErrRecovery& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
class SystemStatusPQWP1;
|
||||
class SystemStatusInjectedPosition : public SystemStatusItemBase
|
||||
{
|
||||
public:
|
||||
uint8_t mEpiValidity;
|
||||
float mEpiLat;
|
||||
float mEpiLon;
|
||||
float mEpiAlt;
|
||||
float mEpiHepe;
|
||||
float mEpiAltUnc;
|
||||
uint8_t mEpiSrc;
|
||||
SystemStatusInjectedPosition(const SystemStatusPQWP1& nmea);
|
||||
bool equals(SystemStatusInjectedPosition& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
class SystemStatusPQWP2;
|
||||
class SystemStatusBestPosition : public SystemStatusItemBase
|
||||
{
|
||||
public:
|
||||
float mBestLat;
|
||||
float mBestLon;
|
||||
float mBestAlt;
|
||||
float mBestHepe;
|
||||
float mBestAltUnc;
|
||||
SystemStatusBestPosition(const SystemStatusPQWP2& nmea);
|
||||
bool equals(SystemStatusBestPosition& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
class SystemStatusPQWP3;
|
||||
class SystemStatusXtra : public SystemStatusItemBase
|
||||
{
|
||||
public:
|
||||
uint8_t mXtraValidMask;
|
||||
uint32_t mGpsXtraAge;
|
||||
uint32_t mGloXtraAge;
|
||||
uint32_t mBdsXtraAge;
|
||||
uint32_t mGalXtraAge;
|
||||
uint32_t mQzssXtraAge;
|
||||
uint32_t mGpsXtraValid;
|
||||
uint32_t mGloXtraValid;
|
||||
uint64_t mBdsXtraValid;
|
||||
uint64_t mGalXtraValid;
|
||||
uint8_t mQzssXtraValid;
|
||||
SystemStatusXtra(const SystemStatusPQWP3& nmea);
|
||||
bool equals(SystemStatusXtra& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
class SystemStatusPQWP4;
|
||||
class SystemStatusEphemeris : public SystemStatusItemBase
|
||||
{
|
||||
public:
|
||||
uint32_t mGpsEpheValid;
|
||||
uint32_t mGloEpheValid;
|
||||
uint64_t mBdsEpheValid;
|
||||
uint64_t mGalEpheValid;
|
||||
uint8_t mQzssEpheValid;
|
||||
SystemStatusEphemeris(const SystemStatusPQWP4& nmea);
|
||||
bool equals(SystemStatusEphemeris& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
class SystemStatusPQWP5;
|
||||
class SystemStatusSvHealth : public SystemStatusItemBase
|
||||
{
|
||||
public:
|
||||
uint32_t mGpsUnknownMask;
|
||||
uint32_t mGloUnknownMask;
|
||||
uint64_t mBdsUnknownMask;
|
||||
uint64_t mGalUnknownMask;
|
||||
uint8_t mQzssUnknownMask;
|
||||
uint32_t mGpsGoodMask;
|
||||
uint32_t mGloGoodMask;
|
||||
uint64_t mBdsGoodMask;
|
||||
uint64_t mGalGoodMask;
|
||||
uint8_t mQzssGoodMask;
|
||||
uint32_t mGpsBadMask;
|
||||
uint32_t mGloBadMask;
|
||||
uint64_t mBdsBadMask;
|
||||
uint64_t mGalBadMask;
|
||||
uint8_t mQzssBadMask;
|
||||
SystemStatusSvHealth(const SystemStatusPQWP5& nmea);
|
||||
bool equals(SystemStatusSvHealth& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
class SystemStatusPQWP6;
|
||||
class SystemStatusPdr : public SystemStatusItemBase
|
||||
{
|
||||
public:
|
||||
uint32_t mFixInfoMask;
|
||||
SystemStatusPdr(const SystemStatusPQWP6& nmea);
|
||||
bool equals(SystemStatusPdr& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
class SystemStatusPQWS1;
|
||||
class SystemStatusPositionFailure : public SystemStatusItemBase
|
||||
{
|
||||
public:
|
||||
uint32_t mFixInfoMask;
|
||||
uint32_t mHepeLimit;
|
||||
SystemStatusPositionFailure(const SystemStatusPQWS1& nmea);
|
||||
bool equals(SystemStatusPositionFailure& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
SystemStatusReports
|
||||
******************************************************************************/
|
||||
class SystemStatusReports
|
||||
{
|
||||
public:
|
||||
std::vector<SystemStatusTimeAndClock> mTimeAndClock;
|
||||
std::vector<SystemStatusXoState> mXoState;
|
||||
std::vector<SystemStatusRfAndParams> mRfAndParams;
|
||||
std::vector<SystemStatusErrRecovery> mErrRecovery;
|
||||
|
||||
std::vector<SystemStatusInjectedPosition> mInjectedPosition;
|
||||
std::vector<SystemStatusBestPosition> mBestPosition;
|
||||
std::vector<SystemStatusXtra> mXtra;
|
||||
std::vector<SystemStatusEphemeris> mEphemeris;
|
||||
std::vector<SystemStatusSvHealth> mSvHealth;
|
||||
std::vector<SystemStatusPdr> mPdr;
|
||||
std::vector<SystemStatusPositionFailure> mPositionFailure;
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
SystemStatus
|
||||
******************************************************************************/
|
||||
class SystemStatus
|
||||
{
|
||||
static pthread_mutex_t mMutexSystemStatus;
|
||||
|
||||
static const uint32_t maxTimeAndClock = 5;
|
||||
static const uint32_t maxXoState = 5;
|
||||
static const uint32_t maxRfAndParams = 5;
|
||||
static const uint32_t maxErrRecovery = 5;
|
||||
|
||||
static const uint32_t maxInjectedPosition = 5;
|
||||
static const uint32_t maxBestPosition = 5;
|
||||
static const uint32_t maxXtra = 5;
|
||||
static const uint32_t maxEphemeris = 5;
|
||||
static const uint32_t maxSvHealth = 5;
|
||||
static const uint32_t maxPdr = 5;
|
||||
static const uint32_t maxPositionFailure = 5;
|
||||
|
||||
SystemStatusReports mCache;
|
||||
|
||||
bool setTimeAndCLock(const SystemStatusPQWM1& nmea);
|
||||
bool setXoState(const SystemStatusPQWM1& nmea);
|
||||
bool setRfAndParams(const SystemStatusPQWM1& nmea);
|
||||
bool setErrRecovery(const SystemStatusPQWM1& nmea);
|
||||
|
||||
bool setInjectedPosition(const SystemStatusPQWP1& nmea);
|
||||
bool setBestPosition(const SystemStatusPQWP2& nmea);
|
||||
bool setXtra(const SystemStatusPQWP3& nmea);
|
||||
bool setEphemeris(const SystemStatusPQWP4& nmea);
|
||||
bool setSvHealth(const SystemStatusPQWP5& nmea);
|
||||
bool setPdr(const SystemStatusPQWP6& nmea);
|
||||
bool setPositionFailure(const SystemStatusPQWS1& nmea);
|
||||
|
||||
public:
|
||||
SystemStatus();
|
||||
~SystemStatus() { }
|
||||
|
||||
bool setNmeaString(const char *data, uint32_t len);
|
||||
bool getReport(SystemStatusReports& reports, bool isLatestonly = false) const;
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif //__SYSTEM_STATUS__
|
||||
|
|
@ -401,14 +401,15 @@ typedef uint32_t NmeaSentenceTypesMask;
|
|||
#define LOC_NMEA_MASK_GAGGA_V02 ((NmeaSentenceTypesMask)0x00004000) /**< Enable GAGGA type */
|
||||
#define LOC_NMEA_MASK_PQGSA_V02 ((NmeaSentenceTypesMask)0x00008000) /**< Enable PQGSA type */
|
||||
#define LOC_NMEA_MASK_PQGSV_V02 ((NmeaSentenceTypesMask)0x00010000) /**< Enable PQGSV type */
|
||||
#define LOC_NMEA_MASK_DEBUG_V02 ((NmeaSentenceTypesMask)0x00020000) /**< Enable DEBUG type */
|
||||
|
||||
#define LOC_NMEA_ALL_SUPPORTED_MASK (LOC_NMEA_MASK_GGA_V02 | LOC_NMEA_MASK_RMC_V02 | \
|
||||
LOC_NMEA_MASK_GSV_V02 | LOC_NMEA_MASK_GSA_V02 | LOC_NMEA_MASK_VTG_V02 | \
|
||||
LOC_NMEA_MASK_PQXFI_V02 | LOC_NMEA_MASK_PSTIS_V02 | LOC_NMEA_MASK_GLGSV_V02 | \
|
||||
LOC_NMEA_MASK_GNGSA_V02 | LOC_NMEA_MASK_GNGNS_V02 | LOC_NMEA_MASK_GARMC_V02 | \
|
||||
LOC_NMEA_MASK_GAGSV_V02 | LOC_NMEA_MASK_GAGSA_V02 | LOC_NMEA_MASK_GAVTG_V02 | \
|
||||
LOC_NMEA_MASK_GAGGA_V02 | LOC_NMEA_MASK_PQGSA_V02 | LOC_NMEA_MASK_PQGSV_V02 )
|
||||
|
||||
|
||||
LOC_NMEA_MASK_GAGGA_V02 | LOC_NMEA_MASK_PQGSA_V02 | LOC_NMEA_MASK_PQGSV_V02 | \
|
||||
LOC_NMEA_MASK_DEBUG_V02 )
|
||||
|
||||
typedef enum {
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC = 0,
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include <string>
|
||||
#include <loc_log.h>
|
||||
#include <Agps.h>
|
||||
#include <SystemStatus.h>
|
||||
|
||||
using namespace loc_core;
|
||||
|
||||
|
@ -509,9 +510,16 @@ GnssAdapter::setConfigCommand()
|
|||
mAdapter.convertLppeCp(ContextBase::mGps_conf.LPPE_CP_TECHNOLOGY));
|
||||
mApi.setLPPeProtocolUp(
|
||||
mAdapter.convertLppeUp(ContextBase::mGps_conf.LPPE_UP_TECHNOLOGY));
|
||||
|
||||
// set nmea mask type
|
||||
uint32_t mask = 0;
|
||||
if (NMEA_PROVIDER_MP == ContextBase::mGps_conf.NMEA_PROVIDER) {
|
||||
mApi.setNMEATypes(LOC_NMEA_ALL_SUPPORTED_MASK);
|
||||
mask = LOC_NMEA_ALL_SUPPORTED_MASK;
|
||||
} else {
|
||||
mask = LOC_NMEA_MASK_DEBUG_V02;
|
||||
}
|
||||
mApi.setNMEATypes(mask);
|
||||
|
||||
mApi.setXtraVersionCheck(ContextBase::mGps_conf.XTRA_VERSION_CHECK);
|
||||
if (ContextBase::mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID ||
|
||||
ContextBase::mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||
|
||||
|
@ -999,8 +1007,7 @@ GnssAdapter::updateClientsEventMask()
|
|||
if (it->second.gnssSvCb != nullptr) {
|
||||
mask |= LOC_API_ADAPTER_BIT_SATELLITE_REPORT;
|
||||
}
|
||||
if (it->second.gnssNmeaCb != nullptr &&
|
||||
NMEA_PROVIDER_MP == ContextBase::mGps_conf.NMEA_PROVIDER) {
|
||||
if (it->second.gnssNmeaCb != nullptr) {
|
||||
mask |= LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT;
|
||||
}
|
||||
if (it->second.gnssMeasurementsCb != nullptr) {
|
||||
|
@ -1997,7 +2004,16 @@ GnssAdapter::reportNmeaEvent(const char* nmea, size_t length, bool fromUlp)
|
|||
delete[] mNmea;
|
||||
}
|
||||
inline virtual void proc() const {
|
||||
mAdapter.reportNmea(mNmea, mLength);
|
||||
// extract bug report info - this returns true if consumed by systemstatus
|
||||
bool ret = false;
|
||||
SystemStatus* s = LocDualContext::getSystemStatus();
|
||||
if (nullptr != s) {
|
||||
ret = s->setNmeaString(mNmea, mLength);
|
||||
}
|
||||
if (false == ret) {
|
||||
// forward NMEA message to upper layer
|
||||
mAdapter.reportNmea(mNmea, mLength);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue