HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2020-09-22 ade5917841b0fdcb1df7353ef7c56b1a1bdc9282
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
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
using System;
using System.Text;
using Newtonsoft.Json.Linq;
using static ZigBee.Device.ZbGateway;
 
namespace ZigBee.Common
{
    public class SendDataToGateway : ZigBee.Device.CommonDevice
    {
        //#region 网关信息
        ///// <summary>
        /////获取网关版本信息
        ///// </summary>
        //public static void GetZbGwVersion(ZigBee.Device.ZbGateway gateway)
        //{
        //    var jobject1 = new JObject { { "Cluster_ID", 0 }, { "Command", 92 } };
        //    gateway.Send("GetZbGwVersion", Common.SecuritySet.Encryption(jobject1.ToString()));
        //}
 
        ///// <summary>
        ///// 获取所有网关的节点设备信息(用于主网关)
        ///// </summary>
        //public static void GetAllDeviceInfo(ZigBee.Device.ZbGateway gateway)
        //{
        //    var jobject2 = new JObject { { "Cluster_ID", 0 }, { "Command", 90 } };
        //    gateway.Send("GetAllDeviceInfo", Common.SecuritySet.Encryption(jobject2.ToString()));
        //}
 
        ///// <summary>
        ///// 获取网关信息
        ///// </summary>
        //public static void GetZbGwInfo(ZigBee.Device.ZbGateway gateway)
        //{
        //    var jobject2 = new JObject { { "Cluster_ID", 0 }, { "Command", 95 } };
        //    gateway.Send("GetZbGwInfo", Common.SecuritySet.Encryption(jobject2.ToString()));
        //}
        //#endregion
 
        //#region 设备信息
        /////<summary >
        ///// 获取网关已入网设备信息 
        ///// </summary>
        //public static void GetDeviceInfo(ZigBee.Device.ZbGateway gateway)
        //{
        //    var jobject = new JObject();
        //    jobject.Add("Cluster_ID", 0);
        //    jobject.Add("Command", 93);
        //    gateway.Send(("GetDeviceInfo"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary >
        ///// 搜索新设备(允许设备入网)
        ///// Time:0-255,0:关闭搜索,255:一直开启
        ///// </summary>
        //public static void SearchNewDevice(ZigBee.Device.ZbGateway gateway)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 94 } };
        //    var data = new JObject { { "Time", 180 } };
        //    jobject.Add("Data", data);
        //    gateway.Send(("SearchNewDevice"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary >
        ///// 修改设备名称
        ///// </summary>
        //public static void DeviceRename(ZigBee.Device.ZbGateway gateway)
        //{
        //    var jobject = new JObject { { "DeviceAddr", "00124b00076a210b" }, { "Epoint", 11 }, { "Cluster_ID", 0 }, { "Command", 96 } };
        //    var data = new JObject { { "DeviceName", "HDL" } };
        //    jobject.Add("Data", data);
        //    gateway.Send(("DeviceRename"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary >
        ///// 使设备恢复出厂设置
        ///// </summary>
        //public static void FactoryReset(ZigBee.Device.ZbGateway gateway)
        //{
        //    var jobject = new JObject { { "DeviceAddr", "00124b00076a210b" }, { "Epoint", 11 }, { "Cluster_ID", 0 }, { "Command", 97 } };
        //    gateway.Send(("FactoryReset"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary >
        ///// 删除设备
        ///// </summary>
        //public static void RemoveDevice(ZigBee.Device.ZbGateway gateway)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 99 } };
        //    var DeviceAddrList = new JArray
        //    {
        //        //发不出去,可能是手机没练Wi-Fi
        //        new JObject {
        //            { "DeviceAddr", "00124b00076a210b"}
        //         }
        //    };
        //    var data = new JObject { { "CompelClear", 1 }, { "DeviceAddrList", DeviceAddrList } };
        //    jobject.Add("Data", data);
        //    gateway.Send(("RemoveDevice"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary >
        ///// 打开或关闭设备
        ///// Command
        ///// 0 : 关闭
        ///// 1: 打开
        ///// 2:取反
        ///// </summary>
        //public static void OpenCloseDevice(ZigBee.Device.ZbGateway gateway, ZigBee.Device.CommonDevice device, int command)
        //{
        //    var jobject = new JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 6 }, { "Command", command }, { "SendMode", 2 } };
        //    gateway.Send("DeviceControl", Common.SecuritySet.Encryption(jobject.ToString()));
        //}
        //#endregion 
 
        //#region 升级固件
        /////<summary >
        ///// 设定OTA升级固件
        ///// <para>oTAImageName:升级镜像名称</para>
        ///// <para>oTAImagePath:镜像所在路径。镜像在系统的目录路径。如:/tmp/</para>
        ///// </summary>
        //public static void SetImage(ZigBee.Device.ZbGateway gateway, string oTAImageName, string oTAImagePath)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 25 }, { "Command", 30 } };
        //    var data = new JObject { { "OTAImageName", oTAImageName }, { "OTAImagePath", oTAImagePath } };
        //    jobject.Add("Data", data);
        //    gateway.Send(("OTA/SetImage"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
        //#endregion
 
