Integrate XtraSysStatObs with SystemStatusObserver
Use SystemStatusObserver to subscribe for dataitems in XtraSystemStatusObserver. Change-Id: Ib1828b9025c9c5bb5194a36014249472ed3f6f9e CRs-Fixed: 2093290
This commit is contained in:
parent
6ef3b74714
commit
ff8b31761c
9 changed files with 921 additions and 797 deletions
|
@ -37,6 +37,7 @@
|
||||||
#include <platform_lib_log_util.h>
|
#include <platform_lib_log_util.h>
|
||||||
#include <MsgTask.h>
|
#include <MsgTask.h>
|
||||||
#include <loc_nmea.h>
|
#include <loc_nmea.h>
|
||||||
|
#include <DataItemsFactoryProxy.h>
|
||||||
#include <SystemStatus.h>
|
#include <SystemStatus.h>
|
||||||
#include <SystemStatusOsObserver.h>
|
#include <SystemStatusOsObserver.h>
|
||||||
|
|
||||||
|
@ -1212,7 +1213,8 @@ IOsObserver* SystemStatus::getOsObserver()
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemStatus::SystemStatus(const MsgTask* msgTask) :
|
SystemStatus::SystemStatus(const MsgTask* msgTask) :
|
||||||
mSysStatusObsvr(msgTask)
|
mSysStatusObsvr(msgTask),
|
||||||
|
mConnected(false)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
ENTRY_LOG ();
|
ENTRY_LOG ();
|
||||||
|
@ -1413,6 +1415,28 @@ bool SystemStatus::setPositionFailure(const SystemStatusPQWS1& nmea)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
SystemStatus - storing dataitems
|
||||||
|
******************************************************************************/
|
||||||
|
bool SystemStatus::setNetworkInfo(IDataItemCore* dataitem)
|
||||||
|
{
|
||||||
|
SystemStatusNetworkInfo* data = reinterpret_cast<SystemStatusNetworkInfo*>(dataitem);
|
||||||
|
SystemStatusNetworkInfo s(data->mType,data->mTypeName,data->mSubTypeName,
|
||||||
|
data->mAvailable,data->mConnected,data->mRoaming);
|
||||||
|
s.dump();
|
||||||
|
mConnected = data->mConnected;
|
||||||
|
|
||||||
|
if (!mCache.mNetworkInfo.empty() && mCache.mNetworkInfo.back().equals(s)) {
|
||||||
|
mCache.mNetworkInfo.back().mUtcReported = s.mUtcReported;
|
||||||
|
} else {
|
||||||
|
mCache.mNetworkInfo.push_back(s);
|
||||||
|
if (mCache.mNetworkInfo.size() > maxNetworkInfo) {
|
||||||
|
mCache.mNetworkInfo.erase(mCache.mNetworkInfo.begin());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@brief API to set report data into internal buffer
|
@brief API to set report data into internal buffer
|
||||||
|
|
||||||
|
@ -1533,6 +1557,26 @@ bool SystemStatus::eventPosition(const UlpLocation& location,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
@brief API to set report DataItem event into internal buffer
|
||||||
|
|
||||||
|
@param[In] DataItem
|
||||||
|
|
||||||
|
@return true when successfully done
|
||||||
|
******************************************************************************/
|
||||||
|
bool SystemStatus::eventDataItemNotify(IDataItemCore* dataitem)
|
||||||
|
{
|
||||||
|
pthread_mutex_lock(&mMutexSystemStatus);
|
||||||
|
switch(dataitem->getId())
|
||||||
|
{
|
||||||
|
case NETWORKINFO_DATA_ITEM_ID:
|
||||||
|
setNetworkInfo(dataitem);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&mMutexSystemStatus);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@brief API to get report data into a given buffer
|
@brief API to get report data into a given buffer
|
||||||
|
|
||||||
|
@ -1712,5 +1756,33 @@ bool SystemStatus::setDefaultReport(void)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
@brief API to handle connection status update event from GnssRil
|
||||||
|
|
||||||
|
@param[In] Connection status
|
||||||
|
|
||||||
|
@return true when successfully done
|
||||||
|
******************************************************************************/
|
||||||
|
bool SystemStatus::eventConnectionStatus(bool connected, uint8_t type)
|
||||||
|
{
|
||||||
|
if (connected != mConnected) {
|
||||||
|
mConnected = connected;
|
||||||
|
|
||||||
|
// send networkinof dataitem to systemstatus observer clients
|
||||||
|
SystemStatusNetworkInfo s(type, "", "", false, connected, false);
|
||||||
|
IDataItemCore *networkinfo =
|
||||||
|
DataItemsFactoryProxy::createNewDataItem(NETWORKINFO_DATA_ITEM_ID);
|
||||||
|
if (nullptr == networkinfo) {
|
||||||
|
LOC_LOGE("Unable to create dataitemd");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
networkinfo->copy(&s);
|
||||||
|
list<IDataItemCore*> dl(0);
|
||||||
|
dl.push_back(networkinfo);
|
||||||
|
mSysStatusObsvr.notify(dl);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace loc_core
|
} // namespace loc_core
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <platform_lib_log_util.h>
|
#include <platform_lib_log_util.h>
|
||||||
#include <MsgTask.h>
|
#include <MsgTask.h>
|
||||||
|
#include <IDataItemCore.h>
|
||||||
#include <IOsObserver.h>
|
#include <IOsObserver.h>
|
||||||
#include <SystemStatusOsObserver.h>
|
#include <SystemStatusOsObserver.h>
|
||||||
|
|
||||||
|
@ -367,19 +368,183 @@ public:
|
||||||
void dump(void);
|
void dump(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
SystemStatus report data structure - from DataItem observer
|
||||||
|
******************************************************************************/
|
||||||
|
class SystemStatusGpsState : public SystemStatusItemBase, public IDataItemCore
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline SystemStatusGpsState() :
|
||||||
|
mEnabled(false) {}
|
||||||
|
inline SystemStatusGpsState(bool enabled) :
|
||||||
|
mEnabled(enabled) {}
|
||||||
|
|
||||||
|
bool mEnabled;
|
||||||
|
|
||||||
|
inline bool equals(SystemStatusGpsState& peer) {
|
||||||
|
return (mEnabled == peer.mEnabled);
|
||||||
|
}
|
||||||
|
inline void dump(void) {
|
||||||
|
LOC_LOGD("GpsState: state=%u", mEnabled);
|
||||||
|
}
|
||||||
|
inline DataItemId getId() {
|
||||||
|
return GPSSTATE_DATA_ITEM_ID;
|
||||||
|
}
|
||||||
|
inline void stringify(string& valueStr) {
|
||||||
|
valueStr.clear();
|
||||||
|
valueStr += "GpsState: enabled=";
|
||||||
|
valueStr += to_string(mEnabled);
|
||||||
|
}
|
||||||
|
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
|
||||||
|
SystemStatusGpsState* gpsstate = static_cast<SystemStatusGpsState*>(src);
|
||||||
|
mEnabled = gpsstate->mEnabled;
|
||||||
|
if (dataItemCopied) {
|
||||||
|
*dataItemCopied = true;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class SystemStatusNetworkInfo : public SystemStatusItemBase, public IDataItemCore
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline SystemStatusNetworkInfo() :
|
||||||
|
mType(0),
|
||||||
|
mTypeName(""),
|
||||||
|
mSubTypeName(""),
|
||||||
|
mAvailable(false),
|
||||||
|
mConnected(false),
|
||||||
|
mRoaming(false) {}
|
||||||
|
inline SystemStatusNetworkInfo(
|
||||||
|
uint32_t type,
|
||||||
|
std::string typeName,
|
||||||
|
std::string subTypeName,
|
||||||
|
bool available,
|
||||||
|
bool connected,
|
||||||
|
bool roaming) :
|
||||||
|
mType(type),
|
||||||
|
mTypeName(typeName),
|
||||||
|
mSubTypeName(subTypeName),
|
||||||
|
mAvailable(available),
|
||||||
|
mConnected(connected),
|
||||||
|
mRoaming(roaming) {}
|
||||||
|
|
||||||
|
uint32_t mType;
|
||||||
|
std::string mTypeName;
|
||||||
|
std::string mSubTypeName;
|
||||||
|
bool mAvailable;
|
||||||
|
bool mConnected;
|
||||||
|
bool mRoaming;
|
||||||
|
|
||||||
|
inline bool equals(SystemStatusNetworkInfo& peer) {
|
||||||
|
if ((mType != peer.mType) ||
|
||||||
|
(mTypeName != peer.mTypeName) ||
|
||||||
|
(mSubTypeName != peer.mSubTypeName) ||
|
||||||
|
(mAvailable != peer.mAvailable) ||
|
||||||
|
(mConnected != peer.mConnected) ||
|
||||||
|
(mRoaming != peer.mRoaming)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
inline void dump(void) {
|
||||||
|
LOC_LOGD("NetworkInfo: type=%u connected=%u", mType, mConnected);
|
||||||
|
}
|
||||||
|
inline DataItemId getId() {
|
||||||
|
return NETWORKINFO_DATA_ITEM_ID;
|
||||||
|
}
|
||||||
|
inline void stringify(string& /*valueStr*/) { }
|
||||||
|
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
|
||||||
|
SystemStatusNetworkInfo* networkinfo = static_cast<SystemStatusNetworkInfo*>(src);
|
||||||
|
mType = networkinfo->mType;
|
||||||
|
mTypeName = networkinfo->mTypeName;
|
||||||
|
mSubTypeName = networkinfo->mSubTypeName;
|
||||||
|
mAvailable = networkinfo->mAvailable;
|
||||||
|
mConnected = networkinfo->mConnected;
|
||||||
|
mRoaming = networkinfo->mRoaming;
|
||||||
|
if (dataItemCopied) {
|
||||||
|
*dataItemCopied = true;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class SystemStatusTac : public SystemStatusItemBase, public IDataItemCore
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline SystemStatusTac() :
|
||||||
|
mValue("") {}
|
||||||
|
inline SystemStatusTac(std::string value) :
|
||||||
|
mValue(value) {}
|
||||||
|
|
||||||
|
std::string mValue;
|
||||||
|
|
||||||
|
inline bool equals(SystemStatusTac& peer) {
|
||||||
|
return (mValue == peer.mValue);
|
||||||
|
}
|
||||||
|
inline void dump(void) {
|
||||||
|
LOC_LOGD("Tac: value=%s", mValue.c_str());
|
||||||
|
}
|
||||||
|
inline DataItemId getId() {
|
||||||
|
return TAC_DATA_ITEM_ID;
|
||||||
|
}
|
||||||
|
inline void stringify(string& /*valueStr*/) { }
|
||||||
|
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
|
||||||
|
SystemStatusTac* tac = static_cast<SystemStatusTac*>(src);
|
||||||
|
mValue = tac->mValue;
|
||||||
|
if (dataItemCopied) {
|
||||||
|
*dataItemCopied = true;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class SystemStatusMccMnc : public SystemStatusItemBase, public IDataItemCore
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline SystemStatusMccMnc() :
|
||||||
|
mValue("") {}
|
||||||
|
inline SystemStatusMccMnc(std::string value) :
|
||||||
|
mValue(value) {}
|
||||||
|
|
||||||
|
std::string mValue;
|
||||||
|
|
||||||
|
inline bool equals(SystemStatusMccMnc& peer) {
|
||||||
|
return (mValue == peer.mValue);
|
||||||
|
}
|
||||||
|
inline void dump(void) {
|
||||||
|
LOC_LOGD("TacMccMnc value=%s", mValue.c_str());
|
||||||
|
}
|
||||||
|
inline DataItemId getId() {
|
||||||
|
return MCCMNC_DATA_ITEM_ID;
|
||||||
|
}
|
||||||
|
inline void stringify(string& /*valueStr*/) { }
|
||||||
|
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
|
||||||
|
SystemStatusMccMnc* mccmnc = static_cast<SystemStatusMccMnc*>(src);
|
||||||
|
mValue = mccmnc->mValue;
|
||||||
|
if (dataItemCopied) {
|
||||||
|
*dataItemCopied = true;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
SystemStatusReports
|
SystemStatusReports
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
class SystemStatusReports
|
class SystemStatusReports
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
// from QMI_LOC indication
|
||||||
std::vector<SystemStatusLocation> mLocation;
|
std::vector<SystemStatusLocation> mLocation;
|
||||||
|
|
||||||
|
// from ME debug NMEA
|
||||||
std::vector<SystemStatusTimeAndClock> mTimeAndClock;
|
std::vector<SystemStatusTimeAndClock> mTimeAndClock;
|
||||||
std::vector<SystemStatusXoState> mXoState;
|
std::vector<SystemStatusXoState> mXoState;
|
||||||
std::vector<SystemStatusRfAndParams> mRfAndParams;
|
std::vector<SystemStatusRfAndParams> mRfAndParams;
|
||||||
std::vector<SystemStatusErrRecovery> mErrRecovery;
|
std::vector<SystemStatusErrRecovery> mErrRecovery;
|
||||||
|
|
||||||
|
// from PE debug NMEA
|
||||||
std::vector<SystemStatusInjectedPosition> mInjectedPosition;
|
std::vector<SystemStatusInjectedPosition> mInjectedPosition;
|
||||||
std::vector<SystemStatusBestPosition> mBestPosition;
|
std::vector<SystemStatusBestPosition> mBestPosition;
|
||||||
std::vector<SystemStatusXtra> mXtra;
|
std::vector<SystemStatusXtra> mXtra;
|
||||||
|
@ -388,7 +553,14 @@ public:
|
||||||
std::vector<SystemStatusPdr> mPdr;
|
std::vector<SystemStatusPdr> mPdr;
|
||||||
std::vector<SystemStatusNavData> mNavData;
|
std::vector<SystemStatusNavData> mNavData;
|
||||||
|
|
||||||
|
// from SM debug NMEA
|
||||||
std::vector<SystemStatusPositionFailure> mPositionFailure;
|
std::vector<SystemStatusPositionFailure> mPositionFailure;
|
||||||
|
|
||||||
|
// from dataitems observer
|
||||||
|
std::vector<SystemStatusGpsState> mGpsState;
|
||||||
|
std::vector<SystemStatusNetworkInfo> mNetworkInfo;
|
||||||
|
std::vector<SystemStatusTac> mTac;
|
||||||
|
std::vector<SystemStatusMccMnc> mMccMnc;
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -424,7 +596,13 @@ private:
|
||||||
|
|
||||||
static const uint32_t maxPositionFailure = 5;
|
static const uint32_t maxPositionFailure = 5;
|
||||||
|
|
||||||
|
static const uint32_t maxGpsState = 5;
|
||||||
|
static const uint32_t maxNetworkInfo = 5;
|
||||||
|
static const uint32_t maxTac = 5;
|
||||||
|
static const uint32_t maxMccMnc = 5;
|
||||||
|
|
||||||
SystemStatusReports mCache;
|
SystemStatusReports mCache;
|
||||||
|
bool mConnected;
|
||||||
|
|
||||||
bool setLocation(const UlpLocation& location);
|
bool setLocation(const UlpLocation& location);
|
||||||
|
|
||||||
|
@ -443,6 +621,8 @@ private:
|
||||||
|
|
||||||
bool setPositionFailure(const SystemStatusPQWS1& nmea);
|
bool setPositionFailure(const SystemStatusPQWS1& nmea);
|
||||||
|
|
||||||
|
bool setNetworkInfo(IDataItemCore* dataitem);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Static methods
|
// Static methods
|
||||||
static SystemStatus* getInstance(const MsgTask* msgTask);
|
static SystemStatus* getInstance(const MsgTask* msgTask);
|
||||||
|
@ -451,9 +631,11 @@ public:
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
bool eventPosition(const UlpLocation& location,const GpsLocationExtended& locationEx);
|
bool eventPosition(const UlpLocation& location,const GpsLocationExtended& locationEx);
|
||||||
|
bool eventDataItemNotify(IDataItemCore* dataitem);
|
||||||
bool setNmeaString(const char *data, uint32_t len);
|
bool setNmeaString(const char *data, uint32_t len);
|
||||||
bool getReport(SystemStatusReports& reports, bool isLatestonly = false) const;
|
bool getReport(SystemStatusReports& reports, bool isLatestonly = false) const;
|
||||||
bool setDefaultReport(void);
|
bool setDefaultReport(void);
|
||||||
|
bool eventConnectionStatus(bool connected, uint8_t type);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace loc_core
|
} // namespace loc_core
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -29,36 +29,34 @@
|
||||||
#ifndef __SYSTEM_STATUS_OSOBSERVER__
|
#ifndef __SYSTEM_STATUS_OSOBSERVER__
|
||||||
#define __SYSTEM_STATUS_OSOBSERVER__
|
#define __SYSTEM_STATUS_OSOBSERVER__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <cinttypes>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <platform_lib_log_util.h>
|
|
||||||
#include <DataItemId.h>
|
|
||||||
#include <MsgTask.h>
|
#include <MsgTask.h>
|
||||||
|
#include <DataItemId.h>
|
||||||
#include <IOsObserver.h>
|
#include <IOsObserver.h>
|
||||||
|
#include <platform_lib_log_util.h>
|
||||||
|
|
||||||
namespace loc_core
|
namespace loc_core
|
||||||
{
|
{
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
SystemStatusOsObserver
|
SystemStatusOsObserver
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
// Forward Declarations
|
// Forward Declarations
|
||||||
class IDataItemCore;
|
class IDataItemCore;
|
||||||
|
template<typename CT, typename DIT> class IClientIndex;
|
||||||
template <typename CT, typename DIT>
|
template<typename CT, typename DIT> class IDataItemIndex;
|
||||||
class IClientIndex;
|
|
||||||
|
|
||||||
template <typename CT, typename DIT>
|
|
||||||
class IDataItemIndex;
|
|
||||||
|
|
||||||
struct SystemContext {
|
struct SystemContext {
|
||||||
IDataItemSubscription *mSubscriptionObj;
|
IDataItemSubscription* mSubscriptionObj;
|
||||||
IFrameworkActionReq *mFrameworkActionReqObj;
|
IFrameworkActionReq* mFrameworkActionReqObj;
|
||||||
const MsgTask *mMsgTask;
|
const MsgTask* mMsgTask;
|
||||||
|
|
||||||
inline SystemContext() :
|
inline SystemContext() :
|
||||||
mSubscriptionObj(NULL),
|
mSubscriptionObj(NULL),
|
||||||
|
@ -66,6 +64,8 @@ struct SystemContext {
|
||||||
mMsgTask(NULL) {}
|
mMsgTask(NULL) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef map<IDataItemObserver*, list<DataItemId>> ObserverReqCache;
|
||||||
|
|
||||||
// Clients wanting to get data from OS/Framework would need to
|
// Clients wanting to get data from OS/Framework would need to
|
||||||
// subscribe with OSObserver using IDataItemSubscription interface.
|
// subscribe with OSObserver using IDataItemSubscription interface.
|
||||||
// Such clients would need to implement IDataItemObserver interface
|
// Such clients would need to implement IDataItemObserver interface
|
||||||
|
@ -80,252 +80,54 @@ public:
|
||||||
~SystemStatusOsObserver();
|
~SystemStatusOsObserver();
|
||||||
|
|
||||||
// To set the subscription object
|
// To set the subscription object
|
||||||
inline void setSubscriptionObj(IDataItemSubscription *subscriptionObj) {
|
virtual void setSubscriptionObj(IDataItemSubscription* subscriptionObj);
|
||||||
mContext.mSubscriptionObj = subscriptionObj;
|
|
||||||
};
|
|
||||||
|
|
||||||
// To set the framework action request object
|
// To set the framework action request object
|
||||||
inline void setFrameworkActionReqObj(IFrameworkActionReq *frameworkActionReqObj) {
|
inline void setFrameworkActionReqObj(IFrameworkActionReq* frameworkActionReqObj) {
|
||||||
mContext.mFrameworkActionReqObj = frameworkActionReqObj;
|
mContext.mFrameworkActionReqObj = frameworkActionReqObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
// IDataItemObserver Overrides
|
|
||||||
virtual void getName (string & name);
|
|
||||||
virtual void notify (const std::list <IDataItemCore *> & dlist);
|
|
||||||
|
|
||||||
// IDataItemSubscription Overrides
|
// IDataItemSubscription Overrides
|
||||||
virtual void subscribe (const std :: list <DataItemId> & l, IDataItemObserver * client);
|
virtual void subscribe(const list<DataItemId>& l, IDataItemObserver* client);
|
||||||
virtual void updateSubscription
|
virtual void updateSubscription(const list<DataItemId>& l, IDataItemObserver* client);
|
||||||
(
|
virtual void requestData(const list<DataItemId>& l, IDataItemObserver* client);
|
||||||
const std :: list <DataItemId> & l,
|
virtual void unsubscribe(const list<DataItemId>& l, IDataItemObserver* client);
|
||||||
IDataItemObserver * client
|
virtual void unsubscribeAll(IDataItemObserver* client);
|
||||||
);
|
|
||||||
virtual void requestData
|
// IDataItemObserver Overrides
|
||||||
(
|
virtual void notify(const list<IDataItemCore*>& dlist);
|
||||||
const std :: list <DataItemId> & l,
|
inline virtual void getName(string& name) {
|
||||||
IDataItemObserver * client
|
name = mAddress;
|
||||||
);
|
}
|
||||||
virtual void unsubscribe (const std :: list <DataItemId> & l, IDataItemObserver * client);
|
|
||||||
virtual void unsubscribeAll (IDataItemObserver * client);
|
|
||||||
|
|
||||||
// IFrameworkActionReq Overrides
|
// IFrameworkActionReq Overrides
|
||||||
virtual void turnOn (DataItemId dit, int timeOut = 0);
|
virtual void turnOn(DataItemId dit, int timeOut = 0);
|
||||||
virtual void turnOff (DataItemId dit);
|
virtual void turnOff(DataItemId dit);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SystemContext mContext;
|
||||||
|
const string mAddress;
|
||||||
|
IClientIndex<IDataItemObserver*, DataItemId>* mClientIndex;
|
||||||
|
IDataItemIndex<IDataItemObserver*, DataItemId>* mDataItemIndex;
|
||||||
|
map<DataItemId, IDataItemCore*> mDataItemCache;
|
||||||
|
map<DataItemId, int> mActiveRequestCount;
|
||||||
|
|
||||||
SystemContext mContext;
|
// Cache the subscribe and requestData till subscription obj is obtained
|
||||||
const string mAddress;
|
ObserverReqCache mSubscribeReqCache;
|
||||||
IClientIndex <IDataItemObserver *, DataItemId> *mClientIndex;
|
ObserverReqCache mReqDataCache;
|
||||||
IDataItemIndex <IDataItemObserver *, DataItemId> *mDataItemIndex;
|
void cacheObserverRequest(ObserverReqCache& reqCache,
|
||||||
map < DataItemId, IDataItemCore * > mDataItemCache;
|
const list<DataItemId>& l, IDataItemObserver* client);
|
||||||
map < DataItemId, int > mActiveRequestCount;
|
|
||||||
|
|
||||||
// Nested types
|
|
||||||
// Messages
|
|
||||||
struct HandleMsgBase : public LocMsg {
|
|
||||||
HandleMsgBase (SystemStatusOsObserver * parent);
|
|
||||||
virtual ~HandleMsgBase ();
|
|
||||||
// Data members
|
|
||||||
SystemStatusOsObserver * mParent;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
int sendFirstResponse
|
void sendFirstResponse(const list<DataItemId>& l, IDataItemObserver* to);
|
||||||
(
|
void sendCachedDataItems(const list<DataItemId>& l, IDataItemObserver* to);
|
||||||
const list <DataItemId> & l,
|
void updateCache(IDataItemCore* d, bool& dataItemUpdated);
|
||||||
IDataItemObserver * to
|
inline void logMe(const list<DataItemId>& l) {
|
||||||
);
|
for (auto id : l) {
|
||||||
|
LOC_LOGD("DataItem %d", id);
|
||||||
int sendCachedDataItems
|
}
|
||||||
(
|
|
||||||
const list <DataItemId> & l,
|
|
||||||
IDataItemObserver * to
|
|
||||||
);
|
|
||||||
|
|
||||||
int updateCache (IDataItemCore * d, bool &dataItemUpdated);
|
|
||||||
void logMe (const list <DataItemId> & l);
|
|
||||||
|
|
||||||
// Messages
|
|
||||||
struct HandleClientMsg : public LocMsg {
|
|
||||||
HandleClientMsg (SystemStatusOsObserver * parent, IDataItemObserver * client);
|
|
||||||
virtual ~HandleClientMsg ();
|
|
||||||
// Data Members
|
|
||||||
SystemStatusOsObserver * mParent;
|
|
||||||
IDataItemObserver * mClient;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct HandleSubscribeReq : public HandleClientMsg {
|
|
||||||
HandleSubscribeReq (SystemStatusOsObserver * parent,
|
|
||||||
const list <DataItemId> & l,
|
|
||||||
IDataItemObserver * client);
|
|
||||||
virtual ~HandleSubscribeReq ();
|
|
||||||
void proc () const;
|
|
||||||
// Data members
|
|
||||||
const list <DataItemId> mDataItemList;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct HandleUpdateSubscriptionReq : public HandleClientMsg {
|
|
||||||
HandleUpdateSubscriptionReq (SystemStatusOsObserver * parent,
|
|
||||||
const list <DataItemId> & l,
|
|
||||||
IDataItemObserver * client);
|
|
||||||
virtual ~HandleUpdateSubscriptionReq ();
|
|
||||||
void proc () const;
|
|
||||||
// Data members
|
|
||||||
const list <DataItemId> mDataItemList;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct HandleRequestData : public HandleClientMsg {
|
|
||||||
HandleRequestData (SystemStatusOsObserver * parent,
|
|
||||||
const list <DataItemId> & l,
|
|
||||||
IDataItemObserver * client);
|
|
||||||
virtual ~HandleRequestData ();
|
|
||||||
void proc () const;
|
|
||||||
const list <DataItemId> mDataItemList;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct HandleUnsubscribeReq : public HandleClientMsg {
|
|
||||||
HandleUnsubscribeReq (SystemStatusOsObserver * parent,
|
|
||||||
const list <DataItemId> & l,
|
|
||||||
IDataItemObserver * client);
|
|
||||||
virtual ~HandleUnsubscribeReq ();
|
|
||||||
void proc () const;
|
|
||||||
// Data members
|
|
||||||
const list <DataItemId> mDataItemList;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct HandleUnsubscribeAllReq : public HandleClientMsg {
|
|
||||||
HandleUnsubscribeAllReq
|
|
||||||
(
|
|
||||||
SystemStatusOsObserver * parent,
|
|
||||||
IDataItemObserver * client
|
|
||||||
);
|
|
||||||
virtual ~HandleUnsubscribeAllReq ();
|
|
||||||
void proc () const;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct HandleNotify : public HandleMsgBase {
|
|
||||||
HandleNotify (SystemStatusOsObserver * parent, list <IDataItemCore *> dlist);
|
|
||||||
virtual ~HandleNotify ();
|
|
||||||
void getListOfClients
|
|
||||||
(
|
|
||||||
const list <DataItemId> & dlist,
|
|
||||||
list <IDataItemObserver *> & clients
|
|
||||||
) const;
|
|
||||||
void proc () const;
|
|
||||||
// Data members
|
|
||||||
list <IDataItemCore *> mDList;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct HandleTurnOn : public HandleMsgBase {
|
|
||||||
HandleTurnOn (SystemStatusOsObserver * parent,
|
|
||||||
const DataItemId dit,
|
|
||||||
const int timeOut);
|
|
||||||
virtual ~HandleTurnOn ();
|
|
||||||
void proc () const;
|
|
||||||
// Data members
|
|
||||||
DataItemId mDataItemId;
|
|
||||||
int mTimeOut;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct HandleTurnOff : public HandleMsgBase {
|
|
||||||
HandleTurnOff (SystemStatusOsObserver * parent,const DataItemId dit);
|
|
||||||
virtual ~HandleTurnOff ();
|
|
||||||
void proc () const;
|
|
||||||
// Data members
|
|
||||||
DataItemId mDataItemId;
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
Messages
|
|
||||||
******************************************************************************/
|
|
||||||
// Ctors
|
|
||||||
inline SystemStatusOsObserver :: HandleMsgBase :: HandleMsgBase (SystemStatusOsObserver * parent)
|
|
||||||
:
|
|
||||||
mParent (parent)
|
|
||||||
{}
|
|
||||||
|
|
||||||
inline SystemStatusOsObserver :: HandleClientMsg :: HandleClientMsg
|
|
||||||
(
|
|
||||||
SystemStatusOsObserver * parent,
|
|
||||||
IDataItemObserver * client
|
|
||||||
)
|
|
||||||
:
|
|
||||||
mParent (parent),
|
|
||||||
mClient (client)
|
|
||||||
{}
|
|
||||||
|
|
||||||
inline SystemStatusOsObserver :: HandleSubscribeReq :: HandleSubscribeReq
|
|
||||||
(SystemStatusOsObserver * parent, const list <DataItemId> & l, IDataItemObserver * client)
|
|
||||||
:
|
|
||||||
HandleClientMsg (parent, client), mDataItemList (l)
|
|
||||||
{}
|
|
||||||
|
|
||||||
inline SystemStatusOsObserver :: HandleUpdateSubscriptionReq :: HandleUpdateSubscriptionReq
|
|
||||||
(SystemStatusOsObserver * parent, const list <DataItemId> & l, IDataItemObserver * client)
|
|
||||||
:
|
|
||||||
HandleClientMsg (parent, client), mDataItemList (l)
|
|
||||||
{}
|
|
||||||
|
|
||||||
inline SystemStatusOsObserver :: HandleRequestData :: HandleRequestData
|
|
||||||
(SystemStatusOsObserver * parent, const list <DataItemId> & l, IDataItemObserver * client)
|
|
||||||
:
|
|
||||||
HandleClientMsg (parent, client), mDataItemList (l)
|
|
||||||
{}
|
|
||||||
|
|
||||||
inline SystemStatusOsObserver :: HandleUnsubscribeReq :: HandleUnsubscribeReq
|
|
||||||
(SystemStatusOsObserver * parent, const list <DataItemId> & l, IDataItemObserver * client)
|
|
||||||
:
|
|
||||||
HandleClientMsg (parent, client), mDataItemList (l)
|
|
||||||
{}
|
|
||||||
|
|
||||||
inline SystemStatusOsObserver :: HandleUnsubscribeAllReq :: HandleUnsubscribeAllReq
|
|
||||||
(SystemStatusOsObserver * parent, IDataItemObserver * client)
|
|
||||||
:
|
|
||||||
HandleClientMsg (parent, client)
|
|
||||||
{}
|
|
||||||
|
|
||||||
inline SystemStatusOsObserver :: HandleNotify :: HandleNotify
|
|
||||||
(SystemStatusOsObserver * parent, list <IDataItemCore *> dlist)
|
|
||||||
:
|
|
||||||
HandleMsgBase (parent), mDList (dlist)
|
|
||||||
{}
|
|
||||||
|
|
||||||
inline SystemStatusOsObserver :: HandleTurnOn :: HandleTurnOn
|
|
||||||
(SystemStatusOsObserver * parent, const DataItemId dit,const int timeOut)
|
|
||||||
:
|
|
||||||
HandleMsgBase (parent), mDataItemId (dit), mTimeOut (timeOut)
|
|
||||||
{}
|
|
||||||
|
|
||||||
inline SystemStatusOsObserver :: HandleTurnOff :: HandleTurnOff
|
|
||||||
(SystemStatusOsObserver * parent, const DataItemId dit)
|
|
||||||
:
|
|
||||||
HandleMsgBase (parent), mDataItemId (dit)
|
|
||||||
{}
|
|
||||||
|
|
||||||
// Dtors
|
|
||||||
inline SystemStatusOsObserver :: HandleMsgBase :: ~HandleMsgBase () {}
|
|
||||||
inline SystemStatusOsObserver :: HandleClientMsg :: ~HandleClientMsg () {}
|
|
||||||
inline SystemStatusOsObserver :: HandleSubscribeReq :: ~HandleSubscribeReq () {}
|
|
||||||
inline SystemStatusOsObserver :: HandleUpdateSubscriptionReq :: ~HandleUpdateSubscriptionReq() {}
|
|
||||||
inline SystemStatusOsObserver :: HandleRequestData :: ~HandleRequestData() {}
|
|
||||||
inline SystemStatusOsObserver :: HandleUnsubscribeReq :: ~HandleUnsubscribeReq () {}
|
|
||||||
inline SystemStatusOsObserver :: HandleUnsubscribeAllReq :: ~HandleUnsubscribeAllReq () {}
|
|
||||||
|
|
||||||
inline SystemStatusOsObserver :: HandleNotify :: ~HandleNotify () {
|
|
||||||
list <IDataItemCore *> :: iterator it = mDList.begin ();
|
|
||||||
for (; it != mDList.end (); ++it) {
|
|
||||||
delete *it;
|
|
||||||
*it = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
inline SystemStatusOsObserver :: HandleTurnOn :: ~HandleTurnOn () {}
|
|
||||||
inline SystemStatusOsObserver :: HandleTurnOff :: ~HandleTurnOff () {}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace loc_core
|
} // namespace loc_core
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,8 @@ GnssAdapter::GnssAdapter() :
|
||||||
mAgpsManager(),
|
mAgpsManager(),
|
||||||
mAgpsCbInfo(),
|
mAgpsCbInfo(),
|
||||||
mSystemStatus(SystemStatus::getInstance(mMsgTask)),
|
mSystemStatus(SystemStatus::getInstance(mMsgTask)),
|
||||||
mServerUrl("")
|
mServerUrl(""),
|
||||||
|
mXtraObserver(mSystemStatus->getOsObserver(), mMsgTask)
|
||||||
{
|
{
|
||||||
LOC_LOGD("%s]: Constructor %p", __func__, this);
|
LOC_LOGD("%s]: Constructor %p", __func__, this);
|
||||||
mUlpPositionMode.mode = LOC_POSITION_MODE_INVALID;
|
mUlpPositionMode.mode = LOC_POSITION_MODE_INVALID;
|
||||||
|
|
|
@ -106,11 +106,11 @@ class GnssAdapter : public LocAdapterBase {
|
||||||
// This must be initialized via initAgps()
|
// This must be initialized via initAgps()
|
||||||
AgpsManager mAgpsManager;
|
AgpsManager mAgpsManager;
|
||||||
AgpsCbInfo mAgpsCbInfo;
|
AgpsCbInfo mAgpsCbInfo;
|
||||||
XtraSystemStatusObserver mXtraObserver;
|
|
||||||
|
|
||||||
/* === SystemStatus ===================================================================== */
|
/* === SystemStatus ===================================================================== */
|
||||||
SystemStatus* mSystemStatus;
|
SystemStatus* mSystemStatus;
|
||||||
std::string mServerUrl;
|
std::string mServerUrl;
|
||||||
|
XtraSystemStatusObserver mXtraObserver;
|
||||||
|
|
||||||
/*==== CONVERSION ===================================================================*/
|
/*==== CONVERSION ===================================================================*/
|
||||||
static void convertOptions(LocPosMode& out, const LocationOptions& options);
|
static void convertOptions(LocPosMode& out, const LocationOptions& options);
|
||||||
|
@ -280,10 +280,6 @@ public:
|
||||||
void injectLocationCommand(double latitude, double longitude, float accuracy);
|
void injectLocationCommand(double latitude, double longitude, float accuracy);
|
||||||
void injectTimeCommand(int64_t time, int64_t timeReference, int32_t uncertainty);
|
void injectTimeCommand(int64_t time, int64_t timeReference, int32_t uncertainty);
|
||||||
|
|
||||||
inline void updateConnectionStatusCommand(bool connected, uint8_t type) {
|
|
||||||
mXtraObserver.updateConnectionStatus(connected, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GNSS_ADAPTER_H
|
#endif //GNSS_ADAPTER_H
|
||||||
|
|
|
@ -45,40 +45,55 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <XtraSystemStatusObserver.h>
|
#include <XtraSystemStatusObserver.h>
|
||||||
#include <LocAdapterBase.h>
|
#include <LocAdapterBase.h>
|
||||||
|
#include <DataItemId.h>
|
||||||
|
#include <DataItemsFactoryProxy.h>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace loc_core;
|
using namespace loc_core;
|
||||||
|
|
||||||
#define XTRA_HAL_SOCKET_NAME "/data/vendor/location/xtra/socket_hal_xtra"
|
#define XTRA_HAL_SOCKET_NAME "/data/vendor/location/xtra/socket_hal_xtra"
|
||||||
|
|
||||||
bool XtraSystemStatusObserver::updateLockStatus(uint32_t lock) {
|
bool XtraSystemStatusObserver::updateLockStatus(uint32_t lock) {
|
||||||
std::stringstream ss;
|
stringstream ss;
|
||||||
ss << "gpslock";
|
ss << "gpslock";
|
||||||
ss << " " << lock;
|
ss << " " << lock;
|
||||||
ss << "\n"; // append seperator
|
ss << "\n"; // append seperator
|
||||||
return ( sendEvent(ss) );
|
return ( sendEvent(ss) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XtraSystemStatusObserver::updateConnectionStatus(bool connected, uint8_t type) {
|
bool XtraSystemStatusObserver::updateConnectionStatus(bool connected, uint32_t type) {
|
||||||
std::stringstream ss;
|
stringstream ss;
|
||||||
ss << "connection";
|
ss << "connection";
|
||||||
ss << " " << (connected ? "1" : "0");
|
ss << " " << (connected ? "1" : "0");
|
||||||
ss << " " << (int)type;
|
ss << " " << (int)type;
|
||||||
ss << "\n"; // append seperator
|
ss << "\n"; // append seperator
|
||||||
return ( sendEvent(ss) );
|
return ( sendEvent(ss) );
|
||||||
}
|
}
|
||||||
|
bool XtraSystemStatusObserver::updateTac(const string& tac) {
|
||||||
|
stringstream ss;
|
||||||
|
ss << "tac";
|
||||||
|
ss << " " << tac.c_str();
|
||||||
|
ss << "\n"; // append seperator
|
||||||
|
return ( sendEvent(ss) );
|
||||||
|
}
|
||||||
|
|
||||||
bool XtraSystemStatusObserver::sendEvent(std::stringstream& event) {
|
bool XtraSystemStatusObserver::updateMccMnc(const string& mccmnc) {
|
||||||
|
stringstream ss;
|
||||||
|
ss << "mncmcc";
|
||||||
|
ss << " " << mccmnc.c_str();
|
||||||
|
ss << "\n"; // append seperator
|
||||||
|
return ( sendEvent(ss) );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool XtraSystemStatusObserver::sendEvent(const stringstream& event) {
|
||||||
int socketFd = createSocket();
|
int socketFd = createSocket();
|
||||||
if (socketFd < 0) {
|
if (socketFd < 0) {
|
||||||
LOC_LOGe("XTRA unreachable. sending failed.");
|
LOC_LOGe("XTRA unreachable. sending failed.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& data = event.str();
|
const string& data = event.str();
|
||||||
int remain = data.length();
|
int remain = data.length();
|
||||||
ssize_t sent = 0;
|
ssize_t sent = 0;
|
||||||
|
|
||||||
while (remain > 0 &&
|
while (remain > 0 &&
|
||||||
(sent = ::send(socketFd, data.c_str() + (data.length() - remain),
|
(sent = ::send(socketFd, data.c_str() + (data.length() - remain),
|
||||||
remain, MSG_NOSIGNAL)) > 0) {
|
remain, MSG_NOSIGNAL)) > 0) {
|
||||||
|
@ -125,3 +140,95 @@ void XtraSystemStatusObserver::closeSocket(const int socketFd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XtraSystemStatusObserver::subscribe(bool yes)
|
||||||
|
{
|
||||||
|
// Subscription data list
|
||||||
|
list<DataItemId> subItemIdList;
|
||||||
|
subItemIdList.push_back(NETWORKINFO_DATA_ITEM_ID);
|
||||||
|
subItemIdList.push_back(MCCMNC_DATA_ITEM_ID);
|
||||||
|
|
||||||
|
if (yes) {
|
||||||
|
mSystemStatusObsrvr->subscribe(subItemIdList, this);
|
||||||
|
|
||||||
|
list<DataItemId> reqItemIdList;
|
||||||
|
reqItemIdList.push_back(TAC_DATA_ITEM_ID);
|
||||||
|
|
||||||
|
mSystemStatusObsrvr->requestData(reqItemIdList, this);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mSystemStatusObsrvr->unsubscribe(subItemIdList, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDataItemObserver overrides
|
||||||
|
void XtraSystemStatusObserver::getName(string& name)
|
||||||
|
{
|
||||||
|
name = "XtraSystemStatusObserver";
|
||||||
|
}
|
||||||
|
|
||||||
|
void XtraSystemStatusObserver::notify(const list<IDataItemCore*>& dlist)
|
||||||
|
{
|
||||||
|
struct handleOsObserverUpdateMsg : public LocMsg {
|
||||||
|
XtraSystemStatusObserver* mXtraSysStatObj;
|
||||||
|
list <IDataItemCore*> mDataItemList;
|
||||||
|
|
||||||
|
inline handleOsObserverUpdateMsg(XtraSystemStatusObserver* xtraSysStatObs,
|
||||||
|
const list<IDataItemCore*>& dataItemList) :
|
||||||
|
mXtraSysStatObj(xtraSysStatObs) {
|
||||||
|
for (auto eachItem : dataItemList) {
|
||||||
|
IDataItemCore* dataitem = DataItemsFactoryProxy::createNewDataItem(
|
||||||
|
eachItem->getId());
|
||||||
|
if (NULL == dataitem) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Copy the contents of the data item
|
||||||
|
dataitem->copy(eachItem);
|
||||||
|
|
||||||
|
mDataItemList.push_back(dataitem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ~handleOsObserverUpdateMsg() {
|
||||||
|
for (auto each : mDataItemList) {
|
||||||
|
delete each;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void proc() const {
|
||||||
|
for (auto each : mDataItemList) {
|
||||||
|
switch (each->getId())
|
||||||
|
{
|
||||||
|
case NETWORKINFO_DATA_ITEM_ID:
|
||||||
|
{
|
||||||
|
SystemStatusNetworkInfo* networkInfo =
|
||||||
|
reinterpret_cast<SystemStatusNetworkInfo*>(each);
|
||||||
|
mXtraSysStatObj->updateConnectionStatus(networkInfo->mConnected,
|
||||||
|
networkInfo->mType);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TAC_DATA_ITEM_ID:
|
||||||
|
{
|
||||||
|
SystemStatusTac* tac = reinterpret_cast<SystemStatusTac*>(each);
|
||||||
|
mXtraSysStatObj->updateTac(tac->mValue);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MCCMNC_DATA_ITEM_ID:
|
||||||
|
{
|
||||||
|
SystemStatusMccMnc* mccmnc = reinterpret_cast<SystemStatusMccMnc*>(each);
|
||||||
|
mXtraSysStatObj->updateMccMnc(mccmnc->mValue);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mMsgTask->sendMsg(new (nothrow) handleOsObserverUpdateMsg(this, dlist));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,25 +29,42 @@
|
||||||
#ifndef XTRA_SYSTEM_STATUS_OBS_H
|
#ifndef XTRA_SYSTEM_STATUS_OBS_H
|
||||||
#define XTRA_SYSTEM_STATUS_OBS_H
|
#define XTRA_SYSTEM_STATUS_OBS_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <cinttypes>
|
||||||
|
#include <MsgTask.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using loc_core::IOsObserver;
|
||||||
|
using loc_core::IDataItemObserver;
|
||||||
|
using loc_core::IDataItemCore;
|
||||||
|
|
||||||
|
|
||||||
class XtraSystemStatusObserver {
|
class XtraSystemStatusObserver : public IDataItemObserver {
|
||||||
public :
|
public :
|
||||||
// constructor & destructor
|
// constructor & destructor
|
||||||
XtraSystemStatusObserver() {
|
inline XtraSystemStatusObserver(IOsObserver* sysStatObs, const MsgTask* msgTask):
|
||||||
|
mSystemStatusObsrvr(sysStatObs), mMsgTask(msgTask) {
|
||||||
|
subscribe(true);
|
||||||
}
|
}
|
||||||
|
inline XtraSystemStatusObserver() {};
|
||||||
|
inline virtual ~XtraSystemStatusObserver() { subscribe(false); }
|
||||||
|
|
||||||
virtual ~XtraSystemStatusObserver() {
|
// IDataItemObserver overrides
|
||||||
}
|
inline virtual void getName(string& name);
|
||||||
|
virtual void notify(const list<IDataItemCore*>& dlist);
|
||||||
|
|
||||||
bool updateLockStatus(uint32_t lock);
|
bool updateLockStatus(uint32_t lock);
|
||||||
bool updateConnectionStatus(bool connected, uint8_t type);
|
bool updateConnectionStatus(bool connected, uint32_t type);
|
||||||
|
bool updateTac(const string& tac);
|
||||||
|
bool updateMccMnc(const string& mccmnc);
|
||||||
|
inline const MsgTask* getMsgTask() { return mMsgTask; }
|
||||||
|
void subscribe(bool yes);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int createSocket();
|
int createSocket();
|
||||||
void closeSocket(const int32_t socketFd);
|
void closeSocket(const int32_t socketFd);
|
||||||
bool sendEvent(std::stringstream& event);
|
bool sendEvent(const stringstream& event);
|
||||||
|
IOsObserver* mSystemStatusObsrvr;
|
||||||
|
const MsgTask* mMsgTask;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -253,6 +253,6 @@ static void getDebugReport(GnssDebugReport& report) {
|
||||||
|
|
||||||
static void updateConnectionStatus(bool connected, uint8_t type) {
|
static void updateConnectionStatus(bool connected, uint8_t type) {
|
||||||
if (NULL != gGnssAdapter) {
|
if (NULL != gGnssAdapter) {
|
||||||
gGnssAdapter->updateConnectionStatusCommand(connected, type);
|
gGnssAdapter->getSystemStatus()->eventConnectionStatus(connected, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue