diff options
-rw-r--r-- | main.cpp | 39 |
1 files changed, 33 insertions, 6 deletions
@@ -115,6 +115,7 @@ int32_t g_iAuxOptions = 0; const uint32_t AOPT_OMA_DM_START = 0x00000001; const uint32_t AOPT_DFU_UPLOAD = 0x00000002; const uint32_t AOPT_DFU_APPLY = 0x00000004; +const uint32_t AOPT_FUMO_LOCAL = 0x00000008; void handle_sigterm(int signum); void printHelp(const std::string& sApp); @@ -161,13 +162,15 @@ static struct option long_options[] = { { "set-cellular-mode", required_argument, 0, 'w' }, { "start-oma-dm", no_argument, 0, 'o' }, { "delta-fwu-upload", required_argument, 0, 'x' }, - { "delta-fwu-apply", no_argument, 0, 'F' }, + { "delta-fwu-apply", no_argument, 0, 'A' }, + { "init-fumo-local", required_argument, 0, 'F' }, { 0, 0, 0, 0 } }; Json::Value getStaticData(); Json::Value getNetworkData(); MTS::IO::ICellularRadio::CODE handleDeltaFwUpload(const std::string& sPath); +MTS::IO::ICellularRadio::CODE handleFumoLocal(const std::string& sPath); MTS::IO::ICellularRadio::UpdateCb cb = [](const Json::Value& s)->void { if(s.isString()) { @@ -402,7 +405,9 @@ int main(int argc, char** argv) { } else if (g_iAuxOptions & AOPT_DFU_UPLOAD) { result = handleDeltaFwUpload(g_sDeltaFwPath); } else if (g_iAuxOptions & AOPT_DFU_APPLY) { - result = g_apRadio->applyDeltaFirmwareFile(cb); + result = g_apRadio->fumoLocalApply(cb); + } else if (g_iAuxOptions & AOPT_FUMO_LOCAL) { + result = handleFumoLocal(g_sDeltaFwPath); } shutdown(); @@ -633,10 +638,16 @@ void parseOptions(int argc, char** argv) g_iAuxOptions |= AOPT_DFU_UPLOAD; break; - case 'F': + case 'A': g_iAuxOptions |= AOPT_DFU_APPLY; break; + case 'F': + if (optarg) + g_sDeltaFwPath = optarg; + g_iAuxOptions |= AOPT_FUMO_LOCAL; + break; + default: printf("OPTION: [%d] ABORTING!!\n", c); abort(); @@ -688,8 +699,10 @@ 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("\t--delta-fwu-apply : apply the delta radio FWU image that was already uploaded to the radio\n"); + printf("\t--init-fumo-local <FILE_PATH> : perform the radio firmware upgrade using the provided image file\n"); + // Undocumented: use for debugging and testing purposes + // printf("\t--delta-fwu-upload <FILE_PATH> : upload a delta radio FWU file to the radio\n"); + // printf("\t--delta-fwu-apply : apply the delta radio FWU image that was already uploaded to the radio\n"); printf("\n"); printf("\t--printlvl (p) <level> : sets the printlvl [0-100]\n"); printf("\t--version (v) : returns version\n"); @@ -746,7 +759,21 @@ MTS::IO::ICellularRadio::CODE handleDeltaFwUpload(const std::string& sPath) { return MTS::IO::ICellularRadio::CODE::ERROR; } - auto rc = g_apRadio->uploadDeltaFirmwareFile(fd, cb); + auto rc = g_apRadio->fumoLocalInject(fd, cb); + close(fd); + + return rc; +} + + +MTS::IO::ICellularRadio::CODE handleFumoLocal(const std::string& sPath) { + int fd = open(sPath.c_str(), O_RDONLY); + if (fd < 0) { + printf("FUMO Error: failed to open file [%s]: %d\n", sPath.c_str(), errno); + return MTS::IO::ICellularRadio::CODE::ERROR; + } + + auto rc = g_apRadio->updateFumoLocal(fd, cb); close(fd); return rc; |