Embedded

View Original

BLE: Master Central Slave Peripheral Client Server, We Didn't Start the Fire…

I’ve been learning about BLE and got quite confused about the roles that BLE devices play. As I read through the list of roles:

master central slave peripheral client server

it reminded me of the Billy Joel song “We Didn’t Start The Fire.” That’s not usually a flattering comparison when it comes to naming things. Sure, it’s not as bad as REM’s “It’s the End of the World,” but c’mon.

Now I think I understand BLE’s roles and modes. I’ll try to explain them here - I hope this helps someone else too!

BLE roles are split into pre-connection and post-connection.

Pre-connection: At startup a device is either a peripheral or a central.

  • A peripheral advertises itself and waits for a central to connect to it.
    • A peripheral is usually a small device like a Fitbit or smart watch.
  • A central scans for other devices.
    • A central is usually a smartphone or PC.
  • After a peripheral makes a connection it’s called a slave.
  • After a central makes a connection it’s called a master.

Post-connection: After a BLE connection has been established, devices can be either a client or a server.

  • A client accesses remote resources.
    • A client is usually the master, but this is not required; a client could instead be the slave.
  • A server has a local database of resources (profiles/services/characteristics), it provides resources to the remote client.
    • A server is usually the slave, but this is not required; a server could instead be the master.
  • A client sends read and write operations to the server, and the server responds with data (and changes its local data if appropriate).
  • A server can send data to the client without a read/write request using indicate and notify operations.
    • Indicate operations are acknowledged by the client.
    • Notify operations are not acknowledged by the client.

And here’s my drawing that tries to summarize that wall of text:

I hope this explanation and graphic are a handy cheat sheet for someone out there - I have a feeling they'll be useful for my future self, at the very least!

Note 1: Most of my reading focused on BLE 4.0, so if something doesn’t apply to BLE 4.1 or 4.2 please let me know.

Note 2: My favorite summary is: https://web.archive.org/web/20160930015609/http://projects.mbientlab.com:80/bluetooth-low-energy-basics/