#include "XNetSDKTest.h"

void OnUpgradeCallback(EUpgradeStep nStep, int nProcess, int nTotalSize)
{
	if(nStep == EUpgradeStep_Down)
	{
		printf("DownFile Process = %d/%d\r\n", nProcess,nTotalSize);
	}
	else if(nStep == EUpgradeStep_SendFile)
	{
		unsigned int nPos = 100 * nProcess / nTotalSize;
		printf("SendData Process = %d\r\n", nPos);
	}
	else if(nStep == EUpgradeStep_SendFile_Complete)
	{
		printf("EUpgradeStep_SendFile_Complete[%d]\r\n", nProcess);
	}
	else if(nStep == EUpgradeStep_Upgrade)
	{
		printf("Upgrade Process = %d\r\n", nProcess);
	}
	else if(nStep == EUpgradeStep_Upgrade_Complete )
	{
		printf("EUpgradeStep_Upgrade_Complete[%d]\r\n", nProcess);
	}
	else if(nStep == EUpgradeStep_Complete )
	{
		printf("EUpgradeStep_Complete Process = %d\r\n", nProcess);
	}
	else
	{
		printf("%s[Step:%d][Process:%d][TotalSize:%d]\r\n", __FUNCTION__, nStep, nProcess, nTotalSize);
	}
}

int TestUpgrade()
{
	printf("%s\r\n", __FUNCTION__);
	char c = 0;
	do
	{
		switch(c)
		{
		case 's':
			{
				XSDK_DevUpgrade(g_hDevice, "/mnt/hgfs/myeye50/General_General_FBOX-804C-B2_V4.02.R11.7601.Nat.OnvifC.20180928.bin", 123, 5000);
			}
			break;
		case 'f':
			{
				XSDK_DevUpgrade(g_hDevice, "/mnt/hgfs/myeye50/General_General_FBOX-804C-B2_V4.03.R11.7601.Nat.OnvifC.20181123.bin", 123, 5000);
			}
			break;
		}
	}while((c = getchar()) != 'q');

	return 0;
}