add IsSingleton to OT's application API (#398)

This commit is contained in:
Marcin K Szczodrak
2016-08-16 19:15:29 -07:00
committed by Jonathan Hui
parent 20ce66eb90
commit 8c48712617
5 changed files with 44 additions and 1 deletions
+9
View File
@@ -226,6 +226,15 @@ ThreadError otThreadStart(void);
*/
ThreadError otThreadStop(void);
/**
* This function indicates whether a node is the only router on the network.
*
* @retval TRUE It is the only router in the network.
* @retval FALSE It is a child or is not a single router in the network.
*
*/
bool otIsSingleton(void);
/**
* This function pointer is called during an IEEE 802.15.4 Active Scan when an IEEE 802.15.4 Beacon is received or
* the scan completes.
+20
View File
@@ -88,6 +88,7 @@ const struct Command Interpreter::sCommands[] =
{ "router", &ProcessRouter },
{ "routerupgradethreshold", &ProcessRouterUpgradeThreshold },
{ "scan", &ProcessScan },
{ "singleton", &ProcessSingleton },
{ "state", &ProcessState },
{ "thread", &ProcessThread },
{ "version", &ProcessVersion },
@@ -1542,6 +1543,25 @@ exit:
return;
}
void Interpreter::ProcessSingleton(int argc, char *argv[])
{
ThreadError error = kThreadError_None;
if (otIsSingleton())
{
sServer->OutputFormat("true\r\n");
}
else
{
sServer->OutputFormat("false\r\n");
}
(void)argc;
(void)argv;
AppendResult(error);
}
void Interpreter::ProcessState(int argc, char *argv[])
{
ThreadError error = kThreadError_None;
+1
View File
@@ -172,6 +172,7 @@ private:
static void ProcessRouterUpgradeThreshold(int argc, char *argv[]);
static void ProcessRloc16(int argc, char *argv[]);
static void ProcessScan(int argc, char *argv[]);
static void ProcessSingleton(int argc, char *argv[]);
static void ProcessState(int argc, char *argv[]);
static void ProcessThread(int argc, char *argv[]);
static void ProcessVersion(int argc, char *argv[]);
+5
View File
@@ -903,6 +903,11 @@ exit:
return error;
}
bool otIsSingleton(void)
{
return mEnabled && sThreadNetif->GetMle().IsSingleton();
}
ThreadError otActiveScan(uint32_t aScanChannels, uint16_t aScanDuration, otHandleActiveScanResult aCallback)
{
return sThreadNetif->GetMac().ActiveScan(aScanChannels, aScanDuration, &HandleActiveScanResult,
+9 -1
View File
@@ -97,6 +97,15 @@ public:
*/
void SetRouterRoleEnabled(bool aEnabled);
/**
* This method indicates whether a node is the only router on the network.
*
* @retval TRUE It is the only router in the network.
* @retval FALSE It is a child or is not a single router in the network.
*
*/
bool IsSingleton(void);
/**
* This method generates an Address Solicit request for a Router ID.
*
@@ -440,7 +449,6 @@ private:
ThreadError HandleChildUpdateRequest(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
ThreadError HandleDataRequest(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
ThreadError HandleNetworkDataUpdateRouter(void);
bool IsSingleton(void);
ThreadError ProcessRouteTlv(const RouteTlv &aRoute);
ThreadError ResetAdvertiseInterval(void);