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 --- .../stack/Components/ZDO/include/appFramework.h | 310 ++++ .../Components/ZDO/include/private/zdoBinding.h | 46 + .../stack/Components/ZDO/include/private/zdoDbg.h | 129 ++ .../ZDO/include/private/zdoDiscoveryManager.h | 24 + .../ZDO/include/private/zdoEndDeviceBinding.h | 134 ++ .../stack/Components/ZDO/include/private/zdoInit.h | 39 + .../ZDO/include/private/zdoLeaveNetwork.h | 111 ++ .../Components/ZDO/include/private/zdoManager.h | 116 ++ .../stack/Components/ZDO/include/private/zdoMem.h | 177 +++ .../ZDO/include/private/zdoNodeManager.h | 68 + .../Components/ZDO/include/private/zdoNwkManager.h | 87 + .../ZDO/include/private/zdoPowerManager.h | 66 + .../Components/ZDO/include/private/zdoReset.h | 75 + .../ZDO/include/private/zdoResetNetwork.h | 61 + .../ZDO/include/private/zdoStartNetwork.h | 127 ++ .../ZDO/include/private/zdoTaskManager.h | 66 + .../ZDO/include/private/zdoTcKeepAlive.h | 72 + .../Components/ZDO/include/private/zdoTcSwapOut.h | 92 ++ .../ZDO/include/private/zdoZdpFrameProcessor.h | 121 ++ .../Components/ZDO/include/private/zdoZdpManager.h | 65 + .../stack/Components/ZDO/include/private/zdoZib.h | 99 ++ .../bitcloud/stack/Components/ZDO/include/zdo.h | 1676 ++++++++++++++++++++ .../stack/Components/ZDO/include/zdoNotify.h | 108 ++ .../Components/ZDO/include/zdoSecurityManager.h | 85 + 24 files changed, 3954 insertions(+) create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/appFramework.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoBinding.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoDbg.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoDiscoveryManager.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoEndDeviceBinding.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoInit.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoLeaveNetwork.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoManager.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoMem.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoNodeManager.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoNwkManager.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoPowerManager.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoReset.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoResetNetwork.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoStartNetwork.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTaskManager.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTcKeepAlive.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTcSwapOut.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZdpFrameProcessor.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZdpManager.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZib.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/zdo.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/zdoNotify.h create mode 100644 digital/zigbit/bitcloud/stack/Components/ZDO/include/zdoSecurityManager.h (limited to 'digital/zigbit/bitcloud/stack/Components/ZDO/include') diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/appFramework.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/appFramework.h new file mode 100644 index 00000000..7924d250 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/appFramework.h @@ -0,0 +1,310 @@ +/***********************************************************************//** + \file appFramework.h + + \brief The header file describes the types of ZDP and descriptors + + \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 +*******************************************************************/ + +/****************************************************************************** +* The header file contains ZIGBEE type definitions*/ + +#ifndef _APPFRAMEWORK_H +#define _APPFRAMEWORK_H + +#include +#include +#include +#include + +#define ZDP_USER_DESC_FIELD_SIZE 16 + +// These defines are used only during preprocessor phase. Please use DeviceType_t enumeration values instead. +#define DEV_TYPE_COORDINATOR 0 +#define DEV_TYPE_ROUTER 1 +#define DEV_TYPE_ENDDEVICE 2 + +/******************************************************************************** +* Base types +********************************************************************************/ +typedef uint8_t Endpoint_t; +typedef uint16_t ProfileId_t; +typedef uint16_t ClusterId_t; +typedef uint16_t GroupAddr_t; +typedef uint8_t StackProfile_t; + + +/******************************************************************************** +* Zigbee APFW types definition +********************************************************************************/ + +BEGIN_PACK +//!\brief Node descriptor +/*! Mandatory for each node. */ +typedef struct PACK +{ + LITTLE_ENDIAN_OCTET(4, ( + /*! Device role:\n + 000 - ::DEVICE_TYPE_COORDINATOR,\n + 001 - ::DEVICE_TYPE_ROUTER,\n + 010 - ::DEVICE_TYPE_END_DEVICE,\n + 011-111 - reserved.*/ + uint8_t logicalType : 3, + /*! Specifies whether a complex descriptor is available on this device. */ + uint8_t complexDescriptorAvailable: 1, + /*! Specifies whether a user descriptor is available on this device. */ + uint8_t userDescriptorAvailable: 1, + /*! Reserved. */ + uint8_t reserved: 3 + )) + + LITTLE_ENDIAN_OCTET(2, ( + /*! APS capability flags. Not supported (always set to 0). */ + uint8_t apsFlags : 3, + /*! Bit mask for supported frequency bands.\n + Bit 0: 868 - 868.6 MHz\n + Bit 1: Reserved\n + Bit 2: 902 - 928 MHz\n + Bit 3: 2400 - 2483.5 MHz\n + Bit 4: Reserved. */ + uint8_t frequencyBand : 5 + )) + + /*! MAC capability flags.\n + Bit 0: is the node capable of becoming an alternate PAN coordinator\n + Bit 1: device type (full-function vs. reduced-function device)\n + Bit 2: is the device mains-powered \n + Bit 3: is the receiver enabled when the device is idle \n + Bits 4-5: Reserved\n + Bit 6: is MAC security enabled \n + Bit 7: Always equals 1. */ + MAC_CapabilityInf_t macCapbFlags; + + /*! 16-bit manufacturer code allocated by the ZigBee Alliance. */ + uint16_t manufacturerCode; + + /*! Maximum size of the network sub-layer data unit (NSDU) for this node, in octets. + Valid range is 0x00-0x7f. */ + uint8_t maxBufferSize; + + /*! Maximum size of the application sub-layer data unit (ASDU) that can be + transferred to this node in one single message transfer, in octets. + Valid range is 0x0000-0x7fff. May exceed the maxBufferSize value through the + use of fragmentation. */ + uint16_t maxTransferSize; + + /*! Bit mask denoting the system server capabilities of this node.\n + Used to facilitate discovery of particular system servers by other nodes.\n + Bit 0: Primary Trust Center\n + Bit 1: Backup Trust Center\n + Bit 2: Primary Binding Table Cache\n + Bit 3: Backup Binding Table Cache\n + Bit 4: Primary Discovery Cache\n + Bit 5: Backup Discovery Cache\n + Bit 6: Network Manager\n + Bits 7-15: Reserved. */ + uint16_t serverMask; + + /*! Maximum size of the application sub-layer data unit (ASDU) that can be + transferred from this node in one single message transfer, in octets. + Valid range is 0x0000-0x7fff. */ + uint16_t maxOutcTransferSize; + + /*! Descriptor capabilities bit mask. + Bit 0: Extended Active Endpoint list available\n + Bit 1: Extended Simple Descriptor list available\n + Bits 2-7: Reserved. */ + uint8_t descriptorCapabilityField; +} NodeDescriptor_t; + +//!\brief Power descriptor +/*! Mandatory for each node. */ +typedef struct PACK +{ +/*! Specifies the current sleep/power-saving mode of the node.\n +0000 - Receiver synchronized with the 'receiver on when idle' subfield of the node descriptor.\n +0001 - Receiver comes on periodically as defined by the node power descriptor.\n +0010 - Receiver comes on when stimulated, e.g. by a user pressing a button.\n +0011-1111 - Reserved. */ + uint8_t currentPowerMode : 4; +/*! Specifies the power sources available on this node.\n +0 - Constant (mains) power\n +1 - Rechargeable battery\n +2 - Disposable battery\n +3 - Reserved. */ + uint8_t availablePowerSources : 4; +/*! Specifies the power source being currently used by the node.\n +0 - Constant (mains) power\n +1 - Rechargeable battery\n +2 - Disposable battery\n +3 - Reserved. */ + uint8_t currentPowerSource : 4; +/*! Specifies the level of charge of the power source.\n +0000 - Critical\n +0100 - 33%\n +1000 - 66%\n +1100 - 100%\n +All other values - Reserved. */ + uint8_t currentPowerSourceLevel : 4; +} PowerDescriptor_t; + +//!\brief Simple Descriptor +/*! Mandatory for each endpoint present in the node. */ +typedef struct PACK +{ +/*! ID of the endpoint within the node to which this description refers. +Applications shall only use endpoints 1-240. */ + Endpoint_t endpoint; +/*! Profile that is supported on this endpoint. */ + ProfileId_t AppProfileId; +/*! Device description supported on this endpoint. */ + uint16_t AppDeviceId; +/*! Version of the device description supported on this endpoint. */ + uint8_t AppDeviceVersion : 4; +/*! Reserved. */ + uint8_t Reserved : 4; +/*! Number of input clusters supported on this endpoint. If 0, the +application input cluster list field shall not be included. */ + uint8_t AppInClustersCount; +/*! List of input clusters supported on this endpoint. */ + ClusterId_t* AppInClustersList; +/*! Number of output clusters supported on this endpoint. If 0, the +application output cluster list field shall not be included. */ + uint8_t AppOutClustersCount; +/*! List of output clusters supported on this endpoint. */ + ClusterId_t* AppOutClustersList; +} SimpleDescriptor_t; + +//!\brief User descriptor. +/*! Used optionally. */ +typedef struct PACK +{ + uint8_t FieldLength; +/*! Human-readable character string that allows the user to identify the device. */ + uint8_t FieldName[ZDP_USER_DESC_FIELD_SIZE]; +} UserDescriptor_t; + +END_PACK + +/*! Intended for specifying device role. */ +typedef enum +{ + DEVICE_TYPE_COORDINATOR = DEV_TYPE_COORDINATOR, + DEVICE_TYPE_ROUTER = DEV_TYPE_ROUTER, + DEVICE_TYPE_END_DEVICE = DEV_TYPE_ENDDEVICE +} DeviceType_t; + +/*! Intended for specifying NodeDescriptor_t::macCapbFlags field. */ +enum +{ + MAC_CAP_ALTERNATE_PAN_COORDINATOR = 0x01, + MAC_CAP_DEVICE_TYPE_FFD = 0x02, + MAC_CAP_POWER_SOURCE_MAINS = 0x04, + MAC_CAP_RX_ON_WHEN_IDLE = 0x08, + MAC_CAP_SECURITY_CAPABLE = 0x40, + MAC_CAP_ALLOCATE_ADDRESS = 0x80 // always set for rev13 +}; + +/*! Intended for specifying NodeDescriptor_t::serverMask field. */ +enum +{ + SERVER_MASK_NO_SERVER = 0x0000, + SERVER_MASK_PRIMARY_TRUST_CENTER = 0x0001, + SERVER_MASK_BACKUP_TRUST_CENTER = 0x0002, + SERVER_MASK_PRIMARY_BINDING_TABLE_CACHE = 0x0004, + SERVER_MASK_BACKUP_BINDING_TABLE_CACHE = 0x0008, + SERVER_MASK_PRIMARY_DISCOVERY_CACHE = 0x0010, + SERVER_MASK_BACKUP_DISCOVERY_CACHE = 0x0020, + SERVER_MASK_NETWORK_MANAGER = 0x0040 +}; + +/*! Intended for specifying NodeDescriptor_t::descriptorCapabilityField field. */ +enum +{ + EXT_LIST_ACTIVE_EP = 0x01, + EXT_LIST_SIMPLE_DESC = 0x02 +}; + +/*! Intended for specifying PowerDescriptor_t::currentPowerMode field. */ +typedef enum +{ + RECEIVER_SYNCRONIZED_WHEN_ON_IDLE = 0, + RECEIVER_COMES_PERIODICALLY = 1, + RECEIVER_COMES_WHEN_STIMULATED = 2 + //RESERVED = 0xF /* all other values */ +} PowerMode_t; + +/*! Intended for specifying PowerDescriptor_t::availablePowerSources +and PowerDescriptor_t::currentPowerSource fields. */ +typedef enum +{ + MAINS_POWER = 0x1, + RECHARGEABLE_BATTERY = 0x2, + DISPOSABLE_BATTERY = 0x4, + //RESERVED +} PowerSource_t; + +/*! Intended for specifying PowerDescriptor_t::currentPowerSourceLevel field. */ +typedef enum +{ + CRITICAL_0 = 0, + PERCENT_33 = 4, + PERCENT_66 = 8, + PERCENT_100 = 0xC + //RESERVED = 0xFF; /* all over values */ +} PowerSourceLevel_t; + + +/*! Intended for specifying ComplexDescriptorField_t::CompressedXMLTag field. */ +enum +{ + TAG_LANGUAGE_AND_CHARACTER_SET = 0001, + TAG_MANUFACTURER_NAME = 0010, + TAG_MODEL_NAME = 0011, + TAG_SERIAL_NUMBER = 0100, + TAG_DEVICE_URL = 0101, + TAG_ICON = 0110, + TAG_ICON_URL = 0111, +}; + +//!\brief Complex Descriptor field. +typedef struct +{ +/*! Field type.\n +Possible values:\n +0x00 - Reserved\n +0x01 - ISO 639-1 language code\n +0x02 - Manufacturer name\n +0x03 - Model name\n +0x04 - Serial number\n +0x05 - Device URL\n +0x06 - Icon\n +0x07 - Icon URL\n +0x08-0xFF - Reserved. */ + uint8_t CompressedXMLTag; +/*! Field contents. */ + uint8_t* pDataField; +} ComplexDescriptorField_t; + + +//!\brief Complex Descriptor. +/*! Used optionally.\n +Consists of compressed XML tags.\n +The overall length shall be less than or equal to apscMaxDescriptorSize.*/ +typedef struct +{ +/*! Field count. */ + uint8_t FieldCount; +/*! List of fields. */ + ComplexDescriptorField_t* pFields; +} ComplexDescriptor_t; + +#endif /* _APPFRAMEWORK_H */ + diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoBinding.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoBinding.h new file mode 100644 index 00000000..3ae2cc93 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoBinding.h @@ -0,0 +1,46 @@ +/**************************************************************************//** + \file zdoBinding.h + + \brief Internal interface of ZDO binding functionality. + + \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: + 2011-03-17 Max Gekk - Created. + Last change: + $Id: zdoBinding.h 17448 2011-06-09 13:53:59Z ataradov $ + ******************************************************************************/ +#if !defined _ZDO_BINDING_H +#define _ZDO_BINDING_H + +/****************************************************************************** + Prototypes section + ******************************************************************************/ +/**************************************************************************//** + \brief Prepare Bind or Unbind ZDP request. + ******************************************************************************/ +void zdoUnbindBindRequestCreate(void); + +/**************************************************************************//** + \brief Process an incoming Bind or Unbind request and send response. + ******************************************************************************/ +void zdoUnbindBindInd(void); + +/**************************************************************************//** + \brief Prepare ZDP Mgmt Bind request. Init APS_DataReq_t structure. + ******************************************************************************/ +void zdoMgmtBindRequestCreate(void); + +/**************************************************************************//** + \brief Process an incoming Mgmt Bind request and send response. + ******************************************************************************/ +void zdoMgmtBindInd(void); + +#endif /* _ZDO_BINDING_H */ +/** eof zdoBinding.h */ diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoDbg.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoDbg.h new file mode 100644 index 00000000..8121410e --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoDbg.h @@ -0,0 +1,129 @@ +/************************************************************************//** + \file zdoDbg.h + + \brief ZDO assert codes + + \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: + 27.07.09 A. Taradov - Refactoring + 29.10.09 A. Taradov - Refactoring +******************************************************************************/ + +#ifndef _ZDODBG_H +#define _ZDODBG_H + +#include + +typedef enum _ZdoDbgCode_t +{ + ZDO_NULL_CONFIRM_MESSAGE = 0x5001, + ZDO_UNKNOWN_STATE_MESSAGE = 0x5004, + ZDO_UNEXPECTED_FAIL_CONFIRM_MESSAGE = 0x5005, + ZDO_UNKNOWN_NETWORK_START_TYPE_MESSAGE = 0x5006, + ZDO_STACK_RESET_FAIL_MESSAGE = 0x5007, + ZDO_UNKNOWN_ZDP_CLUSTER_MESSAGE = 0x5008, + ZDO_ILLEGAL_ADDRESS_MODE_MESSAGE = 0x5009, + ZDO_UNKNOWN_SECURITY_KEY_MESSAGE = 0x500A, + ZDO_UNEXPECTED_CALLBACK = 0x500B, + ZDO_NULL_CALLBACK_SET_TX_POWER_CONF_0 = 0x500E, + ZDO_NULL_CALLBACK_SET_TX_POWER_CONF_1 = 0x500F, + ZDO_NULL_CALLBACK_ENDTOENDAPPKEY_CONF = 0x5010, + ZDO_ZDP_MANAGER_QUEUE_EMPTY = 0x5013, + ZDO_INVALID_ZDP_REQUEST_STATE = 0x5014, + ZDO_DISCOVERY_MANAGER_UNKNOWN_REQ_CLUSTER = 0x5015, + ZDO_BIND_MANAGER_UNKNOWN_REQ_CLUSTER = 0x5016, + ZDO_NODE_MANAGER_UNKNOWN_REQ_CLUSTER = 0x5017, + ZDO_DISCOVERY_MANAGER_UNKNOWN_RESP_CLUSTER = 0x5018, + ZDO_BIND_MANAGER_UNKNOWN_RESP_CLUSTER = 0x5019, + ZDO_NODE_MANAGER_UNKNOWN_RESP_CLUSTER = 0x5020, + ZDO_NODE_MANAGER_INVALID_SRC_ADDR_MODE = 0x5021, + + ZDO_SECURITY_MANAGER_0 = 0x5030, + + ZDO_NWK_MANAGER_0 = 0x5040, + + ZDO_START_NETWORK_0 = 0x5050, + ZDO_START_NETWORK_1 = 0x5051, + ZDO_START_NETWORK_2 = 0x5052, + ZDO_START_NETWORK_3 = 0x5053, + ZDO_START_NETWORK_4 = 0x5054, + ZDO_START_NETWORK_5 = 0x5055, + ZDO_START_NETWORK_6 = 0x5056, + ZDO_START_NETWORK_7 = 0x5057, + ZDO_START_NETWORK_8 = 0x5058, + ZDO_START_NETWORK_9 = 0x5059, + ZDO_START_NETWORK_10 = 0x505a, + ZDO_START_NETWORK_11 = 0x505b, + ZDO_START_NETWORK_12 = 0x505c, + ZDO_START_NETWORK_13 = 0x505d, + ZDO_START_NETWORK_14 = 0x505e, + ZDO_START_NETWORK_15 = 0x505f, + ZDO_START_NETWORK_16 = 0x5060, + ZDO_START_NETWORK_17 = 0x5061, + ZDO_START_NETWORK_18 = 0x5062, + ZDO_START_NETWORK_19 = 0x5063, + + ZDO_RESET_NETWORK_0 = 0x5070, + ZDO_RESET_NETWORK_1 = 0x5071, + ZDO_RESET_NETWORK_2 = 0x5072, + ZDO_RESET_NETWORK_3 = 0x5073, + + ZDO_LEAVE_NETWORK_0 = 0x5090, + ZDO_LEAVE_NETWORK_1 = 0x5091, + ZDO_LEAVE_NETWORK_2 = 0x5092, + ZDO_LEAVE_NETWORK_3 = 0x5093, + + ZDO_TC_SWAPOUT_0 = 0x50a0, + ZDO_TC_SWAPOUT_1 = 0x50a1, + ZDO_TC_SWAPOUT_2 = 0x50a2, + ZDO_TC_SWAPOUT_3 = 0x50a3, + ZDO_TC_SWAPOUT_4 = 0x50a4, + ZDO_TC_SWAPOUT_5 = 0x50a5, + ZDO_TC_SWAPOUT_6 = 0x50a6, + ZDO_TC_SWAPOUT_7 = 0x50a7, + + ZDO_TC_KEEP_ALIVE_0 = 0x50b0, + + ZDO_POWER_MANAGER_0 = 0x50c0, + ZDO_POWER_MANAGER_1 = 0x50c1, + ZDO_POWER_MANAGER_2 = 0x50c2, + ZDO_POWER_MANAGER_3 = 0x50c3, + ZDO_POWER_MANAGER_4 = 0x50c4, + ZDO_POWER_MANAGER_5 = 0x50c5, + ZDO_POWER_MANAGER_6 = 0x50c6, + ZDO_POWER_MANAGER_7 = 0x50c7, + + ZDO_MEMORY_CORRUPTION_0 = 0x50d0, + ZDO_MEMORY_CORRUPTION_1 = 0x50d1, + + ZDO_RESET_0 = 0x50e0, + ZDO_RESET_1 = 0x50e1, + ZDO_RESET_2 = 0x50e2, + ZDO_RESET_3 = 0x50e3, + + ZDOENDDEVICEBINDING_ENDDEVICEBINDINGIND_0 = 0x50f0, + ZDOENDDEVICEBINDING_SAVESECONDENDDEVICEBINDINGREQ_0 = 0x50f1, + ZDOENDDEVICEBINDING_ENDDEVICEBINDINGRESPONSECREATE_0 = 0x50f2, + ZDOENDDEVICEBINDING_ENDDEVICEBINDINGRESPONSECREATE_1 = 0x50f3, + ZDOENDDEVICEBINDING_SENDNEXTBINDREQ_0 = 0x50f4, + ZDOENDDEVICEBINDING_ENDDEVICEBINDINGREQUESTCREATE_0 = 0x50f5, + ZDOENDDEVICEBINDING_ENDDEVICEBINDINGREQUESTCREATE_1 = 0x50f6, + ZDOENDDEVICEBINDING_PREPAREFIRSTUNBINDREQ_0 = 0x50f7, + + ZDOBINDING_GENERATEUNBINDBINDREQ_0 = 0x5100, + ZDOBINDING_UNBINDBINDIND_0 = 0x5101, + ZDOBINDING_UNBINDBINDIND_1 = 0x5102, + ZDOBINDING_MGMTBINDIND_0 = 0x5103, + ZDOBINDING_INITDSTADDRESS_0 = 0x5104 +} ZdoDbgCode_t; + +#endif // _ZDODBG_H + +// eof zdoDbg.h diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoDiscoveryManager.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoDiscoveryManager.h new file mode 100644 index 00000000..d06dd565 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoDiscoveryManager.h @@ -0,0 +1,24 @@ +/************************************************************************//** + \file zdoDiscoveryManager.h + + \brief The header file describes the constants and types of + ZDO discovery manager + + \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 ZDODISCOVERYMANAGER_H_ +#define ZDODISCOVERYMANAGER_H_ + +void zdoZdpDiscoveryRequestCreate(void); +void zdoZdpDiscoveryMessageInd(void); + +#endif /*ZDODISCOVERYMANAGER_H_*/ diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoEndDeviceBinding.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoEndDeviceBinding.h new file mode 100644 index 00000000..22380e81 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoEndDeviceBinding.h @@ -0,0 +1,134 @@ +/**************************************************************************//** + \file zdoEndDeviceBinding.h + + \brief Internal interface of ZDO End device Binding module. + + \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: + 2011-03-11 Max Gekk - Created. + Last change: + $Id: zdoEndDeviceBinding.h 18225 2011-08-12 14:02:16Z mgekk $ + ******************************************************************************/ +#if !defined _ZDO_END_DEVICE_BINDING_H +#define _ZDO_END_DEVICE_BINDING_H + +/****************************************************************************** + Includes section + ******************************************************************************/ +#include +#include + +/****************************************************************************** + Definition section + ******************************************************************************/ +/** Pre-configured timeout duration awaiting a second End_Device_Bind_req. + * See ZigBee Smart Energy Profile Specification r15, Table 5.9 and ZigBee + * HA Profile Specification r26, 5.3.8, page 15. */ +#define ZDO_END_DEVICE_BIND_TIMEOUT 60000UL /* milliseconds */ + +/** Minimum size of ZDP End Device Binding command: + * - 2 bytes - binding target, + * - 8 bytes - IEEE address of the device generating request, + * - 1 byte - source endpoint, + * - 2 bytes - profileId, + * - 2 bytes - numInClusters and numOutClusters. + */ +#define ZDO_MIN_END_DEVICE_BINDING_COMMAND_SIZE 15U + +/** Maximum number of stored input and output cluster ids. */ +#define ZDO_TOTAL_BIND_CLUSTERS_AMOUNT (2 * MAX_REQUESTED_CLUSTER_NUMBER) + +#if defined _END_DEVICE_BINDING_ +/****************************************************************************** + Types section + ******************************************************************************/ +/* States of End Device Binding module. */ +typedef enum _ZdoEndDeviceBindingState_t +{ + ZDO_END_DEVICE_BINDING_NO_INIT_STATE = 0x00, + ZDO_WAIT_FIRST_END_DEVICE_BINDING_REQ_STATE = 0x45, + ZDO_WAIT_SECOND_END_DEVICE_BINDING_REQ_STATE = 0x46, + ZDO_SEND_FIRST_UNBIND_REQ_STATE = 0x47, + ZDO_SEND_END_DEVICE_BINDING_NO_MATCH_STATE = 0x48, + ZDO_SEND_END_DEVICE_BINDING_TIMEOUT_STATE = 0x49, + ZDO_SENDING_FIRST_UNBIND_REQ_STATE = 0x4A, + ZDO_SENDING_UNBIND_BIND_REQ_STATE = 0x4B, + ZDO_SENDING_FIRST_END_DEVICE_BINDING_RESP_STATE = 0x4C, + ZDO_SENDING_SECOND_END_DEVICE_BINDING_RESP_STATE = 0x4D, + ZDO_SENDING_END_DEVICE_BINDING_TIMEOUT_STATE = 0x4E +} ZdoEndDeviceBindingState_t; + +/* Information about cluster that is received in ZDO End Device Binding request. */ +typedef struct _ZdoSavedClusterId_t +{ + ClusterId_t id; /* Identifier of stored cluster. */ + bool busy : 1; /* Current entry is used (true) or not (false). */ + /* If this field is 'true' then clusterId was received in the Input Cluster List + * of ZDP End Device Binding command frame. */ + bool isInputCluster : 1; + /* if it's output cluster then this flag indicates bind state. */ + bool bound : 1; +} ZdoSavedClusterId_t; + +/* Information from received End Device Binding request. */ +typedef struct _ZdoBindDevice_t +{ + ExtAddr_t extAddress; + ShortAddr_t shortAddress; + ShortAddr_t bindingTarget; + Endpoint_t endpoint; + uint8_t seqNum; /*!< Sequence number of ZDP request. */ +} ZdoBindDevice_t; + +/* Internal state and variables of the End Device Binding module. */ +typedef struct _ZdoEndDeviceBinding_t +{ + ZdoEndDeviceBindingState_t state; + bool zdpReqBusy; /*!< Flag indicates using of zdpReq. */ + ZDO_ZdpReq_t zdpReq; + HAL_AppTimer_t timer; + /* List of clusterIds (input and output) from first ZDP request. */ + ZdoSavedClusterId_t cluster[ZDO_TOTAL_BIND_CLUSTERS_AMOUNT]; + ProfileId_t profileId; + ClusterId_t bindClusterId; + ZDO_Status_t responseStatus; /*!< Status used in finish stage. */ + ZdoBindDevice_t first; /*!< Information about a first binding device. */ + ZdoBindDevice_t second; /*!< Information about a second binding device. */ +} ZdoEndDeviceBinding_t; + +/****************************************************************************** + Prototypes section + ******************************************************************************/ +/**************************************************************************//** + \brief Prepare of APS_DataReq_t structure for end device binding request. + ******************************************************************************/ +void zdoEndDeviceBindingRequestCreate(void); + +#if defined _COORDINATOR_ +/**************************************************************************//** + \brief Process an incoming ZDP End Device Binding command. + ******************************************************************************/ +void zdoEndDeviceBindingInd(void); + +/**************************************************************************//** + \brief Prepare APS_DataReq_t structure for end device binding response. + ******************************************************************************/ +void zdoEndDeviceBindingResponseCreate(void); + +/**************************************************************************//** + \brief Reset internal state and variables of ZDO End Device Binding modile. + ******************************************************************************/ +void zdoResetEndDeviceBinding(void); + +#endif /* _COORDINATOR_ */ +#endif /* _END_DEVICE_BINDING_ */ +#endif /* _ZDO_END_DEVICE_BINDING_H */ +/** eof zdoEndDeviceBinding.h */ + diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoInit.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoInit.h new file mode 100644 index 00000000..9490fcda --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoInit.h @@ -0,0 +1,39 @@ +/**************************************************************************//** + \file zdoInit.h + + \brief Interface for ZDO initialization routines + + \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: + 27.10.09 A. Taradov - Created +******************************************************************************/ + +#ifndef _ZDOINIT_H +#define _ZDOINIT_H + +/****************************************************************************** + Includes section +******************************************************************************/ +#include +#include +#include + +/****************************************************************************** + Prototypes section +******************************************************************************/ + +/****************************************************************************** + \brief ZDO initialization routine +******************************************************************************/ +void zdoInitHandler(void); + +#endif // _ZDOINIT_H + +// eof zdoInit.h diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoLeaveNetwork.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoLeaveNetwork.h new file mode 100644 index 00000000..1b16792c --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoLeaveNetwork.h @@ -0,0 +1,111 @@ +/**************************************************************************//** + \file zdoLeaveNetwork.h + + \brief Interface for ZDO Leave Network routines + + \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: + 29.10.09 A. Taradov - Created +******************************************************************************/ +#ifndef _ZDOLEAVENETWORK_H +#define _ZDOLEAVENETWORK_H + +/****************************************************************************** + Includes section +******************************************************************************/ +#include + +/****************************************************************************** + Definitions section +******************************************************************************/ + +/****************************************************************************** + Types section +******************************************************************************/ +typedef enum _ZdoLeaveNetworkState_t +{ + ZDO_LEAVE_NETWORK_IDLE_STATE, + ZDO_LEAVE_NETWORK_NWK_LEAVE_STATE, + ZDO_LEAVE_NETWORK_APS_STOP_STATE +} ZdoLeaveNetworkState_t; + +typedef void (ZdoLeaveNetworkConf_t)(ZDO_Status_t status); + +typedef struct _ZdoLeaveNetwork_t +{ + ZdoLeaveNetworkState_t state; + ZdoLeaveNetworkConf_t *confirm; + bool rejoin; +} ZdoLeaveNetwork_t; + +/****************************************************************************** + Prototypes section +******************************************************************************/ + +/****************************************************************************** + Network leave indication + Parameters: + rejoin - true if rejoin is required + Return: + none +******************************************************************************/ +void zdoLeaveNetworkInd(bool rejoin); + +/****************************************************************************** + Leave device from network + Parameters: + removeChildren - remove or not children + rejoin - perform or not rejoin after leaving + Returns: + None +******************************************************************************/ +void zdoLeaveNetworkReq(bool removeChildren, bool rejoin); + +/****************************************************************************** + Leave device from network. Leave Network module must be allocated before + calling this function. + Parameters: + removeChildren - remove or not children + rejoin - perform or not rejoin after leaving + Returns: + None +******************************************************************************/ +void zdoLeaveNetwork(bool removeChildren, bool rejoin); + +/****************************************************************************** + Allocate Leave Network module + Parameters: + leaveNetworkConf - confirmation callback + Return: + true - if module was alocated, false otherwise +******************************************************************************/ +bool zdoLeaveNetworkAlloc(ZdoLeaveNetworkConf_t *leaveNetworkConf); + +/****************************************************************************** + Free Leave Network module + Parameters: + none + Return: + none +******************************************************************************/ +void zdoLeaveNetworkFree(void); + +/****************************************************************************** + Reset Leave Network component. + Parameters: + none + Return: + none +******************************************************************************/ +void zdoLeaveNetworkReset(void); + +#endif // _ZDOLEAVENETWORK_H + +// eof zdoLeaveNetwork.h diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoManager.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoManager.h new file mode 100644 index 00000000..e21a8db2 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoManager.h @@ -0,0 +1,116 @@ +/**************************************************************************//** + \file zdoManager.h + + \brief ZDO internal management functions interface + + \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: + 28.10.09 A. Taradov - Created +******************************************************************************/ +#ifndef _ZDOMANAGER_H +#define _ZDOMANAGER_H + +/****************************************************************************** + Includes section +******************************************************************************/ +#include + +/****************************************************************************** + Types section +******************************************************************************/ +typedef enum _ZdoModuleId_t +{ + ZDO_START_NETWORK_MODULE_ID = (1 << 0), + ZDO_RESET_NETWORK_MODULE_ID = (1 << 1), + ZDO_LEAVE_NETWORK_MODULE_ID = (1 << 2), + ZDO_BINDING_MANAGER_MODULE_ID = (1 << 3), + ZDO_DISCOVERY_MANAGER_MODULE_ID = (1 << 4), + ZDO_NODE_MANAGER_MODULE_ID = (1 << 5), + ZDO_NWK_MANAGER_MODULE_ID = (1 << 6), + ZDO_POWER_MANAGER_MODULE_ID = (1 << 7), + ZDO_SECURITY_MANAGER_MODULE_ID = (1 << 8), + ZDO_ZDP_FRAME_PROCESSOR_MODULE_ID = (1 << 9), + ZDO_ZDP_MANAGER_MODULE_ID = (1 << 10), + ZDO_NETWORK_STATUS_MODULE_ID = (1 << 11), + ZDO_TC_SWAPOUT_MODULE_ID = (1 << 12), +} ZdoModuleId_t; + +typedef enum _ZdoModuleSet_t +{ + ZDO_INITIAL_MODULE_SET = 0, + ZDO_ALL_DISABLED_MODULE_SET = 0, + ZDO_READY_MODULE_SET = ZDO_START_NETWORK_MODULE_ID | ZDO_RESET_NETWORK_MODULE_ID | + ZDO_POWER_MANAGER_MODULE_ID | ZDO_TC_SWAPOUT_MODULE_ID, + ZDO_START_NETWORK_MODULE_SET = ZDO_ZDP_MANAGER_MODULE_ID, + ZDO_IN_NETWORK_MODULE_SET = ZDO_BINDING_MANAGER_MODULE_ID | ZDO_DISCOVERY_MANAGER_MODULE_ID | + ZDO_NODE_MANAGER_MODULE_ID | ZDO_NWK_MANAGER_MODULE_ID | + ZDO_POWER_MANAGER_MODULE_ID | ZDO_SECURITY_MANAGER_MODULE_ID | + ZDO_ZDP_FRAME_PROCESSOR_MODULE_ID | ZDO_ZDP_MANAGER_MODULE_ID | + ZDO_NETWORK_STATUS_MODULE_ID | ZDO_RESET_NETWORK_MODULE_ID | + ZDO_LEAVE_NETWORK_MODULE_ID | ZDO_TC_SWAPOUT_MODULE_ID, + ZDO_REJOIN_NETWORK_MODULE_SET = ZDO_ZDP_MANAGER_MODULE_ID, + ZDO_LEAVING_MODULE_SET = ZDO_LEAVE_NETWORK_MODULE_ID | ZDO_ZDP_MANAGER_MODULE_ID, + ZDO_TC_SWAPOUT_MODULE_SET = ZDO_ZDP_MANAGER_MODULE_ID, + ZDO_RESET_NETWORK_MODULE_SET = 0, +} ZdoModuleSet_t; + +/****************************************************************************** + Prototypes section +******************************************************************************/ +void zdoUpdateRandSeed(void); +/****************************************************************************** + Implementations section +******************************************************************************/ + +/****************************************************************************** + Enable certain modules + Parameters: + modules - modules to enable + Return: + none +******************************************************************************/ +inline static void zdoEnable(uint16_t modules) +{ + zdoMem.enabledModules = modules; +} + +/****************************************************************************** + Check if certain module is enabled + Parameters: + module - module id to check + Return: + true - module is enabled + false - module is disabled +******************************************************************************/ +inline static bool zdoEnabled(uint16_t module) +{ + return (zdoMem.enabledModules & module); +} + +/****************************************************************************** + Set 'Out of Network' flag for correct state restore after power failure. + Parameters: + none + Return: + none +******************************************************************************/ +inline static void zdoSetOutOfNetworkFlag(void) +{ +#if defined(_POWER_FAILURE_) + ExtPanId_t nwkExtPanId = NWK_NO_EXT_PANID; + NWK_SetExtPanId(&nwkExtPanId); + + zdoMem.zdoStartNetwork.powerFailureControl.networkOperationsAccepted = 0U; +#endif +} + +#endif // _ZDOMANAGER_H + +// eof zdoManager.h diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoMem.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoMem.h new file mode 100644 index 00000000..ce80a64d --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoMem.h @@ -0,0 +1,177 @@ +/************************************************************************//** + \file zdoMem.h + + \brief The header file describes the internal ZDO memory + + \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 _ZDOMEM_H +#define _ZDOMEM_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef union _ZdoStackReq_t +{ + // Requests from ZDO to NLME +#if defined(_COORDINATOR_) + NWK_NetworkFormationReq_t nwkFormationReq; +#endif + +#if defined(_ROUTER_) || defined(_ENDDEVICE_) + NWK_JoinReq_t nwkJoinReq; +#endif + +#if defined(_COORDINATOR_) || defined(_ROUTER_) + NWK_PermitJoiningReq_t nwkPermitJoiningReq; +#endif + +#if defined(_ROUTER_) + NWK_StartRouterReq_t nwkStartRouterReq; +#endif + + NWK_LeaveReq_t nwkLeaveReq; + + // Requests from ZDO to APSME + APS_ResetReq_t apsResetReq; + APS_StartReq_t apsStartReq; + APS_StopReq_t apsStopReq; +} ZdoStackReq_t; + +typedef struct _ZdoMem_t +{ + ZdoStackReq_t stackReq; + ZdoStartNetwork_t zdoStartNetwork; + ZdoLeaveNetwork_t zdoLeaveNetwork; + ZdoReset_t zdoReset; + ZdoResetNetwork_t zdoResetNetwork; + ZdoPowerManager_t powerManager; + ZdoNodeManager_t nodeManager; + ZdoNwkManager_t nwkManager; + ZdoZdpManager_t zdoZdpManager; + ZdoFrameProc_t zdpFrameProcessor; +#ifdef _SECURITY_ + ZdoSecurityManager_t zdoSecurityManager; +#endif +#ifdef _TC_SWAPOUT_ + ZdoTcSwapOut_t zdoTcSwapOut; + ZdoTcKeepAlive_t zdoTcKeepAlive; +#endif + uint16_t enabledModules; + RF_RandomReq_t randReq; + HAL_AppTimer_t timerReq; +#ifdef _END_DEVICE_BINDING_ + ZdoEndDeviceBinding_t endDevBinding; +#endif +} ZdoMem_t; + +extern ZdoMem_t zdoMem; + +static inline ZdoStackReq_t * zdoMemStackRequest(void) +{ + return &zdoMem.stackReq; +} + +static inline HAL_AppTimer_t * zdoMemTimerRequest(void) +{ + return &zdoMem.timerReq; +} + +static inline RF_RandomReq_t * zdoMemRandRequest(void) +{ + return &zdoMem.randReq; +} + +static inline ZdoPowerManager_t * zdoMemPowerManager(void) +{ + return &zdoMem.powerManager; +} + +static inline ZdoNodeManager_t * zdoMemNodeManager(void) +{ + return &zdoMem.nodeManager; +} + +static inline ZdoNwkManager_t * zdoMemNwkManager(void) +{ + return &zdoMem.nwkManager; +} + +static inline ZdoZdpManager_t * zdoMemZdpManager(void) +{ + return &zdoMem.zdoZdpManager; +} + +static inline ZdoFrameProc_t * zdoMemZdpFrameProcessor(void) +{ + return &zdoMem.zdpFrameProcessor; +} + +static inline ZdoStartNetwork_t * zdoMemStartNetwork(void) +{ + return &zdoMem.zdoStartNetwork; +} + +static inline ZdoResetNetwork_t * zdoMemResetNetwork(void) +{ + return &zdoMem.zdoResetNetwork; +} + +static inline ZdoReset_t * zdoMemReset(void) +{ + return &zdoMem.zdoReset; +} + +static inline ZdoLeaveNetwork_t * zdoMemLeaveNetwork(void) +{ + return &zdoMem.zdoLeaveNetwork; +} + +#ifdef _SECURITY_ +static inline ZdoSecurityManager_t * zdoMemSecurityManager(void) +{ + return &zdoMem.zdoSecurityManager; +} +#endif + +#ifdef _TC_SWAPOUT_ +static inline ZdoTcSwapOut_t * zdoMemTcSwapOut(void) +{ + return &zdoMem.zdoTcSwapOut; +} + +static inline ZdoTcKeepAlive_t * zdoMemTcKeepAlive(void) +{ + return &zdoMem.zdoTcKeepAlive; +} +#endif + +#ifdef _END_DEVICE_BINDING_ +static inline ZdoEndDeviceBinding_t * zdoMemEndDeviceBinding(void) +{ + return &zdoMem.endDevBinding; +} +#endif +#endif // _ZDOMEM_H + diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoNodeManager.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoNodeManager.h new file mode 100644 index 00000000..49cddb1a --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoNodeManager.h @@ -0,0 +1,68 @@ +/************************************************************************//** + \file zdoNodeManager.h + + \brief The header file describes the constants, types and internal interface + of ZDO node manager + + \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 ZDONODEMANAGER_H_ +#define ZDONODEMANAGER_H_ + +#include +#include +#include +#include +#include + + +// ScanDuration field of Mgmt_NWK_Update_req +#define MGMT_NWK_UPDATE_DUR_0 ((uint8_t)0x00) +#define MGMT_NWK_UPDATE_DUR_1 ((uint8_t)0x01) +#define MGMT_NWK_UPDATE_DUR_2 ((uint8_t)0x02) +#define MGMT_NWK_UPDATE_DUR_3 ((uint8_t)0x03) +#define MGMT_NWK_UPDATE_DUR_4 ((uint8_t)0x04) +#define MGMT_NWK_UPDATE_DUR_5 ((uint8_t)0x05) +#define MGMT_NWK_UPDATE_DUR_CHANNEL_CHANGE ((uint8_t)0xFE) +#define MGMT_NWK_UPDATE_DUR_PARAMS_CHANGE ((uint8_t)0xFF) + + +typedef struct zdoNodeManager_t_ +{ + NWK_EDScanReq_t nwkEDScanReq; + MAC_SetReq_t macSetReq; + HAL_AppTimer_t channelChangeTimer; + uint8_t edScanCount; + uint8_t newChannel; + uint8_t nwkUpdateId; + NWK_EDScanConf_t *nwkEDScanConf; + ZDO_ZdpReq_t zdpNwkUpdateNotify; + ZDO_ZdpReq_t *storedZdpRequest; +} ZdoNodeManager_t; + +void zdoZdpNodeManagerReset(void); +void zdoExecuteEDScan(uint32_t scanChannels, uint8_t scanDuration); +void zdoZdpNodeRequestCreate(void); +void zdoZdpNodeMessageInd(void); +void zdpNodeWaitTimerFired(void); + +/****************************************************************************** + Set timer on interval BROADCAST_DELIVERY_TIME upon fires which node will + change the channel + Parameters: + scanChannels - channels to move to + Returns: + None. +******************************************************************************/ +void zdoSetChannelChangeTimer(const uint32_t scanChannels); + +#endif /*ZDONODEMANAGER_H_*/ diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoNwkManager.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoNwkManager.h new file mode 100644 index 00000000..6c9d4ef8 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoNwkManager.h @@ -0,0 +1,87 @@ +/************************************************************************//** + \file zdoNwkManager.h + + \brief The header file describes the constants, types and internal interface + of ZDO network manager + + \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: + 07/06/07 I. Kalganova - Modified +******************************************************************************/ + +#ifndef _ZDONWKMANAGER_H +#define _ZDONWKMANAGER_H + +/****************************************************************************** + Includes section +******************************************************************************/ +#include +#include +#include +#include +#include + +/****************************************************************************** + Types section +******************************************************************************/ +/********************************************************************************//** +\brief States of ZDO NWKUpdateState functionality +***********************************************************************************/ +typedef enum +{ + ZDO_IDLE_NWK_UPDATE_STATE, + ZDO_INTERNAL_NWK_UPDATE_STATE, + ZDO_EXTERNAL_NWK_UPDATE_STATE, + ZDO_EXTERNAL_ERROR_NWK_UPDATE_STATE +} ZdoNWKUpdateState_t; + +typedef struct _ZdoNwkManager_t +{ + uint8_t statusIndCounter: 4; + bool resendAnnce: 1; + bool zdpDataReqBusy: 1; + bool updateDeviceReqBusy: 1; + bool updateDeviceReqPending: 1; + ZDO_ZdpReq_t zdpDataReq; + void (*deviceAnnceConf)(ZDO_ZdpResp_t *zdpResp); + void (*resendAnnceConf)(ZDO_ZdpResp_t *zdpResp); + MAC_SetReq_t macSetReq; + ZDO_SetTxPowerReq_t *txPowerReq; +#ifdef _SECURITY_ + APS_UpdateDeviceReq_t apsUpdateDeviceReq; +#endif //_SECURITY_ + uint16_t totalTransactions; + uint16_t failTransactions; + bool badLink; + HAL_AppTimer_t updateNwkWaitTimer; + ZdoNWKUpdateState_t updateState; + uint8_t transSeqNum; +} ZdoNwkManager_t; + +/****************************************************************************** + Prototypes section +******************************************************************************/ +void zdoNwkManagerReset(void); +void zdoSendDeviceAnnce(void (*deviceAnnceConf)(ZDO_ZdpResp_t *zdpResp)); + +/****************************************************************************** + Check if short address is available for given extended address and send + appropriate request if not. + Parameters: + addr - extended address to check + Return: + true - short address already available + false - short address currently is not available, request was sent +******************************************************************************/ +bool zdoDiscoverNwkAddress(const ExtAddr_t *const addr); + +#endif // _ZDONWKMANAGER_H + +// eof zdoNwkManager.h diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoPowerManager.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoPowerManager.h new file mode 100644 index 00000000..3e827aeb --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoPowerManager.h @@ -0,0 +1,66 @@ +/*************************************************************************//** + \file zdoPowerManager.h + + \brief The header file describes the constants, types and internal interface + of ZDO power manager + + \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 _ZDOPOWERMANAGER_H +#define _ZDOPOWERMANAGER_H + +/****************************************************************************** + Includes section +******************************************************************************/ +#include +#include + +/****************************************************************************** + Types section +******************************************************************************/ +typedef struct _ZdoPowerManager_t +{ + ZDO_SleepReq_t *sleepReq; + ZDO_WakeUpReq_t *wakeUpReq; + bool sleeping; + MAC_RxEnableReq_t rxReq; + bool rxOnWhenIdle; + DeviceType_t deviceType; +#ifdef _ENDDEVICE_ + NWK_SyncReq_t syncReq; + HAL_AppTimer_t syncTimer; + uint8_t syncFailCounter; + bool waitingSyncConf; + bool polling; +#endif // _ENDDEVICE_ +} ZdoPowerManager_t; + +/****************************************************************************** + Prototypes section +******************************************************************************/ + +/**************************************************************************//** + \brief Reset power manager +******************************************************************************/ +void zdoPowerManagerReset(void); + +/****************************************************************************** + \brief Power Manager module task handler + + Note: always post ZDO_POWER_MANAGER_TASK_ID after performing actions that + may result in device ability to sleep. +******************************************************************************/ +void zdoPowerManagerHandler(void); + +#endif // _ZDOPOWERMANAGER_H_ + +// eof zdoPowerManager.h diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoReset.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoReset.h new file mode 100644 index 00000000..859ea7b4 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoReset.h @@ -0,0 +1,75 @@ +/**************************************************************************//** + \file zdoReset.h + + \brief Interface for ZDO reset routine + + \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: + 29.10.09 A. Taradov - Created +******************************************************************************/ + +#ifndef _ZDORESET_H +#define _ZDORESET_H + +/****************************************************************************** + Definitions section +******************************************************************************/ +typedef struct +{ + ZDO_Status_t status; +} ZDO_SoftwareResetConf_t; + +typedef struct +{ + ZDO_SoftwareResetConf_t confirm; + void (*ZDO_SoftwareResetConf)(ZDO_Status_t status); +} ZDO_SoftwareResetReq_t; + +typedef struct +{ + void (*stackResetCallback)(ZDO_Status_t status); +} ZdoReset_t; + +/****************************************************************************** + Prototypes section +******************************************************************************/ +/**************************************************************************//** + \brief Stack software reset routine. + + \param[in] req - pointer to request parameters. + + \return None. + ******************************************************************************/ +void ZDO_SoftwareResetReq(ZDO_SoftwareResetReq_t *req); + +/****************************************************************************** + \brief ZDO reset routine +******************************************************************************/ +void zdoReset(void); + +/**************************************************************************//** + \brief Stack resetting start routine. + + \param[in] powerFailureControl - stack restoring after power failure control bitfield; + affects on initialization procedure. + \param[out] callback - callback to stack reset finished handler. + + \return None. + ******************************************************************************/ +void zdoStackReset(NWK_PowerFailureControl_t powerFailureControl, void (*callback)(ZDO_Status_t status)); + +/**************************************************************************//** + \brief Reset component initialization routine. + ******************************************************************************/ +void zdoInitResetComponent(void); + +#endif // _ZDORESET_H + +// eof zdoReset.h diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoResetNetwork.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoResetNetwork.h new file mode 100644 index 00000000..c71d7c17 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoResetNetwork.h @@ -0,0 +1,61 @@ +/**************************************************************************//** + \file zdoResetNetwork.h + + \brief Interface for ZDO Reset Network request routine + + \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: + 17.09.09 A. Taradov - Created +******************************************************************************/ +#ifndef _ZDORESETNETWORK_H +#define _ZDORESETNETWORK_H + +/****************************************************************************** + Includes section +******************************************************************************/ +#include +#include +#include + +/****************************************************************************** + Definitions section +******************************************************************************/ + +/****************************************************************************** + Types section +******************************************************************************/ +typedef enum _ZdoResetNetworkState_t +{ + ZDO_RESET_NETWORK_IDLE_STATE, + ZDO_RESET_NETWORK_APS_RESET_STATE, +} ZdoResetNetworkState_t; + +typedef struct _ZdoResetNetwork_t +{ + ZdoResetNetworkState_t state; + ZDO_ResetNetworkReq_t *req; +} ZdoResetNetwork_t; + +/****************************************************************************** + Prototypes section +******************************************************************************/ + +/****************************************************************************** + Reset Reset Network component. + Parameters: + none + Return: + none +******************************************************************************/ +void zdoResetNetworkReset(void); + +#endif // _ZDORESETNETWORK_H + +// eof zdoResetNetwork.h diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoStartNetwork.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoStartNetwork.h new file mode 100644 index 00000000..57be2ed0 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoStartNetwork.h @@ -0,0 +1,127 @@ +/**************************************************************************//** + \file zdoStartNetwork.h + + \brief Interface for ZDO Start Network request routines + + \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: + 17.09.09 A. Taradov - Created +******************************************************************************/ +#ifndef _ZDOSTARTNETWORK_H +#define _ZDOSTARTNETWORK_H + +/****************************************************************************** + Includes section +******************************************************************************/ +#include +#include +#include + +/****************************************************************************** + Definitions section +******************************************************************************/ + +/****************************************************************************** + Types section +******************************************************************************/ +typedef enum _ZdoStartNetworkState_t +{ + ZDO_START_NETWORK_IDLE_STATE, + ZDO_START_NETWORK_BEGIN_STATE, + ZDO_START_NETWORK_APS_RESET_STATE, + ZDO_START_NETWORK_FORMATION_STATE, + ZDO_START_NETWORK_JOIN_STATE, + ZDO_START_NETWORK_REJOIN_STATE, + ZDO_START_NETWORK_JOINED_STATE, + ZDO_START_NETWORK_START_ROUTER_STATE, + ZDO_START_NETWORK_PERMIT_JOIN_STATE, + ZDO_START_NETWORK_APS_START_STATE, + ZDO_START_NETWORK_ANNCE_STATE, + ZDO_START_NETWORK_CONFIRM_STATE +} ZdoStartNetworkState_t; + +typedef void (ZdoStartNetworkConf_t)(ZDO_Status_t status); + +typedef struct _ZdoStartNetwork_t +{ + QueueDescriptor_t queue; + ZdoStartNetworkState_t state; + NWK_RejoinNetwork_t startupType; + ZdoStartNetworkConf_t *confirm; + NWK_PowerFailureControl_t powerFailureControl; +#if defined(_ROUTER_) || defined(_ENDDEVICE_) + uint8_t joinAttempts; + HAL_AppTimer_t joinTimer; +#endif +} ZdoStartNetwork_t; + +/****************************************************************************** + Prototypes section +******************************************************************************/ + +/****************************************************************************** + Reset Start Network component. + Parameters: + none + Return: + none +******************************************************************************/ +void zdoStartNetworkReset(void); + +/****************************************************************************** + Start network rejoin + Parameters: + none + Return: + none +******************************************************************************/ +void zdoRejoinNetwork(void); + +/****************************************************************************** + Start Network request task handler. + Parameters: + none + Return: + none +******************************************************************************/ +void zdoStartNetworkTaskHandler(void); + +/****************************************************************************** + Allocate Start Network module + Parameters: + startNetworkConf - confirmation callback + Return: + true - if module was alocated, false otherwise +******************************************************************************/ +bool zdoStartNetworkAlloc(ZdoStartNetworkConf_t *startNetworkConf); + +/****************************************************************************** + Free Start Network module + Parameters: + none + Return: + none +******************************************************************************/ +void zdoStartNetworkFree(void); + +#ifdef _COORDINATOR_ +/****************************************************************************** + NLME-NETWORK-FORMATION.request preparing and sending. + Parameters: + none + Return: + none +******************************************************************************/ +void zdoNetworkFormationReq(void); +#endif /* _COORDINATOR_ */ + +#endif // _ZDOSTARTNETWORK_H + +// eof zdoStartNetwork.h diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTaskManager.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTaskManager.h new file mode 100644 index 00000000..d7fbf779 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTaskManager.h @@ -0,0 +1,66 @@ +/**************************************************************************//** + \file zdoTaskManager.h + + \brief The header file describes the constants, types and internal interface + of ZDO task manager + + \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 _ZDOTASKMANAGER_H +#define _ZDOTASKMANAGER_H + +/****************************************************************************** + Includes section +******************************************************************************/ +#include + +/****************************************************************************** + Definitions section +******************************************************************************/ + +/****************************************************************************** + Types section +******************************************************************************/ +typedef enum _ZdoTaskId_t +{ + ZDO_SECURITYMANAGER_TASK_ID, + ZDO_ZDP_FRAME_PROCESSOR_TASK_ID, + ZDO_ZDP_MANAGER_TASK_ID, + ZDO_POWER_MANAGER_TASK_ID, + ZDO_START_NETWORK_TASK_ID, +#ifdef _TC_SWAPOUT_ + ZDO_TC_SWAPOUT_TASK_ID, +#endif // _TC_SWAPOUT_ + ZDO_INIT_TASK_ID, + ZDO_LAST_TASK_ID // Not a real task +} ZdoTaskId_t; + +// Mask of posted ZDO tasks +typedef uint16_t ZdoTaskBitMask_t; + +typedef void (*ZdoTaskHandler_t)(void); + +/****************************************************************************** + Prototypes section +******************************************************************************/ + +/****************************************************************************** + \brief Post ZDO subtask +******************************************************************************/ +void zdoPostTask(ZdoTaskId_t task); + +/****************************************************************************** + \brief Remove ZDO subtask from list of posted tasks +******************************************************************************/ +void zdoUnpostTask(ZdoTaskId_t task); + +#endif // _ZDOTASKMANAGER_H_ diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTcKeepAlive.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTcKeepAlive.h new file mode 100644 index 00000000..57e3f13d --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTcKeepAlive.h @@ -0,0 +1,72 @@ +/************************************************************************//** + \file zdoTcKeepAlive.h + + \brief + The TC keep-alive mechanism interface. + + \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: + 20.01.10 A. Taradov - Created. +******************************************************************************/ +#ifndef _ZDO_TC_KEEP_ALIVE_H +#define _ZDO_TC_KEEP_ALIVE_H + +#ifdef _TC_SWAPOUT_ + +/****************************************************************************** + Includes section +******************************************************************************/ +#include +#include + +/****************************************************************************** + Types section +******************************************************************************/ +typedef enum _ZdoKeepAliveState_t +{ + ZDO_TC_KEEP_ALIVE_STARTED_STATE, + ZDO_TC_KEEP_ALIVE_STOPPED_STATE, +} ZdoTcKeepAliveState_t; + +typedef enum _ZdoKeepAliveReqState_t +{ + ZDO_TC_KEEP_ALIVE_REQ_FREE_STATE, + ZDO_TC_KEEP_ALIVE_REQ_BUSY_STATE, +} ZdoTcKeepAliveReqState_t; + +typedef struct _ZdoTcKeepAlive_t +{ + ZdoTcKeepAliveState_t state; + ZdoTcKeepAliveReqState_t reqState; + ZCL_Request_t req; + HAL_AppTimer_t timer; + uint8_t pingsFailed; + Endpoint_t localEndpoint; + Endpoint_t remoteEndpoint; +} ZdoTcKeepAlive_t; + +/****************************************************************************** + Prototypes section +******************************************************************************/ + +/****************************************************************************** + Reset TC keep-alive module + Parameters: + none + Return: + none +******************************************************************************/ +void zdoTcKeepAliveReset(void); + +#endif // _TC_SWAPOUT_ + +#endif // _ZDO_TC_KEEP_ALIVE_H + +// eof zdoTcKeepAlive.h diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTcSwapOut.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTcSwapOut.h new file mode 100644 index 00000000..f71712f4 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTcSwapOut.h @@ -0,0 +1,92 @@ +/**************************************************************************//** + \file zdoTcSwapOut.h + + \brief Interface to TC Swap-out implementation + + \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: + 25.01.10 A. Taradov - Created +******************************************************************************/ + +#ifndef _ZDOTCSWAPOUT_H +#define _ZDOTCSWAPOUT_H + +#ifdef _TC_SWAPOUT_ + +/****************************************************************************** + Includes section +******************************************************************************/ +#include +#include +#include +#include +#include + +/****************************************************************************** + Definitions section +******************************************************************************/ + +/****************************************************************************** + Types section +******************************************************************************/ +typedef enum _ZdoTcSwapoutState_t +{ + ZDO_TC_SWAPOUT_IDLE_STATE, + ZDO_TC_SWAPOUT_BEGIN_STATE, + ZDO_TC_SWAPOUT_LEAVE_BEFORE_REJOIN_STATE, + ZDO_TC_SWAPOUT_REJOIN_STATE, + ZDO_TC_SWAPOUT_LEAVE_BEFORE_CONFIRM_STATE, + ZDO_TC_SWAPOUT_CONFIRM_STATE +} ZdoTcSwapoutState_t; + +typedef struct _ZdoTcSwapOut_t +{ + QueueDescriptor_t queue; + ZdoTcSwapoutState_t state; + APS_Status_t keyWasSecuredWith; + ZCL_StartSecurityReq_t zclStartSecurityReq; +} ZdoTcSwapOut_t; + +/****************************************************************************** + Prototypes section +******************************************************************************/ + +/****************************************************************************** + Indication of Transport Key command receipt + Parameters: + ind - indication parameters + Return: + none +******************************************************************************/ +void zdoTcSwapOutTransportKeyInd(APS_TransportKeyInd_t *ind); + +/****************************************************************************** + TC Swap-out request task handler. + Parameters: + none + Return: + none +******************************************************************************/ +void zdoTcSwapOutTaskHandler(void); + +/****************************************************************************** + Reset Trust Centre Swap-out component. + Parameters: + none + Return: + none +******************************************************************************/ +void zdoTcSwapOutReset(void); + +#endif // _TC_SWAPOUT_ + +#endif // _ZDOTCSWAPOUT_H + +// eof zdoTcSwapOut.h diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZdpFrameProcessor.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZdpFrameProcessor.h new file mode 100644 index 00000000..da0d6678 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZdpFrameProcessor.h @@ -0,0 +1,121 @@ +/************************************************************************//** + \file zdoZdpFrameProcessor.h + + \brief The header file describes the constants, types and internal interface + of ZDP parser component. This component sends/receives ZDP commands. + + \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: + 28/11/07 A. Zemlyanov - Created. +******************************************************************************/ + +#ifndef _ZDP_FRAME_PROCESSOR_H +#define _ZDP_FRAME_PROCESSOR_H + +/****************************************************************************** + Includes section +******************************************************************************/ +#include +#include +#include +#include +#include + +/****************************************************************************** + Definitions section +******************************************************************************/ + +/****************************************************************************** + Types section +******************************************************************************/ +typedef void (*ZdoAPSDataConf_t)(APS_DataConf_t *conf); + +typedef enum +{ + ZDO_ZDP_DATA_REQ_FREE_STATE, + ZDO_ZDP_DATA_REQ_BUSY_STATE, + ZDO_ZDP_DATA_REQ_SEND_STATE, + ZDO_ZDP_DATA_REQ_WAIT_CONF_STATE +} ZDO_ZdpDataReqState_t; + +typedef enum +{ + ZDO_ZDP_IND_FREE_STATE, + ZDO_ZDP_IND_BUSY_STATE +} ZDO_ZdpIndState_t; + + +typedef struct zdoFrameProc_t_ +{ + uint8_t requestSeqNum; + ZDO_ZdpReq_t *zdpRequest; // Currently processed zdpRequest + + ZDO_ZdpDataReqState_t apsDataReqState; + APS_DataReq_t apsDataReq; // Common for all requests to APS + + // Incoming data from APS + ZDO_ZdpIndState_t apsDataIndState; + APS_DataInd_t apsDataInd; + uint8_t apsAsduBuff[APS_MAX_ASDU_SIZE]; // Buffer for inconing APS ASDU +} ZdoFrameProc_t; + + +/****************************************************************************** + Prototypes section +******************************************************************************/ +/****************************************************************************** + Reset the ZDP Frame Processor into initial state + Parameters: + None + Returns: + None. +******************************************************************************/ +void zdoZdpFrameProcessorReset(void); + +/****************************************************************************** + Send ZDP request + Parameters: + req - pointer to request object + Returns: + None. +******************************************************************************/ +void zdoZdpSendRequest(ZDO_ZdpReq_t *req); + +/****************************************************************************** + TODO +******************************************************************************/ +void zdoSetZdpDataReqState(ZDO_ZdpDataReqState_t state); + +/****************************************************************************** + TODO +******************************************************************************/ +void zdoSetZdpIndState(ZDO_ZdpIndState_t state); + +/****************************************************************************** + Process incoming ZDP frames data from APS layer + Parameters: + ind - Pointer to APS_DataInd_t type object + Returns: + None. +******************************************************************************/ +void APS_ZdoDataInd(APS_DataInd_t *ind); + +/****************************************************************************** + To be called when gets frame from APS + Parameters: + apsInd - Pointer to APS_DataInd_t type object + Returns: + None. +******************************************************************************/ +void zdoZdpMessageInd(APS_DataInd_t *dataInd); + +void zdoZdpFrameProcessorHandler(void); + +#endif /* _ZDP_FRAME_PROCESSOR_H */ diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZdpManager.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZdpManager.h new file mode 100644 index 00000000..641b47c3 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZdpManager.h @@ -0,0 +1,65 @@ +/************************************************************************//** + \file zdoZdpManager.h + + \brief The header file describes the constants, types and internal interface + of ZDP manager. This component manages ZDP requests and responses. + + \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 _ZDOZDPMANAGER_H +#define _ZDOZDPMANAGER_H + +/****************************************************************************** + Includes section +******************************************************************************/ +#include +#include +#include + +/****************************************************************************** + Definitions section +******************************************************************************/ + +/****************************************************************************** + Types section +******************************************************************************/ +typedef enum _ZDO_ZdpRequestState_t +{ + ZDO_IDLE_ZDP_REQUEST_STATE, + ZDO_SEND_ZDP_REQUEST_STATE, + ZDO_WAIT_RESP_CONF_ZDP_REQUEST_STATE, + ZDO_WAIT_CONF_ZDP_REQUEST_STATE, + ZDO_WAIT_RESP_ZDP_REQUEST_STATE, + ZDO_CONFIRM_MDR_ZDP_REQUEST_STATE, + ZDO_CONFIRM_MDR1_ZDP_REQUEST_STATE, + ZDO_CONFIRM_ZDP_REQUEST_STATE, + ZDO_WAIT_CONFIRM_UPDATE_ZDP_REQUEST_STATE +} ZDO_ZdpRequestState_t; + +typedef struct _ZdoZdpManager_t +{ + QueueDescriptor_t requestQueue; + HAL_AppTimer_t ttlUpdateTimer; + ZDO_ZdpFrame_t zdpFrame; +} ZdoZdpManager_t; + + +/****************************************************************************** + Prototypes section +******************************************************************************/ +void zdoZdpResetReq(void); + +void zdoZdpManagerHandler(void); + +void zdoInitZdpRequestTTL(ZDO_ZdpReq_t *const zdpReq, const uint32_t ttl); + +#endif // _ZDOZDPMANAGER_H_ diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZib.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZib.h new file mode 100644 index 00000000..baaa5eab --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZib.h @@ -0,0 +1,99 @@ +/************************************************************************//** + \file zdoZib.h + + \brief The header file describes the ZDO information base + + \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 _ZDOZIB_H +#define _ZDOZIB_H + +/****************************************************************************** + Includes section. +******************************************************************************/ +#include +#include + +/****************************************************************************** + Definitions section. +******************************************************************************/ +#define LUXOFT_MANUFACTURER_CODE 0x100c +#define CT_EPID_MASK 0xFFFFFFFFFFFF0000 // ??? +#define COMMISSIONING_EPID 0x0050C27710000000 // ??? +#define NUM_ACTIVE_EP 1 //FIXME +#define MAX_DISCOVERED_NETWORKS_NUMBER 3 +#define NETWORK_SELECT_CRITERIES (CHOOSENET_EXTPANID | CHOOSENET_STACKPROFILE | CHOOSENET_ZBVERSION) +#define BEACON_ORDER 0x0f +#define SUPER_FRAME_ORDER 0x0f +#define BATTERY_LIFE_EXTENTION true + +/****************************************************************************** + Types section +******************************************************************************/ +typedef struct +{ + //scannig channel mask + uint32_t channelMask; + //extended PAN ID + ExtPanId_t extPanId; + //short address + ShortAddr_t shortAddr; + //current channel + uint8_t channel; + //parent extended address + ExtAddr_t parentExtAddress; + //parent short address + ShortAddr_t parentNetworkAddress; + //current PAN ID + PanId_t panID; + //node descriptor + NodeDescriptor_t nodeDescriptor; + //node power descriptor + PowerDescriptor_t powerDescriptor; + //simple descriptor + //SimpleDescriptor_t configSimpleDescriptors[NUM_ACTIVE_EP]; + //scanning duration in seconds + uint8_t scanDuration; + //number of failure parent sync retries + uint8_t parentLinkRetryThreshold; + // + uint8_t permitJoinDuration; + //ZDP response wait timeout + uint16_t zdpResponseTimeout; +} ZIB_t; + +extern ZIB_t csZIB; + +/****************************************************************************** + Prototypes section +******************************************************************************/ + +/****************************************************************************** + Reload ZIB from ConfigServer + Parameters: + none + Return: + none +******************************************************************************/ +void zdoReloadZibFromConfigServer(void); + +/****************************************************************************** + Set actual network parameters to ZIB + Parameters: + none + Return: + none +******************************************************************************/ +void setNetworkParametersToZib(void); + +#endif // _ZDOZIB_H + +// eof zdoZib.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; //! +#include + +/****************************************************************************** + Types section +******************************************************************************/ + +/****************************************************************************** + Prototypes section +******************************************************************************/ + +/****************************************************************************** + Call ZDO_MgmtNwkUpdateNotf() only with status information. + Parameters: + status - update status + Return: + none +******************************************************************************/ +void ZDO_NotifySimple(ZDO_Status_t status); + +/****************************************************************************** + Call ZDO_MgmtNwkUpdateNotf() with prepared notification information + Parameters: + notf - notification information + Return: + none +******************************************************************************/ +void ZDO_NotifyGeneral(ZDO_MgmtNwkUpdateNotf_t *notf); + +/****************************************************************************** + Call ZDO_MgmtNwkUpdateNotf() with child update information. + Parameters: + status - update status + childInfo - updated device information + Return: + none +******************************************************************************/ +void ZDO_NotifyChildUpdate(ZDO_Status_t status, ChildInfo_t *childInfo); + +/****************************************************************************** + Call ZDO_MgmtNwkUpdateNotf() with new network parameters. + Parameters: + status - update status + Return: + none +******************************************************************************/ +void ZDO_NotifyNwkUpdate(ZDO_Status_t status); + +/****************************************************************************** + Call ZDO_MgmtNwkUpdateNotf() with conflict address. + Parameters: + status - update status + shortAddr - conflicting address + Return: + none +******************************************************************************/ +void ZDO_NotifyAddressConflict(ZDO_Status_t status, ShortAddr_t *shortAddr); + +#if defined(_SECURITY_) && defined _LINK_SECURITY_ +/****************************************************************************** + Call ZDO_MgmtNwkUpdateNotf() with information about security keys updates. + Parameters: + status - update status + extAddr - extended address of updated device + Return: + none +******************************************************************************/ +void ZDO_NotifySecurityUpdate(ZDO_Status_t status, ExtAddr_t *extAddr); + +#ifdef _TC_PROMISCUOUS_MODE_ +/**************************************************************************//** +\brief Notification about remote device bind have been staled + + The function should be defined by an application. + It is called when the device was notificated about bounded device lost + +\param[in] extAddr - pointer to extended address of lost bounded device +******************************************************************************/ +void ZDO_NotifyBindLost(ExtAddr_t* extAddr); +#endif /* _TC_PROMISCUOUS_MODE_ */ + +#endif // defined(_SECURITY_) && defined _LINK_SECURITY_ + +#endif // _ZDONOTIFY_H + +// eof zdoNotify.h diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/zdoSecurityManager.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/zdoSecurityManager.h new file mode 100644 index 00000000..fb093ec9 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/zdoSecurityManager.h @@ -0,0 +1,85 @@ +/************************************************************************//** + \file zdoSecurityManager.h + + \brief The header file describes the constants, types and internal interface + of ZDO security manager + + \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 _ZDOSECURITYMANAGER_H +#define _ZDOSECURITYMANAGER_H + +/****************************************************************************** + Includes section +******************************************************************************/ +#include +#include + +/****************************************************************************** + Types section +******************************************************************************/ +typedef enum +{ + ZDO_IDLE_SECURITY_STATE, + ZDO_NORMAL_OPERATING_SECURITY_STATE, + ZDO_WAITING_ESTABLISH_KEY_SECURITY_STATE, + ZDO_WAITING_TRANSPORT_KEY_SECURITY_STATE, + ZDO_WAITING_PARENT_AUTHENTICATION_SECURITY_STATE, + ZDO_WAITING_CHILD_AUTHENTICATION_SECURITY_STATE, + ZDO_APP_KEY_ESTABLISH_RESPONDER_SECURITY_STATE, + ZDO_APP_KEY_ESTABLISH_INITIATOR_SECURITY_STATE, + ZDO_STARTING_NORMAL_OPERATING_SECURITY_STATE, + ZDO_FAIL_CONFIRM_SECURITY_STATE, + ZDO_CONFIRM_APP_KEY_SECURITY_STATE, + ZDO_WAITING_APP_KEY_SECURITY_STATE, + ZDO_WAITING_TC_LINK_KEY_SECURITY_STATE, +} ZdoSecurityManagerState_t; + +typedef struct +{ + ZdoSecurityManagerState_t state; +#ifdef _SECURITY_ + HAL_AppTimer_t waitTimer; + HAL_AppTimer_t delayTimer; + uint8_t newKeySeqNum; +#ifdef _LINK_SECURITY_ + union + { + APS_AuthenticateReq_t apsAuthenticateReq; +#ifdef _HI_SECURITY_ + APS_EstablishKeyReq_t apsEstablishKeyReq; +#endif // _HI_SECURITY_ +#ifdef _CUSTOM_4_SECURITY_MODE_ + APS_RequestKeyReq_t apsRequestKeyReq; +#endif // _CUSTOM_4_SECURITY_MODE_ + }; +#ifdef _HI_SECURITY_ + APS_EstablishKeyResp_t apsEstablishKeyResp; +#endif // _HI_SECURITY_ + ZDO_EndToEndAppKeyReq_t *appKeyReq; +#endif // _LINK_SECURITY_ +#endif // _SECURITY_ +} ZdoSecurityManager_t; + +/****************************************************************************** + Prototypes section +******************************************************************************/ +void zdoResetSecurityManager(void); +void zdoAuthenticationStart(void); +void zdoAuthenticationConf(ZDO_Status_t status); +uint8_t ZDO_GetPreconfiguredStatus(void); +void zdoAuthenticateChild(const ExtAddr_t *childAddr); +void zdoSecurityManagerHandler(void); + +#endif // _ZDOSECURITYMANAGER_H + +// eof zdoSecurityManager.h -- cgit v1.2.3