O'Reilly logo

Mastering Internet of Things by Peter Waher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reacting to sensor data events

Any incoming events related to our subscription can be accessed through event handlers on the subscription object that is returned from the subscription request. To follow these events, we define three event handlers:

         this.subscription.OnStateChanged += 
               Subscription_OnStateChanged; 
         this.subscription.OnFieldsReceived += 
               Subscription_OnFieldsReceived; 
         this.subscription.OnErrorsReceived += 
               Subscription_OnErrorsReceived; 
   } 
} 

For two of these events, we will simply output their state to the event log, so we can follow the process:

private void Subscription_OnStateChanged(object Sender, SensorDataReadoutState NewState) { Log.Informational("Sensor subscription state changed.", NewState.ToString()); } private void ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required