What are the arguments needed for ConnectionParameter?

117 Views Asked by At

I've been following 3DR Dronekit-Android step-by-step project to create a mission planner app on Android Studio. I am stuck on creating a method for connecting via UDP.

extraParams.putInt(ConnectionType.EXTRA_UDP_SERVER_PORT, DEFAULT_UDP_PORT);
ConnectionParameter connectionParameter = new ConnectionParameter(ConnectionType.TYPE_UDP,extraParams, null);
drone.connect(connectionParameter);

I get an error message on ConnectionParameter as below

ConnectionParameter(int, android.os.Bundle, androind.net.Uri)' has private access in 'com.o3dr.services.android.lib.drone.connection.ConnectionParameter'

What are the arguments needed for ConnectionParameter? Is there any other way for me to find out required parameters in java libraries?

1

There are 1 best solutions below

0
On

This is because the library has been changed, now, it follows the Singleton design pattern.

You don't need to create a new ConnectionParameter but to directly call the static method newUsbConnection() or newUdpConnection() in the ConnectionParameter class as follow:

int selectedConnectionType = connectionSelector.getSelectedItemPosition();
ConnectionParameter connectionParams = selectedConnectionType == ConnectionType.TYPE_USB
    ? ConnectionParameter.newUsbConnection(null)
    : ConnectionParameter.newUdpConnection(null);