Родитель
6d7f2c73c8
Коммит
effa757dec
|
@ -21,7 +21,7 @@ This is an SDK for Azure IoT Hub using MQTT broker.</description>
|
|||
<dependencies>
|
||||
<dependency id="nanoFramework.CoreLibrary" version="1.12.0" />
|
||||
<dependency id="nanoFramework.Json" version="2.2.72" />
|
||||
<dependency id="nanoFramework.M2Mqtt" version="5.1.53" />
|
||||
<dependency id="nanoFramework.M2Mqtt" version="5.1.59" />
|
||||
<dependency id="nanoFramework.System.Net.Http" version="1.5.54" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
|
|
|
@ -69,8 +69,8 @@
|
|||
<HintPath>..\packages\nanoFramework.Json.2.2.72\lib\nanoFramework.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="nanoFramework.M2Mqtt, Version=5.1.53.29824, Culture=neutral, PublicKeyToken=c07d481e9758c731">
|
||||
<HintPath>..\packages\nanoFramework.M2Mqtt.5.1.53\lib\nanoFramework.M2Mqtt.dll</HintPath>
|
||||
<Reference Include="nanoFramework.M2Mqtt, Version=5.1.59.36480, Culture=neutral, PublicKeyToken=c07d481e9758c731">
|
||||
<HintPath>..\packages\nanoFramework.M2Mqtt.5.1.59\lib\nanoFramework.M2Mqtt.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="nanoFramework.Runtime.Events, Version=1.11.1.42088, Culture=neutral, PublicKeyToken=c07d481e9758c731">
|
||||
|
@ -106,6 +106,9 @@
|
|||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="packages.lock.json" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
|
||||
<ProjectExtensions>
|
||||
<ProjectCapabilities>
|
||||
|
|
|
@ -309,7 +309,13 @@ namespace nanoFramework.Azure.Devices.Client
|
|||
public Twin GetTwin(CancellationToken cancellationToken = default)
|
||||
{
|
||||
_twinReceived = false;
|
||||
_mqttc.Publish($"{TwinDesiredPropertiesTopic}?$rid={Guid.NewGuid()}", Encoding.UTF8.GetBytes(""), MqttQoSLevel.AtLeastOnce, false);
|
||||
_mqttc.Publish(
|
||||
$"{TwinDesiredPropertiesTopic}?$rid={Guid.NewGuid()}",
|
||||
Encoding.UTF8.GetBytes(""),
|
||||
null,
|
||||
new ArrayList(),
|
||||
MqttQoSLevel.AtLeastOnce,
|
||||
false);
|
||||
|
||||
while (!_twinReceived && !cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
|
@ -329,7 +335,13 @@ namespace nanoFramework.Azure.Devices.Client
|
|||
{
|
||||
string twin = reported.ToJson();
|
||||
Debug.WriteLine($"update twin: {twin}");
|
||||
var rid = _mqttc.Publish($"{TwinReportedPropertiesTopic}?$rid={Guid.NewGuid()}", Encoding.UTF8.GetBytes(twin), MqttQoSLevel.AtLeastOnce, false);
|
||||
var rid = _mqttc.Publish(
|
||||
$"{TwinReportedPropertiesTopic}?$rid={Guid.NewGuid()}",
|
||||
Encoding.UTF8.GetBytes(twin),
|
||||
null,
|
||||
new ArrayList(),
|
||||
MqttQoSLevel.AtLeastOnce,
|
||||
false);
|
||||
ConfirmationStatus conf = new(rid);
|
||||
_waitForConfirmation.Add(conf);
|
||||
_ioTHubStatus.Status = Status.TwinUpdated;
|
||||
|
@ -382,7 +394,13 @@ namespace nanoFramework.Azure.Devices.Client
|
|||
topic += $"$.sub={dtdlComponentname}";
|
||||
}
|
||||
|
||||
var rid = _mqttc.Publish(topic, Encoding.UTF8.GetBytes(message), QosLevel, false);
|
||||
var rid = _mqttc.Publish(
|
||||
topic,
|
||||
Encoding.UTF8.GetBytes(message),
|
||||
null,
|
||||
new ArrayList(),
|
||||
QosLevel,
|
||||
false);
|
||||
ConfirmationStatus conf = new(rid);
|
||||
_waitForConfirmation.Add(conf);
|
||||
|
||||
|
@ -470,11 +488,23 @@ namespace nanoFramework.Azure.Devices.Client
|
|||
try
|
||||
{
|
||||
var res = mt.Invoke(rid, message);
|
||||
_mqttc.Publish($"$iothub/methods/res/200/?$rid={rid:X}", Encoding.UTF8.GetBytes(res), MqttQoSLevel.AtLeastOnce, false);
|
||||
_mqttc.Publish(
|
||||
$"$iothub/methods/res/200/?$rid={rid:X}",
|
||||
Encoding.UTF8.GetBytes(res),
|
||||
null,
|
||||
new ArrayList(),
|
||||
MqttQoSLevel.AtLeastOnce,
|
||||
false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_mqttc.Publish($"$iothub/methods/res/504/?$rid={rid:X}", Encoding.UTF8.GetBytes($"{{\"Exception:\":\"{ex}\"}}"), MqttQoSLevel.AtLeastOnce, false);
|
||||
_mqttc.Publish(
|
||||
$"$iothub/methods/res/504/?$rid={rid:X}",
|
||||
Encoding.UTF8.GetBytes($"{{\"Exception:\":\"{ex}\"}}"),
|
||||
null,
|
||||
new ArrayList(),
|
||||
MqttQoSLevel.AtLeastOnce,
|
||||
false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<packages>
|
||||
<package id="nanoFramework.CoreLibrary" version="1.12.0" targetFramework="netnanoframework10" />
|
||||
<package id="nanoFramework.Json" version="2.2.72" targetFramework="netnano1.0" />
|
||||
<package id="nanoFramework.M2Mqtt" version="5.1.53" targetFramework="netnano1.0" />
|
||||
<package id="nanoFramework.M2Mqtt" version="5.1.59" targetFramework="netnano1.0" />
|
||||
<package id="nanoFramework.Runtime.Events" version="1.11.1" targetFramework="netnano1.0" />
|
||||
<package id="nanoFramework.Runtime.Native" version="1.5.4" targetFramework="netnanoframework10" />
|
||||
<package id="nanoFramework.System.Collections" version="1.4.0" targetFramework="netnanoframework10" />
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
},
|
||||
"nanoFramework.M2Mqtt": {
|
||||
"type": "Direct",
|
||||
"requested": "[5.1.53, 5.1.53]",
|
||||
"resolved": "5.1.53",
|
||||
"contentHash": "0YqnUbWFfrOKH2kKwwVbO8wMyBXEUF0O8Jfm7su3C9zY8tigD3ux4wjhIE5tOSmhQ1GnYdiPcpJ1jYGjPE8VXg=="
|
||||
"requested": "[5.1.59, 5.1.59]",
|
||||
"resolved": "5.1.59",
|
||||
"contentHash": "/q/+sKyASsut6vz9f8V1/BQqdBt8H9WVurabW/WLvxq5I14+Ov8wDt7SnBOv4X4fwys88gfTHsCsX7ZX7Z0BcA=="
|
||||
},
|
||||
"nanoFramework.Runtime.Events": {
|
||||
"type": "Direct",
|
||||
|
|
Загрузка…
Ссылка в новой задаче