裝置型號會定義:
- 裝置傳送至服務的遙測。
- 裝置與服務同步的屬性。
- 服務在裝置上呼叫的命令。
提示
Hint
Azure IoT Central 是遵循即插即用慣例的服務。 在 IoT Central 中,裝置模型是裝置範本的一部分。 IoT Central 目前支援具有 IoT Central 延伸模組的 DTDL v2。 IoT Central 應用程式預期會收到 UTF-8 編碼的 JSON 資料。
Azure IoT Centre is a service that follows the rule of plug-in. In Iot Centre, the device model is .
本文說明裝置傳送和接收的 JSON 承載,用於 DTDL 裝置模型中定義的遙測、屬性和命令。
This indicates that the JSON carriers sent and received by the device are used to detect, attribute and command as defined in the DTDL device model.
本文不會說明每個可能類型的遙測、屬性和命令承載,但範例會說明關鍵類型。
This paper will not describe each possible type of remote, attribute and command carrying, but the example will describe the key type.
每個範例會顯示裝置模型的程式碼片段,其會定義類型和範例 JSON 承載,藉以說明裝置如何與 IoT Central 等隨插即用感知服務互動。
Each example displays a code snippet of the device model, which defines the type and example of JSON to be carried to explain how the device interacts with Iot Central and the like.
本文中的範例 JSON 代碼段會使用 Digital Twin Definition Language (DTDL) v2。 IoT Central 也會使用一些 DTDL 延伸模組。
The example in this paper is used by JSON code paragraph . Iot Central will also use some of the 如需顯示其中一些使用中承載的範例裝置程式碼,請參閱將在 Linux 或 Windows 上執行的範例 IoT 隨插即用裝置應用程式連線至 IoT 中樞教學課程或建立用戶端應用程式並將其連線至您的 Azure IoT Central 應用程式教學課程。 If you need to show some of the templates that are being used, please refer to or
如果您使用 IoT Central,則可以檢視裝置傳送至應用程式的未經處理資料。 對於疑難排解從裝置傳送承載的問題,此檢視相當實用。 若要檢視裝置傳送的未經處理資料: If you use IOT Central, you can view unprocessed data from the device to the application. This view is useful for the question of how to send the load from the device. To view the unprocessed data from the device: 從 [裝置] 頁面瀏覽至裝置。 Browse to the device from the [device] page. 選取 [未經處理資料] 索引標籤: Can not delete folder: %s: No such folder
在此檢視中,您可以選取要顯示的資料行,並設定要檢視的時間範圍。 [未模型化的資料] 資料行會顯示裝置內不符合裝置範本中任何屬性或遙測定義的資料。 In this view, you can select the data line you want to display and set the time range you want to view. [unmodeled data] will show any data in the device that does not match the properties or the remote definition of the device template. 如需更多疑難排解秘訣,請參閱針對裝置中的資料未顯示在 Azure IoT Central 的原因進行疑難排解。 For more questions, see
若要深入了解 DTDL 遙測命名規則,請參閱 DTDL > 遙測。 您無法使用 字元作為遙測名稱的開頭。 For more information on the DTDL remote naming rules, please refer to DTDL & gt; remote . You cannot use the character as the starting point for the bytename. 請勿使用下列名稱建立下列遙測類型。 IoT Central 會內部使用這些保留名稱。 如果您嘗試使用這些名稱,IoT Central 將忽略您的資料: Do not use the following names to create the following types of remote measurements. Iot Central uses these reserved names inside. If you try using these names, Iot Central ignores your data: 如果遙測是在元件中定義,請新增名為 的訊息屬性及裝置模型中定義的元件名稱。 若要深入了解,請參閱教學課程:連線 IoT 隨插即用多個元件裝置應用程式。 本教學課程示範如何使用不同的程式設計語言,從元件傳送遙測。 If the remote is defined in widgets, add the name of the component as defined in the message attribute and device model. For further information, please refer to . 重要 Important 若要正確顯示在 IoT Edge 模組中裝載元件的遙測,請使用 IoT Edge 版本 1.2.4 或更新版本。 如果您使用舊版本,IoT Edge 模組中元件的遙測會顯示為 _unmodeleddata。 To correctly display the remotes of the widgets in the Iot Edge module, use or update. If you use the old version, the remotes of the widgets in the Iot Edge module will be shown as _unmodeddata. 如果遙測是在繼承介面中定義,您的裝置就會傳送遙測,如同在根介面中定義一樣。 指定下列裝置型號: If the remote is defined in the successor interface, your device will transmit the remote as defined in the root interface. Specify the following device types: 裝置會使用下列承載來傳送計量電壓遙測。 裝置不包含承載中的介面名稱: Devices use the following loads to transmit measured voltage remotes. The device does not contain the interface name of the load: 本節說明裝置可串流的基本遙測類型範本。 This section describes the basic remote type samples for which the device can stream. 下列裝置模型的程式碼片段顯示 遙測類型的定義: Snippets of the following device models show the definition of the remote type: 裝置用戶端應以 JSON 的形式傳送遙測,如下列範例所示: Device client should transmit remote measurements in the form of JSON, as shown in the following examples: 下列裝置模型的程式碼片段顯示 遙測類型的定義: Snippets of the following device models show the definition of the remote type: 裝置用戶端應以 JSON 的形式傳送遙測,如下列範例所示: Device client should transmit remote measurements in the form of JSON, as shown in the following examples: 下列裝置模型的程式碼片段顯示 遙測類型的定義: Snippets of the following device models show the definition of the remote type: 裝置用戶端應以 JSON 的形式傳送遙測,如下列範例所示: Device client should transmit remote measurements in the form of JSON, as shown in the following examples: 下列裝置模型的程式碼片段顯示 遙測類型的定義: Snippets of the following device models show the definition of the remote type: 裝置用戶端應以 JSON 的形式傳送遙測,如下列範例所示: Device client should transmit remote measurements in the form of JSON, as shown in the following examples: 下列裝置模型的程式碼片段顯示 遙測類型的定義: Snippets of the following device models show the definition of the remote type: 裝置用戶端應以 JSON 的形式傳送遙測,如下列範例所示 - 類型的格式必須為 ISO 8061: Device client should send remotes in the form of JSON, as shown in the following examples - the type must be formatted in ISO 8061: 下列裝置模型的程式碼片段顯示 遙測類型的定義: Snippets of the following device models show the definition of the remote type: 裝置用戶端應以 JSON 的形式傳送遙測,如下列範例所示 - 持續時間的格式必須為 ISO 8601: Device client should send remotes in the form of JSON, as shown in the following examples - the format of the duration must be ISO 8601: 本節說明裝置可串流的複雜遙測類型範本。 This section describes the complex remote type of device that can stream. 下列裝置模型的程式碼片段顯示 遙測類型的定義: Snippets of the following device models show the definition of the remote type: 裝置用戶端應以 JSON 的形式傳送遙測,如下列範例所示。 可能的值為 、 和 ,其在 IoT Central 中顯示為 、 和 : Device client should send remote measurements in the form of JSON, as shown in the following examples. Possible values are, and are shown in Iot Central as, and: 下列裝置模型的程式碼片段顯示 遙測類型的定義。 此物件有三個欄位,其類型為 、 和 : The following device models have code snippets showing the definition of the remote type. This object has three columns of type, and: 裝置用戶端應以 JSON 的形式傳送遙測,如下列範例所示。 類型必須符合 ISO 8061 規範。 的可能值為 、,且在 IoT Central 中會顯示為 、 和 : Device client should send remote measurements in the form of JSON, as shown in the following examples. Type must conform to ISO 8061. Possible values are, and will be shown in Iot Central as, and: 下列裝置模型的程式碼片段顯示 遙測類型的定義: Snippets of the following device models show the definition of the remote type: 裝置用戶端應以 JSON 的形式傳送遙測,如下列範例所示: Device client should transmit remote measurements in the form of JSON, as shown in the following examples: 下列裝置模型的程式碼片段顯示 遙測類型的定義: Snippets of the following device models show the definition of the remote type: 注意 Attention. geopoint 結構描述類型是 DTDL IoT Central 延伸模組的一部分。 為顧及回溯相容性,IoT Central 目前支援 geopoint 結構描述類型和 location 語意類型。 裝置用戶端應以 JSON 的形式傳送遙測,如下列範例所示。 IoT Central 會顯示值作為地圖上的釘選: Device client should send remote measurements in the form of JSON, as shown in the following examples. Iot Central displays values as nails on the map: 本節會顯示裝置傳送至 IoT Central 應用程式的遙測事件和狀態範例。 This section shows the remote event and status examples of the device sent to the Iot Central application. 下列裝置模型的程式碼片段顯示 事件類型的定義: The following device models have code snippets showing the definition of the event type: 裝置用戶端應以 JSON 的形式傳送事件資料,如下列範例所示: Device client should send event data in the form of JSON, as illustrated by the following examples: 下列裝置模型的程式碼片段顯示 狀態類型的定義: The following device models have code snippets showing the definition of the status type: 裝置用戶端應以 JSON 的形式傳送狀態,如下列範例所示。 可能的整數狀態值為 、 或 : Device client should transmit the status in the form of JSON, as shown in the following examples. Possible integer status values are, or: 若要深入了解 DTDL 屬性命名規則,請參閱 DTDL > 屬性。 您無法使用 字元作為屬性名稱的開頭。 For more information on the DTDL attribute naming rules, see . You cannot use a character as the beginning of a property name. 如果屬性是在元件中定義,請將屬性包裝在元件名稱中。 下列範例會設定 元件中的 。 標記 表示此區段會定義元件: If properties are defined in widgets, package properties in widget names. The following examples are set in widgets. Marks indicate that this segment is defined in widgets: 若要深入了解,請參閱教學課程:建立用戶端應用程式並將其連線至您的 Azure IoT Central 應用程式。 For more information, see . 本節說明裝置傳送至服務的基本屬性類型範圍。 This section describes the range of basic attributes that the device sends to the service. 下列裝置模型的程式碼片段顯示 屬性類型的定義: The following device models have code snippets showing the definition of attribute type: 裝置用戶端應傳送 JSON 承載作為裝置對應項中的報告屬性,如下列範例所示: Device client sends JSON to carry the report properties in the device response, as shown in the following examples: 下列裝置模型的程式碼片段顯示 屬性類型的定義: The following device models have code snippets showing the definition of attribute type: 裝置用戶端應傳送 JSON 承載作為裝置對應項中的報告屬性,如下列範例所示: Device client sends JSON to carry the report properties in the device response, as shown in the following examples: 下列裝置模型的程式碼片段顯示 屬性類型的定義: The following device models have code snippets showing the definition of attribute type: 裝置用戶端應傳送 JSON 承載作為裝置對應項中的報告屬性,如下列範例所示。 類型必須符合 ISO 8061 規範: Device client sends JSON to carry the report properties of the device as a response, as shown in the following examples. The type must conform to ISO 8061: 下列裝置模型的程式碼片段顯示 屬性類型的定義: The following device models have code snippets showing the definition of attribute type: 裝置用戶端應傳送 JSON 承載作為裝置對應項中的報告屬性 - 持續時間必須符合 ISO 8601 規範,如下列範例所示: Device client sends JSON to carry the report properties in the device response - the continuous time must meet ISO 8601, as shown in the following examples: 下列裝置模型的程式碼片段顯示 屬性類型的定義: The following device models have code snippets showing the definition of attribute type: 裝置用戶端應傳送 JSON 承載作為裝置對應項中的報告屬性,如下列範例所示: Device client sends JSON to carry the report properties in the device response, as shown in the following examples: 下列裝置模型的程式碼片段顯示 屬性類型的定義: The following device models have code snippets showing the definition of attribute type: 裝置用戶端應傳送 JSON 承載作為裝置對應項中的報告屬性,如下列範例所示: Device client sends JSON to carry the report properties in the device response, as shown in the following examples: 本節說明裝置傳送至服務的複雜屬性類型範圍。 This section describes the range of complex attributes that the device sends to the service. 下列裝置模型的程式碼片段顯示 屬性類型的定義: The following device models have code snippets showing the definition of attribute type: 裝置用戶端應傳送 JSON 承載作為裝置對應項中的報告屬性,如下列範例所示。 可能的值為 、,其在 IoT Central 中顯示為 、 和 : Device client sends JSON to carry the report properties of the device as a response, as shown in the following examples. Possible values are, in Iot Central, shown as, and: 下列裝置模型的程式碼片段顯示 屬性類型的定義。 此物件有兩個欄位,其類型為 和 : The code snippets of the following device models show the definition of the attribute type. This object has two columns of type and: 裝置用戶端應傳送 JSON 承載作為裝置對應項中的報告屬性,如下列範例所示: Device client sends JSON to carry the report properties in the device response, as shown in the following examples: 下列裝置模型的程式碼片段顯示 屬性類型的定義: The following device models have code snippets showing the definition of attribute type: 裝置用戶端應傳送 JSON 承載作為裝置對應項中的報告屬性,如下列範例所示: Device client sends JSON to carry the report properties in the device response, as shown in the following examples: 下列裝置模型的程式碼片段顯示 屬性類型的定義: The following device models have code snippets showing the definition of attribute type: 注意 Attention. geopoint 結構描述類型是 DTDL IoT Central 延伸模組的一部分。 為顧及回溯相容性,IoT Central 目前支援 geopoint 結構描述類型和 location 語意類型。 裝置用戶端應傳送 JSON 承載作為裝置對應項中的報告屬性,如下列範例所示: Device client sends JSON to carry the report properties in the device response, as shown in the following examples: 本節說明裝置從服務接收的可寫入屬性類型範例。 This section describes writeable attributes examples that the device receives from the service. 如果可寫入的屬性是在元件中定義,所需屬性訊息會包含元件名稱。 下列範例顯示要求裝置更新 元件中 的訊息。 標記 表示此區段會定義元件: If the properties that can be written are defined in a widget, the required attribute message will contain a widget name. The following examples show the messages in the requested device update widget. Mark indicates that this segment will define the widget: 若要深入了解,請參閱連線 IoT 隨插即用多個元件裝置應用程式。 For further information, please refer to
裝置或模組應該藉由傳送報告屬性來確認其已接收屬性。 報告的屬性應該包括: Devices or modules should be identified by sending the report properties to confirm that they have received properties. The report should include: 若要深入了解這些欄位,請參閱 IoT 隨插即用慣例 > 通知回應 For more information on these columns, please refer to 下列裝置模型的程式碼片段顯示可寫入 屬性類型的定義: Snippets of the following device models show the definition of the properties that can be written: 裝置會收到來自服務的下列承載: The device will receive the following loads from the service: 裝置處理更新之後,應將下列 JSON 承載傳送至服務。 此訊行包含自服務所接收原始更新的版本號碼。 When the device is updated, the following JSON carriers should be sent to the service. This message line contains the original updated version number received by the service. 提示 Hint 如果服務為 IoT Central,則當其收到此訊息時,會在 UI 中將屬性標示為 [已同步]: If the service is IOT Central, the attribute is marked in UI as [synchronized] : 下列裝置模型的程式碼片段顯示可寫入 屬性類型的定義: Snippets of the following device models show the definition of the properties that can be written: 裝置會收到來自服務的下列承載: The device will receive the following loads from the service: 裝置處理更新之後,應將下列 JSON 承載傳送至服務。 此訊行包含自服務所接收原始更新的版本號碼。 When the device is updated, the following JSON carriers should be sent to the service. This message line contains the original updated version number received by the service. 提示 Hint 如果服務為 IoT Central,則當其收到此訊息時,會在 UI 中將屬性標示為 [已同步]: If the service is IOT Central, the attribute is marked in UI as [synchronized] : 若要深入了解 DTDL 命令命名規則,請參閱 DTDL > 命令。 您無法使用 字元作為命名名稱的開頭。 For more information on the DTDL command naming rules, please refer to . You cannot use a character as the beginning of a name name. 如果命令是在元件中定義,裝置接收的命令名稱包含元件名稱。 例如,如果命令稱為 而元件稱為 ,則裝置會收到執行名為 命令的要求。 If the command is defined in a widget, the command name of the device receiving the command contains the widget name. For example, if the command is called and the widget is called, the device will be required to execute the command by the name of the command. 下列裝置模型的程式碼片段會顯示沒有參數且不會預期裝置傳回任何項目的命令定義: The following device models have code snippets that show no parameters and do not expect the device to return the definition of the command for any item: 裝置會在要求中收到空白承載並應會在回應中傳回空白承載,其中包含 HTPP 回應碼來表示成功。 The device receives a blank load in the request and responds to the blank load in the response, which contains a HTPP response to indicate success. 下列裝置模型的程式碼片段會顯示具有整數參數且預期裝置傳送整數值的命令定義: The code snippets of the following device models show the command definition with integer parameters and the expected integer value of the device: 裝置會收到整數值作為要求承載。 裝置應傳回整數值作為回應承載,其中包含 HTTP 回應碼以表示成功。 Device receives integer values as required. The device returns the integer values as a response. It contains a HTTP response to indicate success. 下列裝置模型的程式碼片段顯示具有物件參數且預期裝置傳回物件的命令定義。 在此範例中,兩個物件皆有整數和字串欄位: The code snippets of the following device models show the command definition of objects with object parameters and the intended device returns the object. In this example, both objects have integer and string fields: 下列程式碼片段顯示傳送至裝置的範例要求承載: The following examples of code snippets showing the transmission to the device are required to be carried: 下列程式碼片段顯示從裝置傳送的範例回應承載。 使用 HTTP 回應碼來表示成功: The following code snippets show the examples sent from the device responding to the load. Use the HTTP response to indicate success: 提示 Hint IoT Central 有自己的慣例,可實作長時間執行的命令和離線命令。 IOT Central has its own custom to implement long-standing orders and 裝置開發人員指南。 Since you already know how to carry the device, the suggested follow-on step is to read .
注册有任何问题请添加
微信:MVIP619
拉你进入群
打开微信扫一扫 添加客服 进入交流群
发表评论