From 26f6e69e9d5c7049d42559259933482b35559889 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Thu, 28 May 2020 14:51:31 +0300 Subject: Quectel Delta Radio Firmware Upgrade support - libmts-io implementation Declared base interface and added stub implementation for the Delta Radio Firmware Upgrade support in libmts-io. --- include/mts/MTS_IO_CellularRadio.h | 3 +++ include/mts/MTS_IO_ICellularRadio.h | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 56506af..9fdb076 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -98,6 +98,9 @@ namespace MTS { 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 uploadDeltaFirmwareFile(int fd, UpdateCb& stepCb) override; + CODE removeDeltaFirmwareFile() override; + CODE applyDeltaFirmwareFile(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; diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index 58d5076..5123ba1 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -405,6 +405,56 @@ namespace MTS { */ virtual CODE updateFumo(const Json::Value& jArgs, UpdateCb& stepCb) = 0; + /** + * @brief uploadDeltaFirmwareFile - upload delta file to the radio's internal memory. + * + * This command uploads (injects) the whole delta firmware image to some place that + * can be later used by the radio to perform the Delta Radio Firmware Upgrade. + * + * This delta firmware image is NOT validated on the firmware image upload step. + * + * @param fd - file sescriptor of a file that shall be uploaded to the radio. + * @param stepCb - the callback to receive status updates during the upload. + * @return CODE::SUCCESS when the file was successfully uploaded, + * CODE::INVALID_ARGS when the file can't be opened for reading, + * CODE::NOT_APPLICABLE when not supported by this radio, + * CODE::ERROR otherwise. + */ + virtual CODE uploadDeltaFirmwareFile(int fd, UpdateCb& stepCb) = 0; + + /** + * @brief removeDeltaFirmwareFile - remove the delta file from the radio's internal memory. + * + * This command allows to remove the old delta firmware image from the radio's internal + * memory for cases when it's no longer needed. + * + * @param fd - file sescriptor of a file that shall be uploaded to the radio. + * @return CODE::SUCCESS when the file was successfully deleted, + * CODE::FAILURE when the file can't be deleted (i.e. no such file), + * CODE::NOT_APPLICABLE when not supported by this radio, + * CODE::ERROR otherwise. + */ + virtual CODE removeDeltaFirmwareFile() = 0; + + /** + * @brief applyDeltaFirmwareFile - apply the delta file that was previously uploaded. + * + * This commands initializes and tracks the progress of the delta firmware upgrade + * procedure using the delta firmware image file that was previously uploaded + * into internal radio's memory. + * + * See ICellularRadio::removeDeltaFirmwareFile to upload the file and prepare + * for the upgrade. + * + * @param fd - file sescriptor of a file that shall be uploaded to the radio. + * @param stepCb - the callback to receive status updates during the upgrade. + * @return CODE::SUCCESS when the file was successfully deleted, + * CODE::FAILURE when the file can't be deleted (i.e. no such file), + * CODE::NOT_APPLICABLE when not supported by this radio, + * CODE::ERROR otherwise. + */ + virtual CODE applyDeltaFirmwareFile(UpdateCb& stepCb) = 0; + /* * jArgs = { * "msl" : "Master Subsidy Lock (Sprint): STRING" -- cgit v1.2.3 From 9f5a4f138b56a0a1b4e5764a69261aa4a4edaa71 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Thu, 28 May 2020 15:55:00 +0300 Subject: Quectel Delta Radio Firmware Upgrade support - libmts-io implementation Declared base interface and added started implementation for the QuectelRadio class. Implemented file listing (file status check) and file removal logic. --- include/mts/MTS_IO_QuectelRadio.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index df3b5b5..8aba437 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -42,6 +42,10 @@ namespace MTS { CODE setMdn(const Json::Value& jArgs) override; + CODE uploadDeltaFirmwareFile(int fd, UpdateCb& stepCb) override; + CODE removeDeltaFirmwareFile() override; + CODE applyDeltaFirmwareFile(UpdateCb& stepCb) override; + protected: QuectelRadio(const std::string& sName, const std::string& sRadioPort); @@ -51,7 +55,13 @@ namespace MTS { virtual CODE getServiceDomain(SERVICEDOMAIN& sd); virtual CODE convertToActiveBand(const std::string& sQuectelBand, ACTIVEBAND& band); + virtual CODE uploadFile(int fd, const std::string& sTargetFilename, UpdateCb& stepCb); + virtual CODE removeFile(const std::string& sTargetFilename); + virtual CODE checkFile(bool& bFilePresent, const std::string& sTargetFilename); + private: + static const std::string VALUE_MTS_DELTA_NAME; + static const std::string VALUE_MTS_DELTA_PATH; }; } -- cgit v1.2.3 From 6e9ce61addd97809d5ea7b912332dd11a4bf7cee Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Fri, 29 May 2020 21:02:15 +0300 Subject: Quectel Delta Radio Firmware Upgrade support - libmts-io implementation Initial implementation of the delta firmware image upload for Quectel radios. --- include/mts/MTS_IO_CellularRadio.h | 2 ++ include/mts/MTS_IO_ICellularRadio.h | 1 + include/mts/MTS_IO_QuectelRadio.h | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 9fdb076..92df561 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -177,6 +177,8 @@ namespace MTS { REGISTRATION parseRegResponse(std::string sResult); CODE getRegistration(REGISTRATION& eRegistration, const std::string& sType); + virtual CODE sendData(const char* pData, size_t nBytes); + class RadioBandMap : public MTS::NonCopyable { public: RadioBandMap() diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index 5123ba1..7ad69c7 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -103,6 +103,7 @@ namespace MTS { static const char *RSP_OK; static const char *RSP_ERROR; + static const char *RSP_CONNECT; static const char *VALUE_NOT_REGISTERED; static const char *VALUE_REGISTERED; diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index 8aba437..9ccf50a 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -60,11 +60,31 @@ namespace MTS { virtual CODE checkFile(bool& bFilePresent, const std::string& sTargetFilename); private: + static const size_t FILE_CHUNK_SIZE; + static const std::string CMD_ABORT_UPLOAD; static const std::string VALUE_MTS_DELTA_NAME; static const std::string VALUE_MTS_DELTA_PATH; + CODE startFileUpload(const std::string& sTargetFilename, size_t nBytes); + CODE abortFileUpload(); + + static uint16_t getQuectelChecksum(const void* data, size_t nBytes); + static inline void updateQuectelChecksum(uint16_t& iChecksum, uint16_t iNewFragment); + static inline uint16_t bytesToUint16(uint8_t high, uint8_t low); + static CODE getFileSize(int fd, size_t& nBytes, size_t& nFileChunks); + static CODE readChunk(int fd, char* pChunk, size_t dChunkSize, size_t& nReadBytes); }; } } +void MTS::IO::QuectelRadio::updateQuectelChecksum(uint16_t& iChecksum, uint16_t iNewFragment) { + iChecksum = iChecksum ^ iNewFragment; +} + +uint16_t MTS::IO::QuectelRadio::bytesToUint16(uint8_t high, uint8_t low) { + uint16_t comboHigh = static_cast(high << 8); // explicit cast to prevent warnings + uint16_t comboLow = low; + return (comboHigh | comboLow); +} + #endif /* MTS_IO_QUECTELRADIO_H_ */ -- cgit v1.2.3 From d1798ea6a82c46b43e4caf27148189f34cc44ca5 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Wed, 1 Jul 2020 11:25:34 +0300 Subject: WIP: Quectel Delta Radio Firmware Upgrade support - libmts-io implementation Initial implementation of the "Apply delta firmware" step. Requires cleanup. --- 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 506b21b..cb455d8 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -76,6 +76,9 @@ namespace MTS { static inline uint16_t bytesToUint16(uint8_t high, uint8_t low); static CODE getFileSize(int fd, size_t& nBytes, size_t& nFileChunks); static CODE readChunk(int fd, char* pChunk, size_t dChunkSize, size_t& nReadBytes); + CODE waitApplyDeltaFirmware(UpdateCb& stepCb); + CODE waitFotaFinish(UpdateCb& stepCb); + CODE waitNewFirmware(UpdateCb& stepCb); }; } } -- cgit v1.2.3 From 2c3296b5239b5d27f5df4d61a9609ace6d70904f Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Fri, 3 Jul 2020 17:59:47 +0300 Subject: Quectel Delta Radio Firmware Upgrade support - libmts-io implementation Started code cleanup before finishing the procedure. Renamed functions related to the delta radio firmware upgrade to follow established patterns: - uploadDeltaFirmwareFile -> fumoLocalInject - applyDeltaFirmwareFile -> fumoLocalApply - removeDeltaFirmwareFile -> fumoLocalCleanup - new function: updateFumoLocal - encapsulates all the magic for radios that may not support separate stages for the delta upload and delta apply --- include/mts/MTS_IO_CellularRadio.h | 7 +++-- include/mts/MTS_IO_ICellularRadio.h | 55 +++++++++++++++++++++++-------------- include/mts/MTS_IO_QuectelRadio.h | 12 ++++---- 3 files changed, 45 insertions(+), 29 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index e65e7cd..e3941c3 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -99,9 +99,10 @@ namespace MTS { 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 uploadDeltaFirmwareFile(int fd, UpdateCb& stepCb) override; - CODE removeDeltaFirmwareFile() override; - CODE applyDeltaFirmwareFile(UpdateCb& stepCb) override; + CODE updateFumoLocal(int fd, UpdateCb& stepCb) override; + CODE fumoLocalInject(int fd, UpdateCb& stepCb) override; + CODE fumoLocalApply(UpdateCb& stepCb) override; + CODE fumoLocalCleanup() override; CODE resetHfa(const Json::Value& jArgs, UpdateCb& stepCb) override; CODE activate(const Json::Value& jArgs, UpdateCb& stepCb) override; CODE startOmaDm(UpdateCb& stepCb) override; diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index 3259041..e1edbcd 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -429,54 +429,69 @@ namespace MTS { virtual CODE updateFumo(const Json::Value& jArgs, UpdateCb& stepCb) = 0; /** - * @brief uploadDeltaFirmwareFile - upload delta file to the radio's internal memory. + * @brief updateFumoLocal - Performs the radio firmware upgrade using local firmware image. * - * This command uploads (injects) the whole delta firmware image to some place that - * can be later used by the radio to perform the Delta Radio Firmware Upgrade. - * - * This delta firmware image is NOT validated on the firmware image upload step. + * This command uploads (injects) the whole delta firmware image to the radio, performs the + * upgrade and waits for it to complete. * - * @param fd - file sescriptor of a file that shall be uploaded to the radio. - * @param stepCb - the callback to receive status updates during the upload. - * @return CODE::SUCCESS when the file was successfully uploaded, + * @param fd - file descriptor of a file that shall be injected to the radio. + * @param stepCb - callback to receive status updates during the firmware upgrade. + * @return CODE::SUCCESS when the firmware upgrade was successful, * CODE::INVALID_ARGS when the file can't be opened for reading, + * CODE::FAILURE when upgrade failed on the radio side, * CODE::NOT_APPLICABLE when not supported by this radio, * CODE::ERROR otherwise. */ - virtual CODE uploadDeltaFirmwareFile(int fd, UpdateCb& stepCb) = 0; + virtual CODE updateFumoLocal(int fd, UpdateCb& stepCb) = 0; /** - * @brief removeDeltaFirmwareFile - remove the delta file from the radio's internal memory. + * @brief fumoLocalInject - upload delta file to the radio's internal memory. * - * This command allows to remove the old delta firmware image from the radio's internal - * memory for cases when it's no longer needed. + * This command uploads (injects) the whole delta firmware image to some place that + * can be later used by the radio to perform the Delta Radio Firmware Upgrade. + * + * This delta firmware image is NOT validated on the firmware image upload step. * * @param fd - file sescriptor of a file that shall be uploaded to the radio. - * @return CODE::SUCCESS when the file was successfully deleted, - * CODE::FAILURE when the file can't be deleted (i.e. no such file), + * @param stepCb - callback to receive status updates during the upload. + * @return CODE::SUCCESS when the file was successfully uploaded, + * CODE::INVALID_ARGS when the file can't be opened for reading, * CODE::NOT_APPLICABLE when not supported by this radio, * CODE::ERROR otherwise. */ - virtual CODE removeDeltaFirmwareFile() = 0; + virtual CODE fumoLocalInject(int fd, UpdateCb& stepCb) = 0; /** - * @brief applyDeltaFirmwareFile - apply the delta file that was previously uploaded. + * @brief fumoLocalApply - apply the delta file that was previously uploaded. * * This commands initializes and tracks the progress of the delta firmware upgrade * procedure using the delta firmware image file that was previously uploaded - * into internal radio's memory. + * into internal memory of the radio. * - * See ICellularRadio::removeDeltaFirmwareFile to upload the file and prepare + * See ICellularRadio::fumoLocalInject to upload the file and prepare * for the upgrade. * - * @param fd - file sescriptor of a file that shall be uploaded to the radio. + * @param fd - file descriptor of a file that shall be uploaded to the radio. * @param stepCb - the callback to receive status updates during the upgrade. + * @return CODE::SUCCESS when the firmware upgrade was successful, + * CODE::FAILURE when upgrade failed on the radio side, + * CODE::NOT_APPLICABLE when not supported by this radio, + * CODE::ERROR otherwise. + */ + virtual CODE fumoLocalApply(UpdateCb& stepCb) = 0; + + /** + * @brief fumoLocalCleanup - remove the delta file from the radio's internal memory. + * + * This command allows to remove the old delta firmware image from the radio's internal + * memory for cases when it's no longer needed. + * * @return CODE::SUCCESS when the file was successfully deleted, * CODE::FAILURE when the file can't be deleted (i.e. no such file), * CODE::NOT_APPLICABLE when not supported by this radio, * CODE::ERROR otherwise. */ - virtual CODE applyDeltaFirmwareFile(UpdateCb& stepCb) = 0; + virtual CODE fumoLocalCleanup() = 0; /* * jArgs = { diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index cb455d8..b805ed8 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -45,9 +45,10 @@ namespace MTS { CODE setCellularMode(CELLULAR_MODES networks) override; - CODE uploadDeltaFirmwareFile(int fd, UpdateCb& stepCb) override; - CODE removeDeltaFirmwareFile() override; - CODE applyDeltaFirmwareFile(UpdateCb& stepCb) override; + CODE updateFumoLocal(int fd, UpdateCb& stepCb) override; + CODE fumoLocalInject(int fd, UpdateCb& stepCb) override; + CODE fumoLocalCleanup() override; + CODE fumoLocalApply(UpdateCb& stepCb) override; protected: QuectelRadio(const std::string& sName, const std::string& sRadioPort); @@ -76,9 +77,8 @@ namespace MTS { static inline uint16_t bytesToUint16(uint8_t high, uint8_t low); static CODE getFileSize(int fd, size_t& nBytes, size_t& nFileChunks); static CODE readChunk(int fd, char* pChunk, size_t dChunkSize, size_t& nReadBytes); - CODE waitApplyDeltaFirmware(UpdateCb& stepCb); - CODE waitFotaFinish(UpdateCb& stepCb); - CODE waitNewFirmware(UpdateCb& stepCb); + CODE fumoWaitUpgradeFinished(UpdateCb& stepCb); + CODE fumoWaitNewFirmware(UpdateCb& stepCb); }; } } -- cgit v1.2.3 From d19829b7e9cdd3c7e3d209628044ab62cd46b907 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Fri, 3 Jul 2020 18:53:57 +0300 Subject: Quectel Delta Radio Firmware Upgrade support - libmts-io implementation Simplified usage of step callbacks in the QuectelRadio class. Refactored existing function to use a wrapper and preven repetitive checks. --- include/mts/MTS_IO_QuectelRadio.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include') diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index b805ed8..3751b5a 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -72,6 +72,9 @@ namespace MTS { CODE startFileUpload(const std::string& sTargetFilename, size_t nBytes); CODE abortFileUpload(); + static inline void callNextStep(UpdateCb& stepCb, const char* csMessage); + static inline void callNextStep(UpdateCb& stepCb, const std::string& sMessage); + static uint16_t getQuectelChecksum(const void* data, size_t nBytes); static inline void updateQuectelChecksum(uint16_t& iChecksum, uint16_t iNewFragment); static inline uint16_t bytesToUint16(uint8_t high, uint8_t low); @@ -83,6 +86,18 @@ namespace MTS { } } +void MTS::IO::QuectelRadio::callNextStep(ICellularRadio::UpdateCb& stepCb, const char* csMessage) { + if (stepCb) { + stepCb(Json::Value(csMessage)); + } +} + +void MTS::IO::QuectelRadio::callNextStep(ICellularRadio::UpdateCb& stepCb, const std::string& sMessage) { + if (stepCb) { + stepCb(Json::Value(sMessage)); + } +} + void MTS::IO::QuectelRadio::updateQuectelChecksum(uint16_t& iChecksum, uint16_t iNewFragment) { iChecksum = iChecksum ^ iNewFragment; } -- cgit v1.2.3 From 0d5806073d2e9bbd7259c474b4079991e0c5ef13 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Fri, 3 Jul 2020 22:59:02 +0300 Subject: Quectel Delta Radio Firmware Upgrade support - libmts-io implementation Implemented firmware version check detection. --- include/mts/MTS_IO_QuectelRadio.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index 3751b5a..d8228cb 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -64,11 +64,18 @@ namespace MTS { virtual CODE checkFile(bool& bFilePresent, const std::string& sTargetFilename); private: + // private variable to save old firmware versions during FOTA + std::string m_sQuectelFirmware; + static const size_t FILE_CHUNK_SIZE; static const std::string CMD_ABORT_UPLOAD; static const std::string VALUE_MTS_DELTA_NAME; static const std::string VALUE_MTS_DELTA_PATH; + // TODO: Consider asbtracting to the ICellularRadio::getFirmwareBuild + //!< Get Quectel-specific firmware version (firmware build?) + CODE getQuectelFirmware(std::string& sFirmware); + CODE startFileUpload(const std::string& sTargetFilename, size_t nBytes); CODE abortFileUpload(); -- cgit v1.2.3 From e09f54c6b6fe35dc022fcea66935f5269866bff1 Mon Sep 17 00:00:00 2001 From: Andrii Pientsov Date: Fri, 10 Jul 2020 15:40:48 +0300 Subject: MTX-3404 mPower Oct20: Delta Radio Firmware Upgrade - L4E1 - libmts-io support --- include/mts/MTS_IO_LE910C4EURadio.h | 1 + include/mts/MTS_IO_TelitRadio.h | 50 ++++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/mts/MTS_IO_LE910C4EURadio.h b/include/mts/MTS_IO_LE910C4EURadio.h index e872df3..a0d6baa 100644 --- a/include/mts/MTS_IO_LE910C4EURadio.h +++ b/include/mts/MTS_IO_LE910C4EURadio.h @@ -35,6 +35,7 @@ namespace MTS { virtual ~LE910C4EURadio(){}; protected: + FOTA_GROUP getFotaGroup() override; private: diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index bd542f1..07a95de 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -44,6 +44,10 @@ namespace MTS { CODE getSupportedCellularModes(CELLULAR_MODES &networks) override; CODE setCellularMode(CELLULAR_MODES networks) override; + CODE updateFumoLocal(int fd, UpdateCb& stepCb) override; + CODE fumoLocalInject(int fd, UpdateCb& stepCb) override; + CODE fumoLocalApply(UpdateCb& stepCb) override; + protected: TelitRadio(const std::string& sName, const std::string& sRadioPort); @@ -53,10 +57,54 @@ namespace MTS { CODE getIsSimInserted(bool& bData) override; CODE getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk) override; + enum FOTA_GROUP : uint8_t { + VALUE_GROUP_A = 0, + VALUE_GROUP_B, + VALUE_GROUP_C, + VALUE_GROUP_D, + VALUE_UNKNOWN + }; + + virtual FOTA_GROUP getFotaGroup(); + virtual CODE uploadFile(int fd, UpdateCb& stepCb); + private: virtual CODE getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk, const std::string& sLockStatus); ICellularRadio::CODE wdsList(std::set &wds); + + // private variable to save old firmware versions during FOTA + std::string m_sTelitFirmware; + + static const size_t FILE_CHUNK_SIZE; + static const std::string CMD_ABORT_UPLOAD; + + CODE getTelitFirmware(std::string& sFirmware); + + CODE startFileUpload(); + CODE abortFileUpload(); + + static inline void callNextStep(UpdateCb& stepCb, const char* csMessage); + static inline void callNextStep(UpdateCb& stepCb, const std::string& sMessage); + + static CODE getFileSize(int fd, size_t& nBytes, size_t& nFileChunks); + static CODE readChunk(int fd, char* pChunk, size_t dChunkSize, size_t& nReadBytes); + CODE fumoWaitRadioBooted(UpdateCb& stepCb); + CODE fumoCheckNewFirmware(UpdateCb& stepCb); + }; } } -#endif + +void MTS::IO::TelitRadio::callNextStep(ICellularRadio::UpdateCb& stepCb, const char* csMessage) { + if (stepCb) { + stepCb(Json::Value(csMessage)); + } +} + +void MTS::IO::TelitRadio::callNextStep(ICellularRadio::UpdateCb& stepCb, const std::string& sMessage) { + if (stepCb) { + stepCb(Json::Value(sMessage)); + } +} + +#endif /* MTS_IO_TELITRADIO_H_ */ -- cgit v1.2.3 From ccd41677d998134ff501a8d6ac3a154dcaca9321 Mon Sep 17 00:00:00 2001 From: Andrii Pientsov Date: Mon, 13 Jul 2020 15:29:38 +0300 Subject: MTX-3404 Code Review --- include/mts/MTS_IO_CellularRadio.h | 4 ++++ include/mts/MTS_IO_QuectelRadio.h | 3 --- include/mts/MTS_IO_TelitRadio.h | 12 +++++------- 3 files changed, 9 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index e3941c3..6b23986 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -217,6 +217,10 @@ namespace MTS { std::string m_sRadioType; }; + static const size_t FILE_CHUNK_SIZE = 1024; + static CODE getFileSize(int fd, size_t& nBytes, size_t& nFileChunks); + static CODE readChunk(int fd, char* pChunk, size_t dChunkSize, size_t& nReadBytes); + private: std::string m_sName; std::string m_sRadioPort; diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index d8228cb..2121f7c 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -67,7 +67,6 @@ namespace MTS { // private variable to save old firmware versions during FOTA std::string m_sQuectelFirmware; - static const size_t FILE_CHUNK_SIZE; static const std::string CMD_ABORT_UPLOAD; static const std::string VALUE_MTS_DELTA_NAME; static const std::string VALUE_MTS_DELTA_PATH; @@ -85,8 +84,6 @@ namespace MTS { static uint16_t getQuectelChecksum(const void* data, size_t nBytes); static inline void updateQuectelChecksum(uint16_t& iChecksum, uint16_t iNewFragment); static inline uint16_t bytesToUint16(uint8_t high, uint8_t low); - static CODE getFileSize(int fd, size_t& nBytes, size_t& nFileChunks); - static CODE readChunk(int fd, char* pChunk, size_t dChunkSize, size_t& nReadBytes); CODE fumoWaitUpgradeFinished(UpdateCb& stepCb); CODE fumoWaitNewFirmware(UpdateCb& stepCb); }; diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index 07a95de..fdf8a20 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -66,7 +66,8 @@ namespace MTS { }; virtual FOTA_GROUP getFotaGroup(); - virtual CODE uploadFile(int fd, UpdateCb& stepCb); + virtual CODE fumoWriteGroupsABD(int fd, UpdateCb& stepCb); + //virtual CODE fumoWriteGroupC(int fd, UpdateCb& stepCb); private: virtual CODE getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk, const std::string& sLockStatus); @@ -75,20 +76,17 @@ namespace MTS { // private variable to save old firmware versions during FOTA std::string m_sTelitFirmware; - static const size_t FILE_CHUNK_SIZE; static const std::string CMD_ABORT_UPLOAD; CODE getTelitFirmware(std::string& sFirmware); - CODE startFileUpload(); - CODE abortFileUpload(); + CODE startWrite(); + CODE abortWrite(); static inline void callNextStep(UpdateCb& stepCb, const char* csMessage); static inline void callNextStep(UpdateCb& stepCb, const std::string& sMessage); - static CODE getFileSize(int fd, size_t& nBytes, size_t& nFileChunks); - static CODE readChunk(int fd, char* pChunk, size_t dChunkSize, size_t& nReadBytes); - CODE fumoWaitRadioBooted(UpdateCb& stepCb); + CODE fumoWaitUpgradeFinished(UpdateCb& stepCb); CODE fumoCheckNewFirmware(UpdateCb& stepCb); }; -- cgit v1.2.3 From 8186f98913c55191b5a3610d19c8580c6a86c2f4 Mon Sep 17 00:00:00 2001 From: Andrii Pientsov Date: Wed, 15 Jul 2020 13:49:59 +0300 Subject: MTX-3404 Code Review --- include/mts/MTS_IO_CellularRadio.h | 4 ++-- include/mts/MTS_IO_QuectelRadio.h | 1 + include/mts/MTS_IO_TelitRadio.h | 1 + 3 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 6b23986..57a4de6 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -217,8 +217,8 @@ namespace MTS { std::string m_sRadioType; }; - static const size_t FILE_CHUNK_SIZE = 1024; - static CODE getFileSize(int fd, size_t& nBytes, size_t& nFileChunks); + static CODE getFileSize(int fd, size_t& nBytes); + static CODE sizeToChunks(const size_t nBytes, const size_t chunkSize, size_t& nChunks); static CODE readChunk(int fd, char* pChunk, size_t dChunkSize, size_t& nReadBytes); private: diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index 2121f7c..6e7372b 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -67,6 +67,7 @@ namespace MTS { // private variable to save old firmware versions during FOTA std::string m_sQuectelFirmware; + static const size_t FILE_CHUNK_SIZE; static const std::string CMD_ABORT_UPLOAD; static const std::string VALUE_MTS_DELTA_NAME; static const std::string VALUE_MTS_DELTA_PATH; diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index fdf8a20..a3425f9 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -76,6 +76,7 @@ namespace MTS { // private variable to save old firmware versions during FOTA std::string m_sTelitFirmware; + static const size_t FILE_CHUNK_SIZE; static const std::string CMD_ABORT_UPLOAD; CODE getTelitFirmware(std::string& sFirmware); -- cgit v1.2.3 From 1986b67d54e8e6a3f8176f5b4cb78786ac3ee496 Mon Sep 17 00:00:00 2001 From: Andrii Pientsov Date: Thu, 16 Jul 2020 19:23:40 +0300 Subject: Add vendor firmware version --- include/mts/MTS_IO_CellularRadio.h | 1 + include/mts/MTS_IO_ICellularRadio.h | 2 ++ include/mts/MTS_IO_QuectelRadio.h | 4 +--- include/mts/MTS_IO_TelitRadio.h | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 57a4de6..ab6e00a 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -55,6 +55,7 @@ namespace MTS { CODE getFirmware(std::string& sFirmware) override; CODE getFirmwareBuild(std::string& sFirmwareBuild) override; + CODE getVendorFirmware(std::string& sVendorFirmware) override; CODE getHardware(std::string& sHardware) override; CODE getManufacturer(std::string& sManufacturer) override; CODE getImei(std::string& sImei) override; diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index e1edbcd..085c217 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -119,6 +119,7 @@ namespace MTS { 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_VENDOR_FIRMWARE; //!< Radio Vendor Firmware Version 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 @@ -221,6 +222,7 @@ namespace MTS { virtual CODE getFirmware(std::string& sFirmware) = 0; virtual CODE getFirmwareBuild(std::string& sFirmwareBuild) = 0; + virtual CODE getVendorFirmware(std::string& sVendorFirmware) = 0; virtual CODE getHardware(std::string& sHardware) = 0; virtual CODE getManufacturer(std::string& sManufacturer) = 0; virtual CODE getImei(std::string& sImei) = 0; diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index 6e7372b..b49004d 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -72,9 +72,7 @@ namespace MTS { static const std::string VALUE_MTS_DELTA_NAME; static const std::string VALUE_MTS_DELTA_PATH; - // TODO: Consider asbtracting to the ICellularRadio::getFirmwareBuild - //!< Get Quectel-specific firmware version (firmware build?) - CODE getQuectelFirmware(std::string& sFirmware); + CODE getVendorFirmware(std::string& sVendorFirmware); CODE startFileUpload(const std::string& sTargetFilename, size_t nBytes); CODE abortFileUpload(); diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index a3425f9..2f20996 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -79,7 +79,7 @@ namespace MTS { static const size_t FILE_CHUNK_SIZE; static const std::string CMD_ABORT_UPLOAD; - CODE getTelitFirmware(std::string& sFirmware); + CODE getVendorFirmware(std::string& sVendorFirmware); CODE startWrite(); CODE abortWrite(); -- cgit v1.2.3 From a05854f5d389f67001b7ecc4cda62c7320433349 Mon Sep 17 00:00:00 2001 From: Andrii Pientsov Date: Fri, 17 Jul 2020 10:03:48 +0300 Subject: Code review --- include/mts/MTS_IO_ME910Radio.h | 2 -- include/mts/MTS_IO_TelitRadio.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_ME910Radio.h b/include/mts/MTS_IO_ME910Radio.h index 09e8ede..93af86f 100644 --- a/include/mts/MTS_IO_ME910Radio.h +++ b/include/mts/MTS_IO_ME910Radio.h @@ -36,8 +36,6 @@ namespace MTS { virtual CODE setRxDiversity(const Json::Value& jArgs); - virtual CODE getFirmwareBuild(std::string& sFirmware); - protected: private: diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index 2f20996..d0a70ed 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -30,6 +30,7 @@ namespace MTS { public: bool resetRadio(uint32_t iTimeoutMillis = 5000) override; + CODE getFirmwareBuild(std::string& sFirmwareBuild) override; CODE getModel(std::string& sModel) override; CODE getIccid(std::string& sIccid) override; CODE getService(std::string& sService) override; -- cgit v1.2.3 From 298efe4e17d3665f9ddbb9298a37b563c60de735 Mon Sep 17 00:00:00 2001 From: Andrii Pientsov Date: Fri, 17 Jul 2020 10:42:16 +0300 Subject: Code review --- include/mts/MTS_IO_QuectelRadio.h | 3 +-- include/mts/MTS_IO_TelitRadio.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index b49004d..41c89dc 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -31,6 +31,7 @@ namespace MTS { public: bool resetRadio(uint32_t iTimeoutMillis = 5000) override; + CODE getVendorFirmware(std::string& sVendorFirmware) override; CODE getModel(std::string& sModel) override; CODE getIccid(std::string& sIccid) override; CODE getService(std::string& sService) override; @@ -72,8 +73,6 @@ namespace MTS { static const std::string VALUE_MTS_DELTA_NAME; static const std::string VALUE_MTS_DELTA_PATH; - CODE getVendorFirmware(std::string& sVendorFirmware); - CODE startFileUpload(const std::string& sTargetFilename, size_t nBytes); CODE abortFileUpload(); diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index d0a70ed..c3ba764 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -31,6 +31,7 @@ namespace MTS { bool resetRadio(uint32_t iTimeoutMillis = 5000) override; CODE getFirmwareBuild(std::string& sFirmwareBuild) override; + CODE getVendorFirmware(std::string& sVendorFirmware) override; CODE getModel(std::string& sModel) override; CODE getIccid(std::string& sIccid) override; CODE getService(std::string& sService) override; @@ -80,8 +81,6 @@ namespace MTS { static const size_t FILE_CHUNK_SIZE; static const std::string CMD_ABORT_UPLOAD; - CODE getVendorFirmware(std::string& sVendorFirmware); - CODE startWrite(); CODE abortWrite(); -- cgit v1.2.3 From b9a5e7ab27ad313b95fe6642f08e230091efef0f Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Tue, 21 Jul 2020 20:24:00 +0300 Subject: Telit Delta Radio Firmware Upgrade support - libmts-io implementation Changes after code review: 1. Handle cases when the number of bytes written is different from the number of bytes requested to transfer. 2. Use fstat instead of lseek to determine the firmware size. 3. Renamed TelitRadio::startWrite and TelitRadio::abortWrite functions to better represent their applicability scope. --- include/mts/MTS_IO_TelitRadio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index c3ba764..ffdddd9 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -81,8 +81,8 @@ namespace MTS { static const size_t FILE_CHUNK_SIZE; static const std::string CMD_ABORT_UPLOAD; - CODE startWrite(); - CODE abortWrite(); + CODE startFotaWriteABD(); + CODE abortFotaWriteABD(); static inline void callNextStep(UpdateCb& stepCb, const char* csMessage); static inline void callNextStep(UpdateCb& stepCb, const std::string& sMessage); -- cgit v1.2.3