summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrodion.shyshkin <rodion.shyshkin@globallogic.com>2021-03-31 20:49:08 +0300
committerrodion.shyshkin <rodion.shyshkin@globallogic.com>2021-03-31 20:49:08 +0300
commit285cee922e229cb1bbd704e6227dbbb3756bd889 (patch)
tree2c0547033ed3e6a030594476ee37c3bb2fb15beb /src
parentad6b4d51ac469d4e7300fd74d1ada87b1caece93 (diff)
downloadlibmts-io-285cee922e229cb1bbd704e6227dbbb3756bd889.tar.gz
libmts-io-285cee922e229cb1bbd704e6227dbbb3756bd889.tar.bz2
libmts-io-285cee922e229cb1bbd704e6227dbbb3756bd889.zip
[GP-1111] mPower R. Apr 2021: +CEMODE shall be set to CEMODE=2 - libmts-io for Telit
Adding an ability to set UE mode of operation to libmts-io. There was added two clear virtual methods in iCellularRadio, correct implementation for them for Telit LTE modems and implementation with error messages for all other.
Diffstat (limited to 'src')
-rw-r--r--src/MTS_IO_CellularRadio.cpp39
-rw-r--r--src/MTS_IO_LE910Radio.cpp85
2 files changed, 124 insertions, 0 deletions
diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp
index fe252c0..ee45ace 100644
--- a/src/MTS_IO_CellularRadio.cpp
+++ b/src/MTS_IO_CellularRadio.cpp
@@ -1378,3 +1378,42 @@ 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;
+}
+
+ICellularRadio::CODE CellularRadio::convertUeModeToString(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 = "unknown";
+ rc = CODE::FAILURE;
+ break;
+ }
+ 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;
+}
+