Home/Support/Support Forum/Python, XBee3: How to get a add_packet_received_callback(my_packet_received_callback) stop after first reception
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Python, XBee3: How to get a add_packet_received_callback(my_packet_received_callback) stop after first reception

0 votes
Python, XBee3: How to get an "add_packet_received_callback(my_packet_received_callback)" to stop after first reception.

right now I have it in a while loop like so:

while True:

# Add the callback.
local_device.add_packet_received_callback(my_packet_received_callback)
time.sleep(2)
#
local_device.del_packet_received_callback(my_packet_received_callback)
This is triggered because on my xbee router device the join notification is enabled (JN=1)

When it receives the api packet it runs the callback function.

Right now it seems to trigger multiple times during the notification sending process from the router device .i want it to just receive one packet and then stop.

using the delete callback worked for a different callback I used recently.. but for this one it doesn't seem to receive ONE packet, do what I want and then stop and wait for a different packet.. instead it triggers when it gets the notification packet, and then keeps getting triggered by the same notification packet.
asked Aug 7 in Python by edunn106 New to the Community (22 points)
recategorized Aug 7 by mvut

Please log in or register to answer this question.

1 Answer

0 votes
You need to use a Non Blocking mode.

http://cms.digi.com/resources/documentation/digidocs/90002219/#tasks/t_set_timeout.htm?Highlight=None%20blocking
answered Aug 11 by mvut Veteran of the Digi Community (13,094 points)
the above post is the nonblocking data reception callback.. the other option from the xbee python library, is headlined as "polling" which is said to be blocking.
You are trying to put your receive into a Non blocking mode right? If so, the above link should do it.
...