How to use the iotagent-node-lib.getDevice function in iotagent-node-lib

To help you get started, we’ve selected a few iotagent-node-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Atos-Research-and-Innovation / IoTagent-LoRaWAN / lib / iotagent-lora.js View on Github external
winston.error(errorMessage, JSON.stringify(iotaError));
                        } else {
                            winston.info('Observations sent to CB successfully for device ', deviceId);
                        }
                    });
                } else {
                    errorMessage = 'Could not cast message to NGSI';
                    winston.error(errorMessage);
                }
            } else {
                errorMessage = 'Unexpected error';
                winston.error(errorMessage);
            }
        });
    } else {
        iotAgentLib.getDevice(deviceId, deviceObject.service, deviceObject.subservice, function (error, device) {
            if (error) {
                errorMessage = 'Error getting IoTA device object';
                winston.error(errorMessage, JSON.stringify(error));
            } else if (device) {
                winston.info('IOTA provisioned devices:', JSON.stringify(device));
                var ngsiMessage = dataTranslation.toNgsi(message, device);
                if (ngsiMessage && ngsiMessage instanceof Array && ngsiMessage.length > 0) {
                    iotAgentLib.update(device.name, device.type, '', ngsiMessage, device, function (iotaError) {
                        if (iotaError) {
                            errorMessage = 'Couldn\'t send the updated values to the Context Broker due to an error:';
                            winston.error(errorMessage, JSON.stringify(iotaError));
                        } else {
                            winston.info('Observations sent to CB successfully for device ', deviceId);
                        }
                    });
                } else {