Connect a device
491527
def Connect(self):
    ''' '''
    device_path = self.path

    if device_path not in mockobject.objects:
        raise dbus.exceptions.DBusException('No such device.',
                                            name='org.bluez.Error.NoSuchDevice')

    device = mockobject.objects[device_path]

    device.props[AUDIO_IFACE]['State'] = dbus.String("connected",
                                                     variant_level=1)
    device.EmitSignal(AUDIO_IFACE, 'PropertyChanged', 'sv', [
        'State', dbus.String("connected", variant_level=1),
    ])

    device.props[DEVICE_IFACE]['Connected'] = dbus.Boolean(True,
                                                           variant_level=1)
    device.EmitSignal(DEVICE_IFACE, 'PropertyChanged', 'sv', [
        'Connected', dbus.Boolean(True, variant_level=1),
    ])
490722
def connect(self, mac: str):
        """"""
        import pygatt

        address_type = pygatt.BLEAddressType.public
        if self._address_type == 'random':
            address_type = pygatt.BLEAddressType.random
        self._device = self._adapter.connect(mac, address_type=address_type)
166581
def connect(self):
        '''
        
        '''
        if self.connected:
            raise RuntimeError(
                '{} is connected already'.format(self.__class__.__name__))
        if self.closed:
            raise RuntimeError(
                '{} is closed already'.format(self.__class__.__name__))
        self.connected = True
        self._connect()
1039686
def start_device(name, frontend, backend):
    
    device = getattr(devices, name)
    device(frontend, backend)
1157394
def init_device(self):
        """"""
        Device.init_device(self)

        # Add anything here that has to be done before the device is set to
        # its ON state.

        self._set_master_state('on')
        self._devProxy = DeviceProxy(self.get_name())
28901
def connect(self, addr):
        '''
        
        '''
        if addr.find(':') == -1:
            addr += ':5555'
        output = self.run_cmd('connect', addr)
        return 'unable to connect' not in output
229218
def connect(self, signal, **kwargs):
        """"""
        signal.connect(self, **kwargs)
        self.connections.append((signal, kwargs))
335506
def connect(self, params):
        """"""

        self._logger.info("iface '%s' connects to AP: '%s'",
                          self.name(), params.ssid)

        self._wifi_ctrl.connect(self._raw_obj, params)
184160
def connect
      unless @connected
        once('report_version', ->() do
          once('firmware_query', ->() do
            once('capability_query', ->() do
              once('analog_mapping_query', ->() do

                2.times { |i| toggle_pin_reporting(i) }

                @connected = true
                emit('ready')
              end)
              query_analog_mapping
           end)
            query_capabilities
          end)
        end)

         until connected?
          read_and_process
          delay(0.5)
        end
      end

      self
    end
495334
public void connectDevice(Device device) throws ShanksException {
        if (this.linkedDevices.size() < deviceCapacity) {
            if (!this.linkedDevices.contains(device)) {
                this.linkedDevices.add(device);
                device.connectToLink(this);
                logger.finer("Link " + this.getID() + " has Device "
                        + device.getID() + " in its linked device list.");
            } else {
                logger.finer("Link " + this.getID() + " already has Device "
                        + device.getID() + " in its linked device list.");
            }
        } else {
            if (!this.linkedDevices.contains(device)) {
                logger.warning("Link " + this.getID()
                        + " is full of its capacity. Device " + device.getID()
                        + " was not included in its linked device list.");
                throw new TooManyConnectionException(this);
            } else {
                logger.finer("Link " + this.getID() + " already has Device "
                        + device.getID() + " in its linked device list.");
            }
        }
    }
1057512
def ConnectHandler(*args, **kwargs):
    """"""
    if kwargs["device_type"] not in platforms:
        raise ValueError(
            "Unsupported device_type: "
            "currently supported platforms are: {}".format(platforms_str)
        )
    ConnectionClass = ssh_dispatcher(kwargs["device_type"])
    return ConnectionClass(*args, **kwargs)
426325
public synchronized void connected(BluetoothSocket socket, BluetoothDevice
            device, final String socketType) {
        // Cancel the thread that completed the connection
        if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}

        // Cancel any thread currently running a connection
        if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}

        // Cancel the accept thread because we only want to connect to one device
        if (mSecureAcceptThread != null) {
            mSecureAcceptThread.cancel();
            mSecureAcceptThread = null;
        }

        // Start the thread to manage the connection and perform transmissions
        mConnectedThread = new ConnectedThread(socket, socketType);
        mConnectedThread.start();

        // Send the name of the connected device back to the UI Activity
        Message msg = mHandler.obtainMessage(BluetoothState.MESSAGE_DEVICE_NAME);
        Bundle bundle = new Bundle();
        bundle.putString(BluetoothState.DEVICE_NAME, device.getName());
        bundle.putString(BluetoothState.DEVICE_ADDRESS, device.getAddress());
        msg.setData(bundle);
        mHandler.sendMessage(msg);

        setState(BluetoothState.STATE_CONNECTED);
    }
861427
def connect(self, receiver):
        """"""
        if not callable(receiver):
            raise ValueError('Invalid receiver: %s' % receiver)
        self.receivers.append(receiver)
502841
def connect(self, mac: str):
        """"""
        from bluepy.btle import Peripheral
        match_result = re.search(r'hci([\d]+)', self.adapter)
        if match_result is None:
            raise BluetoothBackendException(
                'Invalid pattern "{}" for BLuetooth adpater. '
                'Expetected something like "hci0".'.format(self.adapter))
        iface = int(match_result.group(1))
        self._peripheral = Peripheral(mac, iface=iface, addrType=self.address_type)
1200985
async def pair_with_device(loop):
    """"""
    my_zeroconf = Zeroconf()
    details = conf.AppleTV('127.0.0.1', 'Apple TV')
    details.add_service(conf.DmapService('login_id'))
    atv = pyatv.connect_to_apple_tv(details, loop)

    atv.pairing.pin(PIN_CODE)
    await atv.pairing.start(zeroconf=my_zeroconf, name=REMOTE_NAME)
    print('You can now pair with pyatv')

    # Wait for a minute to allow pairing
    await asyncio.sleep(60, loop=loop)

    await atv.pairing.stop()

    # Give some feedback about the process
    if atv.pairing.has_paired:
        print('Paired with device!')
        print('Credentials:', atv.pairing.credentials)
    else:
        print('Did not pair with device!')

    my_zeroconf.close()
53493
def connect(self, slot):
        
        self._ensure_slot_args(slot)
        if not self.is_connected(slot):
            self.slots.append(slot)
1311174
public synchronized void connect(BluetoothDevice device, boolean past)
            throws IOException, InterruptedException {
        // Cancel any thread attempting to make a connection
        if (mState == STATE_CONNECTING) {
            if (mConnectThread != null) {
                mConnectThread.cancel();
                mConnectThread = null;
            }
        }

        // Cancel any thread currently running a connection
        if (mEngConnectedThread != null) {
            mEngConnectedThread.cancel();
            mEngConnectedThread = null;
        }
        if (mImpConnectedThread != null) {
            mImpConnectedThread.cancel();
            mImpConnectedThread = null;
        }

        mPast = past;

        // Start the thread to connect with the given device
        try {
            mConnectThread = new ConnectThread(device);
            mConnectThread.start();
        } catch (IOException e) {
            e.printStackTrace();
            connectionFailed();
            setState(STATE_NONE);
        }
        setState(STATE_CONNECTING);
    }