Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var hostName = '';
var deviceId = '';
var sharedAccessKey = '';
// String containing Hostname, Device Id & Device Key in the following formats:
// "HostName=;DeviceId=;SharedAccessKey="
var connectionString = 'HostName=' + hostName + ';DeviceId=' + deviceId + ';SharedAccessKey=' + sharedAccessKey;
// Sensor data
var temperature = 0;
var humidity = 0;
var externalTemperature = 0;
// Create IoT Hub client
var client = Client.fromConnectionString(connectionString, Protocol);
// Helper function to print results for an operation
function printErrorFor(op) {
return function printError(err) {
if (err) console.log(op + ' error: ' + err.toString());
};
}
// Send device meta data
var deviceMetaData = {
'ObjectType': 'DeviceInfo',
'IsSimulatedDevice': 0,
'Version': '1.0',
'DeviceProperties': {
'DeviceID': deviceId,
'HubEnabledState': 1,