aboutsummaryrefslogtreecommitdiff
path: root/src/dbus
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-07-03 15:52:58 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-07-03 15:52:58 +0000
commitf9055633b0e8642869404f8598d6b12260bdeaaf (patch)
tree71aaa03f4550146976967c79fa0a109ad00b93ec /src/dbus
parent16b861c374c60830e369f58cff33a5b5349f9e5c (diff)
parent943382cf28dccd0527094011080cc6f2a8c109cc (diff)
downloadot-br-posix-android14-mainline-adbd-release.tar.gz
Snap for 10428683 from 943382cf28dccd0527094011080cc6f2a8c109cc to mainline-adbd-releaseaml_adb_340912530aml_adb_340912350aml_adb_340912200aml_adb_340912000android14-mainline-adbd-release
Change-Id: I0f803e7067276e0baf236def7a84729fbd4dc930
Diffstat (limited to 'src/dbus')
-rw-r--r--src/dbus/client/thread_api_dbus.cpp104
-rw-r--r--src/dbus/client/thread_api_dbus.hpp503
-rw-r--r--src/dbus/common/constants.hpp17
-rw-r--r--src/dbus/common/dbus_message_helper.hpp167
-rw-r--r--src/dbus/common/dbus_message_helper_openthread.cpp477
-rw-r--r--src/dbus/common/types.hpp135
-rw-r--r--src/dbus/server/dbus_agent.cpp76
-rw-r--r--src/dbus/server/dbus_agent.hpp40
-rw-r--r--src/dbus/server/dbus_object.cpp18
-rw-r--r--src/dbus/server/dbus_object.hpp70
-rw-r--r--src/dbus/server/dbus_request.hpp32
-rw-r--r--src/dbus/server/dbus_thread_object.cpp495
-rw-r--r--src/dbus/server/dbus_thread_object.hpp42
-rw-r--r--src/dbus/server/introspect.xml280
14 files changed, 2069 insertions, 387 deletions
diff --git a/src/dbus/client/thread_api_dbus.cpp b/src/dbus/client/thread_api_dbus.cpp
index 57ffed34..cc9bb2be 100644
--- a/src/dbus/client/thread_api_dbus.cpp
+++ b/src/dbus/client/thread_api_dbus.cpp
@@ -123,6 +123,7 @@ DBusHandlerResult ThreadApiDBus::sDBusMessageFilter(DBusConnection *aConnection,
DBusHandlerResult ThreadApiDBus::DBusMessageFilter(DBusConnection *aConnection, DBusMessage *aMessage)
{
+ DBusHandlerResult handled = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
OTBR_UNUSED_VARIABLE(aConnection);
DBusMessageIter iter, subIter, dictEntryIter, valIter;
@@ -150,9 +151,10 @@ DBusHandlerResult ThreadApiDBus::DBusMessageFilter(DBusConnection *aConnection,
{
f(role);
}
+ handled = DBUS_HANDLER_RESULT_HANDLED;
exit:
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ return handled;
}
void ThreadApiDBus::AddDeviceRoleHandler(const DeviceRoleHandler &aHandler)
@@ -192,6 +194,39 @@ void ThreadApiDBus::ScanPendingCallHandler(DBusPendingCall *aPending)
mScanHandler = nullptr;
}
+ClientError ThreadApiDBus::EnergyScan(uint32_t aScanDuration, const EnergyScanHandler &aHandler)
+{
+ ClientError error = ClientError::ERROR_NONE;
+ const auto args = std::tie(aScanDuration);
+
+ VerifyOrExit(mEnergyScanHandler == nullptr, error = ClientError::OT_ERROR_INVALID_STATE);
+ mEnergyScanHandler = aHandler;
+
+ error = CallDBusMethodAsync(OTBR_DBUS_ENERGY_SCAN_METHOD, args,
+ &ThreadApiDBus::sHandleDBusPendingCall<&ThreadApiDBus::EnergyScanPendingCallHandler>);
+ if (error != ClientError::ERROR_NONE)
+ {
+ mEnergyScanHandler = nullptr;
+ }
+exit:
+ return error;
+}
+
+void ThreadApiDBus::EnergyScanPendingCallHandler(DBusPendingCall *aPending)
+{
+ std::vector<EnergyScanResult> results;
+ UniqueDBusMessage message(dbus_pending_call_steal_reply(aPending));
+ auto args = std::tie(results);
+
+ if (message != nullptr)
+ {
+ DBusMessageToTuple(*message, args);
+ }
+
+ mEnergyScanHandler(results);
+ mEnergyScanHandler = nullptr;
+}
+
ClientError ThreadApiDBus::PermitUnsecureJoin(uint16_t aPort, uint32_t aSeconds)
{
return CallDBusMethodSync(OTBR_DBUS_PERMIT_UNSECURE_JOIN_METHOD, std::tie(aPort, aSeconds));
@@ -267,6 +302,45 @@ void ThreadApiDBus::AttachPendingCallHandler(DBusPendingCall *aPending)
handler(ret);
}
+ClientError ThreadApiDBus::Detach(const OtResultHandler &aHandler)
+{
+ ClientError error = ClientError::ERROR_NONE;
+
+ VerifyOrExit(mDetachHandler == nullptr && mJoinerHandler == nullptr, error = ClientError::OT_ERROR_INVALID_STATE);
+ mDetachHandler = aHandler;
+
+ if (aHandler)
+ {
+ error = CallDBusMethodAsync(OTBR_DBUS_DETACH_METHOD,
+ &ThreadApiDBus::sHandleDBusPendingCall<&ThreadApiDBus::DetachPendingCallHandler>);
+ }
+ else
+ {
+ error = CallDBusMethodSync(OTBR_DBUS_DETACH_METHOD);
+ }
+ if (error != ClientError::ERROR_NONE)
+ {
+ mDetachHandler = nullptr;
+ }
+exit:
+ return error;
+}
+
+void ThreadApiDBus::DetachPendingCallHandler(DBusPendingCall *aPending)
+{
+ ClientError ret = ClientError::OT_ERROR_FAILED;
+ UniqueDBusMessage message(dbus_pending_call_steal_reply(aPending));
+ auto handler = mDetachHandler;
+
+ if (message != nullptr)
+ {
+ ret = CheckErrorMessage(message.get());
+ }
+
+ mDetachHandler = nullptr;
+ handler(ret);
+}
+
ClientError ThreadApiDBus::FactoryReset(const OtResultHandler &aHandler)
{
ClientError error = ClientError::ERROR_NONE;
@@ -544,6 +618,11 @@ ClientError ThreadApiDBus::GetExternalRoutes(std::vector<ExternalRoute> &aExtern
return GetProperty(OTBR_DBUS_PROPERTY_EXTERNAL_ROUTES, aExternalRoutes);
}
+ClientError ThreadApiDBus::GetOnMeshPrefixes(std::vector<OnMeshPrefix> &aOnMeshPrefixes)
+{
+ return GetProperty(OTBR_DBUS_PROPERTY_ON_MESH_PREFIXES, aOnMeshPrefixes);
+}
+
ClientError ThreadApiDBus::GetActiveDatasetTlvs(std::vector<uint8_t> &aDataset)
{
return GetProperty(OTBR_DBUS_PROPERTY_ACTIVE_DATASET_TLVS, aDataset);
@@ -554,6 +633,23 @@ ClientError ThreadApiDBus::GetRadioRegion(std::string &aRadioRegion)
return GetProperty(OTBR_DBUS_PROPERTY_RADIO_REGION, aRadioRegion);
}
+ClientError ThreadApiDBus::GetSrpServerInfo(SrpServerInfo &aSrpServerInfo)
+{
+ return GetProperty(OTBR_DBUS_PROPERTY_SRP_SERVER_INFO, aSrpServerInfo);
+}
+
+ClientError ThreadApiDBus::GetMdnsTelemetryInfo(MdnsTelemetryInfo &aMdnsTelemetryInfo)
+{
+ return GetProperty(OTBR_DBUS_PROPERTY_MDNS_TELEMETRY_INFO, aMdnsTelemetryInfo);
+}
+
+#if OTBR_ENABLE_DNSSD_DISCOVERY_PROXY
+ClientError ThreadApiDBus::GetDnssdCounters(DnssdCounters &aDnssdCounters)
+{
+ return GetProperty(OTBR_DBUS_PROPERTY_DNSSD_COUNTERS, aDnssdCounters);
+}
+#endif
+
std::string ThreadApiDBus::GetInterfaceName(void)
{
return mInterfaceName;
@@ -719,5 +815,11 @@ ClientError ThreadApiDBus::AttachAllNodesTo(const std::vector<uint8_t> &aDataset
return CallDBusMethodSync(OTBR_DBUS_ATTACH_ALL_NODES_TO_METHOD, args);
}
+ClientError ThreadApiDBus::UpdateVendorMeshCopTxtEntries(std::vector<TxtEntry> &aUpdate)
+{
+ auto args = std::tie(aUpdate);
+ return CallDBusMethodSync(OTBR_DBUS_UPDATE_VENDOR_MESHCOP_TXT_METHOD, args);
+}
+
} // namespace DBus
} // namespace otbr
diff --git a/src/dbus/client/thread_api_dbus.hpp b/src/dbus/client/thread_api_dbus.hpp
index 006dbca6..8ab2bcaf 100644
--- a/src/dbus/client/thread_api_dbus.hpp
+++ b/src/dbus/client/thread_api_dbus.hpp
@@ -53,6 +53,7 @@ class ThreadApiDBus
public:
using DeviceRoleHandler = std::function<void(DeviceRole)>;
using ScanHandler = std::function<void(const std::vector<ActiveScanResult> &)>;
+ using EnergyScanHandler = std::function<void(const std::vector<EnergyScanResult> &)>;
using OtResultHandler = std::function<void(ClientError)>;
/**
@@ -60,7 +61,7 @@ public:
*
* Will use the default interfacename
*
- * @param[in] aConnection The dbus connection.
+ * @param[in] aConnection The dbus connection.
*
*/
ThreadApiDBus(DBusConnection *aConnection);
@@ -68,8 +69,8 @@ public:
/**
* The constructor of a d-bus object.
*
- * @param[in] aConnection The dbus connection.
- * @param[in] aInterfaceName The network interface name.
+ * @param[in] aConnection The dbus connection.
+ * @param[in] aInterfaceName The network interface name.
*
*/
ThreadApiDBus(DBusConnection *aConnection, const std::string &aInterfaceName);
@@ -77,7 +78,7 @@ public:
/**
* This method adds a callback for device role change.
*
- * @param[in] aHandler The device role handler.
+ * @param[in] aHandler The device role handler.
*
*/
void AddDeviceRoleHandler(const DeviceRoleHandler &aHandler);
@@ -85,12 +86,12 @@ public:
/**
* This method permits unsecure join on port.
*
- * @param[in] aPort The port number.
- * @param[in] aSeconds The timeout to close the port, 0 for never close.
+ * @param[in] aPort The port number.
+ * @param[in] aSeconds The timeout to close the port, 0 for never close.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError PermitUnsecureJoin(uint16_t aPort, uint32_t aSeconds);
@@ -98,28 +99,43 @@ public:
/**
* This method performs a Thread network scan.
*
- * @param[in] aHandler The scan result handler.
+ * @param[in] aHandler The scan result handler.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError Scan(const ScanHandler &aHandler);
/**
+ * This method performs an IEEE 802.15.4 Energy Scan.
+ *
+ * @param[in] aScanDuration The duration for the scan for each channel, in milliseconds. Note that maximum value
+ * for the duration is currently 65535. If it's the duration is larger than that, the
+ * handler will get an INVALID_ARGS error code.
+ * @param[in] aHandler The energy scan result handler.
+ *
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
+ *
+ */
+ ClientError EnergyScan(uint32_t aScanDuration, const EnergyScanHandler &aHandler);
+
+ /**
* This method attaches the device to the Thread network.
- * @param[in] aNetworkName The network name.
- * @param[in] aPanId The pan id, UINT16_MAX for random.
- * @param[in] aExtPanId The extended pan id, UINT64_MAX for random.
- * @param[in] aNetworkKey The network key, empty for random.
- * @param[in] aPSKc The pre-shared commissioner key, empty for random.
- * @param[in] aChannelMask A bitmask for valid channels, will random select one.
- * @param[in] aHandler The attach result handler.
+ * @param[in] aNetworkName The network name.
+ * @param[in] aPanId The pan id, UINT16_MAX for random.
+ * @param[in] aExtPanId The extended pan id, UINT64_MAX for random.
+ * @param[in] aNetworkKey The network key, empty for random.
+ * @param[in] aPSKc The pre-shared commissioner key, empty for random.
+ * @param[in] aChannelMask A bitmask for valid channels, will random select one.
+ * @param[in] aHandler The attach result handler.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError Attach(const std::string & aNetworkName,
@@ -136,22 +152,32 @@ public:
* The network parameters will be set with the active dataset under this
* circumstance.
*
- * @param[in] aHandler The attach result handler.
+ * @param[in] aHandler The attach result handler.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError Attach(const OtResultHandler &aHandler);
/**
+ * This method detaches the device from the Thread network.
+ *
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
+ *
+ */
+ ClientError Detach(const OtResultHandler &aHandler);
+
+ /**
* This method attaches the device to the specified Thread network.
*
* If the device has already attached to a network, send a request to migrate the existing network.
*
- * @param[in] aDataset The Operational Dataset that contains parameter values of the Thread network to attach
- * to. It must have a valid Delay Timer and Pending Timestamp.
+ * @param[in] aDataset The Operational Dataset that contains parameter values of the Thread network to attach
+ * to. It must have a valid Delay Timer and Pending Timestamp.
*
* @retval ERROR_NONE Successfully requested the Thread network migration.
* @retval ERROR_DBUS D-Bus encode/decode error.
@@ -167,11 +193,11 @@ public:
/**
* This method performs a factory reset.
*
- * @param[in] aHandler The reset result handler.
+ * @param[in] aHandler The reset result handler.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError FactoryReset(const OtResultHandler &aHandler);
@@ -179,9 +205,9 @@ public:
/**
* This method performs a soft reset.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError Reset(void);
@@ -191,17 +217,17 @@ public:
*
* @note The joiner start and the attach proccesses are exclusive
*
- * @param[in] aPskd The pre-shared key for device.
- * @param[in] aProvisioningUrl The provision url.
- * @param[in] aVendorName The vendor name.
- * @param[in] aVendorModel The vendor model.
- * @param[in] aVendorSwVersion The vendor software version.
- * @param[in] aVendorData The vendor custom data.
- * @param[in] aHandler The join result handler.
+ * @param[in] aPskd The pre-shared key for device.
+ * @param[in] aProvisioningUrl The provision url.
+ * @param[in] aVendorName The vendor name.
+ * @param[in] aVendorModel The vendor model.
+ * @param[in] aVendorSwVersion The vendor software version.
+ * @param[in] aVendorData The vendor custom data.
+ * @param[in] aHandler The join result handler.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError JoinerStart(const std::string & aPskd,
@@ -215,9 +241,9 @@ public:
/**
* This method stops the joiner process
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError JoinerStop(void);
@@ -225,11 +251,11 @@ public:
/**
* This method adds a on-mesh address prefix.
*
- * @param[in] aPrefix The address prefix.
+ * @param[in] aPrefix The address prefix.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError AddOnMeshPrefix(const OnMeshPrefix &aPrefix);
@@ -237,11 +263,11 @@ public:
/**
* This method removes a on-mesh address prefix.
*
- * @param[in] aPrefix The address prefix.
+ * @param[in] aPrefix The address prefix.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError RemoveOnMeshPrefix(const Ip6Prefix &aPrefix);
@@ -249,11 +275,11 @@ public:
/**
* This method adds an external route.
*
- * @param[in] aExternalroute The external route config
+ * @param[in] aExternalroute The external route config
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError AddExternalRoute(const ExternalRoute &aExternalRoute);
@@ -261,11 +287,11 @@ public:
/**
* This method removes an external route.
*
- * @param[in] aPrefix The route prefix.
+ * @param[in] aPrefix The route prefix.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError RemoveExternalRoute(const Ip6Prefix &aPrefix);
@@ -273,11 +299,11 @@ public:
/**
* This method sets the mesh-local prefix.
*
- * @param[in] aPrefix The address prefix.
+ * @param[in] aPrefix The address prefix.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError SetMeshLocalPrefix(const std::array<uint8_t, OTBR_IP6_PREFIX_SIZE> &aPrefix);
@@ -285,11 +311,11 @@ public:
/**
* This method sets the legacy prefix of ConnectIP.
*
- * @param[in] aPrefix The address prefix.
+ * @param[in] aPrefix The address prefix.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError SetLegacyUlaPrefix(const std::array<uint8_t, OTBR_IP6_PREFIX_SIZE> &aPrefix);
@@ -297,11 +323,11 @@ public:
/**
* This method sets the active operational dataset.
*
- * @param[out] aDataset The active operational dataset
+ * @param[out] aDataset The active operational dataset
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError SetActiveDatasetTlvs(const std::vector<uint8_t> &aDataset);
@@ -309,11 +335,11 @@ public:
/**
* This method sets the link operating mode.
*
- * @param[in] aConfig The operating mode config.
+ * @param[in] aConfig The operating mode config.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError SetLinkMode(const LinkModeConfig &aConfig);
@@ -321,11 +347,11 @@ public:
/**
* This method sets the radio region.
*
- * @param[in] aRadioRegion The radio region.
+ * @param[in] aRadioRegion The radio region.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError SetRadioRegion(const std::string &aRadioRegion);
@@ -333,11 +359,11 @@ public:
/**
* This method gets the link operating mode.
*
- * @param[out] aConfig The operating mode config.
+ * @param[out] aConfig The operating mode config.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetLinkMode(LinkModeConfig &aConfig);
@@ -345,11 +371,11 @@ public:
/**
* This method gets the current device role.
*
- * @param[out] aDeviceRole The device role
+ * @param[out] aDeviceRole The device role
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetDeviceRole(DeviceRole &aDeviceRole);
@@ -357,11 +383,11 @@ public:
/**
* This method gets the network name.
*
- * @param[out] aName The network name.
+ * @param[out] aName The network name.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetNetworkName(std::string &aName);
@@ -369,11 +395,11 @@ public:
/**
* This method gets the network pan id.
*
- * @param[out] aPanId The pan id.
+ * @param[out] aPanId The pan id.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetPanId(uint16_t &aPanId);
@@ -381,11 +407,11 @@ public:
/**
* This method gets the extended pan id.
*
- * @param[out] aExtPanId The extended pan id.
+ * @param[out] aExtPanId The extended pan id.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetExtPanId(uint64_t &aExtPanId);
@@ -393,11 +419,11 @@ public:
/**
* This method gets the extended pan id.
*
- * @param[out] aChannel The extended pan id.
+ * @param[out] aChannel The extended pan id.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetChannel(uint16_t &aChannel);
@@ -405,11 +431,11 @@ public:
/**
* This method gets the network network key.
*
- * @param[out] aNetworkKey The network network key.
+ * @param[out] aNetworkKey The network network key.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetNetworkKey(std::vector<uint8_t> &aNetworkKey);
@@ -417,11 +443,11 @@ public:
/**
* This method gets the Clear Channel Assessment failure rate.
*
- * @param[out] aFailureRate The failure rate.
+ * @param[out] aFailureRate The failure rate.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetCcaFailureRate(uint16_t &aFailureRate);
@@ -429,11 +455,11 @@ public:
/**
* This method gets the mac level statistics counters.
*
- * @param[out] aCounters The statistic counters.
+ * @param[out] aCounters The statistic counters.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetLinkCounters(MacCounters &aCounters); // For telemetry
@@ -441,11 +467,11 @@ public:
/**
* This method gets the ip level statistics counters.
*
- * @param[out] aCounters The statistic counters.
+ * @param[out] aCounters The statistic counters.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetIp6Counters(IpCounters &aCounters); // For telemetry
@@ -453,11 +479,11 @@ public:
/**
* This method gets the supported channel mask.
*
- * @param[out] aChannelMask The channel mask.
+ * @param[out] aChannelMask The channel mask.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetSupportedChannelMask(uint32_t &aChannelMask);
@@ -465,11 +491,11 @@ public:
/**
* This method gets the Thread routing locator
*
- * @param[out] aRloc16 The routing locator
+ * @param[out] aRloc16 The routing locator
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetRloc16(uint16_t &aRloc16);
@@ -477,11 +503,11 @@ public:
/**
* This method gets 802.15.4 extended address
*
- * @param[out] aExtendedAddress The extended address
+ * @param[out] aExtendedAddress The extended address
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetExtendedAddress(uint64_t &aExtendedAddress);
@@ -489,12 +515,12 @@ public:
/**
* This method gets the node's router id.
*
- * @param[out] aRouterId The router id.
+ * @param[out] aRouterId The router id.
*
- * @retval ERROR_NONE Successfully performed the dbus function call.
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval OT_ERROR_INVALID_STATE The node is not a router.
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call.
+ * @retval ERROR_DBUS dbus encode/decode error.
+ * @retval OT_ERROR_INVALID_STATE The node is not a router.
+ * @retval ... OpenThread defined error value otherwise.
*
*/
ClientError GetRouterId(uint8_t &aRouterId);
@@ -502,11 +528,11 @@ public:
/**
* This method gets the network's leader data.
*
- * @param[out] aLeaderData The leader data.
+ * @param[out] aLeaderData The leader data.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetLeaderData(LeaderData &aLeaderData);
@@ -514,11 +540,11 @@ public:
/**
* This method gets the network data.
*
- * @param[out] aNetworkData The network data.
+ * @param[out] aNetworkData The network data.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetNetworkData(std::vector<uint8_t> &aNetworkData);
@@ -526,11 +552,11 @@ public:
/**
* This method gets the stable network data.
*
- * @param[out] aNetworkData The stable network data.
+ * @param[out] aNetworkData The stable network data.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetStableNetworkData(std::vector<uint8_t> &aNetworkData);
@@ -538,11 +564,11 @@ public:
/**
* This method gets the node's local leader weight.
*
- * @param[out] aWeight The local leader weight.
+ * @param[out] aWeight The local leader weight.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetLocalLeaderWeight(uint8_t &aWeight);
@@ -550,11 +576,11 @@ public:
/**
* This method gets the channel monitor sample count.
*
- * @param[out] aSampleCount The channel monitor sample count.
+ * @param[out] aSampleCount The channel monitor sample count.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetChannelMonitorSampleCount(uint32_t &aSampleCount);
@@ -562,11 +588,11 @@ public:
/**
* This method gets the channel qualities
*
- * @param[out] aChannelQualities The channel qualities.
+ * @param[out] aChannelQualities The channel qualities.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetChannelMonitorAllChannelQualities(std::vector<ChannelQuality> &aChannelQualities);
@@ -574,11 +600,11 @@ public:
/**
* This method gets the child table.
*
- * @param[out] aChildTable The child table.
+ * @param[out] aChildTable The child table.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetChildTable(std::vector<ChildInfo> &aChildTable);
@@ -586,11 +612,11 @@ public:
/**
* This method gets the neighbor table.
*
- * @param[out] aNeighborTable The neighbor table.
+ * @param[out] aNeighborTable The neighbor table.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetNeighborTable(std::vector<NeighborInfo> &aNeighborTable);
@@ -598,11 +624,11 @@ public:
/**
* This method gets the network's parition id.
*
- * @param[out] aPartitionId The partition id.
+ * @param[out] aPartitionId The partition id.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetPartitionId(uint32_t &aPartitionId);
@@ -610,11 +636,11 @@ public:
/**
* This method gets the rssi of the latest packet.
*
- * @param[out] aRssi The rssi of the latest packet.
+ * @param[out] aRssi The rssi of the latest packet.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetInstantRssi(int8_t &aRssi);
@@ -622,11 +648,11 @@ public:
/**
* This method gets the radio transmit power.
*
- * @param[out] aTxPower The radio transmit power.
+ * @param[out] aTxPower The radio transmit power.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetRadioTxPower(int8_t &aTxPower);
@@ -634,23 +660,35 @@ public:
/**
* This method gets the external route table
*
- * @param[out] aExternalRoutes The external route table
+ * @param[out] aExternalRoutes The external route table
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetExternalRoutes(std::vector<ExternalRoute> &aExternalRoutes);
/**
+ * This method gets the on-mesh prefixes
+ *
+ * @param[out] aOnMeshPrefixes The on-mesh prefixes
+ *
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
+ *
+ */
+ ClientError GetOnMeshPrefixes(std::vector<OnMeshPrefix> &aOnMeshPrefixes);
+
+ /**
* This method gets the active operational dataset
*
- * @param[out] aDataset The active operational dataset
+ * @param[out] aDataset The active operational dataset
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetActiveDatasetTlvs(std::vector<uint8_t> &aDataset);
@@ -658,16 +696,54 @@ public:
/**
* This method gets the radio region.
*
- * @param[out] aRadioRegion The radio region.
+ * @param[out] aRadioRegion The radio region.
*
- * @retval ERROR_NONE successfully performed the dbus function call
- * @retval ERROR_DBUS dbus encode/decode error
- * @retval ... OpenThread defined error value otherwise
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
*
*/
ClientError GetRadioRegion(std::string &aRadioRegion);
/**
+ * This method gets the SRP server information.
+ *
+ * @param[out] aSrpServerInfo The SRP server information.
+ *
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
+ *
+ */
+ ClientError GetSrpServerInfo(SrpServerInfo &aSrpServerInfo);
+
+ /**
+ * This method gets the MDNS telemetry information.
+ *
+ * @param[out] aMdnsTelemetryInfo The MDNS telemetry information.
+ *
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
+ *
+ */
+ ClientError GetMdnsTelemetryInfo(MdnsTelemetryInfo &aMdnsTelemetryInfo);
+
+#if OTBR_ENABLE_DNSSD_DISCOVERY_PROXY
+ /**
+ * This method gets the DNS-SD counters.
+ *
+ * @param[out] aDnssdCounters The DNS-SD counters.
+ *
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
+ *
+ */
+ ClientError GetDnssdCounters(DnssdCounters &aDnssdCounters);
+#endif
+
+ /**
* This method returns the network interface name the client is bound to.
*
* @returns The network interface name.
@@ -675,6 +751,25 @@ public:
*/
std::string GetInterfaceName(void);
+ /**
+ * This method sets multiple vendor-specific entries for the TXT record of the MeshCoP service.
+ *
+ * @note
+ * - The @p aUpdate must contain all vendor-specific TXT entries you want to update. The latest call will supersede
+ * previous calls.
+ * - If @p aUpdate contains thread-specific entries like 'nn', 'at', the whole update will be rejected.
+ * - If @p aUpdate contains a key which is already published in TXT record, it will be updated according to @p
+ * aUpdate.
+ *
+ * @param[in] aUpdate The updated key-value entries.
+ *
+ * @retval ERROR_NONE Successfully performed the dbus function call
+ * @retval ERROR_DBUS dbus encode/decode error
+ * @retval ... OpenThread defined error value otherwise
+ *
+ */
+ ClientError UpdateVendorMeshCopTxtEntries(std::vector<TxtEntry> &aUpdate);
+
private:
ClientError CallDBusMethodSync(const std::string &aMethodName);
ClientError CallDBusMethodAsync(const std::string &aMethodName, DBusPendingCallNotifyFunction aFunction);
@@ -698,10 +793,12 @@ private:
static void sHandleDBusPendingCall(DBusPendingCall *aPending, void *aThreadApiDBus);
void AttachPendingCallHandler(DBusPendingCall *aPending);
+ void DetachPendingCallHandler(DBusPendingCall *aPending);
void FactoryResetPendingCallHandler(DBusPendingCall *aPending);
void JoinerStartPendingCallHandler(DBusPendingCall *aPending);
static void sScanPendingCallHandler(DBusPendingCall *aPending, void *aThreadApiDBus);
void ScanPendingCallHandler(DBusPendingCall *aPending);
+ void EnergyScanPendingCallHandler(DBusPendingCall *aPending);
static void EmptyFree(void *) {}
@@ -709,10 +806,12 @@ private:
DBusConnection *mConnection;
- ScanHandler mScanHandler;
- OtResultHandler mAttachHandler;
- OtResultHandler mFactoryResetHandler;
- OtResultHandler mJoinerHandler;
+ ScanHandler mScanHandler;
+ EnergyScanHandler mEnergyScanHandler;
+ OtResultHandler mAttachHandler;
+ OtResultHandler mDetachHandler;
+ OtResultHandler mFactoryResetHandler;
+ OtResultHandler mJoinerHandler;
std::vector<DeviceRoleHandler> mDeviceRoleHandlers;
};
diff --git a/src/dbus/common/constants.hpp b/src/dbus/common/constants.hpp
index 2004f0a9..ce2e1a7f 100644
--- a/src/dbus/common/constants.hpp
+++ b/src/dbus/common/constants.hpp
@@ -45,6 +45,7 @@
#define OTBR_DBUS_OBJECT_PREFIX "/io/openthread/BorderRouter/"
#define OTBR_DBUS_SCAN_METHOD "Scan"
+#define OTBR_DBUS_ENERGY_SCAN_METHOD "EnergyScan"
#define OTBR_DBUS_ATTACH_METHOD "Attach"
#define OTBR_DBUS_DETACH_METHOD "Detach"
#define OTBR_DBUS_FACTORY_RESET_METHOD "FactoryReset"
@@ -57,6 +58,8 @@
#define OTBR_DBUS_ADD_EXTERNAL_ROUTE_METHOD "AddExternalRoute"
#define OTBR_DBUS_REMOVE_EXTERNAL_ROUTE_METHOD "RemoveExternalRoute"
#define OTBR_DBUS_ATTACH_ALL_NODES_TO_METHOD "AttachAllNodesTo"
+#define OTBR_DBUS_UPDATE_VENDOR_MESHCOP_TXT_METHOD "UpdateVendorMeshCopTxtEntries"
+#define OTBR_DBUS_GET_PROPERTIES_METHOD "GetProperties"
#define OTBR_DBUS_PROPERTY_MESH_LOCAL_PREFIX "MeshLocalPrefix"
#define OTBR_DBUS_PROPERTY_LEGACY_ULA_PREFIX "LegacyULAPrefix"
@@ -86,8 +89,20 @@
#define OTBR_DBUS_PROPERTY_INSTANT_RSSI "InstantRssi"
#define OTBR_DBUS_PROPERTY_RADIO_TX_POWER "RadioTxPower"
#define OTBR_DBUS_PROPERTY_EXTERNAL_ROUTES "ExternalRoutes"
+#define OTBR_DBUS_PROPERTY_ON_MESH_PREFIXES "OnMeshPrefixes"
#define OTBR_DBUS_PROPERTY_ACTIVE_DATASET_TLVS "ActiveDatasetTlvs"
#define OTBR_DBUS_PROPERTY_RADIO_REGION "RadioRegion"
+#define OTBR_DBUS_PROPERTY_SRP_SERVER_INFO "SrpServerInfo"
+#define OTBR_DBUS_PROPERTY_DNSSD_COUNTERS "DnssdCounters"
+#define OTBR_DBUS_PROPERTY_OT_HOST_VERSION "OtHostVersion"
+#define OTBR_DBUS_PROPERTY_OT_RCP_VERSION "OtRcpVersion"
+#define OTBR_DBUS_PROPERTY_THREAD_VERSION "ThreadVersion"
+#define OTBR_DBUS_PROPERTY_EUI64 "Eui64"
+#define OTBR_DBUS_PROPERTY_MDNS_TELEMETRY_INFO "MdnsTelemetryInfo"
+#define OTBR_DBUS_PROPERTY_RADIO_SPINEL_METRICS "RadioSpinelMetrics"
+#define OTBR_DBUS_PROPERTY_RCP_INTERFACE_METRICS "RcpInterfaceMetrics"
+#define OTBR_DBUS_PROPERTY_UPTIME "Uptime"
+#define OTBR_DBUS_PROPERTY_RADIO_COEX_METRICS "RadioCoexMetrics"
#define OTBR_ROLE_NAME_DISABLED "disabled"
#define OTBR_ROLE_NAME_DETACHED "detached"
@@ -95,4 +110,6 @@
#define OTBR_ROLE_NAME_ROUTER "router"
#define OTBR_ROLE_NAME_LEADER "leader"
+#define OTBR_DBUS_SIGNAL_READY "Ready"
+
#endif // OTBR_DBUS_CONSTANTS_HPP_
diff --git a/src/dbus/common/dbus_message_helper.hpp b/src/dbus/common/dbus_message_helper.hpp
index e7240f6b..ccc81192 100644
--- a/src/dbus/common/dbus_message_helper.hpp
+++ b/src/dbus/common/dbus_message_helper.hpp
@@ -53,6 +53,8 @@ otbrError DBusMessageEncode(DBusMessageIter *aIter, const otbrError &aError);
otbrError DBusMessageExtract(DBusMessageIter *aIter, otbrError &aError);
otbrError DBusMessageEncode(DBusMessageIter *aIter, const ActiveScanResult &aScanResult);
otbrError DBusMessageExtract(DBusMessageIter *aIter, ActiveScanResult &aScanResult);
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const EnergyScanResult &aResult);
+otbrError DBusMessageExtract(DBusMessageIter *aIter, EnergyScanResult &aResult);
otbrError DBusMessageEncode(DBusMessageIter *aIter, const LinkModeConfig &aConfig);
otbrError DBusMessageExtract(DBusMessageIter *aIter, LinkModeConfig &aConfig);
otbrError DBusMessageEncode(DBusMessageIter *aIter, const Ip6Prefix &aPrefix);
@@ -73,6 +75,26 @@ otbrError DBusMessageEncode(DBusMessageIter *aIter, const LeaderData &aLeaderDat
otbrError DBusMessageExtract(DBusMessageIter *aIter, LeaderData &aLeaderData);
otbrError DBusMessageEncode(DBusMessageIter *aIter, const ChannelQuality &aQuality);
otbrError DBusMessageExtract(DBusMessageIter *aIter, ChannelQuality &aQuality);
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const TxtEntry &aTxtEntry);
+otbrError DBusMessageExtract(DBusMessageIter *aIter, TxtEntry &aTxtEntry);
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const SrpServerInfo::Registration &aRegistration);
+otbrError DBusMessageExtract(DBusMessageIter *aIter, SrpServerInfo::Registration &aRegistration);
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const SrpServerInfo::ResponseCounters &aResponseCounters);
+otbrError DBusMessageExtract(DBusMessageIter *aIter, SrpServerInfo::ResponseCounters &aResponseCounters);
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const SrpServerInfo &aSrpServerInfo);
+otbrError DBusMessageExtract(DBusMessageIter *aIter, SrpServerInfo &aSrpServerInfo);
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const MdnsResponseCounters &aMdnsResponseCounters);
+otbrError DBusMessageExtract(DBusMessageIter *aIter, MdnsResponseCounters &aMdnsResponseCounters);
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const MdnsTelemetryInfo &aMdnsTelemetryInfo);
+otbrError DBusMessageExtract(DBusMessageIter *aIter, MdnsTelemetryInfo &aMdnsTelemetryInfo);
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const DnssdCounters &aDnssdCounters);
+otbrError DBusMessageExtract(DBusMessageIter *aIter, DnssdCounters &aDnssdCounters);
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const RadioSpinelMetrics &aRadioSpinelMetrics);
+otbrError DBusMessageExtract(DBusMessageIter *aIter, RadioSpinelMetrics &RadioSpinelMetrics);
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const RcpInterfaceMetrics &aRcpInterfaceMetrics);
+otbrError DBusMessageExtract(DBusMessageIter *aIter, RcpInterfaceMetrics &aRcpInterfaceMetrics);
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const RadioCoexMetrics &aRadioCoexMetrics);
+otbrError DBusMessageExtract(DBusMessageIter *aIter, RadioCoexMetrics &aRadioCoexMetrics);
template <typename T> struct DBusTypeTrait;
@@ -124,6 +146,18 @@ template <> struct DBusTypeTrait<std::vector<ExternalRoute>>
static constexpr const char *TYPE_AS_STRING = "a((ayy)qybb)";
};
+template <> struct DBusTypeTrait<OnMeshPrefix>
+{
+ // struct of {{array of bytes, byte}, uint16, byte, bool, bool, bool, bool, bool, bool, bool, bool, bool}
+ static constexpr const char *TYPE_AS_STRING = "((ayy)qybbbbbbbbb)";
+};
+
+template <> struct DBusTypeTrait<std::vector<OnMeshPrefix>>
+{
+ // array of {{array of bytes, byte}, uint16, byte, bool, bool, bool, bool, bool, bool, bool, bool, bool}
+ static constexpr const char *TYPE_AS_STRING = "a((ayy)qybbbbbbbbb)";
+};
+
template <> struct DBusTypeTrait<LeaderData>
{
// struct of { uint32, byte, byte, byte, byte }
@@ -164,6 +198,12 @@ template <> struct DBusTypeTrait<ActiveScanResult>
static constexpr const char *TYPE_AS_STRING = "(tstayqqyyyybb)";
};
+template <> struct DBusTypeTrait<EnergyScanResult>
+{
+ // struct of { uint8, int8_t }
+ static constexpr const char *TYPE_AS_STRING = "(yy)";
+};
+
template <> struct DBusTypeTrait<ChannelQuality>
{
// struct of { uint8, uint16}
@@ -177,6 +217,75 @@ template <> struct DBusTypeTrait<std::vector<ChildInfo>>
static constexpr const char *TYPE_AS_STRING = "a(tuuqqyyyyqqbbbb)";
};
+template <> struct DBusTypeTrait<TxtEntry>
+{
+ // struct of { string, array<uint8> }
+ static constexpr const char *TYPE_AS_STRING = "(say)";
+};
+
+template <> struct DBusTypeTrait<std::vector<TxtEntry>>
+{
+ // array of struct of { string, array<uint8> }
+ static constexpr const char *TYPE_AS_STRING = "a(say)";
+};
+
+template <> struct DBusTypeTrait<SrpServerState>
+{
+ static constexpr int TYPE = DBUS_TYPE_BYTE;
+ static constexpr const char *TYPE_AS_STRING = DBUS_TYPE_BYTE_AS_STRING;
+};
+
+template <> struct DBusTypeTrait<SrpServerAddressMode>
+{
+ static constexpr int TYPE = DBUS_TYPE_BYTE;
+ static constexpr const char *TYPE_AS_STRING = DBUS_TYPE_BYTE_AS_STRING;
+};
+
+template <> struct DBusTypeTrait<SrpServerInfo>
+{
+ // struct of { uint8, uint16, uint8,
+ // struct of { uint32, uint32, uint64, uint64, uint64, uint64 },
+ // struct of { uint32, uint32, uint64, uint64, uint64, uint64 },
+ // struct of { uint32, uint32, uint32, uint32, uint32, uint32} }
+ static constexpr const char *TYPE_AS_STRING = "(yqy(uutttt)(uutttt)(uuuuuu))";
+};
+
+template <> struct DBusTypeTrait<MdnsTelemetryInfo>
+{
+ // struct of { struct of { uint32, uint32, uint32, uint32, uint32, uint32 },
+ // struct of { uint32, uint32, uint32, uint32, uint32, uint32 },
+ // struct of { uint32, uint32, uint32, uint32, uint32, uint32 },
+ // struct of { uint32, uint32, uint32, uint32, uint32, uint32 },
+ // uint32, uint32, uint32, uint32 }
+ static constexpr const char *TYPE_AS_STRING = "((uuuuuu)(uuuuuu)(uuuuuu)(uuuuuu)uuuu)";
+};
+
+template <> struct DBusTypeTrait<DnssdCounters>
+{
+ // struct of { uint32, uint32, uint32, uint32, uint32, uint32, uint32 }
+ static constexpr const char *TYPE_AS_STRING = "(uuuuuuu)";
+};
+
+template <> struct DBusTypeTrait<RadioSpinelMetrics>
+{
+ // struct of { uint32, uint32, uint32, uint32 }
+ static constexpr const char *TYPE_AS_STRING = "(uuuu)";
+};
+
+template <> struct DBusTypeTrait<RcpInterfaceMetrics>
+{
+ // struct of { uint8, uint64, uint64, uint64, uint64, uint64, uint64, uint64 }
+ static constexpr const char *TYPE_AS_STRING = "(yttttttt)";
+};
+
+template <> struct DBusTypeTrait<RadioCoexMetrics>
+{
+ // struct of { uint32, uint32, uint32, uint32, uint32, uint32, uint32, uint32,
+ // uint32, uint32, uint32, uint32, uint32, uint32, uint32, uint32,
+ // uint32, uint32, bool }
+ static constexpr const char *TYPE_AS_STRING = "(uuuuuuuuuuuuuuuuuub)";
+};
+
template <> struct DBusTypeTrait<int8_t>
{
static constexpr int TYPE = DBUS_TYPE_BYTE;
@@ -449,6 +558,24 @@ public:
}
};
+template <> class DBusMessageIterFor<0, 0>
+{
+public:
+ static otbrError ConvertToTuple(DBusMessageIter *aIter, std::tuple<> &aValues)
+ {
+ OTBR_UNUSED_VARIABLE(aIter);
+ OTBR_UNUSED_VARIABLE(aValues);
+ return OTBR_ERROR_NONE;
+ }
+
+ static otbrError ConvertToDBusMessage(DBusMessageIter *aIter, const std::tuple<> &aValues)
+ {
+ OTBR_UNUSED_VARIABLE(aIter);
+ OTBR_UNUSED_VARIABLE(aValues);
+ return OTBR_ERROR_NONE;
+ }
+};
+
template <size_t N, typename... FieldTypes> class DBusMessageIterFor<1, N, FieldTypes...>
{
public:
@@ -486,11 +613,11 @@ constexpr otbrError ConvertToTuple(DBusMessageIter *aIter, std::tuple<FieldTypes
/**
* This function converts a value to a d-bus variant.
*
- * @param[out] aIter The message iterator pointing to the variant.
- * @param[in] aValue The value input.
+ * @param[out] aIter The message iterator pointing to the variant.
+ * @param[in] aValue The value input.
*
- * @retval OTBR_ERROR_NONE Successfully encoded to the variant.
- * @retval OTBR_ERROR_DBUS Failed to encode to the variant.
+ * @retval OTBR_ERROR_NONE Successfully encoded to the variant.
+ * @retval OTBR_ERROR_DBUS Failed to encode to the variant.
*/
template <typename ValueType> otbrError DBusMessageEncodeToVariant(DBusMessageIter *aIter, const ValueType &aValue)
{
@@ -512,11 +639,11 @@ exit:
/**
* This function converts a d-bus variant to a value.
*
- * @param[in] aIter The message iterator pointing to the variant.
- * @param[out] aValue The value output.
+ * @param[in] aIter The message iterator pointing to the variant.
+ * @param[out] aValue The value output.
*
- * @retval OTBR_ERROR_NONE Successfully decoded the variant.
- * @retval OTBR_ERROR_DBUS Failed to decode the variant.
+ * @retval OTBR_ERROR_NONE Successfully decoded the variant.
+ * @retval OTBR_ERROR_DBUS Failed to decode the variant.
*/
template <typename ValueType> otbrError DBusMessageExtractFromVariant(DBusMessageIter *aIter, ValueType &aValue)
{
@@ -535,11 +662,11 @@ exit:
/**
* This function converts a d-bus message to a tuple of C++ types.
*
- * @param[in] aMessage The dbus message to decode.
- * @param[out] aValues The tuple output.
+ * @param[in] aMessage The dbus message to decode.
+ * @param[out] aValues The tuple output.
*
- * @retval OTBR_ERROR_NONE Successfully decoded the message.
- * @retval OTBR_ERROR_DBUS Failed to decode the message.
+ * @retval OTBR_ERROR_NONE Successfully decoded the message.
+ * @retval OTBR_ERROR_DBUS Failed to decode the message.
*/
template <typename... FieldTypes>
otbrError DBusMessageToTuple(DBusMessage &aMessage, std::tuple<FieldTypes...> &aValues)
@@ -558,11 +685,11 @@ exit:
/**
* This function converts a tuple of C++ types to a d-bus message.
*
- * @param[out] aMessage The dbus message output.
- * @param[in] aValues The tuple to encode.
+ * @param[out] aMessage The dbus message output.
+ * @param[in] aValues The tuple to encode.
*
- * @retval OTBR_ERROR_NONE Successfully encoded the message.
- * @retval OTBR_ERROR_DBUS Failed to encode the message.
+ * @retval OTBR_ERROR_NONE Successfully encoded the message.
+ * @retval OTBR_ERROR_DBUS Failed to encode the message.
*/
template <typename... FieldTypes>
otbrError TupleToDBusMessage(DBusMessage &aMessage, const std::tuple<FieldTypes...> &aValues)
@@ -576,11 +703,11 @@ otbrError TupleToDBusMessage(DBusMessage &aMessage, const std::tuple<FieldTypes.
/**
* This function converts a d-bus message to a tuple of C++ types.
*
- * @param[in] aMessage The dbus message to decode.
- * @param[out] aValues The tuple output.
+ * @param[in] aMessage The dbus message to decode.
+ * @param[out] aValues The tuple output.
*
- * @retval OTBR_ERROR_NONE Successfully decoded the message.
- * @retval OTBR_ERROR_DBUS Failed to decode the message.
+ * @retval OTBR_ERROR_NONE Successfully decoded the message.
+ * @retval OTBR_ERROR_DBUS Failed to decode the message.
*/
template <typename... FieldTypes>
otbrError DBusMessageToTuple(UniqueDBusMessage const &aMessage, std::tuple<FieldTypes...> &aValues)
diff --git a/src/dbus/common/dbus_message_helper_openthread.cpp b/src/dbus/common/dbus_message_helper_openthread.cpp
index 7193f4d4..b91c5479 100644
--- a/src/dbus/common/dbus_message_helper_openthread.cpp
+++ b/src/dbus/common/dbus_message_helper_openthread.cpp
@@ -68,7 +68,7 @@ otbrError DBusMessageExtract(DBusMessageIter *aIter, ActiveScanResult &aScanResu
SuccessOrExit(error = DBusMessageExtract(&sub, aScanResult.mLqi));
SuccessOrExit(error = DBusMessageExtract(&sub, aScanResult.mVersion));
SuccessOrExit(error = DBusMessageExtract(&sub, aScanResult.mIsNative));
- SuccessOrExit(error = DBusMessageExtract(&sub, aScanResult.mIsJoinable));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aScanResult.mDiscover));
dbus_message_iter_next(aIter);
error = OTBR_ERROR_NONE;
@@ -93,7 +93,7 @@ otbrError DBusMessageEncode(DBusMessageIter *aIter, const ActiveScanResult &aSca
SuccessOrExit(error = DBusMessageEncode(&sub, aScanResult.mLqi));
SuccessOrExit(error = DBusMessageEncode(&sub, aScanResult.mVersion));
SuccessOrExit(error = DBusMessageEncode(&sub, aScanResult.mIsNative));
- SuccessOrExit(error = DBusMessageEncode(&sub, aScanResult.mIsJoinable));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aScanResult.mDiscover));
VerifyOrExit(dbus_message_iter_close_container(aIter, &sub), error = OTBR_ERROR_DBUS);
error = OTBR_ERROR_NONE;
@@ -101,6 +101,38 @@ exit:
return error;
}
+otbrError DBusMessageExtract(DBusMessageIter *aIter, EnergyScanResult &aResult)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+
+ VerifyOrExit(dbus_message_iter_get_arg_type(aIter) == DBUS_TYPE_STRUCT, error = OTBR_ERROR_DBUS);
+ dbus_message_iter_recurse(aIter, &sub);
+
+ SuccessOrExit(error = DBusMessageExtract(&sub, aResult.mChannel));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aResult.mMaxRssi));
+
+ dbus_message_iter_next(aIter);
+exit:
+ return error;
+}
+
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const EnergyScanResult &aResult)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+
+ VerifyOrExit(dbus_message_iter_open_container(aIter, DBUS_TYPE_STRUCT, nullptr, &sub), error = OTBR_ERROR_DBUS);
+
+ SuccessOrExit(error = DBusMessageEncode(&sub, aResult.mChannel));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aResult.mMaxRssi));
+
+ VerifyOrExit(dbus_message_iter_close_container(aIter, &sub), error = OTBR_ERROR_DBUS);
+
+exit:
+ return error;
+}
+
otbrError DBusMessageEncode(DBusMessageIter *aIter, const LinkModeConfig &aConfig)
{
otbrError error = OTBR_ERROR_NONE;
@@ -208,36 +240,51 @@ exit:
otbrError DBusMessageEncode(DBusMessageIter *aIter, const OnMeshPrefix &aPrefix)
{
- DBusMessageIter sub, flagsSub;
- auto args = std::tie(aPrefix.mPreferred, aPrefix.mSlaac, aPrefix.mDhcp, aPrefix.mConfigure, aPrefix.mDefaultRoute,
- aPrefix.mOnMesh, aPrefix.mStable);
- otbrError error = OTBR_ERROR_NONE;
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
VerifyOrExit(dbus_message_iter_open_container(aIter, DBUS_TYPE_STRUCT, nullptr, &sub), error = OTBR_ERROR_DBUS);
- SuccessOrExit(error = ConvertToDBusMessage(&sub, std::tie(aPrefix.mPrefix, aPrefix.mPreference)));
- VerifyOrExit(dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, nullptr, &flagsSub), error = OTBR_ERROR_DBUS);
- SuccessOrExit(error = ConvertToDBusMessage(&flagsSub, args));
- VerifyOrExit(dbus_message_iter_close_container(&sub, &flagsSub) == true, error = OTBR_ERROR_DBUS);
- VerifyOrExit(dbus_message_iter_close_container(aIter, &sub) == true, error = OTBR_ERROR_DBUS);
+
+ SuccessOrExit(error = DBusMessageEncode(&sub, aPrefix.mPrefix));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aPrefix.mRloc16));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aPrefix.mPreference));
+
+ SuccessOrExit(error = DBusMessageEncode(&sub, aPrefix.mPreferred));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aPrefix.mSlaac));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aPrefix.mDhcp));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aPrefix.mConfigure));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aPrefix.mDefaultRoute));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aPrefix.mOnMesh));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aPrefix.mStable));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aPrefix.mNdDns));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aPrefix.mDp));
+ VerifyOrExit(dbus_message_iter_close_container(aIter, &sub), error = OTBR_ERROR_DBUS);
+
exit:
return error;
}
otbrError DBusMessageExtract(DBusMessageIter *aIter, OnMeshPrefix &aPrefix)
{
- DBusMessageIter sub, flagsSub;
- auto args = std::tie(aPrefix.mPrefix, aPrefix.mPreference);
- auto flagArgs = std::tie(aPrefix.mPreferred, aPrefix.mSlaac, aPrefix.mDhcp, aPrefix.mConfigure,
- aPrefix.mDefaultRoute, aPrefix.mOnMesh, aPrefix.mStable);
- otbrError error = OTBR_ERROR_NONE;
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
- VerifyOrExit(dbus_message_iter_get_arg_type(aIter) == DBUS_TYPE_STRUCT, error = OTBR_ERROR_DBUS);
dbus_message_iter_recurse(aIter, &sub);
- SuccessOrExit(error = ConvertToTuple(&sub, args));
- VerifyOrExit(dbus_message_iter_get_arg_type(&sub) == DBUS_TYPE_STRUCT, error = OTBR_ERROR_DBUS);
- dbus_message_iter_recurse(&sub, &flagsSub);
- SuccessOrExit(error = ConvertToTuple(&flagsSub, flagArgs));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aPrefix.mPrefix));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aPrefix.mRloc16));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aPrefix.mPreference));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aPrefix.mPreferred));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aPrefix.mSlaac));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aPrefix.mDhcp));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aPrefix.mConfigure));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aPrefix.mDefaultRoute));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aPrefix.mOnMesh));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aPrefix.mStable));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aPrefix.mNdDns));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aPrefix.mDp));
+
dbus_message_iter_next(aIter);
+
exit:
return error;
}
@@ -438,5 +485,393 @@ exit:
return error;
}
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const TxtEntry &aTxtEntry)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+ auto args = std::tie(aTxtEntry.mKey, aTxtEntry.mValue);
+
+ VerifyOrExit(dbus_message_iter_open_container(aIter, DBUS_TYPE_STRUCT, nullptr, &sub));
+ SuccessOrExit(error = ConvertToDBusMessage(&sub, args));
+ VerifyOrExit(dbus_message_iter_close_container(aIter, &sub) == true, error = OTBR_ERROR_DBUS);
+exit:
+ return error;
+}
+
+otbrError DBusMessageExtract(DBusMessageIter *aIter, TxtEntry &aTxtEntry)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+ auto args = std::tie(aTxtEntry.mKey, aTxtEntry.mValue);
+
+ VerifyOrExit(dbus_message_iter_get_arg_type(aIter) == DBUS_TYPE_STRUCT, error = OTBR_ERROR_DBUS);
+ dbus_message_iter_recurse(aIter, &sub);
+ SuccessOrExit(error = ConvertToTuple(&sub, args));
+ dbus_message_iter_next(aIter);
+exit:
+ return error;
+}
+
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const SrpServerInfo::Registration &aRegistration)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+ auto args = std::tie(aRegistration.mFreshCount, aRegistration.mDeletedCount, aRegistration.mLeaseTimeTotal,
+ aRegistration.mKeyLeaseTimeTotal, aRegistration.mRemainingLeaseTimeTotal,
+ aRegistration.mRemainingKeyLeaseTimeTotal);
+
+ VerifyOrExit(dbus_message_iter_open_container(aIter, DBUS_TYPE_STRUCT, nullptr, &sub), error = OTBR_ERROR_DBUS);
+ SuccessOrExit(error = ConvertToDBusMessage(&sub, args));
+ VerifyOrExit(dbus_message_iter_close_container(aIter, &sub) == true, error = OTBR_ERROR_DBUS);
+exit:
+ return error;
+}
+
+otbrError DBusMessageExtract(DBusMessageIter *aIter, SrpServerInfo::Registration &aRegistration)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+ auto args = std::tie(aRegistration.mFreshCount, aRegistration.mDeletedCount, aRegistration.mLeaseTimeTotal,
+ aRegistration.mKeyLeaseTimeTotal, aRegistration.mRemainingLeaseTimeTotal,
+ aRegistration.mRemainingKeyLeaseTimeTotal);
+
+ VerifyOrExit(dbus_message_iter_get_arg_type(aIter) == DBUS_TYPE_STRUCT, error = OTBR_ERROR_DBUS);
+ dbus_message_iter_recurse(aIter, &sub);
+ SuccessOrExit(error = ConvertToTuple(&sub, args));
+ dbus_message_iter_next(aIter);
+exit:
+ return error;
+}
+
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const SrpServerInfo::ResponseCounters &aResponseCounters)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+ auto args = std::tie(aResponseCounters.mSuccess, aResponseCounters.mServerFailure, aResponseCounters.mFormatError,
+ aResponseCounters.mNameExists, aResponseCounters.mRefused, aResponseCounters.mOther);
+
+ VerifyOrExit(dbus_message_iter_open_container(aIter, DBUS_TYPE_STRUCT, nullptr, &sub), error = OTBR_ERROR_DBUS);
+ SuccessOrExit(error = ConvertToDBusMessage(&sub, args));
+ VerifyOrExit(dbus_message_iter_close_container(aIter, &sub) == true, error = OTBR_ERROR_DBUS);
+exit:
+ return error;
+}
+
+otbrError DBusMessageExtract(DBusMessageIter *aIter, SrpServerInfo::ResponseCounters &aResponseCounters)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+ auto args = std::tie(aResponseCounters.mSuccess, aResponseCounters.mServerFailure, aResponseCounters.mFormatError,
+ aResponseCounters.mNameExists, aResponseCounters.mRefused, aResponseCounters.mOther);
+
+ VerifyOrExit(dbus_message_iter_get_arg_type(aIter) == DBUS_TYPE_STRUCT, error = OTBR_ERROR_DBUS);
+ dbus_message_iter_recurse(aIter, &sub);
+ SuccessOrExit(error = ConvertToTuple(&sub, args));
+ dbus_message_iter_next(aIter);
+exit:
+ return error;
+}
+
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const SrpServerInfo &aSrpServerInfo)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+
+ VerifyOrExit(dbus_message_iter_open_container(aIter, DBUS_TYPE_STRUCT, nullptr, &sub), error = OTBR_ERROR_DBUS);
+
+ SuccessOrExit(error = DBusMessageEncode(&sub, aSrpServerInfo.mState));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aSrpServerInfo.mPort));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aSrpServerInfo.mAddressMode));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aSrpServerInfo.mHosts));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aSrpServerInfo.mServices));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aSrpServerInfo.mResponseCounters));
+
+ VerifyOrExit(dbus_message_iter_close_container(aIter, &sub), error = OTBR_ERROR_DBUS);
+exit:
+ return error;
+}
+
+otbrError DBusMessageExtract(DBusMessageIter *aIter, SrpServerInfo &aSrpServerInfo)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+
+ dbus_message_iter_recurse(aIter, &sub);
+ SuccessOrExit(error = DBusMessageExtract(&sub, aSrpServerInfo.mState));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aSrpServerInfo.mPort));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aSrpServerInfo.mAddressMode));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aSrpServerInfo.mHosts));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aSrpServerInfo.mServices));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aSrpServerInfo.mResponseCounters));
+
+ dbus_message_iter_next(aIter);
+exit:
+ return error;
+}
+
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const DnssdCounters &aDnssdCounters)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+
+ VerifyOrExit(dbus_message_iter_open_container(aIter, DBUS_TYPE_STRUCT, nullptr, &sub), error = OTBR_ERROR_DBUS);
+
+ SuccessOrExit(error = DBusMessageEncode(&sub, aDnssdCounters.mSuccessResponse));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aDnssdCounters.mServerFailureResponse));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aDnssdCounters.mFormatErrorResponse));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aDnssdCounters.mNameErrorResponse));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aDnssdCounters.mNotImplementedResponse));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aDnssdCounters.mOtherResponse));
+
+ SuccessOrExit(error = DBusMessageEncode(&sub, aDnssdCounters.mResolvedBySrp));
+
+ VerifyOrExit(dbus_message_iter_close_container(aIter, &sub), error = OTBR_ERROR_DBUS);
+exit:
+ return error;
+}
+
+otbrError DBusMessageExtract(DBusMessageIter *aIter, DnssdCounters &aDnssdCounters)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+
+ dbus_message_iter_recurse(aIter, &sub);
+
+ SuccessOrExit(error = DBusMessageExtract(&sub, aDnssdCounters.mSuccessResponse));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aDnssdCounters.mServerFailureResponse));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aDnssdCounters.mFormatErrorResponse));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aDnssdCounters.mNameErrorResponse));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aDnssdCounters.mNotImplementedResponse));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aDnssdCounters.mOtherResponse));
+
+ SuccessOrExit(error = DBusMessageExtract(&sub, aDnssdCounters.mResolvedBySrp));
+
+ dbus_message_iter_next(aIter);
+exit:
+ return error;
+}
+
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const MdnsResponseCounters &aMdnsResponseCounters)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+
+ VerifyOrExit(dbus_message_iter_open_container(aIter, DBUS_TYPE_STRUCT, nullptr, &sub), error = OTBR_ERROR_DBUS);
+
+ SuccessOrExit(error = DBusMessageEncode(&sub, aMdnsResponseCounters.mSuccess));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aMdnsResponseCounters.mNotFound));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aMdnsResponseCounters.mInvalidArgs));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aMdnsResponseCounters.mDuplicated));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aMdnsResponseCounters.mNotImplemented));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aMdnsResponseCounters.mUnknownError));
+
+ VerifyOrExit(dbus_message_iter_close_container(aIter, &sub), error = OTBR_ERROR_DBUS);
+exit:
+ return error;
+}
+
+otbrError DBusMessageExtract(DBusMessageIter *aIter, MdnsResponseCounters &aMdnsResponseCounters)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+
+ dbus_message_iter_recurse(aIter, &sub);
+
+ SuccessOrExit(error = DBusMessageExtract(&sub, aMdnsResponseCounters.mSuccess));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aMdnsResponseCounters.mNotFound));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aMdnsResponseCounters.mInvalidArgs));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aMdnsResponseCounters.mDuplicated));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aMdnsResponseCounters.mNotImplemented));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aMdnsResponseCounters.mUnknownError));
+
+ dbus_message_iter_next(aIter);
+exit:
+ return error;
+}
+
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const MdnsTelemetryInfo &aMdnsTelemetryInfo)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+
+ VerifyOrExit(dbus_message_iter_open_container(aIter, DBUS_TYPE_STRUCT, nullptr, &sub), error = OTBR_ERROR_DBUS);
+
+ SuccessOrExit(error = DBusMessageEncode(&sub, aMdnsTelemetryInfo.mHostRegistrations));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aMdnsTelemetryInfo.mServiceRegistrations));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aMdnsTelemetryInfo.mHostResolutions));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aMdnsTelemetryInfo.mServiceResolutions));
+
+ SuccessOrExit(error = DBusMessageEncode(&sub, aMdnsTelemetryInfo.mHostRegistrationEmaLatency));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aMdnsTelemetryInfo.mServiceRegistrationEmaLatency));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aMdnsTelemetryInfo.mHostResolutionEmaLatency));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aMdnsTelemetryInfo.mServiceResolutionEmaLatency));
+
+ VerifyOrExit(dbus_message_iter_close_container(aIter, &sub), error = OTBR_ERROR_DBUS);
+exit:
+ return error;
+}
+
+otbrError DBusMessageExtract(DBusMessageIter *aIter, MdnsTelemetryInfo &aMdnsTelemetryInfo)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+
+ dbus_message_iter_recurse(aIter, &sub);
+
+ SuccessOrExit(error = DBusMessageExtract(&sub, aMdnsTelemetryInfo.mHostRegistrations));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aMdnsTelemetryInfo.mServiceRegistrations));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aMdnsTelemetryInfo.mHostResolutions));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aMdnsTelemetryInfo.mServiceResolutions));
+
+ SuccessOrExit(error = DBusMessageExtract(&sub, aMdnsTelemetryInfo.mHostRegistrationEmaLatency));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aMdnsTelemetryInfo.mServiceRegistrationEmaLatency));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aMdnsTelemetryInfo.mHostResolutionEmaLatency));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aMdnsTelemetryInfo.mServiceResolutionEmaLatency));
+
+ dbus_message_iter_next(aIter);
+exit:
+ return error;
+}
+
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const RadioSpinelMetrics &aRadioSpinelMetrics)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+
+ VerifyOrExit(dbus_message_iter_open_container(aIter, DBUS_TYPE_STRUCT, nullptr, &sub), error = OTBR_ERROR_DBUS);
+
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioSpinelMetrics.mRcpTimeoutCount));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioSpinelMetrics.mRcpUnexpectedResetCount));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioSpinelMetrics.mRcpRestorationCount));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioSpinelMetrics.mSpinelParseErrorCount));
+
+ VerifyOrExit(dbus_message_iter_close_container(aIter, &sub), error = OTBR_ERROR_DBUS);
+exit:
+ return error;
+}
+
+otbrError DBusMessageExtract(DBusMessageIter *aIter, RadioSpinelMetrics &aRadioSpinelMetrics)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+
+ dbus_message_iter_recurse(aIter, &sub);
+
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioSpinelMetrics.mRcpTimeoutCount));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioSpinelMetrics.mRcpUnexpectedResetCount));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioSpinelMetrics.mRcpRestorationCount));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioSpinelMetrics.mSpinelParseErrorCount));
+
+ dbus_message_iter_next(aIter);
+exit:
+ return error;
+}
+
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const RcpInterfaceMetrics &aRcpInterfaceMetrics)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+
+ VerifyOrExit(dbus_message_iter_open_container(aIter, DBUS_TYPE_STRUCT, nullptr, &sub), error = OTBR_ERROR_DBUS);
+
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRcpInterfaceMetrics.mRcpInterfaceType));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRcpInterfaceMetrics.mTransferredFrameCount));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRcpInterfaceMetrics.mTransferredValidFrameCount));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRcpInterfaceMetrics.mTransferredGarbageFrameCount));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRcpInterfaceMetrics.mRxFrameCount));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRcpInterfaceMetrics.mRxFrameByteCount));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRcpInterfaceMetrics.mTxFrameCount));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRcpInterfaceMetrics.mTxFrameByteCount));
+
+ VerifyOrExit(dbus_message_iter_close_container(aIter, &sub), error = OTBR_ERROR_DBUS);
+exit:
+ return error;
+}
+
+otbrError DBusMessageExtract(DBusMessageIter *aIter, RcpInterfaceMetrics &aRcpInterfaceMetrics)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+
+ dbus_message_iter_recurse(aIter, &sub);
+
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRcpInterfaceMetrics.mRcpInterfaceType));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRcpInterfaceMetrics.mTransferredFrameCount));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRcpInterfaceMetrics.mTransferredValidFrameCount));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRcpInterfaceMetrics.mTransferredGarbageFrameCount));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRcpInterfaceMetrics.mRxFrameCount));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRcpInterfaceMetrics.mRxFrameByteCount));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRcpInterfaceMetrics.mTxFrameCount));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRcpInterfaceMetrics.mTxFrameByteCount));
+
+ dbus_message_iter_next(aIter);
+exit:
+ return error;
+}
+
+otbrError DBusMessageEncode(DBusMessageIter *aIter, const RadioCoexMetrics &aRadioCoexMetrics)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+
+ VerifyOrExit(dbus_message_iter_open_container(aIter, DBUS_TYPE_STRUCT, nullptr, &sub), error = OTBR_ERROR_DBUS);
+
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mNumGrantGlitch));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mNumTxRequest));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mNumTxGrantImmediate));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mNumTxGrantWait));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mNumTxGrantWaitActivated));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mNumTxGrantWaitTimeout));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mNumTxGrantDeactivatedDuringRequest));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mNumTxDelayedGrant));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mAvgTxRequestToGrantTime));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mNumRxRequest));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mNumRxGrantImmediate));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mNumRxGrantWait));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mNumRxGrantWaitActivated));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mNumRxGrantWaitTimeout));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mNumRxGrantDeactivatedDuringRequest));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mNumRxDelayedGrant));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mAvgRxRequestToGrantTime));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mNumRxGrantNone));
+ SuccessOrExit(error = DBusMessageEncode(&sub, aRadioCoexMetrics.mStopped));
+
+ VerifyOrExit(dbus_message_iter_close_container(aIter, &sub), error = OTBR_ERROR_DBUS);
+exit:
+ return error;
+}
+
+otbrError DBusMessageExtract(DBusMessageIter *aIter, RadioCoexMetrics &aRadioCoexMetrics)
+{
+ DBusMessageIter sub;
+ otbrError error = OTBR_ERROR_NONE;
+
+ dbus_message_iter_recurse(aIter, &sub);
+
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mNumGrantGlitch));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mNumTxRequest));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mNumTxGrantImmediate));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mNumTxGrantWait));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mNumTxGrantWaitActivated));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mNumTxGrantWaitTimeout));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mNumTxGrantDeactivatedDuringRequest));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mNumTxDelayedGrant));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mAvgTxRequestToGrantTime));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mNumRxRequest));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mNumRxGrantImmediate));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mNumRxGrantWait));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mNumRxGrantWaitActivated));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mNumRxGrantWaitTimeout));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mNumRxGrantDeactivatedDuringRequest));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mNumRxDelayedGrant));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mAvgRxRequestToGrantTime));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mNumRxGrantNone));
+ SuccessOrExit(error = DBusMessageExtract(&sub, aRadioCoexMetrics.mStopped));
+
+ dbus_message_iter_next(aIter);
+exit:
+ return error;
+}
+
} // namespace DBus
} // namespace otbr
diff --git a/src/dbus/common/types.hpp b/src/dbus/common/types.hpp
index 08811c81..76c41034 100644
--- a/src/dbus/common/types.hpp
+++ b/src/dbus/common/types.hpp
@@ -66,7 +66,13 @@ struct ActiveScanResult
uint8_t mLqi; ///< LQI
uint8_t mVersion; ///< Version
bool mIsNative; ///< Native Commissioner flag
- bool mIsJoinable; ///< Joining Permitted flag
+ bool mDiscover; ///< Result from MLE Discovery
+};
+
+struct EnergyScanResult
+{
+ uint8_t mChannel; ///< IEEE 802.15.4 Channel
+ int8_t mMaxRssi; ///< The max RSSI (dBm)
};
struct LinkModeConfig
@@ -91,6 +97,11 @@ struct OnMeshPrefix
Ip6Prefix mPrefix;
/**
+ * The Rloc associated with the Border Router prefix.
+ */
+ uint16_t mRloc16;
+
+ /**
* A 2-bit signed integer indicating router preference as defined in RFC 4191.
*/
int8_t mPreference;
@@ -121,14 +132,24 @@ struct OnMeshPrefix
bool mDefaultRoute;
/**
- * TRUE, if this prefix is considered on-mesh. FALSE, otherwise.
+ * TRUE if this prefix is considered on-mesh. FALSE otherwise.
*/
bool mOnMesh;
/**
- * TRUE, if this configuration is considered Stable Network Data. FALSE, otherwise.
+ * TRUE if this configuration is considered Stable Network Data. FALSE otherwise.
*/
bool mStable;
+
+ /**
+ * TRUE if this border router can supply DNS information via ND. FALSE otherwise.
+ */
+ bool mNdDns;
+
+ /**
+ * TRUE if this prefix is a Thread Domain Prefix. FALSE otherwise.
+ */
+ bool mDp;
};
struct ExternalRoute
@@ -490,6 +511,114 @@ struct LeaderData
uint8_t mLeaderRouterId; ///< Leader Router ID
};
+struct TxtEntry
+{
+ std::string mKey;
+ std::vector<uint8_t> mValue;
+};
+
+enum SrpServerState : uint8_t
+{
+ OTBR_SRP_SERVER_STATE_DISABLED = 0, ///< The SRP server is disabled.
+ OTBR_SRP_SERVER_STATE_RUNNING = 1, ///< The SRP server is running.
+ OTBR_SRP_SERVER_STATE_STOPPED = 2, ///< The SRP server is stopped.
+};
+
+enum SrpServerAddressMode : uint8_t
+{
+ OTBR_SRP_SERVER_ADDRESS_MODE_UNICAST = 0, ///< Unicast address mode.
+ OTBR_SRP_SERVER_ADDRESS_MODE_ANYCAST = 1, ///< Anycast address mode.
+};
+
+struct SrpServerInfo
+{
+ struct Registration
+ {
+ uint32_t mFreshCount; ///< The number of active hosts/services registered on the SRP server
+ uint32_t mDeletedCount; ///< The number of hosts/services in 'Deleted' state on the SRP server
+ uint64_t mLeaseTimeTotal; ///< The sum of lease time in milliseconds of all active hosts/services
+ ///< on the SRP server
+ uint64_t mKeyLeaseTimeTotal; ///< The sum of key lease time in milliseconds of all active hosts/services on the
+ ///< SRP server
+ uint64_t mRemainingLeaseTimeTotal; ///< The sum of remaining lease time in milliseconds of all active
+ ///< hosts/services on the SRP server
+ uint64_t mRemainingKeyLeaseTimeTotal; ///< The sum of remaining key lease time in milliseconds of all active
+ ///< hosts/services on the SRP server
+ };
+
+ struct ResponseCounters
+ {
+ uint32_t mSuccess; ///< The number of successful responses
+ uint32_t mServerFailure; ///< The number of server failure responses
+ uint32_t mFormatError; ///< The number of format error responses
+ uint32_t mNameExists; ///< The number of 'name exists' responses
+ uint32_t mRefused; ///< The number of refused responses
+ uint32_t mOther; ///< The number of other responses
+ };
+
+ SrpServerState mState; ///< The state of the SRP server
+ uint16_t mPort; ///< The listening port number
+ SrpServerAddressMode mAddressMode; ///< The address mode {unicast, anycast} of the SRP server
+ Registration mHosts; ///< The registration information of hosts on the SRP server
+ Registration mServices; ///< The registration information of services on the SRP server
+ ResponseCounters mResponseCounters; ///< The counters of response codes sent by the SRP server
+};
+
+struct DnssdCounters
+{
+ uint32_t mSuccessResponse; ///< The number of successful responses
+ uint32_t mServerFailureResponse; ///< The number of server failure responses
+ uint32_t mFormatErrorResponse; ///< The number of format error responses
+ uint32_t mNameErrorResponse; ///< The number of name error responses
+ uint32_t mNotImplementedResponse; ///< The number of 'not implemented' responses
+ uint32_t mOtherResponse; ///< The number of other responses
+
+ uint32_t mResolvedBySrp; ///< The number of queries completely resolved by the local SRP server
+};
+
+struct RadioSpinelMetrics
+{
+ uint32_t mRcpTimeoutCount; ///< The number of RCP timeouts.
+ uint32_t mRcpUnexpectedResetCount; ///< The number of RCP unexcepted resets.
+ uint32_t mRcpRestorationCount; ///< The number of RCP restorations.
+ uint32_t mSpinelParseErrorCount; ///< The number of spinel frame parse errors.
+};
+
+struct RcpInterfaceMetrics
+{
+ uint8_t mRcpInterfaceType; ///< The RCP interface type.
+ uint64_t mTransferredFrameCount; ///< The number of transferred frames.
+ uint64_t mTransferredValidFrameCount; ///< The number of transferred valid frames.
+ uint64_t mTransferredGarbageFrameCount; ///< The number of transferred garbage frames.
+ uint64_t mRxFrameCount; ///< The number of received frames.
+ uint64_t mRxFrameByteCount; ///< The number of received bytes.
+ uint64_t mTxFrameCount; ///< The number of transmitted frames.
+ uint64_t mTxFrameByteCount; ///< The number of transmitted bytes.
+};
+
+struct RadioCoexMetrics
+{
+ uint32_t mNumGrantGlitch; ///< Number of grant glitches.
+ uint32_t mNumTxRequest; ///< Number of tx requests.
+ uint32_t mNumTxGrantImmediate; ///< Number of tx requests while grant was active.
+ uint32_t mNumTxGrantWait; ///< Number of tx requests while grant was inactive.
+ uint32_t mNumTxGrantWaitActivated; ///< Number of tx requests while grant was inactive that were ultimately granted.
+ uint32_t mNumTxGrantWaitTimeout; ///< Number of tx requests while grant was inactive that timed out.
+ uint32_t mNumTxGrantDeactivatedDuringRequest; ///< Number of tx that were in progress when grant was deactivated.
+ uint32_t mNumTxDelayedGrant; ///< Number of tx requests that were not granted within 50us.
+ uint32_t mAvgTxRequestToGrantTime; ///< Average time in usec from tx request to grant.
+ uint32_t mNumRxRequest; ///< Number of rx requests.
+ uint32_t mNumRxGrantImmediate; ///< Number of rx requests while grant was active.
+ uint32_t mNumRxGrantWait; ///< Number of rx requests while grant was inactive.
+ uint32_t mNumRxGrantWaitActivated; ///< Number of rx requests while grant was inactive that were ultimately granted.
+ uint32_t mNumRxGrantWaitTimeout; ///< Number of rx requests while grant was inactive that timed out.
+ uint32_t mNumRxGrantDeactivatedDuringRequest; ///< Number of rx that were in progress when grant was deactivated.
+ uint32_t mNumRxDelayedGrant; ///< Number of rx requests that were not granted within 50us.
+ uint32_t mAvgRxRequestToGrantTime; ///< Average time in usec from rx request to grant.
+ uint32_t mNumRxGrantNone; ///< Number of rx requests that completed without receiving grant.
+ bool mStopped; ///< Stats collection stopped due to saturation.
+};
+
} // namespace DBus
} // namespace otbr
diff --git a/src/dbus/server/dbus_agent.cpp b/src/dbus/server/dbus_agent.cpp
index b0aaaee9..de94927d 100644
--- a/src/dbus/server/dbus_agent.cpp
+++ b/src/dbus/server/dbus_agent.cpp
@@ -30,49 +30,81 @@
#include "dbus/server/dbus_agent.hpp"
+#include <chrono>
+#include <thread>
+#include <unistd.h>
+
#include "common/logging.hpp"
#include "dbus/common/constants.hpp"
+#include "mdns/mdns.hpp"
namespace otbr {
namespace DBus {
-const struct timeval DBusAgent::kPollTimeout = {0, 0};
+const struct timeval DBusAgent::kPollTimeout = {0, 0};
+constexpr std::chrono::seconds DBusAgent::kDBusWaitAllowance;
-DBusAgent::DBusAgent(otbr::Ncp::ControllerOpenThread &aNcp)
+DBusAgent::DBusAgent(otbr::Ncp::ControllerOpenThread &aNcp, Mdns::Publisher &aPublisher)
: mInterfaceName(aNcp.GetInterfaceName())
, mNcp(aNcp)
+ , mPublisher(aPublisher)
{
}
-otbrError DBusAgent::Init(void)
+void DBusAgent::Init(void)
+{
+ otbrError error = OTBR_ERROR_NONE;
+
+ auto connection_deadline = Clock::now() + kDBusWaitAllowance;
+
+ while ((mConnection = PrepareDBusConnection()) == nullptr && Clock::now() < connection_deadline)
+ {
+ otbrLogWarning("Failed to setup DBus connection, will retry after 1 second");
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+ }
+
+ VerifyOrDie(mConnection != nullptr, "Failed to get DBus connection");
+
+ mThreadObject =
+ std::unique_ptr<DBusThreadObject>(new DBusThreadObject(mConnection.get(), mInterfaceName, &mNcp, &mPublisher));
+ error = mThreadObject->Init();
+ VerifyOrDie(error == OTBR_ERROR_NONE, "Failed to initialize DBus Agent");
+}
+
+DBusAgent::UniqueDBusConnection DBusAgent::PrepareDBusConnection(void)
{
- DBusError dbusError;
- otbrError error = OTBR_ERROR_NONE;
- int requestReply;
- std::string serverName = OTBR_DBUS_SERVER_PREFIX + mInterfaceName;
+ DBusError dbusError;
+ DBusConnection * conn = nullptr;
+ UniqueDBusConnection uniqueConn;
+ int requestReply;
+ std::string serverName = OTBR_DBUS_SERVER_PREFIX + mInterfaceName;
dbus_error_init(&dbusError);
- DBusConnection *conn = dbus_bus_get(DBUS_BUS_SYSTEM, &dbusError);
- mConnection = std::unique_ptr<DBusConnection, std::function<void(DBusConnection *)>>(
- conn, [](DBusConnection *aConnection) { dbus_connection_unref(aConnection); });
- VerifyOrExit(mConnection != nullptr, error = OTBR_ERROR_DBUS);
- dbus_bus_register(mConnection.get(), &dbusError);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, &dbusError);
+
+ uniqueConn = UniqueDBusConnection(conn, [](DBusConnection *aConnection) { dbus_connection_unref(aConnection); });
+
+ VerifyOrExit(uniqueConn != nullptr,
+ otbrLogWarning("Failed to get DBus connection: %s: %s", dbusError.name, dbusError.message));
+ dbus_bus_register(uniqueConn.get(), &dbusError);
+
requestReply =
- dbus_bus_request_name(mConnection.get(), serverName.c_str(), DBUS_NAME_FLAG_REPLACE_EXISTING, &dbusError);
+ dbus_bus_request_name(uniqueConn.get(), serverName.c_str(), DBUS_NAME_FLAG_REPLACE_EXISTING, &dbusError);
VerifyOrExit(requestReply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER ||
requestReply == DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER,
- error = OTBR_ERROR_DBUS);
+ {
+ otbrLogWarning("Failed to request DBus name: %s: %s", dbusError.name, dbusError.message);
+ uniqueConn = nullptr;
+ });
VerifyOrExit(
- dbus_connection_set_watch_functions(mConnection.get(), AddDBusWatch, RemoveDBusWatch, nullptr, this, nullptr));
- mThreadObject = std::unique_ptr<DBusThreadObject>(new DBusThreadObject(mConnection.get(), mInterfaceName, &mNcp));
- error = mThreadObject->Init();
+ dbus_connection_set_watch_functions(uniqueConn.get(), AddDBusWatch, RemoveDBusWatch, nullptr, this, nullptr),
+ uniqueConn = nullptr);
+
exit:
- if (error != OTBR_ERROR_NONE)
- {
- otbrLogErr("Dbus error %s: %s", dbusError.name, dbusError.message);
- }
dbus_error_free(&dbusError);
- return error;
+
+ return uniqueConn;
}
dbus_bool_t DBusAgent::AddDBusWatch(struct DBusWatch *aWatch, void *aContext)
diff --git a/src/dbus/server/dbus_agent.hpp b/src/dbus/server/dbus_agent.hpp
index 4e349d9a..d334a965 100644
--- a/src/dbus/server/dbus_agent.hpp
+++ b/src/dbus/server/dbus_agent.hpp
@@ -39,6 +39,7 @@
#include <string>
#include <sys/select.h>
+#include "common/code_utils.hpp"
#include "common/mainloop.hpp"
#include "dbus/common/dbus_message_helper.hpp"
#include "dbus/common/dbus_resources.hpp"
@@ -50,52 +51,43 @@
namespace otbr {
namespace DBus {
-class DBusAgent : public MainloopProcessor
+class DBusAgent : public MainloopProcessor, private NonCopyable
{
public:
/**
* The constructor of dbus agent.
*
- * @param[in] aNcp A reference to the NCP controller.
+ * @param[in] aNcp A reference to the NCP controller.
*
*/
- DBusAgent(otbr::Ncp::ControllerOpenThread &aNcp);
+ DBusAgent(otbr::Ncp::ControllerOpenThread &aNcp, Mdns::Publisher &aPublisher);
/**
* This method initializes the dbus agent.
*
- * @returns The intialization error.
- *
*/
- otbrError Init(void);
+ void Init(void);
- /**
- * This method updates the mainloop context.
- *
- * @param[inout] aMainloop A reference to the mainloop to be updated.
- *
- */
void Update(MainloopContext &aMainloop) override;
-
- /**
- * This method processes mainloop events.
- *
- * @param[in] aMainloop A reference to the mainloop context.
- *
- */
void Process(const MainloopContext &aMainloop) override;
private:
- static dbus_bool_t AddDBusWatch(struct DBusWatch *aWatch, void *aContext);
- static void RemoveDBusWatch(struct DBusWatch *aWatch, void *aContext);
+ using Clock = std::chrono::steady_clock;
+ constexpr static std::chrono::seconds kDBusWaitAllowance = std::chrono::seconds(30);
+
+ using UniqueDBusConnection = std::unique_ptr<DBusConnection, std::function<void(DBusConnection *)>>;
+
+ static dbus_bool_t AddDBusWatch(struct DBusWatch *aWatch, void *aContext);
+ static void RemoveDBusWatch(struct DBusWatch *aWatch, void *aContext);
+ UniqueDBusConnection PrepareDBusConnection(void);
static const struct timeval kPollTimeout;
std::string mInterfaceName;
std::unique_ptr<DBusThreadObject> mThreadObject;
- using UniqueDBusConnection = std::unique_ptr<DBusConnection, std::function<void(DBusConnection *)>>;
- UniqueDBusConnection mConnection;
- otbr::Ncp::ControllerOpenThread &mNcp;
+ UniqueDBusConnection mConnection;
+ otbr::Ncp::ControllerOpenThread & mNcp;
+ Mdns::Publisher & mPublisher;
/**
* This map is used to track DBusWatch-es.
diff --git a/src/dbus/server/dbus_object.cpp b/src/dbus/server/dbus_object.cpp
index 7965d4eb..b33e8886 100644
--- a/src/dbus/server/dbus_object.cpp
+++ b/src/dbus/server/dbus_object.cpp
@@ -134,7 +134,8 @@ void DBusObject::GetPropertyMethodHandler(DBusRequest &aRequest)
DBusMessageIter iter;
std::string interfaceName;
std::string propertyName;
- otError error = OT_ERROR_NONE;
+ otError error = OT_ERROR_NONE;
+ otError replyError = OT_ERROR_NONE;
VerifyOrExit(reply != nullptr, error = OT_ERROR_NO_BUFS);
VerifyOrExit(dbus_message_iter_init(aRequest.GetMessage(), &iter), error = OT_ERROR_FAILED);
@@ -152,11 +153,11 @@ void DBusObject::GetPropertyMethodHandler(DBusRequest &aRequest)
VerifyOrExit(interfaceIter != interfaceHandlers.end(), error = OT_ERROR_NOT_FOUND);
dbus_message_iter_init_append(reply.get(), &replyIter);
- SuccessOrExit(error = interfaceIter->second(replyIter));
+ SuccessOrExit(replyError = interfaceIter->second(replyIter));
}
}
exit:
- if (error == OT_ERROR_NONE)
+ if (error == OT_ERROR_NONE && replyError == OT_ERROR_NONE)
{
if (otbrLogGetLevel() >= OTBR_LOG_DEBUG)
{
@@ -166,6 +167,12 @@ exit:
dbus_connection_send(aRequest.GetConnection(), reply.get(), nullptr);
}
+ else if (error == OT_ERROR_NONE)
+ {
+ otbrLogInfo("GetProperty %s.%s reply:%s", interfaceName.c_str(), propertyName.c_str(),
+ ConvertToDBusErrorName(replyError));
+ aRequest.ReplyOtResult(replyError);
+ }
else
{
otbrLogWarning("GetProperty %s.%s error:%s", interfaceName.c_str(), propertyName.c_str(),
@@ -249,5 +256,10 @@ DBusObject::~DBusObject(void)
{
}
+UniqueDBusMessage DBusObject::NewSignalMessage(const std::string &aInterfaceName, const std::string &aSignalName)
+{
+ return UniqueDBusMessage(dbus_message_new_signal(mObjectPath.c_str(), aInterfaceName.c_str(), aSignalName.c_str()));
+}
+
} // namespace DBus
} // namespace otbr
diff --git a/src/dbus/server/dbus_object.hpp b/src/dbus/server/dbus_object.hpp
index 5d601833..69a5c0c3 100644
--- a/src/dbus/server/dbus_object.hpp
+++ b/src/dbus/server/dbus_object.hpp
@@ -60,7 +60,7 @@ namespace DBus {
* This class is a base class for implementing a d-bus object.
*
*/
-class DBusObject
+class DBusObject : private NonCopyable
{
public:
using MethodHandlerType = std::function<void(DBusRequest &)>;
@@ -70,8 +70,8 @@ public:
/**
* The constructor of a d-bus object.
*
- * @param[in] aConnection The dbus-connection the object bounds to.
- * @param[in] aObjectPath The path of the object.
+ * @param[in] aConnection The dbus-connection the object bounds to.
+ * @param[in] aObjectPath The path of the object.
*
*/
DBusObject(DBusConnection *aConnection, const std::string &aObjectPath);
@@ -81,8 +81,8 @@ public:
*
* This method will register the object to the d-bus library.
*
- * @retval OTBR_ERROR_NONE Successfully registered the object.
- * @retval OTBR_ERROR_DBUS Failed to ragister an object.
+ * @retval OTBR_ERROR_NONE Successfully registered the object.
+ * @retval OTBR_ERROR_DBUS Failed to ragister an object.
*
*/
virtual otbrError Init(void);
@@ -90,9 +90,9 @@ public:
/**
* This method registers the method handler.
*
- * @param[in] aInterfaceName The interface name.
- * @param[in] aMethodName The method name.
- * @param[in] aHandler The method handler.
+ * @param[in] aInterfaceName The interface name.
+ * @param[in] aMethodName The method name.
+ * @param[in] aHandler The method handler.
*
*/
void RegisterMethod(const std::string & aInterfaceName,
@@ -102,33 +102,33 @@ public:
/**
* This method registers the get handler for a property.
*
- * @param[in] aInterfaceName The interface name.
- * @param[in] aMethodName The method name.
- * @param[in] aHandler The method handler.
+ * @param[in] aInterfaceName The interface name.
+ * @param[in] aPropertyName The property name.
+ * @param[in] aHandler The method handler.
*
*/
- void RegisterGetPropertyHandler(const std::string & aInterfaceName,
- const std::string & aMethodName,
- const PropertyHandlerType &aHandler);
+ virtual void RegisterGetPropertyHandler(const std::string & aInterfaceName,
+ const std::string & aPropertyName,
+ const PropertyHandlerType &aHandler);
/**
* This method registers the set handler for a property.
*
- * @param[in] aInterfaceName The interface name.
- * @param[in] aMethodName The method name.
- * @param[in] aHandler The method handler.
+ * @param[in] aInterfaceName The interface name.
+ * @param[in] aPropertyName The property name.
+ * @param[in] aHandler The method handler.
*
*/
- void RegisterSetPropertyHandler(const std::string & aInterfaceName,
- const std::string & aPropertyName,
- const PropertyHandlerType &aHandler);
+ virtual void RegisterSetPropertyHandler(const std::string & aInterfaceName,
+ const std::string & aPropertyName,
+ const PropertyHandlerType &aHandler);
/**
* This method sends a signal.
*
- * @param[in] aInterfaceName The interface name.
- * @param[in] aSignalName The signal name.
- * @param[in] aArgs The tuple to be encoded into the signal.
+ * @param[in] aInterfaceName The interface name.
+ * @param[in] aSignalName The signal name.
+ * @param[in] aArgs The tuple to be encoded into the signal.
*
* @retval OTBR_ERROR_NONE Signal successfully sent.
* @retval OTBR_ERROR_DBUS Failed to send the signal.
@@ -139,12 +139,11 @@ public:
const std::string & aSignalName,
const std::tuple<FieldTypes...> &aArgs)
{
- UniqueDBusMessage signalMsg{
- dbus_message_new_signal(mObjectPath.c_str(), aInterfaceName.c_str(), aSignalName.c_str())};
- otbrError error = OTBR_ERROR_NONE;
+ UniqueDBusMessage signalMsg = NewSignalMessage(aInterfaceName, aSignalName);
+ otbrError error = OTBR_ERROR_NONE;
VerifyOrExit(signalMsg != nullptr, error = OTBR_ERROR_DBUS);
- VerifyOrExit(error = otbr::DBus::TupleToDBusMessage(*signalMsg, aArgs));
+ SuccessOrExit(error = otbr::DBus::TupleToDBusMessage(*signalMsg, aArgs));
VerifyOrExit(dbus_connection_send(mConnection, signalMsg.get(), nullptr), error = OTBR_ERROR_DBUS);
@@ -155,9 +154,9 @@ public:
/**
* This method sends a property changed signal.
*
- * @param[in] aInterfaceName The interface name.
- * @param[in] aPropertyName The property name.
- * @param[in] aValue New value of the property.
+ * @param[in] aInterfaceName The interface name.
+ * @param[in] aPropertyName The property name.
+ * @param[in] aValue New value of the property.
*
* @retval OTBR_ERROR_NONE Signal successfully sent.
* @retval OTBR_ERROR_DBUS Failed to send the signal.
@@ -168,10 +167,9 @@ public:
const std::string &aPropertyName,
const ValueType & aValue)
{
- UniqueDBusMessage signalMsg{
- dbus_message_new_signal(mObjectPath.c_str(), DBUS_INTERFACE_PROPERTIES, DBUS_PROPERTIES_CHANGED_SIGNAL)};
- DBusMessageIter iter, subIter, dictEntryIter;
- otbrError error = OTBR_ERROR_NONE;
+ UniqueDBusMessage signalMsg = NewSignalMessage(DBUS_INTERFACE_PROPERTIES, DBUS_PROPERTIES_CHANGED_SIGNAL);
+ DBusMessageIter iter, subIter, dictEntryIter;
+ otbrError error = OTBR_ERROR_NONE;
VerifyOrExit(signalMsg != nullptr, error = OTBR_ERROR_DBUS);
dbus_message_iter_init_append(signalMsg.get(), &iter);
@@ -216,14 +214,14 @@ public:
private:
void GetAllPropertiesMethodHandler(DBusRequest &aRequest);
-
void GetPropertyMethodHandler(DBusRequest &aRequest);
-
void SetPropertyMethodHandler(DBusRequest &aRequest);
static DBusHandlerResult sMessageHandler(DBusConnection *aConnection, DBusMessage *aMessage, void *aData);
DBusHandlerResult MessageHandler(DBusConnection *aConnection, DBusMessage *aMessage);
+ UniqueDBusMessage NewSignalMessage(const std::string &aInterfaceName, const std::string &aSignalName);
+
std::unordered_map<std::string, MethodHandlerType> mMethodHandlers;
std::unordered_map<std::string, std::unordered_map<std::string, PropertyHandlerType>> mGetPropertyHandlers;
std::unordered_map<std::string, PropertyHandlerType> mSetPropertyHandlers;
diff --git a/src/dbus/server/dbus_request.hpp b/src/dbus/server/dbus_request.hpp
index 7126cd5b..9c89bfd0 100644
--- a/src/dbus/server/dbus_request.hpp
+++ b/src/dbus/server/dbus_request.hpp
@@ -35,6 +35,7 @@
#define OTBR_LOG_TAG "DBUS"
#endif
+#include "common/code_utils.hpp"
#include "common/logging.hpp"
#include "dbus/common/dbus_message_dump.hpp"
@@ -55,8 +56,8 @@ public:
/**
* The constructor of dbus request.
*
- * @param[in] aConnection The dbus connection.
- * @param[in] aMessage The incoming dbus message.
+ * @param[in] aConnection The dbus connection.
+ * @param[in] aMessage The incoming dbus message.
*
*/
DBusRequest(DBusConnection *aConnection, DBusMessage *aMessage)
@@ -70,7 +71,7 @@ public:
/**
* The copy constructor of dbus request.
*
- * @param[in] aOther The object to be copied from.
+ * @param[in] aOther The object to be copied from.
*
*/
DBusRequest(const DBusRequest &aOther)
@@ -83,7 +84,7 @@ public:
/**
* The assignment operator of dbus request.
*
- * @param[in] aOther The object to be copied from.
+ * @param[in] aOther The object to be copied from.
*
*/
DBusRequest &operator=(const DBusRequest &aOther)
@@ -95,7 +96,7 @@ public:
/**
* This method returns the message sent to call the d-bus method.
*
- * @returns The dbus message.
+ * @returns The dbus message.
*
*/
DBusMessage *GetMessage(void) { return mMessage; }
@@ -103,7 +104,7 @@ public:
/**
* This method returns underlying d-bus connection.
*
- * @returns The dbus connection.
+ * @returns The dbus connection.
*
*/
DBusConnection *GetConnection(void) { return mConnection; }
@@ -136,9 +137,11 @@ public:
* This method replies an otError to the d-bus method call.
*
* @param[in] aError The error to be sent.
+ * @param[in] aResult The return value of the method call, if any.
*
*/
- void ReplyOtResult(otError aError)
+ template <typename ResultType = int>
+ void ReplyOtResult(otError aError, Optional<ResultType> aResult = Optional<ResultType>())
{
UniqueDBusMessage reply{nullptr};
@@ -161,12 +164,19 @@ public:
{
reply = UniqueDBusMessage(dbus_message_new_error(mMessage, ConvertToDBusErrorName(aError), nullptr));
}
+ VerifyOrDie(reply != nullptr, "Failed to allocate message");
- VerifyOrExit(reply != nullptr);
- dbus_connection_send(mConnection, reply.get(), nullptr);
+ if (aResult.HasValue())
+ {
+ DBusMessageIter replyIter;
+ otbrError error;
- exit:
- return;
+ dbus_message_iter_init_append(reply.get(), &replyIter);
+ error = DBusMessageEncode(&replyIter, *aResult);
+ VerifyOrDie(error == OTBR_ERROR_NONE, "Failed to encode result");
+ }
+
+ dbus_connection_send(mConnection, reply.get(), nullptr);
}
/**
diff --git a/src/dbus/server/dbus_thread_object.cpp b/src/dbus/server/dbus_thread_object.cpp
index ea1cce44..b5b99f85 100644
--- a/src/dbus/server/dbus_thread_object.cpp
+++ b/src/dbus/server/dbus_thread_object.cpp
@@ -31,11 +31,13 @@
#include <openthread/border_router.h>
#include <openthread/channel_monitor.h>
+#include <openthread/dnssd_server.h>
#include <openthread/instance.h>
#include <openthread/joiner.h>
#include <openthread/link_raw.h>
#include <openthread/ncp.h>
#include <openthread/netdata.h>
+#include <openthread/srp_server.h>
#include <openthread/thread_ftd.h>
#include <openthread/platform/radio.h>
@@ -93,22 +95,29 @@ namespace DBus {
DBusThreadObject::DBusThreadObject(DBusConnection * aConnection,
const std::string & aInterfaceName,
- otbr::Ncp::ControllerOpenThread *aNcp)
+ otbr::Ncp::ControllerOpenThread *aNcp,
+ Mdns::Publisher * aPublisher)
: DBusObject(aConnection, OTBR_DBUS_OBJECT_PREFIX + aInterfaceName)
, mNcp(aNcp)
+ , mPublisher(aPublisher)
{
}
otbrError DBusThreadObject::Init(void)
{
- otbrError error = DBusObject::Init();
+ otbrError error = OTBR_ERROR_NONE;
auto threadHelper = mNcp->GetThreadHelper();
+ SuccessOrExit(error = DBusObject::Init());
+
threadHelper->AddDeviceRoleHandler(std::bind(&DBusThreadObject::DeviceRoleHandler, this, _1));
+ threadHelper->AddActiveDatasetChangeHandler(std::bind(&DBusThreadObject::ActiveDatasetChangeHandler, this, _1));
mNcp->RegisterResetHandler(std::bind(&DBusThreadObject::NcpResetHandler, this));
RegisterMethod(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_SCAN_METHOD,
std::bind(&DBusThreadObject::ScanHandler, this, _1));
+ RegisterMethod(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_ENERGY_SCAN_METHOD,
+ std::bind(&DBusThreadObject::EnergyScanHandler, this, _1));
RegisterMethod(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_ATTACH_METHOD,
std::bind(&DBusThreadObject::AttachHandler, this, _1));
RegisterMethod(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_DETACH_METHOD,
@@ -133,6 +142,10 @@ otbrError DBusThreadObject::Init(void)
std::bind(&DBusThreadObject::RemoveExternalRouteHandler, this, _1));
RegisterMethod(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_ATTACH_ALL_NODES_TO_METHOD,
std::bind(&DBusThreadObject::AttachAllNodesToHandler, this, _1));
+ RegisterMethod(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_UPDATE_VENDOR_MESHCOP_TXT_METHOD,
+ std::bind(&DBusThreadObject::UpdateMeshCopTxtHandler, this, _1));
+ RegisterMethod(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_GET_PROPERTIES_METHOD,
+ std::bind(&DBusThreadObject::GetPropertiesHandler, this, _1));
RegisterMethod(DBUS_INTERFACE_INTROSPECTABLE, DBUS_INTROSPECT_METHOD,
std::bind(&DBusThreadObject::IntrospectHandler, this, _1));
@@ -159,6 +172,8 @@ otbrError DBusThreadObject::Init(void)
std::bind(&DBusThreadObject::GetPanIdHandler, this, _1));
RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_EXTPANID,
std::bind(&DBusThreadObject::GetExtPanIdHandler, this, _1));
+ RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_EUI64,
+ std::bind(&DBusThreadObject::GetEui64Handler, this, _1));
RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_CHANNEL,
std::bind(&DBusThreadObject::GetChannelHandler, this, _1));
RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_NETWORK_KEY,
@@ -203,11 +218,36 @@ otbrError DBusThreadObject::Init(void)
std::bind(&DBusThreadObject::GetRadioTxPowerHandler, this, _1));
RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_EXTERNAL_ROUTES,
std::bind(&DBusThreadObject::GetExternalRoutesHandler, this, _1));
+ RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_ON_MESH_PREFIXES,
+ std::bind(&DBusThreadObject::GetOnMeshPrefixesHandler, this, _1));
RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_ACTIVE_DATASET_TLVS,
std::bind(&DBusThreadObject::GetActiveDatasetTlvsHandler, this, _1));
RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_RADIO_REGION,
std::bind(&DBusThreadObject::GetRadioRegionHandler, this, _1));
+ RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_SRP_SERVER_INFO,
+ std::bind(&DBusThreadObject::GetSrpServerInfoHandler, this, _1));
+ RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_MDNS_TELEMETRY_INFO,
+ std::bind(&DBusThreadObject::GetMdnsTelemetryInfoHandler, this, _1));
+ RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_DNSSD_COUNTERS,
+ std::bind(&DBusThreadObject::GetDnssdCountersHandler, this, _1));
+ RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_OT_HOST_VERSION,
+ std::bind(&DBusThreadObject::GetOtHostVersionHandler, this, _1));
+ RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_OT_RCP_VERSION,
+ std::bind(&DBusThreadObject::GetOtRcpVersionHandler, this, _1));
+ RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_THREAD_VERSION,
+ std::bind(&DBusThreadObject::GetThreadVersionHandler, this, _1));
+ RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_RADIO_SPINEL_METRICS,
+ std::bind(&DBusThreadObject::GetRadioSpinelMetricsHandler, this, _1));
+ RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_RCP_INTERFACE_METRICS,
+ std::bind(&DBusThreadObject::GetRcpInterfaceMetricsHandler, this, _1));
+ RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_UPTIME,
+ std::bind(&DBusThreadObject::GetUptimeHandler, this, _1));
+ RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_RADIO_COEX_METRICS,
+ std::bind(&DBusThreadObject::GetRadioCoexMetrics, this, _1));
+
+ SuccessOrExit(error = Signal(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_SIGNAL_READY, std::make_tuple()));
+exit:
return error;
}
@@ -219,6 +259,8 @@ void DBusThreadObject::DeviceRoleHandler(otDeviceRole aDeviceRole)
void DBusThreadObject::NcpResetHandler(void)
{
mNcp->GetThreadHelper()->AddDeviceRoleHandler(std::bind(&DBusThreadObject::DeviceRoleHandler, this, _1));
+ mNcp->GetThreadHelper()->AddActiveDatasetChangeHandler(
+ std::bind(&DBusThreadObject::ActiveDatasetChangeHandler, this, _1));
SignalPropertyChanged(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_DEVICE_ROLE,
GetDeviceRoleName(OT_DEVICE_ROLE_DISABLED));
}
@@ -245,19 +287,55 @@ void DBusThreadObject::ReplyScanResult(DBusRequest & aR
{
ActiveScanResult result;
- result.mExtAddress = ConvertOpenThreadUint64(r.mExtAddress.m8);
- result.mExtendedPanId = ConvertOpenThreadUint64(r.mExtendedPanId.m8);
- result.mNetworkName = r.mNetworkName.m8;
- result.mSteeringData =
- std::vector<uint8_t>(r.mSteeringData.m8, r.mSteeringData.m8 + r.mSteeringData.mLength);
- result.mPanId = r.mPanId;
- result.mJoinerUdpPort = r.mJoinerUdpPort;
- result.mChannel = r.mChannel;
- result.mRssi = r.mRssi;
- result.mLqi = r.mLqi;
- result.mVersion = r.mVersion;
- result.mIsNative = r.mIsNative;
- result.mIsJoinable = r.mIsJoinable;
+ result.mExtAddress = ConvertOpenThreadUint64(r.mExtAddress.m8);
+ result.mPanId = r.mPanId;
+ result.mChannel = r.mChannel;
+ result.mRssi = r.mRssi;
+ result.mLqi = r.mLqi;
+
+ results.emplace_back(result);
+ }
+
+ aRequest.Reply(std::tie(results));
+ }
+}
+
+void DBusThreadObject::EnergyScanHandler(DBusRequest &aRequest)
+{
+ otError error = OT_ERROR_NONE;
+ auto threadHelper = mNcp->GetThreadHelper();
+ uint32_t scanDuration;
+
+ auto args = std::tie(scanDuration);
+
+ VerifyOrExit(DBusMessageToTuple(*aRequest.GetMessage(), args) == OTBR_ERROR_NONE, error = OT_ERROR_INVALID_ARGS);
+ threadHelper->EnergyScan(scanDuration, std::bind(&DBusThreadObject::ReplyEnergyScanResult, this, aRequest, _1, _2));
+
+exit:
+ if (error != OT_ERROR_NONE)
+ {
+ aRequest.ReplyOtResult(error);
+ }
+}
+
+void DBusThreadObject::ReplyEnergyScanResult(DBusRequest & aRequest,
+ otError aError,
+ const std::vector<otEnergyScanResult> &aResult)
+{
+ std::vector<EnergyScanResult> results;
+
+ if (aError != OT_ERROR_NONE)
+ {
+ aRequest.ReplyOtResult(aError);
+ }
+ else
+ {
+ for (const auto &r : aResult)
+ {
+ EnergyScanResult result;
+
+ result.mChannel = r.mChannel;
+ result.mMaxRssi = r.mMaxRssi;
results.emplace_back(result);
}
@@ -280,7 +358,11 @@ void DBusThreadObject::AttachHandler(DBusRequest &aRequest)
if (IsDBusMessageEmpty(*aRequest.GetMessage()))
{
- threadHelper->Attach([aRequest](otError aError) mutable { aRequest.ReplyOtResult(aError); });
+ threadHelper->Attach([aRequest](otError aError, int64_t aAttachDelayMs) mutable {
+ OT_UNUSED_VARIABLE(aAttachDelayMs);
+
+ aRequest.ReplyOtResult(aError);
+ });
}
else if (DBusMessageToTuple(*aRequest.GetMessage(), args) != OTBR_ERROR_NONE)
{
@@ -289,7 +371,11 @@ void DBusThreadObject::AttachHandler(DBusRequest &aRequest)
else
{
threadHelper->Attach(name, panid, extPanId, networkKey, pskc, channelMask,
- [aRequest](otError aError) mutable { aRequest.ReplyOtResult(aError); });
+ [aRequest](otError aError, int64_t aAttachDelayMs) mutable {
+ OT_UNUSED_VARIABLE(aAttachDelayMs);
+
+ aRequest.ReplyOtResult(aError);
+ });
}
}
@@ -302,8 +388,9 @@ void DBusThreadObject::AttachAllNodesToHandler(DBusRequest &aRequest)
VerifyOrExit(DBusMessageToTuple(*aRequest.GetMessage(), args) == OTBR_ERROR_NONE, error = OT_ERROR_INVALID_ARGS);
- mNcp->GetThreadHelper()->AttachAllNodesTo(dataset,
- [aRequest](otError error) mutable { aRequest.ReplyOtResult(error); });
+ mNcp->GetThreadHelper()->AttachAllNodesTo(dataset, [aRequest](otError error, int64_t aAttachDelayMs) mutable {
+ aRequest.ReplyOtResult<int64_t>(error, aAttachDelayMs);
+ });
exit:
if (error != OT_ERROR_NONE)
@@ -1009,6 +1096,40 @@ exit:
return error;
}
+otError DBusThreadObject::GetOnMeshPrefixesHandler(DBusMessageIter &aIter)
+{
+ auto threadHelper = mNcp->GetThreadHelper();
+ otError error = OT_ERROR_NONE;
+ otNetworkDataIterator iter = OT_NETWORK_DATA_ITERATOR_INIT;
+ otBorderRouterConfig config;
+ std::vector<OnMeshPrefix> onMeshPrefixes;
+
+ while (otNetDataGetNextOnMeshPrefix(threadHelper->GetInstance(), &iter, &config) == OT_ERROR_NONE)
+ {
+ OnMeshPrefix prefix;
+
+ prefix.mPrefix.mPrefix = std::vector<uint8_t>(&config.mPrefix.mPrefix.mFields.m8[0],
+ &config.mPrefix.mPrefix.mFields.m8[OTBR_IP6_PREFIX_SIZE]);
+ prefix.mPrefix.mLength = config.mPrefix.mLength;
+ prefix.mRloc16 = config.mRloc16;
+ prefix.mPreference = config.mPreference;
+ prefix.mPreferred = config.mPreferred;
+ prefix.mSlaac = config.mSlaac;
+ prefix.mDhcp = config.mDhcp;
+ prefix.mConfigure = config.mConfigure;
+ prefix.mDefaultRoute = config.mDefaultRoute;
+ prefix.mOnMesh = config.mOnMesh;
+ prefix.mStable = config.mStable;
+ prefix.mNdDns = config.mNdDns;
+ prefix.mDp = config.mDp;
+ onMeshPrefixes.push_back(prefix);
+ }
+ VerifyOrExit(DBusMessageEncodeToVariant(&aIter, onMeshPrefixes) == OTBR_ERROR_NONE, error = OT_ERROR_INVALID_ARGS);
+
+exit:
+ return error;
+}
+
otError DBusThreadObject::SetActiveDatasetTlvsHandler(DBusMessageIter &aIter)
{
auto threadHelper = mNcp->GetThreadHelper();
@@ -1059,6 +1180,29 @@ exit:
return error;
}
+void DBusThreadObject::UpdateMeshCopTxtHandler(DBusRequest &aRequest)
+{
+ auto threadHelper = mNcp->GetThreadHelper();
+ otError error = OT_ERROR_NONE;
+ std::map<std::string, std::vector<uint8_t>> update;
+ std::vector<TxtEntry> updatedTxtEntries;
+ auto args = std::tie(updatedTxtEntries);
+
+ VerifyOrExit(DBusMessageToTuple(*aRequest.GetMessage(), args) == OTBR_ERROR_NONE, error = OT_ERROR_INVALID_ARGS);
+ for (const auto &entry : updatedTxtEntries)
+ {
+ update[entry.mKey] = entry.mValue;
+ }
+ for (const auto reservedKey : {"rv", "tv", "sb", "nn", "xp", "at", "pt", "dn", "sq", "bb", "omr"})
+ {
+ VerifyOrExit(!update.count(reservedKey), error = OT_ERROR_INVALID_ARGS);
+ }
+ threadHelper->OnUpdateMeshCopTxt(std::move(update));
+
+exit:
+ aRequest.ReplyOtResult(error);
+}
+
otError DBusThreadObject::GetRadioRegionHandler(DBusMessageIter &aIter)
{
auto threadHelper = mNcp->GetThreadHelper();
@@ -1077,5 +1221,318 @@ exit:
return error;
}
+otError DBusThreadObject::GetSrpServerInfoHandler(DBusMessageIter &aIter)
+{
+#if OTBR_ENABLE_SRP_ADVERTISING_PROXY
+ auto threadHelper = mNcp->GetThreadHelper();
+ auto instance = threadHelper->GetInstance();
+ otError error = OT_ERROR_NONE;
+ SrpServerInfo srpServerInfo{};
+ otSrpServerLeaseInfo leaseInfo;
+ const otSrpServerHost * host = nullptr;
+ const otSrpServerResponseCounters *responseCounters = otSrpServerGetResponseCounters(instance);
+
+ srpServerInfo.mState = SrpServerState(static_cast<uint8_t>(otSrpServerGetState(instance)));
+ srpServerInfo.mPort = otSrpServerGetPort(instance);
+ srpServerInfo.mAddressMode = SrpServerAddressMode(static_cast<uint8_t>(otSrpServerGetAddressMode(instance)));
+
+ while ((host = otSrpServerGetNextHost(instance, host)))
+ {
+ const otSrpServerService *service = nullptr;
+
+ if (otSrpServerHostIsDeleted(host))
+ {
+ ++srpServerInfo.mHosts.mDeletedCount;
+ }
+ else
+ {
+ ++srpServerInfo.mHosts.mFreshCount;
+ otSrpServerHostGetLeaseInfo(host, &leaseInfo);
+ srpServerInfo.mHosts.mLeaseTimeTotal += leaseInfo.mLease;
+ srpServerInfo.mHosts.mKeyLeaseTimeTotal += leaseInfo.mKeyLease;
+ srpServerInfo.mHosts.mRemainingLeaseTimeTotal += leaseInfo.mRemainingLease;
+ srpServerInfo.mHosts.mRemainingKeyLeaseTimeTotal += leaseInfo.mRemainingKeyLease;
+ }
+
+ while ((service = otSrpServerHostGetNextService(host, service)))
+ {
+ if (otSrpServerServiceIsDeleted(service))
+ {
+ ++srpServerInfo.mServices.mDeletedCount;
+ }
+ else
+ {
+ ++srpServerInfo.mServices.mFreshCount;
+ otSrpServerServiceGetLeaseInfo(service, &leaseInfo);
+ srpServerInfo.mServices.mLeaseTimeTotal += leaseInfo.mLease;
+ srpServerInfo.mServices.mKeyLeaseTimeTotal += leaseInfo.mKeyLease;
+ srpServerInfo.mServices.mRemainingLeaseTimeTotal += leaseInfo.mRemainingLease;
+ srpServerInfo.mServices.mRemainingKeyLeaseTimeTotal += leaseInfo.mRemainingKeyLease;
+ }
+ }
+ }
+
+ srpServerInfo.mResponseCounters.mSuccess = responseCounters->mSuccess;
+ srpServerInfo.mResponseCounters.mServerFailure = responseCounters->mServerFailure;
+ srpServerInfo.mResponseCounters.mFormatError = responseCounters->mFormatError;
+ srpServerInfo.mResponseCounters.mNameExists = responseCounters->mNameExists;
+ srpServerInfo.mResponseCounters.mRefused = responseCounters->mRefused;
+ srpServerInfo.mResponseCounters.mOther = responseCounters->mOther;
+
+ VerifyOrExit(DBusMessageEncodeToVariant(&aIter, srpServerInfo) == OTBR_ERROR_NONE, error = OT_ERROR_INVALID_ARGS);
+
+exit:
+ return error;
+#else // OTBR_ENABLE_SRP_ADVERTISING_PROXY
+ OTBR_UNUSED_VARIABLE(aIter);
+
+ return OT_ERROR_NOT_IMPLEMENTED;
+#endif // OTBR_ENABLE_SRP_ADVERTISING_PROXY
+}
+
+otError DBusThreadObject::GetMdnsTelemetryInfoHandler(DBusMessageIter &aIter)
+{
+ otError error = OT_ERROR_NONE;
+
+ VerifyOrExit(DBusMessageEncodeToVariant(&aIter, mPublisher->GetMdnsTelemetryInfo()) == OTBR_ERROR_NONE,
+ error = OT_ERROR_INVALID_ARGS);
+exit:
+ return error;
+}
+
+otError DBusThreadObject::GetDnssdCountersHandler(DBusMessageIter &aIter)
+{
+#if OTBR_ENABLE_DNSSD_DISCOVERY_PROXY
+ auto threadHelper = mNcp->GetThreadHelper();
+ auto instance = threadHelper->GetInstance();
+ otError error = OT_ERROR_NONE;
+ DnssdCounters dnssdCounters;
+ otDnssdCounters otDnssdCounters = *otDnssdGetCounters(instance);
+
+ dnssdCounters.mSuccessResponse = otDnssdCounters.mSuccessResponse;
+ dnssdCounters.mServerFailureResponse = otDnssdCounters.mServerFailureResponse;
+ dnssdCounters.mFormatErrorResponse = otDnssdCounters.mFormatErrorResponse;
+ dnssdCounters.mNameErrorResponse = otDnssdCounters.mNameErrorResponse;
+ dnssdCounters.mNotImplementedResponse = otDnssdCounters.mNotImplementedResponse;
+ dnssdCounters.mOtherResponse = otDnssdCounters.mOtherResponse;
+
+ dnssdCounters.mResolvedBySrp = otDnssdCounters.mResolvedBySrp;
+
+ VerifyOrExit(DBusMessageEncodeToVariant(&aIter, dnssdCounters) == OTBR_ERROR_NONE, error = OT_ERROR_INVALID_ARGS);
+
+exit:
+ return error;
+#else // OTBR_ENABLE_DNSSD_DISCOVERY_PROXY
+ OTBR_UNUSED_VARIABLE(aIter);
+
+ return OT_ERROR_NOT_IMPLEMENTED;
+#endif // OTBR_ENABLE_DNSSD_DISCOVERY_PROXY
+}
+
+void DBusThreadObject::GetPropertiesHandler(DBusRequest &aRequest)
+{
+ UniqueDBusMessage reply(dbus_message_new_method_return(aRequest.GetMessage()));
+ DBusMessageIter iter;
+ DBusMessageIter replyIter;
+ DBusMessageIter replySubIter;
+ std::vector<std::string> propertyNames;
+ otError error = OT_ERROR_NONE;
+
+ VerifyOrExit(reply != nullptr, error = OT_ERROR_NO_BUFS);
+ VerifyOrExit(dbus_message_iter_init(aRequest.GetMessage(), &iter), error = OT_ERROR_FAILED);
+ VerifyOrExit(DBusMessageExtract(&iter, propertyNames) == OTBR_ERROR_NONE, error = OT_ERROR_PARSE);
+
+ dbus_message_iter_init_append(reply.get(), &replyIter);
+ VerifyOrExit(
+ dbus_message_iter_open_container(&replyIter, DBUS_TYPE_ARRAY, DBUS_TYPE_VARIANT_AS_STRING, &replySubIter),
+ error = OT_ERROR_NO_BUFS);
+
+ for (const std::string &propertyName : propertyNames)
+ {
+ auto handlerIter = mGetPropertyHandlers.find(propertyName);
+
+ otbrLogInfo("GetPropertiesHandler getting property: %s", propertyName.c_str());
+ VerifyOrExit(handlerIter != mGetPropertyHandlers.end(), error = OT_ERROR_NOT_FOUND);
+
+ SuccessOrExit(error = handlerIter->second(replySubIter));
+ }
+
+ VerifyOrExit(dbus_message_iter_close_container(&replyIter, &replySubIter), error = OT_ERROR_NO_BUFS);
+
+exit:
+ if (error == OT_ERROR_NONE)
+ {
+ dbus_connection_send(aRequest.GetConnection(), reply.get(), nullptr);
+ }
+ else
+ {
+ aRequest.ReplyOtResult(error);
+ }
+}
+
+void DBusThreadObject::RegisterGetPropertyHandler(const std::string & aInterfaceName,
+ const std::string & aPropertyName,
+ const PropertyHandlerType &aHandler)
+{
+ DBusObject::RegisterGetPropertyHandler(aInterfaceName, aPropertyName, aHandler);
+ mGetPropertyHandlers[aPropertyName] = aHandler;
+}
+
+otError DBusThreadObject::GetOtHostVersionHandler(DBusMessageIter &aIter)
+{
+ otError error = OT_ERROR_NONE;
+ std::string version = otGetVersionString();
+
+ VerifyOrExit(DBusMessageEncodeToVariant(&aIter, version) == OTBR_ERROR_NONE, error = OT_ERROR_FAILED);
+
+exit:
+ return error;
+}
+
+otError DBusThreadObject::GetEui64Handler(DBusMessageIter &aIter)
+{
+ auto threadHelper = mNcp->GetThreadHelper();
+ otError error = OT_ERROR_NONE;
+ otExtAddress extAddr;
+ uint64_t eui64;
+
+ otLinkGetFactoryAssignedIeeeEui64(threadHelper->GetInstance(), &extAddr);
+
+ eui64 = ConvertOpenThreadUint64(extAddr.m8);
+
+ VerifyOrExit(DBusMessageEncodeToVariant(&aIter, eui64) == OTBR_ERROR_NONE, error = OT_ERROR_INVALID_ARGS);
+
+exit:
+ return error;
+}
+
+otError DBusThreadObject::GetOtRcpVersionHandler(DBusMessageIter &aIter)
+{
+ auto threadHelper = mNcp->GetThreadHelper();
+ otError error = OT_ERROR_NONE;
+ std::string version = otGetRadioVersionString(threadHelper->GetInstance());
+
+ VerifyOrExit(DBusMessageEncodeToVariant(&aIter, version) == OTBR_ERROR_NONE, error = OT_ERROR_FAILED);
+
+exit:
+ return error;
+}
+
+otError DBusThreadObject::GetThreadVersionHandler(DBusMessageIter &aIter)
+{
+ otError error = OT_ERROR_NONE;
+
+ VerifyOrExit(DBusMessageEncodeToVariant(&aIter, otThreadGetVersion()) == OTBR_ERROR_NONE, error = OT_ERROR_FAILED);
+
+exit:
+ return error;
+}
+
+otError DBusThreadObject::GetRadioSpinelMetricsHandler(DBusMessageIter &aIter)
+{
+ otError error = OT_ERROR_NONE;
+ RadioSpinelMetrics radioSpinelMetrics;
+ otRadioSpinelMetrics otRadioSpinelMetrics = *otSysGetRadioSpinelMetrics();
+
+ radioSpinelMetrics.mRcpTimeoutCount = otRadioSpinelMetrics.mRcpTimeoutCount;
+ radioSpinelMetrics.mRcpUnexpectedResetCount = otRadioSpinelMetrics.mRcpUnexpectedResetCount;
+ radioSpinelMetrics.mRcpRestorationCount = otRadioSpinelMetrics.mRcpRestorationCount;
+ radioSpinelMetrics.mSpinelParseErrorCount = otRadioSpinelMetrics.mSpinelParseErrorCount;
+
+ VerifyOrExit(DBusMessageEncodeToVariant(&aIter, radioSpinelMetrics) == OTBR_ERROR_NONE,
+ error = OT_ERROR_INVALID_ARGS);
+
+exit:
+ return error;
+}
+
+otError DBusThreadObject::GetRcpInterfaceMetricsHandler(DBusMessageIter &aIter)
+{
+ otError error = OT_ERROR_NONE;
+ RcpInterfaceMetrics rcpInterfaceMetrics;
+ otRcpInterfaceMetrics otRcpInterfaceMetrics = *otSysGetRcpInterfaceMetrics();
+
+ rcpInterfaceMetrics.mRcpInterfaceType = otRcpInterfaceMetrics.mRcpInterfaceType;
+ rcpInterfaceMetrics.mTransferredFrameCount = otRcpInterfaceMetrics.mTransferredFrameCount;
+ rcpInterfaceMetrics.mTransferredValidFrameCount = otRcpInterfaceMetrics.mTransferredValidFrameCount;
+ rcpInterfaceMetrics.mTransferredGarbageFrameCount = otRcpInterfaceMetrics.mTransferredGarbageFrameCount;
+ rcpInterfaceMetrics.mRxFrameCount = otRcpInterfaceMetrics.mRxFrameCount;
+ rcpInterfaceMetrics.mRxFrameByteCount = otRcpInterfaceMetrics.mRxFrameByteCount;
+ rcpInterfaceMetrics.mTxFrameCount = otRcpInterfaceMetrics.mTxFrameCount;
+ rcpInterfaceMetrics.mTxFrameByteCount = otRcpInterfaceMetrics.mTxFrameByteCount;
+
+ VerifyOrExit(DBusMessageEncodeToVariant(&aIter, rcpInterfaceMetrics) == OTBR_ERROR_NONE,
+ error = OT_ERROR_INVALID_ARGS);
+
+exit:
+ return error;
+}
+
+otError DBusThreadObject::GetUptimeHandler(DBusMessageIter &aIter)
+{
+ otError error = OT_ERROR_NONE;
+
+ VerifyOrExit(DBusMessageEncodeToVariant(&aIter, otInstanceGetUptime(mNcp->GetThreadHelper()->GetInstance())) ==
+ OTBR_ERROR_NONE,
+ error = OT_ERROR_INVALID_ARGS);
+
+exit:
+ return error;
+}
+
+otError DBusThreadObject::GetRadioCoexMetrics(DBusMessageIter &aIter)
+{
+ otError error = OT_ERROR_NONE;
+ otRadioCoexMetrics otRadioCoexMetrics;
+ RadioCoexMetrics radioCoexMetrics;
+
+ SuccessOrExit(error = otPlatRadioGetCoexMetrics(mNcp->GetInstance(), &otRadioCoexMetrics));
+
+ radioCoexMetrics.mNumGrantGlitch = otRadioCoexMetrics.mNumGrantGlitch;
+ radioCoexMetrics.mNumTxRequest = otRadioCoexMetrics.mNumTxRequest;
+ radioCoexMetrics.mNumTxGrantImmediate = otRadioCoexMetrics.mNumTxGrantImmediate;
+ radioCoexMetrics.mNumTxGrantWait = otRadioCoexMetrics.mNumTxGrantWait;
+ radioCoexMetrics.mNumTxGrantWaitActivated = otRadioCoexMetrics.mNumTxGrantWaitActivated;
+ radioCoexMetrics.mNumTxGrantWaitTimeout = otRadioCoexMetrics.mNumTxGrantWaitTimeout;
+ radioCoexMetrics.mNumTxGrantDeactivatedDuringRequest = otRadioCoexMetrics.mNumTxGrantDeactivatedDuringRequest;
+ radioCoexMetrics.mNumTxDelayedGrant = otRadioCoexMetrics.mNumTxDelayedGrant;
+ radioCoexMetrics.mAvgTxRequestToGrantTime = otRadioCoexMetrics.mAvgTxRequestToGrantTime;
+ radioCoexMetrics.mNumRxRequest = otRadioCoexMetrics.mNumRxRequest;
+ radioCoexMetrics.mNumRxGrantImmediate = otRadioCoexMetrics.mNumRxGrantImmediate;
+ radioCoexMetrics.mNumRxGrantWait = otRadioCoexMetrics.mNumRxGrantWait;
+ radioCoexMetrics.mNumRxGrantWaitActivated = otRadioCoexMetrics.mNumRxGrantWaitActivated;
+ radioCoexMetrics.mNumRxGrantWaitTimeout = otRadioCoexMetrics.mNumRxGrantWaitTimeout;
+ radioCoexMetrics.mNumRxGrantDeactivatedDuringRequest = otRadioCoexMetrics.mNumRxGrantDeactivatedDuringRequest;
+ radioCoexMetrics.mNumRxDelayedGrant = otRadioCoexMetrics.mNumRxDelayedGrant;
+ radioCoexMetrics.mAvgRxRequestToGrantTime = otRadioCoexMetrics.mAvgRxRequestToGrantTime;
+ radioCoexMetrics.mNumRxGrantNone = otRadioCoexMetrics.mNumRxGrantNone;
+ radioCoexMetrics.mStopped = otRadioCoexMetrics.mStopped;
+
+ VerifyOrExit(DBusMessageEncodeToVariant(&aIter, radioCoexMetrics) == OTBR_ERROR_NONE,
+ error = OT_ERROR_INVALID_ARGS);
+
+exit:
+ return error;
+}
+
+void DBusThreadObject::ActiveDatasetChangeHandler(const otOperationalDatasetTlvs &aDatasetTlvs)
+{
+ std::vector<uint8_t> value(aDatasetTlvs.mLength);
+ std::copy(aDatasetTlvs.mTlvs, aDatasetTlvs.mTlvs + aDatasetTlvs.mLength, value.begin());
+ SignalPropertyChanged(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_ACTIVE_DATASET_TLVS, value);
+}
+
+static_assert(OTBR_SRP_SERVER_STATE_DISABLED == static_cast<uint8_t>(OT_SRP_SERVER_STATE_DISABLED),
+ "OTBR_SRP_SERVER_STATE_DISABLED value is incorrect");
+static_assert(OTBR_SRP_SERVER_STATE_RUNNING == static_cast<uint8_t>(OT_SRP_SERVER_STATE_RUNNING),
+ "OTBR_SRP_SERVER_STATE_RUNNING value is incorrect");
+static_assert(OTBR_SRP_SERVER_STATE_STOPPED == static_cast<uint8_t>(OT_SRP_SERVER_STATE_STOPPED),
+ "OTBR_SRP_SERVER_STATE_STOPPED value is incorrect");
+
+static_assert(OTBR_SRP_SERVER_ADDRESS_MODE_UNICAST == static_cast<uint8_t>(OT_SRP_SERVER_ADDRESS_MODE_UNICAST),
+ "OTBR_SRP_SERVER_ADDRESS_MODE_UNICAST value is incorrect");
+static_assert(OTBR_SRP_SERVER_ADDRESS_MODE_ANYCAST == static_cast<uint8_t>(OT_SRP_SERVER_ADDRESS_MODE_ANYCAST),
+ "OTBR_SRP_SERVER_ADDRESS_MODE_ANYCAST value is incorrect");
+
} // namespace DBus
} // namespace otbr
diff --git a/src/dbus/server/dbus_thread_object.hpp b/src/dbus/server/dbus_thread_object.hpp
index 7a86214a..91ebb77c 100644
--- a/src/dbus/server/dbus_thread_object.hpp
+++ b/src/dbus/server/dbus_thread_object.hpp
@@ -39,6 +39,7 @@
#include <openthread/link.h>
#include "dbus/server/dbus_object.hpp"
+#include "mdns/mdns.hpp"
#include "ncp/ncp_openthread.hpp"
namespace otbr {
@@ -63,28 +64,30 @@ public:
/**
* This constructor of dbus thread object.
*
- * @param[in] aConnection The dbus connection.
- * @param[in] aInterfaceName The dbus interface name.
- * @param[in] aNcp The ncp controller
+ * @param[in] aConnection The dbus connection.
+ * @param[in] aInterfaceName The dbus interface name.
+ * @param[in] aNcp The ncp controller
+ * @param[in] aPublisher The Mdns::Publisher
*
*/
DBusThreadObject(DBusConnection * aConnection,
const std::string & aInterfaceName,
- otbr::Ncp::ControllerOpenThread *aNcp);
+ otbr::Ncp::ControllerOpenThread *aNcp,
+ Mdns::Publisher * aPublisher);
- /**
- * This method initializes the dbus thread object.
- *
- * @returns The initialization error.
- *
- */
otbrError Init(void) override;
+ void RegisterGetPropertyHandler(const std::string & aInterfaceName,
+ const std::string & aPropertyName,
+ const PropertyHandlerType &aHandler) override;
+
private:
void DeviceRoleHandler(otDeviceRole aDeviceRole);
+ void ActiveDatasetChangeHandler(const otOperationalDatasetTlvs &aDatasetTlvs);
void NcpResetHandler(void);
void ScanHandler(DBusRequest &aRequest);
+ void EnergyScanHandler(DBusRequest &aRequest);
void AttachHandler(DBusRequest &aRequest);
void AttachAllNodesToHandler(DBusRequest &aRequest);
void DetachHandler(DBusRequest &aRequest);
@@ -98,6 +101,8 @@ private:
void RemoveOnMeshPrefixHandler(DBusRequest &aRequest);
void AddExternalRouteHandler(DBusRequest &aRequest);
void RemoveExternalRouteHandler(DBusRequest &aRequest);
+ void UpdateMeshCopTxtHandler(DBusRequest &aRequest);
+ void GetPropertiesHandler(DBusRequest &aRequest);
void IntrospectHandler(DBusRequest &aRequest);
@@ -112,6 +117,7 @@ private:
otError GetNetworkNameHandler(DBusMessageIter &aIter);
otError GetPanIdHandler(DBusMessageIter &aIter);
otError GetExtPanIdHandler(DBusMessageIter &aIter);
+ otError GetEui64Handler(DBusMessageIter &aIter);
otError GetChannelHandler(DBusMessageIter &aIter);
otError GetNetworkKeyHandler(DBusMessageIter &aIter);
otError GetCcaFailureRateHandler(DBusMessageIter &aIter);
@@ -133,12 +139,26 @@ private:
otError GetInstantRssiHandler(DBusMessageIter &aIter);
otError GetRadioTxPowerHandler(DBusMessageIter &aIter);
otError GetExternalRoutesHandler(DBusMessageIter &aIter);
+ otError GetOnMeshPrefixesHandler(DBusMessageIter &aIter);
otError GetActiveDatasetTlvsHandler(DBusMessageIter &aIter);
otError GetRadioRegionHandler(DBusMessageIter &aIter);
+ otError GetSrpServerInfoHandler(DBusMessageIter &aIter);
+ otError GetMdnsTelemetryInfoHandler(DBusMessageIter &aIter);
+ otError GetDnssdCountersHandler(DBusMessageIter &aIter);
+ otError GetOtHostVersionHandler(DBusMessageIter &aIter);
+ otError GetOtRcpVersionHandler(DBusMessageIter &aIter);
+ otError GetThreadVersionHandler(DBusMessageIter &aIter);
+ otError GetRadioSpinelMetricsHandler(DBusMessageIter &aIter);
+ otError GetRcpInterfaceMetricsHandler(DBusMessageIter &aIter);
+ otError GetUptimeHandler(DBusMessageIter &aIter);
+ otError GetRadioCoexMetrics(DBusMessageIter &aIter);
void ReplyScanResult(DBusRequest &aRequest, otError aError, const std::vector<otActiveScanResult> &aResult);
+ void ReplyEnergyScanResult(DBusRequest &aRequest, otError aError, const std::vector<otEnergyScanResult> &aResult);
- otbr::Ncp::ControllerOpenThread *mNcp;
+ otbr::Ncp::ControllerOpenThread * mNcp;
+ std::unordered_map<std::string, PropertyHandlerType> mGetPropertyHandlers;
+ otbr::Mdns::Publisher * mPublisher;
};
} // namespace DBus
diff --git a/src/dbus/server/introspect.xml b/src/dbus/server/introspect.xml
index a3f86efb..46dfe8c3 100644
--- a/src/dbus/server/introspect.xml
+++ b/src/dbus/server/introspect.xml
@@ -9,22 +9,33 @@
<literallayout>
struct {
uint64 ext_address
- string network_name
- uint64 ext_panid
- uint8[] steering_data
uint16 panid
- uint16 joiner_udp_port
uint16 channel
uint16 rssi
uint8 lqi
- uint8 version
- bool is_native
- bool is_joinable
}
</literallayout>
-->
<method name="Scan">
- <arg name="scan_result" type="a(tstayqqqqyybb)" direction="out"/>
+ <arg name="scan_result" type="a(tqqqy)" direction="out"/>
+ </method>
+
+ <!-- Energy Scan: Perform a Thread energy scan.
+ @scanDuration: The 32-bit duration time for the scan of each channel, in milliseconds.
+
+ @result: array of energy scan results.
+
+ The result struture definition is:
+ <literallayout>
+ struct {
+ uint8 channel
+ int8_t max_rssi
+ }
+ </literallayout>
+ -->
+ <method name="EnergyScan">
+ <arg name="scanduration" type="u"/>
+ <arg name="result" type="a(yy)" direction="out"/>
</method>
<!-- Attach: Attach the current device to the Thread network.
@@ -49,9 +60,15 @@
<!-- AttachAllNodesTo: Request to attach all nodes to the specified Thread network.
@dataset: The Operational Dataset that contains parameter values of the Thread network
to attach to. It must be a full dataset.
+ @delay_ms: The delay between the method returns and the dataset takes effect, in
+ milliseconds. If this value is 0, then the node is attached to the given network
+ when this method returns. If this value is not 0, then the node is attached to
+ its existing network when this method returns, and will attach to the given
+ network after the delay.
-->
<method name="AttachAllNodesTo">
<arg name="dataset" type="ay"/>
+ <arg name="delay_ms" type="x" direction="out"/>
</method>
<!-- Detach: Detach the current device from the Thread network. -->
@@ -146,12 +163,12 @@
byte preference
struct {
boolean preferred
- boolean slaac
- boolean dhcp
- boolean configure
- boolean default_route
+ boolean slaac
+ boolean dhcp
+ boolean configure
+ boolean default_route
boolean on_mesh
- boolean stable
+ boolean stable
}
}
</literallayout>
@@ -159,7 +176,7 @@
<method name="AddOnMeshPrefix">
<arg name="prefix" type="((ayy)y(bbbbbbb))"/>
</method>
-
+
<!-- RemoveOnMeshPrefix: Remove an on-mesh prefix from the network.
@prefix: The on-mesh prefix.
@@ -175,6 +192,29 @@
<arg name="prefix" type="(ayy)"/>
</method>
+ <!-- UpdateMeshCopTxt: Update multiple entries in the TXT record.
+ @key: The key of the entry.
+ @value: The value of the entry.
+
+ The prefix structure is:
+ <literallayout>
+ struct {
+ string key
+ uint8[] value
+ }
+ </literallayout>
+ -->
+ <method name="UpdateVendorMeshCopTxtEntries">
+ <arg name="update" type="a(say)" direction="in"/>
+ </method>
+
+ <!-- GetProperties: Get one or more OpenThread properties.
+ @properties: Names of properties.
+ -->
+ <method name="GetProperties">
+ <arg name="properties" type="as" direction="in"/>
+ </method>
+
<!-- MeshLocalPrefix: The /64 mesh-local prefix. -->
<property name="MeshLocalPrefix" type="ay" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
@@ -449,6 +489,32 @@
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
+ <!-- OnMeshPrefixes: The list of current on-mesh prefixes.
+ on-mesh prefix structure definition:
+ <literallayout>
+ struct {
+ struct {
+ uint8[] prefix_bytes
+ uint8 prefix_length
+ }
+ uint16 rloc
+ uint8 preference
+ bool is_preferred
+ bool is_slaac
+ bool is_dhcp
+ bool is_configure
+ bool is_default_route
+ bool is_on_mesh
+ bool is_stable
+ bool is_nd_dns
+ bool is_dp
+ }
+ </literallayout>
+ -->
+ <property name="OnMeshPrefixes" type="a((ayy)qybbbbbbbbb)" access="read">
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
+ </property>
+
<!-- ActiveDatasetTlvs: The Thread active dataset tlv in binary form. -->
<property name="ActiveDatasetTlvs" type="ay" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
@@ -458,6 +524,192 @@
<property name="RadioRegion" type="s" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
+
+ <!-- SrpServerInfo: The SRP server information.
+ <literallayout>
+ struct {
+ uint8 state
+ uint16 port
+ uint8 address_mode
+ struct { // hosts
+ uint32 fresh_count
+ uint32 deleted_count
+ uint64 lease_time_total
+ uint64 key_lease_time_total
+ uint64 remaining_lease_time_total
+ uint64 remaining_key_lease_time_total
+ }
+ struct { // services
+ uint32 fresh_count
+ uint32 deleted_count
+ uint64 lease_time_total
+ uint64 key_lease_time_total
+ uint64 remaining_lease_time_total
+ uint64 remaining_key_lease_time_total
+ }
+ struct { // response counters
+ uint32 success
+ uint32 server_failure
+ uint32 format_error
+ uint32 name_exists
+ uint32 refused
+ uint32 other
+ }
+ }
+ </literallayout>
+ -->
+ <property name="SrpServerInfo" type="(yqy(uutttt)(uutttt)(uuuuuu))" access="read">
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
+ </property>
+ <!-- DnssdCounters: The DNS-SD counters
+ <literallayout>
+ struct {
+ uint32 success
+ uint32 server_failure
+ uint32 format_error
+ uint32 name_error
+ uint32 not_implemented
+ uint32 other
+ uint32 resolved_by_srp
+ }
+ </literallayout>
+ -->
+ <property name="DnssdCounters" type="(uuuuuuu)" access="read">
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
+ </property>
+
+ <!-- MdnsTelemetryInfo: The MDNS information
+ <literallayout>
+ struct {
+ struct { // host registration responses
+ uint32 success
+ uint32 not_found
+ uint32 invalid_args
+ uint32 duplicated
+ uint32 not_implemented
+ uint32 unknown_error
+ }
+ struct { // service registration responses
+ uint32 success
+ uint32 not_found
+ uint32 invalid_args
+ uint32 duplicated
+ uint32 not_implemented
+ uint32 unknown_error
+ }
+ struct { // host resolution responses
+ uint32 success
+ uint32 not_found
+ uint32 invalid_args
+ uint32 duplicated
+ uint32 not_implemented
+ uint32 unknown_error
+ }
+ struct { // service resolution responses
+ uint32 success
+ uint32 not_found
+ uint32 invalid_args
+ uint32 duplicated
+ uint32 not_implemented
+ uint32 unknown_error
+ }
+ uint32 host_registration_ema_latency
+ uint32 service_registration_ema_latency
+ uint32 host_resolution_ema_latency
+ uint32 service_resolution_ema_latency
+ }
+ </literallayout>
+ -->
+ <property name="MdnsTelemetryInfo" type="(uuuuuu)(uuuuuu)(uuuuuu)(uuuuuu)uuuu" access="read">
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
+ </property>
+
+ <!-- OtHostVersion: The version string of the host build. -->
+ <property name="OtHostVersion" type="s" access="read">
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
+ </property>
+
+ <!-- OtRcpVersion: The version string of the RCP firmware. -->
+ <property name="OtRcpVersion" type="s" access="read">
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
+ </property>
+
+ <!-- ThreadVersion: The Thread protocol version. -->
+ <property name="ThreadVersion" type="q" access="read">
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
+ </property>
+
+ <!-- Eui64: The IEEE EUI-64 of this Thread interface. -->
+ <property name="Eui64" type="t" access="read">
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
+ </property>
+
+ <!-- RadioSpinelMetrics: The radio spinel metrics
+ <literallayout>
+ struct {
+ uint32_t mRcpTimeoutCount; // The number of RCP timeouts.
+ uint32_t mRcpUnexpectedResetCount; // The number of RCP unexcepted resets.
+ uint32_t mRcpRestorationCount; // The number of RCP restorations.
+ uint32_t mSpinelParseErrorCount; // The number of spinel frame parse errors.
+ }
+ </literallayout>
+ -->
+ <property name="RadioSpinelMetrics" type="(uuuu)" access="read">
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
+ </property>
+
+ <!-- RcpInterfaceMetrics: The RCP interface metrics
+ <literallayout>
+ struct {
+ uint8_t mRcpInterfaceType; // The RCP interface type.
+ uint64_t mTransferredFrameCount; // The number of transferred frames.
+ uint64_t mTransferredValidFrameCount; // The number of transferred valid frames.
+ uint64_t mTransferredGarbageFrameCount; // The number of transferred garbage frames.
+ uint64_t mRxFrameCount; // The number of received frames.
+ uint64_t mRxFrameByteCount; // The number of received bytes.
+ uint64_t mTxFrameCount; // The number of transmitted frames.
+ uint64_t mTxFrameByteCount; // The number of transmitted bytes.
+ }
+ </literallayout>
+ -->
+ <property name="RcpInterfaceMetrics" type="(yttttttt)" access="read">
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
+ </property>
+
+ <!-- Uptime: The number of milliseconds since OpenThread instance was initialized. -->
+ <property name="Uptime" type="t" access="read">
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
+ </property>
+
+ <!-- RadioCoexMetrics: The radio coexistence metrics
+ <literallayout>
+ struct {
+ uint32_t mNumGrantGlitch; // Number of grant glitches.
+ uint32_t mNumTxRequest; // Number of tx requests.
+ uint32_t mNumTxGrantImmediate; // Number of tx requests while grant was active.
+ uint32_t mNumTxGrantWait; // Number of tx requests while grant was inactive.
+ uint32_t mNumTxGrantWaitActivated; // Number of tx requests while grant was inactive that were ultimately granted.
+ uint32_t mNumTxGrantWaitTimeout; // Number of tx requests while grant was inactive that timed out.
+ uint32_t mNumTxGrantDeactivatedDuringRequest; // Number of tx that were in progress when grant was deactivated.
+ uint32_t mNumTxDelayedGrant; // Number of tx requests that were not granted within 50us.
+ uint32_t mAvgTxRequestToGrantTime; // Average time in usec from tx request to grant.
+ uint32_t mNumRxRequest; // Number of rx requests.
+ uint32_t mNumRxGrantImmediate; // Number of rx requests while grant was active.
+ uint32_t mNumRxGrantWait; // Number of rx requests while grant was inactive.
+ uint32_t mNumRxGrantWaitActivated; // Number of rx requests while grant was inactive that were ultimately granted.
+ uint32_t mNumRxGrantWaitTimeout; // Number of rx requests while grant was inactive that timed out.
+ uint32_t mNumRxGrantDeactivatedDuringRequest; // Number of rx that were in progress when grant was deactivated.
+ uint32_t mNumRxDelayedGrant; // Number of rx requests that were not granted within 50us.
+ uint32_t mAvgRxRequestToGrantTime; // Average time in usec from rx request to grant.
+ uint32_t mNumRxGrantNone; // Number of rx requests that completed without receiving grant.
+ bool mStopped; // Stats collection stopped due to saturation.
+ }
+ </literallayout>
+ -->
+ <property name="RadioCoexMetrics" type="(uuuuuuuuuuuuuuuuuub)" access="read">
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
+ </property>
+
</interface>
<interface name="org.freedesktop.DBus.Properties">