summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrii Pientsov <andrii.pientsov@globallogic.com>2020-07-06 12:58:51 -0500
committerAndrii Pientsov <andrii.pientsov@globallogic.com>2020-07-06 12:58:51 -0500
commit9e007df4a7e3fafff27a0c3fa11d4ba53e785985 (patch)
tree48851ebc4c9dbb8c4f7d9885453aa1986ac41148 /include
parent343e662b6224cf03fea5ebfd419c7cf990528b53 (diff)
parent63b1b15a510ff3acdc4f93bbac1ed14548e6620b (diff)
downloadlibmts-io-9e007df4a7e3fafff27a0c3fa11d4ba53e785985.tar.gz
libmts-io-9e007df4a7e3fafff27a0c3fa11d4ba53e785985.tar.bz2
libmts-io-9e007df4a7e3fafff27a0c3fa11d4ba53e785985.zip
Merge branch 'sk/quectel-delta-fwu' into 'delta-radio-fwu'
Quectel Delta Radio Firmware Upgrade support - libmts-io implementation See merge request !26
Diffstat (limited to 'include')
-rw-r--r--include/mts/MTS_IO_CellularRadio.h6
-rw-r--r--include/mts/MTS_IO_ICellularRadio.h66
-rw-r--r--include/mts/MTS_IO_QuectelRadio.h55
3 files changed, 127 insertions, 0 deletions
diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h
index ed87a24..e3941c3 100644
--- a/include/mts/MTS_IO_CellularRadio.h
+++ b/include/mts/MTS_IO_CellularRadio.h
@@ -99,6 +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 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;
@@ -179,6 +183,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 f2d4dfe..e1edbcd 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;
@@ -427,6 +428,71 @@ namespace MTS {
*/
virtual CODE updateFumo(const Json::Value& jArgs, UpdateCb& stepCb) = 0;
+ /**
+ * @brief updateFumoLocal - Performs the radio firmware upgrade using local firmware image.
+ *
+ * This command uploads (injects) the whole delta firmware image to the radio, performs the
+ * upgrade and waits for it to complete.
+ *
+ * @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 updateFumoLocal(int fd, UpdateCb& stepCb) = 0;
+
+ /**
+ * @brief fumoLocalInject - 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 - 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 fumoLocalInject(int fd, UpdateCb& stepCb) = 0;
+
+ /**
+ * @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 memory of the radio.
+ *
+ * See ICellularRadio::fumoLocalInject to upload the file and prepare
+ * for the upgrade.
+ *
+ * @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 fumoLocalCleanup() = 0;
+
/*
* jArgs = {
* "msl" : "Master Subsidy Lock (Sprint): STRING"
diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h
index fcee069..d8228cb 100644
--- a/include/mts/MTS_IO_QuectelRadio.h
+++ b/include/mts/MTS_IO_QuectelRadio.h
@@ -45,6 +45,11 @@ namespace MTS {
CODE setCellularMode(CELLULAR_MODES networks) 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);
@@ -54,10 +59,60 @@ 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:
+ // 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();
+
+ 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);
+ 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);
};
}
}
+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;
+}
+
+uint16_t MTS::IO::QuectelRadio::bytesToUint16(uint8_t high, uint8_t low) {
+ uint16_t comboHigh = static_cast<uint16_t>(high << 8); // explicit cast to prevent warnings
+ uint16_t comboLow = low;
+ return (comboHigh | comboLow);
+}
+
#endif /* MTS_IO_QUECTELRADIO_H_ */