Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bluetooth] BluetoothUtils.toIntArray throwing type mismatch error from [Bluetooth.Airthings] (introduced in commit #13967) #15313

Closed
dw-8 opened this issue Jul 27, 2023 · 5 comments · Fixed by #15320 or #15891
Labels
bug An unexpected problem or unintended behavior of an add-on

Comments

@dw-8
Copy link
Contributor

dw-8 commented Jul 27, 2023

Current Behavior

With the recent changes made in commit #13967, the call to updateChannels(BluetoothUtils.toIntArray(data)) within org.openhab.binding.bluetooth.airthings.internal.AbstractAirthingsHandler is now silently failing for an Airthings Wave Gen 1.

This call is not converting the Byte data to Int data so sensor data is not getting updated.

Adding additional logging returned the following error message:

java.lang.ArrayStoreException: arraycopy: type mismatch: can not copy byte[] into int[]
	at java.lang.System.arraycopy(Native Method) ~[?:?]

Expected Behavior

This call converts the Byte data to Int data and updates the sensor data

New code (commit #13967)

    public static int[] toIntArray(byte[] value) {
        int[] ret = new int[value.length];
        System.arraycopy(value, 0, ret, 0, value.length);
        return ret;
    }

Previous code

    public static int[] toIntArray(byte[] value) {
        if (value == null) {
            return null;
        }
        int[] ret = new int[value.length];
        for (int i = 0; i < value.length; i++) {
            ret[i] = value[i];
        }
        return ret;
    }

Reverting this commit back to the original code restores the functionality for Airthings Wave Gen 1.

Your Environment

Debian 10 amd64
openHab 4.0
Zulu Embedded Java 17

@dw-8 dw-8 added the bug An unexpected problem or unintended behavior of an add-on label Jul 27, 2023
jlaur pushed a commit to jlaur/openhab-addons that referenced this issue Jul 28, 2023
Fixes openhab#15313

Partially reverts openhab#13967

Signed-off-by: Jacob Laursen <[email protected]>
jlaur pushed a commit to jlaur/openhab-addons that referenced this issue Jul 28, 2023
Fixes openhab#15313

Partially reverts openhab#13967

Signed-off-by: Jacob Laursen <[email protected]>
jlaur added a commit to jlaur/openhab-addons that referenced this issue Jul 28, 2023
Fixes openhab#15313

Partially reverts openhab#13967

Signed-off-by: Jacob Laursen <[email protected]>
@jlaur
Copy link
Contributor

jlaur commented Jul 28, 2023

@dw-8 - thanks for your issue and detailed analysis. With that analysis I was able to quickly provide a pull request for reverting to the last known working state of the code. We aim to get this into a 4.0.1 hotfix release.

@jlaur jlaur changed the title [Bluetooth]: BluetoothUtils.toIntArray throwing type mismatch error from [Bluetooth.Airthings] (introduced in commit #13967) [Bluetooth] BluetoothUtils.toIntArray throwing type mismatch error from [Bluetooth.Airthings] (introduced in commit #13967) Jul 28, 2023
kaikreuzer pushed a commit that referenced this issue Jul 28, 2023
Fixes #15313

Partially reverts #13967

Signed-off-by: Jacob Laursen <[email protected]>
kaikreuzer pushed a commit that referenced this issue Jul 28, 2023
Fixes #15313

Partially reverts #13967

Signed-off-by: Jacob Laursen <[email protected]>
@jlaur
Copy link
Contributor

jlaur commented Jul 28, 2023

@dw-8 - can you test org.openhab.binding.bluetooth-4.1.0-SNAPSHOT.jar just to be sure everything is working as expected?

@dw-8
Copy link
Contributor Author

dw-8 commented Jul 28, 2023

@dw-8 - can you test org.openhab.binding.bluetooth-4.1.0-SNAPSHOT.jar just to be sure everything is working as expected?

@jlaur - After deleting the original bluetooth binding, dropping in your jar file, and restarting OH, it is now working as expected.

@jlaur
Copy link
Contributor

jlaur commented Jul 28, 2023

@jlaur - After deleting the original bluetooth binding, dropping in your jar file, and restarting OH, it is now working as expected.

Thanks! Now you can revert that and upgrade to 4.0.1. 😉

@dw-8
Copy link
Contributor Author

dw-8 commented Nov 13, 2023

Re-opening this bug as it looks like @lsiepel reverted this bug fix inside #15828

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
2 participants