oh how I love Java

Dirk Hohndel dirk at hohndel.org
Thu Jun 29 21:10:32 PDT 2017


On Fri, Jun 30, 2017 at 04:51:03AM +0300, Lubomir I. Ivanov wrote:
> On 30 June 2017 at 03:58, Dirk Hohndel <dirk at hohndel.org> wrote:
> > So how the heck do I get an int return value out of a JNI call???
> >
> > I've tried quite a few different variations of this
> >
> >                         // returns a BluetoothDevice
> >                         QAndroidJniObject dev=iterator.callObjectMethod("next","()Ljava/lang/Object;");
> >                         if (checkException("Iterator<BluetoothDevice>.next()", &dev)) {
> >                                 continue;
> >                         }
> >                         QAndroidJniObject typeObj = dev.callObjectMethod("getType", "()I");
> >
> > getType() returns an int. I want to check if this is an LE-only device.
> >
> 
> untested:
> 
> http://doc.qt.io/qt-5/qandroidjniobject.html#callMethod
> 
> jint type_jni = dev.callMethod<jint>("getType");
> int type_c = (int)type_jni;
> 
> ^
> https://android.googlesource.com/platform/libnativehelper/+/master/include/nativehelper/jni.h#35

Yup, that did the trip.

Thanks, Lubomir.

Linus, here's what I get when trying to connect to the Perdix from
Android:

06-29 21:06:19.846 21696 21941 D /data/newandroid/subsurface/qt-models/messagehandlermodel.cpp: INFO: getDetectedDeviceAddress "LE:E4:3B:31:49:F5:D0"
06-29 21:06:19.846 21696 21941 D /data/newandroid/subsurface/qt-models/messagehandlermodel.cpp: INFO: getDeviceDescriptorVendor "Shearwater"
06-29 21:06:19.847 21696 21941 D /data/newandroid/subsurface/qt-models/messagehandlermodel.cpp: INFO: getDeviceDescriptorProduct "Perdix"
06-29 21:06:19.847 21696 21941 D /data/newandroid/subsurface/qt-models/messagehandlermodel.cpp: INFO: "167.298: DCDownloadThread started for LE:E4:3B:31:49:F5:D0"
06-29 21:06:19.847 21696 22485 D /data/newandroid/subsurface/qt-models/messagehandlermodel.cpp: INFO: Starting download from  BT
06-29 21:06:19.847 21696 22485 D /data/newandroid/subsurface/qt-models/messagehandlermodel.cpp: INFO: Starting the thread 0
06-29 21:06:19.857 21696 22485 D /data/newandroid/subsurface/qt-models/messagehandlermodel.cpp: INFO: Creating Android Central/Client support for BTLE
06-29 21:06:19.858 21696 22485 D /data/newandroid/subsurface/qt-models/messagehandlermodel.cpp: INFO: qt_ble_open( E4:3B:31:49:F5:D0 )
06-29 21:06:19.861 21696 22485 D BluetoothGatt: connect() - device: E4:3B:31:49:F5:D0, auto: false
06-29 21:06:19.861 21696 22485 D BluetoothGatt: registerApp()
06-29 21:06:19.862 21696 22485 D BluetoothGatt: registerApp() - UUID=1c2df551-a6b5-4f6a-a655-4765dca617da
06-29 21:06:19.863 23293 23360 D BtGatt.GattService: registerClient() - UUID=1c2df551-a6b5-4f6a-a655-4765dca617da
06-29 21:06:19.863 23293 23315 D BtGatt.GattService: onClientRegistered() - UUID=1c2df551-a6b5-4f6a-a655-4765dca617da, clientIf=23
06-29 21:06:19.863 21696 22485 W QtBluetoothGatt: Using Android v23 BluetoothDevice.connectGatt()
06-29 21:06:19.864 21696 21943 D BluetoothGatt: onClientRegistered() - status=0 clientIf=23
06-29 21:06:19.864 23293 23304 D BtGatt.GattService: clientConnect() - address=E4:3B:31:49:F5:D0, isDirect=true
06-29 21:06:19.865 23293 23315 D bt_btif_config: btif_get_address_type: Device [e4:3b:31:49:f5:d0] address type 1
06-29 21:06:19.865 23293 23315 D bt_btif_config: btif_get_device_type: Device [e4:3b:31:49:f5:d0] type 2
06-29 21:06:19.865 23293 23328 E bt_btif : Connection open failure
06-29 21:06:19.865 23293 23315 D BtGatt.GattService: onConnected() - clientIf=23, connId=0, address=E4:3B:31:49:F5:D0
06-29 21:06:19.865 21696 21708 D BluetoothGatt: onClientConnectionState() - status=133 clientIf=23 device=E4:3B:31:49:F5:D0
06-29 21:06:19.865 21696 21708 D BluetoothGatt: close()
06-29 21:06:19.865 21696 21708 D BluetoothGatt: unregisterApp() - mClientIf=23
06-29 21:06:19.866 23293 23306 D BtGatt.GattService: unregisterClient() - clientIf=23
06-29 21:06:19.866 21696 21708 W QtBluetoothGatt: Unhandled error code on connectionStateChanged: 133 0
06-29 21:06:19.874 21696 22485 D /data/newandroid/subsurface/qt-models/messagehandlermodel.cpp: INFO: Connection updated: error: QLowEnergyController::Error(133) oldState: QLowEnergyController::ControllerState(ConnectingState) newState: QLowEnergyController::ControllerState(UnconnectedState)
06-29 21:06:19.965 21696 22485 D /data/newandroid/subsurface/qt-models/messagehandlermodel.cpp: INFO: failed to connect to the controller  E4:3B:31:49:F5:D0 with error "Error occurred trying to connect to remote device."
06-29 21:06:19.965 21696 22485 D /data/newandroid/subsurface/core/libdivecomputer.c: INFO: dc_deveice_open error value of -6
06-29 21:06:19.965 21696 22485 D /data/newandroid/subsurface/qt-models/messagehandlermodel.cpp: INFO: Finishing the thread Insufficient privileges to open the device %s %s (%s) dives downloaded 0
06-29 21:06:19.966 21696 21941 D /data/newandroid/subsurface/qt-models/messagehandlermodel.cpp: INFO: "167.417: DCDownloadThread finished"
06-29 21:06:20.144  6361  6502 D BluetoothAdapter: isLeEnabled(): ON


Any ideas / suggestions?

/D


More information about the subsurface mailing list