From the xbee python library I am using the provided network modification callback function:
def my_callback(event_type, reason, node):
Callback to notify about a new network modification event.
event_type (:class:`.NetworkEventType`): The type of modification.
reason (:class:`.NetworkEventReason`): The cause of the modification.
node (:class:`.AbstractXBeeDevice`): The node involved in the
modification (``None`` for ``NetworkEventType.CLEAR`` events)
# Define the network modified callback.
def cb_network_modified(event_type, reason, node):
print(" >>>> Network event:")
print(" Type: %s (%d)" % (event_type.description, event_type.code))
print(" Reason: %s (%d)" % (reason.description, reason.code))
if not node:
print(" %s" % node)
xnet = local_device.get_network()
then add the callback:
So, it prints out stuff accordingly when I add or update a device... so that's good. But my question is as follows:
How to have it also tell you when a device is powered off.. like I connect a device, then I unplug it's power cord... and it doesn't tell me about this event. I need to know that a device is shut off, retrieve that device's info, and remove it from the network in anticipation of a different device being connected in its place.
How to have the network modification callback function tell you when a device on the network just shut off.. it should right? because it is removed from the network.. but Im guessing that the program still see's that device in the xbeeNetwork object or cache or something...?
That's not useful to have a device that is not connected somehow remain in existence in the network object cache? A ghost node.
Let me know if I have explained my question well enough..