Skip to content

Commit

Permalink
[thci] fix channel mask format issue in wpanctl commissioner command (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
FiveDimensions authored and jwhui committed Oct 12, 2018
1 parent e6df05b commit a2865b5
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions tools/harness-thci/OpenThread_WpanCtl.py
Expand Up @@ -692,6 +692,26 @@ def __convertChannelMask(self, channelsArray):

return maskSet

def __ChannelMaskListToStr(self, channelList):
"""convert a channel list to a string
Args:
channelList: channel list (i.e. [21, 22, 23])
Returns:
a string with range-like format (i.e. '21-23')
"""
chan_mask_range = ''
if isinstance(channelList, list):
if len(channelList) == 1:
chan_mask_range = str(channelList[0])
elif len(channelList) > 1:
chan_mask_range = str(channelList[0]) + '-' + str(channelList[-1])
else:
print 'not a list:', channelList

return chan_mask_range

def __setChannelMask(self, channelMask):
print 'call _setChannelMask'
try:
Expand Down Expand Up @@ -2161,7 +2181,7 @@ def MGMT_ED_SCAN(self, sAddr, xCommissionerSessionId, listChannelMask, xCount, x
"""
print '%s call MGMT_ED_SCAN' % self.port
channelMask = ''
channelMask = '0x' + self.__convertLongToString(self.__convertChannelMask(listChannelMask))
channelMask = self.__ChannelMaskListToStr(listChannelMask)
try:
cmd = WPANCTL_CMD + 'commissioner energy-scan %s %s %s %s %s' % (channelMask, xCount, xPeriod, xScanDuration, sAddr)
print cmd
Expand All @@ -2182,7 +2202,7 @@ def MGMT_PANID_QUERY(self, sAddr, xCommissionerSessionId, listChannelMask, xPanI
print '%s call MGMT_PANID_QUERY' % self.port
panid = ''
channelMask = ''
channelMask = '0x' + self.__convertLongToString(self.__convertChannelMask(listChannelMask))
channelMask = self.__ChannelMaskListToStr(listChannelMask)

if not isinstance(xPanId, str):
panid = str(hex(xPanId))
Expand All @@ -2203,7 +2223,7 @@ def MGMT_ANNOUNCE_BEGIN(self, sAddr, xCommissionerSessionId, listChannelMask, xC
"""
print '%s call MGMT_ANNOUNCE_BEGIN' % self.port
channelMask = ''
channelMask = '0x' + self.__convertLongToString(self.__convertChannelMask(listChannelMask))
channelMask = self.__ChannelMaskListToStr(listChannelMask)
try:
cmd = WPANCTL_CMD + 'commissioner announce-begin %s %s %s %s' % (channelMask, xCount, xPeriod, sAddr)
print cmd
Expand Down

0 comments on commit a2865b5

Please sign in to comment.