mirror of
https://github.com/espressif/openthread.git
synced 2026-07-28 22:57:47 +00:00
[timer] multiple microseconds timer support (#1962)
* [timer] multiple microseconds timer support * Remove TimerSchedulerLocator, Timer inherit from Ip6Locator instead to get TimerScheduler. * Add separate UsecTimer and UsecTimerScheduler for multiple microseconds timer support. * [timer] refine Timer names * Rename alarm header files to alarm-milli.h and alarm-micro.h * Rename alarm APIs to start with otPlatAlarmMilli and otPlatAlarmMicro * Rename Timer classes to TimerMilli/TimerMilliScheduler and TimerMicro/TimerMicroScheduler * [Timer] Refactor Timer code structure * Create TimerBase and TimerSchedulerBase class for common functions; * Use TimerMilli/TimerMicro and TimerMilliScheduler/TimerMicroScheduler for different functions; * Define AlarmApi, so then TimerMilliScheduler/TimerMicroScheduler could use different AlarmApi.
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
#include "alarm.tmh"
|
||||
|
||||
uint32_t
|
||||
otPlatAlarmGetNow()
|
||||
otPlatAlarmMilliGetNow()
|
||||
{
|
||||
// Return number of 'ticks'
|
||||
LARGE_INTEGER PerformanceCounter = KeQueryPerformanceCounter(NULL);
|
||||
@@ -46,22 +46,22 @@ otPlatAlarmGetNow()
|
||||
}
|
||||
|
||||
void
|
||||
otPlatAlarmStop(
|
||||
otPlatAlarmMilliStop(
|
||||
_In_ otInstance *otCtx
|
||||
)
|
||||
{
|
||||
LogVerbose(DRIVER_DEFAULT, "otPlatAlarmStop");
|
||||
LogVerbose(DRIVER_DEFAULT, "otPlatAlarmMilliStop");
|
||||
otLwfEventProcessingIndicateNewWaitTime(otCtxToFilter(otCtx), (ULONG)(-1));
|
||||
}
|
||||
|
||||
void
|
||||
otPlatAlarmStartAt(
|
||||
otPlatAlarmMilliStartAt(
|
||||
_In_ otInstance *otCtx,
|
||||
uint32_t now,
|
||||
uint32_t waitTime
|
||||
)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(now);
|
||||
LogVerbose(DRIVER_DEFAULT, "otPlatAlarmStartAt %u ms", waitTime);
|
||||
LogVerbose(DRIVER_DEFAULT, "otPlatAlarmMilliStartAt %u ms", waitTime);
|
||||
otLwfEventProcessingIndicateNewWaitTime(otCtxToFilter(otCtx), waitTime);
|
||||
}
|
||||
|
||||
@@ -863,7 +863,7 @@ otLwfEventWorkerThread(
|
||||
pFilter->EventTimerState = OT_EVENT_TIMER_NOT_RUNNING;
|
||||
|
||||
// Indicate to OpenThread that the alarm has fired
|
||||
otPlatAlarmFired(pFilter->otCtx);
|
||||
otPlatAlarmMilliFired(pFilter->otCtx);
|
||||
}
|
||||
else if (status == STATUS_WAIT_0 + 1) // EventWorkerThreadProcessNBLs fired
|
||||
{
|
||||
|
||||
@@ -77,7 +77,7 @@ RtlCopyBufferToMdl(
|
||||
#include <openthread/platform/logging-windows.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
#include <openthread/platform/misc.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/settings.h>
|
||||
#include <openthread/platform/messagepool.h>
|
||||
#include <ncp/spinel.h>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/openthread.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
#include <openthread/platform/platform.h>
|
||||
|
||||
@@ -60,12 +60,12 @@ void cc2538AlarmInit(void)
|
||||
HWREG(NVIC_ST_CTRL) = NVIC_ST_CTRL_CLK_SRC | NVIC_ST_CTRL_INTEN | NVIC_ST_CTRL_ENABLE;
|
||||
}
|
||||
|
||||
uint32_t otPlatAlarmGetNow(void)
|
||||
uint32_t otPlatAlarmMilliGetNow(void)
|
||||
{
|
||||
return sCounter;
|
||||
}
|
||||
|
||||
void otPlatAlarmStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
{
|
||||
(void)aInstance;
|
||||
sAlarmT0 = t0;
|
||||
@@ -73,7 +73,7 @@ void otPlatAlarmStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
sIsRunning = true;
|
||||
}
|
||||
|
||||
void otPlatAlarmStop(otInstance *aInstance)
|
||||
void otPlatAlarmMilliStop(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
sIsRunning = false;
|
||||
@@ -116,7 +116,7 @@ void cc2538AlarmProcess(otInstance *aInstance)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
otPlatAlarmFired(aInstance);
|
||||
otPlatAlarmMilliFired(aInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/openthread.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#include "platform-cc2538.h"
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
|
||||
#include "platform-cc2538.h"
|
||||
#include "rom-utility.h"
|
||||
@@ -102,10 +102,10 @@ exit:
|
||||
otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint32_t start = otPlatAlarmGetNow();
|
||||
uint32_t start = otPlatAlarmMilliGetNow();
|
||||
uint32_t busy = 1;
|
||||
|
||||
while (busy && ((otPlatAlarmGetNow() - start) < aTimeout))
|
||||
while (busy && ((otPlatAlarmMilliGetNow() - start) < aTimeout))
|
||||
{
|
||||
busy = HWREG(FLASH_CTRL_FCTL) & FLASH_CTRL_FCTL_BUSY;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <openthread/types.h>
|
||||
#include <driverlib/aon_rtc.h>
|
||||
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
|
||||
/**
|
||||
@@ -56,9 +56,9 @@ void cc2650AlarmInit(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* Function documented in platform/alarm.h
|
||||
* Function documented in platform/alarm-milli.h
|
||||
*/
|
||||
uint32_t otPlatAlarmGetNow(void)
|
||||
uint32_t otPlatAlarmMilliGetNow(void)
|
||||
{
|
||||
/*
|
||||
* This is current value of RTC as it appears in the register.
|
||||
@@ -70,9 +70,9 @@ uint32_t otPlatAlarmGetNow(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* Function documented in platform/alarm.h
|
||||
* Function documented in platform/alarm-milli.h
|
||||
*/
|
||||
void otPlatAlarmStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
|
||||
{
|
||||
(void)aInstance;
|
||||
sTime0 = aT0;
|
||||
@@ -81,9 +81,9 @@ void otPlatAlarmStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
|
||||
}
|
||||
|
||||
/**
|
||||
* Function documented in platform/alarm.h
|
||||
* Function documented in platform/alarm-milli.h
|
||||
*/
|
||||
void otPlatAlarmStop(otInstance *aInstance)
|
||||
void otPlatAlarmMilliStop(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
sIsRunning = false;
|
||||
@@ -99,7 +99,7 @@ void cc2650AlarmProcess(otInstance *aInstance)
|
||||
if (sIsRunning)
|
||||
{
|
||||
/* unsinged subtraction will result in the absolute offset */
|
||||
offsetTime = otPlatAlarmGetNow() - sTime0;
|
||||
offsetTime = otPlatAlarmMilliGetNow() - sTime0;
|
||||
|
||||
if (sAlarmTime <= offsetTime)
|
||||
{
|
||||
@@ -113,7 +113,7 @@ void cc2650AlarmProcess(otInstance *aInstance)
|
||||
else
|
||||
#endif /* OPENTHREAD_ENABLE_DIAG */
|
||||
{
|
||||
otPlatAlarmFired(aInstance);
|
||||
otPlatAlarmMilliFired(aInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
|
||||
#include "hw_timer0.h"
|
||||
#include "hw_gpio.h"
|
||||
@@ -57,7 +57,7 @@ void da15000AlarmProcess(otInstance *aInstance)
|
||||
if ((sIsRunning) && (sAlarm <= sCounter))
|
||||
{
|
||||
sIsRunning = false;
|
||||
otPlatAlarmFired(aInstance);
|
||||
otPlatAlarmMilliFired(aInstance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,12 +72,12 @@ void da15000AlarmInit(void)
|
||||
hw_timer0_set_on_clock_div(false);
|
||||
}
|
||||
|
||||
uint32_t otPlatAlarmGetNow(void)
|
||||
uint32_t otPlatAlarmMilliGetNow(void)
|
||||
{
|
||||
return sCounter;
|
||||
}
|
||||
|
||||
void otPlatAlarmStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
{
|
||||
(void)aInstance;
|
||||
sAlarm = t0 + dt;
|
||||
@@ -97,7 +97,7 @@ void otPlatAlarmStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
hw_timer0_unfreeze();
|
||||
}
|
||||
|
||||
void otPlatAlarmStop(otInstance *aInstance)
|
||||
void otPlatAlarmMilliStop(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
sIsRunning = false;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
|
||||
#include "hw_qspi.h"
|
||||
#include "qspi_automode.h"
|
||||
@@ -81,9 +81,9 @@ uint32_t utilsFlashGetSize(void)
|
||||
otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
{
|
||||
|
||||
sWaitStatusTimeout = otPlatAlarmGetNow();
|
||||
sWaitStatusTimeout = otPlatAlarmMilliGetNow();
|
||||
|
||||
while (qspi_get_erase_status() && ((otPlatAlarmGetNow() - sWaitStatusTimeout) < aTimeout));
|
||||
while (qspi_get_erase_status() && ((otPlatAlarmMilliGetNow() - sWaitStatusTimeout) < aTimeout));
|
||||
|
||||
if (qspi_get_erase_status())
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/openthread.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/uart.h>
|
||||
|
||||
#include "platform-da15000.h"
|
||||
@@ -107,13 +107,13 @@ void ExampleProcess(otInstance *aInstance)
|
||||
|
||||
devRole = otThreadGetDeviceRole(aInstance);
|
||||
|
||||
if (sBlink == false && otPlatAlarmGetNow() != 0)
|
||||
if (sBlink == false && otPlatAlarmMilliGetNow() != 0)
|
||||
{
|
||||
sMsCounterInit = otPlatAlarmGetNow();
|
||||
sMsCounterInit = otPlatAlarmMilliGetNow();
|
||||
sBlink = true;
|
||||
}
|
||||
|
||||
sMsCounter = otPlatAlarmGetNow() - sMsCounterInit;
|
||||
sMsCounter = otPlatAlarmMilliGetNow() - sMsCounterInit;
|
||||
|
||||
switch (devRole)
|
||||
{
|
||||
@@ -136,7 +136,7 @@ void ExampleProcess(otInstance *aInstance)
|
||||
if ((thrValue != 0x00) && (sMsCounter >= thrValue))
|
||||
{
|
||||
hw_gpio_toggle(HW_GPIO_PORT_1, HW_GPIO_PIN_5);
|
||||
sMsCounterInit = otPlatAlarmGetNow();
|
||||
sMsCounterInit = otPlatAlarmMilliGetNow();
|
||||
}
|
||||
|
||||
if (thrValue == 0)
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#include <openthread/openthread.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
#include "utils/code_utils.h"
|
||||
|
||||
@@ -222,10 +222,10 @@ otError otPlatRadioSleep(otInstance *aInstance)
|
||||
|
||||
if (sRadioState == OT_RADIO_STATE_RECEIVE && sSleepInitDelay == 0)
|
||||
{
|
||||
sSleepInitDelay = otPlatAlarmGetNow();
|
||||
sSleepInitDelay = otPlatAlarmMilliGetNow();
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
else if ((otPlatAlarmGetNow() - sSleepInitDelay) < dg_configINITIAL_SLEEP_DELAY_TIME)
|
||||
else if ((otPlatAlarmMilliGetNow() - sSleepInitDelay) < dg_configINITIAL_SLEEP_DELAY_TIME)
|
||||
{
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
#include <openthread/platform/platform.h>
|
||||
|
||||
@@ -54,7 +54,7 @@ void efr32AlarmInit(void)
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t otPlatAlarmGetNow(void)
|
||||
uint32_t otPlatAlarmMilliGetNow(void)
|
||||
{
|
||||
uint32_t timer_lo;
|
||||
|
||||
@@ -70,7 +70,7 @@ uint32_t otPlatAlarmGetNow(void)
|
||||
return (((uint64_t)sTimerHi << 32) | sTimerLo) / 1000;
|
||||
}
|
||||
|
||||
void otPlatAlarmStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
{
|
||||
(void)aInstance;
|
||||
sAlarmT0 = t0;
|
||||
@@ -78,7 +78,7 @@ void otPlatAlarmStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
sIsRunning = true;
|
||||
}
|
||||
|
||||
void otPlatAlarmStop(otInstance *aInstance)
|
||||
void otPlatAlarmMilliStop(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
sIsRunning = false;
|
||||
@@ -86,7 +86,7 @@ void otPlatAlarmStop(otInstance *aInstance)
|
||||
|
||||
void efr32AlarmProcess(otInstance *aInstance)
|
||||
{
|
||||
uint32_t now = otPlatAlarmGetNow();
|
||||
uint32_t now = otPlatAlarmMilliGetNow();
|
||||
uint32_t expires;
|
||||
bool fire = false;
|
||||
|
||||
@@ -116,7 +116,7 @@ void efr32AlarmProcess(otInstance *aInstance)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
otPlatAlarmFired(aInstance);
|
||||
otPlatAlarmMilliFired(aInstance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#include "platform-efr32.h"
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
|
||||
#include "utils/code_utils.h"
|
||||
#include "utils/flash.h"
|
||||
@@ -93,7 +93,7 @@ otError utilsFlashErasePage(uint32_t aAddress)
|
||||
otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
{
|
||||
otError error = OT_ERROR_BUSY;
|
||||
uint32_t start = otPlatAlarmGetNow();
|
||||
uint32_t start = otPlatAlarmMilliGetNow();
|
||||
|
||||
do
|
||||
{
|
||||
@@ -103,7 +103,7 @@ otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (aTimeout && ((otPlatAlarmGetNow() - start) < aTimeout));
|
||||
while (aTimeout && ((otPlatAlarmMilliGetNow() - start) < aTimeout));
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "openthread/platform/alarm.h"
|
||||
#include "openthread/platform/alarm-milli.h"
|
||||
#include "platform-emsk.h"
|
||||
|
||||
static uint32_t sCounter = 0;
|
||||
@@ -46,19 +46,19 @@ void emskAlarmInit(void)
|
||||
sCounter = OSP_GET_CUR_MS();
|
||||
}
|
||||
|
||||
uint32_t otPlatAlarmGetNow(void)
|
||||
uint32_t otPlatAlarmMilliGetNow(void)
|
||||
{
|
||||
return (OSP_GET_CUR_MS() - sCounter);
|
||||
}
|
||||
|
||||
void otPlatAlarmStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
{
|
||||
(void)aInstance;
|
||||
expires = t0 + dt;
|
||||
sIsRunning = true;
|
||||
}
|
||||
|
||||
void otPlatAlarmStop(otInstance *aInstance)
|
||||
void otPlatAlarmMilliStop(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
sIsRunning = false;
|
||||
@@ -72,7 +72,7 @@ void emskAlarmUpdateTimeout(int32_t *aTimeout)
|
||||
|
||||
if (sIsRunning)
|
||||
{
|
||||
remaining = (int32_t)(expires - otPlatAlarmGetNow());
|
||||
remaining = (int32_t)(expires - otPlatAlarmMilliGetNow());
|
||||
|
||||
if (remaining > 0)
|
||||
{
|
||||
@@ -99,12 +99,12 @@ void emskAlarmProcess(otInstance *aInstance)
|
||||
|
||||
if (sIsRunning)
|
||||
{
|
||||
remaining = (int32_t)(expires - otPlatAlarmGetNow());
|
||||
remaining = (int32_t)(expires - otPlatAlarmMilliGetNow());
|
||||
|
||||
if (remaining <= 0)
|
||||
{
|
||||
sIsRunning = false;
|
||||
otPlatAlarmFired(aInstance);
|
||||
otPlatAlarmMilliFired(aInstance);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include "openthread/platform/alarm.h"
|
||||
#include "openthread/platform/alarm-milli.h"
|
||||
#include <utils/flash.h>
|
||||
#include <utils/code_utils.h>
|
||||
#include "platform-emsk.h"
|
||||
@@ -105,11 +105,11 @@ exit:
|
||||
otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint32_t start = otPlatAlarmGetNow();
|
||||
uint32_t start = otPlatAlarmMilliGetNow();
|
||||
bool busy = true;
|
||||
uint32_t status = 0x01;
|
||||
|
||||
while (busy && ((otPlatAlarmGetNow() - start) < aTimeout))
|
||||
while (busy && ((otPlatAlarmMilliGetNow() - start) < aTimeout))
|
||||
{
|
||||
status = flash_read_status();
|
||||
busy = status & 0x01;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
#include "openthread/openthread.h"
|
||||
#include "openthread/platform/platform.h"
|
||||
#include "openthread/platform/alarm.h"
|
||||
#include "openthread/platform/alarm-milli.h"
|
||||
#include "openthread/platform/diag.h"
|
||||
|
||||
static volatile uint32_t sTime = 0;
|
||||
@@ -74,24 +74,24 @@ void kw41zAlarmProcess(otInstance *aInstance)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
otPlatAlarmFired(aInstance);
|
||||
otPlatAlarmMilliFired(aInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void otPlatAlarmStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
|
||||
{
|
||||
(void)aInstance;
|
||||
sAlarmTime = aT0 + aDt;
|
||||
}
|
||||
|
||||
void otPlatAlarmStop(otInstance *aInstance)
|
||||
void otPlatAlarmMilliStop(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
sAlarmTime = 0;
|
||||
}
|
||||
|
||||
uint32_t otPlatAlarmGetNow(void)
|
||||
uint32_t otPlatAlarmMilliGetNow(void)
|
||||
{
|
||||
return sTime;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include "fsl_device_registers.h"
|
||||
#include "openthread/openthread.h"
|
||||
|
||||
#include "openthread/platform/alarm.h"
|
||||
#include "openthread/platform/alarm-milli.h"
|
||||
#include "openthread/platform/radio.h"
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <stdint.h>
|
||||
#include "fsl_device_registers.h"
|
||||
#include "fsl_flash.h"
|
||||
#include "openthread/platform/alarm.h"
|
||||
#include "openthread/platform/alarm-milli.h"
|
||||
#include <utils/flash.h>
|
||||
#include <utils/code_utils.h>
|
||||
|
||||
@@ -78,7 +78,7 @@ otError utilsFlashErasePage(uint32_t aAddress)
|
||||
otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
{
|
||||
otError error = OT_ERROR_BUSY;
|
||||
uint32_t start = otPlatAlarmGetNow();
|
||||
uint32_t start = otPlatAlarmMilliGetNow();
|
||||
|
||||
do
|
||||
{
|
||||
@@ -88,7 +88,7 @@ otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (aTimeout && ((otPlatAlarmGetNow() - start) < aTimeout));
|
||||
while (aTimeout && ((otPlatAlarmMilliGetNow() - start) < aTimeout));
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -37,9 +37,9 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-micro.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
#include <openthread/platform/usec-alarm.h>
|
||||
|
||||
#include "platform-config.h"
|
||||
#include "cmsis/core_cmFunc.h"
|
||||
@@ -100,9 +100,6 @@ static const AlarmChannelData sChannelData[kNumTimers] =
|
||||
}
|
||||
};
|
||||
|
||||
static otPlatUsecAlarmHandler sUsecHandler = NULL; ///< Handler called when usec alarm fires.
|
||||
static void *sUsecContext = NULL; ///< The context information passed to the usec handler callback.
|
||||
|
||||
static void HandleOverflow(void);
|
||||
|
||||
static inline uint32_t TimeToTicks(uint32_t aTime, AlarmIndex aIndex)
|
||||
@@ -335,7 +332,7 @@ void nrf5AlarmProcess(otInstance *aInstance)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
otPlatAlarmFired(aInstance);
|
||||
otPlatAlarmMilliFired(aInstance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,16 +340,16 @@ void nrf5AlarmProcess(otInstance *aInstance)
|
||||
{
|
||||
sTimerData[kUsTimer].mFireAlarm = false;
|
||||
|
||||
sUsecHandler(sUsecContext);
|
||||
otPlatAlarmMicroFired(aInstance);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t otPlatAlarmGetNow(void)
|
||||
uint32_t otPlatAlarmMilliGetNow(void)
|
||||
{
|
||||
return (uint32_t)(AlarmGetCurrentTime() / US_PER_MS);
|
||||
}
|
||||
|
||||
void otPlatAlarmStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
|
||||
{
|
||||
(void)aInstance;
|
||||
uint32_t targetTime = aT0 + aDt;
|
||||
@@ -360,31 +357,27 @@ void otPlatAlarmStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
|
||||
AlarmStartAt(targetTime, kMsTimer);
|
||||
}
|
||||
|
||||
void otPlatAlarmStop(otInstance *aInstance)
|
||||
void otPlatAlarmMilliStop(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
|
||||
AlarmStop(kMsTimer);
|
||||
}
|
||||
|
||||
uint32_t otPlatUsecAlarmGetNow(void)
|
||||
uint32_t otPlatAlarmMicroGetNow(void)
|
||||
{
|
||||
return (uint32_t)AlarmGetCurrentTime();
|
||||
}
|
||||
|
||||
void otPlatUsecAlarmStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt,
|
||||
otPlatUsecAlarmHandler aHandler, void *aContext)
|
||||
void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
|
||||
{
|
||||
(void)aInstance;
|
||||
uint32_t targetTime = aT0 + aDt;
|
||||
|
||||
AlarmStartAt(targetTime, kUsTimer);
|
||||
|
||||
sUsecHandler = aHandler;
|
||||
sUsecContext = aContext;
|
||||
}
|
||||
|
||||
void otPlatUsecAlarmStop(otInstance *aInstance)
|
||||
void otPlatAlarmMicroStop(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#include <common/logging.hpp>
|
||||
@@ -150,17 +150,17 @@ static void processTransmit(otInstance *aInstance, int argc, char *argv[], char
|
||||
}
|
||||
else if (strcmp(argv[0], "stop") == 0)
|
||||
{
|
||||
otPlatAlarmStop(aInstance);
|
||||
otPlatAlarmMilliStop(aInstance);
|
||||
snprintf(aOutput, aOutputMaxLen, "diagnostic message transmission is stopped\r\nstatus 0x%02x\r\n", error);
|
||||
sTransmitActive = false;
|
||||
}
|
||||
else if (strcmp(argv[0], "start") == 0)
|
||||
{
|
||||
otPlatAlarmStop(aInstance);
|
||||
otPlatAlarmMilliStop(aInstance);
|
||||
sTransmitActive = true;
|
||||
sTxCount = sTxRequestedCount;
|
||||
uint32_t now = otPlatAlarmGetNow();
|
||||
otPlatAlarmStartAt(aInstance, now, sTxPeriod);
|
||||
uint32_t now = otPlatAlarmMilliGetNow();
|
||||
otPlatAlarmMilliStartAt(aInstance, now, sTxPeriod);
|
||||
snprintf(aOutput, aOutputMaxLen, "sending %" PRId32 " diagnostic messages with %" PRIu32
|
||||
" ms interval\r\nstatus 0x%02x\r\n",
|
||||
sTxRequestedCount, sTxPeriod, error);
|
||||
@@ -300,13 +300,13 @@ void otPlatDiagAlarmCallback(otInstance *aInstance)
|
||||
sTxCount--;
|
||||
}
|
||||
|
||||
uint32_t now = otPlatAlarmGetNow();
|
||||
otPlatAlarmStartAt(aInstance, now, sTxPeriod);
|
||||
uint32_t now = otPlatAlarmMilliGetNow();
|
||||
otPlatAlarmMilliStartAt(aInstance, now, sTxPeriod);
|
||||
}
|
||||
else
|
||||
{
|
||||
sTransmitActive = false;
|
||||
otPlatAlarmStop(aInstance);
|
||||
otPlatAlarmMilliStop(aInstance);
|
||||
otPlatLog(OT_LOG_LEVEL_DEBG, OT_LOG_REGION_PLATFORM, "Transmit done");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <utils/flash.h>
|
||||
#include <utils/code_utils.h>
|
||||
|
||||
@@ -88,7 +88,7 @@ otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t startTime = otPlatAlarmGetNow();
|
||||
uint32_t startTime = otPlatAlarmMilliGetNow();
|
||||
|
||||
do
|
||||
{
|
||||
@@ -98,7 +98,7 @@ otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (otPlatAlarmGetNow() - startTime < aTimeout);
|
||||
while (otPlatAlarmMilliGetNow() - startTime < aTimeout);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
|
||||
#include <utils/code_utils.h>
|
||||
#include <utils/flash.h>
|
||||
@@ -80,7 +80,7 @@ void nrf5SdSocFlashProcess(uint32_t aEvtId)
|
||||
static otError sdFlashSingleWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
{
|
||||
uint32_t retval;
|
||||
uint32_t startTime = otPlatAlarmGetNow();
|
||||
uint32_t startTime = otPlatAlarmMilliGetNow();
|
||||
|
||||
// Expect SotfDevice Flash Complete event.
|
||||
sFlashStatus = FLASH_STATUS_PENDING;
|
||||
@@ -97,7 +97,7 @@ static otError sdFlashSingleWrite(uint32_t aAddress, uint8_t *aData, uint32_t aS
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (otPlatAlarmGetNow() - startTime < FLASH_TIMEOUT);
|
||||
while (otPlatAlarmMilliGetNow() - startTime < FLASH_TIMEOUT);
|
||||
|
||||
if (sFlashStatus != FLASH_STATUS_SUCCESS)
|
||||
{
|
||||
@@ -113,7 +113,7 @@ static otError sdFlashSingleWrite(uint32_t aAddress, uint8_t *aData, uint32_t aS
|
||||
otError nrf5FlashPageErase(uint32_t aAddress)
|
||||
{
|
||||
uint32_t retval;
|
||||
uint32_t startTime = otPlatAlarmGetNow();
|
||||
uint32_t startTime = otPlatAlarmMilliGetNow();
|
||||
|
||||
// Expect SotfDevice Flash Complete event.
|
||||
sFlashStatus = FLASH_STATUS_PENDING;
|
||||
@@ -130,7 +130,7 @@ otError nrf5FlashPageErase(uint32_t aAddress)
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (otPlatAlarmGetNow() - startTime < FLASH_TIMEOUT);
|
||||
while (otPlatAlarmMilliGetNow() - startTime < FLASH_TIMEOUT);
|
||||
|
||||
if (sFlashStatus != FLASH_STATUS_SUCCESS)
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <openthread/platform/logging.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <utils/code_utils.h>
|
||||
|
||||
#include "platform-nrf5.h"
|
||||
@@ -103,7 +103,7 @@ static inline const char *levelToString(otLogLevel aLogLevel)
|
||||
static inline uint16_t logTimestamp(char *aLogString, uint16_t aMaxSize)
|
||||
{
|
||||
return snprintf(aLogString, aMaxSize, "%s[%010ld]", RTT_COLOR_CODE_CYAN,
|
||||
otPlatAlarmGetNow());
|
||||
otPlatAlarmMilliGetNow());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -84,12 +84,12 @@
|
||||
#define OPENTHREAD_CONFIG_ENABLE_SOFTWARE_RETRANSMIT 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_BACKOFF_TIMER
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
*
|
||||
* Define to 1 if you want to enable microsecond backoff timer implemented in platform.
|
||||
* Define to 1 if you want to support microsecond timer in platform.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_BACKOFF_TIMER 1
|
||||
#define OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER 1
|
||||
|
||||
/**
|
||||
* @def SETTINGS_CONFIG_BASE_ADDRESS
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
|
||||
static bool s_is_running = false;
|
||||
@@ -44,7 +44,7 @@ void platformAlarmInit(void)
|
||||
gettimeofday(&s_start, NULL);
|
||||
}
|
||||
|
||||
uint32_t otPlatAlarmGetNow(void)
|
||||
uint32_t otPlatAlarmMilliGetNow(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
@@ -54,14 +54,14 @@ uint32_t otPlatAlarmGetNow(void)
|
||||
return (uint32_t)((tv.tv_sec * 1000) + (tv.tv_usec / 1000));
|
||||
}
|
||||
|
||||
void otPlatAlarmStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
{
|
||||
(void)aInstance;
|
||||
s_alarm = t0 + dt;
|
||||
s_is_running = true;
|
||||
}
|
||||
|
||||
void otPlatAlarmStop(otInstance *aInstance)
|
||||
void otPlatAlarmMilliStop(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
s_is_running = false;
|
||||
@@ -78,7 +78,7 @@ void platformAlarmUpdateTimeout(struct timeval *aTimeout)
|
||||
|
||||
if (s_is_running)
|
||||
{
|
||||
remaining = (int32_t)(s_alarm - otPlatAlarmGetNow());
|
||||
remaining = (int32_t)(s_alarm - otPlatAlarmMilliGetNow());
|
||||
|
||||
if (remaining > 0)
|
||||
{
|
||||
@@ -104,7 +104,7 @@ void platformAlarmProcess(otInstance *aInstance)
|
||||
|
||||
if (s_is_running)
|
||||
{
|
||||
remaining = (int32_t)(s_alarm - otPlatAlarmGetNow());
|
||||
remaining = (int32_t)(s_alarm - otPlatAlarmMilliGetNow());
|
||||
|
||||
if (remaining <= 0)
|
||||
{
|
||||
@@ -119,7 +119,7 @@ void platformAlarmProcess(otInstance *aInstance)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
otPlatAlarmFired(aInstance);
|
||||
otPlatAlarmMilliFired(aInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/openthread.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "utils/code_utils.h"
|
||||
#include "utils/flash.h"
|
||||
|
||||
static int sFlashFd;
|
||||
static int sFlashFd = -1;
|
||||
uint32_t sEraseAddress;
|
||||
|
||||
enum
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
#include <openthread/openthread.h>
|
||||
#include <openthread/tasklet.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
|
||||
uint32_t NODE_ID = 1;
|
||||
uint32_t WELLKNOWN_NODE_ID = 34;
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
|
||||
|
||||
ot_platform_headers =\
|
||||
alarm.h \
|
||||
alarm-micro.h \
|
||||
alarm-milli.h \
|
||||
diag.h \
|
||||
memory.h \
|
||||
misc.h \
|
||||
@@ -42,7 +43,6 @@ ot_platform_headers =\
|
||||
settings.h \
|
||||
messagepool.h \
|
||||
toolchain.h \
|
||||
usec-alarm.h \
|
||||
$(NULL)
|
||||
|
||||
ot_platformdir = $(includedir)/openthread/platform
|
||||
|
||||
+13
-17
@@ -32,8 +32,8 @@
|
||||
* This file includes the platform abstraction for the microsecond alarm service.
|
||||
*/
|
||||
|
||||
#ifndef USEC_ALARM_H_
|
||||
#define USEC_ALARM_H_
|
||||
#ifndef ALARM_MICRO_H_
|
||||
#define ALARM_MICRO_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -50,26 +50,15 @@ extern "C" {
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This defines the callback for indicating when the alarm has expired.
|
||||
*
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*
|
||||
*/
|
||||
typedef void (*otPlatUsecAlarmHandler)(void *aContext);
|
||||
|
||||
/**
|
||||
* Set the alarm to fire at @p aDt microseconds after @p aT0.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aT0 The reference time.
|
||||
* @param[in] aDt The time delay in microseconds from @p aT0.
|
||||
* @param[in] aHandler A pointer to a function that is called when the timer expires.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*
|
||||
*/
|
||||
void otPlatUsecAlarmStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt,
|
||||
otPlatUsecAlarmHandler aHandler, void *aContext);
|
||||
void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt);
|
||||
|
||||
/**
|
||||
* Stop the alarm.
|
||||
@@ -77,7 +66,7 @@ void otPlatUsecAlarmStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt,
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
*/
|
||||
void otPlatUsecAlarmStop(otInstance *aInstance);
|
||||
void otPlatAlarmMicroStop(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the current time.
|
||||
@@ -85,7 +74,14 @@ void otPlatUsecAlarmStop(otInstance *aInstance);
|
||||
* @param[out] aNow The current time in microseconds.
|
||||
*
|
||||
*/
|
||||
uint32_t otPlatUsecAlarmGetNow(void);
|
||||
uint32_t otPlatAlarmMicroGetNow(void);
|
||||
|
||||
/**
|
||||
* Signal that the alarm has fired.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
extern void otPlatAlarmMicroFired(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
@@ -96,4 +92,4 @@ uint32_t otPlatUsecAlarmGetNow(void);
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // USEC_ALARM_H_
|
||||
#endif // ALARM_MICRO_H_
|
||||
@@ -32,8 +32,8 @@
|
||||
* This file includes the platform abstraction for the millisecond alarm service.
|
||||
*/
|
||||
|
||||
#ifndef ALARM_H_
|
||||
#define ALARM_H_
|
||||
#ifndef ALARM_MILLI_H_
|
||||
#define ALARM_MILLI_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -60,28 +60,28 @@ extern "C" {
|
||||
* @param[in] aT0 The reference time.
|
||||
* @param[in] aDt The time delay in milliseconds from @p aT0.
|
||||
*/
|
||||
void otPlatAlarmStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt);
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt);
|
||||
|
||||
/**
|
||||
* Stop the alarm.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
void otPlatAlarmStop(otInstance *aInstance);
|
||||
void otPlatAlarmMilliStop(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the current time.
|
||||
*
|
||||
* @returns The current time in milliseconds.
|
||||
*/
|
||||
uint32_t otPlatAlarmGetNow(void);
|
||||
uint32_t otPlatAlarmMilliGetNow(void);
|
||||
|
||||
/**
|
||||
* Signal that the alarm has fired.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
extern void otPlatAlarmFired(otInstance *aInstance);
|
||||
extern void otPlatAlarmMilliFired(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Signal diagnostics module that the alarm has fired.
|
||||
@@ -99,4 +99,4 @@ extern void otPlatDiagAlarmFired(otInstance *aInstance);
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // ALARM_H_
|
||||
#endif // ALARM_MILLI_H_
|
||||
+3
-3
@@ -243,7 +243,7 @@ Interpreter::Interpreter(otInstance *aInstance):
|
||||
mLength(8),
|
||||
mCount(1),
|
||||
mInterval(1000),
|
||||
mPingTimer(aInstance->mIp6.mTimerScheduler, &Interpreter::s_HandlePingTimer, this),
|
||||
mPingTimer(aInstance->mIp6, &Interpreter::s_HandlePingTimer, this),
|
||||
#if OPENTHREAD_ENABLE_DNS_CLIENT
|
||||
mResolvingInProgress(0),
|
||||
#endif
|
||||
@@ -1607,7 +1607,7 @@ void Interpreter::HandleIcmpReceive(Message &aMessage, const Ip6::MessageInfo &a
|
||||
if (aMessage.Read(aMessage.GetOffset(), sizeof(uint32_t), ×tamp) >=
|
||||
static_cast<int>(sizeof(uint32_t)))
|
||||
{
|
||||
mServer->OutputFormat(" time=%dms", Timer::GetNow() - HostSwap32(timestamp));
|
||||
mServer->OutputFormat(" time=%dms", TimerMilli::GetNow() - HostSwap32(timestamp));
|
||||
}
|
||||
|
||||
mServer->OutputFormat("\r\n");
|
||||
@@ -1690,7 +1690,7 @@ void Interpreter::s_HandlePingTimer(Timer &aTimer)
|
||||
void Interpreter::HandlePingTimer()
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint32_t timestamp = HostSwap32(Timer::GetNow());
|
||||
uint32_t timestamp = HostSwap32(TimerMilli::GetNow());
|
||||
|
||||
otMessage *message;
|
||||
const otMessageInfo *messageInfo = static_cast<const otMessageInfo *>(&mMessageInfo);
|
||||
|
||||
+1
-1
@@ -364,7 +364,7 @@ private:
|
||||
uint16_t mLength;
|
||||
uint16_t mCount;
|
||||
uint32_t mInterval;
|
||||
Timer mPingTimer;
|
||||
TimerMilli mPingTimer;
|
||||
|
||||
otNetifAddress mSlaacAddresses[OPENTHREAD_CONFIG_NUM_SLAAC_ADDRESSES];
|
||||
#if OPENTHREAD_ENABLE_DHCP6_CLIENT
|
||||
|
||||
@@ -64,11 +64,6 @@ ot::MeshForwarder &otGetMeshForwarder(void)
|
||||
return sInstance->mThreadNetif.GetMeshForwarder();
|
||||
}
|
||||
|
||||
ot::TimerScheduler &otGetTimerScheduler(void)
|
||||
{
|
||||
return sInstance->mIp6.mTimerScheduler;
|
||||
}
|
||||
|
||||
ot::TaskletScheduler &otGetTaskletScheduler(void)
|
||||
{
|
||||
return sInstance->mIp6.mTaskletScheduler;
|
||||
|
||||
@@ -131,10 +131,12 @@ private:
|
||||
kTimerReasonEnergyScanComplete,
|
||||
};
|
||||
|
||||
Timer mTimer;
|
||||
TimerMilli mTimer;
|
||||
TimerReason mTimerReason;
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
TimerMicro mTimerMicro;
|
||||
#endif
|
||||
|
||||
static void HandleTimer(void *aContext);
|
||||
static void HandleTimer(Timer &aTimer);
|
||||
void HandleTimer(void);
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <openthread/platform/random.h>
|
||||
#include <openthread/platform/usec-alarm.h>
|
||||
|
||||
#include "openthread-instance.h"
|
||||
#include "common/debug.hpp"
|
||||
@@ -270,8 +269,11 @@ LinkRaw::LinkRaw(otInstance &aInstance):
|
||||
mTransmitDoneCallback(NULL),
|
||||
mEnergyScanDoneCallback(NULL)
|
||||
#if OPENTHREAD_LINKRAW_TIMER_REQUIRED
|
||||
, mTimer(aInstance.mIp6.mTimerScheduler, &LinkRaw::HandleTimer, this)
|
||||
, mTimer(aInstance.mIp6, &LinkRaw::HandleTimer, this)
|
||||
, mTimerReason(kTimerReasonNone)
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
, mTimerMicro(aInstance.mIp6, &LinkRaw::HandleTimer, this)
|
||||
#endif
|
||||
#endif // OPENTHREAD_LINKRAW_TIMER_REQUIRED
|
||||
#if OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ENERGY_SCAN
|
||||
, mEnergyScanTask(aInstance.mIp6.mTaskletScheduler, &LinkRaw::HandleEnergyScanTask, this)
|
||||
@@ -479,11 +481,6 @@ void LinkRaw::InvokeEnergyScanDone(int8_t aEnergyScanMaxRssi)
|
||||
|
||||
#if OPENTHREAD_LINKRAW_TIMER_REQUIRED
|
||||
|
||||
void LinkRaw::HandleTimer(void *aContext)
|
||||
{
|
||||
static_cast<LinkRaw *>(aContext)->HandleTimer();
|
||||
}
|
||||
|
||||
void LinkRaw::HandleTimer(Timer &aTimer)
|
||||
{
|
||||
GetOwner(aTimer).HandleTimer();
|
||||
@@ -565,11 +562,11 @@ void LinkRaw::StartCsmaBackoff(void)
|
||||
otLogDebgPlat(aInstance, "LinkRaw Starting RetransmitTimeout Timer (%d ms)", backoff);
|
||||
mTimerReason = kTimerReasonRetransmitTimeout;
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_BACKOFF_TIMER
|
||||
otPlatUsecAlarmStartAt(&mInstance, otPlatUsecAlarmGetNow(), backoff, &HandleTimer, this);
|
||||
#else // OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_BACKOFF_TIMER
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
mTimerMicro.Start(backoff);
|
||||
#else // OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
mTimer.Start(backoff / 1000UL);
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_BACKOFF_TIMER
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_SOFTWARE_RETRANSMIT
|
||||
|
||||
@@ -317,7 +317,8 @@ otError otThreadGetParentInfo(otInstance *aInstance, otRouterInfo *aParentInfo)
|
||||
aParentInfo->mPathCost = parent->GetCost();
|
||||
aParentInfo->mLinkQualityIn = parent->GetLinkInfo().GetLinkQuality(aInstance->mThreadNetif.GetMac().GetNoiseFloor());
|
||||
aParentInfo->mLinkQualityOut = parent->GetLinkQualityOut();
|
||||
aParentInfo->mAge = static_cast<uint8_t>(Timer::MsecToSec(Timer::GetNow() - parent->GetLastHeard()));
|
||||
aParentInfo->mAge = static_cast<uint8_t>(TimerMilli::MsecToSec(TimerMilli::GetNow() -
|
||||
parent->GetLastHeard()));
|
||||
aParentInfo->mAllocated = parent->IsAllocated();
|
||||
aParentInfo->mLinkEstablished = parent->GetState() == Neighbor::kStateValid;
|
||||
|
||||
|
||||
+11
-11
@@ -52,7 +52,7 @@ namespace Coap {
|
||||
Coap::Coap(ThreadNetif &aNetif):
|
||||
ThreadNetifLocator(aNetif),
|
||||
mSocket(aNetif.GetIp6().mUdp),
|
||||
mRetransmissionTimer(aNetif.GetIp6().mTimerScheduler, &Coap::HandleRetransmissionTimer, this),
|
||||
mRetransmissionTimer(aNetif.GetIp6(), &Coap::HandleRetransmissionTimer, this),
|
||||
mResources(NULL),
|
||||
mContext(NULL),
|
||||
mInterceptor(NULL),
|
||||
@@ -305,7 +305,7 @@ void Coap::HandleRetransmissionTimer(Timer &aTimer)
|
||||
|
||||
void Coap::HandleRetransmissionTimer(void)
|
||||
{
|
||||
uint32_t now = otPlatAlarmGetNow();
|
||||
uint32_t now = TimerMilli::GetNow();
|
||||
uint32_t nextDelta = 0xffffffff;
|
||||
CoapMetadata coapMetadata;
|
||||
Message *message = mPendingRequests.GetHead();
|
||||
@@ -740,20 +740,20 @@ CoapMetadata::CoapMetadata(bool aConfirmable, const Ip6::MessageInfo &aMessageIn
|
||||
mResponseHandler = aHandler;
|
||||
mResponseContext = aContext;
|
||||
mRetransmissionCount = 0;
|
||||
mRetransmissionTimeout = Timer::SecToMsec(kAckTimeout);
|
||||
mRetransmissionTimeout = TimerMilli::SecToMsec(kAckTimeout);
|
||||
mRetransmissionTimeout += otPlatRandomGet() %
|
||||
(Timer::SecToMsec(kAckTimeout) * kAckRandomFactorNumerator / kAckRandomFactorDenominator -
|
||||
Timer::SecToMsec(kAckTimeout) + 1);
|
||||
(TimerMilli::SecToMsec(kAckTimeout) * kAckRandomFactorNumerator / kAckRandomFactorDenominator -
|
||||
TimerMilli::SecToMsec(kAckTimeout) + 1);
|
||||
|
||||
if (aConfirmable)
|
||||
{
|
||||
// Set next retransmission timeout.
|
||||
mNextTimerShot = Timer::GetNow() + mRetransmissionTimeout;
|
||||
mNextTimerShot = TimerMilli::GetNow() + mRetransmissionTimeout;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set overall response timeout.
|
||||
mNextTimerShot = Timer::GetNow() + kMaxTransmitWait;
|
||||
mNextTimerShot = TimerMilli::GetNow() + kMaxTransmitWait;
|
||||
}
|
||||
|
||||
mAcknowledged = false;
|
||||
@@ -761,7 +761,7 @@ CoapMetadata::CoapMetadata(bool aConfirmable, const Ip6::MessageInfo &aMessageIn
|
||||
}
|
||||
|
||||
ResponsesQueue::ResponsesQueue(ThreadNetif &aNetif):
|
||||
mTimer(aNetif.GetIp6().mTimerScheduler, &ResponsesQueue::HandleTimer, this)
|
||||
mTimer(aNetif.GetIp6(), &ResponsesQueue::HandleTimer, this)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -870,7 +870,7 @@ void ResponsesQueue::EnqueueResponse(Message &aMessage, const Ip6::MessageInfo &
|
||||
|
||||
if (!mTimer.IsRunning())
|
||||
{
|
||||
mTimer.Start(Timer::SecToMsec(kExchangeLifetime));
|
||||
mTimer.Start(TimerMilli::SecToMsec(kExchangeLifetime));
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -923,7 +923,7 @@ void ResponsesQueue::HandleTimer(void)
|
||||
{
|
||||
enqueuedResponseHeader.ReadFrom(*message);
|
||||
|
||||
if (enqueuedResponseHeader.IsEarlier(Timer::GetNow()))
|
||||
if (enqueuedResponseHeader.IsEarlier(TimerMilli::GetNow()))
|
||||
{
|
||||
DequeueResponse(*message);
|
||||
}
|
||||
@@ -937,7 +937,7 @@ void ResponsesQueue::HandleTimer(void)
|
||||
|
||||
uint32_t EnqueuedResponseHeader::GetRemainingTime(void) const
|
||||
{
|
||||
int32_t remainingTime = static_cast<int32_t>(mDequeueTime - Timer::GetNow());
|
||||
int32_t remainingTime = static_cast<int32_t>(mDequeueTime - TimerMilli::GetNow());
|
||||
|
||||
return remainingTime >= 0 ? static_cast<uint32_t>(remainingTime) : 0;
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ public:
|
||||
*
|
||||
*/
|
||||
EnqueuedResponseHeader(const Ip6::MessageInfo &aMessageInfo):
|
||||
mDequeueTime(Timer::GetNow() + Timer::SecToMsec(kExchangeLifetime)),
|
||||
mDequeueTime(TimerMilli::GetNow() + TimerMilli::SecToMsec(kExchangeLifetime)),
|
||||
mMessageInfo(aMessageInfo) {}
|
||||
|
||||
/**
|
||||
@@ -413,7 +413,7 @@ private:
|
||||
void HandleTimer(void);
|
||||
|
||||
MessageQueue mQueue;
|
||||
Timer mTimer;
|
||||
TimerMilli mTimer;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -695,7 +695,7 @@ private:
|
||||
|
||||
MessageQueue mPendingRequests;
|
||||
uint16_t mMessageId;
|
||||
Timer mRetransmissionTimer;
|
||||
TimerMilli mRetransmissionTimer;
|
||||
|
||||
Resource *mResources;
|
||||
|
||||
|
||||
@@ -54,11 +54,6 @@ otInstance *MeshForwarderLocator::GetInstance(void) const
|
||||
return otInstanceFromThreadNetif(&GetMeshForwarder().GetNetif());
|
||||
}
|
||||
|
||||
otInstance *TimerSchedulerLocator::GetInstance(void) const
|
||||
{
|
||||
return otInstanceFromIp6(Ip6::Ip6FromTimerScheduler(&GetTimerScheduler()));
|
||||
}
|
||||
|
||||
otInstance *TaskletSchedulerLocator::GetInstance(void) const
|
||||
{
|
||||
return otInstanceFromIp6(Ip6::Ip6FromTaskletScheduler(&GetTaskletScheduler()));
|
||||
|
||||
@@ -46,7 +46,6 @@ namespace ot {
|
||||
class ThreadNetif;
|
||||
class MeshForwarder;
|
||||
class TaskletScheduler;
|
||||
class TimerScheduler;
|
||||
namespace Ip6 { class Ip6; }
|
||||
|
||||
/**
|
||||
@@ -168,47 +167,6 @@ protected:
|
||||
MeshForwarderLocator(MeshForwarder &aMeshForwarder): Locator(aMeshForwarder) { }
|
||||
};
|
||||
|
||||
/**
|
||||
* This class implements a locator for TimerScheduler object.
|
||||
*
|
||||
*/
|
||||
class TimerSchedulerLocator: private Locator<TimerScheduler>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This method returns a reference to the TimerScheduler.
|
||||
*
|
||||
* @returns A reference to the TimerScheduler.
|
||||
*
|
||||
*/
|
||||
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
TimerScheduler &GetTimerScheduler(void) const { return mLocatorObject; }
|
||||
#else
|
||||
TimerScheduler &GetTimerScheduler(void) const { return otGetTimerScheduler(); }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This method returns the pointer to the parent otInstance structure.
|
||||
*
|
||||
* @returns The pointer to the parent otInstance structure, or NULL if the instance has been finalized.
|
||||
*
|
||||
*/
|
||||
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
otInstance *GetInstance(void) const;
|
||||
#else
|
||||
otInstance *GetInstance(void) const { return otGetInstance(); }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
*
|
||||
* @param[in] aTimerScheduler A reference to the TimerScheduler.
|
||||
*
|
||||
*/
|
||||
TimerSchedulerLocator(TimerScheduler &aTimerScheduler): Locator(aTimerScheduler) { }
|
||||
};
|
||||
|
||||
/**
|
||||
* This class implements a locator for TaskletScheduler object.
|
||||
*
|
||||
|
||||
+98
-54
@@ -37,8 +37,6 @@
|
||||
|
||||
#include "timer.hpp"
|
||||
|
||||
#include <openthread/platform/alarm.h>
|
||||
|
||||
#include "openthread-instance.h"
|
||||
#include "common/code_utils.hpp"
|
||||
#include "common/debug.hpp"
|
||||
@@ -47,20 +45,63 @@
|
||||
|
||||
namespace ot {
|
||||
|
||||
TimerScheduler::TimerScheduler(void):
|
||||
mHead(NULL)
|
||||
const TimerScheduler::AlarmApi TimerMilliScheduler::sAlarmMilliApi =
|
||||
{
|
||||
&otPlatAlarmMilliStartAt,
|
||||
&otPlatAlarmMilliStop,
|
||||
&otPlatAlarmMilliGetNow
|
||||
};
|
||||
|
||||
bool Timer::DoesFireBefore(const Timer &aSecondTimer, uint32_t aNow)
|
||||
{
|
||||
bool retval;
|
||||
bool isBeforeNow = TimerScheduler::IsStrictlyBefore(GetFireTime(), aNow);
|
||||
|
||||
// Check if one timer is before `now` and the other one is not.
|
||||
if (TimerScheduler::IsStrictlyBefore(aSecondTimer.GetFireTime(), aNow) != isBeforeNow)
|
||||
{
|
||||
// One timer is before `now` and the other one is not, so if this timer's fire time is before `now` then
|
||||
// the second fire time would be after `now` and this timer would fire before the second timer.
|
||||
|
||||
retval = isBeforeNow;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Both timers are before `now` or both are after `now`. Either way the difference is guaranteed to be less
|
||||
// than `kMaxDt` so we can safely compare the fire times directly.
|
||||
|
||||
retval = TimerScheduler::IsStrictlyBefore(GetFireTime(), aSecondTimer.GetFireTime());
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void TimerScheduler::Add(Timer &aTimer)
|
||||
void TimerMilli::StartAt(uint32_t aT0, uint32_t aDt)
|
||||
{
|
||||
Remove(aTimer);
|
||||
assert(aDt <= kMaxDt);
|
||||
mFireTime = aT0 + aDt;
|
||||
GetTimerMilliScheduler().Add(*this);
|
||||
}
|
||||
|
||||
void TimerMilli::Stop(void)
|
||||
{
|
||||
GetTimerMilliScheduler().Remove(*this);
|
||||
}
|
||||
|
||||
TimerMilliScheduler &TimerMilli::GetTimerMilliScheduler(void) const
|
||||
{
|
||||
return GetIp6().mTimerMilliScheduler;
|
||||
}
|
||||
|
||||
void TimerScheduler::Add(Timer &aTimer, const AlarmApi &aAlarmApi)
|
||||
{
|
||||
Remove(aTimer, aAlarmApi);
|
||||
|
||||
if (mHead == NULL)
|
||||
{
|
||||
mHead = &aTimer;
|
||||
aTimer.mNext = NULL;
|
||||
SetAlarm();
|
||||
SetAlarm(aAlarmApi);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -69,7 +110,7 @@ void TimerScheduler::Add(Timer &aTimer)
|
||||
|
||||
for (cur = mHead; cur; cur = cur->mNext)
|
||||
{
|
||||
if (aTimer.DoesFireBefore(*cur))
|
||||
if (aTimer.DoesFireBefore(*cur, aAlarmApi.AlarmGetNow()))
|
||||
{
|
||||
if (prev)
|
||||
{
|
||||
@@ -80,7 +121,7 @@ void TimerScheduler::Add(Timer &aTimer)
|
||||
{
|
||||
aTimer.mNext = mHead;
|
||||
mHead = &aTimer;
|
||||
SetAlarm();
|
||||
SetAlarm(aAlarmApi);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -97,14 +138,14 @@ void TimerScheduler::Add(Timer &aTimer)
|
||||
}
|
||||
}
|
||||
|
||||
void TimerScheduler::Remove(Timer &aTimer)
|
||||
void TimerScheduler::Remove(Timer &aTimer, const AlarmApi &aAlarmApi)
|
||||
{
|
||||
VerifyOrExit(aTimer.mNext != &aTimer);
|
||||
|
||||
if (mHead == &aTimer)
|
||||
{
|
||||
mHead = aTimer.mNext;
|
||||
SetAlarm();
|
||||
SetAlarm(aAlarmApi);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -124,55 +165,43 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void TimerScheduler::SetAlarm(void)
|
||||
void TimerScheduler::SetAlarm(const AlarmApi &aAlarmApi)
|
||||
{
|
||||
if (mHead == NULL)
|
||||
{
|
||||
otPlatAlarmStop(GetIp6()->GetInstance());
|
||||
aAlarmApi.AlarmStop(GetIp6().GetInstance());
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t now = otPlatAlarmGetNow();
|
||||
uint32_t now = aAlarmApi.AlarmGetNow();
|
||||
uint32_t remaining = IsStrictlyBefore(now, mHead->mFireTime) ? (mHead->mFireTime - now) : 0;
|
||||
|
||||
otPlatAlarmStartAt(GetIp6()->GetInstance(), now, remaining);
|
||||
aAlarmApi.AlarmStartAt(GetIp6().GetInstance(), now, remaining);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void otPlatAlarmFired(otInstance *aInstance)
|
||||
{
|
||||
otLogFuncEntry();
|
||||
aInstance->mIp6.mTimerScheduler.ProcessTimers();
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void TimerScheduler::ProcessTimers(void)
|
||||
void TimerScheduler::ProcessTimers(const AlarmApi &aAlarmApi)
|
||||
{
|
||||
Timer *timer = mHead;
|
||||
|
||||
if (timer)
|
||||
{
|
||||
if (!IsStrictlyBefore(otPlatAlarmGetNow(), timer->mFireTime))
|
||||
if (!IsStrictlyBefore(aAlarmApi.AlarmGetNow(), timer->mFireTime))
|
||||
{
|
||||
Remove(*timer);
|
||||
Remove(*timer, aAlarmApi);
|
||||
timer->Fired();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetAlarm();
|
||||
SetAlarm(aAlarmApi);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetAlarm();
|
||||
SetAlarm(aAlarmApi);
|
||||
}
|
||||
}
|
||||
|
||||
Ip6::Ip6 *TimerScheduler::GetIp6(void)
|
||||
{
|
||||
return Ip6::Ip6FromTimerScheduler(this);
|
||||
}
|
||||
|
||||
bool TimerScheduler::IsStrictlyBefore(uint32_t aTimeA, uint32_t aTimeB)
|
||||
{
|
||||
uint32_t diff = aTimeA - aTimeB;
|
||||
@@ -185,29 +214,44 @@ bool TimerScheduler::IsStrictlyBefore(uint32_t aTimeA, uint32_t aTimeB)
|
||||
return ((diff & (1UL << 31)) != 0);
|
||||
}
|
||||
|
||||
bool Timer::DoesFireBefore(const Timer &aSecondTimer)
|
||||
extern "C" void otPlatAlarmMilliFired(otInstance *aInstance)
|
||||
{
|
||||
bool retval;
|
||||
uint32_t now = GetNow();
|
||||
bool isBeforeNow = TimerScheduler::IsStrictlyBefore(GetFireTime(), now);
|
||||
|
||||
// Check if one timer is before `now` and the other one is not.
|
||||
if (TimerScheduler::IsStrictlyBefore(aSecondTimer.GetFireTime(), now) != isBeforeNow)
|
||||
{
|
||||
// One timer is before `now` and the other one is not, so if this timer's fire time is before `now` then
|
||||
// the second fire time would be after `now` and this timer would fire before the second timer.
|
||||
|
||||
retval = isBeforeNow;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Both timers are before `now` or both are after `now`. Either way the difference is guaranteed to be less
|
||||
// than `kMaxDt` so we can safely compare the fire times directly.
|
||||
|
||||
retval = TimerScheduler::IsStrictlyBefore(GetFireTime(), aSecondTimer.GetFireTime());
|
||||
}
|
||||
|
||||
return retval;
|
||||
otLogFuncEntry();
|
||||
aInstance->mIp6.mTimerMilliScheduler.ProcessTimers();
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
const TimerScheduler::AlarmApi TimerMicroScheduler::sAlarmMicroApi =
|
||||
{
|
||||
&otPlatAlarmMicroStartAt,
|
||||
&otPlatAlarmMicroStop,
|
||||
&otPlatAlarmMicroGetNow
|
||||
};
|
||||
|
||||
void TimerMicro::StartAt(uint32_t aT0, uint32_t aDt)
|
||||
{
|
||||
assert(aDt <= kMaxDt);
|
||||
mFireTime = aT0 + aDt;
|
||||
GetTimerMicroScheduler().Add(*this);
|
||||
}
|
||||
|
||||
void TimerMicro::Stop(void)
|
||||
{
|
||||
GetTimerMicroScheduler().Remove(*this);
|
||||
}
|
||||
|
||||
TimerMicroScheduler &TimerMicro::GetTimerMicroScheduler(void) const
|
||||
{
|
||||
return GetIp6().mTimerMicroScheduler;
|
||||
}
|
||||
|
||||
extern "C" void otPlatAlarmMicroFired(otInstance *aInstance)
|
||||
{
|
||||
otLogFuncEntry();
|
||||
aInstance->mIp6.mTimerMicroScheduler.ProcessTimers();
|
||||
otLogFuncExit();
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
|
||||
} // namespace ot
|
||||
|
||||
+288
-95
@@ -38,7 +38,8 @@
|
||||
#include "utils/wrap_stdint.h"
|
||||
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-micro.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
|
||||
#include "common/context.hpp"
|
||||
#include "common/debug.hpp"
|
||||
@@ -49,7 +50,7 @@ namespace ot {
|
||||
|
||||
namespace Ip6 { class Ip6; }
|
||||
|
||||
class Timer;
|
||||
class TimerMilliScheduler;
|
||||
|
||||
/**
|
||||
* @addtogroup core-timer
|
||||
@@ -61,81 +62,11 @@ class Timer;
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class implements the timer scheduler.
|
||||
*
|
||||
*/
|
||||
class TimerScheduler
|
||||
{
|
||||
friend class Timer;
|
||||
|
||||
public:
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
*
|
||||
*/
|
||||
TimerScheduler(void);
|
||||
|
||||
/**
|
||||
* This method adds a timer instance to the timer scheduler.
|
||||
*
|
||||
* @param[in] aTimer A reference to the timer instance.
|
||||
*
|
||||
*/
|
||||
void Add(Timer &aTimer);
|
||||
|
||||
/**
|
||||
* This method removes a timer instance to the timer scheduler.
|
||||
*
|
||||
* @param[in] aTimer A reference to the timer instance.
|
||||
*
|
||||
*/
|
||||
void Remove(Timer &aTimer);
|
||||
|
||||
/**
|
||||
* This method processes the running timers.
|
||||
*
|
||||
*/
|
||||
void ProcessTimers(void);
|
||||
|
||||
private:
|
||||
/**
|
||||
* This method sets the platform alarm based on timer at front of the list.
|
||||
*
|
||||
*/
|
||||
void SetAlarm(void);
|
||||
|
||||
/**
|
||||
* This method returns the pointer to the parent Ip6 structure.
|
||||
*
|
||||
* @returns The pointer to the parent Ip6 structure.
|
||||
*
|
||||
*/
|
||||
Ip6::Ip6 *GetIp6(void);
|
||||
|
||||
/**
|
||||
* This static method compares two times and indicates if the first time is strictly before (earlier) than the
|
||||
* second time.
|
||||
*
|
||||
* This method requires that the difference between the two given times to be smaller than kMaxDt.
|
||||
*
|
||||
* @param[in] aTimerA The first time for comparison.
|
||||
* @param[in] aTimerB The second time for comparison.
|
||||
*
|
||||
* @returns TRUE if aTimeA is before aTimeB.
|
||||
* @returns FALSE if aTimeA is same time or after aTimeB.
|
||||
*
|
||||
*/
|
||||
static bool IsStrictlyBefore(uint32_t aTimeA, uint32_t aTimeB);
|
||||
|
||||
Timer *mHead;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class implements a timer.
|
||||
*
|
||||
*/
|
||||
class Timer: public TimerSchedulerLocator, public Context
|
||||
class Timer: public Ip6Locator, public Context
|
||||
{
|
||||
friend class TimerScheduler;
|
||||
|
||||
@@ -157,13 +88,13 @@ public:
|
||||
/**
|
||||
* This constructor creates a timer instance.
|
||||
*
|
||||
* @param[in] aScheduler A reference to the timer scheduler.
|
||||
* @param[in] aIp6 A reference to the IPv6 network object.
|
||||
* @param[in] aHandler A pointer to a function that is called when the timer expires.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*
|
||||
*/
|
||||
Timer(TimerScheduler &aScheduler, Handler aHandler, void *aContext):
|
||||
TimerSchedulerLocator(aScheduler),
|
||||
Timer(Ip6::Ip6 &aIp6, Handler aHandler, void *aContext):
|
||||
Ip6Locator(aIp6),
|
||||
Context(aContext),
|
||||
mHandler(aHandler),
|
||||
mFireTime(0),
|
||||
@@ -187,6 +118,45 @@ public:
|
||||
*/
|
||||
bool IsRunning(void) const { return (mNext != this); }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* This method indicates if the fire time of this timer is strictly before the fire time of a second given timer.
|
||||
*
|
||||
* @param[in] aTimer A reference to the second timer object.
|
||||
* @param[in] aNow The current time (may in milliseconds or microsecond, which depends on the timer type).
|
||||
*
|
||||
* @retval TRUE If the fire time of this timer object is strictly before aTimer's fire time
|
||||
* @retval FALSE If the fire time of this timer object is the same or after aTimer's fire time.
|
||||
*
|
||||
*/
|
||||
bool DoesFireBefore(const Timer &aTimer, uint32_t aNow);
|
||||
|
||||
void Fired(void) { mHandler(*this); }
|
||||
|
||||
Handler mHandler;
|
||||
uint32_t mFireTime;
|
||||
Timer *mNext;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class implements the millisecond timer.
|
||||
*
|
||||
*/
|
||||
class TimerMilli: public Timer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This constructor creates a millisecond timer instance.
|
||||
*
|
||||
* @param[in] aIp6 A reference to the IPv6 network object.
|
||||
* @param[in] aHandler A pointer to a function that is called when the timer expires.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*
|
||||
*/
|
||||
TimerMilli(Ip6::Ip6 &aIp6, Handler aHandler, void *aContext):
|
||||
Timer(aIp6, aHandler, aContext) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method schedules the timer to fire a @p dt milliseconds from now.
|
||||
*
|
||||
@@ -204,17 +174,13 @@ public:
|
||||
* (aDt must be smaller than or equal to kMaxDt).
|
||||
*
|
||||
*/
|
||||
void StartAt(uint32_t aT0, uint32_t aDt) {
|
||||
assert(aDt <= kMaxDt);
|
||||
mFireTime = aT0 + aDt;
|
||||
GetTimerScheduler().Add(*this);
|
||||
}
|
||||
void StartAt(uint32_t aT0, uint32_t aDt);
|
||||
|
||||
/**
|
||||
* This method stops the timer.
|
||||
*
|
||||
*/
|
||||
void Stop(void) { GetTimerScheduler().Remove(*this); }
|
||||
void Stop(void);
|
||||
|
||||
/**
|
||||
* This static method returns the current time in milliseconds.
|
||||
@@ -222,7 +188,7 @@ public:
|
||||
* @returns The current time in milliseconds.
|
||||
*
|
||||
*/
|
||||
static uint32_t GetNow(void) { return otPlatAlarmGetNow(); }
|
||||
static uint32_t GetNow(void) { return otPlatAlarmMilliGetNow(); }
|
||||
|
||||
/**
|
||||
* This static method returns the number of milliseconds given seconds.
|
||||
@@ -242,23 +208,250 @@ public:
|
||||
|
||||
private:
|
||||
/**
|
||||
* This method indicates if the fire time of this timer is strictly before the fire time of a second given timer.
|
||||
* This method returns a reference to the TimerMilliScheduler.
|
||||
*
|
||||
* @param[in] aTimer A reference to the second timer object.
|
||||
*
|
||||
* @retval TRUE If the fire time of this timer object is strictly before aTimer's fire time
|
||||
* @retval FALSE If the fire time of this timer object is the same or after aTimer's fire time.
|
||||
* @returns A reference to the TimerMilliScheduler.
|
||||
*
|
||||
*/
|
||||
bool DoesFireBefore(const Timer &aTimer);
|
||||
|
||||
void Fired(void) { mHandler(*this); }
|
||||
|
||||
Handler mHandler;
|
||||
uint32_t mFireTime;
|
||||
Timer *mNext;
|
||||
TimerMilliScheduler &GetTimerMilliScheduler(void) const;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This class implements the base timer scheduler.
|
||||
*
|
||||
*/
|
||||
class TimerScheduler: public Ip6Locator
|
||||
{
|
||||
friend class Timer;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The Alarm APIs definition
|
||||
*
|
||||
*/
|
||||
struct AlarmApi
|
||||
{
|
||||
void (*AlarmStartAt)(otInstance *aInstance, uint32_t aT0, uint32_t aDt);
|
||||
void (*AlarmStop)(otInstance *aInstance);
|
||||
uint32_t (*AlarmGetNow)(void);
|
||||
};
|
||||
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
*
|
||||
* @param[in] aIp6 A reference to the IPv6 network object.
|
||||
*
|
||||
*/
|
||||
TimerScheduler(Ip6::Ip6 &aIp6):
|
||||
Ip6Locator(aIp6),
|
||||
mHead(NULL) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds a timer instance to the timer scheduler.
|
||||
*
|
||||
* @param[in] aTimer A reference to the timer instance.
|
||||
* @param[in] aAlarmApi A reference to the Alarm APIs.
|
||||
*
|
||||
*/
|
||||
void Add(Timer &aTimer, const AlarmApi &aAlarmApi);
|
||||
|
||||
/**
|
||||
* This method removes a timer instance to the timer scheduler.
|
||||
*
|
||||
* @param[in] aTimer A reference to the timer instance.
|
||||
* @param[in] aAlarmApi A reference to the Alarm APIs.
|
||||
*
|
||||
*/
|
||||
void Remove(Timer &aTimer, const AlarmApi &aAlarmApi);
|
||||
|
||||
/**
|
||||
* This method processes the running timers.
|
||||
*
|
||||
* @param[in] aAlarmApi A reference to the Alarm APIs.
|
||||
*
|
||||
*/
|
||||
void ProcessTimers(const AlarmApi &aAlarmApi);
|
||||
|
||||
/**
|
||||
* This method sets the platform alarm based on timer at front of the list.
|
||||
*
|
||||
* @param[in] aAlarmApi A reference to the Alarm APIs.
|
||||
*
|
||||
*/
|
||||
void SetAlarm(const AlarmApi &aAlarmApi);
|
||||
|
||||
/**
|
||||
* This static method compares two times and indicates if the first time is strictly before (earlier) than the
|
||||
* second time.
|
||||
*
|
||||
* This method requires that the difference between the two given times to be smaller than kMaxDt.
|
||||
*
|
||||
* @param[in] aTimerA The first time for comparison.
|
||||
* @param[in] aTimerB The second time for comparison.
|
||||
*
|
||||
* @returns TRUE if aTimeA is before aTimeB.
|
||||
* @returns FALSE if aTimeA is same time or after aTimeB.
|
||||
*
|
||||
*/
|
||||
static bool IsStrictlyBefore(uint32_t aTimeA, uint32_t aTimeB);
|
||||
|
||||
Timer *mHead;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class implements the millisecond timer scheduler.
|
||||
*
|
||||
*/
|
||||
class TimerMilliScheduler: public TimerScheduler
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
*
|
||||
* @param[in] aIp6 A reference to the IPv6 network object.
|
||||
*
|
||||
*/
|
||||
TimerMilliScheduler(Ip6::Ip6 &aIp6):
|
||||
TimerScheduler(aIp6) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds a timer instance to the timer scheduler.
|
||||
*
|
||||
* @param[in] aTimer A reference to the timer instance.
|
||||
*
|
||||
*/
|
||||
void Add(TimerMilli &aTimer) { TimerScheduler::Add(aTimer, sAlarmMilliApi); }
|
||||
|
||||
/**
|
||||
* This method removes a timer instance to the timer scheduler.
|
||||
*
|
||||
* @param[in] aTimer A reference to the timer instance.
|
||||
*
|
||||
*/
|
||||
void Remove(TimerMilli &aTimer) { TimerScheduler::Remove(aTimer, sAlarmMilliApi); };
|
||||
|
||||
/**
|
||||
* This method processes the running timers.
|
||||
*
|
||||
*/
|
||||
void ProcessTimers(void) { TimerScheduler::ProcessTimers(sAlarmMilliApi); }
|
||||
|
||||
private:
|
||||
static const AlarmApi sAlarmMilliApi;
|
||||
};
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
class TimerMicroScheduler;
|
||||
|
||||
/**
|
||||
* This class implements the microsecond timer.
|
||||
*
|
||||
*/
|
||||
class TimerMicro: public Timer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This constructor creates a timer instance.
|
||||
*
|
||||
* @param[in] aIp6 A reference to the IPv6 network object.
|
||||
* @param[in] aHandler A pointer to a function that is called when the timer expires.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*
|
||||
*/
|
||||
TimerMicro(Ip6::Ip6 &aIp6, Handler aHandler, void *aContext):
|
||||
Timer(aIp6, aHandler, aContext) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method schedules the timer to fire a @p dt microseconds from now.
|
||||
*
|
||||
* @param[in] aDt The expire time in microseconds from now.
|
||||
* (aDt must be smaller than or equal to kMaxDt).
|
||||
*
|
||||
*/
|
||||
void Start(uint32_t aDt) { StartAt(GetNow(), aDt); }
|
||||
|
||||
/**
|
||||
* This method schedules the timer to fire at @p aDt microseconds from @p aT0.
|
||||
*
|
||||
* @param[in] aT0 The start time in microseconds.
|
||||
* @param[in] aDt The expire time in microseconds from @p aT0.
|
||||
* (aDt must be smaller than or equal to kMaxDt).
|
||||
*
|
||||
*/
|
||||
void StartAt(uint32_t aT0, uint32_t aDt);
|
||||
|
||||
/**
|
||||
* This method stops the timer.
|
||||
*
|
||||
*/
|
||||
void Stop(void);
|
||||
|
||||
/**
|
||||
* This static method returns the current time in microseconds.
|
||||
*
|
||||
* @returns The current time in microseconds.
|
||||
*
|
||||
*/
|
||||
static uint32_t GetNow(void) { return otPlatAlarmMicroGetNow(); }
|
||||
|
||||
private:
|
||||
/**
|
||||
* This method returns a reference to the TimerMicroScheduler.
|
||||
*
|
||||
* @returns A reference to the TimerMicroScheduler.
|
||||
*
|
||||
*/
|
||||
TimerMicroScheduler &GetTimerMicroScheduler(void) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class implements the microsecond timer scheduler.
|
||||
*
|
||||
*/
|
||||
class TimerMicroScheduler: public TimerScheduler
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
*
|
||||
* @param[in] aIp6 A reference to the IPv6 network object.
|
||||
*
|
||||
*/
|
||||
TimerMicroScheduler(Ip6::Ip6 &aIp6):
|
||||
TimerScheduler(aIp6) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds a timer instance to the timer scheduler.
|
||||
*
|
||||
* @param[in] aTimer A reference to the timer instance.
|
||||
*
|
||||
*/
|
||||
void Add(TimerMicro &aTimer) { TimerScheduler::Add(aTimer, sAlarmMicroApi); }
|
||||
|
||||
/**
|
||||
* This method removes a timer instance to the timer scheduler.
|
||||
*
|
||||
* @param[in] aTimer A reference to the timer instance.
|
||||
*
|
||||
*/
|
||||
void Remove(TimerMicro &aTimer) { TimerScheduler::Remove(aTimer, sAlarmMicroApi); };
|
||||
|
||||
/**
|
||||
* This method processes the running timers.
|
||||
*
|
||||
*/
|
||||
void ProcessTimers(void) { TimerScheduler::ProcessTimers(sAlarmMicroApi); }
|
||||
|
||||
private:
|
||||
static const AlarmApi sAlarmMicroApi;
|
||||
};
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
|
||||
@@ -44,13 +44,13 @@
|
||||
namespace ot {
|
||||
|
||||
TrickleTimer::TrickleTimer(
|
||||
TimerScheduler &aScheduler,
|
||||
Ip6::Ip6 &aIp6,
|
||||
#ifdef ENABLE_TRICKLE_TIMER_SUPPRESSION_SUPPORT
|
||||
uint32_t aRedundancyConstant,
|
||||
#endif
|
||||
Handler aTransmitHandler, Handler aIntervalExpiredHandler, void *aContext)
|
||||
:
|
||||
Timer(aScheduler, HandleTimerFired, aContext),
|
||||
TimerMilli(aIp6, HandleTimerFired, aContext),
|
||||
#ifdef ENABLE_TRICKLE_TIMER_SUPPRESSION_SUPPORT
|
||||
k(aRedundancyConstant),
|
||||
c(0),
|
||||
@@ -97,7 +97,7 @@ void TrickleTimer::Start(uint32_t aIntervalMin, uint32_t aIntervalMax, Mode aMod
|
||||
void TrickleTimer::Stop(void)
|
||||
{
|
||||
mPhase = kPhaseDormant;
|
||||
Timer::Stop();
|
||||
TimerMilli::Stop();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_TRICKLE_TIMER_SUPPRESSION_SUPPORT
|
||||
@@ -117,7 +117,7 @@ void TrickleTimer::IndicateInconsistent(void)
|
||||
I = Imin;
|
||||
|
||||
// Stop the existing timer
|
||||
Timer::Stop();
|
||||
TimerMilli::Stop();
|
||||
|
||||
// Start a new interval
|
||||
StartNewInterval();
|
||||
@@ -156,7 +156,7 @@ void TrickleTimer::StartNewInterval(void)
|
||||
}
|
||||
|
||||
// Start the timer for 't' milliseconds from now
|
||||
Timer::Start(t);
|
||||
TimerMilli::Start(t);
|
||||
}
|
||||
|
||||
void TrickleTimer::HandleTimerFired(Timer &aTimer)
|
||||
@@ -204,7 +204,7 @@ void TrickleTimer::HandleTimerFired(void)
|
||||
mPhase = kPhaseInterval;
|
||||
|
||||
// Start the time for 'I - t' milliseconds
|
||||
Timer::Start(I - t);
|
||||
TimerMilli::Start(I - t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace ot {
|
||||
* This class implements a trickle timer.
|
||||
*
|
||||
*/
|
||||
class TrickleTimer: public Timer
|
||||
class TrickleTimer: public TimerMilli
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -80,14 +80,14 @@ public:
|
||||
/**
|
||||
* This constructor creates a trickle timer instance.
|
||||
*
|
||||
* @param[in] aScheduler A reference to the timer scheduler.
|
||||
* @param[in] aIp6 A reference to the IPv6 network object.
|
||||
* @param[in] aRedundancyConstant The redundancy constant for the timer, k.
|
||||
* @param[in] aTransmitHandler A pointer to a function that is called when transmission should occur.
|
||||
* @param[in] aIntervalExpiredHandler An optional pointer to a function that is called when the interval expires.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*
|
||||
*/
|
||||
TrickleTimer(TimerScheduler &aScheduler,
|
||||
TrickleTimer(Ip6::Ip6 &aIp6,
|
||||
#ifdef ENABLE_TRICKLE_TIMER_SUPPRESSION_SUPPORT
|
||||
uint32_t aRedundancyConstant,
|
||||
#endif
|
||||
|
||||
+7
-15
@@ -40,7 +40,6 @@
|
||||
#include "utils/wrap_string.h"
|
||||
|
||||
#include <openthread/platform/random.h>
|
||||
#include <openthread/platform/usec-alarm.h>
|
||||
|
||||
#include "openthread-instance.h"
|
||||
#include "common/code_utils.hpp"
|
||||
@@ -98,21 +97,19 @@ void Mac::StartCsmaBackoff(void)
|
||||
backoff = (otPlatRandomGet() % (1UL << backoffExponent));
|
||||
backoff *= (static_cast<uint32_t>(kUnitBackoffPeriod) * OT_RADIO_SYMBOL_TIME);
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_BACKOFF_TIMER
|
||||
otPlatUsecAlarmStartAt(GetInstance(), otPlatUsecAlarmGetNow(), backoff, &Mac::HandleBeginTransmit, this);
|
||||
#else // OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_BACKOFF_TIMER
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
mBackoffTimer.Start(backoff);
|
||||
#else // OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
mBackoffTimer.Start(backoff / 1000UL);
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_BACKOFF_TIMER
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
}
|
||||
}
|
||||
|
||||
Mac::Mac(ThreadNetif &aThreadNetif):
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
mMacTimer(aThreadNetif.GetIp6().mTimerScheduler, &Mac::HandleMacTimer, this),
|
||||
#if !OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_BACKOFF_TIMER
|
||||
mBackoffTimer(aThreadNetif.GetIp6().mTimerScheduler, &Mac::HandleBeginTransmit, this),
|
||||
#endif
|
||||
mReceiveTimer(aThreadNetif.GetIp6().mTimerScheduler, &Mac::HandleReceiveTimer, this),
|
||||
mMacTimer(aThreadNetif.GetIp6(), &Mac::HandleMacTimer, this),
|
||||
mBackoffTimer(aThreadNetif.GetIp6(), &Mac::HandleBeginTransmit, this),
|
||||
mReceiveTimer(aThreadNetif.GetIp6(), &Mac::HandleReceiveTimer, this),
|
||||
mShortAddress(kShortAddrInvalid),
|
||||
mPanId(kPanIdBroadcast),
|
||||
mChannel(OPENTHREAD_CONFIG_DEFAULT_CHANNEL),
|
||||
@@ -771,11 +768,6 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void Mac::HandleBeginTransmit(void *aContext)
|
||||
{
|
||||
static_cast<Mac *>(aContext)->HandleBeginTransmit();
|
||||
}
|
||||
|
||||
void Mac::HandleBeginTransmit(Timer &aTimer)
|
||||
{
|
||||
GetOwner(aTimer).HandleBeginTransmit();
|
||||
|
||||
@@ -674,7 +674,6 @@ private:
|
||||
|
||||
static void HandleMacTimer(Timer &aTimer);
|
||||
void HandleMacTimer(void);
|
||||
static void HandleBeginTransmit(void *aContext);
|
||||
static void HandleBeginTransmit(Timer &aTimer);
|
||||
void HandleBeginTransmit(void);
|
||||
static void HandleReceiveTimer(Timer &aTimer);
|
||||
@@ -691,11 +690,13 @@ private:
|
||||
|
||||
static Mac &GetOwner(const Context &aContext);
|
||||
|
||||
Timer mMacTimer;
|
||||
#if !OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_BACKOFF_TIMER
|
||||
Timer mBackoffTimer;
|
||||
TimerMilli mMacTimer;
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
TimerMicro mBackoffTimer;
|
||||
#else
|
||||
TimerMilli mBackoffTimer;
|
||||
#endif
|
||||
Timer mReceiveTimer;
|
||||
TimerMilli mReceiveTimer;
|
||||
|
||||
ExtAddress mExtAddress;
|
||||
ShortAddress mShortAddress;
|
||||
|
||||
@@ -70,8 +70,8 @@ Commissioner::Commissioner(ThreadNetif &aThreadNetif):
|
||||
mState(OT_COMMISSIONER_STATE_DISABLED),
|
||||
mJoinerPort(0),
|
||||
mJoinerRloc(0),
|
||||
mJoinerExpirationTimer(aThreadNetif.GetIp6().mTimerScheduler, HandleJoinerExpirationTimer, this),
|
||||
mTimer(aThreadNetif.GetIp6().mTimerScheduler, HandleTimer, this),
|
||||
mJoinerExpirationTimer(aThreadNetif.GetIp6(), HandleJoinerExpirationTimer, this),
|
||||
mTimer(aThreadNetif.GetIp6(), HandleTimer, this),
|
||||
mSessionId(0),
|
||||
mTransmitAttempts(0),
|
||||
mRelayReceive(OT_URI_PATH_RELAY_RX, &Commissioner::HandleRelayReceive, this),
|
||||
@@ -232,7 +232,7 @@ otError Commissioner::AddJoiner(const Mac::ExtAddress *aExtAddress, const char *
|
||||
|
||||
(void)strlcpy(mJoiners[i].mPsk, aPSKd, sizeof(mJoiners[i].mPsk));
|
||||
mJoiners[i].mValid = true;
|
||||
mJoiners[i].mExpirationTime = Timer::GetNow() + Timer::SecToMsec(aTimeout);
|
||||
mJoiners[i].mExpirationTime = TimerMilli::GetNow() + TimerMilli::SecToMsec(aTimeout);
|
||||
|
||||
UpdateJoinerExpirationTimer();
|
||||
|
||||
@@ -275,12 +275,12 @@ otError Commissioner::RemoveJoiner(const Mac::ExtAddress *aExtAddress, uint32_t
|
||||
|
||||
if (aDelay > 0)
|
||||
{
|
||||
uint32_t now = Timer::GetNow();
|
||||
uint32_t now = TimerMilli::GetNow();
|
||||
|
||||
if ((static_cast<int32_t>(mJoiners[i].mExpirationTime - now) > 0) &&
|
||||
(static_cast<uint32_t>(mJoiners[i].mExpirationTime - now) > Timer::SecToMsec(aDelay)))
|
||||
(static_cast<uint32_t>(mJoiners[i].mExpirationTime - now) > TimerMilli::SecToMsec(aDelay)))
|
||||
{
|
||||
mJoiners[i].mExpirationTime = now + Timer::SecToMsec(aDelay);
|
||||
mJoiners[i].mExpirationTime = now + TimerMilli::SecToMsec(aDelay);
|
||||
UpdateJoinerExpirationTimer();
|
||||
}
|
||||
}
|
||||
@@ -343,7 +343,7 @@ void Commissioner::HandleJoinerExpirationTimer(Timer &aTimer)
|
||||
|
||||
void Commissioner::HandleJoinerExpirationTimer(void)
|
||||
{
|
||||
uint32_t now = Timer::GetNow();
|
||||
uint32_t now = TimerMilli::GetNow();
|
||||
|
||||
// Remove Joiners.
|
||||
for (size_t i = 0; i < sizeof(mJoiners) / sizeof(mJoiners[0]); i++)
|
||||
@@ -365,7 +365,7 @@ void Commissioner::HandleJoinerExpirationTimer(void)
|
||||
|
||||
void Commissioner::UpdateJoinerExpirationTimer(void)
|
||||
{
|
||||
uint32_t now = Timer::GetNow();
|
||||
uint32_t now = TimerMilli::GetNow();
|
||||
uint32_t nextTimeout = 0xffffffff;
|
||||
|
||||
// Check if timer should be set for next Joiner.
|
||||
@@ -655,7 +655,7 @@ void Commissioner::HandleLeaderPetitionResponse(Coap::Header *aHeader, Message *
|
||||
mState = OT_COMMISSIONER_STATE_ACTIVE;
|
||||
|
||||
mTransmitAttempts = 0;
|
||||
mTimer.Start(Timer::SecToMsec(kKeepAliveTimeout) / 2);
|
||||
mTimer.Start(TimerMilli::SecToMsec(kKeepAliveTimeout) / 2);
|
||||
|
||||
exit:
|
||||
|
||||
@@ -667,7 +667,7 @@ exit:
|
||||
}
|
||||
else
|
||||
{
|
||||
mTimer.Start(Timer::SecToMsec(kPetitionRetryDelay));
|
||||
mTimer.Start(TimerMilli::SecToMsec(kPetitionRetryDelay));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -748,7 +748,7 @@ void Commissioner::HandleLeaderKeepAliveResponse(Coap::Header *aHeader, Message
|
||||
|
||||
VerifyOrExit(state.GetState() == StateTlv::kAccept, mState = OT_COMMISSIONER_STATE_DISABLED);
|
||||
|
||||
mTimer.Start(Timer::SecToMsec(kKeepAliveTimeout) / 2);
|
||||
mTimer.Start(TimerMilli::SecToMsec(kKeepAliveTimeout) / 2);
|
||||
|
||||
exit:
|
||||
|
||||
|
||||
@@ -279,9 +279,9 @@ private:
|
||||
};
|
||||
uint16_t mJoinerPort;
|
||||
uint16_t mJoinerRloc;
|
||||
Timer mJoinerExpirationTimer;
|
||||
TimerMilli mJoinerExpirationTimer;
|
||||
|
||||
Timer mTimer;
|
||||
TimerMilli mTimer;
|
||||
uint16_t mSessionId;
|
||||
uint8_t mTransmitAttempts;
|
||||
|
||||
|
||||
@@ -358,7 +358,7 @@ otError Dataset::Set(const otOperationalDataset &aDataset)
|
||||
Set(tlv);
|
||||
}
|
||||
|
||||
mUpdateTime = Timer::GetNow();
|
||||
mUpdateTime = TimerMilli::GetNow();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -427,7 +427,7 @@ otError Dataset::Set(const Tlv &aTlv)
|
||||
memcpy(mTlvs + mLength, &aTlv, sizeof(Tlv) + aTlv.GetLength());
|
||||
mLength += sizeof(Tlv) + aTlv.GetLength();
|
||||
|
||||
mUpdateTime = Timer::GetNow();
|
||||
mUpdateTime = TimerMilli::GetNow();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -440,7 +440,7 @@ otError Dataset::Set(const Message &aMessage, uint16_t aOffset, uint8_t aLength)
|
||||
VerifyOrExit(aLength == aMessage.Read(aOffset, aLength, mTlvs), error = OT_ERROR_INVALID_ARGS);
|
||||
mLength = aLength;
|
||||
|
||||
mUpdateTime = Timer::GetNow();
|
||||
mUpdateTime = TimerMilli::GetNow();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -481,7 +481,7 @@ otError Dataset::AppendMleDatasetTlv(Message &aMessage) const
|
||||
}
|
||||
else if (cur->GetType() == Tlv::kDelayTimer)
|
||||
{
|
||||
uint32_t elapsed = Timer::GetNow() - mUpdateTime;
|
||||
uint32_t elapsed = TimerMilli::GetNow() - mUpdateTime;
|
||||
DelayTimerTlv delayTimer;
|
||||
|
||||
memcpy(&delayTimer, cur, sizeof(delayTimer));
|
||||
|
||||
@@ -82,7 +82,7 @@ otError DatasetLocal::Get(Dataset &aDataset)
|
||||
delayTimer = static_cast<DelayTimerTlv *>(aDataset.Get(Tlv::kDelayTimer));
|
||||
VerifyOrExit(delayTimer);
|
||||
|
||||
elapsed = Timer::GetNow() - mUpdateTime;
|
||||
elapsed = TimerMilli::GetNow() - mUpdateTime;
|
||||
|
||||
if (delayTimer->GetDelayTimer() > elapsed)
|
||||
{
|
||||
@@ -93,7 +93,7 @@ otError DatasetLocal::Get(Dataset &aDataset)
|
||||
delayTimer->SetDelayTimer(0);
|
||||
}
|
||||
|
||||
aDataset.mUpdateTime = Timer::GetNow();
|
||||
aDataset.mUpdateTime = TimerMilli::GetNow();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -396,7 +396,7 @@ otError DatasetLocal::Set(const Dataset &aDataset)
|
||||
|
||||
SuccessOrExit(error);
|
||||
|
||||
mUpdateTime = Timer::GetNow();
|
||||
mUpdateTime = TimerMilli::GetNow();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
@@ -66,7 +66,7 @@ DatasetManager::DatasetManager(ThreadNetif &aThreadNetif, const Tlv::Type aType,
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
mLocal(aThreadNetif.GetInstance(), aType),
|
||||
mNetwork(aType),
|
||||
mTimer(aThreadNetif.GetIp6().mTimerScheduler, aTimerHander, this),
|
||||
mTimer(aThreadNetif.GetIp6(), aTimerHander, this),
|
||||
mUriSet(aUriSet),
|
||||
mUriGet(aUriGet)
|
||||
{
|
||||
@@ -1022,7 +1022,7 @@ static PendingDatasetBase &GetPendingDatasetOwner(const Context &aContext)
|
||||
PendingDatasetBase::PendingDatasetBase(ThreadNetif &aThreadNetif):
|
||||
DatasetManager(aThreadNetif, Tlv::kPendingTimestamp, OT_URI_PATH_PENDING_SET, OT_URI_PATH_PENDING_GET,
|
||||
&PendingDatasetBase::HandleTimer),
|
||||
mDelayTimer(aThreadNetif.GetIp6().mTimerScheduler, &PendingDatasetBase::HandleDelayTimer, this),
|
||||
mDelayTimer(aThreadNetif.GetIp6(), &PendingDatasetBase::HandleDelayTimer, this),
|
||||
mResourceGet(OT_URI_PATH_PENDING_GET, &PendingDatasetBase::HandleGet, this)
|
||||
{
|
||||
aThreadNetif.GetCoap().AddResource(mResourceGet);
|
||||
|
||||
@@ -131,7 +131,7 @@ protected:
|
||||
*
|
||||
*/
|
||||
DatasetManager(ThreadNetif &aThreadNetif, const Tlv::Type aType, const char *aUriSet, const char *aUriGet,
|
||||
Timer::Handler aTimerHander);
|
||||
TimerMilli::Handler aTimerHander);
|
||||
|
||||
/**
|
||||
* This method restores the Operational Dataset from non-volatile memory.
|
||||
@@ -213,7 +213,7 @@ private:
|
||||
void SendGetResponse(const Coap::Header &aRequestHeader, const Ip6::MessageInfo &aMessageInfo,
|
||||
uint8_t *aTlvs, uint8_t aLength) const;
|
||||
|
||||
Timer mTimer;
|
||||
TimerMilli mTimer;
|
||||
|
||||
const char *mUriSet;
|
||||
const char *mUriGet;
|
||||
@@ -442,7 +442,7 @@ protected:
|
||||
void StartDelayTimer(void);
|
||||
void HandleNetworkUpdate(void);
|
||||
|
||||
Timer mDelayTimer;
|
||||
TimerMilli mDelayTimer;
|
||||
|
||||
private:
|
||||
static void HandleGet(void *aContext, otCoapHeader *aHeader, otMessage *aMessage,
|
||||
|
||||
@@ -57,7 +57,7 @@ Dtls::Dtls(ThreadNetif &aNetif):
|
||||
ThreadNetifLocator(aNetif),
|
||||
mPskLength(0),
|
||||
mStarted(false),
|
||||
mTimer(aNetif.GetIp6().mTimerScheduler, &Dtls::HandleTimer, this),
|
||||
mTimer(aNetif.GetIp6(), &Dtls::HandleTimer, this),
|
||||
mTimerIntermediate(0),
|
||||
mTimerSet(false),
|
||||
mReceiveMessage(NULL),
|
||||
@@ -311,7 +311,7 @@ int Dtls::HandleMbedtlsGetTimer(void)
|
||||
{
|
||||
rval = 2;
|
||||
}
|
||||
else if (static_cast<int32_t>(mTimerIntermediate - Timer::GetNow()) <= 0)
|
||||
else if (static_cast<int32_t>(mTimerIntermediate - TimerMilli::GetNow()) <= 0)
|
||||
{
|
||||
rval = 1;
|
||||
}
|
||||
@@ -341,7 +341,7 @@ void Dtls::HandleMbedtlsSetTimer(uint32_t aIntermediate, uint32_t aFinish)
|
||||
{
|
||||
mTimerSet = true;
|
||||
mTimer.Start(aFinish);
|
||||
mTimerIntermediate = Timer::GetNow() + aIntermediate;
|
||||
mTimerIntermediate = TimerMilli::GetNow() + aIntermediate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ private:
|
||||
mbedtls_ssl_cookie_ctx mCookieCtx;
|
||||
bool mStarted;
|
||||
|
||||
Timer mTimer;
|
||||
TimerMilli mTimer;
|
||||
uint32_t mTimerIntermediate;
|
||||
bool mTimerSet;
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ Joiner::Joiner(ThreadNetif &aNetif):
|
||||
mVendorModel(NULL),
|
||||
mVendorSwVersion(NULL),
|
||||
mVendorData(NULL),
|
||||
mTimer(aNetif.GetIp6().mTimerScheduler, &Joiner::HandleTimer, this),
|
||||
mTimer(aNetif.GetIp6(), &Joiner::HandleTimer, this),
|
||||
mJoinerEntrust(OT_URI_PATH_JOINER_ENTRUST, &Joiner::HandleJoinerEntrust, this)
|
||||
{
|
||||
aNetif.GetCoap().AddResource(mJoinerEntrust);
|
||||
|
||||
@@ -150,7 +150,7 @@ private:
|
||||
const char *mVendorSwVersion;
|
||||
const char *mVendorData;
|
||||
|
||||
Timer mTimer;
|
||||
TimerMilli mTimer;
|
||||
Coap::Resource mJoinerEntrust;
|
||||
};
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ JoinerRouter::JoinerRouter(ThreadNetif &aNetif):
|
||||
ThreadNetifLocator(aNetif),
|
||||
mSocket(aNetif.GetIp6().mUdp),
|
||||
mRelayTransmit(OT_URI_PATH_RELAY_TX, &JoinerRouter::HandleRelayTransmit, this),
|
||||
mTimer(aNetif.GetIp6().mTimerScheduler, &JoinerRouter::HandleTimer, this),
|
||||
mTimer(aNetif.GetIp6(), &JoinerRouter::HandleTimer, this),
|
||||
mJoinerUdpPort(0),
|
||||
mIsJoinerPortConfigured(false),
|
||||
mExpectJoinEntRsp(false)
|
||||
@@ -407,7 +407,7 @@ otError JoinerRouter::DelaySendingJoinerEntrust(const Ip6::MessageInfo &aMessage
|
||||
messageInfo = aMessageInfo;
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
|
||||
delayedMessage = DelayedJoinEntHeader(Timer::GetNow() + kDelayJoinEnt, messageInfo, aKek.GetKek());
|
||||
delayedMessage = DelayedJoinEntHeader(TimerMilli::GetNow() + kDelayJoinEnt, messageInfo, aKek.GetKek());
|
||||
SuccessOrExit(delayedMessage.AppendTo(*message));
|
||||
mDelayedJoinEnts.Enqueue(*message);
|
||||
|
||||
@@ -442,7 +442,7 @@ void JoinerRouter::SendDelayedJoinerEntrust(void)
|
||||
ThreadNetif &netif = GetNetif();
|
||||
DelayedJoinEntHeader delayedJoinEnt;
|
||||
Message *message = mDelayedJoinEnts.GetHead();
|
||||
uint32_t now = Timer::GetNow();
|
||||
uint32_t now = TimerMilli::GetNow();
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
VerifyOrExit(message != NULL);
|
||||
|
||||
@@ -118,7 +118,7 @@ private:
|
||||
Ip6::UdpSocket mSocket;
|
||||
Coap::Resource mRelayTransmit;
|
||||
|
||||
Timer mTimer;
|
||||
TimerMilli mTimer;
|
||||
MessageQueue mDelayedJoinEnts;
|
||||
|
||||
uint16_t mJoinerUdpPort;
|
||||
|
||||
@@ -60,7 +60,7 @@ Leader::Leader(ThreadNetif &aThreadNetif):
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
mPetition(OT_URI_PATH_LEADER_PETITION, Leader::HandlePetition, this),
|
||||
mKeepAlive(OT_URI_PATH_LEADER_KEEP_ALIVE, Leader::HandleKeepAlive, this),
|
||||
mTimer(aThreadNetif.GetIp6().mTimerScheduler, HandleTimer, this),
|
||||
mTimer(aThreadNetif.GetIp6(), HandleTimer, this),
|
||||
mDelayTimerMinimal(DelayTimerTlv::kDelayTimerMinimal),
|
||||
mSessionId(0xffff)
|
||||
{
|
||||
@@ -111,7 +111,7 @@ void Leader::HandlePetition(Coap::Header &aHeader, Message &aMessage, const Ip6:
|
||||
mCommissionerId = commissionerId;
|
||||
|
||||
state = StateTlv::kAccept;
|
||||
mTimer.Start(Timer::SecToMsec(kTimeoutLeaderPetition));
|
||||
mTimer.Start(TimerMilli::SecToMsec(kTimeoutLeaderPetition));
|
||||
|
||||
exit:
|
||||
OT_UNUSED_VARIABLE(aMessageInfo);
|
||||
@@ -198,7 +198,7 @@ void Leader::HandleKeepAlive(Coap::Header &aHeader, Message &aMessage, const Ip6
|
||||
else
|
||||
{
|
||||
responseState = StateTlv::kAccept;
|
||||
mTimer.Start(Timer::SecToMsec(kTimeoutLeaderPetition));
|
||||
mTimer.Start(TimerMilli::SecToMsec(kTimeoutLeaderPetition));
|
||||
}
|
||||
|
||||
SendKeepAliveResponse(aHeader, aMessageInfo, responseState);
|
||||
|
||||
@@ -135,7 +135,7 @@ private:
|
||||
|
||||
Coap::Resource mPetition;
|
||||
Coap::Resource mKeepAlive;
|
||||
Timer mTimer;
|
||||
TimerMilli mTimer;
|
||||
|
||||
uint32_t mDelayTimerMinimal;
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Dhcp6 {
|
||||
|
||||
Dhcp6Client::Dhcp6Client(ThreadNetif &aThreadNetif) :
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
mTrickleTimer(aThreadNetif.GetIp6().mTimerScheduler, &Dhcp6Client::HandleTrickleTimer, NULL, this),
|
||||
mTrickleTimer(aThreadNetif.GetIp6(), &Dhcp6Client::HandleTrickleTimer, NULL, this),
|
||||
mSocket(aThreadNetif.GetIp6().mUdp),
|
||||
mStartTime(0),
|
||||
mAddresses(NULL),
|
||||
@@ -318,8 +318,8 @@ bool Dhcp6Client::ProcessNextIdentityAssociation()
|
||||
}
|
||||
|
||||
mTrickleTimer.Start(
|
||||
Timer::SecToMsec(kTrickleTimerImin),
|
||||
Timer::SecToMsec(kTrickleTimerImax),
|
||||
TimerMilli::SecToMsec(kTrickleTimerImin),
|
||||
TimerMilli::SecToMsec(kTrickleTimerImax),
|
||||
TrickleTimer::kModeNormal);
|
||||
|
||||
mTrickleTimer.IndicateInconsistent();
|
||||
@@ -345,7 +345,7 @@ bool Dhcp6Client::HandleTrickleTimer(void)
|
||||
switch (mIdentityAssociationHead->GetStatus())
|
||||
{
|
||||
case IdentityAssociation::kStatusSolicit:
|
||||
mStartTime = otPlatAlarmGetNow();
|
||||
mStartTime = TimerMilli::GetNow();
|
||||
mIdentityAssociationHead->SetStatus(IdentityAssociation::kStatusSoliciting);
|
||||
|
||||
// fall through
|
||||
@@ -427,7 +427,7 @@ otError Dhcp6Client::AppendElapsedTime(Message &aMessage)
|
||||
ElapsedTime option;
|
||||
|
||||
option.Init();
|
||||
option.SetElapsedTime(static_cast<uint16_t>(Timer::MsecToSec(otPlatAlarmGetNow() - mStartTime)));
|
||||
option.SetElapsedTime(static_cast<uint16_t>(TimerMilli::MsecToSec(TimerMilli::GetNow() - mStartTime)));
|
||||
return aMessage.Append(&option, sizeof(option));
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ otError Client::Query(const otDnsQuery *aQuery, otDnsResponseHandler aHandler, v
|
||||
messageInfo = static_cast<const Ip6::MessageInfo *>(aQuery->mMessageInfo);
|
||||
|
||||
queryMetadata.mHostname = aQuery->mHostname;
|
||||
queryMetadata.mTransmissionTime = Timer::GetNow() + kResponseTimeout;
|
||||
queryMetadata.mTransmissionTime = TimerMilli::GetNow() + kResponseTimeout;
|
||||
queryMetadata.mSourceAddress = messageInfo->GetSockAddr();
|
||||
queryMetadata.mDestinationPort = messageInfo->GetPeerPort();
|
||||
queryMetadata.mDestinationAddress = messageInfo->GetPeerAddr();
|
||||
@@ -155,7 +155,7 @@ exit:
|
||||
Message *Client::CopyAndEnqueueMessage(const Message &aMessage, const QueryMetadata &aQueryMetadata)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint32_t now = Timer::GetNow();
|
||||
uint32_t now = TimerMilli::GetNow();
|
||||
Message *messageCopy = NULL;
|
||||
uint32_t nextTransmissionTime;
|
||||
|
||||
@@ -389,7 +389,7 @@ void Client::HandleRetransmissionTimer(Timer &aTimer)
|
||||
|
||||
void Client::HandleRetransmissionTimer(void)
|
||||
{
|
||||
uint32_t now = Timer::GetNow();
|
||||
uint32_t now = TimerMilli::GetNow();
|
||||
uint32_t nextDelta = 0xffffffff;
|
||||
QueryMetadata queryMetadata;
|
||||
Message *message = mPendingQueries.GetHead();
|
||||
|
||||
@@ -159,7 +159,7 @@ public:
|
||||
Client(Ip6::Netif &aNetif):
|
||||
mSocket(aNetif.GetIp6().mUdp),
|
||||
mMessageId(0),
|
||||
mRetransmissionTimer(aNetif.GetIp6().mTimerScheduler, &Client::HandleRetransmissionTimer, this) {
|
||||
mRetransmissionTimer(aNetif.GetIp6(), &Client::HandleRetransmissionTimer, this) {
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -256,7 +256,7 @@ private:
|
||||
|
||||
uint16_t mMessageId;
|
||||
MessageQueue mPendingQueries;
|
||||
Timer mRetransmissionTimer;
|
||||
TimerMilli mRetransmissionTimer;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
|
||||
@@ -58,6 +58,10 @@ Ip6::Ip6(void):
|
||||
mUdp(*this),
|
||||
mMpl(*this),
|
||||
mMessagePool(GetInstance()),
|
||||
mTimerMilliScheduler(*this),
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
mTimerMicroScheduler(*this),
|
||||
#endif
|
||||
mForwardingEnabled(false),
|
||||
mSendQueueTask(mTaskletScheduler, HandleSendQueue, this),
|
||||
mReceiveIp6DatagramCallback(NULL),
|
||||
|
||||
@@ -374,7 +374,10 @@ public:
|
||||
|
||||
MessagePool mMessagePool;
|
||||
TaskletScheduler mTaskletScheduler;
|
||||
TimerScheduler mTimerScheduler;
|
||||
TimerMilliScheduler mTimerMilliScheduler;
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
TimerMicroScheduler mTimerMicroScheduler;
|
||||
#endif
|
||||
|
||||
private:
|
||||
static void HandleSendQueue(Tasklet &aTasklet);
|
||||
@@ -412,11 +415,6 @@ static inline Ip6 *Ip6FromTaskletScheduler(TaskletScheduler *aTaskletScheduler)
|
||||
return (Ip6 *)CONTAINING_RECORD(aTaskletScheduler, Ip6, mTaskletScheduler);
|
||||
}
|
||||
|
||||
static inline Ip6 *Ip6FromTimerScheduler(TimerScheduler *aTimerScheduler)
|
||||
{
|
||||
return (Ip6 *)CONTAINING_RECORD(aTimerScheduler, Ip6, mTimerScheduler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
|
||||
@@ -57,8 +57,8 @@ void MplBufferedMessageMetadata::GenerateNextTransmissionTime(uint32_t aCurrentT
|
||||
|
||||
Mpl::Mpl(Ip6 &aIp6):
|
||||
Ip6Locator(aIp6),
|
||||
mSeedSetTimer(aIp6.mTimerScheduler, &Mpl::HandleSeedSetTimer, this),
|
||||
mRetransmissionTimer(aIp6.mTimerScheduler, &Mpl::HandleRetransmissionTimer, this),
|
||||
mSeedSetTimer(aIp6, &Mpl::HandleSeedSetTimer, this),
|
||||
mRetransmissionTimer(aIp6, &Mpl::HandleRetransmissionTimer, this),
|
||||
mTimerExpirations(0),
|
||||
mSequence(0),
|
||||
mSeedId(0),
|
||||
@@ -164,7 +164,7 @@ exit:
|
||||
|
||||
void Mpl::AddBufferedMessage(Message &aMessage, uint16_t aSeedId, uint8_t aSequence, bool aIsOutbound)
|
||||
{
|
||||
uint32_t now = Timer::GetNow();
|
||||
uint32_t now = TimerMilli::GetNow();
|
||||
otError error = OT_ERROR_NONE;
|
||||
Message *messageCopy = NULL;
|
||||
MplBufferedMessageMetadata messageMetadata;
|
||||
@@ -258,7 +258,7 @@ void Mpl::HandleRetransmissionTimer(Timer &aTimer)
|
||||
|
||||
void Mpl::HandleRetransmissionTimer(void)
|
||||
{
|
||||
uint32_t now = Timer::GetNow();
|
||||
uint32_t now = TimerMilli::GetNow();
|
||||
uint32_t nextDelta = 0xffffffff;
|
||||
MplBufferedMessageMetadata messageMetadata;
|
||||
|
||||
|
||||
@@ -535,8 +535,8 @@ private:
|
||||
|
||||
static Mpl &GetOwner(const Context &aContext);
|
||||
|
||||
Timer mSeedSetTimer;
|
||||
Timer mRetransmissionTimer;
|
||||
TimerMilli mSeedSetTimer;
|
||||
TimerMilli mRetransmissionTimer;
|
||||
|
||||
uint8_t mTimerExpirations;
|
||||
uint8_t mSequence;
|
||||
|
||||
@@ -735,13 +735,13 @@
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_BACKOFF_TIMER
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
*
|
||||
* Define to 1 if you want to enable microsecond backoff timer implemented in platform.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_BACKOFF_TIMER
|
||||
#define OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_BACKOFF_TIMER 0
|
||||
#ifndef OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
#define OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,7 +48,6 @@ namespace ot {
|
||||
|
||||
class ThreadNetif;
|
||||
class MeshForwarder;
|
||||
class TimerScheduler;
|
||||
class TaskletScheduler;
|
||||
namespace Ip6 { class Ip6; }
|
||||
|
||||
@@ -79,14 +78,6 @@ ot::ThreadNetif &otGetThreadNetif(void);
|
||||
*/
|
||||
ot::MeshForwarder &otGetMeshForwarder(void);
|
||||
|
||||
/**
|
||||
* This function returns a reference to the single TimerScheduler instance.
|
||||
*
|
||||
* @returns A reference to the TimerScheduler instance.
|
||||
*
|
||||
*/
|
||||
ot::TimerScheduler &otGetTimerScheduler(void);
|
||||
|
||||
/**
|
||||
* This function returns a reference to the single TaskletShceduler instance.
|
||||
*
|
||||
|
||||
@@ -64,7 +64,7 @@ AddressResolver::AddressResolver(ThreadNetif &aThreadNetif) :
|
||||
mAddressQuery(OT_URI_PATH_ADDRESS_QUERY, &AddressResolver::HandleAddressQuery, this),
|
||||
mAddressNotification(OT_URI_PATH_ADDRESS_NOTIFY, &AddressResolver::HandleAddressNotification, this),
|
||||
mIcmpHandler(&AddressResolver::HandleIcmpReceive, this),
|
||||
mTimer(aThreadNetif.GetIp6().mTimerScheduler, &AddressResolver::HandleTimer, this)
|
||||
mTimer(aThreadNetif.GetIp6(), &AddressResolver::HandleTimer, this)
|
||||
{
|
||||
Clear();
|
||||
|
||||
@@ -557,7 +557,7 @@ void AddressResolver::HandleAddressQuery(Coap::Header &aHeader, Message &aMessag
|
||||
}
|
||||
|
||||
mlIidTlv.SetIid(children[i].GetExtAddress());
|
||||
lastTransactionTimeTlv.SetTime(Timer::GetNow() - children[i].GetLastHeard());
|
||||
lastTransactionTimeTlv.SetTime(TimerMilli::GetNow() - children[i].GetLastHeard());
|
||||
SendAddressQueryResponse(targetTlv, mlIidTlv, &lastTransactionTimeTlv, aMessageInfo.GetPeerAddr());
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ private:
|
||||
Coap::Resource mAddressNotification;
|
||||
Cache mCache[kCacheEntries];
|
||||
Ip6::IcmpHandler mIcmpHandler;
|
||||
Timer mTimer;
|
||||
TimerMilli mTimer;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,7 +58,7 @@ AnnounceBeginServer::AnnounceBeginServer(ThreadNetif &aThreadNetif) :
|
||||
mPeriod(0),
|
||||
mCount(0),
|
||||
mChannel(0),
|
||||
mTimer(aThreadNetif.GetIp6().mTimerScheduler, &AnnounceBeginServer::HandleTimer, this),
|
||||
mTimer(aThreadNetif.GetIp6(), &AnnounceBeginServer::HandleTimer, this),
|
||||
mAnnounceBegin(OT_URI_PATH_ANNOUNCE_BEGIN, &AnnounceBeginServer::HandleRequest, this)
|
||||
{
|
||||
aThreadNetif.GetCoap().AddResource(mAnnounceBegin);
|
||||
|
||||
@@ -100,7 +100,7 @@ private:
|
||||
uint8_t mCount;
|
||||
uint8_t mChannel;
|
||||
|
||||
Timer mTimer;
|
||||
TimerMilli mTimer;
|
||||
|
||||
Coap::Resource mAnnounceBegin;
|
||||
};
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace ot {
|
||||
|
||||
DataPollManager::DataPollManager(MeshForwarder &aMeshForwarder):
|
||||
MeshForwarderLocator(aMeshForwarder),
|
||||
mTimer(aMeshForwarder.GetNetif().GetIp6().mTimerScheduler, &DataPollManager::HandlePollTimer, this),
|
||||
mTimer(aMeshForwarder.GetNetif().GetIp6(), &DataPollManager::HandlePollTimer, this),
|
||||
mTimerStartTime(0),
|
||||
mExternalPollPeriod(0),
|
||||
mPollPeriod(0),
|
||||
@@ -345,7 +345,7 @@ void DataPollManager::ScheduleNextPoll(PollPeriodSelector aPollPeriodSelector)
|
||||
}
|
||||
else
|
||||
{
|
||||
mTimerStartTime = Timer::GetNow();
|
||||
mTimerStartTime = TimerMilli::GetNow();
|
||||
mTimer.StartAt(mTimerStartTime, mPollPeriod);
|
||||
}
|
||||
}
|
||||
@@ -422,7 +422,7 @@ DataPollManager &DataPollManager::GetOwner(Context &aContext)
|
||||
|
||||
uint32_t DataPollManager::GetDefaultPollPeriod(void) const
|
||||
{
|
||||
return Timer::SecToMsec(GetMeshForwarder().GetNetif().GetMle().GetTimeout()) -
|
||||
return TimerMilli::SecToMsec(GetMeshForwarder().GetNetif().GetMle().GetTimeout()) -
|
||||
static_cast<uint32_t>(kRetxPollPeriod) * kMaxPollRetxAttempts;
|
||||
}
|
||||
|
||||
|
||||
@@ -221,18 +221,18 @@ private:
|
||||
static DataPollManager &GetOwner(Context &aContext);
|
||||
uint32_t GetDefaultPollPeriod(void) const;
|
||||
|
||||
Timer mTimer;
|
||||
uint32_t mTimerStartTime;
|
||||
uint32_t mExternalPollPeriod;
|
||||
uint32_t mPollPeriod;
|
||||
TimerMilli mTimer;
|
||||
uint32_t mTimerStartTime;
|
||||
uint32_t mExternalPollPeriod;
|
||||
uint32_t mPollPeriod;
|
||||
|
||||
bool mEnabled: 1; //< Indicates whether data polling is enabled/started.
|
||||
bool mAttachMode: 1; //< Indicates whether in attach mode (to use attach poll period).
|
||||
bool mRetxMode: 1; //< Indicates whether last poll tx failed at mac/radio layer (poll retx mode).
|
||||
bool mNoBufferRetxMode: 1; //< Indicates whether last poll tx failed due to insufficient buffer.
|
||||
uint8_t mPollTimeoutCounter: 4; //< Poll timeouts counter (0 to `kQuickPollsAfterTimout`).
|
||||
uint8_t mPollTxFailureCounter: 4; //< Poll tx failure counter (0 to `kMaxPollRetxAttempts`).
|
||||
uint8_t mRemainingFastPolls: 4; //< Number of remaining fast polls when in transient fast polling mode.
|
||||
bool mEnabled: 1; //< Indicates whether data polling is enabled/started.
|
||||
bool mAttachMode: 1; //< Indicates whether in attach mode (to use attach poll period).
|
||||
bool mRetxMode: 1; //< Indicates whether last poll tx failed at mac/radio layer (poll retx mode).
|
||||
bool mNoBufferRetxMode: 1; //< Indicates whether last poll tx failed due to insufficient buffer.
|
||||
uint8_t mPollTimeoutCounter: 4; //< Poll timeouts counter (0 to `kQuickPollsAfterTimout`).
|
||||
uint8_t mPollTxFailureCounter: 4; //< Poll tx failure counter (0 to `kMaxPollRetxAttempts`).
|
||||
uint8_t mRemainingFastPolls: 4; //< Number of remaining fast polls when in transient fast polling mode.
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,7 +59,7 @@ EnergyScanServer::EnergyScanServer(ThreadNetif &aThreadNetif) :
|
||||
mCount(0),
|
||||
mActive(false),
|
||||
mScanResultsLength(0),
|
||||
mTimer(aThreadNetif.GetIp6().mTimerScheduler, &EnergyScanServer::HandleTimer, this),
|
||||
mTimer(aThreadNetif.GetIp6(), &EnergyScanServer::HandleTimer, this),
|
||||
mEnergyScan(OT_URI_PATH_ENERGY_SCAN, &EnergyScanServer::HandleRequest, this)
|
||||
{
|
||||
mNetifCallback.Set(&EnergyScanServer::HandleNetifStateChanged, this);
|
||||
|
||||
@@ -99,7 +99,7 @@ private:
|
||||
int8_t mScanResults[OPENTHREAD_CONFIG_MAX_ENERGY_RESULTS];
|
||||
uint8_t mScanResultsLength;
|
||||
|
||||
Timer mTimer;
|
||||
TimerMilli mTimer;
|
||||
|
||||
Ip6::NetifCallback mNetifCallback;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ KeyManager::KeyManager(ThreadNetif &aThreadNetif):
|
||||
mKeyRotationTime(kDefaultKeyRotationTime),
|
||||
mKeySwitchGuardTime(kDefaultKeySwitchGuardTime),
|
||||
mKeySwitchGuardEnabled(false),
|
||||
mKeyRotationTimer(aThreadNetif.GetIp6().mTimerScheduler, &KeyManager::HandleKeyRotationTimer, this),
|
||||
mKeyRotationTimer(aThreadNetif.GetIp6(), &KeyManager::HandleKeyRotationTimer, this),
|
||||
mKekFrameCounter(0),
|
||||
mSecurityPolicyFlags(0xff)
|
||||
{
|
||||
|
||||
@@ -357,7 +357,7 @@ private:
|
||||
uint32_t mKeyRotationTime;
|
||||
uint32_t mKeySwitchGuardTime;
|
||||
bool mKeySwitchGuardEnabled;
|
||||
Timer mKeyRotationTimer;
|
||||
TimerMilli mKeyRotationTimer;
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
uint8_t mPSKc[kMaxKeyLength];
|
||||
|
||||
@@ -62,8 +62,8 @@ MeshForwarder::MeshForwarder(ThreadNetif &aThreadNetif):
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
mMacReceiver(&MeshForwarder::HandleReceivedFrame, &MeshForwarder::HandleDataPollTimeout, this),
|
||||
mMacSender(&MeshForwarder::HandleFrameRequest, &MeshForwarder::HandleSentFrame, this),
|
||||
mDiscoverTimer(aThreadNetif.GetIp6().mTimerScheduler, &MeshForwarder::HandleDiscoverTimer, this),
|
||||
mReassemblyTimer(aThreadNetif.GetIp6().mTimerScheduler, &MeshForwarder::HandleReassemblyTimer, this),
|
||||
mDiscoverTimer(aThreadNetif.GetIp6(), &MeshForwarder::HandleDiscoverTimer, this),
|
||||
mReassemblyTimer(aThreadNetif.GetIp6(), &MeshForwarder::HandleReassemblyTimer, this),
|
||||
mMessageNextOffset(0),
|
||||
mSendMessageFrameCounter(0),
|
||||
mSendMessage(NULL),
|
||||
@@ -2192,7 +2192,7 @@ void MeshForwarder::HandleDataRequest(const Mac::Address &aMacSource, const Thre
|
||||
VerifyOrExit(netif.GetMle().GetRole() != OT_DEVICE_ROLE_DETACHED);
|
||||
|
||||
VerifyOrExit((child = netif.GetMle().GetChild(aMacSource)) != NULL);
|
||||
child->SetLastHeard(Timer::GetNow());
|
||||
child->SetLastHeard(TimerMilli::GetNow());
|
||||
child->ResetLinkFailures();
|
||||
indirectMsgCount = child->GetIndirectMessageCount();
|
||||
|
||||
|
||||
@@ -296,8 +296,8 @@ private:
|
||||
|
||||
Mac::Receiver mMacReceiver;
|
||||
Mac::Sender mMacSender;
|
||||
Timer mDiscoverTimer;
|
||||
Timer mReassemblyTimer;
|
||||
TimerMilli mDiscoverTimer;
|
||||
TimerMilli mReassemblyTimer;
|
||||
|
||||
PriorityQueue mSendQueue;
|
||||
MessageQueue mReassemblyList;
|
||||
|
||||
@@ -71,8 +71,8 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
|
||||
mAssignLinkMargin(0),
|
||||
mParentRequestState(kParentIdle),
|
||||
mReattachState(kReattachStop),
|
||||
mParentRequestTimer(aThreadNetif.GetIp6().mTimerScheduler, &Mle::HandleParentRequestTimer, this),
|
||||
mDelayedResponseTimer(aThreadNetif.GetIp6().mTimerScheduler, &Mle::HandleDelayedResponseTimer, this),
|
||||
mParentRequestTimer(aThreadNetif.GetIp6(), &Mle::HandleParentRequestTimer, this),
|
||||
mDelayedResponseTimer(aThreadNetif.GetIp6(), &Mle::HandleDelayedResponseTimer, this),
|
||||
mLastPartitionRouterIdSequence(0),
|
||||
mLastPartitionId(0),
|
||||
mParentLeaderCost(0),
|
||||
@@ -591,7 +591,7 @@ otError Mle::SetStateChild(uint16_t aRloc16)
|
||||
|
||||
if ((mDeviceMode & ModeTlv::kModeRxOnWhenIdle) != 0)
|
||||
{
|
||||
mParentRequestTimer.Start(Timer::SecToMsec(mTimeout) -
|
||||
mParentRequestTimer.Start(TimerMilli::SecToMsec(mTimeout) -
|
||||
static_cast<uint32_t>(kUnicastRetransmissionDelay) * kMaxChildKeepAliveAttempts);
|
||||
}
|
||||
|
||||
@@ -1451,7 +1451,7 @@ void Mle::HandleDelayedResponseTimer(Timer &aTimer)
|
||||
void Mle::HandleDelayedResponseTimer(void)
|
||||
{
|
||||
DelayedResponseHeader delayedResponse;
|
||||
uint32_t now = otPlatAlarmGetNow();
|
||||
uint32_t now = TimerMilli::GetNow();
|
||||
uint32_t nextDelay = 0xffffffff;
|
||||
Message *message = mDelayedResponses.GetHead();
|
||||
Message *nextMessage = NULL;
|
||||
@@ -1978,7 +1978,7 @@ otError Mle::AddDelayedResponse(Message &aMessage, const Ip6::Address &aDestinat
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint32_t alarmFireTime;
|
||||
uint32_t sendTime = otPlatAlarmGetNow() + aDelay;
|
||||
uint32_t sendTime = TimerMilli::GetNow() + aDelay;
|
||||
|
||||
// Append the message with DelayedRespnoseHeader and add to the list.
|
||||
DelayedResponseHeader delayedResponse(sendTime, aDestination);
|
||||
@@ -2317,7 +2317,7 @@ otError Mle::HandleAdvertisement(const Message &aMessage, const Ip6::MessageInfo
|
||||
}
|
||||
|
||||
isNeighbor = true;
|
||||
mParent.SetLastHeard(Timer::GetNow());
|
||||
mParent.SetLastHeard(TimerMilli::GetNow());
|
||||
break;
|
||||
|
||||
case OT_DEVICE_ROLE_ROUTER:
|
||||
@@ -2987,7 +2987,7 @@ otError Mle::HandleChildUpdateResponse(const Message &aMessage, const Ip6::Messa
|
||||
}
|
||||
else
|
||||
{
|
||||
mParentRequestTimer.Start(Timer::SecToMsec(mTimeout) -
|
||||
mParentRequestTimer.Start(TimerMilli::SecToMsec(mTimeout) -
|
||||
static_cast<uint32_t>(kUnicastRetransmissionDelay) * kMaxChildKeepAliveAttempts);
|
||||
netif.GetMeshForwarder().SetRxOnWhenIdle(true);
|
||||
}
|
||||
|
||||
@@ -1350,8 +1350,8 @@ protected:
|
||||
};
|
||||
ReattachState mReattachState;
|
||||
|
||||
Timer mParentRequestTimer; ///< The timer for driving the Parent Request process.
|
||||
Timer mDelayedResponseTimer; ///< The timer to delay MLE responses.
|
||||
TimerMilli mParentRequestTimer; ///< The timer for driving the Parent Request process.
|
||||
TimerMilli mDelayedResponseTimer; ///< The timer to delay MLE responses.
|
||||
uint8_t mLastPartitionRouterIdSequence;
|
||||
uint32_t mLastPartitionId;
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ namespace Mle {
|
||||
|
||||
MleRouter::MleRouter(ThreadNetif &aThreadNetif):
|
||||
Mle(aThreadNetif),
|
||||
mAdvertiseTimer(aThreadNetif.GetIp6().mTimerScheduler, &MleRouter::HandleAdvertiseTimer, NULL, this),
|
||||
mStateUpdateTimer(aThreadNetif.GetIp6().mTimerScheduler, &MleRouter::HandleStateUpdateTimer, this),
|
||||
mAdvertiseTimer(aThreadNetif.GetIp6(), &MleRouter::HandleAdvertiseTimer, NULL, this),
|
||||
mStateUpdateTimer(aThreadNetif.GetIp6(), &MleRouter::HandleStateUpdateTimer, this),
|
||||
mAddressSolicit(OT_URI_PATH_ADDRESS_SOLICIT, &MleRouter::HandleAddressSolicit, this),
|
||||
mAddressRelease(OT_URI_PATH_ADDRESS_RELEASE, &MleRouter::HandleAddressRelease, this),
|
||||
mRouterIdSequence(0),
|
||||
@@ -178,12 +178,12 @@ uint8_t MleRouter::AllocateRouterId(uint8_t aRouterId)
|
||||
|
||||
// init router state
|
||||
router->SetAllocated(true);
|
||||
router->SetLastHeard(Timer::GetNow());
|
||||
router->SetLastHeard(TimerMilli::GetNow());
|
||||
router->ClearExtAddress();
|
||||
|
||||
// bump sequence number
|
||||
mRouterIdSequence++;
|
||||
mRouterIdSequenceLastUpdated = Timer::GetNow();
|
||||
mRouterIdSequenceLastUpdated = TimerMilli::GetNow();
|
||||
rval = aRouterId;
|
||||
|
||||
otLogInfoMle(GetInstance(), "add router id %d", aRouterId);
|
||||
@@ -217,7 +217,7 @@ otError MleRouter::ReleaseRouterId(uint8_t aRouterId)
|
||||
}
|
||||
|
||||
mRouterIdSequence++;
|
||||
mRouterIdSequenceLastUpdated = Timer::GetNow();
|
||||
mRouterIdSequenceLastUpdated = TimerMilli::GetNow();
|
||||
netif.GetAddressResolver().Remove(aRouterId);
|
||||
netif.GetNetworkDataLeader().RemoveBorderRouter(GetRloc16(aRouterId));
|
||||
ResetAdvertiseInterval();
|
||||
@@ -228,7 +228,7 @@ exit:
|
||||
|
||||
uint32_t MleRouter::GetLeaderAge(void) const
|
||||
{
|
||||
return Timer::MsecToSec(Timer::GetNow() - mRouterIdSequenceLastUpdated);
|
||||
return TimerMilli::MsecToSec(TimerMilli::GetNow() - mRouterIdSequenceLastUpdated);
|
||||
}
|
||||
|
||||
otError MleRouter::BecomeRouter(ThreadStatusTlv::Status aStatus)
|
||||
@@ -356,7 +356,7 @@ otError MleRouter::HandleChildStart(AttachMode aMode)
|
||||
{
|
||||
ThreadNetif &netif = GetNetif();
|
||||
otError error = OT_ERROR_NONE;
|
||||
mRouterIdSequenceLastUpdated = Timer::GetNow();
|
||||
mRouterIdSequenceLastUpdated = TimerMilli::GetNow();
|
||||
mRouterSelectionJitterTimeout = (otPlatRandomGet() % mRouterSelectionJitter) + 1;
|
||||
|
||||
StopLeader();
|
||||
@@ -476,7 +476,7 @@ otError MleRouter::SetStateLeader(uint16_t aRloc16)
|
||||
mRouters[mRouterId].SetNextHop(mRouterId);
|
||||
mPreviousPartitionId = mLeaderData.GetPartitionId();
|
||||
mStateUpdateTimer.Start(kStateUpdatePeriod);
|
||||
mRouters[mRouterId].SetLastHeard(Timer::GetNow());
|
||||
mRouters[mRouterId].SetLastHeard(TimerMilli::GetNow());
|
||||
|
||||
netif.GetNetworkDataLeader().Start();
|
||||
netif.GetActiveDataset().StartLeader();
|
||||
@@ -529,8 +529,8 @@ void MleRouter::ResetAdvertiseInterval(void)
|
||||
if (!mAdvertiseTimer.IsRunning())
|
||||
{
|
||||
mAdvertiseTimer.Start(
|
||||
Timer::SecToMsec(kAdvertiseIntervalMin),
|
||||
Timer::SecToMsec(kAdvertiseIntervalMax),
|
||||
TimerMilli::SecToMsec(kAdvertiseIntervalMin),
|
||||
TimerMilli::SecToMsec(kAdvertiseIntervalMax),
|
||||
TrickleTimer::kModeNormal);
|
||||
}
|
||||
|
||||
@@ -1017,7 +1017,7 @@ otError MleRouter::HandleLinkAccept(const Message &aMessage, const Ip6::MessageI
|
||||
router->SetRloc16(sourceAddress.GetRloc16());
|
||||
router->SetLinkFrameCounter(linkFrameCounter.GetFrameCounter());
|
||||
router->SetMleFrameCounter(mleFrameCounter.GetFrameCounter());
|
||||
router->SetLastHeard(Timer::GetNow());
|
||||
router->SetLastHeard(TimerMilli::GetNow());
|
||||
router->SetDeviceMode(ModeTlv::kModeFFD | ModeTlv::kModeRxOnWhenIdle | ModeTlv::kModeFullNetworkData);
|
||||
router->GetLinkInfo().Clear();
|
||||
router->GetLinkInfo().AddRss(GetNetif().GetMac().GetNoiseFloor(), threadMessageInfo->mRss);
|
||||
@@ -1159,7 +1159,7 @@ otError MleRouter::ProcessRouteTlv(const RouteTlv &aRoute)
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
mRouterIdSequence = aRoute.GetRouterIdSequence();
|
||||
mRouterIdSequenceLastUpdated = Timer::GetNow();
|
||||
mRouterIdSequenceLastUpdated = TimerMilli::GetNow();
|
||||
|
||||
for (uint8_t i = 0; i <= kMaxRouterId; i++)
|
||||
{
|
||||
@@ -1457,7 +1457,7 @@ otError MleRouter::HandleAdvertisement(const Message &aMessage, const Ip6::Messa
|
||||
ExitNow(error = OT_ERROR_NO_ROUTE);
|
||||
}
|
||||
|
||||
router->SetLastHeard(Timer::GetNow());
|
||||
router->SetLastHeard(TimerMilli::GetNow());
|
||||
|
||||
ExitNow();
|
||||
|
||||
@@ -1505,7 +1505,7 @@ otError MleRouter::HandleAdvertisement(const Message &aMessage, const Ip6::Messa
|
||||
ExitNow(error = OT_ERROR_NO_ROUTE);
|
||||
}
|
||||
|
||||
router->SetLastHeard(Timer::GetNow());
|
||||
router->SetLastHeard(TimerMilli::GetNow());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1599,7 +1599,7 @@ void MleRouter::UpdateRoutes(const RouteTlv &aRoute, uint8_t aRouterId)
|
||||
|
||||
mRouters[i].SetNextHop(kInvalidRouterId);
|
||||
mRouters[i].SetCost(0);
|
||||
mRouters[i].SetLastHeard(Timer::GetNow());
|
||||
mRouters[i].SetLastHeard(TimerMilli::GetNow());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1727,8 +1727,8 @@ otError MleRouter::HandleParentRequest(const Message &aMessage, const Ip6::Messa
|
||||
child->SetState(Neighbor::kStateParentRequest);
|
||||
child->SetDataRequestPending(false);
|
||||
|
||||
child->SetLastHeard(Timer::GetNow());
|
||||
child->SetTimeout(Timer::MsecToSec(kMaxChildIdRequestTimeout));
|
||||
child->SetLastHeard(TimerMilli::GetNow());
|
||||
child->SetTimeout(TimerMilli::MsecToSec(kMaxChildIdRequestTimeout));
|
||||
}
|
||||
|
||||
SuccessOrExit(error = SendParentResponse(child, challenge, !scanMask.IsEndDeviceFlagSet()));
|
||||
@@ -1784,8 +1784,8 @@ void MleRouter::HandleStateUpdateTimer(void)
|
||||
SendAdvertisement();
|
||||
|
||||
mAdvertiseTimer.Start(
|
||||
Timer::SecToMsec(kReedAdvertiseInterval),
|
||||
Timer::SecToMsec(kReedAdvertiseInterval + kReedAdvertiseJitter),
|
||||
TimerMilli::SecToMsec(kReedAdvertiseInterval),
|
||||
TimerMilli::SecToMsec(kReedAdvertiseInterval + kReedAdvertiseJitter),
|
||||
TrickleTimer::kModePlainTimer);
|
||||
}
|
||||
|
||||
@@ -1817,7 +1817,7 @@ void MleRouter::HandleStateUpdateTimer(void)
|
||||
if (GetLeaderAge() >= kRouterIdSequencePeriod)
|
||||
{
|
||||
mRouterIdSequence++;
|
||||
mRouterIdSequenceLastUpdated = Timer::GetNow();
|
||||
mRouterIdSequenceLastUpdated = TimerMilli::GetNow();
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1858,7 +1858,7 @@ void MleRouter::HandleStateUpdateTimer(void)
|
||||
case Neighbor::kStateValid:
|
||||
case Neighbor::kStateRestored:
|
||||
case Neighbor::kStateChildUpdateRequest:
|
||||
timeout = Timer::SecToMsec(mChildren[i].GetTimeout());
|
||||
timeout = TimerMilli::SecToMsec(mChildren[i].GetTimeout());
|
||||
break;
|
||||
|
||||
case Neighbor::kStateLinkRequest:
|
||||
@@ -1866,7 +1866,7 @@ void MleRouter::HandleStateUpdateTimer(void)
|
||||
break;
|
||||
}
|
||||
|
||||
if ((Timer::GetNow() - mChildren[i].GetLastHeard()) >= timeout)
|
||||
if ((TimerMilli::GetNow() - mChildren[i].GetLastHeard()) >= timeout)
|
||||
{
|
||||
RemoveNeighbor(mChildren[i]);
|
||||
}
|
||||
@@ -1877,7 +1877,7 @@ void MleRouter::HandleStateUpdateTimer(void)
|
||||
{
|
||||
if (mRouters[i].GetState() == Neighbor::kStateValid)
|
||||
{
|
||||
if ((Timer::GetNow() - mRouters[i].GetLastHeard()) >= Timer::SecToMsec(kMaxNeighborAge))
|
||||
if ((TimerMilli::GetNow() - mRouters[i].GetLastHeard()) >= TimerMilli::SecToMsec(kMaxNeighborAge))
|
||||
{
|
||||
RemoveNeighbor(mRouters[i]);
|
||||
}
|
||||
@@ -1889,15 +1889,15 @@ void MleRouter::HandleStateUpdateTimer(void)
|
||||
{
|
||||
if (!IsRouterIdValid(mRouters[i].GetNextHop()) &&
|
||||
GetLinkCost(i) >= kMaxRouteCost &&
|
||||
(Timer::GetNow() - mRouters[i].GetLastHeard()) >= Timer::SecToMsec(kMaxLeaderToRouterTimeout))
|
||||
(TimerMilli::GetNow() - mRouters[i].GetLastHeard()) >= TimerMilli::SecToMsec(kMaxLeaderToRouterTimeout))
|
||||
{
|
||||
ReleaseRouterId(i);
|
||||
}
|
||||
}
|
||||
else if (mRouters[i].IsReclaimDelay())
|
||||
{
|
||||
if ((Timer::GetNow() - mRouters[i].GetLastHeard()) >=
|
||||
Timer::SecToMsec((kMaxLeaderToRouterTimeout + kRouterIdReuseDelay)))
|
||||
if ((TimerMilli::GetNow() - mRouters[i].GetLastHeard()) >=
|
||||
TimerMilli::SecToMsec((kMaxLeaderToRouterTimeout + kRouterIdReuseDelay)))
|
||||
{
|
||||
mRouters[i].SetReclaimDelay(false);
|
||||
}
|
||||
@@ -2164,7 +2164,7 @@ otError MleRouter::HandleChildIdRequest(const Message &aMessage, const Ip6::Mess
|
||||
}
|
||||
|
||||
|
||||
child->SetLastHeard(Timer::GetNow());
|
||||
child->SetLastHeard(TimerMilli::GetNow());
|
||||
child->SetLinkFrameCounter(linkFrameCounter.GetFrameCounter());
|
||||
child->SetMleFrameCounter(mleFrameCounter.GetFrameCounter());
|
||||
child->SetKeySequence(aKeySequence);
|
||||
@@ -2323,7 +2323,7 @@ otError MleRouter::HandleChildUpdateRequest(const Message &aMessage, const Ip6::
|
||||
}
|
||||
}
|
||||
|
||||
child->SetLastHeard(Timer::GetNow());
|
||||
child->SetLastHeard(TimerMilli::GetNow());
|
||||
|
||||
if (child->IsStateRestoring())
|
||||
{
|
||||
@@ -2418,7 +2418,7 @@ otError MleRouter::HandleChildUpdateResponse(const Message &aMessage, const Ip6:
|
||||
}
|
||||
|
||||
SetChildStateToValid(child);
|
||||
child->SetLastHeard(Timer::GetNow());
|
||||
child->SetLastHeard(TimerMilli::GetNow());
|
||||
child->SetKeySequence(aKeySequence);
|
||||
child->GetLinkInfo().AddRss(GetNetif().GetMac().GetNoiseFloor(), threadMessageInfo->mRss);
|
||||
|
||||
@@ -3125,7 +3125,7 @@ otError MleRouter::RemoveNeighbor(Neighbor &aNeighbor)
|
||||
Router &routerToRemove = static_cast<Router &>(aNeighbor);
|
||||
|
||||
routerToRemove.SetLinkQualityOut(0);
|
||||
routerToRemove.SetLastHeard(Timer::GetNow());
|
||||
routerToRemove.SetLastHeard(TimerMilli::GetNow());
|
||||
|
||||
for (uint8_t j = 0; j <= kMaxRouterId; j++)
|
||||
{
|
||||
@@ -3536,7 +3536,7 @@ otError MleRouter::RestoreChildren(void)
|
||||
child->SetTimeout(childInfo.mTimeout);
|
||||
child->SetDeviceMode(childInfo.mMode);
|
||||
child->SetState(Neighbor::kStateRestored);
|
||||
child->SetLastHeard(Timer::GetNow());
|
||||
child->SetLastHeard(TimerMilli::GetNow());
|
||||
GetNetif().GetMeshForwarder().GetSourceMatchController().SetSrcMatchAsShort(*child, true);
|
||||
}
|
||||
|
||||
@@ -3623,7 +3623,7 @@ otError MleRouter::GetChildInfo(Child &aChild, otChildInfo &aChildInfo)
|
||||
aChildInfo.mRloc16 = aChild.GetRloc16();
|
||||
aChildInfo.mChildId = GetChildId(aChild.GetRloc16());
|
||||
aChildInfo.mNetworkDataVersion = aChild.GetNetworkDataVersion();
|
||||
aChildInfo.mAge = Timer::MsecToSec(Timer::GetNow() - aChild.GetLastHeard());
|
||||
aChildInfo.mAge = TimerMilli::MsecToSec(TimerMilli::GetNow() - aChild.GetLastHeard());
|
||||
aChildInfo.mLinkQualityIn = aChild.GetLinkInfo().GetLinkQuality(GetNetif().GetMac().GetNoiseFloor());
|
||||
aChildInfo.mAverageRssi = aChild.GetLinkInfo().GetAverageRss();
|
||||
aChildInfo.mLastRssi = aChild.GetLinkInfo().GetLastRss();
|
||||
@@ -3665,7 +3665,8 @@ otError MleRouter::GetRouterInfo(uint16_t aRouterId, otRouterInfo &aRouterInfo)
|
||||
aRouterInfo.mPathCost = router->GetCost();
|
||||
aRouterInfo.mLinkQualityIn = router->GetLinkInfo().GetLinkQuality(GetNetif().GetMac().GetNoiseFloor());
|
||||
aRouterInfo.mLinkQualityOut = router->GetLinkQualityOut();
|
||||
aRouterInfo.mAge = static_cast<uint8_t>(Timer::MsecToSec(Timer::GetNow() - router->GetLastHeard()));
|
||||
aRouterInfo.mAge = static_cast<uint8_t>(TimerMilli::MsecToSec(TimerMilli::GetNow() -
|
||||
router->GetLastHeard()));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -3720,7 +3721,7 @@ exit:
|
||||
if (neighbor != NULL)
|
||||
{
|
||||
memcpy(&aNeighInfo.mExtAddress, &neighbor->GetExtAddress(), sizeof(aNeighInfo.mExtAddress));
|
||||
aNeighInfo.mAge = Timer::MsecToSec(Timer::GetNow() - neighbor->GetLastHeard());
|
||||
aNeighInfo.mAge = TimerMilli::MsecToSec(TimerMilli::GetNow() - neighbor->GetLastHeard());
|
||||
aNeighInfo.mRloc16 = neighbor->GetRloc16();
|
||||
aNeighInfo.mLinkFrameCounter = neighbor->GetLinkFrameCounter();
|
||||
aNeighInfo.mMleFrameCounter = neighbor->GetMleFrameCounter();
|
||||
@@ -3967,7 +3968,7 @@ void MleRouter::HandleAddressSolicitResponse(Coap::Header *aHeader, Message *aMe
|
||||
|
||||
// copy router id information
|
||||
mRouterIdSequence = routerMaskTlv.GetIdSequence();
|
||||
mRouterIdSequenceLastUpdated = Timer::GetNow();
|
||||
mRouterIdSequenceLastUpdated = TimerMilli::GetNow();
|
||||
|
||||
for (uint8_t i = 0; i <= kMaxRouterId; i++)
|
||||
{
|
||||
|
||||
@@ -793,7 +793,7 @@ private:
|
||||
static MleRouter &GetOwner(const Context &aContext);
|
||||
|
||||
TrickleTimer mAdvertiseTimer;
|
||||
Timer mStateUpdateTimer;
|
||||
TimerMilli mStateUpdateTimer;
|
||||
|
||||
Coap::Resource mAddressSolicit;
|
||||
Coap::Resource mAddressRelease;
|
||||
|
||||
@@ -608,7 +608,7 @@ otError NetworkData::SendServerDataNotification(uint16_t aRloc16)
|
||||
Message *message = NULL;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
VerifyOrExit(!mLastAttemptWait || static_cast<int32_t>(Timer::GetNow() - mLastAttempt) < kDataResubmitDelay,
|
||||
VerifyOrExit(!mLastAttemptWait || static_cast<int32_t>(TimerMilli::GetNow() - mLastAttempt) < kDataResubmitDelay,
|
||||
error = OT_ERROR_ALREADY);
|
||||
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
@@ -642,7 +642,7 @@ otError NetworkData::SendServerDataNotification(uint16_t aRloc16)
|
||||
|
||||
if (mLocal)
|
||||
{
|
||||
mLastAttempt = Timer::GetNow();
|
||||
mLastAttempt = TimerMilli::GetNow();
|
||||
mLastAttemptWait = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace NetworkData {
|
||||
|
||||
Leader::Leader(ThreadNetif &aThreadNetif):
|
||||
LeaderBase(aThreadNetif),
|
||||
mTimer(aThreadNetif.GetIp6().mTimerScheduler, &Leader::HandleTimer, this),
|
||||
mTimer(aThreadNetif.GetIp6(), &Leader::HandleTimer, this),
|
||||
mServerData(OT_URI_PATH_SERVER_DATA, &Leader::HandleServerData, this),
|
||||
mCommissioningDataGet(OT_URI_PATH_COMMISSIONER_GET, &Leader::HandleCommissioningGet, this),
|
||||
mCommissioningDataSet(OT_URI_PATH_COMMISSIONER_SET, &Leader::HandleCommissioningSet, this)
|
||||
@@ -897,7 +897,7 @@ otError Leader::RemoveRloc(PrefixTlv &prefix, uint16_t aRloc16)
|
||||
if (prefix.GetSubTlvsLength() == sizeof(ContextTlv))
|
||||
{
|
||||
context->ClearCompress();
|
||||
mContextLastUsed[context->GetContextId() - kMinContextId] = Timer::GetNow();
|
||||
mContextLastUsed[context->GetContextId() - kMinContextId] = TimerMilli::GetNow();
|
||||
|
||||
if (mContextLastUsed[context->GetContextId() - kMinContextId] == 0)
|
||||
{
|
||||
@@ -1066,7 +1066,7 @@ void Leader::HandleTimer(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((Timer::GetNow() - mContextLastUsed[i]) >= Timer::SecToMsec(mContextIdReuseDelay))
|
||||
if ((TimerMilli::GetNow() - mContextLastUsed[i]) >= TimerMilli::SecToMsec(mContextIdReuseDelay))
|
||||
{
|
||||
FreeContext(kMinContextId + i);
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ private:
|
||||
uint16_t mContextUsed;
|
||||
uint32_t mContextLastUsed[kNumContextIds];
|
||||
uint32_t mContextIdReuseDelay;
|
||||
Timer mTimer;
|
||||
TimerMilli mTimer;
|
||||
|
||||
Coap::Resource mServerData;
|
||||
|
||||
|
||||
@@ -317,7 +317,7 @@ otError NetworkDiagnostic::FillRequestedTlvs(Message &aRequest, Message &aRespon
|
||||
TimeoutTlv tlv;
|
||||
tlv.Init();
|
||||
tlv.SetTimeout(
|
||||
Timer::MsecToSec(netif.GetMeshForwarder().GetDataPollManager().GetKeepAlivePollPeriod()));
|
||||
TimerMilli::MsecToSec(netif.GetMeshForwarder().GetDataPollManager().GetKeepAlivePollPeriod()));
|
||||
SuccessOrExit(error = aResponse.Append(&tlv, sizeof(tlv)));
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ PanIdQueryServer::PanIdQueryServer(ThreadNetif &aThreadNetif) :
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
mChannelMask(0),
|
||||
mPanId(Mac::kPanIdBroadcast),
|
||||
mTimer(aThreadNetif.GetIp6().mTimerScheduler, &PanIdQueryServer::HandleTimer, this),
|
||||
mTimer(aThreadNetif.GetIp6(), &PanIdQueryServer::HandleTimer, this),
|
||||
mPanIdQuery(OT_URI_PATH_PANID_QUERY, &PanIdQueryServer::HandleQuery, this)
|
||||
{
|
||||
aThreadNetif.GetCoap().AddResource(mPanIdQuery);
|
||||
|
||||
@@ -89,7 +89,7 @@ private:
|
||||
uint32_t mChannelMask;
|
||||
uint16_t mPanId;
|
||||
|
||||
Timer mTimer;
|
||||
TimerMilli mTimer;
|
||||
|
||||
Coap::Resource mPanIdQuery;
|
||||
};
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Utils {
|
||||
|
||||
ChildSupervisor::ChildSupervisor(ThreadNetif &aThreadNetif) :
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
mTimer(aThreadNetif.GetIp6().mTimerScheduler, &ChildSupervisor::HandleTimer, this),
|
||||
mTimer(aThreadNetif.GetIp6(), &ChildSupervisor::HandleTimer, this),
|
||||
mSupervisionInterval(kDefaultSupervisionInterval)
|
||||
{
|
||||
}
|
||||
@@ -133,7 +133,7 @@ void ChildSupervisor::UpdateOnSend(Child &aChild)
|
||||
aChild.ResetSecondsSinceLastSupervision();
|
||||
}
|
||||
|
||||
void ChildSupervisor::HandleTimer(Timer &aTimer)
|
||||
void ChildSupervisor::HandleTimer(TimerMilli &aTimer)
|
||||
{
|
||||
GetOwner(aTimer).HandleTimer();
|
||||
}
|
||||
@@ -183,7 +183,7 @@ ChildSupervisor &ChildSupervisor::GetOwner(const Context &aContext)
|
||||
|
||||
SupervisionListener::SupervisionListener(ThreadNetif &aThreadNetif) :
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
mTimer(aThreadNetif.GetIp6().mTimerScheduler, &SupervisionListener::HandleTimer, this),
|
||||
mTimer(aThreadNetif.GetIp6().mTimerMilliScheduler, &SupervisionListener::HandleTimer, this),
|
||||
mTimeout(0)
|
||||
{
|
||||
SetTimeout(kDefaultTimeout);
|
||||
@@ -232,7 +232,7 @@ void SupervisionListener::RestartTimer(void)
|
||||
if ((mTimeout != 0) && (netif.GetMle().GetRole() == OT_DEVICE_ROLE_CHILD) &&
|
||||
(netif.GetMeshForwarder().GetRxOnWhenIdle() == false))
|
||||
{
|
||||
mTimer.Start(Timer::SecToMsec(mTimeout));
|
||||
mTimer.Start(TimerMilli::SecToMsec(mTimeout));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -240,7 +240,7 @@ void SupervisionListener::RestartTimer(void)
|
||||
}
|
||||
}
|
||||
|
||||
void SupervisionListener::HandleTimer(Timer &aTimer)
|
||||
void SupervisionListener::HandleTimer(TimerMilli &aTimer)
|
||||
{
|
||||
GetOwner(aTimer).HandleTimer();
|
||||
}
|
||||
|
||||
@@ -156,11 +156,11 @@ private:
|
||||
};
|
||||
|
||||
void SendMessage(Child &aChild);
|
||||
static void HandleTimer(Timer &aTimer);
|
||||
static void HandleTimer(TimerMilli &aTimer);
|
||||
void HandleTimer(void);
|
||||
static ChildSupervisor &GetOwner(const Context &aContext);
|
||||
|
||||
Timer mTimer;
|
||||
TimerMilli mTimer;
|
||||
uint16_t mSupervisionInterval;
|
||||
};
|
||||
|
||||
@@ -248,11 +248,11 @@ private:
|
||||
};
|
||||
|
||||
void RestartTimer(void);
|
||||
static void HandleTimer(Timer &aTimer);
|
||||
static void HandleTimer(TimerMilli &aTimer);
|
||||
void HandleTimer(void);
|
||||
static SupervisionListener &GetOwner(const Context &aContext);
|
||||
|
||||
Timer mTimer;
|
||||
TimerMilli mTimer;
|
||||
uint16_t mTimeout;
|
||||
};
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ JamDetector::JamDetector(ThreadNetif &aNetif) :
|
||||
mHandler(NULL),
|
||||
mContext(NULL),
|
||||
mRssiThreshold(kDefaultRssiThreshold),
|
||||
mTimer(aNetif.GetIp6().mTimerScheduler, &JamDetector::HandleTimer, this),
|
||||
mTimer(aNetif.GetIp6(), &JamDetector::HandleTimer, this),
|
||||
mHistoryBitmap(0),
|
||||
mCurSecondStartTime(0),
|
||||
mSampleInterval(0),
|
||||
@@ -76,7 +76,7 @@ otError JamDetector::Start(Handler aHandler, void *aContext)
|
||||
|
||||
mEnabled = true;
|
||||
|
||||
mCurSecondStartTime = Timer::GetNow();
|
||||
mCurSecondStartTime = TimerMilli::GetNow();
|
||||
mAlwaysAboveThreshold = true;
|
||||
mHistoryBitmap = 0;
|
||||
mJamState = false;
|
||||
@@ -184,7 +184,7 @@ exit:
|
||||
|
||||
void JamDetector::UpdateHistory(bool aDidExceedThreshold)
|
||||
{
|
||||
uint32_t now = Timer::GetNow();
|
||||
uint32_t now = TimerMilli::GetNow();
|
||||
|
||||
// If the RSSI is ever below the threshold, update mAlwaysAboveThreshold
|
||||
// for current second interval.
|
||||
|
||||
@@ -196,7 +196,7 @@ private:
|
||||
Handler mHandler; // Handler/callback to inform about jamming state
|
||||
void *mContext; // Context for handler/callback
|
||||
int8_t mRssiThreshold; // RSSI threshold for jam detection
|
||||
Timer mTimer; // RSSI sample timer
|
||||
TimerMilli mTimer; // RSSI sample timer
|
||||
uint64_t mHistoryBitmap; // History bitmap, each bit correspond to 1 sec interval
|
||||
uint32_t mCurSecondStartTime; // Start time for current 1 sec interval
|
||||
uint16_t mSampleInterval; // Current sample interval
|
||||
|
||||
@@ -136,7 +136,7 @@ void Diag::ProcessStart(int argc, char *argv[], char *aOutput, size_t aOutputMax
|
||||
otPlatRadioSetPromiscuous(sContext, true);
|
||||
|
||||
// stop timer
|
||||
otPlatAlarmStop(sContext);
|
||||
otPlatAlarmMilliStop(sContext);
|
||||
|
||||
// start to listen on the default channel
|
||||
SuccessOrExit(error = otPlatRadioReceive(sContext, sChannel));
|
||||
@@ -160,7 +160,7 @@ void Diag::ProcessStop(int argc, char *argv[], char *aOutput, size_t aOutputMaxL
|
||||
|
||||
VerifyOrExit(otPlatDiagModeGet(), error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
otPlatAlarmStop(sContext);
|
||||
otPlatAlarmMilliStop(sContext);
|
||||
otPlatDiagModeSet(false);
|
||||
otPlatRadioSetPromiscuous(sContext, false);
|
||||
|
||||
@@ -277,7 +277,7 @@ void Diag::ProcessRepeat(int argc, char *argv[], char *aOutput, size_t aOutputMa
|
||||
|
||||
if (strcmp(argv[0], "stop") == 0)
|
||||
{
|
||||
otPlatAlarmStop(sContext);
|
||||
otPlatAlarmMilliStop(sContext);
|
||||
sRepeatActive = false;
|
||||
snprintf(aOutput, aOutputMaxLen, "repeated packet transmission is stopped\r\nstatus 0x%02x\r\n", error);
|
||||
}
|
||||
@@ -295,8 +295,8 @@ void Diag::ProcessRepeat(int argc, char *argv[], char *aOutput, size_t aOutputMa
|
||||
sTxLen = static_cast<uint8_t>(value);
|
||||
|
||||
sRepeatActive = true;
|
||||
uint32_t now = otPlatAlarmGetNow();
|
||||
otPlatAlarmStartAt(sContext, now, sTxPeriod);
|
||||
uint32_t now = otPlatAlarmMilliGetNow();
|
||||
otPlatAlarmMilliStartAt(sContext, now, sTxPeriod);
|
||||
snprintf(aOutput, aOutputMaxLen, "sending packets of length %#x at the delay of %#x ms\r\nstatus 0x%02x\r\n", static_cast<int>(sTxLen), static_cast<int>(sTxPeriod), error);
|
||||
}
|
||||
|
||||
@@ -376,10 +376,10 @@ void Diag::AlarmFired(otInstance *aInstance)
|
||||
{
|
||||
if(sRepeatActive)
|
||||
{
|
||||
uint32_t now = otPlatAlarmGetNow();
|
||||
uint32_t now = otPlatAlarmMilliGetNow();
|
||||
|
||||
TxPacket();
|
||||
otPlatAlarmStartAt(aInstance, now, sTxPeriod);
|
||||
otPlatAlarmMilliStartAt(aInstance, now, sTxPeriod);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/alarm.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ extern "C" void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength)
|
||||
(void)aBufLength;
|
||||
}
|
||||
|
||||
extern "C" void otPlatAlarmFired(otInstance *)
|
||||
extern "C" void otPlatAlarmMilliFired(otInstance *)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user