diff --git a/include/openthread/thread.h b/include/openthread/thread.h index bd0a55abc..260343d5d 100644 --- a/include/openthread/thread.h +++ b/include/openthread/thread.h @@ -216,6 +216,14 @@ typedef struct otThreadParentResponseInfo */ otError otThreadSetEnabled(otInstance *aInstance, bool aEnabled); +/** + * This function gets the Thread protocol version. + * + * @returns the Thread protocol version. + * + */ +uint16_t otThreadGetVersion(void); + /** * This function indicates whether a node is the only router on the network. * diff --git a/src/cli/README.md b/src/cli/README.md index d34ae33fd..3da8e916e 100644 --- a/src/cli/README.md +++ b/src/cli/README.md @@ -1314,6 +1314,16 @@ Disable Thread protocol operation and detach from a Thread network. Done ``` +### thread version + +Get the Thread Version number. + +```bash +> thread version +2 +Done +``` + ### txpower Get the transmit power in dBm. diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index a8643b0cf..f49ea19a3 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -3077,6 +3077,10 @@ void Interpreter::ProcessThread(int argc, char *argv[]) { SuccessOrExit(error = otThreadSetEnabled(mInstance, false)); } + else if (strcmp(argv[0], "version") == 0) + { + mServer->OutputFormat("%u\r\n", otThreadGetVersion()); + } else { ExitNow(error = OT_ERROR_INVALID_ARGS); diff --git a/src/core/api/thread_api.cpp b/src/core/api/thread_api.cpp index 65c3246d7..f9b90074f 100644 --- a/src/core/api/thread_api.cpp +++ b/src/core/api/thread_api.cpp @@ -414,6 +414,11 @@ otError otThreadSetEnabled(otInstance *aInstance, bool aEnabled) return error; } +uint16_t otThreadGetVersion(void) +{ + return OPENTHREAD_THREAD_VERSION; +} + bool otThreadIsSingleton(otInstance *aInstance) { Instance &instance = *static_cast(aInstance); diff --git a/src/core/openthread-core-config.h b/src/core/openthread-core-config.h index e670a79e8..80a46fd03 100644 --- a/src/core/openthread-core-config.h +++ b/src/core/openthread-core-config.h @@ -42,6 +42,8 @@ #include OPENTHREAD_PROJECT_CORE_CONFIG_FILE #endif +#define OPENTHREAD_THREAD_VERSION (2) + #include "config/openthread-core-default-config.h" #include "config/announce_sender.h" diff --git a/src/core/thread/mle_constants.hpp b/src/core/thread/mle_constants.hpp index 2c2c71c35..50a389cf5 100644 --- a/src/core/thread/mle_constants.hpp +++ b/src/core/thread/mle_constants.hpp @@ -57,24 +57,24 @@ enum */ enum { - kThreadVersion = 2, ///< Thread Version - kUdpPort = 19788, ///< MLE UDP Port - kParentRequestRouterTimeout = 750, ///< Router Parent Request timeout - kParentRequestDuplicateMargin = 50, ///< Margin for duplicate parent request - kParentRequestReedTimeout = 1250, ///< Router and REEDs Parent Request timeout - kAttachStartJitter = 50, ///< Maximum jitter time added to start of attach. - kAnnounceProcessTimeout = 250, ///< Timeout after receiving Announcement before channel/pan-id change - kAnnounceTimeout = 1400, ///< Total timeout used for sending Announcement messages - kMinAnnounceDelay = 80, ///< Minimum delay between Announcement messages - kParentResponseMaxDelayRouters = 500, ///< Maximum delay for response for Parent Request sent to routers only - kParentResponseMaxDelayAll = 1000, ///< Maximum delay for response for Parent Request sent to all devices - kUnicastRetransmissionDelay = 1000, ///< Base delay before retransmitting an MLE unicast. - kChildUpdateRequestPendingDelay = 100, ///< Delay (in ms) for aggregating Child Update Request. - kMaxTransmissionCount = 3, ///< Maximum number of times an MLE message may be transmitted. - kMaxResponseDelay = 1000, ///< Maximum delay before responding to a multicast request - kMaxChildIdRequestTimeout = 5000, ///< Maximum delay for receiving a Child ID Request - kMaxChildUpdateResponseTimeout = 2000, ///< Maximum delay for receiving a Child Update Response - kMaxLinkRequestTimeout = 2000, ///< Maximum delay for receiving a Link Accept + kThreadVersion = OPENTHREAD_THREAD_VERSION, ///< Thread Version + kUdpPort = 19788, ///< MLE UDP Port + kParentRequestRouterTimeout = 750, ///< Router Parent Request timeout + kParentRequestDuplicateMargin = 50, ///< Margin for duplicate parent request + kParentRequestReedTimeout = 1250, ///< Router and REEDs Parent Request timeout + kAttachStartJitter = 50, ///< Maximum jitter time added to start of attach. + kAnnounceProcessTimeout = 250, ///< Timeout after receiving Announcement before channel/pan-id change + kAnnounceTimeout = 1400, ///< Total timeout used for sending Announcement messages + kMinAnnounceDelay = 80, ///< Minimum delay between Announcement messages + kParentResponseMaxDelayRouters = 500, ///< Maximum delay for response for Parent Request sent to routers only + kParentResponseMaxDelayAll = 1000, ///< Maximum delay for response for Parent Request sent to all devices + kUnicastRetransmissionDelay = 1000, ///< Base delay before retransmitting an MLE unicast. + kChildUpdateRequestPendingDelay = 100, ///< Delay (in ms) for aggregating Child Update Request. + kMaxTransmissionCount = 3, ///< Maximum number of times an MLE message may be transmitted. + kMaxResponseDelay = 1000, ///< Maximum delay before responding to a multicast request + kMaxChildIdRequestTimeout = 5000, ///< Maximum delay for receiving a Child ID Request + kMaxChildUpdateResponseTimeout = 2000, ///< Maximum delay for receiving a Child Update Response + kMaxLinkRequestTimeout = 2000, ///< Maximum delay for receiving a Link Accept kMinTimeoutKeepAlive = (((kMaxChildKeepAliveAttempts + 1) * kUnicastRetransmissionDelay) / 1000), ///< Minimum timeout(s) for keep alive kMinTimeoutDataPoll = (OPENTHREAD_CONFIG_MAC_MINIMUM_POLL_PERIOD +