summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormykola.salomatin <mykola.salomatin@globallogic.com>2021-04-15 20:47:36 +0300
committermykola.salomatin <mykola.salomatin@globallogic.com>2021-04-15 20:47:36 +0300
commit6cab1e29fc2031a76c87e49c3bcdd7c5db8f40dc (patch)
treebbb704819781eb1f57648adb4dde434376fc0018
parent67a991ff3d772d2f81cb9907e1a710a88436f7c7 (diff)
downloadlibmts-io-6cab1e29fc2031a76c87e49c3bcdd7c5db8f40dc.tar.gz
libmts-io-6cab1e29fc2031a76c87e49c3bcdd7c5db8f40dc.tar.bz2
libmts-io-6cab1e29fc2031a76c87e49c3bcdd7c5db8f40dc.zip
[MTX-3998] mPower R. Apr 2021: +CEMODE shall be set to CEMODE=2 - Quectel - GP-1111
Refactoring common functions, telit and quectel functions related to CEMODE switching
-rw-r--r--include/mts/MTS_IO_CellularRadio.h4
-rw-r--r--include/mts/MTS_IO_ICellularRadio.h6
-rw-r--r--include/mts/MTS_IO_LE910Radio.h4
-rw-r--r--src/MTS_IO_CellularRadio.cpp10
-rw-r--r--src/MTS_IO_ICellularRadio.cpp73
-rw-r--r--src/MTS_IO_LE910Radio.cpp62
-rw-r--r--src/MTS_IO_QuectelRadio.cpp8
7 files changed, 86 insertions, 81 deletions
diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h
index 6840398..b245c48 100644
--- a/include/mts/MTS_IO_CellularRadio.h
+++ b/include/mts/MTS_IO_CellularRadio.h
@@ -134,8 +134,8 @@ namespace MTS {
virtual std::string waitResponse(IsNeedMoreData& isNeedMoreData,
int32_t timeoutMillis = 100) override;
- CODE setUeModeOfOperation(UE_MODES_OF_OPERATION newmode) override;
- CODE getUeModeOfOperation(UE_MODES_OF_OPERATION& newmode) override;
+ CODE setUeModeOfOperation(UE_MODES_OF_OPERATION mode) override;
+ CODE getUeModeOfOperation(UE_MODES_OF_OPERATION& mode) override;
protected:
diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h
index c35e903..63cedbe 100644
--- a/include/mts/MTS_IO_ICellularRadio.h
+++ b/include/mts/MTS_IO_ICellularRadio.h
@@ -82,7 +82,7 @@ namespace MTS {
static CODE convertModelToMtsShortCode(const std::string& sModel, std::string& sCode, ICellularRadio *radioObj = NULL);
static CODE convertServiceDomainToString(SERVICEDOMAIN eSd, std::string& sSd);
static CODE convertActiveBandToString(ACTIVEBAND eBand, std::string& sBand);
- static CODE convertUeModeToString(UE_MODES_OF_OPERATION mode, std::string& string);
+ static CODE convertUeModeToString(UE_MODES_OF_OPERATION mode, std::string& sMode);
static CODE convertStringToUeMode(const std::string& sMode, UE_MODES_OF_OPERATION& mode);
static std::string sendCommand(MTS::AutoPtr<MTS::IO::Connection>& apIo,
@@ -575,8 +575,8 @@ namespace MTS {
int32_t timeoutMillis = 100) = 0;
- virtual CODE setUeModeOfOperation(UE_MODES_OF_OPERATION newmode) = 0;
- virtual CODE getUeModeOfOperation(UE_MODES_OF_OPERATION& newmode) = 0;
+ virtual CODE setUeModeOfOperation(UE_MODES_OF_OPERATION mode) = 0;
+ virtual CODE getUeModeOfOperation(UE_MODES_OF_OPERATION& mode) = 0;
};
}
}
diff --git a/include/mts/MTS_IO_LE910Radio.h b/include/mts/MTS_IO_LE910Radio.h
index e8a0dec..f64600d 100644
--- a/include/mts/MTS_IO_LE910Radio.h
+++ b/include/mts/MTS_IO_LE910Radio.h
@@ -45,8 +45,8 @@ namespace MTS {
CODE setRxDiversity(const Json::Value& jArgs);
CODE getModemLocation(std::string& sLocation);
- CODE setUeModeOfOperation(UE_MODES_OF_OPERATION newmode) override;
- CODE getUeModeOfOperation(UE_MODES_OF_OPERATION &newmode) override;
+ CODE setUeModeOfOperation(UE_MODES_OF_OPERATION mode) override;
+ CODE getUeModeOfOperation(UE_MODES_OF_OPERATION& mode) override;
protected:
diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp
index 49bdcb4..81e3332 100644
--- a/src/MTS_IO_CellularRadio.cpp
+++ b/src/MTS_IO_CellularRadio.cpp
@@ -1379,13 +1379,13 @@ ICellularRadio::CODE CellularRadio::readChunk(int fd, char* pChunk, size_t dChun
return rc;
}
-ICellularRadio::CODE CellularRadio::setUeModeOfOperation(UE_MODES_OF_OPERATION newmode) {
+ICellularRadio::CODE CellularRadio::setUeModeOfOperation(UE_MODES_OF_OPERATION mode) {
printTrace("%s| Set UE Mode Of Operation: not applicable", m_sName.c_str());
- return CODE::NOT_APPLICABLE;
+ return NOT_APPLICABLE;
}
-ICellularRadio::CODE CellularRadio::getUeModeOfOperation(UE_MODES_OF_OPERATION &newmode) {
+ICellularRadio::CODE CellularRadio::getUeModeOfOperation(UE_MODES_OF_OPERATION& mode) {
printTrace("%s| Get UE Mode Of Operation: not applicable", m_sName.c_str());
- newmode = UE_MODES_OF_OPERATION::UNKNOWN_MODE;
- return CODE::NOT_APPLICABLE;
+ mode = UE_MODES_OF_OPERATION::UNKNOWN_MODE;
+ return NOT_APPLICABLE;
}
diff --git a/src/MTS_IO_ICellularRadio.cpp b/src/MTS_IO_ICellularRadio.cpp
index 1fbad0c..3394b4e 100644
--- a/src/MTS_IO_ICellularRadio.cpp
+++ b/src/MTS_IO_ICellularRadio.cpp
@@ -513,65 +513,64 @@ std::string MTS::IO::ICellularRadio::getCodeAsString(CODE eCode) {
}
}
-MTS::IO::ICellularRadio::CODE MTS::IO::ICellularRadio::convertUeModeToString(MTS::IO::ICellularRadio::UE_MODES_OF_OPERATION mode, std::string &string) {
+MTS::IO::ICellularRadio::CODE MTS::IO::ICellularRadio::convertUeModeToString(UE_MODES_OF_OPERATION mode, std::string& sMode) {
CODE rc;
switch (mode) {
- case ICellularRadio::UE_MODES_OF_OPERATION::PS_MODE1:
- string = "ps_1";
- rc = CODE::SUCCESS;
+ case UE_MODES_OF_OPERATION::PS_MODE1:
+ sMode = "ps_1";
+ rc = SUCCESS;
break;
- case ICellularRadio::UE_MODES_OF_OPERATION::PS_MODE2:
- string = "ps_2";
- rc = CODE::SUCCESS;
+ case UE_MODES_OF_OPERATION::PS_MODE2:
+ sMode = "ps_2";
+ rc = SUCCESS;
break;
- case ICellularRadio::UE_MODES_OF_OPERATION::CS_PS_MODE1:
- string = "csps_1";
- rc = CODE::SUCCESS;
+ case UE_MODES_OF_OPERATION::CS_PS_MODE1:
+ sMode = "csps_1";
+ rc = SUCCESS;
break;
- case ICellularRadio::UE_MODES_OF_OPERATION::CS_PS_MODE2:
- string = "csps_2";
- rc = CODE::SUCCESS;
+ case UE_MODES_OF_OPERATION::CS_PS_MODE2:
+ sMode = "csps_2";
+ rc = SUCCESS;
break;
- case ICellularRadio::UE_MODES_OF_OPERATION::CS_MODE1:
- string = "cs_1";
- rc = CODE::SUCCESS;
+ case UE_MODES_OF_OPERATION::CS_MODE1:
+ sMode = "cs_1";
+ rc = SUCCESS;
break;
- case ICellularRadio::UE_MODES_OF_OPERATION::CS_MODE2:
- string = "cs_2";
- rc = CODE::SUCCESS;
+ case UE_MODES_OF_OPERATION::CS_MODE2:
+ sMode = "cs_2";
+ rc = SUCCESS;
break;
default:
- string = MTS::IO::ICellularRadio::VALUE_UNKNOWN;
- rc = CODE::FAILURE;
+ sMode = ICellularRadio::VALUE_UNKNOWN;
+ rc = FAILURE;
break;
}
return rc;
}
-MTS::IO::ICellularRadio::CODE MTS::IO::ICellularRadio::convertStringToUeMode(const std::string &sMode, UE_MODES_OF_OPERATION& mode) {
- using namespace MTS::IO;
+MTS::IO::ICellularRadio::CODE MTS::IO::ICellularRadio::convertStringToUeMode(const std::string& sMode, UE_MODES_OF_OPERATION& mode) {
CODE rc;
if (sMode == "ps_1") {
- mode = ICellularRadio::UE_MODES_OF_OPERATION::PS_MODE1;
- rc = CODE::SUCCESS;
+ mode = UE_MODES_OF_OPERATION::PS_MODE1;
+ rc = SUCCESS;
} else if (sMode == "ps_2") {
- mode = ICellularRadio::UE_MODES_OF_OPERATION::PS_MODE2;
- rc = CODE::SUCCESS;
+ mode = UE_MODES_OF_OPERATION::PS_MODE2;
+ rc = SUCCESS;
} else if (sMode == "csps_1") {
- mode = ICellularRadio::UE_MODES_OF_OPERATION::CS_PS_MODE1;
- rc = CODE::SUCCESS;
+ mode = UE_MODES_OF_OPERATION::CS_PS_MODE1;
+ rc = SUCCESS;
} else if (sMode == "csps_2") {
- mode = ICellularRadio::UE_MODES_OF_OPERATION::CS_PS_MODE2;
- rc = CODE::SUCCESS;
+ mode = UE_MODES_OF_OPERATION::CS_PS_MODE2;
+ rc = SUCCESS;
} else if (sMode == "cs_1") {
- mode = ICellularRadio::UE_MODES_OF_OPERATION::CS_MODE1;
- rc = CODE::SUCCESS;
+ mode = UE_MODES_OF_OPERATION::CS_MODE1;
+ rc = SUCCESS;
} else if (sMode == "cs_2") {
- mode = ICellularRadio::UE_MODES_OF_OPERATION::CS_MODE2;
- rc = CODE::SUCCESS;
+ mode = UE_MODES_OF_OPERATION::CS_MODE2;
+ rc = SUCCESS;
} else {
- mode = ICellularRadio::UNKNOWN_MODE;
- rc = CODE::FAILURE;
+ mode = UE_MODES_OF_OPERATION::UNKNOWN_MODE;
+ rc = FAILURE;
}
return rc;
}
diff --git a/src/MTS_IO_LE910Radio.cpp b/src/MTS_IO_LE910Radio.cpp
index 764ac5e..74cf5c1 100644
--- a/src/MTS_IO_LE910Radio.cpp
+++ b/src/MTS_IO_LE910Radio.cpp
@@ -78,51 +78,55 @@ ICellularRadio::CODE LE910Radio::getModemLocation(std::string& sLocation) {
return SUCCESS;
}
-ICellularRadio::CODE LE910Radio::setUeModeOfOperation(ICellularRadio::UE_MODES_OF_OPERATION newmode) {
- uint8_t iValue;
+ICellularRadio::CODE LE910Radio::setUeModeOfOperation(UE_MODES_OF_OPERATION mode) {
+ printTrace("%s| Set UE Mode Of Operation", getName().c_str());
- switch (newmode) {
+ std::string sValue;
+
+ switch (mode) {
case UE_MODES_OF_OPERATION::PS_MODE1:
- iValue = 3;
+ sValue = "3";
break;
case UE_MODES_OF_OPERATION::PS_MODE2:
- iValue = 0;
+ sValue = "0";
break;
case UE_MODES_OF_OPERATION::CS_PS_MODE1:
- iValue = 1;
+ sValue = "1";
break;
case UE_MODES_OF_OPERATION::CS_PS_MODE2:
- iValue = 2;
+ sValue = "2";
break;
default:
- printTrace("Set UE Mode Of Operation: invalid argument");
- return CODE::INVALID_ARGS;
+ printError("%s| Set UE Mode Of Operation: invalid argument", getName().c_str());
+ return INVALID_ARGS;
}
const int dTimeout = 1000; // ms
- const std::string sCommand = "AT+CEMODE=" + MTS::Text::format(iValue);
+ const std::string sCommand = "AT+CEMODE=" + sValue;
return sendBasicCommand(sCommand, dTimeout);
}
-ICellularRadio::CODE LE910Radio::getUeModeOfOperation(ICellularRadio::UE_MODES_OF_OPERATION& newmode) {
+ICellularRadio::CODE LE910Radio::getUeModeOfOperation(UE_MODES_OF_OPERATION& mode) {
+ printTrace("%s| Get UE Mode Of Operation", getName().c_str());
+
const std::string sCommand = "AT+CEMODE?";
const int dTimeout = 1000; // ms
std::string sResult = sendCommand(sCommand, ICellularRadio::DEFAULT_BAIL_STRINGS, dTimeout);
- printTrace("Got response from the radio: %s", sResult.c_str());
+ printTrace("%s| Got response from the radio: %s", getName().c_str(), sResult.c_str());
size_t end = sResult.rfind(ICellularRadio::RSP_OK);
if (std::string::npos == end) {
- printWarning("Unable to get UE Mode Of Operation from radio using command [%s]", sCommand.c_str());
- return CODE::FAILURE;
+ printError("%s| Unable to get UE Mode Of Operation from radio using command [%s]", getName().c_str(), sCommand.c_str());
+ return FAILURE;
}
const std::string sLabel = "+CEMODE: ";
size_t start = sResult.find(sLabel);
if (std::string::npos == start) {
- printWarning("Unable to get UE Mode Of Operation from radio using command [%s]", sCommand.c_str());
- return CODE::FAILURE;
+ printError("%s| Unable to get UE Mode Of Operation from radio using command [%s]", getName().c_str(), sCommand.c_str());
+ return FAILURE;
}
start += sLabel.length();
@@ -130,32 +134,32 @@ ICellularRadio::CODE LE910Radio::getUeModeOfOperation(ICellularRadio::UE_MODES_O
uint8_t uiValue;
if (!MTS::Text::parse(uiValue, sValue)) {
- printWarning("Unable to parse CEMODE from response [%s]", sResult.c_str());
- return CODE::FAILURE;
+ printError("%s| Unable to parse CEMODE from response [%s]", getName().c_str(), sResult.c_str());
+ return FAILURE;
}
CODE rc;
switch (uiValue) {
case 0:
- newmode = ICellularRadio::UE_MODES_OF_OPERATION::PS_MODE2;
- rc = CODE::SUCCESS;
+ mode = UE_MODES_OF_OPERATION::PS_MODE2;
+ rc = SUCCESS;
break;
case 1:
- newmode = ICellularRadio::UE_MODES_OF_OPERATION::CS_PS_MODE1;
- rc = CODE::SUCCESS;
+ mode = UE_MODES_OF_OPERATION::CS_PS_MODE1;
+ rc = SUCCESS;
break;
case 2:
- newmode = ICellularRadio::UE_MODES_OF_OPERATION::CS_PS_MODE2;
- rc = CODE::SUCCESS;
+ mode = UE_MODES_OF_OPERATION::CS_PS_MODE2;
+ rc = SUCCESS;
break;
case 3:
- newmode = ICellularRadio::UE_MODES_OF_OPERATION::PS_MODE1;
- rc = CODE::SUCCESS;
+ mode = UE_MODES_OF_OPERATION::PS_MODE1;
+ rc = SUCCESS;
break;
default:
- printWarning("Unable to parse CEMODE from response [%s]", sResult.c_str());
- newmode = ICellularRadio::UE_MODES_OF_OPERATION::UNKNOWN_MODE;
- rc = CODE::FAILURE;
+ printError("%s| Unable to parse CEMODE from response [%s]", getName().c_str(), sResult.c_str());
+ mode = UE_MODES_OF_OPERATION::UNKNOWN_MODE;
+ rc = FAILURE;
break;
}
return rc;
diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp
index 4f20627..7d96627 100644
--- a/src/MTS_IO_QuectelRadio.cpp
+++ b/src/MTS_IO_QuectelRadio.cpp
@@ -1223,6 +1223,8 @@ ICellularRadio::CODE QuectelRadio::abortFileUpload() {
}
ICellularRadio::CODE QuectelRadio::setUeModeOfOperation(UE_MODES_OF_OPERATION mode) {
+ printTrace("%s| Set UE Mode Of Operation", getName().c_str());
+
std::string sDomain, sPreference;
switch (mode) {
@@ -1251,7 +1253,7 @@ ICellularRadio::CODE QuectelRadio::setUeModeOfOperation(UE_MODES_OF_OPERATION mo
sPreference = "01";
break;
default:
- printTrace("Set UE Mode Of Operation: invalid argument");
+ printError("%s| Set UE Mode Of Operation: invalid argument", getName().c_str());
return INVALID_ARGS;
}
@@ -1261,7 +1263,7 @@ ICellularRadio::CODE QuectelRadio::setUeModeOfOperation(UE_MODES_OF_OPERATION mo
rc = sendBasicCommand(sCommand, dTimeout);
if (rc != SUCCESS) {
- printError("Voice/data preference configuration failed with code [%d]", rc);
+ printError("%s| Voice/data preference configuration failed with code [%d]", getName().c_str(), rc);
return rc;
}
@@ -1269,7 +1271,7 @@ ICellularRadio::CODE QuectelRadio::setUeModeOfOperation(UE_MODES_OF_OPERATION mo
rc = sendBasicCommand(sCommand, dTimeout);
if (rc != SUCCESS) {
- printError("Service domain configuration failed with code [%d]", rc);
+ printError("%s| Service domain configuration failed with code [%d]", getName().c_str(), rc);
return rc;
}