Skip to content

0.36.0

Latest
Compare
Choose a tag to compare
@github-actions github-actions released this 08 Feb 08:25
· 2 commits to refs/heads/main since this release
98acf44

πŸš€ Changes

Peripheral.scope property

To be more explicit, Peripheral's CoroutineScope has been moved to the scope property on the Peripheral:

Old New
peripheral.launch {      
    // ..
}
peripheral.scope.launch {      
    // ..
}
peripheral.cancel()      
peripheral.close()
// or..
peripheral.scope.cancel()      

Peripheral AutoCloseable

Peripheral now implements AutoCloseable if you need to use a Peripheral for a quick/short task:

// `peripheral` will automatically `close` after the `use` block.
peripheral.use {
    it.connect()
    it.write(..)
    it.disconnect()
}

Connection scope on Connected state

The Connected state now carries the active connection CoroutineScope. Previously, the connection CoroutineScope was only available from the return of the connect function, but now it is also available from the Connected state, for example:

peripheral.state
    .filterIsInstance<State.Connected>()
    .onEach { (connectionScope) ->
        // `connectionScope` is automatically cancelled on disconnect
        connectionScope.launch {
            // ..
        }
    }
    .launchIn(peripheral.scope)

Standard library Uuid

Kable now uses UUIDs as provided by the Kotlin standard library. Be sure and update your imports and Uuid usages appropriately, for example:

Old New
import com.benasher44.uuid.Uuid
import com.juul.kable.Options
import com.juul.kable.requestPeripheral

val options = Options {
  filters {
    match {
      services = listOf(
        uuidFrom("0000aa80-0000-1000-8000-00805f9b34fb"),
      )
    }
  }
  // ..
}
import com.juul.kable.Bluetooth
import com.juul.kable.Options
import com.juul.kable.requestPeripheral

val options = Options {
  filters {
    match {
      services = listOf(
        Bluetooth.BaseUuid + 0xAA80,
      )
    }
  }
  // ..
}
import com.juul.kable.descriptorOf

val descriptor = descriptorOf(
    service = "00001815-0000-1000-8000-00805f9b34fb",
    characteristic = "00002a56-0000-1000-8000-00805f9b34fb",
    descriptor = "00002902-0000-1000-8000-00805f9b34fb",
)
import com.juul.kable.Bluetooth
import com.juul.kable.descriptor
import com.juul.kable.descriptorOf
import kotlin.uuid.Uuid

val descriptor = descriptorOf(
    service = Bluetooth.BaseUuid + 0x1815,
    characteristic = Bluetooth.BaseUuid + 0x2A56,
    descriptor = Uuid.descriptor("gatt.client_characteristic_configuration"),
)

Common

  • Allow filtering by company ID only (#855), thanks to @tsuijten for reporting
  • Propagate unknown onScanFailed error codes as IllegalStateExceptions (#851), thanks to @mjordan-gpfw for reporting
  • Expose connection scope on State.Connected (#852)
  • Provide Peripheral CoroutineScope via scope property (#846)
  • Convert discovered services, characteristics, descriptors to interfaces (#839), thanks to @UnknownJoe796 for reporting
  • Support Web Bluetooth named UUIDs (#835)
  • Move GattRequestRejectedException to common (#838), thanks to @francismariano for reporting
  • Allow for advertisement manufacturer data length to exceed filter data mask length (#842), thanks to @eygraber for reporting
  • Expose Android GATT status Int on GattStatusException (#836), thanks to @joharei for reporting
  • Create copy of observations in Observers.onConnected (#841), thanks to @eygraber for reporting
  • Fix error string for GATT_INVALID_ATTRIBUTE_LENGTH (#831), thanks to @angusholder for the contribution
  • Use Uuid from Kotlin standard library (#758), thanks to @ykws for the contribution

Logo Android

  • Simplify "client characteristic config" UUID definition (#837)

Logo Apple

  • Support 32-bit (8 hex characters) CBUUIDs (#834), thanks to @liamzhouacc for reporting

🧰 Maintenance

  • Update "maven central" badge to use kable-core artifact (#823)
  • Update plugin dokka to v2 (#845)
  • Update dependency gradle to v8.12.1 (#816, #821, #848)
  • Update dependency org.jetbrains.kotlinx:kotlinx-io-core to v0.6.0 (#820)
  • Update plugin android-library to v8.8.0 (#812, #832)
  • Update plugin kotlinter to v5.0.1 (#818)
  • Update coroutines to v1.10.1 (#819)
  • Update dependency org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom to v2025.1.6 (#807, #825, #828, #833, #844)
  • Update plugin maven-publish to v0.30.0 (#826)
  • Update dependency com.juul.khronicle:khronicle-core to v0.5.1 (#813, #824)
  • Update dependency nl.jqno.equalsverifier:equalsverifier to v3.19 (#849, #859)
  • Update dependency org.jetbrains.kotlin.multiplatform to v2.1.10 (#817, #858)
  • Update gradle/actions action to v4 (#827)
  • Update plugin api to v0.17.0 (#822)
  • Update atomicfu to v0.27.0 (#829)