summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/mts/MTS_IO_CellularRadio.h5
-rw-r--r--include/mts/MTS_IO_ICellularRadio.h51
-rw-r--r--include/mts/MTS_IO_QuectelRadio.h30
3 files changed, 86 insertions, 0 deletions
diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h
index ed87a24..e65e7cd 100644
--- a/include/mts/MTS_IO_CellularRadio.h
+++ b/include/mts/MTS_IO_CellularRadio.h
@@ -99,6 +99,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 startOmaDm(UpdateCb& stepCb) override;
@@ -179,6 +182,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..3259041 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,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"
diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h
index fcee069..506b21b 100644
--- a/include/mts/MTS_IO_QuectelRadio.h
+++ b/include/mts/MTS_IO_QuectelRadio.h
@@ -45,6 +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;
+
protected:
QuectelRadio(const std::string& sName, const std::string& sRadioPort);
@@ -54,10 +58,36 @@ 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 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<uint16_t>(high << 8); // explicit cast to prevent warnings
+ uint16_t comboLow = low;
+ return (comboHigh | comboLow);
+}
+
#endif /* MTS_IO_QUECTELRADIO_H_ */