Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't show data in html #434

Open
AlexandreInsua opened this issue Dec 9, 2020 · 0 comments
Open

I can't show data in html #434

AlexandreInsua opened this issue Dec 9, 2020 · 0 comments

Comments

@AlexandreInsua
Copy link

Hi people.
I am currently using the plugin to build an angular style ionic app.
This application must receive arduino data using the HC-05 bluetooth module.
I managed to connect the device but when I receive the data I can only see them on the console or alerts but I were not able to display them in html using variable interpolation.
I noticed that by pressing the Back button on the device, the data is displayed on the html template..
I suspect the data stream is left open and for this reason no data is displayed, even if a value is set for the variable.
I also noticed that the documentation describes a method unsubscribe() that my IDE does not recognize.
Does any body have any ideas?
I leave a snippet in my code below.
Thank you very much.

connect(device: any) {
    let i = 1;
    this.presentToast("Connecting with " + device.name + "... ")
    this.serial.connect(device.address).subscribe(
      ok => {
        this.presentToast(device.name + "Connected.")
        this.presentToast("Recibiendo datos...");
        this.dataSubscription = this.serial.subscribe('\n').subscribe(
          data => {
            console.log(`${i}.- Receiving data  ${data}`);
            this.receivedData = data;

            // this.serial.unsubscribe() my IDE does not recognize this function

            // this options also do not working 

            // this.dataSubscription.unsubscribe(); 

            // this.serial.readUntil("\n")
            //   .then(data2 => {
            //     this.receivedData = data2;
            //   })

            // this.serial.clear();

            i++;
          },
          error => {
            console.log('subscribe data', error);
            this.presentToast("Subscribe data error.")
          }
        )
      },
      error => {
        console.warn('error', error);
        this.presentToast("Connection error.")
      }
    );
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant