mirror of
https://github.com/espressif/openthread.git
synced 2026-07-28 22:57:47 +00:00
[mle] add API to detach gracefully (#7666)
This commit adds an API `otThreadDetachGracefully` to notify other nodes in the network (if any) and then stop Thread protocol operation. It sends an Address Release if it's a router, or sets its child timeout to 0 if it's a child.
This commit is contained in:
@@ -815,6 +815,30 @@ class NodeImpl:
|
||||
self.send_command('thread stop')
|
||||
self._expect_done()
|
||||
|
||||
def detach(self, is_async=False):
|
||||
cmd = 'detach'
|
||||
if is_async:
|
||||
cmd += ' async'
|
||||
|
||||
self.send_command(cmd)
|
||||
|
||||
if is_async:
|
||||
self._expect_done()
|
||||
return
|
||||
|
||||
end = self.simulator.now() + 4
|
||||
while True:
|
||||
self.simulator.go(1)
|
||||
try:
|
||||
self._expect_done(timeout=0.1)
|
||||
return
|
||||
except (pexpect.TIMEOUT, socket.timeout):
|
||||
if self.simulator.now() > end:
|
||||
raise
|
||||
|
||||
def expect_finished_detaching(self):
|
||||
self._expect('Finished detaching')
|
||||
|
||||
def commissioner_start(self):
|
||||
cmd = 'commissioner start'
|
||||
self.send_command(cmd)
|
||||
|
||||
Reference in New Issue
Block a user