diff options
Diffstat (limited to 'include/mts/MTS_IO_CellularRadio.h')
-rw-r--r-- | include/mts/MTS_IO_CellularRadio.h | 168 |
1 files changed, 167 insertions, 1 deletions
diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index c2aa346..a2fa3f3 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -269,6 +269,7 @@ namespace MTS { virtual CODE sendData(const char* pData, size_t nBytes); virtual CODE sendBasicQuery(const std::string& sCmd, const std::string& sLabel, std::string& sResult, int32_t timeoutMillis = 100, const char& ESC = ICellularRadio::CR); + virtual CODE isCommandSupported(const std::string& sCmd, bool& bIsSupported); /** * @brief getDiagCommands - returns the list of Cellular Diagnostics commands for this radio. * @@ -278,7 +279,172 @@ namespace MTS { */ virtual const std::vector<std::string>& getDiagCommands(bool bIsSimReady = true) = 0; - virtual CODE setTimeFormat() = 0; + virtual CODE setTimeFormat() = 0; + struct PdpContextInfo { + std::string sId; + std::string sIpMode; + std::string sApn; + std::string sAuthType; + std::string sUsername; + std::string sPassword; + }; + + virtual std::vector<std::string> getSupportedPdpContextAuthTypes() const = 0; + static CODE convertPdpContextAuthTypeToString(PDP_CONTEXT_AUTH_TYPE eAuthType, std::string& sAuthType); + static CODE convertStringToPdpContextAuthType(const std::string& sAuthType, PDP_CONTEXT_AUTH_TYPE& eAuthType); + + /** + * @brief checks if PDP context authentication is supported by the modem. + * + * @param isSupported - sets to "true" if PDP context authentication is supported, "false" otherwise. + * + * @return CODE::SUCCESS when the response from the radio is received + * CODE::NO_RESPONSE when the modem doesn't respond, + * CODE::FAILURE otherwise. + */ + virtual CODE isPdpContextAuthSupported(bool& isSupported) = 0; + + /** + * @brief Get the list of PDP contexts with the base info about them from the radio. + * + * @param jData - a JSON object to be filled with data. + * { + * "context_number : STRING": { + * "apn" : "apn_value: STRING", + * "ipMode" : "ip_mode_value: STRING", + * } + * } + * + * @return CODE::SUCCESS when fetched successfully, + * CODE::NO_RESPONSE when the modem doesn't respond, + * CODE::ERROR when the radio returns "ERROR", + * CODE::FAILURE otherwise (unexpected response). + */ + virtual CODE getPdpContextsBase(Json::Value& jData); + + /** + * @brief fills jData with the information about PDP context authentication + * + * @param jData - a JSON object that is pre-filled with the list of PDP contexts: + * { + * "context_number : STRING": { + * "apn" : "apn_value: STRING", + * "ipMode" : "ip_mode_value: STRING", + * } + * } + * On success the method will complement jData with the PDP context authentication fields: + * { + * "context_number : STRING": { + * "apn" : "apn_value: STRING", + * "authType" : "auth_type_value: STRING", + * "ipMode" : "ip_mode_value: STRING", + * "password" : "password_value (optional): STRING", + * "username" : "username_value (optional): STRING" + * } + * } + * + * @return CODE::SUCCESS when fetched successfully, + * CODE::NO_RESPONSE when the modem doesn't respond, + * CODE::ERROR when the radio returns "ERROR", + * CODE::FAILURE otherwise (unexpected response). + */ + virtual CODE fillPdpContextAuthFields(Json::Value& jData) = 0; + + /** + * @brief merges the current configuration of the PDP context with the one requested by user + * + * @param sId - ID of the PDP context to change. + * @param jCurrentContext - a JSON object filled with current configuration data + * { + * "apn" : "apn_value (optional): STRING", + * "authType" : "auth_type_value: STRING", + * "ipMode" : "ip_mode_value: STRING", + * "password" : "password_value (optional): STRING", + * "username" : "username_value (optional): STRING" + * } + * @param jChanges - a JSON object filled with new configuration data + * { + * "apn" : "apn_value (optional): STRING", + * "authType" : "auth_type_value (optional): STRING", + * "ipMode" : "ip_mode_value (optional): STRING", + * "password" : "password_value (optional): STRING", + * "username" : "username_value (optional): STRING" + * } + * @param jResult - a JSON object to be filled with merged data + * { + * "apn" : "apn_value (optional): STRING", + * "authType" : "auth_type_value (optional): STRING", + * "id" : "ctx_id (optional): STRING", + * "ipMode" : "ip_mode_value (optional): STRING", + * "password" : "password_value (optional): STRING", + * "username" : "username_value (optional): STRING" + * } + * @return CODE::SUCCESS. + */ + virtual CODE mergePdpContexts(const std::string& sId, const Json::Value& jCurrentContext, const Json::Value& jChanges, Json::Value& jResult); + + /** + * @brief fills a PdpContextInfo instance with the data from JSON + * @param jData - a JSON object that contains: + * { + * "apn" : "apn_value: STRING", + * "authType" : "auth_type_value: STRING", + * "id" : "ctx_id: STRING", + * "ipMode" : "ip_mode_value: STRING", + * "password" : "password_value: STRING", + * "username" : "username_value: STRING" + * } + * @param pdpContextResult - PdpContextInfo object to be filled with parameters. + * @return CODE::SUCCESS if validated successfully, + * CODE::INVALID_ARGS if validation failed. + */ + virtual CODE initPdpContextInfo(const Json::Value& jConfig, PdpContextInfo& pdpContextResult); + + /** + * @brief checks if PDP context authentication should be configured + * @param jData - a JSON object that contains: + * { + * "apn" : "apn_value (optional): STRING", + * "authType" : "auth_type_value: STRING", + * "ipMode" : "ip_mode_value: STRING", + * "password" : "password_value (optional): STRING", + * "username" : "username_value (optional): STRING" + * } + * @param bIsAuthEditRequired - sets to "false" if there are no authType, username, and password fields in the json, otherwise sets to "true". + * @return CODE::SUCCESS. + */ + static CODE isPdpContextAuthEditRequired(const Json::Value& jConfig, bool& bIsAuthEditRequired); + + /** + * @brief Sets the base PDP context parameters: IP Mode and APN + * @param pdpContext - The new PDP context configuration + * @return CODE::SUCCESS when set successfully, + * CODE::NO_RESPONSE when the modem doesn't respond, + * CODE::ERROR when the radio returns "ERROR", + * CODE::FAILURE otherwise (unexpected response). + */ + virtual CODE setPdpContextBase(const PdpContextInfo& pdpContext); + + /** + * @brief Sets the Cellular Authentication parameters for this PDP context: Authentication Type, Username and Password. + * NOTE: Some implementations (Quectel) override the current IP Mode and APN in addition to the authentication fields. + * @param pdpContext - The new PDP context configuration + * @return CODE::SUCCESS when set successfully, + * CODE::NO_RESPONSE when the modem doesn't respond, + * CODE::ERROR when the radio returns "ERROR", + * CODE::FAILURE otherwise (unexpected response). + */ + virtual CODE setPdpContextAuth(const PdpContextInfo& pdpContext) = 0; + + /** + * @brief Delete the PDP context by its ID. + * @param sId - PDP context ID + * @return CODE::SUCCESS when delete successfully, + * CODE::NO_RESPONSE when the modem doesn't respond, + * CODE::ERROR when the radio returns "ERROR", + * CODE::FAILURE otherwise (unexpected response). + */ + virtual CODE deletePdpContext(const std::string& sId); class RadioBandMap : public MTS::NonCopyable { public: |