        //#region Hdl按键
        ///////<summary>
        ///////获取所有绑定(用于主网关)
        /////// </summary>
        ////public static void hdlButtonGetAllBind(ZigBee.Device.ZbGateway gateway)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 64528 }, { "Command", 10 } };
        ////    gateway.Send(("hdlButton/BindInfo"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        ///////<summary>
        ///////读取按键信息
        /////// </summary>
        ////public static void hdlButtonGetInfo(ZigBee.Device.ZbGateway gateway, string buttonMacAddr, int epoint, int endpoint)
        ////{
        ////    var jobject = new JObject { { "DeviceAddr", buttonMacAddr }, { "Epoint", epoint }, { "Cluster_ID", 64528 }, { "Command", 3 } };
        ////    var data = new JObject { { "Endpoint", endpoint } };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("hdlButton/GetInfo"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        ///////<summary>
        ///////配置锁键
        /////// IsLock
        /////// 0:不锁
        ///////1:锁
        /////// </summary>
        ////public static void hdlButtonLock(ZigBee.Device.ZbGateway gateway, string buttonMacAddr, int epoint, int endpoint, int isLock)
        ////{
        ////    var jobject = new JObject { { "DeviceAddr", buttonMacAddr }, { "Epoint", epoint }, { "Cluster_ID", 64528 }, { "Command", 5 } };
        ////    var data = new JObject { { "Endpoint", endpoint }, { "IsLock", isLock } };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("hdlButton/Lock"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        ///////<summary>
        ///////配置绑定属性(用于主网关)
        /////// IsLock
        /////// 0:不锁
        ///////1:锁
        /////// </summary>
        ////public static void hdlButtonSetBindAttribute(ZigBee.Device.ZbGateway gateway, string buttonMacAddr, int epoint, int buttonMode, int buttonType, string bindName, int bindClusterId, int bindCmdId)
        ////{
        ////    var jobject = new JObject { { "DeviceAddr", buttonMacAddr }, { "Epoint", epoint }, { "Cluster_ID", 64528 }, { "Command", 4 } };
 
        ////    var ParameterList = new JArray{
        ////        new JObject {}
        ////    };
 
        ////    var data = new JObject { { "ButtonEpoint", epoint },
        ////        { "ButtonMode", buttonMode },{ "ButtonType", buttonType },
        ////        { "BindName", bindName },
        ////        { "BindClusterId", bindClusterId },{ "BindCmdId", bindCmdId },
        ////        { "ParameterList", ParameterList },
        ////     };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("hdlButton/SetBindAttribute"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        ///////<summary>
        ///////设备绑定(用于主网关)
        /////// 绑定设备
        /////// </summary>
        ////public static void hdlButtonSetBind(ZigBee.Device.ZbGateway gateway, ZigBee.Device.HDLbutton.BindListDeviceInfo bindListObj, string buttonMacAddr, int epoint, int buttonMode, int buttonType)
        ////{
        ////    var jobject = new JObject { { "DeviceAddr", buttonMacAddr }, { "Epoint", epoint }, { "Cluster_ID", 64528 }, { "Command", 6 } };
 
