From b24866225a6301d3a663f874725e83c012dc25d3 Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Wed, 26 Dec 2012 17:36:00 +0100 Subject: digital/beacon: add bitcloud stack into common directory digital/zigbit --- .../bitcloud/stack/Components/ZDO/include/zdo.h | 1676 ++++++++++++++++++++ 1 file changed, 1676 insertions(+) create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/zdo.h (limited to 'digital/zigbit/bitcloud/stack/Components/ZDO/include/zdo.h') diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/zdo.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/zdo.h new file mode 100644 index 00000000..50b71edb --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/zdo.h @@ -0,0 +1,1676 @@ +/************************************************************************//** + \file zdo.h + + \brief The header file describes the public ZDO interface and ZDO types + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: +******************************************************************************/ + +#ifndef _ZDO_H +#define _ZDO_H + +#include +#include +#include +#include +#include + +// \cond internal +#define ZDP_REQUEST_MASK CCPU_TO_LE16(0x7FFF) +#define ZDP_RESPONSE_MASK CCPU_TO_LE16(0x8000) + +#ifdef _SECURITY_ +#define PRECONFIGURED_NETWORK_KEY NWK_PRECONFIGURED_NETWORK_KEY +#define PRECONFIGURED_TRUST_CENTER_LINK_KEY 1 +#define PRECONFIGURED_TRUST_CENTER_MASTER_KEY 2 +#define NOT_PRECONFIGURED NWK_NOT_PRECONFIGURED_NETWORK_KEY + +#ifndef ZDO_SECURITY_STATUS +#define ZDO_SECURITY_STATUS NOT_PRECONFIGURED +#endif //ZDO_SECURITY_STATUS + + +#define ZDO_NONE_SECURITY_MODE 0 +#define ZDO_STANDARD_SECURITY_MODE 1 +#define ZDO_HIGH_SECURITY_MODE 2 +#endif//_SECURITY_ + +#define MAX_REQUESTED_CLUSTER_NUMBER 9 +#define MAX_ACTIVE_EP_NUMBER 3 + +#define ZDP_NEIGBOR_TABLE_LIST_OFFSET 3U +#define ZDP_NEIGBOR_TABLE_LIST_SIZE (APS_MAX_ASDU_SIZE / (ZDP_NEIGBOR_TABLE_LIST_OFFSET + sizeof(NeighborTableList_t))) +#define ZDP_ADDR_LIST_SIZE 10 +#define ZDP_BINDING_TABLE_LIST_SIZE 3 +// \endcond + +/*! +\brief ZDO result status primitives. +*/ +typedef enum +{ + //! The primitive has finished successfully + ZDO_SUCCESS_STATUS = 0x00, + //! Wrong parameters were put into the primitive + ZDO_INVALID_PARAMETERS_STATUS = 0x01, + ZDO_RESPONSE_WAIT_TIMEOUT_STATUS = 0x02, + //! ZDO layer is busy and cannot execute the primitive + ZDO_BUSY_STATUS = 0x04, + //! No network was found + ZDO_NO_NETWORKS_STATUS = 0x05, + //! There is a network with the same extended PANID + ZDO_EXTPANID_ALREADY_EXIST_STATUS = 0x06, + //! Unknown error + ZDO_FAIL_STATUS = 0x07, + ZDO_AUTHENTICATION_SUCCESS_STATUS = 0x08, + ZDO_AUTHENTICATION_FAIL_STATUS = 0x09, + ZDO_SECURITY_SUCCESS_STATUS = 0x0A, + ZDO_SECURITY_FAIL_STATUS = 0x0B, + ZDO_SECURITY_NOT_SUPPORTED_STATUS = 0x0C, + //! Indicates that command execution has finished. For a match descriptor + //request the confirmation with this status is issued if the timeout for + //ZDP response has exceeded and the stack has ceased waiting + ZDO_CMD_COMPLETED_STATUS = 0x0D, + ZDO_KEY_ESTABLISHMENT_NOT_SUPPORTED_STATUS = 0x0E, + + //! Trust center could not find key pair descriptor to authenticate device + ZDO_NO_KEY_PAIR_DESCRIPTOR_STATUS = 0x50, + + //! Link key for device was updated + ZDO_UPDATE_LINK_KEY_STATUS = 0x51, + //! Master key for device was updated + ZDO_UPDATE_MASTER_KEY_STATUS = 0x52, + //! Key pair descriptor was deleted + ZDO_DELETE_KEY_PAIR_STATUS = 0x53, + //! Link key for device was deleted + ZDO_DELETE_LINK_KEY_STATUS = 0x54, + + //! TC is not responding to keep-alive requests + ZDO_TC_NOT_AVAILABLE_STATUS = 0x60, + + //! ZDP request is invalid + ZDO_INVALID_REQUEST_STATUS = 0x80, + //! Requested device was not found + ZDO_DEVICE_NOT_FOUND_STATUS = 0x81, + //! Unsupported endpoint of 0x00 or between 0xF1 and 0xFF was requested + ZDO_INVALID_EP_STATUS = 0x82, + //! Requested endpoint has not been registered + ZDO_NOT_ACTIVE_STATUS = 0x83, + //! Requested optional feature is not supported + ZDO_NOT_SUPPORTED_STATUS = 0x84, + //! Timeout occured during the requested operation + ZDO_TIMEOUT_STATUS = 0x85, + //! End device bind request is unsuccessful due to a failure to match any suitable clusters + ZDO_NO_MATCH_STATUS = 0x86, + //! Unbind request is unsuccessful + ZDO_NO_ENTRY_STATUS = 0x88, + //! Child descriptor is not available + ZDO_NO_DESCRIPTOR_STATUS = 0x89, + //! Device does not have enough storage space + ZDO_INSUFFICIENT_SPACE_STATUS = 0x8A, + //! The device does not have storage space to support the requested operation. + ZDO_NOT_PERMITTED_STATUS = 0x8B, + //! Device does not have enough table space + ZDO_TABLE_FULL_STATUS = 0x8C, + //! Request is not authorized from this device + ZDO_NOT_AUTHORIZED_STATUS = 0x8D, + //! Network parameters have been updated (channel, PanId, shortAddr...) + ZDO_NWK_UPDATE_STATUS = 0x8E, + //! Device has joined/rejoined a network and data can be transmitted + ZDO_NETWORK_STARTED_STATUS = 0x8F, + //! Device has lost connection with a parent and the stack tries rejoin by itself. In this case transmission should be stopped. + ZDO_NETWORK_LOST_STATUS = 0x90, + //! Device has left a network. If autonetwork option is on, the stack will rejoin a network. Otherwise, an application should rejoin. + ZDO_NETWORK_LEFT_STATUS = 0x91, + //! New device has joined a network as a child of this device + ZDO_CHILD_JOINED_STATUS = 0x92, + //! Child has been removed from children list + ZDO_CHILD_REMOVED_STATUS = 0x93, + //! User descriptor is changed event + ZDO_USER_DESCRIPTOR_UPDATE_STATUS = 0x94, + //! On the device with static addressing the conflict of network addresses has been detected + ZDO_STATIC_ADDRESS_CONFLICT_STATUS = 0x95 +} ZDO_Status_t; + +/**************************************************************************//** +\brief Types of response to address request +******************************************************************************/ +enum +{ + SINGLE_RESPONSE_REQUESTTYPE = 0x00, + EXTENDED_RESPONSE_REQUESTTYPE = 0x01 +}; + +/*! +\brief The ZDP clusters ID list. + + +The ZDP cluster ID determines the type of ZDP request/confirm +*/ +enum +{ +// Device and Service Discovery commands + NWK_ADDR_CLID = CCPU_TO_LE16(0x0000),//!< Request for the 16-bit address of a remote device based on its known IEEE address. + IEEE_ADDR_CLID = CCPU_TO_LE16(0x0001),//!< Request for the 64-bit IEEE address of a remote device based on its known 16-bit address. + NODE_DESCRIPTOR_CLID = CCPU_TO_LE16(0x0002),//!< Request for the node descriptor of a remote device. + POWER_DESCRIPTOR_CLID = CCPU_TO_LE16(0x0003),//!< Request for the power descriptor of a remote device. + SIMPLE_DESCRIPTOR_CLID = CCPU_TO_LE16(0x0004),//!< Request for the simple descriptor of a remote device on the specified endpoint. + ACTIVE_ENDPOINTS_CLID = CCPU_TO_LE16(0x0005),//!< Request for the list of endpoints on a remote device with simple descriptors. + MATCH_DESCRIPTOR_CLID = CCPU_TO_LE16(0x0006),//!< Request for remote devices supporting a specific simple descriptor match criterion. + COMPLEX_DESCRIPTOR_CLID = CCPU_TO_LE16(0x0010),//!< Request for the complex descriptor of a remote device. + USER_DESCRIPTOR_CLID = CCPU_TO_LE16(0x0011),//!< Request for the user descriptor of a remote device. + DISCOVERY_CASH_CLID = CCPU_TO_LE16(0x0012),//!< Request to locate a Primary Discovery Cache device on the network. + DEVICE_ANNCE_CLID = CCPU_TO_LE16(0x0013),//!< Request to notify other ZigBee devices on the network that the device has joined or re-joined the network. + USER_DESC_CONF_CLID = CCPU_TO_LE16(0x0014),//!< Command to configure the user descriptor on a remote device. + SYSTEM_SERVER_DISCOVERY_CLID = CCPU_TO_LE16(0x0015),//!< Request for the location of a particular system server or servers. + DISCOVERY_STORE_CLID = CCPU_TO_LE16(0x0016),//!< Request for the storage of the device's discovery cache information on a Primary Discovery Cache device. + NODE_DESC_STORE_CLID = CCPU_TO_LE16(0x0017),//!< Request for the storage of the device's Node Descriptor on a Primary Discovery Cache device. + POWER_DESC_STORE_CLID = CCPU_TO_LE16(0x0018),//!< Request for the storage of the device's Descriptor on a Primary Discovery Cache device. + ACTIVE_EP_STORE_CLID = CCPU_TO_LE16(0x0019),//!< Request for the storage of the device's list of Active Endpoints on a Primary Discovery Cache device. + SIMPLE_DESC_STORE_CLID = CCPU_TO_LE16(0x001A),//!< Request for the storage of the device's list of Simple Descriptors on a Primary Discovery Cache device. + REMOVE_NODE_CACHE_CLID = CCPU_TO_LE16(0x001B),//!< Command for removal of discovery cache information for a specified ZigBee end device from a Primary Discovery Cache device. + FIND_NODE_CACHE_CLID = CCPU_TO_LE16(0x001C),//!< Request for a device on the network that holds discovery information for the device of interest. + EXTENDED_SIMPLE_DESC_CLID = CCPU_TO_LE16(0x001D),//!< Request for the simple descriptor of a remote device on the specified endpoint, to be used with devices which support more active endpoints than can be returned by a single ::SIMPLE_DESCRIPTOR_CLID request. + EXTENDED_ACTIVE_EP_CLID = CCPU_TO_LE16(0x001E),//!< Request for the list of endpoints on a remote device with simple descriptors, to be used with devices which support more active endpoints than can be returned by a single ::ACTIVE_ENDPOINTS_CLID request. +// Bind client manager commands + END_DEVICE_BIND_CLID = CCPU_TO_LE16(0x0020),//!< Request generated from a Local Device wishing to perform End Device Bind with a Remote Device. + BIND_CLID = CCPU_TO_LE16(0x0021),//!< Request generated from a Local Device wishing to create a Binding Table entry for the source and destination addresses contained as parameters. + UNBIND_CLID = CCPU_TO_LE16(0x0022),//!< Request generated from a Local Device wishing to remove a Binding Table entry for the source and destination addresses contained as parameters. + BIND_REGISTER_CLID = CCPU_TO_LE16(0x0023),//!< Request generated from a Local Device and sent to a primary binding table cache device to register that the local device wishes to hold its own binding table entries. + REPLACE_DEVICE_CLID = CCPU_TO_LE16(0x0024),//!< Request sent to a primary binding table cache device to change all binding table entries which match OldAddress and OldEndpoint as specified. + STORE_BCKUP_BIND_ENTRY_CLID = CCPU_TO_LE16(0x0025),//!< Request generated from a local primary binding table cache and sent to a remote backup binding table cache device to request backup storage of the entry. + REMOVE_BCKUP_BIND_ENTRY_CLID = CCPU_TO_LE16(0x0026),//!< Request generated from a local primary binding table cache and sent to a remote backup binding table cache device to request removal of the entry from backup storage. + BACKUP_BIND_TABLE_CLID = CCPU_TO_LE16(0x0027),//!< Request generated from a local primary binding table cache and sent to the remote backup binding table cache device to request backup storage of its entire binding table. + RECOVER_BIND_TABLE_CLID = CCPU_TO_LE16(0x0028),//!< Request generated from a local primary binding table cache and sent to a remote backup binding table cache device when it wants a complete restore of the binding table. + BACKUP_SOURCE_BIND_CLID = CCPU_TO_LE16(0x0029),//!< Request generated from a local primary binding table cache and sent to a remote backup binding table cache device to request backup storage of its entire source table. + RECOVER_SOURCE_BIND_CLID = CCPU_TO_LE16(0x002A),//!< Request generated from a local primary binding table cache and sent to the remote backup binding table cache device when it wants a complete restore of the source binding table. +// Network Management Client Services commands + MGMT_NWK_DISC_CLID = CCPU_TO_LE16(0x0030),//!< Request generated from a Local Device requesting that the Remote Device execute a Scan to report back networks in the vicinity of the Local Device. + MGMT_LQI_CLID = CCPU_TO_LE16(0x0031),//!< Request generated from a Local Device wishing to obtain a neighbor list for the Remote Device along with associated LQI values to each neighbor. + MGMT_RTG_CLID = CCPU_TO_LE16(0x0032),//!< Request generated from a Local Device wishing to retrieve the contents of the Routing Table from the Remote Device. + MGMT_BIND_CLID = CCPU_TO_LE16(0x0033),//!< Request generated from a Local Device wishing to retrieve the contents of the Binding Table from the Remote Device. + MGMT_LEAVE_CLID = CCPU_TO_LE16(0x0034),//!< Request generated from a Local Device requesting that a Remote Device leave the network or to request that another device leave the network. + MGMT_DIRECT_JOIN_CLID = CCPU_TO_LE16(0x0035),//!< Request generated from a Local Device requesting that a Remote Device permit a device designated by DeviceAddress to join the network directly. + MGMT_PERMIT_JOINING_CLID = CCPU_TO_LE16(0x0036),//!< Request generated from a Local Device requesting that a remote device or devices allow or disallow association. + MGMT_CACHE_CLID = CCPU_TO_LE16(0x0037),//!< Request The Mgmt_Cache_req is provided to enable ZigBee devices on the network to retrieve a list of ZigBee End Devices registered with a Primary Discovery Cache device. + MGMT_NWK_UPDATE_CLID = CCPU_TO_LE16(0x0038) //!< Command provided to allow updating of network configuration parameters or to request information from devices on network conditions in the local operating environment. +}; + +/**************************************************************************//** +\brief Possible address modes +******************************************************************************/ +typedef enum +{ + SHORT_ADDR_MODE, //!< Indicates that short address is used to point out a node + EXT_ADDR_MODE //!< Indicates that extended address is used to point out a node +} AddrMode_t; + +#define ZDO_MGMT_ED_SCAN_DUR_0 0x00 //!< Used as a value for ZDO_MgmtNwkUpdateReq_t::scanDuration +#define ZDO_MGMT_ED_SCAN_DUR_1 0x01 //!< Used as a value for ZDO_MgmtNwkUpdateReq_t::scanDuration +#define ZDO_MGMT_ED_SCAN_DUR_2 0x02 //!< Used as a value for ZDO_MgmtNwkUpdateReq_t::scanDuration +#define ZDO_MGMT_ED_SCAN_DUR_3 0x03 //!< Used as a value for ZDO_MgmtNwkUpdateReq_t::scanDuration +#define ZDO_MGMT_ED_SCAN_DUR_4 0x04 //!< Used as a value for ZDO_MgmtNwkUpdateReq_t::scanDuration +#define ZDO_MGMT_ED_SCAN_DUR_5 0x05 //!< Used as a value for ZDO_MgmtNwkUpdateReq_t::scanDuration +#define ZDO_MGMT_CHANNEL_CHANGE 0xFE //!< Used as a special value for ZDO_MgmtNwkUpdateReq_t::scanDuration +#define ZDO_MGMT_NWK_PARAMS_CHANGE 0xFF //!< Used as a special value for ZDO_MgmtNwkUpdateReq_t::scanDuration + +/**************************************************************************//** +\brief Information about the addresses of a device. +******************************************************************************/ +BEGIN_PACK +typedef struct PACK +{ + ShortAddr_t shortAddr; //!< Short address + ExtAddr_t extAddr; //!< Extended address +} NodeAddr_t; +END_PACK + +BEGIN_PACK +typedef struct PACK +{ + ShortAddr_t shortAddr; //!< Short address + ExtAddr_t extAddr; //!< Extended address + MAC_CapabilityInf_t capabilityInfo; //!< Device capability information +} ChildInfo_t; +END_PACK + +/**************************************************************************//** +\brief Describes the parameters of the ZDO_StartNetworkConf() function +******************************************************************************/ +typedef struct +{ + uint8_t activeChannel; //!< Current channel on which the device has connected. + ShortAddr_t shortAddr; //!< Assigned short address. + PanId_t PANId; //!< Received short network PANId. + uint64_t extPANId; //!< Received extended PANId if it was not determined during startup + ShortAddr_t parentAddr; //!< Parent short address + ZDO_Status_t status; //!< Resulting status of a network start operation +} ZDO_StartNetworkConf_t; + +/**************************************************************************//** +\brief Describes the parameters of the ZDO_StartNetworkReq() function +******************************************************************************/ +typedef struct +{ + /** \cond SERVICE_FIELDS **/ + struct + { + void *next; + } service; //!< Service field for internal use only, should not be touched by user + /** \endcond **/ + + ZDO_StartNetworkConf_t confirm; //!< Parameters of the confirm being returned in ZDO_StartNetworkConf() +#ifdef _NWK_SILENT_JOIN_ + NWK_RejoinNetwork_t startupType; //!< Startup type in case if Silent Join is enabled +#endif +#ifdef _LIGHT_LINK_PROFILE_ + ShortAddr_t parent; //!< Known parent address (0xffff if unknown) +#endif // _LIGHT_LINK_PROFILE_ + void (*ZDO_StartNetworkConf)(ZDO_StartNetworkConf_t *conf); //!< The callback function to be called to confirm the request +} ZDO_StartNetworkReq_t; + +/**************************************************************************//** +\brief Desribes the parameters of the ZDO_ResetNetworkConf() function + *****************************************************************************/ +typedef struct +{ + ZDO_Status_t status; //!< Result of the reset request +} ZDO_ResetNetworkConf_t; + +/**************************************************************************//** +\brief Describes the parameters of the ZDO_ResetNetworkReq() function +******************************************************************************/ +typedef struct +{ + ZDO_ResetNetworkConf_t confParams; //!< Parameters of the confirm being returned in ZDO_ResetNetworkConf() + void (*ZDO_ResetNetworkConf)(ZDO_ResetNetworkConf_t *conf); //!< The function called to confirm the request +} ZDO_ResetNetworkReq_t; + +/**************************************************************************//** +\brief This information is provided to enable ZigBee devices to report +the condition on local channels to a network manager. The scanned channel list is +the report of channels scanned and it is followed by a list of records, one for each +channel scanned, each record including one byte of the energy level measured +during the scan, or 0xff if there is too much interference on this channel. +******************************************************************************/ +BEGIN_PACK +typedef struct PACK +{ + uint32_t scannedChannels; //!< Bit mask of channels scanned by the request + uint16_t totalTransmissions; //!< Count of transmissions reported by the device + uint16_t transmissionsFailures; //!< Count of transmission failures reported by the device + uint8_t scannedChannelsListCount; //!< Number of records contained in the energyValues[] list + uint8_t energyValues[32]; /*! Results of energy measurements by channel. +Each value is within the range from 0 to 84. Actually measured input power +in dBm can be obtained by subtracting 91.*/ +} EDScan_t; +END_PACK + +/**************************************************************************//** +\brief This information is provided to inform an application about new network parameters +if a device rejoined a network. +******************************************************************************/ +BEGIN_PACK +typedef struct PACK +{ + ShortAddr_t parentShortAddr; //!< Parent short address + PanId_t panId; //!< PAN ID of a network + uint8_t currentChannel; //!< Current channel + ShortAddr_t shortAddr; //!< New short address +} NetworkInf_t; +END_PACK +/**************************************************************************//** +\brief The type used to pack information about network updates in an argument of ZDO_MgmtNwkUpdateNotf() function + +The struct of this type comprises information about certain network updates. The type of the event is indicated by the ZDO_MgmtNwkUpdateNotf_t::status field. +Additional event data is provided by the fields of the unnamed union. +******************************************************************************/ +BEGIN_PACK +typedef struct PACK +{ + /*! The parameter shows the notification status and can be: + ZDO_SUCCESS_STATUS, + ZDO_INVALID_PARAMETERS_STATUS, + ZDO_FAIL_STATUS, + ZDO_RESPONSE_WAIT_TIMEOUT_STATUS, + ZDO_NETWORK_STARTED_STATUS, + ZDO_NETWORK_LEFT_STATUS, + ZDO_NETWORK_LOST_STATUS, + ZDO_CHILD_JOINED_STATUS, + ZDO_CHILD_REMOVED_STATUS, + ZDO_USER_DESCRIPTOR_UPDATE_STATUS, + ZDO_STATIC_ADDRESS_CONFLICT_STATUS, + ZDO_NWK_UPDATE_STATUS + ZDO_NO_KEY_PAIR_DESCRIPTOR_STATUS*/ + uint8_t status; + union PACK + { + //! Conflicting address + ShortAddr_t conflictAddress; + //! ED scan result + EDScan_t scanResult; + //! Network information updated + NetworkInf_t nwkUpdateInf; + //! Information about joined device or failed to authenticate child event + ChildInfo_t childInfo; + //! Addresses of removed device + NodeAddr_t childAddr; + //! Extended address of updated device + ExtAddr_t deviceExtAddr; + }; +} ZDO_MgmtNwkUpdateNotf_t; +END_PACK + +/**************************************************************************//** +\brief Desribes the parameters of the LQI response +******************************************************************************/ +BEGIN_PACK +typedef struct PACK _NeighborTableList_t +{ + ExtPanId_t extPanId; + ExtAddr_t extAddr; + ShortAddr_t networkAddr; + LITTLE_ENDIAN_OCTET(4, ( + uint8_t deviceType : 2, + uint8_t rxOnWhenIdle : 2, + uint8_t relationship : 3, + uint8_t reserved1 : 1 + )) + LITTLE_ENDIAN_OCTET(2, ( + uint8_t permitJoining : 2, + uint8_t reserved2 : 6 + )) + uint8_t depth; + uint8_t lqi; +} NeighborTableList_t; + +typedef struct PACK _ZDO_MgmtLqiResp_t +{ + uint8_t neighborTableEntries; + uint8_t startIndex; + uint8_t neighborTableListCount; + NeighborTableList_t neighborTableList[ZDP_NEIGBOR_TABLE_LIST_SIZE]; +} ZDO_MgmtLqiResp_t; +END_PACK + +/**************************************************************************//** +\brief Desribes the parameters of the LQI request +******************************************************************************/ +typedef struct +{ + uint8_t startIndex; +} ZDO_MgmtLqiReq_t; + +/**************************************************************************//** +\brief Desribes the parameters of the ZDO_SleepConf() function +******************************************************************************/ +typedef struct +{ + /*! Stack is ready to sleep if status is ZDO_SUCCESS_STATUS, + stack is not ready to sleep if status is ZDO_BUSY_STATUS */ + ZDO_Status_t status; +} ZDO_SleepConf_t; + +/**************************************************************************//** +\brief Describes the parameters of the ZDO_SleepReq() function +******************************************************************************/ +typedef struct +{ + ZDO_SleepConf_t confirm; //!< Parameters of the confirm being returned in ZDO_SleepConf() + void (*ZDO_SleepConf)(ZDO_SleepConf_t *conf); //!< The function called to confirm the request +} ZDO_SleepReq_t; + +/**************************************************************************//** +\brief Describes the parameters of the ZDO_WakeUp() function +******************************************************************************/ +typedef struct +{ + ZDO_Status_t status; //!< Result of the wakeup request +} ZDO_WakeUpConf_t; + +/**************************************************************************//** +\brief Describes the parameters of the ZDO_SleepReq() function +******************************************************************************/ +typedef struct +{ + ZDO_WakeUpConf_t confirm; //!< Parameters of the confirm being returned in ZDO_WakeUpConf() + void (*ZDO_WakeUpConf)(ZDO_WakeUpConf_t *conf); //!< The function called to confirm the request +} ZDO_WakeUpReq_t; + +/**************************************************************************//** +\brief This request is generated from a Local Device wishing to inquire as to the +16-bit address of the Remote Device based on its known IEEE address. The +destination addressing on this command shall be unicast or broadcast to all +devices for which macRxOnWhenIdle = TRUE. +******************************************************************************/ +BEGIN_PACK +typedef struct PACK +{ + /*! The IEEE address to be matched by the Remote Device */ + ExtAddr_t ieeeAddrOfInterest; + /*! Request type for this command: + 0x00 Single device response + 0x01 Extended response + 0x02-0xFF reserved */ + uint8_t reqType; + /*! If the Request type for this command is + Extended response, the StartIndex + provides the starting index for the + requested elements of the associated + devices list*/ + uint8_t startIndex; +} ZDO_NwkAddrReq_t; + +/**************************************************************************//** +\brief This request is generated from a Local Device wishing to inquire as to the +64-bit IEEE address of the Remote Device based on their known 16-bit address. +The destination addressing on this command shall be unicast. +******************************************************************************/ +typedef struct PACK +{ + /*! NWK address that is used for IEEE address mapping. */ + ShortAddr_t nwkAddrOfInterest; + /*! Request type for this command: + 0x00 Single device response + 0x01 Extended response + 0x02-0xff reserved */ + uint8_t reqType; + /*! If the Request type for this + command is Extended response, the + StartIndex provides the starting + index for the requested elements of + the associated devices list.*/ + uint8_t startIndex; +} ZDO_IeeeAddrReq_t; + +/**************************************************************************//** +\brief This request is generated from a local device wishing to inquire +as to the node descriptor of a remote device. This command shall be unicast either +to the remote device itself or to an alternative device that contains the discovery +information of the remote device. +******************************************************************************/ +typedef struct PACK +{ + ShortAddr_t nwkAddrOfInterest; //!< NWK address for the node descriptor request +} ZDO_NodeDescReq_t; + +/**************************************************************************//** +\brief This request is generated from a local device wishing to +inquire as to the power descriptor of a remote device. This command shall be +unicast either to the remote device itself or to an alternative device that contains +the discovery information of the remote device. +******************************************************************************/ +typedef struct PACK +{ + ShortAddr_t nwkAddrOfInterest; //!< NWK address for the power descriptor request +} ZDO_PowerDescReq_t; + +/**************************************************************************//** +\brief This request is generated from a local device wishing to acquire +the list of endpoints on a remote device with simple descriptors. This command +shall be unicast either to the remote device itself or to an alternative device that +contains the discovery information of the remote device. +******************************************************************************/ +typedef struct PACK +{ + ShortAddr_t nwkAddrOfInterest; //!< NWK address for the active endpoints request +} ZDO_ActiveEPReq_t; + +/**************************************************************************//** +\brief This request is generated from a local device wishing to +inquire as to the complex descriptor of a remote device. This command shall be +unicast either to the remote device itself or to an alternative device that contains +the discovery information of the remote device. +******************************************************************************/ +typedef struct PACK +{ + ShortAddr_t nwkAddrOfInterest; //!< NWK address for the complex descriptor request +} ZDO_ComplexDescReq_t; + +/**************************************************************************//** +\brief This request is generated from a local device wishing to inquire +as to the user descriptor of a remote device. This command shall be unicast either +to the remote device itself or to an alternative device that contains the discovery +information of the remote device. +******************************************************************************/ +typedef struct PACK +{ + ShortAddr_t nwkAddrOfInterest; //!< NWK address for the user descriptor request +} ZDO_UserDescReq_t; + +/**************************************************************************//** +\brief This is generated from a local device wishing to +configure the user descriptor on a remote device. This command shall be unicast +either to the remote device itself or to an alternative device that contains the +discovery information of the remote device. +******************************************************************************/ +typedef struct PACK +{ + ShortAddr_t nwkAddrOfInterest; //!< NWK address for the user descriptor setting request + UserDescriptor_t userDescriptor; //!< The user descriptor of a device +} ZDO_UserDescSetReq_t; + +/**************************************************************************//** +\brief This request is generated from a local device wishing to +inquire as to the simple descriptor of a remote device on a specified endpoint. This +command shall be unicast either to the remote device itself or to an alternative +device that contains the discovery information of the remote device. +******************************************************************************/ +typedef struct PACK +{ + ShortAddr_t nwkAddrOfInterest; //!< NWK address for the simple descriptor request + Endpoint_t endpoint; //!< The endpoint on the destination +} ZDO_SimpleDescReq_t; + +/**************************************************************************//** +\brief This request is provided to enable ZigBee devices on the network to notify +other ZigBee devices that the device has joined or re-joined the network, +identifying the devices 64-bit IEEE address and new 16-bit NWK address, and +informing the Remote Devices of the capability of the ZigBee device. This +command shall be invoked for all ZigBee end devices upon join or rejoin. This +command may also be invoked by ZigBee routers upon join or rejoin as part of +NWK address conflict resolution. The destination addressing on this primitive is +broadcast to all devices for which macRxOnWhenIdle = TRUE. +******************************************************************************/ +typedef struct PACK +{ + ShortAddr_t nwkAddrLocal; //!< NWK address for the Local Device + ExtAddr_t ieeeAddrLocal; //!< IEEE address for the Local Device + MAC_CapabilityInf_t macCapability; //!< Capability of the local device +} ZDO_DeviceAnnceReq_t; + +/**************************************************************************//** +\brief This request is generated from a Local Device wishing to +discover the location of a particular system server or servers as indicated by the +ServerMask parameter. The destination addressing on this request is broadcast to +all devices for which macRxOnWhenIdle = TRUE +******************************************************************************/ +typedef struct PACK +{ + uint16_t serverMask; //!< Server mask field of the node descriptor +} ZDO_SystemServerDiscoveryReq_t; + +#ifdef _BINDING_ +/**************************************************************************//** +\brief ZDO Match Descriptor request primitive allows to find remote devices + supporting a specific simple descriptor match criterion. + ZigBee spec r17 Table 2.50 page 105. +******************************************************************************/ +typedef struct PACK +{ + /*! NWK address for the request.*/ + ShortAddr_t nwkAddrOfInterest; + /*! Profile ID to be matched at the destination.*/ + ProfileId_t profileId; + /*! The number of Input Clusters provided for matching within the InClusterList.*/ + uint8_t numInClusters; + /*! List of Input ClusterIDs to be used for matching; the InClusterList is the + desired list to be matched by the Remote Device (the elements of the InClusterList + are the supported output clusters of the Local Device).*/ + ClusterId_t inClusterList[MAX_REQUESTED_CLUSTER_NUMBER]; + /*! The number of Output Clusters provided for matching within OutClusterList.*/ + uint8_t numOutClusters; + /*! List of Output ClusterIDs to be used for matching; the OutClusterList is the + desired list to be matched by the Remote Device (the elements of the OutClusterList + are the supported input clusters of the Local Device).*/ + ClusterId_t outClusterList[MAX_REQUESTED_CLUSTER_NUMBER]; +} ZDO_MatchDescReq_t; + +/**************************************************************************//** +\brief (ClusterID = 0x0020) This request is generated from a Local Device wishing +to perform End Device with a Remote Device. The End Device Bind Request is generated, +typically based on some user action like a button press. The destination addressing +on this command shall be unicast, and the destination addressshall be that of the ZigBee +Coordinator. +******************************************************************************/ +typedef struct PACK +{ + /*! The address of the target for binding. This is a short address of the + local device.*/ + ShortAddr_t bindingTarget; + /*! The IEEE address of the device generating the request.*/ + ExtAddr_t srcExtAddr; + /*! The endpoint on the device generating the request.*/ + Endpoint_t srcEndpoint; + /*! ProfileID wich is to be matched between two End_Device_Bind_Req received + at the ZigBee Coordinator within the timeout value pre-configured in the + ZigBee Coordinator.*/ + ProfileId_t profileId; + /*! The Number of Input Clusters provided for end device binding within the + inClusterList.*/ + uint8_t numInClusters; + /*! List of Input ClusterIDs to be used for matching. The inClusterList is the + desired list to be matched by the ZigBee Coordinator with the Remote Device's + output clusters (the elements of the inClusterList are supported input + clusters of the Local Device).*/ + ClusterId_t inClusterList[MAX_REQUESTED_CLUSTER_NUMBER]; + /*! The number of Output Clusters provided for matching within outClusterList.*/ + uint8_t numOutClusters; + /*! List of Output ClusterIDs to be used for matching. The outClusterList is + the desired list to be matched by the ZigBee Coordinator with the Remote Device's + input clusters (the elements of the outClusterList are supported output clusters + of the Local Device).*/ + ClusterId_t outClusterList[MAX_REQUESTED_CLUSTER_NUMBER]; +} ZDO_EndDeviceBindReq_t; + +/**************************************************************************//** +\brief (ClusterID = 0x0021) This request is generated from a Local Device wishing +to create a Binding Table entry for the source and destination addresses contained +as parameters. The destination addressing on this command shall be unicast only, +and the destination address shall be SrcAddress itself. +******************************************************************************/ +typedef struct PACK +{ + /*! The IEEE address for the source.*/ + ExtAddr_t srcAddr; + /*! The source endpoint for the binding entry.*/ + Endpoint_t srcEndpoint; + /*! The identifier of the cluster on the source device that is bound to the + destination */ + ClusterId_t clusterId; + /*! The addressing mode for the destination address used in this command. This + field can take one of the none-reserved values from the following list: + 0x00 = reserved + 0x01 = 16-bit group address for dstAddr and dstEndoint not present. + 0x02 = reserved + 0x03 = 64-bit extended address for dstAddr and dstEndpoint present + 0x04 - 0xff = reserved*/ + uint8_t dstAddrMode; + /*! The destination address for the binding entry.*/ + union PACK + { + struct PACK + { + ExtAddr_t dstExtAddr; + /*! This field shall be present only if the dstAddrMode field has a value of + 0x03 and, if present, shall be the destination endpoint for the binding entry.*/ + Endpoint_t dstEndpoint; + }; + ShortAddr_t dstGroupAddr; + }; +} ZDO_BindReq_t; + +/**************************************************************************//** +\brief Declaration of ZDO Bind indication parameters structure. For details go +to ZDO_BindReq declaration. ZB Specification extension! +******************************************************************************/ +typedef ZDO_BindReq_t ZDO_BindInd_t; + +/**************************************************************************//** +\brief (ClusterID = 0x0022) This request is generated from a Local Device wishing +to remove a Binding Table entry for the source and destination addresses contained +as parameters. The destination addressing on this command shall be unicast only, +and the destination address shall be SrcAddress itself. +******************************************************************************/ +typedef ZDO_BindReq_t ZDO_UnbindReq_t; + +/**************************************************************************//** +\brief Declaration of ZDO Unbind indication parameters structure. For details go +to ZDO_UnbindReq declaration. ZB Specification extension! +******************************************************************************/ +typedef ZDO_UnbindReq_t ZDO_UnbindInd_t; + +/**************************************************************************//** +\brief This request is generated from a Local Device wishing to retrieve the + contents of the Binding Table from the Remote Device. +******************************************************************************/ +typedef struct PACK +{ + /*! Starting Index for the requested elements of the Binding Table. */ + uint8_t startIndex; +} ZDO_MgmtBindReq_t; + +#endif // _BINDING_ + +/**************************************************************************//** +\brief This request is generated from a Local Device requesting that a Remote +Device leave the network or to request that another device leave the network. +The Mgmt_Leave_req is generated by a management application which directs the +request to a Remote Device where the NLME-LEAVE.request is to be executed +using the parameter supplied by Mgmt_Leave_req. + +Besides the deviceAddr field, the structure also has two more bit fields embraced into +a single octet and taking 1 or 0 as a value: + \li removeChildren - should be 1 to force the children of the affected node to + leave as well, otherwise, 0 + \li rejoin - if it equals 1 the destination node will attempt ro rejoin the network + after it leaves +******************************************************************************/ +typedef struct PACK +{ + ExtAddr_t deviceAddr; //!< IEEE address + LITTLE_ENDIAN_OCTET(3, ( + uint8_t reserved : 6, //!< Reserved; can not be changed by user. + /*! This field shall have a value of 1 if the + device being asked to leave the + network is also asked to + remove all its child devices, if any. + Otherwise, it has a value of 0.*/ + uint8_t removeChildren : 1, + /*! This field shall have a value of 1 if the + device being asked to leave from the + current parent is requested to rejoin + the network. Otherwise, it has a + value of 0.*/ + uint8_t rejoin : 1 + )) +} ZDO_MgmtLeaveReq_t; + +/**************************************************************************//** +\brief This request is generated from a Local Device requesting that +a remote device or devices allow or disallow association. +******************************************************************************/ +typedef struct PACK +{ + /*! Time span in seconds during + which the ZigBee coordinator or router + will allow associations. The value 0x00 + or 0xff indicate that permission is, respectively, + disabled or enabled permanently.*/ + uint8_t permitDuration; + /*! If this is set to 0x01 and the remote device is + the Trust Center, the command affects the + Trust Center authentication policy as + described in the sub-clauses below; If this is + set to 0x00, there is no effect on the Trust + Center.*/ + uint8_t tcSignificance; +} ZDO_MgmtPermitJoiningReq_t; + +/**************************************************************************//** +\brief This command is provided to allow updating of network configuration parameters +or to request information from devices on network conditions in the local +operating environment. The destination addressing on this primitive shall be +unicast or broadcast to all devices for which macRxOnWhenIdle = TRUE. +******************************************************************************/ +typedef struct PACK +{ + /*! The five most significant bits (b27,... b31) are reserved. The 27 least + significant bits (b0, b1,... b26) indicate which channels are to be scanned + (1 = scan, 0 = do not scan) for each of the 27 valid channels*/ + uint32_t scanChannels; + /*! Possible values are:\n +::ZDO_MGMT_ED_SCAN_DUR_0 (0x00) to ::ZDO_MGMT_ED_SCAN_DUR_5 (0x05) - request +to perform an ED scan with duration depending exponentially on the parameter value;\n +::ZDO_MGMT_CHANNEL_CHANGE (0xFE) - request to change the working channel to +the one specified by the ZDO_MgmtNwkUpdateReq_t::scanChannels bitmask;\n +::ZDO_MGMT_NWK_PARAMS_CHANGE (0xFF) - request to change the device +nwkUpdateId and nwkManagerAddr values to those contained in the request.\n +Other values are invalid.*/ + uint8_t scanDuration; + union PACK + { + /*! This field represents the number of + energy scans to be conducted and reported. + This field shall be present only if the + ZDO_MgmtNwkUpdateReq_t::scanDuration is within the range of + 0x00 to 0x05.*/ + uint8_t scanCount; + /*! The value of the nwkUpdateId + contained in this request. This value + is set by the Network Channel + Manager prior to sending the message. + This field shall only be present if the + ZDO_MgmtNwkUpdateReq_t::scanDuration is 0xFE or 0xFF.*/ + uint8_t nwkUpdateId; + }; + /*! This field shall be present only if the ZDO_MgmtNwkUpdateReq_t::scanDuration + is set to 0xFF, and, if present, indicates the NWK address + for the device with the Network Manager bit set in its Node Descriptor.*/ + ShortAddr_t nwkManagerAddr; +} ZDO_MgmtNwkUpdateReq_t; + +/**************************************************************************//** +\brief This command is generated by a Remote Device in response to a +NWK_addr_req command inquiring as to the NWK address of the Remote Device +or the NWK address of an address held in a local discovery cache. +The destination addressing on this command is unicast. +******************************************************************************/ +typedef struct PACK +{ + /*! 64-bit address for the Remote Device.*/ + ExtAddr_t ieeeAddrRemote; + /*! 16-bit address for the Remote Device.*/ + ShortAddr_t nwkAddrRemote; + /*! Count of the number of 16-bit short addresses to follow. + If the RequestType in the request is Extended Response + and there are no associated devices on the Remote + Device, this field shall be set to 0. + If an error occurs or the RequestType in the request is + for a Single Device Response, this field shall not + be included in the frame.*/ + uint8_t numAssocDev; + /*! Starting index into the list of associated devices for this report. + If the RequestType in the request is Extended Response and there are no associated + devices on the Remote Device, this field shall not be included in the frame. + If an error occurs or the RequestType in the request is for a Single Device + Response, this field shall not be included in the frame.*/ + uint8_t startIndex; + /*! A list of 16-bit addresses, one corresponding to each + associated device to Remote Device; The number of 16-bit + network addresses contained in this field is specified in the + NumAssocDev field. + If the RequestType in the request is Extended Response + and there are no associated devices on the Remote + Device, this field shall not be included in the frame. + If an error occurs or the RequestType in the request is + for a Single Device Response, this field shall not + be included in the frame.*/ + ShortAddr_t nwkAddrAssocDevList[ZDP_ADDR_LIST_SIZE]; +} ZDO_NwkAddrResp_t; + +/**************************************************************************//** +\brief This command is generated by a Remote Device in response to an +IEEE_addr_req command inquiring as to the 64-bit IEEE address of the Remote +Device or the 64-bit IEEE address of an address held in a local discovery cache. +The destination addressing on this command shall be unicast. +******************************************************************************/ +typedef struct PACK +{ + /*! 64-bit address for the Remote Device.*/ + ExtAddr_t ieeeAddrRemote; + /*! 16-bit address for the Remote Device.*/ + ShortAddr_t nwkAddrRemote; + /*! Count of the number of 16-bit short addresses to follow. + If the RequestType in the request is Extended + Response and there are no associated devices on the + Remote Device, this field shall be set to 0. + If an error occurs or the RequestType in the + request is for a Single Device Response, this + field shall not be included in the frame.*/ + uint8_t numAssocDev; + /*! Starting index into the list of associated devices for this report. + If the RequestType in the request is Extended + Response and there are no associated devices on the + Remote Device, this field shall not be included in the frame. + If an error occurs or the RequestType in the request is for a Single + Device Response, this field shall not be included in the frame.*/ + uint8_t startIndex; + /*! A list of 16-bit addresses, one corresponding to each + associated device to Remote Device; The number of 16-bit network + addresses contained in this field is specified in the NumAssocDev field. + If the RequestType in the request is Extended Response and there are no + associated devices on the Remote Device, this field + shall not be included in the frame. + If an error occurs or the RequestType in the request is for a Single + Device Response, this field shall not be included in the frame*/ + ShortAddr_t nwkAddrAssocDevList[ZDP_ADDR_LIST_SIZE]; +} ZDO_IeeeAddrResp_t; + +/**************************************************************************//** +\brief This command is generated by a remote device in response to a +Node_Desc_req directed to the remote device. This command shall be unicast to +the originator of the Node_Desc_req command. +******************************************************************************/ +typedef struct PACK +{ + ShortAddr_t nwkAddrOfInterest; //!< NWK address of the node descriptor request + NodeDescriptor_t nodeDescriptor; //!< Node descriptor of the device +} ZDO_NodeDescResp_t; + +/**************************************************************************//** +\brief This command is generated by a remote device in response to a +Power_Desc_req directed to the remote device. This command shall be unicast to +the originator of the Power_Desc_req command. +******************************************************************************/ +typedef struct PACK +{ + ShortAddr_t nwkAddrOfInterest; //!< NWK address of the power descriptor request + PowerDescriptor_t powerDescriptor; //!< Power descriptor of the device +} ZDO_PowerDescResp_t; + +/**************************************************************************//** +\brief This command is generated by a remote device in response to a +Complex_Desc_req directed to the remote device. This command shall be unicast +to the originator of the Complex_Desc_req command. +******************************************************************************/ +typedef struct PACK +{ + ShortAddr_t nwkAddrOfInterest; //!< NWK address of the complex descriptor request + uint8_t length; //!< Length in bytes of the ComplexDescriptor field. +} ZDO_ComplexDescResp_t; + +/**************************************************************************//** +\brief The User_Desc_rsp is generated by a remote device in response to a +User_Desc_req directed to the remote device. This command shall be unicast to +the originator of the User_Desc_req command. +******************************************************************************/ +typedef struct PACK +{ + ShortAddr_t nwkAddrOfInterest; //!< NWK address of the user descriptor request + UserDescriptor_t userDescriptor; //!< The user descriptor of a device +} ZDO_UserDescResp_t; + +/**************************************************************************//** +\brief This command is generated by a remote device in response to a +User_Desc_set directed to the remote device. This command shall be unicast to +the originator of the User_Desc_set command. +******************************************************************************/ +typedef struct PACK +{ + ShortAddr_t nwkAddrOfInterest; //!< NWK address of the user descriptor setting request +} ZDO_UserDescConfResp_t; + +/**************************************************************************//** +\brief This command is generated by a remote device in response to an +Active_EP_req directed to the remote device. This command shall be unicast to +the originator of the Active_EP_req command. +******************************************************************************/ +typedef struct PACK +{ + ShortAddr_t nwkAddrOfInterest; //!< NWK address of the active endpoints request + uint8_t activeEPCount; //!< Count of active endpoints on the remote device. + uint8_t activeEPList[MAX_ACTIVE_EP_NUMBER];//!< List of active endpoint Ids. +} ZDO_ActiveEPResp_t; + +/**************************************************************************//** +\brief The simple descriptor contains information specific to each endpoint contained in +this node. The simple descriptor is mandatory for each endpoint present in the node. +******************************************************************************/ +typedef struct PACK +{ + /*! The endpoint field of the simple descriptor is eight bits in length and specifies the + endpoint within the node to which this description refers. Applications shall only + use endpoints 1-240.*/ + Endpoint_t endpoint; + /*! The application profile identifier field of the simple descriptor is sixteen bits in + length and specifies the profile that is supported on this endpoint. Profile + identifiers shall be obtained from the ZigBee Alliance.*/ + ProfileId_t AppProfileId; + /*! The application device identifier field of the simple descriptor is sixteen bits in + length and specifies the device description supported on this endpoint. Device + description identifiers shall be obtained from the ZigBee Alliance.*/ + uint16_t AppDeviceId; + LITTLE_ENDIAN_OCTET(2, ( + /*! The application device version field of the simple descriptor is four bits in length + and specifies the version of the device description supported on this endpoint.*/ + uint8_t AppDeviceVersion : 4, + uint8_t Reserved : 4 + )) + /*! The application input cluster count field of the simple descriptor is eight bits in + length and specifies the number of input clusters, supported on this endpoint, that + will appear in the application input cluster list field. If the value of this field is + zero, the application input cluster list field shall not be included.*/ + uint8_t AppInClustersCount; + /*! The application input cluster list of the simple descriptor is 16*i bits in length, + where i is the value of the application input cluster count field. This field specifies + the list of input clusters supported on this endpoint, for use during the service + discovery and binding procedures. + The application input cluster list field shall be included only if the value of the + application input cluster count field is greater than zero.*/ + ClusterId_t AppInClustersList[MAX_REQUESTED_CLUSTER_NUMBER]; + /*! The application output cluster count field of the simple descriptor is eight bits in + length and specifies the number of output clusters, supported on this endpoint, that + will appear in the application output cluster list field. If the value of this field is + zero, the application output cluster list field shall not be included.*/ + uint8_t AppOutClustersCount; + /*! The application output cluster list of the simple descriptor is 16*o bits in length, + where o is the value of the application output cluster count field. This field + specifies the list of output clusters supported on this endpoint, for use during the + service discovery and binding procedures. + The application output cluster list field shall be included only if the value of the + application output cluster count field is greater than zero.*/ + ClusterId_t AppOutClustersList[MAX_REQUESTED_CLUSTER_NUMBER]; + +} ZdpSimpleDescriptor_t; + +/**************************************************************************//** +\brief This command is generated by a remote device in response to a +Simple_Desc_req directed to the remote device. This command shall be unicast to +the originator of the Simple_Desc_req command. +******************************************************************************/ +typedef struct PACK +{ + ShortAddr_t nwkAddrOfInterest; //!< NWK address of the simple descriptor request + uint8_t length; //!< Length in bytes of the Simple Descriptor to follow. + ZdpSimpleDescriptor_t simpleDescriptor; //!