{"action":"opened","issue":{"url":"https://api.github.com/repos/YUKAI/konashi-android-sdk/issues/110","labels_url":"https://api.github.com/repos/YUKAI/konashi-android-sdk/issues/110/labels{/name}","comments_url":"https://api.github.com/repos/YUKAI/konashi-android-sdk/issues/110/comments","events_url":"https://api.github.com/repos/YUKAI/konashi-android-sdk/issues/110/events","html_url":"https://github.com/YUKAI/konashi-android-sdk/issues/110","id":109425274,"number":110,"title":"Konashi の電源を落とした場合 KonashiListener#onError() は呼ばれるが KonashiListener#onDisconnect() が呼ばれない。","user":{"login":"kiryuxxu","id":12708655,"avatar_url":"https://avatars.githubusercontent.com/u/12708655?v=3","gravatar_id":"","url":"https://api.github.com/users/kiryuxxu","html_url":"https://github.com/kiryuxxu","followers_url":"https://api.github.com/users/kiryuxxu/followers","following_url":"https://api.github.com/users/kiryuxxu/following{/other_user}","gists_url":"https://api.github.com/users/kiryuxxu/gists{/gist_id}","starred_url":"https://api.github.com/users/kiryuxxu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiryuxxu/subscriptions","organizations_url":"https://api.github.com/users/kiryuxxu/orgs","repos_url":"https://api.github.com/users/kiryuxxu/repos","events_url":"https://api.github.com/users/kiryuxxu/events{/privacy}","received_events_url":"https://api.github.com/users/kiryuxxu/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/YUKAI/konashi-android-sdk/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-02T03:51:05Z","updated_at":"2015-10-02T03:51:05Z","closed_at":null,"body":"BluetoothGattCallback#onConnectionStateChange() の仕様を見ると\r\n\r\n> public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState)\r\n>\r\n> Added in API level 18\r\n> Callback indicating when GATT client has connected/disconnected to/from a remote GATT server.\r\n>\r\n> Parameters\r\n> gatt    GATT client\r\n> status  Status of the connect or disconnect operation. GATT_SUCCESS if the operation succeeds.\r\n> newState    Returns the new connection state. Can be one of STATE_DISCONNECTED or STATE_CONNECTED\r\n> https://developer.android.com/intl/ja/reference/android/bluetooth/BluetoothGattCallback.html#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)\r\n\r\nなので Bletia の実装を `status != GATT_SUCCES && newState == STATE_DISCONNECTED` の場合も `onDisconnect()` とするべきではないでしょうか?\r\n\r\nBluetoothGattCallbackHandler.class\r\n```java\r\n    public void onConnectionStateChange(BluetoothGattWrapper gatt, int status, int newState) {\r\n        if(status == 0) {\r\n            if(newState == 2) {\r\n                this.mCallback.onConnect(gatt);\r\n            }\r\n\r\n            if(newState == 0) {\r\n                this.mCallback.onDisconnect(gatt);\r\n            }\r\n        } else {\r\n            this.mCallback.onError(new BletiaException(BleErrorType.valueOf(status)));\r\n        }\r\n    }\r\n```"}}