【发布时间】:2017-10-30 14:19:23
【问题描述】:
我正在使用这个插件https://github.com/don/BluetoothSerial 来管理蓝牙连接等,我在 arduino Leonardo 上使用 HC-06 模块。一切正常,问题出在移动应用程序上。 这是home.ts
connect() {
this.blt = this.bluetoothSerial.connect("XX:XX:XX:XX:XX:XX");
this.blt.subscribe((data) => {
this._disable1 = false;
this._connected = true;
this.bluetoothSerial.subscribeRawData().subscribe((dt) => {
this.bluetoothSerial.read().then((dd) => {
this.onDataReceive(dd)
});
});
}, (error) => {
this._connected = false;
this.setStatus("Not Connected");
});
}
sendToHc(num) {
this.bluetoothSerial.write(""+num).then((ok) => { });
}
dummyCheck() {
// Do nothing
}
onDataReceive(dd) {
this._debug += "\n" + JSON.stringify(dd);
}
在 home.html 上有一个按钮调用 connect() 和另一个调用 sendToHc 并带有参数。到目前为止一切正常。问题是当 subscribeRawData 从 arduino 读取响应时,它不会自动更新 UI。我必须插入第三个按钮来调用 dummyCheck() 并在更新 UI 之后。是否有在读取响应时自动更新 UI?
【问题讨论】:
标签: angular bluetooth arduino ionic3