📄 af.h
字号:
#ifndef AF_H
#define AF_H
/*********************************************************************
Filename: AF.h
Revised: $Date: 2007-02-23 11:29:38 -0800 (Fri, 23 Feb 2007) $
Revision: $Revision: 13588 $
Description:
This file contains the General Operational Framework definitions.
Notes:
Copyright (c) 2006 by Texas Instruments, Inc.
All Rights Reserved. Permission to use, reproduce, copy, prepare
derivative works, modify, distribute, perform, display or sell this
software and/or its documentation for any purpose is prohibited
without the express written consent of Texas Instruments, Inc.
*********************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
#include "ZComDef.h"
#include "nwk.h"
#include "APSMEDE.h"
/*********************************************************************
* CONSTANTS
*/
// Manage AF code size with the following conditional compilation flags.
#if !defined ( AF_KVP_SUPPORT )
#define AF_KVP_SUPPORT FALSE
#endif
#if !defined ( AF_V1_SUPPORT )
#define AF_V1_SUPPORT FALSE
#endif
#if !defined ( AF_FLOAT_SUPPORT )
#define AF_FLOAT_SUPPORT FALSE
#endif
#define AF_BROADCAST_ENDPOINT 0xFF
#define AF_FRAGMENTED 0x01
#define AF_ACK_REQUEST 0x10
#define AF_DISCV_ROUTE 0x20
#define AF_EN_SECURITY 0x40
#define AF_SKIP_ROUTING 0x80
// Backwards support for afAddOrSendMessage / afFillAndSendMessage.
#if ( AF_V1_SUPPORT || AF_KVP_SUPPORT )
#define AFCMD_KVPMSG_TRANSID 1
#endif
#define AF_TX_OPTIONS_NONE 0
#define AF_MSG_ACK_REQUEST AF_ACK_REQUEST
// Default Radius Count value
#define AF_DEFAULT_RADIUS DEF_NWK_RADIUS
/*********************************************************************
* Node Descriptor
*/
#define AF_MAX_USER_DESCRIPTOR_LEN 16
#define AF_USER_DESCRIPTOR_FILL 0x20
typedef struct
{
byte len; // Length of string descriptor
byte desc[AF_MAX_USER_DESCRIPTOR_LEN];
} UserDescriptorFormat_t;
// Node Logical Types
#define NODETYPE_COORDINATOR 0x00
#define NODETYPE_ROUTER 0x01
#define NODETYPE_DEVICE 0x02
// Node Frequency Band - bit map
#define NODEFREQ_800 0x01 // 868 - 868.6 MHz
#define NODEFREQ_900 0x04 // 902 - 928 MHz
#define NODEFREQ_2400 0x08 // 2400 - 2483.5 MHz
// Node MAC Capabilities - bit map
// Use CAPINFO_ALTPANCOORD, CAPINFO_DEVICETYPE_FFD,
// CAPINFO_DEVICETYPE_RFD, CAPINFO_POWER_AC,
// and CAPINFO_RCVR_ON_IDLE from NLMEDE.h
// Node Descriptor format structure
typedef struct
{
byte LogicalType:3;
byte ComplexDescAvail:1; /* AF_V1_SUPPORT - reserved bit. */
byte UserDescAvail:1; /* AF_V1_SUPPORT - reserved bit. */
byte Reserved:3;
byte APSFlags:3;
byte FrequencyBand:5;
byte CapabilityFlags;
byte ManufacturerCode[2];
byte MaxBufferSize;
byte MaxTransferSize[2];
uint16 ServerMask;
} NodeDescriptorFormat_t;
// Bit masks for the ServerMask.
#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
/*********************************************************************
* Node Power Descriptor
*/
// Node Current Power Modes (CURPWR)
// Receiver permanently on or sync with coordinator beacon.
#define NODECURPWR_RCVR_ALWAYS_ON 0x00
// Receiver automatically comes on periodically as defined by the
// Node Power Descriptor.
#define NODECURPWR_RCVR_AUTO 0x01
// Receiver comes on when simulated, eg by a user pressing a button.
#define NODECURPWR_RCVR_STIM 0x02
// Node Available Power Sources (AVAILPWR) - bit map
// Can be used for AvailablePowerSources or CurrentPowerSource
#define NODEAVAILPWR_MAINS 0x01 // Constant (Mains) power
#define NODEAVAILPWR_RECHARGE 0x02 // Rechargeable Battery
#define NODEAVAILPWR_DISPOSE 0x04 // Disposable Battery
// Power Level
#define NODEPOWER_LEVEL_CRITICAL 0x00 // Critical
#define NODEPOWER_LEVEL_33 0x04 // 33%
#define NODEPOWER_LEVEL_66 0x08 // 66%
#define NODEPOWER_LEVEL_100 0x0C // 100%
// Node Power Descriptor format structure
typedef struct
{
unsigned int PowerMode:4;
unsigned int AvailablePowerSources:4;
unsigned int CurrentPowerSource:4;
unsigned int CurrentPowerSourceLevel:4;
} NodePowerDescriptorFormat_t;
/*********************************************************************
* Simple Descriptor
*/
// AppDevVer values
#if ( AF_V1_SUPPORT )
#define APPDEVVER_1 0x00
#else
#define APPDEVVER_1 0x01
#endif
// AF_V1_SUPPORT AppFlags - bit map
#define APPFLAG_NONE 0x00 // Backwards compatibility to AF_V1.
// AF-AppFlags - bit map
#define AF_APPFLAG_NONE 0x00
#define AF_APPFLAG_COMPLEXDESC 0x01 // Complex Descriptor Available
#define AF_APPFLAG_USERDESC 0x02 // User Descriptor Available
typedef uint16 cId_t;
// Simple Description Format Structure
typedef struct
{
byte EndPoint;
uint16 AppProfId;
uint16 AppDeviceId;
byte AppDevVer:4;
byte Reserved:4; // AF_V1_SUPPORT uses for AppFlags:4.
byte AppNumInClusters;
cId_t *pAppInClusterList;
byte AppNumOutClusters;
cId_t *pAppOutClusterList;
} SimpleDescriptionFormat_t;
/*********************************************************************
* AF Message Format
*/
// Frame Types
#define FRAMETYPE_KVP 0x01 // 0001
#define FRAMETYPE_MSG 0x02 // 0010
#if ( AF_KVP_SUPPORT )
// Command Types
#define CMDTYPE_SET 0x01
#define CMDTYPE_EVENT 0x02
#define CMDTYPE_GET_ACK 0x04 // GET with ACK
#define CMDTYPE_SET_ACK 0x05 // SET with ACK
#define CMDTYPE_EVENT_ACK 0x06 // EVENT with ACK
#define CMDTYPE_GET_RESP 0x08 // GET Response
#define CMDTYPE_SET_RESP 0x09 // SET Response
#define CMDTYPE_EVENT_RESP 0x0A // EVENT Response
// Attribute Data Types
#define DATATYPE_NO_DATA 0x00
#define DATATYPE_UINT8 0x01 // unsigned integer 8 bit
#define DATATYPE_INT8 0x02 // signed integer 8 bit
#define DATATYPE_UINT16 0x03 // unsigned integer 16 bit
#define DATATYPE_INT16 0x04 // signed integer 16 bit
#define DATATYPE_SEMIPREC 0x0B // Semi-Precision (16 bit)
#define DATATYPE_ABS_TIME 0x0C // Absolute Time (32 bits)
#define DATATYPE_REL_TIME 0x0D // Relative Time (32 bits)
#define DATATYPE_CHAR_STR 0x0E // Character String
#define DATATYPE_OCTET_STR 0x0F // Octet String
// Error Codes
#define ERRORCODE_UNSUPPORTED_ATTRIB 0x03
#define ERRORCODE_INVALIDE_CMDTYPE 0x04
#define ERRORCODE_INVALID_DATALENGTH 0x05
#define ERRORCODE_INVALID_DATA 0x06
#endif
#define ERRORCODE_SUCCESS 0x00
#define AF_HDR_KVP_MAX_LEN 0x08 // Max possible AF KVP header.
#define AF_HDR_V1_0_MAX_LEN 0x03 // Max possible AF Ver 1.0 header.
#define AF_HDR_V1_1_MAX_LEN 0x00 // Max possible AF Ver 1.1 header.
#if ( AF_KVP_SUPPORT )
// Generalized KVP Command Format
typedef struct
{
byte TransSeqNumber;
unsigned int CommandType:4;
unsigned int AttribDataType:4;
uint16 AttribId;
byte ErrorCode; // Only used in responses
byte DataLength; // Number of bytes in TransData
byte *Data;
} afKVPCommandFormat_t;
#endif
#if ( AF_V1_SUPPORT || AF_KVP_SUPPORT )
// Add Or Send - Multiple Transactions
typedef enum
{
ADD_MESSAGE,
SEND_MESSAGE
} afAddOrSend_t;
#endif
// Generalized MSG Command Format
typedef struct
{
byte TransSeqNumber;
uint16 DataLength; // Number of bytes in TransData
byte *Data;
} afMSGCommandFormat_t;
typedef enum
{
noLatencyReqs,
fastBeacons,
slowBeacons
} afNetworkLatencyReq_t;
/*********************************************************************
* Endpoint Descriptions
*/
typedef enum
{
afAddrNotPresent = AddrNotPresent,
afAddr16Bit = Addr16Bit,
afAddrGroup = AddrGroup,
afAddrBroadcast = AddrBroadcast
} afAddrMode_t;
typedef struct
{
union
{
uint16 shortAddr;
} addr;
afAddrMode_t addrMode;
byte endPoint;
} afAddrType_t;
#if ( AF_KVP_SUPPORT )
typedef struct
{
osal_event_hdr_t hdr;
uint16 clusterId;
afAddrType_t srcAddr;
byte endPoint; // Destination endpoint
byte wasBroadcast;
uint8 LinkQuality;
byte SecurityUse;
byte count; // trans count number within packet (1-n)
byte totalTrans; // total number of trans in packet
afKVPCommandFormat_t cmd;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -