private void OnPropertiesGet(RawMessage message)
        {
            string requestId = IotUtil.GetRequestId(message.Topic);

            PropsGet propsGet = JsonUtil.ConvertJsonStringToObject <PropsGet>(message.ToString());

            if (propsGet == null)
            {
                return;
            }

            if (propertyListener != null && (propsGet.deviceId == null || propsGet.deviceId == this.deviceId))
            {
                propertyListener.OnPropertiesGet(requestId, propsGet.serviceId);

                return;
            }

            device.OnPropertiesGet(requestId, propsGet);
        }
        /// <summary>
        /// 属性查询回调,由SDK自动调用
        /// </summary>
        /// <param name="requestId">请求ID</param>
        /// <param name="propsGet">属性查询请求</param>
        public void OnPropertiesGet(string requestId, PropsGet propsGet)
        {
            List <ServiceProperty> serviceProperties = new List <ServiceProperty>();

            // 查询所有
            if (propsGet.serviceId == null)
            {
                foreach (KeyValuePair <string, AbstractService> kv in services)
                {
                    IService deviceService = GetService(kv.Key);
                    if (deviceService != null)
                    {
                        Dictionary <string, object> properties      = deviceService.OnRead();
                        ServiceProperty             serviceProperty = new ServiceProperty();
                        serviceProperty.properties = properties;
                        serviceProperty.serviceId  = kv.Key;
                        serviceProperties.Add(serviceProperty);
                    }
                }
            }
            else
            {
                IService deviceService = GetService(propsGet.serviceId);

                if (deviceService != null)
                {
                    Dictionary <string, object> properties      = deviceService.OnRead();
                    ServiceProperty             serviceProperty = new ServiceProperty();
                    serviceProperty.properties = properties;
                    serviceProperty.serviceId  = propsGet.serviceId;
                    serviceProperties.Add(serviceProperty);
                }
            }

            client.RespondPropsGet(requestId, serviceProperties);
        }
Esempio n. 3
0
 public override void OnSubdevPropertiesGet(string requestId, PropsGet propsGet)
 {
     // 不建议平台直接读子设备的属性,这里直接返回失败
     Log.Error("not supporte onSubdevPropertiesGet");
     GetClient().RespondPropsSet(requestId, IotResult.FAIL);
 }
Esempio n. 4
0
 /// <summary>
 /// 子设备读属性,网关需要转发给子设备,需要子类实现
 /// </summary>
 /// <param name="requestId">请求ID</param>
 /// <param name="propsGet">属性查询</param>
 public abstract void OnSubdevPropertiesGet(string requestId, PropsGet propsGet);