aboutsummaryrefslogtreecommitdiff
path: root/gps/core/SystemStatus.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gps/core/SystemStatus.cpp')
-rw-r--r--gps/core/SystemStatus.cpp74
1 files changed, 73 insertions, 1 deletions
diff --git a/gps/core/SystemStatus.cpp b/gps/core/SystemStatus.cpp
index dc03604..52d28c7 100644
--- a/gps/core/SystemStatus.cpp
+++ b/gps/core/SystemStatus.cpp
@@ -37,6 +37,7 @@
#include <platform_lib_log_util.h>
#include <MsgTask.h>
#include <loc_nmea.h>
+#include <DataItemsFactoryProxy.h>
#include <SystemStatus.h>
#include <SystemStatusOsObserver.h>
@@ -1212,7 +1213,8 @@ IOsObserver* SystemStatus::getOsObserver()
}
SystemStatus::SystemStatus(const MsgTask* msgTask) :
- mSysStatusObsvr(msgTask)
+ mSysStatusObsvr(msgTask),
+ mConnected(false)
{
int result = 0;
ENTRY_LOG ();
@@ -1414,6 +1416,28 @@ bool SystemStatus::setPositionFailure(const SystemStatusPQWS1& nmea)
}
/******************************************************************************
+ 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
@param[In] data pointer to the NMEA string
@@ -1534,6 +1558,26 @@ bool SystemStatus::eventPosition(const UlpLocation& location,
}
/******************************************************************************
+@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
@param[In] reference to report buffer
@@ -1712,5 +1756,33 @@ bool SystemStatus::setDefaultReport(void)
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