Add instruction if device-discovery-cli is not installed

This commit is contained in:
formulahendry 2016-11-07 20:52:40 +08:00
Родитель 3ff7372d19
Коммит 0ce0ed95ca
3 изменённых файлов: 15 добавлений и 3 удалений

Просмотреть файл

@ -26,7 +26,7 @@ Toolkit makes Azure IoT Development easier
| List device | Ctrl+Alt+F1 | editor/context |
| Create device | Ctrl+Alt+F2 | editor/context |
| Delete device | Ctrl+Alt+F3 | editor/context |
| Discover device | Ctrl+Alt+F6 | editor/context |
| Discover connected device | Ctrl+Alt+F6 | editor/context |
## Usages
@ -84,6 +84,9 @@ By default, anonymous telemetry data collection is turned on to understand user
```
## Change Log
### 0.0.4
* Add instruction if device-discovery-cli is not installed
### 0.0.3
* Discover Ethernet, USB serial, WiFi devices

Просмотреть файл

@ -2,7 +2,7 @@
"name": "azure-iot-toolkit",
"displayName": "Azure IoT Toolkit",
"description": "Iteract with Azure IoT Hub; IoT Device Management; Discover Ethernet, USB serial, WiFi connected devices",
"version": "0.0.3",
"version": "0.0.4",
"publisher": "formulahendry",
"icon": "images/logo.png",
"engines": {

Просмотреть файл

@ -6,6 +6,7 @@ import { Utility } from './utility';
import { AppInsightsClient } from './appInsightsClient';
import { BaseExplorer } from './baseExplorer';
const types = ['eth', 'usb', 'wifi'];
const devdisco = 'devdisco';
export class DeviceDiscoverer extends BaseExplorer {
private _deviceStatus = {};
@ -26,8 +27,9 @@ export class DeviceDiscoverer extends BaseExplorer {
}
private deviceDiscovery(label: string, type: string): void {
let process = exec(`devdisco list --${type}`);
let process = exec(`${devdisco} list --${type}`);
let startTime = new Date();
let devdiscoNotFound = false;
process.stdout.on('data', (data) => {
this._outputChannel.append(data);
@ -35,6 +37,9 @@ export class DeviceDiscoverer extends BaseExplorer {
process.stderr.on('data', (data) => {
this._outputChannel.append(data);
if (data.indexOf(devdisco) >= 0) {
devdiscoNotFound = true;
}
});
process.on('close', (code) => {
@ -42,6 +47,10 @@ export class DeviceDiscoverer extends BaseExplorer {
let elapsedTime = (endTime.getTime() - startTime.getTime()) / 1000;
this._appInsightsClient.sendEvent(`${label}.${type}`, { Code: code.toString() });
this.outputLine(label, 'Finished with exit code=' + code + ' in ' + elapsedTime + ' seconds');
if (devdiscoNotFound && code >= 1) {
this.outputLine(label, '[Note!!!] Please install device-discovery-cli with below command if not yet:');
this.outputLine(label, 'npm install --global device-discovery-cli');
}
});
}
}