class StackPeer<T : StackService> : Peer<T>
A Peer (hub or node) that encapsulates a connection via a Stack including the StackConfig, StackService, Stack, and Bridge
key
- the BluetoothAddressNodeKey to use for this StackPeer
stackConfig
- the StackConfig of the Stack
stackService
- the StackService at the top of the Stack
linkupHandler
- the LinkupWithPeerNodeHandler used to link up the stack to golden gate stack services
peerConnector
- the PeerConnector used to connect the stack to the gatt layer
connectionStatusProvider
- provides an Observable stream which emits PeripheralConnectionStatus updates when provided a GattConnection
dtlsEventObservableProvider
- provides an Observable stream which emits DtlsProtocolStatus updates when provided a Stack
peerProvider
- a function which returns a BitGattPeer for a given GattConnection
mtuChangeRequesterProvider
- provides and MtuChangeRequester when provided an Int and a Stack
startMtu
- the default mtu used when connecting
connectTimeout
- timeout in TimeUnit.SECONDS when connecting
buildStack
- builds a Stack when provided a Bridge
buildBridge
- builds a Bridge when provided a BluetoothDevice
mtuRequestSubject
- used to inform an active connection of a desired mtu
stackEventObservableProvider
- provides an Observable stream which emits StackEvent updates when provided a Stack
stackEventHandlerProvider
- provides a StackEvent dispatcher for a given Stack and GattConnection
StackPeer(key: BluetoothAddressNodeKey, peerRole: PeerRole, stackConfig: StackConfig, stackService: T, connectionStatusProvider: (GattConnection) -> Observable<PeripheralConnectionStatus>, dtlsEventObservableProvider: (stack: Stack) -> Observable<DtlsProtocolStatus>)
Utility constructor for injecting connectionStatusProvider and dtlsEventObservableProvider used for status messages in the Host app |
val key: BluetoothAddressNodeKey
the BluetoothAddressNodeKey to use for this StackPeer |
|
val stackConfig: StackConfig
the StackConfig of the Stack |
val peerRole: PeerRole |
|
val stackService: T |
fun connection(): Observable<PeerConnectionStatus>
Get a reference to the connection of the Peer. If the Peer is not yet connected, it will connect upon subscription. The returned Observable will be shared for all callers connection until the connection is lost or disconnected. A successive call after disconnected will return a new Observable. Disposing the returned Observable will NOT disconnect the connection. This method should be Synchronized with disconnect and close |
|
fun disconnect(): Unit
Disconnects the Peer if currently connected. All subscribers of the current connection will have their disposables disposed. This method should be Synchronized with connection and close |