Skip to content

Commit 3d6e061

Browse files
committed
Switch to JSON IoT Agent
1 parent f22fbfd commit 3d6e061

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

README.ja.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
デバイスを接続します。**Custom IoT Agent** は、[Orion Context Broker](https://fiware-orion.readthedocs.io/en/latest/)
1111
に送信された [NGSI-v2](https://fiware.github.io/specifications/OpenAPI/ngsiv2) リクエストを使用して測定値を読み取り、
1212
コマンドを送信できるように、IoT Agent Node.js [ライブラリ](https://iotagent-node-lib.readthedocs.io/en/latest/)
13-
[IoT Agent for Ultralight](https://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual)
13+
[IoT Agent for JSON](https://fiware-iotagent-json.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual)
1414
デバイスにあるフレームワークに基づいて作成されます。
1515

1616
チュートリアルでは、全体を通して [cUrl](https://ec.haxx.se/) コマンドを使用していますが、
@@ -62,10 +62,10 @@
6262
独自の IoT Agent を作成するプロセスは比較的簡単です。これは、必要なデータ転送を使用する IoT Agent を選択し、
6363
ペイロード処理コードを書き換え/修正して、問題のペイロードを処理することにより、最もよく達成されます。
6464

65-
このチュートリアルでは、既存の Ultralight IoT Agent のコードを修正して、同様のカスタム XML 形式を処理します。
65+
このチュートリアルでは、既存の JSON IoT Agent のコードを修正して、同様のカスタム XML 形式を処理します。
6666
2つの IoT Agent の直接比較を以下に示します:
6767

68-
| IoT Agent for Ultralight | IoT Agent for XML | プロトコルの関心領域 |
68+
| IoT Agent for JSON | IoT Agent for XML | プロトコルの関心領域 |
6969
| -------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | -------------------------- |
7070
| 測定値のサンプル `c\|1` | 測定値のサンプル `<measure device="lamp002" key="xxx">`<br/>&nbsp;`<c value="1"/>`<br/>`</measure>` | メッセージ・ペイロード |
7171
| コマンドのサンプル `Robot1@turn\|left=30` | コマンドのサンプル `<turn device="Robot1">`<br/>&nbsp;`<left>30</left>`<br/>`</turn>` | メッセージ・ペイロード |
@@ -92,7 +92,7 @@
9292
## このチュートリアルの目標
9393

9494
このチュートリアルの目的は、独自のカスタム IoT Agent を作成する方法について開発者の理解を深めることです。一連の簡単な
95-
変更が Ultralight IoT Agent のコードに加えられ、変更方法が示されています。このチュートリアルは、関連するコードの
95+
変更が JSON IoT Agent のコードに加えられ、変更方法が示されています。このチュートリアルは、関連するコードの
9696
ウォークスルーと、新しい IoT Agent に接続するための一連の HTTP リクエストで構成されています。コードは、現在、
9797
[GitHub リポジトリ](https://github.com/FIWARE/tutorials.Custom-IoT-Agent/tree/NGSI-v2/iot-agent) にあります。
9898

@@ -207,7 +207,7 @@ YAML ファイルに記述されている他の `tutorial` コンテナ設定値
207207

208208
カスタム XML IoT Agent のコードは、このチュートリアルに関連付けられている
209209
[GitHub リポジトリ](https://github.com/FIWARE/tutorials.Custom-IoT-Agent/tree/NGSI-v2/iot-agent)にあります。これは、
210-
IoT Agent for Ultralight の 1.12.0 バージョンのコピーであり、以下に説明するように少し変更されています。関連する
210+
IoT Agent for JSON の 1.12.0 バージョンのコピーであり、以下に説明するように少し変更されています。関連する
211211
[Dockerfile](https://github.com/FIWARE/tutorials.Custom-IoT-Agent/blob/NGSI-v2/iot-agent/Dockerfile) は、Node.js
212212
を実行している Docker コンテナ内の適切な場所にコードをコピーするだけです。これにより、`docker-compose.yaml`
213213
ファイルを使用してコンポーネントをインスタンス化できます。必要な設定は次のとおりです:
@@ -428,7 +428,7 @@ http://iot-agent:7896/iot/xml
428428
</measure>
429429
```
430430
431-
この構文は、デバイス ID と API キーが URL パラメータとして送信される Ultralight IoT Agent とは異なります。
431+
この構文は、デバイス ID と API キーが URL パラメータとして送信される JSON IoT Agent とは異なります。
432432
433433
関連する変更は、XML パーサーがインスタンス化される `HTTPBindings.js` ファイルにあります。
434434
@@ -532,7 +532,7 @@ curl -iX POST \
532532
'
533533
```
534534

535-
予想通り、元の Ultralight IoT Agent と同じ HTTP トランスポートを使用しているため、**デバイスをプロビジョニングする**
535+
予想通り、元の JSON IoT Agent と同じ HTTP トランスポートを使用しているため、**デバイスをプロビジョニングする**
536536
HTTP コマンドは、基になるペイロードまたはトランスポート・プロトコルに基づいて変更されません。`internal_atttributes`
537537
を使用して、必要に応じて Custom IoT Agent の追加情報を提供できます。リクエストでは、デバイス `motion001` を URN
538538
`urn:ngsi-ld:Motion:001` に関連付け、デバイスの `c` をコンテキスト属性 `count` (`Integer` として定義されている)
@@ -553,7 +553,7 @@ curl -L -X POST 'http://localhost:7896/iot/xml' \
553553
```
554554

555555
ペイロードと `Content-Type` の両方が更新されました。ダミー IoT デバイスは、ドアがロックされていないときに、
556-
以前のチュートリアルで同様の Ultralight リクエストを行いました。各 Motion sensor の状態が変化し、
556+
以前のチュートリアルで同様の JSON リクエストを行いました。各 Motion sensor の状態が変化し、
557557
ノースバウンド・リクエストがデバイス・モニタに記録されます。
558558

559559
これで IoT Agent が接続され、サービス・グループは IoT Agent がリッスンするリソース (`iot/xml`) を定義し、
@@ -673,7 +673,7 @@ curl -iX POST \
673673

674674
1. Custom IoT Agent が属性を登録します
675675
2. Custom IoT Agent が `/v2/op/update` エンドポイントで、コンテキストを更新するための各リクエストをします
676-
3. リクエストの処理方法が決定されます。Custom IoT Agent と Ultralight Agent の両方で、これは `<command>State`
676+
3. リクエストの処理方法が決定されます。Custom IoT Agent と JSON Agent の両方で、これは `<command>State`
677677
属性を設定し、`/cmd` エンドポイントでリクエストを修正して、デバイス (またはデバイスの責任を負うミドルウェア)
678678
にフォワーディングするというパラダイムに従います
679679

@@ -763,7 +763,7 @@ function createCommandPayload(device, command, attributes) {
763763
}
764764
```
765765
766-
これは Ultralight プロトコルの修正であり、 `@` および `|` 記号が Ultralight デバイス用に生成されます。
766+
これは JSON プロトコルの修正であり、 `@` および `|` 記号が JSON デバイス用に生成されます。
767767
768768
ただし、ペイロードの作成はジョブの半分にすぎず、デバイスに送信して理解する必要があるため、明確に定義された
769769
通信ハンドシェイクを使用して通信を完了する必要があります。そのため、ペイロードを生成した後、 `HTTPBindings.js`

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
This tutorial a wires up the dummy IoT devices which are responding using a custom [XML](https://www.w3.org/TR/xml11/)
1616
message format. A **custom IoT Agent** is created based on the IoT Agent Node.js
1717
[library](https://iotagent-node-lib.readthedocs.io/en/latest/) and the framework found in the
18-
[IoT Agent for Ultralight](https://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual)
18+
[IoT Agent for JSON](https://fiware-iotagent-json.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual)
1919
devices so that measurements can be read and commands can be sent using
2020
[NGSI-v2](https://fiware.github.io/specifications/OpenAPI/ngsiv2) requests sent to the
2121
[Orion Context Broker](https://fiware-orion.readthedocs.io/en/latest/).
@@ -69,10 +69,10 @@ The process for creating your own IoT Agent is relatively simple. It is best ach
6969
which uses the required data transport and rewriting/amending the payload processing code to handle the payloads in
7070
question.
7171

72-
For the purpose of this tutorial we will amend code from the existing Ultralight IoT Agent to process a similar custom
72+
For the purpose of this tutorial we will amend code from the existing JSON IoT Agent to process a similar custom
7373
XML format. A direct comparison of the two IoT Agents can be seen below:
7474

75-
| IoT Agent for Ultralight | New IoT Agent for XML | Protocol's Area of Concern |
75+
| IoT Agent for JSON | New IoT Agent for XML | Protocol's Area of Concern |
7676
| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | -------------------------- |
7777
| Sample Measure `c\|1` | Sample Measure `<measure device="lamp002" key="xxx">`<br/>&nbsp;`<c value="1"/>`<br/>`</measure>` | Message Payload |
7878
| Sample Command `Robot1@turn\|left=30` | Sample Command `<turn device="Robot1">`<br/>&nbsp;`<left>30</left>`<br/>`</turn>` | Message Payload |
@@ -98,7 +98,7 @@ lower-level CoAP transport used by the devices.
9898
## The teaching goal of this tutorial
9999

100100
The aim of this tutorial is to improve developer understanding of how to create their own custom IoT Agents, a series of
101-
simple modifications has been made to the code of the Ultralight IoT Agent demonstrating how to make changes. The
101+
simple modifications has been made to the code of the JSON IoT Agent demonstrating how to make changes. The
102102
tutorial consists of a walkthrough of the relevant code and a series of HTTP requests to connect the new IoT Agent. The
103103
code can be found within the current
104104
[GitHub Repository](https://github.com/FIWARE/tutorials.Custom-IoT-Agent/tree/master/iot-agent)
@@ -208,7 +208,7 @@ The other `tutorial` container configuration values described in the YAML file a
208208

209209
The code for the custom XML IoT Agent can be found within the
210210
[GitHub Repository](https://github.com/FIWARE/tutorials.Custom-IoT-Agent/tree/master/iot-agent) associated to this
211-
tutorial. It is a copy of the 1.12.0 version of the IoT Agent for Ultralight, lightly modified as described below. The
211+
tutorial. It is a copy of the 1.12.0 version of the IoT Agent for JSON, lightly modified as described below. The
212212
associated [Dockerfile](https://github.com/FIWARE/tutorials.Custom-IoT-Agent/blob/master/iot-agent/Dockerfile) merely
213213
copies the code into an appropriate location within a Docker container running Node.js. This allows the component to be
214214
instantiated using a `docker-compose.yaml` file. The necessary configuration can be seen below:
@@ -418,7 +418,7 @@ Where the `<measure>` holds the relevant device ID and API key.
418418
</measure>
419419
```
420420
421-
This syntax differs from the Ultralight IoT Agent where the device ID and API key are sent as URL parameters.
421+
This syntax differs from the JSON IoT Agent where the device ID and API key are sent as URL parameters.
422422
423423
The relevant changes can be found in the `HTTPBindings.js` file where an XML parser is instantiated.
424424
@@ -521,7 +521,7 @@ curl -iX POST \
521521
```
522522

523523
As expected the HTTP command to **provision a device** does not change based on the underlying payload or transport
524-
protocol since we are using the same HTTP transport as the original Ultralight IoT Agent. `internal_atttributes` can be
524+
protocol since we are using the same HTTP transport as the original JSON IoT Agent. `internal_atttributes` can be
525525
used to supply additional information for the custom IoT Agent if necessary. In the request we are associating the
526526
device `motion001` with the URN `urn:ngsi-ld:Motion:001` and mapping the device reading `c` with the context attribute
527527
`count` (which is defined as an `Integer`) A `refStore` is defined as a `static_attribute`, placing the device within
@@ -540,7 +540,7 @@ curl -L -X POST 'http://localhost:7896/iot/xml' \
540540
</measure>'
541541
```
542542

543-
Both the payload and the `Content-Type` have been updated. The dummy devices made a similar Ultralight request in the
543+
Both the payload and the `Content-Type` have been updated. The dummy devices made a similar JSON request in the
544544
previous tutorials when the door was unlocked, you will have seen the state of each motion sensor changing and a
545545
Northbound request will be logged in the device monitor.
546546

@@ -661,7 +661,7 @@ Agent the provisioning of commands fulfills the following implied contract:
661661

662662
1. The custom IoT Agent is making a registration for an attribute
663663
2. The custom IoT Agent each request for updating context (on the `/v2/op/update` endpoint)
664-
3. A decision is made how to handle the request - for both the Custom IoT Agent and the Ultralight Agent this follows
664+
3. A decision is made how to handle the request - for both the Custom IoT Agent and the JSON Agent this follows
665665
the paradigm of setting a `<command>State` attribute, amending and forwarding the request on a `/cmd` endpoint to
666666
the device (or alternatively to a middleware responsible for the device).
667667

@@ -751,7 +751,7 @@ function createCommandPayload(device, command, attributes) {
751751
}
752752
```
753753
754-
This is an amendment from the Ultralight protocol where the `@` and `|` symbol is generated for Ultralight devices.
754+
This is an amendment from the JSON protocol where the `@` and `|` symbol is generated for JSON devices.
755755
756756
However, creating a payload is only half the job, it must be sent to the device and understood, so communications must
757757
be completed using a well-defined communications handshake. So after generating the payload the `sendXMLCommandHTTP()`

0 commit comments

Comments
 (0)