我正在使用BLE设备,并使用notify接收消息。我正在使用react-native-ble-manager
connectPeripheral = (per: Peripheral) => {
BleManager.connect(per.id)
.then(async () => {
console.log('Connected', per.name || per.id);
const services = await BleManager.retrieveServices(per.id);
console.log('Services', JSON.stringify(services));
await BleManager.startNotification(per.id, ServiceId, CharecteristicId);
})
.catch((err) => {
console.log('Error connecting', err, per.name || per.id);
});
};
const onUpdateValueForCharacteristic = bleManagerEmitter.addListener(
'BleManagerDidUpdateValueForCharacteristic',
this.onUpdateValueForCharacteristic,
);
onUpdateValueForCharacteristic = (
data: {
value: any;
peripheral: any;
characteristic: any;
service: any;
},
...args: any[]
) => {
console.log(
data.value,
data.peripheral,
data.service,
data.characteristic,
args,
);
};
我在onUpdateValueForCharacteristic中收到的值只是预期的部分数据。 谁能帮忙使用notify来获取全部有效负载?