BLE and multiple connections

Ask, and ye shall receive.
User avatar
micke
Posts: 256
Joined: 20:49, 18 Nov 2013

BLE and multiple connections

Postby micke » 11:03, 19 May 2014

Anybody knows if a BLE peripheral can accept multiple connections? And would it be possible to scan for a peripheral while it is connected? Can a device advertise while connected?
Best regards, Micke

ruyterb
Posts: 2
Joined: 07:58, 16 Sep 2014

Re: BLE and multiple connections

Postby ruyterb » 08:03, 16 Sep 2014

Hi,

I am having the same question...
Not knowing if it can technically be done I will try to start two instances of the client App and sees if both can connect to a different sensor tag.

Any other suggestions on how to make this work?

regards

User avatar
micke
Posts: 256
Joined: 20:49, 18 Nov 2013

Re: BLE and multiple connections

Postby micke » 09:31, 18 Sep 2014

Hi, how did the experiment go? Would be cool if it worked.

I think that you cannot do multiple connections to BLE devices in general, but I wonder if it would be possible to design a BLE device that could both be in announce mode and at the same time accept multiple connections? Perhaps there is something in the design of BLE that prevents that?

Best, Mikael

ruyterb
Posts: 2
Joined: 07:58, 16 Sep 2014

Re: BLE and multiple connections

Postby ruyterb » 11:05, 18 Sep 2014

Hi,

It worked perfect.

But, what I had to do was to use 3 buttons to manually connect one-by-one. If I have them all 3 connected as part of the page load it only ends up with a connection with the last tag. I assume that I should have respected some time interval before connecting the next one but since a manual approach (pressing a button to connect) works for me that solved the question.

The basic thing was to declare 3 objects:

Code: Select all

   // SensorTag object.
   var sensorTag_1 = new TISensorTag.createInstance()
   var sensorTag_2 = new TISensorTag.createInstance()
   var sensorTag_2 = new TISensorTag.createInstance()


and then have a button per tag that executes a start for the tag:

Code: Select all

   function start1()
      {
      sensorTag_1.connectToKnownDevice("C70C0D0F-CB9A-D7B7-3683-2CB07ED3E40D");
      }


and have this function for the AddEventListener:

Code: Select all

   function initialiseSensortags()
      {
      sensorTag_1.statusCallback(statusHandler1);
      sensorTag_1.errorCallback(errorHandler1);
      sensorTag_1.accelerometerCallback(accelerometerHandler1, 100);
      
      sensorTag_2.statusCallback(statusHandler2);
      sensorTag_2.errorCallback(errorHandler2);
      sensorTag_2.accelerometerCallback(accelerometerHandler2, 100);
      
      sensorTag_3.statusCallback(statusHandler3);
      sensorTag_3.errorCallback(errorHandler3);
      sensorTag_3.accelerometerCallback(accelerometerHandler3, 100);
      }


Works just fine.

User avatar
micke
Posts: 256
Joined: 20:49, 18 Nov 2013

Re: BLE and multiple connections

Postby micke » 17:15, 18 Sep 2014

Great! Thanks for sharing!
Micke


Return to “Questions and answers”

Who is online

Users browsing this forum: No registered users and 25 guests