Skip to content

Commit 1eac9e8

Browse files
committed
Modify methods to allow for backwards compatibility between clients and servers
1 parent b3766dc commit 1eac9e8

5 files changed

Lines changed: 24 additions & 9 deletions

File tree

src/dbus/client/thread_api_dbus.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,17 @@ void ThreadApiDBus::sHandleDBusPendingCall(DBusPendingCall *aPending, void *aThr
884884

885885
ClientError ThreadApiDBus::AttachAllNodesTo(const std::vector<uint8_t> &aDataset, uint32_t aDelayMs)
886886
{
887-
auto args = std::tie(aDataset, aDelayMs);
888-
return CallDBusMethodSync(OTBR_DBUS_ATTACH_ALL_NODES_TO_METHOD, args);
887+
// Omit delay_timer_ms when using default (0) for backward compatibility with older servers
888+
if (aDelayMs == 0)
889+
{
890+
auto args = std::tie(aDataset);
891+
return CallDBusMethodSync(OTBR_DBUS_ATTACH_ALL_NODES_TO_METHOD, args);
892+
}
893+
else
894+
{
895+
auto args = std::tie(aDataset, aDelayMs);
896+
return CallDBusMethodSync(OTBR_DBUS_ATTACH_ALL_NODES_TO_METHOD, args);
897+
}
889898
}
890899

891900
ClientError ThreadApiDBus::SetBorderAgentEnabled(bool aEnabled)

src/dbus/client/thread_api_dbus.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ class ThreadApiDBus
174174
* automatically.
175175
* @param[in] aDelayMs The delay timer in milliseconds to embed in the pending dataset.
176176
* Use 0 (default) for 300 seconds (5 minutes). Maximum is 72 hours.
177+
* When 0, the delay_timer_ms argument is omitted from the DBus call for
178+
* backward compatibility with older servers.
177179
*
178180
* @retval ERROR_NONE Successfully requested the Thread network migration.
179181
* @retval ERROR_DBUS D-Bus encode/decode error.

src/dbus/server/dbus_thread_object_rcp.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,16 @@ void DBusThreadObjectRcp::AttachAllNodesToHandler(DBusRequest &aRequest)
466466
uint32_t delayTimerMs = 0;
467467
otError error = OT_ERROR_NONE;
468468

469-
auto args = std::tie(dataset, delayTimerMs);
470-
471-
VerifyOrExit(DBusMessageToTuple(*aRequest.GetMessage(), args) == OTBR_ERROR_NONE, error = OT_ERROR_INVALID_ARGS);
469+
// Try parsing with both arguments first (new API)
470+
auto argsWithDelay = std::tie(dataset, delayTimerMs);
471+
if (DBusMessageToTuple(*aRequest.GetMessage(), argsWithDelay) != OTBR_ERROR_NONE)
472+
{
473+
// Fall back to parsing only dataset argument (old API, for backward compatibility)
474+
auto argsDatasetOnly = std::tie(dataset);
475+
VerifyOrExit(DBusMessageToTuple(*aRequest.GetMessage(), argsDatasetOnly) == OTBR_ERROR_NONE,
476+
error = OT_ERROR_INVALID_ARGS);
477+
delayTimerMs = 0; // Use default
478+
}
472479

473480
mHost.GetThreadHelper()->AttachAllNodesTo(dataset, delayTimerMs,
474481
[aRequest](otError error, int64_t aAttachDelayMs) mutable {

src/dbus/server/introspect.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<!-- AttachAllNodesTo: Request to attach all nodes to the specified Thread network.
6868
@dataset: The Operational Dataset that contains parameter values of the Thread network
6969
to attach to. It must be a full dataset.
70-
@delay_timer_ms: The delay timer value in milliseconds to embed in the pending dataset.
70+
@delay_timer_ms: (Optional) The delay timer value in milliseconds to embed in the pending dataset.
7171
If 0, the default of 300 seconds (300000 ms) is used. Maximum is 72 hours
7272
(259200000 ms).
7373
@delay_ms: The delay between the method returns and the dataset takes effect, in

tests/dbus/test-client

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ EOF
336336
--type=method_call --print-reply /io/openthread/BorderRouter/wpan0 \
337337
io.openthread.BorderRouter.AttachAllNodesTo \
338338
"array:byte:${dataset}" \
339-
uint32:0 \
340339
| grep "int64 300000"
341340

342341
ot_ctl dataset pending | grep "Active Timestamp: 2"
@@ -352,7 +351,6 @@ EOF
352351
--type=method_call --print-reply /io/openthread/BorderRouter/wpan0 \
353352
io.openthread.BorderRouter.AttachAllNodesTo \
354353
"array:byte:${dataset}" \
355-
uint32:0 \
356354
| grep "int64 0"
357355
ot_ctl state | grep "leader"
358356

@@ -378,7 +376,6 @@ EOF
378376
--type=method_call --reply-timeout=40000 --print-reply /io/openthread/BorderRouter/wpan0 \
379377
io.openthread.BorderRouter.AttachAllNodesTo \
380378
"array:byte:${dataset}" \
381-
uint32:0 \
382379
| grep "int64 300000"
383380

384381
ot_ctl state | grep "leader"

0 commit comments

Comments
 (0)