Skip to content

Instantly share code, notes, and snippets.

@shiehnpin
Created August 10, 2020 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shiehnpin/5a89722a42a129b2861f73a138ca681a to your computer and use it in GitHub Desktop.
Save shiehnpin/5a89722a42a129b2861f73a138ca681a to your computer and use it in GitHub Desktop.
val conn = device.establishConnection(false)
conn
.flatMap(rxBleConnection -> rxBleConnection.setupNotification(battTxCharUuid))
.doOnNext(notificationObservable -> {
conn.writeCharacteristic(battRxCharUuid,cmd).subscribe();
})
.flatMap(notificationObservable -> notificationObservable) // <-- Notification has been set up, now observe value changes.
.subscribe(
bytes -> {
// Given characteristic has been changes, here is the value.
},
throwable -> {
// Handle an error here.
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment