TinyOS code to set a Node as Root


According to a collection protocol a node has four roles : producer,consumer,snooper and in-network processor.Consumer is the root.

To set the node as the root the TinyOS code is

Node_RootC.nc

module Node_RootC 
{ 
 uses interface Boot; 
 uses interface Leds;  
 uses interface RootControl; 
} 

implementation 
{ 
 event void Boot.booted() 
 { 
                call RootControl.setRoot(); 
   
                if(call RootControl.isRoot()==TRUE) 
   call Leds.led0On(); 

                  
 } 
}

Node_RootAppC .nc
configuration Node_RootAppC 
{ 

} 

implementation 
{ 
 components MainC,LedsC,CollectionC,Node_RootC; 
 Node_RootC.Boot->MainC; 
 Node_RootC.Leds->LedsC; 
 Node_RootC.RootControl->CollectionC; 
}


Here RootControl.setRoot() command is used to set the node as Root and RootControl.isRoot() commands returns a boolean value. It returns TRUE when the node is root . It returns FALSE when the node is non-root.

Comments

Popular posts from this blog

bb.utils.contains yocto

Difference between RDEPENDS and DEPENDS in Yocto

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig