Dynamically add new device or invoke new driver using applicaiton

Developer
Jun 19, 2014 at 12:12 PM
Hey!

1- Is there anyway so that I can invoke new driver using my application or use GetDevices() in my application so that I can add new device without moving to add device page ?
2- Is there anyway that we can add new device as soon as it is plugged into the home hub instead of polling based mechanism ?
Coordinator
Jun 19, 2014 at 4:46 PM

1. To properly set up a device, a couple of functions need to be called on the backend. Normally, this workflow starts when you click on a discovered device and ends at the AddDeviceFinalDeviceSetup page. The functions are called by the Dashboard (HTML/JS dashboard), main functions are StartDriver() and ConfigureDeviceWeb() in Platform\GuiService.cs.

To bypass the dashboard, you’ll have to call these functions from your application. You could start by making the rest calls that the Dashboard makes to the Platform. The URL will be something like http://localhost:51430/<homeid>/GuiWeb/webapp/<function-name> and pack the function parameters like they are packed by the dashboard (JSON).

Note that StartDriver only takes a uniqueDeviceId as parameter, not the identity of the driver. This works because the scout is expected to inform the platform of the driver to use for a deviceId. Make sure that this has happened for your device before calling StartDriver. The dummy scout/driver are good places to understand what goes on and how to replicate that functionality without the Dashboard.

2. Devices are not automatically today for two reasons:

a. Not all devices discovered by a scout are expected to the added to the HomeHub

b. Some device specific configuration is needed (e.g., the device name and which applications can use it)

In your setting, however, you can make the assumptions you want and automatically add devices as soon as they are discovered. How the discovery happens depends on the scout – it does not have to be polling. If your device is plugging in over USB, I believe that you can register with Windows to get a callback when USB devices are plugged in. If that works, the Scout needs to call ProcessNewDiscoveryResults() on the platform to tell it about the device. Then, to the get device fully functional, StartDriver() and ConfigureDeviceWeb() should be somehow called.

Cheers.