mirror of
https://github.com/espressif/openthread.git
synced 2026-08-09 20:27:47 +00:00
[thci] wpanctl thci firmeware validation and modify getGUA according to GRL change (#3106)
This commit is contained in:
@@ -1829,8 +1829,7 @@ class OpenThread(IThci):
|
||||
filterByPrefix: a given expected global IPv6 prefix to be matched
|
||||
|
||||
Returns:
|
||||
a global IPv6 address that matches with filterByPrefix
|
||||
or None if no matched GUA
|
||||
a global IPv6 address
|
||||
"""
|
||||
print '%s call getGUA' % self.port
|
||||
print filterByPrefix
|
||||
@@ -1847,7 +1846,7 @@ class OpenThread(IThci):
|
||||
if fullIp.startswith(filterByPrefix):
|
||||
return fullIp
|
||||
print 'no global address matched'
|
||||
return None
|
||||
return str(globalAddrs[0])
|
||||
except Exception, e:
|
||||
ModuleHelper.WriteIntoDebugLogger("getGUA() Error: " + str(e))
|
||||
|
||||
|
||||
@@ -61,6 +61,10 @@ class OpenThread_WpanCtl(IThci):
|
||||
LOWEST_POSSIBLE_PARTATION_ID = 0x1
|
||||
LINK_QUALITY_CHANGE_TIME = 100
|
||||
|
||||
# Used for reference firmware version control for Test Harness.
|
||||
# This variable will be updated to match the OpenThread reference firmware officially released.
|
||||
firmwarePrefix = "OPENTHREAD/"
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
"""initialize the serial port and default network parameters
|
||||
Args:
|
||||
@@ -259,7 +263,7 @@ class OpenThread_WpanCtl(IThci):
|
||||
return 'Fail'
|
||||
else:
|
||||
retry_times -= 1
|
||||
time.sleep(0.1)
|
||||
time.sleep(0.2)
|
||||
else:
|
||||
retry_times -= 1
|
||||
time.sleep(1)
|
||||
@@ -607,7 +611,14 @@ class OpenThread_WpanCtl(IThci):
|
||||
Returns:
|
||||
IPv6 address dotted-quad format
|
||||
"""
|
||||
return strIp6Prefix[0:4] + '::'
|
||||
prefix1 = strIp6Prefix.rstrip('L')
|
||||
prefix2 = prefix1.lstrip("0x")
|
||||
hexPrefix = str(prefix2).ljust(16, '0')
|
||||
hexIter = iter(hexPrefix)
|
||||
finalMac = ':'.join(a + b + c + d for a, b, c, d in zip(hexIter, hexIter, hexIter, hexIter))
|
||||
prefix = str(finalMac)
|
||||
strIp6Prefix = prefix[:20]
|
||||
return strIp6Prefix + ':'
|
||||
|
||||
def __convertLongToString(self, iValue):
|
||||
"""convert a long hex integer to string
|
||||
@@ -781,10 +792,16 @@ class OpenThread_WpanCtl(IThci):
|
||||
print '%s call intialize' % self.port
|
||||
try:
|
||||
# init serial port
|
||||
self.deviceConnected = False
|
||||
self._connect()
|
||||
self.__sendCommand(WPANCTL_CMD + 'leave')
|
||||
self.__sendCommand(WPANCTL_CMD + 'dataset erase')
|
||||
self.deviceConnected = True
|
||||
|
||||
if self.firmwarePrefix in self.UIStatusMsg:
|
||||
self.deviceConnected = True
|
||||
else:
|
||||
self.UIStatusMsg = "Firmware Not Matching Expecting " + self.firmwarePrefix + " Now is " + self.UIStatusMsg
|
||||
ModuleHelper.WriteIntoDebugLogger("Err: OpenThread device Firmware not matching..")
|
||||
except Exception, e:
|
||||
ModuleHelper.WriteIntoDebugLogger('intialize() Error: ' + str(e))
|
||||
self.deviceConnected = False
|
||||
@@ -1845,8 +1862,7 @@ class OpenThread_WpanCtl(IThci):
|
||||
filterByPrefix: a given expected global IPv6 prefix to be matched
|
||||
|
||||
Returns:
|
||||
a global IPv6 address that matches with filterByPrefix
|
||||
or None if no matched GUA
|
||||
a global IPv6 address
|
||||
"""
|
||||
print '%s call getGUA' % self.port
|
||||
print filterByPrefix
|
||||
@@ -1860,13 +1876,14 @@ class OpenThread_WpanCtl(IThci):
|
||||
else:
|
||||
for line in globalAddrs:
|
||||
line = self.__padIp6Addr(line)
|
||||
print line
|
||||
print "Padded IPv6 Address:" + line
|
||||
if line.startswith(filterByPrefix):
|
||||
return line
|
||||
print 'no global address matched'
|
||||
return None
|
||||
return str(globalAddrs[0])
|
||||
except Exception, e:
|
||||
ModuleHelper.WriteIntoDebugLogger('getGUA() Error: ' + str(e))
|
||||
return e
|
||||
|
||||
def getShortAddress(self):
|
||||
"""get Rloc16 short address of Thread device"""
|
||||
|
||||
Reference in New Issue
Block a user