* Re: [PATCH v4] HID: Add support for Sony PS3 BD Remote Control
From: Antonio Ospite @ 2012-10-01 8:19 UTC (permalink / raw)
To: David Dillow
Cc: linux-bluetooth, David Herrmann, Luiz Augusto von Dentz,
Bastien Nocera, linux-input, Jiri Kosina, Antonio Ospite
In-Reply-To: <1348606947-3055-1-git-send-email-ospite@studenti.unina.it>
On Tue, 25 Sep 2012 23:02:27 +0200
Antonio Ospite <ospite@studenti.unina.it> wrote:
Ping.
Jiri, I see that linux-3.6 is out, can we have this in for 3.7-rc1?
Thanks,
Antonio
> From: David Dillow <dave@thedillows.org>
>
> The Sony PS3 Blue-ray Disc Remote Control used to be supported by the
> BlueZ project's user space, but the code that handled it was recently
> removed as its functionality conflicted with a real HSP implementation
> and the mapping was thought to be better handled in the kernel. This is
> a port of the mapping logic from the fakehid driver by Marcel Holtmann
> to the in-kernel HID layer.
>
> We also add support for the Logitech Harmony Adapter for PS3, which
> emulates the BD Remote.
>
> Signed-off-by: David Dillow <dave@thedillows.org>
> Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
> ---
>
> Changes since v3:
> - move the size check into the switch statement.
>
> Thanks,
> Antonio
>
> drivers/hid/Kconfig | 13 ++-
> drivers/hid/Makefile | 1 +
> drivers/hid/hid-core.c | 2 +
> drivers/hid/hid-ids.h | 2 +
> drivers/hid/hid-ps3remote.c | 215 +++++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 232 insertions(+), 1 deletion(-)
> create mode 100644 drivers/hid/hid-ps3remote.c
>
> diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
> index fbf4950..378be0b 100644
> --- a/drivers/hid/Kconfig
> +++ b/drivers/hid/Kconfig
> @@ -534,6 +534,15 @@ config HID_PRIMAX
> Support for Primax devices that are not fully compliant with the
> HID standard.
>
> +config HID_PS3REMOTE
> + tristate "Sony PS3 BD Remote Control"
> + depends on BT_HIDP
> + ---help---
> + Support for the Sony PS3 Blue-ray Disk Remote Control and Logitech
> + Harmony Adapter for PS3, which connect over Bluetooth.
> +
> + Support for the 6-axis controllers is provided by HID_SONY.
> +
> config HID_ROCCAT
> tristate "Roccat device support"
> depends on USB_HID
> @@ -561,7 +570,9 @@ config HID_SONY
> tristate "Sony PS3 controller"
> depends on USB_HID
> ---help---
> - Support for Sony PS3 controller.
> + Support for Sony PS3 6-axis controllers.
> +
> + Support for the Sony PS3 BD Remote is provided by HID_PS3REMOTE.
>
> config HID_SPEEDLINK
> tristate "Speedlink VAD Cezanne mouse support"
> diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
> index f975485..333ed6c 100644
> --- a/drivers/hid/Makefile
> +++ b/drivers/hid/Makefile
> @@ -70,6 +70,7 @@ obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o
> obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o
> obj-$(CONFIG_HID_PICOLCD) += hid-picolcd.o
> obj-$(CONFIG_HID_PRIMAX) += hid-primax.o
> +obj-$(CONFIG_HID_PS3REMOTE) += hid-ps3remote.o
> obj-$(CONFIG_HID_ROCCAT) += hid-roccat.o hid-roccat-common.o \
> hid-roccat-arvo.o hid-roccat-isku.o hid-roccat-kone.o \
> hid-roccat-koneplus.o hid-roccat-kovaplus.o hid-roccat-pyra.o \
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index 8bcd168..e4275d4 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -1566,6 +1566,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
> { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) },
> { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) },
> { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) },
> + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3) },
> { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) },
> { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) },
> { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) },
> @@ -1639,6 +1640,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
> { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
> { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
> { HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) },
> + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_BDREMOTE) },
> { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
> { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
> { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
> diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
> index 1dcb76f..40411c9 100644
> --- a/drivers/hid/hid-ids.h
> +++ b/drivers/hid/hid-ids.h
> @@ -496,6 +496,7 @@
> #define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101
> #define USB_DEVICE_ID_LOGITECH_HARMONY_FIRST 0xc110
> #define USB_DEVICE_ID_LOGITECH_HARMONY_LAST 0xc14f
> +#define USB_DEVICE_ID_LOGITECH_HARMONY_PS3 0x0306
> #define USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD 0xc20a
> #define USB_DEVICE_ID_LOGITECH_RUMBLEPAD 0xc211
> #define USB_DEVICE_ID_LOGITECH_EXTREME_3D 0xc215
> @@ -683,6 +684,7 @@
>
> #define USB_VENDOR_ID_SONY 0x054c
> #define USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE 0x024b
> +#define USB_DEVICE_ID_SONY_PS3_BDREMOTE 0x0306
> #define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268
> #define USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER 0x042f
>
> diff --git a/drivers/hid/hid-ps3remote.c b/drivers/hid/hid-ps3remote.c
> new file mode 100644
> index 0000000..03811e5
> --- /dev/null
> +++ b/drivers/hid/hid-ps3remote.c
> @@ -0,0 +1,215 @@
> +/*
> + * HID driver for Sony PS3 BD Remote Control
> + *
> + * Copyright (c) 2012 David Dillow <dave@thedillows.org>
> + * Based on a blend of the bluez fakehid user-space code by Marcel Holtmann
> + * and other kernel HID drivers.
> + */
> +
> +/*
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published by the Free
> + * Software Foundation; either version 2 of the License, or (at your option)
> + * any later version.
> + */
> +
> +/* NOTE: in order for the Sony PS3 BD Remote Control to be found by
> + * a Bluetooth host, the key combination Start+Enter has to be kept pressed
> + * for about 7 seconds with the Bluetooth Host Controller in discovering mode.
> + *
> + * There will be no PIN request from the device.
> + */
> +
> +#include <linux/device.h>
> +#include <linux/hid.h>
> +#include <linux/module.h>
> +
> +#include "hid-ids.h"
> +
> +static __u8 ps3remote_rdesc[] = {
> + 0x05, 0x01, /* GUsagePage Generic Desktop */
> + 0x09, 0x05, /* LUsage 0x05 [Game Pad] */
> + 0xA1, 0x01, /* MCollection Application (mouse, keyboard) */
> +
> + /* Use collection 1 for joypad buttons */
> + 0xA1, 0x02, /* MCollection Logical (interrelated data) */
> +
> + /* Ignore the 1st byte, maybe it is used for a controller
> + * number but it's not needed for correct operation */
> + 0x75, 0x08, /* GReportSize 0x08 [8] */
> + 0x95, 0x01, /* GReportCount 0x01 [1] */
> + 0x81, 0x01, /* MInput 0x01 (Const[0] Arr[1] Abs[2]) */
> +
> + /* Bytes from 2nd to 4th are a bitmap for joypad buttons, for these
> + * buttons multiple keypresses are allowed */
> + 0x05, 0x09, /* GUsagePage Button */
> + 0x19, 0x01, /* LUsageMinimum 0x01 [Button 1 (primary/trigger)] */
> + 0x29, 0x18, /* LUsageMaximum 0x18 [Button 24] */
> + 0x14, /* GLogicalMinimum [0] */
> + 0x25, 0x01, /* GLogicalMaximum 0x01 [1] */
> + 0x75, 0x01, /* GReportSize 0x01 [1] */
> + 0x95, 0x18, /* GReportCount 0x18 [24] */
> + 0x81, 0x02, /* MInput 0x02 (Data[0] Var[1] Abs[2]) */
> +
> + 0xC0, /* MEndCollection */
> +
> + /* Use collection 2 for remote control buttons */
> + 0xA1, 0x02, /* MCollection Logical (interrelated data) */
> +
> + /* 5th byte is used for remote control buttons */
> + 0x05, 0x09, /* GUsagePage Button */
> + 0x18, /* LUsageMinimum [No button pressed] */
> + 0x29, 0xFE, /* LUsageMaximum 0xFE [Button 254] */
> + 0x14, /* GLogicalMinimum [0] */
> + 0x26, 0xFE, 0x00, /* GLogicalMaximum 0x00FE [254] */
> + 0x75, 0x08, /* GReportSize 0x08 [8] */
> + 0x95, 0x01, /* GReportCount 0x01 [1] */
> + 0x80, /* MInput */
> +
> + /* Ignore bytes from 6th to 11th, 6th to 10th are always constant at
> + * 0xff and 11th is for press indication */
> + 0x75, 0x08, /* GReportSize 0x08 [8] */
> + 0x95, 0x06, /* GReportCount 0x06 [6] */
> + 0x81, 0x01, /* MInput 0x01 (Const[0] Arr[1] Abs[2]) */
> +
> + /* 12th byte is for battery strength */
> + 0x05, 0x06, /* GUsagePage Generic Device Controls */
> + 0x09, 0x20, /* LUsage 0x20 [Battery Strength] */
> + 0x14, /* GLogicalMinimum [0] */
> + 0x25, 0x05, /* GLogicalMaximum 0x05 [5] */
> + 0x75, 0x08, /* GReportSize 0x08 [8] */
> + 0x95, 0x01, /* GReportCount 0x01 [1] */
> + 0x81, 0x02, /* MInput 0x02 (Data[0] Var[1] Abs[2]) */
> +
> + 0xC0, /* MEndCollection */
> +
> + 0xC0 /* MEndCollection [Game Pad] */
> +};
> +
> +static const unsigned int ps3remote_keymap_joypad_buttons[] = {
> + [0x01] = KEY_SELECT,
> + [0x02] = BTN_THUMBL, /* L3 */
> + [0x03] = BTN_THUMBR, /* R3 */
> + [0x04] = BTN_START,
> + [0x05] = KEY_UP,
> + [0x06] = KEY_RIGHT,
> + [0x07] = KEY_DOWN,
> + [0x08] = KEY_LEFT,
> + [0x09] = BTN_TL2, /* L2 */
> + [0x0a] = BTN_TR2, /* R2 */
> + [0x0b] = BTN_TL, /* L1 */
> + [0x0c] = BTN_TR, /* R1 */
> + [0x0d] = KEY_OPTION, /* options/triangle */
> + [0x0e] = KEY_BACK, /* back/circle */
> + [0x0f] = BTN_0, /* cross */
> + [0x10] = KEY_SCREEN, /* view/square */
> + [0x11] = KEY_HOMEPAGE, /* PS button */
> + [0x14] = KEY_ENTER,
> +};
> +static const unsigned int ps3remote_keymap_remote_buttons[] = {
> + [0x00] = KEY_1,
> + [0x01] = KEY_2,
> + [0x02] = KEY_3,
> + [0x03] = KEY_4,
> + [0x04] = KEY_5,
> + [0x05] = KEY_6,
> + [0x06] = KEY_7,
> + [0x07] = KEY_8,
> + [0x08] = KEY_9,
> + [0x09] = KEY_0,
> + [0x0e] = KEY_ESC, /* return */
> + [0x0f] = KEY_CLEAR,
> + [0x16] = KEY_EJECTCD,
> + [0x1a] = KEY_MENU, /* top menu */
> + [0x28] = KEY_TIME,
> + [0x30] = KEY_PREVIOUS,
> + [0x31] = KEY_NEXT,
> + [0x32] = KEY_PLAY,
> + [0x33] = KEY_REWIND, /* scan back */
> + [0x34] = KEY_FORWARD, /* scan forward */
> + [0x38] = KEY_STOP,
> + [0x39] = KEY_PAUSE,
> + [0x40] = KEY_CONTEXT_MENU, /* pop up/menu */
> + [0x60] = KEY_FRAMEBACK, /* slow/step back */
> + [0x61] = KEY_FRAMEFORWARD, /* slow/step forward */
> + [0x63] = KEY_SUBTITLE,
> + [0x64] = KEY_AUDIO,
> + [0x65] = KEY_ANGLE,
> + [0x70] = KEY_INFO, /* display */
> + [0x80] = KEY_BLUE,
> + [0x81] = KEY_RED,
> + [0x82] = KEY_GREEN,
> + [0x83] = KEY_YELLOW,
> +};
> +
> +static __u8 *ps3remote_fixup(struct hid_device *hdev, __u8 *rdesc,
> + unsigned int *rsize)
> +{
> + *rsize = sizeof(ps3remote_rdesc);
> + return ps3remote_rdesc;
> +}
> +
> +static int ps3remote_mapping(struct hid_device *hdev, struct hid_input *hi,
> + struct hid_field *field, struct hid_usage *usage,
> + unsigned long **bit, int *max)
> +{
> + unsigned int key = usage->hid & HID_USAGE;
> +
> + if ((usage->hid & HID_USAGE_PAGE) != HID_UP_BUTTON)
> + return -1;
> +
> + switch (usage->collection_index) {
> + case 1:
> + if (key >= ARRAY_SIZE(ps3remote_keymap_joypad_buttons))
> + return -1;
> +
> + key = ps3remote_keymap_joypad_buttons[key];
> + if (!key)
> + return -1;
> + break;
> + case 2:
> + if (key >= ARRAY_SIZE(ps3remote_keymap_remote_buttons))
> + return -1;
> +
> + key = ps3remote_keymap_remote_buttons[key];
> + if (!key)
> + return -1;
> + break;
> + default:
> + return -1;
> + }
> +
> + hid_map_usage_clear(hi, usage, bit, max, EV_KEY, key);
> + return 1;
> +}
> +
> +static const struct hid_device_id ps3remote_devices[] = {
> + /* PS3 BD Remote Control */
> + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_BDREMOTE) },
> + /* Logitech Harmony Adapter for PS3 */
> + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3) },
> + { }
> +};
> +MODULE_DEVICE_TABLE(hid, ps3remote_devices);
> +
> +static struct hid_driver ps3remote_driver = {
> + .name = "ps3_remote",
> + .id_table = ps3remote_devices,
> + .report_fixup = ps3remote_fixup,
> + .input_mapping = ps3remote_mapping,
> +};
> +
> +static int __init ps3remote_init(void)
> +{
> + return hid_register_driver(&ps3remote_driver);
> +}
> +
> +static void __exit ps3remote_exit(void)
> +{
> + hid_unregister_driver(&ps3remote_driver);
> +}
> +
> +module_init(ps3remote_init);
> +module_exit(ps3remote_exit);
> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("David Dillow <dave@thedillows.org>, Antonio Ospite <ospite@studenti.unina.it>");
> --
> 1.7.10.4
>
>
--
Antonio Ospite
http://ao2.it
A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
^ permalink raw reply
* Re: [PATCH 1/2] mgmt-api: Add missing error code descriptions
From: Johan Hedberg @ 2012-10-01 8:17 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1349077763-26830-1-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
On Mon, Oct 01, 2012, Szymon Janc wrote:
> ---
> doc/mgmt-api.txt | 2 ++
> 1 file changed, 2 insertions(+)
Both patches have been applied. Thanks.
Johan
^ permalink raw reply
* Re: [RFC] Convert storage to use per-remote device directories
From: Johan Hedberg @ 2012-10-01 8:16 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: Frederic Danis, linux-bluetooth@vger.kernel.org
In-Reply-To: <1348842803.13371.25.camel@aeonflux>
Hi Marcel,
On Fri, Sep 28, 2012, Marcel Holtmann wrote:
> > Here is my proposal for new storage directory structure using ini-file
> > format.
> >
> > Each adapter directory (/var/lib/bluetooth/<adapter address>/) will
> > contain a config file for the local adapter and one directory per remote
> > device.
> > The adapter config file just need to be converted to ini-file format
> > with only 1 group called [adapter].
> >
> > Each of remote device directories' name will be based on remote device
> > address and address type (address#type).
> > This directory will contain a config file with remote device infos and a
> > linkkey file.
> > Remote device config file will include a [device] group with general
> > device infos (name, alias, profiles or services list, ...), and groups
> > named by profile uuid (or service uuid) with related infos.
> >
> > So the directory structure should be:
> > /var/lib/bluetooth/<adapter address>/
> > ./config
> > ./<remote device address#type>/
> > ./config
> > ./linkkey
> > ./<remote device address#type>/
> > ./config
> > ./linkkey
> > ...
>
> why do we care about the address type here? Can we actually have a
> different link key for BR/EDR and for LE? Right now it is really only
> one choice on how to use that remote device. If it is dual-mode, then we
> use BR/EDR and if it is single-mode we use LE.
I think the idea here was to avoid potential (though unlikely)
collisions of a static random address of device A and a public address
of device B. However, thinking about it, is such a collision actually
possible considering that the two most significant bits of a static
random address must be 1. I'd imagine that the Core spec. writers would
have tried to make sure that this will not clash with any OUI's.
In any case we do at least need to have the address type info somewhere
in the device-specific directory so bluetoothd knows how to connect to
the device.
Johan
^ permalink raw reply
* Re: [PATCH v4] HID: Add support for Sony PS3 BD Remote Control
From: Jiri Kosina @ 2012-10-01 8:12 UTC (permalink / raw)
To: Antonio Ospite
Cc: David Dillow, linux-bluetooth, David Herrmann,
Luiz Augusto von Dentz, Bastien Nocera, linux-input
In-Reply-To: <1348606947-3055-1-git-send-email-ospite@studenti.unina.it>
On Tue, 25 Sep 2012, Antonio Ospite wrote:
> From: David Dillow <dave@thedillows.org>
>
> The Sony PS3 Blue-ray Disc Remote Control used to be supported by the
> BlueZ project's user space, but the code that handled it was recently
> removed as its functionality conflicted with a real HSP implementation
> and the mapping was thought to be better handled in the kernel. This is
> a port of the mapping logic from the fakehid driver by Marcel Holtmann
> to the in-kernel HID layer.
>
> We also add support for the Logitech Harmony Adapter for PS3, which
> emulates the BD Remote.
>
> Signed-off-by: David Dillow <dave@thedillows.org>
> Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Applied, thanks.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply
* Re: question: what is the git repository of linux bluetooth (kernel) for submitting pathces ? Kevin EOM
From: Andrei Emeltchenko @ 2012-10-01 7:52 UTC (permalink / raw)
To: Kevin Wilson; +Cc: linux-bluetooth
In-Reply-To: <CAGXs5wXFnr-Rc26JQ0+TuRGWinwUHM3GyWZvp37h7F6tV4UVcQ@mail.gmail.com>
Hi Kevin,
origin
git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git
Best regards
Andrei Emeltchenko
On Sun, Sep 30, 2012 at 11:02:26AM +0200, Kevin Wilson wrote:
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH 2/2] mgmt: Fix error code passed to bonding_complete in disconnect_complete
From: Szymon Janc @ 2012-10-01 7:49 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349077763-26830-1-git-send-email-szymon.janc@tieto.com>
bonding_complete expects mgmt status code not hci error code.
---
src/mgmt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/mgmt.c b/src/mgmt.c
index 2472173..e368b8a 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -1166,7 +1166,7 @@ static void disconnect_complete(int sk, uint16_t index, uint8_t status,
btd_event_disconn_complete(&info->bdaddr, &rp->addr.bdaddr);
- bonding_complete(info, &rp->addr.bdaddr, HCI_CONNECTION_TERMINATED);
+ bonding_complete(info, &rp->addr.bdaddr, MGMT_STATUS_DISCONNECTED);
}
static void pair_device_complete(int sk, uint16_t index, uint8_t status,
--
1.7.9.5
^ permalink raw reply related
* [PATCH 1/2] mgmt-api: Add missing error code descriptions
From: Szymon Janc @ 2012-10-01 7:49 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
---
doc/mgmt-api.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index 3d0b875..202c055 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
@@ -54,6 +54,8 @@ and Command Complete events:
0x0D Invalid Parameters
0x0E Disconnected
0x0F Not Powered
+0x10 Cancelled
+0x11 Invalid Index
Read Management Version Information Command
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH] client: Add Message.MarkAsRead and Message.MarkAsDeleted implementation and documentation.
From: Venkateswaran, Srinivasa Ragavan @ 2012-10-01 7:14 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Srinivasa Ragavan
In-Reply-To: <5069401d.e758420a.0377.6163@mx.google.com>
On Mon, Oct 1, 2012 at 12:33 PM,
<srinivasa.ragavan.venkateswaran@intel.com> wrote:
> From: Srinivasa Ragavan <srinivasa.ragavan.venkateswaran@intel.com>
>
> ---
> client/map.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++-
> client/transfer.c | 3 +-
> doc/client-api.txt | 11 +++++
> 3 files changed, 127 insertions(+), 2 deletions(-)
Ignore this patch, this has a partial patch I was trying from Luiz.
Sorry for the mess, sent an updated one.
-Srini.
^ permalink raw reply
* [PATCH] client: Add Message.MarkAsRead and Message.MarkAsDeleted implementation and documentation.
From: Srinivasa Ragavan @ 2012-10-01 7:10 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Srinivasa Ragavan
---
client/map.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++
client/transfer.c | 3 +-
doc/client-api.txt | 11 ++++++
3 files changed, 125 insertions(+), 1 deletion(-)
diff --git a/client/map.c b/client/map.c
index 4f07fcb..69a9a21 100644
--- a/client/map.c
+++ b/client/map.c
@@ -26,7 +26,9 @@
#include <errno.h>
#include <string.h>
+#include <fcntl.h>
#include <glib.h>
+#include <glib/gstdio.h>
#include <gdbus.h>
#include "dbus.h"
@@ -36,6 +38,8 @@
#include "transfer.h"
#include "session.h"
#include "driver.h"
+#include "src/map_ap.h"
+#include "gobex/gobex-apparam.h"
#define OBEX_MAS_UUID \
"\xBB\x58\x2B\x40\x42\x0C\x11\xDB\xB0\xDE\x08\x00\x20\x0C\x9A\x66"
@@ -46,6 +50,10 @@
#define ERROR_INTERFACE "org.bluez.obex.Error"
#define MAS_UUID "00001132-0000-1000-8000-00805f9b34fb"
+#define STATUS_READ 0
+#define STATUS_DELETE 1
+#define FILLER_BYTE 0x30
+
struct map_data {
struct obc_session *session;
DBusMessage *msg;
@@ -72,6 +80,7 @@ struct map_msg {
uint64_t size;
char *status;
uint8_t flags;
+ DBusMessage *msg;
};
struct map_parser {
@@ -284,12 +293,115 @@ fail:
return reply;
}
+static void set_message_flag_cb(struct obc_session *session,
+ struct obc_transfer *transfer,
+ GError *err, void *user_data)
+{
+ struct map_msg *msg = user_data;
+ DBusMessage *reply;
+ char *target_file;
+
+ if (err != NULL) {
+ reply = g_dbus_create_error(msg->msg,
+ ERROR_INTERFACE ".Failed",
+ "%s", err->message);
+ goto done;
+ }
+
+ /* Get rid of the tmp file */
+ target_file = g_build_filename (g_get_tmp_dir(), "bt-msg-status", NULL);
+ g_unlink (target_file);
+ g_free (target_file);
+
+ reply = dbus_message_new_method_return(msg->msg);
+ if (reply == NULL)
+ return;
+
+done:
+ g_dbus_send_message(conn, reply);
+ dbus_message_unref(msg->msg);
+ msg->msg = NULL;
+}
+
+static DBusMessage *map_msg_mark_flag (DBusConnection *connection,
+ DBusMessage *message, int op, void *user_data)
+{
+ struct map_msg *msg = user_data;
+ struct obc_transfer *transfer;
+ char *target_file;
+ gboolean status;
+ GError *err = NULL;
+ DBusMessage *reply;
+ GObexApparam *apparam;
+ guint8 buf[6];
+ gsize len;
+ char contents[2];
+
+ if (dbus_message_get_args(message, NULL,
+ DBUS_TYPE_BOOLEAN, &status,
+ DBUS_TYPE_INVALID) == FALSE)
+ return g_dbus_create_error(message,
+ ERROR_INTERFACE ".InvalidArguments", NULL);
+
+ target_file = g_build_filename (g_get_tmp_dir(), "bt-msg-status", NULL);
+
+ contents[0] = FILLER_BYTE;
+ contents[1] = '\0';
+
+ transfer = obc_transfer_put("x-bt/messageStatus", msg->handle, target_file,
+ contents, sizeof(contents), &err);
+ if (transfer == NULL)
+ goto fail;
+
+ apparam = g_obex_apparam_set_uint8(NULL, MAP_AP_STATUSINDICATOR,
+ op);
+ apparam = g_obex_apparam_set_uint8(apparam, MAP_AP_STATUSVALUE,
+ status);
+ len = g_obex_apparam_encode(apparam, buf, sizeof(buf));
+
+ obc_transfer_set_params(transfer, buf, len);
+
+ g_obex_apparam_free(apparam);
+
+ if (!obc_session_queue(msg->data->session, transfer, set_message_flag_cb, msg, &err))
+ goto fail;
+
+ msg->msg = dbus_message_ref (message);
+
+ return NULL;
+
+fail:
+ reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s",
+ err->message);
+ g_free (target_file);
+ g_error_free(err);
+ return reply;
+}
+
+static DBusMessage *map_msg_mark_deleted (DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ return map_msg_mark_flag (connection, message, STATUS_DELETE, user_data);
+}
+
+static DBusMessage *map_msg_mark_read (DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ return map_msg_mark_flag (connection, message, STATUS_READ, user_data);
+}
+
static const GDBusMethodTable map_msg_methods[] = {
{ GDBUS_METHOD("Get",
GDBUS_ARGS({ "targetfile", "s" }),
GDBUS_ARGS({ "transfer", "o" },
{ "properties", "a{sv}" }),
map_msg_get) },
+ { GDBUS_ASYNC_METHOD("MarkAsRead",
+ GDBUS_ARGS({ "read", "b" }), NULL,
+ map_msg_mark_read) },
+ { GDBUS_ASYNC_METHOD("MarkAsDeleted",
+ GDBUS_ARGS({ "deleted", "b" }), NULL,
+ map_msg_mark_deleted) },
{ }
};
diff --git a/client/transfer.c b/client/transfer.c
index e9fabfb..0040f74 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -416,7 +416,7 @@ struct obc_transfer *obc_transfer_put(const char *type, const char *name,
if (contents != NULL) {
ssize_t w;
- if (!transfer_open(transfer, O_RDWR, 0, err))
+ if (!transfer_open(transfer, O_RDWR|O_CREAT|O_TRUNC, 0, err))
goto fail;
w = write(transfer->fd, contents, size);
@@ -432,6 +432,7 @@ struct obc_transfer *obc_transfer_put(const char *type, const char *name,
"Writing all contents to file failed");
goto fail;
}
+ lseek(transfer->fd, 0, SEEK_SET);
} else {
if (!transfer_open(transfer, O_RDONLY, 0, err))
goto fail;
diff --git a/doc/client-api.txt b/doc/client-api.txt
index f447789..aa98399 100644
--- a/doc/client-api.txt
+++ b/doc/client-api.txt
@@ -471,6 +471,17 @@ Methods object, dict Get(string targetfile)
The properties of this transfer are also returned along
with the object path, to avoid a call to GetProperties.
+ void MarkAsRead(boolean read)
+
+ Mark the message as read or unread depending on the *read*
+ flag.
+
+ void MarkAsDeleted(boolean deleted)
+
+ Mark the message as deleted or undeleted depending on the
+ *deleted* flag.
+
+
Transfer hierarchy
==================
--
1.7.10.4
^ permalink raw reply related
* [PATCH] client: Add Message.MarkAsRead and Message.MarkAsDeleted implementation and documentation.
From: srinivasa.ragavan.venkateswaran @ 2012-10-01 7:03 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Srinivasa Ragavan
From: Srinivasa Ragavan <srinivasa.ragavan.venkateswaran@intel.com>
---
client/map.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++-
client/transfer.c | 3 +-
doc/client-api.txt | 11 +++++
3 files changed, 127 insertions(+), 2 deletions(-)
diff --git a/client/map.c b/client/map.c
index 4f07fcb..a08d272 100644
--- a/client/map.c
+++ b/client/map.c
@@ -26,7 +26,9 @@
#include <errno.h>
#include <string.h>
+#include <fcntl.h>
#include <glib.h>
+#include <glib/gstdio.h>
#include <gdbus.h>
#include "dbus.h"
@@ -36,6 +38,8 @@
#include "transfer.h"
#include "session.h"
#include "driver.h"
+#include "src/map_ap.h"
+#include "gobex/gobex-apparam.h"
#define OBEX_MAS_UUID \
"\xBB\x58\x2B\x40\x42\x0C\x11\xDB\xB0\xDE\x08\x00\x20\x0C\x9A\x66"
@@ -46,6 +50,10 @@
#define ERROR_INTERFACE "org.bluez.obex.Error"
#define MAS_UUID "00001132-0000-1000-8000-00805f9b34fb"
+#define STATUS_READ 0
+#define STATUS_DELETE 1
+#define FILLER_BYTE 0x30
+
struct map_data {
struct obc_session *session;
DBusMessage *msg;
@@ -72,6 +80,7 @@ struct map_msg {
uint64_t size;
char *status;
uint8_t flags;
+ DBusMessage *msg;
};
struct map_parser {
@@ -284,12 +293,116 @@ fail:
return reply;
}
+static void set_message_flag_cb(struct obc_session *session,
+ struct obc_transfer *transfer,
+ GError *err, void *user_data)
+{
+ struct map_msg *msg = user_data;
+ DBusMessage *reply;
+ char *target_file;
+
+ if (err != NULL) {
+ reply = g_dbus_create_error(msg->msg,
+ ERROR_INTERFACE ".Failed",
+ "%s", err->message);
+ goto done;
+ }
+
+ /* Get rid of the tmp file */
+ target_file = g_build_filename (g_get_tmp_dir(), "bt-msg-status", NULL);
+ g_unlink (target_file);
+ g_free (target_file);
+
+ reply = dbus_message_new_method_return(msg->msg);
+ if (reply == NULL)
+ return;
+
+done:
+ g_dbus_send_message(conn, reply);
+ dbus_message_unref(msg->msg);
+ msg->msg = NULL;
+}
+
+static DBusMessage *map_msg_mark_flag (DBusConnection *connection,
+ DBusMessage *message, int op, void *user_data)
+{
+ struct map_msg *msg = user_data;
+ struct obc_transfer *transfer;
+ char *target_file;
+ gboolean status;
+ GError *err = NULL;
+ DBusMessage *reply;
+ GObexApparam *apparam;
+ guint8 buf[6];
+ gsize len;
+ char contents[2];
+
+ if (dbus_message_get_args(message, NULL,
+ DBUS_TYPE_BOOLEAN, &status,
+ DBUS_TYPE_INVALID) == FALSE)
+ return g_dbus_create_error(message,
+ ERROR_INTERFACE ".InvalidArguments", NULL);
+
+ target_file = g_build_filename (g_get_tmp_dir(), "bt-msg-status", NULL);
+
+ contents[0] = FILLER_BYTE;
+ contents[1] = '\0';
+
+ transfer = obc_transfer_put("x-bt/messageStatus", msg->handle, target_file,
+ contents, sizeof(contents), &err);
+ if (transfer == NULL)
+ goto fail;
+
+ apparam = g_obex_apparam_set_uint8(NULL, MAP_AP_STATUSINDICATOR,
+ op);
+ apparam = g_obex_apparam_set_uint8(apparam, MAP_AP_STATUSVALUE,
+ status);
+ len = g_obex_apparam_encode(apparam, buf, sizeof(buf));
+
+ obc_transfer_set_params(transfer, buf, len);
+
+ g_obex_apparam_free(apparam);
+
+ if (!obc_session_queue(msg->data->session, transfer, set_message_flag_cb, msg, &err))
+ goto fail;
+
+ msg->msg = dbus_message_ref (message);
+
+ return NULL;
+
+fail:
+ reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s",
+ err->message);
+ g_free (target_file);
+ g_error_free(err);
+ return reply;
+}
+
+static DBusMessage *map_msg_mark_deleted (DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ return map_msg_mark_flag (connection, message, STATUS_DELETE, user_data);
+}
+
+static DBusMessage *map_msg_mark_read (DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ return map_msg_mark_flag (connection, message, STATUS_READ, user_data);
+}
+
static const GDBusMethodTable map_msg_methods[] = {
{ GDBUS_METHOD("Get",
- GDBUS_ARGS({ "targetfile", "s" }),
+ GDBUS_ARGS({ "targetfile", "s" },
+ { "attachment", "b" }),
GDBUS_ARGS({ "transfer", "o" },
{ "properties", "a{sv}" }),
map_msg_get) },
+ { GDBUS_ASYNC_METHOD("MarkAsRead",
+ GDBUS_ARGS({ "read", "b" }), NULL,
+ map_msg_mark_read) },
+ { GDBUS_ASYNC_METHOD("MarkAsDeleted",
+ GDBUS_ARGS({ "deleted", "b" }), NULL,
+ map_msg_mark_deleted) },
{ }
};
diff --git a/client/transfer.c b/client/transfer.c
index e9fabfb..0040f74 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -416,7 +416,7 @@ struct obc_transfer *obc_transfer_put(const char *type, const char *name,
if (contents != NULL) {
ssize_t w;
- if (!transfer_open(transfer, O_RDWR, 0, err))
+ if (!transfer_open(transfer, O_RDWR|O_CREAT|O_TRUNC, 0, err))
goto fail;
w = write(transfer->fd, contents, size);
@@ -432,6 +432,7 @@ struct obc_transfer *obc_transfer_put(const char *type, const char *name,
"Writing all contents to file failed");
goto fail;
}
+ lseek(transfer->fd, 0, SEEK_SET);
} else {
if (!transfer_open(transfer, O_RDONLY, 0, err))
goto fail;
diff --git a/doc/client-api.txt b/doc/client-api.txt
index f447789..aa98399 100644
--- a/doc/client-api.txt
+++ b/doc/client-api.txt
@@ -471,6 +471,17 @@ Methods object, dict Get(string targetfile)
The properties of this transfer are also returned along
with the object path, to avoid a call to GetProperties.
+ void MarkAsRead(boolean read)
+
+ Mark the message as read or unread depending on the *read*
+ flag.
+
+ void MarkAsDeleted(boolean deleted)
+
+ Mark the message as deleted or undeleted depending on the
+ *deleted* flag.
+
+
Transfer hierarchy
==================
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH BlueZ] build: Fix out-of-tree builds
From: Marcel Holtmann @ 2012-10-01 6:38 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <1348861411-31555-1-git-send-email-anderson.lizardo@openbossa.org>
Hi Anderson,
> This commit makes a few changes that mostly affect "out-of-tree" builds:
>
> * Fix symlink creation for profiles/sap/sap.c (should use build
> directory, not source tree).
> * Remove useless -I$(builddir)/{tools,health} directives (these
> build directories do not contain any headers).
> * Add -I$(srcdir)/profiles/sap (necessary because sap.c is a symlink
> into the build directory, and refers to headers in the source tree).
>
> Tested with:
>
> ./bootstrap
> mkdir build
> cd build
> ../configure [...]
> ---
> Makefile.am | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/Makefile.am b/Makefile.am
> index c27eb01..257c18a 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -405,10 +405,10 @@ AM_CFLAGS += @DBUS_CFLAGS@ @GLIB_CFLAGS@
> INCLUDES = -I$(builddir)/lib -I$(builddir)/src -I$(srcdir)/src \
> -I$(srcdir)/audio -I$(srcdir)/sbc -I$(srcdir)/gdbus \
> -I$(srcdir)/attrib -I$(srcdir)/btio -I$(srcdir)/tools \
> - -I$(builddir)/tools -I$(srcdir)/monitor
> + -I$(srcdir)/monitor
>
> -if MCAP
> -INCLUDES += -I$(builddir)/health
> +if SAPPLUGIN
> +INCLUDES += -I$(srcdir)/profiles/sap
> endif
>
> unit_objects =
> @@ -447,7 +447,7 @@ audio/telephony.c: audio/@TELEPHONY_DRIVER@
> $(AM_V_GEN)$(LN_S) $(abs_top_builddir)/$< $@
>
> profiles/sap/sap.c: profiles/sap/@SAP_DRIVER@
> - $(AM_V_GEN)$(LN_S) $(abs_top_srcdir)/$< $@
> + $(AM_V_GEN)$(LN_S) $(abs_top_builddir)/$< $@
>
> profiles/input/suspend.c: profiles/input/@HOG_SUSPEND_DRIVER@
> $(AM_V_GEN)$(LN_S) $(abs_top_srcdir)/$< $@
personally I am no longer a big fan of these selection of a specific
driver. We should be able to build all of them and make the selection at
runtime. So there is more work needed here.
Regards
Marcel
^ permalink raw reply
* [PATCH -next] bluetooth: fix printk format warnings
From: Randy Dunlap @ 2012-10-01 1:44 UTC (permalink / raw)
To: Stephen Rothwell
Cc: linux-next, LKML, Marcel Holtmann, Gustavo Padovan, Johan Hedberg,
linux-bluetooth
In-Reply-To: <20120928165112.6b0f5328b72428799c3f995d@canb.auug.org.au>
From: Randy Dunlap <rdunlap@xenotime.net>
Fix printk format warnings in net/bluetooth/:
net/bluetooth/hci_event.c:886:3: warning: format '%ld' expects type 'long int', but argument 2 has type 'size_t'
net/bluetooth/hci_event.c:886:3: warning: format '%ld' expects type 'long int', but argument 3 has type 'size_t'
net/bluetooth/a2mp.c:386:2: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'unsigned int'
Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
M: Marcel Holtmann <marcel@holtmann.org>
M: Gustavo Padovan <gustavo@padovan.org>
M: Johan Hedberg <johan.hedberg@gmail.com>
L: linux-bluetooth@vger.kernel.org
---
net/bluetooth/a2mp.c | 2 +-
net/bluetooth/hci_event.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
--- linux-next-20120928.orig/net/bluetooth/a2mp.c
+++ linux-next-20120928/net/bluetooth/a2mp.c
@@ -383,7 +383,7 @@ static int a2mp_getampassoc_rsp(struct a
if (len < sizeof(*rsp))
return -EINVAL;
- BT_DBG("id %d status 0x%2.2x assoc len %lu", rsp->id, rsp->status,
+ BT_DBG("id %d status 0x%2.2x assoc len %zu", rsp->id, rsp->status,
len - sizeof(*rsp));
if (rsp->status)
--- linux-next-20120928.orig/net/bluetooth/hci_event.c
+++ linux-next-20120928/net/bluetooth/hci_event.c
@@ -883,7 +883,7 @@ static void hci_cc_read_local_amp_assoc(
rem_len = __le16_to_cpu(rp->rem_len);
if (rem_len > frag_len) {
- BT_DBG("frag_len %ld rem_len %ld", frag_len, rem_len);
+ BT_DBG("frag_len %zu rem_len %zu", frag_len, rem_len);
memcpy(assoc->data + assoc->offset, rp->frag, frag_len);
assoc->offset += frag_len;
^ permalink raw reply
* Re: [PATCH v4 01/10] battery: Add generic device battery documentation
From: Johan Hedberg @ 2012-09-30 10:56 UTC (permalink / raw)
To: Chen Ganir; +Cc: linux-bluetooth
In-Reply-To: <5067ED60.1080202@ti.com>
Hi Chen,
On Sun, Sep 30, 2012, Chen Ganir wrote:
> >On Mon, Sep 24, 2012, chen.ganir@ti.com wrote:
> >>+BlueZ D-Bus Battery API description
> >>+****************************************
> >
> >Please keep the "underline" consistent with the length of the text above
> >it.
> >
> >>+ Texas Instruments, Inc. <chen.ganir@ti.com>
> >
> >What's this supposed to be? If you want a copyright statement here then
> >make it of the proper format. Author info is not needed as we have the
> >AUTHORS file and the commit history.
> >
> Would you please specify what is the proper copyright message format
> ? doc/adapter-api.txt, doc/health-api.txt have two different styles.
> doc/oob-api.txt has a third style (AUTHOR <author@email> for
> COMPANY),
> doc/media-api.txt for example does not have any copyright
> information. In addition - you say author information is not
> required, yet all other copyright messages contain this. Is this a
> new policy ? If so, please specify the proper copyright message.
How about git grep "Texas Instruments"? None of the entries contain
author information so your assertion makes it look like you didn't
really dig too deep. The policy has always been to keep author info in
AUTHORS and the commit history and have copyright statements only for
the sake of copyright information. Exceptions do of course slip through
as the maintainers are humans and not robots ;)
Ultimately you need to ask your employer for what kind of copyright
statement you should use, e.g. some prefer to have a "All rights
reserved" at the end whereas others don't care.
> >>+ array{object} Batteries [readonly]
> >
> >I guess you should mark this with [experimental] since it'll be removed
> >with the advent of ObjectManager.
> >
> What is the difference between the Batteries property and the
> services or UUIDs property in device-api.txt ? Should all of them
> get marked with experimental ?
The Services property will probably be removed for 5.0 but the UUIDs
will stay (not sure why you brought it up anyway?). Just mark this new
property as experimental since it'll likely be gone by the time 5.0 goes
out.
Johan
^ permalink raw reply
* question: what is the git repository of linux bluetooth (kernel) for submitting pathces ? Kevin EOM
From: Kevin Wilson @ 2012-09-30 9:02 UTC (permalink / raw)
To: linux-bluetooth
^ permalink raw reply
* Re: [PATCH v4 01/10] battery: Add generic device battery documentation
From: Chen Ganir @ 2012-09-30 6:57 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <20120928105937.GA14450@x220>
Johan,
On 09/28/2012 12:59 PM, Johan Hedberg wrote:
> Hi Chen,
>
> On Mon, Sep 24, 2012, chen.ganir@ti.com wrote:
>> +BlueZ D-Bus Battery API description
>> +****************************************
>
> Please keep the "underline" consistent with the length of the text above
> it.
>
>> + Texas Instruments, Inc. <chen.ganir@ti.com>
>
> What's this supposed to be? If you want a copyright statement here then
> make it of the proper format. Author info is not needed as we have the
> AUTHORS file and the commit history.
>
Would you please specify what is the proper copyright message format ?
doc/adapter-api.txt, doc/health-api.txt have two different styles.
doc/oob-api.txt has a third style (AUTHOR <author@email> for COMPANY),
doc/media-api.txt for example does not have any copyright information.
In addition - you say author information is not required, yet all other
copyright messages contain this. Is this a new policy ? If so, please
specify the proper copyright message.
>> +Device Battery hierarchy
>> +=====================================
>
> Same thing with the consistency of the "underline"
>
Ok.
>> +Service org.bluez
>> +Interface org.bluez.Battery
>> +Object path [variable prefix]/{hci0,..}/dev_XX_XX_XX_XX_XX_XX/BATTYYYY
>> +YYYY is numeric value between 0 and 9999.
>
> I don't think you need a separate comment for the "YYY". We don't have
> that for the "XX" stuff either.
>
Ok.
>> + array{object} Batteries [readonly]
>
> I guess you should mark this with [experimental] since it'll be removed
> with the advent of ObjectManager.
>
What is the difference between the Batteries property and the services
or UUIDs property in device-api.txt ? Should all of them get marked with
experimental ?
> Johan
>
--
BR,
Chen Ganir
Texas Instruments
^ permalink raw reply
* Re: scan fails
From: Vinicius Costa Gomes @ 2012-09-29 21:12 UTC (permalink / raw)
To: Kevin Wilson; +Cc: linux-bluetooth
In-Reply-To: <CAGXs5wVu=deRjaKwh0wLKCPy+Pqf3F9rH4pMyCCPCM_iA-yNeg@mail.gmail.com>
Hi Kevin,
On 22:29 Sat 29 Sep, Kevin Wilson wrote:
> Hi,
> Sorry , just forget to mention that in reset I also
> get an error:
> hciconfig hci0 reset
> Can't init device hci0: Connection timed out (110)
Can you install hcidump (IIRC in Fedora it is called bluez-hcidump) and send
the log, pass '-Xt' to it please, when doing 'hciconfig hci0 up'?
Right now, I am thinking that our initialization procedure sends a command
that your device doesn't support, probably because we expect a newer Bluetooth
version than your device is.
> kevin
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Cheers,
--
Vinicius
^ permalink raw reply
* Re: scan fails
From: Kevin Wilson @ 2012-09-29 20:29 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <CAGXs5wX2N7P5=_ZwPPUw-kUxGjhpMB2xyfWHmHOUM99XggvQ2Q@mail.gmail.com>
Hi,
Sorry , just forget to mention that in reset I also
get an error:
hciconfig hci0 reset
Can't init device hci0: Connection timed out (110)
kevin
^ permalink raw reply
* scan fails
From: Kevin Wilson @ 2012-09-29 20:28 UTC (permalink / raw)
To: linux-bluetooth
Hi,
I have fedora 17.
When I try:
hciconfig hci0 up
I get:
Can't init device hci0: Connection timed out (110)
lsusb DOES recognize the USB BT
lsusb
....
Bus 004 Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd
Bluetooth Dongle (HCI mode)
^ permalink raw reply
* [PATCH BlueZ] gatt: Remove offset parameter from gatt_read_char
From: Jefferson Delfes @ 2012-09-28 20:34 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jefferson Delfes
The Core spec allows to implement Read Long Characteristic Value as a
Read Request, followed by zero or more Read Blob Requests, therefore the
offset parameter is unnecessary and is always 0 for normal use.
---
attrib/client.c | 12 ++++++------
attrib/gatt.c | 15 ++++-----------
attrib/gatt.h | 4 ++--
attrib/gatttool.c | 5 +----
attrib/interactive.c | 16 ++--------------
profiles/deviceinfo/deviceinfo.c | 2 +-
profiles/heartrate/heartrate.c | 2 +-
profiles/input/hog_device.c | 12 ++++++------
profiles/proximity/monitor.c | 4 ++--
profiles/thermometer/thermometer.c | 8 ++++----
10 files changed, 29 insertions(+), 51 deletions(-)
diff --git a/attrib/client.c b/attrib/client.c
index 2423fad..ece16bf 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -782,7 +782,7 @@ static void update_char_desc(guint8 status, const guint8 *pdu, guint16 len,
if (bt_io_set(io, NULL,
BT_IO_OPT_SEC_LEVEL, level,
BT_IO_OPT_INVALID)) {
- gatt_read_char(gatt->attrib, current->handle, 0,
+ gatt_read_char(gatt->attrib, current->handle,
update_char_desc, current);
return;
}
@@ -833,7 +833,7 @@ static void update_char_value(guint8 status, const guint8 *pdu,
if (bt_io_set(io, NULL,
BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_HIGH,
BT_IO_OPT_INVALID)) {
- gatt_read_char(gatt->attrib, chr->handle, 0,
+ gatt_read_char(gatt->attrib, chr->handle,
update_char_value, current);
return;
}
@@ -894,12 +894,12 @@ static void descriptor_cb(guint8 status, const guint8 *pdu, guint16 plen,
if (uuid_desc16_cmp(&uuid, GATT_CHARAC_USER_DESC_UUID) == 0) {
query_list_append(gatt, qfmt);
- gatt_read_char(gatt->attrib, handle, 0, update_char_desc,
+ gatt_read_char(gatt->attrib, handle, update_char_desc,
qfmt);
} else if (uuid_desc16_cmp(&uuid, GATT_CHARAC_FMT_UUID) == 0) {
query_list_append(gatt, qfmt);
- gatt_read_char(gatt->attrib, handle, 0,
- update_char_format, qfmt);
+ gatt_read_char(gatt->attrib, handle, update_char_format,
+ qfmt);
} else
g_free(qfmt);
}
@@ -931,7 +931,7 @@ static void update_all_chars(gpointer data, gpointer user_data)
query_list_append(gatt, qvalue);
- gatt_read_char(gatt->attrib, chr->handle, 0, update_char_value, qvalue);
+ gatt_read_char(gatt->attrib, chr->handle, update_char_value, qvalue);
}
static DBusMessage *create_discover_char_reply(DBusMessage *msg, GSList *chars)
diff --git a/attrib/gatt.c b/attrib/gatt.c
index 6880e2d..882f3c1 100644
--- a/attrib/gatt.c
+++ b/attrib/gatt.c
@@ -481,8 +481,8 @@ done:
long_read->func(status, rpdu, rlen, long_read->user_data);
}
-guint gatt_read_char(GAttrib *attrib, uint16_t handle, uint16_t offset,
- GAttribResultFunc func, gpointer user_data)
+guint gatt_read_char(GAttrib *attrib, uint16_t handle, GAttribResultFunc func,
+ gpointer user_data)
{
uint8_t *buf;
size_t buflen;
@@ -501,16 +501,9 @@ guint gatt_read_char(GAttrib *attrib, uint16_t handle, uint16_t offset,
long_read->handle = handle;
buf = g_attrib_get_buffer(attrib, &buflen);
- if (offset > 0) {
- plen = enc_read_blob_req(long_read->handle, offset, buf,
- buflen);
- id = g_attrib_send(attrib, 0, ATT_OP_READ_BLOB_REQ, buf, plen,
- read_blob_helper, long_read, read_long_destroy);
- } else {
- plen = enc_read_req(handle, buf, buflen);
- id = g_attrib_send(attrib, 0, ATT_OP_READ_REQ, buf, plen,
+ plen = enc_read_req(handle, buf, buflen);
+ id = g_attrib_send(attrib, 0, ATT_OP_READ_REQ, buf, plen,
read_char_helper, long_read, read_long_destroy);
- }
if (id == 0)
g_free(long_read);
diff --git a/attrib/gatt.h b/attrib/gatt.h
index 6bb6f0f..3862011 100644
--- a/attrib/gatt.h
+++ b/attrib/gatt.h
@@ -75,8 +75,8 @@ guint gatt_discover_char(GAttrib *attrib, uint16_t start, uint16_t end,
bt_uuid_t *uuid, gatt_cb_t func,
gpointer user_data);
-guint gatt_read_char(GAttrib *attrib, uint16_t handle, uint16_t offset,
- GAttribResultFunc func, gpointer user_data);
+guint gatt_read_char(GAttrib *attrib, uint16_t handle, GAttribResultFunc func,
+ gpointer user_data);
guint gatt_write_char(GAttrib *attrib, uint16_t handle, uint8_t *value,
size_t vlen, GAttribResultFunc func,
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 416bb71..3b0ebbc 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -53,7 +53,6 @@ static int opt_end = 0xffff;
static int opt_handle = -1;
static int opt_mtu = 0;
static int opt_psm = 0;
-static int opt_offset = 0;
static gboolean opt_primary = FALSE;
static gboolean opt_characteristics = FALSE;
static gboolean opt_char_read = FALSE;
@@ -318,7 +317,7 @@ static gboolean characteristics_read(gpointer user_data)
return FALSE;
}
- gatt_read_char(attrib, opt_handle, opt_offset, char_read_cb, attrib);
+ gatt_read_char(attrib, opt_handle, char_read_cb, attrib);
return FALSE;
}
@@ -498,8 +497,6 @@ static GOptionEntry char_rw_options[] = {
{ "value", 'n' , 0, G_OPTION_ARG_STRING, &opt_value,
"Write characteristic value (required for write operation)",
"0x0001" },
- { "offset", 'o', 0, G_OPTION_ARG_INT, &opt_offset,
- "Offset to long read characteristic by handle", "N"},
{NULL},
};
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 38ac30f..8d9531f 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -503,7 +503,6 @@ static void cmd_char_desc(int argcp, char **argvp)
static void cmd_read_hnd(int argcp, char **argvp)
{
int handle;
- int offset = 0;
if (conn_state != STATE_CONNECTED) {
printf("Command failed: disconnected\n");
@@ -521,18 +520,7 @@ static void cmd_read_hnd(int argcp, char **argvp)
return;
}
- if (argcp > 2) {
- char *e;
-
- errno = 0;
- offset = strtol(argvp[2], &e, 0);
- if (errno != 0 || *e != '\0') {
- printf("Invalid offset: %s\n", argvp[2]);
- return;
- }
- }
-
- gatt_read_char(attrib, handle, offset, char_read_cb, attrib);
+ gatt_read_char(attrib, handle, char_read_cb, attrib);
}
static void cmd_read_uuid(int argcp, char **argvp)
@@ -759,7 +747,7 @@ static struct {
"Characteristics Discovery" },
{ "char-desc", cmd_char_desc, "[start hnd] [end hnd]",
"Characteristics Descriptor Discovery" },
- { "char-read-hnd", cmd_read_hnd, "<handle> [offset]",
+ { "char-read-hnd", cmd_read_hnd, "<handle>",
"Characteristics Value/Descriptor Read by handle" },
{ "char-read-uuid", cmd_read_uuid, "<UUID> [start hnd] [end hnd]",
"Characteristics Value/Descriptor Read by UUID" },
diff --git a/profiles/deviceinfo/deviceinfo.c b/profiles/deviceinfo/deviceinfo.c
index e7c442f..57652a0 100644
--- a/profiles/deviceinfo/deviceinfo.c
+++ b/profiles/deviceinfo/deviceinfo.c
@@ -113,7 +113,7 @@ static void read_pnpid_cb(guint8 status, const guint8 *pdu, guint16 len,
static void process_deviceinfo_char(struct characteristic *ch)
{
if (g_strcmp0(ch->attr.uuid, PNPID_UUID) == 0)
- gatt_read_char(ch->d->attrib, ch->attr.value_handle, 0,
+ gatt_read_char(ch->d->attrib, ch->attr.value_handle,
read_pnpid_cb, ch);
}
diff --git a/profiles/heartrate/heartrate.c b/profiles/heartrate/heartrate.c
index 4b95c5d..94d4b8d 100644
--- a/profiles/heartrate/heartrate.c
+++ b/profiles/heartrate/heartrate.c
@@ -355,7 +355,7 @@ static void discover_char_cb(GSList *chars, guint8 status, gpointer user_data)
} else if (g_strcmp0(c->uuid, BODY_SENSOR_LOCATION_UUID) == 0) {
DBG("Body Sensor Location supported");
- gatt_read_char(hr->attrib, c->value_handle, 0,
+ gatt_read_char(hr->attrib, c->value_handle,
read_sensor_location_cb, hr);
} else if (g_strcmp0(c->uuid,
HEART_RATE_CONTROL_POINT_UUID) == 0) {
diff --git a/profiles/input/hog_device.c b/profiles/input/hog_device.c
index d0912f5..a8cc568 100644
--- a/profiles/input/hog_device.c
+++ b/profiles/input/hog_device.c
@@ -233,12 +233,12 @@ static void discover_descriptor_cb(guint8 status, const guint8 *pdu,
break;
case GATT_REPORT_REFERENCE:
report = user_data;
- gatt_read_char(report->hogdev->attrib, handle, 0,
+ gatt_read_char(report->hogdev->attrib, handle,
report_reference_cb, report);
break;
case GATT_EXTERNAL_REPORT_REFERENCE:
hogdev = user_data;
- gatt_read_char(hogdev->attrib, handle, 0,
+ gatt_read_char(hogdev->attrib, handle,
external_report_reference_cb, hogdev);
break;
}
@@ -479,7 +479,7 @@ static void char_discovered_cb(GSList *chars, guint8 status, gpointer user_data)
report);
discover_descriptor(hogdev->attrib, chr, next, report);
} else if (bt_uuid_cmp(&uuid, &report_map_uuid) == 0) {
- gatt_read_char(hogdev->attrib, chr->value_handle, 0,
+ gatt_read_char(hogdev->attrib, chr->value_handle,
report_map_read_cb, hogdev);
discover_descriptor(hogdev->attrib, chr, next, hogdev);
} else if (bt_uuid_cmp(&uuid, &info_uuid) == 0)
@@ -492,13 +492,13 @@ static void char_discovered_cb(GSList *chars, guint8 status, gpointer user_data)
if (proto_mode_handle) {
hogdev->proto_mode_handle = proto_mode_handle;
- gatt_read_char(hogdev->attrib, proto_mode_handle, 0,
+ gatt_read_char(hogdev->attrib, proto_mode_handle,
proto_mode_read_cb, hogdev);
}
if (info_handle)
- gatt_read_char(hogdev->attrib, info_handle, 0,
- info_read_cb, hogdev);
+ gatt_read_char(hogdev->attrib, info_handle, info_read_cb,
+ hogdev);
}
static void output_written_cb(guint8 status, const guint8 *pdu,
diff --git a/profiles/proximity/monitor.c b/profiles/proximity/monitor.c
index a791916..6444a75 100644
--- a/profiles/proximity/monitor.c
+++ b/profiles/proximity/monitor.c
@@ -250,7 +250,7 @@ static void tx_power_handle_cb(GSList *characteristics, guint8 status,
DBG("Tx Power handle: 0x%04x", monitor->txpowerhandle);
- gatt_read_char(monitor->attrib, monitor->txpowerhandle, 0,
+ gatt_read_char(monitor->attrib, monitor->txpowerhandle,
tx_power_read_cb, monitor);
}
@@ -260,7 +260,7 @@ static void read_tx_power(struct monitor *monitor)
bt_uuid_t uuid;
if (monitor->txpowerhandle != 0) {
- gatt_read_char(monitor->attrib, monitor->txpowerhandle, 0,
+ gatt_read_char(monitor->attrib, monitor->txpowerhandle,
tx_power_read_cb, monitor);
return;
}
diff --git a/profiles/thermometer/thermometer.c b/profiles/thermometer/thermometer.c
index 77dcb26..3506ba7 100644
--- a/profiles/thermometer/thermometer.c
+++ b/profiles/thermometer/thermometer.c
@@ -393,8 +393,8 @@ static void process_thermometer_desc(struct descriptor *desc)
if (bt_uuid_cmp(&desc->uuid, &btuuid) == 0 && g_strcmp0(ch->attr.uuid,
MEASUREMENT_INTERVAL_UUID) == 0) {
- gatt_read_char(ch->t->attrib, desc->handle, 0,
- valid_range_desc_cb, desc);
+ gatt_read_char(ch->t->attrib, desc->handle, valid_range_desc_cb,
+ desc);
return;
}
@@ -508,10 +508,10 @@ static void process_thermometer_char(struct characteristic *ch)
change_property(ch->t, "Intermediate", &intermediate);
return;
} else if (g_strcmp0(ch->attr.uuid, TEMPERATURE_TYPE_UUID) == 0)
- gatt_read_char(ch->t->attrib, ch->attr.value_handle, 0,
+ gatt_read_char(ch->t->attrib, ch->attr.value_handle,
read_temp_type_cb, ch);
else if (g_strcmp0(ch->attr.uuid, MEASUREMENT_INTERVAL_UUID) == 0)
- gatt_read_char(ch->t->attrib, ch->attr.value_handle, 0,
+ gatt_read_char(ch->t->attrib, ch->attr.value_handle,
read_interval_cb, ch);
}
--
1.7.12.1
^ permalink raw reply related
* [RFC BlueZ v0 4/4] gatt: Remove Service Changed handle from storage
From: Claudio Takahasi @ 2012-09-28 20:01 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1348862494-16911-1-git-send-email-claudio.takahasi@openbossa.org>
This patch removes the Service Changed handle from the GATT storage when
the device is removed from the system.
---
profiles/gatt/gas.c | 26 +++++++++++++++++++++++++-
profiles/gatt/gas.h | 2 +-
profiles/gatt/manager.c | 2 +-
3 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index da6d555..6917ea8 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -130,6 +130,19 @@ static int read_ctp_handle(bdaddr_t *sba, bdaddr_t *dba, uint8_t bdaddr_type,
return 0;
}
+static int delete_ctp_handle(bdaddr_t *sba, bdaddr_t *dba, uint8_t bdaddr_type,
+ uint16_t uuid)
+{
+ char filename[PATH_MAX + 1], addr[18], key[25];
+
+ create_filename(filename, PATH_MAX, sba, "gatt");
+
+ ba2str(dba, addr);
+ snprintf(key, sizeof(key), "%17s#%hhu#0x%04x", addr, bdaddr_type, uuid);
+
+ return textfile_del(filename, key);
+}
+
static void gap_appearance_cb(guint8 status, const guint8 *pdu, guint16 plen,
gpointer user_data)
{
@@ -403,7 +416,7 @@ int gas_register(struct btd_device *device, struct att_range *gap,
return 0;
}
-void gas_unregister(struct btd_device *device)
+void gas_unregister(struct btd_device *device, gboolean purge)
{
struct gas *gas;
GSList *l;
@@ -414,5 +427,16 @@ void gas_unregister(struct btd_device *device)
gas = l->data;
devices = g_slist_remove(devices, gas);
+
+ if (gas->changed_handle && purge) {
+ bdaddr_t sba, dba;
+ uint8_t bdaddr_type;
+
+ adapter_get_address(device_get_adapter(gas->device), &sba);
+ device_get_address(gas->device, &dba, &bdaddr_type);
+ delete_ctp_handle(&sba, &dba, bdaddr_type,
+ GATT_CHARAC_SERVICE_CHANGED);
+ }
+
gas_free(gas);
}
diff --git a/profiles/gatt/gas.h b/profiles/gatt/gas.h
index 34853c7..436a543 100644
--- a/profiles/gatt/gas.h
+++ b/profiles/gatt/gas.h
@@ -22,4 +22,4 @@
int gas_register(struct btd_device *device, struct att_range *gap,
struct att_range *gatt);
-void gas_unregister(struct btd_device *device);
+void gas_unregister(struct btd_device *device, gboolean purge);
diff --git a/profiles/gatt/manager.c b/profiles/gatt/manager.c
index 94921d2..0392a23 100644
--- a/profiles/gatt/manager.c
+++ b/profiles/gatt/manager.c
@@ -70,7 +70,7 @@ static int gatt_driver_probe(struct btd_profile *p, struct btd_device *device,
static void gatt_driver_remove(struct btd_profile *p,
struct btd_device *device, gboolean purge)
{
- gas_unregister(device);
+ gas_unregister(device, purge);
}
static struct btd_profile gatt_profile = {
--
1.7.12
^ permalink raw reply related
* [RFC BlueZ v0 3/4] proximity: Store Bluetooth Address type
From: Claudio Takahasi @ 2012-09-28 20:01 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1348862494-16911-1-git-send-email-claudio.takahasi@openbossa.org>
This patch stores the remote Bluetooth Address type in the "proximity"
file. The textfile key is now "address#type#alert"
---
profiles/proximity/monitor.c | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/profiles/proximity/monitor.c b/profiles/proximity/monitor.c
index 4745791..77caf35 100644
--- a/profiles/proximity/monitor.c
+++ b/profiles/proximity/monitor.c
@@ -94,9 +94,9 @@ static inline int create_filename(char *buf, size_t size,
}
static int write_proximity_config(bdaddr_t *sba, bdaddr_t *dba,
- const char *alert, const char *level)
+ uint8_t bdaddr_type, const char *alert, const char *level)
{
- char filename[PATH_MAX + 1], addr[18], key[38];
+ char filename[PATH_MAX + 1], addr[18], key[40];
create_filename(filename, PATH_MAX, sba, "proximity");
@@ -104,7 +104,7 @@ static int write_proximity_config(bdaddr_t *sba, bdaddr_t *dba,
ba2str(dba, addr);
- snprintf(key, sizeof(key), "%17s#%s", addr, alert);
+ snprintf(key, sizeof(key), "%17s#%hhu#%s", addr, bdaddr_type, alert);
if (level)
return textfile_put(filename, key, level);
@@ -113,15 +113,15 @@ static int write_proximity_config(bdaddr_t *sba, bdaddr_t *dba,
}
static char *read_proximity_config(bdaddr_t *sba, bdaddr_t *dba,
- const char *alert)
+ uint8_t bdaddr_type, const char *alert)
{
- char filename[PATH_MAX + 1], addr[18], key[38];
+ char filename[PATH_MAX + 1], addr[18], key[40];
char *str, *strnew;
create_filename(filename, PATH_MAX, sba, "proximity");
ba2str(dba, addr);
- snprintf(key, sizeof(key), "%17s#%s", addr, alert);
+ snprintf(key, sizeof(key), "%17s#%hhu#%s", addr, bdaddr_type, alert);
str = textfile_caseget(filename, key);
if (str == NULL)
@@ -411,6 +411,7 @@ static DBusMessage *set_link_loss_alert(DBusConnection *conn, DBusMessage *msg,
struct monitor *monitor = data;
struct btd_device *device = monitor->device;
bdaddr_t sba, dba;
+ uint8_t bdaddr_type;
if (!level_is_valid(level))
return btd_error_invalid_args(msg);
@@ -422,9 +423,10 @@ static DBusMessage *set_link_loss_alert(DBusConnection *conn, DBusMessage *msg,
monitor->linklosslevel = g_strdup(level);
adapter_get_address(device_get_adapter(device), &sba);
- device_get_address(device, &dba, NULL);
+ device_get_address(device, &dba, &bdaddr_type);
- write_proximity_config(&sba, &dba, "LinkLossAlertLevel", level);
+ write_proximity_config(&sba, &dba, bdaddr_type, "LinkLossAlertLevel",
+ level);
if (monitor->attrib)
write_alert_level(monitor);
@@ -597,12 +599,14 @@ int monitor_register(struct btd_device *device,
const char *path = device_get_path(device);
struct monitor *monitor;
bdaddr_t sba, dba;
+ uint8_t bdaddr_type;
char *level;
adapter_get_address(device_get_adapter(device), &sba);
- device_get_address(device, &dba, NULL);
+ device_get_address(device, &dba, &bdaddr_type);
- level = read_proximity_config(&sba, &dba, "LinkLossAlertLevel");
+ level = read_proximity_config(&sba, &dba, bdaddr_type,
+ "LinkLossAlertLevel");
monitor = g_new0(struct monitor, 1);
monitor->device = btd_device_ref(device);
@@ -670,10 +674,12 @@ void monitor_unregister(struct btd_device *device, gboolean purge)
PROXIMITY_INTERFACE);
if (purge) {
bdaddr_t sba, dba;
+ uint8_t bdaddr_type;
adapter_get_address(device_get_adapter(device), &sba);
- device_get_address(device, &dba, NULL);
+ device_get_address(device, &dba, &bdaddr_type);
- write_proximity_config(&sba, &dba, "LinkLossAlertLevel", NULL);
+ write_proximity_config(&sba, &dba, bdaddr_type,
+ "LinkLossAlertLevel", NULL);
}
}
--
1.7.12
^ permalink raw reply related
* [RFC BlueZ v0 2/4] proximity: Remove alert level storage
From: Claudio Takahasi @ 2012-09-28 20:01 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1348862494-16911-1-git-send-email-claudio.takahasi@openbossa.org>
This patch fix leftover LinkLossAlertLevel store value when the device
is removed from the system.
---
profiles/proximity/manager.c | 2 +-
profiles/proximity/monitor.c | 15 +++++++++++++--
profiles/proximity/monitor.h | 2 +-
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/profiles/proximity/manager.c b/profiles/proximity/manager.c
index 93dc33e..afc2569 100644
--- a/profiles/proximity/manager.c
+++ b/profiles/proximity/manager.c
@@ -80,7 +80,7 @@ static int monitor_device_probe(struct btd_profile *p,
static void monitor_device_remove(struct btd_profile *p,
struct btd_device *device, gboolean purge)
{
- monitor_unregister(device);
+ monitor_unregister(device, purge);
}
static struct btd_profile pxp_monitor_profile = {
diff --git a/profiles/proximity/monitor.c b/profiles/proximity/monitor.c
index a791916..4745791 100644
--- a/profiles/proximity/monitor.c
+++ b/profiles/proximity/monitor.c
@@ -106,7 +106,10 @@ static int write_proximity_config(bdaddr_t *sba, bdaddr_t *dba,
snprintf(key, sizeof(key), "%17s#%s", addr, alert);
- return textfile_put(filename, key, level);
+ if (level)
+ return textfile_put(filename, key, level);
+ else
+ return textfile_del(filename, key);
}
static char *read_proximity_config(bdaddr_t *sba, bdaddr_t *dba,
@@ -659,10 +662,18 @@ int monitor_register(struct btd_device *device,
return 0;
}
-void monitor_unregister(struct btd_device *device)
+void monitor_unregister(struct btd_device *device, gboolean purge)
{
const char *path = device_get_path(device);
g_dbus_unregister_interface(btd_get_dbus_connection(), path,
PROXIMITY_INTERFACE);
+ if (purge) {
+ bdaddr_t sba, dba;
+
+ adapter_get_address(device_get_adapter(device), &sba);
+ device_get_address(device, &dba, NULL);
+
+ write_proximity_config(&sba, &dba, "LinkLossAlertLevel", NULL);
+ }
}
diff --git a/profiles/proximity/monitor.h b/profiles/proximity/monitor.h
index 191b562..bffc8af 100644
--- a/profiles/proximity/monitor.h
+++ b/profiles/proximity/monitor.h
@@ -31,4 +31,4 @@ struct enabled {
int monitor_register(struct btd_device *device, struct gatt_primary *linkloss,
struct gatt_primary *txpower, struct gatt_primary *immediate,
struct enabled *enabled);
-void monitor_unregister(struct btd_device *device);
+void monitor_unregister(struct btd_device *device, gboolean purge);
--
1.7.12
^ permalink raw reply related
* [RFC BlueZ v0 1/4] core: Add purge parameter to profile remove
From: Claudio Takahasi @ 2012-09-28 20:01 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1348862494-16911-1-git-send-email-claudio.takahasi@openbossa.org>
This patch extends the profile device remove callback allowing the
profiles to remove stored data or execute other profile specific
actions before removing completely the device from the system.
---
audio/manager.c | 3 ++-
profiles/deviceinfo/manager.c | 2 +-
profiles/gatt/manager.c | 2 +-
profiles/health/hdp_manager.c | 3 ++-
profiles/heartrate/manager.c | 2 +-
profiles/input/hog_manager.c | 3 ++-
profiles/input/manager.c | 3 ++-
profiles/network/manager.c | 3 ++-
profiles/proximity/manager.c | 2 +-
profiles/proximity/reporter.c | 3 ++-
profiles/proximity/reporter.h | 3 ++-
profiles/scanparam/manager.c | 3 ++-
profiles/thermometer/manager.c | 2 +-
src/device.c | 26 +++++++++++++++++---------
src/profile.h | 2 +-
15 files changed, 39 insertions(+), 23 deletions(-)
diff --git a/audio/manager.c b/audio/manager.c
index 70be01b..3a89b0f 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -665,7 +665,8 @@ static struct audio_device *get_audio_dev(struct btd_device *device)
return manager_get_device(&src, &dst, TRUE);
}
-static void audio_remove(struct btd_profile *p, struct btd_device *device)
+static void audio_remove(struct btd_profile *p, struct btd_device *device,
+ gboolean purge)
{
struct audio_device *dev;
const char *path;
diff --git a/profiles/deviceinfo/manager.c b/profiles/deviceinfo/manager.c
index 3217283..f620f2c 100644
--- a/profiles/deviceinfo/manager.c
+++ b/profiles/deviceinfo/manager.c
@@ -62,7 +62,7 @@ static int deviceinfo_driver_probe(struct btd_profile *p,
}
static void deviceinfo_driver_remove(struct btd_profile *p,
- struct btd_device *device)
+ struct btd_device *device, gboolean purge)
{
deviceinfo_unregister(device);
}
diff --git a/profiles/gatt/manager.c b/profiles/gatt/manager.c
index 747760b..94921d2 100644
--- a/profiles/gatt/manager.c
+++ b/profiles/gatt/manager.c
@@ -68,7 +68,7 @@ static int gatt_driver_probe(struct btd_profile *p, struct btd_device *device,
}
static void gatt_driver_remove(struct btd_profile *p,
- struct btd_device *device)
+ struct btd_device *device, gboolean purge)
{
gas_unregister(device);
}
diff --git a/profiles/health/hdp_manager.c b/profiles/health/hdp_manager.c
index 7b799f4..5b98f21 100644
--- a/profiles/health/hdp_manager.c
+++ b/profiles/health/hdp_manager.c
@@ -60,7 +60,8 @@ static int hdp_driver_probe(struct btd_profile *p, struct btd_device *device,
return hdp_device_register(device);
}
-static void hdp_driver_remove(struct btd_profile *p, struct btd_device *device)
+static void hdp_driver_remove(struct btd_profile *p, struct btd_device *device,
+ gboolean purge)
{
hdp_device_unregister(device);
}
diff --git a/profiles/heartrate/manager.c b/profiles/heartrate/manager.c
index 19b18a8..7be9156 100644
--- a/profiles/heartrate/manager.c
+++ b/profiles/heartrate/manager.c
@@ -70,7 +70,7 @@ static int heartrate_device_probe(struct btd_profile *p,
}
static void heartrate_device_remove(struct btd_profile *p,
- struct btd_device *device)
+ struct btd_device *device, gboolean purge)
{
heartrate_device_unregister(device);
}
diff --git a/profiles/input/hog_manager.c b/profiles/input/hog_manager.c
index 362c38a..13cd902 100644
--- a/profiles/input/hog_manager.c
+++ b/profiles/input/hog_manager.c
@@ -107,7 +107,8 @@ static void remove_device(gpointer hogdev, gpointer b)
hog_device_unregister(hogdev);
}
-static void hog_device_remove(struct btd_profile *p, struct btd_device *device)
+static void hog_device_remove(struct btd_profile *p, struct btd_device *device,
+ gboolean purge)
{
const gchar *path = device_get_path(device);
diff --git a/profiles/input/manager.c b/profiles/input/manager.c
index 32698aa..4ef2ff2 100644
--- a/profiles/input/manager.c
+++ b/profiles/input/manager.c
@@ -70,7 +70,8 @@ static int hid_device_probe(struct btd_profile *p, struct btd_device *device,
idle_timeout * 60);
}
-static void hid_device_remove(struct btd_profile *p, struct btd_device *device)
+static void hid_device_remove(struct btd_profile *p, struct btd_device *device,
+ gboolean purge)
{
input_remove(device, HID_UUID);
}
diff --git a/profiles/network/manager.c b/profiles/network/manager.c
index e1f4164..dc09ced 100644
--- a/profiles/network/manager.c
+++ b/profiles/network/manager.c
@@ -95,7 +95,8 @@ static int network_probe(struct btd_profile *p, struct btd_device *device,
return 0;
}
-static void network_remove(struct btd_profile *p, struct btd_device *device)
+static void network_remove(struct btd_profile *p, struct btd_device *device,
+ gboolean purge)
{
const gchar *path = device_get_path(device);
diff --git a/profiles/proximity/manager.c b/profiles/proximity/manager.c
index 58e5193..93dc33e 100644
--- a/profiles/proximity/manager.c
+++ b/profiles/proximity/manager.c
@@ -78,7 +78,7 @@ static int monitor_device_probe(struct btd_profile *p,
}
static void monitor_device_remove(struct btd_profile *p,
- struct btd_device *device)
+ struct btd_device *device, gboolean purge)
{
monitor_unregister(device);
}
diff --git a/profiles/proximity/reporter.c b/profiles/proximity/reporter.c
index 6ec5f73..90f1f77 100644
--- a/profiles/proximity/reporter.c
+++ b/profiles/proximity/reporter.c
@@ -238,7 +238,8 @@ int reporter_device_probe(struct btd_profile *p, struct btd_device *device,
return 0;
}
-void reporter_device_remove(struct btd_profile *p, struct btd_device *device)
+void reporter_device_remove(struct btd_profile *p, struct btd_device *device,
+ gboolean purge)
{
struct reporter_adapter *radapter;
struct btd_adapter *adapter = device_get_adapter(device);
diff --git a/profiles/proximity/reporter.h b/profiles/proximity/reporter.h
index 480c668..bd64a92 100644
--- a/profiles/proximity/reporter.h
+++ b/profiles/proximity/reporter.h
@@ -36,7 +36,8 @@ enum {
HIGH_ALERT = 0x02,
};
-void reporter_device_remove(struct btd_profile *p, struct btd_device *device);
+void reporter_device_remove(struct btd_profile *p, struct btd_device *device,
+ gboolean purge);
int reporter_device_probe(struct btd_profile *p, struct btd_device *device,
GSList *uuids);
diff --git a/profiles/scanparam/manager.c b/profiles/scanparam/manager.c
index 24d1e78..0ce0583 100644
--- a/profiles/scanparam/manager.c
+++ b/profiles/scanparam/manager.c
@@ -68,7 +68,8 @@ static int scan_param_probe(struct btd_profile *p, struct btd_device *device,
return scan_register(device, l->data);
}
-static void scan_param_remove(struct btd_profile *p, struct btd_device *device)
+static void scan_param_remove(struct btd_profile *p, struct btd_device *device,
+ gboolean purge)
{
scan_unregister(device);
}
diff --git a/profiles/thermometer/manager.c b/profiles/thermometer/manager.c
index d965976..81eb8be 100644
--- a/profiles/thermometer/manager.c
+++ b/profiles/thermometer/manager.c
@@ -61,7 +61,7 @@ static int thermometer_driver_probe(struct btd_profile *p,
}
static void thermometer_driver_remove(struct btd_profile *p,
- struct btd_device *device)
+ struct btd_device *device, gboolean purge)
{
thermometer_unregister(device);
}
diff --git a/src/device.c b/src/device.c
index efa3dbe..8f34f01 100644
--- a/src/device.c
+++ b/src/device.c
@@ -497,7 +497,15 @@ static DBusMessage *set_trust(DBusMessage *msg, gboolean value, void *data)
static void profile_remove(struct btd_profile *profile,
struct btd_device *device)
{
- profile->device_remove(profile, device);
+ profile->device_remove(profile, device, FALSE);
+
+ device->profiles = g_slist_remove(device->profiles, profile);
+}
+
+static void profile_purge(struct btd_profile *profile,
+ struct btd_device *device)
+{
+ profile->device_remove(profile, device, TRUE);
device->profiles = g_slist_remove(device->profiles, profile);
}
@@ -1270,10 +1278,13 @@ void device_remove(struct btd_device *device, gboolean remove_stored)
if (device->connected)
do_disconnect(device);
- if (remove_stored)
+ if (remove_stored) {
device_remove_stored(device);
-
- g_slist_foreach(device->profiles, (GFunc) profile_remove, device);
+ g_slist_foreach(device->profiles, (GFunc) profile_purge,
+ device);
+ } else
+ g_slist_foreach(device->profiles, (GFunc) profile_remove,
+ device);
g_slist_free(device->profiles);
device->profiles = NULL;
@@ -1406,9 +1417,7 @@ void device_remove_profile(gpointer a, gpointer b)
if (!g_slist_find(device->profiles, profile))
return;
- device->profiles = g_slist_remove(device->profiles, profile);
-
- profile->device_remove(profile, device);
+ profile_remove(profile, device);
}
void device_probe_profiles(struct btd_device *device, GSList *uuids)
@@ -1486,8 +1495,7 @@ static void device_remove_profiles(struct btd_device *device, GSList *uuids)
continue;
}
- profile->device_remove(profile, device);
- device->profiles = g_slist_remove(device->profiles, profile);
+ profile_remove(profile, device);
}
}
diff --git a/src/profile.h b/src/profile.h
index 1702901..25da63c 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -39,7 +39,7 @@ struct btd_profile {
int (*device_probe) (struct btd_profile *p, struct btd_device *device,
GSList *uuids);
void (*device_remove) (struct btd_profile *p,
- struct btd_device *device);
+ struct btd_device *device, gboolean purge);
int (*connect) (struct btd_device *device, struct btd_profile *profile,
btd_profile_cb cb);
--
1.7.12
^ permalink raw reply related
* [RFC BlueZ v0 0/4] Remove profile specific storage
From: Claudio Takahasi @ 2012-09-28 20:01 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In the current implementation it is not possible to detect in the
profile driver remove callback if the device is being removed from
the system or if bluetoothd is exiting.
This patch series allows the profile to identify when a given device
is being removed from the system, allowing the profiles to execute
actions or remove stored data before being removed.
Another possible approach could be add a new callback in the profile
indicating that the device is being removed.
There is also a TODO file item: "Convert storage to user per-remote
device directories and ini-file format". What is the idea? Should the
core remove everything under the remote device address directory?
Claudio Takahasi (4):
core: Add purge parameter to profile remove
proximity: Remove alert level storage
proximity: Store Bluetooth Address type
gatt: Remove Service Changed handle from storage
audio/manager.c | 3 ++-
profiles/deviceinfo/manager.c | 2 +-
profiles/gatt/gas.c | 26 +++++++++++++++++++++++++-
profiles/gatt/gas.h | 2 +-
profiles/gatt/manager.c | 4 ++--
profiles/health/hdp_manager.c | 3 ++-
profiles/heartrate/manager.c | 2 +-
profiles/input/hog_manager.c | 3 ++-
profiles/input/manager.c | 3 ++-
profiles/network/manager.c | 3 ++-
profiles/proximity/manager.c | 4 ++--
profiles/proximity/monitor.c | 41 +++++++++++++++++++++++++++++------------
profiles/proximity/monitor.h | 2 +-
profiles/proximity/reporter.c | 3 ++-
profiles/proximity/reporter.h | 3 ++-
profiles/scanparam/manager.c | 3 ++-
profiles/thermometer/manager.c | 2 +-
src/device.c | 26 +++++++++++++++++---------
src/profile.h | 2 +-
19 files changed, 97 insertions(+), 40 deletions(-)
--
1.7.12
^ permalink raw reply
* Re: [PATCH 3/3] Bluetooth: btmrvl: Fix skb buffer overflow
From: Gustavo Padovan @ 2012-09-28 19:52 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth, bzhao
In-Reply-To: <1348832170-13250-3-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
* Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com> [2012-09-28 14:36:10 +0300]:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Add extra check to avoid skb buffer overflow. Fixes crash below:
>
> [ 101.030427] ------------[ cut here ]------------
> [ 101.030459] kernel BUG at net/core/skbuff.c:127!
> [ 101.030486] invalid opcode: 0000 [#1] SMP
> ...
> [ 101.030806] Pid: 2010, comm: btmrvl_main_ser Not tainted 3.5.0+ #80 Laptop
> [ 101.030859] EIP: 0060:[<c14f2ba9>] EFLAGS: 00010282 CPU: 0
> [ 101.030894] EIP is at skb_put+0x99/0xa0
> [ 101.030919] EAX: 00000080 EBX: f129380b ECX: ef923540 EDX: 00000001
> [ 101.030956] ESI: f00a4000 EDI: 00001003 EBP: ed4a5efc ESP: ed4a5ecc
> [ 101.030992] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
> [ 101.031024] CR0: 8005003b CR2: 08fca014 CR3: 30960000 CR4: 000407f0
> [ 101.031062] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
> [ 101.031100] DR6: ffff0ff0 DR7: 00000400
> [ 101.031125] Process btmrvl_main_ser (pid: 2010, ti=ed4a4000 task=ef923540 task.ti=ed4a4000)
> [ 101.031174] Stack:
> [ 101.031188] c18126f8 c1651938 f853f8d2 00001003 00001003 f1292800 f1292808 f129380b
> [ 101.031250] f1292940 f00a4000 eddb1280 efc0f9c0 ed4a5f44 f853f8d2 00000040 00000000
> [ 101.031312] ef923540 c15ee096 ef923540 eddb12d4 00000004 f00a4000 00000040 00000000
> [ 101.031376] Call Trace:
> [ 101.031396] [<f853f8d2>] ? btmrvl_sdio_process_int_status+0x272/0x3d0 [btmrvl_sdio]
> [ 101.031444] [<f853f8d2>] btmrvl_sdio_process_int_status+0x272/0x3d0 [btmrvl_sdio]
> [ 101.031488] [<c15ee096>] ? _raw_spin_unlock_irqrestore+0x36/0x70
> [ 101.031526] [<f85a46e4>] btmrvl_service_main_thread+0x244/0x300 [btmrvl]
> [ 101.031568] [<f853fb50>] ? btmrvl_sdio_poll_card_status.isra.6.constprop.7+0x90/0x90 [btmrvl_sdio]
> [ 101.031619] [<c107eda0>] ? try_to_wake_up+0x270/0x270
> [ 101.031648] [<f85a44a0>] ? btmrvl_process_event+0x3b0/0x3b0 [btmrvl]
> [ 101.031686] [<c106d19d>] kthread+0x7d/0x90
> [ 101.031713] [<c106d120>] ? flush_kthread_work+0x150/0x150
> [ 101.031745] [<c15f5a82>] kernel_thread_helper+0x6/0x10
> ...
> [ 101.032008] EIP: [<c14f2ba9>] skb_put+0x99/0xa0 SS:ESP 0068:ed4a5ecc
> [ 101.056125] ---[ end trace a0bd01d1a9a796c8 ]---
>
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
> drivers/bluetooth/btmrvl_sdio.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
All 3 patches were applied. Thanks.
Gustavo
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox