Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
IvBaranov committed Nov 25, 2015
1 parent 3aadfb7 commit 26bb4f7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,34 @@ BluetoothAdapter.SCAN_MODE_CONNECTABLE
BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE
```

#### Getting the profile proxy object

```java
rxBluetooth.observeBluetoothProfile(this, myProfile)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(new Action1<ServiceEvent>() {
@Override public void call(ServiceEvent serviceEvent) {
switch (serviceEvent.getState()) {
case CONNECTED:
BluetoothProfile bluetoothProfile = serviceEvent.getBluetoothProfile();
//..
break;
case DISCONNECTED:
//serviceEvent.getBluetoothProfile() returns null
break;
}
}
});
```

`myProfile` can be one of `BluetoothProfile.HEALTH`, `BluetoothProfile.HEADSET`, `BluetoothProfile.A2DP`, `BluetoothProfile.GATT` or `BluetoothProfile.GATT_SERVER`

Clients should close profile proxy when they are no longer using the proxy obtained from `observeBluetoothProfile`:
```java
rxBluetooth.closeProfileProxy(int profile, BluetoothProfile proxy);
```

Download
--------
```groovy
Expand Down

0 comments on commit 26bb4f7

Please sign in to comment.