[英]Connecting bluetooth devices with React-Native App
我正在使用 react-native-bluetooth-serial。 每當我嘗試通過我的 react native 應用程序連接藍牙設備時,我都會收到此錯誤:
錯誤:讀取失敗,套接字可能關閉或超時,讀取 ret:-1 無法連接到設備
這是我正在嘗試做的事情:
connectToDevice () {
if (this.state.discovering) {
return false
} else {
this.setState({ discovering: true })
console.log("searching");
BluetoothSerial.list()
.then((Devices) => {
this.setState({ Devices, discovering: false })
for(var i = 0; 1; i++)
{
if(Devices[i]["name"] == "JBL Flip 3 SE")
{
console.log(Devices[i]["id"]);
BluetoothSerial.connect(Devices[i]["id"]).then((res) => {
console.log(res);
}).catch(err => {
console.log(err);
})
break;
}
}
// console.log(unpairedDevices);
})
.catch((err) => console.log(err.message))
}
}
即使我克隆示例存儲庫也會發生同樣的情況。
知道為什么會這樣嗎?
我鼓勵您在 React Native 中使用react-native-ble-plx藍牙,如果您需要實時示例,您可以查看我們的側面項目,該項目使用此庫將 colors 發送到 Arduino 並處理 LED 燈Z5E056C500A1C4076A7110B0D /SparingSoftware/HomeLed
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.