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

📄 nwkformation.c

📁 ucos在NEC平台下的移植
💻 C
字号:
//#pragma  section @@DATA NwkForm at 0xF500

#include"includes.h"
/*only the zigbee coordinator can start to form a network*/
extern NEIGHBOR_RECORD neighborTable[NEIGHBOR_TABLE_ENTRIES];
extern NWK_FORMATION_INFO nwkFormInfo;
extern DEVICE_INFO deviceInfo;
extern NWK_DISCOVERY_INFO              nwkDiscoveryInfo;
extern NWK_NIB nnib;
extern MLME_START_REQUEST_INFO  mlmeStartRequestInfo;
extern NEIGHBOR_TABLE_INFO     currentNeighborTableInfo;    



/*
*********************************************************************************************************
*                                                VARIABLES
*********************************************************************************************************
*/

OS_STK        mscScanProcedureStk[TASK_STK_SIZE];
BYTE          mscScanState=0;
OS_STK        nwkFormNetworkProcedureStk[TASK_STK_SIZE];

OS_EVENT    *formAndScanMessageBox=NULL;  
OS_EVENT    *formAndActiveScanMessageBox=NULL;  

static BYTE * scanResult;

#ifdef NWK_OPT_ZIGBEE_PAN_COORDINATOR
/*********************************************************************
* ZBOOL RequestedPANIDFound( BYTE channel );
*
* DESCRIPTION:
*            Check if PAN ID conflict is present.
* PARAMETER:        
*            BYTE channel
*              the channel to be checked for PAN ID conflicts
* RETURN-VALUE:
*             TRUE - conflict found
*             FALSE - no conflict found
* Overview:  This function determines if a node in our neighbor
*                  table on the specified channel has the same PAN ID
*                  as the one requested.
*
* Note:    In a Cluster-tree topology,this routine may not work if the destination
*                  is our child.
*PAN id collision is said to have occurred if there is more than one PAN with same PAN id operates in overlapping radio range.
********************************************************************/
ZBOOL RequestedPANIDFound( BYTE channel )
{
	BYTE i;

	//the information in the neighbor table is stored in the ROM,we should read the 
	//information in the RAM,and then do the comparation
	//to search every entry in the neighbor table to see if the PAN ID specified
	//by the application is conflicting with the PAN ID used by the device in the neighbor table
	//because the information collected during the scan is stored in the neighbor table
	pCurrentNeighborRecord = &neighborTable[0];

	for ( i=0; i<NEIGHBOR_TABLE_ENTRIES; i++, pCurrentNeighborRecord++)
	{
		// Read the address into RAM.
		ReadNeighborRecordIntoRAM(&currentNeighborRecord, (void*)pCurrentNeighborRecord );

		// Make sure that this record is in use
		if (currentNeighborRecord.deviceInfo.bits.bInUse)
		{
			if ((currentNeighborRecord.logicalChannel == channel) &&
				(currentNeighborRecord.panID == nwkFormInfo.panID))
			{
				return TRUE;
			}
		}
	}
	return FALSE;

}

//-------------------------------------------------------------------------------------------------------
//  void nwkFormNetworkProcedure(void *formState)
//
//  DESCRIPTION:
//      This task implements the network formation state machine.
//  PARAMETER:
//      void *formState,
//          Some information about the network formation.
//  RETURN-VALUE:
//      NO.
//-------------------------------------------------------------------------------------------------------
void nwkFormNetworkProcedure(void *formInfo)
{

	BYTE    formNwkState;
	MAC_SCAN_RESULT pScanResult;
	BYTE scanType=ENERGY_SCAN;
	DWORD scanChannels=nwkFormInfo.scanChannels;
	UINT8 scanDuration=0;
	BYTE activeScan=0;
	MAC_SCAN_RESULT  activeScanResult;
	BYTE j=0;
	BYTE i=0;
	CHANNEL_INFO    tempChannel;
	MAC_SCAN_RESULT nScanResult;
	MAC_ENUM          macStartResult;
	UINT16            panCoordShortAddress;
	NWK_STATE_TYPE nwkState;
     
	//婸槑脣_旼拡檸覕幪楋媍孿晭粫幊榰晭

⌨️ 快捷键说明

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