Python bluetooth.lookup_name() Examples

The following are 6 code examples of bluetooth.lookup_name(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module bluetooth , or try the search function .
Example #1
Source File: bluetoothObexSpam.py    From Offensive-Security-Certified-Professional with MIT License 10 votes vote down vote up
def findDevs(opts):
    global foundDevs
    devList = bluetooth.discover_devices(lookup_names=True)
    repeat = range(0, int(opts.repeat))

    for (dev, name) in devList:
        if dev not in foundDevs:
            name = str(bluetooth.lookup_name(dev))
            printDev(name, dev)
            foundDevs.append(dev)
            for i in repeat:
                sendFile(dev, opts.file)
            continue

        if opts.spam:
            for i in repeat:
                sendFile(dev, opts.file) 
Example #2
Source File: __init__.py    From platypush with MIT License 6 votes vote down vote up
def lookup_name(self, addr: str, timeout: int = 10) -> BluetoothLookupNameResponse:
        """
        Look up the name of a nearby bluetooth device given the address

        :param addr: Device address
        :param timeout: Lookup timeout (default: 10 seconds)
        """
        from bluetooth import lookup_name

        self.logger.info('Looking up name for device {}'.format(addr))
        name = lookup_name(addr, timeout=timeout)

        dev = {
            'addr': addr,
            'name': name,
            'class': self._devices_by_addr.get(addr, {}).get('class'),
        }

        self._devices_by_addr[addr] = dev
        if name:
            self._devices_by_name[name] = dev

        return BluetoothLookupNameResponse(addr=addr, name=name) 
Example #3
Source File: adapter.py    From btproxy with GNU General Public License v3.0 6 votes vote down vote up
def lookup_info(addr, **kwargs):
    Class = kwargs.get('Class',True)
    Name = kwargs.get('Name',True)
    Address = kwargs.get('Address',True)
    info = {}
    while True:
        s = _run(['hcitool','inq'])
        for i in s.splitlines():
            i = str(i)
            if addr in i:
                info['class'] = re.compile(r'class: ([A-Fa-fx0-9]*)').findall(i)[0]
                info['addr'] = addr
                info['name'] = bluetooth.lookup_name(addr)
                return info

        print( 'Still looking for ', addr,'...', ' Is it discoverable? ') 
Example #4
Source File: device.py    From Blueproximity with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, mac, port=None, name=None):
        self.sock = None

        self.mac = mac
        self.port = port
        self.name = name

        self.port = self.scan_ports() if not port else port
        self.name = bluetooth.lookup_name(mac) if not name else name 
Example #5
Source File: bluetoothObexSpam.py    From Offensive-Security-Certified-Professional with MIT License 5 votes vote down vote up
def checkBluetooth(btAddr):
    btName = bluetooth.lookup_name(btAddr)
    if btName:
        printDev('Hidden Bluetooth device detected', btName, btAddr)
        return True

    return False 
Example #6
Source File: bluetoothScanner.py    From sensorReporter with Apache License 2.0 5 votes vote down vote up
def getPresence(self):
        """Detects whether the device is near by or not using lookup_name"""
        result = bluetooth.lookup_name(self.address, timeout=25)
        if(result != None):
            return "ON"
        else:
            return "OFF"