summaryrefslogtreecommitdiffhomepage
path: root/digital/zigbit/bitcloud/stack/Components/ZCL/include/zcl.h
blob: 0731a4177bcbc82fc656817c827ac417d34ddc09 (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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
/************************************************************************//**
  \file zcl.h

  \brief
    The header file describes the public ZCL interface

    The file describes the public interface and types of ZCL

  \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:
    01.12.08 I. Fedina & A. Potashov - Created.
******************************************************************************/

#ifndef _ZCL_H
#define _ZCL_H

/******************************************************************************
                           Includes section
******************************************************************************/
#include <types.h>
#include <appFramework.h>
#include <aps.h>

/******************************************************************************
                           Definitions section
******************************************************************************/
#define PROFILE_ID_SMART_ENERGY  CCPU_TO_LE16(0x0109)
#define PROFILE_ID_CBA CCPU_TO_LE16(0x0105)
#define PROFILE_ID_HOME_AUTOMATION CCPU_TO_LE16(0x0104)
#define PROFILE_ID_SMART_LIGHTING CCPU_TO_LE16(0xc05e)

#define ZCL_MAX_ASDU_SIZE    75 //it is temporary hack to prevent fragmentation for ZCL packets. It should be fixed with correct calculation of payload size.

// Macros defines the maximum size allocated for a value of type OCTET_STRING
#define OCTET_STRING_MAX_SIZE 255
/******************************************************************************
                           Types section
******************************************************************************/
typedef uint8_t  ZCL_ClusterType_t;
typedef uint16_t ZCL_AttributeId_t; //<! Describes type of attributes IDs
typedef uint8_t  ZCL_CommandId_t;
typedef uint32_t ZCL_UTCTime_t;
typedef uint32_t ZCL_Date_t;
typedef uint16_t ZCL_ReportTime_t; // time for reporting in seconds

/***************************************************************************//**
\brief Enumerated status values used in the ZCL
*******************************************************************************/
typedef enum
{
  //! Operation was successful.
  ZCL_SUCCESS_STATUS                      = 0x00,
  //!Operation was not successful
  ZCL_FAILURE_STATUS                      = 0x01,

  //0x02 - 0x7d - Reserved
  ZCL_INVALID_ATTRIBUTE_VALUE_STATUS      = 0x02,
  ZCL_TC_PERMISSION_TABLE_ERROR_STATUS    = 0x03,
  ZCL_APS_LINK_KEY_ERROR_STATUS           = 0x04,

  //!The sender of the command does not have authorization to carry out this command.
  ZCL_NOT_AUTHORIZED_STATUS               = 0x7e,
  //!A reserved field/subfield/bit contains a nonzero value
  ZCL_RESERVED_FIELD_NOT_ZERO_STATUS      = 0x7f,
  /*!The command appears to contain the wrong fields, as detected either by the
  presence of one or more invalid field entries or by there being missing fields.
  Command not carried out. Implementer has discretion as to whether to return
  this error or ZCL_INVALID_FIELD_STATUS.*/
  ZCL_MALFORMED_COMMAND_STATUS            = 0x80,
  /*!The specified cluster command is not supported on the device.Command not
  carried out.*/
  ZCL_UNSUP_CLUSTER_COMMAND_STATUS        = 0x81,
  /*!The specified general ZCL command is not supported on the device.*/
  ZCL_UNSUP_GENERAL_COMMAND_STATUS        = 0x82,
  /*!A manufacturer specific unicast, cluster specific command was received
  with an unknown manufacturer code, or the manufacturer code was recognized but
  the command is not supported*/
  ZCL_UNSUP_MANUF_CLUSTER_COMMAND         = 0x83,
  /*!A manufacturer specific unicast, ZCL specific command was received with an
  unknown manufacturer code, or manufacturer code was recognized but the command
  is not supported*/
  ZCL_UNSUP_MANUF_GENERAL_COMMAND_STATUS  = 0x84,
  /*!At least one field of the command contains an incorrect value, according
  to the specification the device is implemented to.*/
  ZCL_INVALID_FIELD_STATUS                = 0x85,
  /*!The specified attribute does not exist on the device.*/
  ZCL_UNSUPPORTED_ATTRIBUTE_STATUS        = 0x86,
  /*!Out of range error, or set to a reserved value. Attribute keeps its old
  value.*/
  ZCL_INVALID_VALUE_STATUS                = 0x87,
  /*!Attempt to write a read only attribute.*/
  ZCL_READ_ONLY_STATUS                    = 0x88,
  /*!An operation (e.g. an attempt to create an entry in a table) failed due
  to an insufficient amount of free space available.*/
  ZCL_INSUFFICIENT_SPACE_STATUS           = 0x89,
  /*!An attempt to create an entry in a table failed due to a duplicate entry
  already being present in the table.*/
  ZCL_DUPLICATE_EXISTS_STATUS             = 0x8a,
  /*!The requested information (e.g. table entry) could not be found.*/
  ZCL_NOT_FOUND_STATUS                    = 0x8b,
  /*!Periodic reports cannot be issued for this attribute.*/
  ZCL_UNREPORTABLE_ATTRIBUTE_STATUS       = 0x8c,
  /*!The data type given for an attribute is incorrect. Command not carried out.*/
  ZCL_INVALID_DATA_TYPE_STATUS            = 0x8d,
  /*!The selector for an attribute is incorrect.*/
  ZCL_INVALID_SELECTOR_STATUS             = 0x8e,
  /*!A request has been made to read an attribute that the requester is not
  authorized to read. No action taken.*/
  ZCL_WRITE_ONLY_STATUS                   = 0x8f,
  /*!Setting the requested values would put the device in an inconsistent state
  on startup. No action taken.*/
  ZCL_INCONSISTENT_STARTUP_STATE_STATUS   = 0x90,
  /*!An attempt has been made to write an attribute that is present but is
  defined using an out-of-band method and not over the air.*/
  ZCL_DEFINED_OUT_OF_BAND_STATUS          = 0x91,
  /*!Failed case when a otau client or a otau server decides to abort the upgrade process. */
  ZCL_ABORT_STATUS                        = 0x95,
  /*!Invalid OTA upgrade image (ex. failed signature validation or signer information check or CRC check) */
  ZCL_INVALID_IMAGE_STATUS                = 0x96,
  /*!Server does not have data block available yet */
  ZCL_WAIT_FOR_DATA_STATUS                = 0x97,
  /*!No OTA upgrade image available for a particular client */
  ZCL_NO_IMAGE_AVAILABLE_STATUS           = 0x98,
  /*!The client still requires more OTA upgrade image files in order to successfully upgrade*/
  ZCL_REQUIRE_MORE_IMAGE_STATUS           = 0x99,

  //0x97 - 0xbf - Reserved

  /*!An operation was unsuccessful due to a hardware failure.*/
  ZCL_HARDWARE_FAILURE_STATUS             = 0xc0,
  /*!An operation was unsuccessful due to a software failure.*/
  ZCL_SOFTWARE_FAILURE_STATUS             = 0xc1,
  /*!An error occurred during calibration.*/
  ZCL_CALIBRATION_ERROR_STATUS            = 0xc2,

  //0xc3 - 0xff - Reserved

  ZCL_SENDING_ERROR_STATUS                = 0xc3,
  //ZCL_ATTRIBUTE_NOT_FOUND_STATUS,
  ZCL_BAD_FRAME_STATUS                    = 0xc4,
  //ZCL_WRONG_ATTRIBUTE_TYPE_STATUS,
  ZCL_WRONG_RESPONSE_LENGTH_STATUS        = 0xc5,
  ZCL_END_PAYLOAD_REACHED_STATUS          = 0xfd,
  ZCL_MAX_PAYLOAD_REACHED_STATUS          = 0xfe,
  ZCL_INVALID_PARAMETER_STATUS            = 0xff,

} ZCL_Status_t;

/********************************************************************************//**
\brief ZigBee data types identifiers.

ZigBee devices, such as thermostats, lamps, etc., are defined in terms of the
attributes they contain, which can be written, read or reported using the
ZCL commands. The following list defines the data types and formats that
can be used for these attributes. Note that individual clusters, which may use
different or new types, show valid values, ranges, and units for the attributes they
represent.
Each data type is allocated an 8-bit data type ID. The most significant 5 bits of this
ID is used to divide the types into 32 type classes, and the least significant 3 bits
specify a specific data type within this class.
***********************************************************************************/
typedef enum
{
  //Null
  ZCL_NO_DATA_TYPE_ID                       = 0x00,

  //General data
  ZCL_8BIT_DATA_TYPE_ID                     = 0x08,
  ZCL_16BIT_DATA_TYPE_ID                    = 0x09,
  ZCL_24BIT_DATA_TYPE_ID                    = 0x0a,
  ZCL_32BIT_DATA_TYPE_ID                    = 0x0b,
  ZCL_40BIT_DATA_TYPE_ID                    = 0x0c,
  ZCL_48BIT_DATA_TYPE_ID                    = 0x0d,
  ZCL_56BIT_DATA_TYPE_ID                    = 0x0e,
  ZCL_64BIT_DATA_TYPE_ID                    = 0x0f,

  //Logical
  ZCL_BOOLEAN_DATA_TYPE_ID                  = 0x10,

  //Bitmap
  ZCL_8BIT_BITMAP_DATA_TYPE_ID              = 0x18,
  ZCL_16BIT_BITMAP_DATA_TYPE_ID             = 0x19,
  ZCL_24BIT_BITMAP_DATA_TYPE_ID             = 0x1a,
  ZCL_32BIT_BITMAP_DATA_TYPE_ID             = 0x1b,
  ZCL_40BIT_BITMAP_DATA_TYPE_ID             = 0x1c,
  ZCL_48BIT_BITMAP_DATA_TYPE_ID             = 0x1d,
  ZCL_56BIT_BITMAP_DATA_TYPE_ID             = 0x1e,
  ZCL_64BIT_BITMAP_DATA_TYPE_ID             = 0x1f,

  //Unsigned integer
  ZCL_U8BIT_DATA_TYPE_ID                    = 0x20,
  ZCL_U16BIT_DATA_TYPE_ID                   = 0x21,
  ZCL_U24BIT_DATA_TYPE_ID                   = 0x22,
  ZCL_U32BIT_DATA_TYPE_ID                   = 0x23,
  ZCL_U40BIT_DATA_TYPE_ID                   = 0x24,
  ZCL_U48BIT_DATA_TYPE_ID                   = 0x25,
  ZCL_U56BIT_DATA_TYPE_ID                   = 0x26,
  ZCL_U64BIT_DATA_TYPE_ID                   = 0x27,

  //Signed integer
  ZCL_S8BIT_DATA_TYPE_ID                    = 0x28,
  ZCL_S16BIT_DATA_TYPE_ID                   = 0x29,
  ZCL_S24BIT_DATA_TYPE_ID                   = 0x2a,
  ZCL_S32BIT_DATA_TYPE_ID                   = 0x2b,
  ZCL_S40BIT_DATA_TYPE_ID                   = 0x2c,
  ZCL_S48BIT_DATA_TYPE_ID                   = 0x2d,
  ZCL_S56BIT_DATA_TYPE_ID                   = 0x2e,
  ZCL_S64BIT_DATA_TYPE_ID                   = 0x2f,

  //Enumeration
  ZCL_8BIT_ENUM_DATA_TYPE_ID                = 0x30,
  ZCL_16BIT_ENUM_DATA_TYPE_ID               = 0x31,

  //Floating point
  ZCL_FSEMI_PRECISION_DATA_TYPE_ID          = 0x38,
  ZCL_FSINGLE_PRECISION_DATA_TYPE_ID        = 0x39,
  ZCL_FDOUBLE_PRECISION_DATA_TYPE_ID        = 0x3a,

  //String
  ZCL_OCTET_STRING_DATA_TYPE_ID             = 0x41,
  ZCL_CHARACTER_STRING_DATA_TYPE_ID         = 0x42,
  ZCL_LONG_OCTET_STRING_DATA_TYPE_ID        = 0x43,
  ZCL_LONG_CHARACTER_STRING_DATA_TYPE_ID    = 0x44,

  //Ordered sequence
  ZCL_ARRAY_DATA_TYPE_ID                    = 0x48,
  ZCL_STRUCTURE_DATA_TYPE_ID                = 0x4c,

  //Collection
  ZCL_SET_DATA_TYPE_ID                      = 0x50,
  ZCL_BAG_DATA_TYPE_ID                      = 0x51,

  //Time
  ZCL_TIME_OF_DAY_DATA_TYPE_ID              = 0xe0,
  ZCL_DATE_DATA_TYPE_ID                     = 0xe1,
  ZCL_UTC_TIME_DATA_TYPE_ID                 = 0xe2,

  //Identifier
  ZCL_CLUSTER_ID_DATA_TYPE_ID               = 0xe8,
  ZCL_ATTRIBUTE_ID_DATA_TYPE_ID             = 0xe9,
  ZCL_BACNET_OID_DATA_TYPE_ID               = 0xea,

  //Misscellaneous
  ZCL_IEEE_ADDRESS_DATA_TYPE_ID             = 0xf0,
  ZCL_128BIT_SECURITY_KEY_DATA_TYPE_ID      = 0xf1,
} ZCL_AttributeType_t;

/***************************************************************************//**
\brief The list of general ZCL commands.
*******************************************************************************/
typedef enum
{
  /*! Reading particular attributes' values from a remote device*/
  ZCL_READ_ATTRIBUTES_COMMAND_ID                            = 0x00,
  ZCL_READ_ATTRIBUTES_RESPONSE_COMMAND_ID                   = 0x01,

/*Write attributes*/
  /*! Modifying values of particular attributes on a remote device*/
  ZCL_WRITE_ATTRIBUTES_COMMAND_ID                           = 0x02,
  ZCL_WRITE_ATTRIBUTES_UNDIVIDED_COMMAND_ID                 = 0x03,
  ZCL_WRITE_ATTRIBUTES_RESPONSE_COMMAND_ID                  = 0x04,
  ZCL_WRITE_ATTRIBUTES_NO_RESPONSE_COMMAND_ID               = 0x05,

/*Configure reporting*/
  ZCL_CONFIGURE_REPORTING_COMMAND_ID                        = 0x06,
  ZCL_CONFIGURE_REPORTING_RESPONSE_COMMAND_ID               = 0x07,

/*Read reporting*/
  ZCL_READ_REPORTING_CONFIGURATION_COMMAND_ID               = 0x08,
  ZCL_READ_REPORTING_CONFIGURATION_RESPONSE_COMMAND_ID      = 0x09,

/*Report attributes*/
  /*! Reporting particular attributes to a remote device; that is, 
  sending current attributes' values*/
  ZCL_REPORT_ATTRIBUTES_COMMAND_ID                          = 0x0a,

/*Default response*/
  ZCL_DEFAULT_RESPONSE_COMMAND_ID                           = 0x0b,

/*Discover attributes*/
  /*! Obtaining information (IDs and types) of attributes supported 
  by a particular cluster on a remote device*/
  ZCL_DISCOVER_ATTRIBUTES_COMMAND_ID                        = 0x0c,
  ZCL_DISCOVER_ATTRIBUTES_RESPONSE_COMMAND_ID               = 0x0d,

/*Read attributes structured*/
  ZCL_READ_ATTRIBUTES_STRUCTURED_COMMAND_ID                 = 0x0e,

/*Write attributes structured*/
  ZCL_WRITE_ATTRIBUTES_STRUCTURED_COMMAND_ID                = 0x0f,
  ZCL_WRITE_ATTRIBUTES_STRUCTURED_RESPONSE_COMMAND_ID       = 0x10
} ZCL_GeneralCommandId_t;

/***************************************************************************//**
\brief Type describing possible ZSE Device IDs.
*******************************************************************************/
typedef enum
{
  /*! The Range Extender is a simple device that acts as a router for other devices. The
  Range Extender device shall not be a ZigBee end device. A product that
  implements the Range Extender device shall not implement any other devices
  defined in this profile. This device shall only be used if the product is not intended
  to have any other application, or if a private application is implemented that has
  not been addressed by this profile.*/
  ZSE_RANGE_EXTENDER_DEVICE_ID                          = 0x0008,
  /*! The Energy Service Portal connects the energy supply company communication
  network to the metering and energy management devices within the home. It
  routes messages to and from the relevant end points. It may be installed within a
  meter, thermostat, or In-Premise Display, or may be a standalone device, and it
  will contain another non-ZigBee communication module (e.g. power-line carrier,
  RF, GPRS, broadband Internet connection).*/
  ZSE_ENERGY_SERVICE_PORTAL_DEVICE_ID                   = 0x0500,
  /*!The Metering end device is a meter (electricity, gas, water, heat, etc.) that is fitted
  with a ZigBee device. Depending on what is being metered, the device may be
  capable of immediate (requested) reads or it will autonomously send readings
  periodically. A Metering end device may also be capable of communicating
  certain status indicators (e.g. battery low, tamper detected).*/
  ZSE_METERING_DEVICE_DEVICE_ID                         = 0x0501,
  /*! The In-Premise Display device will relay energy consumption data to the user by
  way of a graphical or text display. The display may or may not be an interactive
  device. At a minimum at least one of the following should be displayed: current
  energy usage, a history over selectable periods, pricing information, or text
  messages. As an interactive device, it can be used for returning simple messages
  for interpretation by the recipient.*/
  ZSE_IN_PREMISE_DISPLAY_DEVICE_ID                      = 0x0502,
  /*! The PCT device shall provide the capability to control the premise heating and
  cooling systems.*/
  ZSE_PROGRAMMABLE_COMMUNICATING_THERMOSTAT_DEVICE_ID   = 0x0503,
  /*! The Load Control device is capable of receiving Demand Response and Load
  Control events to manage consumption on a range of devices. Example devices
  are water heaters, exterior lighting, and pool pumps.*/
  ZSE_LOAD_CONTROL_DEVICE_DEVICE_ID                     = 0x0504,
  /*! Smart Appliance devices on the ZigBee network can participate in energy
  management activities. Examples of these are when Utilities initiate a demand
  response or pricing event, or the appliance actively informs customers via inhome
  displays of when or how energy is being used. In the latter case, scenarios
  include: Washer switching to cold water during periods of higher energy costs;
  Washer/Dryer/Oven/Hot Water Heater reporting cycle status;
  Over temperature conditions in Freezers and Refrigerators.*/
  ZSE_SMART_APPLIANCE_DEVICE_ID                         = 0x0505,
  /*! The Prepayment Terminal device will allow utility customers or other users (e.g.
  sub-metered tenants) to pay for consumption in discrete increments rather than
  establishing a traditional billing agreement. The Prepayment Terminal device will
  accept payment (e.g. credit card, code entry), display remaining balances, and
  alert the user of a balance approaching zero, and may perform some or all of the
  other functions described in In-Premise Display.*/
  ZSE_PREPAYMENT_TERMINAL_DEVICE_ID                     = 0x0506,
} ZSE_DeviceId_t;

/***************************************************************************//**
\brief Type describing possible HA Device Ids.
*******************************************************************************/
typedef enum
{
  /*! Home-Automation-Profile_r25 7.4.1 On/Off Light*/
  HA_ON_OFF_LIGHT_DEVICE_ID                             = 0x0100,
  /*! Home-Automation-Profile_r25 7.4.4 On/Off Light Switch*/
  HA_ON_OFF_LIGHT_SWITCH_DEVICE_ID                      = 0x0103,
  /*! Home-Automation-Profile_r25 7.4.5 Dimmer Switch*/
  HA_DIMMER_SWITCH_DEVICE_ID                            = 0x0104,
  /*! Home-Automation-Profile_r25 7.4.8 Occupancy Sensor*/
  HA_OCCUPANCY_SENSOR_DEVICE_ID                         = 0x0107,
  /*! Home-Automation-Profile_r25 7.3.7 Remote Control*/
  HA_REMOTE_CONTROL_DEVICE_ID                           = 0x0006,
  /*! Home-Automation-Profile_r25 7.4.2 Dimmable Light*/
  HA_DIMMABLE_LIGHT_DEVICE_ID                           = 0x0101,
    /*! Home-Automation-Profile_r25 7.6.2 Thermostat*/
  HA_THERMOSTAT_DEVICE_ID                               = 0x0301,
} HA_DeviceId_t;

/***************************************************************************//**
\brief Type describing possible ZLL Device Ids.
*******************************************************************************/
typedef enum
{
  /*! On/Off Light */
  ZLL_ON_OFF_LIGHT_DEVICE_ID                            = 0x0000,
  /*! On/off plug-in unit */
  ZLL_ON_OFF_PLUGIN_UNIT_DEVICE_ID                      = 0x0010,
  /*! Dimmable light */
  ZLL_DIMMABLE_LIGHT_DEVICE_ID                          = 0x0100,
  /*! Dimmable plug-in unit */
  ZLL_DIMMABLE_PLUGIN_UNIT_DEVICE_ID                    = 0x0110,
  /*! Color light */
  ZLL_COLOR_LIGHT_DEVICE_ID                             = 0x0200,
  /*! Color remote */
  ZLL_COLOR_REMOTE_DEVICE_ID                            = 0x0800,
  /*! Color scene remote */
  ZLL_COLOR_SCENE_REMOTE_DEVICE_ID                      = 0x0810,
  /*! Non-color remote */
  ZLL_NON_COLOR_REMOTE_DEVICE_ID                        = 0x0820,
  /*! Non-color scene remote */
  ZLL_NON_COLOR_SCENE_REMOTE_DEVICE_ID                  = 0x0830,
  /*! Control bridge */
  ZLL_CONTROL_BRIDGE_DEVICE_ID                          = 0x0840,
  /*! On/off sensor */
  ZLL_ON_OFF_SENSOR_DEVICE_ID                           = 0x0850,
} ZLL_DeviceId_t;

/*************************************************************************//**
  \brief ZCL event Ids
*****************************************************************************/
typedef enum
{
  ZCL_ATTRIBUTE_READ_EVENT_ID,      //!< attribute read event
  ZCL_ATTRIBUTE_WRITE_EVENT_ID,     //!< attribute written event
} ZCL_EventId_t;

/*************************************************************************//**
  \brief Reserved type to organize the queue of ZCL requests
*****************************************************************************/
typedef struct
{
  void    *next;
  uint8_t requestType;
} ZCL_Service_t;

/********************************************************************************//**
\brief Type describing address fields of some attributes in ZCL
***********************************************************************************/
typedef struct
{
  APS_AddrMode_t      addrMode;     //!< address mode indicates which address shall be used
  APS_Address_t       addr;         //!< address can be short, extended or group
  ProfileId_t         profileId;    //!< profile identifier
  Endpoint_t          endpointId;   //!< endpoint identifier
  ClusterId_t         clusterId;    //!< cluster identifier
  uint8_t             clusterSide;  //!< cluster side: server or client
  uint16_t            manufacturerSpecCode; //!< manufacturer specific code
} ZCL_Addressing_t;

/***************************************************************************//**
\brief Type describing ZCL Cluster options.
*******************************************************************************/
typedef struct
{
  uint8_t type        : 1;
  uint8_t security    : 1;
  uint8_t reserved    : 6;
} ZCL_ClusterOptions_t;

/***************************************************************************//**
\brief Type describing ZCL's events on cluster's attribute.
*******************************************************************************/
typedef enum
{
  ZCL_READ_ATTRIBUTE_EVENT,
  ZCL_WRITE_ATTRIBUTE_EVENT
} ZCL_AttributeEvent_t;

/***************************************************************************//**
\brief Type describing ZCL Cluster.
*******************************************************************************/
typedef struct
{
  ClusterId_t       id;                 //!< Cluster Id
  ZCL_ClusterOptions_t options;
  uint8_t           attributesAmount;   //!< Number of cluster attributes
  uint8_t           *attributes;        //!< Cluster attribute descriptors
  uint8_t           commandsAmount;     //!< Number of cluster-specific commands
  uint8_t           *commands;          //!< Cluster-specific command descriptors
  uint8_t           isReporting;        //!< Service field - if any automatic attribute reports are in progress
  void (*ZCL_ReportInd)(ZCL_Addressing_t *addressing, uint8_t reportLength, uint8_t *reportPayload); //!< Callback for reporting events
  void (*ZCL_AttributeEventInd)(ZCL_Addressing_t *addressing, ZCL_AttributeId_t attributeId, ZCL_AttributeEvent_t event); //!< Callback indicates action on cluster's attribute
} ZCL_Cluster_t;

/********************************************************************************//**
\brief Type describing information which is necessary for put/get element to/from payload
***********************************************************************************/
typedef struct
{
  uint8_t id; //!< element id. Can be either ::ZCL_GeneralCommandId_t value or special cluster command id
  uint8_t payloadLength; //!< payload length after adding a new element
  uint8_t *payload; //!< payload pointer where an element is added.
  void    *content; //!< pointer to content (memory) which shall be added/filled to/from payload
} ZCL_NextElement_t;

/********************************************************************************//**
\brief Type describing ZCL response
***********************************************************************************/
typedef struct
{
  ZCL_Status_t          status;          //!< status of command
  uint8_t               responseLength;  //!< length of response payload
  uint8_t              *responsePayload; //!< pointer to response payload. Response payload can be parsed by ZCL_GetNextElement() function
} ZCL_Response_t;

typedef struct
{
  // Service structure
  ZCL_Service_t       service;
  ZCL_Response_t      response;         //!< Response structure
  void (*ZCL_Response)(ZCL_Response_t *resp); //!< callback for response
  void (*ZCL_DefaultResponse)(ZCL_Response_t *resp); //!< callback for default response
  ZCL_Addressing_t    dstAddressing;    //!< addressing of destination node
  Endpoint_t          endpointId;       //!< endpoint id who is request initiator
  uint8_t             id;               //!< command id
  uint8_t             requestLength;    //!< request payload length
  uint8_t             defaultResponse;  //!< default response bit state
  uint8_t             *requestPayload;  //!< request payload. It can be filled by ZCL_PutNextElement() function.
} ZCL_Request_t;

BEGIN_PACK

/********************************************************************************//**
\brief Reporting record of an cluster attribute.
***********************************************************************************/
typedef struct PACK
{
  /*! The direction field specifies whether values of the attribute are be reported (0x00),
   * or whether reports of the attribute are to be received (0x01).*/
  uint8_t direction;
  /*! If the direction field is 0x00, this field contains the identifier of the attribute
   * that is to be reported. If instead the direction field is 0x01,
   * the device shall expect reports of values of this attribute.*/
  ZCL_AttributeId_t attributeId;
  union PACK
  {
    struct PACK
    {
      /*! The Attribute data type field contains the data type of the attribute
      * that is to be reported.*/
      uint8_t attributeType;
      /*! The minimum reporting interval field is 16-bits in length and shall contain
      * the minimum interval, in seconds, between issuing reports of the specified attribute.*/
      ZCL_ReportTime_t minReportInterval;
      /*! The maximum reporting interval field is 16-bits in length and
      * shall contain the maximum interval, in seconds, between issuing reports
      * of the specified attribute.*/
      ZCL_ReportTime_t maxReportInterval;
      /*! The reportable change field shall contain the minimum change to the attribute
      * that will result in a report being issued. This field is of variable length.
      * For attributes with 'analog' data type the field has the same data type
      * as the attribute.*/
      uint8_t reportableChange[1];
    };
    /*! The timeout period field is 16-bits in length and shall contain the maximum
      * expected time, in seconds, between received reports for the attribute specified
      * in the attribute identifier field. If more time than this elapses between reports,
      * this may be an indication that there is a problem with reporting.
      * If this value is set to 0x0000, reports of the attribute are not subject to timeout.*/
    ZCL_ReportTime_t timeoutPeriod;
  };
} ZCL_ReportRecord_t;

/********************************************************************************//**
\brief Type describing payload element of read request command.

This type can be used to add one attribute entry to the read request payload.
***********************************************************************************/
typedef struct PACK
{
  ZCL_AttributeId_t id; //!< requested attribute id
} ZCL_ReadAttributeReq_t;

/********************************************************************************//**
\brief Type describing payload element of response to read request command.

This type can be used to get one attribute entry from the read response payload.
***********************************************************************************/
typedef struct PACK
{
  ZCL_AttributeId_t id;       //!< requested attribute id
  uint8_t           status;   //!< status of reading attribute operation
  uint8_t           type;     //!< requested attribute type
  uint8_t           value[1]; //!< requested attribute value
} ZCL_ReadAttributeResp_t;

/********************************************************************************//**
\brief Type describing payload element of write request command.

This type can be used to add one attribute entry to the write request payload.
***********************************************************************************/
typedef struct PACK
{
  ZCL_AttributeId_t id;       //!< requested attribute id
  uint8_t           type;     //!< requested attribute type
  uint8_t           value[1]; //!< requested attribute value
} ZCL_WriteAttributeReq_t;

/********************************************************************************//**
\brief Type describing payload element of response to write request command.

This type can be used to get next writing status from the write response payload.
***********************************************************************************/
typedef struct PACK
{
  uint8_t           status; //!< status of writing attribute operation
  ZCL_AttributeId_t id;     //!< requested attribute id
} ZCL_WriteAttributeResp_t;

/********************************************************************************//**
\brief Type describing payload element of configure report request command.

This type can be used to add one reporting record to the "configure report" request payload.
***********************************************************************************/
typedef struct PACK
{
  ZCL_ReportRecord_t record; //!< Reporting record
} ZCL_ConfigureReportReq_t;

typedef struct PACK
{
  /*! TBD */
  uint8_t             direction;
  /*! TBD */
  uint16_t            attributeId;
  union PACK
  {
    struct PACK
    {
      /*! TBD */
      uint8_t         attributeType;
      /*! TBD */
      uint16_t        minReportingInterval;
      /*! TBD */
      uint16_t        maxReportingInterval;
      /*! TBD */
      uint8_t         reportableChange[1];
    };
    /*! TBD */
    uint16_t          timeoutPeriod;
  };
} ZCL_ConfigureReportingReq_t;


typedef struct PACK
{
  uint8_t   status;
  uint8_t   direction;
  uint16_t  attributeId;
} ZCL_ConfigureReportingResp_t;

/********************************************************************************//**
\brief Type describing payload element of response to configure report request command.

This type can be used to get next status entry from the "configure report" response payload.
***********************************************************************************/
typedef struct PACK
{
  uint8_t           status;    //!< status of the configure reporting operation
  uint8_t           direction; //!< The direction field specifies whether values of the attribute are be reported (0x00), or whether reports of the attribute are to be received (0x01).
  ZCL_AttributeId_t id;        //!< requested attribute identifier
} ZCL_ConfigureReportResp_t;

/********************************************************************************//**
\brief Type describing payload element of ZCL Read Reporting Configuration command.
***********************************************************************************/
typedef struct PACK
{
  uint8_t           direction;    //!< The direction field specifies whether values of the attribute are be reported (0x00), or whether reports of the attribute are to be received (0x01).
  uint16_t          attributeId;  //!< requested attribute identifier
} ZCL_ReadReportingConfigurationReq_t;

/********************************************************************************//**
\brief Type describing payload element of ZCL Read Reporting Configuration Response command.
***********************************************************************************/
typedef struct PACK
{
  /*! If the attribute is not implemented on the sender or receiver of the command,
   * whichever is relevant (depending on direction), this field shall be set
   * to UNSUPPORTED_ATTRIBUTE. If the attribute is supported, but is not capable of
   * being reported, this field shall be set to UNREPORTABLE_ATTRIBUTE.
   * Otherwise, this field shall be set to SUCCESS.*/
  uint8_t             status;
  /*! The direction field specifies whether values of the attribute are reported (0x00),
   * or whether reports of the attribute are received (0x01).*/
  uint8_t             direction;
  /*! TBD */
  uint16_t            attributeId;
  union PACK
  {
    struct PACK
    {
      /*! TBD */
      uint8_t         attributeType;
      /*! TBD */
      uint16_t        minReportingInterval;
      /*! TBD */
      uint16_t        maxReportingInterval;
      /*! TBD */
      uint8_t         reportableChange[1];
    };
    /*! TBD */
    uint16_t          timeoutPeriod;
  };
} ZCL_ReadReportingConfigurationResp_t;

/********************************************************************************//**
\brief Type describing payload element of report command.

This type can be used to get next reported attribute from the report payload.
***********************************************************************************/
typedef struct PACK
{
  ZCL_AttributeId_t id;       //!< requested attribute id
  uint8_t           type;     //!< requested attribute type
  uint8_t           value[1]; //!< requested attribute value
} ZCL_Report_t;

/********************************************************************************//**
\brief Type describing payload of ZCL Default Response Command.
***********************************************************************************/
typedef struct PACK
{
  /*!The command identifier field is 8-bit in length and specifies the identifier
  of the received command to which this command is a response.*/
  uint8_t           commandId;
  /*!The status code field is 8-bit in length and specifies either SUCCESS or
  the nature of the error that was detected in the receive command.*/
  uint8_t           statusCode;
} ZCL_DefaultResp_t;

/********************************************************************************//**
\brief Type describing payload of ZCL Discovery Attributes Command.
***********************************************************************************/
typedef struct PACK
{
  /*!The start attribute identifier field is 16-bit in length and specifies
  the value of the identifier at which to begin the attribute discovery.*/
  ZCL_AttributeId_t startAttributeId;
  /*!The maximum attribute identifiers field is 8-bit in length and specifies
  the maximum number of attribute identifiers that are to be returned in the
  resulting discovery attributes response command.*/
  uint8_t           maxAttributeIds;
} ZCL_DiscoverAttributesReq_t;

/********************************************************************************//**
\brief Type describing payload the Attribute Report field of ZCL Discovery
       Attributes Response Command.
***********************************************************************************/
typedef struct PACK
{
  ZCL_AttributeId_t attributeId;  //!<Attribute identifier
  uint8_t           typeId;       //!<Attribute data type Id
} ZCL_DiscoverAttributesRespRec_t;

/********************************************************************************//**
\brief Type describing payload of ZCL Discovery Attributes Response Command.
***********************************************************************************/
typedef struct PACK
{
  /*!The discovery complete field is a boolean field. A value of 0 indicates
  that there are more attributes to be discovered. A value of 1 indicates that
  there are no more attributes to be discovered.*/
  uint8_t                           discoveryComplete;
  /*!Discovered attribute information*/
  ZCL_DiscoverAttributesRespRec_t   attributeInfo[1];
} ZCL_DiscoverAttributesResp_t;

END_PACK

/*************************************************************************//**
  \brief Type describing attribute events notification
*****************************************************************************/
typedef struct
{
  ZCL_Addressing_t   addressing;        //!< source addressing, source endpoint, destination cluster
  uint8_t            attributeId;       //!< attribute id
} ZCL_AttributeEventNtfy_t;

/*************************************************************************//**
  \brief Type describing parameter of ZCL_EventNtfy() function
*****************************************************************************/
typedef struct
{
  ZCL_EventId_t       eventId;         //!< event Id (e.g. ZCL_ATTRIBUTE_READ_EVENT_ID)
  union
  {
    ZCL_AttributeEventNtfy_t   attribute;  //!< attribute event
  } eventType;
} ZCL_EventNtfy_t;

/********************************************************************************//**
\brief Type describing parameter of ZCL_RegisterEndpoint() function
***********************************************************************************/
typedef struct
{
  // Service structure
  struct
  {
    APS_RegisterEndpointReq_t apsEndpoint;
    uint8_t seqNum;
  } service;

  SimpleDescriptor_t    simpleDescriptor;   //!< Device endpoint Simple Descriptor
  ZCL_Cluster_t         *serverCluster;     //!< Device server clusters
  ZCL_Cluster_t         *clientCluster;     //!< Device client clusters
} ZCL_DeviceEndpoint_t;

/*************************************************************************//**
 \brief ZCL Data Type Descriptor.
        Describes the Data Type length in bytes and Data Type kind (Analog or Descrete).
*****************************************************************************/
typedef struct
{
  uint16_t   length;                     //!<Length in bytes
  /*!Kind of Data Type (Analog or Descrete). The #ZCL_DATA_TYPE_ANALOG_KIND or \n
  !#ZCL_DATA_TYPE_DESCRETE_KIND should be used).*/
  uint8_t   kind;
} ZCL_DataTypeDescriptor_t;

/******************************************************************************
                           Inline functions section
******************************************************************************/
/********************************************************************************//**
  \brief Gets Cluster Side the Incoming command is intended to.

  \param[in] direction - incoming command direction
  \return cluster side detected
***********************************************************************************/
INLINE uint8_t getDstClusterSideByIncommingCommandDirection(uint8_t direction)
{
  return direction;
}

/********************************************************************************//**
  \brief Gets source Cluster Side by destination Cluster side.

  \param[in] clusterSide - destination cluster's side
  \return cluster side detected
***********************************************************************************/
INLINE uint8_t getSrcClusterSideByDstClusterSide(uint8_t clusterSide)
{
  return !clusterSide;
}

/********************************************************************************//**
  \brief Gets destination Cluster Side by source Cluster side.

  \param[in] clusterSide - source cluster's side
  \return cluster side detected
***********************************************************************************/
INLINE uint8_t getDstClusterSideBySrcClusterSide(uint8_t clusterSide)
{
  return !clusterSide;
}

/********************************************************************************//**
  \brief Gets outgoing command direction by destination Cluster side.

  \param[in] clusterSide - destination cluster's side
  \return command direction detected
***********************************************************************************/
INLINE uint8_t getOutgoingCommandDirectionByDstClusterSide(uint8_t clusterSide)
{
  return clusterSide;
}

/********************************************************************************//**
  \brief Gets source Cluster side by direction of incoming command.

  \param[in] direction - incoming command direction.
  \return detected cluster side.
***********************************************************************************/
INLINE uint8_t getOwnClusterSideByIncomingCommandDirection(uint8_t direction)
{
  return direction;
}

/********************************************************************************//**
  \brief Gets destination Cluster side by direction of outgoing command.

  \param[in] direction - outgoing command direction.
  \return detected cluster side.
***********************************************************************************/
INLINE uint8_t getDstClusterSideByOutgoingCommandDirection(uint8_t direction)
{
  return direction;
}

/******************************************************************************
                           Functions prototypes section
******************************************************************************/
/*********************************************************************************//**
\brief Register device endpoint.

This function registers a device endpoint to make ZCL know which devices types
are used in applications and which clusters they support.

\param[in] endpoint - contains device descriptor
************************************************************************************/
void ZCL_RegisterEndpoint(ZCL_DeviceEndpoint_t *endpoint);

/*************************************************************************//**
 \brief This function resets ZCL component.

 \param[in] none
*****************************************************************************/
void ZCL_ResetReq(void);

/*************************************************************************//**
 \brief Finds attribute in ZCL and returns attribute value

 \param[in] endpointId - endpoint on which cluster is registered
 \param[in] clusterId - cluster unique identifier
 \param[in] direction - detects the cluster's side (client or server)
 \param[in] attrId - attribute unique identifier
 \param[out] attrType - pointer to attribute type determined and returned
 \param[out] attrValue - read out attribute value pointer

 \return status of operation
*****************************************************************************/
ZCL_Status_t ZCL_ReadAttributeValue(Endpoint_t endpointId, ClusterId_t clusterId, uint8_t direction,
                                    ZCL_AttributeId_t attrId, uint8_t *attrType, uint8_t *attrValue);

/*************************************************************************//**
 \brief Finds attribute in ZCL and rewrites its value by the new one
 (to be used with local write request).

 \param[in] endpointId - endpoint on which cluster is registered
 \param[in] clusterId - cluster unique identifier
 \param[in] direction - detects the cluster's side (client or server)
 \param[in] attrId - attribute unique identifier
 \param[in] attrType - type of the attribute to be set
 \param[in] attrValue - pointer to attribute value to be set

 \return status of operation
*****************************************************************************/
ZCL_Status_t ZCL_WriteAttributeValue(Endpoint_t endpointId, ClusterId_t clusterId, uint8_t direction,
                                     ZCL_AttributeId_t attrId, uint8_t attrType, uint8_t *attrValue);

/*************************************************************************//**
 \brief Finds attribute in ZCL and rewrites its value by the new one
 (to be used with remote write request).

 \param[in] endpointId - endpoint on which cluster is registered
 \param[in] clusterId - cluster unique identifier
 \param[in] direction - detects the cluster's side (client or server)
 \param[in] attrId - attribute unique identifier
 \param[in] attrType - type of the attribute to be set
 \param[in] attrValue - pointer to attribute value to be set

 \return status of operation
*****************************************************************************/
ZCL_Status_t zclRemoteWriteAttributeValue(Endpoint_t endpointId, ClusterId_t clusterId, uint8_t direction,
                                          ZCL_AttributeId_t attrId, uint8_t attrType, uint8_t *attrValue);

/*************************************************************************//**
 \brief Sends a general ZCL command related to attributes to a remote device
 
 The function is used to read/write attributes from a remote device, to report
 local attributes, and to discover attributes supported by a particular cluster
 on a remote device.
 
 Command's parameters include addressing information, calback functions, command's
 ID, and the payload. The payload may be formed via the ZCL_PutNextElement() function 
 and an instance of ZCL_NextElement_t type. The command may be used to perform 
 actions on multiple attributes at a time; for example, to read several attributes
 from a remote device.
 
 Attribute related commands are usually send to specific short or extended addresses.
 Sending such commands to bound devices (employing ::APS_NO_ADDRESS mode) may not
 be as efficient, because in case of responses from more than one device the ZCL 
 component will process only the first one.
 
 Upon receiving the response from the remote device, the callback function specified
 in the \c req->ZCL_Response field is called.

 Common uses of the function include sending the following commands (the command's
 ID listed below should be assigned to the \c req->id field):
 \li ::ZCL_READ_ATTRIBUTES_COMMAND_ID - reading remote attributes (obtaining values)
 \li ::ZCL_WRITE_ATTRIBUTES_COMMAND_ID - writing remote attributes (assigning new values)
 \li ::ZCL_REPORT_ATTRIBUTES_COMMAND_ID - reporting local attributes to remote devices 
     (sending current attributes' values)
 \li ::ZCL_DISCOVER_ATTRIBUTES_COMMAND_ID - discovering attributes of a remote device (obtaining 
     data types and IDs of attributes supported by a particular cluster)
  
 \param[in] req - command parameters
*****************************************************************************/
void ZCL_AttributeReq(ZCL_Request_t *req);

/*********************************************************************************//**
 \brief Sends a cluster command

 The function sends a general cluster specific command. The command's type is
 recognized according to the \c req->id field. Commands' IDs are defined in clusters'
 definition files, which also contain all definition related to a particular cluster.
 
 In addition to addressing information and command's ID, eesential fields of
 the request parameters include the payload and the payload length. The payload 
 for each command is defined as a structure in the cluster's definition file.
 The pointer to a properly configured instance of the command's payload shall be \
 assigned to the \c req->requestPayload field.

 The callback function specified in the \c req->ZCL_Response field is called to
 indicate the status of the command's delivery (not a specific response for the
 command). If acknowledgment of the command's delivery is received the success
 status is reported in the callback.
 
 A specific response to the command is processed by a special indication function
 registered for the command. If a command does not imply a specific response
 the default response may be requested (to indicate that the command has been 
 executed). To request the default response set the \c req->defaultResponse field
 to ::ZCL_FRAME_CONTROL_ENABLE_DEFAULT_RESPONSE and assign the callback function
 that should be called upon default response reception to the \c req->ZCL_DefaultResponse
 field. To disable default response set \c req->defaultResponse to 
 ::ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE and \c req->ZCL_DefaultResponse to \c NULL.
 
 \param[in] req - contains request descriptor
************************************************************************************/
void ZCL_CommandReq(ZCL_Request_t *req);

/*********************************************************************************//**
\brief Specific command indication handler

\param[in] ind - contains indication descriptor
************************************************************************************/
//void ZCL_CommandInd(ZCL_CommandInd_t *ind);

/*************************************************************************//**
 \brief ZCL event notification handler

 \param[in] event - contains event descriptor
*****************************************************************************/
void ZCL_EventNtfy(ZCL_EventNtfy_t *event);

/*************************************************************************//**
 \brief This function returns bytes amount of a type by type id.

 \param[in] typeId - type id
 \param[in] value - pointer to variable of typeId, NULL means maximum possible
            size.
*****************************************************************************/
uint16_t ZCL_GetAttributeLength(uint8_t typeId, const uint8_t *value);

/*************************************************************************//**
 \brief Adds an element to the outgoing command payload

 This function is used to simplify forming a correst payload for general
 commands (read/write attributes etc.). A single command may involve actions on 
 several attributes, and so the overall payload should contain pieces 
 corresponding to each attribute.
 
 The general idea is to provide a buffer for the payload and some content. The
 function writes the content in a correct way to the buffer and calculate the
 overall payload length. The buffer and the payload length are then passed as
 parameters to the ZCL_AttributeReq() function.

 See the following example:
 
\code
ZCL_NextElement_t element;
ZCL_ReadAttributeReq_t readAttrReqElement;
ZCL_Request_t readAttrReq;
uint8_t buffer[BUFFER_SIZE];

element.payloadLength = 0;
element.payload = buffer;
element.id = ZCL_READ_ATTRIBUTES_COMMAND_ID;
element.content = &readAttrReqElement;

readAttrReqElement = ATTRIBUTE_ID1; //Set to the ID of the first attribute
ZCL_PutNextElement(&element);

readAttrReqElement = ATTRIBUTE_ID2; //Set to the ID of the second attribute
ZCL_PutNextElement(&element);

readAttrReq.requestLength = element.payloadLength;
readAttrReq.requestPayload = element.payload;
...
\endcode
 
 Note, however, that the usage may differ depending on a command's type.
 
 \param[in] element - information about payload and element
 \param[out] status of the operation
*****************************************************************************/
ZCL_Status_t ZCL_PutNextElement(ZCL_NextElement_t *element);

/*************************************************************************//**
 \brief Gets an element from the incoming command's payload

 The function is used to simplify processing of responses fo general
 attributes related commands. Such command may return information concerning
 several attributes in a single frame. This function reads the next portion
 of information from the response payload.
 
 To use the function configure an instance of ZCL_NextElement type.
 The \c element->payload field should be set to the response payload,
 the \c element->payloadLength to the reponse payload's length, and
 the \c element->id field to the ID of the response. After calling this
 function, the \c element->content field may be casted to the appropriate
 response type (depending on the command's type); for example, for
 read attributes response it is ZCL_ReadAttributeResp_t.
 
 \param[in] element - information about payload and element
 \param[out] status of the operation
*****************************************************************************/
ZCL_Status_t ZCL_GetNextElement(ZCL_NextElement_t *element);

/***************************************************************************//**
\brief Checks whether ZCL is busy or not.

\return true - if ZCL is busy, false - otherwise.
******************************************************************************/
bool ZCL_IsBusy(void);

/*************************************************************************//**
  \brief  ZCL Data Type Descriptor get by Type Id function.
          Fills the ZCL Data Type Descriptor dased on ZCL Data Type Id
  \param  Id - ZCL Data Type Id (unsigned 8-bit integer)
  \param  value - pointer to variable of typeId, NULL means maximum possible
          size.
  \param  descriptor - ZCL Data Type Descriptor being filled.
  \return None.
  \sa     ZCL_DataTypeDescriptor_t
  \sa     ZCL_GetAttributeLength()
*****************************************************************************/
void ZCL_GetDataTypeDescriptor(uint8_t typeId, const uint8_t *value, ZCL_DataTypeDescriptor_t *descriptor);

#endif //_ZCL_H