[英]React Native BLE with MiBand
我真的很陌生,但是我已经知道(通过Internet搜索其他项目)MiBands具有身份验证过程。
事情是我尝试写在没有和响应我通过连接获得的唯一服务UUID的情况下,总是说乐队没有该UUID服务。
我正在使用React-Native-BLE-PLX库。
从图像中可以看出,我使用设备的服务UUID,因为我无法获得任何其他服务,但始终表示该服务不存在。
search(){
this.manager = new BleManager();
this.manager.startDeviceScan(null, null, (error, device) => {
if (error) {
console.log(error.message);
return;
}
if (device.name == 'Mi Band 3') {
this.manager.stopDeviceScan();
this.device = device;
this.connect();
}
});
}
connect() {
console.log("CONNECTING...");
this.device.connect()
.then(async (device) => {
console.log("CONNECTED!!!");
console.log("DEVICE CONNECTED:\n");
console.log(device);
this.auth(device);
// return this.manager.discoverAllServicesAndCharacteristicsForDevice(device.id)
})
// .then((device) => {
// console.log(device);
// this.send(device);
// })
// .catch((error) => {
// console.log("ERROR: ");
// console.log(error);
// });
}
async auth(device) {
console.log("DEVICE: \n");console.log(this.device);
console.log("DEVICE'S SERVICE UUID: \n" +this.device.serviceUUIDs[0]);
console.log("TRYING");
this.manager.writeCharacteristicWithoutResponseForDevice('D7:2D:F8:F2:24:3F', '0000fee0-0000-1000-8000-00805f9b34fb', '00000009-0000-3512-2118-0009af100700', 0x01 + 0x00 + new Buffer("OLA MUNDO"))
.then((device) => {
console.log("STUFF GOING ON:\n");
console.log(device);
})
.catch((error) => {
throw error;
});
}
确实需要帮助,并为此表示感谢。
如果有什么我需要描述的,请告诉我。
连接后,您必须首先发现服务和特性。 之后,您可以启动身份验证部分。 但是,您的身份验证部分完全错误。 进行一些谷歌搜索以找出正确的方法...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.