Page 1 of 1

Ionic bluetooth with Bitalino

Posted: Tue Apr 25, 2017 12:02 pm
by jared
Hey there,

I've been fiddling with the Bitalino for a couple of weeks now and think it's rather cool.

I'm trying to make a mobile app that will interface with it. Porting the Java API across to React is a little beyond my technical ability so thought I would rewrite the bluetooth protocol with the Ionic bluetooth-serial plugin - https://ionicframework.com/docs/native/ ... th-serial/.

It's connecting fine and the commands I'm sending to it seem to be working but I have no idea how to parse what is returned. Could one of you guys point me in the right direction where it comes to parsing the returned packets?

When I send an 18 to the Bitalino in the hopes of getting some simulated data back from A3 channel, I get back a short stream of seemingly random-lengthed array buffers...

I apologise if this is a stupid question but I've been banging my head against a brick wall for a while now.

Any help you could give would be greatly appreciated.

Cheers,

Jared

Re: Ionic bluetooth with Bitalino

Posted: Wed Apr 26, 2017 8:59 am
by cazevedo
Hi Jared,

On the Data Packets section of the MCU datasheet:
http://bitalino.com/datasheets/REVOLUTION_MCU_Block_Datasheet.pdf
you can find the data packet structure sent by device while in live or simulated mode.

This should be enough for you to parse the received frames, but if you experience further constraints feel free to ask.

Best regards,
Carlos Azevedo

Re: Ionic bluetooth with Bitalino

Posted: Wed Apr 26, 2017 12:10 pm
by jared
Hey Cazevedo,

I've been referring to that and have got the bluetooth sending nicely I think.

I'm struggling with parsing the data coming back. From looking at the source of a few of the APIs, I need to do bit-wise operations on the returned data which my brain is having a hard time with.

The data I get back from the device looks like:

{"0":23,"1":20,"2":39,"3":35,"4":55, ... } and comes back from the device in different lengths.

I've done a lot of googling but can't seem to find how to parse these values. Any help would be appreciated.

Cheers,

Jared

Re: Ionic bluetooth with Bitalino

Posted: Thu May 04, 2017 2:34 am
by jared
So after many hours of head-smashing I think I go it.

Subscribing to the subscribeRawData method of the bluetoothSerial plugin with the following:

Code: Select all

     this.bluetoothSerial
        .subscribeRawData()
        .subscribe(
           (data) => {
              let bytes = new Uint8Array(data);
              let beat = ((bytes[1] - 0) & 0x0f) + (((bytes[0] - 0) & 0xfc) << 2) // Extract the 10-bit integer

              this.dataPoints.shift(); // Shift the first element off the graph array
              this.dataPoints.push(beat) // Push the reading onto the end of the graph array
              this.lineChart.update() // Update the graph

           }, (error) => {
              this.bluetoothData = error;
           }
        )


Now it seems that I'm not getting 3 bytes every time but I think this is an issue with the bluetooth plugin rather than the bitalino. Though I might be wrong.