Python machine.reset() Examples
The following are 30
code examples of machine.reset().
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
machine
, or try the search function
.
Example #1
Source File: _wifi.py From ulnoiot-upy with MIT License | 6 votes |
def setup(name, password, reset=True): if name != _cfg.config.wifi_name or \ password != _cfg.config.wifi_pw: _cfg.wifi(name, password) print("Updated wifi config.") if reset: print("Resetting system in 3 seconds.") time.sleep(1) nr.stop() time.sleep(2) machine.reset() else: activate() # when module loaded the first time start blocking to also bring up netrepl at # right time
Example #2
Source File: http.py From terkin-datalogger with GNU Affero General Public License v3.0 | 6 votes |
def restart(microWebSrv2: MicroWebSrv2, request: HttpRequest): TerkinHttpApi.respond_text(request, 'ACK') def do_reset(): """ """ log.info('Resetting device') microWebSrv2.Stop() machine.reset() try: import _thread _thread.start_new_thread(do_reset, ()) except: do_reset() # =========== # Application # ===========
Example #3
Source File: main.py From microhomie with MIT License | 6 votes |
def __init__(self): super().__init__( id="relay", name="Wifi Power Socket", type="OW8266-02Q" ) self.led = Pin(4, Pin.OUT, value=1) self.r_on = Pin(12, Pin.OUT) self.r_off = Pin(5, Pin.OUT) self.power_property = HomieNodeProperty( id="power", name="Relay", settable=True, retained=True, datatype=BOOLEAN, default=FALSE, restore=True, ) self.add_property(self.power_property, self.on_power_msg) self.button = Pushbutton(Pin(14, Pin.IN, Pin.PULL_UP)) self.button.release_func(self.toggle, ()) self.button.long_func(reset, (self.led,))
Example #4
Source File: _wifi.py From ulnoiot-upy with MIT License | 6 votes |
def setup(name, password, reset=True): if name != _cfg.config.wifi_name or \ password != _cfg.config.wifi_pw: _cfg.wifi(name, password) print("Updated wifi config.") if reset: print("Resetting system in 3 seconds.") time.sleep(1) nr.stop() time.sleep(2) machine.reset() else: activate() # when module loaded the first time start blocking to also bring up netrepl at # right time
Example #5
Source File: _wifi.py From ulnoiot-upy with MIT License | 6 votes |
def setup(name, password, reset=True): if name != _cfg.config.wifi_name or \ password != _cfg.config.wifi_pw: _cfg.wifi(name, password) print("Updated wifi config.") if reset: print("Resetting system in 3 seconds.") time.sleep(1) nr.stop() time.sleep(2) machine.reset() else: activate() # when module loaded the first time start blocking to also bring up netrepl at # right time
Example #6
Source File: _wifi.py From ulnoiot-upy with MIT License | 6 votes |
def setup(name, password, reset=True): if name != _cfg.config.wifi_name or \ password != _cfg.config.wifi_pw: _cfg.wifi(name, password) print("Updated wifi config.") if reset: print("Resetting system in 3 seconds.") time.sleep(1) nr.stop() time.sleep(2) machine.reset() else: activate() # when module loaded the first time start blocking to also bring up netrepl at # right time
Example #7
Source File: _wifi.py From ulnoiot-upy with MIT License | 6 votes |
def setup(name, password, reset=True): if name != _cfg.config.wifi_name or \ password != _cfg.config.wifi_pw: _cfg.wifi(name, password) print("Updated wifi config.") if reset: print("Resetting system in 3 seconds.") time.sleep(1) nr.stop() time.sleep(2) machine.reset() else: activate() # when module loaded the first time start blocking to also bring up netrepl at # right time
Example #8
Source File: _wifi.py From ulnoiot-upy with MIT License | 6 votes |
def setup(name, password, reset=True): if name != _cfg.config.wifi_name or \ password != _cfg.config.wifi_pw: _cfg.wifi(name, password) print("Updated wifi config.") if reset: print("Resetting system in 3 seconds.") time.sleep(1) nr.stop() time.sleep(2) machine.reset() else: activate() # when module loaded the first time start blocking to also bring up netrepl at # right time
Example #9
Source File: stock.py From kmk_firmware with GNU General Public License v3.0 | 5 votes |
def reset(*args, **kwargs): try: import machine machine.reset() except ImportError: import microcontroller microcontroller.reset()
Example #10
Source File: wifiWebCfg.py From UIFlow-Code with GNU General Public License v3.0 | 5 votes |
def _httpHanderConfig(httpClient, httpResponse) : formData = httpClient.GetRequestQueryParams() ssid = formData.get("ssid") password = formData.get("password") other_flg = formData.get("other") print(formData) content = '' is_connected = False if other_flg == 'true' or doConnect(ssid, password, False): is_connected = True saveWiFi(ssid, password) content = """<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><style>h1{text-align:center;margin-top:120px;font-size:1.4rem;color:#0064a0}p{text-align:center;font-size:1.1rem}div{width:200px;margin:0 auto;padding-left:60px}</style><title></title></head><body><h1>^_^ WiFi connection success</h1><div><span>Reset device now </span><span id="wating">...</span></div></body><script>var wating=document.getElementById("wating");setInterval(function(){if(wating.innerText==="..."){return wating.innerText="."}wating.innerText+="."},500);</script></html>""" else: content = """<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><style>h1{text-align:center;margin-top:120px;font-size:1.4rem;color:red}p{text-align:center;font-size:1.1rem}</style><title></title></head><body><h1>×_× WiFi connection failed</h1><p>Click <a href="/">here</a> return configure page.</p></body></html>""" httpResponse.WriteResponseOk( headers = None, contentType = "text/html", contentCharset = "UTF-8", content = content ) if is_connected: lcd.image(0, 0, '/flash/img/1-3.jpg', type=lcd.JPG) time.sleep(3) wlan_ap.active(False) machine.reset()
Example #11
Source File: device.py From microhomie with MIT License | 5 votes |
def reset(self, reason): if reason != "reset": RTC().memory(reason) await self.publish(DEVICE_STATE, reason) await self.mqtt.disconnect() await sleep_ms(500) reset()
Example #12
Source File: device.py From microhomie with MIT License | 5 votes |
def sub_cb(self, topic, payload, retained): topic = topic.decode() payload = payload.decode() self.dprint( "MQTT MESSAGE: {} --> {}, {}".format(topic, payload, retained) ) # Only non-retained messages are allowed on /set topics if retained and topic.endswith(T_SET): return # broadcast callback passed to nodes if T_BC in topic: nodes = self.nodes for n in nodes: n.broadcast_callback(topic, payload, retained) # Micropython extension elif topic.endswith(T_MPY): if payload == "reset": launch(self.reset, ("reset",)) elif payload == "webrepl": launch(self.reset, ("webrepl",)) elif payload == "yaota8266": launch(self.reset, ("yaotaota",)) else: # node property callbacks nt = topic.split(SLASH) node = nt[len(self.dtopic.split(SLASH))] if node in self.callback_topics: self.callback_topics[node](topic, payload, retained)
Example #13
Source File: util.py From esp32-weather-google-sheets with MIT License | 5 votes |
def reboot(delay = 5): print('rebooting ...') time.sleep(delay) machine.reset() # start a wi-fi access point
Example #14
Source File: main.py From microhomie with MIT License | 5 votes |
def reset(led): import machine wdt = machine.WDT() wdt.feed() led(0) machine.reset()
Example #15
Source File: Board.py From illuminOS with MIT License | 5 votes |
def reboot(self): log.info("Rebooting board ...") import machine machine.reset()
Example #16
Source File: mpuserver.py From py-mpu6050 with GNU General Public License v3.0 | 5 votes |
def isr(self, pin): # debounce if time.ticks_diff(time.ticks_ms(), self.last_isr) < 10: return print('! reset gyro request') self.flag_reset_gyro = True self.last_isr = time.ticks_ms()
Example #17
Source File: util.py From developer-badge-2018-apps with Apache License 2.0 | 5 votes |
def reboot(pressed=True): machine.reset()
Example #18
Source File: __init__.py From ulnoiot-upy with MIT License | 5 votes |
def reset(): machine.reset()
Example #19
Source File: client.py From micropython-iot with MIT License | 5 votes |
def _keepalive(self): while True: due = self._tim_ka - utime.ticks_diff(utime.ticks_ms(), self._last_wr) if due <= 0: # error sets ._evfail, .run cancels this coro await self._send(b'\n') else: await asyncio.sleep_ms(due) # Read a line from nonblocking socket: reads can return partial data which # are joined into a line. Blank lines are keepalive packets which reset # the timeout: _readline() pauses until a complete line has been received.
Example #20
Source File: __init__.py From ulnoiot-upy with MIT License | 5 votes |
def reset(): machine.reset()
Example #21
Source File: client.py From micropython-iot with MIT License | 5 votes |
def _readline(self, to): led = self._led line = b'' start = utime.ticks_ms() while True: if line.endswith(b'\n'): self._ok = True # Got at least 1 packet after an outage. if len(line) > 1: return line # Got a keepalive: discard, reset timers, toggle LED. self._feed(0) line = b'' if led is not None: if isinstance(led, machine.Pin): led(not led()) else: # On Pyboard D led.toggle() try: d = self._sock.readline() except Exception as e: self._verbose and print('_readline exception', d) raise if d == b'': self._verbose and print('_readline peer disconnect') raise OSError if d is None: # Nothing received: wait on server if utime.ticks_diff(utime.ticks_ms(), start) > to: self._verbose and print('_readline timeout') raise OSError await asyncio.sleep_ms(0) else: # Something received: reset timer start = utime.ticks_ms() line = b''.join((line, d)) if line else d
Example #22
Source File: __init__.py From platypush with MIT License | 5 votes |
def reset(self, **kwargs): """ Perform a device reset, similar to the user pushing the RESET button. :param kwargs: Parameters to pass to :meth:`platypush.plugins.esp.EspPlugin.execute`. """ code = ''' import machine machine.reset() ''' return self.execute(code, wait_response=False, **kwargs).output
Example #23
Source File: __init__.py From ulnoiot-upy with MIT License | 5 votes |
def reset(): machine.reset()
Example #24
Source File: stock.py From kmk_firmware with GNU General Public License v3.0 | 5 votes |
def bootloader(*args, **kwargs): try: import machine machine.bootloader() except ImportError: import microcontroller microcontroller.on_next_reset(microcontroller.RunMode.BOOTLOADER) microcontroller.reset()
Example #25
Source File: __init__.py From ulnoiot-upy with MIT License | 5 votes |
def reset(): machine.reset()
Example #26
Source File: watchdog.py From pysmartnode with MIT License | 5 votes |
def _wdt(self, t): self._counter += self._timeout if self._counter >= self._timeout * 10: if self._use_rtc_memory and platform == "esp8266": rtc = machine.RTC() rtc.memory(b"WDT reset") elif self._has_filesystem: try: with open("reset_reason.txt", "w") as f: f.write("WDT reset") except Exception as e: print("Error saving to file: {!s}".format(e)) machine.reset()
Example #27
Source File: watchdog.py From pysmartnode with MIT License | 5 votes |
def __init__(self, id=0, timeout=120, use_rtc_memory=True): self._timeout = timeout / 10 self._counter = 0 self._timer = machine.Timer(id) self._use_rtc_memory = use_rtc_memory self._has_filesystem = False self.init() asyncio.get_event_loop().create_task(self._resetCounter()) """ Done in pysmartnode.main if use_rtc_memory and platform == "esp8266": rtc = machine.RTC() if rtc.memory() == b"WDT reset": logging.getLogger("WDT").critical("Reset reason: Watchdog") rtc.memory(b"") elif sys_vars.hasFilesystem(): self._has_filesystem = True try: with open("reset_reason.txt", "r") as f: if f.read() == "True": logging.getLogger("WDT").warn("Reset reason: Watchdog") except Exception as e: print(e) # file probably just does not exist try: os.remove("reset_reason.txt") except Exception as e: logging.getLogger("WDT").error("Error saving to file: {!s}".format(e)) """
Example #28
Source File: main.py From pysmartnode with MIT License | 5 votes |
def main(): print("free ram {!r}".format(gc.mem_free())) gc.collect() loop.create_task(_resetReason()) config.getMQTT().registerWifiCallback(start_services) print("Starting uasyncio loop") try: loop.run_forever() except Exception as e: try: config.getMQTT().close() except: pass if config.DEBUG_STOP_AFTER_EXCEPTION: # want to see the exception trace in debug mode if config.USE_SOFTWARE_WATCHDOG: wdt.deinit() # so it doesn't reset the board raise e # just log the exception and reset the microcontroller if sys.platform == "esp8266": try: rtc.memory("{!s}".format(e).encode()) except Exception as e: print(e) print("{!s}".format(e).encode()) else: with open("reset_reason.txt", "w") as f: f.write(e) machine.reset()
Example #29
Source File: util.py From esp8266 with BSD 2-Clause "Simplified" License | 5 votes |
def reboot() : import machine machine.reset()
Example #30
Source File: cmd.py From esp8266 with BSD 2-Clause "Simplified" License | 5 votes |
def reboot(): import machine machine.reset()