def scanPortResult(self,port): # here we scan exactly one port and give a textual result _sock = bluez.btsocket() sock = bluetooth.BluetoothSocket( bluetooth.RFCOMM , _sock ) try: sock.connect((self.mac, port)) sock.close return _("usable") except: return _("closed or denied")
def _connect(self): """ Try to connect to the device. """ if self._sock: self._disconnect() self._sock = bt.btsocket(bt.RFCOMM) for port in range(1,31): try: self._sock.bind(('', port)) break except Exception, e: pass
def get_connection(self,dev_mac,dev_channel): # fire up a connection # don't forget to set up your phone not to ask for a connection # (at least for this computer) #args = ["rfcomm", "connect" ,"1", dev_mac, str(self.config['device_channel']), ">/dev/null"] #cmd = "/usr/bin/rfcomm" #self.procid = os.spawnv(os.P_NOWAIT, cmd, args) try: self.procid = 1 _sock = bluez.btsocket() self.sock = bluetooth.BluetoothSocket( bluetooth.RFCOMM , _sock ) self.sock.connect((dev_mac, dev_channel)) #print str(_sock.getsockid()) except: self.procid = 0 pass # take some time to connect (only when using spawnv) #time.sleep(5) return self.procid
def __init__(self, proto=RFCOMM, _sock=None): if _sock is None: _sock = _bt.btsocket(proto) self._sock = _sock self._proto = proto
def __init__ (self, proto = RFCOMM, _sock=None): if _sock is None: _sock = _bt.btsocket (proto) self._sock = _sock self._proto = proto