我正在使用react-native-ble-plx库连接到BLE设备,然后读取/写入数据。但是,在尝试从设备读取数据时,我得到了errorCode: 4
,message: '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)
}
}
有人可以在这里帮助我吗?谢谢。