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

📄 zmac.h

📁 zigbee精简协议栈代码
💻 H
📖 第 1 页 / 共 3 页
字号:
 *                  RX buffer contains desired number of bytes.
 ********************************************************************/
BYTE MACGetArray(BYTE *b, BYTE len);

/*********************************************************************
 * Function:        void MACDiscardRx(void)
 *
 * PreCondition:    MACIsGetReady() = TRUE
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        Fetches remaining data bytes for current received
 *                  frame.
 *
 * Note:            None
 ********************************************************************/
void MACDiscardRx(void);

/*********************************************************************
 * Function:        BOOL MACProcessAssociation(void)
 *
 * PreCondition:    A valid frame is in RX buffer and
 *                  header is already fetched and processed.
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        Fetches rest of the frame and processes it if
 *                  is a valid association request frame.
 *
 * Note:            Available to coordinator only.
 ********************************************************************/
BOOL MACProcessAssociation(void);

/*********************************************************************
 * Function:        HFRAME MACSendAssociateResponse(
 *                              SHORT_ADDR *assocShortAddr,
 *                              MAC_ASSOCIATE_STATUS status)
 *
 * PreCondition:    assocShortAddr  - Short address to be sent
 *                                    as part of association response
 *                  status          - Association result code to be sent
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        Creates and sends valid association response frame
 *                  as per IEEE spec.
 *
 * Note:            Available to coordinator only.
 ********************************************************************/
HFRAME MACSendAssociateResponse(SHORT_ADDR *assocShortAddr,
                                MAC_ASSOCIATE_STATUS status);

/*********************************************************************
 * Function:        HFRAME MACSendRealignment(
 *                          SHORT_ADDR *destShortAddr, BOOL bBroadcast)
 *
 * PreCondition:    MACIsPutReady() = TRUE
 *
 * Input:           destShortAddr - node to whom relignment frame to send
 *                  bBroadcast    - indicates if this is to be broadcast
 *
 * Output:          Handle to frame that was just transmitted.
 *                  Caller must use this handle to determine if this
 *                  frame was ack'ed by intended remote node.
 *
 * Side Effects:    None
 *
 * Overview:        Creates and sends valid relignment frame
 *                  as per IEEE spec.
 *
 * Note:            Available to coordinator only.
 ********************************************************************/
HFRAME MACSendRealignment(SHORT_ADDR *destShortAddr, BOOL bBroadcast);

/*********************************************************************
 * Function:        BOOL MACProcessDisassociation(void)
 *
 * PreCondition:    MACGetHeader() is already called and this frame
 *                  is identified as Disassociate command frame.
 *
 * Input:           None
 *
 * Output:          TRUE if found valid association frame.
 *                  FALSE othersie
 *
 * Side Effects:    None
 *
 * Overview:        Fetches rest of disassociation frame and validates
 *                  as per IEEE spec.
 *
 * Note:            Available to coordinator only.
 ********************************************************************/
BOOL MACProcessDisassociation(void);

