def _connect(self): # Activate existing connection, if there is one connection = network.find_connection_by_ssid(self._ssid) if connection: logging.debug('Activating existing connection for SSID %r', self._ssid) connection.activate(self._device) return # Otherwise, create new connection and activate it logging.debug('Creating new connection for SSID %r', self._ssid) settings = Settings() settings.connection.id = self._display_name settings.connection.uuid = str(uuid.uuid4()) settings.connection.type = '802-11-wireless' settings.wireless.ssid = self._ssid if self._mode == network.NM_802_11_MODE_INFRA: settings.wireless.mode = 'infrastructure' settings.connection.autoconnect = True elif self._mode == network.NM_802_11_MODE_ADHOC: settings.wireless.mode = 'adhoc' settings.wireless.band = 'bg' settings.ip4_config = IP4Config() settings.ip4_config.method = 'link-local' wireless_security = self._get_security() settings.wireless_security = wireless_security if wireless_security is not None: settings.wireless.security = '802-11-wireless-security' network.add_and_activate_connection(self._device, settings, self.get_first_ap().model)
def _add_connection(self, channel, xs_hosted): anycast_addr = _XS_ANYCAST if xs_hosted else None wireless_config = OlpcMeshSettings(channel, anycast_addr) settings = Settings(wireless_cfg=wireless_config) if not xs_hosted: settings.ip4_config = network.IP4Config() settings.ip4_config.method = 'link-local' settings.connection.id = self._get_connection_id(channel, xs_hosted) settings.connection.autoconnect = False settings.connection.uuid = unique_id() settings.connection.type = '802-11-olpc-mesh' network.add_connection(settings, reply_handler=self._add_connection_reply_cb, error_handler=self._add_connection_err_cb)
def _add_connection(self, channel): ssid = 'Ad-hoc Network %d' % (channel, ) settings = Settings() settings.connection.id = self._get_connection_id(channel) settings.connection.uuid = str(uuid.uuid4()) settings.connection.type = '802-11-wireless' settings.connection.autoconnect = False settings.wireless.ssid = dbus.ByteArray(ssid) settings.wireless.band = 'bg' settings.wireless.channel = channel settings.wireless.mode = 'adhoc' settings.ip4_config = IP4Config() settings.ip4_config.method = 'link-local' network.add_connection(settings)
def _add_connection(self, channel): ssid = 'Ad-hoc Network %d' % (channel,) settings = Settings() settings.connection.id = self._get_connection_id(channel) settings.connection.uuid = str(uuid.uuid4()) settings.connection.type = '802-11-wireless' settings.connection.autoconnect = False settings.wireless.ssid = dbus.ByteArray(ssid) settings.wireless.band = 'bg' settings.wireless.channel = channel settings.wireless.mode = 'adhoc' settings.ip4_config = IP4Config() settings.ip4_config.method = 'link-local' network.add_connection(settings)
def _add_connection(self, channel, xs_hosted): anycast_addr = _XS_ANYCAST if xs_hosted else None wireless_config = OlpcMeshSettings(channel, anycast_addr) settings = Settings(wireless_cfg=wireless_config) if not xs_hosted: settings.ip4_config = network.IP4Config() settings.ip4_config.method = 'link-local' settings.connection.id = self._get_connection_id(channel, xs_hosted) settings.connection.autoconnect = False settings.connection.uuid = str(uuid.uuid4()) settings.connection.type = '802-11-olpc-mesh' network.add_connection(settings, reply_handler=self._add_connection_reply_cb, error_handler=self._add_connection_err_cb)
def _add_connection(self, channel): ssid = "Ad-hoc Network %d" % (channel,) settings = Settings() settings.connection.id = self._get_connection_id(channel) settings.connection.uuid = unique_id() settings.connection.type = "802-11-wireless" settings.connection.autoconnect = False settings.wireless.ssid = dbus.ByteArray(ssid) settings.wireless.band = "bg" settings.wireless.channel = channel settings.wireless.mode = "adhoc" settings.ip4_config = IP4Config() settings.ip4_config.method = "link-local" network.add_connection(settings)