summaryrefslogtreecommitdiff
path: root/digital/zigbit/bitcloud/stack/Components/ZDO/include/appFramework.h
blob: 7924d250d17189acfe6738321206249599b0054f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
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 <types.h>
#include <bcEndian.h>
#include <mac.h>
#include <queue.h>

#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 */