Python network.STAT_CONNECTING Examples
The following are 6
code examples of network.STAT_CONNECTING().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
network
, or try the search function
.
Example #1
Source File: stats_api.py From esp8266 with BSD 2-Clause "Simplified" License | 6 votes |
def get_wlan_status(self, wlan): status = wlan.status() if status == network.STAT_IDLE: return 'STAT_IDLE' elif status == network.STAT_CONNECTING: return 'STAT_CONNECTING' elif status == network.STAT_WRONG_PASSWORD: return 'STAT_WRONG_PASSWORD' elif status == network.STAT_NO_AP_FOUND: return 'STAT_NO_AP_FOUND' elif status == network.STAT_CONNECT_FAIL: return 'STAT_CONNECT_FAIL' elif status == network.STAT_GOT_IP: return 'STAT_GOT_IP' else: return "Unknown wlan status: {}".format(status)
Example #2
Source File: api.py From esp8266 with BSD 2-Clause "Simplified" License | 6 votes |
def get_wlan_status(self, wlan): status = wlan.status() if status == network.STAT_IDLE: return 'STAT_IDLE' elif status == network.STAT_CONNECTING: return 'STAT_CONNECTING' elif status == network.STAT_WRONG_PASSWORD: return 'STAT_WRONG_PASSWORD' elif status == network.STAT_NO_AP_FOUND: return 'STAT_NO_AP_FOUND' elif status == network.STAT_CONNECT_FAIL: return 'STAT_CONNECT_FAIL' elif status == network.STAT_GOT_IP: return 'STAT_GOT_IP' else: return "Unknown wlan status: {}".format(status)
Example #3
Source File: client_w.py From micropython-samples with MIT License | 5 votes |
def _connect(self, s): print('Connecting to WiFi') s.active(True) s.connect() # ESP8266 remembers connection. # Break out on fail or success. while s.status() == network.STAT_CONNECTING: await asyncio.sleep(1) t = utime.ticks_ms() print('Checking WiFi stability for {}ms'.format(2 * self.timeout)) # Timeout ensures stable WiFi and forces minimum outage duration while s.isconnected() and utime.ticks_diff(utime.ticks_ms(), t) < 2 * self.timeout: await asyncio.sleep(1)
Example #4
Source File: wifi_manager.py From micropython-wifimanager with BSD 2-Clause "Simplified" License | 5 votes |
def manage(cls): while True: status = cls.wlan().status() # ESP32 does not currently return if (status != network.STAT_GOT_IP) or \ (cls.wlan().ifconfig()[0] == '0.0.0.0'): # temporary till #3967 log.info("Network not connected: managing") # Ignore connecting status for now.. ESP32 is a bit strange # if status != network.STAT_CONNECTING: <- do not care yet cls.setup_network() await asyncio.sleep(10) # Pause 5 seconds
Example #5
Source File: mqtt_as.py From micropython-mqtt with MIT License | 4 votes |
def wifi_connect(self): s = self._sta_if if ESP8266: if s.isconnected(): # 1st attempt, already connected. return s.active(True) s.connect() # ESP8266 remembers connection. for _ in range(60): if s.status() != network.STAT_CONNECTING: # Break out on fail or success. Check once per sec. break await asyncio.sleep(1) if s.status() == network.STAT_CONNECTING: # might hang forever awaiting dhcp lease renewal or something else s.disconnect() await asyncio.sleep(1) if not s.isconnected() and self._ssid is not None and self._wifi_pw is not None: s.connect(self._ssid, self._wifi_pw) while s.status() == network.STAT_CONNECTING: # Break out on fail or success. Check once per sec. await asyncio.sleep(1) else: s.active(True) s.connect(self._ssid, self._wifi_pw) if PYBOARD: # Doesn't yet have STAT_CONNECTING constant while s.status() in (1, 2): await asyncio.sleep(1) elif LOBO: i = 0 while not s.isconnected(): await asyncio.sleep(1) i += 1 if i >= 10: break else: while s.status() == network.STAT_CONNECTING: # Break out on fail or success. Check once per sec. await asyncio.sleep(1) if not s.isconnected(): raise OSError # Ensure connection stays up for a few secs. self.dprint('Checking WiFi integrity.') for _ in range(5): if not s.isconnected(): raise OSError # in 1st 5 secs await asyncio.sleep(1) self.dprint('Got reliable connection')
Example #6
Source File: mqtt_as.py From microhomie with MIT License | 4 votes |
def wifi_connect(self): if LINUX is True: # no network control, assume connected as OS takes care of that self._sta_isconnected = True return s = self._sta_if if ESP8266: if s.isconnected(): # 1st attempt, already connected. return s.active(True) s.connect() # ESP8266 remembers connection. for _ in range(60): if s.status() != network.STAT_CONNECTING: # Break out on fail or success. Check once per sec. break await asyncio.sleep(1) if s.status() == network.STAT_CONNECTING: # might hang forever awaiting dhcp lease renewal or something else s.disconnect() await asyncio.sleep(1) if not s.isconnected() and self._ssid is not None and self._wifi_pw is not None: s.connect(self._ssid, self._wifi_pw) while s.status() == network.STAT_CONNECTING: # Break out on fail or success. Check once per sec. await asyncio.sleep(1) else: s.active(True) s.connect(self._ssid, self._wifi_pw) if PYBOARD: # Doesn't yet have STAT_CONNECTING constant while s.status() in (1, 2): await asyncio.sleep(1) elif LOBO: i = 0 while not s.isconnected(): await asyncio.sleep(1) i += 1 if i >= 10: break else: while s.status() == network.STAT_CONNECTING: # Break out on fail or success. Check once per sec. await asyncio.sleep(1) if not s.isconnected(): raise OSError # Ensure connection stays up for a few secs. self.dprint('Checking WiFi integrity.') for _ in range(5): if not s.isconnected(): raise OSError # in 1st 5 secs await asyncio.sleep(1) self.dprint('Got reliable connection')