From 8d06c947752a1608970e2a603e21ab66f02ce11b Mon Sep 17 00:00:00 2001 From: Jake Swensen Date: Thu, 14 Dec 2023 13:50:28 +0000 Subject: [PATCH] [dbus] add OTBR_PACKAGE_VERSION (#2135) --- src/dbus/common/constants.hpp | 1 + src/dbus/server/dbus_thread_object.cpp | 13 +++++++++++++ src/dbus/server/dbus_thread_object.hpp | 1 + src/dbus/server/introspect.xml | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/src/dbus/common/constants.hpp b/src/dbus/common/constants.hpp index 1d99f1d7f13..561be710359 100644 --- a/src/dbus/common/constants.hpp +++ b/src/dbus/common/constants.hpp @@ -98,6 +98,7 @@ #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_OTBR_VERSION "OtbrVersion" #define OTBR_DBUS_PROPERTY_OT_HOST_VERSION "OtHostVersion" #define OTBR_DBUS_PROPERTY_OT_RCP_VERSION "OtRcpVersion" #define OTBR_DBUS_PROPERTY_THREAD_VERSION "ThreadVersion" diff --git a/src/dbus/server/dbus_thread_object.cpp b/src/dbus/server/dbus_thread_object.cpp index a10ea2d49c4..eee5ee7ac06 100644 --- a/src/dbus/server/dbus_thread_object.cpp +++ b/src/dbus/server/dbus_thread_object.cpp @@ -240,6 +240,8 @@ otbrError DBusThreadObject::Init(void) 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_OTBR_VERSION, + std::bind(&DBusThreadObject::GetOtbrVersionHandler, 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, @@ -1499,6 +1501,17 @@ void DBusThreadObject::RegisterGetPropertyHandler(const std::string &aIn mGetPropertyHandlers[aPropertyName] = aHandler; } +otError DBusThreadObject::GetOtbrVersionHandler(DBusMessageIter &aIter) +{ + otError error = OT_ERROR_NONE; + std::string version = OTBR_PACKAGE_VERSION; + + SuccessOrExit(error = DBusMessageEncodeToVariant(&aIter, version)); + +exit: + return error; +} + otError DBusThreadObject::GetOtHostVersionHandler(DBusMessageIter &aIter) { otError error = OT_ERROR_NONE; diff --git a/src/dbus/server/dbus_thread_object.hpp b/src/dbus/server/dbus_thread_object.hpp index 9b23bd6e9bd..6b5e7c8b8f0 100644 --- a/src/dbus/server/dbus_thread_object.hpp +++ b/src/dbus/server/dbus_thread_object.hpp @@ -155,6 +155,7 @@ class DBusThreadObject : public DBusObject otError GetSrpServerInfoHandler(DBusMessageIter &aIter); otError GetMdnsTelemetryInfoHandler(DBusMessageIter &aIter); otError GetDnssdCountersHandler(DBusMessageIter &aIter); + otError GetOtbrVersionHandler(DBusMessageIter &aIter); otError GetOtHostVersionHandler(DBusMessageIter &aIter); otError GetOtRcpVersionHandler(DBusMessageIter &aIter); otError GetThreadVersionHandler(DBusMessageIter &aIter); diff --git a/src/dbus/server/introspect.xml b/src/dbus/server/introspect.xml index 0a898181d49..2d4b1d216a9 100644 --- a/src/dbus/server/introspect.xml +++ b/src/dbus/server/introspect.xml @@ -659,6 +659,11 @@ + + + + +