标签: react-native-ble-plx

FabricViewStateManager:在没有 StateWrapper 的情况下调用 setState

我是一名 iOS 开发人员,第一次使用 React-native 涉足 Android 领域。

\n

我正在创建一个使用蓝牙le的react-native应用程序,使用polidieas react-native-ble-plx库。iOS 应用程序运行良好,蓝牙扫描并检测设备。当我在 Android 上运行时,它开始扫描,并收到错误“FabricViewStateManager:在没有 StateWrapper 的情况下调用 setState”,并且找不到此错误语句的任何文档或帮助。

\n

两个问题:

\n
    \n
  1. 有没有人在 Anmdroid 上运行 React-Native Apps 时看到此错误:FabricViewStateManager:在没有 StateWrapper 的情况下调用 setState。

    \n
  2. \n
  3. 有人对如何隔离错误发生的位置有任何想法吗?

    \n
  4. \n
\n

这是出现错误之前的控制台:

\n
I/BluetoothAdapter: STATE_ON\nI/BluetoothAdapter: STATE_ON\nI/BluetoothAdapter: STATE_ON\nI/BluetoothAdapter: STATE_ON\nD/BluetoothLeScanner: Start Scan with callback\nD/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=13 mScannerId=0\nI/ReactNative: [GESTURE HANDLER] Initialize gesture handler for root view com.facebook.react.ReactRootView{67ef486 V.E...... ......ID 0,0-1080,2019 #1}\n**E/unknown:FabricViewStateManager: setState called without a StateWrapper**\nI/ReactNativeJS: \xe2\x94\x90 %c action %cCHANGE_STATUS %c@ 20:36:54.384\nI/ReactNativeJS: \xe2\x94\x82 '%c prev state', 'color: …
Run Code Online (Sandbox Code Playgroud)

android reactjs react-native react-native-ble-plx

12
推荐指数
1
解决办法
7364
查看次数

连接蓝牙模块后数据丢失

客观的

我试图在连接后从蓝牙设备返回数据,因为要使用读写功能,需要一些数据。示例数据name, overflowServiceUUIDs, solicitedServiceUUIDs, mtu, rssi...和许多其他数据。因为如果我想读或写,我需要一些属性。我正在使用图书馆react-native-ble-plx

怎么了?

设备连接后,我丢失了一些值。

重要的

type DeviceState = {
  connected: boolean;
  services: Service[];
  device: Device | null;
  characteristics: Record<string, Characteristic[]>;
};

const INITIAL_DEVICE_STATE = {
  connected: false,
  services: [],
  device: null,
  characteristics: {},
};
Run Code Online (Sandbox Code Playgroud)
const [adapterState, setAdapterState] = useState(false);
const [bleDevices, setBleDevices] = useState<Device[]>([]);
const [isScanning, setIsScanning] = useState(false);
const [connectedDevice, setConnectedDevice] = useState<DeviceState>(
    INITIAL_DEVICE_STATE,
);

# The state isScaning is used to be if we are scanning devices.
# The connectedDevice …
Run Code Online (Sandbox Code Playgroud)

bluetooth bluetooth-lowenergy typescript react-native react-native-ble-plx

11
推荐指数
1
解决办法
610
查看次数

React Native - 全局事件监听器

我在我的Pairing屏幕上注册了一个监听器,它在连接的蓝牙设备断开连接时调用一个方法

// Pairing.js

const BleManagerModule = NativeModules.BleManager;
const bleManagerEmitter = new NativeEventEmitter(BleManagerModule);

componentDidMount() {
  this.handlerDisconnected = bleManagerEmitter.addListener(
    "BleManagerDisconnectPeripheral",
    this.handlePeripheralDisconnected
  );
}

componentWillUnmount() {
  this.handlerDisconnected.remove();
}
Run Code Online (Sandbox Code Playgroud)

我希望这个事件贯穿我的应用程序,如何创建全局事件侦听器而不必在每个屏幕上复制粘贴此代码?

ps 如果有帮助,我正在使用 react-native-ble-manager 和 redux+saga

bluetooth reactjs react-native react-native-ble-plx

6
推荐指数
1
解决办法
4948
查看次数

如何使用react-native-ble-plx发现服务UUID和特征UUID?

问题:

我正在尝试连接到我的蓝牙设备,但是在连接并发现所有服务和特征后,我无法继续前进,因为返回的信息不足。我没有收到任何服务 UUID 或任何特征 UUID。

我需要做什么才能访问 UUID,然后才能读取特征?

我尝试过的:

我的设备调用后device.discoverAllServicesAndCharacteristics();返回:

{ _40: 0, _65: 0, _55: null, _72: null }

当我登录时device我得到:

06-23 16:36:54.758  4397  4597 I ReactNativeJS: { isConnectable: null,
06-23 16:36:54.758  4397  4597 I ReactNativeJS:   rssi: null,
06-23 16:36:54.758  4397  4597 I ReactNativeJS:   serviceData: null,
06-23 16:36:54.758  4397  4597 I ReactNativeJS:   overflowServiceUUIDs: null,
06-23 16:36:54.758  4397  4597 I ReactNativeJS:   mtu: 23,
06-23 16:36:54.758  4397  4597 I ReactNativeJS:   localName: null,
06-23 16:36:54.758  4397  4597 I ReactNativeJS:   manufacturerData: …
Run Code Online (Sandbox Code Playgroud)

javascript bluetooth-lowenergy react-native react-native-ble-plx

2
推荐指数
1
解决办法
4266
查看次数