android 6+ How to connect wii balance board?

393
January 04, 2017, at 06:04 AM

I made an Android app that connected and readed input fine with Wii balance board, based on Fitscales code. My app worked like a charm with SDK 15 & 16 until Android 4.4 (KitKat), when Android stopped the Wii support. Wii support is now re-enabled, starting with Android 5.1.1. I have also implemented the new permission scheme for obtaining Bluetooth connectivity permissions (inlcuded ACCESS_COARSE_LOCATION)

My problem is that I can't read Wii balance board input anymore.

I can discover, create socket and when connecting to socket I receive the message: read failed, socket might closed or timeout, read ret: -1

Answer that helped me so far and not working anymore:

Create wiimote socket

How to connect

Some code:

private BluetoothSocket createBluetoothSocket(
        int type, int fd, boolean auth, boolean encrypt, String address, int port){
    try {
        Constructor<BluetoothSocket> constructor = BluetoothSocket.class.getDeclaredConstructor(
                int.class, int.class,boolean.class,boolean.class,String.class, int.class);
        constructor.setAccessible(true);
        BluetoothSocket clientSocket = constructor.newInstance(type,fd,auth,encrypt,address,port);
        return clientSocket;
    } catch (Exception e) {
        Log.v(TAG,"createBluetoothSocket failed: "+errorMsg(e));
        return null;
    }
}   

private connectWii(String MAC) {
    try {
        // MAC is the MAC address of Wiiboard
        int TYPE_L2CAP=3;
        sk = createBluetoothSocket(TYPE_L2CAP, -1, false,false, MAC, 0x13);
        // this fires read failed, socket might closed or timeout, read ret: -1
        sk.connect();
    } catch (Exception e) {
        Log.v(TAG,"Failed : "+errorMsg(e));
    }
}

Thank for your help in advance.

READ ALSO
Convert char into KeyEvent on Android

Convert char into KeyEvent on Android

I cannot manage to get a character recognized by the KeyEventkeyCodeToString(keyEvent) function

253
Is it possible to pass image as argument through intent to activity?

Is it possible to pass image as argument through intent to activity?

Is it possible to pass an Image as an extra to an activity? For Strings it's working this way:

250
Canvas&#39; clearRect() weird bug detected

Canvas' clearRect() weird bug detected

I am drawing 200 pictures per requestAnimationFrame() on the following code:

358
Does launching a new activity destroy my networking Service/AsyncTasks?

Does launching a new activity destroy my networking Service/AsyncTasks?

I am tinkering and building on Google's own WifiDirect code (https://androidgooglesource

236