def enable_bt_scanning(self, on=True): bt_hcis = list(jm_dbus.get_hci_dict().keys()) for hci in bt_hcis: if jm_dbus.enable_adapter(hci): self.pair.update_adapters() if on: jm_dbus.enable_pairable(hci) else: jm_dbus.disable_pairable(hci)
def __init__(self): """Use DBus to find bluetooth controllers""" self.hci_dict = jm_dbus.get_hci_dict() devices = self.hci_dict.values() self.bt_devices = {} for device in devices: self.bt_devices[device] = [] self.pre_existing_devices()
def update_adapters(self): """ Rescan for bluetooth adapters that may not have existed on program launch """ self.hci_dict = jm_dbus.get_hci_dict() for addr in self.hci_dict.values(): if addr not in self.bt_devices.keys(): self.bt_devices[addr] = [] self.pre_existing_devices()
import jm_dbus if __name__ == '__main__': hcis = jm_dbus.get_hci_dict().keys() for hci in hcis: hci_proxy = jm_dbus.get_adapter_proxy(hci) devices = jm_dbus.get_node_child_names(hci_proxy) for dev in devices: jm_dbus.remove_device(hci, dev)