use of com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket in project com.zsmartsystems.zigbee by zsmartsystems.
the class CommandInterfaceImpl method handlePacket.
/**
* Handle parsed packet.
*
* @param packet the packet
*/
@Override
public void handlePacket(final ZToolPacket packet) {
final DoubleByte cmdId = packet.getCMD();
switch(cmdId.getMsb() & 0xE0) {
// Received incoming message which can be either message from dongle or remote device.
case 0x40:
logger.debug("<-- {} ({})", packet.getClass().getSimpleName(), ByteUtils.toBase16(packet.getPacket()));
notifyAsynchronousCommand(packet);
break;
// Received synchronous command response.
case 0x60:
logger.debug("<- {} ({})", packet.getClass().getSimpleName(), ByteUtils.toBase16(packet.getPacket()));
notifySynchronousCommand(packet);
break;
default:
logger.error("Received unknown packet. {}", packet.getClass().getSimpleName());
break;
}
}
use of com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket in project com.zsmartsystems.zigbee by zsmartsystems.
the class Cc2351TestPacket method getPacket.
protected ZToolPacket getPacket(String stringData) {
int[] packet = getPacketData(stringData);
byte[] byteArray = new byte[packet.length - 1];
for (int c = 1; c < packet.length; c++) {
byteArray[c - 1] = (byte) packet[c];
}
ByteArrayInputStream stream = new ByteArrayInputStream(byteArray);
ZigBeePort port = new TestPort(stream, null);
try {
ZToolPacket ztoolPacket = new ZToolPacketStream(port).parsePacket();
assertFalse(ztoolPacket.isError());
return ztoolPacket;
} catch (IOException e) {
return null;
}
}
use of com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZDO_ACTIVE_EP_RSP_Test method testReceive.
@Test
public void testReceive() {
String packetString = "FE 08 45 85 00 00 00 00 00 02 02 01 C9";
ZToolPacket data = getPacket(packetString);
assertEquals(packetString, data.getPacketString());
ZigBeeApsFrame apsFrame = ZdoActiveEndpoint.create(data);
assertEquals(0x0000, apsFrame.getSourceAddress());
assertEquals(0, apsFrame.getProfile());
assertEquals(0, apsFrame.getDestinationEndpoint());
assertTrue(Arrays.equals(getPacketData("00 00 00 00 02 02 01"), apsFrame.getPayload()));
}
use of com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZDO_MSG_CB_INCOMING_Test method testReceive.
@Test
public void testReceive() {
ZToolPacket data = getPacket("FE 15 45 FF 00 00 00 01 80 00 00 00 1B 00 5B 23 EB 09 00 4B 12 00 00 00 00 F6");
ZigBeeApsFrame apsFrame = ZdoCallbackIncoming.create(data);
assertEquals(0x8001, apsFrame.getCluster());
assertEquals(0x0000, apsFrame.getSourceAddress());
assertEquals(0, apsFrame.getProfile());
assertEquals(0, apsFrame.getDestinationEndpoint());
assertTrue(Arrays.equals(getPacketData("1B 00 5B 23 EB 09 00 4B 12 00 00 00 00"), apsFrame.getPayload()));
}
use of com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZDO_NODE_DESC_RSP_Test method testReceive.
@Test
public void testReceive() {
ZToolPacket data = getPacket("FE 12 45 82 00 00 00 00 00 00 40 0F 00 00 50 A0 00 01 00 A0 00 00 CB");
ZigBeeApsFrame apsFrame = ZdoNodeDescriptor.create(data);
assertEquals(0x0000, apsFrame.getSourceAddress());
assertEquals(0, apsFrame.getProfile());
assertEquals(0, apsFrame.getDestinationEndpoint());
assertTrue(Arrays.equals(getPacketData("00 00 00 00 00 40 0F 00 00 50 A0 00 01 00 A0 00 00"), apsFrame.getPayload()));
}
Aggregations