示例#1
0
 def connect(self):
     addr = QtBluetooth.QBluetoothAddress(self.device.address)
     print('connecting to', addr)
     self.dev.connected.connect(self.connected)
     self.dev.disconnected.connect(self.disconnected)
     self.dev.error.connect(self.onError)
     self.dev.connectToService(addr, QtBluetooth.QBluetoothUuid.SerialPort)
示例#2
0
 def connect(self):
   print('connecting to', self.device.address)
   addr = QtBluetooth.QBluetoothAddress(self.device.address)
   self.dev = QtBluetooth.QBluetoothSocket(QtBluetooth.QBluetoothServiceInfo.RfcommProtocol, self)
   self.dev.connected.connect(self.onConnected)
   self.dev.disconnected.connect(self.onDisconnected)
   self.dev.error.connect(self.onError)
   self.dev.connectToService(addr, QtBluetooth.QBluetoothUuid.SerialPort)
示例#3
0
    def connectToRobot(self):
        self.sock = QtBluetooth.QBluetoothSocket(
            QtBluetooth.QBluetoothServiceInfo.RfcommProtocol)

        self.sock.connected.connect(self.connectedToBluetooth)
        self.sock.readyRead.connect(self.receivedBluetoothMessage)
        self.sock.disconnected.connect(self.disconnectedFromBluetooth)
        self.sock.error.connect(self.socketError)
        port = 1
        self.sock.connectToService(
            QtBluetooth.QBluetoothAddress("98:D3:C1:FD:2C:46"), port)
示例#4
0
def PluginConnection(param=""):
    from msgtools.server.BluetoothRFCOMMQt import BluetoothRFCOMMQtConnection
    from PyQt5 import QtBluetooth
    btArgs = param.split(",")
    btHost = btArgs[0]
    if len(btArgs) > 1:
        btPort = int(btArgs[1])
    else:
        btPort = 8
    btSocket = QtBluetooth.QBluetoothSocket(
        QtBluetooth.QBluetoothServiceInfo.RfcommProtocol)
    btSocket.connectToService(QtBluetooth.QBluetoothAddress(btHost), btPort)
    return BluetoothRFCOMMQtConnection(btSocket)