i am trying to create an ionic obd-2 application for my university project. i am using "BluetoothSerial" in order to connect with obd simulator i have done all the settings required(that i know of) but i have hit a wall and i dont know what to do next. i connected to the bluetooth device and when is send the "ATZ" commands using bluetoothserial.write(obdcommand) i am getting "OK" can you please share with me how you connected with bluetoothserial or am i missing something...
I will post my code dow below.
obdcommands=['ATD','ATZ','ATE0','ATL0','ATS0','ATH0','ATAT2','ATSP0','0100', '0105\r', '010C'];
constructor(private bluetooth:BluetoothSerial,
private DataSrv:DataSrvService,
private action:ActionSheetController,
private permission:AndroidPermissions,
private alert: AlertController,
private toastctrl:ToastController) {
}
connect(dvc)
{
if(dvc.address=="")
this.showError("No Address");
else{
this.bluetooth.connect(dvc.address).subscribe(success=>
{
this.modal.dismiss(null, 'cancel');
this.presentToast("Connected Successfully");
this.blue=false;
this.deviceConnected();
this.bluetooth.available().then(tr=>{alert(tr)})
},error=>{
alert("Connect Error: "+error);
})
}
}
deviceConnected()
{
this.bluetooth.subscribe('\n').subscribe(success=>{
alert("Subscribed Successfully" +success);
})
}
async searchOBD()
{
for(let k=0;k<this.obdcommands.length;k++)
{
await this.bluetooth.write(this.obdcommands[k]).then( (success) => {
alert('Connected: '+this.obdcommands[k]+'Data: '+success );
},
(error) => {
alert('Reading failed: ' + error );
});
}
}