You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/usermanual.md
+77Lines changed: 77 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -354,6 +354,83 @@ values.
354
354
The handler is expected to call its callback once with no parameters (failing to do so may cause unexpected behaviors in
355
355
the IoT Agent).
356
356
357
+
##### iotagentLib.setCommandHandler()
358
+
359
+
###### Signature
360
+
361
+
```javascript
362
+
function setCommandHandler(newHandler)
363
+
```
364
+
365
+
###### Description
366
+
367
+
Sets the new user handler for registered entity commands. This handler will be called whenever a command request arrives, with
368
+
the following parameters: (`id`, `type`, `service`, `subservice`, `attributes`, `callback`). The handler must retrieve
369
+
all the corresponding information from the devices and return a NGSI entity with the requested values.
370
+
371
+
The callback must be invoked with the updated Context Element, using the information retrieved from the devices. E.g.:
372
+
373
+
```javascript
374
+
callback(null, {
375
+
type:"TheType",
376
+
isPattern:false,
377
+
id:"EntityID",
378
+
attributes: [
379
+
{
380
+
name:"lumniscence",
381
+
type:"Lumens",
382
+
value:"432"
383
+
}
384
+
]
385
+
});
386
+
```
387
+
388
+
In the case of NGSI requests affecting multiple entities, this handler will be called multiple times, one for each
389
+
entity, and all the results will be combined into a single response. Only IoT Agents which deal with actuator devices will include a handler for commands.
390
+
391
+
###### Params
392
+
393
+
- newHandler: User handler for command requests.
394
+
395
+
##### iotagentLib.setMergePatchHandler()
396
+
397
+
###### Signature
398
+
399
+
```javascript
400
+
functionsetMergePatchHandler(newHandler)
401
+
```
402
+
403
+
###### Description
404
+
405
+
Sets the new user handler for NGSI-LD Entity [merge-patch](https://datatracker.ietf.org/doc/html/rfc7386) requests. This handler will be called whenever a merge-patch request arrives, with
406
+
the following parameters: (`id`, `type`, `service`, `subservice`, `attributes`, `callback`). The handler must retrieve
407
+
all the corresponding information from the devices and return a NGSI entity with the requested values.
408
+
409
+
The callback must be invoked with the updated Context Element, using the information retrieved from the devices. E.g.:
410
+
411
+
```javascript
412
+
callback(null, {
413
+
type:"TheType",
414
+
isPattern:false,
415
+
id:"EntityID",
416
+
attributes: [
417
+
{
418
+
name:"lumniscence",
419
+
type:"Lumens",
420
+
value:"432"
421
+
}
422
+
]
423
+
});
424
+
```
425
+
426
+
In the case of NGSI-LD requests affecting multiple entities, this handler will be
427
+
called multiple times. Since merge-patch is an advanced function, not all IoT Agents
428
+
will include a handler for merge-patch.
429
+
430
+
###### Params
431
+
432
+
- newHandler: User handler for merge-patch requests.
0 commit comments