Skip to content

Commit 2850ef5

Browse files
committed
Switch to JSON IoT Agent
1 parent 5f17aa7 commit 2850ef5

12 files changed

Lines changed: 289 additions & 55 deletions

File tree

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ CURL_VERSION=8.4.0
2222
MONGO_DB_PORT=27017
2323
MONGO_DB_VERSION=6.0
2424

25-
# IoT Agent Ultralight Variables
26-
ULTRALIGHT_VERSION=3.6.0-distroless
25+
# IoT Agent JSON Variables
26+
JSON_VERSION=3.14.0-distroless
2727
IOTA_NORTH_PORT=4041
2828
IOTA_SOUTH_PORT=7896
2929

.github/test/iot_device_smoke_test

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
#
3+
# Smoke test: verify IoT device provisioning by sending an 'on' command to each
4+
# water sprinkler and confirming the context broker reflects the updated
5+
# on_status attribute after the full command round-trip:
6+
# Orion → IoT Agent → iot-sensors simulator → IoT Agent → Orion
7+
#
8+
9+
set -e
10+
11+
export $(cat .env | grep "#" -v)
12+
13+
BROKER="http://orion:1026"
14+
CONTEXT="http://context/user-context.jsonld"
15+
TENANT="openiot"
16+
DEVICES=("water001" "water002" "water003" "water004")
17+
18+
failures=0
19+
20+
run_curl () {
21+
docker run --rm --network fiware_default quay.io/curl/curl:"${CURL_VERSION}" "$@"
22+
}
23+
24+
send_on_command () {
25+
local device="$1"
26+
local status
27+
status=$(run_curl -s -o /dev/null -w "%{http_code}" \
28+
-L -X PATCH \
29+
"${BROKER}/ngsi-ld/v1/entities/urn:ngsi-ld:Device:${device}/attrs/on" \
30+
-H "NGSILD-Tenant: ${TENANT}" \
31+
-H 'Content-Type: application/json' \
32+
-H "Link: <${CONTEXT}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" \
33+
--data-raw '{"type":"Property","value":" "}')
34+
if [ "${status}" != "204" ]; then
35+
echo "FAIL [${device}]: on command returned HTTP ${status} (expected 204)"
36+
return 1
37+
fi
38+
echo "PASS [${device}]: on command accepted (204)"
39+
}
40+
41+
check_on_status () {
42+
local device="$1"
43+
local response
44+
response=$(run_curl -s \
45+
"${BROKER}/ngsi-ld/v1/entities/urn:ngsi-ld:Device:${device}" \
46+
-H "NGSILD-Tenant: ${TENANT}" \
47+
-H "Link: <${CONTEXT}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" \
48+
-H 'Accept: application/json')
49+
if ! echo "${response}" | grep -q '"on_status"'; then
50+
echo "FAIL [${device}]: on_status attribute missing from context broker"
51+
echo " Response: ${response}"
52+
return 1
53+
fi
54+
echo "PASS [${device}]: on_status confirmed in context broker"
55+
}
56+
57+
for device in "${DEVICES[@]}"; do
58+
send_on_command "${device}" || failures=$((failures + 1))
59+
done
60+
61+
echo "Waiting 5s for command round-trip..."
62+
sleep 5
63+
64+
for device in "${DEVICES[@]}"; do
65+
check_on_status "${device}" || failures=$((failures + 1))
66+
done
67+
68+
echo ""
69+
if [ "${failures}" -gt 0 ]; then
70+
echo "Smoke test FAILED: ${failures} assertion(s) did not pass"
71+
exit 1
72+
fi
73+
echo "Smoke test PASSED: all water devices are responding and context broker is updated"

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ jobs:
2828
run: |
2929
./services create || true
3030
- name: Run Orion
31-
run: |
32-
./services orion && ./services stop
31+
run: ./services orion
32+
- name: Smoke Test (Orion)
33+
run: ./.github/test/iot_device_smoke_test
34+
- name: Stop (Orion)
35+
if: always()
36+
run: ./services stop
3337
- name: Run Stellio
3438
run: |
3539
./services stellio && ./services stop

