Open an RFCOMM socket to the Bluetooth device.
<p>
The device may or may not actually exist, the argument is just a
reference to it.
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;
    }
801466
def _try_open(cls):
    """"""
    handle = None
    for usb_cls, subcls, protocol in [(adb_device.CLASS,
                                       adb_device.SUBCLASS,
                                       adb_device.PROTOCOL),
                                      (fastboot_device.CLASS,
                                       fastboot_device.SUBCLASS,
                                       fastboot_device.PROTOCOL)]:
      try:
        handle = local_usb.LibUsbHandle.open(
            serial_number=cls.serial_number,
            interface_class=usb_cls,
            interface_subclass=subcls,
            interface_protocol=protocol)
        cls.serial_number = handle.serial_number
        return True
      except usb_exceptions.DeviceNotFoundError:
        pass
      except usb_exceptions.MultipleInterfacesFoundError:
        _LOG.warning('Multiple Android devices found, ignoring!')
      finally:
        if handle:
          handle.close()
    return False
342130
@Override
  public ClientSocket open()
  {
    State state = _state;
    
    if (! state.isInit())
      return null;

    ClientSocket stream = openRecycle();

    if (stream != null)
      return stream;

    return connect();
  }
47351
private void open() throws ModbusIOException {
        if (commPort != null && !commPort.isOpen()) {
            setTimeout(timeout);
            try {
                commPort.open();
            }
            catch (IOException e) {
                throw new ModbusIOException(String.format("Cannot open port %s - %s", commPort.getDescriptivePortName(), e.getMessage()));
            }
        }
    }
780647
public void start() {
        IntentFilter filter = new IntentFilter();
        filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
        filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
        filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
        context.registerReceiver(receiver, filter);

        LogManager.d(TAG, "started listening for BluetoothAdapter events");
    }
760477
@RequiresPermission(Manifest.permission.BLUETOOTH)
	static void checkAdapterStateOn(@Nullable final BluetoothAdapter adapter) {
		if (adapter == null || adapter.getState() != BluetoothAdapter.STATE_ON) {
			throw new IllegalStateException("BT Adapter is not turned ON");
		}
	}
633457
async def open(self) -> bool:
        """"""
        _LOGGER.debug('%s: Sending open command', self.name)
        if not await self._set_state(1):
            return False

        # Do not allow update of this device's state for 5 seconds.
        self.next_allowed_update = datetime.utcnow() + timedelta(seconds=5)

        # Ensure state is open or opening
        if self.state not in (STATE_OPEN, STATE_OPENING):
            # Set state to opening
            self._update_state('4')
            self._device_json = self._device['device_info']

        _LOGGER.debug('%s: Open command send', self.name)
        return True
1336231
function Device (device, sp) {
  if (!(device && sp))
    throw new Error('a Device and a SerialPort must be passed');

  for (var i in device)
    this[i] = device[i];

  this._open = false;
  this._sp = sp;

  EventEmitter.call(this);
}
918249
@SuppressWarnings("UnusedReturnValue")
	private boolean initialize() {
		// For API level 18 and above, get a reference to BluetoothAdapter through
		// BluetoothManager.
		final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
		if (bluetoothManager == null) {
			loge("Unable to initialize BluetoothManager.");
			return false;
		}

		mBluetoothAdapter = bluetoothManager.getAdapter();
		if (mBluetoothAdapter == null) {
			loge("Unable to obtain a BluetoothAdapter.");
			return false;
		}

		return true;
	}
960234
public void open() throws ModbusException {

        // Start the listener if it isn' already running

        if (!isRunning) {
            try {
                listenerThread = new Thread(listener);
                listenerThread.start();
                isRunning = true;
            }
            catch (Exception x) {
                closeListener();
                throw new ModbusException(x.getMessage());
            }
        }
    }
820625
function (successCallback, errorCallback, deviceHandle) {

			// Find the requested device in our list of discovered devices
			var device = winble.deviceManager.getDeviceFromHandle(deviceHandle, "getDeviceRssi", errorCallback);
			if (device == null)
				return;

			// Return the RSSI value
			winble.logger.logDebug("getDeviceRssi", "Warning: Windows BLE does not currently provide RSSI");
			successCallback(device.rssi);
		}
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.");
            }
        }
    }
8260
public void connectToLink(Link link) throws ShanksException {
        if (!this.linksList.contains(link)) {
            this.linksList.add(link);
            logger.finer("Device " + this.getID()
                    + " is now connected to Link " + link.getID());
            link.connectDevice(this);
        }
    }
546199
private void createSocket() throws Exception {
        // Some socket options, notably setReceiveBufferSize, must be set before the
        // socket is connected. So, first create the socket, then set options, then connect.
        if (m_sslParams != null) {
            SSLSocketFactory factory = m_sslParams.createSSLContext().getSocketFactory();
            m_socket = factory.createSocket(m_host, m_port);
            setSocketOptions();
            ((SSLSocket)m_socket).startHandshake();
        } else {
            m_socket = new Socket();
            setSocketOptions();
            SocketAddress sockAddr = new InetSocketAddress(m_host, m_port);
            m_socket.connect(sockAddr);
        }
    }
1367785
def device_add(self, mountpoint, *device):
        
        if len(device) == 0:
            return

        args = {
            'mountpoint': mountpoint,
            'devices': device,
        }

        self._device_chk.check(args)

        self._client.sync('btrfs.device_add', args)
1086357
def _start_socket(self):
        
        if self._bm is None:
            self._bm = BinanceSocketManager(self._client)

        self._conn_key = self._bm.start_depth_socket(self._symbol, self._depth_event)
        if not self._bm.is_alive():
            self._bm.start()

        # wait for some socket responses
        while not len(self._depth_message_buffer):
            time.sleep(1)
462245
def event(self, interface_id, address, value_key, value):
        """"""
        LOG.debug("RPCFunctions.event: interface_id = %s, address = %s, value_key = %s, value = %s" % (
            interface_id, address, value_key.upper(), str(value)))
        self.devices_all[interface_id.split(
            '-')[-1]][address].event(interface_id, value_key.upper(), value)
        if self.eventcallback:
            self.eventcallback(interface_id=interface_id, address=address,
                               value_key=value_key.upper(), value=value)
        return True