        ////    var bindList = new JArray{
        ////        new JObject {{ "BindType", bindListObj.BindType},{ "BindMacAddr", bindListObj.BindMacAddr},{ "BindEpoint", bindListObj.BindEpoint }}
        ////    };
        ////    var data = new JObject { { "ButtonEpoint", epoint },
        ////        { "ButtonMode", buttonMode },{ "ButtonType", buttonType },
        ////        { "BindList", bindList }
        ////     };
 
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("hdlButton/SetBind"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        ///////<summary>
        ///////设备绑定(用于主网关)
        /////// 绑定场景,当BindType=1时存在
        /////// </summary>
        ////public static void hdlButtonSetSceneBind(ZigBee.Device.ZbGateway gateway, ZigBee.Device.HDLbutton.BindSceneInfo bindListObj, string buttonMacAddr, int epoint, int buttonMode, int buttonType)
        ////{
        ////    var jobject = new JObject { { "DeviceAddr", buttonMacAddr }, { "Epoint", epoint }, { "Cluster_ID", 64528 }, { "Command", 6 } };
 
        ////    var bindList = new JArray{
        ////        new JObject {{ "BindType", bindListObj.BindType},{ "BindScenesId", bindListObj.BindScenesId}}
        ////    };
        ////    var data = new JObject { { "ButtonEpoint", epoint },
        ////        { "ButtonMode", buttonMode },{ "ButtonType", buttonType },
        ////        { "BindList", bindList }
        ////     };
 
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("hdlButton/SetBind"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        ///////<summary>
        ///////移除绑定(用于主网关)
        /////// /// BindScenesId,绑定场景,当BindType=1时存在
        /////// </summary>
        ////public static void hdlButtonRemoveBind(ZigBee.Device.ZbGateway gateway, ZigBee.Device.HDLbutton.RemoveBindListInfo removeListObj, string buttonMacAddr, int epoint, int buttonMode, int buttonType)
        ////{
        ////    var jobject = new JObject { { "DeviceAddr", buttonMacAddr }, { "Epoint", epoint }, { "Cluster_ID", 64528 }, { "Command", 7 } };
 
        ////    var removeBindList = new JArray{
        ////        new JObject {{ "BindType", removeListObj.BindType},{ "BindMacAddr", removeListObj.BindMacAddr},{ "BindEpoint", removeListObj.BindEpoint}}
        ////    };
        ////    var data = new JObject { { "ButtonEpoint", epoint },
        ////        { "ButtonMode", buttonMode },{ "ButtonType", buttonType },
        ////        { "RemoveBindList", removeBindList }
        ////     };
 
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("hdlButton/RemoveBind"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
 
        ///////<summary>
        ///////移除绑定(用于主网关)
        /////// /// BindScenesId,绑定场景,当BindType=1时存在
        /////// </summary>
        ////public static void hdlButtonRemoveSceneBind(ZigBee.Device.ZbGateway gateway, ZigBee.Device.HDLbutton.RemoveSceneBindListInfo removeListObj, string buttonMacAddr, int epoint, int buttonMode, int buttonType)
        ////{
        ////    var jobject = new JObject { { "DeviceAddr", buttonMacAddr }, { "Epoint", epoint }, { "Cluster_ID", 64528 }, { "Command", 7 } };
 
        ////    var removeBindList = new JArray{
        ////        new JObject {{ "BindType", removeListObj.BindType},{ "BindScenesId", removeListObj.BindScenesId}}
        ////    };
        ////    var data = new JObject { { "ButtonEpoint", epoint },
        ////        { "ButtonMode", buttonMode },{ "ButtonType", buttonType },
        ////        { "RemoveBindList", removeBindList }
        ////     };
 
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("hdlButton/RemoveBind"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        ///////<summary>
        ///////删除按键功能(用于主网关)
        /////// buttonMode设为0xffff  65536 ,直接清除按键号下所有按键模式的绑定
        /////// </summary>
        ////public static void hdlButtonDelButtonFunction(ZigBee.Device.ZbGateway gateway, string buttonMacAddr, int epoint, int buttonMode)
        ////{
        ////    var jobject = new JObject { { "DeviceAddr", buttonMacAddr }, { "Epoint", epoint }, { "Cluster_ID", 64528 }, { "Command", 8 } };
        ////    var data = new JObject { { "ButtonEpoint", epoint},
        ////        { "ButtonMode", buttonMode }
        ////    };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("hdlButton/DelButtonFunction"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        ///////<summary>
        ///////修改绑定名称(用于主网关)
        /////// </summary>
        ////public static void hdlButtonBindRename(ZigBee.Device.ZbGateway gateway, string buttonMacAddr, int epoint, int buttonMode, int buttonType, string bindName)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 64528 }, { "Command", 9 } };
        ////    var data = new JObject { { "ButtonMacAddr", buttonMacAddr },
        ////        { "ButtonEpoint", epoint },{ "ButtonMode", buttonMode },
        ////        { "ButtonType", buttonType },
        ////        { "BindName", bindName }
        ////    };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("hdlButton/BindRename"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
        //#endregion
 
        //#region 协调器
        /////<summary >
        /////添加Install Codes码
        ///// <para>installCode:InstallCode码  36个字符</para>
        ///// <para>installCodeAddr:InstallCodes码设备的mac地址16个字符</para>
        ///// </summary>
        //public static void ZbGwInstallCode(ZigBee.Device.ZbGateway gateway, string installCode, string installCodeAddr)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 64512 }, { "Command", 7 } };
        //    var data = new JObject { { "InstallCode", installCode }, { "InstallCodeAddr", installCodeAddr } };
        //    jobject.Add("Data", data);
        //    gateway.Send(("ZbGw/InstallCode"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary >
        /////获取协调器当前信道
        ///// </summary>
        //public static void ZbGwGetChannel(ZigBee.Device.ZbGateway gateway)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 64512 }, { "Command", 8 } };
        //    gateway.Send(("ZbGw/GetChannel"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary >
        /////更改协调器当前信道
        ///// <para>channel:要更改的信道: 11 -26</para>
        ///// </summary>
        //public static void ZbGwChangeChannel(ZigBee.Device.ZbGateway gateway, int channel)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 64512 }, { "Command", 9 } };
        //    var data = new JObject { { "Channel", channel } };
        //    jobject.Add("Data", data);
        //    gateway.Send(("ZbGw/ChangeChannel"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary >
        /////查看当前发射功率
        ///// </summary>
        //public static void ZbGwGetPower(ZigBee.Device.ZbGateway gateway)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 64512 }, { "Command", 10 } };
        //    gateway.Send(("ZbGw/GetPower"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary >
        /////设置发射功率
        ///// <para>power:要更改的设备发射功率,可设置8,10,11,13,15,16,18,19,20,21,22(dBm)</para>
        ///// </summary>
        //public static void ZbGwSetPower(ZigBee.Device.ZbGateway gateway, int power)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 64512 }, { "Command", 11 } };
        //    var data = new JObject { { "Power", power } };
        //    jobject.Add("Data", data);
        //    gateway.Send(("ZbGw/SetPower"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary >
        /////读取当前局域网的PANID
        ///// </summary>
        //public static void ZbGwGetPanId(ZigBee.Device.ZbGateway gateway)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 64512 }, { "Command", 12 } };
        //    gateway.Send(("ZbGw/GetPanId"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary >
        /////读取协调器MAC地址
        ///// </summary>
        //public static void ZbGwGetMac(ZigBee.Device.ZbGateway gateway)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 64512 }, { "Command", 13 } };
        //    gateway.Send(("ZbGw/GetMac"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary >
        /////zigbee协调器恢复出厂设置
        ///// 0:仅将协调器恢复出厂设置,不删除网关保存的设备列表,组列表,场景列表等信息。
        /////1:将协调器恢复出厂设置,并删除网关保存的设备列表,组列表,场景列表等信息。
        ///// </summary>
        //public static void ZbGwOperationReset(ZigBee.Device.ZbGateway gateway, int delAllInfo)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 160 } };
        //    var data = new JObject { { "DelAllInfo", delAllInfo } };
        //    jobject.Add("Data", data);
        //    gateway.Send(("ZbGwOperation/Reset"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        ///////<summary >
        ///////保存zigbee协调器组网信息
        /////// </summary>
        ////public static void ZbGwOperationSaveNVFile(ZigBee.Device.ZbGateway gateway, string imageName, string imagePath)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 500 } };
        ////    var data = new JObject { { "ImageName", imageName }, { "ImagePath", imagePath } };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("ZbGwOperation/SaveNVFile"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        ///////<summary >
        ///////协调器恢复组网信息
        /////// </summary>
        ////public static void ZbGwOperationRestoreNV(ZigBee.Device.ZbGateway gateway, string imageName, string imagePath)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 501 } };
        ////    var data = new JObject { { "ImageName", imageName }, { "ImagePath", imagePath } };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("ZbGwOperation/RestoreNV"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        ///////<summary >
        /////// 协调器升级
        /////// </summary>
        ////public static void ZbGwOperationUpgrade(ZigBee.Device.ZbGateway gateway, string imageName, string imagePath)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 502 } };
        ////    var data = new JObject { { "ImageName", imageName }, { "ImagePath", imagePath } };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("ZbGwOperation/Upgrade"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        /////<summary >
        /////读取协调器MAC地址
        ///// </summary>
        //public static void ZbGwSetOrGetData(ZigBee.Device.ZbGateway gateway, int command_ID, string payload)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 64512 }, { "Command", 2600 } };
        //    var data = new JObject { { "Command_ID", command_ID }, { "Payload", payload } };
        //    jobject.Add("Data", data);
        //    gateway.Send(("ZbGw/GetMac"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
        //#endregion
 
        //#region 场景
        /////<summary >
        ///// 在网关中创建新的场景ID
        ///// </summary>
        ////public static void SceneGetNewId(ZigBee.Device.ZbGateway gateway, string SceneName)
        ////{
        ////    var jObject = new Newtonsoft.Json.Linq.JObject() {
        ////                            { "Cluster_ID", 0 },
        ////                            { "Command", 800 }
        ////                        };
        ////    var data = new JObject { { "ScenesName", SceneName } };
        ////    jObject.Add("Data", data);
        ////    gateway.Send("Scene/GetNewId", Common.SecuritySet.Encryption(jObject.ToString()));
        ////}
 
        /////<summary >
        ///// 添加设备到网关到场景中
        ///// </summary>
        ////public static void SceneAddMember(Shared.Device.ZbGateway gateway,Shared.Device.ZbGateway.TaskListInfo taskInfo, int ScenesId, string DeviceAddr, int Epoint)
        ////public static void SceneAddMember(ZigBee.Device.ZbGateway gateway, ZigBee.Device.Scene.TaskListInfo taskInfo, int ScenesId, string DeviceAddr, int Epoint)
 
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 810 } };
 
        ////    //var taskList = new JArray{
        ////    //new JObject{{ "TaskType", 1}, { "Data1",1}, { "Data2",0}},
        ////    //new JObject{{ "TaskType", 2 }, { "Data1", 60 }, { "Data2", 0 }}
        ////    //};
        ////    var taskList = new JArray
        ////    {
        ////        new JObject{
        ////            { "TaskType", taskInfo.TaskType},
        ////            { "Data1", taskInfo.Data1},
        ////            { "Data2",taskInfo.Data2}
        ////        }
        ////    };
        ////    var data = new JObject {
        ////        { "ScenesId",ScenesId},
        ////        { "Type", 0} ,
        ////        { "DeviceAddr",DeviceAddr} ,
        ////        { "Epoint", Epoint} ,
        ////        { "TaskList", taskList }
        ////    };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("Scene/AddMember"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        /////<summary >
        ///// 从网关的场景中移除设备
        ///// </summary>
        ////public static void SceneRemoveMember(ZigBee.Device.ZbGateway gateway, int ScenesId, string DeviceAddr, int Epoint)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 802 } };
        ////    var DeviceList = new JArray
        ////                        {
        ////                            new JObject {
        ////                                { "Type", 0},
        ////                                { "DeviceAddr",DeviceAddr},
        ////                                { "Epoint",Epoint}
        ////                            }
        ////                        };
        ////    var data = new JObject {
        ////        {"ScenesId",ScenesId},
        ////                            { "DeviceList", DeviceList }
        ////                        };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("Scene/RemoveMember"), Common.SecuritySet.Encryption((jobject.ToString())));
 
        ////}
 
        /////<summary >
        ///// 删除场景
        ///// </summary>
        ////public static void SceneRemove(ZigBee.Device.ZbGateway gateway, int scenesId)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 803 } };
        ////    var data = new JObject { { "ScenesId", scenesId } };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("Scene/Remove"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        /////<summary >
        ///// 修改场景名称
        ///// </summary>
        ////public static void SceneRename(ZigBee.Device.ZbGateway gateway, int scenesId, string scenesName)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 804 } };
        ////    var data = new JObject { { "ScenesId", scenesId }, { "ScenesName", scenesName } };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("Scene/Rename"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        /////<summary >
        ///// 获取网关中场景信息
        ///// </summary>
        ////public static void SceneGetInfo(ZigBee.Device.ZbGateway gateway)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 805 } };
        ////    gateway.Send(("Scene/GetInfo"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        /////<summary >
        /////获取网关中场景的设备列表
        ///// </summary>
        ////public static void SceneGetDeviceList(ZigBee.Device.ZbGateway gateway, int ScenesId)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 806 } };
        ////    var data = new JObject { { "ScenesId", ScenesId } };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("Scene/GetDeviceList"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        /////<summary >
        ///// 获取所有场景信息(包括场景设备列表)
        ///// </summary>
        //public static void SceneGetAllInfo(ZigBee.Device.ZbGateway gateway)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 807 } };
        //    gateway.Send(("Scene/GetAllInfo"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary >
        /////调用场景
        ///// </summary>
        ////public static void SceneOpen(ZigBee.Device.ZbGateway gateway, int ScenesId)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 808 } };
        ////    var data = new JObject { { "ScenesId", ScenesId } };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("Scene/Open"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
        //#endregion
 
        //#region 创建文件,发送文件流
        /////<summary >
        ///// 创建文件
        ///// </summary>
        //public static void CreateFile(ZigBee.Device.ZbGateway gateway, string fileName)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 3000 } };
        //    var data = new JObject { { "FileName", fileName }, { "FilePath", "/tmp/" } };
        //    jobject.Add("Data", data);
        //    gateway.Send(("FileTransfer/CreateFile"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary >
        ///// 客户端发送文件流到网关
        ///// </summary>
        //public static void SendFile(ZigBee.Device.ZbGateway gateway, string fileName)
        //{
 
        //    //System.Threading.Tasks.Task.Run(() =>
        //    //{
        //    //    var downloadFile = new DroidService.service.hdlcontrol.com.WebServiceSoftware().DownloadByOneFile(fileName);//("openwrt-ramips-mt7688-Widora-20180607.bin");
        //    //    var data = SymmetricEncrypt.Encrypt.ToDecrypt(downloadFile.Binary);
        //    //    var ff = "数据包总长度====" + data.Length.ToString();
        //    //    System.Console.WriteLine(ff);
        //    //    if (data == null)
        //    //    {
        //    //        return;
        //    //    }
        //    //    var fileBytes = data;
        //    //    var size = 2048;
        //    //    for (int i = 0, tempSize = 0; i < fileBytes.Length; i += tempSize)
        //    //    {
        //    //        byte finish = 0;
        //    //        if (i + size < fileBytes.Length)
        //    //        {
        //    //            tempSize = size;
        //    //        }
        //    //        else if (i + size == fileBytes.Length)
        //    //        {
        //    //            tempSize = size;
        //    //            finish = 1;
        //    //        }
        //    //        else
        //    //        {
        //    //            tempSize = fileBytes.Length % size;
        //    //            finish = 1;
        //    //        }
        //    //        var bytes = new byte[8 + tempSize];
        //    //        bytes[0] = 0xfe;
        //    //        bytes[1] = 0;
        //    //        bytes[2] = 0;
        //    //        bytes[3] = 0;
        //    //        bytes[4] = 0;
        //    //        bytes[5] = finish;//0x00 或 0x01
        //    //        bytes[6] = Convert.ToByte(tempSize % 256);   // DataLen 0x01 到 0x800 (即每次最大发送2048字节)2
        //    //        bytes[7] = Convert.ToByte(tempSize / 256);
        //    //        System.Array.Copy(fileBytes, i, bytes, 8, tempSize);
 
        //    //        if (finish == 1)
        //    //        {
        //    //            var bb = "最后一个数据包大小" + tempSize.ToString();
        //    //            System.Console.WriteLine(bb);
        //    //            var aa = "最后一个数据包大小" + (i + tempSize).ToString();
        //    //            System.Console.WriteLine(aa);
        //    //        }
        //    //        var dd = "数据包大小====" + (i + tempSize).ToString().ToString();
        //    //        System.Console.WriteLine(dd);
        //    //        gateway.Send("FileTransfer/SendFile", Common.SecuritySet.EncryptionBytes(bytes));
        //    //        System.Threading.Thread.Sleep(100);
        //    //    }
        //    //});
 
        //}
        //#endregion
 
        //#region 属性
        ///// <summary>
        ///// 读取报告属性配置
        ///// </summary>
        ///// <param name="clusterID">Cluster identifier.</param>
        ///// <param name="attriButeId">Attri bute identifier.</param>
        //public static void ReadAttri(ZigBee.Device.ZbGateway gateway, string buttonMacAddr, int epoint, ZigBee.Device.Cluster_ID clusterID, ZigBee.Device.AttriButeId attriButeId)
        //{
        //    var jobject = new JObject {
        //        { "DeviceAddr",buttonMacAddr },
        //        { "Epoint", epoint },
        //        { "Cluster_ID", (int)clusterID },
        //        { "Command", 108 }
        //    };
        //    var attriBute = new JArray{
        //          new JObject {
        //            { "AttriButeId", (int)attriButeId}
        //           }
        //    };
        //    var data = new JObject { { "AttriBute", attriBute } };
        //    jobject.Add("Data", data);
        //    gateway?.Send(("GetDeviceStatus"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        ///// <summary>
        ///// 设置可写属性的值
        ///// </summary>
        ///// <param name="clusterID">Cluster identifier.</param>
        ///// <param name="attriButeId">Attri bute identifier.</param>
        //public static void SetWritableValue(ZigBee.Device.ZbGateway gateway, string buttonMacAddr, int epoint, int clusterID, int attriButeId, int attributeDataType, int attributeData)
        //{
        //    var jobject = new JObject {
        //        { "DeviceAddr",buttonMacAddr },
        //        { "Epoint", epoint },
        //        { "Cluster_ID", clusterID },
        //        { "Command", 120 }
        //    };
        //    var data = new JObject { { "AttributeId", attriButeId },
        //        { "AttributeDataType", attributeDataType },{ "AttributeData", attributeData }
        //     };
        //    jobject.Add("Data", data);
        //    gateway?.Send(("GetDeviceStatus"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
        //#endregion
 
        //#region 开关
        /////<summary >
        /////开关控制
        ///// command的值
        /////0 : 关闭
        /////1: 打开
        /////2:取反
        ///// </summary>
        //public static void SwitchControll(ZigBee.Device.ZbGateway gateway, string buttonMacAddr, int epoint, int command)
        //{
        //    var jobject = new JObject { { "DeviceAddr", buttonMacAddr }, { "Epoint", epoint }, { "Cluster_ID", 6 }, { "Command", command }, { "SendMode", 2 } };
        //    gateway?.Send(("DeviceControl"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
        //#endregion
 
        //#region 灯光
 
        //#region Level
        /////<summary >
        /////设置指定设备亮度(Level)
        ////Command
        ////0:Move to Level Command
        ////4:Move to Level Command(with On/ Off)
        ///// </summary>
        //public static void SetLevel(ZigBee.Device.ZbGateway gateway, string DeviceAddr, int Epoint, int value)
        //{
        //    var jobject = new JObject {
        //        { "DeviceAddr", DeviceAddr},
        //        { "Epoint", Epoint},
        //            { "Cluster_ID", 8 },
        //            { "Command", 0 },
        //            { "SendMode", 2 }
        //        };
        //    var data = new JObject {
        //            { "Level", value },
        //            { "TransitionTime", 0 }
        //        };
        //    jobject.Add("Data", data);
        //    gateway?.Send("DeviceControl", Common.SecuritySet.Encryption(jobject.ToString()));
        //}
 
        /////<summary >
        /////Move Level 
        ////1: Move Command
        ////5:Move to Level Command(with On/ Off)
        ////MoveMode:0: Up mode , Level 变大
        ////MoveMode1:Down mode , Level变小
        ///// </summary>
        //public static void MoveLevel(ZigBee.Device.ZbGateway gateway, string DeviceAddr, int Epoint, int MoveMode)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", Epoint }, { "Cluster_ID", 8 }, { "Command", 1 }, { "SendMode", 2 } };
        //    var data = new JObject { { "MoveMode", MoveMode }, { "Rate", 100 } };
        //    jobject.Add("Data", data);
        //    gateway?.Send("DeviceControl", Common.SecuritySet.Encryption(jobject.ToString()));
        //}
 
        /////<summary >
        ////Move Level Command
        ////2: Move Command
        ////6:Move to Level Command(with On/ Off)
        ////MoveMode:0: Up mode , Level 变大
        ////MoveMode1:Down mode , Level变小
        ///// </summary>
        //public static void StepLevel(ZigBee.Device.ZbGateway gateway, string DeviceAddr, int Epoint, int StepMode)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", Epoint }, { "Cluster_ID", 8 }, { "Command", 2 }, { "SendMode", 2 } };
        //    var data = new JObject { { "StepMode", StepMode }, { "StepSize", 50 }, { "TransitionTime", 0 } };
        //    jobject.Add("Data", data);
        //    gateway?.Send("DeviceControl", Common.SecuritySet.Encryption(jobject.ToString()));
        //}
 
        /////<summary >
        ////Stop Level Command
        ///// </summary>
        //public static void StopLevel(ZigBee.Device.ZbGateway gateway, string DeviceAddr, int Epoint)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", Epoint }, { "Cluster_ID", 8 }, { "Command", 3 }, { "SendMode", 2 } };
        //    gateway?.Send("DeviceControl", Common.SecuritySet.Encryption(jobject.ToString()));
        //}
        //#endregion
 
        //#region Hue
        /////<summary > 
        /////设置指定设备色度(Hue)
        /////0:选最短的路径到达Hue
        /////1:选最长的路径到达Hue
        /////2:正方向到达Hue
        /////3:反方向到达Hue
        ///// </summary>
        //public static void SetHue(ZigBee.Device.ZbGateway gateway, string DeviceAddr, int Epoint, int value)
        //{
 
        //    var jobject = new JObject {
        //            { "DeviceAddr",  DeviceAddr },
        //            { "Epoint",  Epoint },
        //            { "Cluster_ID", 768 },
        //            { "Command", 0 },
        //            { "SendMode", 2 }
        //        };
        //    var data = new JObject {
        //                { "Hue", value },
        //                { "Direction", 0 },
        //            { "TransitionTime", 0 }
        //        };
        //    jobject.Add("Data", data);
        //    gateway?.Send("DeviceControl", Common.SecuritySet.Encryption(jobject.ToString()));
        //}
 
        /////<summary > 
        ///// Move Hue Command
        /////0:stop ,停止变化色调
        /////1:up ,正方向变化色调
        /////3:down,反方向变化色调
        ///// </summary>
        //public static void MoveHue(ZigBee.Device.ZbGateway gateway, string DeviceAddr, int Epoint, int MoveMode)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", Epoint }, { "Cluster_ID", 768 }, { "Command", 1 }, { "SendMode", 2 } };
        //    var data = new JObject { { "MoveMode", MoveMode }, { "Rate", 10 } };
        //    jobject.Add("Data", data);
        //    gateway?.Send("DeviceControl", Common.SecuritySet.Encryption(jobject.ToString()));
        //}
 
        /////<summary > 
        /////设置指定设备色度(Hue)
        /////Step Hue
        /////1:up ,正方向变化色调
        /////3:down,反方向变化色调
        ///// </summary>
        //public static void StepHue(ZigBee.Device.ZbGateway gateway, string DeviceAddr, int Epoint, int StepMode)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", Epoint }, { "Cluster_ID", 768 }, { "Command", 2 }, { "SendMode", 2 } };
        //    var data = new JObject { { "StepMode", StepMode }, { "StepSize", 50 }, { "TransitionTime", 0 } };
        //    jobject.Add("Data", data);
        //    gateway?.Send("DeviceControl", Common.SecuritySet.Encryption(jobject.ToString()));
        //}
 
        /////<summary > 
        /////设置色度和饱和度 
        ///// </summary>
        //public static void setHueAndStaturation(ZigBee.Device.ZbGateway gateway, string DeviceAddr, int Epoint, int Hue, int Saturation)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", Epoint }, { "Cluster_ID", 768 }, { "Command", 6 }, { "SendMode", 2 } };
        //    var data = new JObject { { "Hue", Hue }, { "Saturation", Saturation }, { "TransitionTime", 0 } };
        //    jobject.Add("Data", data);
        //    gateway?.Send("DeviceControl", Common.SecuritySet.Encryption(jobject.ToString()));
        //}
        //#endregion
 
        //#region Saturation
        /////<summary > 
        /////设置指定设备饱和度(Saturation)
        /////Command
        /////0:Move to Level Command
        /////4:Move to Level Command(with On/ Off)
        ///// </summary>
        //public static void SetSaturation(ZigBee.Device.ZbGateway gateway, string DeviceAddr, int Epoint, int value)
        //{
        //    var jobject = new JObject {
        //            { "DeviceAddr", DeviceAddr },
        //            { "Epoint", Epoint },
        //            { "Cluster_ID", 768 },
        //            { "Command", 3 },
        //            { "SendMode", 2 }
        //        };
        //    var data = new JObject {
        //            { "Saturation", value },
        //             { "TransitionTime", 0 }
        //        };
        //    jobject.Add("Data", data);
        //    gateway?.Send("DeviceControl", Common.SecuritySet.Encryption(jobject.ToString()));
        //}
 
        /////<summary > 
        /////Move Saturation Command
        /////0:Stop ,停止变化饱和度
        /////1:Up ,正方向变化,(颜色由白色变为其他色)
        /////3:反方向变化(颜色由其他色变为白色)
        ///// </summary>
        //public static void MoveUpSaturation(ZigBee.Device.ZbGateway gateway, string DeviceAddr, int Epoint, int MoveMode)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", Epoint }, { "Cluster_ID", 768 }, { "Command", 4 }, { "SendMode", 2 } };
        //    var data = new JObject { { "MoveMode", MoveMode }, { "Rate", 15 } };
        //    jobject.Add("Data", data);
        //    gateway?.Send("DeviceControl", Common.SecuritySet.Encryption(jobject.ToString()));
        //}
 
        /////<summary > 
        /////Step Saturation Command
        /////1:up ,正方向变化
        /////3:down ,反方向变化
        ///// </summary>
        //public static void StepSaturation(ZigBee.Device.ZbGateway gateway, string DeviceAddr, int Epoint, int StepMode)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", Epoint }, { "Cluster_ID", 768 }, { "Command", 5 }, { "SendMode", 2 } };
        //    var data = new JObject { { "StepMode", StepMode }, { "StepSize", 50 }, { "TransitionTime", 0 } };
        //    jobject.Add("Data", data);
        //    gateway?.Send("DeviceControl", Common.SecuritySet.Encryption(jobject.ToString()));
        //}
        //#endregion
 
        //#endregion
 
        //#region 窗帘
        /////<summary >
        /////窗帘控制
        ///// command的值
        ///// 0:开
        /////1:关
        /////2:停
        ///// </summary>
        //public static void CurtainControll(ZigBee.Device.ZbGateway gateway, string buttonMacAddr, int epoint, int command)
        //{
        //    var jobject = new JObject { { "DeviceAddr", buttonMacAddr }, { "Epoint", epoint }, { "Cluster_ID", 258 }, { "Command", command }, { "SendMode", 2 } };
        //    gateway.Send(("ZbGwOperation/Reset"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
        //#endregion
 
        //#region 逻辑
        /////<summary>
        ///// 获取逻辑列表
        ///// </summary>
        //public static void LogicGetLogicList()
        //{
        //    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 2004 } };
        //    ZigBee.Device.ZbGateway.MainGateWay?.Send(("Logic/GetLogicList"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary>
        /////通过逻辑id获取逻辑信息
        ///// </summary>
        ////public static void LogicGetLogicInfo(Shared.Device.ZbGateway gateway, int LogicId)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 2002 } };
        ////    var data = new JObject { { "LogicId", LogicId } };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("Logic/GetLogicInfo"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        ///// <summary>
        ///// 在网关中创建新的场景ID
        ///// </summary>
        ///// <param name="gateway">Gateway.</param>
        ///// <param name="logicId">Logic identifier.</param>
        ///// <param name="isEnable">Is enable.</param>
        ///// <param name="logicName">Logic name.</param>
        ///// <param name="relationship">Relationship.</param>
        ///// <param name="Condition">Condition.</param>
        ///// <param name="Action">Action.</param>
        ///// <param name="taskInfo">Task info.</param>
        ////public static void LogicAddLogic(Shared.Device.ZbGateway gateway, int LogicId, int IsEnable, string LogicName, int Relationship, LogicObj.ConditionsData Condition, LogicObj.ActionsData Action, LogicObj.TaskListInfo taskInfo)
        ////{
        ////    var jObject = new Newtonsoft.Json.Linq.JObject() {
        ////                            { "Cluster_ID", 0 },
        ////                            { "Command", 2000 }
        ////                        };
        ////    var Conditions = new JArray
        ////    {
        ////        new JObject{
        ////        //    { "ConditionId", Condition.ConditionId},
        ////        //    { "IsValid", Condition.IsValid},
        ////        //    { "Type",Condition.Type}
        ////        }
        ////    };
        ////    var taskList = new JArray
        ////    {
        ////        new JObject{
        ////        //    { "TaskType", taskInfo.TaskType},
        ////        //    { "Data1", taskInfo.Data1},
        ////        //    { "Data2",taskInfo.Data2}
        ////        }
        ////    };
        ////    var Actions = new JArray
        ////    {
        ////        new JObject{
        ////        //    { "ConditionId", Action.ConditionId},
        ////        //    { "DeviceAddr", Action.DeviceAddr},
        ////        //    { "EnableCondition",Action.EnableCondition},
        ////        //    { "EnableLogic", Action.EnableLogic},
        ////        //    { "Epoint", Action.Epoint},
        ////        //    { "LinkType",Action.LinkType},
        ////        //    { "SecuritySetting", Action.SecuritySetting},
        ////        //    { "TaskList", taskList},
        ////        //    { "Time",Action.Time}
        ////        }
        ////    };
        ////    var data = new JObject {
        ////        { "LogicId", LogicId },
        ////        { "IsEnable", IsEnable },
        ////        { "LogicName", LogicName },
        ////        { "Relationship", Relationship },
        ////        { "Conditions", Conditions },
        ////        { "Actions", Actions }
        ////    };
 
        ////    jObject.Add("Data", data);
        ////    gateway.Send("logic/AddLogic", Common.SecuritySet.Encryption(jObject.ToString()));
        ////}
 
        /////<summary>
        ///// 修改逻辑名称、逻辑关系、是否使能
        ///// </summary>
        ////public static void LogicReviseAttribute(Shared.Device.ZbGateway gateway, int LogicId, int IsEnable, string LogicName, int Relationship)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 2001 } };
        ////    var data = new JObject { { "LogicId", LogicId }, { "IsEnable", IsEnable }, { "LogicName", LogicName }, { "Relationship", Relationship } };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("Logic/ReviseAttribute"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        /////<summary>
        ///// 新增或修改逻辑条件
        ///// </summary>
        ////public static void LogicChangeCondition(Shared.Device.ZbGateway gateway, int LogicId, int ConditionId, int Type, int IsValid)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 2005 } };
        ////    var data = new JObject { { "LogicId", LogicId }, { "ConditionId", ConditionId }, { "Type", Type }, { "IsValid", IsValid } };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("Logic/ChangeCondition"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        /////<summary>
        /////删除/启用/禁用逻辑条件
        ///// </summary>
        ////public static void LogicSetConditionData(Shared.Device.ZbGateway gateway, int LogicId, int ConditionId, int Operation)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 2006 } };
        ////    var data = new JObject { { "LogicId", LogicId }, { "ConditionId", ConditionId }, { "Operation", Operation } };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("Logic/SetCondition"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        /////<summary>
        /////修改或新增动作任务
        ///// </summary>
        ////public static void LogicChangeAction(Shared.Device.ZbGateway gateway, int LogicId, int LinkType, string DeviceAddr, int Epoint, int ConditionId, int EnableCondition, int Time, LogicObj.TaskListInfo taskInfo)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 2007 } };
        ////    var taskList = new JArray
        ////    {
        ////        new JObject{
        ////            { "TaskType", taskInfo.TaskType},
        ////            { "Data1", taskInfo.Data1},
        ////            { "Data2",taskInfo.Data2}
        ////        }
        ////    };
 
        ////    var data = new JObject {
        ////        { "LogicId", LogicId },
        ////        { "LinkType", LinkType },
        ////        { "DeviceAddr", DeviceAddr },
        ////        { "Epoint", Epoint },
        ////        { "ConditionId", ConditionId },
        ////        { "EnableCondition", EnableCondition },
        ////        { "Time", Time },
        ////        { "TaskList", taskList }
        ////    };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("Logic/ ChangeAction"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        /////<summary>
        /////删除动作设备
        ///// </summary>
        ////public static void LogicDelAction(Shared.Device.ZbGateway gateway, int LogicId, int Type, string DeviceAddr, int Epoint, int GwId)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 2008 } };
 
        ////    var data = new JObject {
        ////        { "LogicId", LogicId },
        ////        { "Type", Type },
        ////        { "DeviceAddr", DeviceAddr },
        ////        { "Epoint", Epoint },
        ////        { "GwId", GwId }
        ////       };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("Logic/DelAction"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        ///// <summary>
        ///// 删除逻辑
        ///// </summary>
        ///// <param name="gateway">Gateway.</param>
        ///// <param name="LogicId">Logic identifier.</param>
        ////public static void LogicDelLogic(Shared.Device.ZbGateway gateway, int LogicId)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 2009 } };
 
        ////    var data = new JObject {
        ////        { "LogicId", LogicId }
        ////       };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("Logic/DelLogic"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        ///// <summary>
        ///// 推迟定时
        ///// </summary>
        ///// <param name="gateway">Gateway.</param>
        ///// <param name="LogicId">Logic identifier.</param>
        ////public static void LogicTimeDelayTrigger(Shared.Device.ZbGateway gateway, int LogicId, int ConditionId)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 2011 } };
 
        ////    var data = new JObject {
        ////        { "LogicId", LogicId },
        ////        { "LogicId", ConditionId }
        ////       };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("Logic/TimeDelayTrigger"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
 
        ///// <summary>
        ///// 执行逻辑动作
        ///// </summary>
        ///// <param name="gateway">Gateway.</param>
        ///// <param name="LogicId">Logic identifier.</param>
        ////public static void LogicTestActions(Shared.Device.ZbGateway gateway, int LogicId)
        ////{
        ////    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 2012 } };
 
        ////    var data = new JObject {
        ////        { "LogicId", LogicId }
        ////       };
        ////    jobject.Add("Data", data);
        ////    gateway.Send(("Logic/TestActions"), Common.SecuritySet.Encryption((jobject.ToString())));
        ////}
        //#endregion
 
        //#region 组
        /////<summary >
        /////Group
        ///// </summary>
        //public static void GroupID(ZigBee.Device.ZbGateway gateway)
        //{
        //    var jObject = new Newtonsoft.Json.Linq.JObject() {
        //                            { "Cluster_ID", 0 },
        //                            { "Command", 201 }
        //                        };
        //    gateway.Send("Group/GetNewId", Common.SecuritySet.Encryption(jObject.ToString()));
        //}
        //#endregion
 
        //#region 布防与撤防(用于主网关)
        /////<summary >
        /////管理员密码登陆
        ///// 对防区、布防模式的操作都需要管理员权限。所以要对防区和布防模式进行操作需先以安防管理员的身份进行登陆
        ///// </summary>
        //public static void SecurityAdminLogin(ZigBee.Device.ZbGateway gateway, string Password)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 4001 } };
        //    var data = new JObject { { "Password", Password } };
        //    jobject.Add("Data", data);
        //    gateway.Send(("Security/AdminLogin"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
        /////<summary >
        /////新建或修改防区
        /////需要管理员权限
        ///// </summary>
        //public static void SecurityAddNewZone(ZigBee.Device.ZbGateway gateway, int ZoneId, string ZoneName, int Bypass, int ZoneType, int ElasticBypass)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 4002 } };
        //    var data = new JObject { { "ZoneId", ZoneId }, { "ZoneName", ZoneName }, { "ZoneType", ZoneType }, { "Bypass", Bypass }, { "ElasticBypass", ElasticBypass } };
        //    jobject.Add("Data", data);
        //    gateway.Send(("Security/AddNewZone"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary >
        /////新建或修改防区
        /////需要管理员权限
        ///// </summary>
        //public static void SecurityAddEqToZone(ZigBee.Device.ZbGateway gateway, int ZoneId, string DeviceAddr, int Epoint, int MomentStatus, int TriggerZoneStatus)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 4003 } };
        //    var DeviceList = new JArray
        //                        {
        //                            new JObject {
        //                                { "DeviceAddr",DeviceAddr},
        //                                { "Epoint",Epoint},
        //            { "MomentStatus",MomentStatus},
        //            { "TriggerZoneStatus",TriggerZoneStatus}
        //                            }
        //                        };
        //    var data = new JObject { { "ZoneId", ZoneId }, { "DeviceList", DeviceList } };
        //    jobject.Add("Data", data);
        //    gateway.Send(("Security/AddEqToZone"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary >
        /////新建或修改布防模式
        ///// </summary>
        //public static void SecurityAddNewMode(ZigBee.Device.ZbGateway gateway, int ModeId, string ModeName, int AllowWithdraw, int AllowDisable, int AllowDelay)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 4004 } };
        //    var data = new JObject { { "ModeId", ModeId }, { "ModeName", ModeName }, { "AllowWithdraw", AllowWithdraw }, { "AllowDisable", AllowDisable }, { "AllowDelay", AllowDelay } };
        //    jobject.Add("Data", data);
        //    gateway.Send(("Security/AddNewMode"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
        //#endregion
    }
}