user2298995
user2298995

Reputation: 2173

How to implement BLE communication with two devices?

I have an IoT device which I wish to implement:

  1. A mobile app - where the phone is the master when communication is initiated by the user's phone

  2. A remote key - where a click on said key should make the iot device do something. The remote key should be paired one time with the iot device.

Now, the issue that I'm experiencing is that I can not communicate with both. I would like to enable connection with the mobile app at all time, but I would also like to listen for a click on the remote key at all time (unless I'm connected to the app).

What would be the best architecture for such communication? Who would be the master and who would be the slave? Should I use a beacon device for the remote key? What's the best practice here?

Upvotes: 1

Views: 368

Answers (1)

bavaza
bavaza

Reputation: 11057

Depending on the BLE stack, a device can certainly be a Central and a Peripheral at the same time (the use of 'Master' and 'Slave' is inaccurate here).

If I understand correctly, you have 3 devices - a phone, a key, and an IoT Device. There are several options here:

  1. Phone is Central, and is connected to both Key and Device as Peripherals. A click on the Key will notify the phone, which in turn will send some message to the Device. Pros - easy pairing. Cons - the phone app must run all the time.
  2. Phone is Central, Key is both Central and Peripheral, Device is Peripheral. Phone connects to the Key Peripheral, Key connects to the Device as Central. Pros - Key controls Device even with no phone. Cons - probably harder to setup and pair Key with Device (depends on their I/O capabilities)

Upvotes: 2

Related Questions