예제 #1
0
        public void TestReceive()
        {
            ZToolPacket data = GetPacket("FE 0B 45 B2 00 00 00 01 00 01 2A 2F 00 35 38 F4");

            ZigBeeApsFrame apsFrame = ZdoManagementRouting.Create(data);

            Assert.Equal(0x0000, apsFrame.SourceAddress);
            Assert.Equal(0, apsFrame.Profile);
            Assert.Equal(0, apsFrame.DestinationEndpoint);
            Assert.Equal(GetPacketData("00 00 01 00 01 2A 2F 00 35 38"), apsFrame.Payload);
        }
예제 #2
0
        public void ReceivedAsynchronousCommand(ZToolPacket packet)
        {
            switch (packet.Subsystem)
            {
            case ZToolPacket.CommandSubsystem.AF:
                return;

            case ZToolPacket.CommandSubsystem.ZDO:
                break;

            default:
                break;
            }

            ZigBeeApsFrame apsFrame = null;

            switch ((ZToolCMD)packet.CMD.Value)
            {
            case ZToolCMD.ZDO_MSG_CB_INCOMING:
                apsFrame = ZdoCallbackIncoming.Create(packet);
                break;

            case ZToolCMD.ZDO_IEEE_ADDR_RSP:
                apsFrame = ZdoIeeeAddress.Create(packet);
                break;

            case ZToolCMD.ZDO_END_DEVICE_ANNCE_IND:
                apsFrame = ZdoEndDeviceAnnounce.Create(packet);
                break;

            case ZToolCMD.ZDO_NODE_DESC_RSP:
                apsFrame = ZdoNodeDescriptor.Create(packet);
                break;

            case ZToolCMD.ZDO_POWER_DESC_RSP:
                apsFrame = ZdoPowerDescriptor.Create(packet);
                break;

            case ZToolCMD.ZDO_ACTIVE_EP_RSP:
                apsFrame = ZdoActiveEndpoint.Create(packet);
                break;

            case ZToolCMD.ZDO_SIMPLE_DESC_RSP:
                apsFrame = ZdoSimpleDescriptor.Create(packet);
                break;

            case ZToolCMD.ZDO_MGMT_LQI_RSP:
                apsFrame = ZdoManagementLqi.Create(packet);
                break;

            case ZToolCMD.ZDO_MGMT_RTG_RSP:
                apsFrame = ZdoManagementRouting.Create(packet);
                break;

            case ZToolCMD.ZDO_MGMT_LEAVE_RSP:
                apsFrame = ZdoManagementLeave.Create(packet);
                break;

            default:
                _logger.Debug($"Unhandled SerialPacket type {packet.CMD}");
                break;
            }

            if (apsFrame != null)
            {
                _ZigBeeNetworkReceive.ReceiveCommand(apsFrame);
                return;
            }
        }