當前位置: 首頁>>代碼示例>>Python>>正文


Python socket.SOL_HCI屬性代碼示例

本文整理匯總了Python中socket.SOL_HCI屬性的典型用法代碼示例。如果您正苦於以下問題:Python socket.SOL_HCI屬性的具體用法?Python socket.SOL_HCI怎麽用?Python socket.SOL_HCI使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在socket的用法示例。


在下文中一共展示了socket.SOL_HCI屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_bt_socket

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import SOL_HCI [as 別名]
def create_bt_socket(interface=0):
    exceptions = []
    sock = None
    try:
        sock = socket.socket(family=socket.AF_BLUETOOTH,
                             type=socket.SOCK_RAW,
                             proto=socket.BTPROTO_HCI)
        sock.setblocking(False)
        sock.setsockopt(socket.SOL_HCI, socket.HCI_FILTER, pack("IIIh2x", 0xffffffff,0xffffffff,0xffffffff,0)) #type mask, event mask, event mask, opcode
        try:
            sock.bind((interface,))
        except OSError as exc:
            exc = OSError(
                    exc.errno, 'error while attempting to bind on '
                    'interface {!r}: {}'.format(
                        interface, exc.strerror))
            exceptions.append(exc)
    except OSError as exc:
        if sock is not None:
            sock.close()
        exceptions.append(exc)
    except:
        if sock is not None:
            sock.close()
        raise
    if len(exceptions) == 1:
        raise exceptions[0]
    elif len(exceptions) > 1:
        model = str(exceptions[0])
        if all(str(exc) == model for exc in exceptions):
            raise exceptions[0]
        raise OSError('Multiple exceptions: {}'.format(
            ', '.join(str(exc) for exc in exceptions)))
    return sock

########### 
開發者ID:frawau,項目名稱:aioblescan,代碼行數:38,代碼來源:aioblescan.py

示例2: __init__

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import SOL_HCI [as 別名]
def __init__(self, iface=0x10000, type=None):
        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW, socket.BTPROTO_HCI)
        s.setsockopt(socket.SOL_HCI, socket.HCI_DATA_DIR,1)
        s.setsockopt(socket.SOL_HCI, socket.HCI_TIME_STAMP,1)
        s.setsockopt(socket.SOL_HCI, socket.HCI_FILTER, struct.pack("IIIh2x", 0xffffffffL,0xffffffffL,0xffffffffL,0)) #type mask, event mask, event mask, opcode
        s.bind((iface,))
        self.ins = self.outs = s
#        s.connect((peer,0)) 
開發者ID:medbenali,項目名稱:CyberScan,代碼行數:10,代碼來源:bluetooth.py

示例3: __init__

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import SOL_HCI [as 別名]
def __init__(self, iface=0x10000, type=None):
        if WINDOWS:
            warning("Not available on Windows")
            return
        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW, socket.BTPROTO_HCI)  # noqa: E501
        s.setsockopt(socket.SOL_HCI, socket.HCI_DATA_DIR, 1)
        s.setsockopt(socket.SOL_HCI, socket.HCI_TIME_STAMP, 1)
        s.setsockopt(socket.SOL_HCI, socket.HCI_FILTER, struct.pack("IIIh2x", 0xffffffff, 0xffffffff, 0xffffffff, 0))  # type mask, event mask, event mask, opcode  # noqa: E501
        s.bind((iface,))
        self.ins = self.outs = s
#        s.connect((peer,0)) 
開發者ID:secdev,項目名稱:scapy,代碼行數:13,代碼來源:bluetooth.py

示例4: set_filter

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import SOL_HCI [as 別名]
def set_filter(self, data):
        # flt = bluez.hci_filter_new()
        # bluez.hci_filter_all_events(flt)
        # bluez.hci_filter_set_ptype(flt, bluez.HCI_EVENT_PKT)
        self._socket.setsockopt( socket.SOL_HCI, socket.HCI_FILTER, data )   
        pass
        #self._socket.setsockopt(socket.SOL_HCI, socket.HCI_FILTER, data) 
開發者ID:Adam-Langley,項目名稱:pybleno,代碼行數:9,代碼來源:BluetoothHCI.py

示例5: __init__

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import SOL_HCI [as 別名]
def __init__(self, iface=0x10000, type=None):
        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW, socket.BTPROTO_HCI)
        s.setsockopt(socket.SOL_HCI, socket.HCI_DATA_DIR,1)
        s.setsockopt(socket.SOL_HCI, socket.HCI_TIME_STAMP,1)
        s.setsockopt(socket.SOL_HCI, socket.HCI_FILTER, struct.pack("IIIh2x", 0xffffffff,0xffffffff,0xffffffff,0)) #type mask, event mask, event mask, opcode
        s.bind((iface,))
        self.ins = self.outs = s
#        s.connect((peer,0)) 
開發者ID:phaethon,項目名稱:kamene,代碼行數:10,代碼來源:bluetooth.py

示例6: _set_filter

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import SOL_HCI [as 別名]
def _set_filter(self, data):
        self._socket.setsockopt(socket.SOL_HCI, socket.HCI_FILTER, data) 
開發者ID:TheCellule,項目名稱:python-bleson,代碼行數:4,代碼來源:linux_adapter.py


注:本文中的socket.SOL_HCI屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。