Hi all,
I'm working with the basic asynchronous logging example (https://github.com/bitcraze/crazyflie-l ... asiclog.py) and trying to 1) keep trying to make an initial connection until it finds a Crazyflie, and 2) keep trying to reconnect if the logger has lost connection to a previously connected Crazyflie. I got 1) to work by just adding a while loop in the __init__ of the logger and closing and opening the link until it connects, but I'm not sure how to achieve 2). Is there any chance somebody of you has worked on this before? Thanks!
Jesse
Code for automatic reconnect
Re: Code for automatic reconnect
Hi Jesse!
You could try to work with the callbacks that are there! Everytime you disconnect from a Crazyflie the function ...
... will be called so you can take action to reconnect.
You could try to work with the callbacks that are there! Everytime you disconnect from a Crazyflie the function ...
Code: Select all
def _disconnected(self, link_uri):
"""Callback when the Crazyflie is disconnected (called in all cases)"""
print('Disconnected from %s' % link_uri)
self.is_connected = False
Re: Code for automatic reconnect
Hi Jonas,
Thanks! Using the callbacks gave me recursive reconnection attempts, but creating a separate reconnect function that is called in an outside loop worked for me.
Thanks! Using the callbacks gave me recursive reconnection attempts, but creating a separate reconnect function that is called in an outside loop worked for me.