解决thingsboard PubAck问题

This commit is contained in:
iioter 2022-11-09 09:48:54 +08:00
parent 649da528c0
commit dd1f802390

View File

@ -264,7 +264,7 @@ namespace Plugin
await Client.PublishAsync(new MqttApplicationMessageBuilder() await Client.PublishAsync(new MqttApplicationMessageBuilder()
.WithTopic(_tbRpcTopic) .WithTopic(_tbRpcTopic)
.WithPayload(JsonConvert.SerializeObject(tBRpcResponse)) .WithPayload(JsonConvert.SerializeObject(tBRpcResponse))
.WithQualityOfServiceLevel(MqttQualityOfServiceLevel.ExactlyOnce).Build()); .WithQualityOfServiceLevel(MqttQualityOfServiceLevel.AtMostOnce).Build());
} }
private async Task ResponseTcRpcAsync(TCRpcRequest tCRpcResponse) private async Task ResponseTcRpcAsync(TCRpcRequest tCRpcResponse)
@ -320,7 +320,7 @@ namespace Plugin
{ {
if (Client.IsConnected) if (Client.IsConnected)
return Client.PublishAsync(new MqttApplicationMessageBuilder() return Client.PublishAsync(new MqttApplicationMessageBuilder()
.WithTopic($"devices/{deviceName}/attributes").WithPayload(JsonConvert.SerializeObject(obj)) .WithTopic($"devices/{deviceName}/attributes").WithPayload(JsonConvert.SerializeObject(obj)).WithQualityOfServiceLevel(MqttQualityOfServiceLevel.AtMostOnce)
.Build()); .Build());
} }
catch (Exception ex) catch (Exception ex)
@ -522,7 +522,7 @@ namespace Plugin
case IoTPlatformType.ThingsBoard: case IoTPlatformType.ThingsBoard:
await Client.PublishAsync(new MqttApplicationMessageBuilder().WithTopic("v1/gateway/telemetry") await Client.PublishAsync(new MqttApplicationMessageBuilder().WithTopic("v1/gateway/telemetry")
.WithPayload(JsonConvert.SerializeObject(sendModel)) .WithPayload(JsonConvert.SerializeObject(sendModel))
.WithQualityOfServiceLevel(MqttQualityOfServiceLevel.ExactlyOnce).Build()); .WithQualityOfServiceLevel(MqttQualityOfServiceLevel.AtMostOnce).Build());
break; break;
case IoTPlatformType.IoTSharp: case IoTPlatformType.IoTSharp:
foreach (var payload in sendModel[device.DeviceName]) foreach (var payload in sendModel[device.DeviceName])