diff options
-rw-r--r-- | main.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -34,6 +34,8 @@ #include <iostream> #include <fstream> #include <signal.h> +#include <fcntl.h> +#include <unistd.h> #include "Version.h" const std::string DEFAULT_PORT("/dev/modem_at1"); @@ -68,6 +70,7 @@ std::string g_sConfigFile; Json::Value g_jData; std::string g_sSimPin; std::string g_sCellularMode; +std::string g_sDeltaFwPath; MTS::AutoPtr<MTS::IO::ICellularRadio> g_apRadio; @@ -110,6 +113,7 @@ const uint32_t OPT_RESET_RADIO = 0x40000000; int32_t g_iAuxOptions = 0; const uint32_t AOPT_OMA_DM_START = 0x00000001; +const uint32_t AOPT_DFU_UPLOAD = 0x00000002; void handle_sigterm(int signum); void printHelp(const std::string& sApp); @@ -155,11 +159,13 @@ static struct option long_options[] = { { "factory-default", no_argument, &iOption, OPT_INIT_RTN }, { "set-cellular-mode", required_argument, 0, 'w' }, { "start-oma-dm", no_argument, 0, 'o' }, + { "delta-fwu-upload", required_argument, 0, 'x' }, { 0, 0, 0, 0 } }; Json::Value getStaticData(); Json::Value getNetworkData(); +MTS::IO::ICellularRadio::CODE handleDeltaFwUpload(const std::string& sPath); MTS::IO::ICellularRadio::UpdateCb cb = [](const Json::Value& s)->void { if(s.isString()) { @@ -391,6 +397,8 @@ int main(int argc, char** argv) { } } else if (g_iAuxOptions & AOPT_OMA_DM_START) { result = g_apRadio->startOmaDm(cb); + } else if (g_iAuxOptions & AOPT_DFU_UPLOAD) { + result = handleDeltaFwUpload(g_sDeltaFwPath); } shutdown(); @@ -615,6 +623,12 @@ void parseOptions(int argc, char** argv) g_iAuxOptions |= AOPT_OMA_DM_START; break; + case 'x': + if (optarg) + g_sDeltaFwPath = optarg; + g_iAuxOptions |= AOPT_DFU_UPLOAD; + break; + default: printf("OPTION: [%d] ABORTING!!\n", c); abort(); @@ -666,6 +680,7 @@ void printHelp(const std::string& sApp) { printf("\t--unlock-sim-card <SIM PIN> : unlock the SIM card using the PIN code provided\n"); printf("\t--reset-radio : reset the radio module using AT commands\n"); printf("\t--start-oma-dm : start the OMA DM procedure (selected radios and networks only)\n"); + printf("\t--delta-fwu-upload <FILE_PATH> : upload a delta radio FWU file to the radio\n"); printf("\n"); printf("\t--printlvl (p) <level> : sets the printlvl [0-100]\n"); printf("\t--version (v) : returns version\n"); @@ -714,3 +729,16 @@ MTS::IO::ICellularRadio::CELLULAR_MODES cellularModeFlags(const std::string netw } return static_cast<ICellularRadio::CELLULAR_MODES>(result); } + +MTS::IO::ICellularRadio::CODE handleDeltaFwUpload(const std::string& sPath) { + int fd = open(sPath.c_str(), O_RDONLY); + if (fd < 0) { + printf("Failed to open file [%s]: %d\n", sPath.c_str(), errno); + return MTS::IO::ICellularRadio::CODE::ERROR; + } + + auto rc = g_apRadio->uploadDeltaFirmwareFile(fd, cb); + close(fd); + + return rc; +} |