微 网 高 通

P7. 电磁波唤醒节点
来源: | 作者:微网高通 | 发布时间: 2025-06-12 | 21 次浏览 | 分享到:

7.1发送电磁波唤醒报文   


 函数名

char SetWakeupRequest( unsigned char iShell, short iObject, short   iTime, char   iAck, char * pBuffer, char   iSize )

头文件

API-WiMinet.h

静态库

WiMinet.lib

动态库

WiMinet.dll


形式

说明

参数一

char iShell

通讯端口的编号,填写固定数值0X00

参数二

short iObject

需要唤醒的目标节点地址

参数三

short iTime

目标节点被唤醒之后,再次休眠之前需要驻留的时间,单位毫秒;

如果超过了该时间长度,而且后续没有下发任何数据报文,目标节点将会重新进入睡眠状态。

参数四

char iAck

是否需要目标节点做出应答

参数五

char * pBuffer

指向一个已经分配好实体内存空间的内存块,该内存块中的内容会在唤醒报文中附加过去

参数六

long dwSize

内存块中的数据长度,超过了可以附加的**长度,会被截尾,最小长度为9字节

返回值

0X01=操作成功,0X00=操作失败



7.2电磁波唤醒-单元测试例程

电磁波唤醒-单元测试例程

#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;
}


7.3 单元测试例程说明

  该程序根据目标地址列表中的地址,间隔一段时间循环发送唤醒请求报文,并打印出唤醒的参数信息。观察目标节点可以看到被唤醒的标志,比如LED指示灯亮起,并持续一段时间后再次熄灭。


7.4电磁波唤醒-综合测试例程

电磁波唤醒-综合测试例程

#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;