Example #1
0
        /// <summary>
        /// Get the simple descriptor for an endpoint and create the <see cref="ZigBeeEndpoint">
        ///
        /// <param name="endpointId">the endpoint id to request</param>
        /// <returns>the newly created <see cref="ZigBeeEndpoint"> for the endpoint, or null on error</returns>
        /// </summary>
        private async Task <ZigBeeEndpoint> GetSimpleDescriptor(byte endpointId)
        {
            SimpleDescriptorRequest simpleDescriptorRequest = new SimpleDescriptorRequest();

            simpleDescriptorRequest.DestinationAddress = new ZigBeeEndpointAddress((ushort)Node.NetworkAddress);
            simpleDescriptorRequest.NwkAddrOfInterest  = Node.NetworkAddress;
            simpleDescriptorRequest.Endpoint           = endpointId;

            CommandResult response = await NetworkManager.SendTransaction(simpleDescriptorRequest, simpleDescriptorRequest);

            SimpleDescriptorResponse simpleDescriptorResponse = (SimpleDescriptorResponse)response.Response;

            Log.Debug("{IeeeAddress}: Node SVC Discovery: SimpleDescriptorResponse returned {Response}", Node.IeeeAddress, simpleDescriptorResponse);

            if (simpleDescriptorResponse == null)
            {
                return(null);
            }

            if (simpleDescriptorResponse.Status == ZdoStatus.SUCCESS)
            {
                ZigBeeEndpoint   endpoint         = new ZigBeeEndpoint(Node, endpointId);
                SimpleDescriptor simpleDescriptor = simpleDescriptorResponse.SimpleDescriptor;

                endpoint.ProfileId     = simpleDescriptor.ProfileId;
                endpoint.DeviceId      = simpleDescriptor.DeviceId;
                endpoint.DeviceVersion = simpleDescriptor.DeviceVersion;
                endpoint.SetInputClusterIds(simpleDescriptor.InputClusterList.Select(id => id).ToList());
                endpoint.SetOutputClusterIds(simpleDescriptor.OutputClusterList.Select(id => id).ToList());

                return(endpoint);
            }

            return(null);
        }