From 53efcef2e2f521135b323e194c45f1d9fa7b5d5d Mon Sep 17 00:00:00 2001 From: Maksym Telychko Date: Thu, 6 Jun 2019 14:45:58 +0300 Subject: [MTS-MTQ] refactoring: namespace usage Using identificators in appropriate namespace --- include/mts/MTS_IO_ME910C1WWRadio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_ME910C1WWRadio.h b/include/mts/MTS_IO_ME910C1WWRadio.h index bfbb8a6..6612d83 100644 --- a/include/mts/MTS_IO_ME910C1WWRadio.h +++ b/include/mts/MTS_IO_ME910C1WWRadio.h @@ -33,8 +33,8 @@ namespace MTS { ME910C1WWRadio(const std::string& sPort); virtual ~ME910C1WWRadio(){}; - CellularRadio::CODE setActiveFirmware(const Json::Value& jArgs); - CellularRadio::CODE getActiveFirmware(std::string& sFwId); + CODE setActiveFirmware(const Json::Value& jArgs); + CODE getActiveFirmware(std::string& sFwId); protected: -- cgit v1.2.3 From da563a985ccb0b5f316b44e35aabd511687ff4bf Mon Sep 17 00:00:00 2001 From: Maksym Telychko Date: Thu, 6 Jun 2019 16:03:44 +0300 Subject: [MTS-MTQ] refactoring: added quectel empty classes, CellularRadio moved to TelitRadio --- include/mts/MTS_IO_CdmaRadio.h | 4 +- include/mts/MTS_IO_CellularRadio.h | 501 +----------------------------- include/mts/MTS_IO_CellularRadioFactory.h | 42 +-- include/mts/MTS_IO_EG95Radio.h | 15 + include/mts/MTS_IO_GE910Radio.h | 4 +- include/mts/MTS_IO_HE910Radio.h | 4 +- include/mts/MTS_IO_ICellularRadio.h | 399 ++++++++++++++++++++++++ include/mts/MTS_IO_LE866Radio.h | 4 +- include/mts/MTS_IO_LE910Radio.h | 4 +- include/mts/MTS_IO_ME910Radio.h | 4 +- include/mts/MTS_IO_QuectelRadio.h | 15 + include/mts/MTS_IO_TelitRadio.h | 496 +++++++++++++++++++++++++++++ 12 files changed, 960 insertions(+), 532 deletions(-) create mode 100644 include/mts/MTS_IO_EG95Radio.h create mode 100644 include/mts/MTS_IO_ICellularRadio.h create mode 100644 include/mts/MTS_IO_QuectelRadio.h create mode 100644 include/mts/MTS_IO_TelitRadio.h (limited to 'include') diff --git a/include/mts/MTS_IO_CdmaRadio.h b/include/mts/MTS_IO_CdmaRadio.h index 448cdc7..7cdba02 100644 --- a/include/mts/MTS_IO_CdmaRadio.h +++ b/include/mts/MTS_IO_CdmaRadio.h @@ -29,12 +29,12 @@ #ifndef MTS_IO_CDMARADIO_H_ #define MTS_IO_CDMARADIO_H_ -#include +#include namespace MTS { namespace IO { - class CdmaRadio : public CellularRadio { + class CdmaRadio : public TelitRadio { public: virtual ~CdmaRadio(); diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 007c130..1378612 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -29,510 +29,13 @@ #ifndef MTS_IO_CELLULARRADIO_H_ #define MTS_IO_CELLULARRADIO_H_ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -typedef struct -{ - const char *name; - int32_t low; - int32_t high; -} *pNameRangeMap, nameRangeMap; - -static const unsigned int NUM_GSM_BANDS = 7; -static const unsigned int NUM_WCDMA_BANDS = 6; -static const unsigned int NUM_LTE_BANDS = 42; - -// http://niviuk.free.fr/gsm_band.php -static const nameRangeMap GSMband[] = -{ - {"GSM 450", 259, 293}, {"GSM 480", 306, 340}, - {"GSM 750", 438, 511}, {"GSM 850", 128, 251}, - {"GSM 900 P", 1, 124}, {"GSM 900 E/R", 955, 1023}, - {"GSM DCS 1800/1900", 512, 885}, - -}; - -// http://niviuk.free.fr/umts_band.php -static const nameRangeMap WCDMAband[] = -{ - {"BAND I", 10592, 10838}, {"BAND II", 9662, 9938}, - {"BAND III", 1162, 1513}, {"BAND IV", 1537, 1738}, - {"BAND V", 4357, 4458}, {"BAND VI", 4387, 4413} -}; - -// http://niviuk.free.fr/lte_band.php -static const nameRangeMap EULTRAband[] = -{ - {"EUTRAN BAND1", 0, 599}, {"EUTRAN BAND2", 600, 1199}, - {"EUTRAN BAND3", 1200, 1949}, {"EUTRAN BAND4", 1950, 2399}, - {"EUTRAN BAND5", 2400, 2649}, {"EUTRAN BAND6", 2650, 2749}, - {"EUTRAN BAND7", 2750, 3449}, {"EUTRAN BAND8", 3450, 3799}, - {"EUTRAN BAND9", 3800, 4149}, {"EUTRAN BAND10", 4150, 4749}, - {"EUTRAN BAND11", 4750, 4999}, {"EUTRAN BAND12", 5000, 5179}, - {"EUTRAN BAND13", 5180, 5279}, {"EUTRAN BAND14", 5280, 5379}, - {"EUTRAN BAND17", 5730, 5849}, {"EUTRAN BAND18", 5850, 5999}, - {"EUTRAN BAND19", 6000, 6149}, {"EUTRAN BAND20", 6150, 6449}, - {"EUTRAN BAND21", 6450, 6525}, {"EUTRAN BAND22", 6600, 7399}, - {"EUTRAN BAND23", 7500, 7699}, {"EUTRAN BAND24", 7700, 8039}, - {"EUTRAN BAND25", 8040, 8689}, {"EUTRAN BAND26", 8690, 9039}, - {"EUTRAN BAND27", 9040, 9209}, {"EUTRAN BAND28", 9210, 9659}, - {"EUTRAN BAND29", 9660, 9769}, {"EUTRAN BAND30", 9770, 9869}, - {"EUTRAN BAND31", 9870, 9919}, {"EUTRAN BAND32", 9920, 10359}, - {"EUTRAN BAND33", 36000, 36199}, {"EUTRAN BAND34", 36200, 36349}, - {"EUTRAN BAND35", 36350, 36949}, {"EUTRAN BAND36", 36950, 37549}, - {"EUTRAN BAND37", 37550, 37749}, {"EUTRAN BAND38", 37750, 38249}, - {"EUTRAN BAND39", 38250, 38649}, {"EUTRAN BAND40", 38650, 39649}, - {"EUTRAN BAND41", 39650, 41589}, {"EUTRAN BAND42", 41590, 43589}, - {"EUTRAN BAND43", 43590, 45589}, {"EUTRAN BAND44", 45590, 46589} -}; +#include namespace MTS { namespace IO { - class CellularRadio : NonCopyable { - - public: - static const std::string DEFAULT_RADIO_PORT; - static const std::string DEFAULT_RADIO_DIR; - - static const std::string VALUE_UNKNOWN; - static const std::string VALUE_UNAVAILABLE; - static const std::string VALUE_NOT_SUPPORTED; - - //Special Payload Characters - static const char ETX; //Ends socket connection - static const char DLE; //Escapes ETX and DLE within Payload - static const char CR; - static const char NL; - static const char CTRL_Z; - - static const std::string RSP_OK; - static const std::string RSP_ERROR; - - //Registration Values - enum REGISTRATION : uint8_t { - NOT_REGISTERED = 0, - REGISTERED = 1, - SEARCHING=2, - DENIED=3, - UNKNOWN=4, - ROAMING=5 - }; - - enum SERVICEDOMAIN : uint8_t { - NO_SERVICE = 0, - CS_ONLY = 1, - PS_ONLY = 2, - CSPS = 3 - }; - - enum ACTIVEBAND : uint8_t { - GSM_850 = 0, - GSM_900 = 1, - DCS_1800 = 2, - PCS_1900 = 3 - }; - - enum CODE : uint8_t { - SUCCESS = 0, - ERROR, - FAILURE, - NO_RESPONSE, - NOT_APPLICABLE, - INVALID_ARGS - }; - - enum SIMSTATUS : uint8_t { - READY = 0, - LOCKED, - BLOCKED, - NOT_INSERTED - }; - - static const std::string VALUE_NOT_REGISTERED; - static const std::string VALUE_REGISTERED; - static const std::string VALUE_SEARCHING; - static const std::string VALUE_DENIED; - static const std::string VALUE_ROAMING; - - //Static Data - static const std::string KEY_TYPE; //!< GSM or CDMA - static const std::string KEY_CODE; //!< Product Code : H5, H6, C2, EV3, G3 - static const std::string KEY_MODEL; //!< Model : HE910, CE910, DE910, GE910 - static const std::string KEY_MANUFACTURER; //!< Manufacturer: Telit - static const std::string KEY_HARDWARE; //!< Radio Hardware Version - static const std::string KEY_FIRMWARE; //!< Radio Firmware Version - static const std::string KEY_FIRMWARE_BUILD;//!< Radio Firmware Build - static const std::string KEY_IMEI; //!< International Mobile Station Equipment Identity - static const std::string KEY_MEID; //!< Mobile Equipment Identifier - static const std::string KEY_IMSI; //!< International Mobile Subscriber Identity - static const std::string KEY_MSID; //!< Mobil Station ID (MSID) aka MIN aka MSIN aka Last few digits of IMSI - static const std::string KEY_MDN; //!< Mobile Directory Number : Actual phone number dialed to reach radio - static const std::string KEY_CARRIER; //!< Cellular Service Provider (Home Network) - static const std::string KEY_ICCID; //!< Integrated Circuit Card Identifier - static const std::string KEY_MSL; //!< Master Subsidy Lock - - - //Network Status Data - static const std::string KEY_ROAMING; //!< Indicates whether or not using Home Network - static const std::string KEY_DATETIME; //!< Date and Time from tower - static const std::string KEY_SERVICE; //!< Service Connection Type [GPRS, EGPRS, WCDMA, HSDPA, 1xRTT, EVDO] - static const std::string KEY_NETWORK; //!< Cellular Service Provider - static const std::string KEY_NETWORK_REG; //!< Network Registration - static const std::string KEY_CID; //!< Cellular ID (Tower) in HEX - static const std::string KEY_LAC; //!< Location Area Code in HEX - static const std::string KEY_RAC; //!< Routing Area Code in HEX - static const std::string KEY_RSSI; //!< Received Signal Strength Indication - static const std::string KEY_RSSIDBM; //!< Received Signal Strength Indication in dBm - static const std::string KEY_MCC; //!< Mobile Country Code - static const std::string KEY_MNC; //!< Mobile Network (Operator) Code - static const std::string KEY_CHANNEL; //!< ARFCN or UARFCN Assigned Radio Channel - static const std::string KEY_TXPWR; //!< Transmit Power - static const std::string KEY_PSC; //!< Active Primary Synchronization Code (PSC) - static const std::string KEY_ECIO; //!< Active Ec/Io (chip energy per total wideband power in dBm) - static const std::string KEY_RSCP; //!< Active RSCP (Received Signal Code Power in dBm) - static const std::string KEY_DRX; //!< Discontinuous reception cycle length (ms) - static const std::string KEY_MM; //!< Mobility Management State - static const std::string KEY_RR; //!< Radio Resource State - static const std::string KEY_NOM; //!< Network Operator Mode - static const std::string KEY_ABND; //!< Active Band - static const std::string KEY_BLER; //!< Block Error Rate (percentage) - static const std::string KEY_SD; //!< Service Domain - static const std::string KEY_DEBUG; //!< Debug Information - - static const std::string KEY_MIP; //!< Mobile IP Information - static const std::string KEY_MIP_ID; //!< MIP Profile ID - static const std::string KEY_MIP_ENABLED; //!< MIP Profile Enabled/Disabled - static const std::string KEY_MIP_NAI; //!< Network Access Identifier - static const std::string KEY_MIP_HOMEADDRESS; //!< Home Address - static const std::string KEY_MIP_PRIMARYHA; //!< Primary Home Agent - static const std::string KEY_MIP_SECONDARYHA; //!< Secondary Home Agent - static const std::string KEY_MIP_MNAAASPI; //!< Mobile Node Authentication, Authorization, and Accounting Server Security Parameter Index - static const std::string KEY_MIP_MNHASPI; //!< Mobile Node Home Agent Security Server Parameter Index - static const std::string KEY_MIP_REVTUN; //!< Reverse Tunneling Enabled - static const std::string KEY_MIP_MNAAASS; //!< Mobile Node Authentication, Authorization, and Accounting Server Shared Secret - static const std::string KEY_MIP_MNHASS; //!< Mobile Node Home Agent Shared Secret - - - //Values - Type - static const std::string VALUE_TYPE_LTE; - static const std::string VALUE_TYPE_GSM; - static const std::string VALUE_TYPE_CDMA; - - //Values - Carrier - static const std::string VALUE_CARRIER_VERIZON; - static const std::string VALUE_CARRIER_AERIS; - static const std::string VALUE_CARRIER_SPRINT; - static const std::string VALUE_CARRIER_USCELLULAR; - static const std::string VALUE_CARRIER_ATT; - static const std::string VALUE_CARRIER_TMOBILE; - - static const std::string VALUE_SD_NO_SERVICE; - static const std::string VALUE_SD_CS_ONLY; - static const std::string VALUE_SD_PS_ONLY; - static const std::string VALUE_SD_CSPS; - - static const std::string VALUE_ABND_GSM_850; - static const std::string VALUE_ABND_GSM_900; - static const std::string VALUE_ABND_DCS_1800; - static const std::string VALUE_ABND_PCS_1900; - - static const std::vector DEFAULT_BAIL_STRINGS; - - typedef std::function IsNeedMoreData; - typedef std::function UpdateCb; - - virtual ~CellularRadio(); - - virtual bool initialize(uint32_t iTimeoutMillis = 5000); - virtual bool resetRadio(uint32_t iTimeoutMillis = 5000); - virtual bool resetConnection(uint32_t iTimeoutMillis = 5000); - virtual void shutdown(); - - const std::string& getName() const; - - virtual CODE getModel(std::string& sModel); - static CODE convertModelToType(const std::string& sModel, std::string& sType); - static CODE convertModelToMtsShortCode(const std::string& sModel, std::string& sCode, CellularRadio *radioObj = NULL); - static CODE convertServiceDomainToString(SERVICEDOMAIN eSd, std::string& sSd); - static CODE convertActiveBandToString(ACTIVEBAND eBand, std::string& sBand); - - virtual CODE getFirmware(std::string& sFirmware); - virtual CODE getFirmwareBuild(std::string& sFirmwareBuild); - virtual CODE getHardware(std::string& sHardware); - virtual CODE getManufacturer(std::string& sManufacturer); - virtual CODE getImei(std::string& sImei); - virtual CODE getMeid(std::string& sMeid); - virtual CODE getImsi(std::string& sImsi); - virtual CODE getSimStatus(std::string& sSimStatus); - virtual CODE getIccid(std::string& sIccid); - virtual CODE getService(std::string& sService); - virtual CODE getLac(std::string& sLac); - virtual CODE getMdn(std::string& sMdn); - virtual CODE getMsid(std::string& sMsid); - virtual CODE getType(std::string& sType); - virtual CODE getCarrier(std::string& sCarrier); - virtual CODE getNetwork(std::string& sNetwork); - virtual CODE getTower(std::string& sTower); - virtual CODE getTime(std::string& sDate, std::string& sTime, std::string& sTimeZone); - virtual CODE getRoaming(bool& bRoaming); - - virtual CODE getSignalStrength(int32_t& iRssi); - virtual CODE getModemLocation(std::string& sLocation); - virtual CODE convertSignalStrengthTodBm(const int32_t& iRssi, int32_t& dBm); - virtual CODE convertdBmToSignalStrength(const int32_t& dBm, int32_t& iRssi); - - virtual CODE getRegistration(REGISTRATION& eRegistration); - virtual CODE convertRegistrationToString(REGISTRATION eRegistration, std::string& sRegistration); - - //! Gather details of the radio's Mobile IP Profile - /*! - \param Json::Value object that will be populated with MIP data - \return Returns result code of gathering MIP - */ - virtual CODE getMipProfile(Json::Value& jMipProfile); - - /* - * jArgs = { - * "msl" : "Master Subsidy Lock (Aeris, Sprint): STRING" - * } - */ - virtual CODE validateMsl(const Json::Value& jArgs); - - /* - * jArgs = { - * "mdn" : "Mobile Directory Number : STRING", - * "msl" : "[OPTIONAL] Master Subsidy Lock (Aeris, Sprint): STRING" - * } - */ - virtual CODE setMdn(const Json::Value& jArgs); - - /* - * jArgs = { - * "msid" : "Mobil Station ID (MSID) aka MIN aka MSIN : STRING", - * "msl" : "[OPTIONAL] Master Subsidy Lock (Aeris, Sprint): STRING" - * } - */ - virtual CODE setMsid(const Json::Value& jArgs); - - /* - * jArgs = { - * "activeProfile" : "Set active profile: STRING" - * } - */ - virtual CODE setMipActiveProfile(const Json::Value& jArgs); - - /* - * jArgs = { - * "nai" : "Network Access Identifier : STRING" - * } - */ - virtual CODE setMipNai(const Json::Value& jArgs); - - /* - * jArgs = { - * "homeIp" : "Home Address : STRING" - * } - */ - virtual CODE setMipHomeIp(const Json::Value& jArgs); - - /* - * jArgs = { - * "primaryHa" : "Primary Home Agent : STRING" - * } - */ - virtual CODE setMipPrimaryHa(const Json::Value& jArgs); - - /* - * jArgs = { - * "secondaryHa" : "Secondary Home Agent : STRING" - * } - */ - virtual CODE setMipSecondaryHa(const Json::Value& jArgs); - - /* - * jArgs = { - * "mnAaaSpi" : "Mobile Node Authentication, Authorization, and Accounting Server Security Parameter Index : STRING" - * } - */ - virtual CODE setMipMnAaaSpi(const Json::Value& jArgs); - - /* - * jArgs = { - * "mnHaSpi" : "Mobile Node Home Agent Security Server Parameter Index : STRING" - * } - */ - virtual CODE setMipMnHaSpi(const Json::Value& jArgs); - - /* - * jArgs = { - * "revTun" : "[DESCRIPTION] : STRING" - * } - */ - virtual CODE setMipRevTun(const Json::Value& jArgs); - - /* - * jArgs = { - * "mnAaaSs" : "Mobile Node Authentication, Authorization, and Accounting Server Shared Secret : STRING" - * } - */ - virtual CODE setMipMnAaaSs(const Json::Value& jArgs); - - /* - * jArgs = { - * "mnHaSs" : "Mobile Node Home Agent Shared Secret : STRING" - * } - */ - virtual CODE setMipMnHaSs(const Json::Value& jArgs); - - /* - * jArgs = null - */ - virtual CODE updateDc(const Json::Value& jArgs, UpdateCb& stepCb); - - /* - * jArgs = null - */ - virtual CODE updatePrl(const Json::Value& jArgs, UpdateCb& stepCb); - - /* - * jArgs = null - */ - virtual CODE updateFumo(const Json::Value& jArgs, UpdateCb& stepCb); - - /* - * jArgs = { - * "msl" : "Master Subsidy Lock (Sprint): STRING" - * } - */ - virtual CODE resetHfa(const Json::Value& jArgs, UpdateCb& stepCb); - - /* - * jArgs = { - * "mdn" : "Mobile Directory Number (Aeris): STRING" - * "msid" : "Mobile Station ID (Aeris): STRING" - * } - */ - virtual CODE activate(const Json::Value& jArgs, UpdateCb& stepCb); - - /* - * jArgs = { - * "enabled" : "RX Diversity Enabled ("0" or "1"): STRING" - * } - */ - virtual CODE setRxDiversity(const Json::Value& jArgs)=0; - /* - * jArgs = { - * "fwid" : "Firmware Image To Be Enabled: STRING" - * } - */ - virtual CODE setActiveFirmware(const Json::Value& jArgs); - virtual CODE getActiveFirmware(std::string& sFwId); - - virtual CODE getEcho(bool& bEnabled); - virtual CODE setEcho(bool bEnabled = true); - - virtual CODE getStaticInformation(Json::Value& jData); - virtual CODE getNetworkStatus(Json::Value& jData); - - virtual CODE sendBasicCommand(const std::string& sCmd, int32_t timeoutMillis = 100, const char& ESC = CR); - - virtual std::string sendCommand(const std::string& sCmd, - const std::vector& vBail = DEFAULT_BAIL_STRINGS, - int32_t timeoutMillis = 100, - const char& ESC = CR); - - - static std::string sendCommand(MTS::AutoPtr& apIo, - const std::string& sCmd, - const std::vector& vBail = DEFAULT_BAIL_STRINGS, - int32_t timeoutMillis = 100, - const char& ESC = CR); - - virtual std::string sendCommand(const std::string& sCmd, - IsNeedMoreData& isNeedMoreData, - int32_t timeoutMillis = 100, - const char& ESC = CR); - - static std::string sendCommand(MTS::AutoPtr& apIo, - const std::string& sCmd, - IsNeedMoreData& isNeedMoreData, - int32_t timeoutMillis = 100, - const char& ESC = CR); - - static CODE test(MTS::AutoPtr& apIo, uint32_t timeoutSeconds = 30); - - static std::string extractModelFromResult(const std::string& sResult); - static std::string getCodeAsString(CODE code); - - protected: - - CellularRadio(const std::string& sName, const std::string& sRadioPort); - - virtual bool getCarrierFromFirmware(const std::string& sFirmware, std::string& sCarrier); - virtual bool getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware); - - virtual void getCommonNetworkStats(Json::Value& jData); - - void initMipProfile(Json::Value& jData); - - bool splitAndAssign(const std::string& sLine, const std::string& sKey, Json::Value& jParent, const std::string& sJsonKey, Json::ValueType eType = Json::ValueType::stringValue); - - - - private: - class RadioBandMap : NonCopyable { - public: - RadioBandMap() - { - m_sChannel = CellularRadio::VALUE_UNKNOWN; - m_iChannel = 0; - m_sRadioType = CellularRadio::VALUE_UNKNOWN; - } - - RadioBandMap(const std::string &channel, const std::string &radioType) : - m_sChannel(channel), - m_sRadioType(radioType) - { - m_iChannel = strtol(m_sChannel.c_str(), NULL, 10); - } - - virtual ~RadioBandMap() {} - - const char *getRadioBandName(); - const char *getRadioBandName(const std::string &channel, const std::string &radioType); - - private: - - const char *getLTEBand(const int channel); - const char *getCDMABand(const int channel); - const char *getGSMBand(const int channel); - - std::string m_sChannel; - int m_iChannel; - std::string m_sRadioType; - }; - - std::string m_sName; - std::string m_sRadioPort; - std::string m_sFirmware; - std::string m_sCarrier; - MTS::AutoPtr m_apIo; - - bool m_bEchoEnabled; - bool m_bEnableEchoOnClose; + class CellularRadio : public ICellularRadio { - std::string queryLteLac(); - std::string queryCGREGstring(); - void setCGREG(std::string value); }; } } diff --git a/include/mts/MTS_IO_CellularRadioFactory.h b/include/mts/MTS_IO_CellularRadioFactory.h index 49f63bd..501f314 100644 --- a/include/mts/MTS_IO_CellularRadioFactory.h +++ b/include/mts/MTS_IO_CellularRadioFactory.h @@ -21,7 +21,7 @@ #ifndef MTS_IO_CELLULARRADIOFACTORY_H_ #define MTS_IO_CELLULARRADIOFACTORY_H_ -#include +#include #include #include @@ -39,26 +39,26 @@ namespace MTS { CellularRadioFactory(); virtual ~CellularRadioFactory() {}; - virtual CellularRadio* create(const std::string& sModel, const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - - virtual CellularRadio* createHE910D(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createHE910EUD(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910NAG(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910C4NF(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910NA1(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910SVG(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910EUG(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910C4EU(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910EU1(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910C1NS(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910C1AP(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createME910C1NA(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createME910C1NV(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createME910C1WW(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createGE910(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createDE910(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createCE910(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE866A1JS(const std::string& sPort = CellularRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* create(const std::string& sModel, const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + + virtual CellularRadio* createHE910D(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createHE910EUD(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createLE910NAG(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createLE910C4NF(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createLE910NA1(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createLE910SVG(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createLE910EUG(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createLE910C4EU(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createLE910EU1(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createLE910C1NS(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createLE910C1AP(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createME910C1NA(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createME910C1NV(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createME910C1WW(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createGE910(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createDE910(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createCE910(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual CellularRadio* createLE866A1JS(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); protected: typedef MTS::IO::CellularRadio* (CellularRadioFactory::*CREATEFUNCPTR)(const std::string& sPort); diff --git a/include/mts/MTS_IO_EG95Radio.h b/include/mts/MTS_IO_EG95Radio.h new file mode 100644 index 0000000..07db773 --- /dev/null +++ b/include/mts/MTS_IO_EG95Radio.h @@ -0,0 +1,15 @@ +#ifndef MTS_IO_EG95RADIO_H +#define MTS_IO_EG95RADIO_H + +#include "mts/MTS_IO_QuectelRadio.h" + +namespace MTS { + namespace IO { + class EG95Radio : public QuectelRadio + { + + }; + } +} + +#endif diff --git a/include/mts/MTS_IO_GE910Radio.h b/include/mts/MTS_IO_GE910Radio.h index 27efbac..4904ea7 100644 --- a/include/mts/MTS_IO_GE910Radio.h +++ b/include/mts/MTS_IO_GE910Radio.h @@ -29,12 +29,12 @@ #ifndef MTS_IO_GE910RADIO_H_ #define MTS_IO_GE910RADIO_H_ -#include +#include namespace MTS { namespace IO { - class GE910Radio : public CellularRadio { + class GE910Radio : public TelitRadio { public: static const std::string MODEL_NAME; diff --git a/include/mts/MTS_IO_HE910Radio.h b/include/mts/MTS_IO_HE910Radio.h index e6fc73c..c8700da 100644 --- a/include/mts/MTS_IO_HE910Radio.h +++ b/include/mts/MTS_IO_HE910Radio.h @@ -29,12 +29,12 @@ #ifndef MTS_IO_HE910RADIO_H_ #define MTS_IO_HE910RADIO_H_ -#include +#include namespace MTS { namespace IO { - class HE910Radio : public CellularRadio { + class HE910Radio : public TelitRadio { public: diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h new file mode 100644 index 0000000..da86946 --- /dev/null +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -0,0 +1,399 @@ +#ifndef MTS_IO_ICELLULARRADIO_H +#define MTS_IO_ICELLULARRADIO_H + +#include +#include +#include + +#include + +#include +#include + +namespace MTS { + namespace IO { + class ICellularRadio; + namespace { + + static const std::string DEFAULT_RADIO_PORT; + static const std::string DEFAULT_RADIO_DIR; + + static const std::string VALUE_UNKNOWN; + static const std::string VALUE_UNAVAILABLE; + static const std::string VALUE_NOT_SUPPORTED; + + //Special Payload Characters + static const char ETX = 0; //Ends socket connection + static const char DLE = 0; //Escapes ETX and DLE within Payload + static const char CR = 0; + static const char NL = 0; + static const char CTRL_Z = 0; + + static const std::string RSP_OK; + static const std::string RSP_ERROR; + + static const std::string VALUE_NOT_REGISTERED; + static const std::string VALUE_REGISTERED; + static const std::string VALUE_SEARCHING; + static const std::string VALUE_DENIED; + static const std::string VALUE_ROAMING; + + //Static Data + static const std::string KEY_TYPE; //!< GSM or CDMA + static const std::string KEY_CODE; //!< Product Code : H5, H6, C2, EV3, G3 + static const std::string KEY_MODEL; //!< Model : HE910, CE910, DE910, GE910 + static const std::string KEY_MANUFACTURER; //!< Manufacturer: Telit + static const std::string KEY_HARDWARE; //!< Radio Hardware Version + static const std::string KEY_FIRMWARE; //!< Radio Firmware Version + static const std::string KEY_FIRMWARE_BUILD;//!< Radio Firmware Build + static const std::string KEY_IMEI; //!< International Mobile Station Equipment Identity + static const std::string KEY_MEID; //!< Mobile Equipment Identifier + static const std::string KEY_IMSI; //!< International Mobile Subscriber Identity + static const std::string KEY_MSID; //!< Mobil Station ID (MSID) aka MIN aka MSIN aka Last few digits of IMSI + static const std::string KEY_MDN; //!< Mobile Directory Number : Actual phone number dialed to reach radio + static const std::string KEY_CARRIER; //!< Cellular Service Provider (Home Network) + static const std::string KEY_ICCID; //!< Integrated Circuit Card Identifier + static const std::string KEY_MSL; //!< Master Subsidy Lock + + + //Network Status Data + static const std::string KEY_ROAMING; //!< Indicates whether or not using Home Network + static const std::string KEY_DATETIME; //!< Date and Time from tower + static const std::string KEY_SERVICE; //!< Service Connection Type [GPRS, EGPRS, WCDMA, HSDPA, 1xRTT, EVDO] + static const std::string KEY_NETWORK; //!< Cellular Service Provider + static const std::string KEY_NETWORK_REG; //!< Network Registration + static const std::string KEY_CID; //!< Cellular ID (Tower) in HEX + static const std::string KEY_LAC; //!< Location Area Code in HEX + static const std::string KEY_RAC; //!< Routing Area Code in HEX + static const std::string KEY_RSSI; //!< Received Signal Strength Indication + static const std::string KEY_RSSIDBM; //!< Received Signal Strength Indication in dBm + static const std::string KEY_MCC; //!< Mobile Country Code + static const std::string KEY_MNC; //!< Mobile Network (Operator) Code + static const std::string KEY_CHANNEL; //!< ARFCN or UARFCN Assigned Radio Channel + static const std::string KEY_TXPWR; //!< Transmit Power + static const std::string KEY_PSC; //!< Active Primary Synchronization Code (PSC) + static const std::string KEY_ECIO; //!< Active Ec/Io (chip energy per total wideband power in dBm) + static const std::string KEY_RSCP; //!< Active RSCP (Received Signal Code Power in dBm) + static const std::string KEY_DRX; //!< Discontinuous reception cycle length (ms) + static const std::string KEY_MM; //!< Mobility Management State + static const std::string KEY_RR; //!< Radio Resource State + static const std::string KEY_NOM; //!< Network Operator Mode + static const std::string KEY_ABND; //!< Active Band + static const std::string KEY_BLER; //!< Block Error Rate (percentage) + static const std::string KEY_SD; //!< Service Domain + static const std::string KEY_DEBUG; //!< Debug Information + + static const std::string KEY_MIP; //!< Mobile IP Information + static const std::string KEY_MIP_ID; //!< MIP Profile ID + static const std::string KEY_MIP_ENABLED; //!< MIP Profile Enabled/Disabled + static const std::string KEY_MIP_NAI; //!< Network Access Identifier + static const std::string KEY_MIP_HOMEADDRESS; //!< Home Address + static const std::string KEY_MIP_PRIMARYHA; //!< Primary Home Agent + static const std::string KEY_MIP_SECONDARYHA; //!< Secondary Home Agent + static const std::string KEY_MIP_MNAAASPI; //!< Mobile Node Authentication, Authorization, and Accounting Server Security Parameter Index + static const std::string KEY_MIP_MNHASPI; //!< Mobile Node Home Agent Security Server Parameter Index + static const std::string KEY_MIP_REVTUN; //!< Reverse Tunneling Enabled + static const std::string KEY_MIP_MNAAASS; //!< Mobile Node Authentication, Authorization, and Accounting Server Shared Secret + static const std::string KEY_MIP_MNHASS; //!< Mobile Node Home Agent Shared Secret + + + //Values - Type + static const std::string VALUE_TYPE_LTE; + static const std::string VALUE_TYPE_GSM; + static const std::string VALUE_TYPE_CDMA; + + //Values - Carrier + static const std::string VALUE_CARRIER_VERIZON; + static const std::string VALUE_CARRIER_AERIS; + static const std::string VALUE_CARRIER_SPRINT; + static const std::string VALUE_CARRIER_USCELLULAR; + static const std::string VALUE_CARRIER_ATT; + static const std::string VALUE_CARRIER_TMOBILE; + + static const std::string VALUE_SD_NO_SERVICE; + static const std::string VALUE_SD_CS_ONLY; + static const std::string VALUE_SD_PS_ONLY; + static const std::string VALUE_SD_CSPS; + + static const std::string VALUE_ABND_GSM_850; + static const std::string VALUE_ABND_GSM_900; + static const std::string VALUE_ABND_DCS_1800; + static const std::string VALUE_ABND_PCS_1900; + + static const std::vector DEFAULT_BAIL_STRINGS; + + typedef std::function IsNeedMoreData; + typedef std::function UpdateCb; + + /* + CODE convertModelToType(const std::string& sModel, std::string& sType); + CODE convertModelToMtsShortCode(const std::string& sModel, std::string& sCode, ICellularRadio *radioObj = NULL); + CODE convertServiceDomainToString(SERVICEDOMAIN eSd, std::string& sSd); + CODE convertActiveBandToString(ACTIVEBAND eBand, std::string& sBand); + + std::string sendCommand(MTS::AutoPtr& apIo, + const std::string& sCmd, + IsNeedMoreData& isNeedMoreData, + int32_t timeoutMillis = 100, + const char& ESC = CR); + + std::string sendCommand(MTS::AutoPtr& apIo, + const std::string& sCmd, + const std::vector& vBail = DEFAULT_BAIL_STRINGS, + int32_t timeoutMillis = 100, + const char& ESC = CR); + CODE test(MTS::AutoPtr& apIo, uint32_t timeoutSeconds = 30); + + std::string extractModelFromResult(const std::string& sResult); + std::string getCodeAsString(CODE code); + */ + + } + class ICellularRadio + { + public: + //Registration Values + enum REGISTRATION : uint8_t { + NOT_REGISTERED = 0, + REGISTERED = 1, + SEARCHING=2, + DENIED=3, + UNKNOWN=4, + ROAMING=5 + }; + + enum SERVICEDOMAIN : uint8_t { + NO_SERVICE = 0, + CS_ONLY = 1, + PS_ONLY = 2, + CSPS = 3 + }; + + enum ACTIVEBAND : uint8_t { + GSM_850 = 0, + GSM_900 = 1, + DCS_1800 = 2, + PCS_1900 = 3 + }; + + enum CODE : uint8_t { + SUCCESS = 0, + ERROR, + FAILURE, + NO_RESPONSE, + NOT_APPLICABLE, + INVALID_ARGS + }; + + enum SIMSTATUS : uint8_t { + READY = 0, + LOCKED, + BLOCKED, + NOT_INSERTED + }; + virtual ~ICellularRadio() = 0; + + virtual bool initialize(uint32_t iTimeoutMillis = 5000) = 0; + virtual bool resetRadio(uint32_t iTimeoutMillis = 5000) = 0; + virtual bool resetConnection(uint32_t iTimeoutMillis = 5000) = 0; + virtual void shutdown() = 0; + + virtual const std::string& getName() const = 0; + + virtual CODE getModel(std::string& sModel) = 0; + + virtual CODE getFirmware(std::string& sFirmware) = 0; + virtual CODE getFirmwareBuild(std::string& sFirmwareBuild) = 0; + virtual CODE getHardware(std::string& sHardware) = 0; + virtual CODE getManufacturer(std::string& sManufacturer) = 0; + virtual CODE getImei(std::string& sImei) = 0; + virtual CODE getMeid(std::string& sMeid) = 0; + virtual CODE getImsi(std::string& sImsi) = 0; + virtual CODE getSimStatus(std::string& sSimStatus) = 0; + virtual CODE getIccid(std::string& sIccid) = 0; + virtual CODE getService(std::string& sService) = 0; + virtual CODE getLac(std::string& sLac) = 0; + virtual CODE getMdn(std::string& sMdn) = 0; + virtual CODE getMsid(std::string& sMsid) = 0; + virtual CODE getType(std::string& sType) = 0; + virtual CODE getCarrier(std::string& sCarrier) = 0; + virtual CODE getNetwork(std::string& sNetwork) = 0; + virtual CODE getTower(std::string& sTower) = 0; + virtual CODE getTime(std::string& sDate, std::string& sTime, std::string& sTimeZone) = 0; + virtual CODE getRoaming(bool& bRoaming) = 0; + + virtual CODE getSignalStrength(int32_t& iRssi) = 0; + virtual CODE getModemLocation(std::string& sLocation) = 0; + virtual CODE convertSignalStrengthTodBm(const int32_t& iRssi, int32_t& dBm) = 0; + virtual CODE convertdBmToSignalStrength(const int32_t& dBm, int32_t& iRssi) = 0; + + virtual CODE getRegistration(REGISTRATION& eRegistration) = 0; + virtual CODE convertRegistrationToString(REGISTRATION eRegistration, std::string& sRegistration) = 0; + + //! Gather details of the radio's Mobile IP Profile + /*! + \param Json::Value object that will be populated with MIP data + \return Returns result code of gathering MIP + */ + virtual CODE getMipProfile(Json::Value& jMipProfile) = 0; + + /* + * jArgs = { + * "msl" : "Master Subsidy Lock (Aeris, Sprint): STRING" + * } + */ + virtual CODE validateMsl(const Json::Value& jArgs) = 0; + + /* + * jArgs = { + * "mdn" : "Mobile Directory Number : STRING", + * "msl" : "[OPTIONAL] Master Subsidy Lock (Aeris, Sprint): STRING" + * } + */ + virtual CODE setMdn(const Json::Value& jArgs) = 0; + + /* + * jArgs = { + * "msid" : "Mobil Station ID (MSID) aka MIN aka MSIN : STRING", + * "msl" : "[OPTIONAL] Master Subsidy Lock (Aeris, Sprint): STRING" + * } + */ + virtual CODE setMsid(const Json::Value& jArgs) = 0; + + /* + * jArgs = { + * "activeProfile" : "Set active profile: STRING" + * } + */ + virtual CODE setMipActiveProfile(const Json::Value& jArgs) = 0; + + /* + * jArgs = { + * "nai" : "Network Access Identifier : STRING" + * } + */ + virtual CODE setMipNai(const Json::Value& jArgs) = 0; + + /* + * jArgs = { + * "homeIp" : "Home Address : STRING" + * } + */ + virtual CODE setMipHomeIp(const Json::Value& jArgs) = 0; + + /* + * jArgs = { + * "primaryHa" : "Primary Home Agent : STRING" + * } + */ + virtual CODE setMipPrimaryHa(const Json::Value& jArgs) = 0; + + /* + * jArgs = { + * "secondaryHa" : "Secondary Home Agent : STRING" + * } + */ + virtual CODE setMipSecondaryHa(const Json::Value& jArgs) = 0; + + /* + * jArgs = { + * "mnAaaSpi" : "Mobile Node Authentication, Authorization, and Accounting Server Security Parameter Index : STRING" + * } + */ + virtual CODE setMipMnAaaSpi(const Json::Value& jArgs) = 0; + + /* + * jArgs = { + * "mnHaSpi" : "Mobile Node Home Agent Security Server Parameter Index : STRING" + * } + */ + virtual CODE setMipMnHaSpi(const Json::Value& jArgs) = 0; + + /* + * jArgs = { + * "revTun" : "[DESCRIPTION] : STRING" + * } + */ + virtual CODE setMipRevTun(const Json::Value& jArgs) = 0; + + /* + * jArgs = { + * "mnAaaSs" : "Mobile Node Authentication, Authorization, and Accounting Server Shared Secret : STRING" + * } + */ + virtual CODE setMipMnAaaSs(const Json::Value& jArgs) = 0; + + /* + * jArgs = { + * "mnHaSs" : "Mobile Node Home Agent Shared Secret : STRING" + * } + */ + virtual CODE setMipMnHaSs(const Json::Value& jArgs) = 0; + + /* + * jArgs = null + */ + virtual CODE updateDc(const Json::Value& jArgs, UpdateCb& stepCb) = 0; + + /* + * jArgs = null + */ + virtual CODE updatePrl(const Json::Value& jArgs, UpdateCb& stepCb) = 0; + + /* + * jArgs = null + */ + virtual CODE updateFumo(const Json::Value& jArgs, UpdateCb& stepCb) = 0; + + /* + * jArgs = { + * "msl" : "Master Subsidy Lock (Sprint): STRING" + * } + */ + virtual CODE resetHfa(const Json::Value& jArgs, UpdateCb& stepCb) = 0; + + /* + * jArgs = { + * "mdn" : "Mobile Directory Number (Aeris): STRING" + * "msid" : "Mobile Station ID (Aeris): STRING" + * } + */ + virtual CODE activate(const Json::Value& jArgs, UpdateCb& stepCb) = 0; + + /* + * jArgs = { + * "enabled" : "RX Diversity Enabled ("0" or "1"): STRING" + * } + */ + virtual CODE setRxDiversity(const Json::Value& jArgs) = 0; + /* + * jArgs = { + * "fwid" : "Firmware Image To Be Enabled: STRING" + * } + */ + virtual CODE setActiveFirmware(const Json::Value& jArgs) = 0; + virtual CODE getActiveFirmware(std::string& sFwId) = 0; + + virtual CODE getEcho(bool& bEnabled) = 0; + virtual CODE setEcho(bool bEnabled = true) = 0; + + virtual CODE getStaticInformation(Json::Value& jData) = 0; + virtual CODE getNetworkStatus(Json::Value& jData) = 0; + + virtual CODE sendBasicCommand(const std::string& sCmd, int32_t timeoutMillis = 100, const char& ESC = CR) = 0; + + virtual std::string sendCommand(const std::string& sCmd, + const std::vector& vBail = DEFAULT_BAIL_STRINGS, + int32_t timeoutMillis = 100, + const char& ESC = CR) = 0; + + virtual std::string sendCommand(const std::string& sCmd, + IsNeedMoreData& isNeedMoreData, + int32_t timeoutMillis = 100, + const char& ESC = CR) = 0; + + }; + } +} + +#endif diff --git a/include/mts/MTS_IO_LE866Radio.h b/include/mts/MTS_IO_LE866Radio.h index c11c5b4..2775e4d 100644 --- a/include/mts/MTS_IO_LE866Radio.h +++ b/include/mts/MTS_IO_LE866Radio.h @@ -35,12 +35,12 @@ A more elaborate description */ -#include +#include namespace MTS { namespace IO { - class LE866Radio : public CellularRadio { + class LE866Radio : public TelitRadio { public: static const std::string MODEL_NAME; diff --git a/include/mts/MTS_IO_LE910Radio.h b/include/mts/MTS_IO_LE910Radio.h index e8ac21f..35e704d 100644 --- a/include/mts/MTS_IO_LE910Radio.h +++ b/include/mts/MTS_IO_LE910Radio.h @@ -29,12 +29,12 @@ #ifndef MTS_IO_LE910RADIO_H_ #define MTS_IO_LE910RADIO_H_ -#include +#include namespace MTS { namespace IO { - class LE910Radio : public CellularRadio { + class LE910Radio : public TelitRadio { public: static const std::string MODEL_NAME; diff --git a/include/mts/MTS_IO_ME910Radio.h b/include/mts/MTS_IO_ME910Radio.h index 91cdfc6..09e8ede 100644 --- a/include/mts/MTS_IO_ME910Radio.h +++ b/include/mts/MTS_IO_ME910Radio.h @@ -21,12 +21,12 @@ #ifndef MTS_IO_ME910RADIO_H_ #define MTS_IO_ME910RADIO_H_ -#include +#include namespace MTS { namespace IO { - class ME910Radio : public CellularRadio { + class ME910Radio : public TelitRadio { public: static const std::string MODEL_NAME; diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h new file mode 100644 index 0000000..55eac60 --- /dev/null +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -0,0 +1,15 @@ +#ifndef MTS_IO_QUECTELRADIO_H +#define MTS_IO_QUECTELRADIO_H + +#include + +namespace MTS { + namespace IO { + class QuectelRadio : public CellularRadio + { + + }; + } +} + +#endif diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h new file mode 100644 index 0000000..f8fce6a --- /dev/null +++ b/include/mts/MTS_IO_TelitRadio.h @@ -0,0 +1,496 @@ +/* + * Copyright (C) 2015 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 . + * + */ + +#ifndef MTS_IO_TELITRADIO_H_ +#define MTS_IO_TELITRADIO_H_ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct +{ + const char *name; + int32_t low; + int32_t high; +} *pNameRangeMap, nameRangeMap; + +static const unsigned int NUM_GSM_BANDS = 7; +static const unsigned int NUM_WCDMA_BANDS = 6; +static const unsigned int NUM_LTE_BANDS = 42; + +// http://niviuk.free.fr/gsm_band.php +static const nameRangeMap GSMband[] = +{ + {"GSM 450", 259, 293}, {"GSM 480", 306, 340}, + {"GSM 750", 438, 511}, {"GSM 850", 128, 251}, + {"GSM 900 P", 1, 124}, {"GSM 900 E/R", 955, 1023}, + {"GSM DCS 1800/1900", 512, 885}, + +}; + +// http://niviuk.free.fr/umts_band.php +static const nameRangeMap WCDMAband[] = +{ + {"BAND I", 10592, 10838}, {"BAND II", 9662, 9938}, + {"BAND III", 1162, 1513}, {"BAND IV", 1537, 1738}, + {"BAND V", 4357, 4458}, {"BAND VI", 4387, 4413} +}; + +// http://niviuk.free.fr/lte_band.php +static const nameRangeMap EULTRAband[] = +{ + {"EUTRAN BAND1", 0, 599}, {"EUTRAN BAND2", 600, 1199}, + {"EUTRAN BAND3", 1200, 1949}, {"EUTRAN BAND4", 1950, 2399}, + {"EUTRAN BAND5", 2400, 2649}, {"EUTRAN BAND6", 2650, 2749}, + {"EUTRAN BAND7", 2750, 3449}, {"EUTRAN BAND8", 3450, 3799}, + {"EUTRAN BAND9", 3800, 4149}, {"EUTRAN BAND10", 4150, 4749}, + {"EUTRAN BAND11", 4750, 4999}, {"EUTRAN BAND12", 5000, 5179}, + {"EUTRAN BAND13", 5180, 5279}, {"EUTRAN BAND14", 5280, 5379}, + {"EUTRAN BAND17", 5730, 5849}, {"EUTRAN BAND18", 5850, 5999}, + {"EUTRAN BAND19", 6000, 6149}, {"EUTRAN BAND20", 6150, 6449}, + {"EUTRAN BAND21", 6450, 6525}, {"EUTRAN BAND22", 6600, 7399}, + {"EUTRAN BAND23", 7500, 7699}, {"EUTRAN BAND24", 7700, 8039}, + {"EUTRAN BAND25", 8040, 8689}, {"EUTRAN BAND26", 8690, 9039}, + {"EUTRAN BAND27", 9040, 9209}, {"EUTRAN BAND28", 9210, 9659}, + {"EUTRAN BAND29", 9660, 9769}, {"EUTRAN BAND30", 9770, 9869}, + {"EUTRAN BAND31", 9870, 9919}, {"EUTRAN BAND32", 9920, 10359}, + {"EUTRAN BAND33", 36000, 36199}, {"EUTRAN BAND34", 36200, 36349}, + {"EUTRAN BAND35", 36350, 36949}, {"EUTRAN BAND36", 36950, 37549}, + {"EUTRAN BAND37", 37550, 37749}, {"EUTRAN BAND38", 37750, 38249}, + {"EUTRAN BAND39", 38250, 38649}, {"EUTRAN BAND40", 38650, 39649}, + {"EUTRAN BAND41", 39650, 41589}, {"EUTRAN BAND42", 41590, 43589}, + {"EUTRAN BAND43", 43590, 45589}, {"EUTRAN BAND44", 45590, 46589} +}; + +namespace MTS { + namespace IO { + + class TelitRadio : public CellularRadio { + + public: + static const std::string DEFAULT_RADIO_PORT; + static const std::string DEFAULT_RADIO_DIR; + + static const std::string VALUE_UNKNOWN; + static const std::string VALUE_UNAVAILABLE; + static const std::string VALUE_NOT_SUPPORTED; + + //Special Payload Characters + static const char ETX; //Ends socket connection + static const char DLE; //Escapes ETX and DLE within Payload + static const char CR; + static const char NL; + static const char CTRL_Z; + + static const std::string RSP_OK; + static const std::string RSP_ERROR; + + static const std::string VALUE_NOT_REGISTERED; + static const std::string VALUE_REGISTERED; + static const std::string VALUE_SEARCHING; + static const std::string VALUE_DENIED; + static const std::string VALUE_ROAMING; + + //Static Data + static const std::string KEY_TYPE; //!< GSM or CDMA + static const std::string KEY_CODE; //!< Product Code : H5, H6, C2, EV3, G3 + static const std::string KEY_MODEL; //!< Model : HE910, CE910, DE910, GE910 + static const std::string KEY_MANUFACTURER; //!< Manufacturer: Telit + static const std::string KEY_HARDWARE; //!< Radio Hardware Version + static const std::string KEY_FIRMWARE; //!< Radio Firmware Version + static const std::string KEY_FIRMWARE_BUILD;//!< Radio Firmware Build + static const std::string KEY_IMEI; //!< International Mobile Station Equipment Identity + static const std::string KEY_MEID; //!< Mobile Equipment Identifier + static const std::string KEY_IMSI; //!< International Mobile Subscriber Identity + static const std::string KEY_MSID; //!< Mobil Station ID (MSID) aka MIN aka MSIN aka Last few digits of IMSI + static const std::string KEY_MDN; //!< Mobile Directory Number : Actual phone number dialed to reach radio + static const std::string KEY_CARRIER; //!< Cellular Service Provider (Home Network) + static const std::string KEY_ICCID; //!< Integrated Circuit Card Identifier + static const std::string KEY_MSL; //!< Master Subsidy Lock + + + //Network Status Data + static const std::string KEY_ROAMING; //!< Indicates whether or not using Home Network + static const std::string KEY_DATETIME; //!< Date and Time from tower + static const std::string KEY_SERVICE; //!< Service Connection Type [GPRS, EGPRS, WCDMA, HSDPA, 1xRTT, EVDO] + static const std::string KEY_NETWORK; //!< Cellular Service Provider + static const std::string KEY_NETWORK_REG; //!< Network Registration + static const std::string KEY_CID; //!< Cellular ID (Tower) in HEX + static const std::string KEY_LAC; //!< Location Area Code in HEX + static const std::string KEY_RAC; //!< Routing Area Code in HEX + static const std::string KEY_RSSI; //!< Received Signal Strength Indication + static const std::string KEY_RSSIDBM; //!< Received Signal Strength Indication in dBm + static const std::string KEY_MCC; //!< Mobile Country Code + static const std::string KEY_MNC; //!< Mobile Network (Operator) Code + static const std::string KEY_CHANNEL; //!< ARFCN or UARFCN Assigned Radio Channel + static const std::string KEY_TXPWR; //!< Transmit Power + static const std::string KEY_PSC; //!< Active Primary Synchronization Code (PSC) + static const std::string KEY_ECIO; //!< Active Ec/Io (chip energy per total wideband power in dBm) + static const std::string KEY_RSCP; //!< Active RSCP (Received Signal Code Power in dBm) + static const std::string KEY_DRX; //!< Discontinuous reception cycle length (ms) + static const std::string KEY_MM; //!< Mobility Management State + static const std::string KEY_RR; //!< Radio Resource State + static const std::string KEY_NOM; //!< Network Operator Mode + static const std::string KEY_ABND; //!< Active Band + static const std::string KEY_BLER; //!< Block Error Rate (percentage) + static const std::string KEY_SD; //!< Service Domain + static const std::string KEY_DEBUG; //!< Debug Information + + static const std::string KEY_MIP; //!< Mobile IP Information + static const std::string KEY_MIP_ID; //!< MIP Profile ID + static const std::string KEY_MIP_ENABLED; //!< MIP Profile Enabled/Disabled + static const std::string KEY_MIP_NAI; //!< Network Access Identifier + static const std::string KEY_MIP_HOMEADDRESS; //!< Home Address + static const std::string KEY_MIP_PRIMARYHA; //!< Primary Home Agent + static const std::string KEY_MIP_SECONDARYHA; //!< Secondary Home Agent + static const std::string KEY_MIP_MNAAASPI; //!< Mobile Node Authentication, Authorization, and Accounting Server Security Parameter Index + static const std::string KEY_MIP_MNHASPI; //!< Mobile Node Home Agent Security Server Parameter Index + static const std::string KEY_MIP_REVTUN; //!< Reverse Tunneling Enabled + static const std::string KEY_MIP_MNAAASS; //!< Mobile Node Authentication, Authorization, and Accounting Server Shared Secret + static const std::string KEY_MIP_MNHASS; //!< Mobile Node Home Agent Shared Secret + + + //Values - Type + static const std::string VALUE_TYPE_LTE; + static const std::string VALUE_TYPE_GSM; + static const std::string VALUE_TYPE_CDMA; + + //Values - Carrier + static const std::string VALUE_CARRIER_VERIZON; + static const std::string VALUE_CARRIER_AERIS; + static const std::string VALUE_CARRIER_SPRINT; + static const std::string VALUE_CARRIER_USCELLULAR; + static const std::string VALUE_CARRIER_ATT; + static const std::string VALUE_CARRIER_TMOBILE; + + static const std::string VALUE_SD_NO_SERVICE; + static const std::string VALUE_SD_CS_ONLY; + static const std::string VALUE_SD_PS_ONLY; + static const std::string VALUE_SD_CSPS; + + static const std::string VALUE_ABND_GSM_850; + static const std::string VALUE_ABND_GSM_900; + static const std::string VALUE_ABND_DCS_1800; + static const std::string VALUE_ABND_PCS_1900; + + static const std::vector DEFAULT_BAIL_STRINGS; + + typedef std::function IsNeedMoreData; + typedef std::function UpdateCb; + + virtual ~TelitRadio(); + + virtual bool initialize(uint32_t iTimeoutMillis = 5000); + virtual bool resetRadio(uint32_t iTimeoutMillis = 5000); + virtual bool resetConnection(uint32_t iTimeoutMillis = 5000); + virtual void shutdown(); + + const std::string& getName() const; + + virtual CODE getModel(std::string& sModel); + static CODE convertModelToType(const std::string& sModel, std::string& sType); + static CODE convertModelToMtsShortCode(const std::string& sModel, std::string& sCode, TelitRadio *radioObj = NULL); + static CODE convertServiceDomainToString(SERVICEDOMAIN eSd, std::string& sSd); + static CODE convertActiveBandToString(ACTIVEBAND eBand, std::string& sBand); + + virtual CODE getFirmware(std::string& sFirmware); + virtual CODE getFirmwareBuild(std::string& sFirmwareBuild); + virtual CODE getHardware(std::string& sHardware); + virtual CODE getManufacturer(std::string& sManufacturer); + virtual CODE getImei(std::string& sImei); + virtual CODE getMeid(std::string& sMeid); + virtual CODE getImsi(std::string& sImsi); + virtual CODE getSimStatus(std::string& sSimStatus); + virtual CODE getIccid(std::string& sIccid); + virtual CODE getService(std::string& sService); + virtual CODE getLac(std::string& sLac); + virtual CODE getMdn(std::string& sMdn); + virtual CODE getMsid(std::string& sMsid); + virtual CODE getType(std::string& sType); + virtual CODE getCarrier(std::string& sCarrier); + virtual CODE getNetwork(std::string& sNetwork); + virtual CODE getTower(std::string& sTower); + virtual CODE getTime(std::string& sDate, std::string& sTime, std::string& sTimeZone); + virtual CODE getRoaming(bool& bRoaming); + + virtual CODE getSignalStrength(int32_t& iRssi); + virtual CODE getModemLocation(std::string& sLocation); + virtual CODE convertSignalStrengthTodBm(const int32_t& iRssi, int32_t& dBm); + virtual CODE convertdBmToSignalStrength(const int32_t& dBm, int32_t& iRssi); + + virtual CODE getRegistration(REGISTRATION& eRegistration); + virtual CODE convertRegistrationToString(REGISTRATION eRegistration, std::string& sRegistration); + + //! Gather details of the radio's Mobile IP Profile + /*! + \param Json::Value object that will be populated with MIP data + \return Returns result code of gathering MIP + */ + virtual CODE getMipProfile(Json::Value& jMipProfile); + + /* + * jArgs = { + * "msl" : "Master Subsidy Lock (Aeris, Sprint): STRING" + * } + */ + virtual CODE validateMsl(const Json::Value& jArgs); + + /* + * jArgs = { + * "mdn" : "Mobile Directory Number : STRING", + * "msl" : "[OPTIONAL] Master Subsidy Lock (Aeris, Sprint): STRING" + * } + */ + virtual CODE setMdn(const Json::Value& jArgs); + + /* + * jArgs = { + * "msid" : "Mobil Station ID (MSID) aka MIN aka MSIN : STRING", + * "msl" : "[OPTIONAL] Master Subsidy Lock (Aeris, Sprint): STRING" + * } + */ + virtual CODE setMsid(const Json::Value& jArgs); + + /* + * jArgs = { + * "activeProfile" : "Set active profile: STRING" + * } + */ + virtual CODE setMipActiveProfile(const Json::Value& jArgs); + + /* + * jArgs = { + * "nai" : "Network Access Identifier : STRING" + * } + */ + virtual CODE setMipNai(const Json::Value& jArgs); + + /* + * jArgs = { + * "homeIp" : "Home Address : STRING" + * } + */ + virtual CODE setMipHomeIp(const Json::Value& jArgs); + + /* + * jArgs = { + * "primaryHa" : "Primary Home Agent : STRING" + * } + */ + virtual CODE setMipPrimaryHa(const Json::Value& jArgs); + + /* + * jArgs = { + * "secondaryHa" : "Secondary Home Agent : STRING" + * } + */ + virtual CODE setMipSecondaryHa(const Json::Value& jArgs); + + /* + * jArgs = { + * "mnAaaSpi" : "Mobile Node Authentication, Authorization, and Accounting Server Security Parameter Index : STRING" + * } + */ + virtual CODE setMipMnAaaSpi(const Json::Value& jArgs); + + /* + * jArgs = { + * "mnHaSpi" : "Mobile Node Home Agent Security Server Parameter Index : STRING" + * } + */ + virtual CODE setMipMnHaSpi(const Json::Value& jArgs); + + /* + * jArgs = { + * "revTun" : "[DESCRIPTION] : STRING" + * } + */ + virtual CODE setMipRevTun(const Json::Value& jArgs); + + /* + * jArgs = { + * "mnAaaSs" : "Mobile Node Authentication, Authorization, and Accounting Server Shared Secret : STRING" + * } + */ + virtual CODE setMipMnAaaSs(const Json::Value& jArgs); + + /* + * jArgs = { + * "mnHaSs" : "Mobile Node Home Agent Shared Secret : STRING" + * } + */ + virtual CODE setMipMnHaSs(const Json::Value& jArgs); + + /* + * jArgs = null + */ + virtual CODE updateDc(const Json::Value& jArgs, UpdateCb& stepCb); + + /* + * jArgs = null + */ + virtual CODE updatePrl(const Json::Value& jArgs, UpdateCb& stepCb); + + /* + * jArgs = null + */ + virtual CODE updateFumo(const Json::Value& jArgs, UpdateCb& stepCb); + + /* + * jArgs = { + * "msl" : "Master Subsidy Lock (Sprint): STRING" + * } + */ + virtual CODE resetHfa(const Json::Value& jArgs, UpdateCb& stepCb); + + /* + * jArgs = { + * "mdn" : "Mobile Directory Number (Aeris): STRING" + * "msid" : "Mobile Station ID (Aeris): STRING" + * } + */ + virtual CODE activate(const Json::Value& jArgs, UpdateCb& stepCb); + + /* + * jArgs = { + * "enabled" : "RX Diversity Enabled ("0" or "1"): STRING" + * } + */ + virtual CODE setRxDiversity(const Json::Value& jArgs)=0; + /* + * jArgs = { + * "fwid" : "Firmware Image To Be Enabled: STRING" + * } + */ + virtual CODE setActiveFirmware(const Json::Value& jArgs); + virtual CODE getActiveFirmware(std::string& sFwId); + + virtual CODE getEcho(bool& bEnabled); + virtual CODE setEcho(bool bEnabled = true); + + virtual CODE getStaticInformation(Json::Value& jData); + virtual CODE getNetworkStatus(Json::Value& jData); + + virtual CODE sendBasicCommand(const std::string& sCmd, int32_t timeoutMillis = 100, const char& ESC = CR); + + virtual std::string sendCommand(const std::string& sCmd, + const std::vector& vBail = DEFAULT_BAIL_STRINGS, + int32_t timeoutMillis = 100, + const char& ESC = CR); + + + static std::string sendCommand(MTS::AutoPtr& apIo, + const std::string& sCmd, + const std::vector& vBail = DEFAULT_BAIL_STRINGS, + int32_t timeoutMillis = 100, + const char& ESC = CR); + + virtual std::string sendCommand(const std::string& sCmd, + IsNeedMoreData& isNeedMoreData, + int32_t timeoutMillis = 100, + const char& ESC = CR); + + static std::string sendCommand(MTS::AutoPtr& apIo, + const std::string& sCmd, + IsNeedMoreData& isNeedMoreData, + int32_t timeoutMillis = 100, + const char& ESC = CR); + + static CODE test(MTS::AutoPtr& apIo, uint32_t timeoutSeconds = 30); + + static std::string extractModelFromResult(const std::string& sResult); + static std::string getCodeAsString(CODE code); + + protected: + + TelitRadio(const std::string& sName, const std::string& sRadioPort); + + virtual bool getCarrierFromFirmware(const std::string& sFirmware, std::string& sCarrier); + virtual bool getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware); + + virtual void getCommonNetworkStats(Json::Value& jData); + + void initMipProfile(Json::Value& jData); + + bool splitAndAssign(const std::string& sLine, const std::string& sKey, Json::Value& jParent, const std::string& sJsonKey, Json::ValueType eType = Json::ValueType::stringValue); + + + + private: + class RadioBandMap { + public: + RadioBandMap() + { + m_sChannel = TelitRadio::VALUE_UNKNOWN; + m_iChannel = 0; + m_sRadioType = TelitRadio::VALUE_UNKNOWN; + } + + RadioBandMap(const std::string &channel, const std::string &radioType) : + m_sChannel(channel), + m_sRadioType(radioType) + { + m_iChannel = strtol(m_sChannel.c_str(), NULL, 10); + } + + virtual ~RadioBandMap() {} + + const char *getRadioBandName(); + const char *getRadioBandName(const std::string &channel, const std::string &radioType); + + private: + + const char *getLTEBand(const int channel); + const char *getCDMABand(const int channel); + const char *getGSMBand(const int channel); + + std::string m_sChannel; + int m_iChannel; + std::string m_sRadioType; + }; + + std::string m_sName; + std::string m_sRadioPort; + std::string m_sFirmware; + std::string m_sCarrier; + MTS::AutoPtr m_apIo; + + bool m_bEchoEnabled; + bool m_bEnableEchoOnClose; + + std::string queryLteLac(); + std::string queryCGREGstring(); + void setCGREG(std::string value); + }; + } +} + + + +#endif -- cgit v1.2.3 From 417049f51180b3b4be84fbc0d86a3c690972fb3b Mon Sep 17 00:00:00 2001 From: Maksym Telychko Date: Thu, 6 Jun 2019 18:06:43 +0300 Subject: [MTS-MTQ] refactoring: moved common consts and static methods to ICellularRadio --- include/mts/MTS_IO_ICellularRadio.h | 257 +++++++++++++++++------------------- include/mts/MTS_IO_TelitRadio.h | 114 ---------------- 2 files changed, 120 insertions(+), 251 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index da86946..257ed00 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -12,146 +12,12 @@ namespace MTS { namespace IO { - class ICellularRadio; - namespace { - - static const std::string DEFAULT_RADIO_PORT; - static const std::string DEFAULT_RADIO_DIR; - - static const std::string VALUE_UNKNOWN; - static const std::string VALUE_UNAVAILABLE; - static const std::string VALUE_NOT_SUPPORTED; - - //Special Payload Characters - static const char ETX = 0; //Ends socket connection - static const char DLE = 0; //Escapes ETX and DLE within Payload - static const char CR = 0; - static const char NL = 0; - static const char CTRL_Z = 0; - - static const std::string RSP_OK; - static const std::string RSP_ERROR; - - static const std::string VALUE_NOT_REGISTERED; - static const std::string VALUE_REGISTERED; - static const std::string VALUE_SEARCHING; - static const std::string VALUE_DENIED; - static const std::string VALUE_ROAMING; - - //Static Data - static const std::string KEY_TYPE; //!< GSM or CDMA - static const std::string KEY_CODE; //!< Product Code : H5, H6, C2, EV3, G3 - static const std::string KEY_MODEL; //!< Model : HE910, CE910, DE910, GE910 - static const std::string KEY_MANUFACTURER; //!< Manufacturer: Telit - static const std::string KEY_HARDWARE; //!< Radio Hardware Version - static const std::string KEY_FIRMWARE; //!< Radio Firmware Version - static const std::string KEY_FIRMWARE_BUILD;//!< Radio Firmware Build - static const std::string KEY_IMEI; //!< International Mobile Station Equipment Identity - static const std::string KEY_MEID; //!< Mobile Equipment Identifier - static const std::string KEY_IMSI; //!< International Mobile Subscriber Identity - static const std::string KEY_MSID; //!< Mobil Station ID (MSID) aka MIN aka MSIN aka Last few digits of IMSI - static const std::string KEY_MDN; //!< Mobile Directory Number : Actual phone number dialed to reach radio - static const std::string KEY_CARRIER; //!< Cellular Service Provider (Home Network) - static const std::string KEY_ICCID; //!< Integrated Circuit Card Identifier - static const std::string KEY_MSL; //!< Master Subsidy Lock - - - //Network Status Data - static const std::string KEY_ROAMING; //!< Indicates whether or not using Home Network - static const std::string KEY_DATETIME; //!< Date and Time from tower - static const std::string KEY_SERVICE; //!< Service Connection Type [GPRS, EGPRS, WCDMA, HSDPA, 1xRTT, EVDO] - static const std::string KEY_NETWORK; //!< Cellular Service Provider - static const std::string KEY_NETWORK_REG; //!< Network Registration - static const std::string KEY_CID; //!< Cellular ID (Tower) in HEX - static const std::string KEY_LAC; //!< Location Area Code in HEX - static const std::string KEY_RAC; //!< Routing Area Code in HEX - static const std::string KEY_RSSI; //!< Received Signal Strength Indication - static const std::string KEY_RSSIDBM; //!< Received Signal Strength Indication in dBm - static const std::string KEY_MCC; //!< Mobile Country Code - static const std::string KEY_MNC; //!< Mobile Network (Operator) Code - static const std::string KEY_CHANNEL; //!< ARFCN or UARFCN Assigned Radio Channel - static const std::string KEY_TXPWR; //!< Transmit Power - static const std::string KEY_PSC; //!< Active Primary Synchronization Code (PSC) - static const std::string KEY_ECIO; //!< Active Ec/Io (chip energy per total wideband power in dBm) - static const std::string KEY_RSCP; //!< Active RSCP (Received Signal Code Power in dBm) - static const std::string KEY_DRX; //!< Discontinuous reception cycle length (ms) - static const std::string KEY_MM; //!< Mobility Management State - static const std::string KEY_RR; //!< Radio Resource State - static const std::string KEY_NOM; //!< Network Operator Mode - static const std::string KEY_ABND; //!< Active Band - static const std::string KEY_BLER; //!< Block Error Rate (percentage) - static const std::string KEY_SD; //!< Service Domain - static const std::string KEY_DEBUG; //!< Debug Information - - static const std::string KEY_MIP; //!< Mobile IP Information - static const std::string KEY_MIP_ID; //!< MIP Profile ID - static const std::string KEY_MIP_ENABLED; //!< MIP Profile Enabled/Disabled - static const std::string KEY_MIP_NAI; //!< Network Access Identifier - static const std::string KEY_MIP_HOMEADDRESS; //!< Home Address - static const std::string KEY_MIP_PRIMARYHA; //!< Primary Home Agent - static const std::string KEY_MIP_SECONDARYHA; //!< Secondary Home Agent - static const std::string KEY_MIP_MNAAASPI; //!< Mobile Node Authentication, Authorization, and Accounting Server Security Parameter Index - static const std::string KEY_MIP_MNHASPI; //!< Mobile Node Home Agent Security Server Parameter Index - static const std::string KEY_MIP_REVTUN; //!< Reverse Tunneling Enabled - static const std::string KEY_MIP_MNAAASS; //!< Mobile Node Authentication, Authorization, and Accounting Server Shared Secret - static const std::string KEY_MIP_MNHASS; //!< Mobile Node Home Agent Shared Secret - - - //Values - Type - static const std::string VALUE_TYPE_LTE; - static const std::string VALUE_TYPE_GSM; - static const std::string VALUE_TYPE_CDMA; - - //Values - Carrier - static const std::string VALUE_CARRIER_VERIZON; - static const std::string VALUE_CARRIER_AERIS; - static const std::string VALUE_CARRIER_SPRINT; - static const std::string VALUE_CARRIER_USCELLULAR; - static const std::string VALUE_CARRIER_ATT; - static const std::string VALUE_CARRIER_TMOBILE; - - static const std::string VALUE_SD_NO_SERVICE; - static const std::string VALUE_SD_CS_ONLY; - static const std::string VALUE_SD_PS_ONLY; - static const std::string VALUE_SD_CSPS; - - static const std::string VALUE_ABND_GSM_850; - static const std::string VALUE_ABND_GSM_900; - static const std::string VALUE_ABND_DCS_1800; - static const std::string VALUE_ABND_PCS_1900; - - static const std::vector DEFAULT_BAIL_STRINGS; - - typedef std::function IsNeedMoreData; - typedef std::function UpdateCb; - - /* - CODE convertModelToType(const std::string& sModel, std::string& sType); - CODE convertModelToMtsShortCode(const std::string& sModel, std::string& sCode, ICellularRadio *radioObj = NULL); - CODE convertServiceDomainToString(SERVICEDOMAIN eSd, std::string& sSd); - CODE convertActiveBandToString(ACTIVEBAND eBand, std::string& sBand); - - std::string sendCommand(MTS::AutoPtr& apIo, - const std::string& sCmd, - IsNeedMoreData& isNeedMoreData, - int32_t timeoutMillis = 100, - const char& ESC = CR); - - std::string sendCommand(MTS::AutoPtr& apIo, - const std::string& sCmd, - const std::vector& vBail = DEFAULT_BAIL_STRINGS, - int32_t timeoutMillis = 100, - const char& ESC = CR); - CODE test(MTS::AutoPtr& apIo, uint32_t timeoutSeconds = 30); - - std::string extractModelFromResult(const std::string& sResult); - std::string getCodeAsString(CODE code); - */ - - } class ICellularRadio { public: + typedef std::function IsNeedMoreData; + typedef std::function UpdateCb; + //Registration Values enum REGISTRATION : uint8_t { NOT_REGISTERED = 0, @@ -191,6 +57,121 @@ namespace MTS { BLOCKED, NOT_INSERTED }; + + // TODO: convert functions + 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); + // XXX + + static const std::string DEFAULT_RADIO_PORT; + static const std::string DEFAULT_RADIO_DIR; + + static const std::string VALUE_UNKNOWN; + static const std::string VALUE_UNAVAILABLE; + static const std::string VALUE_NOT_SUPPORTED; + + //Special Payload Characters + static const char ETX; //Ends socket connection + static const char DLE; //Escapes ETX and DLE within Payload + static const char CR; + static const char NL; + static const char CTRL_Z; + + static const std::string RSP_OK; + static const std::string RSP_ERROR; + + static const std::string VALUE_NOT_REGISTERED; + static const std::string VALUE_REGISTERED; + static const std::string VALUE_SEARCHING; + static const std::string VALUE_DENIED; + static const std::string VALUE_ROAMING; + + //Static Data + static const std::string KEY_TYPE; //!< GSM or CDMA + static const std::string KEY_CODE; //!< Product Code : H5, H6, C2, EV3, G3 + static const std::string KEY_MODEL; //!< Model : HE910, CE910, DE910, GE910 + static const std::string KEY_MANUFACTURER; //!< Manufacturer: Telit + static const std::string KEY_HARDWARE; //!< Radio Hardware Version + static const std::string KEY_FIRMWARE; //!< Radio Firmware Version + static const std::string KEY_FIRMWARE_BUILD;//!< Radio Firmware Build + static const std::string KEY_IMEI; //!< International Mobile Station Equipment Identity + static const std::string KEY_MEID; //!< Mobile Equipment Identifier + static const std::string KEY_IMSI; //!< International Mobile Subscriber Identity + static const std::string KEY_MSID; //!< Mobil Station ID (MSID) aka MIN aka MSIN aka Last few digits of IMSI + static const std::string KEY_MDN; //!< Mobile Directory Number : Actual phone number dialed to reach radio + static const std::string KEY_CARRIER; //!< Cellular Service Provider (Home Network) + static const std::string KEY_ICCID; //!< Integrated Circuit Card Identifier + static const std::string KEY_MSL; //!< Master Subsidy Lock + + + //Network Status Data + static const std::string KEY_ROAMING; //!< Indicates whether or not using Home Network + static const std::string KEY_DATETIME; //!< Date and Time from tower + static const std::string KEY_SERVICE; //!< Service Connection Type [GPRS, EGPRS, WCDMA, HSDPA, 1xRTT, EVDO] + static const std::string KEY_NETWORK; //!< Cellular Service Provider + static const std::string KEY_NETWORK_REG; //!< Network Registration + static const std::string KEY_CID; //!< Cellular ID (Tower) in HEX + static const std::string KEY_LAC; //!< Location Area Code in HEX + static const std::string KEY_RAC; //!< Routing Area Code in HEX + static const std::string KEY_RSSI; //!< Received Signal Strength Indication + static const std::string KEY_RSSIDBM; //!< Received Signal Strength Indication in dBm + static const std::string KEY_MCC; //!< Mobile Country Code + static const std::string KEY_MNC; //!< Mobile Network (Operator) Code + static const std::string KEY_CHANNEL; //!< ARFCN or UARFCN Assigned Radio Channel + static const std::string KEY_TXPWR; //!< Transmit Power + static const std::string KEY_PSC; //!< Active Primary Synchronization Code (PSC) + static const std::string KEY_ECIO; //!< Active Ec/Io (chip energy per total wideband power in dBm) + static const std::string KEY_RSCP; //!< Active RSCP (Received Signal Code Power in dBm) + static const std::string KEY_DRX; //!< Discontinuous reception cycle length (ms) + static const std::string KEY_MM; //!< Mobility Management State + static const std::string KEY_RR; //!< Radio Resource State + static const std::string KEY_NOM; //!< Network Operator Mode + static const std::string KEY_ABND; //!< Active Band + static const std::string KEY_BLER; //!< Block Error Rate (percentage) + static const std::string KEY_SD; //!< Service Domain + static const std::string KEY_DEBUG; //!< Debug Information + + static const std::string KEY_MIP; //!< Mobile IP Information + static const std::string KEY_MIP_ID; //!< MIP Profile ID + static const std::string KEY_MIP_ENABLED; //!< MIP Profile Enabled/Disabled + static const std::string KEY_MIP_NAI; //!< Network Access Identifier + static const std::string KEY_MIP_HOMEADDRESS; //!< Home Address + static const std::string KEY_MIP_PRIMARYHA; //!< Primary Home Agent + static const std::string KEY_MIP_SECONDARYHA; //!< Secondary Home Agent + static const std::string KEY_MIP_MNAAASPI; //!< Mobile Node Authentication, Authorization, and Accounting Server Security Parameter Index + static const std::string KEY_MIP_MNHASPI; //!< Mobile Node Home Agent Security Server Parameter Index + static const std::string KEY_MIP_REVTUN; //!< Reverse Tunneling Enabled + static const std::string KEY_MIP_MNAAASS; //!< Mobile Node Authentication, Authorization, and Accounting Server Shared Secret + static const std::string KEY_MIP_MNHASS; //!< Mobile Node Home Agent Shared Secret + + + //Values - Type + static const std::string VALUE_TYPE_LTE; + static const std::string VALUE_TYPE_GSM; + static const std::string VALUE_TYPE_CDMA; + + //Values - Carrier + static const std::string VALUE_CARRIER_VERIZON; + static const std::string VALUE_CARRIER_AERIS; + static const std::string VALUE_CARRIER_SPRINT; + static const std::string VALUE_CARRIER_USCELLULAR; + static const std::string VALUE_CARRIER_ATT; + static const std::string VALUE_CARRIER_TMOBILE; + + static const std::string VALUE_SD_NO_SERVICE; + static const std::string VALUE_SD_CS_ONLY; + static const std::string VALUE_SD_PS_ONLY; + static const std::string VALUE_SD_CSPS; + + static const std::string VALUE_ABND_GSM_850; + static const std::string VALUE_ABND_GSM_900; + static const std::string VALUE_ABND_DCS_1800; + static const std::string VALUE_ABND_PCS_1900; + + static const std::vector DEFAULT_BAIL_STRINGS; + virtual ~ICellularRadio() = 0; virtual bool initialize(uint32_t iTimeoutMillis = 5000) = 0; @@ -380,6 +361,7 @@ namespace MTS { virtual CODE getStaticInformation(Json::Value& jData) = 0; virtual CODE getNetworkStatus(Json::Value& jData) = 0; + /* virtual CODE sendBasicCommand(const std::string& sCmd, int32_t timeoutMillis = 100, const char& ESC = CR) = 0; virtual std::string sendCommand(const std::string& sCmd, @@ -391,6 +373,7 @@ namespace MTS { IsNeedMoreData& isNeedMoreData, int32_t timeoutMillis = 100, const char& ESC = CR) = 0; + */ }; } diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index f8fce6a..0fdad6b 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -94,116 +94,6 @@ namespace MTS { class TelitRadio : public CellularRadio { public: - static const std::string DEFAULT_RADIO_PORT; - static const std::string DEFAULT_RADIO_DIR; - - static const std::string VALUE_UNKNOWN; - static const std::string VALUE_UNAVAILABLE; - static const std::string VALUE_NOT_SUPPORTED; - - //Special Payload Characters - static const char ETX; //Ends socket connection - static const char DLE; //Escapes ETX and DLE within Payload - static const char CR; - static const char NL; - static const char CTRL_Z; - - static const std::string RSP_OK; - static const std::string RSP_ERROR; - - static const std::string VALUE_NOT_REGISTERED; - static const std::string VALUE_REGISTERED; - static const std::string VALUE_SEARCHING; - static const std::string VALUE_DENIED; - static const std::string VALUE_ROAMING; - - //Static Data - static const std::string KEY_TYPE; //!< GSM or CDMA - static const std::string KEY_CODE; //!< Product Code : H5, H6, C2, EV3, G3 - static const std::string KEY_MODEL; //!< Model : HE910, CE910, DE910, GE910 - static const std::string KEY_MANUFACTURER; //!< Manufacturer: Telit - static const std::string KEY_HARDWARE; //!< Radio Hardware Version - static const std::string KEY_FIRMWARE; //!< Radio Firmware Version - static const std::string KEY_FIRMWARE_BUILD;//!< Radio Firmware Build - static const std::string KEY_IMEI; //!< International Mobile Station Equipment Identity - static const std::string KEY_MEID; //!< Mobile Equipment Identifier - static const std::string KEY_IMSI; //!< International Mobile Subscriber Identity - static const std::string KEY_MSID; //!< Mobil Station ID (MSID) aka MIN aka MSIN aka Last few digits of IMSI - static const std::string KEY_MDN; //!< Mobile Directory Number : Actual phone number dialed to reach radio - static const std::string KEY_CARRIER; //!< Cellular Service Provider (Home Network) - static const std::string KEY_ICCID; //!< Integrated Circuit Card Identifier - static const std::string KEY_MSL; //!< Master Subsidy Lock - - - //Network Status Data - static const std::string KEY_ROAMING; //!< Indicates whether or not using Home Network - static const std::string KEY_DATETIME; //!< Date and Time from tower - static const std::string KEY_SERVICE; //!< Service Connection Type [GPRS, EGPRS, WCDMA, HSDPA, 1xRTT, EVDO] - static const std::string KEY_NETWORK; //!< Cellular Service Provider - static const std::string KEY_NETWORK_REG; //!< Network Registration - static const std::string KEY_CID; //!< Cellular ID (Tower) in HEX - static const std::string KEY_LAC; //!< Location Area Code in HEX - static const std::string KEY_RAC; //!< Routing Area Code in HEX - static const std::string KEY_RSSI; //!< Received Signal Strength Indication - static const std::string KEY_RSSIDBM; //!< Received Signal Strength Indication in dBm - static const std::string KEY_MCC; //!< Mobile Country Code - static const std::string KEY_MNC; //!< Mobile Network (Operator) Code - static const std::string KEY_CHANNEL; //!< ARFCN or UARFCN Assigned Radio Channel - static const std::string KEY_TXPWR; //!< Transmit Power - static const std::string KEY_PSC; //!< Active Primary Synchronization Code (PSC) - static const std::string KEY_ECIO; //!< Active Ec/Io (chip energy per total wideband power in dBm) - static const std::string KEY_RSCP; //!< Active RSCP (Received Signal Code Power in dBm) - static const std::string KEY_DRX; //!< Discontinuous reception cycle length (ms) - static const std::string KEY_MM; //!< Mobility Management State - static const std::string KEY_RR; //!< Radio Resource State - static const std::string KEY_NOM; //!< Network Operator Mode - static const std::string KEY_ABND; //!< Active Band - static const std::string KEY_BLER; //!< Block Error Rate (percentage) - static const std::string KEY_SD; //!< Service Domain - static const std::string KEY_DEBUG; //!< Debug Information - - static const std::string KEY_MIP; //!< Mobile IP Information - static const std::string KEY_MIP_ID; //!< MIP Profile ID - static const std::string KEY_MIP_ENABLED; //!< MIP Profile Enabled/Disabled - static const std::string KEY_MIP_NAI; //!< Network Access Identifier - static const std::string KEY_MIP_HOMEADDRESS; //!< Home Address - static const std::string KEY_MIP_PRIMARYHA; //!< Primary Home Agent - static const std::string KEY_MIP_SECONDARYHA; //!< Secondary Home Agent - static const std::string KEY_MIP_MNAAASPI; //!< Mobile Node Authentication, Authorization, and Accounting Server Security Parameter Index - static const std::string KEY_MIP_MNHASPI; //!< Mobile Node Home Agent Security Server Parameter Index - static const std::string KEY_MIP_REVTUN; //!< Reverse Tunneling Enabled - static const std::string KEY_MIP_MNAAASS; //!< Mobile Node Authentication, Authorization, and Accounting Server Shared Secret - static const std::string KEY_MIP_MNHASS; //!< Mobile Node Home Agent Shared Secret - - - //Values - Type - static const std::string VALUE_TYPE_LTE; - static const std::string VALUE_TYPE_GSM; - static const std::string VALUE_TYPE_CDMA; - - //Values - Carrier - static const std::string VALUE_CARRIER_VERIZON; - static const std::string VALUE_CARRIER_AERIS; - static const std::string VALUE_CARRIER_SPRINT; - static const std::string VALUE_CARRIER_USCELLULAR; - static const std::string VALUE_CARRIER_ATT; - static const std::string VALUE_CARRIER_TMOBILE; - - static const std::string VALUE_SD_NO_SERVICE; - static const std::string VALUE_SD_CS_ONLY; - static const std::string VALUE_SD_PS_ONLY; - static const std::string VALUE_SD_CSPS; - - static const std::string VALUE_ABND_GSM_850; - static const std::string VALUE_ABND_GSM_900; - static const std::string VALUE_ABND_DCS_1800; - static const std::string VALUE_ABND_PCS_1900; - - static const std::vector DEFAULT_BAIL_STRINGS; - - typedef std::function IsNeedMoreData; - typedef std::function UpdateCb; - virtual ~TelitRadio(); virtual bool initialize(uint32_t iTimeoutMillis = 5000); @@ -214,10 +104,6 @@ namespace MTS { const std::string& getName() const; virtual CODE getModel(std::string& sModel); - static CODE convertModelToType(const std::string& sModel, std::string& sType); - static CODE convertModelToMtsShortCode(const std::string& sModel, std::string& sCode, TelitRadio *radioObj = NULL); - static CODE convertServiceDomainToString(SERVICEDOMAIN eSd, std::string& sSd); - static CODE convertActiveBandToString(ACTIVEBAND eBand, std::string& sBand); virtual CODE getFirmware(std::string& sFirmware); virtual CODE getFirmwareBuild(std::string& sFirmwareBuild); -- cgit v1.2.3 From 55c18e47596b6be9f19b33deb6c5cd0e798decd8 Mon Sep 17 00:00:00 2001 From: Maksym Telychko Date: Fri, 7 Jun 2019 12:38:11 +0300 Subject: [MTS-MTQ] refactoring: public symbols visibility Make exported ICellularRadio and CellularRadioFactory only --- include/mts/MTS_IO_CellularRadioFactory.h | 3 ++- include/mts/MTS_IO_ICellularRadio.h | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadioFactory.h b/include/mts/MTS_IO_CellularRadioFactory.h index 501f314..540ed29 100644 --- a/include/mts/MTS_IO_CellularRadioFactory.h +++ b/include/mts/MTS_IO_CellularRadioFactory.h @@ -21,6 +21,7 @@ #ifndef MTS_IO_CELLULARRADIOFACTORY_H_ #define MTS_IO_CELLULARRADIOFACTORY_H_ +#include #include #include #include @@ -32,7 +33,7 @@ namespace MTS { class GE910Radio; class DE910Radio; class CE910Radio; - class CellularRadioFactory { + class EXPORT CellularRadioFactory { public: diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index 257ed00..d954a24 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -7,12 +7,11 @@ #include -#include -#include +#define EXPORT __attribute__((visibility("default"))) namespace MTS { namespace IO { - class ICellularRadio + class EXPORT ICellularRadio { public: typedef std::function IsNeedMoreData; -- cgit v1.2.3 From 402354f2410917888a7d4b04a2cbc3a76a321549 Mon Sep 17 00:00:00 2001 From: Maksym Telychko Date: Fri, 7 Jun 2019 13:56:26 +0300 Subject: [MTS-MTQ] refactoring: factory interface --- include/mts/MTS_IO_CellularRadioFactory.h | 51 ++++++++++++++----------------- 1 file changed, 23 insertions(+), 28 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadioFactory.h b/include/mts/MTS_IO_CellularRadioFactory.h index 540ed29..c26e642 100644 --- a/include/mts/MTS_IO_CellularRadioFactory.h +++ b/include/mts/MTS_IO_CellularRadioFactory.h @@ -21,18 +21,13 @@ #ifndef MTS_IO_CELLULARRADIOFACTORY_H_ #define MTS_IO_CELLULARRADIOFACTORY_H_ -#include -#include #include #include +#include + namespace MTS { namespace IO { - - class HE910Radio; - class GE910Radio; - class DE910Radio; - class CE910Radio; class EXPORT CellularRadioFactory { public: @@ -40,29 +35,29 @@ namespace MTS { CellularRadioFactory(); virtual ~CellularRadioFactory() {}; - virtual CellularRadio* create(const std::string& sModel, const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - - virtual CellularRadio* createHE910D(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createHE910EUD(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910NAG(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910C4NF(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910NA1(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910SVG(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910EUG(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910C4EU(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910EU1(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910C1NS(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE910C1AP(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createME910C1NA(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createME910C1NV(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createME910C1WW(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createGE910(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createDE910(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createCE910(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); - virtual CellularRadio* createLE866A1JS(const std::string& sPort = TelitRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* create(const std::string& sModel, const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + + virtual ICellularRadio* createHE910D(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createHE910EUD(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createLE910NAG(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createLE910C4NF(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createLE910NA1(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createLE910SVG(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createLE910EUG(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createLE910C4EU(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createLE910EU1(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createLE910C1NS(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createLE910C1AP(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createME910C1NA(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createME910C1NV(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createME910C1WW(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createGE910(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createDE910(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createCE910(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + virtual ICellularRadio* createLE866A1JS(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); protected: - typedef MTS::IO::CellularRadio* (CellularRadioFactory::*CREATEFUNCPTR)(const std::string& sPort); + typedef MTS::IO::ICellularRadio* (CellularRadioFactory::*CREATEFUNCPTR)(const std::string& sPort); std::map< std::string, CREATEFUNCPTR > m_mCreationMap; virtual std::string identifyRadio(const std::string& sPort); -- cgit v1.2.3 From 9f1b5b16547536196dde8e9296debbae924bfb2c Mon Sep 17 00:00:00 2001 From: Maksym Telychko Date: Fri, 7 Jun 2019 14:41:03 +0300 Subject: [MTS-MTQ] refactoring: telit radio headers and internal data structures --- include/mts/MTS_IO_TelitRadio.h | 69 ++++------------------------------------- 1 file changed, 6 insertions(+), 63 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index 0fdad6b..621bfb4 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -21,76 +21,19 @@ #ifndef MTS_IO_TELITRADIO_H_ #define MTS_IO_TELITRADIO_H_ -#include +#include +#include + +#include +#include #include #include #include -#include #include -#include -#include -#include -#include - -typedef struct -{ - const char *name; - int32_t low; - int32_t high; -} *pNameRangeMap, nameRangeMap; - -static const unsigned int NUM_GSM_BANDS = 7; -static const unsigned int NUM_WCDMA_BANDS = 6; -static const unsigned int NUM_LTE_BANDS = 42; - -// http://niviuk.free.fr/gsm_band.php -static const nameRangeMap GSMband[] = -{ - {"GSM 450", 259, 293}, {"GSM 480", 306, 340}, - {"GSM 750", 438, 511}, {"GSM 850", 128, 251}, - {"GSM 900 P", 1, 124}, {"GSM 900 E/R", 955, 1023}, - {"GSM DCS 1800/1900", 512, 885}, - -}; - -// http://niviuk.free.fr/umts_band.php -static const nameRangeMap WCDMAband[] = -{ - {"BAND I", 10592, 10838}, {"BAND II", 9662, 9938}, - {"BAND III", 1162, 1513}, {"BAND IV", 1537, 1738}, - {"BAND V", 4357, 4458}, {"BAND VI", 4387, 4413} -}; - -// http://niviuk.free.fr/lte_band.php -static const nameRangeMap EULTRAband[] = -{ - {"EUTRAN BAND1", 0, 599}, {"EUTRAN BAND2", 600, 1199}, - {"EUTRAN BAND3", 1200, 1949}, {"EUTRAN BAND4", 1950, 2399}, - {"EUTRAN BAND5", 2400, 2649}, {"EUTRAN BAND6", 2650, 2749}, - {"EUTRAN BAND7", 2750, 3449}, {"EUTRAN BAND8", 3450, 3799}, - {"EUTRAN BAND9", 3800, 4149}, {"EUTRAN BAND10", 4150, 4749}, - {"EUTRAN BAND11", 4750, 4999}, {"EUTRAN BAND12", 5000, 5179}, - {"EUTRAN BAND13", 5180, 5279}, {"EUTRAN BAND14", 5280, 5379}, - {"EUTRAN BAND17", 5730, 5849}, {"EUTRAN BAND18", 5850, 5999}, - {"EUTRAN BAND19", 6000, 6149}, {"EUTRAN BAND20", 6150, 6449}, - {"EUTRAN BAND21", 6450, 6525}, {"EUTRAN BAND22", 6600, 7399}, - {"EUTRAN BAND23", 7500, 7699}, {"EUTRAN BAND24", 7700, 8039}, - {"EUTRAN BAND25", 8040, 8689}, {"EUTRAN BAND26", 8690, 9039}, - {"EUTRAN BAND27", 9040, 9209}, {"EUTRAN BAND28", 9210, 9659}, - {"EUTRAN BAND29", 9660, 9769}, {"EUTRAN BAND30", 9770, 9869}, - {"EUTRAN BAND31", 9870, 9919}, {"EUTRAN BAND32", 9920, 10359}, - {"EUTRAN BAND33", 36000, 36199}, {"EUTRAN BAND34", 36200, 36349}, - {"EUTRAN BAND35", 36350, 36949}, {"EUTRAN BAND36", 36950, 37549}, - {"EUTRAN BAND37", 37550, 37749}, {"EUTRAN BAND38", 37750, 38249}, - {"EUTRAN BAND39", 38250, 38649}, {"EUTRAN BAND40", 38650, 39649}, - {"EUTRAN BAND41", 39650, 41589}, {"EUTRAN BAND42", 41590, 43589}, - {"EUTRAN BAND43", 43590, 45589}, {"EUTRAN BAND44", 45590, 46589} -}; namespace MTS { namespace IO { - class TelitRadio : public CellularRadio { public: @@ -329,7 +272,7 @@ namespace MTS { private: - class RadioBandMap { + class RadioBandMap : public MTS::NonCopyable { public: RadioBandMap() { -- cgit v1.2.3 From 596f8f8393bf837d73e0a62c87d52557d9191f96 Mon Sep 17 00:00:00 2001 From: Maksym Telychko Date: Sat, 8 Jun 2019 00:23:57 +0300 Subject: [MTS-MTQ] refactoring: telit radio implementation leave telit specific code in telit class. move common code to cellular radio class. --- include/mts/MTS_IO_CellularRadio.h | 154 ++++++++++++++++++- include/mts/MTS_IO_ICellularRadio.h | 2 - include/mts/MTS_IO_TelitRadio.h | 290 +----------------------------------- 3 files changed, 159 insertions(+), 287 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 1378612..e79e6d1 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -29,17 +29,165 @@ #ifndef MTS_IO_CELLULARRADIO_H_ #define MTS_IO_CELLULARRADIO_H_ +#include +#include + +#include + #include +#include +#include +#include +#include namespace MTS { namespace IO { - class CellularRadio : public ICellularRadio { + public: + const std::string& getName() const override; + + ~CellularRadio() override; + + bool initialize(uint32_t iTimeoutMillis = 5000) override; + bool resetConnection(uint32_t iTimeoutMillis = 5000) override; + void shutdown() override; + + CODE getFirmware(std::string& sFirmware) override; + CODE getFirmwareBuild(std::string& sFirmwareBuild) override; + CODE getHardware(std::string& sHardware) override; + CODE getManufacturer(std::string& sManufacturer) override; + CODE getImei(std::string& sImei) override; + CODE getMeid(std::string& sMeid) override; + CODE getImsi(std::string& sImsi) override; + CODE getSimStatus(std::string& sSimStatus) override; + CODE getLac(std::string& sLac) override; + CODE getMdn(std::string& sMdn) override; + CODE getMsid(std::string& sMsid) override; + CODE getType(std::string& sType) override; + CODE getCarrier(std::string& sCarrier) override; + CODE getNetwork(std::string& sNetwork) override; + CODE getTower(std::string& sTower) override; + CODE getTime(std::string& sDate, std::string& sTime, std::string& sTimeZone) override; + CODE getRoaming(bool& bRoaming) override; + + CODE getSignalStrength(int32_t& iRssi) override; + CODE getModemLocation(std::string& sLocation) override; + CODE convertSignalStrengthTodBm(const int32_t& iRssi, int32_t& dBm) override; + CODE convertdBmToSignalStrength(const int32_t& dBm, int32_t& iRssi) override; + + CODE getRegistration(REGISTRATION& eRegistration) override; + CODE convertRegistrationToString(REGISTRATION eRegistration, std::string& sRegistration) override; + CODE getMipProfile(Json::Value& jMipProfile) override; + CODE validateMsl(const Json::Value& jArgs) override; + CODE setMsid(const Json::Value& jArgs) override; + CODE setMipActiveProfile(const Json::Value& jArgs) override; + CODE setMipNai(const Json::Value& jArgs) override; + CODE setMipHomeIp(const Json::Value& jArgs) override; + CODE setMipPrimaryHa(const Json::Value& jArgs) override; + CODE setMipSecondaryHa(const Json::Value& jArgs) override; + CODE setMipMnAaaSpi(const Json::Value& jArgs) override; + CODE setMipMnHaSpi(const Json::Value& jArgs) override; + CODE setMipRevTun(const Json::Value& jArgs) override; + CODE setMipMnAaaSs(const Json::Value& jArgs) override; + CODE setMipMnHaSs(const Json::Value& jArgs) override; + CODE updateDc(const Json::Value& jArgs, UpdateCb& stepCb) override; + CODE updatePrl(const Json::Value& jArgs, UpdateCb& stepCb) override; + CODE updateFumo(const Json::Value& jArgs, UpdateCb& stepCb) override; + CODE resetHfa(const Json::Value& jArgs, UpdateCb& stepCb) override; + CODE activate(const Json::Value& jArgs, UpdateCb& stepCb) override; + CODE setActiveFirmware(const Json::Value& jArgs) override; + CODE getActiveFirmware(std::string& sFwId) override; + CODE getEcho(bool& bEnabled) override; + CODE setEcho(bool bEnabled = true) override; + CODE getStaticInformation(Json::Value& jData) override; + CODE sendBasicCommand(const std::string& sCmd, int32_t timeoutMillis = 100, const char& ESC = CR) override; + + std::string sendCommand(const std::string& sCmd, + const std::vector& vBail = DEFAULT_BAIL_STRINGS, + int32_t timeoutMillis = 100, + const char& ESC = CR) override; + + + static std::string sendCommand(MTS::AutoPtr& apIo, + const std::string& sCmd, + const std::vector& vBail = DEFAULT_BAIL_STRINGS, + int32_t timeoutMillis = 100, + const char& ESC = CR); + + std::string sendCommand(const std::string& sCmd, + IsNeedMoreData& isNeedMoreData, + int32_t timeoutMillis = 100, + const char& ESC = CR) override; + + static std::string sendCommand(MTS::AutoPtr& apIo, + const std::string& sCmd, + IsNeedMoreData& isNeedMoreData, + int32_t timeoutMillis = 100, + const char& ESC = CR); + + static CODE test(MTS::AutoPtr& apIo, uint32_t timeoutSeconds = 30); + + static std::string extractModelFromResult(const std::string& sResult); + static std::string getCodeAsString(CODE code); + + protected: + + CellularRadio(const std::string& sName, const std::string& sRadioPort); + + virtual bool getCarrierFromFirmware(const std::string& sFirmware, std::string& sCarrier); + virtual bool getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware); + virtual void getCommonNetworkStats(Json::Value& jData); + void initMipProfile(Json::Value& jData); + bool splitAndAssign(const std::string& sLine, const std::string& sKey, Json::Value& jParent, const std::string& sJsonKey, Json::ValueType eType = Json::ValueType::stringValue); + + class RadioBandMap : public MTS::NonCopyable { + public: + RadioBandMap() + { + m_sChannel = CellularRadio::VALUE_UNKNOWN; + m_iChannel = 0; + m_sRadioType = CellularRadio::VALUE_UNKNOWN; + } + + RadioBandMap(const std::string &channel, const std::string &radioType) : + m_sChannel(channel), + m_sRadioType(radioType) + { + m_iChannel = strtol(m_sChannel.c_str(), NULL, 10); + } + + virtual ~RadioBandMap() {} + + const char *getRadioBandName(); + const char *getRadioBandName(const std::string &channel, const std::string &radioType); + + private: + + const char *getLTEBand(const int channel); + const char *getCDMABand(const int channel); + const char *getGSMBand(const int channel); + + std::string m_sChannel; + int m_iChannel; + std::string m_sRadioType; + }; + + private: + std::string m_sName; + std::string m_sRadioPort; + std::string m_sFirmware; + std::string m_sCarrier; + MTS::AutoPtr m_apIo; + + bool m_bEchoEnabled; + bool m_bEnableEchoOnClose; + + std::string queryLteLac(); + std::string queryCGREGstring(); + void setCGREG(std::string value); }; } } - - #endif /* MTS_IO_CELLULARRADIO_H_ */ diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index d954a24..ff8383c 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -360,7 +360,6 @@ namespace MTS { virtual CODE getStaticInformation(Json::Value& jData) = 0; virtual CODE getNetworkStatus(Json::Value& jData) = 0; - /* virtual CODE sendBasicCommand(const std::string& sCmd, int32_t timeoutMillis = 100, const char& ESC = CR) = 0; virtual std::string sendCommand(const std::string& sCmd, @@ -372,7 +371,6 @@ namespace MTS { IsNeedMoreData& isNeedMoreData, int32_t timeoutMillis = 100, const char& ESC = CR) = 0; - */ }; } diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index 621bfb4..0c95f98 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -21,305 +21,31 @@ #ifndef MTS_IO_TELITRADIO_H_ #define MTS_IO_TELITRADIO_H_ -#include -#include - -#include - #include -#include -#include -#include -#include namespace MTS { namespace IO { class TelitRadio : public CellularRadio { - public: - virtual ~TelitRadio(); - - virtual bool initialize(uint32_t iTimeoutMillis = 5000); - virtual bool resetRadio(uint32_t iTimeoutMillis = 5000); - virtual bool resetConnection(uint32_t iTimeoutMillis = 5000); - virtual void shutdown(); - - const std::string& getName() const; - - virtual CODE getModel(std::string& sModel); - - virtual CODE getFirmware(std::string& sFirmware); - virtual CODE getFirmwareBuild(std::string& sFirmwareBuild); - virtual CODE getHardware(std::string& sHardware); - virtual CODE getManufacturer(std::string& sManufacturer); - virtual CODE getImei(std::string& sImei); - virtual CODE getMeid(std::string& sMeid); - virtual CODE getImsi(std::string& sImsi); - virtual CODE getSimStatus(std::string& sSimStatus); - virtual CODE getIccid(std::string& sIccid); - virtual CODE getService(std::string& sService); - virtual CODE getLac(std::string& sLac); - virtual CODE getMdn(std::string& sMdn); - virtual CODE getMsid(std::string& sMsid); - virtual CODE getType(std::string& sType); - virtual CODE getCarrier(std::string& sCarrier); - virtual CODE getNetwork(std::string& sNetwork); - virtual CODE getTower(std::string& sTower); - virtual CODE getTime(std::string& sDate, std::string& sTime, std::string& sTimeZone); - virtual CODE getRoaming(bool& bRoaming); - - virtual CODE getSignalStrength(int32_t& iRssi); - virtual CODE getModemLocation(std::string& sLocation); - virtual CODE convertSignalStrengthTodBm(const int32_t& iRssi, int32_t& dBm); - virtual CODE convertdBmToSignalStrength(const int32_t& dBm, int32_t& iRssi); - - virtual CODE getRegistration(REGISTRATION& eRegistration); - virtual CODE convertRegistrationToString(REGISTRATION eRegistration, std::string& sRegistration); - - //! Gather details of the radio's Mobile IP Profile - /*! - \param Json::Value object that will be populated with MIP data - \return Returns result code of gathering MIP - */ - virtual CODE getMipProfile(Json::Value& jMipProfile); - - /* - * jArgs = { - * "msl" : "Master Subsidy Lock (Aeris, Sprint): STRING" - * } - */ - virtual CODE validateMsl(const Json::Value& jArgs); - - /* - * jArgs = { - * "mdn" : "Mobile Directory Number : STRING", - * "msl" : "[OPTIONAL] Master Subsidy Lock (Aeris, Sprint): STRING" - * } - */ - virtual CODE setMdn(const Json::Value& jArgs); - - /* - * jArgs = { - * "msid" : "Mobil Station ID (MSID) aka MIN aka MSIN : STRING", - * "msl" : "[OPTIONAL] Master Subsidy Lock (Aeris, Sprint): STRING" - * } - */ - virtual CODE setMsid(const Json::Value& jArgs); - - /* - * jArgs = { - * "activeProfile" : "Set active profile: STRING" - * } - */ - virtual CODE setMipActiveProfile(const Json::Value& jArgs); - - /* - * jArgs = { - * "nai" : "Network Access Identifier : STRING" - * } - */ - virtual CODE setMipNai(const Json::Value& jArgs); - - /* - * jArgs = { - * "homeIp" : "Home Address : STRING" - * } - */ - virtual CODE setMipHomeIp(const Json::Value& jArgs); - - /* - * jArgs = { - * "primaryHa" : "Primary Home Agent : STRING" - * } - */ - virtual CODE setMipPrimaryHa(const Json::Value& jArgs); - - /* - * jArgs = { - * "secondaryHa" : "Secondary Home Agent : STRING" - * } - */ - virtual CODE setMipSecondaryHa(const Json::Value& jArgs); - - /* - * jArgs = { - * "mnAaaSpi" : "Mobile Node Authentication, Authorization, and Accounting Server Security Parameter Index : STRING" - * } - */ - virtual CODE setMipMnAaaSpi(const Json::Value& jArgs); - - /* - * jArgs = { - * "mnHaSpi" : "Mobile Node Home Agent Security Server Parameter Index : STRING" - * } - */ - virtual CODE setMipMnHaSpi(const Json::Value& jArgs); - - /* - * jArgs = { - * "revTun" : "[DESCRIPTION] : STRING" - * } - */ - virtual CODE setMipRevTun(const Json::Value& jArgs); - - /* - * jArgs = { - * "mnAaaSs" : "Mobile Node Authentication, Authorization, and Accounting Server Shared Secret : STRING" - * } - */ - virtual CODE setMipMnAaaSs(const Json::Value& jArgs); - - /* - * jArgs = { - * "mnHaSs" : "Mobile Node Home Agent Shared Secret : STRING" - * } - */ - virtual CODE setMipMnHaSs(const Json::Value& jArgs); - - /* - * jArgs = null - */ - virtual CODE updateDc(const Json::Value& jArgs, UpdateCb& stepCb); - - /* - * jArgs = null - */ - virtual CODE updatePrl(const Json::Value& jArgs, UpdateCb& stepCb); - - /* - * jArgs = null - */ - virtual CODE updateFumo(const Json::Value& jArgs, UpdateCb& stepCb); - - /* - * jArgs = { - * "msl" : "Master Subsidy Lock (Sprint): STRING" - * } - */ - virtual CODE resetHfa(const Json::Value& jArgs, UpdateCb& stepCb); - - /* - * jArgs = { - * "mdn" : "Mobile Directory Number (Aeris): STRING" - * "msid" : "Mobile Station ID (Aeris): STRING" - * } - */ - virtual CODE activate(const Json::Value& jArgs, UpdateCb& stepCb); + bool resetRadio(uint32_t iTimeoutMillis = 5000) override; - /* - * jArgs = { - * "enabled" : "RX Diversity Enabled ("0" or "1"): STRING" - * } - */ - virtual CODE setRxDiversity(const Json::Value& jArgs)=0; - /* - * jArgs = { - * "fwid" : "Firmware Image To Be Enabled: STRING" - * } - */ - virtual CODE setActiveFirmware(const Json::Value& jArgs); - virtual CODE getActiveFirmware(std::string& sFwId); - - virtual CODE getEcho(bool& bEnabled); - virtual CODE setEcho(bool bEnabled = true); - - virtual CODE getStaticInformation(Json::Value& jData); - virtual CODE getNetworkStatus(Json::Value& jData); - - virtual CODE sendBasicCommand(const std::string& sCmd, int32_t timeoutMillis = 100, const char& ESC = CR); - - virtual std::string sendCommand(const std::string& sCmd, - const std::vector& vBail = DEFAULT_BAIL_STRINGS, - int32_t timeoutMillis = 100, - const char& ESC = CR); - - - static std::string sendCommand(MTS::AutoPtr& apIo, - const std::string& sCmd, - const std::vector& vBail = DEFAULT_BAIL_STRINGS, - int32_t timeoutMillis = 100, - const char& ESC = CR); - - virtual std::string sendCommand(const std::string& sCmd, - IsNeedMoreData& isNeedMoreData, - int32_t timeoutMillis = 100, - const char& ESC = CR); - - static std::string sendCommand(MTS::AutoPtr& apIo, - const std::string& sCmd, - IsNeedMoreData& isNeedMoreData, - int32_t timeoutMillis = 100, - const char& ESC = CR); - - static CODE test(MTS::AutoPtr& apIo, uint32_t timeoutSeconds = 30); - - static std::string extractModelFromResult(const std::string& sResult); - static std::string getCodeAsString(CODE code); + CODE getModel(std::string& sModel) override; + CODE getIccid(std::string& sIccid) override; + CODE getService(std::string& sService) override; + CODE getNetworkStatus(Json::Value& jData) override; + CODE setMdn(const Json::Value& jArgs) override; protected: - TelitRadio(const std::string& sName, const std::string& sRadioPort); - virtual bool getCarrierFromFirmware(const std::string& sFirmware, std::string& sCarrier); - virtual bool getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware); - - virtual void getCommonNetworkStats(Json::Value& jData); - - void initMipProfile(Json::Value& jData); - - bool splitAndAssign(const std::string& sLine, const std::string& sKey, Json::Value& jParent, const std::string& sJsonKey, Json::ValueType eType = Json::ValueType::stringValue); - - + bool getCarrierFromFirmware(const std::string& sFirmware, std::string& sCarrier) override; + bool getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware) override; private: - class RadioBandMap : public MTS::NonCopyable { - public: - RadioBandMap() - { - m_sChannel = TelitRadio::VALUE_UNKNOWN; - m_iChannel = 0; - m_sRadioType = TelitRadio::VALUE_UNKNOWN; - } - - RadioBandMap(const std::string &channel, const std::string &radioType) : - m_sChannel(channel), - m_sRadioType(radioType) - { - m_iChannel = strtol(m_sChannel.c_str(), NULL, 10); - } - - virtual ~RadioBandMap() {} - - const char *getRadioBandName(); - const char *getRadioBandName(const std::string &channel, const std::string &radioType); - - private: - - const char *getLTEBand(const int channel); - const char *getCDMABand(const int channel); - const char *getGSMBand(const int channel); - - std::string m_sChannel; - int m_iChannel; - std::string m_sRadioType; - }; - - std::string m_sName; - std::string m_sRadioPort; - std::string m_sFirmware; - std::string m_sCarrier; - MTS::AutoPtr m_apIo; - - bool m_bEchoEnabled; - bool m_bEnableEchoOnClose; - std::string queryLteLac(); std::string queryCGREGstring(); void setCGREG(std::string value); }; } } - - - #endif -- cgit v1.2.3 From 5a7d8772ea898b3567685431b5a6be13015e5887 Mon Sep 17 00:00:00 2001 From: Maksym Telychko Date: Mon, 10 Jun 2019 11:27:27 +0300 Subject: [MTS-MTQ] refactoring: static function moved to ICellularRadio --- include/mts/MTS_IO_CellularRadio.h | 15 --------------- include/mts/MTS_IO_ICellularRadio.h | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index e79e6d1..0410e0d 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -109,27 +109,12 @@ namespace MTS { const char& ESC = CR) override; - static std::string sendCommand(MTS::AutoPtr& apIo, - const std::string& sCmd, - const std::vector& vBail = DEFAULT_BAIL_STRINGS, - int32_t timeoutMillis = 100, - const char& ESC = CR); std::string sendCommand(const std::string& sCmd, IsNeedMoreData& isNeedMoreData, int32_t timeoutMillis = 100, const char& ESC = CR) override; - static std::string sendCommand(MTS::AutoPtr& apIo, - const std::string& sCmd, - IsNeedMoreData& isNeedMoreData, - int32_t timeoutMillis = 100, - const char& ESC = CR); - - static CODE test(MTS::AutoPtr& apIo, uint32_t timeoutSeconds = 30); - - static std::string extractModelFromResult(const std::string& sResult); - static std::string getCodeAsString(CODE code); protected: diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index ff8383c..3ab8b7e 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -7,6 +7,9 @@ #include +#include +#include + #define EXPORT __attribute__((visibility("default"))) namespace MTS { @@ -62,6 +65,20 @@ 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 std::string sendCommand(MTS::AutoPtr& apIo, + const std::string& sCmd, + IsNeedMoreData& isNeedMoreData, + int32_t timeoutMillis = 100, + const char& ESC = CR); + static std::string sendCommand(MTS::AutoPtr& apIo, + const std::string& sCmd, + const std::vector& vBail = DEFAULT_BAIL_STRINGS, + int32_t timeoutMillis = 100, + const char& ESC = CR); + static CODE test(MTS::AutoPtr& apIo, uint32_t timeoutSeconds = 30); + static std::string extractModelFromResult(const std::string& sResult); + static std::string getCodeAsString(CODE code); // XXX static const std::string DEFAULT_RADIO_PORT; -- cgit v1.2.3 From 07b7b63b15bf5f7cb94f32a5fb45acdf1cb3edfc Mon Sep 17 00:00:00 2001 From: Maksym Telychko Date: Tue, 11 Jun 2019 11:20:50 +0300 Subject: [MTS-MTQ] refactoring: performance optimization strings replaced by const-char pointer --- include/mts/MTS_IO_ICellularRadio.h | 168 ++++++++++++++++++------------------ 1 file changed, 84 insertions(+), 84 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index 3ab8b7e..11ad193 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -81,12 +81,12 @@ namespace MTS { static std::string getCodeAsString(CODE code); // XXX - static const std::string DEFAULT_RADIO_PORT; - static const std::string DEFAULT_RADIO_DIR; + static const char *DEFAULT_RADIO_PORT; + static const char *DEFAULT_RADIO_DIR; - static const std::string VALUE_UNKNOWN; - static const std::string VALUE_UNAVAILABLE; - static const std::string VALUE_NOT_SUPPORTED; + static const char *VALUE_UNKNOWN; + static const char *VALUE_UNAVAILABLE; + static const char *VALUE_NOT_SUPPORTED; //Special Payload Characters static const char ETX; //Ends socket connection @@ -95,96 +95,96 @@ namespace MTS { static const char NL; static const char CTRL_Z; - static const std::string RSP_OK; - static const std::string RSP_ERROR; + static const char *RSP_OK; + static const char *RSP_ERROR; - static const std::string VALUE_NOT_REGISTERED; - static const std::string VALUE_REGISTERED; - static const std::string VALUE_SEARCHING; - static const std::string VALUE_DENIED; - static const std::string VALUE_ROAMING; + static const char *VALUE_NOT_REGISTERED; + static const char *VALUE_REGISTERED; + static const char *VALUE_SEARCHING; + static const char *VALUE_DENIED; + static const char *VALUE_ROAMING; //Static Data - static const std::string KEY_TYPE; //!< GSM or CDMA - static const std::string KEY_CODE; //!< Product Code : H5, H6, C2, EV3, G3 - static const std::string KEY_MODEL; //!< Model : HE910, CE910, DE910, GE910 - static const std::string KEY_MANUFACTURER; //!< Manufacturer: Telit - static const std::string KEY_HARDWARE; //!< Radio Hardware Version - static const std::string KEY_FIRMWARE; //!< Radio Firmware Version - static const std::string KEY_FIRMWARE_BUILD;//!< Radio Firmware Build - static const std::string KEY_IMEI; //!< International Mobile Station Equipment Identity - static const std::string KEY_MEID; //!< Mobile Equipment Identifier - static const std::string KEY_IMSI; //!< International Mobile Subscriber Identity - static const std::string KEY_MSID; //!< Mobil Station ID (MSID) aka MIN aka MSIN aka Last few digits of IMSI - static const std::string KEY_MDN; //!< Mobile Directory Number : Actual phone number dialed to reach radio - static const std::string KEY_CARRIER; //!< Cellular Service Provider (Home Network) - static const std::string KEY_ICCID; //!< Integrated Circuit Card Identifier - static const std::string KEY_MSL; //!< Master Subsidy Lock + static const char *KEY_TYPE; //!< GSM or CDMA + static const char *KEY_CODE; //!< Product Code : H5, H6, C2, EV3, G3 + static const char *KEY_MODEL; //!< Model : HE910, CE910, DE910, GE910 + static const char *KEY_MANUFACTURER; //!< Manufacturer: Telit + static const char *KEY_HARDWARE; //!< Radio Hardware Version + static const char *KEY_FIRMWARE; //!< Radio Firmware Version + static const char *KEY_FIRMWARE_BUILD;//!< Radio Firmware Build + static const char *KEY_IMEI; //!< International Mobile Station Equipment Identity + static const char *KEY_MEID; //!< Mobile Equipment Identifier + static const char *KEY_IMSI; //!< International Mobile Subscriber Identity + static const char *KEY_MSID; //!< Mobil Station ID (MSID) aka MIN aka MSIN aka Last few digits of IMSI + static const char *KEY_MDN; //!< Mobile Directory Number : Actual phone number dialed to reach radio + static const char *KEY_CARRIER; //!< Cellular Service Provider (Home Network) + static const char *KEY_ICCID; //!< Integrated Circuit Card Identifier + static const char *KEY_MSL; //!< Master Subsidy Lock //Network Status Data - static const std::string KEY_ROAMING; //!< Indicates whether or not using Home Network - static const std::string KEY_DATETIME; //!< Date and Time from tower - static const std::string KEY_SERVICE; //!< Service Connection Type [GPRS, EGPRS, WCDMA, HSDPA, 1xRTT, EVDO] - static const std::string KEY_NETWORK; //!< Cellular Service Provider - static const std::string KEY_NETWORK_REG; //!< Network Registration - static const std::string KEY_CID; //!< Cellular ID (Tower) in HEX - static const std::string KEY_LAC; //!< Location Area Code in HEX - static const std::string KEY_RAC; //!< Routing Area Code in HEX - static const std::string KEY_RSSI; //!< Received Signal Strength Indication - static const std::string KEY_RSSIDBM; //!< Received Signal Strength Indication in dBm - static const std::string KEY_MCC; //!< Mobile Country Code - static const std::string KEY_MNC; //!< Mobile Network (Operator) Code - static const std::string KEY_CHANNEL; //!< ARFCN or UARFCN Assigned Radio Channel - static const std::string KEY_TXPWR; //!< Transmit Power - static const std::string KEY_PSC; //!< Active Primary Synchronization Code (PSC) - static const std::string KEY_ECIO; //!< Active Ec/Io (chip energy per total wideband power in dBm) - static const std::string KEY_RSCP; //!< Active RSCP (Received Signal Code Power in dBm) - static const std::string KEY_DRX; //!< Discontinuous reception cycle length (ms) - static const std::string KEY_MM; //!< Mobility Management State - static const std::string KEY_RR; //!< Radio Resource State - static const std::string KEY_NOM; //!< Network Operator Mode - static const std::string KEY_ABND; //!< Active Band - static const std::string KEY_BLER; //!< Block Error Rate (percentage) - static const std::string KEY_SD; //!< Service Domain - static const std::string KEY_DEBUG; //!< Debug Information - - static const std::string KEY_MIP; //!< Mobile IP Information - static const std::string KEY_MIP_ID; //!< MIP Profile ID - static const std::string KEY_MIP_ENABLED; //!< MIP Profile Enabled/Disabled - static const std::string KEY_MIP_NAI; //!< Network Access Identifier - static const std::string KEY_MIP_HOMEADDRESS; //!< Home Address - static const std::string KEY_MIP_PRIMARYHA; //!< Primary Home Agent - static const std::string KEY_MIP_SECONDARYHA; //!< Secondary Home Agent - static const std::string KEY_MIP_MNAAASPI; //!< Mobile Node Authentication, Authorization, and Accounting Server Security Parameter Index - static const std::string KEY_MIP_MNHASPI; //!< Mobile Node Home Agent Security Server Parameter Index - static const std::string KEY_MIP_REVTUN; //!< Reverse Tunneling Enabled - static const std::string KEY_MIP_MNAAASS; //!< Mobile Node Authentication, Authorization, and Accounting Server Shared Secret - static const std::string KEY_MIP_MNHASS; //!< Mobile Node Home Agent Shared Secret + static const char *KEY_ROAMING; //!< Indicates whether or not using Home Network + static const char *KEY_DATETIME; //!< Date and Time from tower + static const char *KEY_SERVICE; //!< Service Connection Type [GPRS, EGPRS, WCDMA, HSDPA, 1xRTT, EVDO] + static const char *KEY_NETWORK; //!< Cellular Service Provider + static const char *KEY_NETWORK_REG; //!< Network Registration + static const char *KEY_CID; //!< Cellular ID (Tower) in HEX + static const char *KEY_LAC; //!< Location Area Code in HEX + static const char *KEY_RAC; //!< Routing Area Code in HEX + static const char *KEY_RSSI; //!< Received Signal Strength Indication + static const char *KEY_RSSIDBM; //!< Received Signal Strength Indication in dBm + static const char *KEY_MCC; //!< Mobile Country Code + static const char *KEY_MNC; //!< Mobile Network (Operator) Code + static const char *KEY_CHANNEL; //!< ARFCN or UARFCN Assigned Radio Channel + static const char *KEY_TXPWR; //!< Transmit Power + static const char *KEY_PSC; //!< Active Primary Synchronization Code (PSC) + static const char *KEY_ECIO; //!< Active Ec/Io (chip energy per total wideband power in dBm) + static const char *KEY_RSCP; //!< Active RSCP (Received Signal Code Power in dBm) + static const char *KEY_DRX; //!< Discontinuous reception cycle length (ms) + static const char *KEY_MM; //!< Mobility Management State + static const char *KEY_RR; //!< Radio Resource State + static const char *KEY_NOM; //!< Network Operator Mode + static const char *KEY_ABND; //!< Active Band + static const char *KEY_BLER; //!< Block Error Rate (percentage) + static const char *KEY_SD; //!< Service Domain + static const char *KEY_DEBUG; //!< Debug Information + + static const char *KEY_MIP; //!< Mobile IP Information + static const char *KEY_MIP_ID; //!< MIP Profile ID + static const char *KEY_MIP_ENABLED; //!< MIP Profile Enabled/Disabled + static const char *KEY_MIP_NAI; //!< Network Access Identifier + static const char *KEY_MIP_HOMEADDRESS; //!< Home Address + static const char *KEY_MIP_PRIMARYHA; //!< Primary Home Agent + static const char *KEY_MIP_SECONDARYHA; //!< Secondary Home Agent + static const char *KEY_MIP_MNAAASPI; //!< Mobile Node Authentication, Authorization, and Accounting Server Security Parameter Index + static const char *KEY_MIP_MNHASPI; //!< Mobile Node Home Agent Security Server Parameter Index + static const char *KEY_MIP_REVTUN; //!< Reverse Tunneling Enabled + static const char *KEY_MIP_MNAAASS; //!< Mobile Node Authentication, Authorization, and Accounting Server Shared Secret + static const char *KEY_MIP_MNHASS; //!< Mobile Node Home Agent Shared Secret //Values - Type - static const std::string VALUE_TYPE_LTE; - static const std::string VALUE_TYPE_GSM; - static const std::string VALUE_TYPE_CDMA; + static const char *VALUE_TYPE_LTE; + static const char *VALUE_TYPE_GSM; + static const char *VALUE_TYPE_CDMA; //Values - Carrier - static const std::string VALUE_CARRIER_VERIZON; - static const std::string VALUE_CARRIER_AERIS; - static const std::string VALUE_CARRIER_SPRINT; - static const std::string VALUE_CARRIER_USCELLULAR; - static const std::string VALUE_CARRIER_ATT; - static const std::string VALUE_CARRIER_TMOBILE; - - static const std::string VALUE_SD_NO_SERVICE; - static const std::string VALUE_SD_CS_ONLY; - static const std::string VALUE_SD_PS_ONLY; - static const std::string VALUE_SD_CSPS; - - static const std::string VALUE_ABND_GSM_850; - static const std::string VALUE_ABND_GSM_900; - static const std::string VALUE_ABND_DCS_1800; - static const std::string VALUE_ABND_PCS_1900; + static const char *VALUE_CARRIER_VERIZON; + static const char *VALUE_CARRIER_AERIS; + static const char *VALUE_CARRIER_SPRINT; + static const char *VALUE_CARRIER_USCELLULAR; + static const char *VALUE_CARRIER_ATT; + static const char *VALUE_CARRIER_TMOBILE; + + static const char *VALUE_SD_NO_SERVICE; + static const char *VALUE_SD_CS_ONLY; + static const char *VALUE_SD_PS_ONLY; + static const char *VALUE_SD_CSPS; + + static const char *VALUE_ABND_GSM_850; + static const char *VALUE_ABND_GSM_900; + static const char *VALUE_ABND_DCS_1800; + static const char *VALUE_ABND_PCS_1900; static const std::vector DEFAULT_BAIL_STRINGS; -- cgit v1.2.3 From f335cec14c262b22f8d9f84e528917d7b1a53fa5 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Tue, 11 Jun 2019 15:52:53 +0300 Subject: [MTS-MTQ] QuectelRadio implementation Moved CellularRadio::getNetwork implementation to the TelitRadio::getNetwork as Quectel radio doesn't have a AT#RFSTS command that returns the needed field. --- include/mts/MTS_IO_CellularRadio.h | 1 - include/mts/MTS_IO_TelitRadio.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 0410e0d..1576588 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -66,7 +66,6 @@ namespace MTS { CODE getMsid(std::string& sMsid) override; CODE getType(std::string& sType) override; CODE getCarrier(std::string& sCarrier) override; - CODE getNetwork(std::string& sNetwork) override; CODE getTower(std::string& sTower) override; CODE getTime(std::string& sDate, std::string& sTime, std::string& sTimeZone) override; CODE getRoaming(bool& bRoaming) override; diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index 0c95f98..7a44529 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -32,6 +32,7 @@ namespace MTS { CODE getModel(std::string& sModel) override; CODE getIccid(std::string& sIccid) override; CODE getService(std::string& sService) override; + CODE getNetwork(std::string& sNetwork) override; CODE getNetworkStatus(Json::Value& jData) override; CODE setMdn(const Json::Value& jArgs) override; -- cgit v1.2.3 From 16c34c61203dee01c8091b92df1bdf0a399af32f Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Tue, 11 Jun 2019 15:59:49 +0300 Subject: [MTS-MTQ] QuectelRadio implementation Removed Telit-specific implementation of the getCarrierFromFirmware and getHardwareVersionFromFirmware out of the QuectelRadio class. BTW, it's still present in the TelitRadio class. --- include/mts/MTS_IO_CellularRadio.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 1576588..c4e5b86 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -119,9 +119,11 @@ namespace MTS { CellularRadio(const std::string& sName, const std::string& sRadioPort); - virtual bool getCarrierFromFirmware(const std::string& sFirmware, std::string& sCarrier); - virtual bool getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware); + virtual bool getCarrierFromFirmware(const std::string& sFirmware, std::string& sCarrier) = 0; + virtual bool getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware) = 0; + virtual void getCommonNetworkStats(Json::Value& jData); + void initMipProfile(Json::Value& jData); bool splitAndAssign(const std::string& sLine, const std::string& sKey, Json::Value& jParent, const std::string& sJsonKey, Json::ValueType eType = Json::ValueType::stringValue); -- cgit v1.2.3 From ea4e0213f94a1014a0b4f0e0e43c3222eddc177a Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Tue, 11 Jun 2019 16:11:14 +0300 Subject: [MTS-MTQ] QuectelRadio implementation Converted the following functions to protected virtual functions: - CellularRadio::queryLteLac - CellularRadio::setCGREG - CellularRadio::queryCGREGstring Those functions are handy to fetch LAC in LTE mode for both Quectel and Telit radios. Also fixed comments and debug messages for the mentioned functions. --- include/mts/MTS_IO_CellularRadio.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index c4e5b86..1572ac8 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -127,6 +127,10 @@ namespace MTS { void initMipProfile(Json::Value& jData); bool splitAndAssign(const std::string& sLine, const std::string& sKey, Json::Value& jParent, const std::string& sJsonKey, Json::ValueType eType = Json::ValueType::stringValue); + virtual std::string queryLteLac(); + virtual std::string queryCGREGstring(); + virtual void setCGREG(std::string value); + class RadioBandMap : public MTS::NonCopyable { public: RadioBandMap() @@ -168,10 +172,6 @@ namespace MTS { bool m_bEchoEnabled; bool m_bEnableEchoOnClose; - - std::string queryLteLac(); - std::string queryCGREGstring(); - void setCGREG(std::string value); }; } } -- cgit v1.2.3 From bce73d000b64fc8ecaf7a25041e97a1ef57a848e Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Tue, 11 Jun 2019 16:30:23 +0300 Subject: [MTS-MTQ] QuectelRadio implementation Moved Telit-specific conversion between RSSI and dBm into the TelitRadio class. Quectel has MOSTLY the same conversion logic but in the case of TD-SCDMA the RSSI values may be uncompatible. --- include/mts/MTS_IO_CellularRadio.h | 2 -- include/mts/MTS_IO_TelitRadio.h | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 1572ac8..8e9201f 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -72,8 +72,6 @@ namespace MTS { CODE getSignalStrength(int32_t& iRssi) override; CODE getModemLocation(std::string& sLocation) override; - CODE convertSignalStrengthTodBm(const int32_t& iRssi, int32_t& dBm) override; - CODE convertdBmToSignalStrength(const int32_t& dBm, int32_t& iRssi) override; CODE getRegistration(REGISTRATION& eRegistration) override; CODE convertRegistrationToString(REGISTRATION eRegistration, std::string& sRegistration) override; diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index 7a44529..7162dfb 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -34,6 +34,10 @@ namespace MTS { CODE getService(std::string& sService) override; CODE getNetwork(std::string& sNetwork) override; CODE getNetworkStatus(Json::Value& jData) override; + + CODE convertSignalStrengthTodBm(const int32_t& iRssi, int32_t& dBm) override; + CODE convertdBmToSignalStrength(const int32_t& dBm, int32_t& iRssi) override; + CODE setMdn(const Json::Value& jArgs) override; protected: -- cgit v1.2.3 From fe1c1e2e87da96fbbc432a35a903fff40f52713a Mon Sep 17 00:00:00 2001 From: Maksym Telychko Date: Tue, 11 Jun 2019 16:47:11 +0300 Subject: [MTS-MTQ] refactoring: cellular factory namespaces --- include/mts/MTS_IO_ICellularRadio.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index 11ad193..d74ad15 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -60,7 +60,6 @@ namespace MTS { NOT_INSERTED }; - // TODO: convert functions 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); @@ -79,7 +78,6 @@ namespace MTS { static CODE test(MTS::AutoPtr& apIo, uint32_t timeoutSeconds = 30); static std::string extractModelFromResult(const std::string& sResult); static std::string getCodeAsString(CODE code); - // XXX static const char *DEFAULT_RADIO_PORT; static const char *DEFAULT_RADIO_DIR; -- cgit v1.2.3 From 2fe0784ab57aa5571e5cd70c1776eecda635b3c0 Mon Sep 17 00:00:00 2001 From: Maksym Telychko Date: Tue, 11 Jun 2019 16:49:09 +0300 Subject: [MTS-MTQ] cellular factory: quectel eg95 instance creation --- include/mts/MTS_IO_CellularRadioFactory.h | 1 + include/mts/MTS_IO_EG95Radio.h | 2 ++ 2 files changed, 3 insertions(+) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadioFactory.h b/include/mts/MTS_IO_CellularRadioFactory.h index c26e642..bd5db43 100644 --- a/include/mts/MTS_IO_CellularRadioFactory.h +++ b/include/mts/MTS_IO_CellularRadioFactory.h @@ -55,6 +55,7 @@ namespace MTS { virtual ICellularRadio* createDE910(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); virtual ICellularRadio* createCE910(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); virtual ICellularRadio* createLE866A1JS(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + ICellularRadio* createEG95Radio(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); protected: typedef MTS::IO::ICellularRadio* (CellularRadioFactory::*CREATEFUNCPTR)(const std::string& sPort); diff --git a/include/mts/MTS_IO_EG95Radio.h b/include/mts/MTS_IO_EG95Radio.h index 07db773..206d15d 100644 --- a/include/mts/MTS_IO_EG95Radio.h +++ b/include/mts/MTS_IO_EG95Radio.h @@ -7,6 +7,8 @@ namespace MTS { namespace IO { class EG95Radio : public QuectelRadio { + public: + static const std::string MODEL_NAME; }; } -- cgit v1.2.3 From 5c8318bea803966f5b883c986919787e77e514a5 Mon Sep 17 00:00:00 2001 From: Maksym Telychko Date: Tue, 11 Jun 2019 16:55:28 +0300 Subject: [MTS-MTQ] refactoring cellular factory: non interface class shouldn't have such virtual methods --- include/mts/MTS_IO_CellularRadioFactory.h | 44 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadioFactory.h b/include/mts/MTS_IO_CellularRadioFactory.h index bd5db43..c9cb56f 100644 --- a/include/mts/MTS_IO_CellularRadioFactory.h +++ b/include/mts/MTS_IO_CellularRadioFactory.h @@ -35,30 +35,30 @@ namespace MTS { CellularRadioFactory(); virtual ~CellularRadioFactory() {}; - virtual ICellularRadio* create(const std::string& sModel, const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - - virtual ICellularRadio* createHE910D(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createHE910EUD(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createLE910NAG(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createLE910C4NF(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createLE910NA1(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createLE910SVG(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createLE910EUG(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createLE910C4EU(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createLE910EU1(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createLE910C1NS(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createLE910C1AP(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createME910C1NA(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createME910C1NV(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createME910C1WW(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createGE910(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createDE910(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createCE910(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - virtual ICellularRadio* createLE866A1JS(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); - ICellularRadio* createEG95Radio(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + ICellularRadio* create(const std::string& sModel, const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT); + + ICellularRadio* createHE910D(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + ICellularRadio* createHE910EUD(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + ICellularRadio* createLE910NAG(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + ICellularRadio* createLE910C4NF(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + ICellularRadio* createLE910NA1(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + ICellularRadio* createLE910SVG(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + ICellularRadio* createLE910EUG(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + ICellularRadio* createLE910C4EU(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + ICellularRadio* createLE910EU1(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + ICellularRadio* createLE910C1NS(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + ICellularRadio* createLE910C1AP(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + ICellularRadio* createME910C1NA(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + ICellularRadio* createME910C1NV(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + ICellularRadio* createME910C1WW(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + ICellularRadio* createGE910(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + ICellularRadio* createDE910(const std::string& sPort = ICellularRadio::DEFAULT_RADIO_PORT) const; + 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; protected: - typedef MTS::IO::ICellularRadio* (CellularRadioFactory::*CREATEFUNCPTR)(const std::string& sPort); + typedef MTS::IO::ICellularRadio* (CellularRadioFactory::*CREATEFUNCPTR)(const std::string& sPort) const; std::map< std::string, CREATEFUNCPTR > m_mCreationMap; virtual std::string identifyRadio(const std::string& sPort); -- cgit v1.2.3 From 38039fe0c4fcc44bdf2534f1f8f4b95de54e14a4 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Tue, 11 Jun 2019 16:57:22 +0300 Subject: [MTS-MTQ] QuectelRadio implementation Removed copies of the following functions: - TelitRadio::queryLteLac - TelitRadio::setCGREG - TelitRadio::queryCGREGstring Those functions are already implemented in the CellularRadio class. Their implementation is common for both Telit and Quectel. There is no need to override them in TelitRadio. --- include/mts/MTS_IO_TelitRadio.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index 7162dfb..70ff8a9 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 by Multi-Tech Systems + * Copyright (C) 2019 by Multi-Tech Systems * * This file is part of libmts-io. * @@ -47,9 +47,7 @@ namespace MTS { bool getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware) override; private: - std::string queryLteLac(); - std::string queryCGREGstring(); - void setCGREG(std::string value); + }; } } -- cgit v1.2.3 From 20471af5d887ab2255716c734661abb95953676c Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Tue, 11 Jun 2019 18:19:36 +0300 Subject: [MTS-MTQ] QuectelRadio implementation Added the full implementation of QuectelRadio class. Ported the changes from a local branch to the new libmts-io architecture. --- include/mts/MTS_IO_QuectelRadio.h | 55 +++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index 55eac60..b486323 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -1,15 +1,60 @@ -#ifndef MTS_IO_QUECTELRADIO_H -#define MTS_IO_QUECTELRADIO_H +/* + * 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 . + * + */ + +#ifndef MTS_IO_QUECTELRADIO_H_ +#define MTS_IO_QUECTELRADIO_H_ #include namespace MTS { namespace IO { - class QuectelRadio : public CellularRadio - { + + class QuectelRadio : public CellularRadio { + + public: + bool resetRadio(uint32_t iTimeoutMillis = 5000) override; + + CODE getModel(std::string& sModel) override; + CODE getIccid(std::string& sIccid) override; + CODE getService(std::string& sService) override; + CODE getNetwork(std::string& sNetwork) override; + CODE getNetworkStatus(Json::Value& jData) override; + + CODE convertSignalStrengthTodBm(const int32_t& iRssi, int32_t& dBm) override; + CODE convertdBmToSignalStrength(const int32_t& dBm, int32_t& iRssi) override; + + CODE setMdn(const Json::Value& jArgs) override; + + protected: + QuectelRadio(const std::string& sName, const std::string& sRadioPort); + + bool getCarrierFromFirmware(const std::string& sFirmware, std::string& sCarrier) override; + bool getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware) override; + + virtual CODE getServiceDomain(SERVICEDOMAIN& sd); + virtual CODE convertToActiveBand(const std::string& sQuectelBand, ACTIVEBAND& band); + + private: }; } } -#endif +#endif /* MTS_IO_QUECTELRADIO_H_ */ -- cgit v1.2.3 From c316cdffa1749a17b7f106ea526ac2288074920b Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Wed, 12 Jun 2019 09:42:22 +0300 Subject: [MTS-MTQ] QuectelRadio implementation Added a proper implementation of the EG95Radio class --- include/mts/MTS_IO_EG95Radio.h | 44 +++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_EG95Radio.h b/include/mts/MTS_IO_EG95Radio.h index 206d15d..f3021cc 100644 --- a/include/mts/MTS_IO_EG95Radio.h +++ b/include/mts/MTS_IO_EG95Radio.h @@ -1,17 +1,47 @@ -#ifndef MTS_IO_EG95RADIO_H -#define MTS_IO_EG95RADIO_H +/* + * 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 . + * + */ + + +#ifndef MTS_IO_EG95RADIO_H_ +#define MTS_IO_EG95RADIO_H_ #include "mts/MTS_IO_QuectelRadio.h" namespace MTS { namespace IO { - class EG95Radio : public QuectelRadio - { - public: - static const std::string MODEL_NAME; + + class EG95Radio : public QuectelRadio { + + public: + static const std::string MODEL_NAME; + + EG95Radio(const std::string& sPort); + virtual ~EG95Radio(); + CODE setRxDiversity(const Json::Value& jArgs); + + protected: + + private: }; } } -#endif +#endif /* MTS_IO_EG95RADIO_H_ */ -- cgit v1.2.3 From 123aed7c4be0b88a4726cae5d722d74ebdf93782 Mon Sep 17 00:00:00 2001 From: Maksym Telychko Date: Wed, 12 Jun 2019 15:22:41 +0300 Subject: [MTS-MTQ] refactoring: using full qualified names for consts --- include/mts/MTS_IO_CellularRadio.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 0410e0d..acb235b 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -101,19 +101,19 @@ namespace MTS { CODE getEcho(bool& bEnabled) override; CODE setEcho(bool bEnabled = true) override; CODE getStaticInformation(Json::Value& jData) override; - CODE sendBasicCommand(const std::string& sCmd, int32_t timeoutMillis = 100, const char& ESC = CR) override; + CODE sendBasicCommand(const std::string& sCmd, int32_t timeoutMillis = 100, const char& ESC = ICellularRadio::CR) override; std::string sendCommand(const std::string& sCmd, const std::vector& vBail = DEFAULT_BAIL_STRINGS, int32_t timeoutMillis = 100, - const char& ESC = CR) override; + const char& ESC = ICellularRadio::CR) override; std::string sendCommand(const std::string& sCmd, IsNeedMoreData& isNeedMoreData, int32_t timeoutMillis = 100, - const char& ESC = CR) override; + const char& ESC = ICellularRadio::CR) override; protected: @@ -130,9 +130,9 @@ namespace MTS { public: RadioBandMap() { - m_sChannel = CellularRadio::VALUE_UNKNOWN; + m_sChannel = ICellularRadio::VALUE_UNKNOWN; m_iChannel = 0; - m_sRadioType = CellularRadio::VALUE_UNKNOWN; + m_sRadioType = ICellularRadio::VALUE_UNKNOWN; } RadioBandMap(const std::string &channel, const std::string &radioType) : -- cgit v1.2.3 From 143feb6a4587817d28c77e4df3a1b594b855f5e5 Mon Sep 17 00:00:00 2001 From: Maksym Telychko Date: Fri, 21 Jun 2019 17:19:09 +0300 Subject: [MTS-MTQ] RAT mode switch: implementation for telit and quectel RAT - Radio Access Technology --- include/mts/MTS_IO_ICellularRadio.h | 11 +++++++++++ include/mts/MTS_IO_QuectelRadio.h | 2 ++ include/mts/MTS_IO_TelitRadio.h | 2 ++ 3 files changed, 15 insertions(+) (limited to 'include') diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index d74ad15..1b95a0d 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); @@ -225,6 +233,9 @@ 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; + //! Gather details of the radio's Mobile IP Profile /*! \param Json::Value object that will be populated with MIP data diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index b486323..0ca7f3b 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 70ff8a9..47d6cf6 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); -- cgit v1.2.3 From 482f5c42c4e0a03b7474d369250121005bc94f3f Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Fri, 21 Jun 2019 18:11:11 +0300 Subject: [MTS-MTQ] SIM status and PIN unlock procedures Declared the interface for SIM status and PIN-related methods --- include/mts/MTS_IO_ICellularRadio.h | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'include') diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index d74ad15..5d2295b 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -205,6 +205,29 @@ namespace MTS { virtual CODE getMeid(std::string& sMeid) = 0; virtual CODE getImsi(std::string& sImsi) = 0; virtual CODE getSimStatus(std::string& sSimStatus) = 0; + + /** + * @brief getSimStatusSummary - get summary on the SIM card status + * (if there is a SIM card inserted, is it locked, etc). + * See below for the full list of returned fields. + * + * - `isSimInserted` - bool, is the SIM card installed or not; + * - `isSimLocked` - bool, is the SIM card blocked with PIN/PUK or not (or is READY); + * - `lockStatus` - string, either "READY", "SIM PUK", "SIM PIN" or other status as + * returned by "AT+CPIN?" AT command; + * - `attemptsPin` - integer, the number of attempts lef to enter a PIN code; + * - `attemptsPuk` - integer, the number of attempts lef to enter a PUK code. + * + * **Only `isSimInserted` is always present.** All other fields are omitted if + * the SIM card is removed. + * + * @param jData - an object to be filled with data + * @return CODE::SUCCESS on success, + * CODE::NOT_APPLICABLE if not supported by this radio + * and CODE::ERROR otherwise + */ + virtual CODE getSimStatusSummary(Json::Value& jData) = 0; + virtual CODE getIccid(std::string& sIccid) = 0; virtual CODE getService(std::string& sService) = 0; virtual CODE getLac(std::string& sLac) = 0; @@ -225,6 +248,26 @@ namespace MTS { virtual CODE getRegistration(REGISTRATION& eRegistration) = 0; virtual CODE convertRegistrationToString(REGISTRATION eRegistration, std::string& sRegistration) = 0; + /** + * @brief unlockSimCard - unlock the SIM card using PIN code provided + * + * This command does not peform any checks on the number of attempts left. + * Use with caution, verify the SIM status manually before execution. + * + * @param jArgs - a JSON object with the following format: + * + * jArgs = { + * "pin" : "A correct PIN code to unlock the SIM card: STRING" + * } + * + * @return CODE::SUCCESS when SIM card was succeffully unlocked, + * CODE::INVALID_ARGS when passed arguments are invalid, + * CODE::ERROR otherwise (i.e. when modem is not responding, + * when SIM card is removed, when PIN code is not correct + * or on any other error). + */ + virtual CODE unlockSimCard(const Json::Value& jArgs) = 0; + //! Gather details of the radio's Mobile IP Profile /*! \param Json::Value object that will be populated with MIP data -- cgit v1.2.3 From 07d0ee6ea892dea71911478fad2c530de41e059b Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Sat, 22 Jun 2019 10:17:30 +0300 Subject: [MTS-MTQ] SIM status and PIN unlock procedures Defined common protected utility methods for the CellularRadio class: - getIsSimInserted - getSimLockStatus - getSimLockAttempts --- include/mts/MTS_IO_CellularRadio.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 899ceeb..e23cbc9 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -122,6 +122,40 @@ namespace MTS { virtual void getCommonNetworkStats(Json::Value& jData); + /** + * @brief getIsSimInserted - returns if the SIM card is inserted / installed or not. + * + * @param bData - an object to be filled with the SIM card insertion status. + * `true` when SIM card is inserted / installed / present, + * `false` otherwise. + * @return CODE::SUCCESS when SIM insertion status is fetched successfully, + * CODE::NOT_APPLICABLE when the modem doesn't support this feature, + * CODE::ERROR otherwise (when modem is inaccessible or in other cases). + */ + virtual CODE getIsSimInserted(bool& bData) = 0; + + /** + * @brief getSimLockStatus - return the SIM lock status as defined by AT+CPIN? command. + * Returns "READY", "SIM PIN", "SIM PUK" or other SIM status. + * + * @param sData - an object to be filled with the SIM lock status + * @return CODE::SUCCESS when SIM status is fetched successfully, + * CODE::NOT_APPLICABLE when the modem doesn't support this feature, + * CODE::ERROR otherwise (SIM card removed, modem is inaccessible, etc). + */ + virtual CODE getSimLockStatus(std::string& sData) = 0; + + /** + * @brief getSimLockAttempts - get the number of SIM unlock attempts left. + * + * @param iAttemptsPin - the number of attempts left to enter a PIN code. + * @param iAttemptsPuk - the number of attempts left to enter a PUK code. + * @return CODE::SUCCESS when both numbers are fetched successfully, + * CODE::NOT_APPLICABLE when the modem doesn't support this feature, + * CODE::ERROR otherwise (SIM card removed, modem is inaccessible, etc). + */ + virtual CODE getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk) = 0; + void initMipProfile(Json::Value& jData); bool splitAndAssign(const std::string& sLine, const std::string& sKey, Json::Value& jParent, const std::string& sJsonKey, Json::ValueType eType = Json::ValueType::stringValue); -- cgit v1.2.3 From da53c2f6955e748862066f727997965f7b9c6849 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Sat, 22 Jun 2019 10:51:06 +0300 Subject: [MTS-MTQ] SIM status and PIN unlock procedures Defined the JSON object fields for SIM Status Summary data --- include/mts/MTS_IO_ICellularRadio.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index 5d2295b..531e0e0 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -160,6 +160,12 @@ namespace MTS { static const char *KEY_MIP_MNAAASS; //!< Mobile Node Authentication, Authorization, and Accounting Server Shared Secret static const char *KEY_MIP_MNHASS; //!< Mobile Node Home Agent Shared Secret + //SIM Status Summary data + static const char *KEY_IS_SIM_INSERTED; //!< SIM card insertion indicator. True when a SIM card is inserted + static const char *KEY_IS_SIM_LOCKED; //!< SIM card lock status indicator. True when a SIM card is locked by PIN / PUK / other code + static const char *KEY_SIM_LOCK_STATUS; //!< SIM card lock status string. Either "READY", "SIM PIN", "SIM PUK" or other state + static const char *KEY_ATTEMPTS_PIN; //!< The number of attempts left to unlock the SIM card using PIN code + static const char *KEY_ATTEMPTS_PUK; //!< The number of attempts left to unlock the SIM card using PUK code //Values - Type static const char *VALUE_TYPE_LTE; -- cgit v1.2.3 From a7673be0a434243c2011d809cc0a3a01441470fb Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Sat, 22 Jun 2019 10:57:44 +0300 Subject: [MTS-MTQ] SIM status and PIN unlock procedures Added a common implementation for the CellularRadio::getSimStatusSummary method --- include/mts/MTS_IO_CellularRadio.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index e23cbc9..5ca9f9a 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -61,6 +61,7 @@ namespace MTS { CODE getMeid(std::string& sMeid) override; CODE getImsi(std::string& sImsi) override; CODE getSimStatus(std::string& sSimStatus) override; + CODE getSimStatusSummary(Json::Value& jData) override; CODE getLac(std::string& sLac) override; CODE getMdn(std::string& sMdn) override; CODE getMsid(std::string& sMsid) override; -- cgit v1.2.3 From d9024556c684f2c157d472eee814e01ff2496ff9 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Sat, 22 Jun 2019 11:24:51 +0300 Subject: [MTS-MTQ] SIM status and PIN unlock procedures Added common implementations for CellularRadio::unlockSimCard and CellularRadio::getSimLockStatus --- include/mts/MTS_IO_CellularRadio.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 5ca9f9a..9866d73 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -76,6 +76,9 @@ namespace MTS { CODE getRegistration(REGISTRATION& eRegistration) override; CODE convertRegistrationToString(REGISTRATION eRegistration, std::string& sRegistration) override; + + CODE unlockSimCard(const Json::Value& jArgs) override; + CODE getMipProfile(Json::Value& jMipProfile) override; CODE validateMsl(const Json::Value& jArgs) override; CODE setMsid(const Json::Value& jArgs) override; @@ -144,7 +147,7 @@ namespace MTS { * CODE::NOT_APPLICABLE when the modem doesn't support this feature, * CODE::ERROR otherwise (SIM card removed, modem is inaccessible, etc). */ - virtual CODE getSimLockStatus(std::string& sData) = 0; + virtual CODE getSimLockStatus(std::string& sData); /** * @brief getSimLockAttempts - get the number of SIM unlock attempts left. -- cgit v1.2.3 From 25bbcb7482dbbb93c9edfc3e1de415cfa4c260d0 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Sat, 22 Jun 2019 12:03:17 +0300 Subject: [MTS-MTQ] SIM status and PIN unlock procedures Added Telit-specific implementation of the CellularRadio::getIsSimInserted and CellularRadio::getSimLockAttempts utility methods --- include/mts/MTS_IO_TelitRadio.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index 70ff8a9..65ca56e 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -46,7 +46,11 @@ namespace MTS { bool getCarrierFromFirmware(const std::string& sFirmware, std::string& sCarrier) override; bool getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware) override; + CODE getIsSimInserted(bool& bData) override; + CODE getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk) override; + private: + virtual CODE getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk, const std::string& sLockStatus); }; } -- cgit v1.2.3 From 1cb0265df2b2e2171a874a52a782de3ecc6620fa Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Sat, 22 Jun 2019 12:03:17 +0300 Subject: [MTS-MTQ] SIM status and PIN unlock procedures Added Quectel-specific implementation of the CellularRadio::getIsSimInserted and CellularRadio::getSimLockAttempts utility methods --- include/mts/MTS_IO_QuectelRadio.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index b486323..81da1ce 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -48,6 +48,9 @@ namespace MTS { bool getCarrierFromFirmware(const std::string& sFirmware, std::string& sCarrier) override; bool getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware) override; + CODE getIsSimInserted(bool& bData) override; + CODE getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk) override; + virtual CODE getServiceDomain(SERVICEDOMAIN& sd); virtual CODE convertToActiveBand(const std::string& sQuectelBand, ACTIVEBAND& band); -- cgit v1.2.3 From 4ef332ec707946a3cf2a55473d05dfc9af3d4b11 Mon Sep 17 00:00:00 2001 From: Maksym Telychko Date: Wed, 26 Jun 2019 13:05:32 +0300 Subject: [MTS-MTQ] network radio mode switch: refactoring method name --- include/mts/MTS_IO_ICellularRadio.h | 16 ++++++++-------- include/mts/MTS_IO_QuectelRadio.h | 4 ++-- include/mts/MTS_IO_TelitRadio.h | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index 2d47fcf..e2bf652 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -60,12 +60,12 @@ namespace MTS { NOT_INSERTED }; - enum RADIOMODE : uint8_t { - RADIOMODE_UNKNOWN = 0, - RADIOMODE_AUTO, - RADIOMODE_GSM_ONLY, - RADIOMODE_UMTS_ONLY, - RADIOMODE_LTE_ONLY + enum RADIO_NETWORK_MODE : uint8_t { + RADIO_NETWORK_MODE_UNKNOWN = 0, + RADIO_NETWORK_MODE_AUTO, + RADIO_NETWORK_MODE_GSM_ONLY, + RADIO_NETWORK_MODE_UMTS_ONLY, + RADIO_NETWORK_MODE_LTE_ONLY }; static CODE convertModelToType(const std::string& sModel, std::string& sType); @@ -262,8 +262,6 @@ 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 * @@ -283,6 +281,8 @@ namespace MTS { * or on any other error). */ virtual CODE unlockSimCard(const Json::Value& jArgs) = 0; + virtual CODE getRadioNetworkMode(RADIO_NETWORK_MODE &mode) = 0; + virtual CODE setRadioNetworkMode(RADIO_NETWORK_MODE mode) = 0; //! Gather details of the radio's Mobile IP Profile /*! diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index 3e5886c..557fd82 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -41,8 +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; + CODE getRadioNetworkMode(RADIO_NETWORK_MODE &mode) override; + CODE setRadioNetworkMode(RADIO_NETWORK_MODE 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 08b144c..6382696 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -39,8 +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; + CODE getRadioNetworkMode(RADIO_NETWORK_MODE &mode) override; + CODE setRadioNetworkMode(RADIO_NETWORK_MODE mode) override; protected: TelitRadio(const std::string& sName, const std::string& sRadioPort); -- cgit v1.2.3 From fe970f5bb77354b7507e230b1465e9178c80ee7a Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Thu, 18 Jul 2019 11:59:02 +0300 Subject: [MTS-MTQ] QuectelRadio implementation Refactored the CellularRadio class to include base stub implementation for the "CellularRadio::getCarrierFromFirmware" and "CellularRadio::getHardwareVersionFromFirmware" methods. From now assuming that those two possibilities are not supported by the modem until otherwise specified (i.e. until the method implementation was overridden in derived class). This change was implemented after a code review. --- include/mts/MTS_IO_CellularRadio.h | 4 ++-- include/mts/MTS_IO_QuectelRadio.h | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 9866d73..eecefee 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -121,8 +121,8 @@ namespace MTS { CellularRadio(const std::string& sName, const std::string& sRadioPort); - virtual bool getCarrierFromFirmware(const std::string& sFirmware, std::string& sCarrier) = 0; - virtual bool getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware) = 0; + virtual bool getCarrierFromFirmware(const std::string& sFirmware, std::string& sCarrier); + virtual bool getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware); virtual void getCommonNetworkStats(Json::Value& jData); diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index 557fd82..3b1ba5a 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -47,9 +47,6 @@ namespace MTS { protected: QuectelRadio(const std::string& sName, const std::string& sRadioPort); - bool getCarrierFromFirmware(const std::string& sFirmware, std::string& sCarrier) override; - bool getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware) override; - CODE getIsSimInserted(bool& bData) override; CODE getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk) override; -- cgit v1.2.3 From 0330513b8913d1d7bf14bad99d64ab002b770b7c Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Thu, 18 Jul 2019 11:41:24 +0300 Subject: [MTR-MTQ] Namespace-related usage improvements Restored full qualification of the ICellularRadio::CODE object type for all files that used full qualification before (effectively, for all source files and only one header file). This commit partially reverses 53efcef2e2f521135b323e194c45f1d9fa7b5d5d. --- include/mts/MTS_IO_ME910C1WWRadio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_ME910C1WWRadio.h b/include/mts/MTS_IO_ME910C1WWRadio.h index 6612d83..d45d86a 100644 --- a/include/mts/MTS_IO_ME910C1WWRadio.h +++ b/include/mts/MTS_IO_ME910C1WWRadio.h @@ -33,8 +33,8 @@ namespace MTS { ME910C1WWRadio(const std::string& sPort); virtual ~ME910C1WWRadio(){}; - CODE setActiveFirmware(const Json::Value& jArgs); - CODE getActiveFirmware(std::string& sFwId); + ICellularRadio::CODE setActiveFirmware(const Json::Value& jArgs); + ICellularRadio::CODE getActiveFirmware(std::string& sFwId); protected: -- cgit v1.2.3