Best Practices & FAQ
General Rules
Section titled “General Rules”Always use .Timeout(TimeSpan.FromSeconds(X)) on BLE observables. Android can hang on certain calls if a connection drops mid-operation.
While Shiny handles many known Android BLE issues internally, following these rules will save you from common pitfalls:
| # | Rule |
|---|---|
| 1 | Don’t hold peripheral references across scans unless the device is connected. |
| 2 | Don’t scan while connected to a GATT server — avoid overlapping radio operations. |
| 3 | Don’t overwhelm the radio. Shiny queues operations internally, but rapid-fire calls still cause issues. |
| 4 | Expect GATT 133 errors on connect. Catch exceptions in your observable subscriptions. |
| 5 | Keep payloads small. BLE is not designed for large data or JSON — use compact binary formats. |
| 6 | Always scan with a Service UUID filter. Unfiltered scans return every BLE device nearby and drain battery. |
| 7 | Don’t discover all services & characteristics. Only query the ones you need — full discovery has a real performance cost. |