2016年6月1日 星期三

How to certify IoT devices running Windows 10 with Azure IoT SDK 如何讓裝置取得 Azure 認證

How to certify IoT devices running Windows 10 with Azure IoT SDK



Table of Contents
  • Introduction
  • Step 1: Sign Up To Azure IoT Hub
  • Step 2: Register Device
  • Step 3: Build and Validate the Sample using C# Client Libraries
    • 3.1 Prepare your development environment
    • 3.2 Build the Samples
    • 3.3 Run and Validate the Samples
  • Step 4: Package and Share
    • 4.1 Package build logs and sample test results
    • 4.2 Share package with Engineering Support
    • 4.3 Next steps
Introduction
About this document
This document provides step by step guidance to IoT hardware publishers on how to certify an IoT enabled hardware with Azure IoT SDK. This multi-step process includes:
  • Configuring Azure IoT Hub
  • Registering your IoT device
  • Build and deploy Azure IoT SDK on device
  • Packaging and sharing the logs
Prepare
Before executing any of the steps below, read through each process, step by step to ensure end to end understanding.
You should have the following items ready before beginning the process:
Step 1: Sign Up To Azure IoT Hub
Follow the instructions here on how to sign up to the Azure IoT Hub service.
As part of the sign up process, you will receive the connection string.
  • IoT Hub Connection String: An example of IoT Hub Connection String is as below:
·         HostName=[YourIoTHubName];SharedAccessKeyName=[YourAccessKeyName];SharedAccessKey=[YourAccessKey]
Step 2: Register Device
In this section, you will register your device using DeviceExplorer. The DeviceExplorer is a Windows application that interfaces with Azure IoT Hub and can perform the following operations:
  • Device management
    • Create new devices
    • List existing devices and expose device properties stored on Device Hub
    • Provides ability to update device keys
    • Provides ability to delete a device
  • Monitoring events from your device
  • Sending messages to your device
  • IoT Hub Connection String
Steps:
  1. Click here to download and install DeviceExplorer.
  2. Add connection information under the Configuration tab and click the Update button.
  3. Create and register the device with your IoT Hub using instructions as below.
a. Click the Management tab.
b. Your registered devices will be visible in the list. In case your device is not there in the list, click Refresh button. If this is your first time, then you shouldn't retrieve anything.
c. Click Create button to create a device ID and key.
d. Once created successfully, device will be listed in DeviceExplorer.
e. Right click the device and from context menu select "Copy connection string for selected device".
f. Save this information in Notepad. You will need this information in later steps.
Not running Windows on your PC? - Please send us an email on iotcert@microsoft.com and we will follow up with you witAzure IoT SDKh instructions.
Step 3: Build and Validate the Sample using C# Client Libraries
This section walks you through building, deploying and validating the IoT Client SDK on your device running Windows 10 operating system. You will install the necessary prerequisites on your device. Once done, you will build and deploy the IoT Client SDK, and validate the sample tests required for IoT certification with the Azure IoT SDK.
3.1 Prepare your development environment
This document describes how to prepare your development environment to use the Microsoft Azure IoT device SDK for C#.
3.2 Build the Samples
  1. Start a new instance of Visual Studio 2015. Open the iothub_csharp_deviceclient.sln solution in the csharp\devicefolder in your local SDK azure-iot-sdks directory.
  2. In Visual Studio, from Solution Explorer, navigate to project based on your choice of protocol:
For AMQP protocol:
Navigate to DeviceClientAmqpSample project and open the Program.cs file.
For HTTP protocol:
Navigate to DeviceClientHttpSample project and open the Program.cs file.
For MQTT protocol:
Navigate to DeviceClientMqttSample project and open the Program.cs file.

  1. Locate the following code in the Program.cs in any of sample application based on your protocol:
4.  private const string DeviceconnectionString = "[device connection string]";
  1. Replace [device connection string] with the connection string for your device and Save the changes. You can get the connection string from DeviceExplorer as explained in Step 2.
