Convenience method to add a Bluetooth adapter

    You have to specify a device name which must be a valid part of an object
    path, e. g. "hci0", and an arbitrary system name (pretty hostname).

    Returns the new object path.
503552
def AddAdapter(self, device_name, system_name):
    '''
    '''
    path = '/org/bluez/' + device_name
    adapter_properties = {
        'UUIDs': dbus.Array([
            # Reference:
            # http://git.kernel.org/cgit/bluetooth/bluez.git/tree/lib/uuid.h
            # PNP
            '00001200-0000-1000-8000-00805f9b34fb',
            # Generic Access Profile
            '00001800-0000-1000-8000-00805f9b34fb',
            # Generic Attribute Profile
            '00001801-0000-1000-8000-00805f9b34fb',
            # Audio/Video Remote Control Profile (remote)
            '0000110e-0000-1000-8000-00805f9b34fb',
            # Audio/Video Remote Control Profile (target)
            '0000110c-0000-1000-8000-00805f9b34fb',
        ], variant_level=1),
        'Discoverable': dbus.Boolean(True, variant_level=1),
        'Discovering': dbus.Boolean(True, variant_level=1),
        'Pairable': dbus.Boolean(True, variant_level=1),
        'Powered': dbus.Boolean(True, variant_level=1),
        'Address': dbus.String('00:01:02:03:04:05', variant_level=1),
        'Alias': dbus.String(system_name, variant_level=1),
        'Modalias': dbus.String('usb:v1D6Bp0245d050A', variant_level=1),
        'Name': dbus.String(system_name, variant_level=1),
        # Reference:
        # http://bluetooth-pentest.narod.ru/software/
        # bluetooth_class_of_device-service_generator.html
        'Class': dbus.UInt32(268, variant_level=1),  # Computer, Laptop
        'DiscoverableTimeout': dbus.UInt32(180, variant_level=1),
        'PairableTimeout': dbus.UInt32(180, variant_level=1),
    }

    self.AddObject(path,
                   ADAPTER_IFACE,
                   # Properties
                   adapter_properties,
                   # Methods
                   [
                       ('RemoveDevice', 'o', '', ''),
                       ('StartDiscovery', '', '', ''),
                       ('StopDiscovery', '', '', ''),
                   ])

    adapter = mockobject.objects[path]
    adapter.AddMethods(MEDIA_IFACE, [
        ('RegisterEndpoint', 'oa{sv}', '', ''),
        ('UnregisterEndpoint', 'o', '', ''),
    ])
    adapter.AddMethods(NETWORK_SERVER_IFACE, [
        ('Register', 'ss', '', ''),
        ('Unregister', 's', '', ''),
    ])

    manager = mockobject.objects['/']
    manager.EmitSignal(OBJECT_MANAGER_IFACE, 'InterfacesAdded',
                       'oa{sa{sv}}', [
                           dbus.ObjectPath(path),
                           {ADAPTER_IFACE: adapter_properties},
                       ])

    return path
435698
def add(name, address)
      device = Device.new(name: name, address: address)
      self << device
      device
    end
932231
def _add_device_to_device_group(self, device):
        '''
        '''

        device_name = get_device_info(device).name
        dg = pollster(self._get_device_group)(device)
        dg.devices_s.devices.create(name=device_name, partition=self.partition)
        pollster(self._check_device_exists_in_device_group)(device_name)
453747
def update_hostname(self, prompt):
        """"""
        result = re.search(self.prompt_re, prompt)
        if result:
            hostname = result.group('hostname')
            self.log("Hostname detected: {}".format(hostname))
        else:
            hostname = self.device.hostname
            self.log("Hostname not set: {}".format(prompt))
        return hostname
805067
public static IpCamDevice register(IpCamDevice ipcam) {

		for (WebcamDevice d : DEVICES) {
			String name = ipcam.getName();
			if (d.getName().equals(name)) {
				throw new WebcamException(String.format("Webcam with name '%s' is already registered", name));
			}
		}

		DEVICES.add(ipcam);

		rescan();

		return ipcam;
	}
965868
def add_device():
    
    req = request.get_json()
    success = False
    if 'device_id' in req and 'host' in req:
        success = add(req['device_id'], req['host'], req.get('adbkey', ''), req.get('adb_server_ip', ''), req.get('adb_server_port', 5037))
    return jsonify(success=success)
1342263
def address_():
    '''
    
    '''
    ret = {}
    cmd = 'hciconfig'
    out = __salt__['cmd.run'](cmd).splitlines()
    dev = ''
    for line in out:
        if line.startswith('hci'):
            comps = line.split(':')
            dev = comps[0]
            ret[dev] = {
                'device': dev,
                'path': '/sys/class/bluetooth/{0}'.format(dev),
            }
        if 'BD Address' in line:
            comps = line.split()
            ret[dev]['address'] = comps[2]
        if 'DOWN' in line:
            ret[dev]['power'] = 'off'
        if 'UP RUNNING' in line:
            ret[dev]['power'] = 'on'
    return ret
