Enable bluetooth discoverablility.
199932
async def set_discovery_enabled(self):
        """"""
        endpoint = '/setup/bluetooth/discovery'
        data = {"enable_discovery": True}
        url = API.format(ip=self._ipaddress, endpoint=endpoint)
        try:
            async with async_timeout.timeout(5, loop=self._loop):
                response = await self._session.post(url,
                                                    headers=HEADERS,
                                                    data=json.dumps(data))
                _LOGGER.debug(response.status)
        except (asyncio.TimeoutError,
                aiohttp.ClientError, socket.gaierror) as error:
            _LOGGER.error('Error connecting to %s - %s', self._ipaddress, error)
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
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;
    }
650593
def light_on(self, button: Button):
        """"""
        self.outport.send(mido.Message('polytouch', note=button.light, value=1))
361200
def enable_mfa_device(self,
                          user_name,
                          serial_number,
                          authentication_code_1,
                          authentication_code_2):
        """"""
        user = self.get_user(user_name)
        if serial_number in user.mfa_devices:
            raise IAMConflictException(
                "EntityAlreadyExists",
                "Device {0} already exists".format(serial_number)
            )

        user.enable_mfa_device(
            serial_number,
            authentication_code_1,
            authentication_code_2
        )
39510
def start(self):
        ''''''
        self.update_device_info()
        self.get_device_status(0) # start addons.
        self.hook()
        self.thread = threading.Thread(target=self._run)
        self.thread.start()
        self.running = True
812732
async def discover(timeout, debug=0, callback=None):
        """"""
        ST = "urn:schemas-sony-com:service:ScalarWebAPI:1"
        _LOGGER.info("Discovering for %s seconds" % timeout)

        from async_upnp_client import UpnpFactory
        from async_upnp_client.aiohttp import AiohttpRequester

        async def parse_device(device):
            requester = AiohttpRequester()
            factory = UpnpFactory(requester)

            url = device["location"]
            device = await factory.async_create_device(url)

            if debug > 0:
                print(etree.ElementTree.tostring(device.xml).decode())

            NS = {
                'av': 'urn:schemas-sony-com:av',
            }

            info = device.xml.find(".//av:X_ScalarWebAPI_DeviceInfo", NS)
            if not info:
                _LOGGER.error("Unable to find X_ScalaerWebAPI_DeviceInfo")
                return

            endpoint = info.find(".//av:X_ScalarWebAPI_BaseURL", NS).text
            version = info.find(".//av:X_ScalarWebAPI_Version", NS).text
            services = [x.text for x in info.findall(".//av:X_ScalarWebAPI_ServiceType", NS)]

            dev = DiscoveredDevice(name=device.name,
                                   model_number=device.model_number,
                                   udn=device.udn,
                                   endpoint=endpoint,
                                   version=version,
                                   services=services,
                                   upnp_services=list(device.services.keys()),
                                   upnp_location=url)

            _LOGGER.debug("Discovered: %s" % dev)

            if callback is not None:
                await callback(dev)

        await async_search(timeout=timeout,
                             service_type=ST,
                             async_callback=parse_device)
1109062
def enable(self, enable_password):
        """"""
        if self.device.prompt[-1] == '#':
            self.log("Device is already in privileged mode")
            return

        events = [self.password_re, self.device.prompt_re, pexpect.TIMEOUT, pexpect.EOF]
        transitions = [
            (self.password_re, [0], 1, partial(a_send_password, enable_password), 10),
            (self.password_re, [1], -1, ConnectionAuthenticationError("Incorrect enable password",
                                                                      self.device.hostname), 0),
            (self.device.prompt_re, [0, 1, 2, 3], -1, a_expected_prompt, 0),
            (pexpect.TIMEOUT, [0, 1, 2], -1, ConnectionAuthenticationError("Unable to get privileged mode",
                                                                           self.device.hostname), 0),
            (pexpect.EOF, [0, 1, 2], -1, ConnectionError("Device disconnected"), 0)
        ]
        self.device.ctrl.send_command(self.enable_cmd)
        fsm = FSM("IOS-ENABLE", self.device, events, transitions, timeout=10, max_transitions=5)
        fsm.run()
        if self.device.prompt[-1] != '#':
            raise ConnectionAuthenticationError("Privileged mode not set", self.device.hostname)
