微 网 高 通

测试例程:基站信道管理
来源: | 作者:微网高通 | 发布时间: 2025-08-30 | 3 次浏览 | 分享到:

测试例程:基站信道管理

#include <stdio.h>
#include <Winsock2.h>
#include "API-WiMinet.h"
int main( int argc, char* argv[] )
{
   char iRetVal;
   unsigned char iMode;
   unsigned char iBand;
   unsigned char iChannel;
   unsigned char iBandSize;
   unsigned char iChannelSize;
   unsigned char iCounter;
   unsigned char iUnit;
   unsigned short iQMax;
   unsigned short index;
   char buffer[0XFF];
   WiMinet_NoiseTable * pTable;
 
   // 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;
   }
   // Get the channel select mode
   iRetVal = GetChannelSelect( 0X00, 0X00, &iMode );
   // ++++++ IMPORTANT NOTES ++++++
   //
   // Set: SetChannelSelect( 0X00, 0X00,  iMode )
   // Get: GetChannelSelect( 0X00, 0X00, &iMode )
   //
   // Validate the operation status
   if ( !iRetVal )
   {
      printf( "GetChannelSelect failed!rn" );
      return 0X00;
   }
   // The channel mode
   switch( iMode )
   {
   case 0X00:
      {
         printf( "Channel mode=%d:固定不变的信道设置,信道冲突不跳频rnrn", iMode );        
      }
     break;
   case 0X01:
      {
         printf( "Channel mode=%d:恢复出厂配置时搜索,信道冲突会跳频rnrn", iMode );        
      }
      break;
   default:
      {
         printf( "Channel mode=%d:每次开机都自动搜索,信道冲突会跳频rnrn", iMode );        
      }
      break;
   }
   // Set the chennel selection mode
   iRetVal = SetChannelSelect( 0X00, 0X00,  iMode );
   // Validate the operation status
   if ( !iRetVal )
   {
      printf( "SetChannelSelect failed!rn" );
      return 0X00;
   }
 
   // Get the module band and channel
   GetModuleChannel( 0X00, 0X00, &iBand, &iChannel );
   // ++++++ IMPORTANT NOTES ++++++
   //
   // Set: SetServerChannel( 0X00, 0X00, &iBand, &iChannel )
   // Get: GetModuleChannel( 0X00, 0X00, &iBand, &iChannel )
   //
   // Note-1: ONLY the server device only needs to set the channel
   // Note-2: The SET function will return current values by iBand/Channel parameter
 
   // The module band and channel
   printf( "Current Band=%d, Channel=%drnrn", iBand, iChannel );
   // Set the chennel selection mode
   iRetVal = SetServerChannel( 0X00, 0X00, &iBand, &iChannel );
 
   // Validate the operation status
   if ( !iRetVal )
   {
      printf( "SetServerChannel failed!rn" );
      return 0X00;
   }
   // ++++++ IMPORTANT NOTES ++++++
   //
   // (1) Notify the channel to scan all the channels for one time
   // (2) If already scan, then read the channel status
   // (3) Once triggered the scan procedure, then should wait some time
   // (4) The noise table will keep until reboot or next scan
   // (5) If the noise table is not required, this step CAN be skipped
   //
   ScanChannelState( 0X00, 0X00, 0X00 );
   // Wait the device to complete the channel scan
   printf( "Scanning the channel status " );
   // The animation for channel scan
   for ( index = 0X00; index < 0X0A; index++ )
   {    
      Sleep( 500 );
      printf( "." );
   }
   printf( "rnrn" );
   // Get the channel count
   GetChannelAmount( 0X00, 0X00, &iBandSize, &iChannelSize, NULL );
   // The max band and channel size
   printf( "Max Band Size=%d, Max Channel Size=%drnrn", iBandSize, iChannelSize );
   // The max band and channel size
   iQMax = iBandSize * iChannelSize;
   // Get all the band and channel table
   index = 0X00;
   // Get all the band and channel
   while ( index < iQMax )
   {
      // Max channel table to read
      iCounter = 0XFF;
      // Get the channel size
      GetActiveChannel( 0X00, 0X00, index, &iCounter, buffer, sizeof( buffer ) );
      // Update the index number
      index += iCounter;
      // The channel noise table
      pTable = ( WiMinet_NoiseTable * )buffer;
      // The channel table contents
      for ( iUnit = 0X00; iUnit < iCounter; iUnit++ )
      {
         // The channel information
         printf(
            "频带=%d, 信道=%-2d, 优选=%d, **噪声=%-4d (dBm), 平均噪声=%-4d (dBm)rn",
            pTable->m_iBand,
            pTable->m_iChannel,
            pTable->m_iGood,
            pTable->m_iMaxVal,
            pTable->m_iAvgVal );
         // Switch to the next item
         pTable++;
      }
   }
   // The end of the table
   printf( "rn" );
 
   // Stop the shell
   StopWiMinetShell( 0X00 );
   // Exit this main program
   return 0X01;
}


点击下载:测试例程:基站信道管理