1298180
def add_device_items(self, item, device):
        
        if item in ('aux', 'console'):
            self.node['properties'][item] = device[item]
        elif item.startswith('slot'):
            # if self.device_info['model'] == 'c7200':
            #     if item != 'slot0':
            #         self.node['properties'][item] = device[item]
            # else:
            self.node['properties'][item] = device[item]
        elif item == 'connections':
            self.connections = device[item]
        elif INTERFACE_RE.search(item) or VBQ_INT_RE.search(item):
            self.interfaces.append({'from': item,
                                    'to': device[item]})
        elif NUMBER_RE.search(item):
            if self.device_info['type'] == 'EthernetSwitch':
                self.calc_ethsw_port(item, device[item])
            elif self.device_info['type'] == 'FrameRelaySwitch':
                self.calc_frsw_port(item, device[item])
        elif MAPINT_RE.search(item):
            self.add_mapping((item, device[item]))
        elif item == 'cnfg':
            new_config = os.path.join('configs', 'i%s_startup-config.cfg' %
                                      self.node['id'])
            self.node['properties']['startup_config'] = new_config

            self.config.append({'old': fix_path(device[item]),
                                'new': new_config})
        elif item.startswith('wic'):
            self.add_wic(item, device[item])
        elif item == 'symbol':
            self.set_symbol(device[item])
        elif item == 'nics':
            self.node['properties']['adapters'] = device[item]
        elif item == 'image':
            self.node['properties']['vmname'] = device[item]
        elif item == 'vbox_id' or item == 'qemu_id':
            self.node[item] = device[item]
501943
def device(self, device_id, *args, **kwargs):
        
        return Device(device_id, self.corsair_sdk, self._corsair_sdk_path, *args, **kwargs)
565557
public static device_profile add(nitro_service client, device_profile resource) throws Exception
	{
		resource.validate("add");
		return ((device_profile[]) resource.perform_operation(client, "add"))[0];
	}
143645
def do_set_device(self, args):
        
        params = args.split()
        device = None

        try:
            device = params[0]
        except IndexError:
            _LOGGING.error('Device name required.')
            self.do_help('set_device')

        if device:
            self.tools.device = device
1187161
def add_group(self, name, devices):
        
        device = self.add_device(name, "group")
        device.add_to_group(devices)
        return device
484662
private BluetoothSocket setupSocket(BluetoothDevice device)
            throws BluetoothException {
        if (device == null) {
            Log.w(TAG, "Can't setup socket -- device is null");
            throw new BluetoothException();
        }

        Log.d(TAG, "Scanning services on " + device);
        BluetoothSocket socket;
        try {
            socket = device.createRfcommSocketToServiceRecord(RFCOMM_UUID);
        } catch (IOException e) {
            String error = "Unable to open a socket to device " + device;
            Log.w(TAG, error);
            throw new BluetoothException(error, e);
        }

        return socket;
    }
328463
def _getdevicetuple(iobtdevice):
    
    addr = _macutil.formatdevaddr(iobtdevice.getAddressString())
    name = iobtdevice.getName()
    cod = iobtdevice.getClassOfDevice()
    return (addr, name, cod)
550921
def _add_device(self, scs_id, ha_id, name):
        
        if scs_id in self._devices:
            return

        self._devices[scs_id] = {
            'name': name,
            'ha_id': ha_id
        }
281280
def adapter_add_nio_binding(self, adapter_number, nio):
        
        try:
            adapter = self._ethernet_adapters[adapter_number]
        except IndexError:
            raise DockerError("Adapter {adapter_number} doesn't exist on Docker container '{name}'".format(name=self.name,
                                                                                                           adapter_number=adapter_number))

        if self.status == "started" and self.ubridge:
            yield from self._connect_nio(adapter_number, nio)

        adapter.add_nio(0, nio)
        log.info("Docker container '{name}' [{id}]: {nio} added to adapter {adapter_number}".format(name=self.name,
                                                                                                    id=self._id,
                                                                                                    nio=nio,
                                                                                                    adapter_number=adapter_number))
784046
private static UsbDevice findDeviceByNameLowLevel(final String name) throws KNXException
	{
		final List<String> list = getDeviceDescriptionsLowLevel();
		if (name.isEmpty())
			list.removeIf(i -> !isKnxInterfaceId(i.substring(i.indexOf("ID") + 3, i.indexOf("\n"))));
		else
			list.removeIf(i -> i.toLowerCase().indexOf(name.toLowerCase()) == -1);
		if (list.isEmpty())
			throw new KNXException("no USB device found with name matching '" + name + "'");

		final String desc = list.get(0);
		final String id = desc.substring(desc.indexOf("ID") + 3, desc.indexOf("\n"));
		return findDevice(id);
	}