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); }
public ChimeMessage(ChimeSubType subType, byte sequenceNumber, byte id1, byte id2, ChimeSound sound, byte rssi) { PacketLength = PacketLengths.Chime; PacketType = PacketType.Chime; SubType = subType; SequenceNumber = sequenceNumber; Id1 = id1; Id2 = id2; Sound = sound; Rssi = rssi; Filler = 0x00; }
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); }