337606
def enable(self):
        """"""
        with self._lock:
            if self.filter is None:
                self.filter = self._filter_type(self)
350547
def run(self):
        """"""
        self.socket = self.bluez.hci_open_dev(self.bt_device_id)

        filtr = self.bluez.hci_filter_new()
        self.bluez.hci_filter_all_events(filtr)
        self.bluez.hci_filter_set_ptype(filtr, self.bluez.HCI_EVENT_PKT)
        self.socket.setsockopt(self.bluez.SOL_HCI, self.bluez.HCI_FILTER, filtr)

        self.set_scan_parameters()
        self.toggle_scan(True)

        while self.keep_going:
            pkt = self.socket.recv(255)
            event = to_int(pkt[1])
            subevent = to_int(pkt[3])
            if event == LE_META_EVENT and subevent == EVT_LE_ADVERTISING_REPORT:
                # we have an BLE advertisement
                self.process_packet(pkt)
        self.socket.close()
275930
public synchronized void enableGestureDetector() {
        final GVRTouchPadGestureListener gestureListener = new GVRTouchPadGestureListener() {
            @Override
            public boolean onSwipe(MotionEvent e, Action action, float vx, float vy) {
                if (null != mGVRMain) {
                    mGVRMain.onSwipe(action, vx);
                }
                return true;
            }

            @Override
            public boolean onSingleTapUp(MotionEvent e) {
                if (null != mGVRMain) {
                    mGVRMain.onSingleTapUp(e);
                }
                return true;
            }
        };
        mGestureDetector = new GestureDetector(mActivity.getApplicationContext(), gestureListener);
        getEventReceiver().addListener(new GVREventListeners.ActivityEvents() {
            @Override
            public void dispatchTouchEvent(MotionEvent event) {
                mGestureDetector.onTouchEvent(event);
            }
        });
    }
1200503
def discover(self, seconds=2):
        
        log.info("Discovering devices")
        with gevent.Timeout(seconds, StopBroadcasting) as timeout:
            try:
                try:
                    while True:
                        self.upnp.broadcast()
                        gevent.sleep(1)
                except Exception as e:
                    raise StopBroadcasting(e)
            except StopBroadcasting:
                return
481331
async def set_bluetooth_settings(self, target: str, value: str) -> None:
        """"""
        params = {"settings": [{"target": target, "value": value}]}
        return await self.services["avContent"]["setBluetoothSettings"](params)
315508
private void setupAudio() {
		audio.setAutoplay(cbAutoPlay.isSelected());
		audio.setLoop(!cbLoop.isDisabled() && cbLoop.isSelected());
		audio.setControls(cbControls.isSelected() ? WAudio.Controls.PLAY_PAUSE : WAudio.Controls.NATIVE);
		audio.setDisabled(cbControls.isSelected() && cbDisable.isSelected());
	}
235294
def CreatePairedDevice(self, device_address, agent, capability):
    '''
    '''
    device_name = 'dev_' + device_address.replace(':', '_').upper()
    device_path = DefaultAdapter(self) + '/' + device_name

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

    device = mockobject.objects[device_path]

    # Based off pairing with a Sennheise headset.
    uuids = [
        '00001108-0000-1000-8000-00805f9b34fb',
        '0000110b-0000-1000-8000-00805f9b34fb',
        '0000110e-0000-1000-8000-00805f9b34fb',
        '0000111e-0000-1000-8000-00805f9b34fb',
    ]

    device.props[DEVICE_IFACE]['UUIDs'] = dbus.Array(uuids, variant_level=1)
    device.props[DEVICE_IFACE]['Paired'] = dbus.Boolean(True, variant_level=1)
    device.props[DEVICE_IFACE]['LegacyPairing'] = dbus.Boolean(True,
                                                               variant_level=1)
    device.props[DEVICE_IFACE]['Trusted'] = dbus.Boolean(False,
                                                         variant_level=1)
    device.props[DEVICE_IFACE]['Connected'] = dbus.Boolean(True,
                                                           variant_level=1)

    adapter = mockobject.objects[self.path]
    adapter.EmitSignal(ADAPTER_IFACE, 'DeviceCreated',
                       'o', [dbus.ObjectPath(device_path, variant_level=1)])

    for prop in device.props[DEVICE_IFACE]:
        try:
            device.EmitSignal(DEVICE_IFACE, 'PropertyChanged', 'sv', [
                prop, device.props[prop]
            ])
        except KeyError:
            pass

    return dbus.ObjectPath(device_path, variant_level=1)
