Skip to content

Commit 90046e8

Browse files
authored
Merge pull request #1302 from jason-fox/feature/exclusive-mode
Update to offer NGSI-LD 1.6.1. Registration
2 parents 55fc51b + e7896d1 commit 90046e8

15 files changed

+181
-47
lines changed

CHANGES_NEXT_RELEASE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
1+
- Update to offer NGSI-LD 1.6.1. Registrations #1302
2+
- Document removal of support for NGSI-LD 1.3.1 Interface

doc/deprecated.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ A list of deprecated features and the version in which they were deprecated foll
1818
- Support to Node.js v8 in iotagent-node-lib 2.12.0 (finally removed in 2.13.0)
1919
- Support to Node.js v10 in iotagent-node-lib 2.15.0 (finally removed in 2.16.0)
2020
- Support to Node.js v12 in iotagent-node-lib 2.24.0 (finally removed in 2.25.0)
21-
- Support to NGSI-LD v1.3 in iotagent-node-lib 2.25.0
21+
- Support to NGSI-LD v1.3 in iotagent-node-lib 2.25.0 (finally removed in 2.26.0)
2222

2323
The use of Node.js v14 is highly recommended.
2424

@@ -46,3 +46,4 @@ The following table provides information about the last iotagent-node-lib versio
4646
| Support to Node.js v8 | 2.12.0 | April 7th, 2020 |
4747
| Support to Node.js v10 | 2.15.0 | February 18th, 2021 |
4848
| Support to Node.js v12 | 2.24.0 | September 2nd, 2022 |
49+
| Support to NGSI-LD 1.3 | 2.25.0 | January 24th, 2023 |

lib/services/devices/registrationUtils.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ function sendRegistrationsNgsiLD(unregister, deviceData, callback) {
310310
return sendUnregistrationsNgsiLD(deviceData, callback);
311311
}
312312

313+
const operations = [];
313314
const properties = [];
314315
const lazy = deviceData.lazy || [];
315316
const commands = deviceData.commands || [];
@@ -321,6 +322,13 @@ function sendRegistrationsNgsiLD(unregister, deviceData, callback) {
321322
properties.push(element.name);
322323
});
323324

