Skip to content

Commit 6f49abc

Browse files
authored
Removing sample (#1)
1 parent 56bd09a commit 6f49abc

File tree

7 files changed

+15
-396
lines changed

7 files changed

+15
-396
lines changed

Azure.Devices.DeviceClient/DeviceClient.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public class DeviceClient
6262
/// <param name="iotHubName">The Azure IoT name fully qualified (ex: youriothub.azure-devices.net)</param>
6363
/// <param name="deviceId">The device ID which is the name of your device.</param>
6464
/// <param name="sasKey">One of the SAS Key either primary, either secondary.</param>
65-
/// <param name="qosLevel">The default quality level delivery for the MQTT messages</param>
66-
public DeviceClient(string iotHubName, string deviceId, string sasKey, byte qosLevel = MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE)
65+
/// <param name="qosLevel">The default quality level delivery for the MQTT messages, default to the lower quality</param>
66+
public DeviceClient(string iotHubName, string deviceId, string sasKey, byte qosLevel = MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE)
6767
{
6868
_clientCert = null;
6969
_privateKey = null;
@@ -83,8 +83,8 @@ public DeviceClient(string iotHubName, string deviceId, string sasKey, byte qosL
8383
/// <param name="iotHubName">The Azure IoT name fully qualified (ex: youriothub.azure-devices.net)</param>
8484
/// <param name="deviceId">The device ID which is the name of your device.</param>
8585
/// <param name="clientCert">The certificate to connect the device containing both public and private key.</param>
86-
/// <param name="qosLevel">The default quality level delivery for the MQTT messages</param>
87-
public DeviceClient(string iotHubName, string deviceId, X509Certificate2 clientCert, byte qosLevel = MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE)
86+
/// <param name="qosLevel">The default quality level delivery for the MQTT messages, default to the lower quality</param>
87+
public DeviceClient(string iotHubName, string deviceId, X509Certificate2 clientCert, byte qosLevel = MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE)
8888
{
8989
_clientCert = clientCert;
9090
_privateKey = Convert.ToBase64String(clientCert.PrivateKey);
@@ -116,7 +116,7 @@ public DeviceClient(string iotHubName, string deviceId, X509Certificate2 clientC
116116
/// <summary>
117117
/// True if the device connected
118118
/// </summary>
119-
public bool IsConnected => _mqttc.IsConnected;
119+
public bool IsConnected => (_mqttc != null) && _mqttc.IsConnected;
120120

121121
/// <summary>
122122
/// Open the connection with Azure IoT. This will connected to Azure IoT Hub the device.

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
This Azure IoT Hub SDK is using MQTT. So you need to ensure you can connect to port 8883 using TLS protocol. If you are in an enterprise network, this may be blocked. In most cases, this is not an issue.
2121

22+
The namespaces, the name of the classes and the methods try to get close to the .NET C# Azure IoT SDK. This should allow an easier portability of the code between both environment.
23+
2224
### Creating a DeviceClient
2325

2426
You can connect to Azure IoT Hub using either a symmetric Key, either a certificate. The following example shows how to use a symmetric key:
@@ -83,6 +85,12 @@ var isReceived = azureIoT.SendMessage($"{{\"Temperature\":42,\"Pressure\":1024}}
8385
Debug.WriteLine($"Message received by IoT Hub: {isReceived}");
8486
```
8587

88+
Note: The message will be send with the default service quality you created the device. You won't get any answer for the quality 0. In this case, you can simplify it to:
89+
90+
```csharp
91+
azureIoT.SendMessage($"{{\"Temperature\":42,\"Pressure\":1024}}");
92+
```
93+
8694
### Cloud to device messages
8795

8896
You can register an event to received the Cloud to device messages:
@@ -147,6 +155,8 @@ string RaiseExceptionCallbackTest(int rid, string payload)
147155
}
148156
```
149157

158+
**Important**: method names are case sensitive. So make sure you name your functions in C# the same way.
159+
150160
### Status update event
151161

152162
A status update event is available:

nanoFramework.Azure.Devices.Client.sln

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio Version 16
33
VisualStudioVersion = 16.0.31321.278
44
MinimumVisualStudioVersion = 10.0.40219.1
5-
Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "AzureIoTExample", "sample\AzureIoTExample.nfproj", "{134D1FF7-73CC-4B27-AA43-58FE42996DD1}"
6-
EndProject
75
Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "Azure.Devices.DeviceClient", "Azure.Devices.DeviceClient\Azure.Devices.DeviceClient.nfproj", "{9EDF2863-99AC-4CA1-93FE-F48ED3C6D45F}"
86
EndProject
97
Global
@@ -12,12 +10,6 @@ Global
1210
Release|Any CPU = Release|Any CPU
1311
EndGlobalSection
1412
GlobalSection(ProjectConfigurationPlatforms) = postSolution
15-
{134D1FF7-73CC-4B27-AA43-58FE42996DD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
16-
{134D1FF7-73CC-4B27-AA43-58FE42996DD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
17-
{134D1FF7-73CC-4B27-AA43-58FE42996DD1}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
18-
{134D1FF7-73CC-4B27-AA43-58FE42996DD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
19-
{134D1FF7-73CC-4B27-AA43-58FE42996DD1}.Release|Any CPU.Build.0 = Release|Any CPU
20-
{134D1FF7-73CC-4B27-AA43-58FE42996DD1}.Release|Any CPU.Deploy.0 = Release|Any CPU
2113
{9EDF2863-99AC-4CA1-93FE-F48ED3C6D45F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2214
{9EDF2863-99AC-4CA1-93FE-F48ED3C6D45F}.Debug|Any CPU.Build.0 = Debug|Any CPU
2315
{9EDF2863-99AC-4CA1-93FE-F48ED3C6D45F}.Debug|Any CPU.Deploy.0 = Debug|Any CPU

sample/AzureIoTExample.nfproj

Lines changed: 0 additions & 163 deletions
This file was deleted.

0 commit comments

Comments
 (0)