| | |
| | | QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce |
| | | }; |
| | | |
| | | |
| | | #region 数据更新推送主题 |
| | | //appHomeRefresh:住宅数据刷新通知--杨涛 |
| | | var appHomeRefresh = new MqttTopicFilter() |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 订阅绑定第三方iot账号结果 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static async Task<bool> SubscribeAsync3tyIotbind() |
| | | { |
| | | var topicFilter = new MqttTopicFilter() |
| | | { |
| | | Topic = $"/user/{UserInfo.Current.ID}/app/third/bind/send", |
| | | QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce |
| | | }; |
| | | var result = await RemoteMqttClient.SubscribeAsync(topicFilter); |
| | | if (result.Items[0].ResultCode == MQTTnet.Client.Subscribing.MqttClientSubscribeResultCode.GrantedQoS0) |
| | | { |
| | | Utlis.WriteLine("订阅绑定第三方iot账号结果成功!"); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | /// <summary> |
| | | /// 取消订阅绑定第三方iot账号结果 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static async Task<bool> UnsubscribeAsync3tyIotbind() |
| | | { |
| | | string[] strs = new string[] { |
| | | $"/user/{UserInfo.Current.ID}/app/third/bind/send" |
| | | }; |
| | | |
| | | var result = await RemoteMqttClient.UnsubscribeAsync(strs); |
| | | |
| | | if (result.Items[0].ReasonCode == MQTTnet.Client.Unsubscribing.MqttClientUnsubscribeResultCode.Success) |
| | | { |
| | | Utlis.WriteLine("取消订阅绑定第三方iot账号结果成功!"); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | /// <summary> |
| | | /// 绑定第三方平台接收回调事件 |
| | | /// </summary> |
| | | public static Action Bind3tyIotAction; |
| | | |
| | | /// <summary> |
| | | /// 启动远程Mqtt |
| | |
| | | //新挤下线主题方案 收到挤下线主题 |
| | | ReceiveNotifySqueezeAsync(mMes); |
| | | } |
| | | //绑定第三方平台结果通知 |
| | | else if(topic == $"/user/{UserInfo.Current.ID}/app/third/bind/send") |
| | | { |
| | | var revString = Encoding.UTF8.GetString(e.ApplicationMessage.Payload); |
| | | Bind3tyIotAction?.Invoke(); |
| | | } |
| | | //设备在线离线状态推送 |
| | | else if(topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/son/session/online") |
| | | else if (topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/son/session/online") |
| | | { |
| | | try |
| | | { |
| | |
| | | //} |
| | | |
| | | } |
| | | catch(Exception ex) |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | } |
| | |
| | | } |
| | | HomePage.LoadEvent_RefreshSecurityStatus(); |
| | | } |
| | | }catch(Exception ex) |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"安防远程信息异常:{ex.Message}"); |
| | | } |
| | |
| | | //Tag 网络状态解析 |
| | | else if (topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/thing/property/send") |
| | | { |
| | | |
| | | var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, tuyaEncryptKey); |
| | | var revString = Encoding.UTF8.GetString(bytes); |
| | | MainPage.Log($"mqtt 状态更新:{revString}"); |
| | | Control.Ins.UpdataFunctionStatus(revString, null, true); |
| | | //Control.Ins.MsgInfoList.Add($"mqtt 状态更新:{revString}"); |
| | | //Control.Ins.MsgInfoList.Add(revString + "\r\n"); |
| | | //if (FunctionList.List.OtherBrandFunction.Find((obj) => obj.sid == updateTemp.sid) == null) |
| | | //{ |
| | | // return; |
| | | //} |
| | | } |
| | | //一端口数据解析 |
| | | else |