本文整理了Java中com.zsmartsystems.zigbee.zcl.ZclHeader.getFrameType()
方法的一些代码示例,展示了ZclHeader.getFrameType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZclHeader.getFrameType()
方法的具体详情如下:
包路径:com.zsmartsystems.zigbee.zcl.ZclHeader
类名称:ZclHeader
方法名:getFrameType
[英]Gets the frame type sub-field.
Specifies if this is a generic command used across the entire profile #ENTIRE_PROFILE_COMMAND, or a command that is specific to a single cluster #CLUSTER_SPECIFIC_COMMAND.
[中]获取帧类型子字段。
指定这是在整个概要文件中使用的通用命令#整个_profile_命令,还是特定于单个群集的命令#特定于群集的_命令。
代码示例来源: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[] {})));
}
}
内容来源于网络,如有侵权,请联系作者删除!