nl::Weave::Profiles::DataManagement_Current::CommandSender

#include <src/lib/profiles/data-management/Current/CommandSender.h>

摘要

注意:此类封装了发送命令的协议详情,从而简化了应用涉及的机制。应用提供了一个 PacketBuffer,其中包含命令的载荷和一组可选参数,这些参数可以更改命令标头的内容以及命令的行为。 此封装容器在命令处理方面的用途确实有限,主要是因为安全验证和数据序列化/反序列化的复杂性/灵活性。

命令验证的详细信息仍待定

此类还有助于应用推断关联的 TraitDataSink 中的数据是否达到了命令的副作用(基于命令响应中提供的版本)。应用负责管理该对象的存储空间。

Weave 装订

此类的对象可通过 Weave Binding 进行初始化,后者将用作发送命令的默认 Binding。用户还可以为每次 SendCommand() 调用提供 Binding,这会替换默认的 Binding。无需提供默认的 Binding,不过向 CommandSender 提供的所有绑定都必须已初始化。

EventCallback

如果用户希望了解在发送命令之后发生的事件的最新动态,则必须定义此类型的函数(请参阅下面的“API 事件”)。如果用户不关心命令发送后会发生什么,该值可以为 NULL。

API 事件

发送 Command 后,可能会出现以下事件:

CommunicationError

生成或发送 Command 时,或等待响应时出错。等待响应期间可能发生的错误示例包括关键错误或连接意外关闭。错误原因会包含在 EventCallback 处理程序的 InEventParam 参数中。

InProgressReceived

接收者可以发送“进行中”消息,表示已收到 Command 但尚未完成。完成后,收件人将发送 Response 或 StatusReport。不需要发送“进行中”消息。

StatusReportReceived

收到 StatusReport 表示处理 Command 时出错。您可以通过 InEventParam 访问 StatusReport。

ResponseReceived

收到响应意味着命令接收方成功处理了命令。响应可能包含载荷,也可能不包含。如果应用需要保留数据包缓冲区,则可能会调用 ExchangeContext::AddRef() 来递增引用计数。

公共类型

EventCallback)(void *const aAppState, EventType aEvent, const InEventParam &aInParam, OutEventParam &aOutEventParam) typedef
void(*
EventType 枚举

公共属性

mAppState = NULL
void *
mSyncronizedTraitState = NULL

公共静态函数

DefaultEventHandler(void *aAppState, EventType aEvent, const InEventParam & aInParam, OutEventParam & aOutParam)
void

公共函数

Close(bool aAbortNow)
void
Init(nl::Weave::Binding *aBinding, const EventCallback aEventCallback, void *const aAppState)
SendCommand(nl::Weave::PacketBuffer *aPayload, nl::Weave::Binding *aBinding, ResourceIdentifier & aResourceId, uint32_t aProfileId, uint32_t aCommandType)
SendCommand(nl::Weave::PacketBuffer *aPayload, nl::Weave::Binding *aBinding, SendParams & aSendParams)
SetSynchronizedTraitState(SynchronizedTraitState *aTraitState)
void

结构体

nl::Weave::Profiles::DataManagement_Current::CommandSender::InEventParam

自定义命令的接收者返回给发送者的数据。

nl::Weave::Profiles::DataManagement_Current::CommandSender::OutEventParam

从 EventCallback 函数返回给 CommandSender 对象的数据。

nl::Weave::Profiles::DataManagement_Current::CommandSender::SendParams

封装要传入 SendCommand() 的参数。

nl::Weave::Profiles::DataManagement_Current::CommandSender::SynchronizedTraitState

公共类型

EventCallback

void(* EventCallback)(void *const aAppState, EventType aEvent, const InEventParam &aInParam, OutEventParam &aOutEventParam)

EventType

 EventType

公共属性

mAppState

void * mAppState = NULL

mSyncronizedTraitState

SynchronizedTraitState * mSyncronizedTraitState = NULL

公共静态函数

DefaultEventHandler

void DefaultEventHandler(
  void *aAppState,
  EventType aEvent,
  const InEventParam & aInParam,
  OutEventParam & aOutParam
)

公共函数

关闭

void Close(
  bool aAbortNow
)

Init

WEAVE_ERROR Init(
  nl::Weave::Binding *aBinding,
  const EventCallback aEventCallback,
  void *const aAppState
)

SendCommand

WEAVE_ERROR SendCommand(
  nl::Weave::PacketBuffer *aPayload,
  nl::Weave::Binding *aBinding,
  ResourceIdentifier & aResourceId,
  uint32_t aProfileId,
  uint32_t aCommandType
)

SendCommand

WEAVE_ERROR SendCommand(
  nl::Weave::PacketBuffer *aPayload,
  nl::Weave::Binding *aBinding,
  SendParams & aSendParams
)

SetSynchronizedTraitState

void SetSynchronizedTraitState(
  SynchronizedTraitState *aTraitState
)