/// <summary>
        /// Decode a Sensor Control packet from the byte stream
        /// </summary>
        /// <param name="buffer"></param>
        /// <param name="index"></param>
        /// <param name="rate"></param>
        /// <returns></returns>
        private static SensorId DecodeSensorControl(byte[] buffer, ref int index, out bool enabled)
        {
            SensorControlPacket status = DeserializePacket <SensorControlPacket>(buffer, ref index);

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

            SerializePacket(buffer, ref index, header);

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

            SerializePacket(buffer, ref index, packet);

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