diff options
author | Petre Eftime <[email protected]> | 2016-09-09 17:29:38 +0300 |
---|---|---|
committer | Petre Eftime <[email protected]> | 2016-09-16 14:13:47 +0300 |
commit | 22c1af1c7f1a47207668ba61ceccea2143500069 (patch) | |
tree | 3fce0058fdff26951df516d362b7e0adf205b63b /src | |
parent | 80e1f741597aec0d2874904f28cce3352bd95d64 (diff) |
Add missing BluetoothDevice properties
Signed-off-by: Petre Eftime <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/BluetoothDevice.cpp | 71 | ||||
-rw-r--r-- | src/generated-code.c | 390 | ||||
-rw-r--r-- | src/org.bluez.xml | 6 |
3 files changed, 460 insertions, 7 deletions
diff --git a/src/BluetoothDevice.cpp b/src/BluetoothDevice.cpp index ad040d80..a0832a43 100644 --- a/src/BluetoothDevice.cpp +++ b/src/BluetoothDevice.cpp @@ -444,3 +444,74 @@ BluetoothAdapter BluetoothDevice::get_adapter () return BluetoothAdapter(adapter); } + +std::map<uint16_t, std::vector<uint8_t>> BluetoothDevice::get_manufacturer_data() +{ + std::map<uint16_t, std::vector<uint8_t>> m_data; + GVariant *v = device1_dup_manufacturer_data (object); + + if (v == nullptr) + return m_data; + + GVariantIter *iter; + g_variant_get (v, "a{qv}", &iter); + + GVariant *array; + uint16_t key; + uint8_t val; + + while (g_variant_iter_loop(iter, "{qv}", &key, &array)) { + + GVariantIter it_array; + g_variant_iter_init(&it_array, array); + while(g_variant_iter_loop(&it_array, "y", &val)) { + m_data[key].push_back(val); + } + } + + g_variant_iter_free(iter); + g_variant_unref(v); + + return m_data; +} + +std::map<std::string, std::vector<uint8_t>> BluetoothDevice::get_service_data() +{ + std::map<std::string, std::vector<uint8_t>> m_data; + GVariant *v = device1_dup_manufacturer_data (object); + + if (v == nullptr) + return m_data; + + GVariantIter *iter; + g_variant_get (v, "a{sv}", &iter); + + GVariant *array; + const char* key; + uint8_t val; + + while (g_variant_iter_loop(iter, "{sv}", &key, &array)) { + + GVariantIter it_array; + g_variant_iter_init(&it_array, array); + while(g_variant_iter_loop(&it_array, "y", &val)) { + m_data[key].push_back(val); + } + } + + g_variant_iter_free(iter); + g_variant_unref(v); + + return m_data; +} + +int16_t BluetoothDevice::get_tx_power () +{ + return device1_get_tx_power (object); +} + +bool BluetoothDevice::get_services_resolved () +{ + return device1_get_services_resolved (object); +} + diff --git a/src/generated-code.c b/src/generated-code.c index 52010714..350e09da 100644 --- a/src/generated-code.c +++ b/src/generated-code.c @@ -1,5 +1,5 @@ /* - * Generated by gdbus-codegen 2.48.1. DO NOT EDIT. + * Generated by gdbus-codegen 2.48.2. DO NOT EDIT. * * The license of this code is the same as for the source it was derived from. */ @@ -3011,6 +3011,58 @@ static const _ExtendedGDBusPropertyInfo _device1_property_info_adapter = FALSE }; +static const _ExtendedGDBusPropertyInfo _device1_property_info_manufacturer_data = +{ + { + -1, + (gchar *) "ManufacturerData", + (gchar *) "a{qv}", + G_DBUS_PROPERTY_INFO_FLAGS_READABLE, + NULL + }, + "manufacturer-data", + FALSE +}; + +static const _ExtendedGDBusPropertyInfo _device1_property_info_service_data = +{ + { + -1, + (gchar *) "ServiceData", + (gchar *) "a{sv}", + G_DBUS_PROPERTY_INFO_FLAGS_READABLE, + NULL + }, + "service-data", + FALSE +}; + +static const _ExtendedGDBusPropertyInfo _device1_property_info_tx_power = +{ + { + -1, + (gchar *) "TxPower", + (gchar *) "n", + G_DBUS_PROPERTY_INFO_FLAGS_READABLE, + NULL + }, + "tx-power", + FALSE +}; + +static const _ExtendedGDBusPropertyInfo _device1_property_info_services_resolved = +{ + { + -1, + (gchar *) "ServicesResolved", + (gchar *) "b", + G_DBUS_PROPERTY_INFO_FLAGS_READABLE, + NULL + }, + "services-resolved", + FALSE +}; + static const _ExtendedGDBusPropertyInfo * const _device1_property_info_pointers[] = { &_device1_property_info_address, @@ -3028,6 +3080,10 @@ static const _ExtendedGDBusPropertyInfo * const _device1_property_info_pointers[ &_device1_property_info_uuids, &_device1_property_info_modalias, &_device1_property_info_adapter, + &_device1_property_info_manufacturer_data, + &_device1_property_info_service_data, + &_device1_property_info_tx_power, + &_device1_property_info_services_resolved, NULL }; @@ -3086,6 +3142,10 @@ device1_override_properties (GObjectClass *klass, guint property_id_begin) g_object_class_override_property (klass, property_id_begin++, "uuids"); g_object_class_override_property (klass, property_id_begin++, "modalias"); g_object_class_override_property (klass, property_id_begin++, "adapter"); + g_object_class_override_property (klass, property_id_begin++, "manufacturer-data"); + g_object_class_override_property (klass, property_id_begin++, "service-data"); + g_object_class_override_property (klass, property_id_begin++, "tx-power"); + g_object_class_override_property (klass, property_id_begin++, "services-resolved"); return property_id_begin - 1; } @@ -3115,11 +3175,15 @@ device1_override_properties (GObjectClass *klass, guint property_id_begin) * @get_connected: Getter for the #Device1:connected property. * @get_icon: Getter for the #Device1:icon property. * @get_legacy_pairing: Getter for the #Device1:legacy-pairing property. + * @get_manufacturer_data: Getter for the #Device1:manufacturer-data property. * @get_modalias: Getter for the #Device1:modalias property. * @get_name: Getter for the #Device1:name property. * @get_paired: Getter for the #Device1:paired property. * @get_rssi: Getter for the #Device1:rssi property. + * @get_service_data: Getter for the #Device1:service-data property. + * @get_services_resolved: Getter for the #Device1:services-resolved property. * @get_trusted: Getter for the #Device1:trusted property. + * @get_tx_power: Getter for the #Device1:tx-power property. * @get_uuids: Getter for the #Device1:uuids property. * * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-bluez-Device1.top_of_page">org.bluez.Device1</link>. @@ -3402,6 +3466,42 @@ device1_default_init (Device1Iface *iface) */ g_object_interface_install_property (iface, g_param_spec_string ("adapter", "Adapter", "Adapter", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + * Device1:manufacturer-data: + * + * Represents the D-Bus property <link linkend="gdbus-property-org-bluez-Device1.ManufacturerData">"ManufacturerData"</link>. + * + * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side. + */ + g_object_interface_install_property (iface, + g_param_spec_variant ("manufacturer-data", "ManufacturerData", "ManufacturerData", G_VARIANT_TYPE ("a{qv}"), NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + * Device1:service-data: + * + * Represents the D-Bus property <link linkend="gdbus-property-org-bluez-Device1.ServiceData">"ServiceData"</link>. + * + * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side. + */ + g_object_interface_install_property (iface, + g_param_spec_variant ("service-data", "ServiceData", "ServiceData", G_VARIANT_TYPE ("a{sv}"), NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + * Device1:tx-power: + * + * Represents the D-Bus property <link linkend="gdbus-property-org-bluez-Device1.TxPower">"TxPower"</link>. + * + * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side. + */ + g_object_interface_install_property (iface, + g_param_spec_int ("tx-power", "TxPower", "TxPower", G_MININT16, G_MAXINT16, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + * Device1:services-resolved: + * + * Represents the D-Bus property <link linkend="gdbus-property-org-bluez-Device1.ServicesResolved">"ServicesResolved"</link>. + * + * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side. + */ + g_object_interface_install_property (iface, + g_param_spec_boolean ("services-resolved", "ServicesResolved", "ServicesResolved", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); } /** @@ -4010,6 +4110,170 @@ device1_set_adapter (Device1 *object, const gchar *value) } /** + * device1_get_manufacturer_data: (skip) + * @object: A #Device1. + * + * Gets the value of the <link linkend="gdbus-property-org-bluez-Device1.ManufacturerData">"ManufacturerData"</link> D-Bus property. + * + * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side. + * + * <warning>The returned value is only valid until the property changes so on the client-side it is only safe to use this function on the thread where @object was constructed. Use device1_dup_manufacturer_data() if on another thread.</warning> + * + * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object. + */ +GVariant * +device1_get_manufacturer_data (Device1 *object) +{ + return DEVICE1_GET_IFACE (object)->get_manufacturer_data (object); +} + +/** + * device1_dup_manufacturer_data: (skip) + * @object: A #Device1. + * + * Gets a copy of the <link linkend="gdbus-property-org-bluez-Device1.ManufacturerData">"ManufacturerData"</link> D-Bus property. + * + * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side. + * + * Returns: (transfer full): The property value or %NULL if the property is not set. The returned value should be freed with g_variant_unref(). + */ +GVariant * +device1_dup_manufacturer_data (Device1 *object) +{ + GVariant *value; + g_object_get (G_OBJECT (object), "manufacturer-data", &value, NULL); + return value; +} + +/** + * device1_set_manufacturer_data: (skip) + * @object: A #Device1. + * @value: The value to set. + * + * Sets the <link linkend="gdbus-property-org-bluez-Device1.ManufacturerData">"ManufacturerData"</link> D-Bus property to @value. + * + * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side. + */ +void +device1_set_manufacturer_data (Device1 *object, GVariant *value) +{ + g_object_set (G_OBJECT (object), "manufacturer-data", value, NULL); +} + +/** + * device1_get_service_data: (skip) + * @object: A #Device1. + * + * Gets the value of the <link linkend="gdbus-property-org-bluez-Device1.ServiceData">"ServiceData"</link> D-Bus property. + * + * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side. + * + * <warning>The returned value is only valid until the property changes so on the client-side it is only safe to use this function on the thread where @object was constructed. Use device1_dup_service_data() if on another thread.</warning> + * + * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object. + */ +GVariant * +device1_get_service_data (Device1 *object) +{ + return DEVICE1_GET_IFACE (object)->get_service_data (object); +} + +/** + * device1_dup_service_data: (skip) + * @object: A #Device1. + * + * Gets a copy of the <link linkend="gdbus-property-org-bluez-Device1.ServiceData">"ServiceData"</link> D-Bus property. + * + * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side. + * + * Returns: (transfer full): The property value or %NULL if the property is not set. The returned value should be freed with g_variant_unref(). + */ +GVariant * +device1_dup_service_data (Device1 *object) +{ + GVariant *value; + g_object_get (G_OBJECT (object), "service-data", &value, NULL); + return value; +} + +/** + * device1_set_service_data: (skip) + * @object: A #Device1. + * @value: The value to set. + * + * Sets the <link linkend="gdbus-property-org-bluez-Device1.ServiceData">"ServiceData"</link> D-Bus property to @value. + * + * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side. + */ +void +device1_set_service_data (Device1 *object, GVariant *value) +{ + g_object_set (G_OBJECT (object), "service-data", value, NULL); +} + +/** + * device1_get_tx_power: (skip) + * @object: A #Device1. + * + * Gets the value of the <link linkend="gdbus-property-org-bluez-Device1.TxPower">"TxPower"</link> D-Bus property. + * + * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side. + * + * Returns: The property value. + */ +gint16 +device1_get_tx_power (Device1 *object) +{ + return DEVICE1_GET_IFACE (object)->get_tx_power (object); +} + +/** + * device1_set_tx_power: (skip) + * @object: A #Device1. + * @value: The value to set. + * + * Sets the <link linkend="gdbus-property-org-bluez-Device1.TxPower">"TxPower"</link> D-Bus property to @value. + * + * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side. + */ +void +device1_set_tx_power (Device1 *object, gint16 value) +{ + g_object_set (G_OBJECT (object), "tx-power", value, NULL); +} + +/** + * device1_get_services_resolved: (skip) + * @object: A #Device1. + * + * Gets the value of the <link linkend="gdbus-property-org-bluez-Device1.ServicesResolved">"ServicesResolved"</link> D-Bus property. + * + * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side. + * + * Returns: The property value. + */ +gboolean +device1_get_services_resolved (Device1 *object) +{ + return DEVICE1_GET_IFACE (object)->get_services_resolved (object); +} + +/** + * device1_set_services_resolved: (skip) + * @object: A #Device1. + * @value: The value to set. + * + * Sets the <link linkend="gdbus-property-org-bluez-Device1.ServicesResolved">"ServicesResolved"</link> D-Bus property to @value. + * + * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side. + */ +void +device1_set_services_resolved (Device1 *object, gboolean value) +{ + g_object_set (G_OBJECT (object), "services-resolved", value, NULL); +} + +/** * device1_call_disconnect: * @proxy: A #Device1Proxy. * @cancellable: (allow-none): A #GCancellable or %NULL. @@ -4729,7 +4993,7 @@ device1_proxy_get_property (GObject *object, { const _ExtendedGDBusPropertyInfo *info; GVariant *variant; - g_assert (prop_id != 0 && prop_id - 1 < 15); + g_assert (prop_id != 0 && prop_id - 1 < 19); info = _device1_property_info_pointers[prop_id - 1]; variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name); if (info->use_gvariant) @@ -4776,7 +5040,7 @@ device1_proxy_set_property (GObject *object, { const _ExtendedGDBusPropertyInfo *info; GVariant *variant; - g_assert (prop_id != 0 && prop_id - 1 < 15); + g_assert (prop_id != 0 && prop_id - 1 < 19); info = _device1_property_info_pointers[prop_id - 1]; variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature)); g_dbus_proxy_call (G_DBUS_PROXY (object), @@ -5087,6 +5351,62 @@ device1_proxy_get_adapter (Device1 *object) return value; } +static GVariant * +device1_proxy_get_manufacturer_data (Device1 *object) +{ + Device1Proxy *proxy = DEVICE1_PROXY (object); + GVariant *variant; + GVariant *value = NULL; + variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "ManufacturerData"); + value = variant; + if (variant != NULL) + g_variant_unref (variant); + return value; +} + +static GVariant * +device1_proxy_get_service_data (Device1 *object) +{ + Device1Proxy *proxy = DEVICE1_PROXY (object); + GVariant *variant; + GVariant *value = NULL; + variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "ServiceData"); + value = variant; + if (variant != NULL) + g_variant_unref (variant); + return value; +} + +static gint16 +device1_proxy_get_tx_power (Device1 *object) +{ + Device1Proxy *proxy = DEVICE1_PROXY (object); + GVariant *variant; + gint16 value = 0; + variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "TxPower"); + if (variant != NULL) + { + value = g_variant_get_int16 (variant); + g_variant_unref (variant); + } + return value; +} + +static gboolean +device1_proxy_get_services_resolved (Device1 *object) +{ + Device1Proxy *proxy = DEVICE1_PROXY (object); + GVariant *variant; + gboolean value = 0; + variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "ServicesResolved"); + if (variant != NULL) + { + value = g_variant_get_boolean (variant); + g_variant_unref (variant); + } + return value; +} + static void device1_proxy_init (Device1Proxy *proxy) { @@ -5139,6 +5459,10 @@ device1_proxy_iface_init (Device1Iface *iface) iface->get_uuids = device1_proxy_get_uuids; iface->get_modalias = device1_proxy_get_modalias; iface->get_adapter = device1_proxy_get_adapter; + iface->get_manufacturer_data = device1_proxy_get_manufacturer_data; + iface->get_service_data = device1_proxy_get_service_data; + iface->get_tx_power = device1_proxy_get_tx_power; + iface->get_services_resolved = device1_proxy_get_services_resolved; } /** @@ -5565,7 +5889,7 @@ device1_skeleton_finalize (GObject *object) { Device1Skeleton *skeleton = DEVICE1_SKELETON (object); guint n; - for (n = 0; n < 15; n++) + for (n = 0; n < 19; n++) g_value_unset (&skeleton->priv->properties[n]); g_free (skeleton->priv->properties); g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free); @@ -5583,7 +5907,7 @@ device1_skeleton_get_property (GObject *object, GParamSpec *pspec G_GNUC_UNUSED) { Device1Skeleton *skeleton = DEVICE1_SKELETON (object); - g_assert (prop_id != 0 && prop_id - 1 < 15); + g_assert (prop_id != 0 && prop_id - 1 < 19); g_mutex_lock (&skeleton->priv->lock); g_value_copy (&skeleton->priv->properties[prop_id - 1], value); g_mutex_unlock (&skeleton->priv->lock); @@ -5701,7 +6025,7 @@ device1_skeleton_set_property (GObject *object, GParamSpec *pspec) { Device1Skeleton *skeleton = DEVICE1_SKELETON (object); - g_assert (prop_id != 0 && prop_id - 1 < 15); + g_assert (prop_id != 0 && prop_id - 1 < 19); g_mutex_lock (&skeleton->priv->lock); g_object_freeze_notify (object); if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1])) @@ -5726,7 +6050,7 @@ device1_skeleton_init (Device1Skeleton *skeleton) g_mutex_init (&skeleton->priv->lock); skeleton->priv->context = g_main_context_ref_thread_default (); - skeleton->priv->properties = g_new0 (GValue, 15); + skeleton->priv->properties = g_new0 (GValue, 19); g_value_init (&skeleton->priv->properties[0], G_TYPE_STRING); g_value_init (&skeleton->priv->properties[1], G_TYPE_STRING); g_value_init (&skeleton->priv->properties[2], G_TYPE_STRING); @@ -5742,6 +6066,10 @@ device1_skeleton_init (Device1Skeleton *skeleton) g_value_init (&skeleton->priv->properties[12], G_TYPE_STRV); g_value_init (&skeleton->priv->properties[13], G_TYPE_STRING); g_value_init (&skeleton->priv->properties[14], G_TYPE_STRING); + g_value_init (&skeleton->priv->properties[15], G_TYPE_VARIANT); + g_value_init (&skeleton->priv->properties[16], G_TYPE_VARIANT); + g_value_init (&skeleton->priv->properties[17], G_TYPE_INT); + g_value_init (&skeleton->priv->properties[18], G_TYPE_BOOLEAN); } static const gchar * @@ -5909,6 +6237,50 @@ device1_skeleton_get_adapter (Device1 *object) return value; } +static GVariant * +device1_skeleton_get_manufacturer_data (Device1 *object) +{ + Device1Skeleton *skeleton = DEVICE1_SKELETON (object); + GVariant *value; + g_mutex_lock (&skeleton->priv->lock); + value = g_value_get_variant (&(skeleton->priv->properties[15])); + g_mutex_unlock (&skeleton->priv->lock); + return value; +} + +static GVariant * +device1_skeleton_get_service_data (Device1 *object) +{ + Device1Skeleton *skeleton = DEVICE1_SKELETON (object); + GVariant *value; + g_mutex_lock (&skeleton->priv->lock); + value = g_value_get_variant (&(skeleton->priv->properties[16])); + g_mutex_unlock (&skeleton->priv->lock); + return value; +} + +static gint16 +device1_skeleton_get_tx_power (Device1 *object) +{ + Device1Skeleton *skeleton = DEVICE1_SKELETON (object); + gint value; + g_mutex_lock (&skeleton->priv->lock); + value = g_value_get_int (&(skeleton->priv->properties[17])); + g_mutex_unlock (&skeleton->priv->lock); + return value; +} + +static gboolean +device1_skeleton_get_services_resolved (Device1 *object) +{ + Device1Skeleton *skeleton = DEVICE1_SKELETON (object); + gboolean value; + g_mutex_lock (&skeleton->priv->lock); + value = g_value_get_boolean (&(skeleton->priv->properties[18])); + g_mutex_unlock (&skeleton->priv->lock); + return value; +} + static void device1_skeleton_class_init (Device1SkeletonClass *klass) { @@ -5953,6 +6325,10 @@ device1_skeleton_iface_init (Device1Iface *iface) iface->get_uuids = device1_skeleton_get_uuids; iface->get_modalias = device1_skeleton_get_modalias; iface->get_adapter = device1_skeleton_get_adapter; + iface->get_manufacturer_data = device1_skeleton_get_manufacturer_data; + iface->get_service_data = device1_skeleton_get_service_data; + iface->get_tx_power = device1_skeleton_get_tx_power; + iface->get_services_resolved = device1_skeleton_get_services_resolved; } /** diff --git a/src/org.bluez.xml b/src/org.bluez.xml index 6d5f8830..0c3b99bb 100644 --- a/src/org.bluez.xml +++ b/src/org.bluez.xml @@ -67,13 +67,19 @@ THE SOFTWARE. <property name="UUIDs" type="as" access="read"/> <property name="Modalias" type="s" access="read"/> <property name="Adapter" type="o" access="read"/> + <property name="ManufacturerData" type="a{qv}" access="read"/> + <property name="ServiceData" type="a{sv}" access="read"/> + <property name="TxPower" type="n" access="read"/> + <property name="ServicesResolved" type="b" access="read"/> </interface> + <interface name="org.bluez.GattService1"> <property name="UUID" type="s" access="read"/> <property name="Device" type="o" access="read"/> <property name="Primary" type="b" access="read"/> <property name="Characteristics" type="ao" access="read"/> </interface> + <interface name="org.bluez.GattCharacteristic1"> <method name="ReadValue"> <arg name="value" type="ay" direction="out"/> |