telefonicaid / telefonicaid/iotagent-node-lib

[New feature] Commands for auto-provisioned devices

Open
#656 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
62
Forks
90
Avg merge
2h 35m
Merged PRs (30d)
1

Description

The issue is not considered a bug but a new feature. It has to be assessed if its possible.
The new feature should allow to add commands to auto-provisioned devices.

1.- El envío de comandos hacia dispositivos "autoprovisionados" a través del envío de una medida no funciona correctamente:

Los dispositivos pueden autoprovisionarse enviando una medida UL2.0 directamente y el propio IoT Agent se encarga de crear la entidad correspondiente en el CB con el id de entidad = "type_entity:id_device".

Ejemplo:

POST /iot/d?k=t3ftmt5e1pj9cdws5hzlalpky&i=deviceNodeMCU3&getCmd=1 HTTP/1.1
Host: XXXX:YYY
Content-Type: text/plain
Accept: application/json
Cache-Control: no-cache
Postman-Token: 8e35bfba-7474-4705-b54e-b12222a6eab8

temp|25#hr|75
El IoT Agent está configurado para que los dispositivos se autoprovisionen en el CB como "entity_type = esp8266". Por lo tanto, el envío de la medida del dispositivo "deviceNodeMCU3" crea la entidad en el CB con el id = "esp8266:deviceNodeMCU3". 
A este dispositivo le definimos el comando "name:led" y "type:command" desde la interfaz de Thinking Cities y se crean los atributos "led_info" y "led_status" en el CB.
Cuando se intenta enviar un comando desde el propio portal normalmente se queda en estado "ERROR" y con info "There was an error in the response of a device to a command []:Error: options.uri is a required argument ", en algunos casos, los menos, parece que el comando se almacena y el "status" indica "PENDING", pero el comando no se puede recuperar desde el dispositivo usando la opción de "pull", por ejemplo usando la misma petición anterior sin payload. Actualmente la entidad "esp8266:device_dvm1" se encuentra en este estado.

Cuando el dispositivo se provisiona con una entidad que no tiene los ":" en el id el envío de comandos funciona correctamente. 
El uso de los ":" en el autoprovisionamiento genera algún conflicto que no permite que el comando llegue correctamente al dispositivo?
La creación del atributo tipo "command" es correcto y se crean el "..info" y "..status", pero no funciona el envío de comandos. "..status" siempre da error cuando se quiere escribir un comando. 
Cuando lo intento con la API pasa lo mismo. He probando a hacer la consulta PUT:

https://{{host}}:10027/v2/entities/esp8266%3AdeviceNodeMCU4/attrs/led?type=esp8266

y

https://{{host}}:10027/v2/entities/esp8266:deviceNodeMCU4/attrs/led?type=esp8266

ambas con el payload:
{
    "value":"led:off",
    "type": "command"

}

Pero no funciona, el "..status" pone "ERROR" y "..info" arroja "There was an error in the response of a device to a command []:Error: options.uri is a required argument ". 
Creo que es debido a que la entidad asociada a un dispositivo autoprovisionando incluye el caracter ":" en el id.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing command creation and retrieval for an auto-provisioned entity such as esp8266:deviceNodeMCU3, comparing the encoded and unencoded entity-ID requests shown in the issue. Trace the command path from the /iot/d?getCmd=1 pull request and the NGSI PUT to the command status and info response; done means commands reach colon-containing auto-provisioned devices without the reported options.uri error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.