I have written an Android app using the groundsdk to connect to the SkyController 3 remote control and then scan for drones and connect to the drone on click.
I am testing with two drones and one remote control and one Android phone as whenever I try to reconnect to one of the drones the connection attempt fails. So I can connect to the first drone successfully, then disconnect and connect to the second drone successfully but if I connect to the first drone, disconnect and then try and connect again the connect call fails, so it does not even reach the CONNECTING state.
I can reproduce this issue with the groundsdk Android demo app but do not see any such issue when using FreeFlight 6.
Is this a bug in the SDK or is there some additional logic I am missing?
When a drone is connected through a RemoteControl (SkyController3), it loses its ability to disconnect by itself. To effectively disconnect it, you have the following options:
- disconnect the remote control itself
- forget the drone
- connect to another drone using the same RemoteControl, in which case the current drone will be disconnected by the remote control in order to connect to the next.
Actually, when connected to a RemoteControl, a drone disconnect() method will always return false. So let’s consider your case in detail to see what happens and what the final state is:
- You connect your first drone (A) through the remote control. This works OK and the drone is connected.
- You call disconnect() on drone A. Since it is connected through the remote control, the method returns false and nothing happens: Drone A remains connected.
- You call connect() on drone A again. The method returns false and nothing happens since the drone is still connected. That is why it won’t reach the CONNECTING state since it is already in CONNECTED state.
Hope this answers your question,