1
0

added interpretation of results

This commit is contained in:
Daniel Tartavel 2023-04-13 00:27:20 +02:00
parent 790562783a
commit 933c73dc04
10 changed files with 838 additions and 399 deletions

BIN
docs/Stack_zigbee_3.ods Normal file

Binary file not shown.

Binary file not shown.

View File

@ -13,10 +13,10 @@ int main(int argc, char *argv[])
ZigateBackend zigateBkd;
// zigbeemgr();
//QObject::connect(&zigbeemgr, SIGNAL(readyRead()), &zigbeemgr, SLOT(getData()));
//QObject::connect(&zigbeemgr, SIGNAL(bytesWritten(qint64)), &zigbeemgr, SLOT(confirmWrite(qint64)));
//QObject::connect(&zigateBkd, SIGNAL(readyRead()), &zigateBkd, SLOT(getData()));
// QObject::connect(&zigateBkd, SIGNAL(bytesWritten()), &zigateBkd, SLOT(confirmWrite()));
zigateBkd.sendCmd(zigateBkd.getVersion.at(0), zigateBkd.getVersion.at(1), zigateBkd.getVersion.at(2));
zigateBkd.sendCmd("0049","FFFC1E");
return a.exec();
//return a.exec();
}

View File

@ -1,9 +1,19 @@
#include "serial.inc.h"
#include <unistd.h>
extern QApplication a;
using namespace std;
ZigbeeMgr::ZigbeeMgr()
{
}
ZigbeeMgr::~ZigbeeMgr()
{
this->close();
}
void ZigbeeMgr::init()
{
//QMessageBox::StandardButton reply;
bool test;
@ -19,47 +29,51 @@ ZigbeeMgr::ZigbeeMgr()
if (!test)
{
cout << this->errorString().toStdString() << "=>" << this->serialDevicePath.toStdString() << endl;
/*QString str = "Device can not be openened : " + errorString() + "=>" + this->device;
reply = QMessageBox::question(
nullptr,
a.applicationName(),
str,
QMessageBox::Retry|QMessageBox::Abort,
QMessageBox::Retry
);
if (reply == QMessageBox::Abort)
{
exit(1);
}*/
sleep(5);
}
}while(!test);
}
ZigbeeMgr::~ZigbeeMgr()
{
this->close();
}
void ZigbeeMgr::getData()
{
dataRead = this->readAll();
cout << dataRead.toHex().toStdString() << endl;
}
void ZigbeeMgr::confirmWrite(qint16 byte)
{
QString str;
if (byte != dataWriteSize)
cout << "getData()" << endl;
if (this->waitForReadyRead(20000))
{
str = "Bytes written not egal to bytes sent : " + QString::number(byte) + " written for " + dataWriteSize + " sent";
cout << str.toStdString() << endl;
cout << "reading datas" << endl;
this->dataRead = this->readAll();
cout << this->dataRead.toHex().toStdString() << endl;
}else
{
cout << "Reading datas has timed out" << endl;
}
}
void ZigbeeMgr::write(QString datas)
void ZigbeeMgr::write(QByteArray msg)
{
dataWriteSize = datas.count();
this->writeData(datas.toStdString().c_str(), datas.count());
cout << "write" << endl;
dataWriteSize = msg.count();
cout << "size = " << dataWriteSize << endl;
this->writeData(msg, msg.count()+1);
cout << msg.toHex().toStdString() << endl;
}
bool ZigbeeMgr::findSerialDevice()
{
const auto serialPortInfos = QSerialPortInfo::availablePorts();
for (const QSerialPortInfo &portInfo : serialPortInfos)
{
cout << portInfo.serialNumber().toStdString() << this->deviceName.toStdString() << endl;
if (portInfo.serialNumber().contains(this->deviceName))
{
this->portName = portInfo.portName();
this->serialDevicePath = portInfo.systemLocation();
this->serialDeviceDescription = portInfo.description();
this->serialDeviceManufacturer = portInfo.manufacturer();
this->serialDeviceNumber = portInfo.serialNumber();
this->serialDeviceVendor = portInfo.vendorIdentifier();
this->serialDeviceProduct = portInfo.productIdentifier();
return true;
}
}
return false;
}

View File

@ -4,6 +4,7 @@
#include <QDebug>
#include <sys/wait.h>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QApplication>
#include <iostream>
@ -17,17 +18,22 @@ class ZigbeeMgr : public QSerialPort
QByteArray dataWrite;
qint64 dataWriteSize;
QString serialDevicePath;
//QAbstractButton * reply;
//QString serialDevicePath;
void write(QString datas);
QString deviceName;
QString portName;
QString serialDeviceDescription;
QString serialDeviceManufacturer;
QString serialDeviceNumber;
QString serialDeviceVendor;
QString serialDeviceProduct;
quint32 baudRate = 115200;
void write(QByteArray datas);
ZigbeeMgr();
~ZigbeeMgr();
void init();
void getData();
bool findSerialDevice();
private slots:
void getData();
void confirmWrite(qint16 byte);
};

6
version.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef VERSION_H
#define VERSION_H
QString version = "0.1";
#endif // VERSION_H

View File

