nl::Weave::Profiles::Heartbeat::WeaveHeartbeatSender

#include <src/lib/profiles/heartbeat/WeaveHeartbeat.h>

Weave Heartbeat Sender class.

Summary

Constructors and Destructors

WeaveHeartbeatSender(void)

Public types

EventCallback)(void *appState, EventType eventType, const InEventParam &inParam, OutEventParam &outParam) typedef
void(*
EventType{
  kEvent_UpdateSubscriptionState = 1,
  kEvent_HeartbeatSent = 2,
  kEvent_HeartbeatFailed = 3,
  kEvent_DefaultCheck = 100
}
enum

Public attributes

AppState
void *

Public functions

GetBinding() const
Get the binding object associated with heartbeat sender.
GetConfiguration(uint32_t & interval, uint32_t & phase, uint32_t & window) const
void
Get heartbeat timing configuration.
GetEventCallback() const
EventCallback
Returns the function that will be called to notify the application of events or changes that occur in the WeaveHeartbeatSender.
GetRequestAck() const
bool
Returns a flag indicating whether heartbeat messages will be sent reliably using Weave Reliable Messaging.
GetSubscriptionState() const
uint8_t
Get the current subscription state value.
Init(WeaveExchangeManager *exchangeMgr, Binding *binding, EventCallback eventCallback, void *appState)
Initialize the Weave Heartbeat Sender.
ScheduleHeartbeat(void)
Schedule sending Weave Heartbeat messages.
SendHeartbeatNow(void)
Send a Weave Heartbeat message now.
SetConfiguration(uint32_t interval, uint32_t phase, uint32_t window)
void
Set heartbeat timing configuration.
SetEventCallback(EventCallback eventCallback)
void
Sets the function that will be called to notify the application of events or changes that occur in the WeaveHeartbeatSender.
SetRequestAck(bool val)
void
Sets a flag indicating whether heartbeat messages should be sent reliably using Weave Reliable Messaging.
SetSubscriptionState(uint8_t val)
void
Set the current subscription state.
Shutdown(void)
Shutdown the Weave Heartbeat Sender.
StartHeartbeat(void)
Start sending Weave Heartbeat messages.
StopHeartbeat(void)
Stop sending Weave Heartbeat messages.

Public static functions

DefaultEventHandler(void *appState, EventType eventType, const InEventParam & inParam, OutEventParam & outParam)
void
Default handler function for WeaveHeartbeatSender API events.

Structs

nl::Weave::Profiles::Heartbeat::WeaveHeartbeatSender::InEventParam

Input parameters to WeaveHeartbeatSender API event.

nl::Weave::Profiles::Heartbeat::WeaveHeartbeatSender::OutEventParam

Output parameters to WeaveHeartbeatSender API event.

Public types

EventCallback

void(* EventCallback)(void *appState, EventType eventType, const InEventParam &inParam, OutEventParam &outParam)

EventType

 EventType
Properties
kEvent_DefaultCheck

Used to verify correct default event handling in the application.

Applications should NOT expressly handle this event.

kEvent_HeartbeatFailed

A heartbeat message failed to be sent to the peer.

kEvent_HeartbeatSent

A heartbeat message was successfully sent to the peer.

If reliable transmission is enabled, this event indicates that the message was acknowledged.

kEvent_UpdateSubscriptionState

The application is requested to update the subscription state.

Public attributes

AppState

void * AppState

Public functions

GetBinding

Binding * GetBinding() const 

Get the binding object associated with heartbeat sender.

GetConfiguration

void GetConfiguration(
  uint32_t & interval,
  uint32_t & phase,
  uint32_t & window
) const 

Get heartbeat timing configuration.

Details
Parameters
[out] interval
A reference to an integer to receive the heartbeat interval.
[out] phase
A reference to an integer to receive the heartbeat phase.
[out] window
A reference to an integer to receive the heartbeat randomization window.

GetEventCallback

EventCallback GetEventCallback() const 

Returns the function that will be called to notify the application of events or changes that occur in the WeaveHeartbeatSender.

GetRequestAck

bool GetRequestAck() const 

Returns a flag indicating whether heartbeat messages will be sent reliably using Weave Reliable Messaging.

GetSubscriptionState

uint8_t GetSubscriptionState() const 

Get the current subscription state value.

Init

WEAVE_ERROR Init(
  WeaveExchangeManager *exchangeMgr,
  Binding *binding,
  EventCallback eventCallback,
  void *appState
)

Initialize the Weave Heartbeat Sender.

Details
Parameters
[in] exchangeMgr
A pointer to the system Weave Exchange Manager.
[in] binding
A pointer to a Weave binding object which will be used to address the peer node.
[in] eventCallback
A pointer to a function that will be called to notify the application of events or state changes that occur in the sender.
[in] appState
A pointer to application-specific data. This pointer will be returned in callbacks to the application.
Return Values
WEAVE_ERROR_INCORRECT_STATE
If the WeaveHeartbeatSender object has already been initialized.
WEAVE_ERROR_INVALID_ARGUMENT
If any of the supplied arguments is null.
WEAVE_NO_ERROR
On success.

ScheduleHeartbeat

WEAVE_ERROR ScheduleHeartbeat(
  void
)

Schedule sending Weave Heartbeat messages.

Details
Return Values
WEAVE_SYSTEM_ERROR_NO_MEMORY
if StartTimer() failed
WEAVE_NO_ERROR
on success

SendHeartbeatNow

WEAVE_ERROR SendHeartbeatNow(
  void
)

Send a Weave Heartbeat message now.

Details
Return Values
WEAVE_ERROR_INCORRECT_STATE
if WeaveHeartbeatSender is not initialized
WEAVE_NO_ERROR
on success

SetConfiguration

void SetConfiguration(
  uint32_t interval,
  uint32_t phase,
  uint32_t window
)

Set heartbeat timing configuration.

Details
Parameters
[in] interval
Interval to use when sending Weave Heartbeat messages.
[in] phase
Phase to use when sending Weave Heartbeat messages.
[in] window
Window range to use for choosing random interval

SetEventCallback

void SetEventCallback(
  EventCallback eventCallback
)

Sets the function that will be called to notify the application of events or changes that occur in the WeaveHeartbeatSender.

SetRequestAck

void SetRequestAck(
  bool val
)

Sets a flag indicating whether heartbeat messages should be sent reliably using Weave Reliable Messaging.

Note that this flag is only meaningful when using UDP as a transport.

Details
Parameters
[in] val
True if heartbeat messages should be sent reliably.

SetSubscriptionState

void SetSubscriptionState(
  uint8_t val
)

Set the current subscription state.

Details
Parameters
[in] val
An 8-bit subscription state value to be conveyed with the heartbeat message.

Shutdown

WEAVE_ERROR Shutdown(
  void
)

Shutdown the Weave Heartbeat Sender.

Details
Return Values
WEAVE_NO_ERROR
On success.

StartHeartbeat

WEAVE_ERROR StartHeartbeat(
  void
)

Start sending Weave Heartbeat messages.

Details
Return Values
INET_ERROR_NO_MEMORY
if StartTimer() failed
WEAVE_NO_ERROR
on success

StopHeartbeat

WEAVE_ERROR StopHeartbeat(
  void
)

Stop sending Weave Heartbeat messages.

Details
Return Values
WEAVE_NO_ERROR
unconditionally

WeaveHeartbeatSender

 WeaveHeartbeatSender(
  void
)

Public static functions

DefaultEventHandler

void DefaultEventHandler(
  void *appState,
  EventType eventType,
  const InEventParam & inParam,
  OutEventParam & outParam
)

Default handler function for WeaveHeartbeatSender API events.

Applications must call this function for any API events that they don't handle.