schedule: encode RepetitiveInterval in ascending order
Change-Id: Ife0ae2a933fdd042c6ffaaafb66839c76c88e508
Refs: #3279
diff --git a/src/schedule.cpp b/src/schedule.cpp
index b16cb6d..14635b4 100644
--- a/src/schedule.cpp
+++ b/src/schedule.cpp
@@ -75,15 +75,15 @@
size_t whiteLength = 0;
// encode the blackIntervalList as an embed TLV structure
- for (const RepetitiveInterval& element : m_blackIntervalList) {
- blackLength += encoder.prependBlock(element.wireEncode());
+ for (auto it = m_blackIntervalList.rbegin(); it != m_blackIntervalList.rend(); it++) {
+ blackLength += encoder.prependBlock(it->wireEncode());
}
blackLength += encoder.prependVarNumber(blackLength);
blackLength += encoder.prependVarNumber(tlv::BlackIntervalList);
// encode the whiteIntervalList as an embed TLV structure
- for (const RepetitiveInterval& element : m_whiteIntervalList) {
- whiteLength += encoder.prependBlock(element.wireEncode());
+ for (auto it = m_whiteIntervalList.rbegin(); it != m_whiteIntervalList.rend(); it++) {
+ whiteLength += encoder.prependBlock(it->wireEncode());
}
whiteLength += encoder.prependVarNumber(whiteLength);
whiteLength += encoder.prependVarNumber(tlv::WhiteIntervalList);
diff --git a/tests/unit-tests/schedule.t.cpp b/tests/unit-tests/schedule.t.cpp
index 61a974a..1d86787 100644
--- a/tests/unit-tests/schedule.t.cpp
+++ b/tests/unit-tests/schedule.t.cpp
@@ -198,15 +198,15 @@
0x86, 0x0f,
0x32, 0x30, 0x31, 0x35, 0x30, 0x38, 0x32, 0x35, 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0x87, 0x0f,
- 0x32, 0x30, 0x31, 0x35, 0x30, 0x38, 0x32, 0x38, 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
+ 0x32, 0x30, 0x31, 0x35, 0x30, 0x38, 0x32, 0x35, 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0x88, 0x01,
- 0x06,
+ 0x04,
0x89, 0x01,
- 0x08,
+ 0x07,
0x8a, 0x01,
- 0x01,
+ 0x00,
0x8b, 0x01,
- 0x01,
+ 0x00,
/////
0x8c, 0x2e, // RepetitiveInterval
0x86, 0x0f,
@@ -226,15 +226,15 @@
0x86, 0x0f,
0x32, 0x30, 0x31, 0x35, 0x30, 0x38, 0x32, 0x35, 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0x87, 0x0f,
- 0x32, 0x30, 0x31, 0x35, 0x30, 0x38, 0x32, 0x35, 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
+ 0x32, 0x30, 0x31, 0x35, 0x30, 0x38, 0x32, 0x38, 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0x88, 0x01,
- 0x04,
+ 0x06,
0x89, 0x01,
- 0x07,
+ 0x08,
0x8a, 0x01,
- 0x00,
+ 0x01,
0x8b, 0x01,
- 0x00,
+ 0x01,
/////
0x8e, 0x30, // BlackIntervalList
/////