Package ipfs.gomobile.android.bledriver

## Class PeerDevice

- java.lang.Object
- - ipfs.gomobile.android.bledriver.PeerDevice

-     public class PeerDevice
      extends java.lang.Object

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `PeerDevice.CONNECTION_STATE` |

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static java.lang.String` | `EOD` |
    `static int` | `L2CAP_BUFFER` |
    `static int` | `L2CAP_HANDSHAKE_DATA_LEN` |
    `static int` | `L2CAP_MPS` |
    `static int` | `MAX_MTU` |
    `java.lang.Object` | `mLockServer` |
    `int` | `STATUS_ERROR` |
    `int` | `STATUS_SUCCESS` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `PeerDevice​(android.content.Context context, BleDriver bleDriver, Logger logger, android.bluetooth.BluetoothDevice bluetoothDevice, java.lang.String localPID, boolean isClient)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `canUseL2cap()` |
    `boolean` | `checkAndSetServerState​(PeerDevice.CONNECTION_STATE state, PeerDevice.CONNECTION_STATE newState)` |
    `void` | `closeClient()` |
    `void` | `closeServer()` |
    `void` | `connectToDevice​(boolean autoConnect, java.util.concurrent.CountDownLatch countDown)` |
    `byte[]` | `createRandomBytes​(int len)` |
    `void` | `disconnect()` |
    `byte[]` | `flushInDataBuffer()` |
    `void` | `flushServerDataCache()` |
    `BleQueue` | `getBleQueue()` |
    `android.bluetooth.BluetoothDevice` | `getBluetoothDevice()` |
    `android.bluetooth.BluetoothSocket` | `getBluetoothSocket()` |
    `PeerDevice.CONNECTION_STATE` | `getClientState()` |
    `java.lang.String` | `getId()` |
    `byte[]` | `getInDataBuffer()` |
    `java.io.InputStream` | `getInputStream()` |
    `java.lang.String` | `getMACAddress()` |
    `int` | `getMtu()` |
    `java.io.OutputStream` | `getOutputStream()` |
    `Peer` | `getPeer()` |
    `java.lang.String` | `getRemotePID()` |
    `PeerDevice.CONNECTION_STATE` | `getServerState()` |
    `android.bluetooth.BluetoothGattCharacteristic` | `getWriterCharacteristic()` |
    `boolean` | `handleClientPIDReceived​(byte[] payload)` |
    `boolean` | `handleDataReceived​(byte[] payload)` |
    `boolean` | `handleServerPIDReceived​(byte[] payload)` |
    `boolean` | `internalWrite​(android.bluetooth.BluetoothGattCharacteristic characteristic, byte[] payload)` |
    `boolean` | `isClientConnected()` |
    `boolean` | `isClientDisconnected()` |
    `boolean` | `isServerConnected()` |
    `boolean` | `isServerDisconnected()` |
    `void` | `l2capRead()` |
    `boolean` | `l2capWrite​(byte[] payload)` |
    `void` | `putInDataBuffer​(byte[] value)` |
    `boolean` | `read​(android.bluetooth.BluetoothGattCharacteristic characteristic)` |
    `void` | `setBluetoothSocket​(android.bluetooth.BluetoothSocket bluetoothSocket)` |
    `void` | `setGattServer​(GattServer gattServer)` |
    `void` | `setId​(java.lang.String mId)` |
    `void` | `setInputStream​(java.io.InputStream inputStream)` |
    `void` | `setL2capServerHandshakeStarted​(boolean status)` |
    `void` | `setMtu​(int mtu)` |
    `void` | `setOutputStream​(java.io.OutputStream outputStream)` |
    `void` | `setPeer​(Peer peer)` |
    `void` | `setServerState​(PeerDevice.CONNECTION_STATE state)` |
    `java.lang.String` | `toString()` |
    `boolean` | `write​(android.bluetooth.BluetoothGattCharacteristic characteristic, byte[] payload, boolean withEOD)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### EOD

          public static final java.lang.String EOD

      See Also:
        Constant Field Values

    - #### MAX_MTU

          public static final int MAX_MTU

      See Also:
        Constant Field Values

    - #### L2CAP_BUFFER

          public static final int L2CAP_BUFFER

      See Also:
        Constant Field Values

    - #### L2CAP_MPS

          public static final int L2CAP_MPS

      See Also:
        Constant Field Values

    - #### L2CAP_HANDSHAKE_DATA_LEN

          public static final int L2CAP_HANDSHAKE_DATA_LEN

      See Also:
        Constant Field Values

    - #### STATUS_SUCCESS

          public final int STATUS_SUCCESS

      See Also:
        Constant Field Values

    - #### STATUS_ERROR

          public final int STATUS_ERROR

      See Also:
        Constant Field Values

    - #### mLockServer

          public final java.lang.Object mLockServer

  - ### Constructor Detail

    - #### PeerDevice

          public PeerDevice​(@NonNull
                            android.content.Context context,
                            @NonNull
                            BleDriver bleDriver,
                            @NonNull
                            Logger logger,
                            @NonNull
                            android.bluetooth.BluetoothDevice bluetoothDevice,
                            java.lang.String localPID,
                            boolean isClient)

  - ### Method Detail

    - #### setGattServer

          public void setGattServer​(GattServer gattServer)

    - #### getId

          public java.lang.String getId()

    - #### setId

          public void setId​(java.lang.String mId)

    - #### getBluetoothDevice

          public android.bluetooth.BluetoothDevice getBluetoothDevice()

    - #### getMACAddress

          public java.lang.String getMACAddress()

    - #### toString

          @NonNull
          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### getBluetoothSocket

          public android.bluetooth.BluetoothSocket getBluetoothSocket()

    - #### setBluetoothSocket

          public void setBluetoothSocket​(android.bluetooth.BluetoothSocket bluetoothSocket)

    - #### getInputStream

          public java.io.InputStream getInputStream()

    - #### setInputStream

          public void setInputStream​(java.io.InputStream inputStream)

    - #### getOutputStream

          public java.io.OutputStream getOutputStream()

    - #### setOutputStream

          public void setOutputStream​(java.io.OutputStream outputStream)

    - #### getInDataBuffer

          public byte[] getInDataBuffer()

    - #### flushInDataBuffer

          public byte[] flushInDataBuffer()

    - #### connectToDevice

          public void connectToDevice​(boolean autoConnect,
                                      java.util.concurrent.CountDownLatch countDown)

    - #### isClientConnected

          public boolean isClientConnected()

    - #### isClientDisconnected

          public boolean isClientDisconnected()

    - #### isServerDisconnected

          public boolean isServerDisconnected()

    - #### isServerConnected

          public boolean isServerConnected()

    - #### disconnect

          public void disconnect()

    - #### closeClient

          public void closeClient()

    - #### closeServer

          public void closeServer()

    - #### getClientState

          public PeerDevice.CONNECTION_STATE getClientState()

    - #### getServerState

          public PeerDevice.CONNECTION_STATE getServerState()

    - #### setServerState

          public void setServerState​(PeerDevice.CONNECTION_STATE state)

    - #### checkAndSetServerState

          public boolean checkAndSetServerState​(PeerDevice.CONNECTION_STATE state,
                                                PeerDevice.CONNECTION_STATE newState)

    - #### getWriterCharacteristic

          public android.bluetooth.BluetoothGattCharacteristic getWriterCharacteristic()

    - #### getRemotePID

          public java.lang.String getRemotePID()

    - #### getPeer

          public Peer getPeer()

    - #### setPeer

          public void setPeer​(Peer peer)

    - #### getBleQueue

          public BleQueue getBleQueue()

    - #### setL2capServerHandshakeStarted

          public void setL2capServerHandshakeStarted​(boolean status)

    - #### canUseL2cap

          public boolean canUseL2cap()

    - #### l2capRead

          public void l2capRead()

    - #### handleDataReceived

          public boolean handleDataReceived​(byte[] payload)

    - #### handleServerPIDReceived

          public boolean handleServerPIDReceived​(byte[] payload)

    - #### handleClientPIDReceived

          public boolean handleClientPIDReceived​(byte[] payload)

    - #### read

          public boolean read​(android.bluetooth.BluetoothGattCharacteristic characteristic)

    - #### l2capWrite

          public boolean l2capWrite​(byte[] payload)

    - #### internalWrite

          public boolean internalWrite​(android.bluetooth.BluetoothGattCharacteristic characteristic,
                                       byte[] payload)

    - #### write

          public boolean write​(android.bluetooth.BluetoothGattCharacteristic characteristic,
                               byte[] payload,
                               boolean withEOD)

    - #### createRandomBytes

          public byte[] createRandomBytes​(int len)

    - #### getMtu

          public int getMtu()

    - #### setMtu

          public void setMtu​(int mtu)

    - #### flushServerDataCache

          public void flushServerDataCache()

    - #### putInDataBuffer

          public void putInDataBuffer​(byte[] value)