3.3 Run and Validate the Samples
In this section you will run the Azure IoT client SDK samples to validate the communication between your device and Azure IoT Hub. You will send the messages to the Azure IoT Hub service and validate that IoT Hub has successfully receive the data. You will also monitor any messages sent from the Azure IoT Hub to client.
Note: Take screenshots of all the operations you will perform in this section. These will be needed in Step 4.
3.3.1 Send Device Events to IoT Hub
  1. Launch the DeviceExplorer as explained in Step 2 and navigate to Data tab. Select the device name you created from the drop-down list of device IDs and click Monitor button.
  1. DeviceExplorer is now monitoring data sent from the selected device to the IoT Hub.
  2. In Visual Studio, from Solution Explorer, right-click on DeviceClientAmqpSample or DeviceClientHttpSample orDeviceClientMqttSample project, click Debug, and then Start new instance to build and run the sample.
  3. You should be able to see the events received in device console on successful execution.
If HTTP protocol:

If MQTT protocol:

If AMQP protocol:

  1. You should be able to see the events received in the DeviceExplorer's data tab.
If HTTP protocol:

If MQTT protocol:

If AMQP protocol:

3.3.2 Receive messages from IoT Hub
  1. To verify that you can send messages from the IoT Hub to your device, go to the Messages to Device tab in DeviceExplorer.
  2. Select the device you created using Device ID drop down.
  3. Add some text to the Message field, then click Send.
  1. You should be able to see the message received in the device console window.
If HTTP protocol:

If MQTT protocol:

If AMQP protocol:

Step 4: Package and Share
4.1 Package build logs and sample test results
Package the following artifacts from your device:
  1. Build logs from section 3.2.
  2. All the screenshots that are shown above in "Send Device Events to IoT Hub" section.
  3. All the screenshots that are shown above in "Receive messages from IoT Hub" section.
  4. Send us clear instructions of how to run this sample with your hardware (explicitly highlighting the new steps for customers). As a guideline on how the instructions should look please refer the examples published on github repositoryhere.
4.2 Share package with the Azure IoT Certification Team
4.3 Next steps
Once you shared the documents with us, we will contact you in the following 48 to 72 business hours with next steps.
  




目錄
  • 簡介
  • 步驟一:建立 IoT Hub
  • 步驟二:註冊裝置
  • 步驟三:使用C#語言產生有效的裝置
    • 3.1 開發環境的建置
    • 3.2 產生範例
    • 3.3 執行範例
  • 步驟四:上傳與提供相關檔案給認證單位
    • 4.1 打包相關檔案和測試結果
    • 4.2 提供相關檔案與測試結果給認證單位
    • 4.3 提供認證單位需求文件
簡介
關於這篇文章
這篇文章會一步一步的教導如何使產品過 Azure IoT 認證。這篇文章會有以下內容:
  • 建置 Azure IoT Hub
  • 創立 IoT 裝置
  • Build and deploy Azure IoT SDK on device
  • 上傳與提供相關檔案給認證單位
事前準備
在開始之前,你必須先安裝相對應的軟體。
  • 開發環境先安裝 azure-iot-sdks 
  • 開發環境安裝 Visual Studio 2015 and Tools.
步驟一:建立 IoT Hub
參考此連結 here,會教導如何建立 Azure IoT Hub 服務。
在建立 Azure IoT Hub的時候,你會得到 Connection string
  • IoT Hub Connection String: 下圖為 Connection string的截圖
·         HostName=[YourIoTHubName];SharedAccessKeyName=[YourAccessKeyName];SharedAccessKey=[YourAccessKey]
步驟二:註冊裝置
這個章節,會教你使用 DeviceExplorerDeviceExplorer 是微軟開發的應用程式,提供了以下的功能:
  • 裝置管理
    • 新增裝置
    • 列出裝置和裝置設定
    • 更新裝置金鑰
    • 刪除裝置
  • 監控裝置
  • 傳送訊息
DeviceExplorer 工具的運作,需要步驟一所產生的連線字串
  • IoT Hub 連線字串
Steps:
  1. 從此連結下載 DeviceExplorer here
  2.  Configuration 頁面中填入連線資訊後,按下 Update 按鈕
  3. 根據以下的步驟去註冊一個裝置
