summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Hatch <jhatch@multitech.com>2021-03-31 16:17:13 -0500
committerJeff Hatch <jhatch@multitech.com>2021-03-31 16:17:13 -0500
commitb7f7d95092b87d0b278b1a74af53bfbc837b7acd (patch)
tree9cab56d25f4d52c734b578fefc2ac493a3d11b16
parentad6b4d51ac469d4e7300fd74d1ada87b1caece93 (diff)
parent76df85f676adde6f31c35f7809f9f7794baca2a1 (diff)
downloadlibmts-io-b7f7d95092b87d0b278b1a74af53bfbc837b7acd.tar.gz
libmts-io-b7f7d95092b87d0b278b1a74af53bfbc837b7acd.tar.bz2
libmts-io-b7f7d95092b87d0b278b1a74af53bfbc837b7acd.zip
Merge branch 'rs/GP-1111-cemode-for-telit' into 'master' 1.0.24
[GP-1111] mPower R. Apr 2021: +CEMODE shall be set to CEMODE=2 - libmts-io for Telit See merge request !37
-rw-r--r--include/mts/MTS_IO_CellularRadio.h3
-rw-r--r--include/mts/MTS_IO_ICellularRadio.h13
-rw-r--r--include/mts/MTS_IO_LE910Radio.h3
-rw-r--r--src/MTS_IO_CellularRadio.cpp11
-rw-r--r--src/MTS_IO_ICellularRadio.cpp48
-rw-r--r--src/MTS_IO_LE910Radio.cpp85
6 files changed, 163 insertions, 0 deletions
diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h
index 2b03d8f..6840398 100644
--- a/include/mts/MTS_IO_CellularRadio.h
+++ b/include/mts/MTS_IO_CellularRadio.h
@@ -134,6 +134,9 @@ 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;
+
protected:
CellularRadio(const std::string& sName, const std::string& sRadioPort);
diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h
index 61ffd20..e8ae891 100644
--- a/include/mts/MTS_IO_ICellularRadio.h
+++ b/include/mts/MTS_IO_ICellularRadio.h
@@ -68,10 +68,20 @@ namespace MTS {
CELLULAR_MODE_5G = 1 << 3 // 5G
};
+ enum UE_MODES_OF_OPERATION : uint8_t {
+ UNKNOWN_MODE = 0, // current mode of operation is not available
+ PS_MODE1, // only EPS (LTE) services are allowed, the usage is “voice centric”
+ PS_MODE2, // only EPS (LTE) services are allowed, the usage is “data centric”
+ CS_PS_MODE1, // both EPS and non-EPS services are allowed, the usage is “voice centric”
+ CS_PS_MODE2 // both EPS and non-EPS services are allowed, the usage is “data centric”
+ };
+
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);
static CODE convertActiveBandToString(ACTIVEBAND eBand, std::string& sBand);
+ static CODE convertUeModeToString(UE_MODES_OF_OPERATION mode, std::string& string);
+ static CODE convertStringToUeMode(const std::string& sMode, UE_MODES_OF_OPERATION& mode);
static std::string sendCommand(MTS::AutoPtr<MTS::IO::Connection>& apIo,
const std::string& sCmd,
@@ -562,6 +572,9 @@ namespace MTS {
virtual std::string waitResponse(IsNeedMoreData& isNeedMoreData,
int32_t timeoutMillis = 100) = 0;
+
+ virtual CODE setUeModeOfOperation(UE_MODES_OF_OPERATION newmode) = 0;
+ virtual CODE getUeModeOfOperation(UE_MODES_OF_OPERATION& newmode) = 0;
};
}
}
diff --git a/include/mts/MTS_IO_LE910Radio.h b/include/mts/MTS_IO_LE910Radio.h
index 35e704d..e8a0dec 100644
--- a/include/mts/MTS_IO_LE910Radio.h
+++ b/include/mts/MTS_IO_LE910Radio.h
@@ -45,6 +45,9 @@ 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;
+
protected:
private:
diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp
index fe252c0..49bdcb4 100644
--- a/src/MTS_IO_CellularRadio.cpp
+++ b/src/MTS_IO_CellularRadio.cpp
@@ -1378,3 +1378,14 @@ ICellularRadio::CODE CellularRadio::readChunk(int fd, char* pChunk, size_t dChun
return rc;
}
+
+ICellularRadio::CODE CellularRadio::setUeModeOfOperation(UE_MODES_OF_OPERATION newmode) {
+ printTrace("%s| Set UE Mode Of Operation: not applicable", m_sName.c_str());
+ return CODE::NOT_APPLICABLE;
+}
+
+ICellularRadio::CODE CellularRadio::getUeModeOfOperation(UE_MODES_OF_OPERATION &newmode) {
+ printTrace("%s| Get UE Mode Of Operation: not applicable", m_sName.c_str());
+ newmode = UE_MODES_OF_OPERATION::UNKNOWN_MODE;
+ return CODE::NOT_APPLICABLE;
+}
diff --git a/src/MTS_IO_ICellularRadio.cpp b/src/MTS_IO_ICellularRadio.cpp
index 73737c7..9f63408 100644
--- a/src/MTS_IO_ICellularRadio.cpp
+++ b/src/MTS_IO_ICellularRadio.cpp
@@ -513,3 +513,51 @@ 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) {
+ CODE rc;
+ switch (mode) {
+ case ICellularRadio::UE_MODES_OF_OPERATION::PS_MODE1:
+ string = "ps_1";
+ rc = CODE::SUCCESS;
+ break;
+ case ICellularRadio::UE_MODES_OF_OPERATION::PS_MODE2:
+ string = "ps_2";
+ rc = CODE::SUCCESS;
+ break;
+ case ICellularRadio::UE_MODES_OF_OPERATION::CS_PS_MODE1:
+ string = "csps_1";
+ rc = CODE::SUCCESS;
+ break;
+ case ICellularRadio::UE_MODES_OF_OPERATION::CS_PS_MODE2:
+ string = "csps_2";
+ rc = CODE::SUCCESS;
+ break;
+ default:
+ string = MTS::IO::ICellularRadio::VALUE_UNKNOWN;
+ rc = CODE::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;
+ CODE rc;
+ if (sMode == "ps_1") {
+ mode = ICellularRadio::UE_MODES_OF_OPERATION::PS_MODE1;
+ rc = CODE::SUCCESS;
+ } else if (sMode == "ps_2") {
+ mode = ICellularRadio::UE_MODES_OF_OPERATION::PS_MODE2;
+ rc = CODE::SUCCESS;
+ } else if (sMode == "csps_1") {
+ mode = ICellularRadio::UE_MODES_OF_OPERATION::CS_PS_MODE1;
+ rc = CODE::SUCCESS;
+ } else if (sMode == "csps_2") {
+ mode = ICellularRadio::UE_MODES_OF_OPERATION::CS_PS_MODE2;
+ rc = CODE::SUCCESS;
+ } else {
+ mode = ICellularRadio::UNKNOWN_MODE;
+ rc = CODE::FAILURE;
+ }
+ return rc;
+}
diff --git a/src/MTS_IO_LE910Radio.cpp b/src/MTS_IO_LE910Radio.cpp
index ea905a8..764ac5e 100644
--- a/src/MTS_IO_LE910Radio.cpp
+++ b/src/MTS_IO_LE910Radio.cpp
@@ -29,6 +29,7 @@
#include <mts/MTS_IO_LE910Radio.h>
#include <mts/MTS_Logger.h>
+#include <mts/MTS_Text.h>
using namespace MTS::IO;
@@ -76,3 +77,87 @@ ICellularRadio::CODE LE910Radio::getModemLocation(std::string& sLocation) {
return SUCCESS;
}
+
+ICellularRadio::CODE LE910Radio::setUeModeOfOperation(ICellularRadio::UE_MODES_OF_OPERATION newmode) {
+ uint8_t iValue;
+
+ switch (newmode) {
+ case UE_MODES_OF_OPERATION::PS_MODE1:
+ iValue = 3;
+ break;
+ case UE_MODES_OF_OPERATION::PS_MODE2:
+ iValue = 0;
+ break;
+ case UE_MODES_OF_OPERATION::CS_PS_MODE1:
+ iValue = 1;
+ break;
+ case UE_MODES_OF_OPERATION::CS_PS_MODE2:
+ iValue = 2;
+ break;
+ default:
+ printTrace("Set UE Mode Of Operation: invalid argument");
+ return CODE::INVALID_ARGS;
+ }
+
+ const int dTimeout = 1000; // ms
+ const std::string sCommand = "AT+CEMODE=" + MTS::Text::format(iValue);
+
+ return sendBasicCommand(sCommand, dTimeout);
+}
+
+ICellularRadio::CODE LE910Radio::getUeModeOfOperation(ICellularRadio::UE_MODES_OF_OPERATION& newmode) {
+ 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());
+
+ 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;
+ }
+
+ 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;
+ }
+
+ start += sLabel.length();
+ const std::string sValue = MTS::Text::trim(sResult.substr(start, end - start));
+ uint8_t uiValue;
+
+ if (!MTS::Text::parse(uiValue, sValue)) {
+ printWarning("Unable to parse CEMODE from response [%s]", sResult.c_str());
+ return CODE::FAILURE;
+ }
+
+ CODE rc;
+ switch (uiValue) {
+ case 0:
+ newmode = ICellularRadio::UE_MODES_OF_OPERATION::PS_MODE2;
+ rc = CODE::SUCCESS;
+ break;
+ case 1:
+ newmode = ICellularRadio::UE_MODES_OF_OPERATION::CS_PS_MODE1;
+ rc = CODE::SUCCESS;
+ break;
+ case 2:
+ newmode = ICellularRadio::UE_MODES_OF_OPERATION::CS_PS_MODE2;
+ rc = CODE::SUCCESS;
+ break;
+ case 3:
+ newmode = ICellularRadio::UE_MODES_OF_OPERATION::PS_MODE1;
+ rc = CODE::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;
+ break;
+ }
+ return rc;
+}
+