Ionic bluetooth with Bitalino

Bluetooth, USB, UART, Storage, etc.
Posts: 3
Joined: Tue Apr 25, 2017 11:12 am

Ionic bluetooth with Bitalino

Postby jared » Tue Apr 25, 2017 12:02 pm

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 - ... 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.



Posts: 18
Joined: Tue Feb 25, 2014 2:17 pm

Re: Ionic bluetooth with Bitalino

Postby cazevedo » Wed Apr 26, 2017 8:59 am

Hi Jared,

On the Data Packets section of the MCU datasheet:
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

Posts: 3
Joined: Tue Apr 25, 2017 11:12 am

Re: Ionic bluetooth with Bitalino

Postby jared » Wed Apr 26, 2017 12:10 pm

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.



Posts: 3
Joined: Tue Apr 25, 2017 11:12 am

Re: Ionic bluetooth with Bitalino

Postby jared » Thu May 04, 2017 2:34 am

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

           (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.

Return to “I/O”