@ -6,8 +6,9 @@ using namespace std;
ZigateBackend::ZigateBackend()
{
bool result;
cmdList["heartbeatEnable"].append({"0008", "0001", "0210"});
this->resultCodes.insert(0x8000, "Status");
this->deviceName = "ZIGATE";
while (1)
{
result = this->findSerialDevice();
@ -21,6 +22,8 @@ ZigateBackend::ZigateBackend()
sleep(10);
}
}
this->init();
this->resultCodes.insert(0x8000, "Status");
//resultCodes.insert();
}
@ -32,16 +35,20 @@ QByteArray ZigateBackend::checksum(QByteArray msgType, QByteArray length, QByteA
{
quint16 temp = 0;
int i;
QString str;
QString str = msgType.mid(0,2);
cout << str.toStdString() << endl;
temp ^= qFromLittleEndian<quint16>(msgType[0] + msgType[1]);
temp ^= qFromLittleEndian<quint16>(msgType[2] + msgType[3]);
temp ^= qFromLittleEndian<quint16>(length[0] + length[1]);
temp ^= qFromLittleEndian<quint16>(length[2] + length[3]);
str = msgType.mid(0,2);
temp ^= str.toInt(nullptr, 16);
str = msgType.mid(2,2);
temp ^= str.toInt(nullptr, 16);
str = length.mid(0,2);
temp ^= str.toInt(nullptr, 16);
str = length.mid(2,2);
temp ^= str.toInt(nullptr, 16);
for (i=0;i<=(datas.count());i+=2)
{
temp ^= qFromLittleEndian<quint16>(datas[i] + datas[i+1]);
str = datas.mid(i,2);
temp ^= str.toInt(nullptr, 16);
}
return QByteArray::number(temp, 16);
}
@ -59,25 +66,24 @@ QByteArray ZigateBackend::transcode(QByteArray datas)
for (i=0;i<datas.count();i+=2)
{
byte = datas.mid(i,2);
cout << byte.toStdString() << " => " << byte.toUInt(nullptr, 16) << endl;
if (byte.toUInt(nullptr, 16)>0x10)
if (byte.toUInt(nullptr, 16) > 15)
{
msg += byte;
}else
{
msg.append("02");
msg.append(QByteArray::number(byte.toUInt(nullptr, 16) ^ 0x10, 16));
msg.append(QByteArray::number(byte.toUInt(nullptr, 16) ^ 16, 16));
}
}
return msg;
}
void ZigateBackend::sendCmd(QByteArray cmd, QByteArray len, QByteArray datas)
void ZigateBackend::sendCmd(QByteArray cmd, QByteArray datas)
{
QByteArray msg;
QByteArray len;
len = QByteArray::number(datas.count()/2+1, 16).insert(0,"000").right(4);
msg = QByteArray::fromHex("01");
msg += QByteArray::fromHex(transcode(cmd));
msg += QByteArray::fromHex(transcode(len));
@ -89,26 +95,208 @@ void ZigateBackend::sendCmd(QByteArray cmd, QByteArray len, QByteArray datas)
msg += QByteArray::fromHex(checksum(cmd, len, "0"));
}
msg += QByteArray::fromHex("03");
cout << msg.toStdString() << endl;
}
bool ZigateBackend::findSerialDevice()
{
const auto serialPortInfos = QSerialPortInfo::availablePorts();
for (const QSerialPortInfo &portInfo : serialPortInfos)
cout << msg.toHex().toStdString() << endl;
this->write(msg);
if (!this->waitForBytesWritten(10000))
{
if (portInfo.serialNumber() == "ZIGATE+")
{
this->portName = portInfo.portName();
this->serialDevicePath = portInfo.systemLocation();
this->serialDeviceDescription = portInfo.description();
this->serialDeviceManufacturer = portInfo.manufacturer();
this->serialDeviceNumber = portInfo.serialNumber();
this->serialDeviceVendor = portInfo.vendorIdentifier();
this->serialDeviceProduct = portInfo.productIdentifier();
return true;
}
cout << "error : no acknoledge of bytes written" << endl;
}
return false;
this->getData();
this->interpretResult(this->dataRead);
}
uint ZigateBackend::interpretResult(QByteArray datas)
{
uint tab = 0;
int length = strlen(datas);
uint crctmp;
uint i;
int payloadLength;
QByteArray type;
QByteArray ln;
QByteArray crc;
QByteArray payload;
QByteArray quality;
if (length >= 12)
{
crctmp = 0;
//type de message
type = datas.mid(0, 4); //[0].$datas[1].$datas[2].$datas[3];
crctmp ^= datas.mid(0, 2).toUInt(); //[0].$datas[1]) ^ hexdec($datas[2].$datas[3]);
//taille message
ln = datas.mid(4, 4); // [4].$datas[5].$datas[6].$datas[7];
crctmp ^= datas.mid(4, 2).toUInt() ^ datas.mid(6, 2).toUInt();
//acquisition du CRC
crc = datas.mid(8, 2); //].$datas[9];
//payload
payload = "";
for(i=0;i<ln.toUInt();i++)
{
payload += datas.mid(10+(i*2), 2); //.$datas[10+(($i*2)+1)];
crctmp ^= datas.mid(10+(i*2), 2).toUInt(); //.$datas[10+(($i*2)+1)]);
}
quality = datas.mid(10+(i*2)-2, 2); //.$datas[10+($i*2)-1];
payloadLength = payload.count() - 2;
//verification du CRC
if (crc.toUInt() == crctmp)
{
//Traitement PAYLOAD
/*switch (type)
{
case "8000" :
echo " (Status)"."\n";
echo " Length: ".substr($payload,0,4)."\n";
echo " Status: ".substr($payload,4,2)."\n";
switch (substr($payload,4,2))
{
case "00":
{
echo " (Success)"."\n";
}
break;
case "01":
{
echo " (Incorrect Parameters)"."\n";
}
break;
case "02":
{
echo " (Unhandled Command)"."\n";
}
break;
case "03":
{
echo " (Command Failed)"."\n";
}
break;
case "04":
{
echo " (Busy)"."\n";
}
break;
case "05":
{
echo " (Stack Already Started)"."\n";
}
break;
default:
{
echo " (ZigBee Error Code)"."\n";
}
break;
}
echo "SQN: : ".substr($payload,6,2)."\n";
if (hexdec(substr($payload,0,4)) > 2)
{
echo " Message: ";
echo hex2str(substr($payload,8,strlen($payload)-2))."\n";
}
break;
case "8001" :
echo " (Log)";
echo "\n";
echo " Level: 0x".substr($payload,0,2);
echo "\n";
echo " Message: ";
echo hex2str(substr($payload,2,strlen($payload)-2))."\n";
break;
case "8010" :
echo "(Version)\n";
echo "Application : ".hexdec(substr($payload,0,4))."\n";
echo "SDK : ".hexdec(substr($payload,4,4))."\n";
break;
case "8102" :
echo "[".date("Y-m-d H:i:s")."]\n";
echo "(Attribute Report)\n";
echo "Src Addr : ".substr($payload,2,4)."\n";
echo "Cluster ID : ".substr($payload,8,4)."\n";
echo "Attr ID : ".substr($payload,12,4)."\n";
echo "Attr Type : ".substr($payload,16,4)."\n";
echo "Attr Size : ".substr($payload,20,4)."\n";
echo "Quality : ".$quality."\n";
if ((substr($payload,8,4)=="0000") && (substr($payload,12,4)=="0001"))
{
echo "DATAS: ".substr($payload,24,(strlen($payload)-24))."\n\n";
}elseif ((substr($payload,8,4)=="0000") && (substr($payload,12,4)=="0005"))
{
echo "DATAS: ".hex2str(substr($payload,24,(substr($payload,20,4))*2))."\n\n";
}else{
echo "DATAS: ".substr($payload,24,(substr($payload,20,4))*2)."\n\n";
}
break;
case "004d" :
echo "(Device announce)\n";
echo "Src Addr : ".substr($payload,0,4)."\n";
echo "IEEE : ".substr($payload,4,8)."\n";
echo "MAC capa : ".substr($payload,12,2)."\n";
echo "Quality : ".$quality;
break;
case "8702" :
echo "(APS Data Confirm Fail)\n";
echo "Status : ".substr($payload,0,2)."\n";
echo "Source Endpoint : ".substr($payload,2,2)."\n";
echo "Destination Endpoint : ".substr($payload,4,2)."\n";
echo "Destination Mode : ".substr($payload,6,2)."\n";
echo "Destination Address : ".substr($payload,8,4)."\n";
echo "SQN: : ".substr($payload,12,2)."\n";
break;
case "8101" :
echo "(Default Response)\n";
echo "SQN : ".substr($payload,0,2)."\n";
echo "EndPoint : ".substr($payload,2,2)."\n";
displayClusterId(substr($payload,4,4));
echo "Command : ".substr($payload,8,2)."\n";
echo "Status : ".substr($payload,10,2)."\n";
break;
case "8045" :
echo "(Active Endpoints Response)\n";
echo "SQN : ".substr($payload,0,2)."\n";
echo "Status : ".substr($payload,2,2)."\n";
echo "Short Address : ".substr($payload,4,4)."\n";
echo "Endpoint Count : ".substr($payload,8,2)."\n";
echo "Endpoint List :" ."\n";
for ($i = 0; $i < (intval(substr($payload,8,2)) *2); $i+=2)
{
echo "Endpoint : ".substr($payload,(8+$i),2)."\n";
}
break;
case "8043" :
echo "(Simple Descriptor Response)\n";
echo "SQN : ".substr($payload,0,2)."\n";
echo "Status : ".substr($payload,2,2)."\n";
echo "Short Address : ".substr($payload,4,4)."\n";
echo "Length : ".substr($payload,8,2)."\n";
if (intval(substr($payload,8,2))>0)
{
echo "Endpoint : ".substr($payload,10,2)."\n";
//PAS FINI
}
break;
default:
break;
}*/
}else
{
tab=-2;
}
}else
{
tab=-1;
}
return tab;
}

