Skip to content

Commit

Permalink
adapter: Implement Version and Manufacturer properties
Browse files Browse the repository at this point in the history
This allows DBus clients to find an adapter's version and
manufacturer company code without querying the management API.
  • Loading branch information
vibhavp authored and Vudentz committed Oct 4, 2023
1 parent 6393012 commit f2677c0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ struct btd_adapter {

bdaddr_t bdaddr; /* controller Bluetooth address */
uint8_t bdaddr_type; /* address type */
uint8_t version; /* controller core spec version */
uint32_t dev_class; /* controller class of device */
char *name; /* controller device name */
char *short_name; /* controller short name */
Expand Down Expand Up @@ -3540,6 +3541,29 @@ static gboolean property_experimental_exists(const GDBusPropertyTable *property,
return !queue_isempty(adapter->exps);
}

static gboolean property_get_manufacturer(const GDBusPropertyTable *property,
DBusMessageIter *iter,
void *user_data)
{
struct btd_adapter *adapter = user_data;
dbus_uint16_t val = adapter->manufacturer;

dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &val);

return TRUE;
}

static gboolean property_get_version(const GDBusPropertyTable *property,
DBusMessageIter *iter, void *user_data)
{
struct btd_adapter *adapter = user_data;
uint8_t val = adapter->version;

dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, &val);

return TRUE;
}

static DBusMessage *remove_device(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
Expand Down Expand Up @@ -3898,6 +3922,8 @@ static const GDBusPropertyTable adapter_properties[] = {
{ "Roles", "as", property_get_roles },
{ "ExperimentalFeatures", "as", property_get_experimental, NULL,
property_experimental_exists },
{ "Manufacturer", "q", property_get_manufacturer },
{ "Version", "y", property_get_version },
{ }
};

Expand Down Expand Up @@ -10164,6 +10190,8 @@ static void read_info_complete(uint8_t status, uint16_t length,
adapter->supported_settings = btohl(rp->supported_settings);
adapter->current_settings = btohl(rp->current_settings);

adapter->version = rp->version;

clear_uuids(adapter);
clear_devices(adapter);

Expand Down

0 comments on commit f2677c0

Please sign in to comment.