无法将蓝牙连接到耳机蓝牙设备离子

时间:2020-05-12 13:40:33

标签: ionic-framework

我有想要在ionic 5应用程序中连接的无线蓝牙设备。 应用程序可以锁定配对的设备,但无法连接它。

搜索到的设备数据

{“名称”:“ MM-G5”,“地址”:“ 47:28:76:52:49:2E”,“ id”:“ 47:28:76:52:49:2E”, “ class”:1028}

这是错误

未捕获无法连接到设备

scan() {
        this.setStatus('Scanning for Bluetooth LE Devices');
        this.devices = [];  // clear list
        this.bluetoothSerial.enable().then(res => {
          console.log(res);
          this.bluetoothSerial.list().then(res => {
            this.devices = res;
          }
          );
        });
    }



 deviceSelected(device) {
    console.log(JSON.stringify(device) + ' selected');
    this.bluetoothSerial.connect(device.address).subscribe(res => {
      console.log(res);
      this.bluetoothSerial.read().then(res => console.log(res));
      this.bluetoothSerial.readRSSI().then(res => console.log(res));
      this.bluetoothSerial.readUntil('battery').then(res => console.log(res));
    });
}

还建议如何获取蓝牙设备数据,例如电池%。

请帮助。

0 个答案:

没有答案