MCPcopy
hub / github.com/smittix/intercept / _bluetooth_scanner_fallback

Method _bluetooth_scanner_fallback

intercept_agent.py:2093–2129  ·  view source on GitHub ↗

Fallback scan using bluetoothctl directly.

(self, adapter: str)

Source from the content-addressed store, hash-verified

2091 }
2092
2093 def _bluetooth_scanner_fallback(self, adapter: str):
2094 """Fallback scan using bluetoothctl directly."""
2095 mode = 'bluetooth'
2096 stop_event = self.stop_events.get(mode)
2097
2098 try:
2099 proc = subprocess.Popen(
2100 ['bluetoothctl'],
2101 stdin=subprocess.PIPE,
2102 stdout=subprocess.PIPE,
2103 stderr=subprocess.PIPE,
2104 )
2105 self.processes['bluetooth'] = proc
2106
2107 proc.stdin.write(b'scan on\n')
2108 proc.stdin.flush()
2109
2110 while not (stop_event and stop_event.is_set()):
2111 line = proc.stdout.readline()
2112 if not line:
2113 break
2114
2115 line = line.decode('utf-8', errors='replace').strip()
2116 if 'Device' in line:
2117 self._parse_bluetooth_line(line)
2118
2119 time.sleep(0.1)
2120
2121 proc.stdin.write(b'scan off\n')
2122 proc.stdin.write(b'exit\n')
2123 proc.stdin.flush()
2124 proc.wait(timeout=2)
2125
2126 except Exception as e:
2127 logger.error(f"Bluetooth scanner error: {e}")
2128 finally:
2129 logger.info("Bluetooth scanner stopped")
2130
2131 def _parse_bluetooth_line(self, line: str):
2132 """Parse bluetoothctl output line."""

Callers

nothing calls this directly

Calls 5

_parse_bluetooth_lineMethod · 0.95
getMethod · 0.80
flushMethod · 0.80
waitMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected