| | |
| | | Topic = $"/user/{DB_ResidenceData.Instance.CurrentRegion.RegionID}/app/thing/property/send", |
| | | QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce |
| | | }; |
| | | //App订阅红外宝 / 网关遥控器添加成功通知 |
| | | var pirStatus = new MqttTopicFilter() |
| | | { |
| | | Topic = $"/user/{DB_ResidenceData.Instance.CurrentRegion.RegionID}/app/thing/topo/found", |
| | | QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce |
| | | }; |
| | | //App订阅遥控器自学按键学习成功通知 |
| | | var study = new MqttTopicFilter() |
| | | { |
| | | Topic = $"/user/{DB_ResidenceData.Instance.CurrentRegion.RegionID}/app/thing/event/irCodeStudyDone/up", |
| | | QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce |
| | | }; |
| | | |
| | | Utlis.WriteLine("开始订阅!"); |
| | | var result = await RemoteMqttClient.SubscribeAsync(new MqttTopicFilter[] { topicFilterPush2, topicAlinkStatus }); |
| | | var result = await RemoteMqttClient.SubscribeAsync(new MqttTopicFilter[] { |
| | | pirStatus, |
| | | study, |
| | | topicFilterPush2, topicAlinkStatus }); |
| | | if (result.Items[0].ResultCode == MQTTnet.Client.Subscribing.MqttClientSubscribeResultCode.GrantedQoS0) |
| | | { |
| | | isSubscribeSuccess = true; |
| | |
| | | |
| | | Utlis.WriteLine($"StartCloudMqtt: 开始"); |
| | | |
| | | await Task.Factory.StartNew(async () => { |
| | | await Task.Factory.StartNew((Func<Task>)(async () => { |
| | | try |
| | | { |
| | | #region 初始化远程Mqtt |
| | |
| | | if (RemoteMqttClient.ApplicationMessageReceivedHandler == null) |
| | | { |
| | | //处理接收到的数据 |
| | | RemoteMqttClient.UseApplicationMessageReceivedHandler((e) => { |
| | | RemoteMqttClient.UseApplicationMessageReceivedHandler((Action<MqttApplicationMessageReceivedEventArgs>)((e) => { |
| | | try |
| | | { |
| | | var topic = e.ApplicationMessage.Topic; |
| | | //MainPage.Log($"收到mqtt主题:{topic}"); |
| | | MainPage.Log($"收到mqtt主题:{topic}"); |
| | | //一端口主题处理 |
| | | if (DB_ResidenceData.Instance.GatewayType == 0 && !DB_ResidenceData.Instance.CheckWhetherGatewayIdIsNull()) |
| | | { |
| | |
| | | //新挤下线主题方案 收到挤下线主题 |
| | | ReceiveNotifySqueezeAsync(mMes); |
| | | } |
| | | //App订阅红外宝/网关遥控器添加成功通知 |
| | | else if (topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.RegionID}/app/thing/topo/found") |
| | | { |
| | | var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, tuyaEncryptKey); |
| | | var revString = Encoding.UTF8.GetString(bytes); |
| | | HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.controldata = revString; |
| | | //ReceiveCheckGateway(ss); |
| | | //return; |
| | | } |
| | | //App订阅遥控器自学按键学习成功通知 |
| | | else if (topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.RegionID}/app/thing/event/irCodeStudyDone/up") |
| | | { |
| | | var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, tuyaEncryptKey); |
| | | var revString = Encoding.UTF8.GetString(bytes); |
| | | HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.buttondata = revString; |
| | | //ReceiveCheckGateway(ss); |
| | | //return; |
| | | } |
| | | //A网关设备状态-包含涂鸦设备 |
| | | else if (topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.RegionID}/app/thing/property/send") |
| | | { |
| | |
| | | } |
| | | } |
| | | catch { } |
| | | }); |
| | | })); |
| | | } |
| | | |
| | | //(2)DisconnectedHandler |
| | |
| | | Utlis.WriteLine($"StartCloudMqtt: 结束"); |
| | | } |
| | | |
| | | }); |
| | | })); |
| | | } |
| | | |
| | | |