telefonicaid/iotagent-json

Edit device by adding endpint does not convert device from pooling to push

AlvaroVega opened this issue · 4 comments

When a device with a command is provisioned like: (for pooling model)

{
"devices": [{
"device_id": "test27",
"protocol": "IoTA-JSON",
"entity_name": "test27",
"entity_type": "thing",
"transport":"HTTP",
"commands": [{
"name": "ping",
"type": "command"
}]
}]
}

and later is updated adding (for being push model)

"endpoint": "http://enf093fez2nfk.x.pipedream.net",

internal pooling device property is not updated to false, appearing in true

Similar bug is present in iotagent-ul

At provision time that check is performed by

function deviceProvisioningHandler(device, callback) {
if (!device.transport) {
device.transport = 'HTTP';
}
if (device.transport === 'HTTP') {
if (device.endpoint) {
device.polling = false;
} else {
device.polling = true;
}
}
callback(null, device);
}

Unfortunately there is not an equivalent handler for update device in iotagent-node-lib

In the mean time the workaround is delete that device and create again that device with proper endpoint value

Fixed by PR #603