Sync settings to the Konnected device
187409
def put_settings(self, sensors=[], actuators=[], auth_token=None,
                     endpoint=None, blink=None, discovery=None,
                     dht_sensors=[], ds18b20_sensors=[]):
        
        url = self.base_url + '/settings'

        payload = {
            "sensors": sensors,
            "actuators": actuators,
            "dht_sensors": dht_sensors,
            "ds18b20_sensors": ds18b20_sensors,
            "token": auth_token,
            "apiUrl": endpoint
        }

        if blink is not None:
            payload['blink'] = blink

        if discovery is not None:
            payload['discovery'] = discovery

        try:
            r = requests.put(url, json=payload, timeout=10)
            return r.ok
        except RequestException as err:
            raise Client.ClientError(err)
1238995
def sync(self):
        
        app = self._api.post(url=self._URL['sync'].format(id=self.id)).json()
        return App(api=self._api, **app)
1039918
async def async_get_connected_devices(self):
        
        devices = {}
        dev = await self.async_get_wl()
        devices.update(dev)
        dev = await self.async_get_arp()
        devices.update(dev)
        dev = await self.async_get_neigh(devices)
        devices.update(dev)
        if not self.mode == 'ap':
            dev = await self.async_get_leases(devices)
            devices.update(dev)

        ret_devices = {}
        for key in devices:
            if not self.require_ip or devices[key].ip is not None:
                ret_devices[key] = devices[key]
        return ret_devices
892496
def update_connected(self, status):
        """"""
        self._client['connected'] = status
        _LOGGER.info('updated connected status to %s on %s', status, self.friendly_name)
        self.callback()
1092139
def connect(self, addr):
        """"""
        if _debug: DeviceToDeviceClientService._debug("connect %r", addr)

        # make a connection
        conn = ConnectionState(addr)
        self.multiplexer.connections[addr] = conn

        # associate with this service, but it is not connected until the ack comes back
        conn.service = self

        # keep a list of pending NPDU objects until the ack comes back
        conn.pendingNPDU = []

        # build a service request
        request = ServiceRequest(DEVICE_TO_DEVICE_SERVICE_ID)
        request.pduDestination = addr

        # send it
        self.service_request(request)

        # return the connection object
        return conn
550922
private synchronized void synchronize() {
		personEmail = conversation.getPerson().getEmail();
		personName = conversation.getPerson().getName();
		messageCenterPendingMessage = conversation.getMessageCenterPendingMessage();
		messageCenterPendingAttachments = conversation.getMessageCenterPendingAttachments();
		hasActiveState = conversation.hasActiveState();
		messageCenterWhoCardPreviouslyDisplayed = conversation.isMessageCenterWhoCardPreviouslyDisplayed();
		unreadMessageCount = conversation.getMessageManager().getUnreadMessageCount();
	}
1165609
function () {
			winble.deviceManager.connectionWatcher = Windows.Devices.Enumeration.Pnp.PnpObject.createWatcher(
				Windows.Devices.Enumeration.Pnp.PnpObjectType.deviceContainer,
				["System.Devices.Connected"],
				"");
			winble.deviceManager.connectionWatcher.onupdated = winble.deviceManager.onDeviceConnectionUpdated;
			winble.deviceManager.connectionWatcher.start();
		}
1361050
def sync_close_connection(self):
        """"""
        loop = asyncio.get_event_loop()
        task = loop.create_task(self.close_connection())
        loop.run_until_complete(task)
318696
def sync(self):
        
        if self._sync is None:
            self._sync = Sync(self)
        return self._sync
799491
private void reconnect() {
        if(uploadInProgress()) {
            setState(OADState.RECONNECTING);
            BeanManager.getInstance().startDiscovery();
            Log.i(TAG, "Waiting for device to reconnect...");
        }
    }
56087
def sync(self):
        """"""
        self.elk.send(az_encode())
        self.elk.send(zd_encode())
        self.elk.send(zp_encode())
        self.elk.send(zs_encode())
        self.get_descriptions(TextDescriptions.ZONE.value)
