IONIC bluetooth communication

Hello, I’m new using Ionic framework.

I’m trying to communicate one bluetooth connect to an Arduino with my app.
I have a button on my app that when pressed allowed the Arduino to start sending serial data.


void loop()  
  if (bluetooth.available()>0) { 
    b1 =; 
    command += b1; 
    if (b1 == 'a'){ //Verifying if its allowed to send data
      dados = bluetooth.write("180,190,30,50,20,15,35"); //Data

But when the app receive this data I have two problems

I’m trying to reach all char array and separate my numbers, but every time I do that I received nothing in my toast message.

If I remove the while, the first time I read a message I received in my toast message and undefined.


comBluetooth() {

    var char: any;
    var i: number = 0;
    var o: number = 0;
    var parada: any = ",";
    var dados: number[];
    var convert: any = "";
    var tamanho: number;


    .then((dadoRecebido: any) => {
      char = String(dadoRecebido);
      tamanho = char.length;
      while(i < tamanho){
        if(char[i].localCompare(",") == 0){
          dados[o] = parseFloat(convert);
          o = o + 1;
          convert = convert + char[i];
          i = i + 1;      
      this.toast.create({ message: char, duration: 3000, position: 'botton' }).present();

Could anyone help me with the correctly way to do this communication? As I said I’m new in ionic framework so any detailed information will helps a lot.


I solved the second problem.

I think that putting write command allowing arduino to start sending data and just after read theses information was to fast to received all data.