[api] add API to get Thread Version (#4225)

This commit is contained in:
wgtdkp
2019-10-14 10:24:30 -07:00
committed by Jonathan Hui
parent ea0cc8f3bb
commit ff789e4ded
6 changed files with 47 additions and 18 deletions
+8
View File
@@ -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.
*
+10
View File
@@ -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.
+4
View File
@@ -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);
+5
View File
@@ -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<Instance *>(aInstance);
+2
View File
@@ -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"
+18 -18
View File
@@ -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 +