Пример #1
0
        protected virtual void InitDeviceInfo(InitialDeviceConfig config)
        {
            dynamic initialDevice = SampleDeviceFactory.GetSampleSimulatedDevice(config.DeviceId, config.Key);

            DeviceProperties = DeviceSchemaHelper.GetDeviceProperties(initialDevice);
            Commands         = CommandSchemaHelper.GetSupportedCommands(initialDevice);
            Telemetry        = CommandSchemaHelper.GetTelemetrySchema(initialDevice);
            HostName         = config.HostName;
            PrimaryAuthKey   = config.Key;
        }
Пример #2
0
        /// <summary>
        /// Generates a DeviceInfo packet for a simulated device to send over the wire
        /// </summary>
        /// <returns></returns>
        public virtual dynamic GetDeviceInfo()
        {
            dynamic device = DeviceSchemaHelper.BuildDeviceStructure(DeviceID, true, null);

            device.DeviceProperties = DeviceSchemaHelper.GetDeviceProperties(this);
            device.Commands         = CommandSchemaHelper.GetSupportedCommands(this);
            device.Telemetry        = CommandSchemaHelper.GetTelemetrySchema(this);
            device.Version          = SampleDeviceFactory.VERSION_1_0;
            device.ObjectType       = SampleDeviceFactory.OBJECT_TYPE_DEVICE_INFO;

            // Remove the system properties from a device, to better emulate the behavior of real devices when sending device info messages.
            DeviceSchemaHelper.RemoveSystemPropertiesForSimulatedDeviceInfo(device);

            return(device);
        }