<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Laurent Ellerbach</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/laurelle/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/laurelle/feed.xml</link>
    <description>Internet of Things, IoT, Arduino, Netduino, Galileo, Spark.IO, NETMF, .NET Microframework and other embedded gadgets :-)</description>
    <lastBuildDate>Mon, 27 Aug 2018 14:52:28 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Azure IoT Edge support for Raspbian 8.0/Debian 8.0</title>
      <link>https://docs.microsoft.com/archive/blogs/laurelle/azure-iot-edge-support-for-raspbian-8-0-debian-8-0</link>
      <pubDate>Fri, 17 Aug 2018 12:04:53 GMT</pubDate>
      <dc:creator><![CDATA[Laurelle]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/laurelle/?p=1425</guid>
      <description><![CDATA[In theory, Azure IoT Edge is working only for the version 9 of Debian. If you’re using a Raspberry...]]></description>
      <content:encoded><![CDATA[<span style="color: #000000;font-family: Calibri">In theory, Azure IoT Edge is working only for the version 9 of Debian. If you’re using a Raspberry Pi, you’ll most likely use a Raspbian version which is based on Debian. So same, you’ll have to be on the version 9 to be able to deploy Azure IoT Edge on your device.</span>

<span style="color: #000000;font-family: Calibri">But what if you’re running a version 8? And for some reasons, you can’t upgrade to version 9? Well, the good news is that there is a way to make it working. Let’s see how and what is needed.</span>
<h2><span style="color: #2f5496;font-family: Calibri Light;font-size: large">Specificities of Azure IoT Edge</span></h2>
<span style="color: #000000;font-family: Calibri">Azure IoT Edge uses some of the components which are not present in v8 of Debians like libssl 1.0.2. Reason is because IoTEdge is using DTLS which are not present in the previous versions.</span>

<span style="color: #000000;font-family: Calibri">You can try to upgrade the list of packages, force the version, in the 8 version (jessie), this package do not exist. So the way to get it is from the next version, 9 so stretch. </span>

<span style="font-family: Calibri"><span style="color: #000000">The libssl can be found here: </span><a href="https://packages.debian.org/stretch/libssl1.0.2">https://packages.debian.org/stretch/libssl1.0.2</a></span><span style="color: #000000;font-family: Calibri"> and as you’ll see there is the support for armhf which is the version of the RPI processor.</span>
<h2><span style="color: #2f5496;font-family: Calibri Light;font-size: large">Pre installation before Azure IoT Edge</span></h2>
<span style="color: #000000;font-family: Calibri">Basically, we’ll have to download and install the package.</span>

<em>wget https://ftp.us.debian.org/debian/pool/main/o/openssl1.0/libssl1.0.2_1.0.2l-2+deb9u3_armhf.deb</em>

<em>sudo dpkg -<span style="color: #000000;font-family: Calibri">i libssl1.0.2_1.0.2l-2+deb9u3_armhf.deb</span></em>

<em>sudo apt-get install -f</em>

<span style="color: #000000;font-family: Calibri">If you get any error message, it may be related to the fact you have a non-compatible version of libssl like the libsll-dev version. In this case, just purge it with</span>

<em>sudo apt-get purge libssl-dev</em>

<span style="font-family: Calibri"><span style="color: #000000">Now, you can follow the instructions here: </span><a href="https://docs.microsoft.com/en-us/azure/iot-edge/how-to-install-iot-edge-linux-arm">https://docs.microsoft.com/en-us/azure/iot-edge/how-to-install-iot-edge-linux-arm</a></span>
<h2><span style="color: #2f5496;font-family: Calibri Light;font-size: large">Bang, another issue: LISTEN_FDNAMES</span></h2>
<span style="color: #000000;font-family: Calibri">Once you’ve done that, you’ll still have an issue. When looking at the journal </span><em>sudo journalctl -u iotedge -f</em><span style="color: #000000;font-family: Calibri">, the IoTEdge will tell you the environment variable LISTEN_FDNAMES is not setup. The reason is that in the Debian 9, this is not used anymore. The way the service is setup is using another mechanism.</span>

<span style="color: #000000;font-family: Calibri">So, in short, we’ll have to add it. Reading a bit about it and searching about it, it needs to be added in the </span><em>/etc/system/system/multi-user.target.wants/iotedge.service</em>

<span style="color: #000000;font-family: Calibri">Just add the line below in the In the [Service] section</span>

<span style="color: #000000;font-family: Calibri">Environment=LISTEN_FDNAMES=iotedge.mgmt.socket:iotedge.socket</span>

<span style="color: #000000;font-family: Calibri">And now, if you look at the journal again, you will see the 2 core containers downloading, you’ll see in your portal that your IoTEdge device will get connected. Just allow some time for the donwloads to happen and you’ll be good to go!</span>

<span style="color: #000000;font-family: Calibri">Keep in mind that if you’re building your own edge containers, they must be built for Debian 8 and not the 9 version. Otherwise, they won’t start or run correctly.</span>

<span style="color: #000000;font-family: Calibri">Please note as well, this scenario is not supported. In theory, Azure IoTEdge is not built to run on Debian 8, only 9. So other things can happen. </span>

<span style="color: #000000;font-family: Calibri"> </span>]]></content:encoded>
    </item>
    <item>
      <title>Accessing embedded serial ports in .NET Core 2.0 on a Raspberry PI 3 running Linux</title>
      <link>https://docs.microsoft.com/archive/blogs/laurelle/accessing-embedded-serial-ports-in-net-core-2-0-on-a-raspberry-pi-3-running-linux</link>
      <pubDate>Tue, 04 Jul 2017 06:04:35 GMT</pubDate>
      <dc:creator><![CDATA[Laurelle]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/laurelle/?p=1416</guid>
      <description><![CDATA[You will find a full documentation and steps by steps explaining how to access the serial ports in...]]></description>
      <content:encoded><![CDATA[You will find a full documentation and steps by steps explaining how to access the serial ports in .NET Core for Raspberry PI 3 running Linux. You can <a href="https://github.com/Ellerbach/serialapp">access here</a>.
In short, you'll need first to unlock the access of the embedded serial port, then install on a supportted Platform the .NET Core, then choose how you want to access the serial ports, either in a simple and efficient way if you have simple things to do and performances don't matter to much, either in a more complex way if performance matter and if you want more features and be able to tune the serial port usage.

Note that the Embedded UART is by default use for the debug console.

As always, feedbacks welcome!]]></content:encoded>
    </item>
    <item>
      <title>How to use Microsoft Graph and Office 365 API in a Service or in a Windows App/UWP without a graphical interface</title>
      <link>https://docs.microsoft.com/archive/blogs/laurelle/how-to-use-microsoft-graph-and-office-365-api-in-a-service-or-in-a-windows-appuwp-without-a-graphical-interface</link>
      <pubDate>Fri, 12 Feb 2016 09:48:00 GMT</pubDate>
      <dc:creator><![CDATA[Laurelle]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/laurelle/2016/02/12/how-to-use-microsoft-graph-and-office-365-api-in-a-service-or-in-a-windows-appuwp-without-a-graphical-interface/</guid>
      <description><![CDATA[Office 365 Graph is just a great way to add Office 365 integration into your application. You’ll...]]></description>
      <content:encoded><![CDATA[Office 365 Graph is just a great way to add Office 365 integration into your application. You’ll find many great information in the <a target="_blank" href="https://dev.office.com/" rel="noopener">Office Dev Center</a> to explain more all what is available. I was interested in adding Office 365 integration in a normal Windows .NET Service on my serveur as well as on a RaspberryPi running Windows IoT Core in a Universal Windows Platform (UWP) application. I want to have a user which can automatically receive emails, do action based on those emails, send calendar items.
<h1>The concepts</h1>
In both cases, I don’t have any user interface. And it’s an issue as Microsoft Graph/Office 365 API are fully REST and are using OAuth2. And in this case, the mechanism used for authentication require the user to have a user interface to log into. User and passwords are not stored in the client application but an authorization token is sent to the application. The application then have to use this token for authentication. The token is valid for a certain period and need to be refreshed.

You’ll find all the documentation on how OAuth 2.0 is working and how it is implemented with Azure Active Directory <a target="_blank" href="https://msdn.microsoft.com/en-us/library/azure/dn645542.aspx" rel="noopener">here</a>. The graph below explain the full mechanism:

<img title="Authorization Code Flow diagram" alt="Authorization Code Flow diagram" src="https://i-msdn.sec.s-msft.com/dynimg/IC740856.jpeg" />

And this does require the user to enter his credentials on a user interface. When you run a service you just can’t on the service itself. From here, there are 2 ways to solve this issue:
<ul>
 	<li>Provide your application a special access that will give full right to the entire directory, Office 365 information with some granularity. Granularity is Read, or Read/Write, for mail, calendar…</li>
 	<li>Do the authentication somewhere else and provide the token to the application. This allow much more granularity vs the previous solution and allow to have a normal user with normal privileges connected.</li>
</ul>
I do not want to go for the first solution because I just want to have one user and just the minimum rights. So I’ve decided to go for the second solution. So far I haven’t found another place where it is document. So my basic idea is to use the following authentication mechanism:

<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/7587.image_150FC8E3.png"><img width="795" height="476" title="image" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/5861.image_thumb_0020D721.png" border="0" /></a>

Basic idea is to have the user authentication on 1 machine and then pass the authorization token to the other machine. Se let see the solution I used.

For the following steps, I’ll use Microsoft Graph but the process is similar if you’re using Office 365 API or any other API using Azure Active Directory with OAuth 2.0.
<h1>Preparing Office 365 tenant and Azure Active Directory</h1>
As very well describe in the documentation, you need:
<ol>
 	<li>Prepare your Azure Active Directory tenant. Follow the steps <a target="_blank" href="https://msdn.microsoft.com/en-us/office/office365/howto/add-common-consent-manually" rel="noopener">here</a>. You will need an Office 365 business account, the rights to add an app into the Azure portal</li>
 	<li>When following the steps add a “Native client application”</li>
 	<li>When specifying the App permission, add Microsoft Graph and select what you need</li>
 	<li>You’ll need to add return URIs. Those are the address that are allow to be redirected on to pass the token/codes after authentication. In the example, I’ll use a Raspberry in a UWP. Name will be “laurellerpitest” and will return on port 81 on page token. So <a href="https://laurellerpitest:81/token">https://laurellerpitest:81/token</a></li>
 	<li>Then download the Manifest, save it and open it with Visual Studio for example<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/2656.image_28BF4328.png"><img width="395" height="183" title="image" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/4578.image_thumb_5D5F9F63.png" border="0" /></a></li>
 	<li>Change “oauth2AllowImplicitFlow” to true and save the file
<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1033.image_5F9C281F.png"><img width="396" height="301" title="image" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1362.image_thumb_6D023B25.png" border="0" /></a></li>
 	<li>Upload the saved manifest. This specific modification in the manifest will allow this manipulation of doing the authentication on a machine which is not the one which will use the token. It will just allow to pass the token to a different place in a flow. This is needed only in cases like this one where the authentification has to follow a flow from one place to another. If you are doing the authentication on the same machine you’ll use the token, this is not needed.</li>
</ol>
You’re now ready and have accomplished all the preparation steps.
<h1>Creating the authorization URL</h1>
This is where it starts to be interesting. To get the access token which will authorize your app to access the resources, when you read the documentation, you need a code and then send this code to get the access token. But there is a shortcut to directly get the token. You can use an URL like this to get the access token directly:

<a href="https://login.microsoftonline.com/12345678-9abc-def1-234567890abcdef12/oauth2/authorize?response_type=token&amp;redirect_uri=http%3a%2f%2flaurellerpitest:81/token&amp;client_id=01234567-89ab-cdef-1234-567890abcdef&amp;resource=https%3A%2F%2Fgraph.microsoft.com%2F">https://login.microsoftonline.com/12345678-9abc-def1-234567890abcdef12/oauth2/authorize?response_type=token&amp;redirect_uri=http%3a%2f%2flaurellerpitest:81/token&amp;client_id=01234567-89ab-cdef-1234-567890abcdef&amp;resource=https%3A%2F%2Fgraph.microsoft.com%2F</a>

You’ll get the first endpoint in your Azure Portal. It’s the connection endpoint to Microsoft Graph. So you’ll replace this string “12345678-9abc-def1-234567890abcdef12” by your tenant ID. The params:
<ul>
 	<li>response_type=token: this is where you’re asking for the access token. You may ask for other types of token depending on what you need to do later on. You will find more information on supported token type <a target="_blank" href="https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-tokens/" rel="noopener">here</a>. Authentication will happen on a webpage and the token will be returned to the return URI.</li>
 	<li>redirect_uri=https://laurellerpi:81/token (encoded to be compatible with uri parameters): this is the return URI you’ve setup into your portal.</li>
 	<li>client_id=01234567-89ab-cdef-1234-567890abcdef: this is the unique ID of your app that you’ll find as well un the Azure portal.</li>
 	<li>resource=https://graph.microsoft.com/: request access to Microsoft Graph. Can be as well other services suing the same endpoint for which you gave autorisation</li>
</ul>
If you click on this link, you’ll get an error message on the bottom right of the page:

<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/5444.image_2F08AA67.png"><img width="371" height="111" title="image" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/3223.image_thumb_75859A6F.png" border="0" /></a>

those error messages are really useful to help you find out if you’ve done a mistake somewhere. If you’ve setup everything correctly, you’ll be able to arrive on a page like this:

<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/4048.image_17DD2FE9.png"><img width="633" height="227" title="image" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8182.image_thumb_12FA7C2D.png" border="0" /></a>

Authentication with user name and password happens on this page.

Depending on the rights you’ve allowed for your app, you may need to have the user agreement to use the app. In this case, it will ask you for your agreement.

And finally, you’re redirected to the redirect URL. And you’ll note that the token is present in the parameter “access_token”.

<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/5086.image_4E4DE1EB.png"><img width="638" height="120" title="image" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/7220.image_thumb_29BC5467.png" border="0" /></a>

And at this point, there is a “but”. And it’s quite a bit “but”. The parameter is passed following a hash tag (#). This means that the parameter won’t be passed to the server! It is a client only parameter like the other passed as well.

So let see how to get this param passed to the server.
<h1>Getting the access token</h1>
The return URI look like this with a much longer token than the one represented here:

<a href="https://laurellerpitest:81/token#access_token=abc.def.ghi-jkl-mno-pqrstuvwxyz&amp;token_type=Bearer&amp;expires_in=3600&amp;session_state=12345678-1234-1234-1234-1234567890ab">https://laurellerpitest:81/token#access_token=abc.def.ghi-jkl-mno-pqrstuvwxyz&amp;token_type=Bearer&amp;expires_in=3600&amp;session_state=12345678-1234-1234-1234-1234567890ab</a>

This token is type of Bearer. More <a target="_blank" href="https://www.rfc-editor.org/rfc/rfc6750.txt" rel="noopener">info on Bearer token in the RFC</a>. There are multiple type of token but the one used to get access is the Bearer one. You can get other types by requesting other tokens like to refresh your token but you’ll need to have a Bearer on to access the resources. Se at the end of the article, more links and resources to go deeper on this topic.

As it is returned only on the client side, we will need a javascript on the page to gather it and return it to the device. So I’ll need to implement a very simple web server into my UWP app on my RaspberryPi to get this token back.

Here is the full code and I’ll explain it right after. Note: I have produced this code during an internal hackathon. It is a very simple, very striaght forward code. It can of course be done in a much more complete way. But it is demonstrating the core part of the process.

<span style="font-family: Consolas"><span style="line-height: 10pt"><span style="color: #0000ff"><span style="font-size: 9.5pt">private</span></span></span><span style="font-size: 9.5pt"><span style="line-height: 10pt"><span style="color: #0000ff">readonly</span></span><span style="line-height: 10pt"><span style="color: #2b91af">HttpServer</span></span></span><span style="line-height: 10pt"><span style="color: #000000;font-size: 9.5pt"> httpServer;</span></span></span>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span style="font-size: 9.5pt">httpServer = </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">new</span></span><span lang="EN-US"><span style="color: #2b91af">HttpServer</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">(81);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 8pt;line-height: 12pt"><span lang="EN-US" style="line-height: 10pt"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt">httpServer.StartServer();</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">    </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">public</span></span><span lang="EN-US"><span style="color: #0000ff">sealed</span></span><span lang="EN-US"><span style="color: #0000ff">partial</span></span><span lang="EN-US"><span style="color: #0000ff">class</span></span><span lang="EN-US"><span style="color: #2b91af">HttpServer</span></span><span lang="EN-US"><span style="color: #000000"> : </span></span></span><span lang="EN-US"><span style="color: #2b91af;font-size: 9.5pt">IDisposable</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">    </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">private</span></span><span lang="EN-US"><span style="color: #0000ff">const</span></span><span lang="EN-US"><span style="color: #0000ff">uint</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> BufferSize = 8192;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">private</span></span><span lang="EN-US"><span style="color: #0000ff">int</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> port = 80;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">private</span></span><span lang="EN-US"><span style="color: #0000ff">readonly</span></span><span lang="EN-US"><span style="color: #2b91af">StreamSocketListener</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> listener;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">private</span></span><span lang="EN-US"><span style="color: #0000ff">string</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> token;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">public</span></span><span lang="EN-US"><span style="color: #0000ff">string</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> Token</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span lang="EN-US"><span style="color: #0000ff;font-size: 9.5pt">get</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">return</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> token;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">internal</span></span></span><span lang="EN-US"><span style="color: #0000ff;font-size: 9.5pt">set</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">token = </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">value</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt">        </span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">public</span></span><span lang="EN-US"><span style="color: #000000"> HttpServer(</span></span><span lang="EN-US"><span style="color: #0000ff">int</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> serverPort)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">listener = </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">new </span></span><span lang="EN-US"><span style="color: #2b91af">StreamSocketListener</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">();</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">port = serverPort;</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">listener.ConnectionReceived += (s, e) =&gt; ProcessRequestAsync(e.Socket);</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">public</span></span><span lang="EN-US"><span style="color: #0000ff">async</span></span><span lang="EN-US"><span style="color: #0000ff">void</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> StartServer()</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #808080"><span style="font-size: 9.5pt">#pragma</span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #808080">warning</span></span><span lang="EN-US"><span style="color: #808080">disable</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> CS4014</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">await</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> listener.BindServiceNameAsync(port.ToString());</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #808080"><span style="font-size: 9.5pt">#pragma</span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #808080">warning</span></span><span lang="EN-US"><span style="color: #808080">restore</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> CS4014</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">public</span></span><span lang="EN-US"><span style="color: #0000ff">void</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> StopServer()</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">((</span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #2b91af">IDisposable</span></span><span lang="EN-US"><span style="color: #000000">)</span></span><span lang="EN-US"><span style="color: #0000ff">this</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">).Dispose();</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">public</span></span><span lang="EN-US"><span style="color: #0000ff">void</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> Dispose()</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">listener.Dispose();</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">private</span></span><span lang="EN-US"><span style="color: #0000ff">async</span></span><span lang="EN-US"><span style="color: #0000ff">void</span></span><span lang="EN-US"><span style="color: #000000"> ProcessRequestAsync(</span></span><span lang="EN-US"><span style="color: #2b91af">StreamSocket</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> socket)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">await</span></span><span lang="EN-US"><span style="color: #2b91af">Task</span></span><span lang="EN-US"><span style="color: #000000">.Run(</span></span><span lang="EN-US"><span style="color: #0000ff">async</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> () =&gt;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                </span></span></span></span><span lang="EN-US"><span style="color: #0000ff;font-size: 9.5pt">try</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                    </span></span></span></span><span lang="EN-US"><span style="color: #008000;font-size: 9.5pt">// this works for text only</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                    </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #2b91af">StringBuilder</span></span><span lang="EN-US"><span style="color: #000000"> request = </span></span><span lang="EN-US"><span style="color: #0000ff">new </span></span><span lang="EN-US"><span style="color: #2b91af">StringBuilder</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">();</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                    </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">using</span></span><span lang="EN-US"><span style="color: #000000"> (</span></span><span lang="EN-US"><span style="color: #2b91af">IInputStream</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> input = socket.InputStream)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">byte</span></span><span lang="EN-US"><span style="color: #000000">[] data = </span></span><span lang="EN-US"><span style="color: #0000ff">new</span></span><span lang="EN-US"><span style="color: #0000ff">byte</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">[BufferSize];</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #2b91af">IBuffer</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> buffer = data.AsBuffer();</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">uint</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> dataRead = BufferSize;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">while</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> (dataRead == BufferSize)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">         </span></span><span style="font-size: 9.5pt"><span>               </span>{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">await</span></span><span lang="EN-US"><span style="color: #000000"> input.ReadAsync(buffer, BufferSize, </span></span><span lang="EN-US"><span style="color: #2b91af">InputStreamOptions</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">.Partial);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">                            </span></span><span style="font-size: 9.5pt">request.Append(</span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #2b91af">Encoding</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">.UTF8.GetString(data, 0, data.Length));</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                            </span></span><span style="font-size: 9.5pt">dataRead = buffer.Length;</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                        </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #2b91af">Debug</span></span><span lang="EN-US"><span style="color: #000000">.WriteLine(</span></span><span lang="EN-US"><span style="color: #a31515">"Request received: {0}"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">, request.ToString());</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                    </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">using</span></span><span lang="EN-US"><span style="color: #000000"> (</span></span><span lang="EN-US"><span style="color: #2b91af">IOutputStream</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> output = socket.OutputStream)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">                       </span></span><span style="font-size: 9.5pt"><span> </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">string</span></span><span lang="EN-US"><span style="color: #000000"> requestMethod = request.ToString().Split(</span></span><span lang="EN-US"><span style="color: #a31515">'\n'</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">)[0];</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">string</span></span><span lang="EN-US"><span style="color: #000000">[] requestParts = requestMethod.Split(</span></span><span lang="EN-US"><span style="color: #a31515">' '</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">if</span></span><span lang="EN-US"><span style="color: #000000"> (requestParts[0] == </span></span><span lang="EN-US"><span style="color: #a31515">"GET"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">await</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> WriteResponseAsync(requestParts[1], output);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                        </span></span></span></span><span lang="EN-US"><span style="color: #0000ff;font-size: 9.5pt">else</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">return</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #2b91af">Debug</span></span><span lang="EN-US"><span style="color: #000000">.WriteLine(</span></span><span lang="EN-US"><span style="color: #a31515">"Request processed from WebServer"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">catch</span></span><span lang="EN-US"><span style="color: #000000"> (</span></span><span lang="EN-US"><span style="color: #2b91af">Exception</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> e)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                    </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #2b91af">Debug</span></span><span lang="EN-US"><span style="color: #000000">.WriteLine(</span></span><span lang="EN-US"><span style="color: #a31515">"Exception in Socket: {0}"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">, e.ToString());</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                </span></span></span></span><span lang="EN-US"><span style="color: #0000ff;font-size: 9.5pt">finally</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                    </span></span></span></span><span lang="EN-US"><span style="color: #0000ff;font-size: 9.5pt">try</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                        </span></span><span style="font-size: 9.5pt">socket.Dispose();</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                    </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">catch</span></span><span lang="EN-US"><span style="color: #000000"> (</span></span><span lang="EN-US"><span style="color: #2b91af">Exception</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> e)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">                       </span></span><span style="font-size: 9.5pt"><span> </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #2b91af">Debug</span></span><span lang="EN-US"><span style="color: #000000">.WriteLine(</span></span><span lang="EN-US"><span style="color: #a31515">"Exception in cleaning exception Socket: {0}"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">, e.ToString());</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">});</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">private</span></span><span lang="EN-US"><span style="color: #0000ff">async</span></span><span lang="EN-US"><span style="color: #2b91af">Task</span></span><span lang="EN-US"><span style="color: #000000"> WriteResponseAsync(</span></span><span lang="EN-US"><span style="color: #0000ff">string</span></span><span lang="EN-US"><span style="color: #000000"> request, </span></span><span lang="EN-US"><span style="color: #2b91af">IOutputStream</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> response)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">string</span></span><span lang="EN-US"><span style="color: #000000"> pageUtil = </span></span><span lang="EN-US"><span style="color: #a31515">"token"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">string</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> strFilePath = request;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">string</span></span><span lang="EN-US"><span style="color: #000000"> strResp = </span></span><span lang="EN-US"><span style="color: #a31515">""</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">if</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> (strFilePath.Length &gt;= pageUtil.Length)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">if</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> (strFilePath.Substring(1, pageUtil.Length).ToLower() == pageUtil)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">ProcessResponsePage(response, strFilePath);</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                    </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">return</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">      </span></span><span><span style="font-size: 9.5pt">      </span></span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt"> </span></span><span style="font-size: 9.5pt"><span>           </span></span></span></span><span lang="EN-US"><span style="color: #008000;font-size: 9.5pt">// send blank text</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">await</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> OutPutStream(response, strResp);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">private</span></span><span lang="EN-US"><span style="color: #0000ff">async</span></span><span lang="EN-US"><span style="color: #0000ff">void</span></span><span lang="EN-US"><span style="color: #000000"> ProcessResponsePage(</span></span><span lang="EN-US"><span style="color: #2b91af">IOutputStream</span></span><span lang="EN-US"><span style="color: #000000"> response, </span></span><span lang="EN-US"><span style="color: #0000ff">string</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> rawURL)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">string</span></span><span lang="EN-US"><span style="color: #000000"> strResp = </span></span><span lang="EN-US"><span style="color: #a31515">""</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">; ;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">if</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> (DecryptProcessResponsePage(rawURL))</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">strResp = </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">"OK"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span lang="EN-US"><span style="color: #0000ff;font-size: 9.5pt">else</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">strResp = BuildScript();</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">         </span></span><span style="font-size: 9.5pt"><span>   </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">await</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> OutPutStream(response, strResp);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">private</span></span><span lang="EN-US"><span style="color: #0000ff">string</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> BuildScript()</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">string</span></span><span lang="EN-US"><span style="color: #000000"> strResp = </span></span><span lang="EN-US"><span style="color: #a31515">""</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">strResp += </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">"&lt;!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"&gt;"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">strResp += </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">"&lt;html xmlns=\"https://www.w3.org/1999/xhtml\"&gt;&lt;head&gt;&lt;title&gt;&lt;/title&gt;"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">strResp += </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">"&lt;SCRIPT language=\"JavaScript\"&gt;"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">strResp += </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">"if (window.location.href.indexOf(\"#access_token\") &gt; 0)"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">strResp += </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">"{var token = window.location.href.substring(window.location.href.indexOf(\"#access_token=\") + 14);"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">strResp += </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">"token = token.substr(0, token.indexOf(\"&amp;\"));"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">strResp += </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">"var xhr = new XMLHttpRequest(); "</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">strResp += </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">"xhr.open('GET', '/token?access_token=' + token);"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">strResp += </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">"xhr.onreadystatechange = function() {if (xhr.readyState == 4) {boxMSG.innerHTML=xhr.responseText;}}; xhr.send();}"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">strResp += </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">""</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">  </span></span><span style="font-size: 9.5pt"><span>          </span>strResp += </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">"&lt;/Script&gt;"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">strResp += </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">"&lt;/head&gt;&lt;body&gt;&lt;span id='boxMSG'&gt;&lt;/span&gt;&lt;/body&gt;&lt;/html&gt;"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">return</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> strResp;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">private</span></span><span lang="EN-US"><span style="color: #0000ff">bool</span></span><span lang="EN-US"><span style="color: #000000"> DecryptProcessResponsePage(</span></span><span lang="EN-US"><span style="color: #0000ff">string</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> strDecrypt)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span lang="EN-US"><span style="color: #008000;font-size: 9.5pt">// decode params</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #2b91af">Param</span></span><span lang="EN-US"><span style="color: #000000">[] Params = </span></span><span lang="EN-US"><span style="color: #2b91af">Param</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">.decryptParam(strDecrypt);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">bool</span></span><span lang="EN-US"><span style="color: #000000"> isvalid = </span></span><span lang="EN-US"><span style="color: #0000ff">false</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span lang="EN-US"><span style="color: #0000ff;font-size: 9.5pt">try</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">if</span></span><span lang="EN-US"><span style="color: #000000"> (Params != </span></span><span lang="EN-US"><span style="color: #0000ff">null</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                    </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">for</span></span><span lang="EN-US"><span style="color: #000000"> (</span></span><span lang="EN-US"><span style="color: #0000ff">int</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> i = 0; i &lt; Params.Length; i++)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                        </span></span></span></span><span lang="EN-US"><span style="color: #008000;font-size: 9.5pt">//on cherche le paramètre strMonth</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">int</span></span><span lang="EN-US"><span style="color: #000000"> j = Params[i].Name.ToLower().IndexOf(</span></span><span lang="EN-US"><span style="color: #a31515">"access_token"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">if</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> (j == 0)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                        </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                            </span></span><span style="font-size: 9.5pt">token = Params[i].Value;</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">                            </span></span><span style="font-size: 9.5pt">isvalid = </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">true</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                        </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">catch</span></span><span lang="EN-US"><span style="color: #000000"> (</span></span><span lang="EN-US"><span style="color: #2b91af">Exception</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">isvalid = </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">false</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">return</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> isvalid;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">private</span></span><span lang="EN-US"><span style="color: #0000ff">async</span></span><span lang="EN-US"><span style="color: #2b91af">Task</span></span><span lang="EN-US"><span style="color: #000000"> OutPutStream(</span></span><span lang="EN-US"><span style="color: #2b91af">IOutputStream</span></span><span lang="EN-US"><span style="color: #000000"> response, </span></span><span lang="EN-US"><span style="color: #0000ff">string</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> strResp)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span lang="EN-US"><span style="color: #0000ff;font-size: 9.5pt">try</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">using</span></span><span lang="EN-US"><span style="color: #000000"> (</span></span><span lang="EN-US"><span style="color: #2b91af">Stream</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> resp = response.AsStreamForWrite())</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                    </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">byte</span></span><span lang="EN-US"><span style="color: #000000">[] bodyArray = </span></span><span lang="EN-US"><span style="color: #2b91af">Encoding</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">.UTF8.GetBytes(strResp);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">resp.Write(bodyArray, 0, bodyArray.Length);</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                    </span></span></span></span><span lang="EN-US"><span style="color: #008000;font-size: 9.5pt">//Flush need to be SYNC. If async, then it goes closed before!</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                    </span></span></span></span><span lang="EN-US"><span style="color: #008000;font-size: 9.5pt">//resp.Flush();</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                    </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #2b91af">Debug</span></span><span lang="EN-US"><span style="color: #000000">.WriteLine(</span></span><span lang="EN-US"><span style="color: #a31515">"OutputStream sent"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span style="color: #000000"><span lang="EN-US"><span><span style="font-size: 9.5pt">                </span></span></span><span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span><span style="color: #0000ff">catch</span></span><span><span style="color: #000000"> (</span></span><span><span style="color: #2b91af">Exception</span></span></span><span><span style="color: #000000;font-size: 9.5pt"> e)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #2b91af">Debug</span></span><span lang="EN-US"><span style="color: #000000">.WriteLine(</span></span><span lang="EN-US"><span style="color: #a31515">"Exception in outputstream: {0}"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">, e.ToString());</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">return</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt">        </span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 8pt;line-height: 12pt"><span lang="EN-US"><span style="font-family: Calibri"><span style="color: #000000;font-size: 11pt">}</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">    </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">public</span></span><span lang="EN-US"><span style="color: #0000ff">sealed</span></span><span lang="EN-US"><span style="color: #0000ff">class</span></span></span><span lang="EN-US"><span style="color: #2b91af;font-size: 9.5pt">Param</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">    </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">public</span></span><span lang="EN-US"><span style="color: #0000ff">string</span></span><span lang="EN-US"><span style="color: #000000"> Name { </span></span><span lang="EN-US"><span style="color: #0000ff">get</span></span><span lang="EN-US"><span style="color: #000000">; </span></span><span lang="EN-US"><span style="color: #0000ff">set</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">; }</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">public</span></span><span lang="EN-US"><span style="color: #0000ff">string</span></span><span lang="EN-US"><span style="color: #000000"> Value { </span></span><span lang="EN-US"><span style="color: #0000ff">get</span></span><span lang="EN-US"><span style="color: #000000">; </span></span><span lang="EN-US"><span style="color: #0000ff">set</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">; }</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">public</span></span><span lang="EN-US"><span style="color: #0000ff">static</span></span><span lang="EN-US"><span style="color: #0000ff">char</span></span><span lang="EN-US"><span style="color: #000000"> ParamStart { </span></span><span lang="EN-US"><span style="color: #0000ff">get</span></span><span lang="EN-US"><span style="color: #000000"> { </span></span><span lang="EN-US"><span style="color: #0000ff">return</span></span><span lang="EN-US"><span style="color: #a31515">'?'</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">; } }</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">public</span></span><span lang="EN-US"><span style="color: #0000ff">static</span></span><span lang="EN-US"><span style="color: #0000ff">char</span></span><span lang="EN-US"><span style="color: #000000"> ParamEqual { </span></span><span lang="EN-US"><span style="color: #0000ff">get</span></span><span lang="EN-US"><span style="color: #000000"> { </span></span><span lang="EN-US"><span style="color: #0000ff">return</span></span><span lang="EN-US"><span style="color: #a31515">'='</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">; } }</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">public</span></span><span lang="EN-US"><span style="color: #0000ff">static</span></span><span lang="EN-US"><span style="color: #0000ff">char</span></span><span lang="EN-US"><span style="color: #000000"> ParamSeparator { </span></span><span lang="EN-US"><span style="color: #0000ff">get</span></span><span lang="EN-US"><span style="color: #000000"> { </span></span><span lang="EN-US"><span style="color: #0000ff">return</span></span><span lang="EN-US"><span style="color: #a31515">'&amp;'</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">; } }</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">public</span></span><span lang="EN-US"><span style="color: #0000ff">static</span></span><span lang="EN-US"><span style="color: #2b91af">Param</span></span><span lang="EN-US"><span style="color: #000000">[] decryptParam(</span></span><span lang="EN-US"><span style="color: #0000ff">string</span></span><span lang="EN-US"><span style="color: #000000"> Parameters, </span></span><span lang="EN-US"><span style="color: #0000ff">char</span></span><span lang="EN-US"><span style="color: #000000"> start = </span></span><span lang="EN-US"><span style="color: #a31515">'?'</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #2b91af">Param</span></span><span lang="EN-US"><span style="color: #000000">[] retParams = </span></span><span lang="EN-US"><span style="color: #0000ff">null</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">int</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> i = Parameters.IndexOf(start);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #2b91af">String</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> strtocut = Parameters;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">if</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> (i &gt;= 0)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">strtocut = Parameters.Substring(i + 1);</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">var</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> strcut = strtocut.Split(ParamSeparator);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">if</span></span><span lang="EN-US"><span style="color: #000000"> (strcut != </span></span><span lang="EN-US"><span style="color: #0000ff">null</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">retParams = </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">new</span></span><span lang="EN-US"><span style="color: #2b91af">Param</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">[strcut.Length];</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">for</span></span><span lang="EN-US"><span style="color: #000000"> (</span></span><span lang="EN-US"><span style="color: #0000ff">int</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> inc = 0; inc &lt; strcut.Length; inc++)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                    </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">var</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> strgood = strcut[inc].Split(ParamEqual);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">retParams[inc] = </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">new</span></span><span lang="EN-US"><span style="color: #2b91af">Param</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">();</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                    </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">if</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> (strgood.Length == 2)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                        </span></span><span style="font-size: 9.5pt">retParams[inc].Name = strgood[0];</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                        </span></span><span style="font-size: 9.5pt">retParams[inc].Value = strgood[1];</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">                    </span></span></span></span><span lang="EN-US"><span style="color: #0000ff;font-size: 9.5pt">else</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">{</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">                        </span></span><span style="font-size: 9.5pt">retParams[inc].Name = </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">""</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">                        </span></span><span style="font-size: 9.5pt">retParams[inc].Value = </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">""</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                    </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt"> </span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">else</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> {</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">retParams = </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">new</span></span><span lang="EN-US"><span style="color: #2b91af">Param</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">[1];</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">retParams[0].Name = </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">""</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">                </span></span><span style="font-size: 9.5pt">retParams[1].Value = </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">""</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">            </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span><span><span style="color: #000000"><span style="font-size: 9.5pt">            </span></span></span></span><span style="font-size: 9.5pt"><span><span style="color: #0000ff">return</span></span></span><span><span style="color: #000000;font-size: 9.5pt"> retParams;</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 8pt;line-height: 12pt"><span style="line-height: 10pt"><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">        </span></span><span style="font-size: 9.5pt">}</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 8pt;line-height: 12pt"><span style="line-height: 10pt"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt">}</span></span></span></p>
&nbsp;

The code shows a very simple implementation of an HTTP server supporting only GET. Whenever a request arrives on the specified port, it is processed by the <em>ProcessRequestAsync</em> function. This function get the headers and body of the request and extract the raw URL. Then it calls the <em>WriteResponseAsync</em> to process the request.

The <em>WriteResponseAsync</em> function is just looking at the raw URL from the HTTP request and check if it’s “token”. If it’s token then it calls the function <em>ProcessResponsePage</em>. This function then call the <em>DecryptProcessResponsePage</em>.

The <em>DecryptProcessResponsePage</em> check if there is a param named “access_token” passed in the URL. If yes, then it does extract it and store it and return true. If not, then it returns false. if it’s true, the <em>ProcessResponsePage</em> will return OK and if it’s false, it will return the <em>BuildScript </em>content which create a javascript.

This javascript is very simple as well and minimal, here is how it does looks like once on the client:
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #0000ff"><span style="font-size: 9.5pt">if</span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #000000"> (window.location.href.indexOf(</span></span><span lang="EN-US"><span style="color: #a31515">"#access_token"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">) &gt; 0)</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span lang="EN-US"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt">{</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">    </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">var</span></span><span lang="EN-US"><span style="color: #000000"> token = window.location.href.substring(window.location.href.indexOf(</span></span><span lang="EN-US"><span style="color: #a31515">"#access_token="</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">) + 14);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">    </span></span><span style="font-size: 9.5pt">token = token.substr(0, token.indexOf(</span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">"&amp;"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">));</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">    </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">var</span></span><span lang="EN-US"><span style="color: #000000"> xhr = </span></span><span lang="EN-US"><span style="color: #0000ff">new</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> XMLHttpRequest();</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">    </span></span><span style="font-size: 9.5pt">xhr.open(</span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">'GET'</span></span><span lang="EN-US"><span style="color: #000000">, </span></span><span lang="EN-US"><span style="color: #a31515">'/token?access_token='</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> + token);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span><span style="font-size: 9.5pt">    </span></span><span style="font-size: 9.5pt">xhr.onreadystatechange = </span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">function</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> () {</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span><span style="color: #000000"><span style="font-size: 9.5pt">        </span></span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #0000ff">if</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> (xhr.readyState == 4) { boxMSG.innerHTML = xhr.responseText; }</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span style="color: #000000"><span lang="EN-US"><span><span style="font-size: 9.5pt">    </span></span></span><span><span style="font-size: 9.5pt">};</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span><span style="font-family: Consolas"><span style="color: #000000"><span><span style="font-size: 9.5pt">    </span></span><span style="font-size: 9.5pt">xhr.send();</span></span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 8pt;line-height: 12pt"><span style="line-height: 10pt"><span style="font-family: Consolas"><span style="color: #000000;font-size: 9.5pt">}</span></span></span></p>
&nbsp;

The script is looking for the #access_token string. And then extract it and pass it to the /token page as a parameter. this call is done thru the XMLHttpRequest class. The result is then put into the boxMSG span. If all goes correctly, then you’ll see an OK on the page.

Here, I’m passing only the access token, not the other elements. But it’s very easy to adapt the code to pass the others. Important one is the expiriaton session to be able to renew it on time. I’m not explaining how to renew the token here but it is explained in the <a target="_blank" href="https://msdn.microsoft.com/en-us/library/azure/dn645542.aspx" rel="noopener">step by step authentication page</a>.
<h1>Using the Microsoft Graph REST API</h1>
Now, it’s the very easy part. The REST API is simple and straight forward to use.
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #2b91af"><span style="font-size: 9.5pt">HttpClient</span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #000000"> client = </span></span><span lang="EN-US"><span style="color: #0000ff">new </span></span><span lang="EN-US"><span style="color: #2b91af">HttpClient</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">();</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #000000"><span style="font-size: 9.5pt">client.DefaultRequestHeaders.Add(</span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #a31515">"Authorization"</span></span><span lang="EN-US"><span style="color: #000000">, </span></span><span lang="EN-US"><span style="color: #a31515">"Bearer "</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> + token);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #2b91af"><span style="font-size: 9.5pt">HttpResponseMessage</span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #000000"> response = </span></span><span lang="EN-US"><span style="color: #0000ff">await</span></span><span lang="EN-US"><span style="color: #000000"> client.GetAsync(</span></span><span lang="EN-US"><span style="color: #a31515">"https://graph.microsoft.com/v1.0/users/"</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt">);</span></span></span></p>
<p class="MsoNormal" style="list-style-type: disc;margin: 0cm 0cm 0pt;line-height: normal"><span style="font-family: Consolas"><span lang="EN-US"><span style="color: #0000ff"><span style="font-size: 9.5pt">string</span></span></span><span style="font-size: 9.5pt"><span lang="EN-US"><span style="color: #000000"> retResp =</span></span><span lang="EN-US"><span style="color: #0000ff">await</span></span></span><span lang="EN-US"><span style="color: #000000;font-size: 9.5pt"> response.Content.ReadAsStringAsync();</span></span></span></p>
&nbsp;

You just need to create an HttpClient, then add the Baerer token in the header and call the Graph API you want. This one will get all the users in the Azure Directory. It is returned as a JSON and then you can play with it.
<h1>Next steps</h1>
As next steps, you can extend the code to ask for refreshed access token.

This is using what is available with the current app model. The app model v2 is much simpler, requires less steps. Some details in these links with the excellent <a target="_blank" href="https://github.com/MicrosoftDX/kurvejs/blob/master/docs/appModelV2/intro.md" rel="noopener">KurveJS</a> framework from <a target="_blank" href="https://twitter.com/matvelloso" rel="noopener">Mat Velloso</a>. You have a good <a target="_blank" href="https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-compare/" rel="noopener">comparison of both models here</a>, the <a target="_blank" href="https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-protocols-implicit/" rel="noopener">protocols</a> and <a target="_blank" href="https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-scopes/" rel="noopener">scopes</a>. And I want to thanks Mat as well for his help on this project and putting all this together.

The all up Microsoft Graph API documentation, including the v1.0 and the beta version, is <a target="_blank" href="https://graph.microsoft.io/en-us/docs/overview/overview" rel="noopener">available are here</a>. The API is rich and well get even richer. A good start is <a href="https://graph.microsoft.io/">https://graph.microsoft.io/</a>. And as authentication, authorization and token access are key point to understand, read as well <a target="_blank" href="https://graph.microsoft.io/docs/authorization/converged_auth" rel="noopener">this article</a> on Microsoft Graph endpoints using converged authentication.

There’s a lot to do and now, you can use it in an embedded device with no UI.]]></content:encoded>
    </item>
    <item>
      <title>How to connect Lego Mindstorms NXT ev3 to Azure IoT Hub using node.js</title>
      <link>https://docs.microsoft.com/archive/blogs/laurelle/how-to-connect-lego-mindstorms-nxt-ev3-to-azure-iot-hub-using-node-js</link>
      <pubDate>Thu, 24 Dec 2015 08:22:35 GMT</pubDate>
      <dc:creator><![CDATA[Laurelle]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/laurelle/2015/12/24/how-to-connect-lego-mindstorms-nxt-ev3-to-azure-iot-hub-using-node-js/</guid>
      <description><![CDATA[Recently, I’ve played with node.js and Azure IoT Hub. You can see my previous blog posts here, here...]]></description>
      <content:encoded><![CDATA[<p>Recently, I’ve played with node.js and Azure IoT Hub. You can see my previous blog posts <a href="https://blogs.msdn.com/b/laurelle/archive/2015/11/13/azure-iot-hub-uploading-a-webcam-picture-in-an-azure-blob-with-node-js-on-windows-and-linux.aspx" target="_blank">here</a>, <a href="https://blogs.msdn.com/b/laurelle/archive/2015/11/24/creating-an-azure-iot-device-explorer-in-node-js-express-and-jade.aspx" target="_blank">here</a> and <a href="https://blogs.msdn.com/b/laurelle/archive/2015/12/01/how-to-deploy-a-node-js-site-into-azure-web-app-to-create-a-website.aspx" target="_blank">here</a>. And as I’m a huge fan of Lego, I’ve decided to connected my <a href="https://www.lego.com/en-us/mindstorms/" target="_blank">Lego Mindstorms ev3</a> (the new version of NXT) to Azure IoT Hub. Well, at the end of the day, the ev3 is just a 32-bit ARM9 processor, Texas Instrument AM1808 cadenced at 300MHz. The main OS is Linux and it does have 1 USB port and 1 SD card reader. It does allow to boot on an SD card another OS so you don’t have to flash the main one. and on the USB port, you can plus a wifi dongle.</p>  <h1>Setup the Mindstorms ev3</h1>  <p>I already used the excellent <a href="https://www.monobrick.dk/" target="_blank">monobrick</a> to run C# code on the brick and it was working perfectly. Now my challenge was to run node.js and connect it to Azure IoT Hub. So I looked quickly at various available images and found quickly the <a href="https://www.ev3dev.org/" target="_blank">ev3dev</a> one.</p>  <p>So I’ flashed a 4Gb SD card and booted on it. Just follow the steps on the ev3dev site to flash the SD card. I’m using a very cheap wireless dongle, an <a href="https://www.amazon.com/Edimax-EW-7811Un-150Mbps-Raspberry-Supports/dp/B003MTTJOY/ref=sr_1_1?ie=UTF8&amp;qid=1450969491&amp;sr=8-1&amp;keywords=edimax" target="_blank">Edimax</a>. It does cost less than 10$/€ and it’s very small, so easy to add to the brick. It does connect at 150Mb max but you really don’t need to have more on the brick!</p>  <p>Time to boot the brick using ev3dev. I’m using an external power supply so I’m not consuming batteries and I do recommend to do it while running all those tests. It is very convenient during the development and test phase. Later you can of course run on batteries.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/5672.WP_20151224_16_08_03_Pro_3A778E5E.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/5672.WP_5F00_20151224_5F00_16_5F00_08_5F00_03_5F00_Pro_5F00_3A778E5E.jpg"><img title="WP_20151224_16_08_03_Pro" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="WP_20151224_16_08_03_Pro" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1854.WP_20151224_16_08_03_Pro_thumb_008ADC23.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/1854.WP_5F00_20151224_5F00_16_5F00_08_5F00_03_5F00_Pro_5F00_thumb_5F00_008ADC23.jpg" width="244" height="139" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8130.WP_20151224_16_08_08_Pro_6DD5E26B.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/8130.WP_5F00_20151224_5F00_16_5F00_08_5F00_08_5F00_Pro_5F00_6DD5E26B.jpg"><img title="WP_20151224_16_08_08_Pro" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="WP_20151224_16_08_08_Pro" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1538.WP_20151224_16_08_08_Pro_thumb_5258927B.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/1538.WP_5F00_20151224_5F00_16_5F00_08_5F00_08_5F00_Pro_5F00_thumb_5F00_5258927B.jpg" width="244" height="139" /></a></p>  <p>Once you’ve booted, connect to the wifi, you can as well use a wired dongle if you prefer. Careful as you only have 2 minutes to enter your key, so you better have to speed up to enter it <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none" alt="Sourire" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1222.wlEmoticon-smile_76ECB0B0.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/1222.wlEmoticon_2D00_smile_5F00_76ECB0B0.png" /> I had to redo it 3 times the first time as I have a quite long key and it’s not that easy to enter using the buttons and screen from the ev3.</p>  <p>Once connected to wifi, the IP address will display on the screen. Time to connect to the brick. I’m using PuTTY to connect to the brick.</p>  <p><font face="Courier New">login as: root     <br />root@192.168.1.20's password:      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; _____&#160;&#160;&#160;&#160; _      <br />&#160;&#160; _____&#160;&#160; _|___ /&#160; __| | _____&#160;&#160; __      <br />&#160; / _ \ \ / / |_ \ / _` |/ _ \ \ / /      <br /> |&#160; __/\ V / ___) | (_| |&#160; __/\ V /      <br />&#160; \___| \_/ |____/ \__,_|\___| \_/</font></p>  <p><font face="Courier New">Debian jessie on LEGO MINDSTORMS EV3!</font></p>  <p><font face="Courier New">The programs included with the Debian GNU/Linux system are free software;     <br />the exact distribution terms for each program are described in the      <br />individual files in /usr/share/doc/*/copyright.</font></p>  <p><font face="Courier New">Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent     <br />permitted by applicable law.      <br />Last login: Wed Dec 23 18:49:39 2015 from pc10.home      <br />root@ev3dev:~# </font></p>  <p>Follow the instruction of the e3vdev website to update the brick. It will take some time to update and upgrade all packages.</p>  <p>At the end of the day, when running a node –v, you’ll get v0.10.29 and npm is 1.4.21. And it’s the best you can get on this armel distribution so far.</p>  <h1>Setup the development environment</h1>  <p>I’ve decided to go for Visual Studio. You can get a free version of Visual Studio Community <a href="https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx" target="_blank">here</a>. I’ve installed as well the needed tools as explained in my blog post <a href="https://blogs.msdn.com/b/laurelle/archive/2015/11/13/azure-iot-hub-uploading-a-webcam-picture-in-an-azure-blob-with-node-js-on-windows-and-linux.aspx" target="_blank">here</a>. If you prefer you can go as well for Visual Studio Code which you’ll find <a href="https://code.visualstudio.com/" target="_blank">here</a>. It does work perfectly as well.</p>  <p>Once all ready, create a new node.js project, I went for the simple web server one. Again, follow the steps from my previous article to get it all setup. I’m of course using TypeScript as it makes it easy to maintain the code. It does generate automatically at build time the javascript files.</p>  <p>Add the azure-iot-device and ev3dev packages. </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/2543.image_364A6441.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/2543.image_5F00_364A6441.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/7450.image_thumb_186BE040.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/7450.image_5F00_thumb_5F00_186BE040.png" width="425" height="127" /></a></p>  <p>Up to this point, it was quite straight forward and I didn’t had any issue. The next steps are where I started to face issues.</p>  <h1>Deploy the solution on the brick</h1>  <p>To deploy the solution, it’s just about creating a directory and copying the needed files on it. This time I used WinSCP for this. I’ve created a nodeNXT directory in /home and deployed the files there. Just copy the generated server.js and package.json file. </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/0447.image_73047D82.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/0447.image_5F00_73047D82.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1016.image_thumb_3FCAD4CA.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/1016.image_5F00_thumb_5F00_3FCAD4CA.png" width="477" height="256" /></a></p>  <p>On the device, in the /home/nodeNXT directory, run an “npm install” command. It will install the missing packages. Be patient, it does take a while. And it’s where the problems starts. </p>  <p>As the needed version of node.js for the Azure IoT SDK is 0.12, and as the system can’t get more recent build than 0.10.29, some of the packages do not get deploy correctly. The main faulty one is the websocket one. </p>  <p>If you try to create in your code a “var device = require('azure-iot-device');” you’ll get an error message on the device. I have to say I didn’t had any idea on how to get thru this. So I’ve asked Pierre Cauchois who is working in the Azure IoT team for advices. And he told me to remove the websocket part and just use classes which I’ll need. In my case I just needed the http way to publish in Azure IoT Hub.</p>  <p>For this, you’ll need to edit on the device “<em>./node_modules/azure-iot-device/device.js</em>”, in the last part of the file, just keep this:</p>  <p><font face="Courier New">var common = require('azure-iot-common');</font></p>  <p><font face="Courier New">module.exports = {     <br />&#160;&#160;&#160; Client: require('./lib/client.js'),      <br />&#160;&#160;&#160; ConnectionString: require('./lib/connection_string.js'),      <br />&#160;&#160;&#160; Http: require('./lib/http.js'),      <br />&#160;&#160;&#160; Message: common.Message,      <br />&#160;&#160;&#160; SharedAccessSignature: require('./lib/shared_access_signature.js'),      <br />};</font></p>  <p>And you’ll need as well to edit the file on the device&#160; “./node_modules/azure-iot-device/lib/http_receiver.js”, comment the following lines:</p>  <p><font face="Courier New">//var util = require('util');</font></p>  <p><font face="Courier New">//util.inherits(HttpReceiver, EventEmitter);</font></p>  <p>It looks like there is an issue as well in the util package. For what I’l do later, looks like those 2 lines have no issue. My goal is just to send data to Azure IoT Hub from the NXT. I haven’t tested to receive data from the Azure IoT Hub, so this may have an impact.</p>  <p>I’ve spend a lot of time fixing this issue due to the outdated version of node.js running on the brick but if you do this, you’ll be able to upload data in the Azure IoT Hub.</p>  <p>I found another issue, not related to the Azure IoT SDK but to the ev3dev version. The version deployed thru npm is the 0.9.2 and is quite basic. You can find a new version on <a href="https://github.com/WasabiFan/ev3dev-lang-js" target="_blank">github which is 0.9.3</a>. So download and install this version in your node modules, add it as a project in Visual Studio, and use this one. There is a bug in the index.ts file. Some references are missing for sensors.</p>  <p>In the sensor.ts file, make sure you reference all sensors from the sensor.ts file:</p>  <p><font face="Courier New">// Sensors     <br />export var Sensor = sensors.Sensor;      <br />export var I2CSensor = sensors.I2CSensor;      <br />export var TouchSensor = sensors.TouchSensor;      <br />export var ColorSensor = sensors.ColorSensor;      <br />export var UltrasonicSensor = sensors.UltrasonicSensor;      <br />export var GyroSensor = sensors.GyroSensor;      <br />export var InfraredSensor = sensors.InfraredSensor;      <br />export var SoundSensor = sensors.SoundSensor;      <br />export var LightSensor = sensors.LightSensor;</font></p>  <p>Note that the code is coming in TypeScript, so you’ll need to compile it and deploy it manually to the device. I did it in a very basic way, once compiled, I’ve just copied all files from the directory. In theory, you just need the js ones and the package.json and the scprits folder.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/7077.image_081AAB4B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/7077.image_5F00_081AAB4B.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/4760.image_thumb_79DEC30B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/4760.image_5F00_thumb_5F00_79DEC30B.png" width="385" height="350" /></a></p>  <p>OK, now we’re really done on the device side <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none" alt="Sourire" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1222.wlEmoticon-smile_76ECB0B0.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/1222.wlEmoticon_2D00_smile_5F00_76ECB0B0.png" /> Good because it takes me a lot of time to figure out all those issues.    <br /></p>  <h1>Some code to upload data</h1>  <p>Now here is some code to play with. This is a very basic code but shows all what you need to get data from sensors and upload them in Azure IoT Hub:</p>  <p><font face="Courier New">import http = require('http');     <br />var url = require('url');      <br />var ev3dev = require('./node_modules/ev3dev-lang/index.js');      <br />var device = require('azure-iot-device');      <br />var connectionString = 'HostName=XXX.azure-devices.net;DeviceId=NXT;SharedAccessKey=XXXXXXXXXXXX';</font></p>  <p>   <br /><font face="Courier New">var port = process.env.port || 1337     <br />http.createServer(function (req, res) {      <br />&#160;&#160;&#160; var request = url.parse(req.url, true);      <br />&#160;&#160;&#160; var action = request.pathname;      <br />&#160;&#160;&#160; var tablee = [];      <br />&#160;&#160;&#160; var i = 0;</font></p>  <p><font face="Courier New">&#160;&#160;&#160; if (action == '/battery') {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var battery = new ev3dev.PowerSupply();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var str = '';</font></p>  <p><font face="Courier New">&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (battery.connected) {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += '&#160; Technology: ' + battery.technology + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += '&#160; Type: ' + battery.type + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += '&#160; Current (microamps): ' + battery.measuredCurrent + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += '&#160; Current (amps): ' + battery.currentAmps + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += '&#160; Voltage (microvolts): ' + battery.measuredVoltage + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += '&#160; Voltage (volts): ' + battery.voltageVolts + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += '&#160; Max voltage (microvolts): ' + battery.maxVoltage + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += '&#160; Min voltage (microvolts): ' + battery.minVoltage + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tablee[i] = JSON.stringify({      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Sensor: 'PowerSupply',      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; technology: battery.technology,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; type: battery.type,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; measuredCurrent: battery.measuredCurrent,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; currentAmps: battery.currentAmps,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; measuredVoltage: battery.measuredVoltage,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; voltageVolts: battery.voltageVolts,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; maxVoltage: battery.maxVoltage,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; minVoltage: battery.minVoltage      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; i++;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; else {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str = '&#160; Battery not connected!';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tablee[i] = JSON.stringify({      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Sensor: 'PowerSupply',      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; error: 'not connected'      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; i++      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; sendmsg(JSON.stringify({      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tablee      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }));      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.writeHead(200, { 'Content-Type': 'text/plain' });      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.end(str + JSON.stringify(battery));      <br />&#160;&#160;&#160; } else if (action == '/sensor') {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var touchSensor = new ev3dev.TouchSensor();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var colorsensor = new ev3dev.ColorSensor();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var UltrasonicSensor = new ev3dev.LightSensor();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var InfraredSensor = new ev3dev.InfraredSensor();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var SoundSensor = new ev3dev.SoundSensor();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var str = '';</font></p>  <p><font face="Courier New">&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (touchSensor.connected) {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += 'touch pressed: ' + touchSensor.isPressed + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tablee[i] = JSON.stringify({      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Sensor: 'TouchSensor',      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; isPressed: touchSensor.isPressed      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; i++;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (colorsensor.connected) {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += 'color sensor: \n&#160;&#160; reflectedLightIntensity: ' + colorsensor.reflectedLightIntensity + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += '&#160;&#160; ambientLightIntensity: ' + colorsensor.ambientLightIntensity + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += '&#160;&#160; color: ' + colorsensor.color + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += '&#160;&#160; red: ' + colorsensor.red + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += '&#160;&#160; green: ' + colorsensor.green + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += '&#160;&#160; blue: ' + colorsensor.blue + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tablee[i] = JSON.stringify({      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Sensor: 'ColorSensor',      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; reflectedLightIntensity: colorsensor.reflectedLightIntensity,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ambientLightIntensity: colorsensor.ambientLightIntensity,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; color: colorsensor.color,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; red: colorsensor.red,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; green: colorsensor.green,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; blue: colorsensor.blue      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; i++;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (UltrasonicSensor.connected) {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += 'UltrasonicSensor: \n&#160;&#160; distanceCentimeters' + UltrasonicSensor.distanceCentimeters + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += '&#160;&#160; otherSensorPresent: ' + UltrasonicSensor.otherSensorPresent + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tablee[i] = JSON.stringify({      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Sensor: 'UltrasonicSensor',      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; distanceCentimeters: UltrasonicSensor.reflectedLightIntensity,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; otherSensorPresent: UltrasonicSensor.ambientLightIntensity      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; i++;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (InfraredSensor.connected) {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += 'InfraredSensor: \n&#160;&#160; proximity: ' + InfraredSensor.proximity + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tablee[i] = JSON.stringify({      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Sensor: 'InfraredSensor',      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; proximity: InfraredSensor.proximity      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; i++;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (SoundSensor.connected) {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += 'SoundSensor: \n&#160;&#160; soundPressure: ' + SoundSensor.soundPressure + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; str += '&#160;&#160; soundPressureLow: ' + SoundSensor.soundPressureLow + '\n';      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tablee[i] = JSON.stringify({      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Sensor: 'SoundSensor',      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; soundPressure: SoundSensor.soundPressure,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; soundPressureLow: SoundSensor.soundPressureLow      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; i++;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; sendmsg(JSON.stringify({      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tablee      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }));</font></p>  <p><font face="Courier New">&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.writeHead(200, { 'Content-Type': 'text/plain' });     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.end(str);      <br />&#160;&#160;&#160; } else </font><font face="Courier New">{     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.writeHead(200, { 'Content-Type': 'text/plain' });      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.end('Try /battery /sensor \n');      <br />&#160;&#160;&#160; }      <br />}).listen(port);</font></p>  <p><font face="Courier New">function sendmsg(data) {     <br />&#160;&#160;&#160; var client = device.Client.fromConnectionString(connectionString);      <br />&#160;&#160;&#160; var message = new device.Message(data);      <br />&#160;&#160;&#160; message.properties.add('NXTsensors', 'sensorData');      <br />&#160;&#160;&#160; console.log(&quot;Sending message: &quot; + message.getData());      <br />&#160;&#160;&#160; client.sendEvent(message, printResultFor('send'));      <br />}</font></p>  <p><font face="Courier New">function printResultFor(op) {     <br />&#160;&#160;&#160; return function printResult(err, res) {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (err) console.log(op + ' error: ' + err.toString());      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (res &amp;&amp; (res.statusCode !== 204)) console.log(op + ' status: ' + res.statusCode + ' ' + res.statusMessage);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160; };      <br />}</font> </p>  <p>The code is quite simple, I do return, as text, in the page, the sensors and their states. At the same time I’m building a JSON table containing the sensors data. </p>  <p>The function sendmsg is sending the data to Azure IoT Hub. This part of the code coming from the sample code you can find in the excellent SDK (it’s the simple http one). In the code, replace the XXX in the connection string by your IoµT Hub, make sure the name of your device is NXT or replace NXT by the name of device you want to use. Don’t forget to create a device before if needed. And of course, the primary key of the device.</p>  <p>Now, compile everything, deploy the server.js file to the device, run “node server.js” and wait 30 seconds. In a browser, you can now access the NXT brick on port 1337 like <a href="https://ipaddress:1337/">https://ipaddress:1337/</a> (replace ipaddress by the IP address of your ev3). It will return: <font face="Courier New">Try /battery /sensor</font></p>  <p>the /sensor returns in my case:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/3531.image_26F6408B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/3531.image_5F00_26F6408B.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/6888.image_thumb_144146D4.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/6888.image_5F00_thumb_5F00_144146D4.png" width="359" height="267" /></a></p>  <p>/battery returns:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/0312.image_3CDFB2DB.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/0312.image_5F00_3CDFB2DB.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/4786.image_thumb_4E52A464.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/4786.image_5F00_thumb_5F00_4E52A464.png" width="771" height="170" /></a></p>  <p>On the device side, you can check that the data has been sent:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/5314.image_4E553515.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/5314.image_5F00_4E553515.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/6835.image_thumb_1B852EA1.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/6835.image_5F00_thumb_5F00_1B852EA1.png" width="764" height="184" /></a></p>  <p>What about Azure IoT Hub? Well, just use the Device Explorer (see my <a href="https://blogs.msdn.com/b/laurelle/archive/2015/11/13/azure-iot-hub-uploading-a-webcam-picture-in-an-azure-blob-with-node-js-on-windows-and-linux.aspx" target="_blank">previous article</a> on where to get it and how to use it). Run the Device Explorer and connect it to your IoT Hub before trying /sensor and /battery.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/0160.image_216262EB.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/0160.image_5F00_216262EB.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1323.image_thumb_66118DDD.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/1323.image_5F00_thumb_5F00_66118DDD.png" width="531" height="671" /></a></p>              <p>And voilà <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none" alt="Sourire" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1222.wlEmoticon-smile_76ECB0B0.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/1222.wlEmoticon_2D00_smile_5F00_76ECB0B0.png" /> we made it <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none" alt="Sourire" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1222.wlEmoticon-smile_76ECB0B0.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/1222.wlEmoticon_2D00_smile_5F00_76ECB0B0.png" /> The Lego Mindstorms ev3 is now connected to Azure IoT Hub using node.js and able to send data to Azure. </p>  <p>Bottom line: when you have sources of and SDK, don’t be afraid to adapt, change and modify what you need for your own platform. I did it with the Azure IoT SDK because my node.js version was too old to fully run it. And I did it with the ev3dev package as it was outdated and there were couple of bugs in it.</p>  <p>As always, feedbacks welcome!</p>]]></content:encoded>
    </item>
    <item>
      <title>How to deploy a node.js site into Azure Web App to create a Website</title>
      <link>https://docs.microsoft.com/archive/blogs/laurelle/how-to-deploy-a-node-js-site-into-azure-web-app-to-create-a-website</link>
      <pubDate>Tue, 01 Dec 2015 01:47:30 GMT</pubDate>
      <dc:creator><![CDATA[Laurelle]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/laurelle/2015/12/01/how-to-deploy-a-node-js-site-into-azure-web-app-to-create-a-website/</guid>
      <description><![CDATA[There is quite a good documentation on the Azure website on how to deploy an Azure WebApp when using...]]></description>
      <content:encoded><![CDATA[<p>There is quite a good documentation on the Azure website on how to deploy an Azure WebApp when using node.js and Git repository from a Mac. Documentation is <a href="https://azure.microsoft.com/en-us/documentation/articles/web-sites-nodejs-develop-deploy-mac/" target="_blank">here</a>.</p>  <p>I wanted to deploy the code thru FTP and deploy selected part of my project. My idea is to deploy the Device Explorer site I’ve build in my <a href="https://blogs.msdn.com/b/laurelle/archive/2015/11/24/creating-an-azure-iot-device-explorer-in-node-js-express-and-jade.aspx" target="_blank">previous post</a>. So for the rest of the article, I will assume you’ve already created a node.js website using either the simple http listener, either an express, jade template like in my example.</p>  <h2>Step 1: create an Azure WebApp</h2>  <p>I’ll assume you already have an Azure subscription. If you don’t, <a href="https://azure.microsoft.com/en-us/pricing/free-trial/" target="_blank">just open a trial account</a>, it’s quite fast and easy. You’ll need your credit card but it won’t be used. It’s just in case you’ll go over the free costs. And in my example, as I don’t need this website to be all the time online and I will only use it sporadically, I’ll use free hosting.</p>  <p>In the <a href="https://portal.azure.com" target="_blank">Azure portal</a>, select <em>New</em>, then <em>Web + Mobile</em>, then <em>Web App</em></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8461.image_1C784490.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/8461.image_5F00_1C784490.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/2047.image_thumb_3E63A714.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/2047.image_5F00_thumb_5F00_3E63A714.png" width="577" height="238" /></a></p>  <p>Then create the site, the App Service Name is the name of your site.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/2625.image_12B2DD18.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/2625.image_5F00_12B2DD18.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1665.image_thumb_645BE81B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/1665.image_5F00_thumb_5F00_645BE81B.png" width="235" height="437" /></a></p>  <p>Allow couple of minutes for it to be created.</p>  <h2>Step 2: allow FTP uploads in the WebApp</h2>  <p>Now, you need to allow FTP deployment.</p>  <p>In the portal, select your newly created site, go into <em>All Settings </em>then <em>deployment credentials</em>, add a username and a password.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/2577.image_318BE1A7.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/2577.image_5F00_318BE1A7.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/7711.image_thumb_0F36DCDF.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/7711.image_5F00_thumb_5F00_0F36DCDF.png" width="618" height="263" /></a></p>  <p>Once done, you’ll get this in the summary view. The blue boxes include information to connect to the ftp deployment with the user name to use.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/5228.image_4A1E0FA8.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/5228.image_5F00_4A1E0FA8.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8270.image_thumb_05717567.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/8270.image_5F00_thumb_5F00_05717567.png" width="598" height="264" /></a></p>  <p>Now, you can check that you have access using any FTP tool like the Explorer in Windows or anything else.</p>  <h2>Step 3: creating the web.config file</h2>  <p>Now, we have to go into the project and add a web.config file. This is necessary to be able to have the node.js project running correctly.</p>  <p>Right click on your project, select <em>Add </em>then <em>New Item</em></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/6507.image_4E972120.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/6507.image_5F00_4E972120.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/5554.image_thumb_708283A4.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/5554.image_5F00_thumb_5F00_708283A4.png" width="592" height="224" /></a></p>  <p>Just write web.config and click on OK</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8357.image_126DE629.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/8357.image_5F00_126DE629.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/3817.image_thumb_600A12A9.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/3817.image_5F00_thumb_5F00_600A12A9.png" width="566" height="70" /></a></p>  <p>Then place this XML code into the web.config file:</p>  <p class="MsoNormal" style="list-style-type: disc; margin: 0cm 0cm 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><font style="font-size: 9.5pt">&lt;?</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">xml</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"> </font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#ff0000">version</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">=</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">1.0</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"> </font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#ff0000">encoding</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">=</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">utf-8</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff">?&gt;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"></span></p>  <p class="MsoNormal" style="list-style-type: disc; margin: 0cm 0cm 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 9.5pt">&#160; </font></span><font style="font-size: 9.5pt">&lt;</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">configuration</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff">&gt;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"></span></p>  <p class="MsoNormal" style="list-style-type: disc; margin: 0cm 0cm 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 9.5pt">&#160;&#160;&#160; </font></span><font style="font-size: 9.5pt">&lt;</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">system.webServer</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><font style="font-size: 9.5pt">&gt;</font><span style="mso-spacerun: yes"><font style="font-size: 9.5pt">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font></span></font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"></span></p>  <p class="MsoNormal" style="list-style-type: disc; margin: 0cm 0cm 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 9.5pt">&#160;&#160;&#160;&#160;&#160; </font></span><font style="font-size: 9.5pt">&lt;</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">handlers</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff">&gt;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"></span></p>  <p class="MsoNormal" style="list-style-type: disc; margin: 0cm 0cm 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 9.5pt">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font></span><font style="font-size: 9.5pt">&lt;</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">add</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"> </font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#ff0000">name</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">=</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">iisnode</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"> </font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#ff0000">path</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">=</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">app.js</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"> </font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#ff0000">verb</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">=</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">*</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"> </font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#ff0000">modules</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">=</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">iisnode</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff">/&gt;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"></span></p>  <p class="MsoNormal" style="list-style-type: disc; margin: 0cm 0cm 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 9.5pt">&#160;&#160;&#160;&#160;&#160; </font></span><font style="font-size: 9.5pt">&lt;/</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">handlers</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff">&gt;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"></span></p>  <p class="MsoNormal" style="list-style-type: disc; margin: 0cm 0cm 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 9.5pt">&#160;&#160;&#160;&#160;&#160; </font></span><font style="font-size: 9.5pt">&lt;</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">rewrite</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff">&gt;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"></span></p>  <p class="MsoNormal" style="list-style-type: disc; margin: 0cm 0cm 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 9.5pt">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font></span><font style="font-size: 9.5pt">&lt;</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">rules</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff">&gt;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"></span></p>  <p class="MsoNormal" style="list-style-type: disc; margin: 0cm 0cm 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 9.5pt">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font></span><font style="font-size: 9.5pt">&lt;</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">rule</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"> </font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#ff0000">name</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">=</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">DynamicContent</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff">&gt;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"></span></p>  <p class="MsoNormal" style="list-style-type: disc; margin: 0cm 0cm 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 9.5pt">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font></span><font style="font-size: 9.5pt">&lt;</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">match</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"> </font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#ff0000">url</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">=</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">/*</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff"> /&gt;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"></span></p>  <p class="MsoNormal" style="list-style-type: disc; margin: 0cm 0cm 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 9.5pt">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font></span><font style="font-size: 9.5pt">&lt;</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">action</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"> </font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#ff0000">type</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">=</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">Rewrite</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"> </font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#ff0000">url</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">=</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">app.js</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff">/&gt;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"></span></p>  <p class="MsoNormal" style="list-style-type: disc; margin: 0cm 0cm 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 9.5pt">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font></span><font style="font-size: 9.5pt">&lt;/</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">rule</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff">&gt;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"></span></p>  <p class="MsoNormal" style="list-style-type: disc; margin: 0cm 0cm 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 9.5pt">&#160;&#160;&#160;&#160;&#160;&#160; </font></span><font style="font-size: 9.5pt">&lt;/</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">rules</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff">&gt;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"></span></p>  <p class="MsoNormal" style="list-style-type: disc; margin: 0cm 0cm 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 9.5pt">&#160;&#160;&#160;&#160;&#160; </font></span><font style="font-size: 9.5pt">&lt;/</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">rewrite</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff">&gt;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"></span></p>  <p class="MsoNormal" style="list-style-type: disc; margin: 0cm 0cm 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 9.5pt">&#160;&#160;&#160; </font></span><font style="font-size: 9.5pt">&lt;/</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">system.webServer</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff">&gt;</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"></span></p>  <p class="MsoNormal" style="list-style-type: disc; margin: 0cm 0cm 8pt; line-height: 12pt"><font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; line-height: 10pt; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 9.5pt">&#160; </font></span><font style="font-size: 9.5pt">&lt;/</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; line-height: 10pt; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">configuration</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; line-height: 10pt; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff">&gt;</font></span></font><span lang="EN-US"></span></p>  <p>&#160;</p>  <p>Important part is on the <font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><font style="font-size: 9.5pt">&lt;</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">handlers</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff">&gt; </font></span></font>as it tells Azure Web App that it’s a node.js app and need to use the node engine. The <span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#ff0000">path</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">=</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff">app.js</font></span><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#000000">&quot;</font></span> tells which js file to use as startup.</p>  <p>The other important part is the <font face="Consolas"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#0000ff"><font style="font-size: 9.5pt">&lt;</font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font color="#a31515">rewrite</font></span></font><span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-bidi-font-family: consolas; mso-highlight: white; mso-ansi-language: fr"><font style="font-size: 9.5pt" color="#0000ff">&gt; </font></span></font>section as it will make sure the app.js page will be called as default page. If you don’t do that, you’ll have to access your site like <a href="https://mysite.net/app.js">https://mysite.net/app.js</a> and you just want to access it like <a href="https://mysite.net/">https://mysite.net/</a> </p>  <h2>Step 4: deploying the files to the Web App</h2>  <p>To deploy, I’m simply using the Windows Explorer as an FTP client. For copying files, it’s just working perfectly. Connect to the FTP host, you’ll be ask for login and password, that’s the one you’ve created at step 2.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/3823.image_1B5D7868.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/3823.image_5F00_1B5D7868.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1805.image_thumb_4F91A1AE.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/1805.image_5F00_thumb_5F00_4F91A1AE.png" width="527" height="390" /></a></p>  <p>Once connected, you can go to the /site/wwroot directory for example. but it can be any directory, you’ll just need to set it up in the Web App properties. In order to make it simple and as it’s the default directly, I’ll use this one.</p>  <p>Now, very important, copy all the files and directories that do contains the code you’ve produced. Make sure you deploy the newly created web.config, your package.json. <strong><font color="#ff0000">Do not deploy </font></strong>the node_modules directory.</p>  <p>Once compiled with Visual Studio, if you’re creating your site using TypeScript, it will create the js file. You don’t need to deploy the ts file, you just need the JavaScript generated js files.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/4401.image_21A6DFA7.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/4401.image_5F00_21A6DFA7.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8836.image_thumb_5E5E6837.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/8836.image_5F00_thumb_5F00_5E5E6837.png" width="541" height="393" /></a></p>  <h2>Step 5: making sure all node modules are installed</h2>  <p>Now you’ve copy all the right files, you can make sure the node.js packages are deployed. In theory, when you’ll run for the first time your app, packages will be downloaded and installed. It is better to do it manually by connecting to the Kudu console. </p>  <p>So connect to <a href="https://nameofsite.scm.azurewebsites.net">https://<b>nameofsite</b>.scm.azurewebsites.net</a> where nameofsite is the name of the site you’ve created, use the login and password you’ve created.</p>  <p>Navigate to your main directory, select <em>Debug console </em>and <em>CMD</em></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/5824.image_674DFA76.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/5824.image_5F00_674DFA76.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/0458.image_thumb_2E8C85EC.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/0458.image_5F00_thumb_5F00_2E8C85EC.png" width="809" height="128" /></a></p>  <p>In the console type “<em>npm install</em>”, this will install al your packages.</p>  <p>This will create the node_modules directory and deploy all the packages in it:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/4188.image_7BBC7F77.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/4188.image_5F00_7BBC7F77.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/3146.image_thumb_1DA7E1FC.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/3146.image_5F00_thumb_5F00_1DA7E1FC.png" width="490" height="314" /></a></p>  <h2>Step 6: you’re good to go</h2>                      <p>Now you can connect to your web site and test it! It will just work <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none" alt="Sourire" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/6567.wlEmoticon-smile_4B2901BF.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/6567.wlEmoticon_2D00_smile_5F00_4B2901BF.png" />&#160;</p>  <p>And big thanks to <a href="https://www.juliencorioland.net/" target="_blank">Julien Corioliand</a> for his help. </p>]]></content:encoded>
    </item>
    <item>
      <title>Creating an Azure IoT Device Explorer in node.js, express and jade</title>
      <link>https://docs.microsoft.com/archive/blogs/laurelle/creating-an-azure-iot-device-explorer-in-node-js-express-and-jade</link>
      <pubDate>Tue, 24 Nov 2015 08:25:45 GMT</pubDate>
      <dc:creator><![CDATA[Laurelle]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/laurelle/2015/11/24/creating-an-azure-iot-device-explorer-in-node-js-express-and-jade/</guid>
      <description><![CDATA[After playing a bit with Azure IoT hub and building a webcam system with a RaspberryPi 2 running...]]></description>
      <content:encoded><![CDATA[<p>After playing a bit with Azure IoT hub and building a <a href="https://blogs.msdn.com/b/laurelle/archive/2015/11/13/azure-iot-hub-uploading-a-webcam-picture-in-an-azure-blob-with-node-js-on-windows-and-linux.aspx" target="_blank">webcam system with a RaspberryPi 2 running Linux</a> in my previous article, I’ve decided to continue developing a bit in node.js to build a simple equivalent of the <a href="https://github.com/Azure/azure-iot-sdks/tree/master/tools/DeviceExplorer" target="_blank">Device Explorer</a> but in node.js. I’m not a node.js expert so there may be more efficient way to write some of the code.</p>  <p>Code is available on GitHub: <a title="https://github.com/Ellerbach/nodejs-webcam-azure-iot/tree/master/DeviceExplorer" href="https://github.com/Ellerbach/nodejs-webcam-azure-iot/tree/master/DeviceExplorer" target="_blank">https://github.com/Ellerbach/nodejs-webcam-azure-iot/tree/master/DeviceExplorer</a>. The code on GitHub does include more than what is explained in this article.</p>  <h3>Setup the dev environement</h3>  <p>I’ll use Windows as my development environment. Visual Studio 2015 can support node.js development and debugging. So first I needed to setup Visual Studio 2015:</p>  <ul>   <li>You can get for free Visual Studio Community 2015 <a href="https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx" target="_blank">here</a>. </li>    <li>Then you need to the free node.js tools for Visual Studio, download them <a href="https://www.visualstudio.com/en-us/features/node-js-vs.aspx" target="_blank">here</a>. </li>    <li>And you need of course to install the node.js framework from <a href="https://nodejs.org/en/" target="_blank">here</a>.</li> </ul>  <p>Once those 3 steps done, you’re good to go!</p>  <h3>Creating a node.js project in Visual Studio</h3>  <p>This is quite straight forward, you have new project type which is node.js. I’ve created a Start Node.js Express 3 Application project. It does come with a simple MVC project containing couple of example pages which makes it easy to learn and understand how all is working.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/6253.image_4E7B973B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/6253.image_5F00_4E7B973B.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/5050.image_thumb_0B331FCC.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/5050.image_5F00_thumb_5F00_0B331FCC.png" width="523" height="365" /></a></p>  <p>Views are using jade. This is a part where I had quite some difficulties to use. I do recommend to read the Language Reference as well as the examples from <a title="https://jade-lang.com/" href="https://jade-lang.com/" target="_blank">https://jade-lang.com/</a>. The most important is to keep in mind the indentation must be respected and this is what makes groups and makes all the code logic. When you got that, the rest is quite easy and really nice to use.</p>  <p>&#160;</p>  <p>It will create a full web site. I do recommend to create TypeScript file and not Javascript. this will allow to have a better support and maintainability over time. Javascript file are generated once compiled. And you can choose which version of Javascript you want to generate.</p>  <p>&#160;</p>  <h3>Listing devices</h3>  <p>The idea is to have a page that will allow to enter the connection key:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/7762.image_1CA61155.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/7762.image_5F00_1CA61155.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/4341.image_thumb_37DE6A56.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/4341.image_5F00_thumb_5F00_37DE6A56.png" width="574" height="118" /></a></p>      <p>Once the key is entered, it will list the devices plus their keys and couple of other info (in real, keys are displayed instead of the blue box):</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/2318.image_0ED65C0B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/2318.image_5F00_0ED65C0B.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/2158.image_thumb_24BFCE5B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/2158.image_5F00_thumb_5F00_24BFCE5B.png" width="585" height="142" /></a></p>  <p>So to build this, we will need to:</p>  <ul>   <li>Create a view which is about adding a jade file in the views directory</li>    <li>Add a function to handle requests on the page</li>    <li>Add a route so the traffic will be correctly redirected to the page</li> </ul>  <p>I will first explain how the principle of views and code is working.</p>  <h4>Adding the view</h4>  <p>Right click on Views then Add and New Items…</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/7317.image_098A060B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/7317.image_5F00_098A060B.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/5153.image_thumb_4F9AC31E.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/5153.image_5F00_thumb_5F00_4F9AC31E.png" width="449" height="158" /></a></p>  <p>select jade file and create one call devices.jade. Let start by replacing what is generated by this code:</p>  <p>extends layout</p>  <p>block content   <br />&#160; h2 #{title}    <br />&#160; h3 #{message}</p>  <p>div.connbox   <br />&#160; p please enter your connection string like HostName=XXX.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=XXX    <br />&#160; form(name=&quot;connection&quot;, action=&quot;/devices&quot;, method=&quot;post&quot;)    <br />&#160;&#160;&#160; input(type=&quot;text&quot;, name=&quot;constr&quot;)    <br />&#160;&#160;&#160; input(type=&quot;submit&quot;, value=&quot;Connect&quot;)    <br /></p>  <p>In jade, it will create a page where the #{title} will be replaced by the default text rendering of the title object which will be given to the page. It can be a string or any object. This will allow to manipulate those objects and we will see later how to do that.</p>  <p>The second part will create a form which will post the value of the text box to the page names /devices</p>  <h4>Adding a function to handle the code</h4>  <p>In the routes/index.js file, add this code:</p>  <p>export function devices(req: express.Request, res: express.Response) {   <br />&#160;&#160;&#160; var cnxstr = req.body['constr'];    <br />&#160;&#160; res.render('devices', { title: 'Devices', message: 'this is the connection string: ‘ + cnxstr });    <br />};</p>  <p>This simple code just find the value of ‘constr’ which has been send by the post form and ask to render the page by sending back the info in the message object. Now, we still don’t have everything as the function has not been declared as a route when the page /devices is called.</p>  <h4>Adding the route for a page</h4>  <p>Find the file app.ts and add the lines after the line “app.get(‘/’, routes.index);”</p>  <p>app.get('/devices', routes.devices);   <br />app.post('/devices', routes.devices);</p>  <p>Basically, the function we’ve just wrote is now linked to a get or post request on the /devices page.</p>  <p>All together, if you click F5, go on the /devices pages, you’ll be able to fill the text box, send the data to the page and see what you’ve posted. This is a very basic example but it does allow to understand how express and jade are working together.</p>  <h4>Requesting Azure IoT Hub devices list in node.js</h4>  <p>You’ll need to add the ‘azure-iothub”&quot;’ module.&#160; Using Visual Studio, makes it super easy. Just right click on “npm” in your project then select “Install new npm Packages…”</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/2337.image_07A05C30.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/2337.image_5F00_07A05C30.png"><img title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/0447.image_thumb_09DCE4EC.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/0447.image_5F00_thumb_5F00_09DCE4EC.png" width="393" height="111" /></a></p>  <p>This will open this window where you can search for the packages.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/4604.image_04FA3130.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/4604.image_5F00_04FA3130.png"><img title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1663.image_thumb_522A2ABB.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/1663.image_5F00_thumb_5F00_522A2ABB.png" width="396" height="287" /></a></p>  <p>&#160;</p>  <p>Here is the code to request all devices present in the IoT hub. It is quite straight forward as the node.js SDK is really nicely done:</p>  <p>var iothub = require('azure-iothub');   <br />var cnxString = '';</p>  <p>export function devices(req: express.Request, res: express.Response) {   <br />&#160;&#160;&#160; var cnxstr = req.body['constr'];    <br />&#160;&#160;&#160; if ((cnxstr != undefined) || (cnxString)) {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (cnxString) {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if ((cnxstr == undefined)||(cnxstr ==''))    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; cnxstr = cnxString;    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var registry = iothub.Registry.fromConnectionString(cnxstr);    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; registry.list(function (err, deviceList) {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (!err) {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; cnxString = cnxstr;    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.render('devices', { title: 'Devices', year, message: 'Getting list of devices', devicelist: deviceList });    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } else    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.render('devices', { title: 'Devices', year, message: 'Error getting list of devices', devicelist: null });    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; });    <br />&#160;&#160;&#160; } else    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.render('devices', { title: 'Devices', year, message: 'Please give a valid connection key', devicelist: null });&#160;&#160;&#160; <br />};</p>  <p>First part of the code is really here to check if a connection string has already been provided. If yes, it will reuse the connection string. The key 2 lines are:</p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var registry = iothub.Registry.fromConnectionString(cnxstr);  <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; registry.list(function (err, deviceList) {  <br />  <p>this will return in devicelist an array of devices. If no error, then it is passed to the devices view. So very straight forward.</p>  <h4>Modifying the jade view to render devices list</h4>  <p>Go back to the devices.jade file and add the following code:</p>  <p>div.text   <br />if(devicelist!=null)    <br />&#160; table    <br />&#160;&#160;&#160; thead    <br />&#160;&#160;&#160;&#160;&#160; tr    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; th    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | DeviceId    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; th    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Prim Key    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; th    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Sec key    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; th    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Last upd    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; th    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Status    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; th    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Msg waiting    <br />&#160;&#160;&#160; tbody    <br />&#160;&#160;&#160;&#160;&#160; each device in devicelist    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; tr    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; a(href='/devicedetail/' + device.deviceId) #{device.deviceId}    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.authentication.SymmetricKey.primaryKey}    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.authentication.SymmetricKey.secondaryKey}    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.lastActivityTime}    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.status}    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.cloudToDeviceMessageCount}    <br />&#160; p     <br />&#160; a(href='/adddevice/') Add a new device</p>  <p>This part took me quite a lot of time. The reason is jade and the way indentation is working. It is really super important to respect it and the alignment almost drives the behavior of what will be generated. the good news is that you can add code in the jade file like testing if you have a devicelist object. and do for each in the code. The code will generate a simple table which contains some of the device properties. I’ve created as well a page for details as well as a page to add a new device.</p>  <p>This code will render exactly as in the screen capture from the first part of this article. Now, let see how to generate the detailed page for devices as well as creating a new device.</p>  <h3>Listing devices properties</h3>  <p>Similar to the previous part, add a devicedetail jade, here is the code very similar to the previous page to generate the details in a table:</p>  <p>extends layout</p>  <p>block content   <br />&#160; h2 #{title}    <br />&#160; p #{message}</p>  <p>&#160; div.text   <br />&#160; if(device!=null)    <br />&#160;&#160;&#160; table    <br />&#160;&#160;&#160;&#160;&#160; thead    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; tr    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; th    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Details    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; th    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Values    <br />&#160;&#160;&#160;&#160;&#160; tbody    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tr    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Device Id    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.deviceId}    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tr    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Primary Key    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.authentication.SymmetricKey.primaryKey}    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tr    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Secondary Key    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.authentication.SymmetricKey.secondaryKey}    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tr    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Last Activity    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.lastActivityTime}    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tr    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Generation Id    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.generationId}    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tr    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Messages waiting    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.cloudToDeviceMessageCount}    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tr    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | etag    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.etag}    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tr    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Status    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.status}    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tr    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Status Reason    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.statusReason}    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tr    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Connection State    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.connectionState}    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tr    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | connectionStateUpdatedTime    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.connectionStateUpdatedTime}    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tr    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | statusUpdatedTime     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; td    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | #{device.statusUpdatedTime}</p>  <p>We’ll need to create a function that will handle the request and return the device object:</p>  <p>export function devicedetail(req: express.Request, res: express.Response) {   <br />&#160;&#160;&#160; var devId = req.params.deviceId;    <br />&#160;&#160;&#160; var strcnx = getHostName(cnxString);    <br />&#160;&#160;&#160; if (strcnx == '')    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.render('devicedetail', { title: 'Device detail', year, message: 'Error getting device details. Connection string was: ' + cnxString + ' and deviceId: ' + devId });    <br />&#160;&#160;&#160; strcnx += ';DeviceId=' + devId;    <br />&#160;&#160;&#160; var registry = iothub.Registry.fromConnectionString(cnxString);    <br />&#160;&#160;&#160; var msg = 'No device found';    <br />&#160;&#160;&#160; registry.get(devId, function (err, device) {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (!err) {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; strcnx += ';SharedAccessKey=' + device.authentication.SymmetricKey.primaryKey;    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.render('devicedetail', { title: 'Device detail', year, message: 'Those are the device details. Connection string: ' + strcnx, device: device });    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; } else    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.render('devicedetail', { title: 'Device detail', year, message: 'Error connecting' });    <br />&#160;&#160;&#160; });    <br />};</p>  <p>function getHostName(str)   <br />{    <br />&#160;&#160;&#160; var txtchain = str.split(';');    <br />&#160;&#160;&#160; for (var strx in txtchain) {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var txtbuck = txtchain[strx].split('=')    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (txtbuck[0].toLowerCase() == 'hostname')    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return txtchain[strx];    <br />&#160;&#160;&#160; }    <br />&#160;&#160;&#160; return '';    <br />}</p>  <p>As you’ll see in the jade page, the link to the page is /devicedeatil/name_of_a_device. In order to catch it, we’ll need to declare it in the route and it will allow to have it thru the req.params function. I will name it deviceid. so add this line in the app.ts file:</p>  <p>app.get('/devicedetail/:deviceId', routes.devicedetail);</p>  <p>First part of the code is about getting the list of devices and making sure the device exists. then it’s about getting the device and returning it. As sometimes you need the device connection string, this string is built and returned as well. As a result, you’ll get a detailed page like:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/0003.image_742EE153.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/0003.image_5F00_742EE153.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/5148.image_thumb_3EB8AFDF.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/5148.image_5F00_thumb_5F00_3EB8AFDF.png" width="484" height="270" /></a></p>  <p>Those properties are the ones available for every device. The status shows is the device is allow or not to connect. If not, you’ll have a reason (128 bit max) displayed in the Status reason. If you send messages to your device, you’ll see as well if messages are waiting.</p>  <h3>Adding a device to Azure IoT hub</h3>  <p>Very similar to the previous part, we’ll just add a jade file adddevice. Here is the code:</p>  <p>extends layout</p>  <p>block content   <br />&#160; h2 #{title}    <br />&#160; p #{message}</p>  <p>&#160; div.connbox   <br />&#160; if(deviceId==null)    <br />&#160;&#160;&#160; p please enter your device name    <br />&#160;&#160;&#160; form(name=&quot;adddevice&quot;, action=&quot;/adddevice&quot;, method=&quot;post&quot;)    <br />&#160;&#160;&#160;&#160;&#160; input(type=&quot;text&quot;, name=&quot;deviceId&quot;)    <br />&#160;&#160;&#160;&#160;&#160; input(type=&quot;submit&quot;, value=&quot;Add&quot;)</p>  <p>Simple code, very similar to the first example. For the main function code, it’s quite easy as well:</p>  <p>export function adddevice(req: express.Request, res: express.Response) {   <br />&#160;&#160;&#160; var devId = req.params.deviceId;    <br />&#160;&#160;&#160; if (devId == undefined) {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; devId = req.body['deviceId'];    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (devId == undefined)    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.render('adddevice', { title: 'Add device', year, message: 'Error, no device ID' });    <br />&#160;&#160;&#160; }     <br />&#160;&#160;&#160; if (cnxString == '')    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.render('adddevice', { title: 'Add device', year, message: 'Error, no connection string' });    <br />&#160;&#160;&#160; else {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var registry = iothub.Registry.fromConnectionString(cnxString);    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; //create a new device    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var device = new iothub.Device(null);    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; device.deviceId = devId;    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; registry.create(device, function (err, deviceInfo, response) {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (err)    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.render('adddevice', { title: 'Add device', year, message: 'Error, creating device' + err.toString() })    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (deviceInfo)    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.render('adddevice', { title: 'Add device', year, message: 'Device created ' + JSON.stringify(deviceInfo) });    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; res.render('adddevice', { title: 'Add device', year, message: 'Unknown error creating device ' + devId });    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; });    <br />&#160;&#160;&#160; }&#160; <br />}</p>  <p>All up, first part of the code is just to check if there is a device name either thru get as a param, either thru post. Second part is about adding a device:</p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var registry = iothub.Registry.fromConnectionString(cnxString);  <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; //create a new device  <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var device = new iothub.Device(null);  <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; device.deviceId = devId;  <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; registry.create(device, function (err, deviceInfo, response) {  <p>Again, very simple, very straight forward. we’re connecting to the Azure IoT Hub registry, then create an empty device, set the deviceId name and ask for creation. </p>  <p>Don’t forget to add the route as well. the “?” in “/adddevice/:deviceId?” is to make the param as optional.</p>  <p>app.get('/adddevice/:deviceId?', routes.adddevice);   <br />app.post('/adddevice', routes.adddevice);</p>  <p>Once created, if there is no error, the device is sent back. I’m just converting it into a JSON and display it in the message:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1803.image_752961E1.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/1803.image_5F00_752961E1.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8156.image_thumb_2B9A13E4.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/8156.image_5F00_thumb_5F00_2B9A13E4.png" width="625" height="113" /></a></p>  <p>You can do a very similar code to delete a device. You can as well send a message to the device and monitor the results. I have to say the Azure IoT SDK in node.js is really great and working perfectly. And please note that this website can be deployed on Azure, Windows or Linux or anything else that can run one of the latest node.js version (see restriction in the Azure Iot SDKs on GitHub <a href="https://github.com/Azure/azure-iot-sdks" target="_blank">here</a>)</p>  <p>More examples on <a href="https://github.com/Ellerbach/nodejs-webcam-azure-iot/tree/master/DeviceExplorer" target="_blank">my GitHub</a>! Enjoy and feedback welcome.</p>]]></content:encoded>
    </item>
    <item>
      <title>Azure IoT Hub uploading a Webcam picture in an Azure blob with node.js on Windows and Linux</title>
      <link>https://docs.microsoft.com/archive/blogs/laurelle/azure-iot-hub-uploading-a-webcam-picture-in-an-azure-blob-with-node-js-on-windows-and-linux</link>
      <pubDate>Fri, 13 Nov 2015 08:07:00 GMT</pubDate>
      <dc:creator><![CDATA[Laurelle]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/laurelle/2015/11/13/azure-iot-hub-uploading-a-webcam-picture-in-an-azure-blob-with-node-js-on-windows-and-linux/</guid>
      <description><![CDATA[In my garden, I have couple of sensors and a greenhouse. In order to play with different...]]></description>
      <content:encoded><![CDATA[<p>In my garden, I have couple of sensors and a greenhouse. In order to play with different technologies I&rsquo;m using a RaspberryPI v1 (RPI) under Linux with an Atmel328 (same as in Arduino) for analogic data. And I wanted to test the new Azure IoT Hub. As I didn&rsquo;t know anything on node.js, I&lsquo;ve decided to go for node.js as well using this RPI under Linux. So many new technologies for me <img class="wlEmoticon wlEmoticon-smile" style="border-style: none;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8625.wlEmoticon-smile_3F5085AF.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/8625.wlEmoticon_2D00_smile_5F00_3F5085AF.png" alt="Sourire" /> As I just wrote, I&rsquo;m not a node.js king neither a Linux expert, just a beginner but I want to share my experience. And there may be best ways to code all this, so feedbacks welcome.</p>
<h1>Setup the dev environement</h1>
<p>I&rsquo;ll use Windows as my development environnement. Visual Studio 2015 can support node.js development and debugging. So first I needed to setup Visual Studio 2015. You can get for free Visual Studio Community 2015 <a href="https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx">here</a>. Then you need to the free node.js tools for Visual Studio, download them <a href="https://www.visualstudio.com/en-us/features/node-js-vs.aspx">here</a>. And you need of course to install the node.js framework from <a href="https://nodejs.org/en/">here</a>.</p>
<p>And you&rsquo;re all done for the dev side! so fast, so quick on the Windows side!</p>
<h1>Setup the RaspberryPI</h1>
<p>I have to say, this part was a bit more difficult for me. First I&rsquo;m not a Linux guy, second, it&rsquo;s not that easy to install node.js when you don&rsquo;t really know what you need. So here are the steps to install the latest version. I have to say I&rsquo;ve spend quite a lot of time trying to install the right version. The one by default in the raspian repository is not the latest version. Finally, after some time I found the way to properly install it from the Azure IoT SDK github page <a href="https://github.com/nodejs/node-v0.x-archive/wiki/Installing-Node.js-via-package-manager">here</a>. The version I&rsquo;m running on the RPI is a Debian (wheezy). So if you&rsquo;re running the Jessie or Wheezy version, to get node.js installed correctly, here are the steps:</p>
<pre><code>sudo apt-get install curl<br /></code><code>sudo curl --silent --location https://deb.nodesource.com/setup_0.12 | bash &ndash;<br /></code><code>sudo apt-get install --yes nodejs</code></pre>
<p>Most likely because of previous/bad versions installed before it didn&rsquo;t worked right away. After a reboot, it did finally (who said, no reboot is necessary in Linux? <img class="wlEmoticon wlEmoticon-smile" style="border-style: none;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8625.wlEmoticon-smile_3F5085AF.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/8625.wlEmoticon_2D00_smile_5F00_3F5085AF.png" alt="Sourire" />). This will install as well &ldquo;npm&rdquo; which will allow later to download some needed module packages.</p>
<h1>Creating a node.js project in Visual Studio</h1>
<p>this is quite straight forward, you have new project type which is node.js. I&rsquo;ve created a Web project (this will allow easily to test couple of functions)</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/5023.image_61A81B28.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/5023.image_5F00_61A81B28.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1643.image_thumb_637870EF.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/1643.image_5F00_thumb_5F00_637870EF.png" alt="image" width="439" height="307" border="0" /></a></p>
<p>It will create a server.ts file. I do recommend to create TypeScript file and not Javascript. this will allow to have a better support and maintainability over time. Javascript file are generated once compiled. And you can choose which version of Javascript you want to generate.</p>
<p>You can hit F5 and run your code <img class="wlEmoticon wlEmoticon-smile" style="border-style: none;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8625.wlEmoticon-smile_3F5085AF.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/8625.wlEmoticon_2D00_smile_5F00_3F5085AF.png" alt="Sourire" /> by default, it will create a project with a simple web server, you can try to debug, put break point. Quite magic <img class="wlEmoticon wlEmoticon-smile" style="border-style: none;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8625.wlEmoticon-smile_3F5085AF.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/8625.wlEmoticon_2D00_smile_5F00_3F5085AF.png" alt="Sourire" /></p>
<h1>How to run all this on Raspberry?</h1>
<p>the only 2 files you&rsquo;ll need are the &ldquo;server.js&rdquo; and the &ldquo;package.json&rdquo; one. this second one contains the dependencies with other modules. So far, no real dependencies. It&rsquo;s needed as well if you want to publish and share back your code as a package. So you&rsquo;ll make sure that you&rsquo;ll get all the right dependencies for your package and that it will always work.</p>
<p>to lunch the server, just type:</p>
<p><code>node server.js</code></p>
<p>The server will run as long as you close the console or stop it. Access it thru a browser with <a href="https://ipaddressport">https://ipaddress:port/</a> the ipaddress is the ip address of the RPI and the port, the port you&rsquo;ve chosen in your code.</p>
<p>If at this point it does not work, then it&rsquo;s maybe because you have a node.js problem. Try to type &ldquo;node &ndash;v&rdquo;, this is supposed to give you the installed version. The one I&rsquo;ve installed is v0.12.7</p>
<h1>Installing packages on dev environment</h1>
<p>With node.js you&rsquo;ll need to install couple of packages. Both on the dev environment and on the production environment.</p>
<p>Using Visual Studio, makes it super easy. Just right click on &ldquo;npm&rdquo; in your project then select &ldquo;Install new npm Packages&hellip;&rdquo;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/2337.image_07A05C30.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/2337.image_5F00_07A05C30.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/0447.image_thumb_09DCE4EC.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/0447.image_5F00_thumb_5F00_09DCE4EC.png" alt="image" width="393" height="111" border="0" /></a></p>
<p>This will open this window where you can search for the packages.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/4604.image_04FA3130.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/4604.image_5F00_04FA3130.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1663.image_thumb_522A2ABB.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/1663.image_5F00_thumb_5F00_522A2ABB.png" alt="image" width="396" height="287" border="0" /></a></p>
<p>We&rsquo;ll need the following ones: &ldquo;azure&rdquo; and &ldquo;azure-iot-device&rdquo;. So install them. this will install all the packages and dependencies needed. It makes it very easy to see what are the available versions, if a package is already installed locally.</p>
<h1>Installing packages on the RPI</h1>
<p>it&rsquo;s about the same except it&rsquo;s in command line. Thanks to the npm utility in Visual Studio, I know the packages I&rsquo;ll need to install <img class="wlEmoticon wlEmoticon-smile" style="border-style: none;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8625.wlEmoticon-smile_3F5085AF.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/8625.wlEmoticon_2D00_smile_5F00_3F5085AF.png" alt="Sourire" />&nbsp;</p>
<p><code>sudo npm install azure<br />sudo npm install azure-iot-device</code></p>
<p>Note: if you need a specific version, you can install it by giving the version like: sudo npm install azure-iot-device@1.0.0-preview5</p>
<h1>Connecting a device to Azure IoT Hub</h1>
<p>The first thing to do is to create an Azure IoT Hub. Step by step <a href="https://azure.microsoft.com/en-us/documentation/articles/iot-hub-csharp-csharp-getstarted/">here</a>. This is great step by step, very easy. I do recommend to do all the tutorial and create all the codes in C#. This will allow you to understand how Azure IoT Hub is working. You&rsquo;ll need this to continue this article.</p>
<p>The most important is to create at least 1 device identity. If you don&rsquo;t, you will not be able to access the IoT Hub, send and receive messages.</p>
<p>The other tool I recommend you to use is part of the Azure IoT SDK and named <a href="https://github.com/Azure/azure-iot-sdks/tree/master/tools/DeviceExplorer">DeviceExplorer</a>. Follow the tutorial to create a device, launch this tool, put the connection string from your Azure IoT Hub in it (connection string look like: HostName=youriothub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=thekey), and you should be able to see the device:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/2500.image_7AC896C2.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/2500.image_5F00_7AC896C2.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/2500.image_thumb_5637093E.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/2500.image_5F00_thumb_5F00_5637093E.png" alt="image" width="458" height="212" border="0" /></a></p>
<p>From here, you&rsquo;ll need for later the device ConnectionString. this connection string is different from the main hub connection string! it is formed the same way as the previous one but is contains DeviceId (here calle LaurelleRPI) which is the name of your device instead of SharedAccessKeyName.</p>
<p>HostName=youriothub.azure-devices.net;DeviceId=LaurelleRPI;SharedAccessKey=thedevicekey</p>
<p>In the code, you&rsquo;ll need this to get connected to the IoT Hub:</p>
<p>var device = require('azure-iot-device');<br />// must match the deviceID in the connection string <br />var connectionstring = HostName=youriothub.azure-devices.net;DeviceId=LaurelleRPI;SharedAccessKey=thedevicekeyI'; <br />var iotHubClient = new device.Client(connectionstring, new device.Https());</p>
<p>And yes, that&rsquo;s all what you need! How to test it? We can modify a bit the web server code to have a function which will send data to the IoT Hub. We will check with the Device Explorer if data arrive. So add this to the previous code and change the server function.</p>
<p>var url = require('url');<br />var deviceID = 'LaurelleRPI';<br />var port = process.env.port || 1337</p>
<p>http.createServer(function (req, res) {<br />&nbsp;&nbsp;&nbsp; var request = url.parse(req.url, true);<br />&nbsp;&nbsp;&nbsp; var action = request.pathname;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; if (action == '/senddata') {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var payload = '{\"deviceid\":\"' + deviceID + '\",\"wind\":42 }';<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var message = new device.Message(payload);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iotHubClient.sendEvent(message, function (err, res) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!err) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (res &amp;&amp; (res.statusCode !== 204)) console.log('send status: ' + res.statusCode + ' ' + res.statusMessage);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; console.log('no data send, error ' + err.toString());<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res.end('data sent');<br />&nbsp;&nbsp;&nbsp; } else {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res.writeHead(200, { 'Content-Type': 'text/plain' });<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res.end('Linux RPI working perfectly, try /status /postimage /senddata and /image.jpg \n');<br />&nbsp;&nbsp;&nbsp; }</p>
<p>}).listen(port);</p>
<p>&nbsp;</p>
<p>Run the code and access to the <a href="https://ipaddress:1337/senddata">https://ipaddress:1337/senddata</a></p>
<p>this will post data to the Azure IoT Hub and you&rsquo;ll see them in the Device Explorer, You&rsquo;ll need to monitor the device you&rsquo;ve just created and you&rsquo;ll use in your node.js code. At this point, you should see this:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1348.image_65D9A500.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/1348.image_5F00_65D9A500.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/2330.image_thumb_3A28DB04.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/2330.image_5F00_thumb_5F00_3A28DB04.png" alt="image" width="389" height="315" border="0" /></a></p>
<p>if not, you&rsquo;ll most likely get an error message. Most of the error I got was because I made a mistake in the connection string or in my Typescript.</p>
<p>Now, the next step is to be able to receive messages from the IoT Hub. In order to see if we have received a message or not, we&rsquo;ll need to listen all the time to check is a message is arrived. The function bellow check is a message is arrived and place it into messageFromIoTHub</p>
<p>var messageFromIoTHub = "";</p>
<p>function pushtoblob()<br />{ //do nothing</p>
<p>}</p>
<p>function isMessage()<br />{<br />&nbsp;&nbsp;&nbsp; iotHubClient.receive(function (err, res, msg) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!err &amp;&amp; res.statusCode !== 204) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; console.log('Received data: ' + msg.getData());<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // process the request<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; messageFromIoTHub = msg.getData();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (messageFromIoTHub === "picture") <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pushtoblob();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iotHubClient.complete(msg, function (err, res) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (err) console.log('complete error: ' + err.toString());<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (res &amp;&amp; (res.statusCode !== 204)) console.log('complete status: ' + res.statusCode + ' ' + res.statusMessage);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return true;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else if (err) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; console.log('receive error: ' + err.toString());<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; });<br />&nbsp;&nbsp;&nbsp; return false;<br />}</p>
<p>var isWaiting = false;<br />function waitForMessages() {<br />&nbsp;&nbsp;&nbsp; isWaiting = true;<br />&nbsp;&nbsp;&nbsp; isMessage()<br />&nbsp;&nbsp;&nbsp; isWaiting = false;<br />}</p>
<p>// Start messages listener<br />setInterval(function () { if (!isWaiting) waitForMessages(); }, 1000);</p>
<p>The hub will be checked every second. Up to this point, you can test the code. Place a break point on the line &ldquo;messageFromIoTHub = msg.getData();&rdquo; and run the code.</p>
<p>From Device Explorer, send the message &ldquo;picture&rdquo;, if all geos well, you&rsquo;ll receive back a feedback.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/1323.image_10B499C4.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/1323.image_5F00_10B499C4.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/3872.image_thumb_40DE7538.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/3872.image_5F00_thumb_5F00_40DE7538.png" alt="image" width="424" height="352" border="0" /></a></p>
<p>In terms of code, it&rsquo;s quite straight forward, the Azure SDK IoT is very well done and easy to use. Most of the function to access the IoT hub are super well designed and only 1 or 2 functions are needed.</p>
<h1>Uploading the picture to an Azure Blob storage</h1>
<p>As for the previous part, you&rsquo;ll need a storage setup. Follow the very well done step by step <a href="https://azure.microsoft.com/en-us/documentation/articles/storage-create-storage-account/">here</a>. You&rsquo;ll need to go thru to continue this code.</p>
<p>Blob storage are very easy as well to access in node.js. They can get access like https://<em>mystorageaccount</em>.blob.core.windows.net/<em>mycontainer</em>/<em>myblob</em>.</p>
<p>In terms of code, as for the IoT Hub, you need the connection string and create the access to the blob service.</p>
<p>var azure = require('azure');</p>
<p>//need to change AccountName and AccountKey<br />var connectionblob = 'DefaultEndpointsProtocol=https;AccountName=mystorageaccount;AccountKey=thelongkey';<br />var blobSvc = azure.createBlobService(connectionblob);</p>
<p>From the previous code, replace</p>
<p>function pushtoblob()<br />{<br />&nbsp;&nbsp;&nbsp; blobSvc.createContainerIfNotExists('webcam', function (error, result, response) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!error) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Container exists<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (result == true)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; console.log('blob created');<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; console.log('blob existing');<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; });<br />&nbsp;&nbsp;&nbsp; //create the picture named image.jpg<br />&nbsp;&nbsp;&nbsp; //webcam.run();&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; // this will upload the picture named image.jpg which needs to be in the same directory as the js file<br />&nbsp;&nbsp;&nbsp; blobSvc.createBlockBlobFromLocalFile('webcam', 'picture', 'image.jpg', function (error, result, response) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!error) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // file uploaded<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; console.log('file uploaded :-) ');<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; console.log('error uploading picture');<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; });<br />}</p>
<p>the code is very straight forward as well. I do create a blob called &ldquo;webcam&rdquo; and upload an existing picture from the disk called &ldquo;image.jpg&rdquo;. We&rsquo;ll see right after how to generate this picture from the webcam. In the meantime, make sure you add a picture called &ldquo;image.jpg&rdquo; in the same directory as your server.js file.</p>
<p>You can as well add the following code into the &lsquo;'&rdquo;http.createServer&rdquo; function, after the &ldquo;action =&rdquo;.</p>
<p>if (action == '/image.jpg') {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //webcam.run();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var img = fs.readFileSync('./image.jpg');<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res.writeHead(200, { 'Content-Type': 'image/jpeg' });<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res.end(img, 'binary');<br />&nbsp;&nbsp;&nbsp; }</p>
<p>Hit F5 in VS and test the code by accessing <a href="https://ipaddress:1337/image.jpg">https://ipaddress:1337/image.jpg</a></p>
<p>You should be able to see the picture you&rsquo;ve placed in the folder. now, go back to the Device Explorer, and send again the &ldquo;picture&rdquo; message. You will see a confirmation in the Device Explorer that the message has been received.</p>
<p>So how to check if the blob picture has been uploaded correctly?</p>
<p>One of the way is to check in the Azure portal is the container has been created. And you can change the properties to make it public for example, so you can directly from the browser check your image. You&rsquo;ll access it like <a href="https://yourblobstorage.blob.core.windows.net/webcam/picture">https://yourblobstorage.blob.core.windows.net/webcam/picture</a></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/0456.image_508110FA.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/0456.image_5F00_508110FA.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/4745.image_thumb_44EB53BB.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/4745.image_5F00_thumb_5F00_44EB53BB.png" alt="image" width="244" height="212" border="0" /></a></p>
<p>You can use as well the excellent CloudBerry Explorer for Azure which you can download from <a href="https://www.cloudberrylab.com/free-microsoft-azure-explorer.aspx">here</a>. Once setup (see <a href="https://blogs.msdn.com/b/laurelle/archive/2015/10/01/how-to-move-azure-vm-between-subscriptions.aspx">my previous post</a> where I show how to move one Azure VM from one subscription to another to have more info on how to setup this tool). If all went correctly, you should be able to see the &ldquo;webcam&rdquo; container created</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/7723.image_6B4D3706.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/7723.image_5F00_6B4D3706.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/5584.image_thumb_0DA4CC80.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/5584.image_5F00_thumb_5F00_0DA4CC80.png" alt="image" width="414" height="170" border="0" /></a></p>
<p>if you double click in it, you&rsquo;ll see the picture blob:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/3730.image_6FC6487E.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/3730.image_5F00_6FC6487E.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/7026.image_thumb_44157E82.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/7026.image_5F00_thumb_5F00_44157E82.png" alt="image" width="417" height="190" border="0" /></a></p>
<p>and if you double click on the &ldquo;picture&rdquo; blob, you can open it and download your picture.</p>
<h1>Saving a picture from the webcam</h1>
<p>I have to say, I did quite a lot of research to see if there is an efficient way to do this on a RPI. And there are not that many nice, easy and straight forward way to do it. First, not all webcam are supported. I had to check couple of webcams to find an old Lifecam-VX-6000 supported.</p>
<p>I finally went for some command line tool that generate images from the webcam entry (/dev/video0 for the default webcam). I&rsquo;ve installed fswebcam</p>
<p><code>sudo apt-get install fswebcam</code></p>
<p>To create an image, just run &ldquo;fswebcam image.jpg&rdquo; and it will generate an image. Worked quite well on my Raspberry.</p>
<p>Then I&rsquo;ve created in my project a webcam.ts file and put the following code:</p>
<p>'use strict'</p>
<p>var child = require('child_process');</p>
<p>module.exports = {<br />&nbsp;&nbsp;&nbsp; run: function () {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; child.execSync('fswebcam image.jpg', function (err, stdout, stderr) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (err !== null) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; console.log('error ' + err);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; console.log('image saved');<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });&nbsp; <br />&nbsp;&nbsp;&nbsp; }<br />};</p>
<p>and in the main server.js file:</p>
<p>var webcam = require('./webcam');</p>
<p>You can un comment the 2 lines you&rsquo;ll find with this &ldquo;//webcam.run();&rdquo; This code just create the image from the webcam. Now, if you test this code on Windows, it will not create the image as the command &ldquo;fswebcam&rdquo; does not exist. But it will work on the RPI where you&rsquo;ve install the command. Note that you need to use execSync to create the external process. It will wait for the external process to finish before continuing. If you're using the normal exec, the picture won't have time to be saved before the next steps.</p>
<h1>Deployment on the Raspberry and all together</h1>
<p>You&rsquo;ll need to deploy only the 3 files: &ldquo;server.js&rdquo;, &ldquo;webcam.js&rdquo; and &ldquo;package.json&rdquo;. Use the method you want (I personnaly use the old smb way, so installing and setting up smb&hellip;). I have to say I like as well to access my Raspberry with Remote Desktop. Just install &ldquo;xrdp&rdquo;&nbsp; and you&rsquo;re good to go for this <img class="wlEmoticon wlEmoticon-smile" style="border-style: none;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8625.wlEmoticon-smile_3F5085AF.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/8625.wlEmoticon_2D00_smile_5F00_3F5085AF.png" alt="Sourire" /></p>
<p>And voil&agrave;, you can get it from your blob storage:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/6866.image.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39/6866.image.jpg"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/6866.image.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/320x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39/6866.image.jpg" alt="" border="0" /></a></p>
<p>For sure all this can be improved, especially with the webcam part.</p>
<p>&lt;edit&gt; I've placed the webcam on the RPI which is in the garden and the picture can be found <a href="https://portalvhdskb2vtjmyg3mg.blob.core.windows.net/webcam/picture">here</a>. &lt;/edit&gt;</p>
<h1>Conclusion</h1>
<p>Visual Studio 2015 + node.js tools + Azure IoT Hub + Azure Storage = happiness</p>
<p>So easy to develop, so easy to debug, so easy to find the right module with the npm tools in VS. All the Azure resources are really easy and simple to use with node.js.</p>
<p>The great news is that my solution is working the same way under Windows and Linux. Only difference is about the webcam part but I really didn&rsquo;t need it on the Windows side.</p>
<p>I&rsquo;ve learned a lot in this project and will for sure continue it!</p>
<p>https://portalvhdskb2vtjmyg3mg.blob.core.windows.net/webcam/picture</p>]]></content:encoded>
    </item>
    <item>
      <title>How to move Azure VM between subscriptions</title>
      <link>https://docs.microsoft.com/archive/blogs/laurelle/how-to-move-azure-vm-between-subscriptions</link>
      <pubDate>Thu, 01 Oct 2015 07:40:17 GMT</pubDate>
      <dc:creator><![CDATA[Laurelle]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/laurelle/2015/10/01/how-to-move-azure-vm-between-subscriptions/</guid>
      <description><![CDATA[I recently needed to move an Azure Virtual Machine from one subscription to another one. I read a...]]></description>
      <content:encoded><![CDATA[<p>I recently needed to move an Azure Virtual Machine from one subscription to another one. I read a LOT on how to do that and it looks super complicated. At the end of the day, I found an easy 3 steps way to make it, so sharing on this blog <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none" alt="Sourire" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/0005.wlEmoticon-smile_3E53B71B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/0005.wlEmoticon_2D00_smile_5F00_3E53B71B.png" /></p>  <h1>Step 1: Move the Azure VM from one Blob storage to another one</h1>  <p>In Microsoft Azure, when you have a blob&#160; storage, it can be attached only to 1 subscription. You can of course have multiple storage attached into a subscription. So first step is to move the VHD which is used by the VM.</p>  <p>For this, I used the excellent CloudBerry Explorer for Azure which you can download for free <a href="https://www.cloudberrylab.com/free-microsoft-azure-explorer.aspx">here</a>. After installation, just register for free and you’re good to go. </p>  <p>You’ll need to add your 2 blob storage, the one you want to move the VHD from and the one you want to move the VHD to.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/0456.image_79A71CD9.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/0456.image_5F00_79A71CD9.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/0458.image_thumb_3BAD8C1B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/0458.image_5F00_thumb_5F00_3BAD8C1B.png" width="244" height="237" /></a></p>  <p>To find the name of the storage and the key, just go into the Azure management console and select Manage Access Keys, you’ll get the info you need to setup both accounts.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/7607.image_7DB3FB5C.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/7607.image_5F00_7DB3FB5C.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/7674.image_thumb_022D0CD5.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/7674.image_5F00_thumb_5F00_022D0CD5.png" width="244" height="202" /></a></p>  <p>Once setup, you can now have a view like this:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/7711.image_584C989F.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/7711.image_5F00_584C989F.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/2112.image_thumb_15705425.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/2112.image_5F00_thumb_5F00_15705425.png" width="500" height="169" /></a></p>  <p>Stop your VM and you’re good to copy/paste your VM from one storage to another.</p>  <h1>Step 2: Create a Disk from VHD</h1>  <p>In the management console, go to Virtual Machine then Disks</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/2388.image_72AF1C67.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/2388.image_5F00_72AF1C67.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/6765.image_thumb_4E1D8EE3.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/6765.image_5F00_thumb_5F00_4E1D8EE3.png" width="236" height="100" /></a></p>  <p>then Create</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/0250.image_0251B82A.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/0250.image_5F00_0251B82A.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8105.image_thumb_2FD2D7ED.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/8105.image_5F00_thumb_5F00_2FD2D7ED.png" width="58" height="61" /></a></p>  <p>fill a name, select the VHD from the storage you just moved your VHD file to.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/2086.image_5D53F7B0.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/2086.image_5F00_5D53F7B0.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/2703.image_thumb_5466F622.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/2703.image_5F00_thumb_5F00_5466F622.png" width="244" height="206" /></a></p>  <h1>Step 3: Create the VM from the Disk</h1>  <p>Go to the Virtual Machine instances</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/6648.image_5AADCCB0.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/6648.image_5F00_5AADCCB0.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/4762.image_thumb_6F331C2E.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/4762.image_5F00_thumb_5F00_6F331C2E.png" width="223" height="86" /></a></p>  <p>then create a New</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/0407.image_1F5CF7A3.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/0407.image_5F00_1F5CF7A3.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8831.image_thumb_710371F5.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/8831.image_5F00_thumb_5F00_710371F5.png" width="124" height="59" /></a></p>  <p>select From Gallery</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8360.image_0588C174.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/8360.image_5F00_0588C174.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/8468.image_thumb_20C11A75.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/8468.image_5F00_thumb_5F00_20C11A75.png" width="244" height="89" /></a></p>  <p>and go to Disks to select the disk you just created.</p>      <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/0383.image_5C148033.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/0383.image_5F00_5C148033.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/39/metablogapi/0871.image_thumb_051F1F30.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-39-metablogapi/0871.image_5F00_thumb_5F00_051F1F30.png" width="336" height="328" /></a></p>              <p>And you’re good to go to run your VM!</p>]]></content:encoded>
    </item>
    <item>
      <title>ESP8266 and Posting on Windows Azure using Mobile Services</title>
      <link>https://docs.microsoft.com/archive/blogs/laurelle/esp8266-and-posting-on-windows-azure-using-mobile-services</link>
      <pubDate>Thu, 18 Jun 2015 07:36:57 GMT</pubDate>
      <dc:creator><![CDATA[Laurelle]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/laurelle/2015/06/18/esp8266-and-posting-on-windows-azure-using-mobile-services/</guid>
      <description><![CDATA[The ESP8266 is a nice, cheap wifi board which does include multiple GPIO, SPI, I2C. It is usually...]]></description>
      <content:encoded><![CDATA[<p>The <a href="https://nurdspace.nl/File:ESP8266_Specifications_English.pdf" target="_blank">ESP8266</a> is a nice, cheap wifi board which does include multiple GPIO, SPI, I2C. It is usually integrated in small boards which does contains 2 GPIO + 1 UART for the basic 01 version. </p>  <p><img src="https://www.seeedstudio.com/depot/images/product/WiFi%20Serial%20Transceiver%20Module.jpg" width="294" height="221" /></p>  <p>You can find them for few $, usually around 3$. It’s a low consumption board which can be powered by a battery and charged with a solar panel without draining the battery too fast when not connected tot eh wifi. So it makes it an interesting element for Internet of Things (IoT). </p>  <p>As there is an UART, you can as well use it as a super cheap wifi board for Arduino, Netduino and other boards like this. Full documentation for AT commands is <a href="https://www.pighixxx.com/test/wp-content/uploads/2014/12/ESP8266Ref.pdf" target="_blank">here</a>.</p>  <p>The other great news is that the Arduino community has been working on making a compatible version so you can use the wiring framework to program those boards. You can follow the steps here to install the components in the Arduino IDE. More info <a href="https://www.esp8266.com/viewtopic.php?f=26&amp;t=3094" target="_blank">here</a>.</p>  <p>And as good news are not coming alone, if like me, you’re a use fan of Visual Studio, you can even use the excellent <a href="https://www.visualmicro.com/" target="_blank">Visual Micro</a> complement to program it. And more info on Visual Micro and ESP8266 support <a href="https://www.visualmicro.com/page/esp8266.aspx" target="_blank">here</a>.</p>  <p>The most complicated part with this board is that it is only 3.3V, so be careful when alimenting it. I did a mistake and used 5V for couple of hours, the module is still alive but made the board reboot any time I wanted to drive a bit of current out of a GPIO. And that’s how when controlling I figured it out! To flash the board, you must put the GPIO0 to ground and reset the board. The UART is 5V tolerant so if you have an FTDI cable or equivalent which you can use to upload the code, make sure you will use only the Ground, RX and TX from the FTDI. Alimentation have to be 3.3V for the board. And once flashed, don’t forget to remove the GPIO0 from the ground.</p>  <p>And as I explained in this <a href="https://blogs.msdn.com/b/laurelle/archive/2014/11/30/connect-arduino-spark-io-netduino-netmf-net-microframework-to-microsoft-azure-mobile-services-create-iot-part-3.aspx" target="_blank">previous post</a> with the Spark.io (renamed Particle.io), you can then directly post to Azure Mobile Services with this 3$ chip! I’m planning to use it to measure temperature and humidity plus level of water from my cellar (I have to manually empty a bucket of water from my cooling system). And this 3$ chip plus 1 DHT11/22 plus a water level sensor (using the digital output only as no analog input) will be perfect! And I’ll still need to see if I can use the UART as something else.</p>  <p>Enjoy :-)</p>]]></content:encoded>
    </item>
    <item>
      <title>Create a DHT11 C library using WiringPI on RaspberryPI and use it in Mono C#</title>
      <link>https://docs.microsoft.com/archive/blogs/laurelle/create-a-dht11-c-library-using-wiringpi-on-raspberrypi-and-use-it-in-mono-c</link>
      <pubDate>Sat, 11 Apr 2015 09:40:05 GMT</pubDate>
      <dc:creator><![CDATA[Laurelle]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/laurelle/2015/04/11/create-a-dht11-c-library-using-wiringpi-on-raspberrypi-and-use-it-in-mono-c/</guid>
      <description><![CDATA[I’m using various boards like RaspberryPI (1 and 2) as well as Arduino and Netduino. I have to say...]]></description>
      <content:encoded><![CDATA[<p>I’m using various boards like RaspberryPI (1 and 2) as well as Arduino and Netduino. I have to say I’m a big fan of C#, so I try to use C# as much as I can. Based on the excellent <a href="https://wiringpi.com/" target="_blank">WiringPI</a> framework, I’ve ported equivalent of .NET Microframework classes to RaspberryPI (see <a href="https://blogs.msdn.com/b/laurelle/archive/2014/10/25/net-microframework-on-raspberrypi-part-2.aspx" target="_blank">previous post here</a>, code not fully updated with latest Wiring PI version, just need to find some time to update it). All is using Mono on Linux.</p>  <p>But as .NET is a managed code runtime, there are some limitations when it come to do some very short timing operations as managed code can’t guaranty those easily. In order to have those operations working, you’ll need to build some native C code. But wait, I know you’re a fan of C# like me and you don’t want to build your full project in C! It’s like the old time when we had the excellent Visual Basic to build all the graphical interfaces, fast development for anything related to interfaces but lack of performance. At this time, most of the code were don in a C/C++ dll and imported with the famous dllimport into the VB code.</p>  <p>Well, we will do exactly the same here but replacing the old VB by the modern C# and for anything that need to be hard real time, we’ll put that into a C dll and import it into C#. But wait, here, our RaspberryPI is running Linux. So how to make that possible? In Linux as well, there are equivalent of dll, those are called library. They start with lib and have .so extensions. They are the exact same as dll but in the Linux world with the same advantages and same weaknesses.</p>  <p>Then, let start by the library first. I wanted to find some code that already worked with the WiringPI framework as I’m using it (<a href="https://blogs.msdn.com/b/laurelle/archive/2013/06/21/net-microframework-on-raspberrypi-part-1.aspx" target="_blank">see this article</a> on how to install it on a RaspberryPI). And I fond <a href="https://www.rpiblog.com/2012/11/interfacing-temperature-and-humidity.html" target="_blank">this great example</a> which was almost what I wanted. I just needed to adapt it a bit to make it working. </p>  <p>So I created (using my preferred tool Visual Studio), a normal C++ project. My main idea is to use it as an editor. I need 2 files: the library header and the core code. Both are important, and if you want to build a library you must have both. Let start with the header (called DHT11library.h in my code), here is the code:</p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">#ifndef</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> _DHTLIB     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">#define</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">_DHTLIB</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">#ifdef</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">__cplusplus</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">extern</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;C&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> {     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">#endif</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">extern</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">bool</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> InitDHT(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">int</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> pinval);     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">extern</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">float</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> getTemp();     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">extern</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">float</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> getHumidity();     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">extern</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">bool</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> dht11_read_val();     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">#ifdef</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">__cplusplus</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">}     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">#endif</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; line-height: 107%; mso-highlight: white">#endif</span>    <p></p> </p>  <p>&#160;</p>  <p>What is the most important here is to have the entry point of the library properly declared in this header with extern. Now, the rest of the code in the file DHT11library.cpp:</p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">#include</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&lt;wiringPi.h&gt;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160; </span>      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">#include</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&lt;stdio.h&gt;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">#include</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&lt;stdlib.h&gt;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">#include</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&lt;stdint.h&gt;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">#include</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;DHT11library.h&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">#define</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">MAX_TIME</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> 85     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">int</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> DHT11PIN;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">int</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> dht11_val[5] = { 0, 0, 0, 0, 0 };     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">bool</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> isinit = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">false</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">bool</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> InitDHT(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">int</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">pinval</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">)     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">{     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (wiringPiSetup() == -1)     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span>{      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>isinit = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">false</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> isinit;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span>}      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span>DHT11PIN = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">pinval</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">// initialize pin</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span>isinit = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">true</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> isinit;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">}     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">float</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> getTemp()     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">{     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">float</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">)(dht11_val[2] + dht11_val[3] / 10);     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">}     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">float</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> getHumidity()     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">{     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">float</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">)(dht11_val[0] + dht11_val[1] / 10);     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">}     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">bool</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> dht11_read_val()     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">{     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (!isinit)     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">false</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">uint8_t</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> lststate = HIGH;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">uint8_t</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> counter = 0;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">uint8_t</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> j = 0, i;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">float</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> farenheit;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">for</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (i = 0; i &lt; 5; i++)     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>dht11_val[i] = 0;      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span>pinMode(DHT11PIN, OUTPUT);      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span>digitalWrite(DHT11PIN, LOW);      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span>delay(18);      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span>digitalWrite(DHT11PIN, HIGH);      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span>delayMicroseconds(40);      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span>pinMode(DHT11PIN, INPUT);      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">for</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (i = 0; i &lt; </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">MAX_TIME</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">; i++)     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span>{      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>counter = 0;      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">while</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (digitalRead(DHT11PIN) == lststate){     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>counter++;      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>delayMicroseconds(1);      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (counter == 255)     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">break</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>lststate = digitalRead(DHT11PIN);      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (counter == 255)     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">break</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">// top 3 transistions are ignored<span style="mso-spacerun: yes">&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> ((i &gt;= 4) &amp;&amp; (i % 2 == 0)){     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>dht11_val[j / 8] &lt;&lt;= 1;      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (counter&gt;16)     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>dht11_val[j / 8] |= 1;      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>j++;      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span>}      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">// verify cheksum and print the verified data<span style="mso-spacerun: yes">&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> ((j &gt;= 40) &amp;&amp; (dht11_val[4] == ((dht11_val[0] + dht11_val[1] + dht11_val[2] + dht11_val[3]) &amp; 0xFF)))     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span>{      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> ((dht11_val[0] == 0) &amp;&amp; (dht11_val[2] == 0))     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">false</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">true</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span>}      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">false</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">}     <p></p>   </span></p>  <p>As you can see, the code is very similar to the example code I found. I just added 3 functions to initialize the pin I’ll use and return both the temperature and humidity. Every time I’ll need to read the DHT11, I’ll call the dht11_read_val and then call both functions to return the temperature and humidity.</p>  <p>Now, this is where you have to pay attention to make sure you’ll build the library correctly. You need to copy both file the DHT11library.cpp and .h into the Raspberry (I’m using a Samba share for this), then using PyuTTY or another way, connect to the Raspberry, go to the directory where you have placed the 2 files and compile the library:</p>  <p><em>sudo gcc -o libDHT11.so DHT11library.cpp -L/usr/local/lib -lwiringPi –shared</em></p>  <p><em></em></p>  <p><em>-o</em> command will allow you to define the name of the library, on Linux, name need to start with lib and finish with so. At least that’s the only way I managed to make it working. I’m not a Linux expect so I may have miss something.</p>  <p><em>-L and –lwinringPI </em>reference the rest of the library. You must have compiled and installed the WiringPI framework before of course.</p>  <p><em>-shared </em>is the command to tell gcc to build a library</p>  <p>If everything goes well, you’ll get your libDHT11.so compiled and ready to use. So let move to C# now. You can create a normal C# project using Visual Studio, .NET 4.0 type is recommended to work on Mono.</p>  <p>I have created a class that embedded the C library and then allow to be used like a normal class:</p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">using</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> System;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">using</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> System.Collections.Generic;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">using</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> System.Linq;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">using</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> System.Runtime.InteropServices;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">using</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> System.Text;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">using</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> RaspberryPiNETMF;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">using</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> Microsoft.SPOT.Hardware;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">using</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> System.Timers;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">namespace</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> SerreManagement     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">{     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">public</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">class</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">NewDataArgs</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>{      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">public</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> NewDataArgs(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">float</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> temp, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">float</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> hum)     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{ Temperature = temp; Humidity = hum; }      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">public</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">float</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> Temperature { </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">get</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">; </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">private</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">set</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">; }     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">public</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">float</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> Humidity { </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">get</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">; </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">private</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">set</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">; }     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>}      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">class</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">DHT11</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>{      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">//bool InitDHT(int pinval)</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">DllImport</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;libDHT11.so&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, EntryPoint = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;InitDHT&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">)]     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">static</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">extern</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">bool</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> InitDHT(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">int</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> pinval);     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">//float getTemp()</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">DllImport</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;libDHT11.so&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, EntryPoint = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;getTemp&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">)]     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">static</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">extern</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">float</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> getTemp();     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">//float getHumidity()</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">DllImport</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;libDHT11.so&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, EntryPoint = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;getHumidity&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">)]     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">static</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">extern</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">float</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> getHumidity();     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">//bool dht11_read_val()</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">DllImport</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;libDHT11.so&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, EntryPoint = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;dht11_read_val&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">)]     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">static</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">extern</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">bool</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> dht11_read_val();     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">// private values</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">private</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Cpu</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Pin</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> mPin;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">private</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">int</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> mSec;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">private</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Timer</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> mTimer = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">new</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Timer</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">();     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">public</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">delegate</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">void</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">NewData</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">object</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> sender, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">NewDataArgs</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> e);     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">public</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">event</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">NewData</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> EventNewData;     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">// to get temperature and humidity</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">public</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">float</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> Temperature { </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">get</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">; </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">internal</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">set</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">; }     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">public</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">float</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> Humidity { </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">get</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">; </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">internal</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">set</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">; }     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">public</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> DHT11(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Cpu</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Pin</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> pin, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">int</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> seconds = 0)     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>mPin = pin;      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>mSec = seconds;      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (!InitDHT((</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">int</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">)pin))     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">throw</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">new</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Exception</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;Error initalizing DHT11&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">);     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>mTimer.Elapsed += mTimer_Elapsed;      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">void</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> mTimer_Elapsed(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">object</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> sender, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">ElapsedEventArgs</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> e)     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (dht11_read_val())     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Temperature = getTemp();      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Humidity = getHumidity();      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (EventNewData != </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">null</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">)     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>EventNewData(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">this</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">new</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">NewDataArgs</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(Temperature, Humidity));     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">public</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">void</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> Start()     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (mSec != 0)     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>mTimer.Interval = mSec * 1000;      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>mTimer.Start();      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">public</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">void</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> Stop()     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>mTimer.Stop();      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">public</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">bool</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> ReadDHT11()     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (dht11_read_val());     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}      <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p>&#160;</p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>}      <p></p>   </span></p>  <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">}</span></p>  <p>The way to import the library is simple, it’s like for a Windows dll, it’s just the name changing. Be very careful if you build more complex library because the type conversion as well as pointers conversion may not be strait forward, you’ll need to use marshaling:</p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">//bool InitDHT(int pinval)</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">DllImport</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;libDHT11.so&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, EntryPoint = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;InitDHT&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">)]     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">static</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">extern</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">bool</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> InitDHT(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">int</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> pinval);     <p></p>   </span></p>  <p>This is working with any kind of already existing Linux library, the only thing you need is the header file with the definition in order to find the right entry points as well as the exact types used.</p>  <p>Then usage of the class is really simple:</p>  <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 107%; mso-highlight: white">DHT11</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"> mDHT;</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">mDHT = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">new</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">DHT11</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Cpu</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Pin</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.Pin_P1_18, 30);     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">mDHT.EventNewData += mDHT_EventNewData;     <p></p>   </span></p>  <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">mDHT.Start();</span></p>  <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"></span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%">     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">void</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> mDHT_EventNewData(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">object</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> sender, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">NewDataArgs</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> e)     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">{     <p></p>   </span></p>  <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Console</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.WriteLine(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;Temp: &quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + e.Temperature + </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;, Hum: &quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + e.Humidity);     <p></p>   </span></p>  <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">}</span>    <p></p> </p>  <p>&#160;</p>  <p>In our case, the DHT11 is linked to the Pin 18 on a Raspberry and the call for temperature and humidity is done every 30 seconds. The event is raised and the data can be read. You can then create an exe with Visual Studio, and run it on the RPI. Don’t forget to copy all the dll you’ll need as well as the libDHT11.so one. It is a dll so it has to be present with the exe. If not present, you’ll get an exception</p>  <p>Results looks like:</p>  <p>Temp: 23, Hum: 34</p>  <p>The DHT11 is very simple and the temperature and humidity is not precise, you don’t have anything after the decimal point. the DHT22 is much better, it’s very easy to adapt this code to it, the difference with DHT11 is very tinny.</p>  <p>&#160;</p>  <p>&#160;</p>  <p><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">&#160;</span></p>]]></content:encoded>
    </item>
  </channel>
</rss>