com.zsmartsystems.zigbee.zcl.ZclHeader.setSequenceNumber()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中com.zsmartsystems.zigbee.zcl.ZclHeader.setSequenceNumber()方法的一些代码示例,展示了ZclHeader.setSequenceNumber()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZclHeader.setSequenceNumber()方法的具体详情如下:
包路径:com.zsmartsystems.zigbee.zcl.ZclHeader
类名称:ZclHeader
方法名:setSequenceNumber

ZclHeader.setSequenceNumber介绍

[英]Sets the sequence number.
The transaction sequence number field is 8 bits in length and specifies an identification number for the transaction so that a response-style command frame can be related to a request-style command frame. The application object itself shall maintain an 8-bit counter that is copied into this field and incremented by one for each command sent. When a value of 0xff is reached, the next command shall re-start the counter with a value of 0x00.
The transaction sequence number field can be used by a controlling device, which may have issued multiple commands, so that it can match the incoming responses to the relevant command. param sequenceNumber the sequence number as int
[中]设置序列号。
事务序列号字段的长度为8位,并指定事务的标识号,以便响应样式的命令帧可以与请求样式的命令帧相关。应用程序对象本身应保持一个8位计数器,该计数器被复制到该字段中,并为每个发送的命令增加一个计数器。当达到0xff值时,下一个命令应以0x00值重新启动计数器。
交易序列号字段可由控制设备使用,控制设备可能已发出多个命令,以便将传入的响应与相关命令相匹配。param sequenceNumber序列号为int

代码示例

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

: ZclFrameType.CLUSTER_SPECIFIC_COMMAND);
zclHeader.setCommandId(zclCommand.getCommandId());
zclHeader.setSequenceNumber(command.getTransactionId());
zclHeader.setDirection(zclCommand.getCommandDirection());

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Test
public void testReceiveZclCommand() {
  ZigBeeNetworkManager networkManager = mockZigBeeNetworkManager();
  networkManager.setSerializer(DefaultSerializer.class, DefaultDeserializer.class);
  ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
  apsFrame.setSourceAddress(1234);
  apsFrame.setDestinationAddress(0);
  apsFrame.setApsCounter(1);
  apsFrame.setCluster(6);
  apsFrame.setDestinationEndpoint(2);
  apsFrame.setProfile(0x104);
  apsFrame.setSourceEndpoint(5);
  ZclHeader zclHeader = new ZclHeader();
  zclHeader.setCommandId(0);
  zclHeader.setFrameType(ZclFrameType.ENTIRE_PROFILE_COMMAND);
  zclHeader.setSequenceNumber(1);
  DefaultSerializer serializer = new DefaultSerializer();
  ZclFieldSerializer fieldSerializer = new ZclFieldSerializer(serializer);
  apsFrame.setPayload(zclHeader.serialize(fieldSerializer, new int[] {}));
  networkManager.receiveCommand(apsFrame);
  Awaitility.await().until(() -> commandListenerUpdated());
  ReadAttributesCommand response = (ReadAttributesCommand) commandListenerCapture.get(0);
  assertEquals(6, (int) response.getClusterId());
  assertEquals(0, (int) response.getCommandId());
  assertEquals(1, (int) response.getTransactionId());
  assertEquals(new ZigBeeEndpointAddress(1234, 5), response.getSourceAddress());
}

相关文章