This function is called on a timed basis to look for available BLE devices
504841
function (successCallback, errorCallback) {

			// If the caller told us to stop scanning since our last scan, nothing to do
			if (!winble.deviceManager.isScanning)
				return;

			// We want to be notified when any device's connection status changes
			if (winble.deviceManager.connectionWatcher === null) {
				winble.deviceManager.startConnectionWatcher();
			}

			// We'll be looking for devices that support the Generic Access service, which most devices should support.
			var serviceName = "Generic Access";
			var serviceId = winble.gatt.GattServiceUuids.genericAccess;

			// Enumerate devices. This call returns a list of all paired bluetooth devices rather than a list of devices that
			// we can actually see, so once we get each device we need to figure out of it's actually "there" by attempting
			// to connect to it.
			winble.logger.logDebug("scanDevices", "Starting scan...");
			Windows.Devices.Enumeration.DeviceInformation.findAllAsync(
				winble.gatt.GattDeviceService.getDeviceSelectorFromUuid(serviceId), ["System.Devices.ContainerId"]).done(
				function (deviceList) {
					winble.logger.logDebug("scanDevices", "Completed scan (success)");

					// See if we found any connected devices that support the Generic Access service
					if (deviceList.length == 0) {
						var msg = "Could not find any " + serviceName + " devices";
						winble.logger.logError("scanDevices", msg);
						errorCallback(msg, { keepCallback: true });
						return;
					}

					// Add newly discovered devices to our list
					var reachableCount = 0;
					for (var i = 0; i < deviceList.length; i++) {

						// Add it to our device list if it's not already there
						var device = winble.deviceManager.getDeviceFromId(deviceList[i].id, "scanDevices", errorCallback);
						if (device == null) {
							winble.logger.logDebug("scanDevices", "Found new " + serviceName + " device '" + deviceList[i].name + "'");
							device = {
								"gattDevice": deviceList[i],
								"handle": winble.nextGattHandle++,
								"containerId": "{" + deviceList[i].properties["System.Devices.ContainerId"] + "}",
								"serviceList": {},
								"charList": {},
								"descList": {},
								"isBeingVerified": false,
								"isReachable": false,
								"isConnected": false,
								"isDeleted": false,
								"verifySkipCounter": 0,
								"rssi": winble.deviceManager.DEFAULT_RSSI,
								connectSuccessCallback: null
							};
							winble.deviceManager.deviceList[device.handle] = device;
						}

						// Add it to our reporting list if it's not already there
						if (winble.deviceManager.reportList.indexOf(device.handle) == -1)
							winble.deviceManager.reportList.push(device.handle);

						// Use this to write the "Reporting x devices" debug message below
						if (device.isReachable)
							reachableCount++;

						// Verify that the device is actually out there and reachable
						if (!device.isBeingVerified)
							winble.deviceManager.verifyDevice(winble.deviceManager.deviceList[device.handle]);
					}

					winble.logger.logDebug("scanDevices", "Reporting " + reachableCount + " devices");

					// Remove from our reporting list any previously discovered devices that were no longer present in this scan
					winble.deviceManager.cleanReportList();

					// Set up the next scan
					setTimeout(function () {
						winble.deviceManager.scanDevices(successCallback, errorCallback);
					}, winble.deviceManager.SCAN_INTERVAL);

					// Start reporting our devices back to the caller if we haven't already done so on a previous scan
					if (!winble.deviceManager.isReporting) {
						winble.deviceManager.isReporting = true;
						setTimeout(function () {
							winble.deviceManager.reportNextDevice(successCallback);
						}, 500);
					}
				},

				function (error) {
					winble.logger.logDebug("scanDevices", "Completed scan (error)");
					var msg = "Windows.Devices.Enumeration.DeviceInformation.findAllAsync failed: " + error;
					winble.logger.logError("scanDevices", msg);
					errorCallback(msg, { keepCallback: true });
				});
		}
1044024
def find_device(vidpid):
    """"""
    for port in list_ports.comports():
        if re.search(vidpid, port[2], flags=re.IGNORECASE):
            return port[0]

    raise exceptions.RoasterLookupError
419391
def isTrackedDeviceConnected(self, unDeviceIndex):
        """"""

        fn = self.function_table.isTrackedDeviceConnected
        result = fn(unDeviceIndex)
        return result
831461
def _on_scan(_loop, adapter, _adapter_id, info, expiration_time):
    """"""

    info['validity_period'] = expiration_time
    adapter.notify_event_nowait(info.get('connection_string'), 'device_seen', info)
490273
function onDeviceFound(device)
	{
		// For debugging, print advertisement data.
		//console.log(JSON.stringify(device.advertisementData))

		// Alternative way to identify the device by advertised service UUID.
		/*
		if (device.advertisementData.kCBAdvDataServiceUUIDs.indexOf(
			'0000aa10-0000-1000-8000-00805f9b34fb') > -1)
		{
			showMessage('Found the TI SensorTag!')
		}
		*/

		if (device.advertisementData.kCBAdvDataLocalName == 'CC2650 SensorTag')
		{
			showMessage('Found the TI SensorTag!')

			// Stop scanning.
			evothings.ble.stopScan()

			// Connect.
			connectToDevice(device)
		}
	}
