summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--include/mts/MTS_IO_ICellularRadio.h10
-rw-r--r--include/mts/MTS_IO_QuectelRadio.h2
-rw-r--r--include/mts/MTS_IO_TelitRadio.h2
-rw-r--r--src/MTS_IO_QuectelRadio.cpp36
-rw-r--r--src/MTS_IO_TelitRadio.cpp36
6 files changed, 87 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 3ace73f..8472075 100644
--- a/Makefile
+++ b/Makefile
@@ -51,7 +51,7 @@ LDFLAGS += -s -shared -Wl,-soname,$(APPNAME).so.0
all: $(APPNAME).a $(SONAME)
$(APPNAME).a: $(OBJS)
- $(AR) -r $@ $?
+ $(AR) -rs $@ $?
$(SONAME): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $? $(LDLIBS)
diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h
index 531e0e0..2d47fcf 100644
--- a/include/mts/MTS_IO_ICellularRadio.h
+++ b/include/mts/MTS_IO_ICellularRadio.h
@@ -60,6 +60,14 @@ namespace MTS {
NOT_INSERTED
};
+ enum RADIOMODE : uint8_t {
+ RADIOMODE_UNKNOWN = 0,
+ RADIOMODE_AUTO,
+ RADIOMODE_GSM_ONLY,
+ RADIOMODE_UMTS_ONLY,
+ RADIOMODE_LTE_ONLY
+ };
+
static CODE convertModelToType(const std::string& sModel, std::string& sType);
static CODE convertModelToMtsShortCode(const std::string& sModel, std::string& sCode, ICellularRadio *radioObj = NULL);
static CODE convertServiceDomainToString(SERVICEDOMAIN eSd, std::string& sSd);
@@ -254,6 +262,8 @@ namespace MTS {
virtual CODE getRegistration(REGISTRATION& eRegistration) = 0;
virtual CODE convertRegistrationToString(REGISTRATION eRegistration, std::string& sRegistration) = 0;
+ virtual CODE getRadioMode(RADIOMODE &mode) = 0;
+ virtual CODE setRadioMode(RADIOMODE mode) = 0;
/**
* @brief unlockSimCard - unlock the SIM card using PIN code provided
*
diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h
index 81da1ce..3e5886c 100644
--- a/include/mts/MTS_IO_QuectelRadio.h
+++ b/include/mts/MTS_IO_QuectelRadio.h
@@ -41,6 +41,8 @@ namespace MTS {
CODE convertdBmToSignalStrength(const int32_t& dBm, int32_t& iRssi) override;
CODE setMdn(const Json::Value& jArgs) override;
+ CODE getRadioMode(RADIOMODE &mode) override;
+ CODE setRadioMode(RADIOMODE mode) override;
protected:
QuectelRadio(const std::string& sName, const std::string& sRadioPort);
diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h
index 65ca56e..08b144c 100644
--- a/include/mts/MTS_IO_TelitRadio.h
+++ b/include/mts/MTS_IO_TelitRadio.h
@@ -39,6 +39,8 @@ namespace MTS {
CODE convertdBmToSignalStrength(const int32_t& dBm, int32_t& iRssi) override;
CODE setMdn(const Json::Value& jArgs) override;
+ CODE getRadioMode(RADIOMODE &mode) override;
+ CODE setRadioMode(RADIOMODE mode) override;
protected:
TelitRadio(const std::string& sName, const std::string& sRadioPort);
diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp
index 0a054ff..8ac9bac 100644
--- a/src/MTS_IO_QuectelRadio.cpp
+++ b/src/MTS_IO_QuectelRadio.cpp
@@ -573,3 +573,39 @@ CellularRadio::CODE QuectelRadio::convertToActiveBand(const std::string& sQuecte
return SUCCESS;
}
+
+ICellularRadio::CODE QuectelRadio::getRadioMode(RADIOMODE &mode)
+{
+ std::string sCmd("AT+QCFG=\"nwscanmode\"");
+ std::string cmdResult = sendCommand(sCmd);
+ if (cmdResult.find(ICellularRadio::RSP_OK) == std::string::npos) {
+ printDebug("%s| AT+QCFG? returned unexpected response: [%s][%s]", getName().c_str(), sCmd.c_str(), cmdResult.c_str());
+ return FAILURE;
+ }
+ switch (stoi(MTS::Text::split(cmdResult, ',')[1])) {
+ case 1: mode = ICellularRadio::RADIOMODE_GSM_ONLY; break;
+ case 5: mode = ICellularRadio::RADIOMODE_UMTS_ONLY; break;
+ case 0: mode = ICellularRadio::RADIOMODE_AUTO; break;
+ default: mode = ICellularRadio::RADIOMODE_UNKNOWN; break;
+ }
+ return SUCCESS;
+}
+
+ICellularRadio::CODE QuectelRadio::setRadioMode(RADIOMODE mode)
+{
+ std::string value;
+ switch (mode) {
+ case ICellularRadio::RADIOMODE_GSM_ONLY: value = "1"; break;
+ case ICellularRadio::RADIOMODE_UMTS_ONLY: value = "5"; break;
+ case ICellularRadio::RADIOMODE_AUTO: value = "0"; break;
+ default: return FAILURE;
+ }
+ std::string sCmd("AT+QCFG=\"nwscanmode\",");
+ sCmd += value;
+ std::string cmdResult = sendCommand(sCmd);
+ if (cmdResult.find(ICellularRadio::RSP_OK) == std::string::npos) {
+ printDebug("%s| AT+QCFG? returned unexpected response: [%s][%s]", getName().c_str(), sCmd.c_str(), cmdResult.c_str());
+ return FAILURE;
+ }
+ return SUCCESS;
+}
diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp
index ae885e9..2d0422d 100644
--- a/src/MTS_IO_TelitRadio.cpp
+++ b/src/MTS_IO_TelitRadio.cpp
@@ -538,6 +538,42 @@ bool TelitRadio::getHardwareVersionFromFirmware(const std::string& sFirmware, st
}
+ICellularRadio::CODE TelitRadio::getRadioMode(RADIOMODE &mode)
+{
+ std::string sCmd("AT+WS46?");
+ std::string cmdResult = sendCommand(sCmd);
+ if (cmdResult.find("+WS46:") == std::string::npos) {
+ printDebug("%s| AT+WS46? returned unexpected response: [%s][%s]", getName().c_str(), sCmd.c_str(), cmdResult.c_str());
+ return FAILURE;
+ }
+ switch (stoi(MTS::Text::split(cmdResult, ':')[1])) {
+ case 12: mode = ICellularRadio::RADIOMODE_GSM_ONLY; break;
+ case 22: mode = ICellularRadio::RADIOMODE_UMTS_ONLY; break;
+ case 25: mode = ICellularRadio::RADIOMODE_AUTO; break;
+ default: mode = ICellularRadio::RADIOMODE_UNKNOWN; break;
+ }
+ return SUCCESS;
+}
+
+ICellularRadio::CODE TelitRadio::setRadioMode(RADIOMODE mode)
+{
+ std::string value;
+ switch (mode) {
+ case ICellularRadio::RADIOMODE_GSM_ONLY: value = "12"; break;
+ case ICellularRadio::RADIOMODE_UMTS_ONLY: value = "22"; break;
+ case ICellularRadio::RADIOMODE_AUTO: value = "25"; break;
+ default: return FAILURE;
+ }
+ std::string sCmd("AT+WS46=");
+ sCmd += value;
+ std::string cmdResult = sendCommand(sCmd);
+ if (cmdResult.find(ICellularRadio::RSP_OK) == std::string::npos) {
+ printDebug("%s| AT+WS46? returned unexpected response: [%s][%s]", getName().c_str(), sCmd.c_str(), cmdResult.c_str());
+ return FAILURE;
+ }
+ return SUCCESS;
+}
+
CellularRadio::CODE TelitRadio::getIsSimInserted(bool& bData) {
printTrace("%s| Get SIM insertion status", getName().c_str());
std::string sCmd("AT#SIMDET?");