diff options
Diffstat (limited to 'include/mts/MTS_IO_QuectelRadio.h')
-rw-r--r-- | include/mts/MTS_IO_QuectelRadio.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index c6114a0..c55b224 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -44,6 +44,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); @@ -53,10 +57,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_ */ |