私はこのプラグインhttps://github.com/don/BluetoothSerialを使用してBluetooth接続などを管理しています。私はarduino LeonardoでHC-06モジュールを使用しています。問題はモバイルアプリケーション上ですべてうまくいきます。ここ はhome.ts(接続呼び出すボタンがあるhome.htmlにIonic BluetoothシリアルSubscribeRawDataアップデートUI
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);
}
)とパラメータでsendToHcを呼び出すこと別です。これまでのところすべてがOKです。問題は、subscribeRawDataがarduinoからの応答を読み込み、UIを自動的に更新しないことです。 dummyCheck()を呼び出すために3番目のボタンを挿入する必要があり、その後UIが更新されます。レスポンスを読むときに自動的にUIを更新する方法はありますか?