DocumentationDevice interactionBeginner's guidesDiscover and connect

Connecting to a Device

There are two steps to connecting to a device:

  • Discovery: sdk.startDiscovering()
    • Returns an observable which will emit a new DiscoveredDevice for every scanned device.
    • The DiscoveredDevice objects contain information about the device model.
    • Use one of these values to connect to a given discovered device.
  • Connection: sdk.connect({ deviceId: device.id })
    • Returns a Promise resolving in a device session identifier DeviceSessionId.
    • Keep this device session identifier to further interact with the device.
    • Then, sdk.getConnectedDevice({ sessionId }) returns the ConnectedDevice, which contains information about the device model and its name.
sdk.startDiscovering().subscribe({
  next: (device) => {
    sdk.connect({ deviceId: device.id }).then((sessionId) => {
      const connectedDevice = sdk.getConnectedDevice({ sessionId });
    });
  },
  error: (error) => {
    console.error(error);
  },
});

Then once a device is connected:

  • Disconnection: sdk.disconnect({ sessionId })
  • Observe the device session state: sdk.getDeviceSessionState({ sessionId })
    • This will return an Observable<DeviceSessionState> to listen to the known information about the device:
      • device status:
        • ready to process a command
        • busy
        • locked
        • disconnected
      • device name
      • information on the OS
      • battery status
      • currently opened app
Ledger
Copyright © Ledger SAS. All rights reserved. Ledger, Ledger Nano S, Ledger Vault, Ledger OS are registered trademarks of Ledger SAS