summaryrefslogtreecommitdiff
path: root/src/MTS_IO_LE910NA1Radio.cpp
diff options
context:
space:
mode:
authorJeff Hatch <Jeff.Hatch@multitech.com>2017-06-02 16:22:48 -0500
committerJeff Hatch <Jeff.Hatch@multitech.com>2017-06-02 16:22:48 -0500
commitcb427be9a092b0968aee1a42a2bc805735c9c8f2 (patch)
treea8f353c619192e1ad5a018c1cdc9dc992cdc64a5 /src/MTS_IO_LE910NA1Radio.cpp
parent646b36e1e1f26e01b4675e2265ee83a5aca55cf2 (diff)
downloadlibmts-io-cb427be9a092b0968aee1a42a2bc805735c9c8f2.tar.gz
libmts-io-cb427be9a092b0968aee1a42a2bc805735c9c8f2.tar.bz2
libmts-io-cb427be9a092b0968aee1a42a2bc805735c9c8f2.zip
Add AT#FWSWITCH command for LNA radio support in radio-query and radio-cmd1.0.1
Diffstat (limited to 'src/MTS_IO_LE910NA1Radio.cpp')
-rw-r--r--src/MTS_IO_LE910NA1Radio.cpp92
1 files changed, 91 insertions, 1 deletions
diff --git a/src/MTS_IO_LE910NA1Radio.cpp b/src/MTS_IO_LE910NA1Radio.cpp
index d58483f..64583b4 100644
--- a/src/MTS_IO_LE910NA1Radio.cpp
+++ b/src/MTS_IO_LE910NA1Radio.cpp
@@ -24,7 +24,8 @@
A more elaborate description
*/
-
+#include <mts/MTS_Text.h>
+#include <mts/MTS_Logger.h>
#include <mts/MTS_IO_LE910NA1Radio.h>
using namespace MTS::IO;
@@ -36,3 +37,92 @@ LE910NA1Radio::LE910NA1Radio(const std::string& sPort)
{
}
+
+CellularRadio::CODE LE910NA1Radio::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 LE910NA1Radio::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;
+}
+