Bluetooth & BLE · Study deck
Python BLE: Runtime Boundaries and Positioning
A Bleak client can scan, connect, or notify, but each role has a runtime limit.
Radio Remi is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Explain: With n=2, an 8 dB weaker reading multiplies 2.00 m to 5.02 m, while an 8 dB stronger reading gives 0.796 m—not the chapter quiz’s 1.4 m.
- Explain: A modern BLE controller can time-slice more than one role, but Bleak exposes the Python host as the scanner, initiator, and GATT client.
- Explain: The error:: A Python script using bleak connects to a BLE temperature sensor, reads data in a loop, but doesn't handle disconnections.
- Explain: File writes, MQTT publishes, and database retries belong outside the BLE callback path.
Major section
Deep Dive: Bleak Role Boundaries and Runtime Limits
Bleak is a Central/client API.
- A modern BLE controller can time-slice more than one role, but Bleak exposes the Python host as the scanner, initiator, and GATT client.
- The scaling constraint is usually scheduling, not Python byte throughput.
- File writes, MQTT publishes, and database retries belong outside the BLE callback path.
Major section
Deep Dive: Bleak Role Boundaries and Runtime Limits (continued)
A 38 byte sensor report needs MTU negotiation or application-level chunking with an order field and a missing-chunk timeout.
- ATT framing also changes what a successful trace proves.
- With the default ATT MTU, a notification commonly carries up to 20 application bytes after overhead.
- Disconnects are normal events.
Major section
Indoor Positioning with BLE Beacons
A location estimate must carry its uncertainty into the decision.
- Bluetooth Low Energy is the short-range radio system used by the beacons; it is shortened to BLE.
- Received signal strength means the radio power that arrives at a receiver.
- RSSI means received signal strength indicator, the radio's reported estimate of that power.
Major section
Indoor Positioning with BLE Beacons (continued)
This route test does not prove room-level accuracy everywhere.
- A beacon signal near a doorway is not yet a position.
- RSSI, calibration, anchor placement, filtering, movement, walls, and uncertainty decide whether a location claim is useful or misleading.
- The mathematical gist.: Distance sits in an exponent: d̂/d0=10^(δ/10n).
Major section
Indoor Positioning with BLE Beacons (continued)
With n=2, an 8 dB weaker reading multiplies 2.00 m to 5.02 m, while an 8 dB stronger reading gives 0.796 m—not the chapter quiz’s 1.4 m.
- The linear shortcut predicts 92.1% at 8 dB, but the exact increase is 151%.
- The estimated position is where the three circles overlap most closely.
- The circles represent the distance measurement from each beacon — the estimated position is where they intersect.
Major section
Common Mistake: Not Handling BLE Disconnections in Long-Running Scripts
The error:: A Python script using bleak connects to a BLE temperature sensor, reads data in a loop, but doesn't handle disconnections.
- Script connects successfully.
- Outer while loop:: Retries connection if it fails initially or drops.
- Rule of thumb:: All production BLE scripts need reconnection logic.
Deck summary
Key takeaways
Bleak is a Central/client API.
- A 38 byte sensor report needs MTU negotiation or application-level chunking with an order field and a missing-chunk timeout.
- A location estimate must carry its uncertainty into the decision.
- This route test does not prove room-level accuracy everywhere.
- With n=2, an 8 dB weaker reading multiplies 2.00 m to 5.02 m, while an 8 dB stronger reading gives 0.796 m—not the chapter quiz’s 1.4 m.
Retrieval practice
Recall check 1 of 3

Radio Remi says: answer from memory, then check your reasoning.
Q1Per this BLE cheat sheet's GATT structure, what is the correct hierarchy from top to bottom?
Show answer
Answer: A The cheat sheet states the GATT structure directly: Profile -> Service -> Characteristic, where each Characteristic supports Read/Write/Notify operations and each Service is identified by a 16-bit or 128-bit UUID.
Q2Per this cheat sheet's Roles list, which role 'has the GATT database'?
Show answer
Answer: A The cheat sheet's Roles section lists four terms: Central (scans, initiates connection), Peripheral (advertises, accepts connection), Server (has GATT database), and Client (reads/writes characteristics).
Retrieval practice
Recall check 2 of 3

Radio Remi says: answer from memory, then check your reasoning.
Q3Why is RSSI-based distance estimation considered approximate in BLE applications?
Show answer
Answer: B Correct!
Retrieval practice
Recall check 3 of 3

Radio Remi says: answer from memory, then check your reasoning.
Q4A trilateration system uses three beacons with clean RSSI readings, yet position estimates still wander by several metres. What is the most fundamental reason?
Show answer
Answer: A Right.
Print reference
Answers
Answer key.
- A · The cheat sheet states the GATT structure directly: Profile -> Service -> Characteristic, where each Characteristic supports Read/Write/Notify operations and each Service is identified by a 16-bit or 128-bit UUID.
- A · The cheat sheet's Roles section lists four terms: Central (scans, initiates connection), Peripheral (advertises, accepts connection), Server (has GATT database), and Client (reads/writes characteristics).
- B · Correct!
- A · Right.