Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function deviceIsReady(dev) {
lamp.setIotHubDevice(dev);
if (!dev.authentication || !dev.authentication.SymmetricKey) {
return;
}
//create Azure IoT Hub conn string for a device
var connStr = "HostName=" + iothubRegistry.config.host + ";CredentialScope=Device;DeviceId=" + dev.deviceId + ";SharedAccessKey=" + dev.authentication.SymmetricKey.primaryKey;
lamp.setIotHubConnectionString(connStr);
//set client
iothubClient = new iothubDev.Client(connStr, new iothub.Https());
//register metadata first
var metadataMsg = new iothubDev.Message(JSON.stringify(lamp.getMetadata()));
iothubClient.sendEvent(metadataMsg, printResultFor('send'));
// start telemetry data send routing
setInterval(sendTelemetryData, 10000);
//listen for notif
setInterval(function () {
if (!isWaiting) waitForNotifications();
}, 1000);
}