⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 router.c

📁 自己写的无线sinffer,可以通过串口查看空间内所有无线数据
💻 C
字号:
#include "router.h"
#include "ap.h"

ROUTER_TABLE father;
ROUTER_TABLE son[5];
extern AP_ATTRIBUTE apAttribute;

void RouterTableInit(void)
{
  father.address=0xffff;
  father.rssi=0x00;
  father.lay=0xff;
  for(BYTE i=0;i<5;i++)
  {
    son[i].address=0xffff;
    son[i].rssi=0x00;
    son[i].lay=0xff;
  }
}


void Router(BYTE lay,BYTE rssi,BYTE addresslow,BYTE addresshigh,BYTE fatherlow,BYTE fatherhigh)
{
  static BYTE currentLoc=0;
  UINT16 address=addresshigh;
  address=addresslow+(address<<8);        //发送节点的地址
  UINT16 nFaAddress=fatherhigh;          //发送节点的父节点地址
  nFaAddress=fatherlow+(fatherlow<<8);
  if(lay<apAttribute.lay)
  {
    if(father.rssi<rssi)
    {
      apAttribute.lay=lay-1;
      father.rssi=rssi;
      father.lay=lay;
      father.address=address;
    }
  }
  else if(lay>=apAttribute.lay)
  {
      if(nFaAddress==apAttribute.localAddress)   //是我的子节点
      {
        apAttribute.flags.bit.newSonNod=FALSE;
        for(BYTE i=0;i<5;i++)
        {
          if(son[i].rssi==0x00)
          {
            son[i].address=address;
            son[i].rssi=rssi;
            son[i].lay=apAttribute.lay-1;
            apAttribute.flags.bit.newSonNod=TRUE;
          }
          else if(son[i].address==address)
          {
            son[i].address=address;
            son[i].rssi=rssi;
            son[i].lay=apAttribute.lay-1;
            apAttribute.flags.bit.newSonNod=TRUE;
          }
        }
        if(apAttribute.flags.bit.newSonNod==FALSE)
        {
          if(currentLoc>=5)
            currentLoc=0;
          else
          {
            son[currentLoc].address=address;
            son[currentLoc].rssi=rssi;
            son[currentLoc].lay=apAttribute.lay-1;
            currentLoc++;
          }
        }
      }
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -