AT command firmware for MultiTech Dot devices.
Fork of mDot_AT_firmware by
Dot Library Not Included!
Because these example programs can be used for both mDot and xDot devices, the LoRa stack is not included. The libmDot library should be imported if building for mDot devices. The libxDot library should be imported if building for xDot devices. The AT firmware was last tested with mbed-os-5.4.7. Using a version past mbed-os-5.4.7 will cause the build to fail. The library used with the AT firmware has to match the mbed-os version.
Dot Library Version 3 Updates
Dot Library versions 3.x.x require a channel plan to be injected into the stack. The Dot-Examples and Dot-AT-Firmware do this by defining a macro called "CHANNEL_PLAN" that controls the channel plan that will be used in the examples. Available channel plans will be in the Dot Library repository in the plans folder.
Revision 20 and earlier of Dot-Examples and revision 15 and earlier of Dot-AT-Firmware should be used with Dot Library versions prior to 3.0.0.
Fota Library
Th Fota Library must be added to compile for mDot 3.1.0 with Fota support. Latest dev libraries and 3.2.0 release will include Fota with libmDot/libxDot.
AT Firmware Description
This AT Firmware is what ships on mDot and xDot devices. It provides an AT command interface for using the mDot or xDot for LoRa communication.
AT command documentation can be found on Multitech.com.
The firmware changelog can be found here.
The library changelog can be found here.
Dot Libraries
Dot Library Limitations
The commit messages in libmDot-mbed5 and libmDot-dev-mbed5 specify the version of the Dot library the commit contains and the version of mbed-os it was compiled against. We recommend building your application with the version of mbed-os specified in the commit message of the version of the Dot library you're using. This will ensure that you don't run into any runtime issues caused by differences in the mbed-os versions.
Stable and development libraries are available for both mDot and xDot platforms. The library chosen must match the target platform. Compiling for the mDot platform with the xDot library or vice versa will not succeed.
mDot Library
Development library for mDot.
Stable library for mDot.
xDot Library
Development library for xDot.
Stable library for xDot.
Diff: CommandTerminal/CmdNetworkId.cpp
- Revision:
- 28:c222ca8383f4
- Parent:
- 27:5fafd3b26ac3
- Child:
- 36:b586cd6e91f3
--- a/CommandTerminal/CmdNetworkId.cpp Fri Sep 11 13:16:33 2020 -0500 +++ b/CommandTerminal/CmdNetworkId.cpp Thu Nov 19 09:58:25 2020 -0600 @@ -1,57 +1,52 @@ #include "CmdNetworkId.h" CmdNetworkId::CmdNetworkId() : - Command("Network ID", "AT+NI", -#if defined(TARGET_MTS_MDOT_F411RE) - "Configured Network Name/EUI (MSB, App EUI in LoRaWAN) AT+NI=0/2,hex AT+NI=1,network_name (Net ID = crc64(network_name)) (8 bytes)", +#if MTS_CMD_TERM_VERBOSE + Command("Network ID", "AT+NI", "Configured Network Name/EUI (MSB, App EUI in LoRaWAN) AT+NI=0/2,hex AT+NI=1,network_name (Net ID = crc64(network_name)) (8 bytes)", "(0/2,(hex:8)),(1,(string:128))") #else - "", + Command("AT+NI") #endif - "(0/2,(hex:8)),(1,(string:128))") { _queryable = true; } uint32_t CmdNetworkId::action(const std::vector<std::string>& args) { - if (args.size() == 1) - { - CommandTerminal::Serial()->writef("%s\r\n", mts::Text::bin2hexString(CommandTerminal::Dot()->getNetworkId(), "-").c_str()); - - if (!CommandTerminal::Dot()->getNetworkName().empty()) - CommandTerminal::Serial()->writef("Passphrase: '%s'\r\n", CommandTerminal::Dot()->getNetworkName().c_str()); + char arg1 = '\0'; + if ((args.size() >= 2) && (args[1].size() == 1)) { + arg1 = args[1][0]; } - else if ((args.size() == 2 || (args.size() == 3 && args[2].find("?") == 0)) && args[1].find("2") == 0 && args[1].size() == 1) { - CommandTerminal::Serial()->writef("%s\r\n", mts::Text::bin2hexString(CommandTerminal::Dot()->getProtectedAppEUI(), "-").c_str()); - } - else - { - if (args[1].find("1") == 0 && args[1].size() == 1) + + if ((args.size() == 1) || ((args.size() == 3) && (args[2].size() == 1) && (args[2][0] == '?'))) { + if (arg1 == '2') { + CommandTerminal::Serial()->writef("%s\r\n", mts::Text::bin2hexString(CommandTerminal::Dot()->getProtectedAppEUI(), "-").c_str()); + } else { + CommandTerminal::Serial()->writef("%s\r\n", mts::Text::bin2hexString(CommandTerminal::Dot()->getNetworkId(), "-").c_str()); + + if (!CommandTerminal::Dot()->getNetworkName().empty()) + CommandTerminal::Serial()->writef("Passphrase: '%s'\r\n", CommandTerminal::Dot()->getNetworkName().c_str()); + } + } else if (args.size() >= 3) { + if (arg1 == '1') { - std::string text; - if (args.size() > 3) + std::string text = args[2]; + + // passphrase was split on commas + for (size_t i = 3; i < args.size(); i++) { - // passphrase was split on commas - for (size_t i = 2; i < args.size(); i++) - { - text.append(args[i]); - if (i < args.size() - 1) - text.append(","); - } - } - else - { - text = args[2]; + text.append(","); + text.append(args[i]); } if (CommandTerminal::Dot()->setNetworkName(text) == mDot::MDOT_OK) { +#if MTS_CMD_TERM_VERBOSE CommandTerminal::Serial()->writef("Set Network Name: "); CommandTerminal::Serial()->writef("%s\r\n", text.c_str()); +#endif } else { - CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; return 1; } } @@ -59,26 +54,28 @@ { std::vector<uint8_t> NewEUI; readByteArray(args[2], NewEUI, EUI_LENGTH); - if (args[1] != "2") { + if (arg1 != '2') { if (CommandTerminal::Dot()->setNetworkId(NewEUI) == mDot::MDOT_OK) { +#if MTS_CMD_TERM_VERBOSE CommandTerminal::Serial()->writef("Set Network ID: "); CommandTerminal::Serial()->writef("%s\r\n", mts::Text::bin2hexString(NewEUI, "-").c_str()); +#endif } else { - CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; return 1; } } else { if (CommandTerminal::Dot()->setProtectedAppEUI(NewEUI) == mDot::MDOT_OK) { +#if MTS_CMD_TERM_VERBOSE CommandTerminal::Serial()->writef("Set Protected AppEUI: "); CommandTerminal::Serial()->writef("%s\r\n", mts::Text::bin2hexString(NewEUI, "-").c_str()); +#endif } else { - CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError()); return 1; } } @@ -93,32 +90,48 @@ if (args.size() == 1) return true; - if (args.size() == 2 && args[1] == "2") - return true; + if (args.size() > 1 && args[1].size() == 1) { + + char arg1 = args[1][0]; + + if (args.size() == 2 && arg1 == '2') + return true; + + if (args.size() >= 3) { + if (arg1 != '0' && arg1 != '1' && arg1 != '2') { + #if MTS_CMD_TERM_VERBOSE + CommandTerminal::setErrorMessage("Invalid type, expects (0,1,2)"); + #endif + return false; + } - if (args.size() == 3) { - if (args[1] != "0" && args[1] != "1" && args[1] != "2") { - CommandTerminal::setErrorMessage("Invalid type, expects (0,1,2)"); - return false; - } - if ((args[1] == "0" || args[1] == "2") && args[2] != "?" && !isHexString(args[2], 8)) { - CommandTerminal::setErrorMessage("Invalid ID, expects (hex:8)"); - return false; + if ((arg1 == '0' || arg1 == '2') && args[2] != "?" && !isHexString(args[2], 8)) { + #if MTS_CMD_TERM_VERBOSE + CommandTerminal::setErrorMessage("Invalid ID, expects (hex:8)"); + #endif + return false; + } else { + if (args[2].size() < 8) { + if (!((args[2].size() == 1) && (args[2][0] == '?'))) { + #if MTS_CMD_TERM_VERBOSE + CommandTerminal::setErrorMessage("Invalid name, expects minimum 8 characters"); + #endif + return false; + } + } else if (args[2].size() > 128) { + #if MTS_CMD_TERM_VERBOSE + CommandTerminal::setErrorMessage("Invalid name, expects (string:128)"); + #endif + return false; + } + } + + return true; } - - if (args[1] == "1" && args[2].size() < 8) { - CommandTerminal::setErrorMessage("Invalid name, expects minimum 8 characters"); - return false; - } - - if (args[1] == "1" && args[2].size() > 128) { - CommandTerminal::setErrorMessage("Invalid name, expects (string:128)"); - return false; - } - - return true; } +#if MTS_CMD_TERM_VERBOSE CommandTerminal::setErrorMessage("Invalid arguments"); +#endif return false; }