RE: [PATCH 0/4] Add Property Changed callbacks to btd_device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi,

This patch set comes as a reply to a previous discussion over the DIS plugin, with Claudio Takashi. The main concern Claudio raised was with a race condition which may occur, when HID Service is loaded before DIS is fully updated with the PNP_ID information, which is required for HID Service /dev/uhid configuration. To prevent this a few ideas were raised, and callback mechanism was one of them.

This mechanism will allow a HID Service to check for the validity of the peer device PNP_ID information (version, vendor, vendor src and product version), and if these are still missing, register a callback for those parameters to follow up with its connection to the device. HID Service cannot operate without this information, so there is no point opening a /dev/uhid before you have this information.

The internal mechanism mimics the D-BUS PropertyChanged events and uses the same events.

Currently, only the "Connected" event is implemented, just to show the idea behind this. After this patch set is applied, we can add more events as needed.

To test this, I simply used a small patch on the adapter.c file, creating a callback and printing the events after a device is created :

diff --git a/src/adapter.c b/src/adapter.c
index 7a2214a..5b57de9 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1380,6 +1380,16 @@ static DBusMessage *cancel_device_creation(DBusConnection *conn,
        return dbus_message_new_method_return(msg);
 }
 
+static void dev_prop_changed_cb(uint16_t property, uint8_t *value, uint16_t len,struct btd_device *device)
+{
+       DBG("property:%X len:%d",property,len);
+
+       if (property == DEVICE_PROPERTY_CHANGED_CONNECTED) {
+               struct property_changed_connected *p =(struct property_changed_connected*)value;
+               DBG("Device %p connected state is %d",device,p->connected);
+       }
+}
+
 static struct btd_device *create_device_internal(DBusConnection *conn,
                                                struct btd_adapter *adapter,
                                                const char *address, int *err)
@@ -1401,6 +1411,8 @@ static struct btd_device *create_device_internal(DBusConnection *conn,
        if (!device && err)
                *err = -ENOMEM;
 
+       btd_device_add_prop_changed_cb(device,dev_prop_changed_cb);
+
        return device;
 }

Thanks,
Chen Ganir


> -----Original Message-----
> From: Chen Ganir [mailto:chen.ganir@xxxxxxxxx] On Behalf Of Ganir, Chen
> Sent: Wednesday, March 28, 2012 4:46 PM
> To: linux-bluetooth@xxxxxxxxxxxxxxx
> Cc: Ganir, Chen
> Subject: [PATCH 0/4] Add Property Changed callbacks to btd_device
> 
> From: Chen Ganir <chen.ganir@xxxxxx>
> 
> Add a callback mechanism for the btd_device, allowing other parts of
> the bluez
> stack to receive notifications for device properties which are changed.
> This
> mechanism is based on the D-BUS API for Device PropertyChanged.
> 
> Chen Ganir (4):
>   Add property changed callback
>   Centralize property changed events
>   Use macros instead of strings
>   Call registered callbacks
> 
>  src/device.c |  223 +++++++++++++++++++++++++++++++++++++++++++++++++-
> --------
>  src/device.h |   93 ++++++++++++++++++++++++
>  2 files changed, 281 insertions(+), 35 deletions(-)
> 
> --
> 1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux