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

Konashi の電源を落とした場合 KonashiListener#onError() は呼ばれるが KonashiListener#onDisconnect() が呼ばれない。 #110

Closed
kiryuxxu opened this issue Oct 2, 2015 · 1 comment
Assignees
Labels

Comments

@kiryuxxu
Copy link
Contributor

kiryuxxu commented Oct 2, 2015

BluetoothGattCallback#onConnectionStateChange() の仕様を見ると

public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState)

Added in API level 18
Callback indicating when GATT client has connected/disconnected to/from a remote GATT server.

Parameters
gatt GATT client
status Status of the connect or disconnect operation. GATT_SUCCESS if the operation succeeds.
newState Returns the new connection state. Can be one of STATE_DISCONNECTED or STATE_CONNECTED
https://developer.android.com/intl/ja/reference/android/bluetooth/BluetoothGattCallback.html#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)

なので Bletia の実装を status != GATT_SUCCES && newState == STATE_DISCONNECTED の場合も onDisconnect() とするべきではないでしょうか?

BluetoothGattCallbackHandler.class

    public void onConnectionStateChange(BluetoothGattWrapper gatt, int status, int newState) {
        if(status == 0) {
            if(newState == 2) {
                this.mCallback.onConnect(gatt);
            }

            if(newState == 0) {
                this.mCallback.onDisconnect(gatt);
            }
        } else {
            this.mCallback.onError(new BletiaException(BleErrorType.valueOf(status)));
        }
    }
@izumin5210
Copy link
Collaborator

ありがとうございます
Bletia側で対応しておきます

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants