Skip to content

Commit 342b2e2

Browse files
committed
copied over the documentation from the iot-sdks repo
1 parent 96a66f4 commit 342b2e2

File tree

639 files changed

+40742
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

639 files changed

+40742
-0
lines changed

c_sdk_architecture.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# C SDK Architecture Overview
2+
3+
The purpose of this document is to provide an overview of the C SDK for the IoT Hub device client.
4+
5+
# Table of contents
6+
7+
- [Overview](#Overview)
8+
9+
<a name="Overview"/>
10+
11+
## Overview
12+
13+
Below is high level architecture diagram representing the C SDK for the IoT Hub device client:
14+
15+
![](c_sdk_architecture.png)

c_sdk_architecture.png

90.5 KB
Loading

c_sdk_architecture.vsdx

37.6 KB
Binary file not shown.

faq.md

+196
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
# Microsoft Azure IoT device SDK FAQ
2+
3+
This document contains both general FAQs about the Microsoft Azure IoT device SDK as a whole, and specific FAQs about the C, .NET, Java, and Node.js SDKs in this repository ([azure-iot-sdks](https://github.com/Azure/azure-iot-sdks)).
4+
5+
**Microsoft Azure IoT SDKs**
6+
7+
- [Using Visual Studio 2013](#vs2013)
8+
- [Line-endings in repository zip archive](#lineendings)
9+
10+
**Microsoft Azure IoT device SDK for C FAQs**
11+
12+
- [Installing CMake manually](#cmake)
13+
- [Using the IoT Hub c-client libraries in C++](#cpp)
14+
15+
**Microsoft Azure IoT device SDK for .NET FAQs**
16+
17+
- [UWP support for Microsoft.Azure.Devices.Client](#uwpsupport)
18+
- [NotImplementedException thrown when using UWP](#notimpluwp)
19+
- [IotHubCommunicationException or FileNotFoundException thrown when using HTTP protocol](#httpexception)
20+
21+
**Microsoft Azure IoT device SDK for Java FAQs**
22+
23+
- [Error when using AMQP on Raspberry Pi2](#javapi2error)
24+
- [qpid-jms build fails](#qpidjmsbuildfail)
25+
26+
**Microsoft Azure IoT SDK for Node.js FAQs**
27+
28+
- [Using promises instead of callbacks with the device client](#nodepromisify)
29+
- [Why not use Typescript instead of Javascript?](#whyunotypescript)
30+
31+
<a name="vs2013"/>
32+
## Using Visual Studio 2013
33+
34+
The Visual Studio native C projects included in this repository ([azure-iot-sdks](https://github.com/Azure/azure-iot-sdks)) are Visual Studio 2015 projects. The following steps describe how to use Visual Studio 2013 if you are unable to install Visual Studio 2015 on your development machine.
35+
36+
Note: You can download the free Community edition of Visual Studio 2015 [here](https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx).
37+
38+
1. Open the native C solution in Visual Studio 2013 (for example, azure_iot_sdks.sln in your home folder).
39+
2. In **Solution Explorer** select all the projects in the solution. The right-click in **Solution Explorer** and click **Properties**.
40+
3. Expand **Configuration Properties**, and then select **General**.
41+
4. Change the **Platform Toolset** to **Visual Studio 2013 (v120)**, then click **OK**.
42+
43+
![][1]
44+
45+
<a name="lineendings"/>
46+
## Line-endings in repository zip archive
47+
48+
If you download a zip archive of this repository to a Windows machine, you may encounter errors when you run some of the scripts. This is due to the way GitHub handles line-endings in zip archives. For more information, see http://stackoverflow.com/questions/17347611/downloading-a-zip-from-github-removes-newlines-from-text-files.
49+
50+
<a name="cmake"/>
51+
## Installing CMake manually
52+
53+
If your Linux OS does not include CMake 3.0 and it is not possible to use a package installer, you can install CMake as follows:
54+
55+
```
56+
wget https://cmake.org/files/v3.4/cmake-3.4.0-Linux-i386.sh
57+
chmod u+x cmake-3.4.0-Linux-i386.sh
58+
./cmake-3.4.0-Linux-i386.sh --help
59+
Usage: ./cmake-3.4.0-Linux-i386.sh [options]
60+
Options: [defaults in brackets after descriptions]
61+
--help print this message
62+
--prefix=dir directory in which to install
63+
--include-subdir include the cmake-3.4.0-Linux-i386 subdirectory
64+
--exclude-subdir exclude the cmake-3.4.0-Linux-i386 subdirectory
65+
```
66+
67+
Make sure that the directory where you install CMake is on your path by exporting it. Alternatively, if you use the option `--prefix=/usr` when you install CMake it replaces your current installation.
68+
69+
<a name="cpp"/>
70+
## Using the IoT Hub c-client libraries in C++
71+
72+
Using the IoT Hub c-client code from C++ is no different than using it from c. Create your C++ project, then reference the client library as you normally would in c++, or install the package via the appropriate package manager based on your platform.
73+
74+
<a name="uwpsupport"/>
75+
## UWP support for Microsoft.Azure.Devices.Client
76+
77+
- [Overview](#overview)
78+
- [Project file and assembly](#project)
79+
- [Device client](#deviceclient)
80+
- [Asynchrony](#asynchrony)
81+
- [Library-specific behaviors](#library)
82+
- [Resources](#resources)
83+
84+
<a name="overview"/>
85+
### Overview: Why UWP?
86+
87+
UWP (Universal Windows Platform) is an evolution of Windows app model introduced in Windows 8. UWP provides a common app platform available on every device that runs Windows 10, including its IoT flavor, the IoT Core. (See https://msdn.microsoft.com/en-us/library/dn894631.aspx). UWP is the official application model supported on IoT Core.
88+
89+
An existing .NET library can be made UWP-compatible by exposing WinRT interfaces and by porting the implementation to .NET Core (See http://blogs.msdn.com/b/dotnet/archive/2014/12/04/introducing-net-core.aspx)
90+
91+
WinRT imposes certain constraints on the public APIs. Most importantly, only WinRT (and not .NET) types can be exposed. This allows other languages (including unmanaged languages like C++/CX and JavaScript) to consume such libraries.
92+
93+
<a name="project"/>
94+
### Project file and assembly
95+
96+
A new project file, Microsoft.Azure.Devices.Client.WinRT.csproj has been created. The project has been added to the main solution. The project produces a WinRT AppX package with metadata in Microsoft.Azure.Devices.Client.winmd.
97+
98+
The existing .NET library, Microsoft.Azure.Devices.Client.dll, has remained unchanged (modulo a small number of breaking changes as described below).
99+
100+
<a name="deviceclient"/>
101+
### DeviceClient
102+
103+
WinRT does not allow exporting abstract classes, therefore **DeviceClient** has become a sealed concrete class. A new private abstract class, **DeviceClientImpl** has been added to maximally reuse the existing implementation.
104+
105+
<a name="asynchrony"/>
106+
### Asynchrony
107+
108+
Only WinRT types can be exported by WinRT assemblies. The signatures of async methods such as **ReceiveAsync** have been changed to return **AsyncTask** or **AsyncTaskOfMessage**, which is aliased to **Windows.Foundation.IAsyncAction** or **Windows.Foundation.IAsyncOperation<Message>** for WinRT, or **System.Threading.Tasks.Task** and **System.Threading.Tasks.Task<Message>** for .NET.
109+
110+
<a name="library"/>
111+
### Library-specific Behaviors
112+
113+
WINDOWS_UWP macro is used to differentiate between .NET and UWP behaviors at compile time. Currently, there are almost 200 occurrences of `#if WINDOWS_UWP` in the code.
114+
115+
<a name="resources"/>
116+
#### Resources
117+
118+
Desktop apps use either text files or XML (.resx) files to create resources. The compiler then embeds them into the assembly. The resources are retrieved using the System.Resources.ResourceManager class.
119+
120+
UWP uses the Windows Store resource model that replaces the hub-and-spoke model common to .NET Framework desktop apps. In UWP apps, .resw files are used to create resources. The format of the file is the same as .resx, but the packaging mechanism is different. At compile time, all the .resw files for an app are packed into a single PRI file by the MakePRI utility and included with the app's deployment package. At run time, the **Windows.ApplicationModel.Resources.ResourceLoader** class and the types in the **Windows.ApplicationModel.Resources.Core** namespace provide access to app resources.
121+
122+
To support resources in Microsoft.Azure.Devices.Client library, the existing Resource.resx file has been copied to Resource.resw. The two files will now need to be kept in sync. Unlike in the .NET version of the library, the UWP version does not contain generated C# files. Instead, a new file, WinRTResources.cs is introduced. Whenever a new string is added to the .resx/.resw file, a corresponding entry must be copied from Resources.Designer.cs to WinRTResources.cs (follow the existing entries as an example)
123+
124+
<a name="notimpluwp"/>
125+
## System.NotImplementedException occurred in Microsoft.Azure.Devices.Client.winmd
126+
The Universal Windows Platform (UWP) version of the .NET client device library does **not** currently support **MQTT** protocol.
127+
128+
For example, calling `DeviceClient deviceClient = DeviceClient.CreateFromConnectionString(DeviceConnectionString, TransportType.Mqtt);`
129+
will result in "Mqtt protocol is not supported" exception.
130+
131+
<a name="httpexception"/>
132+
## IotHubCommunicationException or FileNotFoundException thrown when using HTTP protocol
133+
134+
The **DeviceClient** class in the Microsoft.Azure.Devices.Client package requires the **System.Net.Http.Formatting** class to communicate with IoT Hub over HTTP.
135+
136+
You see an **IotHubCommunicationException** or **FileNotFoundException** exception when you try to use the HTTP protocol to send a device-to-cloud message:
137+
138+
```
139+
DeviceClient deviceClient = DeviceClient.CreateFromConnectionString(DeviceConnectionString, TransportType.Http1);
140+
141+
...
142+
143+
await deviceClient.SendEventAsync(eventMessage);
144+
```
145+
146+
To prevent these exceptions from happening, you should add **Microsoft.AspNet.WebApi.Client** NuGet package to your project.
147+
148+
<a name="javapi2error"/>
149+
## Error when using AMQP on Raspberry Pi2
150+
When building Qpid using Maven on a Raspberry Pi2 you might encounter a known error with the *SureFire* plugin:
151+
152+
```
153+
Error occurred during initialization of VM Could not reserve enough space for object heap
154+
155+
Error: Could not create the Java Virtual Machine.
156+
```
157+
This results in a failure to build Qpid. This is a known issue with OpenJDK7 (for more information, see http://laurenthinoul.com/how-to-solve-the-maven-vm-initialization-error/). This article recommends updating SureFire by updating your pom file. As an alternative, you can opt to skip the SureFire tests with the Maven build, using the following command:
158+
159+
```
160+
mvn install -Dmaven.test.skip=true
161+
```
162+
163+
For more information, see http://maven.apache.org/surefire/maven-surefire-plugin/examples/skipping-test.html.
164+
165+
<a name="qpidjmsbuildfail"/>
166+
## qpid-jms build fails
167+
168+
If you get a build error when you try to [build qpid-jms](get_started/java-devbox-setup.md), then you should set the following variable in your environment before you run `mvn install`.
169+
170+
Windows: `set _JAVA_OPTIONS=-Xmx512M`
171+
172+
Linux: `export _JAVA_OPTIONS=-Xmx512M`
173+
174+
[1]: media/PlatformToolset.png
175+
176+
<a name="nodepromisify"/>
177+
## Using promises instead of callbacks with the device client
178+
Currently the device client asynchronous functions follow the callback pattern rather than returning promises. If you wish to use the SDK with promises instead of callbacks, it's extremely easy though, using the bluebird library to "promisify" the device client class.
179+
180+
```javascript
181+
var Promise = require('bluebird');
182+
var client = Promise.promisifyAll(Client.fromConnectionString(connectionString, Amqp));
183+
```
184+
185+
And there you have it. All the existing functions of the client still exist, and the promise-returning equivalent has been created and has the same name with `Async` appended to it. In other words:
186+
- `client.open(callback)` becomes `client.openAsync().then(...).catch(...)`
187+
- `client.send(message, callback)` becomes `client.sendAsync(message).then(...).catch(...)`
188+
- `client.complete(message, callback)` becomes `client.completeAsync(message).then(...).catch(...)`
189+
- etc.
190+
191+
Events are unchanged, so you still subscribe to those the way you would with the un-promisified client.
192+
193+
<a name="whyunotypescript" />
194+
## Why not use TypeScript instead of JavaScript for the SDK?
195+
At the time when the SDK development was started, pure JavaScript felt like a better choice in order to make contributions as easy as possible for any Node developer, whether or not he or she was aware and proficient with TypesSript.
196+
We regularly re-evaluate this decision as we move forward and you are most welcome to provide feedback or contribute by opening issues or pull-requests and help us decide what to do in the future.

0 commit comments

Comments
 (0)