mirror of
https://github.com/espressif/openthread.git
synced 2026-10-14 11:47:38 +00:00
[csl] update CSL public APIs to use microseconds unit for period (#9285)
This commit updates public APIs for getting and setting CSL period to
use microseconds unit instead of the internal ten symbols unit. This
makes the APIs easier to use.
The CSL APIs have been renamed to follow the `otLinkGet/SetCsl{Item}()`
pattern, which is the common naming style of OpenThread. This
renaming will make the APIs more consistent and avoid potential
confusion with the now-removed APIs, which used a different unit for
CSL period.
This commit also updates the related CLI CSL commands:
- The `csl period` expects the given period to be in microseconds.
- The `csl` command (which outputs all CSL parameter) shows the CSL
period in microsecond unit (e.g., "Period: 160000us").
The NCP spinel `SPINEL_PROP_THREAD_CSL_PERIOD` is also updated to use
microsecond unit for CSL period.
The related test script are updated to use the new unit, in particular
the test harness `setCSLperiod()` in `harness-thci/OpenThread.py` is
updated (no need to convert from msec).
This commit is contained in:
@@ -2923,11 +2923,8 @@ class OpenThreadTHCI(object):
|
||||
Args:
|
||||
period: csl period in ms
|
||||
|
||||
note: OT command 'csl period' accepts parameter in unit of 10 symbols,
|
||||
period is converted from unit ms to ten symbols (160us per 10 symbols).
|
||||
|
||||
"""
|
||||
cmd = 'csl period %u' % (period * 6.25)
|
||||
cmd = 'csl period %u' % (period * 1000)
|
||||
return self.__executeCommand(cmd)[-1] == 'Done'
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -1369,7 +1369,7 @@ class OTCI(object):
|
||||
# TODO: csl period <period>
|
||||
# TODO: csl timeout <timeout>
|
||||
|
||||
_CSL_PERIOD_PATTERN = re.compile(r'(\d+)\(in units of 10 symbols\), \d+ms')
|
||||
_CSL_PERIOD_PATTERN = re.compile(r'(\d+)us')
|
||||
_CSL_TIMEOUT_PATTERN = re.compile(r'(\d+)s')
|
||||
|
||||
def get_csl_config(self) -> Dict[str, int]:
|
||||
@@ -1398,7 +1398,7 @@ class OTCI(object):
|
||||
"""Configure CSL parameters.
|
||||
|
||||
:param channel: Set CSL channel.
|
||||
:param period: Set CSL period in units of 10 symbols. Disable CSL by setting this parameter to 0.
|
||||
:param period: Set CSL period in usec. Disable CSL by setting this parameter to 0.
|
||||
:param timeout: Set the CSL timeout in seconds.
|
||||
"""
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ class TestOTCI(unittest.TestCase):
|
||||
self.assertTrue(all(x == 0 for name, x in leader.get_counter(counter_name).items() if "Time" not in name))
|
||||
|
||||
logging.info("CSL config: %r", leader.get_csl_config())
|
||||
leader.config_csl(channel=13, period=100, timeout=200)
|
||||
leader.config_csl(channel=13, period=16000, timeout=200)
|
||||
logging.info("CSL config: %r", leader.get_csl_config())
|
||||
|
||||
logging.info("EID-to-RLOC cache: %r", leader.get_eidcache())
|
||||
|
||||
Reference in New Issue
Block a user