Пример #1
0
 private void LogMessageFiveVoltPacket(ZigBeeCoordinatorContext ctx, ZigBeeDevice device, MessageFiveVoltPacket packet)
 {
     string message = "Message from [" + device.NetworkAddress.ToHexString() + "]: " + packet.Message;
     switch (packet.Level)
     {
         case MessageLevel.Debug: _log.Debug(message); break;
         case MessageLevel.Info: _log.Info(message); break;
         case MessageLevel.Warning: _log.Warn(message); break;
         case MessageLevel.Error: _log.Error(message); break;
         default:
             _log.Error(message + " (Invalid message level: " + packet.Level + ")");
             break;
     }
 }
Пример #2
0
        public static FiveVoltPacket Decode(byte[] packetData)
        {
            if (packetData.Length < PacketTypeLength)
            {
                return(new InvalidFileVoltPacket("Invalid packet length. Expected at least [" + PacketTypeLength + "] found [" + packetData.Length + "]"));
            }

            switch (packetData[0])
            {
            case (byte)PacketType.Capability:
                return(CapabilityFiveVoltPacket.Decode(packetData));

            case (byte)PacketType.CapabilityData:
                return(CapabilityDataFiveVoltPacket.Decode(packetData));

            case (byte)PacketType.Message:
                return(MessageFiveVoltPacket.Decode(packetData));

            default:
                return(new InvalidFileVoltPacket("Unhandled packet type [" + Convert.ToString(packetData[0], 16) + "]"));
            }
        }