@Test public void isBlueReader_True() { // :: Setup ActiveBluetoothDevice mock = new ActiveBluetoothDevice(); mock.name = "blueReader"; mock.save(); // :: Act boolean isBlueReader = blueReader.isblueReader(); // :: Verify assertThat(isBlueReader).isTrue(); }
public static synchronized boolean is_connected() { ActiveBluetoothDevice activeBluetoothDevice = ActiveBluetoothDevice.first(); return (activeBluetoothDevice != null && activeBluetoothDevice.connected); }
@Override public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) { if (newState == BluetoothProfile.STATE_CONNECTED) { mBluetoothGatt = gatt; mConnectionState = STATE_CONNECTED; ActiveBluetoothDevice.connected(); Log.i(TAG, "Connected to GATT server."); Log.i(TAG, "Connection state: Bonded - " + device.getBondState()); if (device.getBondState() == BluetoothDevice.BOND_BONDED) { currentGattTask = GATT_SETUP; mBluetoothGatt.discoverServices(); } else { device.setPin("000000".getBytes()); device.createBond(); } } else if (newState == BluetoothProfile.STATE_DISCONNECTED) { mConnectionState = STATE_DISCONNECTED; ActiveBluetoothDevice.disconnected(); Log.w(TAG, "Disconnected from GATT server."); } }
public void onClick(View v) { if(mBluetoothManager != null && ActiveBluetoothDevice.first() != null) { final BluetoothAdapter bluetoothAdapter = mBluetoothManager.getAdapter(); if(bluetoothAdapter != null) { for( BluetoothDevice bluetoothDevice : bluetoothAdapter.getBondedDevices()) { if(bluetoothDevice.getAddress().compareTo(ActiveBluetoothDevice.first().address) == 0) { try { Method m = bluetoothDevice.getClass().getMethod("removeBond", (Class[]) null); ActiveBluetoothDevice.forget(); bluetoothAdapter.disable();
servicesDiscovered = DISCOVERED.PENDING; ActiveBluetoothDevice.connected();
private synchronized void handleDisconnectedStateChange() { if (JoH.ratelimit("handle-disconnected-state-change", 2)) { mConnectionState = STATE_DISCONNECTED; ActiveBluetoothDevice.disconnected();
l.add(new StatusItem("Active device connected", String.valueOf(ActiveBluetoothDevice.is_connected()))); l.add(new StatusItem("Bluetooth GATT", String.valueOf(mBluetoothGatt)));
@Test public void isBlueReader_False() { // :: Setup ActiveBluetoothDevice mock = new ActiveBluetoothDevice(); mock.name = "someOtherDevice"; mock.save(); // :: Act boolean isBlueReader = blueReader.isblueReader(); // :: Verify assertThat(isBlueReader).isFalse(); }
public static synchronized boolean is_connected() { ActiveBluetoothDevice activeBluetoothDevice = ActiveBluetoothDevice.first(); return (activeBluetoothDevice != null && activeBluetoothDevice.connected); }
@Override public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) { if (newState == BluetoothProfile.STATE_CONNECTED) { mBluetoothGatt = gatt; mConnectionState = STATE_CONNECTED; ActiveBluetoothDevice.connected(); Log.i(TAG, "Connected to GATT server."); Log.i(TAG, "Connection state: Bonded - " + device.getBondState()); if (device.getBondState() == BluetoothDevice.BOND_BONDED) { currentGattTask = GATT_SETUP; mBluetoothGatt.discoverServices(); } else { device.setPin("000000".getBytes()); device.createBond(); } } else if (newState == BluetoothProfile.STATE_DISCONNECTED) { mConnectionState = STATE_DISCONNECTED; ActiveBluetoothDevice.disconnected(); Log.w(TAG, "Disconnected from GATT server."); } }
public void onClick(View v) { if(mBluetoothManager != null && ActiveBluetoothDevice.first() != null) { final BluetoothAdapter bluetoothAdapter = mBluetoothManager.getAdapter(); if(bluetoothAdapter != null) { for( BluetoothDevice bluetoothDevice : bluetoothAdapter.getBondedDevices()) { if(bluetoothDevice.getAddress().compareTo(ActiveBluetoothDevice.first().address) == 0) { try { Method m = bluetoothDevice.getClass().getMethod("removeBond", (Class[]) null); ActiveBluetoothDevice.forget(); bluetoothAdapter.disable();
servicesDiscovered = DISCOVERED.PENDING; ActiveBluetoothDevice.connected();
private synchronized void handleDisconnectedStateChange() { if (JoH.ratelimit("handle-disconnected-state-change", 2)) { mConnectionState = STATE_DISCONNECTED; ActiveBluetoothDevice.disconnected();
l.add(new StatusItem("Active device connected", String.valueOf(ActiveBluetoothDevice.is_connected()))); l.add(new StatusItem("Bluetooth GATT", String.valueOf(mBluetoothGatt)));
@Test public void isBlueReader_False() { // :: Setup ActiveBluetoothDevice mock = new ActiveBluetoothDevice(); mock.name = "someOtherDevice"; mock.save(); // :: Act boolean isBlueReader = blueReader.isblueReader(); // :: Verify assertThat(isBlueReader).isFalse(); }
public static synchronized boolean is_connected() { ActiveBluetoothDevice activeBluetoothDevice = ActiveBluetoothDevice.first(); return (activeBluetoothDevice != null && activeBluetoothDevice.connected); }
device = mBluetoothGatt.getDevice(); mConnectionState = STATE_CONNECTED; ActiveBluetoothDevice.connected(); Log.i(TAG, "Connected to GATT server."); ActiveBluetoothDevice.disconnected(); if(shouldDisconnect) { stopSelf();