#include <stdio.h>
#include <conio.h>
#include "API-WiMinet.h"
int main( int argc, char* argv[] )
{
char iRetVal;
unsigned char iAck;
unsigned char iSize;
unsigned short iTime;
unsigned short iObject;
char buffer[0XFF];
unsigned char index;
// The wakeup object table
short pObject[] = {
( short )0X0930,
( short )0X0001,
( short )0X5028 };
// COM port interface
iRetVal = OpenWiMinetShell( "COM3",115200, 0X01 );
// Ethernet interface
//iRetVal = OpenWiMinetShell( "192.168.0.240",12580, 0X01 );
// Validate the shell open interface
if ( !iRetVal )
{
printf( "Open shell failed!rn" );
return 0X00;
}
// The exit information
printf( "rnWaking Clients Now......rnrn" );
// The keep timer for client after wakeup, unit is minisecond
iTime = 500;
// NOT need ack from the client
iAck = 0X00;
// The buffer contents
memset( buffer, 0XAA, sizeof( buffer ) );
// The buffer size
iSize = 0X09;
// The initial item index
index = 0X00;
// The wakeup exit information
while ( !_kbhit() )
{
// The task interval
Sleep( 1000 );
// Validate the object index
if ( index >= sizeof( pObject ) / sizeof( pObject[0X00] ) )
{
index = 0X00;
}
// The object address
iObject = pObject[index++];
// Set the wakeup request
SetWakeupRequest( 0X00, iObject, iTime, iAck, buffer, iSize );
// The runtime information
printf(
"[%lu].eWOR -> Obj=0X%04X, Time=%d, Ack=%d, Size=%lurn",
GetTickCount(),
iObject,
iTime,
iAck,
iSize );
}
// Stop the shell
StopWiMinetShell( 0X00 );
// Exit this main program
return 0X01;
}
该程序根据目标地址列表中的地址,间隔一段时间循环发送唤醒请求报文,并打印出唤醒的参数信息。观察目标节点可以看到被唤醒的标志,比如LED指示灯亮起,并持续一段时间后再次熄灭。
#include <conio.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include "API-WiMinet.h"
// -----------------------------------------------------------------------------
// DESCRIPTION:
// -----------------------------------------------------------------------------
#define TIME_OUT_TIMER 20UL
// -----------------------------------------------------------------------------
// DESCRIPTION: Convert from 100ns to mili-second
// -----------------------------------------------------------------------------
#define X64_MIS_TIMER_CONST ( 10000UL )
// -----------------------------------------------------------------------------
// DESCRIPTION: Convert from 100ns to mili-second, and then to second
// -----------------------------------------------------------------------------
#define X64_SEC_TIMER_CONST ( X64_MIS_TIMER_CONST * 1000UL )
// -----------------------------------------------------------------------------
// DESCRIPTION:
// -----------------------------------------------------------------------------
char * pOutputFileName[] = {
"D:BMP1.bwrg.mLZO",
"D:BMP2.bwrg.mLZO",
"D:BMP3.bwrg.mLZO",
"D:BMP4.bwrg.mLZO",
"D:BMP5.bwrg.mLZO",
"D:BMP6.bwrg.mLZO",
"D:BMP7.bwrg.mLZO",
"D:BMP8.bwrg.mLZO",
"D:BMP9.bwrg.mLZO",
"D:BMP10.bwrg.mLZO",
"D:BMP11.bwrg.mLZO",
"D:BMP12.bwrg.mLZO",
"D:BMP13.bwrg.mLZO",
"D:BMP14.bwrg.mLZO" };
/*
// -----------------------------------------------------------------------------
// DESCRIPTION:
// -----------------------------------------------------------------------------
char * pOutputFileName[] = {
"D:BMP1.bmp.mLZO",
"D:BMP2.bmp.mLZO",
"D:BMP3.bmp.mLZO",
"D:BMP4.bmp.mLZO",
"D:BMP5.bmp.mLZO",
"D:BMP6.mp.mLZO",
"D:BMP7.bmp.mLZO",
"D:BMP8.bmp.mLZO",
"D:BMP9.bmp.mLZO",
"D:BMP10.bmp.mLZO",
"D:BMP11.bmp.mLZO",
"D:BMP12.bmp.mLZO",
"D:BMP13.bmp.mLZO",
"D:BMP14.bmp.mLZO" };
*/
/*
// -----------------------------------------------------------------------------
// DESCRIPTION:
// -----------------------------------------------------------------------------
char * pOutputFileName[] = {
"D:BMP1.bwrg",
"D:BMP2.bwrg",
"D:BMP3.bwrg",
"D:BMP4.bwrg",
"D:BMP5.bwrg",
"D:BMP6.bwrg",
"D:BMP7.bwrg",
"D:BMP8.bwrg",
"D:BMP9.bwrg",
"D:BMP10.bwrg",
"D:BMP11.bwrg",
"D:BMP12.bwrg",
"D:BMP13.bwrg",
"D:BMP14.bwrg" };
*/
/*
// -----------------------------------------------------------------------------
// DESCRIPTION:
// -----------------------------------------------------------------------------
// The file table
char * pOutputFileName[] = {
"D:BMP1.bmp",
"D:BMP2.bmp",
"D:BMP3.bmp",
"D:BMP4.bmp",
"D:BMP5.bmp",
"D:BMP6.bmp",
"D:BMP7.bmp",
"D:BMP8.bmp",
"D:BMP9.bmp",
"D:BMP10.bmp",
"D:BMP11.bmp",
"D:BMP12.bmp",
"D:BMP13.bmp",
"D:BMP14.bmp" };
*/
// *****************************************************************************
// Design Notes:
// -----------------------------------------------------------------------------
unsigned long Translate_Output_File_Number( unsigned long dwChar )
{
// Select the file ID
if ( ( dwChar >= '0' ) && ( dwChar <= '9' ) )
{
// Skip off the base value
dwChar -= '0';
}
else if ( ( dwChar >= 'a' ) && ( dwChar <= 'f' ) )
{
// Skip off the base value
dwChar -= 'a';
// Add the basic value
dwChar += 0X0A;
}
else if ( ( dwChar >= 'A' ) && ( dwChar <= 'F' ) )
{
// Skip off the base value
dwChar -= 'A';
// Add the basic value
dwChar += 0X0A;
}
else
{
dwChar = 0XFFFFFFFF;
}
// The new output file number
return dwChar;
}
// *****************************************************************************
// Design Notes:
// -----------------------------------------------------------------------------
char Validate_Output_File_Number( unsigned long dwFile )
{
// Validate the file index
if ( dwFile >= ( sizeof( pOutputFileName ) / sizeof( pOutputFileName[0X00] ) ) )
{
return 0X00;
}
// The file name
return 0X01;
}
// *****************************************************************************
// Design Notes:
// -----------------------------------------------------------------------------
void Wait_Tx_Active_Ready( void )
{
unsigned char iStatus;
// Query the TxStatus
while ( 0X01 )
{
// Query the Tx status
QueryTxMsgStatus( 0X00, ( char * )&iStatus );
// Check if end of the Tx procedure
if ( iStatus & TXD_TASK_STATUS_REPORTTABLE )
{
break;
}
// Waiting the task is free
printf( "%02X ", iStatus );
// Release the control of the processor
Sleep( 0X01 );
}
}
// *****************************************************************************
// Design Notes:
// -----------------------------------------------------------------------------
void Print_Tx_Task_Status( unsigned long dwIndex )
{
float fTimer;
unsigned char iStatus;
unsigned char iProgress;
unsigned long dwTimerA;
unsigned long dwTimerB;
unsigned long dwTimerX;