Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Workaround for https://github.com/microsoft/vscode-azure-iot-toolkit/issues/331
setTimeout(() => {
vscode.commands.executeCommand("azure-iot-toolkit.refresh");
}, 500);
}
}
TelemetryClient.sendEvent(eventName, { Result: result }, iotHubConnectionString);
this.outputLine(label, `[${op}][${result}] status: ${res.statusCode} ${res.statusMessage}`, outputChannel);
}
if (deviceInfo) {
if (deviceInfo.authentication.SymmetricKey.primaryKey != null) {
deviceInfo.connectionString = ConnectionString.createWithSharedAccessKey(hostName,
deviceInfo.deviceId, deviceInfo.authentication.SymmetricKey.primaryKey);
}
if (deviceInfo.authentication.x509Thumbprint.primaryThumbprint != null) {
deviceInfo.connectionString = ConnectionString.createWithX509Certificate(hostName, deviceInfo.deviceId);
}
this.outputLine(label, `[${op}] device info: ${JSON.stringify(deviceInfo, null, 2)}`, outputChannel);
resolve(deviceInfo);
}
resolve();
};
}
deviceList.forEach((device, index) => {
let image = device.connectionState.toString() === "Connected" ? "device-on.png" : "device-off.png";
let deviceConnectionString = "";
if (device.authentication.SymmetricKey.primaryKey != null) {
deviceConnectionString = ConnectionString.createWithSharedAccessKey(hostName, device.deviceId,
device.authentication.SymmetricKey.primaryKey);
} else if (device.authentication.x509Thumbprint.primaryThumbprint != null) {
deviceConnectionString = ConnectionString.createWithX509Certificate(hostName, device.deviceId);
}
devices.push(new DeviceItem(device.deviceId,
deviceConnectionString,
this.context.asAbsolutePath(path.join("resources", image)),
{
command: "azure-iot-toolkit.getDevice",
title: "",
arguments: [device.deviceId],
}));
});
resolve(devices);
deviceList.forEach((device, index) => {
let deviceConnectionString: string = "";
if (device.authentication.SymmetricKey.primaryKey != null) {
deviceConnectionString = DeviceConnectionString.createWithSharedAccessKey(hostName, device.deviceId,
device.authentication.SymmetricKey.primaryKey);
} else if (device.authentication.x509Thumbprint.primaryThumbprint != null) {
deviceConnectionString = DeviceConnectionString.createWithX509Certificate(hostName, device.deviceId);
}
devices.push(new DeviceItem(device.deviceId,
deviceConnectionString,
null,
device.connectionState.toString(),
null));
});
resolve(devices.sort((a: DeviceItem, b: DeviceItem) => { return a.deviceId.localeCompare(b.deviceId); }));