| | |
| | | //2020-05-14 订阅主题质量改为0 |
| | | var topicFilterBusGateWayToClient = new MqttTopicFilter() |
| | | { |
| | | Topic = $"/BusGateWayToClient/{MqttInfoConfig.Current.HomeGatewayInfo.id}/#", |
| | | Topic = $"/BusGateWayToClient/{MqttInfoConfig.Current.HomeGatewayInfo.gatewayId}/#", |
| | | QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce |
| | | //QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.ExactlyOnce |
| | | }; |
| | |
| | | //新挤下线主题方案 收到挤下线主题 |
| | | ReceiveNotifySqueezeAsync(mMes); |
| | | } |
| | | else if (topic == $"/BusGateWayToClient/{MqttInfoConfig.Current.HomeGatewayInfo.id}/NotifyBusGateWayInfoChange") |
| | | else if (topic == $"/BusGateWayToClient/{MqttInfoConfig.Current.HomeGatewayInfo.gatewayId}/NotifyBusGateWayInfoChange") |
| | | {//网关上线,需要更新aeskey |
| | | //收到网关上线消息主题 |
| | | ReceiveNotifyBusGateWayInfoChange(); |
| | | } |
| | | else if (topic == $"/BusGateWayToClient/{MqttInfoConfig.Current.HomeGatewayInfo.id}/NotifyGateWayOffline") |
| | | else if (topic == $"/BusGateWayToClient/{MqttInfoConfig.Current.HomeGatewayInfo.gatewayId}/NotifyGateWayOffline") |
| | | {//网关掉线 |
| | | //----第二步:读取账号下面的网关列表 |
| | | ReceiveNotifyGateWayOffline(); |
| | | } |
| | | else if (topic == $"/BusGateWayToClient/{MqttInfoConfig.Current.HomeGatewayInfo.id}/Common/CheckGateway") |
| | | else if (topic == $"/BusGateWayToClient/{MqttInfoConfig.Current.HomeGatewayInfo.gatewayId}/Common/CheckGateway") |
| | | { |
| | | var ss = Encoding.UTF8.GetString(e.ApplicationMessage.Payload); |
| | | ReceiveCheckGateway(ss); |
| | |
| | | switch (optionType) |
| | | { |
| | | case 0: |
| | | topicName = $"/ClientToBusGateWay/{MqttInfoConfig.Current.HomeGatewayInfo.id}/Common/ON"; |
| | | topicName = $"/ClientToBusGateWay/{MqttInfoConfig.Current.HomeGatewayInfo.gatewayId}/Common/ON"; |
| | | if (!string.IsNullOrEmpty(mqttEncryptKey)) |
| | | { |
| | | message = Securitys.EncryptionService.AesEncryptPayload(message, mqttEncryptKey); |
| | |
| | | await RemoteMqttClient.PublishAsync(new MqttApplicationMessage { Topic = topicName, Payload = message, Retain = false, QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce }); |
| | | break; |
| | | case 3: |
| | | topicName = $"/ClientToBusGateWay/{MqttInfoConfig.Current.HomeGatewayInfo.id}/Common/CheckGateway"; |
| | | topicName = $"/ClientToBusGateWay/{MqttInfoConfig.Current.HomeGatewayInfo.gatewayId}/Common/CheckGateway"; |
| | | Utlis.WriteLine("CheckGateway"); |
| | | await RemoteMqttClient.PublishAsync(new MqttApplicationMessage { Topic = topicName, Retain = false, QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce }); |
| | | break; |