mirror of
https://github.com/espressif/openthread.git
synced 2026-08-18 16:39:52 +00:00
cli: pollperiod fix (#387)
This commit is contained in:
+4
-4
@@ -567,20 +567,20 @@ Send an ICMPv6 Echo Request.
|
||||
|
||||
### pollperiod
|
||||
|
||||
Get the data poll period of sleepy end device
|
||||
Get the customized data poll period of sleepy end device (seconds). Only for certification test
|
||||
|
||||
```bash
|
||||
> pollperiod
|
||||
240
|
||||
0
|
||||
Done
|
||||
```
|
||||
|
||||
### pollperiod \<pollperiod>\
|
||||
|
||||
Set the data poll period for sleepy end device
|
||||
Set the customized data poll period for sleepy end device (seconds). Only for certification test
|
||||
|
||||
```bash
|
||||
> pollperiod 240
|
||||
> pollperiod 10
|
||||
Done
|
||||
```
|
||||
|
||||
|
||||
+2
-2
@@ -1040,12 +1040,12 @@ void Interpreter::ProcessPollPeriod(int argc, char *argv[])
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
sServer->OutputFormat("%d\r\n", otGetPollPeriod());
|
||||
sServer->OutputFormat("%d\r\n", (otGetPollPeriod() / 1000)); // ms->s
|
||||
}
|
||||
else
|
||||
{
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
otSetPollPeriod(static_cast<uint32_t>(value));
|
||||
otSetPollPeriod(static_cast<uint32_t>(value * 1000)); // s->ms
|
||||
}
|
||||
|
||||
exit:
|
||||
|
||||
@@ -793,12 +793,12 @@ const char *otGetVersionString(void)
|
||||
|
||||
uint32_t otGetPollPeriod()
|
||||
{
|
||||
return sThreadNetif->GetMeshForwarder().GetPollPeriod();
|
||||
return sThreadNetif->GetMeshForwarder().GetAssignPollPeriod();
|
||||
}
|
||||
|
||||
void otSetPollPeriod(uint32_t aPollPeriod)
|
||||
{
|
||||
sThreadNetif->GetMeshForwarder().SetPollPeriod(aPollPeriod);
|
||||
sThreadNetif->GetMeshForwarder().SetAssignPollPeriod(aPollPeriod);
|
||||
}
|
||||
|
||||
ThreadError otEnable(void)
|
||||
|
||||
@@ -66,7 +66,7 @@ MeshForwarder::MeshForwarder(ThreadNetif &aThreadNetif):
|
||||
{
|
||||
mFragTag = static_cast<uint16_t>(otPlatRandomGet());
|
||||
mPollPeriod = 0;
|
||||
mPollPeriodAssigned = false;
|
||||
mAssignPollPeriod = 0;
|
||||
mSendMessage = NULL;
|
||||
mSendBusy = false;
|
||||
mEnabled = false;
|
||||
@@ -573,29 +573,29 @@ void MeshForwarder::SetRxOnWhenIdle(bool aRxOnWhenIdle)
|
||||
}
|
||||
}
|
||||
|
||||
void MeshForwarder::SetAssignPollPeriod(uint32_t aPeriod)
|
||||
{
|
||||
mAssignPollPeriod = aPeriod;
|
||||
}
|
||||
|
||||
uint32_t MeshForwarder::GetAssignPollPeriod()
|
||||
{
|
||||
return mAssignPollPeriod;
|
||||
}
|
||||
|
||||
void MeshForwarder::SetPollPeriod(uint32_t aPeriod)
|
||||
{
|
||||
if (!mNetif.IsUp())
|
||||
if (mPollPeriod != aPeriod)
|
||||
{
|
||||
mPollPeriodAssigned = true;
|
||||
mPollPeriod = aPeriod;
|
||||
ExitNow();
|
||||
if (mAssignPollPeriod != 0 && aPeriod != (OPENTHREAD_CONFIG_ATTACH_DATA_POLL_PERIOD))
|
||||
{
|
||||
mPollPeriod = mAssignPollPeriod;
|
||||
}
|
||||
else
|
||||
{
|
||||
mPollPeriod = aPeriod;
|
||||
}
|
||||
}
|
||||
|
||||
if (mPollPeriodAssigned && mMac.GetRxOnWhenIdle() == false)
|
||||
{
|
||||
mPollTimer.Start(mPollPeriod);
|
||||
ExitNow();
|
||||
}
|
||||
else if (mMac.GetRxOnWhenIdle() == false && mPollPeriod != aPeriod)
|
||||
{
|
||||
mPollTimer.Start(aPeriod);
|
||||
}
|
||||
|
||||
mPollPeriod = aPeriod;
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t MeshForwarder::GetPollPeriod()
|
||||
|
||||
@@ -132,6 +132,22 @@ public:
|
||||
*/
|
||||
void SetRxOnWhenIdle(bool aRxOnWhenIdle);
|
||||
|
||||
/**
|
||||
* This method sets customized Data Poll period. Only for certification test
|
||||
*
|
||||
* @param[in] aPeriod The Data Poll period in milliseconds.
|
||||
*
|
||||
*/
|
||||
void SetAssignPollPeriod(uint32_t aPeriod);
|
||||
|
||||
/**
|
||||
* This method gets the customized Data Poll period. Only for certification test
|
||||
*
|
||||
* @returns The Data Poll period in milliseconds.
|
||||
*
|
||||
*/
|
||||
uint32_t GetAssignPollPeriod(void);
|
||||
|
||||
/**
|
||||
* This method sets the Data Poll period.
|
||||
*
|
||||
@@ -217,7 +233,7 @@ private:
|
||||
uint16_t mFragTag;
|
||||
uint16_t mMessageNextOffset;
|
||||
uint32_t mPollPeriod;
|
||||
bool mPollPeriodAssigned;
|
||||
uint32_t mAssignPollPeriod; ///< only for certification test
|
||||
Message *mSendMessage;
|
||||
|
||||
Mac::Address mMacSource;
|
||||
|
||||
Reference in New Issue
Block a user