mirror of
https://github.com/espressif/openthread.git
synced 2026-08-17 16:09:51 +00:00
[low-power] fix csl channel (#5501)
If CSL Channel is never specified, the actual CSL channel should always be the phy channel that the device is using. If CSL Channel hasn't been specified and radio channel changes, the actual CSL channel should also change. In current implementation, CSL Channel is by default a valid value (not specified by upper layer) and wouldn't change when radio channel changes even if it's never specified. This commit fixes this issue. On CSL receiver, a bit is extracted from mCslChannel to be used as a flag mIsCslChannelSpecified. If it is false, mCslChannel would keep synchronized to the value of mRadioChannel in Mac and Csl Channel TLV wouldn't be appended in Child Update Request to its parent. On CSL transmitter, CSL channel info in child is allowed to be 0. If it's 0, the channel info in frame would be set using Mac::GetPanChannel.
This commit is contained in:
@@ -229,6 +229,7 @@ def create_default_mle_tlvs_factories():
|
||||
mle.TlvType.PANID: mle.PanIdFactory(),
|
||||
mle.TlvType.ACTIVE_TIMESTAMP: mle.ActiveTimestampFactory(),
|
||||
mle.TlvType.PENDING_TIMESTAMP: mle.PendingTimestampFactory(),
|
||||
mle.TlvType.CSL_CHANNEL: mle.CslChannelFactory(),
|
||||
mle.TlvType.CSL_SYNCHRONIZED_TIMEOUT: mle.CslSynchronizedTimeoutFactory(),
|
||||
mle.TlvType.ACTIVE_OPERATIONAL_DATASET: mle.ActiveOperationalDatasetFactory(),
|
||||
mle.TlvType.PENDING_OPERATIONAL_DATASET: mle.PendingOperationalDatasetFactory(),
|
||||
|
||||
@@ -87,6 +87,7 @@ class TlvType(IntEnum):
|
||||
ACTIVE_OPERATIONAL_DATASET = 24
|
||||
PENDING_OPERATIONAL_DATASET = 25
|
||||
THREAD_DISCOVERY = 26
|
||||
CSL_CHANNEL = 80
|
||||
CSL_SYNCHRONIZED_TIMEOUT = 85
|
||||
TIME_REQUEST = 252
|
||||
TIME_PARAMETER = 253
|
||||
@@ -1048,6 +1049,20 @@ class ThreadDiscoveryFactory:
|
||||
return ThreadDiscovery(tlvs)
|
||||
|
||||
|
||||
class CslChannel:
|
||||
# TODO: Not implemented yet
|
||||
|
||||
def __init__(self):
|
||||
print("CslChannel is not implemented yet.")
|
||||
|
||||
|
||||
class CslChannelFactory:
|
||||
# TODO: Not implemented yet
|
||||
|
||||
def parse(self, data, message_info):
|
||||
return CslChannel()
|
||||
|
||||
|
||||
class CslSynchronizedTimeout:
|
||||
# TODO: Not implemented yet
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
import unittest
|
||||
|
||||
import mle
|
||||
import thread_cert
|
||||
|
||||
LEADER = 1
|
||||
@@ -55,7 +56,6 @@ class SSED_CslTransmission(thread_cert.TestCase):
|
||||
|
||||
self.nodes[SSED_1].set_csl_period(CSL_PERIOD)
|
||||
self.nodes[SSED_1].set_csl_timeout(CSL_TIMEOUT)
|
||||
self.nodes[SSED_1].set_csl_channel(CSL_CHANNEL)
|
||||
|
||||
self.nodes[SSED_1].get_csl_info()
|
||||
|
||||
@@ -71,6 +71,27 @@ class SSED_CslTransmission(thread_cert.TestCase):
|
||||
self.assertTrue(self.nodes[LEADER].ping(self.nodes[SSED_1].get_rloc()))
|
||||
self.simulator.go(5)
|
||||
|
||||
ssed_messages = self.simulator.get_messages_sent_by(SSED_1)
|
||||
msg = ssed_messages.next_mle_message(mle.CommandType.CHILD_UPDATE_REQUEST)
|
||||
msg.assertMleMessageDoesNotContainTlv(mle.CslChannel)
|
||||
|
||||
self.nodes[SSED_1].set_csl_channel(CSL_CHANNEL)
|
||||
self.simulator.go(1)
|
||||
ssed_messages = self.simulator.get_messages_sent_by(SSED_1)
|
||||
msg = ssed_messages.next_mle_message(mle.CommandType.CHILD_UPDATE_REQUEST)
|
||||
msg.assertMleMessageContainsTlv(mle.CslChannel)
|
||||
self.assertTrue(self.nodes[LEADER].ping(self.nodes[SSED_1].get_rloc()))
|
||||
self.simulator.go(5)
|
||||
|
||||
self.nodes[SSED_1].set_csl_channel(0)
|
||||
self.simulator.go(1)
|
||||
self.assertTrue(self.nodes[LEADER].ping(self.nodes[SSED_1].get_rloc()))
|
||||
self.simulator.go(5)
|
||||
|
||||
ssed_messages = self.simulator.get_messages_sent_by(SSED_1)
|
||||
msg = ssed_messages.next_mle_message(mle.CommandType.CHILD_UPDATE_REQUEST)
|
||||
msg.assertMleMessageDoesNotContainTlv(mle.CslChannel)
|
||||
|
||||
self.nodes[SSED_1].set_csl_period(0)
|
||||
self.assertFalse(self.nodes[LEADER].ping(self.nodes[SSED_1].get_rloc()))
|
||||
self.simulator.go(2)
|
||||
|
||||
Reference in New Issue
Block a user