README.ja.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ API を使いやすくし、開発者の負担を軽減するために、NGSI-LD
205205
このチュートリアルの目的のために、一連のダミーの農業用 IoT デバイスが作成され、Context Broker に接続されます。使用
206206
されているアーキテクチャとプロトコルの詳細は、
207207
[IoT センサ・チュートリアル](https://github.com/FIWARE/tutorials.IoT-Sensors/tree/NGSI-LD)にあります。各デバイスの
208-
状態は、 UltraLight デバイス・モニタの Web ページは次の場所にあります: `http://localhost:3000/device/monitor`
208+
状態は、 JSON デバイス・モニタの Web ページは次の場所にあります: `http://localhost:3000/device/monitor`
209209

210210
![FIWARE Monitor](https://fiware.github.io/tutorials.Concise-Format/img/farm-devices.png)
211211

@@ -217,7 +217,7 @@ API を使いやすくし、開発者の負担を軽減するために、NGSI-LD
217217

218218
このアプリケーションは、[以前のチュートリアル](https://github.com/FIWARE/tutorials.IoT-Agent/)で作成したコンポーネント
219219
とダミーの IoT デバイスに基づいて構築されています。[Orion Context Broker](https://fiware-orion.readthedocs.io/en/latest/)
220-
[IoT Agent for Ultralight 2.0](https://fiware-iotagent-ul.readthedocs.io/en/latest/) の2つの FIWARE コンポーネントを
220+
[IoT Agent for JSON](https://fiware-iotagent-json.readthedocs.io/en/latest/) の2つの FIWARE コンポーネントを
221221
使用します。
222222

223223
したがって、アーキテクチャ全体は次の要素で構成されます:
@@ -227,10 +227,10 @@ API を使いやすくし、開発者の負担を軽減するために、NGSI-LD
227227
- [Orion Context Broker](https://fiware-orion.readthedocs.io/en/latest/) は、
228228
[NGSI-LD](https://forge.etsi.org/swagger/ui/?url=https://forge.etsi.org/rep/NGSI-LD/NGSI-LD/raw/master/spec/updated/generated/full_api.json)
229229
を使用してリクエストを受信します
230-
- FIWARE [IoT Agent for UltraLight 2.0](https://fiware-iotagent-ul.readthedocs.io/en/latest/) は、
230+
- FIWARE [IoT Agent for JSON](https://fiware-iotagent-json.readthedocs.io/en/latest/) は、
231231
[NGSI-LD](https://forge.etsi.org/swagger/ui/?url=https://forge.etsi.org/rep/NGSI-LD/NGSI-LD/raw/master/spec/updated/generated/full_api.json)
232232
を使用してサウスバウンド・リクエストを受信し、それらをデバイスの
233-
[UltraLight 2.0](https://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual)
233+
[JSON](https://fiware-iotagent-json.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual)
234234
コマンドに変換します
235235

236236
- [MongoDB](https://www.mongodb.com/) データベース:
@@ -243,7 +243,7 @@ API を使いやすくし、開発者の負担を軽減するために、NGSI-LD
243243

244244
- **チュートリアル・アプリケーション**は、以下のことを行います:
245245
- HTTP を介して実行される
246-
[UltraLight 2.0](https://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual)
246+
[JSON](https://fiware-iotagent-json.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual)
247247
プロトコルを使用して、ダミーの[農業 IoT デバイス](https://github.com/FIWARE/tutorials.IoT-Sensors/tree/NGSI-LD)
248248
のセットとして機能します
249249

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ designed to bridge the gap between the two.
207207
For the purpose of this tutorial, a series of dummy agricultural IoT devices have been created, which will be attached
208208
to the context broker. Details of the architecture and protocol used can be found in the
209209
[IoT Sensors tutorial](https://github.com/FIWARE/tutorials.IoT-Sensors/tree/NGSI-LD) The state of each device can be
210-
seen on the UltraLight device monitor web page found at: `http://localhost:3000/device/monitor`.
210+
seen on the JSON device monitor web page found at: `http://localhost:3000/device/monitor`.
211211

212212
![FIWARE Monitor](https://fiware.github.io/tutorials.Concise-Format/img/farm-devices.png)
213213

@@ -218,19 +218,19 @@ seen on the UltraLight device monitor web page found at: `http://localhost:3000/
218218
This application builds on the components and dummy IoT devices created in
219219
[previous tutorials](https://github.com/FIWARE/tutorials.IoT-Agent/). It will use two FIWARE components: the
220220
[Orion Context Broker](https://fiware-orion.readthedocs.io/en/latest/) and the
221-
[IoT Agent for Ultralight 2.0](https://fiware-iotagent-ul.readthedocs.io/en/latest/).
221+
[IoT Agent for JSON](https://fiware-iotagent-json.readthedocs.io/en/latest/).
222222

223223
Therefore the overall architecture will consist of the following elements:
224224

225225
- The **FIWARE Generic Enablers**:
226226

227227
- The [Orion Context Broker](https://fiware-orion.readthedocs.io/en/latest/) which will receive requests using
228228
[NGSI-LD](https://forge.etsi.org/swagger/ui/?url=https://forge.etsi.org/rep/NGSI-LD/NGSI-LD/raw/master/spec/updated/generated/full_api.json)
229-
- The FIWARE [IoT Agent for UltraLight 2.0](https://fiware-iotagent-ul.readthedocs.io/en/latest/) which will
229+
- The FIWARE [IoT Agent for JSON](https://fiware-iotagent-json.readthedocs.io/en/latest/) which will
230230
receive southbound requests using
231231
[NGSI-LD](https://forge.etsi.org/swagger/ui/?url=https://forge.etsi.org/rep/NGSI-LD/NGSI-LD/raw/master/spec/updated/generated/full_api.json)
232232
and convert them to
233-
[UltraLight 2.0](https://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual)
233+
[JSON](https://fiware-iotagent-json.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual)
234234
commands for the devices
235235

236236
- A [MongoDB](https://www.mongodb.com/) database:
@@ -243,7 +243,7 @@ Therefore the overall architecture will consist of the following elements:
243243
- The **Tutorial Application** does the following:
244244
- Acts as set of dummy [agricultural IoT devices](https://github.com/FIWARE/tutorials.IoT-Sensors/tree/NGSI-LD)
245245
using the
246-
[UltraLight 2.0](https://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual)
246+
[JSON](https://fiware-iotagent-json.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual)
247247
protocol running over HTTP.
248248

249249
Since all interactions between the elements are initiated by HTTP requests, the entities can be containerized and run

docker-compose/common.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ services:
5959
iot-agent:
6060
labels:
6161
org.fiware: 'tutorial'
62-
image: quay.io/fiware/iotagent-ul:${ULTRALIGHT_VERSION}
62+
image: quay.io/fiware/iotagent-json:${JSON_VERSION}
6363
hostname: iot-agent
6464
container_name: fiware-iot-agent
6565
depends_on:
@@ -84,10 +84,9 @@ services:
8484
- IOTA_LOG_LEVEL=DEBUG # The log level of the IoT Agent
8585
- IOTA_TIMESTAMP=true # Supply timestamp information with each measurement
8686
- IOTA_AUTOCAST=true # Ensure Ultralight number values are read as numbers not strings
87-
- IOTA_MONGO_HOST=mongo-db # The host name of MongoDB
88-
- IOTA_MONGO_PORT=${MONGO_DB_PORT} # The port mongoDB is listening on
89-
- IOTA_MONGO_DB=iotagentul # The name of the database used in mongoDB
90-
- IOTA_HTTP_PORT=${IOTA_SOUTH_PORT} # The port used for device traffic over HTTP
87+
- IOTA_MONGO_URI=mongodb://mongo-db:${MONGO_DB_PORT}/iotagentjson
88+
- IOTA_HTTP_PORT=${IOTA_SOUTH_PORT}
89+
- IOTA_DEFAULT_RESOURCE=/iot/json # The port used for device traffic over HTTP
9190
- IOTA_PROVIDER_URL=http://iot-agent:${IOTA_NORTH_PORT}
9291
- IOTA_CB_NGSI_VERSION=ld # use NGSI-LD when sending updates for active attributes
9392
- IOTA_JSON_LD_CONTEXT=http://context/user-context.jsonld
@@ -120,6 +119,8 @@ services:
120119
- IOTA_JSON_LD_CONTEXT=http://context/user-context.jsonld
121120

122121

122+
- IOTA_DEFAULT_RESOURCE=/iot/json
123+
- DUMMY_DEVICES_PAYLOAD=JSON
123124
networks:
124125
default:
125126
labels:

docker-compose/orion-ld.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ services:
5353
- IOTA_DEFAULT_RESOURCE=/iot/d
5454
- DUMMY_DEVICES_PORT=${TUTORIAL_DUMMY_DEVICE_PORT} # Port used by the dummy IOT devices to receive commands
5555
- DUMMY_DEVICES_TRANSPORT=HTTP # Default transport used by dummy Io devices
56-
- DUMMY_DEVICES_PAYLOAD=ULTRALIGHT
56+
- DUMMY_DEVICES_PAYLOAD=JSON
5757
- CONTEXT_BROKER=http://orion:${ORION_LD_PORT}/ngsi-ld/v1 # URL of the context broker to update context
5858

docker-compose/scorpio.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ services:
6565
- IOTA_DEFAULT_RESOURCE=/iot/d
6666
- DUMMY_DEVICES_PORT=${TUTORIAL_DUMMY_DEVICE_PORT} # Port used by the dummy IOT devices to receive commands
6767
- DUMMY_DEVICES_TRANSPORT=HTTP # Default transport used by dummy Io devices
68-
- DUMMY_DEVICES_PAYLOAD=ULTRALIGHT
68+
- DUMMY_DEVICES_PAYLOAD=JSON
6969
- CONTEXT_BROKER=http://scorpio:${SCORPIO_PORT}/ngsi-ld/v1 # URL of the context broker to update context
7070

7171
volumes:

docker-compose/stellio.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ services:
139139
- IOTA_DEFAULT_RESOURCE=/iot/d
140140
- DUMMY_DEVICES_PORT=${TUTORIAL_DUMMY_DEVICE_PORT} # Port used by the dummy IOT devices to receive commands
141141
- DUMMY_DEVICES_TRANSPORT=HTTP # Default transport used by dummy Io devices
142-
- DUMMY_DEVICES_PAYLOAD=ULTRALIGHT
142+
- DUMMY_DEVICES_PAYLOAD=JSON
143143
- CONTEXT_BROKER=http://stellio:${STELLIO_PORT}/ngsi-ld/v1 # URL of the context broker to update context
144144

145145
volumes:

0 commit comments

Comments
 (0)