summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/main.cpp b/main.cpp
index cfe7727..3ec00db 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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,9 @@ 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;
+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);
@@ -155,11 +161,16 @@ 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' },
+ { "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()) {
@@ -391,6 +402,12 @@ 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);
+ } else if (g_iAuxOptions & AOPT_DFU_APPLY) {
+ result = g_apRadio->fumoLocalApply(cb);
+ } else if (g_iAuxOptions & AOPT_FUMO_LOCAL) {
+ result = handleFumoLocal(g_sDeltaFwPath);
}
shutdown();
@@ -615,6 +632,22 @@ 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;
+
+ 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();
@@ -666,6 +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--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");
@@ -714,3 +751,30 @@ 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->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;
+}