Welcome to mirror list, hosted at ThFree Co, Russian Federation.

zigbee.zdo.h « include « stack « zigbee « STM32_WPAN « ST « Middlewares - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6bd0e95657a4d4bbc26898970dc57980254fffcd (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
/**
 * @file zigbee.zdo.h
 * @brief Zigbee ZDO header file
 * @author Exegin Technologies Limited
 * @copyright Copyright [2009 - 2021] Exegin Technologies Limited. All rights reserved.
 *
 * This file provides the declaration of all the public API's and macros used by the ZDO layer.
 */

#ifndef ZIGBEE_ZDO_H
# define ZIGBEE_ZDO_H

struct ZbZdoFilterT;

/*---------------------------------------------------------------
 * Misc. Definitions and Structures
 *---------------------------------------------------------------
 */
/* Profile, and Device Identifiers for the ZDO. */
#define ZB_ZDO_PROFILE_ID                           0x0000U
#define ZB_ZDO_DEVICE_ID                            0x0000U
#define ZB_ZDO_DEVICE_VER                           0x00U

#define ZB_ZDO_ADDRRSP_DEVLIST_MAX                  32U

/** NWK_addr_req / IEEE_addr_req definitions */
enum ZbZdoAddrReqTypeT {
    ZB_ZDO_ADDR_REQ_TYPE_SINGLE = 0x00, /**< Single address request - Returns the information requested only */
    ZB_ZDO_ADDR_REQ_TYPE_EXTENDED = 0x01 /**< Extended address request - Returns the information requested and appends the devices in its network table */
};

/* NWK_Update_Req special duration values. */
#define ZB_ZDP_NWK_UPDATE_MAX_DURATION              0x05U
#define ZB_ZDP_NWK_UPDATE_CHANNEL_SWITCH            0xfeU
#define ZB_ZDP_NWK_UPDATE_MANAGER_PARAMETERS        0xffU

/* Maximum Response Sizes */
/* NOTE was 64, but end up allocating too much on the stack */
#define ZB_ZDO_CLUSTER_LIST_MAX_SZ                  16U
#define ZB_ZDO_NETWORK_LIST_MAX_SZ                  8U
#define ZB_ZDO_NEIGHBOR_LIST_MAX_SZ                 4U
#define ZB_ZDO_ROUTE_LIST_MAX_SZ                    16U
/* Each entry in the ZDO message is either 14 or 21 bytes long.
 * It's only possible to return up to 4 entries at a time. */
#define ZB_ZDO_BIND_LIST_MAX_SZ                     4U
#define ZB_ZDO_ENDPOINT_LIST_MAXSZ                  32U
#define ZB_ZDO_CHANNEL_LIST_MAXSZ                   (8U * sizeof(uint32_t))
#define ZB_ZDO_CHILD_LIST_MAXSZ                     8U

/* Node Descriptor Definitions. */
#define ZB_ZDP_NODE_TYPE_COORDINATOR                (uint8_t)0x00U
#define ZB_ZDP_NODE_TYPE_ROUTER                     (uint8_t)0x01U
#define ZB_ZDP_NODE_TYPE_END_DEVICE                 (uint8_t)0x02U
#define ZB_ZDP_NODE_FREQ_868MHz                     (uint8_t)0x01U
#define ZB_ZDP_NODE_FREQ_900MHz                     (uint8_t)0x04U
#define ZB_ZDP_NODE_FREQ_2400MHz                    (uint8_t)0x08U
#define ZB_ZDP_NODE_CAPABILITY_EXT_EPLIST           (uint8_t)0x01U
#define ZB_ZDP_NODE_CAPABILITY_EXT_SIMPLE           (uint8_t)0x02U

/* Server Mask Bits. */
#define ZB_ZDP_SERVER_PRIMARY_TRUST                 (uint16_t)0x0001U
#define ZB_ZDP_SERVER_BACKUP_TRUST                  (uint16_t)0x0002U
#define ZB_ZDP_SERVER_PRIMARY_BIND_CACHE            (uint16_t)0x0004U
#define ZB_ZDP_SERVER_BACKUP_BIND_CACHE             (uint16_t)0x0008U
#define ZB_ZDP_SERVER_PRIMARY_DISC_CACHE            (uint16_t)0x0010U
#define ZB_ZDP_SERVER_BACKUP_DISC_CACHE             (uint16_t)0x0020U
#define ZB_ZDP_SERVER_NETWORK_MGR                   (uint16_t)0x0040U
#define ZB_ZDP_SERVER_RESERVED_MASK                 (uint16_t)0x0180U /* Reserved bits */
#define ZB_ZDP_SERVER_REVISION_SHIFT                9U
#define ZB_ZDP_SERVER_REVISION_MASK                 (uint16_t)0xFE00U /* (0x007f << ZB_ZDP_SERVER_REVISION_SHIFT) */

/* Power Descriptor Definitions. */
#define ZB_ZDP_POWER_MODE_ON                        (uint8_t)0x00U
#define ZB_ZDP_POWER_MODE_PERIODIC                  (uint8_t)0x01U
#define ZB_ZDP_POWER_MODE_REQUEST                   (uint8_t)0x02U
#define ZB_ZDP_POWER_SOURCE_CONSTANT                (uint8_t)0x01U
#define ZB_ZDP_POWER_SOURCE_RECHARGEABLE            (uint8_t)0x02U
#define ZB_ZDP_POWER_SOURCE_DISPOSEABLE             (uint8_t)0x04U
#define ZB_ZDP_POWER_LEVEL_CRITICAL                 (uint8_t)0x00U
#define ZB_ZDP_POWER_LEVEL_33                       (uint8_t)0x04U
#define ZB_ZDP_POWER_LEVEL_66                       (uint8_t)0x08U
#define ZB_ZDP_POWER_LEVEL_100                      (uint8_t)0x0cU

/* struct ZbNodeDescriptorT Mask Flag - Section 2.3.2.3  */
#define ZB_ZDP_NODE_OPT_MASK_TYPE                   (uint16_t)0x0007U
#define ZB_ZDP_NODE_OPT_MASK_COMPLEX                (uint16_t)0x0008U
#define ZB_ZDP_NODE_OPT_MASK_USER                   (uint16_t)0x0010U
#define ZB_ZDP_NODE_OPT_MASK_APSFLAG                (uint16_t)0x0700U
#define ZB_ZDP_NODE_OPT_MASK_FREQBAND               (uint16_t)0xf800U
#define ZB_ZDP_NODE_OPT_MASK_RESERVED               (uint16_t)0x00e0U

#define ZB_ZDP_NODE_OPT_OFFSET_TYPE                 0U
#define ZB_ZDP_NODE_OPT_OFFSET_COMPLEX              3U
#define ZB_ZDP_NODE_OPT_OFFSET_USER                 4U
#define ZB_ZDP_NODE_OPT_OFFSET_APSFLAG              8U
#define ZB_ZDP_NODE_OPT_OFFSET_FREQBAND             11U

/* Node Descriptor Definitions */
#define ZB_ZDP_NODE_OPT_TYPE_COORDINATOR            0x00U
#define ZB_ZDP_NODE_OPT_TYPE_ROUTER                 0x01U
#define ZB_ZDP_NODE_OPT_TYPE_END_DEVICE             0x02U
#define ZB_ZDP_NODE_OPT_TYPE(_nodetype_)            (_nodetype_)

#define ZB_ZDP_NODE_OPT_FREQBAND_868MHZ_BPSK        0x01U
#define ZB_ZDP_NODE_OPT_FREQBAND_915MHZ_BPSK        0x04U
#define ZB_ZDP_NODE_OPT_FREQBAND_2400MHZ            0x08U
#define ZB_ZDP_NODE_OPT_FREQBAND_EU_FSK_SUBGHZ      0x10U /* 868 MHz and 915 MHz */
#define ZB_ZDP_NODE_OPT_BAND(_freqband_)            (((uint16_t)_freqband_) << ZB_ZDP_NODE_OPT_OFFSET_FREQBAND)

/* struct ZbPowerDescriptorT Mask Flag - Section 2.3.2.4 */
#define ZB_ZDP_POWER_MASK_MODE                      0x000fU
#define ZB_ZDP_POWER_MASK_AVAILABLE                 0x00f0U
#define ZB_ZDP_POWER_MASK_SOURCE                    0x0f00U
#define ZB_ZDP_POWER_MASK_LEVEL                     0xf000U

#define ZB_ZDP_POWER_OFFSET_MODE                    0U
#define ZB_ZDP_POWER_OFFSET_AVAILABLE               4U
#define ZB_ZDP_POWER_OFFSET_SOURCE                  8U
#define ZB_ZDP_POWER_OFFSET_LEVEL                   12U

/* Complex descriptor tag values. */
#define ZB_ZDP_COMPLEX_TAG_LANGUAGE                 0x01U
#define ZB_ZDP_COMPLEX_TAG_MANUFACTURFER            0x02U
#define ZB_ZDP_COMPLEX_TAG_MODEL                    0x03U
#define ZB_ZDP_COMPLEX_TAG_SERIAL                   0x04U
#define ZB_ZDP_COMPLEX_TAG_DEVICE_URL               0x05U
#define ZB_ZDP_COMPLEX_TAG_ICON                     0x06U
#define ZB_ZDP_COMPLEX_TAG_ICON_URL                 0x07U

/* Network Descriptor Flags. */
#define ZB_ZDP_NETWORK_MASK_PROFILE                 0x0fU
#define ZB_ZDP_NETWORK_MASK_VERSION                 0xf0U
#define ZB_ZDP_NETWORK_MASK_BEACON                  0x0fU
#define ZB_ZDP_NETWORK_MASK_SUPERFRAME              0xf0U
#define ZB_ZDP_NETWORK_MASK_PERMIT_JOIN             0x01U

#define ZB_ZDP_NETWORK_OFFSET_PROFILE               0U
#define ZB_ZDP_NETWORK_OFFSET_VERSION               4U
#define ZB_ZDP_NETWORK_OFFSET_BEACON                0U
#define ZB_ZDP_NETWORK_OFFSET_SUPERFRAME            4U
#define ZB_ZDP_NETWORK_OFFSET_PERMIT_JOIN           0U

/* Neighbor Descriptor Flags */
#define ZB_ZDP_NEIGHBOR_MASK_TYPE                   0x03U
#define ZB_ZDP_NEIGHBOR_MASK_RX_ON_IDLE             0x0cU
#define ZB_ZDP_NEIGHBOR_MASK_RELATIONSHIP           0x70U
#define ZB_ZDP_NEIGHBOR_MASK_PERMIT_JOIN            0x03U

#define ZB_ZDP_NEIGHBOR_OFFSET_TYPE                 0U
#define ZB_ZDP_NEIGHBOR_OFFSET_RX_ON_IDLE           2U
#define ZB_ZDP_NEIGHBOR_OFFSET_RELATIONSHIP         4U
#define ZB_ZDP_NEIGHBOR_OFFSET_PERMIT_JOIN          0U

/* Neighbor Descriptor Definitions */
#define ZB_ZDP_NEIGHBOR_TYPE_COORDINATOR            0x00U
#define ZB_ZDP_NEIGHBOR_TYPE_ROUTER                 0x01U
#define ZB_ZDP_NEIGHBOR_TYPE_END_DEVICE             0x02U
#define ZB_ZDP_NEIGHBOR_RELATIONSHIP_PARENT         0x00U /* ZB_NWK_NEIGHBOR_REL_PARENT */
#define ZB_ZDP_NEIGHBOR_RELATIONSHIP_CHILD          0x01U /* ZB_NWK_NEIGHBOR_REL_CHILD */
#define ZB_ZDP_NEIGHBOR_RELATIONSHIP_SIBLING        0x02U /* ZB_NWK_NEIGHBOR_REL_SIBLING */
#define ZB_ZDP_NEIGHBOR_RELATIONSHIP_NONE           0x03U /* ZB_NWK_NEIGHBOR_REL_NONE */
#define ZD_ZDP_NEIGHBOR_RELATIONSHIP_PREVIOUS       0x04U /* ZB_NWK_NEIGHBOR_REL_PREV_CHILD */
#define ZB_ZDP_NEIGHBOR_PERMIT_JOIN_DISABLED        0x00U
#define ZB_ZDP_NEIGHBOR_PERMIT_JOIN_ENABLED         0x01U
#define ZB_ZDP_NEIGHBOR_PERMIT_JOIN_UNKNOWN         0x02U

/* Routing Descriptor Flags */
#define ZB_ZDP_ROUTE_MASK_STATUS                    0x07U
#define ZB_ZDP_ROUTE_MASK_CONSTRAINED               0x08U
#define ZB_ZDP_ROUTE_MASK_MANY_TO_ONE               0x10U
#define ZB_ZDP_ROUTE_MASK_RECORD_REQUIRED           0x20U

#define ZB_ZDP_ROUTE_OFFSET_STATUS                  0U
#define ZB_ZDP_ROUTE_OFFSET_CONSTRAINED             3U
#define ZB_ZDP_ROUTE_OFFSET_MANY_TO_ONE             4U
#define ZB_ZDP_ROUTE_OFFSET_RECORD_REQUIRED         5U

/* Complex Descriptor */
#define ZB_ZDP_COMPLEX_DESC_MAX_DESC_LEN            256U

/* User Descriptor */
#define ZB_ZDP_USER_DESC_MAX_DESC_LEN               0x10U

/*
 * ZigBee Device Object cluster definitions.
 */
/* This bit in the cluster ID denotes a response or request. */
#define ZB_ZDO_CLUSTER_RESPONSE_BIT                 0x8000U

/* ZDP Request IDs (Responses are the same, but with ZB_ZDO_CLUSTER_RESPONSE_BIT set) */
#define ZB_ZDO_NWK_ADDR_REQ                         0x0000U
#define ZB_ZDO_IEEE_ADDR_REQ                        0x0001U
#define ZB_ZDO_NODE_DESC_REQ                        0x0002U
#define ZB_ZDO_POWER_DESC_REQ                       0x0003U
#define ZB_ZDO_SIMPLE_DESC_REQ                      0x0004U
#define ZB_ZDO_ACTIVE_EP_REQ                        0x0005U
#define ZB_ZDO_MATCH_DESC_REQ                       0x0006U
#define ZB_ZDO_COMPLEX_DESC_REQ                     0x0010U
#define ZB_ZDO_USER_DESC_REQ                        0x0011U
#define ZB_ZDO_DISCOVERY_CACHE_REQ                  0x0012U
#define ZB_ZDO_DEVICE_ANNCE                         0x0013U
#define ZB_ZDO_USER_DESC_SET                        0x0014U
#define ZB_ZDO_SYSTEM_SERVER_DISC_REQ               0x0015U
#define ZB_ZDO_DISCOVERY_STORE_REQ                  0x0016U
#define ZB_ZDO_NODE_DESC_STORE_REQ                  0x0017U
#define ZB_ZDO_POWER_DESC_STORE_REQ                 0x0018U
#define ZB_ZDO_ACTIVE_EP_STORE_REQ                  0x0019U
#define ZB_ZDO_SIMPLE_DESC_STORE_REQ                0x001aU
#define ZB_ZDO_REMOVE_NODE_CACHE_REQ                0x001bU
#define ZB_ZDO_FIND_NODE_CACHE_REQ                  0x001cU
#define ZB_ZDO_EXT_SIMPLE_DESC_REQ                  0x001dU
#define ZB_ZDO_EXT_ACTIVE_EP_REQ                    0x001eU
#define ZB_ZDO_PARENT_ANNCE                         0x001fU
#define ZB_ZDO_END_DEVICE_BIND_REQ                  0x0020U
#define ZB_ZDO_BIND_REQ                             0x0021U
#define ZB_ZDO_UNBIND_REQ                           0x0022U
/* ZB_ZDO_MGMT_NWK_DISC_REQ depreciated             0x0030U */
#define ZB_ZDO_MGMT_LQI_REQ                         0x0031U
#define ZB_ZDO_MGMT_RTG_REQ                         0x0032U
#define ZB_ZDO_MGMT_BIND_REQ                        0x0033U
#define ZB_ZDO_MGMT_LEAVE_REQ                       0x0034U
#define ZB_ZDO_MGMT_DIRECT_JOIN_REQ                 0x0035U
#define ZB_ZDO_MGMT_PERMIT_JOINING_REQ              0x0036U
#define ZB_ZDO_MGMT_CACHE_REQ                       0x0037U
#define ZB_ZDO_MGMT_NWK_UPDATE_REQ                  0x0038U
#define ZB_ZDO_MGMT_NWK_ENHANCED_UPDATE_REQ         0x0039U
#define ZB_ZDO_MGMT_IEEE_JOINING_LIST_REQ           0x003aU
#define ZB_ZDO_MGMT_UNSOLICITED_UPDATE_NOTIFY       0x003bU

/** ZigBee Node Descriptor */
struct ZbNodeDescriptorT {
    uint8_t logicalType; /**< Logical type */
    uint8_t complexDesc;
    uint8_t userDesc;
    uint8_t apsFlags; /**< APS flags */
    uint8_t freqBands; /**< Frequency band */
    uint8_t macCapability; /**< MAC capability flags */
    uint16_t mfrCode; /**< Manufacturer code */
    uint8_t maxBuffer; /**< Maximum buffer size */
    uint16_t maxIncomingTransfer; /**< Maximum incoming transfer size */
    uint16_t serverMask; /**< Server mask */
    uint16_t maxOutgoingTransfer; /**< Maximum outgoing transfer size */
    uint8_t descCapability; /**< Descriptor capability field */
};

/** ZigBee Power Descriptor */
struct ZbPowerDescriptorT {
    uint8_t currentMode; /**< Current power mode */
    uint8_t availableSources; /**< Available power sources */
    uint8_t currentSource; /**< Current power source */
    uint8_t currentLevel; /**< Current power source level */
};

/** ZigBee Simple (Application) Descriptor. */
struct ZbSimpleDescriptorT {
    uint8_t endpoint; /**< Endpoint */
    uint16_t profileId; /**< Application profile identifier */
    uint16_t deviceId; /**< Application device identifier */
    uint8_t version; /**< Application device version */
    uint8_t inputClusterCount; /**< Application input cluster count */
    uint16_t inputClusterList[ZB_ZDO_CLUSTER_LIST_MAX_SZ]; /**< Application input cluster list */
    uint8_t outputClusterCount; /**< Application output cluster count */
    uint16_t outputClusterList[ZB_ZDO_CLUSTER_LIST_MAX_SZ]; /**< Application output cluster list */
};

/** Network Descriptor */
struct ZbZdoNetworkDescT {
    uint64_t epid; /**< ExtendedPANId */
    uint8_t logicalChannel; /**< LogicalChannel */
    uint8_t version; /**< ZigBeeVersion */
    uint8_t stackProfile; /**< StackProfile */
    uint8_t superframeOrder; /**< SuperframeOrder */
    uint8_t beaconOrder; /**< BeaconOrder */
    uint8_t permitJoin; /**< PermitJoining */
};

/** Neighbor Descriptor */
struct ZbZdoNeighborDescT {
    uint64_t epid; /**< Extended PAN ID */
    uint64_t extAddr; /**< Extended address */
    uint16_t nwkAddr; /**< Network address */
    uint8_t deviceType; /**< Device type */
    uint8_t rxOnWhenIdle; /**< RxOnWhenIdle */
    uint8_t relationship; /**< Relationship */
    uint8_t permitJoin; /**< Permit joining */
    uint8_t depth; /**< Depth */
    uint8_t lqi; /**< LQI */
};

/** Routing Descriptor */
struct ZbZdoRoutingDescT {
    uint16_t destAddr; /**< Destination address */
    uint8_t status; /**< Status */ /* EXEGIN - convert to an enum type? */
    uint8_t constrained; /**< Memory Constrained */
    uint8_t manyToOne; /**< Many-to-one */
    uint8_t recordRequired; /**< Route record required */
    uint16_t nextHopAddr; /**< Next-hop address */
};

/** Binding Descriptor */
struct ZbZdoBindingDescT {
    uint64_t srcAddr; /**< SrcAddr */
    uint8_t srcEndpt; /**< SrcEndpoint */
    uint16_t clusterId; /**< ClusterId */
    /* dst.panId not used, dst.nwkAddr is only for the group address,
     * and dst.endpoint only used if mode == ZB_APSDE_ADDRMODE_EXT */
    struct ZbApsAddrT dst; /**< DstAddr */
};

/*---------------------------------------------------------------
 * ZDP Discovery Requests
 *---------------------------------------------------------------
 */
/** NWK_addr_req */
struct ZbZdoNwkAddrReqT {
    uint16_t dstNwkAddr; /**<  Destination network address, not in spec */ /* typically set to ZB_NWK_ADDR_BCAST_RXON (0xfffd) */
    uint64_t extAddr; /**< IEEEAddr */
    enum ZbZdoAddrReqTypeT reqType; /**< RequestType */
    uint8_t startIndex; /**< StartIndex */
};

/** NWK_addr_rsp */
struct ZbZdoNwkAddrRspT {
    enum ZbStatusCodeT status; /**< Status */
    uint64_t extAddr; /**< IEEEAddrRemoteDev */
    uint16_t nwkAddr; /**< NWKAddrRemoteDev */
    uint8_t deviceCount; /**< NumAssocDev */
    uint8_t startIndex; /**< StartIndex */
    uint16_t deviceList[ZB_ZDO_ADDRRSP_DEVLIST_MAX]; /**< NWKAddrAssocDevList */
};

/** IEEE_addr_req */
struct ZbZdoIeeeAddrReqT {
    uint16_t dstNwkAddr; /**< Destination network address */
    uint16_t nwkAddrOfInterest; /**< NWKAddrOfInterest */
    enum ZbZdoAddrReqTypeT reqType; /**< RequestType */
    uint8_t startIndex; /**< StartIndex */
};

/** IEEE_addr_rsp */
struct ZbZdoIeeeAddrRspT {
    enum ZbStatusCodeT status; /**< Status */
    uint64_t extAddr; /**< IEEEAddrRemoteDev */
    uint16_t nwkAddr; /**< NWKAddrRemoteDev */
    uint8_t deviceCount; /**< NumAssocDev */
    uint8_t startIndex; /**< StartIndex */
    uint16_t deviceList[ZB_ZDO_ADDRRSP_DEVLIST_MAX]; /**< NWKAddrAssocDevList */
};

/** Node_Desc_req */
struct ZbZdoNodeDescReqT {
    uint16_t dstNwkAddr; /**< Destination network address */
    uint16_t nwkAddrOfInterest; /**< NWKAddrOfInterest */
};

/** Node_Desc_rsp */
struct ZbZdoNodeDescRspT {
    enum ZbStatusCodeT status; /**< Status */
    uint16_t nwkAddr; /**< NWKAddrOfInterest */
    struct ZbNodeDescriptorT nodeDesc; /**< NodeDescriptor */
};

/** Power_Desc_req */
struct ZbZdoPowerDescReqT {
    uint16_t dstNwkAddr; /**< Destination network address */
    uint16_t nwkAddrOfInterest; /**< NWKAddrOfInterest */
};

/** Power_Desc_rsp */
struct ZbZdoPowerDescRspT {
    enum ZbStatusCodeT status; /**< Status */
    uint16_t nwkAddr; /**< NWKAddrOfInterest */
    struct ZbPowerDescriptorT powerDesc; /**< PowerDescriptor */
};

/** Simple_Desc_req */
struct ZbZdoSimpleDescReqT {
    uint16_t dstNwkAddr; /**< Destination network address */
    uint16_t nwkAddrOfInterest; /**< NWKAddrOfInterest */
    uint8_t endpt; /**< Endpoint */
};

/** Simple_Desc_rsp */
struct ZbZdoSimpleDescRspT {
    enum ZbStatusCodeT status; /**< Status */
    uint16_t nwkAddr; /**< NWKAddrOfInterest */
    struct ZbSimpleDescriptorT simpleDesc; /**< SimpleDescriptor */
};

/* Discovery_Cache_rsp */
typedef struct ZbZdoDiscCacheRspT {
    enum ZbStatusCodeT status;
    /* Added by Exegin */
    uint16_t nwkAddr;
} ZbZdoDiscCacheRspT;

/** Active_EP_req */
struct ZbZdoActiveEpReqT {
    uint16_t dstNwkAddr; /**< Destination network address */
    uint16_t nwkAddrOfInterest; /**< NWKAddrOfInterest */
};

/** Active_EP_rsp */
struct ZbZdoActiveEpRspT {
    enum ZbStatusCodeT status; /**< Status */
    uint16_t nwkAddr; /**< NWKAddrOfInterest */
    uint8_t activeEpCount; /**< ActiveEPCount */
    uint8_t activeEpList[ZB_ZDO_ENDPOINT_LIST_MAXSZ]; /**< ActiveEPList */
};

/** Match_Desc_req */
struct ZbZdoMatchDescReqT {
    uint16_t dstNwkAddr; /**< Destination network address */
    uint16_t nwkAddrOfInterest; /**< NWKAddrOfInterest */
    uint16_t profileId; /**< ProfileID */
    uint8_t numInClusters; /**< NumInClusters */
    uint16_t inClusterList[ZB_ZDO_CLUSTER_LIST_MAX_SZ]; /**< InClusterList */
    uint8_t numOutClusters; /**< NumOutClusters */
    uint16_t outClusterList[ZB_ZDO_CLUSTER_LIST_MAX_SZ]; /**< OutClusterList */
};

/** Match_Desc_rsp */
struct ZbZdoMatchDescRspT {
    enum ZbStatusCodeT status; /**< Status */
    uint16_t nwkAddr; /**< NWKAddrOfInterest */
    uint8_t matchLength; /**< MatchLength */
    uint8_t matchList[ZB_ZDO_ENDPOINT_LIST_MAXSZ]; /**< MatchList */
};

/** Device_annce (ZB_ZDO_DEVICE_ANNCE) */
struct ZbZdoDeviceAnnceT {
    uint16_t nwkAddr; /**< NWKAddr */
    uint64_t extAddr; /**< IEEEAddr */
    uint8_t capability; /**< Capability */
};

/** Bind_req */
struct ZbZdoBindReqT {
    uint16_t target; /**< Destination for the ZDO Bind Request message */
    /* Binding Source */
    uint64_t srcExtAddr; /**< SrcAddress */
    uint8_t srcEndpt; /**< SrcEndp */
    /* Binding Cluster ID */
    uint16_t clusterId; /**< ClusterID */
    /* Binding Destination (not the destination of the message)
     * dst.panId not used, dst.nwkAddr is only for the group address,
     * and dst.endpoint only used if mode == ZB_APSDE_ADDRMODE_EXT */
    struct ZbApsAddrT dst; /**< DstAddrMode, DstAddress, DstEndp */
};

/** Bind_rsp */
struct ZbZdoBindRspT {
    enum ZbStatusCodeT status; /**< Status */
};

/** Mgmt_Lqi_req */
struct ZbZdoLqiReqT {
    uint16_t destAddr; /**< Destination address */
    uint8_t startIndex; /**< StartIndex */
};

/** Mgmt_Lqi_rsp */
struct ZbZdoLqiRspT {
    enum ZbStatusCodeT status; /**< Status */
    uint16_t respAddr; /**< Response address */
    uint8_t neighborTblSz; /**< NeighborTableEntries */
    uint8_t startIndex; /**< StartIndex */
    uint8_t neighborListSz; /**< NeighborTableListCount */
    struct ZbZdoNeighborDescT neighborList[ZB_ZDO_NEIGHBOR_LIST_MAX_SZ]; /**< NeighborTableList */
};

/** Mgmt_Rtg_req */
struct ZbZdoRtgReqT {
    uint16_t destAddr; /**< Destination address */
    uint8_t startIndex; /**< StartIndex */
};

/** Mgmt_Rtg_rsp */
struct ZbZdoRtgRspT {
    enum ZbStatusCodeT status; /**< Status */
    uint16_t respAddr; /**< Response address */
    uint8_t routeTblSz; /**< RoutingTableEntries */
    uint8_t startIndex; /**< StartIndex */
    uint8_t routeListSz; /**< RoutingTableListCount */
    struct ZbZdoRoutingDescT routeList[ZB_ZDO_ROUTE_LIST_MAX_SZ]; /**< RoutingTableList */
};

/** Mgmt_Bind_req */
struct ZbZdoMgmtBindReqT {
    uint16_t destAddr; /**< Destination address */
    uint8_t startIndex; /**< StartIndex */
};

/** Mgmt_Bind_rsp */
struct ZbZdoMgmtBindRspT {
    enum ZbStatusCodeT status; /**< Status */
    uint8_t bindTblSz; /**< BindingTableEntries */ /* Total number */
    uint8_t startIndex; /**< StartIndex */ /* Starting index being reported here */
    uint8_t bindListSz; /**< BindingTableListCount */ /* Number reported here */
    struct ZbZdoBindingDescT bindList[ZB_ZDO_BIND_LIST_MAX_SZ]; /**< BindingTableList */
};

/** ZDO Mgmt_Permit_Join_req */
struct ZbZdoPermitJoinReqT {
    uint16_t destAddr; /**< Destination address */
    uint8_t duration; /**< PermitDuration */
    uint8_t tcSignificance; /**< TC_Significance */
};

/** ZDO Mgmt_Permit_Join_rsp */
struct ZbZdoPermitJoinRspT {
    enum ZbStatusCodeT status; /**< Status */
};

/** Mgmt_Nwk_Update_req */
struct ZbZdoNwkUpdateReqT {
    uint16_t destAddr; /**< Destination address */
    uint32_t channelMask; /**< ScanChannels */
    uint8_t scanDuration; /**< ScanDuration */ /* or ZB_ZDP_NWK_UPDATE_CHANNEL_SWITCH, or ZB_ZDP_NWK_UPDATE_MANAGER_PARAMETERS */
    uint8_t scanCount; /**< ScanCount */
    uint8_t updateId; /**< nwkUpdateId */ /* only for ZB_ZDP_NWK_UPDATE_CHANNEL_SWITCH or ZB_ZDP_NWK_UPDATE_MANAGER_PARAMETERS */
    uint16_t managerAddr; /**< nwkManagerAddr */ /* only for ZB_ZDP_NWK_UPDATE_MANAGER_PARAMETERS */
};

/** Mgmt_Nwk_Enhanced_Update_req */
struct ZbZdoNwkEnhUpdateReqT {
    uint16_t destAddr; /**< Destination address */
    struct ZbChannelListT channelList; /**< ScanChannelsListStructure */
    uint8_t scanDuration; /**< ScanDuration */
    uint8_t scanCount; /**< ScanCount */
    uint8_t updateId; /**< nwkUpdateId */
    uint16_t managerAddr; /**< nwkManagerAddr */
};

/** Mgmt_Nwk_Update_notify */
struct ZbZdoNwkUpdateNotifyT {
    enum ZbStatusCodeT status; /**< Status */
    uint32_t scannedChannels; /**< ScannedChannels */
    uint16_t txTotal; /**< TotalTransmissions */
    uint16_t txFails; /**< TransmissionFailures */
    uint8_t channelListSz; /**< ScannedChannelsListCount */
    uint8_t channelList[ZB_ZDO_CHANNEL_LIST_MAXSZ]; /**< Channel energy list */
};

#define ZB_ZDO_MGMT_NWK_LEAVE_FLAG_REJOIN                   0x80U
#define ZB_ZDO_MGMT_NWK_LEAVE_FLAG_REMOVE_CHILDREN          0x40U

/** Mgmt_Nwk_Leave_req */
struct ZbZdoLeaveReqT {
    uint16_t destAddr; /**< Destination address */
    uint64_t deviceAddr; /**< Device address */
    uint8_t flags; /**< Remove Children, Rejoin */
};

/** Mgmt_Nwk_Leave_rsp */
struct ZbZdoLeaveRspT {
    enum ZbStatusCodeT status; /**< Status */
};

#define ZDP_JOINING_LIST_MAX_LEN            9U

/** Mgmt_Nwk_Ieee_Joining_List_req */
struct ZbZdoNwkIeeeJoinListReqT {
    uint16_t destAddr; /**< Destination address */
    uint8_t startIndex; /**< StartIndex */
};

/** Mgmt_Nwk_Ieee_Joining_List_rsp */
struct ZbZdoNwkIeeeJoinListRspT {
    enum ZbStatusCodeT status; /**< Status */
    uint16_t respAddr; /**< Response address */ /* not part of ZDP payload */
    uint8_t updateId; /**< IeeeJoiningListUpdateID */
    enum WpanJoinPolicyT joiningPolicy; /**< JoiningPolicy */
    uint8_t ieeeJoiningListTotal; /**< IeeeJoiningListTotal */
    uint8_t startIndex; /**< StartIndex */
    uint8_t ieeeJoiningListCount; /**< IeeeJoiningCount */
    uint64_t ieeeJoiningList[ZDP_JOINING_LIST_MAX_LEN]; /**< IeeeJoiningList */
};

/*---------------------------------------------------------------
 * ZDO
 *---------------------------------------------------------------
 */

/**
 * Return and increment the next ZDO sequence number.
 * @param zb Zigbee stack instance
 * @return Returns ZDO sequence number.
 */
uint8_t ZbZdoGetNextSeqNum(struct ZigBeeT *zb);

/**
 * Retrive the 16-bit short address for a device if given an extended address.
 * @param zb Zigbee stack instance
 * @param req NWK_Addr_req
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoNwkAddrReq(struct ZigBeeT *zb, struct ZbZdoNwkAddrReqT *req,
    void (*callback)(struct ZbZdoNwkAddrRspT *rsp, void *cb_arg), void *arg);

/**
 * Retrive the 64-bit extended address for a device if given a short network address.
 * @param zb Zigbee stack instance
 * @param req IEEE_Addr_req
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoIeeeAddrReq(struct ZigBeeT *zb, struct ZbZdoIeeeAddrReqT *req,
    void (*callback)(struct ZbZdoIeeeAddrRspT *rsp, void *cb_arg), void *arg);

/**
 * Retrieve the node descriptor for a device.
 * @param zb Zigbee stack instance
 * @param req Node_desc_req
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoNodeDescReq(struct ZigBeeT *zb, struct ZbZdoNodeDescReqT *req,
    void (*callback)(struct ZbZdoNodeDescRspT *rsp, void *cb_arg), void *arg);

/**
 * Retrieve the power descriptor for a device.
 * @param zb Zigbee stack instance
 * @param req Power_desc_req
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoPowerDescReq(struct ZigBeeT *zb, struct ZbZdoPowerDescReqT *req,
    void (*callback)(struct ZbZdoPowerDescRspT *rsp, void *cb_arg), void *arg);

/**
 * Retrieve the simple descriptor for a device.
 * @param zb Zigbee stack instance
 * @param req Simple_desc_req
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoSimpleDescReq(struct ZigBeeT *zb, struct ZbZdoSimpleDescReqT *req,
    void (*callback)(struct ZbZdoSimpleDescRspT *rsp, void *cb_arg), void *arg);

/**
 * Retrieve the active endpoint list for a device.
 * @param zb Zigbee stack instance
 * @param req Active_ep_req
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoActiveEpReq(struct ZigBeeT *zb, struct ZbZdoActiveEpReqT *req,
    void (*callback)(struct ZbZdoActiveEpRspT *rsp, void *cb_arg), void *arg);

/**
 * Retrieve the mach descriptor for a device.
 * @param zb Zigbee stack instance
 * @param req Match_desc_req
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoMatchDescReq(struct ZigBeeT *zb, struct ZbZdoMatchDescReqT *req,
    void (*callback)(struct ZbZdoMatchDescRspT *rsp, void *cb_arg), void *arg);

/**
 * Send a ZDO Match-Desc request and receive multiple responses.
 * The responses, if any, are received by the callback.
 * Each callback contains the result of a callback from a single device.
 * The callback will be called each time a response is received.
 * After a timeout period, the callback is called with a status of ZB_ZDP_STATUS_TIMEOUT to indicate the internal response filter
 * is removed and any additional responses for this request are not processed.
 * @param zb Zigbee stack instance
 * @param req Match_desc_req
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZB_ZDP_STATUS_SUCCESS for received responses, ZB_ZDP_STATUS_TABLE_FULL if there's a problem starting the request,
 * ZB_ZDP_STATUS_TIMEOUT when the stack decides to stop receiving responses, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoMatchDescMulti(struct ZigBeeT *zb, struct ZbZdoMatchDescReqT *req,
    void (*callback)(struct ZbZdoMatchDescRspT *rsp, void *cb_arg), void *arg);

/**
 * Send a Device_annce message to the network. Automatically called by the stack after joining.
 * @param zb Zigbee stack instance
 * @param deviceAnncePtr Pointer to Device_annce structure
 * @return Returns void
 */
void ZbZdoDeviceAnnce(struct ZigBeeT *zb, struct ZbZdoDeviceAnnceT *deviceAnncePtr);

/**
 * Send a Device_annce message to the network using aliasing.
 * @param zb Zigbee stack instance
 * @param deviceAnncePtr Pointer to Device_annce structure
 * @return Returns void
 */
void ZbZdoDeviceAnnceAlias(struct ZigBeeT *zb, struct ZbZdoDeviceAnnceT *deviceAnncePtr);

/**
 * Parse the device announce received.
 * @param structPtr Pointer to structure
 * @param buf Packet buffer
 * @param len Packet length
 * @return size of the device announce size, which will be 11, or other value on error
 */
int ZbZdoParseDeviceAnnce(struct ZbZdoDeviceAnnceT *structPtr, const uint8_t *buf, unsigned int len);

/**
 * Register a filter in the ZDO for the application to receive Device_Annce messages.
 * Freed by calling ZbZdoFilterRemove.
 * @param zb Zigbee stack instance
 * @param callback Function to call upon reception of a valid ZDO Device-Annce message.
 * Callback can return ZB_APS_FILTER_CONTINUE to process other filters,
 * or ZB_APS_FILTER_DISCARD if all processing of this message should stop.
 * @param arg Callback argument
 * @return Pointer to filter structure
 */
struct ZbZdoFilterT * ZbZdoDeviceAnnceFilterRegister(struct ZigBeeT *zb,
    int (*callback)(struct ZigBeeT *zb, struct ZbZdoDeviceAnnceT *annce, uint8_t seqno, void *arg), void *arg);

/*---------------------------------------------------------------
 * ZDP Binding Requests
 *---------------------------------------------------------------
 */

/**
 * Perform a ZDO Bind operation.
 * @param zb Zigbee stack instance
 * @param req Bind_req
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoBindReq(struct ZigBeeT *zb, struct ZbZdoBindReqT *req,
    void (*callback)(struct ZbZdoBindRspT *rsp, void *cb_arg), void *arg);

/**
 * Perform a ZDP Unbind Bind operation.
 * @param zb Zigbee stack instance
 * @param req Unbind_req
 * @param Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoUnbindReq(struct ZigBeeT *zb, struct ZbZdoBindReqT *req,
    void (*callback)(struct ZbZdoBindRspT *rsp, void *cb_arg), void *arg);

/*---------------------------------------------------------------
 * ZDP Management Requests
 *---------------------------------------------------------------
 */

/**
 * Perform a Mgmt_Lqi_req command.
 * @param zb Zigbee stack instance
 * @param req Mgmt_Lqi_req
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoLqiReq(struct ZigBeeT *zb, struct ZbZdoLqiReqT *req,
    void (*callback)(struct ZbZdoLqiRspT *rsp, void *cb_arg), void *arg);

/**
 * Perform a Mgmt_Rtg_req command.
 * @param zb Zigbee stack instance
 * @param req Mgmt_Rtg_req
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoRtgReq(struct ZigBeeT *zb, struct ZbZdoRtgReqT *req,
    void (*callback)(struct ZbZdoRtgRspT *rsp, void *cb_arg), void *arg);

/**
 * Perform a Mgmt_Bind_req command.
 * @param zb Zigbee stack instance
 * @param req Mgmt_bind_req
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoMgmtBindReq(struct ZigBeeT *zb, struct ZbZdoMgmtBindReqT *req,
    void (*callback)(struct ZbZdoMgmtBindRspT *rsp, void *cb_arg), void *arg);

/**
 * Perform a Mgmt_permit_joining_req command.
 * @param zb Zigbee stack instance
 * @param req Mgmt_permit_joining_req
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoPermitJoinReq(struct ZigBeeT *zb, struct ZbZdoPermitJoinReqT *req,
    void (*callback)(struct ZbZdoPermitJoinRspT *rsp, void *cb_arg), void *arg);

/**
 * Perform a Mgmt_Nwk_update_req command.
 * @param zb Zigbee stack instance
 * @param req Mgmt_Nwk_update_req
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoNwkUpdateReq(struct ZigBeeT *zb, struct ZbZdoNwkUpdateReqT *req,
    void (*callback)(struct ZbZdoNwkUpdateNotifyT *reqPtr, void *cb_arg), void *arg);

/**
 * Perform a Mgmt_Nwk_Enhanced_Update_req command.
 * @param zb Zigbee stack instance
 * @param req Mgmt_Nwk_Enhanced_Update_req
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoNwkEnhUpdateReq(struct ZigBeeT *zb, struct ZbZdoNwkEnhUpdateReqT *req,
    void (*callback)(struct ZbZdoNwkUpdateNotifyT *reqPtr, void *cb_arg), void *arg);

/**
 * Send an unsolicited Mgmt_Nwk_Update_notify command to the network manager. Does not wait for any response.
 * @param zb Zigbee stack instance
 * @param reqPtr Mgmt_Nwk_Update_notify
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoNwkUpdateNotify(struct ZigBeeT *zb, struct ZbZdoNwkUpdateNotifyT *reqPtr);

/**
 * Register a filter in the ZDO for the application to receive Mgmt_Nwk_Update_notify messages.
 * Freed by calling ZbZdoFilterRemove.
 * @param zb Zigbee stack instance
 * @param callback Function to call upon reception of a valid ZDO NWK-Update-Notify message.
 * Callback can return ZB_APS_FILTER_CONTINUE to process other filters,
 * or ZB_APS_FILTER_DISCARD if all processing of this message should stop.
 * @param arg Callback argument
 * @return Pointer to filter structure
 */
struct ZbZdoFilterT * ZbZdoNwkUpdateNotifyFilterRegister(struct ZigBeeT *zb,
    int (*callback)(struct ZigBeeT *zb, struct ZbZdoNwkUpdateNotifyT *msg,
        uint8_t seqno, void *arg), void *arg);

/**
 * Perform a Mgmt_leave_req command.
 * @param zb Zigbee stack instance
 * @param req Mgmt_Leave_req
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoLeaveReq(struct ZigBeeT *zb, struct ZbZdoLeaveReqT *req,
    void (*callback)(struct ZbZdoLeaveRspT *rsp, void *cb_arg), void *arg);

/*---------------------------------------------------------------
 * Receive incoming ZDO messages
 *---------------------------------------------------------------
 */
/* Configures the callback to receive incoming ZDO messages in your application. */
typedef int (*ZbZdoPreHandlerFuncT)(struct ZigBeeT *zb, struct ZbApsdeDataIndT *dataIndPtr, uint8_t seqnum);
void ZbZdoSetPreHandler(struct ZigBeeT *zb, ZbZdoPreHandlerFuncT func);

/*---------------------------------------------------------------
 * Complex Descriptor
 *---------------------------------------------------------------
 */
/* Internal complex descriptor format */
typedef struct ZbZdoComplexDescT {
    char manufacturerName[16];
    char modelName[16];
    char serialNumber[16];
} ZbZdoComplexDescT;

enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoSetComplexDesc(struct ZigBeeT *zb, struct ZbZdoComplexDescT *structPtr);

/*---------------------------------------------------------------
 * IEEE Joining List
 *---------------------------------------------------------------
 */

/**
 * Send an IEEE-Joining-List request.
 * @param zb Zigbee stack instance
 * @param IEEE-Joining-List.request Structure
 * @param callback Function to call on completion
 * @param arg Callback argument
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZbStatusCodeT ZB_WARN_UNUSED ZbZdoNwkIeeeJoinListReq(struct ZigBeeT *zb, struct ZbZdoNwkIeeeJoinListReqT *req,
    void (*callback)(struct ZbZdoNwkIeeeJoinListRspT *rsp, void *cb_arg), void *arg);

/**
 * Send an IEEE-Joining-List.response.
 * Used primarily by GB868 applications.
 * @param zb Zigbee stack instance
 * @param dstNwkAddr Destination network address
 * @param startIndex Start index
 * @param seqnum Sequence number
 * @param fromRequest Use start index from request
 * @return Number of entries sent in response
 */
unsigned int ZbZdoNwkIeeeJoinListRsp(struct ZigBeeT *zb, uint16_t dstNwkAddr,
    uint8_t startIndex, uint8_t seqnum, bool fromRequest);
/* Helper to broadcast the entire list to the network */

/**
 * Send an IEEE-Joining-List.response broadcast message for all entries in the IEEE Join List.
 * Used primarily by GB868 applications.
 * @param zb Zigbee stack instance
 * @return Returns number of entries sent
 */
unsigned int ZbZdoNwkIeeeJoinListBcastAll(struct ZigBeeT *zb);

/**
 * Remove a ZDO filter.
 * @param zb Zigbee stack instance
 * @param filter Filter instance to remove and free
 * @return Returns void
 */
void ZbZdoFilterRemove(struct ZigBeeT *zb, struct ZbZdoFilterT *filter);

#endif