onDeviceFound

Handle a supported Bluetooth device when the SDK discovers it.

  • Stable unknown
  • Release candidate since 1.16.1-rc.3
  • Development since 1.16.1-dev.2111+9796905

onDeviceFound runs after BTManager recognizes a peripheral as one of the provider's acceptedDevices. It receives the managed device and the manager instance.

<BTProvider
  bleManager={bleManager}
  acceptedDevices={acceptedDevices}
  onDeviceFound={async (device, manager) => {
    await device.connect();
    console.log(manager);
  }}
>
  {children}
</BTProvider>

The callback is asynchronous. Returning device.connect() is a common choice when the app should connect as soon as the accepted device appears. If the user must choose a device, use the autoConnect and onDeviceSelectionRequired flow instead of connecting every discovery.

The device is a BTManagedDevice for the accepted device key. The manager can be used for supported manager operations; BTProvider remains responsible for its scan and lifecycle.

See BTProvider for setup and BluetoothDevicePicker for multi-device choice.

Last updated on