本文整理汇总了Python中bluetooth.lookup_name方法的典型用法代码示例。如果您正苦于以下问题:Python bluetooth.lookup_name方法的具体用法?Python bluetooth.lookup_name怎么用?Python bluetooth.lookup_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bluetooth
的用法示例。
在下文中一共展示了bluetooth.lookup_name方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lookup_name
# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import lookup_name [as 别名]
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)
示例2: findDevs
# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import lookup_name [as 别名]
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)
示例3: lookup_info
# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import lookup_name [as 别名]
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? ')
示例4: __init__
# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import lookup_name [as 别名]
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
示例5: checkBluetooth
# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import lookup_name [as 别名]
def checkBluetooth(btAddr):
btName = bluetooth.lookup_name(btAddr)
if btName:
printDev('Hidden Bluetooth device detected', btName, btAddr)
return True
return False
示例6: getPresence
# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import lookup_name [as 别名]
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"