首页 > 解决方案 > react-native-ble-manager 不返回任何内容或永远不会触发事件“handleDiscoverPeripheral”

问题描述

我正在尝试使用此示例获取可用蓝牙设备的列表。

(我不使用模拟器,我通过USB连接了手机。)

这是代码的官方示例。 代码在这里

但是,我看不到任何设备。永远不会触发事件“handleDiscoverPeripheral”。

我应该能够看到至少 2 个设备。

这是我的反应原生日志

info Reloading app...
 BUNDLE  [android, dev] ./index.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (1/1), done.

 LOG  Running "ArduinoBluetooth" with {"rootTag":1}
 WARN  VirtualizedLists should never be nested inside plain ScrollViews with the same orientation - use another VirtualizedList-backed container instead.
 LOG  Permission is OK
 LOG  Scanning...
 LOG  Scan is stopped
 LOG  No connected peripherals
 LOG  []
 LOG  Scanning...

PS 我已将扫描秒数增加到 30

BleManager.scan([], 30, true)

此外,所有权限都已设置。

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

标签: javascriptreact-nativebluetoothandroid-bluetooth

解决方案


推荐阅读