Initializing the Device

This topic explains how to initialize the device information, add a service to it, and start the device stack.

The static class Dpws.Device.Device represents the device stack itself. This class provides infrastructure functionality for DPWS-enabled devices as well as acting as the host for services you write. Include a call to Dpws.Device.Device.Start in your application’s main class to start the DPWS device stack.

The Device class also serves to contain parameters used by the device stack, such as the device’s endpoint address. The Device.ThisModel class contains information specific to the device model, such as the model name and model number, and the Device.ThisDevice class contains information specific to the device itself, such as serial number. Your Main method should set these as appropriate, using code like the following.

      // Set device information (in Main)
      Device.EndpointAddress = "http://localhost:1234";
      Device.ThisModel.Manufacturer = "Microsoft Corporation";
      Device.ThisModel.ManufacturerUrl = "";
      Device.ThisModel.ModelName = "SampleService Test Device";
      Device.ThisModel.ModelNumber = "12021345";
      Device.ThisModel.ModelUrl = "";
      Device.ThisModel.PresentationUrl = "";

      Device.ThisDevice.FriendlyName = "SampleService Device";
      Device.ThisDevice.FirmwareVersion = "alpha";
      Device.ThisDevice.SerialNumber = "12345678";

      // add a service
      Device.HostedServices.Add(typeof(TestService), typeof(ITestService), new Uri("http://localhost:1234/TestService/"));

      // Start the device stack