BluetoothPeripheral { public boolean readRemoteRssi() { boolean result = commandQueue.add(new Runnable() { @Override public void run() { if (isConnected()) { if (!bluetoothGatt.readRemoteRssi()) { Timber.e("readRemoteRssi failed"); completedCommand(); } } else { Timber.e("cannot get rssi, peripheral not connected"); completedCommand(); } } }); if (result) { nextCommand(); } else { Timber.e("could not enqueue setNotify command"); } return result; } BluetoothPeripheral(@NotNull Context context, @NotNull BluetoothDevice device, @NotNull InternalCallback listener, BluetoothPeripheralCallback peripheralCallback, Handler callbackHandler); boolean createBond(); boolean requestConnectionPriority(final int priority); void cancelConnection(); @NotNull String getAddress(); int getType(); String getName(); int getBondState(); @SuppressWarnings("WeakerAccess") @NotNull List<BluetoothGattService> getServices(); @Nullable BluetoothGattService getService(@NotNull UUID serviceUUID); @Nullable BluetoothGattCharacteristic getCharacteristic(@NotNull UUID serviceUUID, @NotNull UUID characteristicUUID); int getState(); int getCurrentMtu(); boolean isNotifying(@NotNull BluetoothGattCharacteristic characteristic); boolean readCharacteristic(@NotNull final BluetoothGattCharacteristic characteristic); boolean writeCharacteristic(@NotNull final BluetoothGattCharacteristic characteristic, @NotNull final byte[] value, final int writeType); boolean readDescriptor(@NotNull final BluetoothGattDescriptor descriptor); boolean writeDescriptor(@NotNull final BluetoothGattDescriptor descriptor, @NotNull final byte[] value); boolean setNotify(@NotNull final BluetoothGattCharacteristic characteristic, final boolean enable); boolean clearServicesCache(); boolean readRemoteRssi(); boolean requestMtu(final int mtu); @SuppressWarnings("WeakerAccess")
    static final int GATT_SUCCESS; @SuppressWarnings("WeakerAccess")
    static final int GATT_CONN_L2C_FAILURE; @SuppressWarnings("WeakerAccess")
    static final int GATT_CONN_TIMEOUT; @SuppressWarnings("WeakerAccess")
    static final int GATT_READ_NOT_PERMITTED; @SuppressWarnings("WeakerAccess")
    static final int GATT_WRITE_NOT_PERMITTED; @SuppressWarnings("WeakerAccess")
    static final int GATT_INSUFFICIENT_AUTHENTICATION; @SuppressWarnings("WeakerAccess")
    static final int GATT_REQUEST_NOT_SUPPORTED; @SuppressWarnings("WeakerAccess")
    static final int GATT_INSUFFICIENT_ENCRYPTION; @SuppressWarnings("WeakerAccess")
    static final int GATT_CONN_TERMINATE_PEER_USER; @SuppressWarnings("WeakerAccess")
    static final int GATT_CONN_TERMINATE_LOCAL_HOST; @SuppressWarnings("WeakerAccess")
    static final int GATT_CONN_LMP_TIMEOUT; @SuppressWarnings("WeakerAccess")
    static final int BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE; @SuppressWarnings("WeakerAccess")
    static final int GATT_CONN_FAIL_ESTABLISH; @SuppressWarnings("WeakerAccess")
    static final int GATT_NO_RESOURCES; @SuppressWarnings("WeakerAccess")
    static final int GATT_INTERNAL_ERROR; @SuppressWarnings("WeakerAccess")
    static final int GATT_BUSY; @SuppressWarnings("WeakerAccess")
    static final int GATT_ERROR; @SuppressWarnings("WeakerAccess")
    static final int GATT_AUTH_FAIL; @SuppressWarnings("WeakerAccess")
    static final int GATT_CONN_CANCEL; @SuppressWarnings("WeakerAccess")
    static final int DEVICE_TYPE_UNKNOWN; @SuppressWarnings("WeakerAccess")
    static final int DEVICE_TYPE_CLASSIC; @SuppressWarnings("WeakerAccess")
    static final int DEVICE_TYPE_LE; @SuppressWarnings("WeakerAccess")
    static final int DEVICE_TYPE_DUAL; @SuppressWarnings("WeakerAccess")
    static final int BOND_NONE; @SuppressWarnings("WeakerAccess")
    static final int BOND_BONDING; @SuppressWarnings("WeakerAccess")
    static final int BOND_BONDED; @SuppressWarnings("WeakerAccess")
    static final int STATE_DISCONNECTED; @SuppressWarnings("WeakerAccess")
    static final int STATE_CONNECTING; @SuppressWarnings("WeakerAccess")
    static final int STATE_CONNECTED; @SuppressWarnings("WeakerAccess")
    static final int STATE_DISCONNECTING; }
@Test public void readRemoteRSSITest() { BluetoothGattCallback callback = connectAndGetCallback(); callback.onConnectionStateChange(gatt, GATT_SUCCESS, STATE_CONNECTED); peripheral.readRemoteRssi(); verify(gatt).readRemoteRssi(); callback.onReadRemoteRssi(gatt, -40, 0); verify(peripheralCallback).onReadRemoteRssi(peripheral, -40, 0); }