Skip to content

How to get services for the peripheral #138

Closed Answered by carillem
carillem asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Reedyuk, I figured out what I was missing after some fiddling last night. What I was doing was storing the connected device information immediately after connection and wasn't waiting for the discoverServices to be completed. So what I did was:

  • Updated DeviceEvent with a new data class:
data class OnServicesDiscovered(val btPeripheral: BluetoothPeripheral): BTDeviceEvent
  • Updated the didDiscoverServices function in Delegate to pass in the bluetoothPeripheral:
onDeviceEvent?.let {
            it(BTDeviceEvent.OnServicesDiscovered(bluetoothPeripheral))
        }
  • and then in my ViewModel, added a new case for the new event:
is BTDeviceEvent.OnServicesDiscovered -> {
log("in viewmo…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Reedyuk
Comment options

@carillem
Comment options

Answer selected by carillem
@Reedyuk
Comment options

@carillem
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants