![]() |
![]() |
OpenThread
1.05.03.02
|
#include <notifier.hpp>
Data Structures | |
struct | ExternalCallback |
Public Member Functions | |
bool | HasSignaled (Event aEvent) const |
bool | IsPending (void) const |
Notifier (Instance &aInstance) | |
Error | RegisterCallback (otStateChangedCallback aCallback, void *aContext) |
void | RemoveCallback (otStateChangedCallback aCallback, void *aContext) |
void | Signal (Event aEvent) |
void | SignalIfFirst (Event aEvent) |
template<typename Type > | |
Error | Update (Type &aVariable, const Type &aNewValue, Event aEvent) |
![]() | |
Instance & | GetInstance (void) const |
![]() | |
Type & | Get (void) const |
Private Member Functions | |
void | EmitEvents (void) |
const char * | EventToString (Event aEvent) const |
void | LogEvents (Events aEvents) const |
![]() | |
NonCopyable (const NonCopyable &)=delete | |
NonCopyable & | operator= (const NonCopyable &)=delete |
NonCopyable (void)=default | |
Static Private Member Functions | |
static void | EmitEvents (Tasklet &aTasklet) |
Private Attributes | |
Events | mEventsToSignal |
ExternalCallback | mExternalCallbacks [kMaxExternalHandlers] |
Events | mSignaledEvents |
Tasklet | mTask |
Static Private Attributes | |
static constexpr uint16_t | kFlagsStringBufferSize = kFlagsStringLineLimit + kMaxFlagNameLength |
static constexpr uint16_t | kFlagsStringLineLimit = 70 |
static constexpr uint16_t | kMaxExternalHandlers = OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS |
static constexpr uint8_t | kMaxFlagNameLength = 25 |
Additional Inherited Members | |
![]() | |
InstanceLocator (Instance &aInstance) | |
![]() | |
GetProvider (void)=default | |
This class implements the OpenThread Notifier.
For core internal modules, Notifier
class emits events directly to them by invoking method HandleNotifierEvents()
on the module instance.
A otStateChangedCallback
callback can be explicitly registered with the Notifier
. This is mainly intended for use by external users (i.e.provided as an OpenThread public API). Max number of such callbacks that can be registered at the same time is specified by OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS
configuration parameter.
This constructor initializes a Notifier
instance.
[in] | aInstance | A reference to OpenThread instance. |
References Notifier::mExternalCallbacks.
Error RegisterCallback | ( | otStateChangedCallback | aCallback, |
void * | aContext | ||
) |
This method registers an otStateChangedCallback
handler.
[in] | aCallback | A pointer to the handler function that is called to notify of the changes. |
[in] | aContext | A pointer to arbitrary context information. |
kErrorNone | Successfully registered the callback. |
kErrorAlready | The callback was already registered. |
kErrorNoBufs | Could not add the callback due to resource constraints. |
References ot::kErrorAlready, ot::kErrorNoBufs, ot::kErrorNone, Notifier::ExternalCallback::mContext, Notifier::mExternalCallbacks, Notifier::ExternalCallback::mHandler, and VerifyOrExit.
void RemoveCallback | ( | otStateChangedCallback | aCallback, |
void * | aContext | ||
) |
This method removes/unregisters a previously registered otStateChangedCallback
handler.
[in] | aCallback | A pointer to the callback function pointer. |
[in] | aContext | A pointer to arbitrary context information. |
References Notifier::mExternalCallbacks, and VerifyOrExit.
void Signal | ( | Event | aEvent | ) |
This method schedules signaling of an event.
[in] | aEvent | The event to signal. |
References Events::Add(), Notifier::mEventsToSignal, Notifier::mSignaledEvents, Notifier::mTask, and Tasklet::Post().
Referenced by Notifier::SignalIfFirst().
void SignalIfFirst | ( | Event | aEvent | ) |
This method schedules signaling of am event only if the event has not been signaled before (first time signal).
[in] | aEvent | The event to signal. |
References Notifier::HasSignaled(), and Notifier::Signal().
|
inline |
This method indicates whether or not an event signal callback is pending/scheduled.
|
inline |
This method indicates whether or not an event has been signaled before.
[in] | aEvent | The event to check. |
TRUE | The event aEvent have been signaled before. |
FALSE | The event aEvent has not been signaled before. |
Referenced by Notifier::SignalIfFirst().
This template method updates a variable of a type Type
with a new value and signals the given event.
If the variable is already set to the same value, this method returns kErrorAlready
and the event is signaled using SignalIfFirst()
(i.e., signal is scheduled only if event has not been signaled before).
The template Type
should support comparison operator ==
and assignment operator =
.
[in,out] | aVariable | A reference to the variable to update. |
[in] | aNewValue | The new value. |
[in] | aEvent | The event to signal. |
kErrorNone | The variable was update successfully and aEvent was signaled. |
kErrorAlready | The variable was already set to the same value. |
References ot::kErrorAlready, and ot::kErrorNone.
|
staticprivate |
References Notifier::EmitEvents(), and GetProvider< InstanceGetProvider >::Get().
|
private |
|
private |
Referenced by Notifier::EmitEvents().
|
private |
Referenced by Notifier::EmitEvents().
|
staticprivate |
|
staticprivate |
Referenced by Notifier::EmitEvents().
|
staticprivate |
|
staticprivate |
|
private |
Referenced by Notifier::EmitEvents(), and Notifier::Signal().
|
private |
Referenced by Notifier::Signal().
|
private |
Referenced by Notifier::Signal().
|
private |
Referenced by Notifier::EmitEvents(), Notifier::Notifier(), Notifier::RegisterCallback(), and Notifier::RemoveCallback().