This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Options for multiple devices to phone

Hi all.  I've seen a few posts about this, but none of them seem to have the knowledge I'm looking for.  I am helping plan a device that has two units and will connect to a phone or other host device (maybe PC).  Each will communicate relatively little information to the host, and would only need to send a syncing signal between them every once in a while to sync LEDs and maybe small audio files - so I guess you can think like ear buds but without so much data.  I thought at first that it might make the most sense to have one unit as peripheral (call it unit A), one unit as combination central/peripheral that would act as central to the other unit and peripheral to the host (call it unit B), and then the host as a central to the B unit's peripheral.  But then I saw in Hung Bui's reply to this post that there might be a way to use a host application to automatically connect to two devices simultaneously without the end user being aware of it.  This sounds like it might be an even better idea, but I can't seem to find any more information about it, which leads me to think that I am googling the wrong words...

So, given that I don't want to the end user to have to be aware of the pairing scenario at all, from their perspective it should just work, and that there are only a few dozen bytes being transferred every few seconds at most, which makes more sense:

  1. Unit A connects as peripheral to Unit B as central which then acts as peripheral to the host.  How do I have these devices pair during manufacture?  If I let the user pair them on first power up, what happens if they buy several pairs and start them at once?
  2. Unit A and Unit B both connect as peripheral to the host.  How do I prevent the user from having to manage two devices pairing with their phone, and the inevitable confusion if one of those pairings goes wrong in some way?  How to prevent the user from even noticing that a device is pairing at all (other than maybe a permissions popup the first time)?

Thanks for any guidance you can give!

Parents
  • Hello,

    This isn't described as part of the bluetooth specification, so it is something you need to handle, and implement.

    If you want your two devices to act as one, you will actually only be connected to one of them, and that one connects to the other. Exactly how you do this, you need to figure out, but perhaps the one that you connect to immediately starts scanning for another one, and connect to it. Another option is that instead of it scanning for nearby devices, is that they can be pre-bonded during production. If so, you need to decide what happens if the end user looses one device. Does he/she need to purchase two new?

    Let us say we have A, B and M (mobile). Basically, one of the devices, let us say A needs to be a central to B, and then A neets to be the peripheral to M. Then you manually need to transmit the data going from M to B and B to M in your A.

     

    Unit A connects as peripheral to Unit B as central which then acts as peripheral to the host.  How do I have these devices pair during manufacture?  If I let the user pair them on first power up, what happens if they buy several pairs and start them at once?

     The easiest way to do so would be to actually allow them to pair. The other alternative is to hard code it in your project. This is not trivial. Study the peer manager and see how it stores bonding data, and insert that data in your flash.

     

    If I let the user pair them on first power up, what happens if they buy several pairs and start them at once?

     Then you either need to make sure that they pair up two and two, using something in the advertisement packet that they need to look for, or you need to pre-bond them. (NB: pairing != bonding. Pairing is the establishment of encryption in a link, while bonding is to actually store the pairing data for later use). 

     

    Unit A and Unit B both connect as peripheral to the host.  How do I prevent the user from having to manage two devices pairing with their phone, and the inevitable confusion if one of those pairings goes wrong in some way?  How to prevent the user from even noticing that a device is pairing at all (other than maybe a permissions popup the first time)?

     Then I suggest that you at least decide up front so that it is decided which device that is connecting to the phone. You need to consider how the devices connect to the phone in the first place. Remember that only HID devices will appear in the phones bluetooth settings. If you intend to not include a HID service, then you need a custom app to connect to the devices. The app can then decide what it connects to (e.g. only A devices, not B devices). 

    I suggest you start by experimenting a bit with bluetooth advertising, scanning and connection establishment. I believe a lot of things may answer itself at that point. 

    Best regards,

    Edvin

  • Thank you! This is very helpful and more or less confirms what I was thinking.  The only follow up question I have is, what should I ask of a host/mobile developer?  In our case, all data will be transmitted by A to M, and M doesn't ever really need to know the existence of B.  So do I just tell them I need the mobile app to connect to a BLE device without an HID service?  Then just tell them the details of the GATT services and characteristics?  The rest of the details of how we want the mobile side to act are pretty straightforward once they have the data.

Reply
  • Thank you! This is very helpful and more or less confirms what I was thinking.  The only follow up question I have is, what should I ask of a host/mobile developer?  In our case, all data will be transmitted by A to M, and M doesn't ever really need to know the existence of B.  So do I just tell them I need the mobile app to connect to a BLE device without an HID service?  Then just tell them the details of the GATT services and characteristics?  The rest of the details of how we want the mobile side to act are pretty straightforward once they have the data.

Children
  • If you try to run e.g. nRF Connect for Android/iOS, you will see that you will find a lot more Bluetooth devices than the ones visible in your Settings->Bluetooth menu. This is because the bluetooth settings page on a phone is limiting the scan results to only the very essential ones.

    Basically, you need to decide upon something that the mobile app can look for in an advertising packet. A typical method is to look for a particular UUID. 

    If you want them to be able to work on their own, tell them to try to connect to the SDK\examples\ble_peripheral\ble_app_uart example by looking for it's UUID. Once they have done that, it should be a very simple task to swap the UUID with the UUID that you end up using.

    Similarly, this example is probably useful for you to, as it is a versatile example. It is a service containing two characteristics. One you can subscribe to (notifications) and one you can write to, so you have two-way communication. What you would have to do is add the scanning and connecting to the second device (B), change out the UUIDs, and then write your application logic (sensors, LEDs and so on).

    Best regards,

    Edvin

Related