542773
function markAndAddActiveDevices(bundle) {
        debugSS('in markAndAddActiveDevices');
        debugLFDS('in markAndAddActiveDevices');
        var defered = q.defer();

        // self.cachedScanBundle.scannedData
        debugMACT('Checking for any previously marked active devices in the last scan cache');

        function isDeviceStillActive(sn) {
            var isActive = false;
            self.cachedCurrentDevices.forEach(function(cachedDevice) {
                var savedAttributes = cachedDevice.savedAttributes;
                var serialNumber = savedAttributes.serialNumber;
                if(sn === serialNumber) {
                    isActive = true;
                }
            });
            return isActive;
        }
        // We need to un-mark any active devices that are no longer active.

        if(self.cachedScanBundle) {
            if(self.cachedScanBundle.scannedData) {
                // debugMACT('We have previously found scanned data', self.cachedScanBundle.scannedData);
                debugMACT('We have previously found scanned data');
                debugPrintFlatScannedData(self.cachedScanBundle.scannedData, debugMACT);
                var scannedData = self.cachedScanBundle.scannedData;
                var dKeys = Object.keys(self.cachedScanBundle.scannedData);
                dKeys.forEach(function(dKey) {
                    var dInfo = scannedData[dKey];
                    var isDeviceActive = dInfo.isActive;
                    var isActuallyActive = isDeviceStillActive(dInfo.serialNumber);
                    debugMACT('SN', dInfo.serialNumber, 'active?',isActuallyActive);
                    // Check to see if the device has the correct active state
                    if(dInfo.isActive != isActuallyActive) {
                        // The device is not actually active...
                        dInfo.isActive = false;
                        // loop through the connection types & fix the active connection.
                        var ctKeys = Object.keys(dInfo.connectionTypes);
                        ctKeys.forEach(function(ctKey) {
                            if(dInfo.connectionTypes[ctKey].isActive) {
                                dInfo.connectionTypes[ctKey].isActive = false;
                                dInfo.connectionTypes[ctKey].insertionMethod = 'scan';
                            }
                        });
                    }
                });
            }
        }

        var promises = self.deviceManager.addCuratedDevices(
            self.cachedCurrentDevices
        );
        
        // Wait for all of the curated devices to get added.
        q.allSettled(promises)
        .then(function() {
            defered.resolve(bundle);
        }, function() {
            defered.resolve(bundle);
        });

        return defered.promise;
    }
910693
def periodic_callback(self):
        

        if self.stopped:
            return

        # Check if we should start scanning again
        if not self.scanning and len(self._connections) == 0 and self.connecting_count == 0:
            self._logger.info("Restarting scan for devices")
            self.start_scan(self._active_scan)
            self._logger.info("Finished restarting scan for devices")
1314307
def _find_device(self, idVendor, idProduct):
        """"""
        for bus in usb.busses():
            for device in bus.devices:
                if (device.idVendor == idVendor and
                    device.idProduct == idProduct):
                    return device
        return None
867347
def _find_devices_mac(self):
        """"""
        self.keyboards.append(Keyboard(self))
        self.mice.append(MightyMouse(self))
        self.mice.append(Mouse(self))
1301899
function (deviceHandle, functionName, errorCallback) {
			var device = winble.deviceManager.deviceList[deviceHandle];
			if (device == null) {
				var msg = "Could not find the requested device handle '" + deviceHandle + "'";
				winble.logger.logError(functionName, msg);
				errorCallback(winble.DEVICE_NOT_FOUND);
			}
			return (device);
		}
380884
def update(self):
        """"""
        _LOGGER.debug("Querying the device..")
        time = datetime.now()
        value = struct.pack('BBBBBBB', PROP_INFO_QUERY,
                            time.year % 100, time.month, time.day,
                            time.hour, time.minute, time.second)

        self._conn.make_request(PROP_WRITE_HANDLE, value)
1195068
def get_alarm(self, area='1', refresh=False):
        """"""
        if self._devices is None:
            self.get_devices()
            refresh = False

        return self.get_device(CONST.ALARM_DEVICE_ID + area, refresh)
1085319
def _stop_scan(self):
        

        try:
            response = self._send_command(6, 4, [])
            if response.payload[0] != 0:
                # Error code 129 means we just were not currently scanning
                if response.payload[0] != 129:
                    self._logger.error('Error stopping scan for devices, error=%d', response.payload[0])

                return False, {'reason': "Could not stop scan for ble devices"}
        except InternalTimeoutError:
            return False, {'reason': "Timeout waiting for response"}
        except DeviceNotConfiguredError:
            return True, {'reason': "Device not connected (did you disconnect the dongle?"}

        return True, None
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()
1192464
def _request_devices(self, url, _type):
        """"""
        res = self._request(url)
        return res.get(_type) if res else {}
666161
def sleep(self, time):
        
        target = 'wait for %s' % str(time)
        self.device(text=target).wait.exists(timeout=time)
1042144
def _find_ble_controllers(self):
        """"""
        controllers = self.bable.list_controllers()
        return [ctrl for ctrl in controllers if ctrl.powered and ctrl.low_energy]