summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhii Kostiuk <serhii.o.kostiuk@globallogic.com>2020-05-29 22:14:22 +0300
committerSerhii Kostiuk <serhii.o.kostiuk@globallogic.com>2020-05-30 11:29:06 +0300
commit1870facf5636ee237b217c5950bb64597ee21a51 (patch)
treed6b02eb47454ac02831b406a4f0009741f756263
parentc01246193e111a6be14449278281ab58865a7123 (diff)
downloadradio-cmd-1870facf5636ee237b217c5950bb64597ee21a51.tar.gz
radio-cmd-1870facf5636ee237b217c5950bb64597ee21a51.tar.bz2
radio-cmd-1870facf5636ee237b217c5950bb64597ee21a51.zip
Quectel Delta Radio Firmware Upgrade support - radio-cmd implementation
Implemented a command for delta radio firmware upgrade file uploads.
-rw-r--r--main.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/main.cpp b/main.cpp
index 5169d4e..8ac634d 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;
@@ -108,6 +111,8 @@ const uint32_t OPT_SET_CELLULAR_MODE = 0x08000000;
const uint32_t OPT_UNLOCK_SIM_CARD = 0x20000000;
const uint32_t OPT_RESET_RADIO = 0x40000000;
+int32_t g_iAuxOptions = 0;
+const uint32_t AOPT_DFU_UPLOAD = 0x00000001;
void handle_sigterm(int signum);
void printHelp(const std::string& sApp);
@@ -152,11 +157,13 @@ static struct option long_options[] = {
{ "init-activation", no_argument, &iOption, OPT_INIT_ACTIVATION },
{ "factory-default", no_argument, &iOption, OPT_INIT_RTN },
{ "set-cellular-mode", required_argument, 0, 'w' },
+ { "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()) {
@@ -386,6 +393,8 @@ int main(int argc, char** argv) {
} else {
printf("Invalid argument: %s\n", g_sCellularMode.c_str());
}
+ } else if (g_iAuxOptions & AOPT_DFU_UPLOAD) {
+ result = handleDeltaFwUpload(g_sDeltaFwPath);
}
shutdown();
@@ -606,6 +615,12 @@ void parseOptions(int argc, char** argv)
g_iOptions |= OPT_SET_CELLULAR_MODE;
break;
+ case 'x':
+ if (optarg)
+ g_sDeltaFwPath = optarg;
+ g_iAuxOptions |= AOPT_DFU_UPLOAD;
+ break;
+
default:
printf("OPTION: [%d] ABORTING!!\n", c);
abort();
@@ -656,13 +671,14 @@ void printHelp(const std::string& sApp) {
printf("\t--factory-default [ --msl <MSL> ] : reset to factory defaults\n");
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--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");
printf("\t--help (?) : returns this message\n");
printf("\n");
printf("\tSupported Radios:\n");
- printf("\t\tLE910, HE910, GE910, DE910, CE910\n");
+ printf("\t\tLE910, HE910, GE910, DE910, CE910, ME910, EG95\n");
}
const char *code2str(MTS::IO::ICellularRadio::CODE code) {
@@ -704,3 +720,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;
+}