#if defined(I_AM_COORDINATOR)
	/*********************************************************************
	 * Macro:           void MACStart(void)
	 *
	 * PreCondition:    MACEnable is called.
	 *
	 * Input:           None
	 *
	 * Output:          None
	 *
	 * Side Effects:    None
	 *
	 * Overview:        Enables PHY receiver.
	 *
	 * Note:            Available to coordinator only.
	 ********************************************************************/
	#define MACStart()                  PHYSetTRXState(PHY_TRX_RX_ON)

	/*********************************************************************
	 * Macro:           void MACFormNetwork(void)
	 *
	 * PreCondition:    An empty channel was found with no coordinator
	 *                  operating in that channel..
	 *
	 * Input:           None
	 *
	 * Output:          None
	 *
	 * Side Effects:    None
	 *
	 * Overview:        Remembers that we are now associated.
	 *
	 * Note:            Available to coordinator only.
	 ********************************************************************/
	#define MACFormNetwork()            (macState.bits.bIsAssociated = TRUE)

	/*********************************************************************
	 * Macro:           BOOL MACIsNetworkEstablished(void)
	 *
	 * PreCondition:    None
	 *
	 * Input:           None
	 *
	 * Output:          TRUE if network is established.
	 *                  FALSE otherwise
	 *
	 * Side Effects:    None
	 *
	 * Overview:        Returns network establish status
	 *
	 * Note:            Available to coordinator only.
	 ********************************************************************/
	#define MACIsNetworkEstablished()   (macState.bits.bIsAssociated)

	/*********************************************************************
	 * Macro:           BOOL MACIsJoinPermitted(void)
	 *
	 * PreCondition:    MACEnable is called.
	 *
	 * Input:           None
	 *
	 * Output:          TRUE if new joins are permitted
	 *                  FALSE otherwise
	 *
	 * Side Effects:    None
	 *
	 * Overview:        Returns previously set flag.
	 *
	 * Note:            Available to coordinator only.
	 ********************************************************************/
	#define MACIsJoinPermitted()        (macState.bits.bPermitAssociation)

#elif defined(I_AM_END_DEVICE)
	/*********************************************************************
	 * Function:        void MACStartAssociation(void)
	 *
	 * PreCondition:    MACAcceptCurrentPAN() is already called.
	 *                  A network scan was performed and appropriate
	 *                  coordinator was selected.
	 *
	 * Input:           None
	 *
	 * Output:          None
	 *
	 * Side Effects:    None
	 *
	 * Overview:        Prepares MAC state machine to begin association
	 *                  sequence.
	 *
	 * Note:            This is available for end device only.
	 ********************************************************************/
	void MACStartAssociation(void);

	/*********************************************************************
	 * Function:        BOOL MACIsAssociationComplete(void)
	 *
	 * PreCondition:    MACStartAssociation() is called.
	 *
	 * Input:           None
	 *
	 * Output:          None
	 *
	 * Side Effects:    None
	 *
	 * Overview:        performs association sequence as per 802.15.4
	 *                  spec.
	 *
	 * Note:            This is available for end device only.
	 ********************************************************************/
	BOOL MACIsAssociationComplete(void);

	/*********************************************************************
	 * Macro:           BOOL MACIsAssociated(void)
	 *
	 * PreCondition:    None
	 *
	 * Input:           None
	 *
	 * Output:          TRUE if associated with a coordinator
	 *                  FALSE otherwise
	 *
	 * Side Effects:    None
	 *
	 * Overview:        returns previusly set flag.
	 *
	 * Note:            This is available for end device only.
	 ********************************************************************/
	#define MACIsAssocated()        (macState.bits.bIsAssociated)

	/*********************************************************************
	 * Function:        void MACAcceptCurrentPAN(void)
	 *
	 * PreCondition:    MACIsScanComplete() = TRUE and there is no
	 *                  ERROR.
	 *
	 * Input:           None
	 *
	 * Output:          None
	 *
	 * Side Effects:    None
	 *
	 * Overview:        Accepts last discovered coordinator as ours.
	 *
	 * Note:            Available to end device only.
	 ********************************************************************/
	void MACAcceptCurrentPAN(void);

	/*********************************************************************
	 * Function:        void MACStartOrphanNotification(void)
	 *
	 * PreCondition:    MACIsPutReady() = TRUE
	 *
	 * Input:           None
	 *
	 * Output:          None
	 *
	 * Side Effects:    None
	 *
	 * Overview:        Prepares the state machine for orphan notification
	 *
	 * Note:            Available to end devices only.
	 ********************************************************************/
	void MACStartOrphanNotification(void);

	/*********************************************************************
	 * Function:        BOOL MACIsOrphanNotificationComplete(void)
	 *
	 * PreCondition:    MACStartOrphanNotification() is called.
	 *
	 * Input:           None
	 *
	 * Output:          TRUE if orphan notification process is complete
	 *                  FALSE otherwise.
	 *
	 * Side Effects:    None
	 *
	 * Overview:        Performs orphan notification steps as per
	 *                  IEEE spec.
	 *
	 * Note:            Available to end devices only.
	 ********************************************************************/
	BOOL MACIsOrphanNotificationComplete(void);

	/*********************************************************************
	 * Function:        void MACStartDisassociation(void)
	 *
	 * PreCondition:    MACInit(), MACEnable() are called
	 *                  And MACIsPutReady() == TRUE
	 *
	 * Input:           None
	 *
	 * Output:          None
	 *
	 * Side Effects:    None
	 *
	 * Overview:        Starts the disassociation process.
	 *
	 * Note:            Available to end devices only.
	 ********************************************************************/
	void MACStartDisassociation(void);

	/*********************************************************************
	 * Function:        BOOL MACIsDisassociationComplete(void)
	 *
	 * PreCondition:    MACStartDisassociation() is already called
	 *
	 * Input:           None
	 *
	 * Output:          TRUE, if disassociation is complete
	 *                  FALSE, if otherwise
	 *
	 * Side Effects:    None
	 *
	 * Overview:        Performs disassociation state machine
	 *
	 * Note:            Available to end devices only.
	 ********************************************************************/
	BOOL MACIsDisassociationComplete(void);

