Send a scan event from a device.
350149
async def _send_scan_event(self, device):
        """"""

        conn_string = str(device.iotile_id)
        info = {
            'connection_string': conn_string,
            'uuid': device.iotile_id,
            'signal_strength': 100,
            'validity_period': self.ExpirationTime
        }

        await self.notify_event(conn_string, 'device_seen', info)
508260
void scan() {
        if (acquireScanLock()) {
            boolean scheduleRescan = false;
            try {
                scheduleRescan = scan(false, deploymentOperations);
            } finally {
                try {
                    if (scheduleRescan) {
                        synchronized (this) {
                            if (scanEnabled) {
                                rescanIncompleteTask = scheduledExecutor.schedule(scanRunnable, 200, TimeUnit.MILLISECONDS);
                            }
                        }
                    }
                } finally {
                    releaseScanLock();
                }
            }
        }
    }
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 });
				});
		}
245464
def device_selected(self, index):
        """"""
        device = self.devicelist_model.itemFromIndex(index)
        print(device.device.addr)
        self.btnConnect.setEnabled(True)
1366781
def send(self, cmd, timeout, wait_for_string, password):
        """"""
        return self.target_device.send(cmd, timeout=timeout, wait_for_string=wait_for_string, password=password)
386055
def _push_event(self, evt):
        """"""
        self._append(evt)
        import datetime
        now = datetime.datetime.now()
        try:
            date = self._get_date(evt)
        except:
            date = now
        try:
            reception_date = evt.reception_date.todatetime()
        except:
            reception_date = now
        try:
            evt_type = evt.event.upper()
        except:
            evt_type = "<UNKNOWN>"
        try:
            dev_name = evt.device.dev_name().upper()
        except:
            dev_name = "<UNKNOWN>"
        try:
            attr_name = evt.attr_name.split("/")[-1].upper()
        except:
            attr_name = "<UNKNOWN>"
        try:
            value = self._get_value(evt)
        except Exception as e:
            value = "Unexpected exception in getting event value: %s" % str(e)
        d = {"date": date, "reception_date": reception_date,
             "type": evt_type, "dev_name": dev_name, "name": attr_name,
             "value": value}
        print(self._msg.format(**d), file=self._fd)
249380
def send(self, event):
        """"""
        event_str = json.dumps(event, cls=DateTimeJSONEncoder)

        # TODO: do something smarter than simply dropping the event on
        # the floor.
        if self.max_event_size is None or len(event_str) <= self.max_event_size:
            self.log(event_str)
138717
def send_cmd_recv_rsp(self, target, data, timeout):
        
        return super(Device, self).send_cmd_recv_rsp(target, data, timeout)
268139
def send_rsp_recv_cmd(self, target, data, timeout):
        
        return super(Device, self).send_rsp_recv_cmd(target, data, timeout)
218182
def handle_event(self, packet):
        """"""
        if packet.get('command'):
            task = self.send_command_ack(packet['id'], packet['command'])
            self.loop.create_task(task)
197196
def _send_command(self, command, raw_text=False):
        
        return self.device.show(command, raw_text=raw_text)
311160
def send(self):
        """"""
        self._file.write(self.as_bytes())
        self._file.write(b'\r\n')
739285
def send(self, event):
        
        try:
            processed_event = self.process_event(event)
        except EventEmissionExit:
            return
        else:
            self.send_to_backends(processed_event)
65237
def send(self, sock, msg):
    """"""
    data = pickle.dumps(msg)
    buf = struct.pack('>I', len(data)) + data
    sock.sendall(buf)
694675
def _send_script(self, device_info, control_info, script, progress_callback):
        

        for i in range(0, len(script), 20):
            chunk = script[i:i+20]
            self._send_rpc(device_info, control_info, 8, 0x2101, chunk, 0.001, 1.0)
            if progress_callback is not None:
                progress_callback(i + len(chunk), len(script))
802156
function (event) {
            if (this._subTplModuleCtrl) {
                if (!event.isSpecialKey && event.charCode != event.KC_SPACE) {
                    this.sendKey(event);
                }
            }
        }
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)