Connection state listener

How do I create a listener for the anafi connection state?
This is what I have tried but it does not seem to work:

import olympe
from olympe.messages.drone_manager import connection_state

class FlightListener(olympe.EventListener):
def on_connection_change(self, event, scheduler):
print(“Connection changed!!”)

Hi !

The “connection_state” is an event message sent by a SkyController to Olympe but you have to be connected to a SkyController first. Moreover, you can’t listen to any event if you are not currently connected to a device (a drone or a SkyController).

For the drone_manager feature messages, you should have a look at this usage example: .

Once you have connected controller object (either an olympe.Drone or an olympe.SkyController object) you can attach a listener to it.

Thank you for your help. I had missed the documentation part that said that it was only available while connected to the SkyController.

Just a follow up…
I instead ended up in polling the drone.connection_state() function. However, this function now bloats my console with printouts since it will print out the state every time I call it. I put an issue on github on you, to kindly remote this print.