#include <stdio.h>
#include <conio.h>
#include "API-WiMinet.h"
int main( int argc, char* argv[] )
{
char iRetVal;
FILE * pFile;
unsigned char iCounter;
unsigned char iUnit;
unsigned long dwCount;
unsigned short index;
unsigned short iSize;
WiMinet_WakeUp nWakeUp;
// COM port interface
//iRetVal = OpenWiMinetShell( "COM6",115200, 0X01 );
// Ethernet interface
iRetVal = OpenWiMinetShell( "192.168.0.240",12580, 0X01 );
// Validate the shell open interface
if ( !iRetVal )
{
printf( "Open shell failed!\r\n" );
return 0X00;
}
// Open one file to save the wakeup items
pFile = fopen( "D:\\Wakeup.Bin", "rb" );
// Validate the file pointer
if ( !pFile )
{
printf( "Failed to open file D:\\Wakeup.Bin" );
return 0X00;
}
// Seek to the end of this file
fseek( pFile, 0X00, SEEK_END );
// Get the file size
dwCount = ftell( pFile );
// Seek to the end of this file
fseek( pFile, 0X00, SEEK_SET );
// The counter of the item in this file
iSize = ( unsigned short )( dwCount / sizeof( WiMinet_WakeUp ) );
// Insert all the items in to this device
for ( index = 0X00; index < iSize; index++ )
{
// Read out the data from the file
fread( &nWakeUp, 0X01, sizeof( WiMinet_WakeUp ), pFile );
// Insert to the device
InsertWakeMember( 0X00, 0X00, &nWakeUp );
}
// Close this file
fclose( pFile );
// Reset the device for reload for working(0X00=hot reset, 0XFF=cool reset)
ResetWiMinetHost( 0X00, 0X00, 0X00 );
// Get the total wakeup size
iRetVal = GetTotalWakeSize( 0X00, 0X00, &iUnit, &iSize );
// Validate the operation status
if ( !iRetVal )
{
printf( "Error:GetTotalWakeSize\r\n" );
return 0X00;
}
// The wakeup item status
printf( "WakeUp:Unit=%d Bytes,Total=%d\r\n\r\n", iUnit, iSize );
// The header table
printf( "index Addr Native Mode Tree Amount Stop Band Channel X64MAC\r\n" );
// Read out all the wakeup items
for ( index = 0X00; index < iSize; index++ )
{
// The item to read from the device
iCounter = 0X01;
// Read out the item
iRetVal = GetOneWakeMember( 0X00, 0X00, index, &iCounter, ( char * )&nWakeUp, sizeof( nWakeUp ) );
// Validate the operation results
if ( !iRetVal )
{
printf( "Error:GetOneWakeMember\r\n" );
break;
}
// Validate the item address
if ( !nWakeUp.m_iTxAddr )
{
continue;
}
// The wakeup item status
printf( "[%03d]", index );
printf( " 0X%04X", nWakeUp.m_iTxAddr );
printf( " %d ", nWakeUp.m_iNative );
printf( " %d", nWakeUp.m_iTxMode );
printf( " %d", nWakeUp.m_iTxTree );
printf( " %d", nWakeUp.m_iAmount );
printf( " %d", nWakeUp.m_iTxStop );
printf( " %d", nWakeUp.m_Profile.m_WORadio.m_iBand );
printf( " 0X%02X", nWakeUp.m_Profile.m_WORadio.m_iChannel );
// The X64MAC address
printf( " " );
for ( iCounter = 0X00; iCounter < 0X08; iCounter++ )
{
printf( "%02X", ( unsigned char )nWakeUp.m_pX64MAC[iCounter] );
}
printf( "\r\n" );
}
// The end of the limiter
printf( "\r\n" );
// Stop the shell
StopWiMinetShell( 0X00 );
// Exit this main program
return 0X01;
}