MultiTech / libxDot-Custom

Fork of libxDot-dev-mbed5-deprecated by MultiTech

The Connect example can be used as a starting point for an xDot application.

Import programmDot_LoRa_Connect_Example_CUSTOM_AS923

Example configuration of frequencies and datarates for AS923 channel plan.

Change the libmDot-Custom library to libxDot-Custom after importing the above example.

Change the platform for the project to xDot in upper right corner of the compiler page.

Ensure the mbed-os version matches the with the library commit.

Currently the AT Firmware cannot be built online for the xDot.

Creating new channel plans

Copy EU868 or US915 custom channel plan as a starting point

Import librarymDot_Channel_Plans

Channel plans to enable libmDot-Custom

EU868 provides a framework for a DYNAMIC channel plan with duty-cycle limitations

US915 provides a framework for a FIXED channel plan

RADIO_POWERS are measured output in dBm for each radio tx power setting.

Additional MAC Commands can be implemented by overriding the HandleMacCommand function.

Steps

  1. Setup datarates, duty-cycle bands and channels in ChannelPlan_* constructor
  2. Modify GetJoinDatarate and CalculateJoinBackoff to change join datarates and backoff
  3. Customize HandleJoinAccept datarates
  4. Use GetRxWindow(int) to define how the device open Rx window 1 and 2
  5. GetNextChannel will pick a channel from the enabled channel at the current datarate before each TX
Revision:
26:15bf2e4ee3d0
Child:
28:3234d66ebb05
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MTS-Utils/MTSLog.h	Wed Jan 18 16:14:14 2017 +0000
@@ -0,0 +1,109 @@
+#ifndef MTSLOG_H
+#define MTSLOG_H
+
+#include <string>
+
+inline const char* className(const std::string& prettyFunction)
+{
+    size_t colons = prettyFunction.find_last_of("::");
+    if (colons == std::string::npos)
+        return "";
+    size_t begin = prettyFunction.substr(0,colons).rfind(" ") + 1;
+    size_t end = colons - begin;
+
+    return prettyFunction.substr(begin,end).c_str();
+}
+
+#define __CLASSNAME__ className(__PRETTY_FUNCTION__)
+
+
+#ifdef MTS_DEBUG
+#define logFatal(format, ...) \
+    mts::MTSLog::printMessage(mts::MTSLog::FATAL_LEVEL, "%s:%s:%d| [%s] " format "\r\n", __CLASSNAME__, __func__, __LINE__, mts::MTSLog::FATAL_LABEL, ##__VA_ARGS__)
+#define logError(format, ...) \
+    mts::MTSLog::printMessage(mts::MTSLog::ERROR_LEVEL, "%s:%s:%d| [%s] " format "\r\n", __CLASSNAME__, __func__, __LINE__, mts::MTSLog::ERROR_LABEL, ##__VA_ARGS__)
+#define logWarning(format, ...) \
+    mts::MTSLog::printMessage(mts::MTSLog::WARNING_LEVEL, "%s:%s:%d| [%s] " format "\r\n", __CLASSNAME__, __func__, __LINE__, mts::MTSLog::WARNING_LABEL, ##__VA_ARGS__)
+#define logInfo(format, ...) \
+    mts::MTSLog::printMessage(mts::MTSLog::INFO_LEVEL, "%s:%s:%d| [%s] " format "\r\n", __CLASSNAME__, __func__, __LINE__, mts::MTSLog::INFO_LABEL, ##__VA_ARGS__)
+#define logDebug(format, ...) \
+    mts::MTSLog::printMessage(mts::MTSLog::DEBUG_LEVEL, "%s:%s:%d| [%s] " format "\r\n", __CLASSNAME__, __func__, __LINE__, mts::MTSLog::DEBUG_LABEL, ##__VA_ARGS__)
+#define logTrace(format, ...) \
+    mts::MTSLog::printMessage(mts::MTSLog::TRACE_LEVEL, "%s:%s:%d| [%s] " format "\r\n", __CLASSNAME__, __func__, __LINE__, mts::MTSLog::TRACE_LABEL, ##__VA_ARGS__)
+#else
+#define logFatal(format, ...) \
+    mts::MTSLog::printMessage(mts::MTSLog::FATAL_LEVEL, "[%s] " format "\r\n", mts::MTSLog::FATAL_LABEL, ##__VA_ARGS__)
+#define logError(format, ...) \
+    mts::MTSLog::printMessage(mts::MTSLog::ERROR_LEVEL, "[%s] " format "\r\n", mts::MTSLog::ERROR_LABEL, ##__VA_ARGS__)
+#define logWarning(format, ...) \
+    mts::MTSLog::printMessage(mts::MTSLog::WARNING_LEVEL, "[%s] " format "\r\n", mts::MTSLog::WARNING_LABEL, ##__VA_ARGS__)
+#define logInfo(format, ...) \
+    mts::MTSLog::printMessage(mts::MTSLog::INFO_LEVEL, "[%s] " format "\r\n", mts::MTSLog::INFO_LABEL, ##__VA_ARGS__)
+#define logDebug(format, ...) \
+    mts::MTSLog::printMessage(mts::MTSLog::DEBUG_LEVEL, "[%s] " format "\r\n", mts::MTSLog::DEBUG_LABEL, ##__VA_ARGS__)
+#define logTrace(format, ...) \
+    mts::MTSLog::printMessage(mts::MTSLog::TRACE_LEVEL, "[%s] " format "\r\n", mts::MTSLog::TRACE_LABEL, ##__VA_ARGS__)
+#endif
+
+namespace mts {
+
+class MTSLog
+{
+public:
+
+    /** Enum of log levels.
+     */
+    enum logLevel {
+        NONE_LEVEL = 0,
+        FATAL_LEVEL = 1,
+        ERROR_LEVEL = 2,
+        WARNING_LEVEL = 3,
+        INFO_LEVEL = 4,
+        DEBUG_LEVEL = 5,
+        TRACE_LEVEL = 6
+    };
+
+    /** Print log message.
+     */
+    static void __attribute__((weak)) printMessage(int level, const char* format, ...);
+
+    /** Determine if the given level is currently printable.
+     */
+    static bool printable(int level);
+
+    /** Set log level
+     * Messages with lower priority than the current level will not be printed.
+     * If the level is set to NONE, no messages will print.
+     */
+    static void setLogLevel(int level);
+
+    /** Get the current log level.
+     */
+    static int getLogLevel();
+
+    /** Get string representation of the current log level.
+     */
+    static const char* getLogLevelString();
+
+    static const char* NONE_LABEL;
+    static const char* FATAL_LABEL;
+    static const char* ERROR_LABEL;
+    static const char* WARNING_LABEL;
+    static const char* INFO_LABEL;
+    static const char* DEBUG_LABEL;
+    static const char* TRACE_LABEL;
+
+private:
+
+    /** Constructor
+     */
+    MTSLog();
+
+    static int currentLevel;
+
+};
+
+}
+
+#endif
+