List of usage examples for android.bluetooth BluetoothProfile STATE_DISCONNECTED
int STATE_DISCONNECTED
To view the source code for android.bluetooth BluetoothProfile STATE_DISCONNECTED.
Click Source Link
From source file:org.bcsphere.bluetooth.BluetoothG43plus.java
private void disconnectManage(BluetoothGatt gatt, int newStatus) { String deviceAddress = getDeviceAddress(gatt); JSONObject obj = new JSONObject(); if (newStatus == BluetoothProfile.STATE_DISCONNECTED) { Tools.addProperty(obj, Tools.DEVICE_ADDRESS, getDeviceAddress(gatt)); disconnectCC.get(deviceAddress).success(obj); disconnectCC.remove(deviceAddress); connectedDevice.remove(deviceAddress); if (deviceServices.get(deviceAddress) != null) { deviceServices.remove(deviceAddress); }// w ww .j a v a2 s. c om mBluetoothGatts.remove(deviceAddress); } else { Tools.addProperty(obj, Tools.DEVICE_ADDRESS, deviceAddress); disconnectCC.get(deviceAddress).error(obj); disconnectCC.remove(deviceAddress); } }
From source file:br.liveo.ndrawer.ui.activity.MainActivity.java
License:asdf
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) public void connectToDevice(BluetoothDevice device) { try {/*ww w.ja va 2s.co m*/ int connState = mBluetoothManager.getConnectionState(device, BluetoothGatt.GATT); switch (connState) { case BluetoothGatt.STATE_CONNECTED: { if (mBluetoothAdapter == null) return; final BluetoothDevice leDevice = mBluetoothAdapter.getRemoteDevice((String) null); int connectionState = mBluetoothManager.getConnectionState(device, BluetoothProfile.GATT); if (mGatt != null) { if (connectionState != BluetoothProfile.STATE_DISCONNECTED) { mGatt.disconnect(); } } } break; case BluetoothGatt.STATE_DISCONNECTED: if (mGatt == null) { scanLeDevice(false); mGatt = device.connectGatt(this, false, gattCallback); } break; default: Log.i("connect to device : ", "device busy"); break; } } catch (Exception ex) { Log.i("Exception", "connectToDevice"); } }
From source file:br.liveo.ndrawer.ui.activity.MainActivity.java
License:asdf
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) public void disconnect(String address) { if (mBluetoothAdapter == null) return;/*from w w w.ja v a2 s . co m*/ final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address); int connectionState = mBluetoothManager.getConnectionState(device, BluetoothProfile.GATT); if (mGatt != null) { if (connectionState != BluetoothProfile.STATE_DISCONNECTED) { mGatt.disconnect(); } } }