summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.cpp169
1 files changed, 89 insertions, 80 deletions
diff --git a/main.cpp b/main.cpp
index 06c6e98..be87d06 100644
--- a/main.cpp
+++ b/main.cpp
@@ -21,7 +21,7 @@
#include <mts/MTS_Text.h>
#include <mts/MTS_Logger.h>
#include <mts/MTS_AutoPtr.h>
-#include <mts/MTS_IO_CellularRadio.h>
+#include <mts/MTS_IO_ICellularRadio.h>
#include <mts/MTS_IO_CellularRadioFactory.h>
#include <json/json.h>
#include <sstream>
@@ -57,7 +57,7 @@ std::string g_sType;
std::string g_sPort(DEFAULT_PORT);
Json::Value g_jData;
-MTS::AutoPtr<MTS::IO::CellularRadio> g_apRadio;
+MTS::AutoPtr<MTS::IO::ICellularRadio> g_apRadio;
int32_t g_iOptions = 0;
@@ -84,6 +84,7 @@ const uint32_t OPT_DATETIME = 0x00004000;
const uint32_t OPT_ACTIVEFIRMWARE = 0x00008000;
const uint32_t OPT_LOCATION = 0x00010000;
const uint32_t OPT_FIRMWAREBUILD = 0x00020000;
+const uint32_t OPT_SIM_STATUS = 0x00040000;
const uint32_t OPT_SUMMARY_STATIC = 0x01000000;
const uint32_t OPT_SUMMARY_NETWORK = 0x02000000;
@@ -150,142 +151,148 @@ int main(int argc, char** argv) {
}
}
- CellularRadio::CODE result = CellularRadio::CODE::SUCCESS;
+ ICellularRadio::CODE result = ICellularRadio::CODE::SUCCESS;
if(g_iOptions & OPT_SUMMARY_NETWORK) {
printf("%s", getNetworkData().toStyledString().c_str());
} else if(g_iOptions & OPT_SUMMARY_STATIC) {
printf("%s", getStaticData().toStyledString().c_str());
+ } else if(g_iOptions & OPT_SIM_STATUS) {
+ Json::Value jValue;
+ result = g_apRadio->getSimStatusSummary(jValue);
+ if(result == ICellularRadio::SUCCESS) {
+ printf("%s", jValue.toStyledString().c_str());
+ }
} else if(g_iOptions & OPT_RSSI) {
int32_t iValue;
result = g_apRadio->getSignalStrength(iValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
writeToCache(FRSSI, iValue);
printf("%d", iValue);
}
}else if(g_iOptions & OPT_LOCATION) {
std::string sValue;
result = g_apRadio->getModemLocation(sValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
printf("%s", sValue.c_str());
} else {
printf("Radio has not location support");
}
}else if(g_iOptions & OPT_NETREG) {
std::string sValue;
- CellularRadio::REGISTRATION eReg;
+ ICellularRadio::REGISTRATION eReg;
result = g_apRadio->getRegistration(eReg);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
result = g_apRadio->convertRegistrationToString(eReg, sValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
printf("%s", sValue.c_str());
}
}
} else if(g_iOptions & OPT_LAC) {
std::string sValue;
result = g_apRadio->getLac(sValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
printf("%s", sValue.c_str());
}
} else if(g_iOptions & OPT_TOWER) {
std::string sValue;
result = g_apRadio->getTower(sValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
printf("%s", sValue.c_str());
}
} else if(g_iOptions & OPT_ICCID) {
std::string sValue;
result = g_apRadio->getIccid(sValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
writeToCache(FICCID, sValue);
printf("%s", sValue.c_str());
}
} else if(g_iOptions & OPT_SERVICE) {
std::string sValue;
result = g_apRadio->getService(sValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
printf("%s", sValue.c_str());
}
} else if(g_iOptions & OPT_NETWORK) {
std::string sValue;
result = g_apRadio->getNetwork(sValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
printf("%s", sValue.c_str());
}
} else if(g_iOptions & OPT_MDN) {
std::string sValue;
result = g_apRadio->getMdn(sValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
writeToCache(FMDN, sValue);
printf("%s", sValue.c_str());
}
} else if(g_iOptions & OPT_FIRMWARE) {
std::string sValue;
result = g_apRadio->getFirmware(sValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
writeToCache(FFIRMWARE, sValue);
printf("%s", sValue.c_str());
}
} else if(g_iOptions & OPT_FIRMWAREBUILD) {
std::string sValue;
result = g_apRadio->getFirmwareBuild(sValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
writeToCache(FFIRMWAREBUILD, sValue);
printf("%s", sValue.c_str());
}
} else if(g_iOptions & OPT_IMEI) {
std::string sValue;
result = g_apRadio->getImei(sValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
printf("%s", sValue.c_str());
}
} else if(g_iOptions & OPT_IMSI) {
std::string sValue;
result = g_apRadio->getImsi(sValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
printf("%s", sValue.c_str());
}
} else if(g_iOptions & OPT_MODEL) {
std::string sValue;
result = g_apRadio->getModel(sValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
printf("%s", sValue.c_str());
}
} else if(g_iOptions & OPT_TYPE) {
std::string sValue;
std::string sType;
result = g_apRadio->getModel(sValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
result = g_apRadio->convertModelToType(sValue, sType);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
printf("%s", sType.c_str());
}
}
} else if(g_iOptions & OPT_CARRIER) {
std::string sValue;
result = g_apRadio->getCarrier(sValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
writeToCache(FCARRIER, sValue);
printf("%s", sValue.c_str());
}
} else if(g_iOptions & OPT_DATETIME) {
std::string sDate, sTime, sZone;
result = g_apRadio->getTime(sDate, sTime, sZone);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
printf("%s %s GMT%s", sDate.c_str(), sTime.c_str(), sZone.c_str());
}
} else if(g_iOptions & OPT_ACTIVEFIRMWARE) {
std::string sValue;
result = g_apRadio->getActiveFirmware(sValue);
- if(result == CellularRadio::SUCCESS) {
+ if(result == ICellularRadio::SUCCESS) {
printf("%s", sValue.c_str());
}
}
- if (g_bIstty && result == CellularRadio::CODE::SUCCESS)
+ if (g_bIstty && result == ICellularRadio::CODE::SUCCESS)
printf("\n");
shutdown();
- return (result == CellularRadio::CODE::SUCCESS) ? 0 : 1;
+ return (result == ICellularRadio::CODE::SUCCESS) ? 0 : 1;
}
void handle_sigterm(int signum) {
@@ -319,47 +326,47 @@ void initializeCache() {
std::ofstream ofile;
ofile.open(g_sCache + "/" + FMODEL);
- ofile << jData[MTS::IO::CellularRadio::KEY_MODEL].asString();
+ ofile << jData[MTS::IO::ICellularRadio::KEY_MODEL].asString();
ofile.close();
- if(g_sType == MTS::IO::CellularRadio::VALUE_TYPE_CDMA) {
+ if(g_sType == MTS::IO::ICellularRadio::VALUE_TYPE_CDMA) {
ofile.open(g_sCache + "/" + FIMEI);
- ofile << jData[MTS::IO::CellularRadio::KEY_MEID].asString();
+ ofile << jData[MTS::IO::ICellularRadio::KEY_MEID].asString();
ofile.close();
ofile.open(g_sCache + "/" + FMEID);
- ofile << jData[MTS::IO::CellularRadio::KEY_MEID].asString();
+ ofile << jData[MTS::IO::ICellularRadio::KEY_MEID].asString();
ofile.close();
} else {
ofile.open(g_sCache + "/" + FIMEI);
- ofile << jData[MTS::IO::CellularRadio::KEY_IMEI].asString();
+ ofile << jData[MTS::IO::ICellularRadio::KEY_IMEI].asString();
ofile.close();
ofile.open(g_sCache + "/" + FMEID);
- ofile << jData[MTS::IO::CellularRadio::KEY_IMEI].asString();
+ ofile << jData[MTS::IO::ICellularRadio::KEY_IMEI].asString();
ofile.close();
}
ofile.open(g_sCache + "/" + FIMSI);
- ofile << jData[MTS::IO::CellularRadio::KEY_IMSI].asString();
+ ofile << jData[MTS::IO::ICellularRadio::KEY_IMSI].asString();
ofile.close();
ofile.open(g_sCache + "/" + FTYPE);
- ofile << jData[MTS::IO::CellularRadio::KEY_TYPE].asString();
+ ofile << jData[MTS::IO::ICellularRadio::KEY_TYPE].asString();
ofile.close();
ofile.open(g_sCache + "/" + FCODE);
- ofile << jData[MTS::IO::CellularRadio::KEY_CODE].asString();
+ ofile << jData[MTS::IO::ICellularRadio::KEY_CODE].asString();
ofile.close();
ofile.open(g_sCache + "/" + FFIRMWARE);
- ofile << jData[MTS::IO::CellularRadio::KEY_FIRMWARE].asString();
+ ofile << jData[MTS::IO::ICellularRadio::KEY_FIRMWARE].asString();
ofile.close();
ofile.open(g_sCache + "/" + FFIRMWAREBUILD);
- ofile << jData[MTS::IO::CellularRadio::KEY_FIRMWARE_BUILD].asString();
+ ofile << jData[MTS::IO::ICellularRadio::KEY_FIRMWARE_BUILD].asString();
ofile.close();
ofile.open(g_sCache + "/" + FCARRIER);
- ofile << jData[MTS::IO::CellularRadio::KEY_CARRIER].asString();
+ ofile << jData[MTS::IO::ICellularRadio::KEY_CARRIER].asString();
ofile.close();
}
@@ -385,87 +392,87 @@ Json::Value getStaticData() {
Json::Value jData;
std::string sImei;
- CellularRadio::CODE eCode = g_apRadio->getImei(sImei);
- if(eCode != CellularRadio::SUCCESS) {
- printWarning("Radio IMEI not found: %s", CellularRadio::getCodeAsString(eCode).c_str());
+ ICellularRadio::CODE eCode = g_apRadio->getImei(sImei);
+ if(eCode != ICellularRadio::SUCCESS) {
+ printWarning("Radio IMEI not found: %s", ICellularRadio::getCodeAsString(eCode).c_str());
}
- if(g_apRadio->getModel(g_sModel) == CellularRadio::SUCCESS) {
- jData[CellularRadio::KEY_MODEL] = g_sModel;
+ if(g_apRadio->getModel(g_sModel) == ICellularRadio::SUCCESS) {
+ jData[ICellularRadio::KEY_MODEL] = g_sModel;
} else {
printWarning("Radio model not found");
}
- if(g_apRadio->convertModelToType(g_sModel, g_sType) == CellularRadio::SUCCESS) {
- jData[CellularRadio::KEY_TYPE] = g_sType;
+ if(g_apRadio->convertModelToType(g_sModel, g_sType) == ICellularRadio::SUCCESS) {
+ jData[ICellularRadio::KEY_TYPE] = g_sType;
} else {
printWarning("Radio type not supported");
}
- std::string sCode(CellularRadio::VALUE_UNKNOWN);
- if(CellularRadio::convertModelToMtsShortCode(g_sModel, sCode, g_apRadio.get()) != CellularRadio::SUCCESS) {
+ std::string sCode(ICellularRadio::VALUE_UNKNOWN);
+ if(ICellularRadio::convertModelToMtsShortCode(g_sModel, sCode, g_apRadio.get()) != ICellularRadio::SUCCESS) {
printWarning("Radio MTS short code not supported");
}
- jData[CellularRadio::KEY_CODE] = sCode;
+ jData[ICellularRadio::KEY_CODE] = sCode;
- if(g_sType == CellularRadio::VALUE_TYPE_CDMA) {
- jData[CellularRadio::KEY_MEID] = sImei;
+ if(g_sType == ICellularRadio::VALUE_TYPE_CDMA) {
+ jData[ICellularRadio::KEY_MEID] = sImei;
} else {
- jData[CellularRadio::KEY_IMEI] = sImei;
+ jData[ICellularRadio::KEY_IMEI] = sImei;
std::string sIccid;
- if(g_apRadio->getIccid(sIccid) == CellularRadio::SUCCESS) {
- jData[CellularRadio::KEY_ICCID] = sIccid;
+ if(g_apRadio->getIccid(sIccid) == ICellularRadio::SUCCESS) {
+ jData[ICellularRadio::KEY_ICCID] = sIccid;
}
}
- std::string sImsi(CellularRadio::VALUE_UNKNOWN);
- if(g_apRadio->getImsi(sImsi) != CellularRadio::SUCCESS) {
+ std::string sImsi(ICellularRadio::VALUE_UNKNOWN);
+ if(g_apRadio->getImsi(sImsi) != ICellularRadio::SUCCESS) {
printWarning("Radio IMSI not found");
}
- jData[CellularRadio::KEY_IMSI] = sImsi;
+ jData[ICellularRadio::KEY_IMSI] = sImsi;
- std::string sMsid(CellularRadio::VALUE_UNKNOWN);
- if(g_apRadio->getMsid(sMsid) != CellularRadio::SUCCESS) {
+ std::string sMsid(ICellularRadio::VALUE_UNKNOWN);
+ if(g_apRadio->getMsid(sMsid) != ICellularRadio::SUCCESS) {
printWarning("Radio MSID not found");
}
- jData[CellularRadio::KEY_MSID] = sMsid;
+ jData[ICellularRadio::KEY_MSID] = sMsid;
- std::string sFirmware(CellularRadio::VALUE_UNKNOWN);
- if(g_apRadio->getFirmware(sFirmware) != CellularRadio::SUCCESS) {
+ std::string sFirmware(ICellularRadio::VALUE_UNKNOWN);
+ if(g_apRadio->getFirmware(sFirmware) != ICellularRadio::SUCCESS) {
printWarning("Radio Firmware not found");
}
- jData[CellularRadio::KEY_FIRMWARE] = sFirmware;
+ jData[ICellularRadio::KEY_FIRMWARE] = sFirmware;
- std::string sFirmwareBuild(CellularRadio::VALUE_UNKNOWN);
- if(g_apRadio->getFirmwareBuild(sFirmwareBuild) != CellularRadio::SUCCESS) {
+ std::string sFirmwareBuild(ICellularRadio::VALUE_UNKNOWN);
+ if(g_apRadio->getFirmwareBuild(sFirmwareBuild) != ICellularRadio::SUCCESS) {
printWarning("Radio Firmware Build not found");
}
- jData[CellularRadio::KEY_FIRMWARE_BUILD] = sFirmwareBuild;
+ jData[ICellularRadio::KEY_FIRMWARE_BUILD] = sFirmwareBuild;
- std::string sCarrier(CellularRadio::VALUE_UNKNOWN);
- if(g_apRadio->getCarrier(sCarrier) != CellularRadio::SUCCESS) {
+ std::string sCarrier(ICellularRadio::VALUE_UNKNOWN);
+ if(g_apRadio->getCarrier(sCarrier) != ICellularRadio::SUCCESS) {
printWarning("Radio Carrier not found");
}
- jData[CellularRadio::KEY_CARRIER] = sCarrier;
+ jData[ICellularRadio::KEY_CARRIER] = sCarrier;
- std::string sHardware(CellularRadio::VALUE_UNKNOWN);
- if(g_apRadio->getHardware(sHardware) != CellularRadio::SUCCESS) {
+ std::string sHardware(ICellularRadio::VALUE_UNKNOWN);
+ if(g_apRadio->getHardware(sHardware) != ICellularRadio::SUCCESS) {
printWarning("Radio Hardware Version not found");
}
- jData[CellularRadio::KEY_HARDWARE] = sHardware;
+ jData[ICellularRadio::KEY_HARDWARE] = sHardware;
- std::string sManufacturer(CellularRadio::VALUE_UNKNOWN);
- if(g_apRadio->getManufacturer(sManufacturer) != CellularRadio::SUCCESS) {
+ std::string sManufacturer(ICellularRadio::VALUE_UNKNOWN);
+ if(g_apRadio->getManufacturer(sManufacturer) != ICellularRadio::SUCCESS) {
printWarning("Radio Manufacturer not found");
}
- jData[CellularRadio::KEY_MANUFACTURER] = sManufacturer;
+ jData[ICellularRadio::KEY_MANUFACTURER] = sManufacturer;
- std::string sMdn(CellularRadio::VALUE_UNKNOWN);
- if(g_apRadio->getMdn(sMdn) == CellularRadio::SUCCESS) {
+ std::string sMdn(ICellularRadio::VALUE_UNKNOWN);
+ if(g_apRadio->getMdn(sMdn) == ICellularRadio::SUCCESS) {
//CDMA Provisioned Flag
- if(g_sType == CellularRadio::VALUE_TYPE_CDMA) {
+ if(g_sType == ICellularRadio::VALUE_TYPE_CDMA) {
if(sMdn.size() == 0 || sMdn.find("000000") != std::string::npos) {
jData["provisioned"] = false;
} else {
@@ -475,11 +482,11 @@ Json::Value getStaticData() {
} else {
printWarning("Radio MDN not found");
}
- jData[CellularRadio::KEY_MDN] = sMdn;
+ jData[ICellularRadio::KEY_MDN] = sMdn;
Json::Value jMip;
- if(g_apRadio->getMipProfile(jMip) == MTS::IO::CellularRadio::SUCCESS) {
- jData[MTS::IO::CellularRadio::KEY_MIP] = jMip;
+ if(g_apRadio->getMipProfile(jMip) == MTS::IO::ICellularRadio::SUCCESS) {
+ jData[MTS::IO::ICellularRadio::KEY_MIP] = jMip;
}
return jData;
@@ -528,6 +535,7 @@ void parseOptions(int argc, char** argv) {
{ "carrier", no_argument, &iOption, OPT_CARRIER },
{ "datetime", no_argument, &iOption, OPT_DATETIME },
{ "active-firmware", no_argument, &iOption, OPT_ACTIVEFIRMWARE },
+ { "sim-status", no_argument, &iOption, OPT_SIM_STATUS },
{ "static", no_argument, &iOption, OPT_SUMMARY_STATIC },
{ "dynamic", no_argument, &iOption, OPT_SUMMARY_NETWORK },
{ 0, 0, 0, 0 } };
@@ -634,6 +642,7 @@ void printHelp(const std::string& sApp) {
printf("\t--type\n");
printf("\t--carrier\n");
printf("\t--datetime\n");
+ printf("\t--sim-status\n");
// Applicable for LTE910-NA1 dual FW images only
// printf("\t--active-firmware\n");
printf("\n");