# Migrating to 2.0.0

Release 2026-11-17 splits the transports out of the Device Management
Kit into their own modules, and contains breaking changes. This page lists what to change in your
application.

> **Note:** Keep all modules on the same BOM version: import `sdk-bom` and declare the Ledger modules without a
> version.

## Dependencies

The transports are now published as separate modules, aligned by `sdk-bom`:

| Module                            | Content                                                                                              |
| --------------------------------- | ---------------------------------------------------------------------------------------------------- |
| `device-transport-kit-core`       | Shared transport contract and models (`DiscoveryDevice`, `LedgerDevice`, `TransportIdentifier`, ...) |
| `device-transport-kit-ble`        | Android and iOS BLE transport, `ble()`                                                               |
| `device-transport-kit-usb`        | Android USB transport, `usb()`                                                                       |
| `device-transport-kit-mockserver` | Simulated devices of a Ledger device mock server, for development and tests                          |

```kotlin
dependencies {
    implementation(platform("io.github.ledgerhq:sdk-bom:2.0.0"))
    implementation("io.github.ledgerhq:device-management-kit")
    implementation("io.github.ledgerhq:device-transport-kit-ble")
    implementation("io.github.ledgerhq:device-transport-kit-usb")
}
```

Add `device-transport-kit-mockserver` only to the builds that develop or test without a device.

## Device Management Kit

### Declare the transports you use

Apps declare their transports in a `transports { }` block. Without one, BLE and USB are still loaded on
Android and BLE on iOS. A block that declares no transport fails when the SDK is built.

```kotlin
import com.ledger.devicetransport.ble.ble
import com.ledger.devicetransport.usb.usb

val dmk: DeviceManagementKitApi = deviceManagementKit {
    context = applicationContext
    transports {
        ble()
        usb()
    }
}
```

`ble()` comes from `device-transport-kit-ble` (`com.ledger.devicetransport.ble.ble`, Android and iOS) and
`usb()` from `device-transport-kit-usb` (`com.ledger.devicetransport.usb.usb`, Android). Swift apps call
`builder.transports { $0.ble() }` through the `LedgerDeviceManagementKit` framework.

### `enableFake` is replaced by the mock server

`enableFake` and the fake devices it loaded are removed. To develop without a real device, declare the
mock server in the block:

```kotlin
import com.ledger.devicetransport.mockserver.mockServer

val dmk: DeviceManagementKitApi = deviceManagementKit {
    context = applicationContext
    transports {
        mockServer(token = "<token of a mock server session>")
    }
}
```

`url` defaults to the Ledger device mock server and `token` to a new session. Its devices carry
`MOCK_SERVER_TRANSPORT`.

### Models moved to `com.ledger.devicetransport.core`

These models move to `com.ledger.devicetransport.core`: update your imports.

| Model                                                   | Package in 1.0.0                            |
| ------------------------------------------------------- | ------------------------------------------- |
| `DeviceOperationResult`, `DeviceOperationFailureReason` | `com.ledger.devicemanagement.api`           |
| `LedgerDevice`, `UsbInfo`, `BleInformation`             | `com.ledger.devicemanagement.api.device`    |
| `DiscoveryDevice`                                       | `com.ledger.devicemanagement.api.discovery` |

### Transport identifiers

Each transport now has an identifier, a `TransportIdentifier` declared by its module:

- `BLE_TRANSPORT` in `com.ledger.devicetransport.ble`;
- `USB_TRANSPORT` in `com.ledger.devicetransport.usb`. The DMK re-exports it from
  `com.ledger.devicemanagement.api.discovery`: the USB module has no iOS framework, so Swift apps only see it
  through the DMK. Kotlin code can import either one.

### `transport` replaces `connectivityType`

`DiscoveryDevice`, `ConnectedDevice` and `ConnectedDeviceInformation` carry `transport: TransportIdentifier`
instead of `connectivityType`. `ConnectivityType` is removed: the RSSI of `ConnectivityType.Bluetooth(rssi)` is
now `DiscoveryDevice.rssi`, `null` when the transport does not measure one.