525431
function(sm_device) {
    if (!(this instanceof SwitchmateToggleSession))
        return new SwitchmateToggleSession();

    var self = this;
    self.Switchmate = sm_device;
    self.event = new EventEmitter();
    self.connectAttempts = 0;
    self.ToggleSuccess = false;
    self.TargetState = null;
    self.TargetBool = null;
    self.Identify = null;
    self.CmdInProgress = false;
    self._toggleTimeout = null;
    self._connectTimeout = null;

    self.onConnect = function() {
        clearTimeout(self._connectTimeout, self.onToggleFail);
        self.connectAttempts += 1;
        self.event.emit('msg', 'Connected to Switchmate ' + self.Switchmate.id + '.');
        self.Switchmate.notifyToggleResult(function(err) {

            if (!err) {
                self.doToggle();
            }
        });
    };

    self.doToggle = function() {
        self.event.emit('msg', 'Turning Switchmate v' + (self.Switchmate._version === 3 ? 3 : '1/2') + ' ' + self.blnToWords(self.TargetBool) + ".");
        self._toggleTimeout = setTimeout(self.onToggleFail, 5 * 1000); //five seconds to work.

        self.Switchmate.toggle(self.TargetBool);
    };

    self.onDisconnect = function() {
        if (self.ToggleSuccess === true) {
            self.Switchmate.CmdInProgress = false;
            self.ToggleSuccess = false;
            self.TargetState = null;
            self.TargetBool = null;
            self.Identify = null;
            self._toggleTimeout = null;
            self._connectTimeout = null;
            self.connectAttempts = 0;
            self.event.emit('success', true);
            self.event.emit('toggleDone', true);
        } else if (self.connectAttempts < 3) {
            self._connectTimeout = setTimeout(self.onToggleFail, 10 * 1000); //five seconds to work.
            self.event.emit('msg', 'Retrying...');
            self.Switchmate.connectAndSetUp(self.onConnect);
        } else {
            self.Switchmate.CmdInProgress = false;
            self.event.emit('fail', '');
            self.event.emit('toggleDone', false);
        }
    };

    self.onToggleSuccess = function(response) {
        if (self.Switchmate._version === 1 || response === self.TargetBool) {
            clearTimeout(self._toggleTimeout);
            if (self.TargetState === "identify" && self.Identify === null) {
                self.Identify = true;
                self.TargetBool = !self.TargetBool;
                self.doToggle();
            } else {
                self.ToggleSuccess = true;
                self.Switchmate.disconnect();
            }
        }
    };

    /**
     * If Toggling the Switchmate fails without the worst error code, return this.
     */
    self.onToggleFail = function(data) {
        clearTimeout(self._toggleTimeout);
        clearTimeout(self._connectTimeout);
        self.ToggleSuccess = false;
        self.event.emit('msg', 'Attempt failed.');
        self.Switchmate.disconnect();
    };

    /**
     * If the Switchmate returns a certain error code during toggle, it resets itself completely.
     * :(
     */
    self.onSwitchmateReset = function() {
        clearTimeout(self._toggleTimeout);
        self.ToggleSuccess = false;
        self.event.emit('msg', 'Your Switchmate received the wrong AuthCode and has reset itself.  You will need to pair it again with all your devices.');
        self.connectAttempts = 999; //give up, the command will never work now.
        self.Switchmate.disconnect();
    };

    self.blnToWords = function(bln) {
        return (bln) ? 'on' : 'off';
    };

    self.Switchmate.on('toggleFail', self.onToggleFail);
    self.Switchmate.on('toggleSuccess', self.onToggleSuccess);
    self.Switchmate.on('disconnect', self.onDisconnect);
    self.Switchmate.on('switchmateReset', self.onSwitchmateReset);
}
1305645
def is_connected(self, use_cached=True):
        """"""
        device_json = self.get_device_json(use_cached)
        return int(device_json.get("dpConnectionStatus")) > 0
1364710
protected function synchronize()
	{
		if( file_exists( $this->syncFile ) )
		{
			$time	= filemtime( $this->syncFile );
			if( ( time() - $time ) < $this->refreshTime )
			{
				$this->syncTime	= $time;
				$this->syncDiff	= FS_File_Reader::load( $this->syncFile );
				return;
			}
		}
		$this->syncTime	= time();
		$this->syncDiff	= $this->syncTime - Net_AtomTime::getTimestamp();
		FS_File_Writer::save( $this->syncFile, $this->syncDiff );
		touch( $this->syncFile );
	}
995063
def _on_connected(self, device):
        
        self._logger.debug("Device connected event: {}".format(device))

        self.connected = True
        self._connection_handle = device['connection_handle']
        self.device.connected = True
        self._audit('ClientConnected')
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),
    ])
1023589
def sync(self, data):
        """"""
        for k, v in data.get('billing', {}).items():
            setattr(self, k, v)
        self.card_number = data.get('credit_card', {}).get('card_number',
                                                           self.card_number)
        self.save(sync=False)