EmberZnet

※This article is based on EmberZnet SDK 6.7.5.0 and EFR32MG Series

概要 [edit]

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

API [edit]

点播 [edit]

Sends unicast.

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

EmberStatus emberAfSendUnicast(EmberOutgoingMessageType 	type, 
				uint16_t 	indexOrDestination, 
				EmberApsFrame * 	apsFrame, 
				uint16_t 	messageLength, 
				uint8_t * 	message 
				)

Sends unicast with attached message sent callback.

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

广播 [edit]

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和源端点匹配的组。

EmberStatus emberAfSendMulticastToBindings(EmberApsFrame * 	apsFrame, 
					uint16_t 	messageLength, 
					uint8_t * 	message 
					)

Sends multicast.

EmberStatus emberAfSendMulticast(EmberMulticastId 	multicastId, 
				EmberApsFrame * 	apsFrame, 
				uint16_t 	messageLength, 
				uint8_t * 	message 
				)

Sends multicast with attached message sent callback.

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

例程 [edit]

使用emAfApsFrameEndpointSetup函数设置源与目的端点 [edit]

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

将自定义的appZclBuffer数据发送出去 [edit]

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);
}

调用 [edit]

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

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(): File not found: "ZigBee.png" at page "++EmberZnet++消息";


Comment:



(画像の文字列を入力して下さい)

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS