Disconnect from BLE device.
(self)
| 73 | print(f" [BLE] Subscribed to TX notifications") |
| 74 | |
| 75 | async def close(self) -> None: |
| 76 | """Disconnect from BLE device.""" |
| 77 | if self._client and self._client.is_connected: |
| 78 | try: |
| 79 | await self._client.stop_notify(BLE_CHAR_TX_UUID) |
| 80 | except KeyboardInterrupt: |
| 81 | import _thread |
| 82 | |
| 83 | _thread.interrupt_main() |
| 84 | raise |
| 85 | except Exception: |
| 86 | pass |
| 87 | await self._client.disconnect() |
| 88 | print(f" [BLE] Disconnected") |
| 89 | self._client = None |
| 90 | |
| 91 | async def write(self, data: str) -> None: |
| 92 | """Write string data to RX characteristic (host -> device).""" |
no test coverage detected