private void Timer_Tick(ThreadPoolTimer timer) { var temperature = TemperatureSensorConfig.GetSensorMeasurement(); var windspeed = WindspeedSensorConfig.GetSensorMeasurement(); var barometricPressure = BarometricPressureSensorConfig.GetSensorMeasurement(); var connectionParams = new ConnectionParameters(ConnectionConfig.ServiceBusNamespace, ConnectionConfig.EventHubName, ConnectionConfig.PolicyName, ConnectionConfig.PolicyKey, ConnectionConfig.PublisherName, ConnectionConfig.TokenTimeToLive); var httpSender = new HttpSender(connectionParams); Debug.WriteLine("Sending temperature to event hub via HTTP"); var temperatureResult = httpSender.Send(temperature); Debug.WriteLine(string.Format("Temperature sent via HTTP ({0}).", temperatureResult.ToString())); Debug.WriteLine("Sending wind speed to event hub via HTTP"); var windspeedResult = httpSender.Send(windspeed); Debug.WriteLine(string.Format("Wind speed sent via HTTP ({0}).", windspeedResult.ToString())); Debug.WriteLine("Sending barometric pressure to event hub via HTTP"); var barometricPressureResult = httpSender.Send(barometricPressure); Debug.WriteLine(string.Format("Barometric pressure sent via HTTP ({0}).", barometricPressureResult.ToString())); }
public void SendTest() { var measurement = MeasurementTestConfig.GetSensorMeasurement(); var connectionParameters = new ConnectionParameters(ConnectionTestParameters.ServiceBusNamespace, ConnectionTestParameters.EventHubName, ConnectionTestParameters.PolicyName, ConnectionTestParameters.PolicyKey, ConnectionTestParameters.PublisherName, ConnectionTestParameters.TokenTimeToLive); var httpSender = new HttpSender(connectionParameters); var result = httpSender.Send(measurement); Assert.AreEqual(SendResult.Success, result); }
static private void EnsureSender() { if (sender == null) { // Create connection params var connectionParams = new ConnectionParameters( "jbienzms", // Service Bus Name "sensornet", // Event Hub Name "sender", // Policy Name "oRvc8a3dul1cI7DLz4SfTan2KRnO10/ZxvqxqCj6LHY=", // Policy Key "DeviceTester", // Publisher Name TimeSpan.FromSeconds(20) // Auth Token Time To Live ); // Create sender sender = new HttpSender(connectionParams); } }
private void InitializeEventHubSettings() { connectionParams = new ConnectionParameters( App.Current.ApplicationConfiguration.ServiceBusNamespace, App.Current.ApplicationConfiguration.EventHubName, App.Current.ApplicationConfiguration.PolicyName, App.Current.ApplicationConfiguration.PolicyKey, App.Current.ApplicationConfiguration.PublisherName, App.Current.ApplicationConfiguration.TokenTimeToLive); eventHubSender = new HttpSender(connectionParams); }