a. 選擇 Management 頁面.
b. 你會在列表上看到剛剛註冊的裝置,如果沒看到,請按下 Refresh 按鈕
c. 按下 Create 去建立一個裝置.
d. 建立成功後,可以在 DeviceExplorer 列表中看到裝置
e. 在列表中裝置的圖示上按下滑鼠右鍵,選擇 "Copy connection string for selected device"
f. 使用記事本紀錄複製的資訊,之後的步驟會使用此資訊
步驟三:使用 C# 語言產生有效的裝置
這個章節會透過 IoT Client SDK ,在 Windows 10 作業系統上,建立、部屬信任的程式。你可以透過以下的步驟完成 IoT 認證。
3.1 準備開發環境
這篇文章選擇開發語言為 C#,會教導如何使用 Azure SDK.
3.2 建立範例程式
  1. 啟動 VS2015 並開啟 iothub_csharp_deviceclient.sln 專案,此專案在 azure-iot-sdks 目錄下的 csharp\device
  2.  Solution Explorer 中,選擇協定:
使用 AMQP 協定:
移至 DeviceClientAmqpSample 專案並開啟 Program.cs
使用 HTTP 協定:
移至 DeviceClientHttpSample 專案並開啟 Program.cs
使用 MQTT 協定:
移至 DeviceClientMqttSample 專案並開啟 Program.cs
 

  1. 找出以下程式碼 Program.cs
  2. private const string DeviceconnectionString = "[device connection string]";
  3. 替換裝置連線字串後存檔
3.3 Run and Validate the Samples
在此章節,你可以透過範例程式,與Azure IoT Hub進行訊息的收送。
Note: 請擷取所有操作的畫面,下章節會使用到
3.3.1 傳送訊息到 IoT Hub
  1. 開啟 DeviceExplorer 並換到 Data 頁面,選擇欲接收裝置的名稱,並按下 Monitor 按鈕
  1. DeviceExplorer 正在監控是否有裝置傳送訊息至 IoT Hub.
  2. 開啟 VS2015,在 Solution Explorer 中,在Debug模式下,在下列其中一個專案上按下滑鼠右鍵 DeviceClientAmqpSample DeviceClientHttpSample DeviceClientMqttSample ,並選擇 Start new instance 去執行專案
  3. 你會看到訊息傳送成功的畫面
使用 HTTP 協定:

使用 MQTT 協定:

使用 AMQP 協定:

  1. 你可以從 DeviceExplorer 頁面確認資料的傳輸是否成功。
使用 HTTP 協定:

使用 MQTT 協定:

使用 AMQP 協定:

3.3.2 IoT Hub 接收訊息
  1. 我們可以透過 DeviceExplorer 中的 Messages to Device 頁面去確認 IoT Hub 可以成功傳送訊息至裝置端
  2. 從下拉式選單選擇要傳送訊息的裝置 ID
  3. 新增欲傳送的字串到訊息欄中
  1. 你可以從裝置端收到訊息
使用 HTTP 協定:

使用MQTT 協定:

使用 AMQP 協定:

步驟四:上傳與提供相關檔案給認證單位
4.1 打包相關檔案與測試結果
打包相關檔案與測試結果
  1. 把步驟3.2所生成的log檔案提供給認證單位
  2. 提供步驟 "Send Device Events to IoT Hub" 的所有截圖
  3. 提供步驟 "Receive messages from IoT Hub" 的所有截圖
  4. 簡單說明環境建置、範例程式執行方式和測試裝置的介紹,可以參考 github 網站提供的範例here
4.2 提供相關檔案與測試結果給相關單位
寄送相關檔案與測試結果至 iotcert@microsoft.com.
4.3 提供認證單位需求文件
48~72小時內,會收到認證單位的電子郵件,並提供認證單位所需資料即可。

OS Operating System 作業系統 恐龍書 筆記分享

發現一個作業系統說明的網站, 對於 process vs thread, semaphore vs mutex, deadlock 說明很詳細, 有興趣的人可以去以下的網頁逛逛。 附上網址連結: link   link2