本文整理了Java中com.zsmartsystems.zigbee.zcl.ZclHeader.getSequenceNumber()
方法的一些代码示例,展示了ZclHeader.getSequenceNumber()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZclHeader.getSequenceNumber()
方法的具体详情如下:
包路径:com.zsmartsystems.zigbee.zcl.ZclHeader
类名称:ZclHeader
方法名:getSequenceNumber
[英]Gets 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.
[中]获取序列号。
事务序列号字段的长度为8位,并指定事务的标识号,以便响应样式的命令帧可以与请求样式的命令帧相关。应用程序对象本身应保持一个8位计数器,该计数器被复制到该字段中,并为每个发送的命令增加一个计数器。当达到0xff值时,下一个命令应以0x00值重新启动计数器。
交易序列号字段可由控制设备使用,控制设备可能已发出多个命令,以便将传入的响应与相关命令相匹配。
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
private ZigBeeCommand receiveZclCommand(final ZclFieldDeserializer fieldDeserializer,
final ZigBeeApsFrame apsFrame) {
// Process the ZCL header
ZclHeader zclHeader = new ZclHeader(fieldDeserializer);
logger.debug("RX ZCL: {}", zclHeader);
// Get the command type
ZclCommandType commandType = null;
if (zclHeader.getFrameType() == ZclFrameType.ENTIRE_PROFILE_COMMAND) {
commandType = ZclCommandType.getGeneric(zclHeader.getCommandId());
} else {
commandType = ZclCommandType.getCommandType(apsFrame.getCluster(), zclHeader.getCommandId(),
zclHeader.getDirection());
}
if (commandType == null) {
logger.debug("No command type found for {}, cluster={}, command={}, direction={}", zclHeader.getFrameType(),
apsFrame.getCluster(), zclHeader.getCommandId(), zclHeader.getDirection());
return null;
}
ZclCommand command = commandType.instantiateCommand();
if (command == null) {
logger.debug("No command found for {}, cluster={}, command={}", zclHeader.getFrameType(),
apsFrame.getCluster(), zclHeader.getCommandId());
return null;
}
command.setCommandDirection(zclHeader.getDirection());
command.deserialize(fieldDeserializer);
command.setClusterId(apsFrame.getCluster());
command.setTransactionId(zclHeader.getSequenceNumber());
return command;
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Test
public void testDeserialize2() {
int[] packet = getPacketData("08 99 88");
DefaultDeserializer deserializer = new DefaultDeserializer(packet);
ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
ZclHeader zclHeader = new ZclHeader(fieldDeserializer);
System.out.println(zclHeader);
assertEquals(0x88, zclHeader.getCommandId());
assertEquals(ZclFrameType.ENTIRE_PROFILE_COMMAND, zclHeader.getFrameType());
assertEquals(false, zclHeader.isManufacturerSpecific());
assertEquals(false, zclHeader.isDisableDefaultResponse());
assertEquals(0x99, zclHeader.getSequenceNumber());
DefaultSerializer serializer = new DefaultSerializer();
ZclFieldSerializer fieldSerializer = new ZclFieldSerializer(serializer);
assertTrue(Arrays.equals(packet, zclHeader.serialize(fieldSerializer, new int[] {})));
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Test
public void testDeserialize() {
int[] packet = getPacketData("11 04 01");
DefaultDeserializer deserializer = new DefaultDeserializer(packet);
ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
ZclHeader zclHeader = new ZclHeader(fieldDeserializer);
System.out.println(zclHeader);
assertEquals(1, zclHeader.getCommandId());
assertEquals(ZclFrameType.CLUSTER_SPECIFIC_COMMAND, zclHeader.getFrameType());
assertEquals(false, zclHeader.isManufacturerSpecific());
assertEquals(true, zclHeader.isDisableDefaultResponse());
assertEquals(4, zclHeader.getSequenceNumber());
DefaultSerializer serializer = new DefaultSerializer();
ZclFieldSerializer fieldSerializer = new ZclFieldSerializer(serializer);
assertTrue(Arrays.equals(packet, zclHeader.serialize(fieldSerializer, new int[] {})));
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Test
public void testDeserializeManufacturerSpecific() {
int[] packet = getPacketData("0C 4E 10 99 88");
DefaultDeserializer deserializer = new DefaultDeserializer(packet);
ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
ZclHeader zclHeader = new ZclHeader(fieldDeserializer);
System.out.println(zclHeader);
assertEquals(0x88, zclHeader.getCommandId());
assertEquals(ZclFrameType.ENTIRE_PROFILE_COMMAND, zclHeader.getFrameType());
assertEquals(true, zclHeader.isManufacturerSpecific());
assertEquals(false, zclHeader.isDisableDefaultResponse());
assertEquals(0x99, zclHeader.getSequenceNumber());
assertEquals(0x104E, zclHeader.getManufacturerCode());
DefaultSerializer serializer = new DefaultSerializer();
ZclFieldSerializer fieldSerializer = new ZclFieldSerializer(serializer);
assertTrue(Arrays.equals(packet, zclHeader.serialize(fieldSerializer, new int[] {})));
}
}
内容来源于网络,如有侵权,请联系作者删除!