Introduction
Imagine you want your phone to talk to a small device like a fitness tracker without wires. The challenge is how these two devices find each other, connect, and share information quickly and efficiently without using much power.
Imagine two friends at a busy party trying to chat. One friend waves to get attention (advertisement), the other friend notices and walks over (connection request). They decide to talk quietly in a corner (connection). One friend holds a notebook with information (server), and the other asks questions or writes notes (client). Sometimes, the notebook owner points out new info without being asked (notifications). They agree to keep their talks short and spaced out so they don't get tired (power efficiency).
┌───────────────┐ ┌───────────────┐
│ Device A │ │ Device B │
│ (Advertiser) │ │ (Scanner) │
└──────┬────────┘ └──────┬────────┘
│ Advertisement Signal │
│─────────────────────────────▶│
│ │
│ Connection Request │
│◀─────────────────────────────│
┌──────┴────────┐ ┌─────────┴───────┐
│ Connection │──────────▶│ Connection │
│ Established │ │ Established │
└──────┬────────┘ └─────────┬───────┘
│ │
│ Data Exchange (GATT) │
│◀─────────────────────────────▶│
│ │
│ Notifications / Indications │
│◀─────────────────────────────▶│
│ │
│ Connection Parameters Set │
│─────────────────────────────▶│device = BLEDevice()
device.scan()
device.connect()
data = device.read_characteristic('temp')
print(data)device.connect() fails. What is the likely mistake?
device = BLEDevice()
device.connect()
device.scan()
data = device.read_characteristic('humidity')Pass the test and this pattern moves unknown