-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdeconz_cli_plugin.cpp
More file actions
1647 lines (1503 loc) · 60.6 KB
/
deconz_cli_plugin.cpp
File metadata and controls
1647 lines (1503 loc) · 60.6 KB
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
/*
* pilight_plugin.ccp
*
* Created on: Dec 18, 2016
* Author: ma-ca
*/
#include <QtPlugin>
#include <QtNetwork>
#include "deconz_cli_plugin.h"
#define MAX_STR 1000
#define TMP_STR 100
#define MAX_ATTR 0x0006
#define TCP_PORT 5008
/*! Plugin constructor.
\param parent - the parent object
*/
CliPlugin::CliPlugin(QObject *parent) : QObject(parent) {
// keep a pointer to the ApsController
m_apsCtrl = deCONZ::ApsController::instance();
DBG_Assert(m_apsCtrl != 0);
// APSDE-DATA.confirm handler
connect(m_apsCtrl, SIGNAL(apsdeDataConfirm(const deCONZ::ApsDataConfirm&)),
this, SLOT(apsdeDataConfirm(const deCONZ::ApsDataConfirm&)));
// APSDE-DATA.indication handler
connect(m_apsCtrl, SIGNAL(apsdeDataIndication(const deCONZ::ApsDataIndication&)),
this, SLOT(apsdeDataIndication(const deCONZ::ApsDataIndication&)));
m_isconnected = false;
m_readattr = false;
m_readclust = 0;
m_zdpmatchreq = false;
m_shortaddr = 0;
m_attrid = -1;
m_cluster = 0;
m_profile = 0;
m_zclSeq = 0;
m_ep = 0;
tcpServer = new QTcpServer(this);
if (!tcpServer->listen(QHostAddress::Any, TCP_PORT)) { // hardcoded listen port 5008
DBG_Printf(DBG_INFO, "Unable to start the server: %s\n", tcpServer->errorString().toStdString().data());
}
QString ipAddress;
QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
// use the first non-localhost IPv4 address
for (int i = 0; i < ipAddressesList.size(); ++i) {
if (ipAddressesList.at(i) != QHostAddress::LocalHost &&
ipAddressesList.at(i).toIPv4Address()) {
ipAddress = ipAddressesList.at(i).toString();
break;
}
}
// if we did not find one, use IPv4 localhost
if (ipAddress.isEmpty())
ipAddress = QHostAddress(QHostAddress::LocalHost).toString();
DBG_Printf(DBG_INFO, "The server is running on\n\nIP: %s port: %d\n\n",
ipAddress.toStdString().data(), tcpServer->serverPort());
connect(tcpServer, SIGNAL(newConnection()), this, SLOT(receiveCommand()));
}
/*! Deconstructor for plugin.
*/
CliPlugin::~CliPlugin() {
m_apsCtrl = 0;
}
/*! APSDE-DATA.indication callback.
\param ind - the indication primitive
\note Will be called from the main application for every incoming indication.
Any filtering for nodes, profiles, clusters must be handled by this plugin.
*/
void CliPlugin::apsdeDataIndication(const deCONZ::ApsDataIndication &ind) {
DBG_Printf(DBG_INFO,
"profileid %04X, clusterid %04X, srcEndpoint %02X, dstEndpoint %02X, status 0x%02X, securityStatus %02X\n",
ind.profileId(), ind.clusterId(), ind.srcEndpoint(), ind.dstEndpoint(), ind.status(), ind.securityStatus());
unsigned int i;
unsigned int length = ind.asdu().length();
int strlen = length * 3; // print each byte in hex (2 bytes) and one white space
char rawstr[strlen+1];
char strout[MAX_STR];
char strtmp[TMP_STR];
memset(rawstr, '\0', strlen + 1);
memset(strout, '\0', MAX_STR);
memset(strtmp, '\0', TMP_STR);
const char *raw = ind.asdu().data();
for (i = 0; i < length; i++) {
char rawtmp[4];
memset(rawtmp, '\0', 4);
snprintf(rawtmp, 4, "%02X ", *raw++);
strcat(rawstr, rawtmp);
}
strcat(rawstr, "\n");
DBG_Printf(DBG_INFO, "APS Ind %d, %s: %s", length, getApsIndSrcAddr(ind).c_str(), rawstr);
if (ind.status() != deCONZ::ApsSuccessStatus) {
DBG_Printf(DBG_INFO, "APS Ind ERROR status 0x%02X\n", ind.status());
return;
}
if (ind.clusterId() == 0x000A) {
DBG_Printf(DBG_INFO, "<-=======> handle Time Cluster <=================== \n");
}
if (ind.profileId() == ZDP_PROFILE_ID) { // handle ZDP response
switch(ind.clusterId()) {
case ZDP_SIMPLE_DESCRIPTOR_RSP_CLID:
handleZdpSimpleResponse(ind);
break;
case ZDP_ACTIVE_ENDPOINTS_RSP_CLID:
handleZdpActiveEpResponse(ind);
break;
case ZDP_MATCH_DESCRIPTOR_RSP_CLID:
handleZdpMatchResponse(ind);
break;
case ZDP_MGMT_LQI_RSP_CLID:
handleZdpLqiResponse(ind);
break;
case ZDP_MGMT_BIND_RSP_CLID:
handleZdpBindResponse(ind);
break;
case ZDP_POWER_DESCRIPTOR_RSP_CLID:
handleZdpPowerResponse(ind);
break;
case ZDP_NWK_ADDR_RSP_CLID:
handleZdpNwkAddrResponse(ind);
break;
default:
DBG_Printf(DBG_INFO, "ZDP clusterId = 0x%04X \n", ind.clusterId());
break;
}
return; // end ZDP response
}
// handle ZCL response
QDataStream stream(ind.asdu());
stream.setByteOrder(QDataStream::LittleEndian);
deCONZ::ZclFrame zclframe;
zclframe.readFromStream(stream);
if ((zclframe.frameControl() & 0x09) == 0x09 /*== 0x19 or 0x1D*/) { // ZclFCClusterCommand and ZclFCDirectionServerToClient or ZclFCManufacturerSpecific
handleZclServerToClientResponse(ind, zclframe);
return;
}
if ((zclframe.frameControl() & 0x08) == 0x08 /*== 0x18 or 0x1C*/) { // ZclFCProfileCommand or ZclFCManufacturerSpecific
switch(zclframe.commandId()) {
case deCONZ::ZclReadAttributesResponseId: // 0x01
handleZclReadAttrbuteResponse(ind, zclframe);
break;
case deCONZ::ZclReadReportingConfigResponseId: // 0x09
handleZclReportConfigResponse(ind, zclframe);
break;
case deCONZ::ZclReportAttributesId: // 0x0A
handleZclReportAttributeResponse(ind, zclframe);
break;
case deCONZ::ZclDiscoverAttributesResponseId: // 0x0D
handleZclDiscoverAttributesResponse(ind, zclframe);
break;
default:
DBG_Printf(DBG_INFO, "ZCL commandId = 0x%02X \n", zclframe.commandId());
break;
}
return; // end ZclFCProfileCommand
}
}
/*! APSDE-DATA.confirm callback.
\param conf - the confirm primitive
\note Will be called from the main application for each incoming confirmation,
even if the APSDE-DATA.request was not issued by this plugin.
*/
void CliPlugin::apsdeDataConfirm(const deCONZ::ApsDataConfirm &conf) {
std::list<deCONZ::ApsDataRequest>::iterator i = m_apsReqQueue.begin();
std::list<deCONZ::ApsDataRequest>::iterator end = m_apsReqQueue.end();
deCONZ::Address srcAddress = conf.dstAddress();
const deCONZ::ApsAddressMode srcAddressMode = conf.dstAddressMode();
char strtmp[TMP_STR], data[MAX_STR];
if (srcAddressMode == 0x3) { //!< 64-bit extended IEEE address mode
snprintf(strtmp, TMP_STR, "0x%016llX", srcAddress.ext());
} else if (srcAddressMode == 0x2) { //!< 16-bit short network address mode
snprintf(strtmp, TMP_STR, "0x%04X", srcAddress.nwk());
}
// search the list of currently active requests
// and check if the confirmation belongs to one of them
for (; i != end; ++i) {
if (i->id() == conf.id()) {
m_apsReqQueue.erase(i);
snprintf(data, MAX_STR,
"APS-DATA.confirm status 0x%02X, id = 0x%02X, srcEp = 0x%02X, dstcEp = 0x%02X, dstAddr = %s\n",
conf.status(), conf.id(), conf.srcEndpoint(), conf.dstEndpoint(), strtmp);
if (conf.status() != deCONZ::ApsSuccessStatus) {
snprintf(data, MAX_STR,
"<-APS-DATA.confirm FAILED status 0x%02X, id = 0x%02X, srcEp = 0x%02X, dstcEp = 0x%02X, dstAddr = %s\n",
conf.status(), conf.id(), conf.srcEndpoint(), conf.dstEndpoint(), strtmp);
writeToConnectedClients(data);
}
DBG_Printf(DBG_INFO, "%s", data);
return;
}
}
}
/*! get APS Ind source address in 64-Bit or 16-Bit string
*/
std::string CliPlugin::getApsIndSrcAddr(const deCONZ::ApsDataIndication &ind) {
char straddr[19];
if (ind.srcAddressMode() == 0x3) { //!< 64-bit extended IEEE address mode
sprintf(straddr, "0x%016llX", ind.srcAddress().ext());
return std::string(straddr);
} else if (ind.srcAddressMode() == 0x2) { //!< 16-bit short network address mode
sprintf(straddr, "0x%04X", ind.srcAddress().nwk());
return std::string(straddr);
}
return std::string(); // empty string
}
/*! get Cluster ID name
*/
const char *CliPlugin::getClusterName(uint16_t clusterid) {
switch (clusterid) {
case 0x0000: return "BASIC_CLUSTER_ID"; //!<Basic cluster Id
case 0x0001: return "POWER_CONFIGURATION_CLUSTER_ID"; //!<Power configuration cluster Id
case 0x0003: return "IDENTIFY_CLUSTER_ID"; //!<Identify cluster Id
case 0x0004: return "GROUPS_CLUSTER_ID"; //!<Groups cluster Id
case 0x0005: return "SCENES_CLUSTER_ID"; //!<Scenes cluster Id
case 0x0006: return "ONOFF_CLUSTER_ID"; //!<OnOff cluster id
case 0x0007: return "ONOFF_SWITCH_CONFIGURATION_CLUSTER_ID"; //!<OnOff Switch Configuration cluster id
case 0x0008: return "LEVEL_CONTROL_CLUSTER_ID"; //!<Level Control cluster id
case 0x0009: return "ALARMS_CLUSTER_ID"; //!<Alarm cluster id
case 0x000a: return "TIME_CLUSTER_ID"; //!<Time cluster Id
case 0x0019: return "OTAU_CLUSTER_ID"; //!<OTAU cluster Id
case 0x0201: return "THERMOSTAT_CLUSTER_ID"; //!<Thermostat cluster Id
case 0x0202: return "FAN_CONTROL_CLUSTER_ID"; //!<Fan control cluster Id
case 0x0204: return "THERMOSTAT_UI_CONF_CLUSTER_ID"; //!<Thermostat ui conf cluster Id
/* Lighting */
case 0x0300: return "COLOR_CONTROL_CLUSTER_ID"; //!<Color Control cluster id
case 0x0400: return "ILLUMINANCE_MEASUREMENT_CLUSTER_ID"; //!<Illuminance Sensing cluster id
case 0x0402: return "TEMPERATURE_MEASUREMENT_CLUSTER_ID"; //!<Temperature measurement cluster id
case 0x0405: return "HUMIDITY_MEASUREMENT_CLUSTER_ID"; //!<Humidity measurement cluster id
case 0x0406: return "OCCUPANCY_SENSING_CLUSTER_ID"; //!<Occupancy Sensing cluster id
/* Security & Safety */
case 0x0500: return "IAS_ZONE_CLUSTER_ID"; //!<IAS Zone Cluster id
case 0x0501: return "IAS_ACE_CLUSTER_ID"; //!<IAS ACE Cluster id
case 0x0600: return "GENERIC_TUNNEL_CLUSTER_ID"; //!<Generic tunnel cluster Id
case 0x0601: return "BACNET_PROTOCOL_TUNNEL_CLUSTER_ID"; //!<BACnet protocol tunnel cluster Id
/* Smart Energy Profile specific clusters */
case 0x0700: return "PRICE_CLUSTER_ID"; //!<Price cluster Id
case 0x0701: return "DEMAND_RESPONSE_AND_LOAD_CONTROL_CLUSTER_ID"; //!<Demand Response and Load Control cluster Id
case 0x0702: return "SIMPLE_METERING_CLUSTER_ID"; //!<Simple Metering cluster Id
case 0x0703: return "MESSAGE_CLUSTER_ID"; //!<Message Cluster Id
case 0x0704: return "ZCL_SE_TUNNEL_CLUSTER_ID"; //!<Smart Energy Tunneling (Complex Metering)
case 0x0800: return "ZCL_KEY_ESTABLISHMENT_CLUSTER_ID"; //!<ZCL Key Establishment Cluster Id
case 0x0b05: return "DIAGNOSTICS_CLUSTER_ID"; //!<Diagnostics cluster Id
/* Light Link Profile clusters */
case 0x1000: return "ZLL_COMMISSIONING_CLUSTER_ID"; //!<ZLL Commissioning Cluster Id
/* Manufacturer specific clusters */
case 0xFF00: return "LINK_INFO_CLUSTER_ID"; //!<Link Info cluster id
default: return "unknown";
}
}
/*! get Attribute Type ID name
*/
const char *CliPlugin::getAttributeTypeIdName(uint8_t attrtypeid) {
switch(attrtypeid) {
case 0x00: return "NoData";
case 0x08: return "8BitData";
case 0x09: return "16BitData";
case 0x0a: return "24BitData";
case 0x0b: return "32BitData";
case 0x0c: return "40BitData";
case 0x0d: return "48BitData";
case 0x0e: return "56BitData";
case 0x0f: return "64BitData";
case 0x10: return "Boolean";
case 0x18: return "8BitBitMap";
case 0x19: return "16BitBitMap";
case 0x1a: return "24BitBitMap";
case 0x1b: return "32BitBitMap";
case 0x1c: return "40BitBitMap";
case 0x1d: return "48BitBitMap";
case 0x1e: return "56BitBitMap";
case 0x1f: return "64BitBitMap";
case 0x20: return "8BitUint";
case 0x21: return "16BitUint";
case 0x22: return "24BitUint";
case 0x23: return "32BitUint";
case 0x24: return "40BitUint";
case 0x25: return "48BitUint";
case 0x26: return "56BitUint";
case 0x27: return "64BitUint";
case 0x28: return "8BitInt";
case 0x29: return "16BitInt";
case 0x2a: return "24BitInt";
case 0x2b: return "32BitInt";
case 0x2c: return "40BitInt";
case 0x2d: return "48BitInt";
case 0x2e: return "56BitInt";
case 0x2f: return "64BitInt";
case 0x30: return "8BitEnum";
case 0x31: return "16BitEnum";
case 0x41: return "OctedString";
case 0x42: return "CharacterString";
case 0x43: return "LongOctedString";
case 0x44: return "LongCharacterString";
case 0x48: return "Array";
case 0xe0: return "TimeOfDay";
case 0xe1: return "Date";
case 0xe2: return "UtcTime";
case 0xe8: return "ClusterId";
case 0xe9: return "AttributeId";
case 0xea: return "BACNetOId";
case 0xf0: return "IeeeAddress";
case 0xf1: return "128BitSecurityKey";
default: return "unknown";
}
}
/*! Handles a simple descriptor request response. (ClusterID = 0x8004)
\param ind a Simple_Desc_rsp ZigBee specification 2.4.4.1.5
*/
void CliPlugin::handleZdpSimpleResponse(const deCONZ::ApsDataIndication &ind) {
unsigned int i;
char strout[MAX_STR];
memset(strout, '\0', MAX_STR);
char strtmp[TMP_STR];
memset(strtmp, '\0', TMP_STR);
const char *simpleraw = ind.asdu().data();
if (ind.asdu().length() > 2) {
simpleraw++; // skip sequence number
uint8_t zdpstatus = *simpleraw++; //!< Result of a ZDP request.
uint16_t *nwkAddr = (uint16_t *) simpleraw; //!< NWK address of the simple descriptor request
simpleraw += 2;
uint8_t length = *simpleraw; //!< Length
if (length > 0) {
simpleraw++;
uint8_t endpoint = *simpleraw++; //!<
uint16_t *AppProfileId = (uint16_t *) simpleraw; //!< The application profile identifier field
simpleraw += 2;
uint16_t *AppDeviceId = (uint16_t *) simpleraw; //!< The application device identifier
simpleraw += 2;
uint8_t AppDeviceVersion = *simpleraw++; //!< The application device identifier field
uint8_t AppInClustersCount = *simpleraw++; //!< The application input cluster count
snprintf(strtmp, TMP_STR, "<-CLUSTER %s 0x%04X ep 0x%02X profile 0x%04X deviceid 0x%04X deviceversion 0x%02X\n",
getApsIndSrcAddr(ind).c_str(), *nwkAddr, endpoint, *AppProfileId, *AppDeviceId, AppDeviceVersion);
int x = snprintf(strout, MAX_STR, strtmp);
for (i = 0; i < AppInClustersCount; i++) {
uint16_t *clusterid = (uint16_t *) simpleraw;
snprintf(strtmp, TMP_STR, "<-CLUSTER %s 0x%04X 0x%02X In 0x%04X %s\n",
getApsIndSrcAddr(ind).c_str(), *nwkAddr, endpoint, *clusterid, getClusterName(*clusterid));
x += snprintf(&strout[x], MAX_STR-x, strtmp);
simpleraw += 2;
}
uint8_t AppOutClustersCount = *simpleraw++; //!< The application output cluster count
for (i = 0; i < AppOutClustersCount; i++) {
uint16_t *clusterid = (uint16_t *) simpleraw;
snprintf(strtmp, TMP_STR, "<-CLUSTER %s 0x%04X 0x%02X Out 0x%04X %s\n",
getApsIndSrcAddr(ind).c_str(), *nwkAddr, endpoint, *clusterid, getClusterName(*clusterid));
x += snprintf(&strout[x], MAX_STR-x, strtmp);
simpleraw += 2;
}
} else {
snprintf(strtmp, TMP_STR, "<-CLUSTER %s response error 0x%04X length = %d ", getApsIndSrcAddr(ind).c_str(), *nwkAddr, length);
strcat(strout, strtmp);
switch(zdpstatus) {
case 0x00: snprintf(strtmp, TMP_STR, "SUCCESS\n"); break;
case 0x80: snprintf(strtmp, TMP_STR, "INVALID_REQUEST\n"); break;
case 0x81: snprintf(strtmp, TMP_STR, "DEVICE_NOT_FOUND\n"); break;
case 0x82: snprintf(strtmp, TMP_STR, "INVALID_EP\n"); break;
case 0x83: snprintf(strtmp, TMP_STR, "NOT_ACTIVE\n"); break;
case 0x89: snprintf(strtmp, TMP_STR, "NO_DESCRIPTOR\n"); break;
default: snprintf(strtmp, TMP_STR, "status = 0x%02X\n", zdpstatus);
}
strcat(strout, strtmp);
}
DBG_Printf(DBG_INFO, "%s", strout);
if (m_isconnected) {
writeToConnectedClients(strout);
}
} else {
snprintf(strtmp, TMP_STR, "<-CLUSTER %s response error\n", getApsIndSrcAddr(ind).c_str());
strcat(strout, strtmp);
}
}
/*! Handles an active endpoint request response.
\param ind a ZDP Active_EP_rsp ZigBee specification 2.4.4.1.6
*/
void CliPlugin::handleZdpActiveEpResponse(const deCONZ::ApsDataIndication &ind) {
unsigned int i;
char strout[MAX_STR];
memset(strout, '\0', MAX_STR);
char strtmp[TMP_STR];
memset(strtmp, '\0', TMP_STR);
const char *epraw = ind.asdu().data();
if (ind.asdu().length() > 2) {
epraw += 2;
uint16_t *nwkAddr = (uint16_t *) epraw; //!< NWK address of the active endpoints request
epraw += 2;
uint8_t activeEPCount = *epraw; //!< Count of active endpoints on the remote device.
for (i = 0; i < activeEPCount; i++) {
epraw++;
snprintf(strtmp, TMP_STR, "<-EP %s 0x%04X %3d (%02X)\n", getApsIndSrcAddr(ind).c_str(), *nwkAddr, *epraw, *epraw);
strcat(strout, strtmp);
}
DBG_Printf(DBG_INFO, "%s", strout);
if (m_isconnected) {
writeToConnectedClients(strout);
}
}
}
/*! Handles an match request response.
\param ind a ZDP Match_Desc_rsp ZigBee specification 2.4.4.1.7
*/
void CliPlugin::handleZdpMatchResponse(const deCONZ::ApsDataIndication &ind) {
unsigned int i;
char strout[MAX_STR];
memset(strout, '\0', MAX_STR);
char strtmp[TMP_STR];
memset(strtmp, '\0', TMP_STR);
const char *matchraw = ind.asdu().data();
if (ind.asdu().length() >= 2) {
if (ind.asdu().length() >= 6) {
matchraw += 2; // skip 2 bytes
uint16_t *nwkAddr = (uint16_t *) matchraw;
matchraw += 2;
uint8_t matchLength = *matchraw;
for (i = 0; i < matchLength; i++) {
matchraw++;
snprintf(strtmp, TMP_STR, "<-ZDP match %s 0x%04X %3d 0x%04X 0x%04X\n",
getApsIndSrcAddr(ind).c_str(), *nwkAddr, *matchraw, m_cluster, m_profile);
strcat(strout, strtmp);
}
} else {
uint8_t seqNum = *matchraw++; //!< Sequence number of a ZDP command
uint8_t zdpstatus = *matchraw; //!< Result of a ZDP request.
snprintf(strout, MAX_STR, "<-ZDP match %s seqNum = 0x%02X zdpstatus = 0x%02X\n",
getApsIndSrcAddr(ind).c_str(), seqNum, zdpstatus);
}
DBG_Printf(DBG_INFO, "%s", strout);
if (m_isconnected) {
writeToConnectedClients(strout);
}
}
}
/*! Handles an LQI request response.
\param ind a ZDP Mgmt_Lqi_rsp ZigBee specification 2.4.4.3.2
*/
void CliPlugin::handleZdpLqiResponse(const deCONZ::ApsDataIndication &ind) {
unsigned int i;
char strout[MAX_STR];
memset(strout, '\0', MAX_STR);
char strtmp[TMP_STR];
memset(strtmp, '\0', TMP_STR);
snprintf(strout, MAX_STR, "<-LQI %s %3d", getApsIndSrcAddr(ind).c_str(), ind.srcEndpoint());
const char *lqiraw = ind.asdu().data();
if (ind.asdu().length() >= 27) {
lqiraw += 2 ; // skip 2 bytes
uint8_t neighborTableEntries = *lqiraw++;
uint8_t startIndex = *lqiraw++;
uint8_t neighborTableListCount = *lqiraw++;
lqiraw += 8; // skip Ext PANID
uint64_t *extAddr = (uint64_t *) lqiraw;
lqiraw += 8;
uint16_t *networkAddr = (uint16_t *) lqiraw;
lqiraw += 2;
snprintf(strtmp, TMP_STR, "%d %d %d 0x%016llX 0x%04X ",
neighborTableEntries, startIndex, neighborTableListCount, *extAddr, *networkAddr);
strcat(strout, strtmp);
uint8_t deviceType = *lqiraw & 0x03; // 0000 00xx 0=CO, 1=RD, 2=ED, 3=unknown
uint8_t rxOnWhenIdle = (*lqiraw >> 2) & 0x03; // 0000 xx00 0=no, 1=yes, 2=unknown
uint8_t relationship = (*lqiraw >> 4) & 0x07; // 0xxx 0000 parent/child/sibling/none/previous child
snprintf(strtmp, TMP_STR, "%u %u %u ", deviceType, rxOnWhenIdle, relationship);
strcat(strout, strtmp);
lqiraw++;
for (i = 0; i < 3; i++) { // depth lqi
snprintf(strtmp, TMP_STR, "%02X ", *lqiraw++); // print hex
strcat(strout, strtmp);
}
strcat(strout, "\n");
DBG_Printf(DBG_INFO, "%s", strout);
if (m_isconnected) {
writeToConnectedClients(strout);
}
}
}
/*! Handles an Bind request response.
\param ind a ZDP Mgmt_Bind_rsp ZigBee specification 2.4.4.3.4
*/
void CliPlugin::handleZdpBindResponse(const deCONZ::ApsDataIndication &ind) {
unsigned int i;
char strout[MAX_STR];
memset(strout, '\0', MAX_STR);
char strtmp[TMP_STR];
memset(strtmp, '\0', TMP_STR);
const char *bindraw = ind.asdu().data();
if (ind.asdu().length() >= 18) {
bindraw += 2 ; // skip 2 bytes
uint8_t bindingTableEntries = *bindraw++;
uint8_t startIndex = *bindraw++;
uint8_t bindingTableListCount = *bindraw;
for (i = 0; i < bindingTableListCount; i++) { // read bind table entries
snprintf(strout, MAX_STR, "<-BIND %s ", getApsIndSrcAddr(ind).c_str());
bindraw++;
uint64_t *srcAddr = (uint64_t *) bindraw;
bindraw += 8;
uint8_t srcEndpoint = *bindraw++;
uint16_t *clusterId = (uint16_t *) bindraw;
bindraw += 2;
uint8_t dstAddrMode = *bindraw++;
snprintf(strtmp, TMP_STR, "%d %d %d 0x%016llX 0x%02X 0x%04X ",
bindingTableEntries, startIndex, bindingTableListCount, *srcAddr, srcEndpoint, *clusterId);
strcat(strout, strtmp);
if (dstAddrMode == 0x03) { // 0x03 = 64-bit extended address for dstAddr and dstEndpoint present
uint64_t *dstExtAddr = (uint64_t *) bindraw;
bindraw += 8;
uint8_t dstEndpoint = *bindraw;
snprintf(strtmp, TMP_STR, "0x%016llX 0x%02X", *dstExtAddr, dstEndpoint);
strcat(strout, strtmp);
} else if (dstAddrMode == 0x01) { //0x01 = 16-bit group address for dstAddr and dstEndoint not present
uint16_t *dstGroupAddr = (uint16_t *) bindraw;
snprintf(strtmp, TMP_STR, "0x%04X", *dstGroupAddr);
strcat(strout, strtmp);
bindraw++; // move pointer to end
}
strcat(strout, "\n");
DBG_Printf(DBG_INFO, "%s", strout);
if (m_isconnected) {
writeToConnectedClients(strout);
}
}
} else if (ind.asdu().length() > 2) {
bindraw += 2;
unsigned int bindrawlen = ind.asdu().length() - 2;
snprintf(strout, MAX_STR, "BIND %s ", getApsIndSrcAddr(ind).c_str());
for (i = 0; i < bindrawlen; i++) {
bindraw++;
snprintf(strtmp, TMP_STR, "%02X ", *bindraw);
strcat(strout, strtmp);
}
strcat(strout, "\n");
DBG_Printf(DBG_INFO, "%s", strout);
if (m_isconnected) {
writeToConnectedClients(strout);
}
}
}
/*! Handles an power descriptor request response.
\param ind a ZDP Power_Desc_rsp ZigBee specification 2.4.4.2.4
*/
void CliPlugin::handleZdpPowerResponse(const deCONZ::ApsDataIndication &ind) {
char strout[MAX_STR];
memset(strout, '\0', MAX_STR);
char strtmp[TMP_STR];
memset(strtmp, '\0', TMP_STR);
snprintf(strout, MAX_STR, "<-POWER %s ", getApsIndSrcAddr(ind).c_str());
const char *powraw = ind.asdu().data();
if (ind.asdu().length() > 2) {
powraw++; // skip sequence number
uint8_t zdpstatus = *powraw++; //!< Result of a ZDP request.
uint16_t *nwkAddr = (uint16_t *) powraw; //!< NWK address of the active endpoints request
powraw += 2;
snprintf(strtmp, TMP_STR, "0x%04X", *nwkAddr);
strcat(strout, strtmp);
if (zdpstatus != 0) {
// SUCCESS, DEVICE_NOT_FOUND, INV_REQUESTTYPE or NO_DESCRIPTOR
switch(zdpstatus) {
case 0x80:
snprintf(strtmp, TMP_STR, " INV_REQUESTTYPE");
break;
case 0x81:
snprintf(strtmp, TMP_STR, " DEVICE_NOT_FOUND");
break;
case 0x89:
snprintf(strtmp, TMP_STR, " NO_DESCRIPTOR");
break;
default:
break;
}
} else {
// Power descriptor 4 x 4 bits
int powmode = *powraw & 0x0F; // Current power mode
int availsrc = (*(powraw++) & 0xF0) >> 4; // Available power sources
int cursrc = *powraw & 0x0F; // Current power source
int powlevel= (*powraw & 0xF0) >> 4; // Current power source level
snprintf(strtmp, TMP_STR, " %X %X %X", powmode, availsrc, cursrc);
strcat(strout, strtmp);
// 0, 33%, 66%, 100%
switch (powlevel) {
case 0x00:
snprintf(strtmp, TMP_STR, " 0");
break;
case 0x04:
snprintf(strtmp, TMP_STR, " 33");
break;
case 0x08:
snprintf(strtmp, TMP_STR, " 66");
break;
case 0x0C:
snprintf(strtmp, TMP_STR, " 100");
break;
default:
break;
}
}
strcat(strout, strtmp);
snprintf(strtmp, TMP_STR, "\n");
strcat(strout, strtmp);
DBG_Printf(DBG_INFO, "%s", strout);
if (m_isconnected) {
writeToConnectedClients(strout);
}
}
}
/*! Handles a NWK_addr_req (ClusterID=0x0000) request response.
\param ind a ZDP NWK_addr_resp ZigBee specification 2.4.4.2.1
*/
void CliPlugin::handleZdpNwkAddrResponse(const deCONZ::ApsDataIndication &ind) {
char strout[MAX_STR];
memset(strout, '\0', MAX_STR);
char strtmp[TMP_STR];
memset(strtmp, '\0', TMP_STR);
snprintf(strout, MAX_STR, "<-NWK %s ", getApsIndSrcAddr(ind).c_str());
const char *nwkraw = ind.asdu().data();
if (ind.asdu().length() > 2) {
nwkraw++; // skip sequence number
uint8_t zdpstatus = *nwkraw++; //!< Result of a ZDP request.
if (zdpstatus != 0) {
// SUCCESS, INV_REQUESTTYPE, or DEVICE_NOT_FOUND
switch(zdpstatus) {
case 0x80:
snprintf(strtmp, TMP_STR, "INV_REQUESTTYPE ");
break;
case 0x81:
snprintf(strtmp, TMP_STR, "DEVICE_NOT_FOUND ");
break;
default:
break;
}
strcat(strout, strtmp);
}
uint64_t *extAddr = (uint64_t *) nwkraw; // IEEEAddr RemoteDev
nwkraw += 8;
uint16_t *nwkAddr = (uint16_t *) nwkraw; //!< NWK address of the remote device
snprintf(strtmp, TMP_STR, "0x%016llX 0x%04X", *extAddr, *nwkAddr);
strcat(strout, strtmp);
snprintf(strtmp, TMP_STR, "\n");
strcat(strout, strtmp);
DBG_Printf(DBG_INFO, "%s", strout);
if (m_isconnected) {
writeToConnectedClients(strout);
}
}
}
/*! Handles a ZCL Read Attribute Response
\param ind a ZDP Active_EP_rsp
*/
void CliPlugin::handleZclReadAttrbuteResponse(const deCONZ::ApsDataIndication &ind,
const deCONZ::ZclFrame &zclframe) {
char strout[MAX_STR];
memset(strout, '\0', MAX_STR);
char strtmp[TMP_STR];
memset(strtmp, '\0', TMP_STR);
const char *respvalue = zclframe.payload().data();
const char *endvalue = respvalue + zclframe.payload().length();
uint16_t *attrid = (uint16_t *) respvalue;
respvalue += 3; // skip attribute id and status
bool writestrout = true;
if (zclframe.payload().length() > 3) {
uint8_t type = *respvalue++; // ZCL attribute typeid
if (m_readattr && ind.clusterId() == 0x0000 && m_zclSeq == zclframe.sequenceNumber()) {
snprintf(strout, MAX_STR, "<-ZCL attr 0x%04X %d 0x%04X 0x%04X ",
m_shortaddr, ind.srcEndpoint(), m_readclust, *attrid);
} else {
snprintf(strout, MAX_STR, "<-APS attr %s %d 0x%04X 0x%04X 0x%02X ",
getApsIndSrcAddr(ind).c_str(), ind.srcEndpoint(), ind.clusterId(), *attrid, type);
}
if (0x42 == type) { // type 0x42 string
uint8_t stringlength = *respvalue++;
const char *endstring = respvalue + stringlength;
while (respvalue < endstring) {
snprintf(strtmp, TMP_STR, "%c", *respvalue++); // print char
strcat(strout, strtmp);
}
} else {
while (respvalue < endvalue) {
snprintf(strtmp, TMP_STR, "%02X ", *respvalue++); // print hex
strcat(strout, strtmp);
}
}
} else { // error
if (m_readattr && ind.clusterId() == 0x0000 && m_zclSeq == zclframe.sequenceNumber()) {
snprintf(strout, MAX_STR, "<-ZCL attr 0x%04X %d 0x%04X 0x%04X unknown",
m_shortaddr, ind.srcEndpoint(), m_readclust, *attrid);
} else {
writestrout = false;
snprintf(strout, MAX_STR, "APS attr %s %d 0x%04X 0x%04X error ",
strtmp, ind.srcEndpoint(), ind.clusterId(), *attrid);
}
}
strcat(strout, "\n");
DBG_Printf(DBG_INFO, "%s", strout);
if (m_isconnected && writestrout) {
writeToConnectedClients(strout);
}
// start next read attribute request if Basic Cluster
if (m_readattr
&& ind.clusterId() == 0x0000
&& *attrid == m_attrid
&& m_zclSeq == zclframe.sequenceNumber()) {
if (m_attrid < MAX_ATTR) {
m_attrid++;
sendZclReadAttributeRequest(m_shortaddr, m_ep, 0x0000, m_attrid);
} else if (m_attrid != 0x4000) {
m_attrid = 0x4000;
sendZclReadAttributeRequest(m_shortaddr, m_ep, 0x0000, m_attrid);
} else {
m_readattr = false;
m_readclust = 0;
}
}
}
/*! Handles a ZCL Report Config request response.
\param ind a ZDP Active_EP_rsp
*/
void CliPlugin::handleZclReportConfigResponse(const deCONZ::ApsDataIndication &ind,
const deCONZ::ZclFrame &zclframe) {
char strout[MAX_STR];
memset(strout, '\0', MAX_STR);
char strtmp[TMP_STR];
memset(strtmp, '\0', TMP_STR);
const char *respvalue = zclframe.payload().data();
const char *endvalue = respvalue + zclframe.payload().length();
snprintf(strout, MAX_STR, "<-REP config %s %d 0x%04X ",
getApsIndSrcAddr(ind).c_str(), ind.srcEndpoint(), ind.clusterId());
uint8_t zclstatus = *respvalue++;
if (zclstatus != 0x00) {
switch(zclstatus) {
case 0x86:
snprintf(strtmp, TMP_STR, "UNSUPPORTED_ATTRIBUTE ");
break;
case 0x8C:
snprintf(strtmp, TMP_STR, "UNREPORTABLE_ATTRIBUTE ");
break;
default:
snprintf(strtmp, TMP_STR, "zcl error status = 0x%02X: ", zclstatus);
break;
}
strcat(strout, strtmp);
} else {
uint8_t direction = *respvalue++;
uint16_t *attributeId = (uint16_t *) respvalue;
respvalue += 2;
uint8_t attributeType = *respvalue++;
uint16_t *minReportingInterval = (uint16_t *) respvalue;
respvalue += 2;
uint16_t *maxReportingInterval = (uint16_t *) respvalue;
respvalue += 2;
snprintf(strtmp, TMP_STR, "dir %02X min %d max %d id 0x%04X type 0x%02X ",
direction, *minReportingInterval, *maxReportingInterval, *attributeId, attributeType);
strcat(strout, strtmp);
}
while (respvalue < endvalue) {
snprintf(strtmp, TMP_STR, "%02X ", *respvalue++); // print hex
strcat(strout, strtmp);
}
strcat(strout, "\n");
DBG_Printf(DBG_INFO, "%s", strout);
if (m_isconnected) {
writeToConnectedClients(strout);
}
}
/*! Handles a ZCL Report Attribute response.
\param ind a ZDP Active_EP_rsp
*/
void CliPlugin::handleZclReportAttributeResponse(const deCONZ::ApsDataIndication &ind,
const deCONZ::ZclFrame &zclframe) {
char strout[MAX_STR];
memset(strout, '\0', MAX_STR);
char strtmp[TMP_STR];
memset(strtmp, '\0', TMP_STR);
const char *respvalue = zclframe.payload().data();
const char *endvalue = respvalue + zclframe.payload().length();
snprintf(strout, MAX_STR,
"<-ZCL attribute report %s 0x%04X %d ", getApsIndSrcAddr(ind).c_str(), ind.clusterId(), ind.srcEndpoint());
while (respvalue < endvalue) {
snprintf(strtmp, TMP_STR, "%02X ", *respvalue++); // print hex
strcat(strout, strtmp);
}
strcat(strout, "\n");
DBG_Printf(DBG_INFO, "%s", strout);
if (m_isconnected) {
writeToConnectedClients(strout);
}
if (!(zclframe.frameControl() & deCONZ::ZclFCDisableDefaultResponse)) {
sendZclDefaultResponse(ind, zclframe, deCONZ::ZclSuccessStatus);
}
}
/*! Handles a ZCL Discover Attributes response.
\param ind ZCL
*/
void CliPlugin::handleZclDiscoverAttributesResponse(const deCONZ::ApsDataIndication &ind,
const deCONZ::ZclFrame &zclframe) {
char strout[MAX_STR];
memset(strout, '\0', MAX_STR);
char strtmp[TMP_STR];
memset(strtmp, '\0', TMP_STR);
const char *respvalue = zclframe.payload().data();
const char *endvalue = respvalue + zclframe.payload().length();
uint8_t discoveryComplete = *respvalue; //!< A value of 0 indicates that there are some more attributes to be discovered
int x = snprintf(strout, MAX_STR, "<-ZCL discover attr %s for cluster 0x%04X discoveryComplete = %s\n ",
getApsIndSrcAddr(ind).c_str(), ind.clusterId(), discoveryComplete ? "Yes" : "No");
while (respvalue + 3 < endvalue) {
respvalue++;
uint16_t *attributeId = (uint16_t *) respvalue;
respvalue += 2;
uint8_t typeId = *respvalue;
snprintf(strtmp, TMP_STR, "<-ZCL discover attr %s 0x%04X 0x%04X 0x%02X %s\n ",
getApsIndSrcAddr(ind).c_str(), ind.clusterId(), *attributeId, typeId, getAttributeTypeIdName(typeId));
x += snprintf(&strout[x], MAX_STR-x, strtmp);
}
DBG_Printf(DBG_INFO, "%s", strout);
if (m_isconnected) {
writeToConnectedClients(strout);
}
}
/*! Handles a ZCL Server To Client response.
\param ind ZCL
*/
void CliPlugin::handleZclServerToClientResponse(const deCONZ::ApsDataIndication &ind,
const deCONZ::ZclFrame &zclframe) {
char strout[MAX_STR];
memset(strout, '\0', MAX_STR);
char strtmp[TMP_STR];
memset(strtmp, '\0', TMP_STR);
const char *respvalue = zclframe.payload().data();
const char *endvalue = respvalue + zclframe.payload().length();
snprintf(strout, MAX_STR,
"<-ZCL serverToClient %s %d for cluster 0x%04X ",
getApsIndSrcAddr(ind).c_str(), ind.srcEndpoint(), ind.clusterId());
if (zclframe.frameControl() & 0x04) { // manufacturer specific
snprintf(strtmp, TMP_STR, "manufacturer 0x%04X ", zclframe.manufacturerCode());
strcat(strout, strtmp);
}
while (respvalue < endvalue) {
snprintf(strtmp, TMP_STR, "%02X ", *respvalue++); // print hex
strcat(strout, strtmp);
}
strcat(strout, "\n");
DBG_Printf(DBG_INFO, "%s", strout);
if (m_isconnected) {
writeToConnectedClients(strout);
}
}
/*! deCONZ will ask this plugin which features are supported.
\param feature - feature to be checked
\return true if supported
*/
bool CliPlugin::hasFeature(Features feature) {
switch (feature)
{
default:
break;
}
return false;
}
/*! Returns the name of this plugin.
*/
const char *CliPlugin::name() {
return "deConz CLI Plugin";
}
/*! Process incoming TCP request
*/
void CliPlugin::receiveCommand() {
DBG_Printf(DBG_INFO, "receiveCommand\n");
QTcpSocket *socket = tcpServer->nextPendingConnection();
clientConnection.append(socket);
connect(socket, SIGNAL(readyRead()),
this, SLOT(readReceivedBytes()));
connect(socket, SIGNAL(disconnected()),
this, SLOT(clientDisconnected()));
connect(socket, SIGNAL(disconnected()),
socket, SLOT(deleteLater()));
m_isconnected = true;
}
/*! Client has disconnected
*/
void CliPlugin::clientDisconnected() {
for (int i = 0; i < clientConnection.size(); i++) {
if (clientConnection.at(i)->state() != QAbstractSocket::ConnectedState) {
DBG_Printf(DBG_INFO, "clientDisconnected %d\n", i);
clientConnection.takeAt(i);
}
}
if (clientConnection.isEmpty()) {
m_isconnected = false;
}
}
/*! Read from data from socket
*/
void CliPlugin::readReceivedBytes() {
deCONZ::Address addr;
bool result = false;
char data[MAX_STR];
memset(data, '\0', MAX_STR);
DBG_Printf(DBG_INFO, "readReceivedBytes clientConnection.size() = %d \n", clientConnection.size());
QTcpSocket *socket = static_cast<QTcpSocket *>(sender());
if (socket->bytesAvailable() > 0) {
int len = socket->read(data, MAX_STR);
DBG_Printf(DBG_INFO, "readReceivedBytes %d bytes: %s\n", len, data);
}
writeToConnectedClients(data);
char command[MAX_STR];
memset(command, '\0', MAX_STR);
int shortaddr = -1, profile = -1, ep = -1, cluster = -1, attrid = -1, manu = 0;
if (sscanf(data, "r %x %d %x %x", &shortaddr, &ep, &cluster, &attrid) == 4) {
DBG_Printf(DBG_INFO, "read attribute on %x %d %x %x\n", shortaddr, ep, cluster, attrid);
result = sendZclReadAttributeRequest(shortaddr, ep, cluster, attrid);
}
if (sscanf(data, "zclattr %x %d %x %s", &shortaddr, &ep, &cluster, command) == 4) {
DBG_Printf(DBG_INFO, "zclattr on %x %d %x %s\n", shortaddr, ep, cluster, command);
addr.setNwk(shortaddr);
result = sendZclAttributeRequest(shortaddr, ep, cluster, QByteArray::fromHex(command));
}
if (sscanf(data, "zclattrmanu %x %d %x %x %s", &shortaddr, &ep, &cluster, &manu, command) == 5) {
DBG_Printf(DBG_INFO, "zclattrmanu on %x %d %x %x %s\n", shortaddr, ep, cluster, manu, command);
addr.setNwk(shortaddr);
result = sendZclAttributeManuSpecRequest(shortaddr, ep, cluster, QByteArray::fromHex(command), manu);
}
if (sscanf(data, "zclcmd %x %d %x %s", &shortaddr, &ep, &cluster, command) == 4) {
DBG_Printf(DBG_INFO, "zclcmd on %x %d %x %s\n", shortaddr, ep, cluster, command);
addr.setNwk(shortaddr);
result = sendZclCmdRequest(addr, ep, cluster, QByteArray::fromHex(command));
}
if (sscanf(data, "zclcmdgrp %x %d %x %s", &shortaddr, &ep, &cluster, command) == 4) {
DBG_Printf(DBG_INFO, "zclcmdgrp on %x %d %x %s\n", shortaddr, ep, cluster, command);
addr.setGroup(shortaddr);
result = sendZclCmdRequest(addr, ep, cluster, QByteArray::fromHex(command));
}
if (sscanf(data, "zclcmdmanu %x %d %x %x %s", &shortaddr, &ep, &cluster, &manu, command) == 5) {
DBG_Printf(DBG_INFO, "zclcmdmanu on %x %d %x %s\n", shortaddr, ep, cluster, command, manu);
addr.setNwk(shortaddr);
result = sendZclCmdManuSpecRequest(addr, ep, cluster, QByteArray::fromHex(command), manu);
}
if (sscanf(data, "b %x %d %x", &shortaddr, &ep, &cluster) == 3) {
DBG_Printf(DBG_INFO, "read basic attributes on %x %d 0x%04X\n", shortaddr, ep, cluster);
m_readclust = cluster;
}
if (sscanf(data, "b %x %d", &shortaddr, &ep) == 2) {
DBG_Printf(DBG_INFO, "read basic attributes on %x %d\n", shortaddr, ep);