Own fork of MbedSmartRestMain

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Cumulocity Official

Revision:
41:804f6a0bda26
Child:
74:ca3001991fdc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DeviceInfo.cpp	Tue Jul 15 12:44:34 2014 +0000
@@ -0,0 +1,56 @@
+#include "DeviceInfo.h"
+#include <stdlib.h>
+#include <string.h>
+
+DeviceInfo::DeviceInfo(MDMSerial& mdm, MDMParser::DevStatus& devStatus) :
+    _mdm(mdm)
+{
+    *_cellId = '\0';
+    memcpy(&_devStatus, &devStatus, sizeof(MDMParser::DevStatus));
+    memset(&_netStatus, 0, sizeof(MDMParser::NetStatus));
+    memset(&_signalQuality, 0, sizeof(DeviceInfo::SignalQuality));
+}
+
+const char * DeviceInfo::imsi()
+{
+    return _devStatus.imsi;
+}
+
+const char * DeviceInfo::imei()
+{
+    return _devStatus.imei;
+}
+
+const char * DeviceInfo::cellId()
+{
+    if (!refreshNetStatus())
+        return NULL;
+
+    if (snprintf(_cellId, sizeof(_cellId), "%X", _netStatus.ci) < 1)
+        return NULL;
+    return _cellId;
+}
+
+const char * DeviceInfo::iccid()
+{
+    return _devStatus.ccid;
+}
+
+DeviceInfo::SignalQuality * DeviceInfo::signalQuality()
+{
+    memset(&_signalQuality, 0, sizeof(DeviceInfo::SignalQuality));
+    if (!refreshNetStatus())
+        return NULL;
+    
+    if ((_netStatus.rssi == 0) || (_netStatus.ber == 0))
+        return NULL;
+
+    _signalQuality.rssi = _netStatus.rssi;
+    _signalQuality.ber = _netStatus.ber;
+    return &_signalQuality;
+}
+
+bool DeviceInfo::refreshNetStatus()
+{
+    return _mdm.checkNetStatus(&_netStatus);
+}