﻿namespace GarminFmiLib.Commands
{
    class Enabler : Command, IEnabler
    {
        public Enabler(ISerialPacketWriter writer)
            : base(writer, 0x0000, 2500) { }

        public bool Enable(bool unicodeSupport = true, bool A607Support = true, bool driverPasswords = false, bool multipleDrivers = false, bool AobrdSupport = false)
        {
            byte IsEnabled(bool feature) => (byte)(feature ? 0x80 : 0);

            return Write(new byte[]
            {
                    0x05, // feature count
                    0x00, // reserved
                    0x01, IsEnabled(unicodeSupport),
                    0x02, IsEnabled(A607Support),
                    0x0A, IsEnabled(driverPasswords),
                    0x0B, IsEnabled(multipleDrivers),
                    0x0C, IsEnabled(AobrdSupport)
            });
        }
    }
}
