def clear_bond(self, address=None):
"""Use the 'bluetoothctl' program to erase a stored BLE bond.
"""
con = pexpect.spawn('sudo bluetoothctl')
con.expect("bluetooth", timeout=1)
log.info("Clearing bond for %s", address)
con.sendline("remove " + address.upper())
try:
con.expect(
["Device has been removed", "# "],
timeout=.5
)
except pexpect.TIMEOUT:
log.error("Unable to remove bonds for %s: %s",
address, con.before)
log.info("Removed bonds for %s", address)
评论列表
文章目录