summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJeff Hatch <jhatch@multitech.com>2020-07-22 08:25:08 -0500
committerJeff Hatch <jhatch@multitech.com>2020-07-22 08:25:08 -0500
commitd340135922da6eb881418824e470cbdba835b498 (patch)
tree90e162e6cf2c6a1d3b890a5483c9f77a000ced09 /include
parent343e662b6224cf03fea5ebfd419c7cf990528b53 (diff)
parentbeb3f36c5dcc70beed900859d6426dc74e4bccc8 (diff)
downloadlibmts-io-d340135922da6eb881418824e470cbdba835b498.tar.gz
libmts-io-d340135922da6eb881418824e470cbdba835b498.tar.bz2
libmts-io-d340135922da6eb881418824e470cbdba835b498.zip
Merge branch 'delta-radio-fwu' into 'master'
Delta Radio Firmware Upgrade support: LEU7 and L4E1 See merge request !30
Diffstat (limited to 'include')
-rw-r--r--include/mts/MTS_IO_CellularRadio.h11
-rw-r--r--include/mts/MTS_IO_ICellularRadio.h68
-rw-r--r--include/mts/MTS_IO_LE910C4EURadio.h1
-rw-r--r--include/mts/MTS_IO_ME910Radio.h2
-rw-r--r--include/mts/MTS_IO_QuectelRadio.h50
-rw-r--r--include/mts/MTS_IO_TelitRadio.h49
6 files changed, 178 insertions, 3 deletions
diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h
index ed87a24..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;
@@ -99,6 +100,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 +184,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()
@@ -211,6 +218,10 @@ namespace MTS {
std::string m_sRadioType;
};
+ 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:
std::string m_sName;
std::string m_sRadioPort;
diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h
index f2d4dfe..085c217 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;
@@ -118,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
@@ -220,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;
@@ -427,6 +430,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_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_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_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h
index fcee069..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;
@@ -45,6 +46,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 +60,54 @@ 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;
+
+ 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);
+ 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_ */
diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h
index bd542f1..ffdddd9 100644
--- a/include/mts/MTS_IO_TelitRadio.h
+++ b/include/mts/MTS_IO_TelitRadio.h
@@ -30,6 +30,8 @@ namespace MTS {
public:
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;
@@ -44,6 +46,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 +59,51 @@ 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 fumoWriteGroupsABD(int fd, UpdateCb& stepCb);
+ //virtual CODE fumoWriteGroupC(int fd, UpdateCb& stepCb);
+
private:
virtual CODE getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk, const std::string& sLockStatus);
ICellularRadio::CODE wdsList(std::set<int> &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 startFotaWriteABD();
+ CODE abortFotaWriteABD();
+
+ static inline void callNextStep(UpdateCb& stepCb, const char* csMessage);
+ static inline void callNextStep(UpdateCb& stepCb, const std::string& sMessage);
+
+ CODE fumoWaitUpgradeFinished(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_ */