diff options
author | mykola.salomatin <mykola.salomatin@globallogic.com> | 2020-05-29 11:44:57 +0300 |
---|---|---|
committer | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2020-05-29 11:49:24 +0300 |
commit | 04b90430c91f4257ebeff3bcccbe8c5d7413e7ae (patch) | |
tree | 64f6423de18f09e5791d9c5da216a5cfe4bc4fd0 | |
parent | b3a9a71afdb0d6f4f104543cedba89d011ca68df (diff) | |
download | libmts-io-04b90430c91f4257ebeff3bcccbe8c5d7413e7ae.tar.gz libmts-io-04b90430c91f4257ebeff3bcccbe8c5d7413e7ae.tar.bz2 libmts-io-04b90430c91f4257ebeff3bcccbe8c5d7413e7ae.zip |
mPower Oct20: L4G1 libmts-io support
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | include/mts/MTS_IO_CellularRadioFactory.h | 1 | ||||
-rw-r--r-- | include/mts/MTS_IO_EG25Radio.h | 48 | ||||
-rw-r--r-- | include/mts/MTS_IO_EG95Radio.h | 2 | ||||
-rw-r--r-- | include/mts/MTS_IO_QuectelRadio.h | 2 | ||||
-rw-r--r-- | src/MTS_IO_CellularRadioFactory.cpp | 9 | ||||
-rw-r--r-- | src/MTS_IO_EG25Radio.cpp | 52 | ||||
-rw-r--r-- | src/MTS_IO_EG95Radio.cpp | 40 | ||||
-rw-r--r-- | src/MTS_IO_ICellularRadio.cpp | 23 | ||||
-rw-r--r-- | src/MTS_IO_QuectelRadio.cpp | 34 |
10 files changed, 170 insertions, 42 deletions
@@ -6,6 +6,7 @@ libdir ?= /usr/lib OBJS += \ src/MTS_IO_TelitRadio.o \ + src/MTS_IO_EG25Radio.o \ src/MTS_IO_EG95Radio.o \ src/MTS_IO_QuectelRadio.o \ src/MTS_IO_CdmaRadio.o \ diff --git a/include/mts/MTS_IO_CellularRadioFactory.h b/include/mts/MTS_IO_CellularRadioFactory.h index e57ca5e..13f3993 100644 --- a/include/mts/MTS_IO_CellularRadioFactory.h +++ b/include/mts/MTS_IO_CellularRadioFactory.h @@ -55,6 +55,7 @@ namespace MTS { ICellularRadio* createCE910(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; ICellularRadio* createLE866A1JS(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; ICellularRadio* createEG95Radio(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + ICellularRadio* createEG25Radio(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; protected: typedef MTS::IO::ICellularRadio* (CellularRadioFactory::*CREATEFUNCPTR)(const std::string& sPort) const; diff --git a/include/mts/MTS_IO_EG25Radio.h b/include/mts/MTS_IO_EG25Radio.h new file mode 100644 index 0000000..46bff20 --- /dev/null +++ b/include/mts/MTS_IO_EG25Radio.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2019 by Multi-Tech Systems + * + * This file is part of libmts-io. + * + * libmts-io is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * libmts-io is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with libmts-io. If not, see <http://www.gnu.org/licenses/>. + * + */ + + +#ifndef MTS_IO_EG25RADIO_H_ +#define MTS_IO_EG25RADIO_H_ + +#include "mts/MTS_IO_QuectelRadio.h" + +namespace MTS { + namespace IO { + + class EG25Radio : public QuectelRadio { + + public: + static const std::string MODEL_NAME; + + EG25Radio(const std::string& sPort); + virtual ~EG25Radio(); + CODE setRxDiversity(const Json::Value& jArgs) override; + + protected: + + private: + CODE getSupportedCellularModes(CELLULAR_MODES &networks) override; + + }; + } +} + +#endif /* MTS_IO_EG25RADIO_H_ */ diff --git a/include/mts/MTS_IO_EG95Radio.h b/include/mts/MTS_IO_EG95Radio.h index 5296e16..17c413e 100644 --- a/include/mts/MTS_IO_EG95Radio.h +++ b/include/mts/MTS_IO_EG95Radio.h @@ -40,7 +40,7 @@ namespace MTS { private: CODE getSupportedCellularModes(CELLULAR_MODES &networks) override; - CODE setCellularMode(CELLULAR_MODES networks) override; + }; } } diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index df3b5b5..c6114a0 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -42,6 +42,8 @@ namespace MTS { CODE setMdn(const Json::Value& jArgs) override; + CODE setCellularMode(CELLULAR_MODES networks) override; + protected: QuectelRadio(const std::string& sName, const std::string& sRadioPort); diff --git a/src/MTS_IO_CellularRadioFactory.cpp b/src/MTS_IO_CellularRadioFactory.cpp index 08c6315..1a2cee2 100644 --- a/src/MTS_IO_CellularRadioFactory.cpp +++ b/src/MTS_IO_CellularRadioFactory.cpp @@ -37,6 +37,7 @@ #include <mts/MTS_IO_CE910Radio.h> #include <mts/MTS_IO_DE910Radio.h> #include "mts/MTS_IO_EG95Radio.h" +#include "mts/MTS_IO_EG25Radio.h" #include <mts/MTS_Logger.h> using namespace MTS::IO; @@ -60,6 +61,7 @@ CellularRadioFactory::CellularRadioFactory() { m_mCreationMap[CE910Radio::MODEL_NAME] = &CellularRadioFactory::createCE910; m_mCreationMap[LE866A1JSRadio::MODEL_NAME] = &CellularRadioFactory::createLE866A1JS; m_mCreationMap[EG95Radio::MODEL_NAME] = &CellularRadioFactory::createEG95Radio; + m_mCreationMap[EG25Radio::MODEL_NAME] = &CellularRadioFactory::createEG25Radio; } ICellularRadio* CellularRadioFactory::create(const std::string& sModel, const std::string& sPort) { @@ -191,7 +193,10 @@ ICellularRadio* CellularRadioFactory::createLE866A1JS(const std::string &sPort) return new LE866A1JSRadio(sPort); } -ICellularRadio* CellularRadioFactory::createEG95Radio(const std::string& sPort) const -{ +ICellularRadio* CellularRadioFactory::createEG95Radio(const std::string& sPort) const { return new EG95Radio(sPort); } + +ICellularRadio* CellularRadioFactory::createEG25Radio(const std::string& sPort) const { + return new EG25Radio(sPort); +} diff --git a/src/MTS_IO_EG25Radio.cpp b/src/MTS_IO_EG25Radio.cpp new file mode 100644 index 0000000..aa5d453 --- /dev/null +++ b/src/MTS_IO_EG25Radio.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2019 by Multi-Tech Systems + * + * This file is part of libmts-io. + * + * libmts-io is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * libmts-io is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with libmts-io. If not, see <http://www.gnu.org/licenses/>. + * + */ + + +#include <mts/MTS_IO_EG25Radio.h> + +using namespace MTS::IO; + +const std::string EG25Radio::MODEL_NAME("EG25"); + +EG25Radio::EG25Radio(const std::string& sPort) +: QuectelRadio(MODEL_NAME, sPort) +{ + +} + +EG25Radio::~EG25Radio() { + +} + +ICellularRadio::CODE EG25Radio::setRxDiversity(const Json::Value& jArgs) { + /* Command string for EG25 radios: AT+QCFG="diversity",(0-1) */ + if (jArgs["enabled"].asString() != "1" && jArgs["enabled"].asString() != "0") { + return FAILURE; + } + std::string sCmd = "AT+QCFG=\"diversity\","; + sCmd += jArgs["enabled"].asString(); + + return sendBasicCommand(sCmd); +} + +ICellularRadio::CODE EG25Radio::getSupportedCellularModes(CELLULAR_MODES &networks) { + networks = static_cast<CELLULAR_MODES>(CELLULAR_MODE_2G | CELLULAR_MODE_3G | CELLULAR_MODE_4G); + return SUCCESS; +}
\ No newline at end of file diff --git a/src/MTS_IO_EG95Radio.cpp b/src/MTS_IO_EG95Radio.cpp index f1c040a..296f183 100644 --- a/src/MTS_IO_EG95Radio.cpp +++ b/src/MTS_IO_EG95Radio.cpp @@ -18,14 +18,8 @@ * */ - #include <mts/MTS_IO_EG95Radio.h> -#include <climits> - -#include <mts/MTS_Logger.h> -#include <mts/MTS_Text.h> - using namespace MTS::IO; const std::string EG95Radio::MODEL_NAME("EG95"); @@ -54,36 +48,4 @@ ICellularRadio::CODE EG95Radio::setRxDiversity(const Json::Value& jArgs) { ICellularRadio::CODE EG95Radio::getSupportedCellularModes(CELLULAR_MODES &networks) { networks = static_cast<CELLULAR_MODES>(CELLULAR_MODE_2G | CELLULAR_MODE_3G | CELLULAR_MODE_4G); return SUCCESS; -} - -ICellularRadio::CODE EG95Radio::setCellularMode(CELLULAR_MODES networks) { - std::string prefNet; - unsigned int prefOnly = 0, prefCount = 0; - for (int i = sizeof(networks)*CHAR_BIT-1; i>=0; --i){ - switch (1<<i & networks) { - case ICellularRadio::CELLULAR_MODE_2G: prefNet += "01" ; prefOnly = 1; prefCount++; break; - case ICellularRadio::CELLULAR_MODE_3G: prefNet += "0302"; prefOnly = 2; prefCount++; break; - case ICellularRadio::CELLULAR_MODE_4G: prefNet += "04" ; prefOnly = 3; prefCount++; break; - } - } - - std::string sCmd; - if (prefCount == 1) { // *g-only - sCmd = "AT+QCFG=\"nwscanmode\"," + std::to_string(prefOnly); - } else { // preferred - sCmd = "AT+QCFG=\"nwscanmode\",0"; - } - std::string cmdResult = sendCommand(sCmd); - if (cmdResult.find(ICellularRadio::RSP_OK) == std::string::npos) { - printError("%s| AT+QCFG=\"nwscanmode\" returned unexpected response: [%s][%s]", getName().c_str(), sCmd.c_str(), cmdResult.c_str()); - return FAILURE; - } - - sCmd = "AT+QCFG=\"nwscanseq\"," + prefNet; - cmdResult = sendCommand(sCmd); - if (cmdResult.find(ICellularRadio::RSP_OK) == std::string::npos) { - printError("%s| AT+QCFG=\"nwscanseq\" returned unexpected response: [%s][%s]", getName().c_str(), sCmd.c_str(), cmdResult.c_str()); - return FAILURE; - } - return SUCCESS; -} +}
\ No newline at end of file diff --git a/src/MTS_IO_ICellularRadio.cpp b/src/MTS_IO_ICellularRadio.cpp index 53c8faa..c9bed33 100644 --- a/src/MTS_IO_ICellularRadio.cpp +++ b/src/MTS_IO_ICellularRadio.cpp @@ -207,6 +207,24 @@ MTS::IO::ICellularRadio::CODE MTS::IO::ICellularRadio::convertModelToMtsShortCod eCode = ERROR; } } + } else if (sModel.find("EG25") == 0) { + if (NULL == radioObject) { + sCode = VALUE_NOT_SUPPORTED; + eCode = ERROR; + } else { + std::string sValue; + eCode = radioObject->getFirmware(sValue); + if (eCode != SUCCESS) { + sCode = VALUE_NOT_SUPPORTED; + eCode = ERROR; + } else if (sValue.find("EG25G") != std::string::npos) { + sCode = "L4G1"; + eCode = SUCCESS; + } else { + sCode = VALUE_NOT_SUPPORTED; + eCode = ERROR; + } + } } else { sCode = VALUE_NOT_SUPPORTED; printError("RADIO| Could not identify MTS short code from model. [%s]", sModel.c_str()); @@ -300,6 +318,9 @@ MTS::IO::ICellularRadio::CODE MTS::IO::ICellularRadio::convertModelToType(const } else if (sModel.find("EG95") == 0) { sType = VALUE_TYPE_LTE; eCode = SUCCESS; + } else if (sModel.find("EG25") == 0) { + sType = VALUE_TYPE_LTE; + eCode = SUCCESS; } else { sType = VALUE_TYPE_GSM; eCode = ERROR; @@ -445,6 +466,8 @@ std::string MTS::IO::ICellularRadio::extractModelFromResult(const std::string& s sModel = "CE910"; } else if(sResult.find("EG95") != std::string::npos) { sModel = "EG95"; + } else if(sResult.find("EG25") != std::string::npos) { + sModel = "EG25"; } return sModel; } diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp index c4bdc56..5024f54 100644 --- a/src/MTS_IO_QuectelRadio.cpp +++ b/src/MTS_IO_QuectelRadio.cpp @@ -20,6 +20,8 @@ #include "mts/MTS_IO_QuectelRadio.h" +#include <climits> + #include <mts/MTS_Logger.h> #include <mts/MTS_Thread.h> #include <mts/MTS_Text.h> @@ -568,3 +570,35 @@ ICellularRadio::CODE QuectelRadio::convertToActiveBand(const std::string& sQuect return SUCCESS; } + +ICellularRadio::CODE QuectelRadio::setCellularMode(CELLULAR_MODES networks) { + std::string prefNet; + unsigned int prefOnly = 0, prefCount = 0; + for (int i = sizeof(networks)*CHAR_BIT-1; i>=0; --i){ + switch (1<<i & networks) { + case ICellularRadio::CELLULAR_MODE_2G: prefNet += "01" ; prefOnly = 1; prefCount++; break; + case ICellularRadio::CELLULAR_MODE_3G: prefNet += "0302"; prefOnly = 2; prefCount++; break; + case ICellularRadio::CELLULAR_MODE_4G: prefNet += "04" ; prefOnly = 3; prefCount++; break; + } + } + + std::string sCmd; + if (prefCount == 1) { // *g-only + sCmd = "AT+QCFG=\"nwscanmode\"," + std::to_string(prefOnly); + } else { // preferred + sCmd = "AT+QCFG=\"nwscanmode\",0"; + } + std::string cmdResult = sendCommand(sCmd); + if (cmdResult.find(ICellularRadio::RSP_OK) == std::string::npos) { + printError("%s| AT+QCFG=\"nwscanmode\" returned unexpected response: [%s][%s]", getName().c_str(), sCmd.c_str(), cmdResult.c_str()); + return FAILURE; + } + + sCmd = "AT+QCFG=\"nwscanseq\"," + prefNet; + cmdResult = sendCommand(sCmd); + if (cmdResult.find(ICellularRadio::RSP_OK) == std::string::npos) { + printError("%s| AT+QCFG=\"nwscanseq\" returned unexpected response: [%s][%s]", getName().c_str(), sCmd.c_str(), cmdResult.c_str()); + return FAILURE; + } + return SUCCESS; +} |