无法通过react-native-ble-plx从BLE设备读取数据(错误代码:4)

时间:2019-12-11 20:33:54

标签: react-native bluetooth-lowenergy react-native-ble-plx

我正在使用react-native-ble-plx库连接到BLE设备,然后读取/写入数据。但是,在尝试从设备读取数据时,我得到了errorCode: 4message: 'Operation was rejected'reason: GATT exception from MAC address XX:XX:XX:XX:XX:XX, with type BleGattOperation{description='CHARACTERISTIC_READ'}

下面是我的阅读功能-

startReading = async (device) => {
    const BLEConstants = constants && constants.BLEConstants;
    try {
        let res = await this.manager.readCharacteristicForDevice(
            device.id,
            BLEConstants.SERVICE_UUID,
            BLEConstants.READ_CHARACTERISTIC_UUID
        ).then(data => {
            console.log(data)
        }).catch(error => {
            console.log(error)
        });
    } catch (error) {
        console.log("Error in startReading function");
        console.log(error)
    }
}

有人可以在这里帮助我吗?谢谢。

0 个答案:

没有答案