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 being disowned

Similarly, we must detect if the device becomes disowned while it is online. This is done by listening to the Disowned event on the ThingRegistry instance:

this.registryClient.Disowned += async (sender, e) => 
{ 
   try 
   { 
         await RuntimeSettings.SetAsync("ThingRegistry.Owner", 
               string.Empty); 
         await this.RegisterDevice(); 
   } 
   catch (Exception ex) 
   { 
         Log.Critical(ex); 
   } 
}; 
There are some other minor changes made in the code between SensorXmpp2 and ActuatorXmpp2 compared to SensorXmpp and ActuatorXmpp that reflect the asynchronous nature of initializing the devices with provisioning. You can view the changes in the GitHub project source code, by comparing the App.xaml.cs files of the corresponding projects.

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