/// <summary> /// 上报固件版本信息 /// </summary> /// <param name="version">固件版本</param> public void ReportVersion(string version) { Dictionary <string, object> node = new Dictionary <string, object>(); node.Add("fw_version", version); node.Add("sw_version", version); DeviceEvent deviceEvent = new DeviceEvent(); deviceEvent.eventType = "version_report"; deviceEvent.paras = node; deviceEvent.serviceId = "$ota"; deviceEvent.eventTime = IotUtil.GetEventTime(); iotDevice.GetClient().ReportEvent(deviceEvent); }
public void RequestTimeSync() { Dictionary <string, object> node = new Dictionary <string, object>(); node.Add("device_send_time", IotUtil.GetTimeStamp()); DeviceEvent deviceEvent = new DeviceEvent(); deviceEvent.eventType = "time_sync_request"; deviceEvent.paras = node; deviceEvent.serviceId = "$time_sync"; deviceEvent.eventTime = IotUtil.GetEventTime(); iotDevice.GetClient().messagePublishListener = this; iotDevice.GetClient().ReportEvent(deviceEvent); }
/// <summary> /// 上报升级状态 /// </summary> /// <param name="result">升级结果</param> /// <param name="progress">升级进度0-100</param> /// <param name="version">当前版本</param> /// <param name="description">具体失败的原因,可选参数</param> public void ReportOtaStatus(int result, int progress, string version, string description) { Dictionary <string, object> node = new Dictionary <string, object>(); node.Add("result_code", result); node.Add("progress", progress); if (description != null) { node.Add("description", description); } node.Add("version", version); DeviceEvent deviceEvent = new DeviceEvent(); deviceEvent.eventType = "upgrade_progress_report"; deviceEvent.paras = node; deviceEvent.serviceId = "$ota"; deviceEvent.eventTime = IotUtil.GetEventTime(); iotDevice.GetClient().ReportEvent(deviceEvent); }
/// <summary> /// 触发属性变化,SDK会上报变化的属性 /// </summary> /// <param name="serviceId">服务id</param> /// <param name="properties">属性列表</param> internal void FirePropertiesChanged(string serviceId, string[] properties) { AbstractService deviceService = GetService(serviceId); if (deviceService == null) { return; } Dictionary <string, object> props = deviceService.OnRead(properties); ServiceProperty serviceProperty = new ServiceProperty(); serviceProperty.serviceId = deviceService.ServiceId; serviceProperty.properties = props; serviceProperty.eventTime = IotUtil.GetEventTime(); List <ServiceProperty> listProperties = new List <ServiceProperty>(); listProperties.Add(serviceProperty); client.ReportProperties(listProperties); }