#endif

/*********************************************************************
 * Macro:           BOOL MACIsPANAvailable(void)
 *
 * PreCondition:    MACStartAssociation() process is completed.
 *
 * Input:           None
 *
 * Output:          TRUE if there was at least one PAN was detected
 *                  FALSE otherwise
 *
 * Side Effects:    None
 *
 * Overview:        Returns previously detected network count
 *
 * Note:            None
 ********************************************************************/
#define MACIsPANAvailable()     (PANDescCount)
    
/*********************************************************************
 * Function:        void MACStartScan(BOOL bActiveScan)
 *
 * PreCondition:    MACInit(), MACEnable() are called
 *                  And MACIsPutReady() == TRUE
 *
 * Input:           bActiveScan - flag to perform active/passive scan
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        If this is active scan, sends out beacon request
 *
 * Note:            None
 ********************************************************************/
void MACStartScan(BOOL bActiveScan);

/*********************************************************************
 * Function:        BOOL MACIsScanComplete(void)
 *
 * PreCondition:    MACStartScan() is called.
 *
 * Input:           None
 *
 * Output:          TRUE if scan is complete
 *                  FALSE otherwise.
 *
 * Side Effects:    None
 *
 * Overview:        Checks to see a beacon was received and if it is,
 *                  it processes it.
 *
 * Note:            None
 ********************************************************************/
BOOL MACIsScanComplete(void);

/*********************************************************************
 * Function:        void MACStartED(void)
 *
 * PreCondition:    PHYInit() has been called
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        Begins an energy detection scan
 *
 * Note:            None
 ********************************************************************/
void MACStartED(void);

/*********************************************************************
 * Function:        BOOL MACIsEDComplete(void)
 *
 * PreCondition:    MACStartED() is called
 *
 * Input:           None
 *
 * Output:          TRUE if this Energy detect is complete
 *                  FALSE otherwise.
 *
 * Side Effects:    None
 *
 * Overview:        Simply determines if predefined time has passed or
 *                  not.
 *
 * Note:            None
 ********************************************************************/
BOOL MACIsEDComplete(void);

/*********************************************************************
 * Macro:           BYTE MACGetEDValue(void)
 *
 * PreCondition:    MACStartED() is complete.
 *
 * Input:           None
 *
 * Output:          Value of measured RF energy
 *
 * Side Effects:    None
 *
 * Overview:        None
 *
 * Note:            None
 ********************************************************************/
#define MACGetEDValue()         PHYGetED()

void MACPutLongAddress(LONG_ADDR *addr);

void MACPutShortAddress(SHORT_ADDR *addr);

BOOL MACIsAddressAssigned(void);

#endif

⌨️ 快捷键说明

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