本文整理汇总了Python中machine.WDT属性的典型用法代码示例。如果您正苦于以下问题:Python machine.WDT属性的具体用法?Python machine.WDT怎么用?Python machine.WDT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类machine
的用法示例。
在下文中一共展示了machine.WDT属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
# 需要导入模块: import machine [as 别名]
# 或者: from machine import WDT [as 别名]
def start(self):
"""
Start the watchdog.
"""
if not self.enabled:
log.info('Skipping watchdog timer (WDT)')
return
watchdog_timeout = self.timeout
log.info('Starting the watchdog timer (WDT) with timeout {}ms'.format(watchdog_timeout))
from machine import WDT
self.wdt = WDT(timeout=watchdog_timeout)
# Feed Watchdog once.
self.feed()
示例2: close
# 需要导入模块: import machine [as 别名]
# 或者: from machine import WDT [as 别名]
def close(self):
self._close() # Close socket and WDT
self._feed(WDT_CANCEL)
# **** For subclassing ****
# May be overridden e.g. to provide timeout (asyncio.wait_for)
示例3: reset
# 需要导入模块: import machine [as 别名]
# 或者: from machine import WDT [as 别名]
def reset(led):
import machine
wdt = machine.WDT()
wdt.feed()
led(0)
machine.reset()
示例4: reset
# 需要导入模块: import machine [as 别名]
# 或者: from machine import WDT [as 别名]
def reset(led):
import machine
wdt = machine.WDT()
wdt.feed()
while True:
led(not led())
sleep_ms(250)
示例5: wdt
# 需要导入模块: import machine [as 别名]
# 或者: from machine import WDT [as 别名]
def wdt(self):
from machine import WDT
wdt = WDT()
while True:
wdt.feed()
await sleep_ms(WDT_DELAY)
示例6: reconfigure_watchdog
# 需要导入模块: import machine [as 别名]
# 或者: from machine import WDT [as 别名]
def reconfigure_watchdog(self, timeout_seconds=600):
"""
:param timeout_seconds: (Default value = 600)
"""
try:
from machine import WDT
watchdog_timeout = timeout_seconds
watchdog_timeout_effective = watchdog_timeout * 1000
wdt = WDT(timeout=watchdog_timeout_effective)
wdt.init(watchdog_timeout_effective)
print('INFO: Reconfigured watchdog to {} seconds'.format(watchdog_timeout))
except:
pass
示例7: connection_handler
# 需要导入模块: import machine [as 别名]
# 或者: from machine import WDT [as 别名]
def connection_handler(self, client):
"""subscribe to all registered device and node topics"""
if self._first_start is False:
await self.publish(DEVICE_STATE, STATE_RECOVER)
retained = []
subscribe = self.subscribe
# Broadcast topic
await self.mqtt.subscribe("{}/{}/#".format(self.btopic, T_BC), QOS)
# Micropython extension
await self.mqtt.subscribe("{}/{}".format(self.dtopic, T_MPY), QOS)
# node topics
nodes = self.nodes
for n in nodes:
props = n._properties
for pid, p in props.items():
if p.restore:
# Restore from topic with retained message
await self.add_node_cb(n)
t = "{}/{}".format(n.id, pid)
await subscribe(t)
retained.append(t)
if p.settable:
await self.add_node_cb(n)
await subscribe("{}/{}/set".format(n.id, pid))
# on first connection:
# * publish device and node properties
# * enable WDT
# * run all coros
if self._first_start is True:
await self.publish_properties()
unsubscribe = self.unsubscribe
# unsubscribe from retained topics
for t in retained:
await unsubscribe(t)
self._first_start = False
# activate WDT
if LINUX is False and self.debug is False:
launch(self.wdt, ())
# start coros waiting for ready state
_EVENT.set()
await sleep_ms(MAIN_DELAY)
_EVENT.clear()
await self.publish(DEVICE_STATE, STATE_READY)