aboutsummaryrefslogtreecommitdiff
path: root/gps/core/SystemStatus.h
diff options
context:
space:
mode:
Diffstat (limited to 'gps/core/SystemStatus.h')
-rw-r--r--gps/core/SystemStatus.h91
1 files changed, 58 insertions, 33 deletions
diff --git a/gps/core/SystemStatus.h b/gps/core/SystemStatus.h
index 1bcef10..b2f4fb6 100644
--- a/gps/core/SystemStatus.h
+++ b/gps/core/SystemStatus.h
@@ -30,9 +30,10 @@
#define __SYSTEM_STATUS__
#include <stdint.h>
-#include <string>
+#include <sys/time.h>
#include <vector>
-#include <platform_lib_log_util.h>
+#include <loc_pla.h>
+#include <log_util.h>
#include <MsgTask.h>
#include <IDataItemCore.h>
#include <IOsObserver.h>
@@ -70,14 +71,17 @@ public:
static const uint32_t maxItem = 5;
SystemStatusItemBase() {
- timeval tv;
- gettimeofday(&tv, NULL);
+ struct timespec tv;
+ clock_gettime(CLOCK_MONOTONIC, &tv);
mUtcTime.tv_sec = tv.tv_sec;
- mUtcTime.tv_nsec = tv.tv_usec *1000ULL;
+ mUtcTime.tv_nsec = tv.tv_nsec;
mUtcReported = mUtcTime;
};
- virtual ~SystemStatusItemBase() { };
- virtual void dump(void) { };
+ virtual ~SystemStatusItemBase() {};
+ inline virtual SystemStatusItemBase& collate(SystemStatusItemBase&) {
+ return *this;
+ }
+ virtual void dump(void) {};
};
class SystemStatusLocation : public SystemStatusItemBase
@@ -92,7 +96,7 @@ public:
const GpsLocationExtended& locationEx) :
mValid(true),
mLocation(location),
- mLocationEx(locationEx) { }
+ mLocationEx(locationEx) {}
bool equals(const SystemStatusLocation& peer);
void dump(void);
};
@@ -152,6 +156,12 @@ public:
double mAgcGlo;
double mAgcBds;
double mAgcGal;
+ uint32_t mGloBpAmpI;
+ uint32_t mGloBpAmpQ;
+ uint32_t mBdsBpAmpI;
+ uint32_t mBdsBpAmpQ;
+ uint32_t mGalBpAmpI;
+ uint32_t mGalBpAmpQ;
inline SystemStatusRfAndParams() :
mPgaGain(0),
mGpsBpAmpI(0),
@@ -165,7 +175,13 @@ public:
mAgcGps(0),
mAgcGlo(0),
mAgcBds(0),
- mAgcGal(0) {}
+ mAgcGal(0),
+ mGloBpAmpI(0),
+ mGloBpAmpQ(0),
+ mBdsBpAmpI(0),
+ mBdsBpAmpQ(0),
+ mGalBpAmpI(0),
+ mGalBpAmpQ(0) {}
inline SystemStatusRfAndParams(const SystemStatusPQWM1& nmea);
bool equals(const SystemStatusRfAndParams& peer);
void dump(void);
@@ -444,38 +460,49 @@ public:
class SystemStatusNetworkInfo : public SystemStatusItemBase,
public NetworkInfoDataItemBase
{
+ NetworkInfoDataItemBase* mSrcObjPtr;
public:
inline SystemStatusNetworkInfo(
int32_t type=0,
std::string typeName="",
string subTypeName="",
- bool available=false,
bool connected=false,
bool roaming=false) :
NetworkInfoDataItemBase(
+ (NetworkType)type,
type,
typeName,
subTypeName,
- available,
+ connected && (!roaming),
connected,
- roaming) {}
+ roaming),
+ mSrcObjPtr(nullptr) {}
inline SystemStatusNetworkInfo(const NetworkInfoDataItemBase& itemBase) :
- NetworkInfoDataItemBase(itemBase) {
+ NetworkInfoDataItemBase(itemBase),
+ mSrcObjPtr((NetworkInfoDataItemBase*)&itemBase) {
mType = itemBase.getType();
}
inline bool equals(const SystemStatusNetworkInfo& peer) {
- if ((mType == peer.mType) &&
- (mTypeName == peer.mTypeName) &&
- (mSubTypeName == peer.mSubTypeName) &&
- (mAvailable == peer.mAvailable) &&
- (mConnected == peer.mConnected) &&
- (mRoaming == peer.mRoaming)) {
- return true;
+ return (mAllTypes == peer.mAllTypes);
+ }
+ inline virtual SystemStatusItemBase& collate(SystemStatusItemBase& curInfo) {
+ uint64_t allTypes = (static_cast<SystemStatusNetworkInfo&>(curInfo)).mAllTypes;
+ if (mConnected) {
+ mAllTypes |= allTypes;
+ } else if (0 != mAllTypes) {
+ mAllTypes = (allTypes & (~mAllTypes));
+ } // else (mConnected == false && mAllTypes == 0)
+ // we keep mAllTypes as 0, which means no more connections.
+
+ if (nullptr != mSrcObjPtr) {
+ // this is critical, changing mAllTypes of the original obj
+ mSrcObjPtr->mAllTypes = mAllTypes;
}
- return false;
+ return *this;
}
inline void dump(void) override {
- LOC_LOGD("NetworkInfo: type=%u connected=%u", mType, mConnected);
+ LOC_LOGD("NetworkInfo: mAllTypes=%" PRIx64 " connected=%u mType=%x",
+ mAllTypes, mConnected, mType);
}
};
@@ -487,8 +514,9 @@ public:
RilServiceInfoDataItemBase() {}
inline SystemStatusServiceInfo(const RilServiceInfoDataItemBase& itemBase) :
RilServiceInfoDataItemBase(itemBase) {}
- inline bool equals(const SystemStatusServiceInfo& /*peer*/) {
- return true;
+ inline bool equals(const SystemStatusServiceInfo& peer) {
+ return static_cast<const RilServiceInfoDataItemBase&>(peer) ==
+ static_cast<const RilServiceInfoDataItemBase&>(*this);
}
};
@@ -500,8 +528,9 @@ public:
RilCellInfoDataItemBase() {}
inline SystemStatusRilCellInfo(const RilCellInfoDataItemBase& itemBase) :
RilCellInfoDataItemBase(itemBase) {}
- inline bool equals(const SystemStatusRilCellInfo& /*peer*/) {
- return true;
+ inline bool equals(const SystemStatusRilCellInfo& peer) {
+ return static_cast<const RilCellInfoDataItemBase&>(peer) ==
+ static_cast<const RilCellInfoDataItemBase&>(*this);
}
};
@@ -770,13 +799,9 @@ private:
// Data members
static pthread_mutex_t mMutexSystemStatus;
SystemStatusReports mCache;
- bool mConnected;
-
- template <typename TYPE_SYSTEMSTATUS_ITEM, typename TYPE_REPORT, typename TYPE_ITEMBASE>
- bool setItemBaseinReport(TYPE_REPORT& report, const TYPE_ITEMBASE& s);
template <typename TYPE_REPORT, typename TYPE_ITEM>
- bool setIteminReport(TYPE_REPORT& report, const TYPE_ITEM& s);
+ bool setIteminReport(TYPE_REPORT& report, TYPE_ITEM&& s);
// set default dataitem derived item in report cache
template <typename TYPE_REPORT, typename TYPE_ITEM>
@@ -796,8 +821,8 @@ public:
bool eventDataItemNotify(IDataItemCore* dataitem);
bool setNmeaString(const char *data, uint32_t len);
bool getReport(SystemStatusReports& reports, bool isLatestonly = false) const;
- bool setDefaultReport(void);
- bool eventConnectionStatus(bool connected, uint8_t type);
+ bool setDefaultGnssEngineStates(void);
+ bool eventConnectionStatus(bool connected, int8_t type);
};
} // namespace loc_core