Ionic native bluetooth serial disconnect method


#1

I have connected to bluetooth device with code below:

let alert = this.alertCtrl.create({
title: ‘Connect’,
message: ‘Do you want to connect with?’,
buttons: [
{
text: ‘Cancel’,
role: ‘cancel’,
handler: () => {
console.log(‘Cancel clicked’);
}
},
{
text: ‘Connect’,
handler: () => {
this.bluetoothSerial.connect(address).subscribe(this.success, this.fail);

  }
}

]
});
alert.present();
it able to connected with no issue.

When i try to disconnect the device and connect another with code below:

let alert = this.alertCtrl.create({
title: ‘Disconnect?’,
message: ‘Do you want to Disconnect?’,
buttons: [
{
text: ‘Cancel’,
role: ‘cancel’,
handler: () => {
console.log(‘Cancel clicked’);
}
},
{
text: ‘Disconnect’,
handler: () => {
this.bluetoothSerial.disconnect();
console.log(‘Disconnect clicked’);
}
}
]
});
alert.present();
i able to print “Disconnect clicked” but no response the device still connected. I have to go to android setting screen bluetooth to unpair the devices. “this.bluetoothSerial.disconnect();” this code look like not working. Any others way i can unpair the device? Please advice


#2

Solved and closed it.


#3

Good night, I’m with the same problem the code to disconnect the device does not work, how could you do to disconnect the device? help me please


#4

How did you solve that problem?


#5

Please help to solve the problem