1
0
This repository has been archived on 2023-11-30. You can view files and clone it, but cannot push or open issues or pull requests.
dtux__zigbeemanager/zigateBackend.h
2023-04-08 15:06:36 +02:00

379 lines
12 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef ZIGATEBACKEND_H
#define ZIGATEBACKEND_H
#include "serial.inc.h"
#include <QMap>
#include <QSerialPortInfo>
#include <QSerialPort>
//#include <QArray>
class ZigbeeMgr;
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();
QMap <QString, QString> clusters
{
{"0000", " (General: Basic)"},
{"0001", " (General: Power Config)"},
{"0002", " (General: Temperature Config)"},
{"0003", " (General: Identify)"},
{"0004", " (General: Groups)"},
{"0005", " (General: Scenes)"},
{"0006", " (General: On/Off)"},
{"0007", " (General: On/Off Config)"},
{"0008", " (General: Level Control)"},
{"0009", " (General: Alarms)"},
{"000A", " (General: Time)"},
{"000F", " (General: Binary Input Basic)"},
{"0020", " (General: Poll Control)"},
{"0019", " (General: OTA)"},
{"0101", " (General: Door Lock"},
{"0201", " (HVAC: Thermostat)"},
{"0202", " (HVAC: Fan Control)"},
{"0300", " (Lighting: Color Control)"},
{"0400", " (Measurement: Illuminance)"},
{"0402", " (Measurement: Temperature)"},
{"0405", " (Measurement: Humidity)"},
{"0406", " (Measurement: Occupancy Sensing)"},
{"0500", " (Security & Safety: IAS Zone)"},
{"0702", " (Smart Energy: Metering)"},
{"0B05", " (Misc: Diagnostics)"},
{"1000", " (ZLL: Commissioning)"},
{"FF01", " Xiaomi private"},
{"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