123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481 |
- #ifndef AF_H
- #define AF_H
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- #include "ZComDef.h"
- #include "nwk.h"
- #include "APSMEDE.h"
- #define AF_BROADCAST_ENDPOINT 0xFF
- #define AF_PREPROCESS 0x04
- #define AF_LIMIT_CONCENTRATOR 0x08
- #define AF_ACK_REQUEST 0x10
- #define AF_DISCV_ROUTE 0x20
- #define AF_EN_SECURITY 0x40
- #define AF_SKIP_ROUTING 0x80
- #define AF_TX_OPTIONS_NONE 0
- #define AF_MSG_ACK_REQUEST AF_ACK_REQUEST
- #define AF_DEFAULT_RADIUS DEF_NWK_RADIUS
- #define AF_MAX_USER_DESCRIPTOR_LEN 16
- #define AF_USER_DESCRIPTOR_FILL 0x20
- typedef struct
- {
- uint8 len;
- uint8 desc[AF_MAX_USER_DESCRIPTOR_LEN];
- } UserDescriptorFormat_t;
- #define NODETYPE_COORDINATOR 0x00
- #define NODETYPE_ROUTER 0x01
- #define NODETYPE_DEVICE 0x02
- #define NODEFREQ_800 0x01
- #define NODEFREQ_900 0x04
- #define NODEFREQ_2400 0x08
- typedef struct
- {
- uint8 LogicalType:3;
- uint8 ComplexDescAvail:1;
- uint8 UserDescAvail:1;
- uint8 Reserved:3;
- uint8 APSFlags:3;
- uint8 FrequencyBand:5;
- uint8 CapabilityFlags;
- uint8 ManufacturerCode[2];
- uint8 MaxBufferSize;
- uint8 MaxInTransferSize[2];
- uint16 ServerMask;
- uint8 MaxOutTransferSize[2];
- uint8 DescriptorCapability;
- } NodeDescriptorFormat_t;
- #define PRIM_TRUST_CENTER 0x01
- #define BKUP_TRUST_CENTER 0x02
- #define PRIM_BIND_TABLE 0x04
- #define BKUP_BIND_TABLE 0x08
- #define PRIM_DISC_TABLE 0x10
- #define BKUP_DISC_TABLE 0x20
- #define NETWORK_MANAGER 0x40
- #define NODECURPWR_RCVR_ALWAYS_ON 0x00
- #define NODECURPWR_RCVR_AUTO 0x01
- #define NODECURPWR_RCVR_STIM 0x02
- #define NODEAVAILPWR_MAINS 0x01
- #define NODEAVAILPWR_RECHARGE 0x02
- #define NODEAVAILPWR_DISPOSE 0x04
- #define NODEPOWER_LEVEL_CRITICAL 0x00
- #define NODEPOWER_LEVEL_33 0x04
- #define NODEPOWER_LEVEL_66 0x08
- #define NODEPOWER_LEVEL_100 0x0C
- typedef struct
- {
- unsigned int PowerMode:4;
- unsigned int AvailablePowerSources:4;
- unsigned int CurrentPowerSource:4;
- unsigned int CurrentPowerSourceLevel:4;
- } NodePowerDescriptorFormat_t;
- #define APPDEVVER_1 0x01
- #define APPFLAG_NONE 0x00
- #define AF_APPFLAG_NONE 0x00
- #define AF_APPFLAG_COMPLEXDESC 0x01
- #define AF_APPFLAG_USERDESC 0x02
- typedef uint16 cId_t;
- typedef struct
- {
- uint8 EndPoint;
- uint16 AppProfId;
- uint16 AppDeviceId;
- uint8 AppDevVer:4;
- uint8 Reserved:4;
- uint8 AppNumInClusters;
- cId_t *pAppInClusterList;
- uint8 AppNumOutClusters;
- cId_t *pAppOutClusterList;
- } SimpleDescriptionFormat_t;
- #define FRAMETYPE_KVP 0x01
- #define FRAMETYPE_MSG 0x02
- #define ERRORCODE_SUCCESS 0x00
- #define AF_HDR_KVP_MAX_LEN 0x08
- #define AF_HDR_V1_0_MAX_LEN 0x03
- #define AF_HDR_V1_1_MAX_LEN 0x00
- typedef struct
- {
- uint8 TransSeqNumber;
- uint16 DataLength;
- uint8 *Data;
- } afMSGCommandFormat_t;
- typedef enum
- {
- noLatencyReqs,
- fastBeacons,
- slowBeacons
- } afNetworkLatencyReq_t;
- typedef enum
- {
- afAddrNotPresent = AddrNotPresent,
- afAddr16Bit = Addr16Bit,
- afAddr64Bit = Addr64Bit,
- afAddrGroup = AddrGroup,
- afAddrBroadcast = AddrBroadcast
- } afAddrMode_t;
- typedef struct
- {
- union
- {
- uint16 shortAddr;
- ZLongAddr_t extAddr;
- } addr;
- afAddrMode_t addrMode;
- uint8 endPoint;
- uint16 panId;
- } afAddrType_t;
- typedef struct
- {
- osal_event_hdr_t hdr;
- uint16 groupId;
- uint16 clusterId;
- afAddrType_t srcAddr;
- uint16 macDestAddr;
- uint8 endPoint;
- uint8 wasBroadcast;
- uint8 LinkQuality;
- uint8 correlation;
- int8 rssi;
- uint8 SecurityUse;
- uint32 timestamp;
- uint8 nwkSeqNum;
- afMSGCommandFormat_t cmd;
- } afIncomingMSGPacket_t;
- typedef struct
- {
- osal_event_hdr_t hdr;
- uint8 endpoint;
- uint8 transID;
- } afDataConfirm_t;
- typedef struct
- {
- uint8 endPoint;
- uint8 *task_id;
- SimpleDescriptionFormat_t *simpleDesc;
- afNetworkLatencyReq_t latencyReq;
- } endPointDesc_t;
- typedef void *(*pDescCB)( uint8 type, uint8 endpoint );
- #define AF_DESCRIPTOR_SIMPLE 1
- #define AF_DESCRIPTOR_PROFILE_ID 2
- typedef enum
- {
- eEP_AllowMatch = 1,
- eEP_NotUsed
- } eEP_Flags;
- typedef struct {
- uint8 frameDelay;
- uint8 windowSize;
- } afAPSF_Config_t;
- typedef struct _epList_t {
- struct _epList_t *nextDesc;
- endPointDesc_t *epDesc;
- pDescCB pfnDescCB;
- afAPSF_Config_t apsfCfg;
- eEP_Flags flags;
- } epList_t;
- #define afStatus_SUCCESS ZSuccess
- #define afStatus_FAILED ZFailure
- #define afStatus_INVALID_PARAMETER ZInvalidParameter
- #define afStatus_MEM_FAIL ZMemError
- #define afStatus_NO_ROUTE ZNwkNoRoute
- typedef ZStatus_t afStatus_t;
- typedef struct
- {
- uint8 kvp;
- APSDE_DataReqMTU_t aps;
- } afDataReqMTU_t;
- extern epList_t *epList;
-
-
- #define afInit()
-
- extern epList_t *afRegisterExtended( endPointDesc_t *epDesc, pDescCB descFn );
-
- extern afStatus_t afRegister( endPointDesc_t *epDesc );
-
- extern afStatus_t afDelete( uint8 EndPoint );
-
- extern void afDataConfirm( uint8 endPoint, uint8 transID, ZStatus_t status );
-
- extern void afIncomingData( aps_FrameFormat_t *aff, zAddrType_t *SrcAddress, uint16 SrcPanId,
- NLDE_Signal_t *sig, uint8 nwkSeqNum, uint8 SecurityUse, uint32 timestamp );
- afStatus_t AF_DataRequest( afAddrType_t *dstAddr, endPointDesc_t *srcEP,
- uint16 cID, uint16 len, uint8 *buf, uint8 *transID,
- uint8 options, uint8 radius );
- afStatus_t AF_DataRequestSrcRtg( afAddrType_t *dstAddr, endPointDesc_t *srcEP,
- uint16 cID, uint16 len, uint8 *buf, uint8 *transID,
- uint8 options, uint8 radius, uint8 relayCnt,
- uint16* pRelayList );
-
- extern endPointDesc_t *afFindEndPointDesc( uint8 endPoint );
-
- extern uint8 afFindSimpleDesc( SimpleDescriptionFormat_t **ppDesc, uint8 EP );
-
- extern uint8 afDataReqMTU( afDataReqMTU_t* fields );
-
- extern uint8 afGetMatch( uint8 ep );
-
- extern uint8 afSetMatch( uint8 ep, uint8 action );
-
- extern uint8 afNumEndPoints( void );
-
- extern void afEndPoints( uint8 *epBuf, uint8 skipZDO );
-
- extern void afCopyAddress (afAddrType_t *afAddr, zAddrType_t *zAddr);
-
- void afAPSF_ConfigGet(uint8 endPoint, afAPSF_Config_t *pCfg);
-
- afStatus_t afAPSF_ConfigSet(uint8 endPoint, afAPSF_Config_t *pCfg);
- #ifdef __cplusplus
- }
- #endif
- #endif
|