Exemplo n.º 1
0
    def __init__(self, name = "LBRC", serverid = "a1e7"):
        """
        @param  serverid:   ID associated to the service we announce
        @type   serverid:   string (hexadecimal)
        @param  name:      The name used to announce the service via bluetooth
        @type   name:      string
        @rtype:     BTServer object
        @return:    BTServer object
        """
        gobject.GObject.__init__(self)
        self.name = name
        self.serverid = serverid
        self.connectable = 'yes'
        self.filter = {}
        self.port = bluetooth.get_available_port( bluetooth.RFCOMM )
        self.connected = None
        self.bluetooth_connection = None
        self.bluetooth_keycode = None
        self.config = config()
        self.paired_by_us = {}

        self.client_sock = None
        self.server_sock = None

        self.server_io_watch = None

        self.server_sock = bluetooth.BluetoothSocket( bluetooth.RFCOMM )
        self.server_sock.bind(("", self.port))
        self.server_sock.listen(1)

        self._register_bluez_signals()
        self._switch_connectable()
Exemplo n.º 2
0
	def __init__(self, port, protocol="RFCOMM", advertise=False):
		super().__init__(protocol)

		if port == None:
			port = bt.get_available_port(self._protocol)

		self._socket.bind(("", port))
		self._socket.listen(1)

		self._clients = []

		if advertise:
			bt.advertise_service(self._socket, EV3BluetoothServiceName, EV3BluetoothServiceUUID)
Exemplo n.º 3
0
    def __init__(self, name = "LBRC", serverid = "a1e7"):
        gobject.GObject.__init__(self)
        self.name = name
        self.serverid = serverid
        self.connectable = 'yes'
        self.filter = {}
        self.port = bluetooth.get_available_port( bluetooth.L2CAP)
        self.connected = None

        self.client_sock = None
        self.server_sock = None

        self.client_io_watch = None
        self.server_io_watch = None

        self.server_sock = bluetooth.BluetoothSocket( bluetooth.L2CAP )
        self.server_sock.bind(("", self.port))
        self.server_sock.listen(1)

        self.__switch_connectable()
Exemplo n.º 4
0
    def advertise_service(self):
        # Create the sever socket
        self.server_sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)

        # bind the socket to the first available port
        self.port = bluetooth.get_available_port(bluetooth.RFCOMM)
        try:
            err = self.server_sock.bind(("", self.port))
            err = self.server_sock.listen(1)

            # advertise our service
            bluetooth.advertise_service(
                self.server_sock,
                "Freevused",
                service_classes=[bluetooth.SERIAL_PORT_CLASS],
                profiles=[bluetooth.SERIAL_PORT_PROFILE])

            self.isbinded = True
            _debug_("Advertising server to the world")

        except bluetooth.BluetoothError, e:
            self.isbinded = False
            _debug_("broken tooth: %s" % str(e))
            time.sleep(self.bind_timeout)
Exemplo n.º 5
0
    def __init__(self, name = "LBRC", serverid = "9c6c8dce-9545-11dc-a3c1-0011d8388a56"):
        """
        @param  serverid:   ID associated to the service we announce
        @type   serverid:   string (hexadecimal)
        @param  name:      The name used to announce the service via bluetooth
        @type   name:      string
        @rtype:     BTServer object
        @return:    BTServer object
        """
        gobject.GObject.__init__(self)
        self.name = name
        self.serverid = serverid
        self.connectable = 'yes'
        self.filter = {}
        
        self.connected = None
        self.bluetooth_connection = None
        self.bluetooth_keycode = None
        self.config = config()
        self.paired_by_us = {}

        self.client_sock = None
        self.server_sock = None

        self.server_io_watch = None

        self.port = bluetooth.get_available_port( bluetooth.RFCOMM )
        self.server_sock = bluetooth.BluetoothSocket( bluetooth.RFCOMM )
        self.server_sock.bind(("", self.port))
        self.server_sock.listen(1)
        
        self.bluez_db = dinterface(dbus.SystemBus(), 'org.bluez', '/org/bluez', 'org.bluez.Database')
        self.advertise_id = None

        self._register_bluez_signals()
        self._switch_connectable()
Exemplo n.º 6
0
import bluetooth

server_sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)

port = bluetooth.get_available_port(bluetooth.RFCOMM)
server_sock.bind(("", port))
server_sock.listen(1)
print("listening on port %d" % port)

uuid = "1e0ca4ea-299d-4335-93eb-27fcfe7fa848"
bluetooth.advertise_service(server_sock, "FooBar Service", uuid)

client_sock, address = server_sock.accept()
print("Accepted connection from ", address)

data = client_sock.recv(1024)
print("received [%s]" % data)

client_sock.close()
server_sock.close()
Exemplo n.º 7
0
import bluetooth

server_sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )

port = bluetooth.get_available_port( bluetooth.RFCOMM )
server_sock.bind(("",port))
server_sock.listen(1)
print "listening on port %d" % port

uuid = "1e0ca4ea-299d-4335-93eb-27fcfe7fa848"
bluetooth.advertise_service( server_sock, "FooBar Service", uuid )

client_sock,address = server_sock.accept()
print "Accepted connection from ",address

data = client_sock.recv(1024)
print "received [%s]" % data

client_sock.close()
server_sock.close()