我想用Python來檢查bash命令hcitool scan
的輸出是否已知MAC地址。Python hcitool掃描
例如:我將手機的MAC地址保存爲變量。然後,我檢查由hcitool scan
確定的所有MAC地址。類似這樣的:
for each (popen('hcitool scan') as $line)
if ($line == $mymac)
print 'Phone in the Bluetooth range';
else
print 'Your phone isn't in the Bluetooth range';
爲什麼不直接使用BlueZ? –
這是我運行查詢時獲得的輸出pi @ raspberrypi〜$ sudo python inquiry.py正在執行查詢... Traceback(最近調用最後一個):文件「inquiry.py」,第12行,在 nearby_devices = bluetooth .discover_devices(lookup_names = True)文件「/usr/lib/python2.7/dist-packages/bluetooth/bluez.py」,第22行,位於discover_devices中raise BluetoothError(「與本地通信時出錯」bluetooth.btcommon.BluetoothError:error本地藍牙適配器 –
danielebuso