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

📄 af.h

📁 Zigbee2006入门(源代码+文档讲解+系统推荐)
💻 H
📖 第 1 页 / 共 2 页
字号:
  } afIncomingKVPPacket_t;
#endif

typedef struct
{
  osal_event_hdr_t hdr;
  uint16 groupId;
  uint16 clusterId;
  afAddrType_t srcAddr;
  byte endPoint;
  byte wasBroadcast;
  byte LinkQuality;
  byte SecurityUse;
  uint32 timestamp;
  afMSGCommandFormat_t cmd;
} afIncomingMSGPacket_t;

typedef struct
{
  osal_event_hdr_t hdr;
  byte endpoint;
  byte transID;
} afDataConfirm_t;

// Endpoint Table - this table is the device description
// or application registration.
// There will be one entry in this table for every
// endpoint defined.
typedef struct
{
  byte endPoint;
  byte *task_id;  // Pointer to location of the Application task ID.
  SimpleDescriptionFormat_t *simpleDesc;
  afNetworkLatencyReq_t latencyReq;
} endPointDesc_t;

// Typedef for callback function to retrieve an endpoints
//   descriptors, contained in the endpoint descriptor.
//   This will allow an application to dynamically change
//   the descriptor and not use the RAM/ROM.
typedef void *(*pDescCB)( uint8 type, uint8 endpoint );

// Descriptor types used in the above callback
#define AF_DESCRIPTOR_SIMPLE            1
#define AF_DESCRIPTOR_PROFILE_ID        2

// Bit definitions for epList_t flags.
typedef enum
{
  eEP_AllowMatch = 1,
#if ( AF_KVP_SUPPORT )
  eEP_UsesKVP =    2,
#endif
  eEP_NotUsed
} eEP_Flags;

typedef struct
{
  endPointDesc_t *epDesc;
  uint16 reflectorAddr;
  eEP_Flags flags;
  pDescCB  pfnDescCB;     // Don't use if this function pointer is NULL.
  void *nextDesc;
} epList_t;

/*********************************************************************
 * MACROS
 */

/*********************************************************************
 * TYPEDEFS
 */

typedef enum
{
  afStatus_SUCCESS,
  afStatus_FAILED = 0x80,
  afStatus_MEM_FAIL,
  afStatus_INVALID_PARAMETER
} afStatus_t;

typedef struct
{
  uint8              kvp;
  APSDE_DataReqMTU_t aps;
} afDataReqMTU_t;


/*********************************************************************
 * Special AF Data Types
 */

#if ( AF_FLOAT_SUPPORT )
  // ZigBee Absolute Time format (32 bit)
  typedef uint32 afAbsoluteTime_t;

  // ZigBee Relative Time format (32 bit)
  typedef uint32 afRelativeTime_t;

  // ZigBee Semi-Precision format (16 bit)
  typedef struct
  {
    unsigned int sign:1;
    unsigned int exponent:5;
    unsigned int mantissa:10;
  } afSemiPrecision_t;
#endif

/*********************************************************************
 * Globals
 */

extern epList_t *epList;

/*********************************************************************
 * FUNCTIONS
 */

 /*
  * afInit - Initialize the AF.
  */
  extern void afInit( void );

 /*
  * afRegisterExtended - Register an Application's EndPoint description
  *           with a callback function for descriptors.
  *
  */
  extern epList_t *afRegisterExtended( endPointDesc_t *epDesc, pDescCB descFn );

 /*
  * afRegister - Register an Application's EndPoint description.
  *
  */
  extern afStatus_t afRegister( endPointDesc_t *epDesc );

 /*
  * afRegisterFlags - If trying to run KVP under V2 network, any non-ZDO
  * endpoint is assumed to be running KVP unless it is specially registered
  * to not use it.
  */
#if ( AF_KVP_SUPPORT )
  extern afStatus_t afRegisterFlags( endPointDesc_t *epDesc, eEP_Flags flags );
#endif

 /*
  * afDataConfirm - APS will call this function after a data message
  *                 has been sent.
  */
  extern void afDataConfirm( uint8 endPoint, uint8 transID, ZStatus_t status );

 /*
  * afIncomingData - APS will call this function when an incoming
  *                   message is received.
  */
  extern void afIncomingData( aps_FrameFormat_t *aff, zAddrType_t *SrcAddress,
                       uint8 LinkQuality, byte SecurityUse, uint32 timestamp );

#if ( AF_KVP_SUPPORT )
 /*
  */
  afStatus_t afAddOrSendMessage(
    afAddrType_t *dstAddr, byte srcEndPoint, cId_t clusterID,
    afAddOrSend_t AddOrSend, byte FrameType, byte *TransSeqNumber,
    byte CommandType, byte AttribDataType, uint16 AttribId, byte ErrorCode,
    byte DataLength, byte *Data,
    byte txOptions, byte DiscoverRoute, byte RadiusCounter );
#endif

#if ( AF_V1_SUPPORT || AF_KVP_SUPPORT )
 /*
  * Fills in the cmd format structure and sends the out-going message.
  */
  afStatus_t afFillAndSendMessage(
    afAddrType_t *dstAddr, byte srcEndPoint, cId_t clusterID,
    byte TransCount, byte FrameType, byte *TransSeqNumber,
    byte CommandType, byte AttribDataType, uint16 AttribId, byte ErrorCode,
    byte DataLength, byte *Data,
    byte txOptions, byte DiscoverRoute, byte RadiusCounter );
#endif

 /*
  * Common functionality for invoking APSDE_DataReq() for both
  * KVP-Send/SendMulti and MSG-Send.
  */
#if ( AF_V1_SUPPORT )
#define AF_DataRequest(dstAddr, srcEP, cID, len, buf, transID, options, radius)\
  afFillAndSendMessage( (dstAddr), (srcEP)->endPoint, (cID), \
                         1, FRAMETYPE_MSG, (transID), \
                         NULL, NULL, NULL, NULL, (byte)(len), (buf), \
                        (options), (byte)((options) & AF_DISCV_ROUTE), (radius) )
#else
  afStatus_t AF_DataRequest( afAddrType_t *dstAddr, endPointDesc_t *srcEP,
                             uint16 cID, uint16 len, uint8 *buf, uint8 *transID,
                             uint8 options, uint8 radius );
#endif

/*********************************************************************
 * Direct Access Functions - ZigBee Device Object
 */

 /*
  *	afFindEndPointDesc - Find the endpoint description entry from the
  *                      endpoint number.
  */
  extern endPointDesc_t *afFindEndPointDesc( byte endPoint );

 /*
  *	afFindSimpleDesc - Find the Simple Descriptor from the endpoint number.
  *   	  If return value is not zero, the descriptor memory must be freed.
  */
  extern byte afFindSimpleDesc( SimpleDescriptionFormat_t **ppDesc, byte EP );

 /*
  *	afGetReflector - Find the reflector for the endpoint.
  *         0xFFFF return if not found
  */
  extern uint16 afGetReflector( byte EndPoint );

 /*
  *	afSetReflector - Set the reflector address for the endpoint.
  *          FALSE if endpoint not found.
  */
  extern uint8 afSetReflector( byte EndPoint, uint16 reflectorAddr );

 /*
  *	afDataReqMTU - Get the Data Request MTU(Max Transport Unit)
  */
  extern uint8 afDataReqMTU( afDataReqMTU_t* fields );

 /*
  *	afGetMatch - Get the action for the Match Descriptor Response
  *             TRUE allow match descriptor response
  */
  extern uint8 afGetMatch( uint8 ep );

 /*
  *	afSetMatch - Set the action for the Match Descriptor Response
  *             TRUE allow match descriptor response
  */
  extern uint8 afSetMatch( uint8 ep, uint8 action );

 /*
  *	afNumEndPoints - returns the number of endpoints defined.
  */
  extern byte afNumEndPoints( void );

 /*
  *	afEndPoints - builds an array of endpoints.
  */
  extern void afEndPoints( byte *epBuf, byte skipZDO );

#if ( AF_FLOAT_SUPPORT )
 /*
  * afCnvtSP_uint16 - Converts uint16 to semi-precision structure format.
  */
  extern uint16 afCnvtSP_uint16( afSemiPrecision_t sp );

 /*
  * afCnvtuint16_SP - Converts uint16 to semi-precision structure format.
  */
  extern afSemiPrecision_t afCnvtuint16_SP( uint16 rawSP );

 /*
  * afCnvtFloat_SP - Converts float to semi-precision
  *                    structure format
  * NOTE: This function will convert to the closest possible
  *       representation in a 16 bit format.  Meaning that
  *       the number may not be exact.  For example, 10.7 will
  *       convert to 10.69531, because .7 is a repeating binary
  *       number.  The mantissa for afSemiPrecision_t is 10 bits
  *       and .69531 is the 10 bit representative of .7.
  */
  extern afSemiPrecision_t afCnvtFloat_SP( float f );

 /*
  * afCnvtSP_Float - Converts semi-precision structure format to float.
  */
  extern float afCnvtSP_Float( afSemiPrecision_t sp );
#endif

#if ( AF_KVP_SUPPORT )
 /*
  * GetDataTypeLength
  */
extern byte GetDataTypeLength ( byte DataType);
#endif

 /*
  * afCopyAddress
  *
  */
extern void afCopyAddress (afAddrType_t *afAddr, zAddrType_t *zAddr);

/*********************************************************************
*********************************************************************/

#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

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