912196
function (device) {

			/*
			winble.logger.logDebug("verifyDevice", device.gattDevice.name + ": Faking isVerified");
			device.isReachable = true;
			device.isConnected = true;
			return;
			*/
			if (device.verifySkipCounter > 0) {
				if (device.verifySkipCounter++ <= winble.deviceManager.VERIFY_SKIP_COUNT) {
					winble.logger.logDebug("verifyDevice", "Skipping " + device.gattDevice.name + ", pass " + (device.verifySkipCounter - 1) + " of " + winble.deviceManager.VERIFY_SKIP_COUNT);
					return;
				}
				device.verifySkipCounter = 0;
			}

			device.isBeingVerified = true;

			// Connect to the device. I have never seen this call fail, whether the device is actually reachable or not; I think we're
			// just getting access to the device's entry in Windows bluetooth database here.
			winble.logger.logDebug("verifyDevice", "Attempting to connect to " + device.gattDevice.name);
			winble.gatt.GattDeviceService.fromIdAsync(device.gattDevice.id).done(
				function (service) {
					if (service) {

						// We successfully connected. Now get a list of all characteristics that this device supports
						// and try to read the first one in "uncached" mode (ie, directly from the device).
						winble.logger.logDebug("verifyDevice", device.gattDevice.name + ": Successfully connected, getting characteristics");
						var charList = service.getAllCharacteristics();
						winble.logger.logDebug("verifyDevice", device.gattDevice.name + ": Successfully got characteristics, " + charList.length + " items in list");
						if (typeof charList[0] !== "undefined") {
							var characteristic = charList[0];
							try {
								winble.logger.logDebug("verifyDevice", device.gattDevice.name + ": Reading first characteristic");
								characteristic.readValueAsync(Windows.Devices.Bluetooth.BluetoothCacheMode.uncached).done(
									function (currentValue) {
										if (currentValue.status === winble.gatt.GattCommunicationStatus.success) {
											// We were able to read the value directly from the device, it's really out there.
											winble.logger.logDebug("verifyDevice", device.gattDevice.name + ": Successfully read first characteristic");
											device.isReachable = true;
											device.isConnected = true;
										} else {
											// We couldn't read the value directly from the device, so we can't currently see it.
											winble.logger.logDebug("verifyDevice", device.gattDevice.name + ": Error reading first characteristic, access denied or unavailable");
											device.isReachable = false;
											device.isConnected = false;
											device.verifySkipCounter = 1;
										}
										device.isBeingVerified = false;
									},
									function (error) {
										winble.logger.logDebug("verifyDevice", device.gattDevice.name + ": Error reading first characteristic, " + error);
										device.isReachable = false;
										device.isConnected = false;
										device.verifySkipCounter = 1;
										device.isBeingVerified = false;
									});
							} catch (e) {
								winble.logger.logDebug("verifyDevice", "Error connecting to " + device.gattDevice.name + ", access denied or unavailable");
								device.isReachable = false;
								device.isConnected = false;
								device.isBeingVerified = false;
							}
						}
					} else {
						winble.logger.logDebug("verifyDevice", "Error connecting to " + device.gattDevice.name + ", access denied or unavailable");
						device.isReachable = false;
						device.isConnected = false;
						device.isBeingVerified = false;
					}
				},
				function (error) {
					winble.logger.logDebug("verifyDevice", "Error connecting to " + device.gattDevice.name + ": " + error);
					device.isReachable = false;
					device.isConnected = false;
					device.isBeingVerified = false;
				});
		}
404641
def enable(self):
        """"""
        # Flip on the power and enable bits.
        self._write8(TCS34725_ENABLE, TCS34725_ENABLE_PON)
        time.sleep(0.01)
        self._write8(TCS34725_ENABLE, (TCS34725_ENABLE_PON | TCS34725_ENABLE_AEN))