0

I am wondering what is the best approach for a server/client Bluetooth connection with multiple devices where all devices exchange data.

The approach im following is a hub and edge devices, where all edge devices exchange data with a central device (hub) and the hub exchanges data with each device. Each edge device has one connection, the hub has multiple

I'm new to Bluetooth but I want to plan ahead as to reduce headaches, so

Which device is the server, which is the client? Should the hub be the server and everything else connect to it. Or should the hub act as the client and connect to each edge device?

Android Bluetooth Chat sample app - multiple connections

step
  • 2,254
  • 2
  • 23
  • 45
Clocker
  • 1,316
  • 2
  • 19
  • 29

1 Answers1

1

The hub should be the server.

The hub needs to route messages between edge devices. The server needs to route messages between clients. Each edge device is also just a single client.

So, in what you're proposing, the "hub" and "server" will be performing the same operation over the exact same set of devices, though one addresses physical devices and the other addresses logical clients. That's because there is a 1 to 1 relationship between device and client meaning the hub and server route exactly the same information.

iheanyi
  • 3,107
  • 2
  • 23
  • 22
  • How is this a better approach than having each edge device be the server and the hub the client? In that case, each edge device would be listening for a connection to be initialized by the hub. – Clocker Sep 09 '15 at 17:19
  • http://stackoverflow.com/questions/23011189/concurrent-threads-for-incoming-outgoing-bluetooth-connections, if the hub is the server then according to that threat it would not be possible for it to receive new connections when it is currently connected to another device – Clocker Sep 09 '15 at 18:56
  • @Clocker It is better for the same reason - reduced duplication of work. The hub already has to route to different devices. Every server will need to do almost the same. They'd need to keep an internal client list and how to address each client (route) through the hub. Furthermore, each edge device would then have to be both a client and a server at the same time. More complexity. – iheanyi Sep 10 '15 at 18:17
  • @Clocker Regarding your second comment - every bluetooth device has this issue. You cannot simultaneously discover new devices and communicate. So, no matter how you organize things by hub/edge or client/server, you will need to deal with pairing devices as a distinct step. – iheanyi Sep 10 '15 at 18:20