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

// format:
#define REPORT_IP_POS			0	// 0-3 IP
#define REPORT_MAC_POS			4	// 4-9 MAC
#define REPORT_VERSION_POS		10	// 10-39 Version
#define REPORT_NUMBER_POS		40	// 40-59 Phone Number
#define REPORT_TYPE_POS			60	// 60 ip type
#define REPORT_LOGON_POS		61	// 61 Logon status
#define REPORT_CALL_POS			62	// 62 Call status
#define REPORT_PROTOCOL_POS		63	// 63 Protocol
#define REPORT_TOTAL_LEN		64

void ReportRun()
{
//	sprintf(p, "Hello, world!");
	if (p_memcmp_c2x((PXCHAR)Adapter_pReceiveUdpData, (PCCHAR)"Hello, world!", 13))	return;

	UdpOpen(Adapter_pReceiveIPAddress, REPORT_SRC_PORT, REPORT_SRC_PORT, UDP_INFO_SDRAM_LO);

	p_memset_x(Adapter_pSendUdpData, 0, REPORT_TOTAL_LEN);
	p_memcpy_ip(Adapter_pSendUdpData, Local_pIPAddress);
	p_memcpy_mac((PXCHAR)(Adapter_pSendUdpData+REPORT_MAC_POS), Local_pMacAddress);
	p_strcpy_x2x((PXCHAR)(Adapter_pSendUdpData+REPORT_VERSION_POS), GetVersionTextEx(TRUE, TRUE));
	p_strcpy_x2x((PXCHAR)(Adapter_pSendUdpData+REPORT_NUMBER_POS), Sys_pLocalNumber);
	X_VAL(Adapter_pSendUdpData, REPORT_TYPE_POS) = Sys_iIPType;
	X_VAL(Adapter_pSendUdpData, REPORT_LOGON_POS) = Task_bLogoned;
	X_VAL(Adapter_pSendUdpData, REPORT_CALL_POS) = Task_bConnected;
	X_VAL(Adapter_pSendUdpData, REPORT_PROTOCOL_POS) = Sys_iProtocol;

	UdpSend(REPORT_TOTAL_LEN, UDP_INFO_SDRAM_LO);
}
