diff options
Diffstat (limited to 'include/mts/MTS_IO_CellularRadio.h')
-rw-r--r-- | include/mts/MTS_IO_CellularRadio.h | 154 |
1 files changed, 151 insertions, 3 deletions
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 <string> +#include <vector> + +#include <json/json.h> + #include <mts/MTS_IO_ICellularRadio.h> +#include <mts/MTS_IO_SerialConnection.h> +#include <mts/MTS_NonCopyable.h> +#include <mts/MTS_AutoPtr.h> +#include <mts/MTS_Stdint.h> 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<std::string>& vBail = DEFAULT_BAIL_STRINGS, + int32_t timeoutMillis = 100, + const char& ESC = CR) override; + + + static std::string sendCommand(MTS::AutoPtr<MTS::IO::Connection>& apIo, + const std::string& sCmd, + const std::vector<std::string>& 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<MTS::IO::Connection>& apIo, + const std::string& sCmd, + IsNeedMoreData& isNeedMoreData, + int32_t timeoutMillis = 100, + const char& ESC = CR); + + static CODE test(MTS::AutoPtr<MTS::IO::Connection>& 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<MTS::IO::Connection> m_apIo; + + bool m_bEchoEnabled; + bool m_bEnableEchoOnClose; + + std::string queryLteLac(); + std::string queryCGREGstring(); + void setCGREG(std::string value); }; } } - - #endif /* MTS_IO_CELLULARRADIO_H_ */ |