#include "zigateBackend.h"
#include "serial.inc.h"

#include <QByteArray>

extern ZigateBackend zigateBkd;
extern SerialManager serialManager;
extern QHash <QString, ResponseProperties *> responseListIndex;

using namespace std;

bool ZigateBackend::initBackend()
{
    bool returnCode = false;
    QString var;
    ResponseProperties * temp;

    foreach (var, responseListCode)
    {
        temp = new ResponseProperties();
        temp->manager = &defaultManager;
        responseListIndex.insert(var, 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}},                                  // <uint8_t>
        {1, {"Sequence number", 1, 0}},                         // <uint8_t>
        {2, {"Packet Type", 2, 0}},                             // <uint16_t>
        {3, {"Optional additional error information", -1, 5}}    // <string>
    };
    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}},      // uint8_t       TODO
        {8, {"Destination address", 2}},           // uint16_t or uint64_t
        {9, {"Payload size", 1}},                  // uint8_t
        {10, {"Payload", -1}}                      // 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, }},
        {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}}  // <Timestamp UTC: uint32_t> 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}}                                   // 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}},                          // 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}},                // uint8_t
        {1, {"Status", 1}},                         // 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, }}                             // 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;

    serialManager.initSerial();
    connect(&serialManager, SIGNAL(datasReady(QByteArray)), this, SLOT(interpretResult(QByteArray)));

    resetCoordinator();
    getVersion();
    return returnCode;
}

void infoOutput(Response *object)
{
    cout << object->code.toHex().toStdString() << " : " <<  object->description.toStdString() << endl;

}