From a54ad9edce697133a024aff096e50f7e4f389d5b Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Sun, 18 Mar 2012 12:22:02 +0100 Subject: digital/beacon: import Zigbit stack (bitcloud) & avr sources --- .../Components/ZDO/include/private/zdoBinding.h | 46 ++++++ .../Components/ZDO/include/private/zdoDbg.h | 129 +++++++++++++++ .../ZDO/include/private/zdoDiscoveryManager.h | 24 +++ .../ZDO/include/private/zdoEndDeviceBinding.h | 134 ++++++++++++++++ .../Components/ZDO/include/private/zdoInit.h | 39 +++++ .../ZDO/include/private/zdoLeaveNetwork.h | 111 +++++++++++++ .../Components/ZDO/include/private/zdoManager.h | 116 ++++++++++++++ .../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 ++++++++ .../Components/ZDO/include/private/zdoZib.h | 99 ++++++++++++ 20 files changed, 1775 insertions(+) create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoBinding.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoDbg.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoDiscoveryManager.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoEndDeviceBinding.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoInit.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoLeaveNetwork.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoManager.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoMem.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoNodeManager.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoNwkManager.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoPowerManager.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoReset.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoResetNetwork.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoStartNetwork.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoTaskManager.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoTcKeepAlive.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoTcSwapOut.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoZdpFrameProcessor.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoZdpManager.h create mode 100644 digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoZib.h (limited to 'digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private') diff --git a/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoBinding.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoBinding.h new file mode 100644 index 00000000..3ae2cc93 --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoDbg.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoDbg.h new file mode 100644 index 00000000..8121410e --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoDiscoveryManager.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoDiscoveryManager.h new file mode 100644 index 00000000..d06dd565 --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoEndDeviceBinding.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoEndDeviceBinding.h new file mode 100644 index 00000000..22380e81 --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoInit.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoInit.h new file mode 100644 index 00000000..9490fcda --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoLeaveNetwork.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoLeaveNetwork.h new file mode 100644 index 00000000..1b16792c --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoManager.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoManager.h new file mode 100644 index 00000000..e21a8db2 --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoMem.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoMem.h new file mode 100644 index 00000000..ce80a64d --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoNodeManager.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoNodeManager.h new file mode 100644 index 00000000..49cddb1a --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoNwkManager.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoNwkManager.h new file mode 100644 index 00000000..6c9d4ef8 --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoPowerManager.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoPowerManager.h new file mode 100644 index 00000000..3e827aeb --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoReset.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoReset.h new file mode 100644 index 00000000..859ea7b4 --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoResetNetwork.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoResetNetwork.h new file mode 100644 index 00000000..c71d7c17 --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoStartNetwork.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoStartNetwork.h new file mode 100644 index 00000000..57be2ed0 --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoTaskManager.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoTaskManager.h new file mode 100644 index 00000000..d7fbf779 --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoTcKeepAlive.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoTcKeepAlive.h new file mode 100644 index 00000000..57e3f13d --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoTcSwapOut.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoTcSwapOut.h new file mode 100644 index 00000000..f71712f4 --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoZdpFrameProcessor.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoZdpFrameProcessor.h new file mode 100644 index 00000000..da0d6678 --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoZdpManager.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoZdpManager.h new file mode 100644 index 00000000..641b47c3 --- /dev/null +++ b/digital/beacon/src/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/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoZib.h b/digital/beacon/src/Bitcloud_stack/Components/ZDO/include/private/zdoZib.h new file mode 100644 index 00000000..baaa5eab --- /dev/null +++ b/digital/beacon/src/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 -- cgit v1.2.3