本文整理匯總了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)