Ejemplo n.º 1
0
        public static bool TryParse(byte[] bytes, out ChimeMessage chimeMessage)
        {
            chimeMessage = default(ChimeMessage);

            if (bytes.Length != 8)
            {
                return(false);
            }

            var packetLength = bytes[0];

            if (packetLength != PacketLengths.Chime)
            {
                return(false);
            }

            PacketType packetType;

            if (PacketType.TryParse(bytes[1], out packetType) && packetType != PacketType.Chime)
            {
                return(false);
            }

            var subType        = ChimeSubType.Parse(bytes[2], ChimeSubType.Unsupported);;
            var sequenceNumber = bytes[3];
            var id1            = bytes[4];
            var id2            = bytes[5];
            var sound          = ChimeSound.Parse(bytes[6], ChimeSound.TubularMix);
            var rssi           = bytes[7];

            chimeMessage = new ChimeMessage(subType, sequenceNumber, id1, id2, sound, rssi);

            return(true);
        }
Ejemplo n.º 2
0
 public async static Task SendChime(this ITransceiver transceiver, ChimeSubType subType, ChimeSound sound)
 {
     var message = new ChimeMessage(subType, 0x00, 0x00, 0x00, sound, 0x00);
     await transceiver.Send(message);
 }