Exemplo n.º 1
0
 def connect(self, address=None, profile=None):
     if address is None:
         print('Need address parameter')
     else:
         self.device = bluezutils.find_device(address, self.adapter_path)
         # print('Device: {0}'.format(device))
         if profile is None:
             self.device.Connect()
         else:
             self.device.ConnectProfile(profile)
Exemplo n.º 2
0
 def name(self, address):
     if address is None:
         print('Need address parameter')
     else:
         device = bluezutils.find_device(address, self.dev_id)
         path = device.object_path
         props = dbus.Interface(self.bus.get_object('org.bluez', path),
                                'org.freedesktop.DBus.Properties')
         name = props.Get('org.bluez.Device1', 'Name')
         return name
Exemplo n.º 3
0
 def uuid(self, address=None):
     if address is None:
         print('Need address parameter')
     else:
         device = bluezutils.find_device(address, self.dev_id)
         path = device.object_path
         print('Path to object: {}'.format(path))
         props = dbus.Interface(self.bus.get_object('org.bluez', path),
                                'org.freedesktop.DBus.Properties')
         cls = props.Get('org.bluez.Device1', 'Class')
         print('0x{0}'.format(cls))
Exemplo n.º 4
0
 def alias(self, address=None, alias_name=None):
     if address is None:
         print('Need address parameter')
     else:
         device = bluezutils.find_device(address, self.dev_id)
         path = device.object_path
         props = dbus.Interface(self.bus.get_object('org.bluez', path),
                                'org.freedesktop.DBus.Properties')
         if alias_name is None:
             alias = props.Get('org.bluez.Device1', 'Alias')
             return alias
         else:
             props.Set('org.bluez.Device1', 'Alias', alias_name)
Exemplo n.º 5
0
 def trusted(self, address=None, state=None):
     if address is None:
         print('Need address parameter')
     else:
         device = bluezutils.find_device(address, self.dev_id)
         path = device.object_path
         props = dbus.Interface(self.bus.get_object('org.bluez', path),
                                'org.freedesktop.DBus.Properties')
         if state is None:
             trusted = props.Get('org.bluez.Device1', 'Trusted')
             return trusted
         else:
             if state == 'yes':
                 value = dbus.Boolean(1)
             elif state == 'no':
                 value = dbus.Boolean(0)
             else:
                 value = dbus.Boolean(state)
             props.Set('org.bluez.Device1', 'Trusted', value)