mirror of
https://github.com/espressif/openthread.git
synced 2026-08-25 11:49:51 +00:00
[thci] reset and multicast changes (#7340)
- THCI changes for bbr reset procedure to make a better effort to reset and to also make sure to restart the otbr-agent prior to attempting a factoryreset to cover the case where the agent cannot currently communicate to the rcp. - THCI change to move from sudo service restart otbr-agent to sudo systemctl restart otbr-agent, which is more comprehensive. - THCI changes for multicast to use ipmaddr in both soc and bbr cases.
This commit is contained in:
@@ -1511,7 +1511,7 @@ class OpenThreadTHCI(object):
|
||||
|
||||
start_time = time.time()
|
||||
while time.time() < start_time + timeout:
|
||||
time.sleep(0.3)
|
||||
time.sleep(0.5)
|
||||
if not self.IsBorderRouter:
|
||||
self._disconnect()
|
||||
self._connect()
|
||||
@@ -1519,6 +1519,10 @@ class OpenThreadTHCI(object):
|
||||
self.__executeCommand('state', timeout=0.1)
|
||||
break
|
||||
except Exception:
|
||||
self.__restartAgentService()
|
||||
time.sleep(2)
|
||||
self.__sendCommand('factoryreset', expectEcho=False)
|
||||
time.sleep(0.5)
|
||||
continue
|
||||
else:
|
||||
raise AssertionError("Could not connect with OT device {} after reset.".format(self))
|
||||
@@ -3489,6 +3493,7 @@ class OpenThreadTHCI(object):
|
||||
Args:
|
||||
sAddr : str : Multicast address to be subscribed and notified OTA.
|
||||
"""
|
||||
self._beforeRegisterMulticast(sAddr, timeout)
|
||||
|
||||
cmd = 'ipmaddr add ' + str(sAddr)
|
||||
|
||||
@@ -3653,6 +3658,12 @@ class OpenThread(OpenThreadTHCI, IThci):
|
||||
def _deviceAfterReset(self):
|
||||
pass
|
||||
|
||||
def __restartAgentService(self):
|
||||
pass
|
||||
|
||||
def _beforeRegisterMulticast(self, sAddr, timeout):
|
||||
pass
|
||||
|
||||
def __socRead(self, size=512):
|
||||
if self._is_net:
|
||||
return self.__handle.recv(size)
|
||||
|
||||
@@ -319,7 +319,23 @@ class OpenThread_BR(OpenThreadTHCI, IThci):
|
||||
self.__dumpSyslog()
|
||||
self.__truncateSyslog()
|
||||
if not self.IsHost:
|
||||
self.bash('sudo service otbr-agent restart')
|
||||
self.bash('sudo systemctl restart otbr-agent')
|
||||
time.sleep(2)
|
||||
|
||||
def _beforeRegisterMulticast(self, sAddr='ff04::1234:777a:1', timeout=300):
|
||||
"""subscribe to the given ipv6 address (sAddr) in interface and send MLR.req OTA
|
||||
|
||||
Args:
|
||||
sAddr : str : Multicast address to be subscribed and notified OTA.
|
||||
"""
|
||||
|
||||
if self.externalCommissioner is not None:
|
||||
self.externalCommissioner.MLR([sAddr], timeout)
|
||||
return True
|
||||
|
||||
cmd = 'sudo nohup ~/repo/openthread/tests/scripts/thread-cert/mcast6.py wpan0 %s' % sAddr
|
||||
cmd = cmd + ' > /dev/null 2>&1 &'
|
||||
self.bash(cmd)
|
||||
|
||||
@API
|
||||
def setupHost(self, setDua=False):
|
||||
@@ -604,7 +620,10 @@ EOF"
|
||||
|
||||
def __checkServiceStatus(self):
|
||||
self.bash('sudo service radvd stop')
|
||||
self.bash('sudo service otbr-agent restart')
|
||||
self.bash('sudo systemctl restart otbr-agent')
|
||||
|
||||
def __restartAgentService(self):
|
||||
self.bash('sudo systemctl restart otbr-agent')
|
||||
|
||||
def __truncateSyslog(self):
|
||||
self.bash('sudo truncate -s 0 /var/log/syslog')
|
||||
@@ -691,14 +710,14 @@ EOF"
|
||||
@API
|
||||
def powerDown(self):
|
||||
self.log('Powering down BBR')
|
||||
self.bash('sudo service otbr-agent stop')
|
||||
self.bash('sudo systemctl stop otbr-agent')
|
||||
super(OpenThread_BR, self).powerDown()
|
||||
|
||||
# Override powerUp
|
||||
@API
|
||||
def powerUp(self):
|
||||
self.log('Powering up BBR')
|
||||
self.bash('sudo service otbr-agent start')
|
||||
self.bash('sudo systemctl start otbr-agent')
|
||||
super(OpenThread_BR, self).powerUp()
|
||||
|
||||
# Override forceSetSlaac
|
||||
@@ -707,25 +726,6 @@ EOF"
|
||||
print('forceSetSlaac %s' % slaacAddress)
|
||||
self.bash('sudo ip -6 addr add %s/64 dev wpan0' % slaacAddress)
|
||||
|
||||
# Override registerMulticast
|
||||
@API
|
||||
def registerMulticast(self, sAddr='ff04::1234:777a:1', timeout=300):
|
||||
"""subscribe to the given ipv6 address (sAddr) in interface and send MLR.req OTA
|
||||
|
||||
Args:
|
||||
sAddr : str : Multicast address to be subscribed and notified OTA.
|
||||
"""
|
||||
|
||||
if self.externalCommissioner is not None:
|
||||
self.externalCommissioner.MLR([sAddr], timeout)
|
||||
return True
|
||||
|
||||
cmd = 'sudo nohup ~/repo/openthread/tests/scripts/thread-cert/mcast6.py wpan0 %s' % sAddr
|
||||
cmd = cmd + ' > /dev/null 2>&1 &'
|
||||
self.bash(cmd)
|
||||
|
||||
return True
|
||||
|
||||
# Override stopListeningToAddr
|
||||
@API
|
||||
def stopListeningToAddr(self, sAddr):
|
||||
|
||||
Reference in New Issue
Block a user