微 网 高 通

​测试例程:休眠节点的删除
来源: | 作者:微网高通 | 发布时间: 2025-08-30 | 4 次浏览 | 分享到:

测试例程:休眠节点的删除

#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 short index;
   unsigned short iSize;
   unsigned short iObject;
   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", "w+b" );
   // Validate the file pointer
   if ( !pFile )
   {
      printf( "Failed to open file D:\\Wakeup.Bin" );
      return 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;
      }
      // Save the item in the disk file
      iCounter = fwrite( &nWakeUp, 0X01, sizeof( nWakeUp ), pFile );
      // 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" );
   // Close this file
   fclose( pFile );
   // The wakeup item to be deleted
   iObject = 0X8341;
   // Delete one item
   iRetVal = DeleteWakeMember( 0X00, 0X00, ( char * )&iObject, sizeof( iObject ) );
 
   // Validate the operation status
   if ( !iRetVal )
   {
      printf( "Error:DeleteWakeMember\r\n" );
      return 0X00;
   }
 
   // Stop the shell
   StopWiMinetShell( 0X00 );
 
   // Exit this main program
   return 0X01;
}