summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Hatch <jhatch@multitech.com>2019-08-14 08:57:56 -0500
committerJeff Hatch <jhatch@multitech.com>2019-08-14 08:57:56 -0500
commit48d19b369ce074a13ecabf692e583710f17cec28 (patch)
tree7d26c4bbc81d7b4d73b57670615d00fe6dc56df8
parent07eb755bbdc2700f31ff4e5fd9a7ac04a14e69e8 (diff)
parent27d52e6d624a6bd56dc52e1b559812f64c4f3e43 (diff)
downloadlibmts-io-48d19b369ce074a13ecabf692e583710f17cec28.tar.gz
libmts-io-48d19b369ce074a13ecabf692e583710f17cec28.tar.bz2
libmts-io-48d19b369ce074a13ecabf692e583710f17cec28.zip
Merge branch 'L4N1_MNA1' into 'master' 1.0.19
L4 n1 mna1 See merge request !3
-rw-r--r--include/mts/MTS_IO_LE910C4NFRadio.h4
-rw-r--r--include/mts/MTS_IO_ME910C1NARadio.h4
-rw-r--r--src/MTS_IO_LE910C4NFRadio.cpp94
-rw-r--r--src/MTS_IO_ME910C1NARadio.cpp88
4 files changed, 190 insertions, 0 deletions
diff --git a/include/mts/MTS_IO_LE910C4NFRadio.h b/include/mts/MTS_IO_LE910C4NFRadio.h
index 04cb4ea..dfd0a0f 100644
--- a/include/mts/MTS_IO_LE910C4NFRadio.h
+++ b/include/mts/MTS_IO_LE910C4NFRadio.h
@@ -34,6 +34,10 @@ namespace MTS {
LE910C4NFRadio(const std::string& sPort);
virtual ~LE910C4NFRadio(){};
+ virtual CODE setActiveFirmware(const Json::Value& jArgs);
+
+ virtual CODE getActiveFirmware(std::string& sFwId);
+
protected:
private:
diff --git a/include/mts/MTS_IO_ME910C1NARadio.h b/include/mts/MTS_IO_ME910C1NARadio.h
index c3ceac3..e8120bd 100644
--- a/include/mts/MTS_IO_ME910C1NARadio.h
+++ b/include/mts/MTS_IO_ME910C1NARadio.h
@@ -42,6 +42,10 @@ namespace MTS {
ME910C1NARadio(const std::string& sPort);
virtual ~ME910C1NARadio(){};
+ virtual CODE setActiveFirmware(const Json::Value& jArgs);
+
+ virtual CODE getActiveFirmware(std::string& sFwId);
+
protected:
private:
diff --git a/src/MTS_IO_LE910C4NFRadio.cpp b/src/MTS_IO_LE910C4NFRadio.cpp
index 53348f7..4c7f5a3 100644
--- a/src/MTS_IO_LE910C4NFRadio.cpp
+++ b/src/MTS_IO_LE910C4NFRadio.cpp
@@ -18,6 +18,8 @@
*
*/
+#include <mts/MTS_Text.h>
+#include <mts/MTS_Logger.h>
#include <mts/MTS_IO_LE910C4NFRadio.h>
using namespace MTS::IO;
@@ -30,3 +32,95 @@ LE910C4NFRadio::LE910C4NFRadio(const std::string& sPort)
}
+CellularRadio::CODE LE910C4NFRadio::setActiveFirmware(const Json::Value& jArgs) {
+ CellularRadio::CODE rc;
+
+ // Set command allows enabling a specific firmware image on products
+ // embedding 2 different firmware images:
+ //
+ // "AT#FWSWITCH=<image_number>[,<storage_conf>]"
+ // <image_number> - Firmware Image To Be Enabled
+ // 0 – Image 1 (Default)
+ // 1 – Image 2
+ // <storage_conf> - Setting Storage Configuration
+ // 0 – Save the <image_number> value in RAM
+ // 1 – Save the <image_number> value in NVM
+
+ printTrace("%s| Set Active Firmware Image Number", getName().c_str());
+
+ if(!jArgs["fwid"].isString()) {
+ return INVALID_ARGS;
+ }
+
+ if (jArgs["fwid"].asString() != "1" && jArgs["fwid"].asString() != "0" && jArgs["fwid"].asString() != "2") {
+ return INVALID_ARGS;
+ }
+
+ // LE910-NA1 and LE910-NA V2 is orderable in single image or dual image (single SKU)
+ // configuration. So issue the test command first to make sure FWSWITCH is a valid command
+ rc = sendBasicCommand("AT#FWSWITCH=?");
+ if (rc == ERROR) {
+ printTrace("%s| FWSWITCH is not supported", getName().c_str());
+ return NOT_APPLICABLE;
+ }
+ else if (rc != SUCCESS) {
+ return rc;
+ }
+
+ std::string sCmd = "AT#FWSWITCH=";
+ sCmd += jArgs["fwid"].asString();
+ sCmd += ",1";
+
+ printTrace("%s| Issuing %s command", getName().c_str(), sCmd.c_str());
+
+ return sendBasicCommand(sCmd, 5000);
+}
+
+CellularRadio::CODE LE910C4NFRadio::getActiveFirmware(std::string& sFwId) {
+ std::string sCmd;
+ CellularRadio::CODE rc;
+ //
+ // Read command reports the current active firmware image:
+ // AT#FWSWITCH?
+ // #FWSWITCH: 1
+ //
+ // OK
+ //
+ printTrace("%s| Get Active Firmware Image Number", getName().c_str());
+
+ // LE910-NA1 and LE910-NA V2 is orderable in single image or dual image (single SKU)
+ // configuration. So issue the test command first
+ sCmd = "AT#FWSWITCH=?";
+ rc = sendBasicCommand(sCmd);
+ if (rc == ERROR) {
+ printTrace("%s| FWSWITCH is not supported", getName().c_str());
+ return NOT_APPLICABLE;
+ }
+ else if (rc != SUCCESS) {
+ return rc;
+ }
+
+ sCmd = "AT#FWSWITCH?";
+ std::string sResult = sendCommand(sCmd);
+ size_t end = sResult.find(RSP_OK);
+ if (end == std::string::npos) {
+ printWarning("%s| Unable to get active image number from radio using command [%s]",
+ getName().c_str(),
+ sCmd.c_str());
+ return FAILURE;
+ }
+
+ size_t start = sResult.find("#FWSWITCH:") + sizeof("#FWSWITCH:");
+ std::string sFwSwitchValue = MTS::Text::trim(sResult.substr(start, end-start));
+ std::vector<std::string> sFwSwitchValues = Text::split(sFwSwitchValue, ',', 2);
+ if (sFwSwitchValues.size() >= 1)
+ {
+ sFwId = sFwSwitchValues[0];
+ }
+ if(sFwId.size() == 0) {
+ printWarning("%s| Firmware Image Number is empty", getName().c_str());
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
diff --git a/src/MTS_IO_ME910C1NARadio.cpp b/src/MTS_IO_ME910C1NARadio.cpp
index 698bbf7..8c9992e 100644
--- a/src/MTS_IO_ME910C1NARadio.cpp
+++ b/src/MTS_IO_ME910C1NARadio.cpp
@@ -37,3 +37,91 @@ ME910C1NARadio::ME910C1NARadio(const std::string& sPort)
{
}
+
+CellularRadio::CODE ME910C1NARadio::setActiveFirmware(const Json::Value& jArgs) {
+ CellularRadio::CODE rc;
+
+ // Set command allows enabling a specific firmware image on products
+ // embedding 2 different firmware images:
+ //
+ // "AT#FWSWITCH=<image_number>[,<storage_conf>]"
+ // <image_number> - Firmware Image To Be Enabled
+ // 0 – Image 1 (Default)
+ // 1 – Image 2
+ // <storage_conf> - Setting Storage Configuration
+ // 0 – Save the <image_number> value in RAM
+ // 1 – Save the <image_number> value in NVM
+
+ printTrace("%s| Set Active Firmware Image Number", getName().c_str());
+
+ if(!jArgs["fwid"].isString()) {
+ return INVALID_ARGS;
+ }
+
+ if (jArgs["fwid"].asString() != "1" && jArgs["fwid"].asString() != "0") {
+ return INVALID_ARGS;
+ }
+
+ // LE910-NA1 and LE910-NA V2 is orderable in single image or dual image (single SKU)
+ // configuration. So issue the test command first
+ rc = sendBasicCommand("AT#FWSWITCH=?");
+ if (rc == ERROR) {
+ printTrace("%s| FWSWITCH is not supported", getName().c_str());
+ return NOT_APPLICABLE;
+ }
+ else if (rc != SUCCESS) {
+ return rc;
+ }
+
+ std::string sCmd = "AT#FWSWITCH=";
+ sCmd += jArgs["fwid"].asString();
+ sCmd += ",1";
+
+ printTrace("%s| Issuing %s command", getName().c_str(), sCmd.c_str());
+
+ return sendBasicCommand(sCmd, 5000);
+}
+
+CellularRadio::CODE ME910C1NARadio::getActiveFirmware(std::string& sFwId) {
+ std::string sCmd;
+ CellularRadio::CODE rc;
+ //
+ // Read command reports the current active firmware image:
+ // AT#FWSWITCH?
+ // #FWSWITCH: 1
+ //
+ // OK
+ //
+ printTrace("%s| Get Active Firmware Image Number", getName().c_str());
+
+ // LE910-NA1 and LE910-NA V2 is orderable in single image or dual image (single SKU)
+ // configuration. So issue the test command first
+ sCmd = "AT#FWSWITCH=?";
+ rc = sendBasicCommand(sCmd);
+ if (rc == ERROR) {
+ printTrace("%s| FWSWITCH is not supported", getName().c_str());
+ return NOT_APPLICABLE;
+ }
+ else if (rc != SUCCESS) {
+ return rc;
+ }
+
+ sCmd = "AT#FWSWITCH?";
+ std::string sResult = sendCommand(sCmd);
+ size_t end = sResult.find(RSP_OK);
+ if (end == std::string::npos) {
+ printWarning("%s| Unable to get active image number from radio using command [%s]",
+ getName().c_str(),
+ sCmd.c_str());
+ return FAILURE;
+ }
+
+ size_t start = sResult.find("#FWSWITCH:") + sizeof("#FWSWITCH:");
+ sFwId = MTS::Text::trim(sResult.substr(start, end-start));
+ if(sFwId.size() == 0) {
+ printWarning("%s| Firmware Image Number is empty", getName().c_str());
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}