Android DroneKit over Bluetooth

198 Views Asked by At

I currently purchased the 3DR bluetooth module for pixhawk to transfer telemetry data to an android phone. I am able to connect to the device, i.e. the bluetooth module turns solid red. However, the android program says that the phone and pixhawk are not connected. Here is my current connection setup.

protected void updateConnectedButton(Boolean isConnected) {
    Button connectButton = (Button)findViewById(R.id.btnConnect);
    connectButton.setText(isConnected ? "Disconnect" : "Connect");
}

public void onBtnConnectTap(View view) {
    if(drone.isConnected()) {
        drone.disconnect();
    } else {
        Bundle extraParams = new Bundle();
        extraParams.putInt(ConnectionType.EXTRA_USB_BAUD_RATE, DEFAULT_USB_BAUD_RATE); // Set default baud rate to 57600
        //connect with usb
        //ConnectionParameter connectionParams = new ConnectionParameter(ConnectionType.TYPE_USB, extraParams, null);
        ConnectionParameter connectionParams = new ConnectionParameter(ConnectionType.TYPE_BLUETOOTH,extraParams,null);
        drone.connect(connectionParams);
    }

    try {
        Thread.sleep(8000);
    } catch(InterruptedException e) {
    }

    updateConnectedButton(drone.isConnected());
}

If I remove the USB Baud rate setting, the red light on the device keeps blinking when I attempt to connect. I added a sleep because the bluetooth module takes a while to connect. The documentation and examples don't talk much about bluetooth connections. Any ideas what I am doing wrong?

0

There are 0 best solutions below