예제 #1
0
        public static EnOceanPacket CreateNew(Span <byte> header, Span <byte> data, Span <byte> optionalData)
        {
            var rawData = new List <byte>();

            byte headerCrc = 0;

            for (int i = 1; i < header.Length; i++)
            {
                headerCrc = EnOcean.Crc8(headerCrc, header[i]);
            }
            rawData.AddRange(header.ToArray());
            rawData.Add(headerCrc);

            rawData.AddRange(data.ToArray());
            rawData.AddRange(optionalData.ToArray());

            byte dataCrc = 0;

            foreach (var b in data)
            {
                dataCrc = EnOcean.Crc8(dataCrc, b);
            }
            foreach (var b in optionalData)
            {
                dataCrc = EnOcean.Crc8(dataCrc, b);
            }
            rawData.Add(dataCrc);

            var p = new EnOceanPacket(rawData.ToArray());

            return(p);
        }
예제 #2
0
        public static EnOceanPacket Parse(Span <byte> data)
        {
            var packet = new EnOceanPacket(data);

            packet.ParseData();
            return(packet);
        }
예제 #3
0
        public static EnOceanPacket Parse(ReadOnlyMemory <byte> header, ReadOnlyMemory <byte> data, ReadOnlyMemory <byte> optionalData, byte crcData)
        {
            var packet = new EnOceanPacket(header, data, optionalData, crcData);

            packet.ParseData();
            return(packet);
        }
        public static EnOceanTelegram FromPacket(EnOceanPacket packet)
        {
            EnOceanTelegram telegram;

            switch (packet.PacketType)
            {
            case EnOcean.PacketType.RadioErp1:
            {
                telegram = new RadioErp1Packet();
                break;
            }

            default:
                throw new NotImplementedException();
            }

            telegram.FromPacket(packet);
            return(telegram);
        }
예제 #5
0
 public PacketSentEventArgs(EnOceanPacket packet, EnOceanTelegram telegram)
 {
     Packet   = packet;
     Telegram = telegram;
 }
예제 #6
0
 public AnswerReceviedEventArgs(EnOceanPacket packet)
 {
     Packet = packet;
 }