#include "p_apps.h"
#include "palmchip.h"
#include "v_task.h"

extern XCHAR Task_iTimer;

#define DISPLAY_REFRESH		60

void _DisplayCurIP()
{
	XCHAR pBuf[18];

//	p_Mac2String(Local_pMacAddress, pBuf);
//	DisplayLine(pBuf, 1);
	p_IP2String(Local_pIPAddress, pBuf);
	DisplayLine(pBuf, 0);
}

void TaskInitialize()                   
{
	Task_iTimer = 0;
	UpgradeInitialize();
	TaskLogon();
}

void TaskHandleTimer()
{
	UpgradeHandleTimer();
	Task_iTimer ++;
	if (Task_iTimer == 60)
	{
		Task_iTimer = 0;
		if (!IsUpgrading())
		{
			_DisplayCurIP();
		}
	}
}

void TaskWaitPacket()
{
	SysSleep(256 + p_rand_char());
}

void TaskSendPacket(USHORT iLen, PXCHAR pPacket)
{
	Ne2000Send(iLen, pPacket);
}

BOOLEAN TaskRunTcp()
{
	if (UpgradeRun())		return TRUE;

	return FALSE;
}

BOOLEAN TaskRunUdp()
{
	if (Adapter_iReceiveUdpPort == UDP_DEBUG_SRC_PORT)
    {
		ReportRun();
	}
	else
	{	// Unknown udp data, ignore
		return FALSE;
	}
	return TRUE;
}

void TaskSignalMsg(UCHAR iType)
{
	switch (iType)
	{
/*	case SIGNAL_IP_CONFLICT:
		DisplayString(g_cDuplicatedIP, 0);
		SysSleep(5000000);
		break;
*/
	}
}

void TaskLogon()
{
	Task_bLogoned = TRUE;
	_DisplayCurIP();
	DisplayString((PCCHAR)"Press 0 to start", 1);
}

void TaskDnsCompleted()				
{
}
			
void TaskDnsFailed()				
{
}

void OnLogoff()
{
}

void Ac97Stop()
{
}


