mirror of
https://github.com/espressif/openthread.git
synced 2026-07-30 07:37:46 +00:00
THCI: setMinDelayTimer() API (#1329)
This commit is contained in:
+24
-2
@@ -458,13 +458,35 @@ OTAPI uint8_t OTCALL otGetChannel(otInstance *aInstance);
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aChannel The IEEE 802.15.4 channel.
|
||||
*
|
||||
* @retval kThreadErrorNone Successfully set the channel.
|
||||
* @retval kThreadErrorInvalidArgs If @p aChnanel is not in the range [11, 26].
|
||||
* @retval kThreadError_None Successfully set the channel.
|
||||
* @retval kThreadError_InvalidArgs If @p aChannel is not in the range [11, 26].
|
||||
*
|
||||
* @sa otGetChannel
|
||||
*/
|
||||
OTAPI ThreadError OTCALL otSetChannel(otInstance *aInstance, uint8_t aChannel);
|
||||
|
||||
/**
|
||||
* Set minimal delay timer.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDelayTimerMinimal The value of minimal delay timer (in ms).
|
||||
*
|
||||
* @retval kThreadError_None Successfully set minimal delay timer.
|
||||
* @retval kThreadError_InvalidArgs If @p aDelayTimerMinimal is not valid.
|
||||
*
|
||||
*/
|
||||
OTAPI ThreadError OTCALL otSetDelayTimerMinimal(otInstance *aInstance, uint32_t aDelayTimerMinimal);
|
||||
|
||||
/**
|
||||
* Get minimal delay timer.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval the value of minimal delay timer (in ms).
|
||||
*
|
||||
*/
|
||||
OTAPI uint32_t OTCALL otGetDelayTimerMinimal(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the maximum number of children currently allowed.
|
||||
*
|
||||
|
||||
@@ -16,6 +16,7 @@ OpenThread test scripts use the CLI to execute test cases.
|
||||
* [contextreusedelay](#contextreusedelay)
|
||||
* [counter](#counter)
|
||||
* [dataset](#dataset)
|
||||
* [delaytimermin](#delaytimermin)
|
||||
* [discover](#discover)
|
||||
* [eidcache](#eidcache)
|
||||
* [eui64](#eui64)
|
||||
@@ -117,6 +118,7 @@ Remove an IEEE 802.15.4 Extended Address from the blacklist.
|
||||
> blacklist remove 166e0a0000000002
|
||||
Done
|
||||
```
|
||||
|
||||
### channel
|
||||
|
||||
Get the IEEE 802.15.4 Channel value.
|
||||
@@ -664,6 +666,25 @@ Set user specific data for the command.
|
||||
Done
|
||||
```
|
||||
|
||||
### delaytimermin
|
||||
|
||||
Get the minimal delay timer (in seconds).
|
||||
|
||||
```bash
|
||||
> delaytimermin
|
||||
30
|
||||
Done
|
||||
```
|
||||
|
||||
### delaytimermin \<delaytimermin\>
|
||||
|
||||
Set the minimal delay timer (in seconds).
|
||||
|
||||
```bash
|
||||
> delaytimermin 60
|
||||
Done
|
||||
```
|
||||
|
||||
### discover \[channel\]
|
||||
|
||||
Perform an MLE Discovery operation.
|
||||
|
||||
@@ -79,6 +79,7 @@ const struct Command Interpreter::sCommands[] =
|
||||
{ "contextreusedelay", &Interpreter::ProcessContextIdReuseDelay },
|
||||
{ "counter", &Interpreter::ProcessCounters },
|
||||
{ "dataset", &Interpreter::ProcessDataset },
|
||||
{ "delaytimermin", &Interpreter::ProcessDelayTimerMin},
|
||||
#if OPENTHREAD_ENABLE_DIAG
|
||||
{ "diag", &Interpreter::ProcessDiag },
|
||||
#endif
|
||||
@@ -568,6 +569,29 @@ void Interpreter::ProcessDataset(int argc, char *argv[])
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessDelayTimerMin(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
sServer->OutputFormat("%d\r\n", (otGetDelayTimerMinimal(mInstance) / 1000));
|
||||
}
|
||||
else if (argc == 1)
|
||||
{
|
||||
unsigned long value;
|
||||
SuccessOrExit(error = ParseUnsignedLong(argv[0], value));
|
||||
SuccessOrExit(error = otSetDelayTimerMinimal(mInstance, static_cast<uint32_t>(value * 1000)));
|
||||
}
|
||||
else
|
||||
{
|
||||
error = kThreadError_InvalidArgs;
|
||||
}
|
||||
|
||||
exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessDiscover(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
@@ -153,6 +153,7 @@ private:
|
||||
void ProcessContextIdReuseDelay(int argc, char *argv[]);
|
||||
void ProcessCounters(int argc, char *argv[]);
|
||||
void ProcessDataset(int argc, char *argv[]);
|
||||
void ProcessDelayTimerMin(int argc, char *argv[]);
|
||||
#if OPENTHREAD_ENABLE_DIAG
|
||||
void ProcessDiag(int argc, char *argv[]);
|
||||
#endif // OPENTHREAD_ENABLE_DIAG
|
||||
|
||||
@@ -506,9 +506,9 @@ ThreadError DatasetManager::Set(Coap::Header &aHeader, Message &aMessage, const
|
||||
{
|
||||
delayTimerTlv->SetDelayTimer(DelayTimerTlv::kDelayTimerDefault);
|
||||
}
|
||||
else if (delayTimerTlv->GetDelayTimer() < DelayTimerTlv::kDelayTimerMinimal)
|
||||
else if (delayTimerTlv->GetDelayTimer() < mNetif.GetLeader().GetDelayTimerMinimal())
|
||||
{
|
||||
delayTimerTlv->SetDelayTimer(DelayTimerTlv::kDelayTimerMinimal);
|
||||
delayTimerTlv->SetDelayTimer(mNetif.GetLeader().GetDelayTimerMinimal());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1118,7 +1118,7 @@ void PendingDatasetBase::ApplyActiveDataset(const Timestamp &aTimestamp, Message
|
||||
|
||||
// add delay timer tlv
|
||||
delayTimer.Init();
|
||||
delayTimer.SetDelayTimer(DelayTimerTlv::kDelayTimerMinimal);
|
||||
delayTimer.SetDelayTimer(mNetif.GetLeader().GetDelayTimerMinimal());
|
||||
mNetwork.Set(delayTimer);
|
||||
|
||||
// add pending timestamp tlv
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <common/code_utils.hpp>
|
||||
#include <common/logging.hpp>
|
||||
#include <meshcop/leader.hpp>
|
||||
#include <meshcop/tlvs.hpp>
|
||||
#include <platform/random.h>
|
||||
#include <thread/thread_netif.hpp>
|
||||
#include <thread/thread_tlvs.hpp>
|
||||
@@ -51,6 +52,7 @@ Leader::Leader(ThreadNetif &aThreadNetif):
|
||||
mPetition(OPENTHREAD_URI_LEADER_PETITION, Leader::HandlePetition, this),
|
||||
mKeepAlive(OPENTHREAD_URI_LEADER_KEEP_ALIVE, Leader::HandleKeepAlive, this),
|
||||
mTimer(aThreadNetif.GetIp6().mTimerScheduler, HandleTimer, this),
|
||||
mDelayTimerMinimal(DelayTimerTlv::kDelayTimerMinimal),
|
||||
mSessionId(0xffff),
|
||||
mNetif(aThreadNetif)
|
||||
{
|
||||
@@ -254,6 +256,22 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
ThreadError Leader::SetDelayTimerMinimal(uint32_t aDelayTimerMinimal)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
VerifyOrExit((aDelayTimerMinimal != 0 && aDelayTimerMinimal < DelayTimerTlv::kDelayTimerDefault),
|
||||
error = kThreadError_InvalidArgs);
|
||||
mDelayTimerMinimal = aDelayTimerMinimal;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
uint32_t Leader::GetDelayTimerMinimal(void) const
|
||||
{
|
||||
return mDelayTimerMinimal;
|
||||
}
|
||||
|
||||
void Leader::HandleTimer(void *aContext)
|
||||
{
|
||||
static_cast<Leader *>(aContext)->HandleTimer();
|
||||
|
||||
@@ -81,6 +81,25 @@ public:
|
||||
*/
|
||||
ThreadError SendDatasetChanged(const Ip6::Address &aAddress);
|
||||
|
||||
/**
|
||||
* This method sets minimal delay timer.
|
||||
*
|
||||
* @param[in] aDelayTimerMinimal The value of minimal delay timer (in ms).
|
||||
*
|
||||
* @retval kThreadError_None Successfully set the minimal delay timer.
|
||||
* @retval kThreadError_InvalidArgs If @p aDelayTimerMinimal is not valid.
|
||||
*
|
||||
*/
|
||||
ThreadError SetDelayTimerMinimal(uint32_t aDelayTimerMinimal);
|
||||
|
||||
/**
|
||||
* This method gets minimal delay timer.
|
||||
*
|
||||
* @retval the miniaml delay timer (in ms).
|
||||
*
|
||||
*/
|
||||
uint32_t GetDelayTimerMinimal(void) const;
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
@@ -110,6 +129,8 @@ private:
|
||||
Coap::Resource mKeepAlive;
|
||||
Timer mTimer;
|
||||
|
||||
uint32_t mDelayTimerMinimal;
|
||||
|
||||
CommissionerIdTlv mCommissionerId;
|
||||
uint16_t mSessionId;
|
||||
ThreadNetif &mNetif;
|
||||
|
||||
@@ -44,6 +44,8 @@ class Leader
|
||||
public:
|
||||
Leader(ThreadNetif &) { }
|
||||
ThreadError SendDatasetChanged(const Ip6::Address &) { return kThreadError_NotImplemented; }
|
||||
ThreadError SetDelayTimerMinimal(uint32_t) { return kThreadError_NotImplemented; }
|
||||
uint32_t GetDelayTimerMinimal(void) { return 0; }
|
||||
};
|
||||
|
||||
} // namespace MeshCoP
|
||||
|
||||
@@ -120,6 +120,16 @@ ThreadError otSetChannel(otInstance *aInstance, uint8_t aChannel)
|
||||
return aInstance->mThreadNetif.GetMac().SetChannel(aChannel);
|
||||
}
|
||||
|
||||
ThreadError otSetDelayTimerMinimal(otInstance *aInstance, uint32_t aDelayTimerMinimal)
|
||||
{
|
||||
return aInstance->mThreadNetif.GetLeader().SetDelayTimerMinimal(aDelayTimerMinimal);
|
||||
}
|
||||
|
||||
uint32_t otGetDelayTimerMinimal(otInstance *aInstance)
|
||||
{
|
||||
return aInstance->mThreadNetif.GetLeader().GetDelayTimerMinimal();
|
||||
}
|
||||
|
||||
uint8_t otGetMaxAllowedChildren(otInstance *aInstance)
|
||||
{
|
||||
uint8_t aNumChildren;
|
||||
|
||||
@@ -2534,3 +2534,6 @@ class OpenThread(IThci):
|
||||
|
||||
def setMinDelayTimer(self, iSeconds):
|
||||
print '%s call setMinDelayTimer' % self.port
|
||||
cmd = 'delaytimermin %s' % iSeconds
|
||||
print cmd
|
||||
return self.__sendCommand(cmd)[0] == 'Done'
|
||||
|
||||
Reference in New Issue
Block a user