我正在使用React-Native-Ble-Manager从血糖仪(Accu-Check Guide)中检索数据。我是蓝牙新手。我可以收听记录访问控制点的通知,该通知提供:-
[6,0,48,4]
但我不知道下一步该怎么做才能得到所有的葡萄糖测量值。我的代码如下。
BleManager.connect(selectedDevice.id).then((peripheral) => {
BleManager.retrieveServices(selectedDevice.id).then((servicesInfo) => {
BleManager.startNotification(
selectedDevice.id,
"00001808-0000-1000-8000-00805f9b34fb",
"00002a18-0000-1000-8000-00805f9b34fb"
)
.then(() => {
BleManager.startNotification(
selectedDevice.id,
"00001808-0000-1000-8000-00805f9b34fb",
"00002a52-0000-1000-8000-00805f9b34fb"
).then((result) => {
NativeAppEventEmitter.addListener('BleManagerDidUpdateValueForCharacteristic', function (data) {
console.log('RESULT FROM RAPC NOTIFICATION')
console.log(data) //[6,0,48,4]
});
});
var myData = "0x0101";
const payloadBytes = stringToBytes(myData);
BleManager.write(
selectedDevice.id,
"00001808-0000-1000-8000-00805f9b34fb",
"00002a52-0000-1000-8000-00805f9b34fb",
payloadBytes
)
.then(() => {
console.log("success");
})
.catch((error) => {
console.log(error);
});
return;
})
.catch((error) => {
// Failure code
console.log(error);
});
});
});
提前致谢。