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
Committer:
jreiss
Date:
Thu Mar 16 13:23:56 2017 +0000
Revision:
28:3234d66ebb05
Parent:
26:15bf2e4ee3d0
remove weak attribute from printMessage

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jreiss 26:15bf2e4ee3d0 1 #ifndef MTSLOG_H
jreiss 26:15bf2e4ee3d0 2 #define MTSLOG_H
jreiss 26:15bf2e4ee3d0 3
jreiss 26:15bf2e4ee3d0 4 #include <string>
jreiss 26:15bf2e4ee3d0 5
jreiss 26:15bf2e4ee3d0 6 inline const char* className(const std::string& prettyFunction)
jreiss 26:15bf2e4ee3d0 7 {
jreiss 26:15bf2e4ee3d0 8 size_t colons = prettyFunction.find_last_of("::");
jreiss 26:15bf2e4ee3d0 9 if (colons == std::string::npos)
jreiss 26:15bf2e4ee3d0 10 return "";
jreiss 26:15bf2e4ee3d0 11 size_t begin = prettyFunction.substr(0,colons).rfind(" ") + 1;
jreiss 26:15bf2e4ee3d0 12 size_t end = colons - begin;
jreiss 26:15bf2e4ee3d0 13
jreiss 26:15bf2e4ee3d0 14 return prettyFunction.substr(begin,end).c_str();
jreiss 26:15bf2e4ee3d0 15 }
jreiss 26:15bf2e4ee3d0 16
jreiss 26:15bf2e4ee3d0 17 #define __CLASSNAME__ className(__PRETTY_FUNCTION__)
jreiss 26:15bf2e4ee3d0 18
jreiss 26:15bf2e4ee3d0 19
jreiss 26:15bf2e4ee3d0 20 #ifdef MTS_DEBUG
jreiss 26:15bf2e4ee3d0 21 #define logFatal(format, ...) \
jreiss 26:15bf2e4ee3d0 22 mts::MTSLog::printMessage(mts::MTSLog::FATAL_LEVEL, "%s:%s:%d| [%s] " format "\r\n", __CLASSNAME__, __func__, __LINE__, mts::MTSLog::FATAL_LABEL, ##__VA_ARGS__)
jreiss 26:15bf2e4ee3d0 23 #define logError(format, ...) \
jreiss 26:15bf2e4ee3d0 24 mts::MTSLog::printMessage(mts::MTSLog::ERROR_LEVEL, "%s:%s:%d| [%s] " format "\r\n", __CLASSNAME__, __func__, __LINE__, mts::MTSLog::ERROR_LABEL, ##__VA_ARGS__)
jreiss 26:15bf2e4ee3d0 25 #define logWarning(format, ...) \
jreiss 26:15bf2e4ee3d0 26 mts::MTSLog::printMessage(mts::MTSLog::WARNING_LEVEL, "%s:%s:%d| [%s] " format "\r\n", __CLASSNAME__, __func__, __LINE__, mts::MTSLog::WARNING_LABEL, ##__VA_ARGS__)
jreiss 26:15bf2e4ee3d0 27 #define logInfo(format, ...) \
jreiss 26:15bf2e4ee3d0 28 mts::MTSLog::printMessage(mts::MTSLog::INFO_LEVEL, "%s:%s:%d| [%s] " format "\r\n", __CLASSNAME__, __func__, __LINE__, mts::MTSLog::INFO_LABEL, ##__VA_ARGS__)
jreiss 26:15bf2e4ee3d0 29 #define logDebug(format, ...) \
jreiss 26:15bf2e4ee3d0 30 mts::MTSLog::printMessage(mts::MTSLog::DEBUG_LEVEL, "%s:%s:%d| [%s] " format "\r\n", __CLASSNAME__, __func__, __LINE__, mts::MTSLog::DEBUG_LABEL, ##__VA_ARGS__)
jreiss 26:15bf2e4ee3d0 31 #define logTrace(format, ...) \
jreiss 26:15bf2e4ee3d0 32 mts::MTSLog::printMessage(mts::MTSLog::TRACE_LEVEL, "%s:%s:%d| [%s] " format "\r\n", __CLASSNAME__, __func__, __LINE__, mts::MTSLog::TRACE_LABEL, ##__VA_ARGS__)
jreiss 26:15bf2e4ee3d0 33 #else
jreiss 26:15bf2e4ee3d0 34 #define logFatal(format, ...) \
jreiss 26:15bf2e4ee3d0 35 mts::MTSLog::printMessage(mts::MTSLog::FATAL_LEVEL, "[%s] " format "\r\n", mts::MTSLog::FATAL_LABEL, ##__VA_ARGS__)
jreiss 26:15bf2e4ee3d0 36 #define logError(format, ...) \
jreiss 26:15bf2e4ee3d0 37 mts::MTSLog::printMessage(mts::MTSLog::ERROR_LEVEL, "[%s] " format "\r\n", mts::MTSLog::ERROR_LABEL, ##__VA_ARGS__)
jreiss 26:15bf2e4ee3d0 38 #define logWarning(format, ...) \
jreiss 26:15bf2e4ee3d0 39 mts::MTSLog::printMessage(mts::MTSLog::WARNING_LEVEL, "[%s] " format "\r\n", mts::MTSLog::WARNING_LABEL, ##__VA_ARGS__)
jreiss 26:15bf2e4ee3d0 40 #define logInfo(format, ...) \
jreiss 26:15bf2e4ee3d0 41 mts::MTSLog::printMessage(mts::MTSLog::INFO_LEVEL, "[%s] " format "\r\n", mts::MTSLog::INFO_LABEL, ##__VA_ARGS__)
jreiss 26:15bf2e4ee3d0 42 #define logDebug(format, ...) \
jreiss 26:15bf2e4ee3d0 43 mts::MTSLog::printMessage(mts::MTSLog::DEBUG_LEVEL, "[%s] " format "\r\n", mts::MTSLog::DEBUG_LABEL, ##__VA_ARGS__)
jreiss 26:15bf2e4ee3d0 44 #define logTrace(format, ...) \
jreiss 26:15bf2e4ee3d0 45 mts::MTSLog::printMessage(mts::MTSLog::TRACE_LEVEL, "[%s] " format "\r\n", mts::MTSLog::TRACE_LABEL, ##__VA_ARGS__)
jreiss 26:15bf2e4ee3d0 46 #endif
jreiss 26:15bf2e4ee3d0 47
jreiss 26:15bf2e4ee3d0 48 namespace mts {
jreiss 26:15bf2e4ee3d0 49
jreiss 26:15bf2e4ee3d0 50 class MTSLog
jreiss 26:15bf2e4ee3d0 51 {
jreiss 26:15bf2e4ee3d0 52 public:
jreiss 26:15bf2e4ee3d0 53
jreiss 26:15bf2e4ee3d0 54 /** Enum of log levels.
jreiss 26:15bf2e4ee3d0 55 */
jreiss 26:15bf2e4ee3d0 56 enum logLevel {
jreiss 26:15bf2e4ee3d0 57 NONE_LEVEL = 0,
jreiss 26:15bf2e4ee3d0 58 FATAL_LEVEL = 1,
jreiss 26:15bf2e4ee3d0 59 ERROR_LEVEL = 2,
jreiss 26:15bf2e4ee3d0 60 WARNING_LEVEL = 3,
jreiss 26:15bf2e4ee3d0 61 INFO_LEVEL = 4,
jreiss 26:15bf2e4ee3d0 62 DEBUG_LEVEL = 5,
jreiss 26:15bf2e4ee3d0 63 TRACE_LEVEL = 6
jreiss 26:15bf2e4ee3d0 64 };
jreiss 26:15bf2e4ee3d0 65
jreiss 26:15bf2e4ee3d0 66 /** Print log message.
jreiss 26:15bf2e4ee3d0 67 */
jreiss 28:3234d66ebb05 68 static void printMessage(int level, const char* format, ...);
jreiss 26:15bf2e4ee3d0 69
jreiss 26:15bf2e4ee3d0 70 /** Determine if the given level is currently printable.
jreiss 26:15bf2e4ee3d0 71 */
jreiss 26:15bf2e4ee3d0 72 static bool printable(int level);
jreiss 26:15bf2e4ee3d0 73
jreiss 26:15bf2e4ee3d0 74 /** Set log level
jreiss 26:15bf2e4ee3d0 75 * Messages with lower priority than the current level will not be printed.
jreiss 26:15bf2e4ee3d0 76 * If the level is set to NONE, no messages will print.
jreiss 26:15bf2e4ee3d0 77 */
jreiss 26:15bf2e4ee3d0 78 static void setLogLevel(int level);
jreiss 26:15bf2e4ee3d0 79
jreiss 26:15bf2e4ee3d0 80 /** Get the current log level.
jreiss 26:15bf2e4ee3d0 81 */
jreiss 26:15bf2e4ee3d0 82 static int getLogLevel();
jreiss 26:15bf2e4ee3d0 83
jreiss 26:15bf2e4ee3d0 84 /** Get string representation of the current log level.
jreiss 26:15bf2e4ee3d0 85 */
jreiss 26:15bf2e4ee3d0 86 static const char* getLogLevelString();
jreiss 26:15bf2e4ee3d0 87
jreiss 26:15bf2e4ee3d0 88 static const char* NONE_LABEL;
jreiss 26:15bf2e4ee3d0 89 static const char* FATAL_LABEL;
jreiss 26:15bf2e4ee3d0 90 static const char* ERROR_LABEL;
jreiss 26:15bf2e4ee3d0 91 static const char* WARNING_LABEL;
jreiss 26:15bf2e4ee3d0 92 static const char* INFO_LABEL;
jreiss 26:15bf2e4ee3d0 93 static const char* DEBUG_LABEL;
jreiss 26:15bf2e4ee3d0 94 static const char* TRACE_LABEL;
jreiss 26:15bf2e4ee3d0 95
jreiss 26:15bf2e4ee3d0 96 private:
jreiss 26:15bf2e4ee3d0 97
jreiss 26:15bf2e4ee3d0 98 /** Constructor
jreiss 26:15bf2e4ee3d0 99 */
jreiss 26:15bf2e4ee3d0 100 MTSLog();
jreiss 26:15bf2e4ee3d0 101
jreiss 26:15bf2e4ee3d0 102 static int currentLevel;
jreiss 26:15bf2e4ee3d0 103
jreiss 26:15bf2e4ee3d0 104 };
jreiss 26:15bf2e4ee3d0 105
jreiss 26:15bf2e4ee3d0 106 }
jreiss 26:15bf2e4ee3d0 107
jreiss 26:15bf2e4ee3d0 108 #endif
jreiss 26:15bf2e4ee3d0 109