예제 #1
0
        // Creates a new instance of NetworkServerConfiguration by reading values from environment variables
        public static IotEdgeConfiguration CreateFromEnviromentVariables()
        {
            var config = new IotEdgeConfiguration();

            // Create case insensitive dictionary from environment variables
            var envVars = new CaseInsensitiveEnvironmentVariables(Environment.GetEnvironmentVariables());

            config.Interval = envVars.GetEnvVar("INTERVAL", config.Interval);
            config.Decoder  = envVars.GetEnvVar("DECODER", string.Empty);

            return(config);
        }
예제 #2
0
        /// <summary>
        /// Initializes the ModuleClient and sets up the callback to receive
        /// messages containing temperature information
        /// </summary>
        static async Task Init()
        {
            AmqpTransportSettings amqpSetting = new AmqpTransportSettings(TransportType.Amqp_Tcp_Only);

            ITransportSettings[] settings = { amqpSetting };

            // Open a connection to the Edge runtime
            ioTHubModuleClient = await ModuleClient.CreateFromEnvironmentAsync(settings);

            await ioTHubModuleClient.OpenAsync();

            Console.WriteLine("IoT Hub module client initialized.");

            configuration = IotEdgeConfiguration.CreateFromEnviromentVariables();

            Console.WriteLine($"Interval set from ENV to: {configuration.Interval}");
            Console.WriteLine($"Decoder set from ENV to: {configuration.Decoder}");

            timer = new System.Threading.Timer(TimerCallback, null, configuration.Interval, configuration.Interval);
        }