//Firmware Update implementation is available in extended version
//please contact info@iq2-development.de for more information
#if false
using iq2dev.com.iqCommLib.Comm.FirmwareUpdate;
using iq2dev.com.IQCommLib;
using iq2dev.com.IQCommLib.BLOB;
using iq2dev.com.IQCommLib.Example;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace iqCommLib.Example
{
    static internal class FwUpdateExample
    {
		public static void FirmwareUpdate_Example(ProtocolCommunicator protocolCommunicator)
		{
			Stopwatch timer = new Stopwatch();
			timer.Start();

			var firmwareUpdate = new FirmwareUpdate(protocolCommunicator);

			firmwareUpdate.LoggingEvent += Program.LoggingEvent;
			firmwareUpdate.PercentageEvent += FirmwareUpdate_PercentageEvent;

			var fileBuffer = File.ReadAllBytes(@"c:\temp\IQ2 Development-V1.1.3.0EMULATE_MAXREFDES42-20190307-IOLFW1.0\fw_application_binary.bin");

			//Isdu cashed level1, supported only from version 1.2.0.0
			//Isdu cashed level2, supported only from version 1.2.1.2
			IsduCacheLevel cashLevel = IsduCacheLevel.Level2;

			firmwareUpdate.Update("BOOTLOAD_FW", "1234", fileBuffer.ToList(), 3, cashLevel);

			timer.Stop();
			Program.LoggingEvent($"Time: {timer.Elapsed.TotalSeconds} seconds");
			firmwareUpdate.LoggingEvent -= Program.LoggingEvent;
			firmwareUpdate.PercentageEvent -= FirmwareUpdate_PercentageEvent;
		}

		private static void FirmwareUpdate_PercentageEvent(uint percent)
		{
			Console.CursorLeft = 0;
			Console.Write($"Processed : {percent} %");
		}
	}
}
#endif