```kotlin
when (device.transport) {
    BLE_TRANSPORT -> showBluetoothIcon() // was: is ConnectivityType.Bluetooth
    USB_TRANSPORT -> showUsbIcon()       // was: ConnectivityType.Usb
}
```

### Transport availability

`observeTransportsAvailability()` replaces `getBluetoothState()`, `isBluetoothBleSupported()`,
`observeAndroidDeviceConnectivityWithCurrentStates()`, `getPermissionsState()`, `isAllPermissionGranted()`,
`needAskBluetoothPermission()` and `needAskLocationPermission()`. It emits the `TransportAvailability` of
every declared transport:

- `PermissionsRequired(permissions)` names the missing permissions;
- `Disabled(settings)` names the settings to turn on (`BLUETOOTH_SETTING`, or `LOCATION_SETTING` for BLE up
  to Android 11);
- `Unsupported` means the phone lacks the link.

`PermissionState` and `ConnectivityState` are removed.

### New failure results

- `DiscoveryResult.Failure.TransportUnavailable(transport, availability)` replaces `BluetoothDisabled`,
  `LocationDisabled`, `BluetoothPermissionNotGranted` and `BluetoothBleNotSupported`. It is also reported
  for an unavailable USB transport, which used to be `Failure.Unknown`, and the other transports keep
  discovering.
- `ConnectionResult.Failure.TransportUnavailable(transport, availability)` replaces `PermissionNotGranted`
  and `BleNotSupported`.
- `ConnectionResult.Failure.DeviceConnectivityBluetoothDisabled` and `DeviceConnectivityLocationDisabled` are
  removed: a connection no longer fails with a dedicated result when Bluetooth or location is off. Check
  `observeTransportsAvailability()` before connecting.
- `DeviceOperationFailureReason.TransportError(transport, message)` replaces `NoUsbEndpointFound`.
- `ConnectionResult.Failure.NoDeviceAddress` and `InternalState` are no longer returned: they come back as
  `DeviceNotFound` and `Unknown`.

### `destroy()` suspends

`destroy()` is now a `suspend` function, called from a coroutine or, from Swift, with `await`. It returns once the
discovery is stopped, every device is disconnected and the transports are stopped. It no longer stops the global Koin
of the app, nor cancels the work of the other SDK modules. A new DMK can then be created in the same process.

The signers now have a `destroy()` too: destroy them before the DMK they were built with, then build new ones on the
new DMK.

### Behaviour changes

- A transport that is or becomes unavailable emits its failure once and no longer stops the discovery.
- The `uid` of a connected USB device is its discovery `uid`, without the `usb_` prefix.
- Connecting a device that is already connected fails with `Unknown("Device already connected")` on every
  transport.
- iOS BLE queues APDUs and can return `DeviceBusy`. It reconnects after an app is opened or closed, in up to
  5 tries over 10 seconds, and gives up on a connection after 1 minute.
- A BLE exchange interrupted by a loss of the link fails with `DeviceDisconnected`.
- BLE frames follow the `0x08` MTU handshake and the last iOS frame is no longer padded. A response frame
  with an unexpected tag or sequence number fails the exchange with `DeviceOperationFailureReason.Unknown`.

## Signers and Context Module

The public API of `context-module`, `device-signer-kit-ethereum` and `device-signer-kit-solana` exposes the
`com.ledger.devicetransport.core` types: update your imports for `DeviceOperationResult` and the other moved
models.

## iOS

`LedgerDeviceManagementKit` exports the transport core, the BLE module and the mock server module, so
`ble()`, `mockServer(url:token:)` and the core types are visible from Swift.

From Swift, `BLE_TRANSPORT` is `BleTransportIdentifierKt.BLE_TRANSPORT`, exported by the BLE module, and
`USB_TRANSPORT` comes from the DMK.
