#author("2022-11-18T09:12:55+08:00","default:Admin","Admin")
#author("2022-11-22T15:50:12+08:00","default:Admin","Admin")
[[+Zigbee30+EmberZnet]]

&color(red){※This article is based on EmberZnet SDK 6.7.5.0 and EFR32MG Series};

#contents

* 概要 [#w85d1a06]

消息发送有组播、广播、单播三种方式

*API [#qb9b2a05]

** 点播 [#y0dc43ac]

Sends unicast.

emberAfSendUnicast(EMBER_OUTGOING_VIA_BINDING 这个是通过绑定表单播给指定的节点地址和端点。

#codeprettify{{
EmberStatus emberAfSendUnicast(EmberOutgoingMessageType 	type, 
				uint16_t 	indexOrDestination, 
				EmberApsFrame * 	apsFrame, 
				uint16_t 	messageLength, 
				uint8_t * 	message 
				)
}}




Sends unicast with attached message sent callback.

#codeprettify{{
EmberStatus emberAfSendUnicastWithCallback(EmberOutgoingMessageType 	type, 
					uint16_t 	indexOrDestination, 
					EmberApsFrame * 	apsFrame, 
					uint16_t 	messageLength, 
					uint8_t * 	message, 
					EmberAfMessageSentFunction 	callback 
					)
}}

** 广播 [#g8a53afc]

Multicasts the message to the group in the binding table that matches the cluster and source endpoint in the APS frame. Note: if the binding table contains many matching entries, calling this API cause a significant amount of network traffic. Care should be taken when considering the effects of broadcasts in a network.


emberAfSendMulticastToBindings是将消息多播到绑定表中与APS帧中的CLUSTER和源端点匹配的组。
#codeprettify{{
EmberStatus emberAfSendMulticastToBindings(EmberApsFrame * 	apsFrame, 
					uint16_t 	messageLength, 
					uint8_t * 	message 
					)
}}



Sends multicast.

#codeprettify{{
EmberStatus emberAfSendMulticast(EmberMulticastId 	multicastId, 
				EmberApsFrame * 	apsFrame, 
				uint16_t 	messageLength, 
				uint8_t * 	message 
				)
}}


Sends multicast with attached message sent callback.

#codeprettify{{
EmberStatus emberAfSendMulticastWithCallback(EmberMulticastId 	multicastId, 
					EmberApsFrame * 	apsFrame, 
					uint16_t 	messageLength, 
					uint8_t * 	message, 
					EmberAfMessageSentFunction 	callback 
					)
}}

	
** 例程 [#z9267821]


*** 使用emAfApsFrameEndpointSetup函数设置源与目的端点 [#pd486fe0]

#codeprettify{{
void emAfApsFrameEndpointSetup(uint8_t srcEndpoint,
                               uint8_t dstEndpoint)
{
  globalApsFrame.sourceEndpoint = (srcEndpoint == 0
                                   ? emberAfPrimaryEndpointForCurrentNetworkIndex()
                                   : srcEndpoint);
  globalApsFrame.destinationEndpoint = dstEndpoint;
}
}}


*** 将自定义的appZclBuffer数据发送出去 [#a79eef5a]

#codeprettify{{
EmberStatus emberAfSendMulticast(EmberMulticastId multicastId,
                                 EmberApsFrame *apsFrame,
                                 uint16_t messageLength,
                                 uint8_t *message)
{
  return emberAfSendMulticastWithCallback(multicastId,
                                          apsFrame,
                                          messageLength,
                                          message,
                                          NULL);
}
 
EmberStatus emberAfSendBroadcast(EmberNodeId destination,
                                 EmberApsFrame *apsFrame,
                                 uint16_t messageLength,
                                 uint8_t *message)
{
  return emberAfSendBroadcastWithCallback(destination,
                                          apsFrame,
                                          messageLength,
                                          message,
                                          NULL);
}
 
EmberStatus emberAfSendUnicast(EmberOutgoingMessageType type,
                               uint16_t indexOrDestination,
                               EmberApsFrame *apsFrame,
                               uint16_t messageLength,
                               uint8_t *message)
{
  return emberAfSendUnicastWithCallback(type,
                                        indexOrDestination,
                                        apsFrame,
                                        messageLength,
                                        message,
                                        NULL);
}
}}

*** EmberOutgoingMessageType [#z628bb0c]

#codeprettify{{
  /** Unicast sent directly to an EmberNodeId. */
  EMBER_OUTGOING_DIRECT,
  /** Unicast sent using an entry in the address table. */
  EMBER_OUTGOING_VIA_ADDRESS_TABLE,
  /** Unicast sent using an entry in the binding table. */
  EMBER_OUTGOING_VIA_BINDING,
  /** Multicast message.  This value is passed to emberMessageSentHandler() only.
   * It may not be passed to emberSendUnicast(). */
  EMBER_OUTGOING_MULTICAST,
  /** An aliased multicast message.  This value is passed to emberMessageSentHandler() only.
   * It may not be passed to emberSendUnicast(). */
  EMBER_OUTGOING_MULTICAST_WITH_ALIAS,
  /** An aliased Broadcast message.  This value is passed to emberMessageSentHandler() only.
   * It may not be passed to emberSendUnicast(). */
  EMBER_OUTGOING_BROADCAST_WITH_ALIAS,
  /** A broadcast message.  This value is passed to emberMessageSentHandler() only.
   * It may not be passed to emberSendUnicast(). */
  EMBER_OUTGOING_BROADCAST
}}

*** 调用 [#bb2db106]

应用实例(实现将0x55、0xABCD两个数据单播到协调器)

#codeprettify{{
static EmberStatus zclBufferSendToCoor(void) //发送到协调器
{
  emAfApsFrameEndpointSetup(1, 1);
  
  return emberAfSendUnicast(EMBER_OUTGOING_DIRECT,
                            COORDINATER_NETWORK_ID,
                            &globalApsFrame,
                            appZclBufferLen,
                            appZclBuffer);
}
 
void UnicastFunction(int16u data)
{
    mfgSpecificId = EMBER_AF_MANUFACTURER_CODE;
    zclXDefaultRespCommand = TRUE;
    zclBufferSetup(ZCL_CLUSTER_SPECIFIC_COMMAND,
                   ZCL_XXX_CLUSTER_ID,
                   ZCL_XXX_COMMAND_ID);
    
    mfgSpecificId = EMBER_AF_NULL_MANUFACTURER_CODE;
    zclBufferAddWord(data);
    if (zclBufferSendToCoor() == EMBER_SUCCESS) //成功
    {
    }
}
}}


&ref(ZigBee.png);

#hr();
Comment:
#comment_kcaptcha

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS