BLE Reconnect는 AUTO CONNENCT를 true주는 거 밖에 reconnect안되나요?
bluetoothcallback에서 BluetoothProfile.STATE_DISCONNECTED경우 재연결 시도 하고 싶은데
어떻게 구현해야할지 모르겠어요
연결되었다가 connectgatt를 통해 재연결하니 이미 사용중이라는 logcat뜨는데 연결은 안되네요 ㅠㅠ
private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
if (newState == BluetoothProfile.STATE_CONNECTED) {
mState = STATE_CONNECTED;
mHandler.sendMessage(msg);
Log.d(TAG, "# Connected to GATT server.");
mHandler.obtainMessage(ServiceClass.MESSAGE_STATE_CHANGE, STATE_CONNECTED, 0).sendToTarget();
gatt.discoverServices();
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
mState = STATE_IDLE;
Log.d(TAG, "# Disconnected from GATT server.");
mHandler.obtainMessage(ServiceClass.MESSAGE_STATE_CHANGE, STATE_IDLE, 0).sendToTarget();
mBluetoothGatt = null;
mGattServices.clear();
mDefaultService = null;
mGattCharacteristics.clear();
mWritableCharacteristics.clear();
mDefaultChar = null;
mDefaultDevice = null;
connectgatt(deviceaddress);
}
}