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

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.

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.

You need to use a Non Blocking mode.

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.