Skip to content

Commit

Permalink
[dbus] add OTBR_PACKAGE_VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
jdswensen committed Dec 14, 2023
1 parent c21797d commit 53feb54
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/dbus/common/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 13 additions & 0 deletions src/dbus/server/dbus_thread_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;

VerifyOrExit(DBusMessageEncodeToVariant(&aIter, version) == OTBR_ERROR_NONE, error = OT_ERROR_FAILED);

exit:
return error;
}

otError DBusThreadObject::GetOtHostVersionHandler(DBusMessageIter &aIter)
{
otError error = OT_ERROR_NONE;
Expand Down
1 change: 1 addition & 0 deletions src/dbus/server/dbus_thread_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/dbus/server/introspect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,11 @@
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>

<!-- OtbrVersion: The version string of the otbr package. -->
<property name="OtbrVersion" type="s" 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"/>
Expand Down

0 comments on commit 53feb54

Please sign in to comment.