325+
if (lazy.length > 0){
326+
operations.push('retrieveOps');
327+
}
328+
if (commands.length > 0){
329+
operations.push('updateOps');
330+
}
331+
324332
if (properties.length === 0) {
325333
logger.debug(context, 'Registration with Context Provider is not needed. Device without lazy atts or commands');
326334
return callback(null, deviceData);
@@ -348,10 +356,18 @@ function sendRegistrationsNgsiLD(unregister, deviceData, callback) {
348356
information: [
349357
{
350358
entities: [{ type: deviceData.type, id }],
351-
properties
359+
propertyNames: properties
352360
}
353361
],
362+
mode: 'exclusive',
363+
operations,
354364
endpoint: config.getConfig().providerUrl,
365+
contextSourceInfo: [
366+
{
367+
'key': 'jsonldContext',
368+
'value': config.getConfig().contextBroker.jsonLdContext
369+
}
370+
],
355371
'@context': config.getConfig().contextBroker.jsonLdContext
356372
},
357373
headers: {
Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
{
2-
"@context": "http://context.json-ld",
3-
"endpoint": "http://smartgondor.com",
4-
"information": [
2+
"type": "ContextSourceRegistration",
3+
"information": [
4+
{
5+
"entities": [
56
{
6-
"entities": [
7-
{
8-
"id": "urn:ngsi-ld:Light:light1",
9-
"type": "Light"
10-
}
11-
],
12-
"properties": [
13-
"temperature"
14-
]
7+
"type": "Light",
8+
"id": "urn:ngsi-ld:Light:light1"
159
}
16-
],
17-
"type": "ContextSourceRegistration"
10+
],
11+
"propertyNames": [
12+
"temperature"
13+
]
14+
}
15+
],
16+
"mode": "exclusive",
17+
"operations": [
18+
"retrieveOps"
19+
],
20+
"endpoint": "http://smartgondor.com",
21+
"contextSourceInfo": [
22+
{
23+
"key": "jsonldContext",
24+
"value": "http://context.json-ld"
25+
}
26+
],
27+
"@context": "http://context.json-ld"
1828
}
Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
{
2-
"type": "ContextSourceRegistration",
3-
"information": [
4-
{
5-
"entities": [
2+
"type": "ContextSourceRegistration",
3+
"information": [
64
{
7-
"type": "Motion",
8-
"id": "urn:ngsi-ld:Motion:motion1"
5+
"entities": [
6+
{
7+
"type": "Motion",
8+
"id": "urn:ngsi-ld:Motion:motion1"
9+
}
10+
],
11+
"propertyNames": [
12+
"moving"
13+
]
914
}
10-
],
11-
"properties": [
12-
"moving"
13-
]
14-
}
15-
],
16-
"endpoint": "http://smartgondor.com",
17-
"@context": "http://context.json-ld"
18-
}
15+
],
16+
"mode": "exclusive",
17+
"operations": [
18+
"retrieveOps"
19+
],
20+
"endpoint": "http://smartgondor.com",
21+
"contextSourceInfo":[
22+
{
23+
"key": "jsonldContext",
24+
"value": "http://context.json-ld"
25+
}
26+
],
27+
"@context": "http://context.json-ld"
28+
}

test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent4.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,25 @@
44
{
55
"entities": [
66
{
7-
"type": "RobotPre",
8-
"id": "urn:ngsi-ld:RobotPre:TestRobotPre"
7+
"type": "Light",
8+
"id": "urn:ngsi-ld:Light:light1"
99
}
1010
],
11-
"properties": [
12-
"moving"
11+
"propertyNames": [
12+
"temperature"
1313
]
1414
}
1515
],
16+
"mode": "exclusive",
17+
"operations": [
18+
"retrieveOps"
19+
],
1620
"endpoint": "http://smartgondor.com",
21+
"contextSourceInfo": [
22+
{
23+
"key": "jsonldContext",
24+
"value": "http://context.json-ld"
25+
}
26+
],
1727
"@context": "http://context.json-ld"
18-
}
28+
}
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
22
"@context": "http://context.json-ld",
33
"endpoint": "http://smartgondor.com",
4+
"contextSourceInfo":[
5+
{
6+
"key": "jsonldContext",
7+
"value": "http://context.json-ld"
8+
}
9+
],
410
"information": [
511
{
612
"entities": [
@@ -9,11 +15,13 @@
915
"type": "Robot"
1016
}
1117
],
12-
"properties": [
18+
"propertyNames": [
1319
"position",
1420
"orientation"
1521
]
1622
}
1723
],
24+
"mode": "exclusive",
25+
"operations" :["updateOps"],
1826
"type": "ContextSourceRegistration"
1927
}
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
22
"@context": "http://context.json-ld",
33
"endpoint": "http://smartgondor.com",
4+
"contextSourceInfo":[
5+
{
6+
"key": "jsonldContext",
7+
"value": "http://context.json-ld"
8+
}
9+
],
410
"information": [
511
{
612
"entities": [
@@ -9,11 +15,16 @@
915
"type": "TheLightType"
1016
}
1117
],
12-
"properties": [
18+
"propertyNames": [
1319
"luminance",
1420
"commandAttr"
1521
]
1622
}
1723
],
24+
"mode": "exclusive",
25+
"operations": [
26+
"retrieveOps",
27+
"updateOps"
28+
],
1829
"type": "ContextSourceRegistration"
1930
}
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
22
"@context": "http://context.json-ld",
33
"endpoint": "http://smartgondor.com",
4+
"contextSourceInfo":[
5+
{
6+
"key": "jsonldContext",
7+
"value": "http://context.json-ld"
8+
}
9+
],
410
"information": [
511
{
612
"entities": [
@@ -9,10 +15,12 @@
915
"type": "TheLightType"
1016
}
1117
],
12-
"properties": [
18+
"propertyNames": [
1319
"luminance"
1420
]
1521
}
1622
],
23+
"mode": "exclusive",
24+
"operations" :["retrieveOps"],
1725
"type": "ContextSourceRegistration"
1826
}
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
22
"@context": "http://context.json-ld",
33
"endpoint": "http://smartgondor.com",
4+
"contextSourceInfo":[
5+
{
6+
"key": "jsonldContext",
7+
"value": "http://context.json-ld"
8+
}
9+
],
410
"information": [
511
{
612
"entities": [
@@ -9,13 +15,18 @@
915
"type": "TheLightType"
1016
}
1117
],
12-
"properties": [
18+
"propertyNames": [
1319
"luminance",
1420
"luminescence",
1521
"commandAttr",
1622
"wheel1"
1723
]
1824
}
1925
],
26+
"mode": "exclusive",
27+
"operations": [
28+
"retrieveOps",
29+
"updateOps"
30+
],
2031
"type": "ContextSourceRegistration"
2132
}
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
22
"@context": "http://context.json-ld",
33
"endpoint": "http://smartgondor.com",
4+
"contextSourceInfo":[
5+
{
6+
"key": "jsonldContext",
7+
"value": "http://context.json-ld"
8+
}
9+
],
410
"information": [
511
{
612
"entities": [
@@ -9,13 +15,18 @@
915
"type": "SensorMachine"
1016
}
1117
],
12-
"properties": [
18+
"propertyNames": [
1319
"luminance",
1420
"luminescence",
1521
"commandAttr",
1622
"wheel1"
1723
]
1824
}
1925
],
26+
"mode": "exclusive",
27+
"operations" : [
28+
"retrieveOps",
29+
"updateOps"
30+
],
2031
"type": "ContextSourceRegistration"
2132
}
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
22
"@context": "http://context.json-ld",
33
"endpoint": "http://smartgondor.com",
4+
"contextSourceInfo":[
5+
{
6+
"key": "jsonldContext",
7+
"value": "http://context.json-ld"
8+
}
9+
],
410
"information": [
511
{
612
"entities": [
@@ -9,10 +15,12 @@
915
"type": "Light"
1016
}
1117
],
12-
"properties": [
18+
"propertyNames": [
1319
"temperature"
1420
]
1521
}
1622
],
23+
"mode": "exclusive",
24+
"operations" :["retrieveOps"],
1725
"type": "ContextSourceRegistration"
1826
}
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{
22
"type":"ContextSourceRegistration",
3+
"contextSourceInfo":[
4+
{
5+
"key": "jsonldContext",
6+
"value": "http://context.json-ld"
7+
}
8+
],
39
"information":[
410
{
511
"entities":[
@@ -8,11 +14,13 @@
814
"id":"urn:ngsi-ld:Light:light1"
915
}
1016
],
11-
"properties":[
17+
"propertyNames":[
1218
"move"
1319
]
1420
}
1521
],
22+
"mode": "exclusive",
23+
"operations":["updateOps"],
1624
"endpoint":"http://smartgondor.com",
1725
"@context": "http://context.json-ld"
18-
}
26+
}

0 commit comments

Comments
 (0)