/// <summary>
        /// Decode a Sensor Status packet from a byte stream.
        /// </summary>
        /// <param name="buffer"></param>
        /// <param name="index"></param>
        /// <param name="enabled"></param>
        /// <returns></returns>
        private static SensorId DecodeSensorStatus(byte[] buffer, ref int index, out bool enabled)
        {
            SensorStatusPacket status = DeserializePacket <SensorStatusPacket>(buffer, ref index);

            enabled = (status.enabled != 0);
            return((SensorId)status.sensorId);
        }
        /// <summary>
        /// Encode a Sensor Status packet into the buffer
        /// </summary>
        /// <param name="buffer"></param>
        /// <param name="index"></param>
        /// <param name="sensor"></param>
        /// <param name="enabled"></param>
        public static void EncodeSensorStatus(byte[] buffer, ref int index, SensorId sensor, bool enabled)
        {
            // Encode header
            PacketHeader header = new PacketHeader(PacketTypeCode.SensorStatus);

            SerializePacket(buffer, ref index, header);

            // Encode payload
            SensorStatusPacket packet = new SensorStatusPacket
            {
                sensorId = (int)sensor,
                enabled  = (byte)(enabled ? 1 : 0)
            };

            SerializePacket(buffer, ref index, packet);

            // Encode footer
            SerializePacket(buffer, ref index, _footer);
        }