mirror of
https://github.com/espressif/openthread.git
synced 2026-08-07 03:07:47 +00:00
THCI: Refine joinCommissioned method (#1292)
This commit is contained in:
@@ -89,6 +89,8 @@ class OpenThread(IThci):
|
||||
self.logThread = Queue()
|
||||
self.logStatus = {'stop':'stop', 'running':'running', "pauseReq":'pauseReq', 'paused':'paused'}
|
||||
self.logThreadStatus = self.logStatus['stop']
|
||||
self.joinStatus = {'notstart':'notstart', 'ongoing':'ongoing', 'succeed':'succeed', "failed":'failed'}
|
||||
self.joinCommissionedStatus = self.joinStatus['notstart']
|
||||
self.intialize()
|
||||
except Exception, e:
|
||||
ModuleHelper.WriteIntoDebugLogger("initialize() Error: " + str(e))
|
||||
@@ -591,6 +593,11 @@ class OpenThread(IThci):
|
||||
print line
|
||||
logs.put(line)
|
||||
|
||||
if "Join success" in line:
|
||||
self.joinCommissionedStatus = self.joinStatus['succeed']
|
||||
elif "Join failed" in line:
|
||||
self.joinCommissionedStatus = self.joinStatus['failed']
|
||||
|
||||
except Exception, e:
|
||||
pass
|
||||
|
||||
@@ -1986,17 +1993,28 @@ class OpenThread(IThci):
|
||||
strPSKd: Joiner's PSKd
|
||||
|
||||
Returns:
|
||||
True: successful to start commissioner
|
||||
False: fail to start commissioner
|
||||
True: successful to start joiner
|
||||
False: fail to start joiner
|
||||
"""
|
||||
print '%s call joinCommissioned' % self.port
|
||||
self.__sendCommand('ifconfig up')
|
||||
cmd = 'joiner start %s %s' %(strPSKd, self.provisioningUrl)
|
||||
print cmd
|
||||
if self.__sendCommand(cmd)[0] == "Done":
|
||||
maxDuration = 150 # seconds
|
||||
self.joinCommissionedStatus = self.joinStatus['ongoing']
|
||||
|
||||
if self.logThreadStatus == self.logStatus['stop']:
|
||||
self.logThread = ThreadRunner.run(target=self.__readCommissioningLogs, args=(90,))
|
||||
time.sleep(100)
|
||||
self.logThread = ThreadRunner.run(target=self.__readCommissioningLogs, args=(maxDuration,))
|
||||
|
||||
t_end = time.time() + maxDuration
|
||||
while time.time() < t_end:
|
||||
if self.joinCommissionedStatus == self.joinStatus['succeed']:
|
||||
break;
|
||||
elif self.joinCommissionedStatus == self.joinStatus['failed']:
|
||||
return False
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
self.__sendCommand('thread start')
|
||||
time.sleep(30)
|
||||
|
||||
Reference in New Issue
Block a user