View File

@ -3,7 +3,6 @@
#include "serial.inc.h"
#include <QMap>
#include <QSerialPortInfo>
#include <QSerialPort>
//#include <QArray>
@ -15,25 +14,559 @@ class ZigateBackend : public ZigbeeMgr
Q_OBJECT
public:
QMap <int, QString> resultCodes;
QString portName;
QString serialDeviceDescription;
QString serialDeviceManufacturer;
QString serialDeviceNumber;
QString serialDeviceVendor;
QString serialDeviceProduct;
quint32 baudRate = 115200;
//ZigbeeMgr serial;
ZigateBackend();
~ZigateBackend();
QByteArray checksum(QByteArray msgType, QByteArray length, QByteArray datas);
QByteArray transcode(QByteArray datas);
void sendCmd(QByteArray cmd, QByteArray len, QByteArray datas);
bool findSerialDevice();
void sendCmd(QByteArray cmd, QByteArray datas);
uint interpretResult(QByteArray datas);
QMap <QString, QString> clusters
QMap <int, QString> resultCodes;
QMap <QString, QList <QByteArray>> cmdList =
{
{"setHeartBeat", {"0008", "0000", ""}},
{"getNetWorkState", {"0009", "0000", ""}},
{"getVersion", {"0010", "0000", ""}},
{"reset", {"0011", "0000", ""}},
{"erasePersistentData", {"0012", "0000", ""}},
{"factoryReset", {"0013", "0000", ""}},
{"permitJoin", {"0014", "0000", ""}},
{"setExpendedPANID", {"0020", "0008", ""}},
{"setChannelMask", {"0021", "0004", ""}},
{"setSecurityStateandKey", {"0022", "0000", ""}},
{"setDeviceType", {"0023", "0001", ""}},
{"startNetwork", {"0024", "0000", ""}},
{"startNetworkScan", {"0025", "0000", ""}},
{"removeDevice", {"0026", "0010", ""}},
{"enablePermissionsControlledJoins", {"0027", "0001", ""}},
{"authenticateDevice", {"0028", "0018", ""}},
{"outOfBandCommissioningDataRequest", {"0029", "0018", ""}},
{"userDescriptorSet", {"002B", "0000", ""}},
{"userDescritporRequest", {"002C", "0000", ""}},
{"bind", {"0030", "", ""}},
{"unbind", {"0031", "", ""}},
{"complexDescriptorRequest", {"0034", "0004", ""}},
{"networkAddressRequest", {"0040", "0012", ""}},
{"ieeeAddressRequest", {"0041", "0006", ""}},
{"nodeDescriptorRequest", {"0042", "0002", ""}},
{"simpleDescriptorRequest", {"0043", "0003", ""}},
{"powerDescriptorRequest", {"0044", "0002", ""}},
{"activeEndpointRequest", {"0045", "0002", ""}},
{"matchDescriptorRequest", {"0046", "", ""}},
{"managementLeaveRequest", {"0047", "001C", ""}},
{"permitJoiningRequest", {"0049", "0004", ""}},
{"managementNetworkUpdateRequest", {"004A", "000B", ""}},
{"systemServerDiscoveryRequest", {"004B", "0004", ""}},
{"managementLQIRequest", {"004E", "0003", ""}},
{"addGroup", {"0060", "0007", ""}},
{"viewGroup", {"0061", "0007", ""}},
{"getGroupMembership", {"0062", "", ""}},
{"removeGroup", {"0063", "0007", ""}},
{"removeAllGroups", {"0064", "0005", ""}},
{"addGroupIfIdentify", {"0065", "0007", ""}},
{"identifySend", {"0070", "0007", ""}},
{"identifyQuery", {"0071", "0005", ""}},
{"moveToLevel", {"0080", "0008", ""}},
{"moveToLevelWithWithoutOnOff", {"0081", "0009", ""}},
{"moveStep", {"0082", "000A", "0000"}},
{"moveStopMove", {"0083", "0005", ""}},
{"moveStopWithOnOff", {"0084", "0005", ""}},
{"onOffWithNoEffects", {"0092", "0006", ""}},
{"onOffTimedSend", {"0093", "000A", ""}},
{"onOffWithEffectsSend", {"0094", "0007", ""}},
{"viewScene", {"00A0", "0008", ""}},
{"addScene", {"00A1", "000D", ""}},
{"removeScene", {"00A2", "0008", ""}},
{"removeAllScenes", {"00A3", "0007", ""}},
{"storeScene", {"00A4", "0008", ""}},
{"recallScene", {"00A5", "0008", ""}},
{"sceneMembershipRequest", {"00A6", "0007", ""}},
{"addEnhancedScene", {"00A7", "", ""}},
{"viewEnhancedHostToNodeScene", {"00A8", "0008", ""}},
{"copyScene", {"00A9", "000C", ""}},
{"moveToHue", {"00B0", "0009", ""}},
{"moveHue", {"00B1", "0007", ""}},
{"stepHue", {"00B2", "0008", ""}},
{"moveToSaturation", {"00B3", "0008", ""}},
{"moveSaturation", {"00B4", "0006", ""}},
{"stepSaturation", {"00B5", "0008", ""}},
{"moveToHueAndSaturation", {"00B6", "0008", ""}},
{"moveToColour", {"00B7", "000B", ""}},
{"moveColour", {"00B8", "0009", ""}},
{"stepColour", {"00B9", "000B", ""}},
{"enhancedMoveToHue", {"00BA", "000A", ""}},
{"enhancedMoveHue", {"00BB", "0007", ""}},
{"enhancedStepHue", {"00BC", "0008", ""}},
{"enhancedMoveToHueAndSaturation", {"00BD", "000E", ""}},
{"colourLoopSet", {"00BE", "000D", ""}},
{"stopMoveStep", {"00BF", "0005", ""}},
{"moveToColourTemperature", {"00C0", "0009", ""}},
{"moveColourTemperature", {"00C1", "000D", ""}},
{"stepColourTemperature", {"00C2", "000E", ""}},
{"Initiate Touchlink", {"00D0", "0000", ""}},
{"touchLinkFactoryResetTarget", {"00D2", "0000", ""}},
{"identifyTriggerEffect", {"00E0", "0007", ""}},
{"lockUnlockDoor", {"00F0", "0006", ""}},
{"readAttributeRequest", {"0100", "", ""}},
{"writeAttributeRequest", {"0110", "000", ""}},
{"configureReportingRequest", {"0120", "", ""}},
{"attributeDiscoveryRequest", {"0140", "000E", ""}},
{"iASZoneEnrollResponse", {"0400", "0007", ""}},
{"rawApsDataRequest", {"0530", "000D", ""}}
};
const QMap <QByteArray, QMap <QString, QByteArray>> responseList //outerMap responseList
{
{
"004D",
{
{"Description", "Device announce"},
{"Short address", "00"}, // uint16_t
{"IEEE address", "0000"}, // uint64_t
{"MAC capability", "0"} // uint8_t
}
/*****************************************************************************
* MAC capability
* Bit 0 - Alternate PAN Coordinator
* Bit 1 - Device Type
* Bit 2 - Power source
* Bit 3 - Receiver On when Idle
* Bit 4,5 - Reserved
* Bit 6 - Security capability
* Bit 7 - Allocate Address
******************************************************************************/
},
{
"8000",
{
{"Description", "Status"},
{"Status", "0"}, // <uint8_t>
{"Sequence number", "0"}, // <uint8_t>
{"Packet Type", "00"}, // <uint16_t>
{"Optional additional error information", ""} // <string>
}
/*****************************************************************************
* Status :
* 0 = Success
* 1 = Incorrect parameters
* 2 = Unhandled command
* 3 = Command failed
* 4 = Busy (Node is carrying out a lengthy operation and is currently unable to handle the incoming command)
* 5 = Stack already started (no new configuration accepted)
* 128 244 = Failed (ZigBee event codes)
* Packet Type: The value of the initiating command request.
******************************************************************************/
},
{
"8001",
{
{"Description", "Log message"},
{"Log level", "0"}, // uint8_t
{"Log message", ""} // string
}
/*****************************************************************************
* Log Level :
* Use the Linux / Unix log levels
* 0 = Emergency
* 1 = Alert
* 2 = Critical
* 3 = Error
* 4 = Warning
* 5 = Notice
* 6 = Information
* 7 = Debug
******************************************************************************/
},
{
"8002",
{
{"Description", "Data indication"},
{"status", "0"}, // uint8_t
{"Profile ID", "00"}, // uint16_t
{"Cluster ID", "00"}, // uint16_t
{"Source endpoint", "0"}, // uint8_t
{"Destination endpoint", "0"}, // uint8_t
{"Source address mode", "0"}, // uint8_t
{"Source address", "0"}, // uint16_t or uint64_t
{"Destination address mode", "0"}, // uint8_t
{"Destination address", "0"}, // uint16_t or uint64_t
{"Payload size", "0"}, // uint8_t>
{"Payload", ""} // data each element is uint8_t
}
},
{
"8003",
{
{"Description", "Liste des clusters de l'objet"},
{"Source endpoint", "0"}, // uint8_t
{"Profile ID", "0"}, // uint16_t
{"Cluster list", ""}, // data each entry is uint16_t>
{"Source endpoint", "0"}, // uint8_t
{"Profile ID", "00"}, // uint16_t>
{"Cluster ID", "00"}, // uint16_t
{"Attribute list", ""} // data each entry is uint16_t>
}
},
{
"8004",
{
{"Description", "Liste des attributs de l'objet"},
{"Source endpoint", "0"}, // uint8_t
{"Profile ID", "00"}, // uint16_t
{"Cluster ID", "00"}, // uint16_t
{"Attribute list", ""} // data each entry is uint16_t>
}
},
{
"8005",
{
{"Description", "Liste des commandes de l'objet"},
{"Source endpoint", "0"}, // uint8_t
{"Profile ID", "0"}, // uint16_t
{"Cluster ID", "00"}, // uint16_t
{"Command ID list", ""} // data each entry is uint8_t>
}
},
{
"8006",
{
{"Description", "Status"},
{"Status", ""}
}
/*****************************************************************************
* 0 - STARTUP
* 2 - NFN_START
* 6 - RUNNING
* The node is provisioned from previous restart.
******************************************************************************/
},
{
"8007",
{
{"Description", "Status"},
{"Status", "0"}
}
/*****************************************************************************
* 0 - STARTUP
* 2 - NFN_START
* 6 - RUNNING
* The node is not yet provisioned.
******************************************************************************/
},
{
"8010",
{
{"Description", "Version list"},
{"Major version number", "00"}, // uint16_t
{"Installer version number", "00"} // uint16_t
}
},
{
"8014",
{
{"Description", "Permit join status response"},
{"Status", "0"} // bool_t
}
/*****************************************************************************
* 0 - Off
* 1 - On
******************************************************************************/
},
{
"8024",
{
{"Description", "Network joined/formed"},
{"Status", "0"}, // uint8_t
{"Short address", "00"}, // uint16_t
{"Extended address", "00"}, // uint64_t
{"Channel", "0"} // uint8_t
}
/*****************************************************************************
* Status:
* 0 = Joined existing network
* 1 = Formed new network
* 128 244 = Failed (ZigBee event codes)
******************************************************************************/
},
{
"8030",
{
{"Description", "Bind response"},
{"Sequence number", "0"}, // uint8_t
{"Status", "0"} // uint8_t
}
},
{
"8031",
{
{"Description", "Unbind response"},
{"Sequence number", "0"}, // uint8_t
{"Status", "0"} // uint8_t
}
},
{
"8040",
{
{"Description", "Network Address response"},
{"Sequence number", "0"}, // uin8_t
{"Status", "0"}, // uint8_t
{"IEEE address", "0"}, // uint64_t
{"Short address", "00"}, // uint16_t
{"Number of associated devices", "0"}, // uint8_t
{"Start index", "0"}, // uint8_t
{"Device list", ""} // data each entry is uint16_t>
}
},
{
"8041",
{
{"Description", "IEEE Address response"},
{"Sequence number", "0"}, // uin8_t
{"Status", "0"}, // uint8_t
{"IEEE address", "0000"}, // uint64_t
{"Short address", "00"}, // uint16_t
{"Number of associated devices", "0"}, // uint8_t
{"Start index", "0"}, // uint8_t
{"Device list", ""} // data each entry is uint16_t
}
},
{
"8042",
{
{"Description", "Node Descriptor response"},
{"Sequence number", "0"}, // uint8_t
{"Status", "0"}, // uint8_t
{"Network address", "0"}, // uint16_t
{"Manufacturer code", "00"}, // uint16_t
{"Max Rx Size", "00"}, // uint16_t
{"Max Tx Size", "00"}, // uint16_t
{"Server mask", "00"}, // uint16_t
{"Descriptor capability", "0"}, // uint8_t
{"Mac flags", "0"}, // uint8_t
{"Max buffer size", "0"}, // uint8_t
{"Bit fields", "00"} // uint16_t
}
/*****************************************************************************
* Bitfields:
* Logical type (bits 0-2
* 0 - Coordinator
* 1 - Router
* 2 - End Device)
* Complex descriptor available (bit 3)
* User descriptor available (bit 4)
* Reserved (bit 5-7)
* APS flags (bit 8-10 currently 0)
* Frequency band(11-15 set to 3 (2.4Ghz))
* Server mask bits:
* 0 - Primary trust center
* 1 - Back up trust center
* 2 - Primary binding cache
* 3 - Backup binding cache
* 4 - Primary discovery cache
* 5 - Backup discovery cache
* 6 - Network manager
* 7 to15 - Reserved
* MAC capability
* Bit 0 - Alternate PAN Coordinator
* Bit 1 - Device Type
* Bit 2 - Power source
* Bit 3 - Receiver On when Idle
* Bit 4-5 - Reserved
* Bit 6 - Security capability
* Bit 7 - Allocate Address
* Descriptor capability:
* 0 - extended Active endpoint list available
* 1 - Extended simple descriptor list available
* 2 to 7 - Reserved
******************************************************************************/
},
{
"8043",
{
{"Description", "Simple Descriptor response"},
{"Sequence number", "0"}, // uint8_t
{"Status", "0"}, // uint8_t
{"NwkAddress", "00"}, // uint16_t
{"Length", "0"}, // uint8_t
{"Endpoint", "0"}, // uint8_t
{"Profile", "00"}, // uint16_t
{"Device id", "00"}, // uint16_t
{"Bit fields", "0"}, // uint8_t
{"InClusterCount", "0"}, // uint8_t
{"In cluster list", ""}, // data each entry is uint16_t>
{"Out Cluster Count", ""}, // uint8_t
{"Out cluster list", ""} // data each entry is uint16_t
}
/*****************************************************************************
* Bit fields:
* Device version: 4 bits (bits 0-4)
* Reserved: 4 bits (bits4-7)
******************************************************************************/
},
{
"8044",
{
{"Description", "Power Descriptor response"},
{"Sequence number", "0"}, // uin8_t
{"Status", "0"}, // uint8_t
{"bit field", "0"} // uint16_t
}
/*****************************************************************************
* Bit fields
* 0 to 3: current power mode
* 4 to 7: available power source
* 8 to 11: current power source
* 12 to 15: current power source level
******************************************************************************/
},
{
"8045",
{
{"Description", "Active Endpoint response"},
{"Sequence number", "0"}, // uint8_t
{"Status", "0"}, // uint8_t
{"Address", "00"}, // uint16_t
{"Endpoint count", "0"}, // uint8_t
{"Active endpoint list", ""} // each data element of the type uint8_t
}
},
{
"8046",
{
{"Description", "Match Descriptor response"},
{"Sequence number", "0"}, // uint8_t
{"Status", "0"}, // uint8_t
{"Network address", "00"}, // uint16_t
{"Length of list", "0"}, // uint8_t
{"Match list", ""} // data each entry is uint8_t
}
},
{
"802B",
{
{"Description", "User Descriptor Notify"},
{"Sequence number", "0"}, // uin8_t
{"Status", "0"}, // uint8_t
{"Network address of interest", "00"} // uint16_t
}
},
{
"802C",
{
{"Description", "User Descriptor Response"},
{"Sequence number", "0"}, // uin8_t
{"Status", "0"}, // uint8_t
{"Network address of interest", "00"}, // uint16_6
{"Length", "0"}, // uint8_t
{"Data", ""} // uint8_t stream
}
},
{
"8034",
{
{"Description", "Complex Descriptor response"},
{"Sequence number", "0"}, // uin8_t
{"status", "0"}, // uint8_t
{"Network address of interest", "0"}, // uint16_t
{"Length", "0"}, // uint8_t
{"xml tag", "0"}, // uint8_t
{"field count", "0"}, // uint8_t
{"field values", ""} // uint8_t stream
}
},
{
"8047",
{
{"Description", "Management Leave response"},
{"Sequence number", "0"}, // uin8_t
{"Status", "0"} // uint8_t
}
},
{
"8048",
{
{"Description", "Leave indication"},
{"Extended address", "0000"}, // uint64_t
{"Rejoin status", "0"} // uint8_t
}
},
{
"804A",
{
{"Description", "Management Network Update response"},
{"Sequence number", "0"}, // uint8_t
{"Status", "0"}, // uint8_t
{"Total transmission", "00"}, // uint16_t
{"Transmission failures", "00"}, // uint16_t
{"Scanned channels", "0000"}, // uint32_t
{"Scanned channel list count", "0"}, // uint8_t
{"Channel list", "0"} // list each element is uint8_t
}
},
{
"804B",
{
{"Description", "System Server Discovery response"},
{"Sequence number", "0"}, // uint8_t
{"status", "0"}, // uint8_t
{"Server mask", "00"} // uint16_t
}
/********************************
* Bitmask according to spec". *
********************************/
},
{
"804E",
{
{"Description", "Management LQI response"},
{"Sequence number", "0"}, // uint8_t
{"status", "0"}, // uint8_t
{"Neighbour Table Entries ", "0"}, // uint8_t
{"Neighbour Table List Count ", "0"}, // uint8_t
{"Start Index ", "0"}, // uint8_t
{"List of Entries elements described below", ""}
}
/*****************************************************************************
* Note: If Neighbour Table list count is 0, there are no elements in the list.
* NWK Address : uint16_t
* Extended PAN ID : uint64_t
* IEEE Address : uint64_t
* Depth : uint_t
* Link Quality : uint8_t
* Bit map of attributes Described below: uint8_t
* bit 0-1 Device Type
* (0-Coordinator 1-Router 2-End Device)
* bit 2-3 Permit Join status
* (1- On 0-Off)
* bit 4-5 Relationship
* (0-Parent 1-Child 2-Sibling)
* bit 6-7 Rx On When Idle status
* (1-On 0-Off)
******************************************************************************/
},
{
"8140",
{
{"Description", "Attribute Discovery response"},
{"Complete", "0"}, // uint8_t
{"Attribute type", "0"}, // uint8_t
{"Attribute id", "00"} // uint16_t
}
/*****************************************************************************
* Complete:
* 0 more attributes to follow
* 1 this was the last attribute
******************************************************************************/
}
};
//ZigbeeMgr serial;
QMap <QByteArray, QString> clusters
{
{"0000", " (General: Basic)"},
{"0001", " (General: Power Config)"},
@ -65,314 +598,5 @@ class ZigateBackend : public ZigbeeMgr
{"FF02", " Xiaomi private"},
{"1234", " Xiaomi private"}
};
/*Zigate -> Obj 0x0008 Set heartBeat enable/disable (ZiGatev2 Firm v3.20) <enable/disable : uint8_t >
0 disable (by default)
1 enable
Status
*/
QList <QByteArray> heartbeatEnable = {"0008", "0001", "0210"};
/*Zigate -> Obj 0x0009 Get Network State (Firm v3.0d) Status
Network State Response
*/
QByteArray networkState = "0009";
/*
Zigate -> Obj 0x0010 Get Version Status
Version List
*/
QList <QByteArray> getVersion = {"0010", "0000", ""};
/*
Zigate -> Obj 0x0011 Reset Status, followed by chip reset
*/
QByteArray reset = "0011";
/*
Zigate -> Obj 0x0012 Erase Persistent Data Status
*/
QByteArray erasePersistentData = "0012";
/*
Zigate -> Obj 0x0013 ZLO/ZLL Factory New Reset No payload Status, followed by chip reset
Resets (Factory New) the Control Bridge but persists the frame counters.
*/
QByteArray factoryReset = "0013";
/*
Zigate -> Obj 0x0014 Permit Join Status, followed by Permit join status response
*/
QByteArray permitJoin = "0014";
/*
Zigate -> Obj 0x0015 Get devices list Get devices authentified in the ZiGates PDM. Status, followed by Get devices list response
*/
QByteArray getDevicesList = "0015";
/*
Zigate -> Obj 0x0016 Set Time server (v3.0f) <timestamp UTC: uQByteArray32_t> from 2000-01-01 00:00:00 Status
*/
QByteArray setTimeServer = "0016";
/*
Zigate -> Obj 0x0017 GetTime server (v3.0f) Status
Get_timer_server_response
*/
QByteArray getTimerServerResponse = "0017";
/*
Zigate -> Obj 0x0018 SetLed (v3.0f) <on/off : uint8_t >
0 Off
1- On
Status
*/
QByteArray setLed = "0018";
/*
Zigate -> Obj 0x0019 Set Certification (v3.0f) <type : uint8_t >
1- CE
2- FCC
Status
*/
QByteArray setCertification = "0019";
/*
Zigate -> Obj 0x0020 Set Expended PANID <64-bit Extended PAN ID:uint64_t> Status
*/
QByteArray setExpended = "0020";
/*
Zigate -> Obj 0x0021 Set Channel Mask <channel mask:uint32_t> Status
*/
QByteArray setChannelMask = "0021";
/*
Zigate -> Obj 0x0022 Set Security State + Key <key type: uint8_t> Status
<key: data>
*/
QByteArray setSecurityState = "0022";
/*
Zigate -> Obj 0x0023 Set device Type <device type: uint8_t> Status
Device Types:
0 = Coordinator
1 = Router
*/
QByteArray setDeviceType = "0023";
/*
Zigate -> Obj 0x0024 Start Network Status
Network Joined / Formed
*/
QByteArray startNetwork = "0024";
/*
Zigate -> Obj 0x0025 Start Network Scan Status
Network Joined / Formed
*/
QByteArray StartNetworkScan = "0025";
/*
Zigate -> Obj 0x0026 Remove Device <Parent IEEE address: uint64_t> Status
<Child IEEE address: uint64_t> Leave indication
*/
QByteArray removeDevice = "0026";
/*
Zigate -> Obj 0x0027 Enable Permissions Controlled Joins <Enable/Disable : uint8_t> Status
1 Enable
2 Disable
*/
QByteArray enablePermControlledJoins = "0027";
/*
Zigate -> Obj 0x0028 Authenticate Device <IEEE address "; uint64_t> Status
<Key : 16 elements byte each> Authenticate response
*/
QByteArray authenticateDevice = "0028";
/*
Zigate -> Obj 0x0029 Out of Band Commissioning Data Request <Address of interest : uint64_t> Status
<Key : 16 elements byte each> Out of Band Commissioning Data Response
*/
QByteArray outOfBandCDR = "0029";
/*
Zigate -> Obj 0x002B User Descriptor Set < target short address: uint16_t> Status
< Address of interest: uint16_t> User descriptor notify response
< string length: uint8_t>
<data: uint8_t stream >
*/
QByteArray userDescriptorSet = "002B";
/*
Zigate -> Obj 0x002C User Descritpor Request < target short address: uint16_t> Status
< Address of interest: uint16_t> User Descriptor response
*/
QByteArray userDescriptorRequest = "002C";
/*
Zigate -> Obj 0x0531 Complex Descriptor request < target short address: uint16_t> Status
< Address of interest: uint16_t> Complex Descriptor Response
*/
QByteArray complexDescriptorRequest = "0531";
/*Zigate -> Obj 0x0030 Bind <target extended address: uint64_t> Status
<target endpoint: uint8_t> Bind response
<cluster ID: uint16_t>
<destination address mode: uint8_t>
<destination address:uint16_t or uint64_t>
<destination endpoint (value ignored for group address): uint8_t>
*/
QByteArray bind = "0030";
/*
Zigate -> Obj 0x0031 Unbind <target extended address: uint64_t> Status
<target endpoint: uint8_t> Unbind response
<cluster ID: uint16_t>
<destination address mode: uint8_t>
<destination address: uint16_t or uint64_t>
<destination endpoint(value ignored for group address): uint8_t>
*/
QByteArray unBind = "0031";
/*
Zigate -> Obj 0x0040 Network Address request <target short address: uint16_t> <extended address:uint64_t> Status
<request type: uint8_t> Network Address response
<start index: uint8_t>
Request Type:
0 = Single Request
1 = Extended Request
*/
QByteArray networkAddressRequest = "0040";
/*
Zigate -> Obj 0x0041 IEEE Address request <target short address: uint16_t> Status
<short address: uint16_t> IEEE Address response
<request type: uint8_t>
<start index: uint8_t>
Request Type:
0 = Single
1 = Extended
*/
QByteArray ieeeAddressRequest = "0041";
/*
Zigate -> Obj 0x0042 Node Descriptor request <target short address: uint16_t> Status
Node Descriptor response
*/
QByteArray nodeDescriptorRequest = "0042";
/*
Zigate -> Obj 0x0043 Simple Descriptor request <target short address: uint16_t> Status
<endpoint: uint8_t> Simple Descriptor response
*/
QByteArray simpleDescriptorRequest = "0043";
/*
Zigate -> Obj 0x0044 Power Descriptor request <target short address: uint16_t> Status
Power Descriptor response
*/
QByteArray powerDescriptorRequest = "0044";
/*
Zigate -> Obj 0x0045 Active Endpoint request <target short address: uint16_t> Status
Active Endpoint response
*/
QByteArray activeEndpointRequest = "0045";
/*
Zigate -> Obj 0x0046 Match Descriptor request <target short address: uint16_t> Status
<profile id: uint16_t> Match Descriptor response
<number of input clusters: uint8_t>
<input cluster list:data: each entry is uint16_t >
<number of output clusters: uint8_t>
<output cluster list:data: each entry is uint16_t>
*/
QByteArray matchDescriptorRequest = "0046";
/*
Zigate -> Obj 0x0047 Management Leave request <target short address: uint16_t> Status
<extended address: uint64_t> Management Leave response
<Rejoin: uint8_t> Leave indication
<Remove Children: uint8_t>
Rejoin,
0 = Do not rejoin
1 = Rejoin
Remove Children
0 = Leave, do not remove children
1 = Leave, removing children
*/
QByteArray managementLeaveRequest = "0047";
/*
Zigate -> Obj 0x0049 Permit Joining request <target short address: uint16_t> Status
<interval: uint8_t>
<TCsignificance: uint8_t>
Target address: May be address of gateway node or broadcast (0xfffc)
Interval:
0 = Disable Joining
1 254 = Time in seconds to allow joins
255 = Allow all joins
TCsignificance:
0 = No change in authentication
1 = Authentication policy as spec
*/
QByteArray permitJoiningRequest = "0049";
/*
Zigate -> Obj 0x004A Management Network Update request <target short address: uint16_t> Status
<channel mask: uint32_t> Management Network Update response
<scan duration: uint8_t>
<scan count: uint8_t>
<network update ID: uint8_t>
<network manager short address: uint16_t>
Channel Mask:
Mask of channels to scan
Scan Duration:
0 0xFF Multiple of superframe duration.
Scan count:
Scan repeats 0 5
Network Update ID:
0 0xFF Transaction ID for scan
*/
QByteArray manaementNetworkUpdateRequest = "004A";
/*
Zigate -> Obj 0x004B System Server Discovery request <target short address: uint16_t> Status
<Server mask: uint16_t> System Server Discovery response
Bitmask according to spec.
*/
QByteArray systemServerDiscoveryRequest = "004B";
/*
Zigate -> Obj 0x004C Leave Request <extended address: uint64_t> Status
<Rejoin: uint8_t> Leave indication Leave indication (0x8048)
<Remove Children: uint8_t>
Rejoin,
0 = Do not rejoin
1 = Rejoin
Remove Children
0 = Leave, do not remove children
1 = Leave, removing children
*/
QByteArray leaveRequest = "004C";
/*
Zigate -> Obj 0x004E Management LQI request <Target Address : uint16_t> Status
<Start Index : uint8_t> Management LQI response
*/
QByteArray managementLqiRequest = "004E";
/*
Zigate -> Obj 0x0051 Free PDM internal address map table (From v.322 ZiGate+) Status
*/
QByteArray freePdmTable = "0051";
/*
Zigate -> Obj 0x0052 Get PDM child table size (From v.322 ZiGate+) Status
PDM child table size response
*/
QByteArray getPdmChildTableSize = "0052";
};
#endif // ZIGATEBACKEND_H

View File

@ -18,11 +18,12 @@ SOURCES += \
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
else: unix:!android: target.path = /usr/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
library.h \
main.h \
serial.inc.h \
version.h \
zigateBackend.h

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 9.0.1, 2023-04-08T05:18:14. -->
<!-- Written by QtCreator 9.0.1, 2023-04-13T00:23:41. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>