/* SPDX-License-Identifier: BSD-3-Clause */
/*
 * Copyright 2020 Raritan Inc. All rights reserved.
 */

#ifndef __ZIGBEEDEVICE_IDL__
#define __ZIGBEEDEVICE_IDL__

#include <Event.idl>

/** Zigbee */
module zigbee {
    /** Zigbee Device */
    interface ZigbeeDevice {

        /**
         * Supported Cluster Types
         * defined by zigbee alliance in the zigbee cluster library specification
         */
        constant int CLUSTER_BASIC               = 0x0000;
        constant int CLUSTER_POWER_CONFIGURATION = 0x0001;
        constant int CLUSTER_RSSI                = 0x000B;
        constant int CLUSTER_CONTACT_CLOSURE     = 0x000F;
        constant int CLUSTER_TEMPERATURE         = 0x0402;
        constant int CLUSTER_HUMIDITY            = 0x0405;

        /** Device MetaData*/
        structure MetaData {
            int sourceId;                       ///< the device source ID
            vector<int> clusters;               ///< the clusters which are reporting to this device
            int preferredSlot;                  ///< the slot which should be assigned to the first sensor
        };

        /** Cluster Value */
        structure ClusterValue {
            int id;                             ///< the cluster ID
            int endpoint;                       ///< the endpoint ID
            int attribute;                      ///< the reported attribute. some clusters have multiple reporting attributes
            time timestamp;                     ///< the time when the cluster value was updated. UNIX timestamp (UTC)
            string value;                       ///< the value which was reported.
        };

        /** Cluster Value Changed Event*/
        valueobject ClusterDataEvent extends idl.Event {
            ClusterValue value;                 ///< the cluster value
        };

        /**
         * Retrieve Dongle MetaData
         *
         * @return MetaData
         */
        MetaData getMetaData();

        /**
         * Retrieve the last cluster values
         * Needed for battery voltage (only reported all 12h)
         *
         * @return list of all cluster values currently reported
         */
        vector<ClusterValue> getClusterValues();
    };

}

#endif /* __ZIGBEEDEVICE_IDL__ */

