Example #1
0
        /// <summary>
        /// Registers the current device using the Device Provisioning Service and assigns it to an IoT hub.
        /// </summary>
        /// <param name="data">
        /// The optional additional data that is passed through to the custom allocation policy webhook if
        /// a custom allocation policy webhook is setup for this enrollment.
        /// </param>
        /// <param name="timeout">The maximum amount of time to allow this operation to run for before timing out.</param>
        /// <remarks>
        /// Due to the AMQP library used by this library uses not accepting cancellation tokens, this overload and <see cref="RegisterAsync(TimeSpan)"/>
        /// are the only overloads for this method that allow for a specified timeout to be respected in the middle of an AMQP operation such as opening
        /// the AMQP connection. MQTT and HTTPS connections do not share that same limitation, though.
        /// </remarks>
        /// <returns>The registration result.</returns>
        public Task <DeviceRegistrationResult> RegisterAsync(ProvisioningRegistrationAdditionalData data, TimeSpan timeout)
        {
            Logging.RegisterAsync(this, _globalDeviceEndpoint, _idScope, _transport, _security);

            var request = new ProvisioningTransportRegisterMessage(_globalDeviceEndpoint, _idScope, _security, data?.JsonData)
            {
                ProductInfo = ProductInfo,
            };

            return(_transport.RegisterAsync(request, timeout));
        }
Example #2
0
        /// <summary>
        /// Registers the current device using the Device Provisioning Service and assigns it to an IoT Hub.
        /// </summary>
        /// <param name="data">The custom content.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>The registration result.</returns>
        public Task <DeviceRegistrationResult> RegisterAsync(ProvisioningRegistrationAdditionalData data, CancellationToken cancellationToken)
        {
            if (Logging.IsEnabled)
            {
                Logging.RegisterAsync(this, _globalDeviceEndpoint, _idScope, _transport, _security);
            }

            var request = new ProvisioningTransportRegisterMessage(_globalDeviceEndpoint, _idScope, _security, data?.JsonData);

            request.ProductInfo = ProductInfo;
            return(_transport.RegisterAsync(request, cancellationToken));
        }
 /// <summary>
 /// Registers the current device using the Device Provisioning Service and assigns it to an IoT Hub.
 /// </summary>
 /// <param name="data">The optional additional data.</param>
 /// <returns>The registration result.</returns>
 public Task <DeviceRegistrationResult> RegisterAsync(ProvisioningRegistrationAdditionalData data)
 {
     return(RegisterAsync(data, CancellationToken.None));
 }