diff --git a/zigateplugin/responseClasses.h b/zigateplugin/responseClasses.h new file mode 100644 index 0000000..9c4233f --- /dev/null +++ b/zigateplugin/responseClasses.h @@ -0,0 +1,73 @@ +#ifndef RESPONSECLASSES_H +#define RESPONSECLASSES_H +#include +#include +#include +#include +#include +#include +//#include "zigateplugin.h" + +//void (*propertyManager)(QByteArray); +class ZigatePlugin; +class Response +{ +public: + QByteArray code; + QByteArray datas; + QString description; + void manager(Response *); +}; + +class ResponseProperties +{ +public: + QByteArray code; + QByteArray datas; + QString description; + QMap > properties; + QMap > propertyDetail; + QHash propertyManagerList; + void (*manager)(ResponseProperties *); +}; + +void infoOutput(ResponseProperties *); +void defaultManager(ResponseProperties *); +//void (*manager)(Response *); +void macCapabilityManager(QByteArray); +//void deviceAnnounceManager(ResponseProperties *); +//void commandReturnStatusManager(ResponseProperties *); +//void logMessageManager(ResponseProperties *); +//void dataIndicationManager(ResponseProperties *); +void clustersListManager(ResponseProperties *); +//void attributesListManager(ResponseProperties *); +//void commandsListManager(ResponseProperties *); +//void statusManager(ResponseProperties *); +//void status2Manager(ResponseProperties *); +//void versionListManager(ResponseProperties *); +//void permitJoinManager(ResponseProperties *); +//void networkJoinedFormedManager(ResponseProperties *); +//void bindResponseManager(ResponseProperties *); +//void unbindResponseManager(ResponseProperties *); +//void networkAddressManager(ResponseProperties *); +void iEEEAddressManager(ResponseProperties *); +void nodeDescriptorManager(ResponseProperties *); +void simpleDescriptorManager(ResponseProperties *); +//void powerDescriptorManager(ResponseProperties *); +//void activeEndpointManager(ResponseProperties *); +//void matchDescriptorManager(ResponseProperties *); +//void userDescriptorNotifyManager(ResponseProperties *); +//void userDescriptorManager(ResponseProperties *); +//void complexDescriptorManager(ResponseProperties *); +//void managementLeaveManager(ResponseProperties *); +//void leaveIndicationManager(ResponseProperties *); +//void managementNetworkUpdateManager(ResponseProperties *); +//void systemServerDiscoveryManager(ResponseProperties *); +//void managementLQIManager(ResponseProperties *); +//void attributeDiscoveryManager(ResponseProperties *); +void deviceListManager(ResponseProperties *); +void networkAddressManager(ResponseProperties *); +void dataIndicationManager(ResponseProperties *); +void macCapabilityManager(QByteArray mac); + +#endif // RESPONSECLASSES_H diff --git a/zigateplugin/serial.cpp b/zigateplugin/serial.cpp new file mode 100644 index 0000000..6f662e2 --- /dev/null +++ b/zigateplugin/serial.cpp @@ -0,0 +1,124 @@ +#include "serial.h" +#include +#include "zigateplugin.h" +#include + +//extern QApplication a; +extern ZigatePlugin zigatePlugin; +extern SerialManager serialManager; + +using namespace std; + +SerialManager::SerialManager() +{ +} + +SerialManager::~SerialManager() +{ + this->close(); +} + +void SerialManager::initSerial() +{ + + this->setBaudRate(115200); + this->setDataBits(QSerialPort::Data8); + this->setStopBits(QSerialPort::OneStop); + this->setParity(QSerialPort::NoParity); + + openSerialPort(); +} + +// open serial port and return true when it is available +bool SerialManager::openSerialPort() +{ + bool result; + bool test = false; + + while (1) + { + result = this->findSerialDevice(); + this->setPortName(this->serialDevicePath); + if (result) + { + cout << "Device found :" + this->serialDevicePath.toStdString() << endl; + break; + }else + { + cout << "Device not found, waiting 10 seconds before retrying" << endl; + sleep(10); + } + } + + while(!test or !this->isOpen()) + { + test = this->open(QIODevice::ReadWrite); + if (!test) + { + cout << "opening device: " << this->errorString().toStdString() << "=>" << this->serialDevicePath.toStdString() << endl; + sleep(5); + } + }; + return true; +} + +// launch the thread which read datas on serial port +void ZigatePlugin::readDatas() +{ + + serialManager.dataRead = serialManager.readAll(); + //cout << "reading datas" << serialManager.dataRead.toHex(' ').toStdString() << endl; + zigatePlugin.interpretResult(serialManager.dataRead); +} + +void SerialManager::write2serial(QByteArray msg) +{ + cout << "writing to serial" << endl; + dataWriteSize = msg.count(); + cout << "size = " << dataWriteSize << endl; + this->write((const QByteArray)msg); + cout << msg.toHex().toStdString() << endl; +} + +bool SerialManager::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; +} + +void SerialManager::serialError(QSerialPort::SerialPortError error) +{ + cout << "error code : " << error << this->errorString().toStdString() << "=>" << this->serialDevicePath.toStdString() << endl; + + switch (error) + { + case 0: + case 3: + return; + break; + case 1: + case 9: + cout << "error code : " << error << this->errorString().toStdString() << "=>" << this->serialDevicePath.toStdString() << endl; + this->close(); + openSerialPort(); + break; + default: + cout << "error code : " << error << this->errorString().toStdString() << "=>" << this->serialDevicePath.toStdString() << endl; + break; + } +} diff --git a/zigateplugin/serial.h b/zigateplugin/serial.h new file mode 100644 index 0000000..5dae8c7 --- /dev/null +++ b/zigateplugin/serial.h @@ -0,0 +1,48 @@ +#ifndef SERIAL_INC_H +#define SERIAL_INC_H + +//#include +#include +#include +#include +//#include +#include + +class SerialManager : public QSerialPort +{ + Q_OBJECT + + public: + //QSerialPort * sp; + QByteArray dataRead; + QByteArray dataWrite; + qint64 dataWriteSize; + QString serialDevicePath; + QString deviceName; + QString portName; + QString serialDeviceDescription; + QString serialDeviceManufacturer; + QString serialDeviceNumber; + QString serialDeviceVendor; + QString serialDeviceProduct; + quint32 baudRate = 115200; + + SerialManager(); + ~SerialManager(); + + void initSerial(); + bool findSerialDevice(); + bool openSerialPort(); + void write2serial(QByteArray); + + //void getData(); + + signals: + void datasReady(QByteArray); + + public slots: + void serialError(QSerialPort::SerialPortError); +}; + + +#endif // SERIAL_INC_H diff --git a/zigateplugin/version.h b/zigateplugin/version.h new file mode 100644 index 0000000..2c93008 --- /dev/null +++ b/zigateplugin/version.h @@ -0,0 +1,8 @@ +#ifndef VERSION_H +#define VERSION_H + +QString version = "0.1"; + + +#endif // VERSION_H + diff --git a/zigateplugin/zigateInit.cpp b/zigateplugin/zigateInit.cpp new file mode 100644 index 0000000..1aa584e --- /dev/null +++ b/zigateplugin/zigateInit.cpp @@ -0,0 +1,720 @@ +#include "zigateplugin.h" +#include "serial.h" +#include "interface.h" +#include + +extern ZigatePlugin zigatePlugin; +extern SerialManager serialManager; + +//extern QHash responseListIndex; + +using namespace std; +extern QHash responseListIndex; + +bool ZigatePlugin::initPlugin() +{ + bool returnCode = false; + ResponseProperties * temp; + QHash::iterator i; + + for (i = responseListIndex.begin(); i != responseListIndex.end(); ++i) + // init lists + //for(i=0;i=responseListIndex.count;i++) + { + temp = new ResponseProperties(); + temp->manager = defaultManager; + i.value() = temp; + } + + temp = responseListIndex["004D"]; + temp->code = QByteArray::fromHex("004D"); + temp->description = "Device announce"; + temp->properties = + { + // {rang, {designation, nbyte, isvalue}} + // isvalue = 0 => display value + // = 1 => is array of bits + // = 2 => is index of string in list + // = 3 => launch a subroutine pointed by propertyManagerList + // = 4 => is a list of objects + {0, {"Short address", 2, 0}}, // uint16_t + {1, {"IEEE address", 4, 0}}, // uint64_t + {2, {"MAC capability", 1, 3}} + }; + temp->propertyManagerList[2] = &macCapabilityManager; + temp->manager = &defaultManager; + temp->propertyDetail[2] = + { + {1, "Alternate PAN Coordinator"}, + {2, "Device Type"}, + {4, "Power source"}, + {8, "Receiver On when Idle"}, + {64, "Security capability"}, + {128, "Allocate Address"} + }; + // ***************************************************************************** + // 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 + // ****************************************************************************** + + temp = responseListIndex["8000"]; + temp->code = QByteArray::fromHex("8000"); + temp->description = "Status returned by command"; + temp->properties = + { + {0, {"Status", 1, 2}}, // + {1, {"Sequence number", 1, 0}}, // + {2, {"Packet Type", 2, 0}}, // + {3, {"Optional additional error information", -1, 5}} // + }; + temp->manager = &defaultManager; + temp->propertyDetail[0] = + { + {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)"}, + {-1, "Failed"} + }; + // ***************************************************************************** + // // 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. + // ****************************************************************************** + + temp = responseListIndex["8001"]; + temp->code = QByteArray::fromHex("8001"); + temp->description = "Log message"; + temp->properties = + { + {0, {"Log level", 1, 2}}, // uint8_t + {1, {"Log message", -1, 5}} // string + }; + temp->manager = &defaultManager; + temp->propertyDetail[0] = + { + {0, "Emergency"}, + {1, "Alert"}, + {2, "Critical"}, + {3, "Error"}, + {4, "Warning"}, + {5, "Notice"}, + {6, "Information"}, + {7, "Debug"} + }; + // ********************************************************************************* + // 0 = Emergency + // 1 = Alert + // 2 = Critical + // 3 = Error + // 4 = Warning + // 5 = Notice + // 6 = Information + // 7 = Debug + // ********************************************************************************* + temp = responseListIndex["8002"]; + temp->code = QByteArray::fromHex("8002"); + temp->description = "Data indication"; + temp->properties = + { + {0, {"status", 1, 1}}, // uint8_t + {1, {"Profile ID", 2, 0}}, // uint16_t + {2, {"Cluster ID", 2, 0}}, // uint16_t + {3, {"Source endpoint", 1, 0}}, // uint8_t + {4, {"Destination endpoint", 1, 0}}, // uint8_t + {5, {"Source address mode", 1, 0}}, // uint8_t TODO + {6, {"Source address", 2, 0}}, // uint16_t or uint64_t + {7, {"Destination address mode", 0, 0}}, // uint8_t TODO + {8, {"Destination address", 2, 0}}, // uint16_t or uint64_t + {9, {"Payload size", 1, 0}}, // uint8_t + {10, {"Payload", -1, 0}} // data each element is uint8_t + }; + temp->manager = &defaultManager; //dataIndicationManager + + temp = responseListIndex["8003"]; + temp->code = QByteArray::fromHex("8003"); + temp->description = "list of object's clusters"; + temp->properties = + { + {0, {"Source endpoint", 1, 0}}, // uint8_t + {1, {"Profile ID", 2, 0}}, // uint16_t + {2, {"Cluster list", 0, 0}}, // data each entry is uint16_t + {3, {"Source endpoint", 1, 0}}, // uint8_t + {4, {"Profile ID", 2, 0}}, // uint16_t + {5, {"Cluster ID", 2, 0}}, // uint16_t + {6, {"Attribute list", 2, 0}} // data each entry is uint16_t + }; + temp->manager = &clustersListManager; + + temp = responseListIndex["8004"]; + temp->code = QByteArray::fromHex("8004"); + temp->description = "list of object's attributes"; + temp->properties = + { + {0, {"Source endpoint", 1, 0}}, // uint8_t + {1, {"Profile ID", 2, 0}}, // uint16_t + {2, {"Cluster ID", 2, 0}}, // uint16_t + {3, {"Attribute list", 2, 0}} // data each entry is uint16_t> + }; + temp->manager = &defaultManager; //TODO + + temp = responseListIndex["8005"]; + temp->code = QByteArray::fromHex("8005"); + temp->description = "List of object's commands"; + temp->properties = + { + {0, {"Source endpoint", 1, 0}}, // uint8_t + {1, {"Profile ID", 1, 0}}, // uint16_t + {2, {"Cluster ID", 1, 0}}, // uint16_t + {3, {"Command ID list", -1, 0}} // data each entry is uint8_t + }; + temp->manager = &defaultManager; //TODO + + temp = responseListIndex["8006"]; + temp->code = QByteArray::fromHex("8006"); + temp->description = "Status after restart"; + temp->properties = + { + {0, {"Status after restart: ", 1, 2}} + }; + temp->manager = &defaultManager; + temp->propertyDetail[0] = + { + {0, "Startup"}, + {1, "NFN_START"}, + {2, "RUNNING"}, + }; + // ***************************************************************************** + // 0 - STARTUP + // 2 - NFN_START + // 6 - RUNNING + // The node is provisioned from previous restart. + // ***************************************************************************** + + temp = responseListIndex["8007"]; + temp->code = QByteArray::fromHex("8007"); + temp->description = "Status after start"; + temp->properties = + { + {0, {"Status after start: ", 1, 2}} + }; + temp->manager = &defaultManager; + temp->propertyDetail[0] = + { + {0, "Startup"}, + {1, "NFN_START"}, + {2, "RUNNING"}, + }; + temp = responseListIndex["8008"]; + temp->code = QByteArray::fromHex("8008"); + temp->description = "HeartBeat"; + temp->properties = + { + {0, {"UTC time :", 4, 0}} + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8009"]; + temp->code = QByteArray::fromHex("8009"); + temp->description = "Network state"; + temp->properties = + { + {0, {"Short Address: ", 2, 0}}, + {1, {"Extended Address: ", 8, 0}}, + {2, {"PAN ID: ", 2, 0}}, + {3, {"Extended PAN ID: ", 8, 0}}, + {4, {"Channel: ", 8, 0}} + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8010"]; + temp->code = QByteArray::fromHex("8010"); + temp->description = "Version List"; + temp->properties = + { + {0, {"Major version number", 2, 0}}, // uint16_t + {1, {"Installer version number", 2, 0}} // uint16_t + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8011"]; + temp->code = QByteArray::fromHex("8011"); + temp->description = "Ack Data"; + temp->properties = + { + {0, {"Status: ", 1, 0}}, + {1, {"Destination address: ", 2, 0}}, + {2, {"Destination endpoint: ", 1, 0}}, + {3, {"Cluster ID :", 2, 0}} + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8012"]; + temp->code = QByteArray::fromHex("8012"); + temp->description = "DATA_CONFIRM"; + temp->properties = + { + {0, {"Status: ", 1, 0}}, + {1, {"Source Endpoint: ", 1, 0}}, + {2, {"Destination endpoint: ", 1, 0}}, + {3, {"Destination Address mode:", 1, 0}}, + {4, {"Destination IEEE address: ", 8, 0}}, + {5, {"APS Sequence number: ", 1, 0}} + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8014"]; + temp->code = QByteArray::fromHex("8014"); + temp->description = "Permit join status response"; + temp->properties = + { + {0, {"Status", 1, 2}} // bool_t + }; + temp->manager = &defaultManager; + temp->propertyDetail[0] = + { + {0, "Off"}, + {1, "On"} + }; + + temp = responseListIndex["8015"]; + temp->code = QByteArray::fromHex("8015"); + temp->description = "Device list"; + temp->properties = + { + {0, {"Device List", 1, 4}} // bool_t + }; + temp->manager = &deviceListManager; + + temp = responseListIndex["8017"]; + temp->code = QByteArray::fromHex("8017"); + temp->description = "Time server"; + temp->properties = + { + {0, {"UTC Time: ", 1, 0}} // from 2000-01-01 00:00:00 + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8024"]; + temp->code = QByteArray::fromHex("8024"); + temp->description = "Network joined/formed"; + temp->properties = + { + {0, {"Status", 1, 2}}, // uint8_t + {1, {"Short address", 2, 0}}, // uint16_t + {2, {"Extended address", 4, 0}}, // uint64_t + {3, {"Channel", 1, 0}} // uint8_t + }; + temp->manager = &defaultManager; + temp->propertyDetail[0] = + { + {0, "Joined"}, + {1, "Formed new network"}, + {-1, "Failed"} + }; + + temp = responseListIndex["8028"]; + temp->code = QByteArray::fromHex("8028"); + temp->description = "Authenticate response"; + temp->properties = + { + {0, {"IEEE address of the Gateway: ", 8, 0}}, + {1, {"Encrypted Key: ", 16, 0}}, + {2, {"MIC: ", 4, 0}}, + {3, {"IEEE address of the initiating node: ", 8, 0}}, + {4, {"Active Key Sequence number: ", 1, 0}}, + {5, {"Channel: ", 1, 0}}, + {6, {"Short PAN Id: ", 2, 0}}, + {7, {"Extended PAN ID: ", 8, 0}}, + }; + temp->manager = &defaultManager; + + temp = responseListIndex["802B"]; + temp->code = QByteArray::fromHex("802B"); + temp->description = "User Descriptor Notify"; + temp->properties = + { + {0, {"Sequence number", 1, 0}}, // uin8_t + {1, {"Status", 1, 0}}, // uint8_t + {2, {"Network address of interest", 2, 0}} // uint16_t + }; + temp->manager = &defaultManager; + + temp = responseListIndex["802C"]; + temp->code = QByteArray::fromHex("802C"); + temp->description = "User Descriptor Response"; + temp->properties = + { + {0, {"Sequence number", 1, 0}}, // uin8_t + {1, {"Status", 1, 0}}, // uint8_t + {2, {"Network address of interest", 2, 0}}, // uint16_6 + {3, {"Length", 1, 0}}, // uint8_t + {4, {"Data", -1, 0}} // uint8_t stream + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8030"]; + temp->code = QByteArray::fromHex("8030"); + temp->description = "Bind response"; + temp->properties = + { + {0, {"Sequence number", 1, 0}}, // uint8_t + {1, {"Status", 1, 0}}, // uint8_t + {2, {"Source address mode: ", 1, 0}}, // uint8_t> (only from v3.1a) + {3, {"Source Address: ", 2, 0}} // uint16_t> (only from v3.1a) + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8031"]; + temp->code = QByteArray::fromHex("8031"); + temp->description = "Unbind response"; + temp->properties = + { + {0, {"Sequence number", 1, 0}}, // uint8_t + {1, {"Status", 1, 0}}, // uint8_t + {2, {"Source address mode: ", 1, 0}}, // uint8_t (only from v3.1a) + {3, {"Source Address: ", 2, 0}} // uint16_t (only from v3.1a) + + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8035"]; + temp->code = QByteArray::fromHex("8035"); + temp->description = "PDM event"; + temp->properties = + { + {0, {"Event status: ", 1, 2}}, // uint8_t + {1, {"record ID: ", 4, 0}} // uint8_t + }; + temp->manager = &defaultManager; + temp->propertyDetail[0] = + { + {0, "E_PDM_SYSTEM_EVENT_WEAR_COUNT_TRIGGER_VALUE_REACHED"}, + {1, "E_PDM_SYSTEM_EVENT_DESCRIPTOR_SAVE_FAILED"}, + {1, "E_PDM_SYSTEM_EVENT_PDM_NOT_ENOUGH_SPACE"}, + {1, "E_PDM_SYSTEM_EVENT_LARGEST_RECORD_FULL_SAVE_NO_LONGER_POSSIBLE"}, + {1, "E_PDM_SYSTEM_EVENT_SEGMENT_DATA_CHECKSUM_FAIL"}, + {1, "E_PDM_SYSTEM_EVENT_SEGMENT_SAVE_OK"}, + {1, "E_PDM_SYSTEM_EVENT_EEPROM_SEGMENT_HEADER_REPAIRED"}, + {1, "E_PDM_SYSTEM_EVENT_SYSTEM_INTERNAL_BUFFER_WEAR_COUNT_SWAP"}, + {1, "E_PDM_SYSTEM_EVENT_SYSTEM_DUPLICATE_FILE_SEGMENT_DETECTED"}, + {1, "E_PDM_SYSTEM_EVENT_SYSTEM_ERROR"}, + {1, "E_PDM_SYSTEM_EVENT_SEGMENT_PREWRITE"}, + {1, "E_PDM_SYSTEM_EVENT_SEGMENT_POSTWRITE"}, + {1, "E_PDM_SYSTEM_EVENT_SEQUENCE_DUPLICATE_DETECTED"}, + {1, "E_PDM_SYSTEM_EVENT_SEQUENCE_VERIFY_FAIL"}, + {1, "E_PDM_SYSTEM_EVENT_PDM_SMART_SAVE"}, + {1, "E_PDM_SYSTEM_EVENT_PDM_FULL_SAVE"} + }; + + temp = responseListIndex["8040"]; + temp->code = QByteArray::fromHex("8040"); + temp->description = "Network Address response"; + temp->properties = + { + {0, {"Sequence number", 1, 0}}, // uin8_t + {1, {"Status", 1, 0}}, // uint8_t + {2, {"IEEE address", 4, 0}}, // uint64_t + {3, {"Short address", 2, 0}}, // uint16_t + {4, {"Number of associated devices", 1, 0}}, // uint8_t + {5, {"Start index", 1, 0}}, // uint8_t + {6, {"Device list", -1, 4}} // data each entry is uint16_t> + }; + temp->manager = &networkAddressManager; + + temp = responseListIndex["8041"]; + temp->code = QByteArray::fromHex("8041"); + temp->description = "IEEE Address response"; + temp->properties = + { + {0, {"Sequence number", 1, 0}}, // uin8_t + {1, {"Status", 1, 0}}, // uint8_t + {2, {"IEEE address", 4, 0}}, // uint64_t + {3, {"Short address", 2, 0}}, // uint16_t + {4, {"Number of associated devices", 1, 0}}, // uint8_t + {5, {"Start index", 1, 0}}, // uint8_t + {6, {"Device list", -1, 4}} // data each entry is uint16_t + }; + temp->manager = &iEEEAddressManager; + + temp = responseListIndex["8042"]; + temp->code = QByteArray::fromHex("8042"); + temp->description = "Node Descriptor response"; + temp->properties = + { + {0, {"Sequence number", 1, 0}}, // uint8_t + {1, {"Network address", 2, 0}}, // uint16_t + {2, {"Manufacturer code", 2, 0}}, // uint16_t + {3, {"Max Rx Size", 2, 0}}, // uint16_t + {4, {"Max Tx Size", 2, 0}}, // uint16_t + {5, {"Server mask", 2, 0}}, // uint16_t + {6, {"Descriptor capability", 1, 0}}, // uint8_t + {7, {"Mac flags", 1, 0}}, // uint8_t + {8, {"Max buffer size", 1, 0}}, // uint8_t + {9, {"Bit fields", 2, -1}} // uint16_t + }; + temp->manager = &nodeDescriptorManager; + + temp = responseListIndex["8043"]; + temp->code = QByteArray::fromHex("8043"); + temp->description = "Simple Descriptor response"; + temp->properties = + { + {0, {"Sequence number", 1, 0}}, // uint8_t + {1, {"Status", 1, 0}}, // uint8_t + {2, {"NwkAddress", 2, 0}}, // uint16_t + {3, {"Length", 1, 0}}, // uint8_t + {4, {"Endpoint", 1, 0}}, // uint8_t + {5, {"Profile", 2, 0}}, // uint16_t + {6, {"Device id", 2, 0}}, // uint16_t + {7, {"Bit fields", 1, 0}}, // uint8_t + {8, {"InClusterCount", 1, 0}}, // uint8_t + {9, {"In cluster list", 0, 0}}, // data each entry is uint16_t> + {10, {"Out Cluster Count", 1, 0}}, // uint8_t + {11, {"Out cluster list", -1, 0}} // data each entry is uint16_t + }; + temp->manager = &defaultManager; //TODO + + temp = responseListIndex["8044"]; + temp->code = QByteArray::fromHex("8044"); + temp->description = "Power Descriptor response"; + temp->properties = + { + {0, {"Sequence number", 1, 0}}, // uin8_t + {1, {"Status", 1, 0}}, // uint8_t + {2, {"bit field", 2, 0}} // uint16_t + }; + temp->manager = &defaultManager; + // ****************************************** + // 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 + // ****************************************** + + temp = responseListIndex["8045"]; + temp->code = QByteArray::fromHex("8045"); + temp->description = "Active Endpoint response"; + temp->properties = + { + {0, {"Sequence number", 1, 0}}, // uint8_t + {1, {"Status", 1, 0}}, // uint8_t + {2, {"Address", 2, 0}}, // uint16_t + {3, {"Endpoint count", 1, 0}}, // uint8_t + {4, {"Active endpoint list", -1, 0}} // each data element of the type uint8_t + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8046"]; + temp->code = QByteArray::fromHex("8046"); + temp->description = "Match Descriptor response"; + temp->properties = + { + {0, {"Sequence number", 1, 0}}, // uint8_t + {1, {"Status", 1, 0}}, // uint8_t + {2, {"Network address", 2, 0}}, // uint16_t + {3, {"Length of list", 1, 0}}, // uint8_t + {4, {"Match list", -1, 0}} // data each entry is uint8_t + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8047"]; + temp->code = QByteArray::fromHex("8047"); + temp->description = "Management Leave response"; + temp->properties = + { + {0, {"Sequence number", 1, 0}}, // uint8_t + {1, {"Status", 1, 0}} // uint8_t + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8048"]; + temp->code = QByteArray::fromHex("8048"); + temp->description = "Leave indication"; + temp->properties = + { + {0, {"Extended address", 4, 0}}, // uint64_t + {1, {"Rejoin status", 1, 0}} // uint8_t + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8049"]; + temp->code = QByteArray::fromHex("8049"); + temp->description = "PDM child table size"; + temp->properties = + { + {0, {"Number of child: ", 1, 0}} // data each entry is uint8_t + }; + temp->manager = &defaultManager; + + temp = responseListIndex["804A"]; + temp->code = QByteArray::fromHex("804A"); + temp->description = "Management Network Update response"; + temp->properties = + { + {0, {"Sequence number", 1, 0}}, // uint8_t + {1, {"Status", 1, 0}}, // uint8_t + {2, {"Total transmission", 2, 0}}, // uint16_t + {3, {"Transmission failures", 2, 0}}, // uint16_t + {4, {"Scanned channels", 4, 0}}, // uint32_t + {5, {"Scanned channel list count", 1, 0}}, // uint8_t + {6, {"Channel list", -1, 0}} // list each element is uint8_t + }; + temp->manager = &defaultManager; + + temp = responseListIndex["804B"]; + temp->code = QByteArray::fromHex("804B"); + temp->description = "System Server Discovery response"; + temp->properties = + { + {0, {"Sequence number", 1, 0}}, // uint8_t + {1, {"status", 1, 0}}, // uint8_t + {2, {"Server mask", 2, 0}} // uint16_t + }; + temp->manager = &defaultManager; + + temp = responseListIndex["804E"]; + temp->code = QByteArray::fromHex("804E"); + temp->description = "Management LQI response"; + temp->properties = + { + {0, {"Sequence number", 1, 0}}, // uint8_t + {1, {"status", 1, 0}}, // uint8_t + {2, {"Neighbour Table Entries ", 1, 0}}, // uint8_t + {3, {"Neighbour Table List Count ", 1, 0}}, // uint8_t + {4, {"Start Index ", 1, 0}}, // uint8_t + {5, {"List of Entries elements described below", -1, 0}} + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8060"]; + temp->code = QByteArray::fromHex("8060"); + temp->description = "Add group"; + temp->properties = + { + {0, {"Sequence number: ", 1, 0}}, + {1, {"Endpoint: ", 1, 0}}, + {2, {"Cluster id: ", 2, 0}}, + {3, {"Status: ", 1, 0}}, //(added only from 3.0f version) + {4, {"Group id :", 2, 0}}, //(added only from 3.0f version) + {5, {"Source Address: ", 2, 0}}, //(added only from 3.0f version) + {6, {"Number of child: ", 1, 0}} // data each entry is uint8_t + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8061"]; + temp->code = QByteArray::fromHex("8061"); + temp->description = "View group"; + temp->properties = + { + {0, {"Sequence number: ", 1, 0}}, + {1, {"Endpoint: ", 1, 0}}, + {2, {"Cluster id: ", 2, 0}}, + {3, {"Status: ", 1, 0}}, //(added only from 3.0f version) + {4, {"Group id :", 2, 0}}, //(added only from 3.0f version) + {5, {"Source Address: ", 2, 0}} //(added only from 3.0f version) + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8062"]; + temp->code = QByteArray::fromHex("8062"); + temp->description = "Group membership"; + temp->properties = + { + {0, {"Sequence number: ", 1, 0}}, + {1, {"Endpoint: ", 1, 0}}, + {2, {"Cluster id: ", 2, 0}}, + {3, {"Source Address:", 2, 0}}, //(added only from 3.0d version) + {4, {"Capacity: ", 1, 0}}, + {5, {"Group count: ", 1, 0}}, + {6, {"List of Group id: ", 2, 0}}, //list each data item uint16_t> + {7, {"Source Addr: ", 2, 0}} //(added only from 3.0f version) + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8063"]; + temp->code = QByteArray::fromHex("8063"); + temp->description = "Remove group"; + temp->properties = + { + {0, {"Sequence number: ", 1, 0}}, + {1, {"Endpoint: ", 1, 0}}, + {2, {"Cluster id: ", 2, 0}}, + {3, {"Source Address:", 2, 0}}, //(added only from 3.0d version) + {4, {"Status: ", 1, 0}}, + {5, {"Group ID: ", 2, 0}} + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8085"]; + temp->code = QByteArray::fromHex("8085"); + temp->description = "Level update"; + temp->properties = + { + {0, {"Sequence number: ", 1, 0}}, + {1, {"Endpoint: ", 1, 0}}, + {2, {"Cluster id: ", 2, 0}}, + {3, {"Source Address mode:", 1, 0}}, //(added only from 3.0d version) + {4, {"Source Address:", 2, 0}}, //(added only from 3.0d version) + {5, {"Status: ", 1, 0}} + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8095"]; + temp->code = QByteArray::fromHex("8095"); + temp->description = "On/Off"; + temp->properties = + { + {0, {"Sequence number: ", 1, 0}}, + {1, {"Endpoint: ", 1, 0}}, + {2, {"Cluster id: ", 2, 0}}, + {3, {"Source Address mode:", 1, 0}}, //(added only from 3.0d version) + {4, {"Source Address:", 2, 0}}, //(added only from 3.0d version) + {5, {"Status: ", 1, 0}} + }; + temp->manager = &defaultManager; + + temp = responseListIndex["8140"]; + temp->code = QByteArray::fromHex("8140"); + temp->description = "Attribute Discovery response"; + temp->properties = + { + {0, {"Complete", 1, 0}}, // uint8_t + {1, {"Attribute type", 1, 0}}, // uint8_t + {2, {"Attribute id", 2, 0}} // uint16_t + }; + temp->manager = &defaultManager; + + + qRegisterMetaType("serialManager"); + serialManager.initSerial(); + connect(&serialManager, SIGNAL(readyRead()), &zigatePlugin, SLOT(readDatas())); + connect(&serialManager, SIGNAL(errorOccurred(QSerialPort::SerialPortError)), &serialManager, SLOT(serialError(QSerialPort::SerialPortError)), Qt::QueuedConnection); + + //sending reset and getting version of zigate + resetCoordinator(); + getVersion(); + + return returnCode; +} + +void infoOutput(ResponseProperties *object) +{ + cout << object->code.toHex().toStdString() << " : " << object->description.toStdString() << endl; + +} + diff --git a/zigateplugin/zigatecmd.cpp b/zigateplugin/zigatecmd.cpp new file mode 100644 index 0000000..ccd6378 --- /dev/null +++ b/zigateplugin/zigatecmd.cpp @@ -0,0 +1,468 @@ +#include "zigateplugin.h" +#include +#include + +using namespace std; +class ZigatePugin; + +bool ZigatePlugin::resetCoordinator() +{ + bool returnCode = false; + + cout << "Sending reset to coordinator" << endl; + sendCmd("0011", ""); + cout << "***************************************************" << endl; + //sleep(5); + return returnCode; +} + +void ZigatePlugin::getVersion() +{ + sendCmd("0010", ""); +} +/* +bool ZigatePlugin::setHeartBeat() +{ + +} + +bool ZigatePlugin::getNetworkState() +{ + +} + +bool ZigatePlugin::erasePersistentData() +{ + +} + +bool ZigatePlugin::factoryNewReset() +{ + +} + +bool ZigatePlugin::permitJoin() +{ + +} + +bool ZigatePlugin::setExpendedPANID() +{ + +} + +bool ZigatePlugin::setChannelMask() +{ + +} + +bool ZigatePlugin::setSecurityStateKey() +{ + +} + +bool ZigatePlugin::setDeviceType() +{ + +} + +bool ZigatePlugin::startNetwork() +{ + +} + +bool ZigatePlugin::startNetworkScan() +{ + +} + +bool ZigatePlugin::removeDevice() +{ + +} + +bool ZigatePlugin::enablePermissionsControlledJoins() +{ + +} + +bool ZigatePlugin::authenticateDevice() +{ + +} + +bool ZigatePlugin::outOfBandCommissioningDataRequest() +{ + +} + +bool ZigatePlugin::userDescriptorSet() +{ + +} + +bool ZigatePlugin::userDescriptorRequest() +{ + +} + +bool ZigatePlugin::bind() +{ + +} + +bool ZigatePlugin::unbind() +{ + +} + +bool ZigatePlugin::complexDescriptorRequest() +{ + +} + +bool ZigatePlugin::networkAddressRequest() +{ + +} + +bool ZigatePlugin::iEEEAddressRequest() +{ + +} + +bool ZigatePlugin::nodeDescriptorRequest() +{ + +} + +bool ZigatePlugin::simpleDescriptorRequest() +{ + +} + +bool ZigatePlugin::powerDescriptorRequest() +{ + +} + +bool ZigatePlugin::activeEndpointRequest() +{ + +} + +bool ZigatePlugin::matchDescriptorRequest() +{ + +} + +bool ZigatePlugin::managementLeaveRequest() +{ + +} + +bool ZigatePlugin::permitJoiningRequest() +{ + +} + +bool ZigatePlugin::managementNetworkUpdateRequest() +{ + +} + +bool ZigatePlugin::systemServerDiscoveryRequest() +{ + +} + +bool ZigatePlugin::managementLQIRequest() +{ + +} + +bool ZigatePlugin::addGroup() +{ + +} + +bool ZigatePlugin::viewGroup() +{ + +} + +bool ZigatePlugin::getGroupMembership() +{ + +} + +bool ZigatePlugin::removeGroup() +{ + +} + +bool ZigatePlugin::removeAllGroups() +{ + +} + +bool ZigatePlugin::addGroupIfIdentify() +{ + +} + +bool ZigatePlugin::identifySend() +{ + +} + +bool ZigatePlugin::identifyQuery() +{ + +} + +bool ZigatePlugin::moveToLevel() +{ + +} + +bool ZigatePlugin::moveToLevelWithWithoutOnOoff() +{ + +} + +bool ZigatePlugin::moveStep() +{ + +} + +bool ZigatePlugin::moveStopMove() +{ + +} + +bool ZigatePlugin::moveStopWithOnOff() +{ + +} + +bool ZigatePlugin::onOffWithNEffects() +{ + +} + +bool ZigatePlugin::onOffWithEffects() +{ + +} + +bool ZigatePlugin::onOffTimedSend() +{ + +} + +bool ZigatePlugin::onOffTimed() +{ + +} + +bool ZigatePlugin::onOffWithEffectsSend() +{ + +} + +bool ZigatePlugin::viewScene() +{ + +} + +bool ZigatePlugin::addScene() +{ + +} + +bool ZigatePlugin::removeScene() +{ + +} + +bool ZigatePlugin::removeAllScenes() +{ + +} + +bool ZigatePlugin::storeScene() +{ + +} + +bool ZigatePlugin::recallScene() +{ + +} + +bool ZigatePlugin::sceneMembershipRequest() +{ + +} + +bool ZigatePlugin::addEnhancedScene() +{ + +} + +bool ZigatePlugin::viewEnhancedHostToNodeScene() +{ + +} + +bool ZigatePlugin::copyScene() +{ + +} + +bool ZigatePlugin::moveToHue() +{ + +} + +bool ZigatePlugin::moveHue() +{ + +} + +bool ZigatePlugin::stepHue() +{ + +} + +bool ZigatePlugin::moveToSaturation() +{ + +} + +bool ZigatePlugin::moveSaturation() +{ + +} + +bool ZigatePlugin::stepSaturation() +{ + +} + +bool ZigatePlugin::moveToHueAndSaturation() +{ + +} + +bool ZigatePlugin::moveToColour() +{ + +} + +bool ZigatePlugin::moveColour() +{ + +} + +bool ZigatePlugin::stepColour() +{ + +} + +bool ZigatePlugin::enhancedMoveToHue() +{ + +} + +bool ZigatePlugin::enhancedMoveHue() +{ + +} + +bool ZigatePlugin::enhancedStepHue() +{ + +} + +bool ZigatePlugin::enhancedMoveToHueAndSaturation() +{ + +} + +bool ZigatePlugin::colourLoopSet() +{ + +} + +bool ZigatePlugin::stopMoveStep() +{ + +} + +bool ZigatePlugin::moveToColourTemperature() +{ + +} + +bool ZigatePlugin::moveColourTemperature() +{ + +} + +bool ZigatePlugin::stepColourTemperature() +{ + +} + +bool ZigatePlugin::initiateTouchlink() +{ + +} + +bool ZigatePlugin::touchLinkFactoryResetTarget() +{ + +} + +bool ZigatePlugin::identifyTriggerEffect() +{ + +} + +bool ZigatePlugin::lockUnlockDoor() +{ + +} + +bool ZigatePlugin::readAttributerequest() +{ + +} + +bool ZigatePlugin::writeAttributeRequest() +{ + +} + +bool ZigatePlugin::configureReportingRequest() +{ + +} + +bool ZigatePlugin::attributeDiscoveryRequest() +{ + +} + +bool ZigatePlugin::iASZoneEnrollResponse() +{ + +} + +bool ZigatePlugin::rawAPSDataRequest() +{ + +} +*/ diff --git a/zigateplugin/zigatecmd.cpp.autosave b/zigateplugin/zigatecmd.cpp.autosave new file mode 100644 index 0000000..4056543 --- /dev/null +++ b/zigateplugin/zigatecmd.cpp.autosave @@ -0,0 +1,467 @@ +#include "zigateplugin.h" +#include +#include + +using namespace std; +class ZigatePugin; + +bool ZigatePlugin::resetCoordinator() +{ + bool returnCode = false; + + cout << "Sending reset to coordinator" << endl; + sendCmd("0011", ""); + return returnCode; +} + +void ZigatePlugin::getVersion() +{ + cout << "Getting o coordinator" << endl; + sendCmd("0010", ""); +} +/* +bool ZigatePlugin::setHeartBeat() +{ + +} + +bool ZigatePlugin::getNetworkState() +{ + +} + +bool ZigatePlugin::erasePersistentData() +{ + +} + +bool ZigatePlugin::factoryNewReset() +{ + +} + +bool ZigatePlugin::permitJoin() +{ + +} + +bool ZigatePlugin::setExpendedPANID() +{ + +} + +bool ZigatePlugin::setChannelMask() +{ + +} + +bool ZigatePlugin::setSecurityStateKey() +{ + +} + +bool ZigatePlugin::setDeviceType() +{ + +} + +bool ZigatePlugin::startNetwork() +{ + +} + +bool ZigatePlugin::startNetworkScan() +{ + +} + +bool ZigatePlugin::removeDevice() +{ + +} + +bool ZigatePlugin::enablePermissionsControlledJoins() +{ + +} + +bool ZigatePlugin::authenticateDevice() +{ + +} + +bool ZigatePlugin::outOfBandCommissioningDataRequest() +{ + +} + +bool ZigatePlugin::userDescriptorSet() +{ + +} + +bool ZigatePlugin::userDescriptorRequest() +{ + +} + +bool ZigatePlugin::bind() +{ + +} + +bool ZigatePlugin::unbind() +{ + +} + +bool ZigatePlugin::complexDescriptorRequest() +{ + +} + +bool ZigatePlugin::networkAddressRequest() +{ + +} + +bool ZigatePlugin::iEEEAddressRequest() +{ + +} + +bool ZigatePlugin::nodeDescriptorRequest() +{ + +} + +bool ZigatePlugin::simpleDescriptorRequest() +{ + +} + +bool ZigatePlugin::powerDescriptorRequest() +{ + +} + +bool ZigatePlugin::activeEndpointRequest() +{ + +} + +bool ZigatePlugin::matchDescriptorRequest() +{ + +} + +bool ZigatePlugin::managementLeaveRequest() +{ + +} + +bool ZigatePlugin::permitJoiningRequest() +{ + +} + +bool ZigatePlugin::managementNetworkUpdateRequest() +{ + +} + +bool ZigatePlugin::systemServerDiscoveryRequest() +{ + +} + +bool ZigatePlugin::managementLQIRequest() +{ + +} + +bool ZigatePlugin::addGroup() +{ + +} + +bool ZigatePlugin::viewGroup() +{ + +} + +bool ZigatePlugin::getGroupMembership() +{ + +} + +bool ZigatePlugin::removeGroup() +{ + +} + +bool ZigatePlugin::removeAllGroups() +{ + +} + +bool ZigatePlugin::addGroupIfIdentify() +{ + +} + +bool ZigatePlugin::identifySend() +{ + +} + +bool ZigatePlugin::identifyQuery() +{ + +} + +bool ZigatePlugin::moveToLevel() +{ + +} + +bool ZigatePlugin::moveToLevelWithWithoutOnOoff() +{ + +} + +bool ZigatePlugin::moveStep() +{ + +} + +bool ZigatePlugin::moveStopMove() +{ + +} + +bool ZigatePlugin::moveStopWithOnOff() +{ + +} + +bool ZigatePlugin::onOffWithNEffects() +{ + +} + +bool ZigatePlugin::onOffWithEffects() +{ + +} + +bool ZigatePlugin::onOffTimedSend() +{ + +} + +bool ZigatePlugin::onOffTimed() +{ + +} + +bool ZigatePlugin::onOffWithEffectsSend() +{ + +} + +bool ZigatePlugin::viewScene() +{ + +} + +bool ZigatePlugin::addScene() +{ + +} + +bool ZigatePlugin::removeScene() +{ + +} + +bool ZigatePlugin::removeAllScenes() +{ + +} + +bool ZigatePlugin::storeScene() +{ + +} + +bool ZigatePlugin::recallScene() +{ + +} + +bool ZigatePlugin::sceneMembershipRequest() +{ + +} + +bool ZigatePlugin::addEnhancedScene() +{ + +} + +bool ZigatePlugin::viewEnhancedHostToNodeScene() +{ + +} + +bool ZigatePlugin::copyScene() +{ + +} + +bool ZigatePlugin::moveToHue() +{ + +} + +bool ZigatePlugin::moveHue() +{ + +} + +bool ZigatePlugin::stepHue() +{ + +} + +bool ZigatePlugin::moveToSaturation() +{ + +} + +bool ZigatePlugin::moveSaturation() +{ + +} + +bool ZigatePlugin::stepSaturation() +{ + +} + +bool ZigatePlugin::moveToHueAndSaturation() +{ + +} + +bool ZigatePlugin::moveToColour() +{ + +} + +bool ZigatePlugin::moveColour() +{ + +} + +bool ZigatePlugin::stepColour() +{ + +} + +bool ZigatePlugin::enhancedMoveToHue() +{ + +} + +bool ZigatePlugin::enhancedMoveHue() +{ + +} + +bool ZigatePlugin::enhancedStepHue() +{ + +} + +bool ZigatePlugin::enhancedMoveToHueAndSaturation() +{ + +} + +bool ZigatePlugin::colourLoopSet() +{ + +} + +bool ZigatePlugin::stopMoveStep() +{ + +} + +bool ZigatePlugin::moveToColourTemperature() +{ + +} + +bool ZigatePlugin::moveColourTemperature() +{ + +} + +bool ZigatePlugin::stepColourTemperature() +{ + +} + +bool ZigatePlugin::initiateTouchlink() +{ + +} + +bool ZigatePlugin::touchLinkFactoryResetTarget() +{ + +} + +bool ZigatePlugin::identifyTriggerEffect() +{ + +} + +bool ZigatePlugin::lockUnlockDoor() +{ + +} + +bool ZigatePlugin::readAttributerequest() +{ + +} + +bool ZigatePlugin::writeAttributeRequest() +{ + +} + +bool ZigatePlugin::configureReportingRequest() +{ + +} + +bool ZigatePlugin::attributeDiscoveryRequest() +{ + +} + +bool ZigatePlugin::iASZoneEnrollResponse() +{ + +} + +bool ZigatePlugin::rawAPSDataRequest() +{ + +} +*/ diff --git a/zigateplugin/zigateplugin.cpp b/zigateplugin/zigateplugin.cpp new file mode 100644 index 0000000..83cefbd --- /dev/null +++ b/zigateplugin/zigateplugin.cpp @@ -0,0 +1,509 @@ +#include "zigateplugin.h" + +using namespace std; + +ZigatePlugin zigatePlugin; +SerialManager serialManager; + +QHash responseListIndex +{ + {"004D", nullptr}, + {"8000", nullptr}, + {"8001", nullptr}, + {"8002", nullptr}, + {"8003", nullptr}, + {"8004", nullptr}, + {"8005", nullptr}, + {"8006", nullptr}, + {"8007", nullptr}, + {"8010", nullptr}, + {"8014", nullptr}, + {"8024", nullptr}, + {"8030", nullptr}, + {"8031", nullptr}, + {"8040", nullptr}, + {"8041", nullptr}, + {"8042", nullptr}, + {"8043", nullptr}, + {"8044", nullptr}, + {"8045", nullptr}, + {"8046", nullptr}, + {"802B", nullptr}, + {"802C", nullptr}, + {"8047", nullptr}, + {"8048", nullptr}, + {"804A", nullptr}, + {"804B", nullptr}, + {"804E", nullptr}, + {"8140", nullptr}, + {"8008", nullptr}, + {"8009", nullptr}, + {"8011", nullptr}, + {"8012", nullptr}, + {"8015", nullptr}, + {"8017", nullptr}, + {"8028", nullptr}, + {"8035", nullptr}, + {"8049", nullptr}, + {"8052", nullptr}, + {"8060", nullptr}, + {"8061", nullptr}, + {"8062", nullptr}, + {"8063", nullptr}, + {"8085", nullptr}, + {"8095", nullptr}, + {"80A0", nullptr}, + {"80A1", nullptr}, + {"80A2", nullptr}, + {"80A3", nullptr}, + {"80A4", nullptr}, + {"80A6", nullptr}, + {"80A7", nullptr}, + {"8100", nullptr}, + {"8101", nullptr}, + {"8102", nullptr}, + {"8110", nullptr}, + {"8120", nullptr}, + {"8122", nullptr}, + {"8531", nullptr}, + {"8701", nullptr}, + {"8702", nullptr}, + {"9999", nullptr} +}; + +QByteArray ZigatePlugin::checksum(QByteArray msgType, QByteArray length, QByteArray datas) +{ + quint16 temp = 0; + int i; + QString str; + + 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) + { + str = datas.mid(i,2); + temp ^= str.toInt(nullptr, 16); + } + return QByteArray::number(temp, 16); +} + +QByteArray ZigatePlugin::transcode(QByteArray datas) +{ + QByteArray msg = ""; + int i; + QByteArray byte; + if (datas.count()%2 != 0) + { + return "-1"; + } + for (i=0;i 15) + { + msg += byte; + }else + { + msg.append("02"); + msg.append(QByteArray::number(byte.toUInt(nullptr, 16) ^ 16, 16)); + } + } + return msg; +} + +QByteArray ZigatePlugin::unTranscode(QByteArray datas) +{ + QByteArray result; + int i; + char tmp; + + if (datas.isEmpty()) + { + return "-1"; + } + + for (i=0;i<=datas.count()-1;i++) + { + tmp = datas.at(i); + if (tmp == 0x02) + { + i++; + result.append(datas[i] ^ 16); + }else + { + //if (tmp != 0 and tmp != 1) + //{ + result += tmp; + //} + } + } + cout << result.toHex(' ').toStdString() << endl; + return result; +} + +void ZigatePlugin::sendCmd(QByteArray cmd, QByteArray datas) +{ + QByteArray msg; + QByteArray len; + + len = QByteArray::number(datas.count()/2, 16).insert(0,"000").right(4); + msg = QByteArray::fromHex("01"); + msg += QByteArray::fromHex(transcode(cmd)); + msg += QByteArray::fromHex(transcode(len)); + if (!datas.isEmpty()) + { + msg += QByteArray::fromHex(checksum(cmd, len, datas)); + msg += QByteArray::fromHex(transcode(datas)); + }else{ + msg += QByteArray::fromHex(checksum(cmd, len, "")); + } + msg += QByteArray::fromHex("03"); + serialManager.write2serial(msg); +} + +void ZigatePlugin::interpretResult(QByteArray payload) +{ + //uint tab = 0; + uint length = 0; + quint8 crctmp = 0; + uint i = 0; + //int datasResultLength = 0; + ResponseProperties * responseObject; + QByteArray type; + uint ln; + quint8 crc; + QByteArray datas; + QByteArray quality; + QByteArray payloadD; + payloadD = unTranscode(payload); + if (this->datas.count() >= 1) + { + cout << "inserting: " << this->datas.toHex(' ').toStdString() << endl; + payloadD.insert(0, this->datas); + } + length = payloadD.count(); + + while(length > 5) + { + cout << "Interpreting datas =>" << payload.left(1).toHex(' ').toStdString() << endl; + cout << "PayloadD : " << payloadD.toHex(' ').toStdString() << endl; + while(payloadD.left(1).toHex() != "01") + { + payloadD.remove(0,1); + } + payloadD.remove(0,1);crctmp = 0; + //type de message + type = payloadD.mid(0, 2); + ln = payloadD.mid(2, 2).toHex().toUInt(nullptr, 16); + if (ln + 6 > length) + { + cout << "storing payloadD: " << payloadD.toHex(' ').toStdString() << endl; + this->datas = payloadD; + break; + }else + { + if ((unsigned char)type[0] == 128 or (unsigned char)type[0] == 0 or (unsigned char)type[0] == 153) + { + crctmp = crctmp ^ payloadD.at(0) ^ payloadD.at(1); + crctmp = crctmp ^ payloadD.at(2) ^ payloadD.at(3); + //acquisition du CRC + crc = payloadD.at(4); + //datasResult + datas = ""; + + for(i=0;imanager != nullptr) + { + responseObject->code = type; + responseObject->datas = datas; + //responseObject.properties = responseListIndex[type]->properties + responseObject->manager(responseObject); + + }else + { + cout << "unknown command or command not implemented :" << type.toHex().toStdString() << endl; + } + }else + { + //tab = -2; + } + }else + { + cout << "unknown type of datagram type: " << type.toHex().toStdString() << endl; + } + } + payloadD.remove(0,ln+6); + length = payloadD.count(); + cout << "---------------" << endl; + } + //return tab; +} + + +void defaultManager(ResponseProperties *responseObject) +{ + int nbyte; + int isValue; + int offset = 0; + int i; + + QByteArray datas = responseObject->datas; + QByteArray result; + //QByteArray code = responseObject->code.toHex(); + + //cout << responseObject->code.toHex().toStdString() << endl; + int n = responseObject->properties.count(); + QMap> propertyList; + QMap propertyDetail; + QMap var; + QList property; + QMap::iterator j; + //int propertyListKey; + + propertyList = responseObject->properties; + infoOutput(responseObject); + for(i=0;ipropertyDetail.value(i); + + switch (isValue) + { + case 0: + cout << result.toHex().toStdString() << endl; + break; + case 1: + cout << result.toHex().toStdString() << endl; + j = propertyDetail.begin(); + while(j != propertyDetail.end()) + { + if (result.toUInt(nullptr,16) & var[0].toUInt(nullptr,16)) + { + cout << var[1].toStdString() << endl; + } + } + break; + case 2: + if (propertyDetail.contains(result.toUInt())) + { + cout << propertyDetail.value(result.toUInt()).toStdString() << endl; + }else if (propertyDetail.contains(-1)) + { + cout << propertyDetail.value(-1).toStdString() << endl; + } + break; + case 3: + responseObject->propertyManagerList[i](result); + break; + case 4: + cout << "Liste" << endl; + break; + case 5: + cout << result.toStdString() << endl; + break; + } + } +} + +void macCapabilityManager(QByteArray mac) +{ + cout << "macCapabilityManger" << mac.toStdString() << endl; +} + + +/* void deviceAnnounceManager() +{ + infoOutput(responseListIndex("")); +} +*/ + +void dataIndicationManager(ResponseProperties * response) +{ + infoOutput(response); +} + + +void clustersListManager(ResponseProperties * response) +{ + infoOutput(response); +} + + +/* +void attributesListManager() +{ + infoOutput(attributesList); +} + +void commandsListManager() +{ + infoOutput(commandsList); +} + +void statusManager() +{ + infoOutput(status); +} + +void status2Manager() +{ + +} + +void versionListManager() +{ + infoOutput(versionList); +} +// **************************************************************************** +// 0 - Off +// 1 - On +// ******************************************************************************* + +void permitJoinManager() +{ + infoOutput(permitJoin); +} + +void networkJoinedFormedManager() +{ + infoOutput(networkJoinedFormed); +} +*/ + + +void deviceListManager(ResponseProperties * response) +{ + infoOutput(response); + // ************************************************************** + // + // + // + // + // 0 – battery 1- AC power + // 1-255 + // ************************************************************** + } + + +/* +void bindResponseManager() +{ + infoOutput(bindResponse); +} + +void unbindResponseManager() +{ + infoOutput(unbindResponse); +} +*/ + + +void networkAddressManager(ResponseProperties * response) +{ + infoOutput(response); +} + +void iEEEAddressManager(ResponseProperties * response) +{ + infoOutput(response); +} + +void nodeDescriptorManager(ResponseProperties * response) +{ + infoOutput(response); +} + +void simpleDescriptorManager(ResponseProperties * response) +{ + infoOutput(response); +} + + +/* +void powerDescriptorManager() +{ + infoOutput(powerDescriptor); +} + +void activeEndpointManager() +{ + infoOutput(activeEndpoint); +} + +void matchDescriptorManager() +{ + infoOutput(matchDescriptor); +} + +void userDescriptorNotifyManager() +{ + infoOutput(userDescriptorNotify); +} + +void userDescriptorManager() +{ + infoOutput(userDescriptor); +} + +void complexDescriptorManager() +{ + infoOutput(complexDescriptor); +} + +void managementLeaveManager() +{ + infoOutput(managementLeave); +} + +void leaveIndicationManager() +{ + infoOutput(leaveIndication); +} + +void managementNetworkUpdateManager() +{ + infoOutput(managementNetworkUpdate); +} + +void systemServerDiscoveryManager() +{ + infoOutput(systemServerDiscovery); +} +// ********************************* // +// Bitmask according to spec". // +// ********************************* // + +void managementLQIManager() +{ + infoOutput(managementLQI); +} + +void attributeDiscoveryManager() +{ + infoOutput(attributeDiscovery); +} +*/ diff --git a/zigateplugin/zigateplugin.h b/zigateplugin/zigateplugin.h new file mode 100644 index 0000000..0d5eec1 --- /dev/null +++ b/zigateplugin/zigateplugin.h @@ -0,0 +1,312 @@ +#ifndef ZIGATEPLUGIN_H +#define ZIGATEPLUGIN_H + +#include +#include +#include +#include "interface.h" +//#include "library.h" +#include "serial.h" +#include +#include +#include +#include "responseClasses.h" +#include +#include +#include +#include +#include + +#define DEVICE_ANNOUNCE "004D" +#define STATUS_RETURNED "8000" +#define LOG_MESSAGE "8001" +#define DATA_INDICATION "8002" +#define CLUSTERS_LIST "8003" +#define ATTRIBUTES_LIST "8004" +#define COMMANDS_LIST "8005" +#define STATUS "8006" +#define STATUS2 "8007" +#define VERSION_LIST "8010" +#define PERMIT_JOIN "8014" +#define NETWORK_JOINED_FORMED "8024" +#define BIND_RESPONSE "8030" +#define UNBIND_RESPONSE "8031" +#define NETWORK_ADDRESS "8040" +#define IEEE_ADDRESS "8041" +#define NODE_DESCRIPTOR "8042" +#define SIMPLE_DESCRIPTOR "8043" +#define POWER_DESCRIPTOR "8044" +#define ACTIVE_ENDPOINT "8045" +#define MATCH_DESCRIPTOR "8046" +#define USER_DESCRIPTOR_NOTIFY "802B" +#define USER_DESCRIPTOR "802C" +#define MANAGEMENT_LEAVE "8047" +#define LEAVE_INDICATION "8048" +#define MANAGEMENT_NETWORK_UPDATE "804A" +#define SYSTEM_SERVER_DISCOVERY "804B" +#define MANAGEMENT_LQI "804E" +#define ATTRIBUTE_DISCOVERY "8140" +#define HEARTBEAT "8008" +#define NETWORK_STATE "8009" +#define ACK_DATA "8011" +#define DATA_CONFIRM "8012" +#define DEVICES_LIST "8015" +#define TIME_SERVER "8017" +#define AUTHENTICATE_RESPONSE "8028" +#define PDM_EVENT "8035" +#define PERMIT_JOINING "8049" +#define PDM_CHILD_TABLE_SIZE "8052" +#define ADD_GROUP "8060" +#define VIEW_GROUP "8061" +#define GROUP_MEMBERSHIP "8062" +#define REMOVE_GROUP "8063" +#define LEVEL_UPDATE "8085" +#define ON_OFF "8095" +#define VIEW_SCENE "80A0" +#define ADD_SCENE "80A1" +#define REMOVE_SCENE "80A2" +#define REMOVE_ALL_SCENE "80A3" +#define STORE_SCENE "80A4" +#define SCENE_MEMBERSHIP "80A6" +#define SCENES_UPDATE "80A7" +#define READ_INDIVIDUAL_ATTRIBUTE "8100" +#define DEFAULT_RESPONSE "8101" +#define REPORT_INDIVIDUAL_ATTRIBUTE "8102" +#define WRITE_ATTRIBUTE "8110" +#define CONFIGURE_REPORTING "8120" +#define READ_REPORT_CONFIG "8122" +#define COMPLEX_DESCRIPTOR "8531" +#define ROUTER_DISCOVERY "8701" +#define APS_DATA_CONFIRM_FAIL "8702" +#define EXTENDED_ERROR "9999" + +class ZigatePlugin : public QObject, public ZigbeeManagerInterface +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.zigbeeManagerInterface" FILE "zigateplugin.json") + Q_INTERFACES(ZigbeeManagerInterface) + + +public slots: + void interpretResult(QByteArray); + void readDatas(); + +signals: + +public: + bool initPlugin() override; + QByteArray checksum(QByteArray msgType, QByteArray length, QByteArray datas); + QByteArray transcode(QByteArray datas); + QByteArray unTranscode(QByteArray datas); + void sendCmd(QByteArray cmd, QByteArray datas); + //int interpretResult(QByteArray datas); + //void getResponse(); + bool resetCoordinator(); + void interpretResult(); + void infoOutput(ResponseProperties *); + void debug(QString text, int level); + void signal_handler(int signal); + + // commands + void getVersion(); + + QByteArray datas; //datas not complete waiting reading new datas + QMap resultCodes; + QMap > 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", ""}} + }; + + +/* QList responseListCode + { + "004D", + "8000", + "8001", + "8002", + "8003", + "8004", + "8005", + "8006", + "8007", + "8010", + "8014", + "8024", + "8030", + "8031", + "8040", + "8041", + "8042", + "8043", + "8044", + "8045", + "8046", + "802B", + "802C", + "8047", + "8048", + "804A", + "804B", + "804E", + "8140", + "8008", + "8009", + "8011", + "8012", + "8015", + "8017", + "8028", + "8035", + "8049", + "8052", + "8060", + "8061", + "8062", + "8063", + "8085", + "8095", + "80A0", + "80A1", + "80A2", + "80A3", + "80A4", + "80A6", + "80A7", + "8100", + "8101", + "8102", + "8110", + "8120", + "8122", + "8531", + "8701", + "8702", + "9999" + }; +*/ + //ZigbeeMgr serial; + QMap 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"} + }; +}; + + + +#endif diff --git a/zigateplugin/zigateplugin.json b/zigateplugin/zigateplugin.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/zigateplugin/zigateplugin.json @@ -0,0 +1 @@ +{} diff --git a/zigateplugin/zigateplugin.pro b/zigateplugin/zigateplugin.pro new file mode 100644 index 0000000..9e2b609 --- /dev/null +++ b/zigateplugin/zigateplugin.pro @@ -0,0 +1,37 @@ +TEMPLATE = lib +CONFIG += plugin +#QT += widgets + +QT += core +QT -= gui +QT += serialport +QT += concurrent + +INCLUDEPATH += ../zigbeemanager + +HEADERS = zigateplugin.h \ + interface.h \ + version.h \ + responseClasses.h \ + # library.h \ + serial.h \ + ../../zigbeemanager/zigbeeManagerinterface.h + + +SOURCES = zigateplugin.cpp \ + zigatecmd.cpp \ + zigateInit.cpp \ + # library.cpp \ + serial.cpp \ + + +TARGET = $$qtLibraryTarget(zigateplugin) +DESTDIR = ../zigbeemanager/plugins + +EXAMPLE_FILES = zigateplugin.json + +# install +target.path = ../zigbeemanager/plugins +INSTALLS += target + +CONFIG += install_ok # Do not cargo-cult this! diff --git a/zigateplugin/zigateplugin.pro.user b/zigateplugin/zigateplugin.pro.user new file mode 100644 index 0000000..742b9c9 --- /dev/null +++ b/zigateplugin/zigateplugin.pro.user @@ -0,0 +1,424 @@ + + + + + + EnvironmentId + {a3117c94-e673-4dca-aa4c-050bbea034fe} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + false + true + false + 1 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + true + true + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 2 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Qt 5.15.7 (qt5) + Qt 5.15.7 (qt5) + {a8a6d767-5e05-45c7-b70b-532f99112b6a} + 0 + 0 + 0 + + 0 + /home/daniel/develope/zigateplugin/plugin/../build-plugin-Qt_5_15_7_qt5-Debug + /home/daniel/develope/zigateplugin/build-plugin-Qt_5_15_7_qt5-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + /home/daniel/develope/zigateplugin/plugin/../build-plugin-Qt_5_15_7_qt5-Release + /home/daniel/develope/zigateplugin/build-plugin-Qt_5_15_7_qt5-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + /home/daniel/develope/zigateplugin/plugin/../build-plugin-Qt_5_15_7_qt5-Profile + /home/daniel/develope/zigateplugin/build-plugin-Qt_5_15_7_qt5-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + ProjectExplorer.CustomExecutableRunConfiguration + + false + true + false + true + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop + Desktop + Desktop + {893f9ca6-0efa-4c08-a4a6-5a818f60a8a0} + 0 + 0 + 0 + + 0 + /home/daniel/develope/zigateplugin/plugin/../build-plugin-Desktop-Debug + /home/daniel/develope/zigateplugin/build-plugin-Desktop-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + /home/daniel/develope/zigateplugin/plugin/../build-plugin-Desktop-Release + /home/daniel/develope/zigateplugin/build-plugin-Desktop-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + /home/daniel/develope/zigateplugin/plugin/../build-plugin-Desktop-Profile + /home/daniel/develope/zigateplugin/build-plugin-Desktop-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + ProjectExplorer.CustomExecutableRunConfiguration + + false + true + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/zigbeemanager.pro b/zigbeemanager.pro new file mode 100644 index 0000000..2bcb45f --- /dev/null +++ b/zigbeemanager.pro @@ -0,0 +1,5 @@ +#! [0] +TEMPLATE = subdirs +SUBDIRS = zigbeemanager \ + zigateplugin +#! [0] diff --git a/LICENSE b/zigbeemanager/LICENSE similarity index 100% rename from LICENSE rename to zigbeemanager/LICENSE diff --git a/README.md b/zigbeemanager/README.md similarity index 100% rename from README.md rename to zigbeemanager/README.md diff --git a/docs/JN-AN-1223-ZigBee-IoT-Gateway-Control-Bridge-UserGuide-1014.pdf b/zigbeemanager/docs/JN-AN-1223-ZigBee-IoT-Gateway-Control-Bridge-UserGuide-1014.pdf similarity index 100% rename from docs/JN-AN-1223-ZigBee-IoT-Gateway-Control-Bridge-UserGuide-1014.pdf rename to zigbeemanager/docs/JN-AN-1223-ZigBee-IoT-Gateway-Control-Bridge-UserGuide-1014.pdf diff --git a/docs/Stack_zigbee_3.ods b/zigbeemanager/docs/Stack_zigbee_3.ods similarity index 100% rename from docs/Stack_zigbee_3.ods rename to zigbeemanager/docs/Stack_zigbee_3.ods diff --git a/docs/ZiGate_API_Developper.ods b/zigbeemanager/docs/ZiGate_API_Developper.ods similarity index 100% rename from docs/ZiGate_API_Developper.ods rename to zigbeemanager/docs/ZiGate_API_Developper.ods diff --git a/docs/docs-05-3474-21-0csg-zigbee-specification.pdf b/zigbeemanager/docs/docs-05-3474-21-0csg-zigbee-specification.pdf similarity index 100% rename from docs/docs-05-3474-21-0csg-zigbee-specification.pdf rename to zigbeemanager/docs/docs-05-3474-21-0csg-zigbee-specification.pdf diff --git a/docs/properties.txt b/zigbeemanager/docs/properties.txt similarity index 100% rename from docs/properties.txt rename to zigbeemanager/docs/properties.txt diff --git a/zigbeemanager/interface.h b/zigbeemanager/interface.h new file mode 100644 index 0000000..3bc6396 --- /dev/null +++ b/zigbeemanager/interface.h @@ -0,0 +1,21 @@ +#ifndef INTERFACE_H +#define INTERFACE_H + +#include + +class ZigbeeManagerInterface +{ +public: + virtual ~ZigbeeManagerInterface() = default; + virtual bool initPlugin() = 0; +}; + + +QT_BEGIN_NAMESPACE + +#define ZigbeeManagerInterface_iid "org.zigbeeManagerInterface" + +Q_DECLARE_INTERFACE(ZigbeeManagerInterface, ZigbeeManagerInterface_iid) +QT_END_NAMESPACE + +#endif diff --git a/zigbeemanager/main.cpp b/zigbeemanager/main.cpp new file mode 100644 index 0000000..4ef15c1 --- /dev/null +++ b/zigbeemanager/main.cpp @@ -0,0 +1,13 @@ +#include + +#include "zigbeemanager.h" +#include "interface.h" + +int main(int argv, char *args[]) +{ + QCoreApplication app(argv, args); + + ZigbeeManager zigbeeManager; + + return app.exec(); +} diff --git a/zigbeemanager/zigbeemanager.cpp b/zigbeemanager/zigbeemanager.cpp new file mode 100644 index 0000000..6a6ee55 --- /dev/null +++ b/zigbeemanager/zigbeemanager.cpp @@ -0,0 +1,45 @@ +#include "zigbeemanager.h" + +#include +#include +#include + +using namespace std; + +ZigbeeManager::ZigbeeManager() +{ + if (!loadPlugin()) { + cout << "Error" << "Could not load the plugin" << endl; + } +} + +bool ZigbeeManager::loadPlugin() +{ + uint i = 0; + + QDir pluginsDir(QCoreApplication::applicationDirPath()); + pluginsDir.cd("plugins"); + const QStringList entries = pluginsDir.entryList(QDir::Files); + + for (const QString &fileName : entries) + { + QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName)); + QObject *plugin = pluginLoader.instance(); + if (plugin) + { + zigbeeManagerInterface.insert(i, qobject_cast(plugin)); + if (zigbeeManagerInterface[i]) + { + zigbeeManagerInterface[i]->initPlugin(); + return true; + } + pluginLoader.unload(); + }else + { + cout << pluginLoader.errorString().toStdString() << endl; + } + } + + return false; +} + diff --git a/zigbeemanager/zigbeemanager.h b/zigbeemanager/zigbeemanager.h new file mode 100644 index 0000000..29d90f8 --- /dev/null +++ b/zigbeemanager/zigbeemanager.h @@ -0,0 +1,28 @@ +#ifndef ZIGBEEMANAGER_H +#define ZIGBEEMANAGER_H + +#include "interface.h" +#include +#include + +QT_BEGIN_NAMESPACE +class QString; +QT_END_NAMESPACE + +class ZigbeeManager : public QObject +{ + Q_OBJECT + +public: + ZigbeeManager(); + +/*private slots: + void sendEcho(); +*/ +private: + bool loadPlugin(); + + QList zigbeeManagerInterface; +}; + +#endif diff --git a/zigbeemanager/zigbeemanager.pro b/zigbeemanager/zigbeemanager.pro new file mode 100644 index 0000000..becf5b7 --- /dev/null +++ b/zigbeemanager/zigbeemanager.pro @@ -0,0 +1,21 @@ +QT += core + +HEADERS = zigbeemanager.h \ + interface.h +SOURCES = zigbeemanager.cpp \ + main.cpp + +TARGET = zigbeemanager +QMAKE_PROJECT_NAME = zigbeemanager +win32 { + CONFIG(debug, release|debug):DESTDIR = ../debug/ + CONFIG(release, release|debug):DESTDIR = ../release/ +} else { + DESTDIR = ./ +} + +# install +target.path = ./ +INSTALLS += target + +CONFIG += install_ok # Do not cargo-cult this! diff --git a/zigbeemanager/zigbeemanager.pro.user b/zigbeemanager/zigbeemanager.pro.user new file mode 100644 index 0000000..59d0d70 --- /dev/null +++ b/zigbeemanager/zigbeemanager.pro.user @@ -0,0 +1,426 @@ + + + + + + EnvironmentId + {a3117c94-e673-4dca-aa4c-050bbea034fe} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + false + true + false + 1 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + true + true + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 2 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Desktop + {893f9ca6-0efa-4c08-a4a6-5a818f60a8a0} + 0 + 0 + 0 + + 0 + /home/daniel/develope/echoplugin/echowindow/../build-echowindow-Desktop-Debug + /home/daniel/develope/echoplugin/build-echowindow-Desktop-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + /home/daniel/develope/echoplugin/echowindow/../build-echowindow-Desktop-Release + /home/daniel/develope/echoplugin/build-echowindow-Desktop-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + /home/daniel/develope/echoplugin/echowindow/../build-echowindow-Desktop-Profile + /home/daniel/develope/echoplugin/build-echowindow-Desktop-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:/home/daniel/develope/echoplugin/echowindow/echowindow.pro + /home/daniel/develope/echoplugin/echowindow/echowindow.pro + false + true + true + false + true + /home/daniel/develope/echoplugin/build-echowindow-Desktop-Debug/../ + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop + Qt 5.15.7 (qt5) + Qt 5.15.7 (qt5) + {a8a6d767-5e05-45c7-b70b-532f99112b6a} + 0 + 0 + 0 + + 0 + /home/daniel/develope/echoplugin/echowindow/../build-echowindow-Qt_5_15_7_qt5-Debug + /home/daniel/develope/echoplugin/build-echowindow-Qt_5_15_7_qt5-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + /home/daniel/develope/echoplugin/echowindow/../build-echowindow-Qt_5_15_7_qt5-Release + /home/daniel/develope/echoplugin/build-echowindow-Qt_5_15_7_qt5-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + /home/daniel/develope/echoplugin/echowindow/../build-echowindow-Qt_5_15_7_qt5-Profile + /home/daniel/develope/echoplugin/build-echowindow-Qt_5_15_7_qt5-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + ProjectExplorer.CustomExecutableRunConfiguration + + false + true + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/zigbeemanager.spec b/zigbeemanager/zigbeemanager.spec similarity index 100% rename from zigbeemanager.spec rename to zigbeemanager/zigbeemanager.spec