@@ -5,9 +5,9 @@ Several XBee modules working together and communicating with each other form a
55network. XBee networks have different topologies and behaviors depending on the
66protocol of the XBee nodes that form it.
77
8- The XBee Python Library includes a class, called ``XBeeNetwork ``, that
9- represents the set of nodes forming the actual XBee network. This class allows
10- you to perform some operations related to the nodes.
8+ The XBee Python Library includes a class, called ``XBeeNetwork ``, to represent
9+ the set of nodes forming the actual XBee network. This class allows you to
10+ perform some operations related to the nodes.
1111
1212.. note ::
1313 There are ``XBeeNetwork `` subclasses for different protocols which correspond
@@ -66,8 +66,8 @@ There are two different types of discovery processes available in this API:
6666 (including quality) even if they are sleeping. It also allows to establish a
6767 number of rounds to continually explore the network.
6868
69- * :ref: `standardDiscovery ` only identifies network nodes. It may not
70- discover sleeping nodes.
69+ * :ref: `standardDiscovery ` only identifies network nodes. It may not discover
70+ sleeping nodes.
7171
7272See :ref: `discoverNetwork ` to know how to launch a deep or standard discovery
7373process.
@@ -114,17 +114,17 @@ Available modes are defined in the ``NeighborDiscoveryMode`` enumeration:
114114 saturate the network.
115115
116116The default discovery mode is **Cascade **. You can configure the discovery mode
117- with the method ``set_deep_discovery_options(NeighborDiscoveryMode, Boolean ) ``.
117+ with the method ``set_deep_discovery_options() ``.
118118
119119
120120.. _configDeepDiscoveryProcess :
121121
122122Configure the deep discovery process
123123````````````````````````````````````
124124
125- Before discovering the nodes of a network, you can configure the settings of
126- the process. The API provides two methods to configure the discovery timeout
127- and discovery options.
125+ Before discovering the nodes of a network, you can configure the settings of the
126+ process. The API provides two methods to configure the discovery timeout and
127+ discovery options.
128128
129129+----------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
130130| Method | Description |
@@ -190,9 +190,9 @@ The discovery process runs until the configured timeout expires or, in case of
190190Configure the standard discovery process
191191````````````````````````````````````````
192192
193- Before discovering the nodes of a network, you can configure the settings of
194- the process. The API provides two methods to configure the discovery timeout
195- and discovery options. These methods set the values in the radio module.
193+ Before discovering the nodes of a network, you can configure the settings of the
194+ process. The API provides two methods to configure the discovery timeout and
195+ discovery options. These methods set the values in the radio module.
196196
197197+--------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
198198| Method | Description |
@@ -261,11 +261,10 @@ following methods provided by the ``XBeeNetwork`` object:
261261
262262.. warning ::
263263 For a standard discovery and depending on your hardware and firmware version,
264- although you call the ``stop_discovery_process `` method, DigiMesh and
264+ although you call the ``stop_discovery_process() `` method, DigiMesh and
265265 DigiPoint modules are blocked until the configured discovery time has elapsed.
266266 This means, if you try to get or set any parameter during that time, a
267- ``TimeoutException `` may be thrown.
268- This does not occur for:
267+ ``TimeoutException `` may be thrown. This does not occur for:
269268
270269 * XBee 3 modules running DigiMesh firmware 300B or higher.
271270 * XBee SX modules running firmware A008 or higher, 9008 or higher.
@@ -334,9 +333,9 @@ The API also allows you to add a discovery event listener to notify when:
334333Notify new discovered nodes
335334'''''''''''''''''''''''''''
336335
337- To get notifications when nodes are discovered, you must provide a callback
338- before starting the discovery process using the
339- `` add_device_discovered_callback() `` method.
336+ To get notifications when nodes are discovered, provide a callback before
337+ starting the discovery process using the `` add_device_discovered_callback() ``
338+ method.
340339
341340**Add a callback to device discovered event **
342341
@@ -365,13 +364,14 @@ before starting the discovery process using the
365364 Every time a new remote XBee node is discovered all registered device discovered
366365callbacks are executed, even if the discovered node is already in the node list
367366of the network. Each callback receives a ``RemoteXBeeDevice `` as argument, with
368- all the available information. Unknown parameters of this remote node are ``None ``.
367+ all the available information. Unknown parameters of this remote node are
368+ ``None ``.
369369
370370Notify discovery finishes
371371'''''''''''''''''''''''''
372372
373- To get notifications when a discovery process finishes, you must provide a
374- callback before starting the discovery process using the
373+ To get notifications when a discovery process finishes, provide a callback
374+ before starting the discovery process using the
375375``add_discovery_process_finished_callback() `` method.
376376
377377**Add a callback to discovery process finished event **
@@ -411,8 +411,8 @@ Discover specific nodes
411411```````````````````````
412412
413413The ``XBeeNetwork `` object also provides methods to discover specific nodes
414- within a network. This may be useful, for example, if you only need to work
415- with a particular remote node.
414+ within a network. This may be useful, for example, to work with a particular
415+ remote node.
416416
417417+--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
418418| Method | Description |
@@ -668,8 +668,8 @@ Clear the list of remote XBee nodes from the XBee network
668668`````````````````````````````````````````````````````````
669669
670670The ``XBeeNetwork `` object also includes a method to clear the list of remote
671- nodes. This can be useful when you want to perform a clean discovery, cleaning
672- the list before calling the discovery method.
671+ nodes. This can be useful to perform a clean discovery, deleting the list before
672+ calling the discovery method.
673673
674674+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
675675| Method | Description |
@@ -706,12 +706,12 @@ the list before calling the discovery method.
706706Listen to network modification events
707707-------------------------------------
708708
709- When a discovery process finds new nodes that were not in the XBee network
710- list (``XBeeNetwork `` or a subclass), they are stored generating a modification
711- event in the XBee network object. A manual removal or addition of an XBee to the
709+ When a discovery process finds new nodes that were not in the XBee network list
710+ (``XBeeNetwork `` or a subclass), they are stored generating a modification event
711+ in the XBee network object. A manual removal or addition of an XBee to the
712712network also launches modification events.
713713
714- The XBee library notifies about these network list modification events to
714+ The XBee Python Library notifies about these network list modification events to
715715registered callbacks. These events inform about the following network
716716modifications:
717717
@@ -720,23 +720,23 @@ modifications:
720720* Update of nodes
721721* Network clear
722722
723- To receive any of these modification events you must provide a callback using
724- the ``add_network_modified_callback() `` method.
723+ To receive any of these modification events, provide a callback using the
724+ ``add_network_modified_callback() `` method.
725725This callback must follow the format:
726726
727727.. code :: python
728728
729- def my_callback (event_type , reason , node ):
730- """
731- Callback to notify about a new network modification event.
729+ def my_net_modified_callback (event_type , reason , node ):
730+ """
731+ Callback to notify about a new network modification event.
732732
733- Args:
734- event_type (:class:`.NetworkEventType`): The type of modification.
735- reason (:class:`.NetworkEventReason`): The cause of the modification.
736- node (:class:`.AbstractXBeeDevice`): The node involved in the
737- modification (``None`` for ``NetworkEventType.CLEAR`` events)
738- """
739- [... ]
733+ Args:
734+ event_type (:class:`.NetworkEventType`): The type of modification.
735+ reason (:class:`.NetworkEventReason`): The cause of the modification.
736+ node (:class:`.AbstractXBeeDevice`): The node involved in the
737+ modification (``None`` for ``NetworkEventType.CLEAR`` events)
738+ """
739+ [... ]
740740
741741 When a modification in the network list occurs, all network modification
742742callbacks are executed. Each callback receives the following arguments:
@@ -757,15 +757,15 @@ callbacks are executed. Each callback receives the following arguments:
757757
758758 # Define the network modified callback.
759759 def cb_network_modified (event_type , reason , node ):
760- print (" >>>> Network event:" )
761- print (" Type: %s (%d )" % (event_type.description, event_type.code))
762- print (" Reason: %s (%d )" % (reason.description, reason.code))
760+ print (" >>>> Network event:" )
761+ print (" Type: %s (%d )" % (event_type.description, event_type.code))
762+ print (" Reason: %s (%d )" % (reason.description, reason.code))
763763
764- if not node:
765- return
764+ if not node:
765+ return
766766
767- print (" Node:" )
768- print (" %s " % node)
767+ print (" Node:" )
768+ print (" %s " % node)
769769
770770 xnet = xbee.get_network()
771771
@@ -774,6 +774,28 @@ callbacks are executed. Each callback receives the following arguments:
774774
775775 [... ]
776776
777+ To stop listening to network modifications, use the
778+ ``del_network_modified_callback() `` method to unsubscribe the already-registered
779+ callback.
780+
781+ **Deregister a network modification callback **
782+
783+ .. code :: python
784+
785+ [... ]
786+
787+ def cb_network_modified (event_type , reason , node ):
788+ [... ]
789+
790+ xbee.add_network_modified_callback(cb_network_modified)
791+
792+ [... ]
793+
794+ # Delete the callback.
795+ xbee.del_network_modified_callback(cb_network_modified)
796+
797+ [... ]
798+
777799
778800 Network events
779801``````````````
0 commit comments