* [PATCH BlueZ 2/8] gdbus: Introduce G_DBUS_SIGNAL_FLAG_EXPERIMENTAL
From: Luiz Augusto von Dentz @ 2012-12-23 20:15 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1356293718-9348-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This flag can be used to mark signals as experimental, the marked
signals with this flag can be enabled by setting the environment variable
GDBUS_EXPERIMENTAL=1
---
gdbus/gdbus.h | 8 +++++++-
gdbus/object.c | 21 ++++++++++++++++++---
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index 00fbb1c..e6b51cd 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -96,7 +96,8 @@ enum GDBusMethodFlags {
};
enum GDBusSignalFlags {
- G_DBUS_SIGNAL_FLAG_DEPRECATED = (1 << 0),
+ G_DBUS_SIGNAL_FLAG_DEPRECATED = (1 << 0),
+ G_DBUS_SIGNAL_FLAG_EXPERIMENTAL = (1 << 1),
};
enum GDBusPropertyFlags {
@@ -204,6 +205,11 @@ struct GDBusSecurityTable {
.args = _args, \
.flags = G_DBUS_SIGNAL_FLAG_DEPRECATED
+#define GDBUS_EXPERIMENTAL_SIGNAL(_name, _args) \
+ .name = _name, \
+ .args = _args, \
+ .flags = G_DBUS_SIGNAL_FLAG_EXPERIMENTAL
+
gboolean g_dbus_register_interface(DBusConnection *connection,
const char *path, const char *name,
const GDBusMethodTable *methods,
diff --git a/gdbus/object.c b/gdbus/object.c
index 30dbbc2..20f7db9 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -165,6 +165,14 @@ static void generate_interface_xml(GString *gstr, struct interface_data *iface)
for (signal = iface->signals; signal && signal->name; signal++) {
gboolean deprecated = signal->flags &
G_DBUS_SIGNAL_FLAG_DEPRECATED;
+ gboolean experimental = signal->flags &
+ G_DBUS_SIGNAL_FLAG_EXPERIMENTAL;
+
+ if (experimental) {
+ const char *env = g_getenv("GDBUS_EXPERIMENTAL");
+ if (g_strcmp0(env, "1") != 0)
+ continue;
+ }
if (!deprecated && !(signal->args && signal->args->name))
g_string_append_printf(gstr,
@@ -1267,10 +1275,17 @@ static gboolean check_signal(DBusConnection *conn, const char *path,
}
for (signal = iface->signals; signal && signal->name; signal++) {
- if (!strcmp(signal->name, name)) {
- *args = signal->args;
- return TRUE;
+ if (strcmp(signal->name, name) != 0)
+ continue;
+
+ if (signal->flags & G_DBUS_SIGNAL_FLAG_EXPERIMENTAL) {
+ const char *env = g_getenv("GDBUS_EXPERIMENTAL");
+ if (g_strcmp0(env, "1") != 0)
+ break;
}
+
+ *args = signal->args;
+ return TRUE;
}
error("No signal named %s on interface %s", name, interface);
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 1/8] gdbus: Introduce G_DBUS_METHOD_FLAG_EXPERIMENTAL
From: Luiz Augusto von Dentz @ 2012-12-23 20:15 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This flag can be used to mark methods as experimental, the marked
methods with this flag can be enabled by setting the environment variable
GDBUS_EXPERIMENTAL=1
---
gdbus/gdbus.h | 21 ++++++++++++++++++---
gdbus/object.c | 17 +++++++++++++++++
2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index 0e5c012..00fbb1c 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -89,9 +89,10 @@ typedef void (* GDBusSecurityFunction) (DBusConnection *connection,
GDBusPendingReply pending);
enum GDBusMethodFlags {
- G_DBUS_METHOD_FLAG_DEPRECATED = (1 << 0),
- G_DBUS_METHOD_FLAG_NOREPLY = (1 << 1),
- G_DBUS_METHOD_FLAG_ASYNC = (1 << 2),
+ G_DBUS_METHOD_FLAG_DEPRECATED = (1 << 0),
+ G_DBUS_METHOD_FLAG_NOREPLY = (1 << 1),
+ G_DBUS_METHOD_FLAG_ASYNC = (1 << 2),
+ G_DBUS_METHOD_FLAG_EXPERIMENTAL = (1 << 3),
};
enum GDBusSignalFlags {
@@ -173,6 +174,20 @@ struct GDBusSecurityTable {
.function = _function, \
.flags = G_DBUS_METHOD_FLAG_ASYNC | G_DBUS_METHOD_FLAG_DEPRECATED
+#define GDBUS_EXPERIMENTAL_METHOD(_name, _in_args, _out_args, _function) \
+ .name = _name, \
+ .in_args = _in_args, \
+ .out_args = _out_args, \
+ .function = _function, \
+ .flags = G_DBUS_METHOD_FLAG_EXPERIMENTAL
+
+#define GDBUS_EXPERIMENTAL_ASYNC_METHOD(_name, _in_args, _out_args, _function) \
+ .name = _name, \
+ .in_args = _in_args, \
+ .out_args = _out_args, \
+ .function = _function, \
+ .flags = G_DBUS_METHOD_FLAG_ASYNC | G_DBUS_METHOD_FLAG_EXPERIMENTAL
+
#define GDBUS_NOREPLY_METHOD(_name, _in_args, _out_args, _function) \
.name = _name, \
.in_args = _in_args, \
diff --git a/gdbus/object.c b/gdbus/object.c
index 776d35e..30dbbc2 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -129,6 +129,14 @@ static void generate_interface_xml(GString *gstr, struct interface_data *iface)
G_DBUS_METHOD_FLAG_DEPRECATED;
gboolean noreply = method->flags &
G_DBUS_METHOD_FLAG_NOREPLY;
+ gboolean experimental = method->flags &
+ G_DBUS_METHOD_FLAG_EXPERIMENTAL;
+
+ if (experimental) {
+ const char *env = g_getenv("GDBUS_EXPERIMENTAL");
+ if (g_strcmp0(env, "1") != 0)
+ continue;
+ }
if (!deprecated && !noreply &&
!(method->in_args && method->in_args->name) &&
@@ -1022,10 +1030,19 @@ static DBusHandlerResult generic_message(DBusConnection *connection,
for (method = iface->methods; method &&
method->name && method->function; method++) {
+ gboolean experimental = method->flags &
+ G_DBUS_METHOD_FLAG_EXPERIMENTAL;
+
if (dbus_message_is_method_call(message, iface->name,
method->name) == FALSE)
continue;
+ if (experimental) {
+ const char *env = g_getenv("GDBUS_EXPERIMENTAL");
+ if (g_strcmp0(env, "1") != 0)
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
if (g_dbus_args_have_signature(method->in_args,
message) == FALSE)
continue;
--
1.7.11.7
^ permalink raw reply related
* Re: [PATCH BlueZ 4/6] gdbus: Call check_signals when sending signals with g_dbus_send_message
From: Marcel Holtmann @ 2012-12-23 16:40 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZJ=cpoaSOk4fvk3Y7pp=vtYyN3Qqwacq6iG6UHBicM5-g@mail.gmail.com>
Hi Luiz,
> >> If message passed to g_dbus_send_message is a signal verify if it is a
> >> valid and there really exists an interface with respective signal name.
> >> ---
> >> gdbus/object.c | 9 +++++++++
> >> 1 file changed, 9 insertions(+)
> >>
> >> diff --git a/gdbus/object.c b/gdbus/object.c
> >> index 510763a..6951171 100644
> >> --- a/gdbus/object.c
> >> +++ b/gdbus/object.c
> >> @@ -1475,6 +1475,15 @@ gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message)
> >>
> >> if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_METHOD_CALL)
> >> dbus_message_set_no_reply(message, TRUE);
> >> + else {
> >> + const char *path = dbus_message_get_path(message);
> >> + const char *interface = dbus_message_get_interface(message);
> >> + const char *name = dbus_message_get_member(message);
> >> + const GDBusArgInfo *args;
> >> +
> >> + if (!check_signal(connection, path, interface, name, &args))
> >> + return FALSE;
> >> + }
> >
> > we have more than just method calls and signals. This could be also used
> > used for sending async method returns.
>
> I guess I should do else if and check for signal type then, or you
> have a better idea?
just do the else if part here. You could use a switch statement, but
then you can not have local variables. So it does not really help.
I am still wondering why we are setting no reply flag when this is a
method call. That makes no sense to me. Must be missing something.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH BlueZ 4/6] gdbus: Call check_signals when sending signals with g_dbus_send_message
From: Luiz Augusto von Dentz @ 2012-12-23 16:31 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1356279010.29264.25.camel@aeonflux>
Hi Marcel,
On Sun, Dec 23, 2012 at 6:10 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Luiz,
>
>> If message passed to g_dbus_send_message is a signal verify if it is a
>> valid and there really exists an interface with respective signal name.
>> ---
>> gdbus/object.c | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>> diff --git a/gdbus/object.c b/gdbus/object.c
>> index 510763a..6951171 100644
>> --- a/gdbus/object.c
>> +++ b/gdbus/object.c
>> @@ -1475,6 +1475,15 @@ gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message)
>>
>> if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_METHOD_CALL)
>> dbus_message_set_no_reply(message, TRUE);
>> + else {
>> + const char *path = dbus_message_get_path(message);
>> + const char *interface = dbus_message_get_interface(message);
>> + const char *name = dbus_message_get_member(message);
>> + const GDBusArgInfo *args;
>> +
>> + if (!check_signal(connection, path, interface, name, &args))
>> + return FALSE;
>> + }
>
> we have more than just method calls and signals. This could be also used
> used for sending async method returns.
I guess I should do else if and check for signal type then, or you
have a better idea?
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH BlueZ 3/6] gdbus: Introduce GDBusInterfaceFlags
From: Marcel Holtmann @ 2012-12-23 16:30 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZ+set-vvzf+6whfPt5zE8c7X_t2DB4vJS6p8v2X0i_U-A@mail.gmail.com>
Hi Luiz,
> >> The flags should be passed in g_dbus_register_interface_with_flags,
> >> currently there only one flag which is G_DBUS_INTERFACE_FLAG_EXPERIMENTAL
> >> which works similarly to G_DBUS_METHOD_FLAG_EXPERIMENTAL but for the
> >> whole interface.
> >> ---
> >> gdbus/gdbus.h | 13 +++++++++++++
> >> gdbus/object.c | 20 ++++++++++++++++++++
> >> 2 files changed, 33 insertions(+)
> >
> > can we not just check if the interface contains any non experimental
> > method, signals and properties and base that decision around that?
>
> It can work, but we would have to iterate on every single item, so in
> terms of code is quite a bit more complex so I favored adding a new
> function even though we might replace it in the long run.
we have to iterate over every single item in the success case anyway, so
why bother trying to optimize this.
> > I am not really in favor of introducing a version with flags.
>
> The final solution I was thinking is passing another interface
> containing the table as this tend to be quite static e.g.:
If this is not the final solution you are heading for, then lets not
even bother introducing it. Lets go with the the simple approach that
does not introduce any new functions.
It has the advantage that you only need to change one place. Otherwise
you need to check the method structs and the calling register function.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH BlueZ 3/6] gdbus: Introduce GDBusInterfaceFlags
From: Luiz Augusto von Dentz @ 2012-12-23 16:27 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1356278946.29264.24.camel@aeonflux>
Hi Marcel,
On Sun, Dec 23, 2012 at 6:09 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Luiz,
>
>> The flags should be passed in g_dbus_register_interface_with_flags,
>> currently there only one flag which is G_DBUS_INTERFACE_FLAG_EXPERIMENTAL
>> which works similarly to G_DBUS_METHOD_FLAG_EXPERIMENTAL but for the
>> whole interface.
>> ---
>> gdbus/gdbus.h | 13 +++++++++++++
>> gdbus/object.c | 20 ++++++++++++++++++++
>> 2 files changed, 33 insertions(+)
>
> can we not just check if the interface contains any non experimental
> method, signals and properties and base that decision around that?
It can work, but we would have to iterate on every single item, so in
terms of code is quite a bit more complex so I favored adding a new
function even though we might replace it in the long run.
> I am not really in favor of introducing a version with flags.
The final solution I was thinking is passing another interface
containing the table as this tend to be quite static e.g.:
struct GDBusInteface {
const char *name;
GDBusInterfaceFlags flags;
const GDBusMethodTable *methods;
const GDBusSignalTable *signals;
const GDBusPropertiesTable *properties;
};
Obviously this would break g_dbus_register_interface and generate
quite a bit more changes to the daemon code.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH BlueZ 4/6] gdbus: Call check_signals when sending signals with g_dbus_send_message
From: Marcel Holtmann @ 2012-12-23 16:10 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1356276298-13795-4-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
> If message passed to g_dbus_send_message is a signal verify if it is a
> valid and there really exists an interface with respective signal name.
> ---
> gdbus/object.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/gdbus/object.c b/gdbus/object.c
> index 510763a..6951171 100644
> --- a/gdbus/object.c
> +++ b/gdbus/object.c
> @@ -1475,6 +1475,15 @@ gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message)
>
> if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_METHOD_CALL)
> dbus_message_set_no_reply(message, TRUE);
> + else {
> + const char *path = dbus_message_get_path(message);
> + const char *interface = dbus_message_get_interface(message);
> + const char *name = dbus_message_get_member(message);
> + const GDBusArgInfo *args;
> +
> + if (!check_signal(connection, path, interface, name, &args))
> + return FALSE;
> + }
we have more than just method calls and signals. This could be also used
used for sending async method returns.
>
> result = dbus_connection_send(connection, message, NULL);
>
Regards
Marcel
^ permalink raw reply
* Re: [PATCH BlueZ 3/6] gdbus: Introduce GDBusInterfaceFlags
From: Marcel Holtmann @ 2012-12-23 16:09 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1356276298-13795-3-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
> The flags should be passed in g_dbus_register_interface_with_flags,
> currently there only one flag which is G_DBUS_INTERFACE_FLAG_EXPERIMENTAL
> which works similarly to G_DBUS_METHOD_FLAG_EXPERIMENTAL but for the
> whole interface.
> ---
> gdbus/gdbus.h | 13 +++++++++++++
> gdbus/object.c | 20 ++++++++++++++++++++
> 2 files changed, 33 insertions(+)
can we not just check if the interface contains any non experimental
method, signals and properties and base that decision around that?
I am not really in favor of introducing a version with flags.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH hcidump] Add TI Logger dump support
From: Marcel Holtmann @ 2012-12-23 15:57 UTC (permalink / raw)
To: chen.ganir; +Cc: linux-bluetooth
In-Reply-To: <1356264452-21200-1-git-send-email-chen.ganir@ti.com>
Hi Chen,
> Texas Instruments controllers can be configured to send the
> internal firmware log through a vendor specific HCI event on
> the hci transport.
> This patch allows capturing those log events, and writing them
> to a file, which can then be used with the latest TI Logger
> application to read and show the logs.
>
> This is usefull in case there is no other way to get the TI log
> (for example, the lack of a connection to the controller Log TX
> hardware line).
> ---
> parser/parser.h | 1 +
> src/hcidump.c | 44 ++++++++++++++++++++++++++++++++++++++++----
> 2 files changed, 41 insertions(+), 4 deletions(-)
we consumed hcidump into bluez.git. Please make patches against
bluez.git since bluez-hcidump.git is closed now.
> diff --git a/parser/parser.h b/parser/parser.h
> index f8f7009..d4fecf0 100644
> --- a/parser/parser.h
> +++ b/parser/parser.h
> @@ -63,6 +63,7 @@ struct frame {
> #define DUMP_BTSNOOP 0x1000
> #define DUMP_PKTLOG 0x2000
> #define DUMP_NOVENDOR 0x4000
> +#define DUMP_TILOGGER 0x8000
> #define DUMP_TYPE_MASK (DUMP_ASCII | DUMP_HEX | DUMP_EXT)
>
> /* Parser filter */
> diff --git a/src/hcidump.c b/src/hcidump.c
> index 18ae64e..3daf2b6 100644
> --- a/src/hcidump.c
> +++ b/src/hcidump.c
> @@ -110,6 +110,14 @@ struct pktlog_hdr {
> } __attribute__ ((packed));
> #define PKTLOG_HDR_SIZE (sizeof(struct pktlog_hdr))
>
> +struct tilogger_pkt {
> + uint8_t type;
> + uint8_t vendor;
> + uint8_t size;
> + uint16_t opcode;
> + uint8_t data[0]; /* Packet Data */
> +} __attribute__ ((packed));
> +
> static inline int read_n(int fd, char *buf, int len)
> {
> int t = 0, w;
> @@ -300,7 +308,24 @@ static int process_frames(int dev, int sock, int fd, unsigned long flags)
> case WRITE:
> case SERVER:
> /* Save or send dump */
> - if (flags & DUMP_BTSNOOP) {
> + if (flags & DUMP_TILOGGER && mode == WRITE) {
Don't bother with mode == WRITE check. I am taking the server code out
of the tool anyway.
> + struct tilogger_pkt *tp = frm.ptr;
> + if (tp->type == HCI_EVENT_PKT &&
> + tp->vendor == 0xFF &&
> + tp->opcode == 0x0400) {
This is not our coding style.
> + char out[2];
> + int i;
> +
> + for(i = 0;i < tp->size-2;i++) {
Neither is this.
> + sprintf(out,"%02X",tp->data[i]);
> + if (write_n(fd, out, 2) < 0) {
> + perror("Write error");
> + return -1;
> + }
> + }
> + }
> + continue;
> + } else if (flags & DUMP_BTSNOOP) {
> uint64_t ts;
> uint8_t pkt_type = ((uint8_t *) frm.data)[0];
> dp->size = htonl(frm.data_len);
> @@ -542,7 +567,9 @@ static int open_file(char *file, int mode, unsigned long flags)
> return fd;
> }
> } else {
> - if (flags & DUMP_BTSNOOP) {
> + if (flags & DUMP_TILOGGER) {
> + printf ("TI Logger dump\n");
And this is still not our coding style.
> + } else if (flags & DUMP_BTSNOOP) {
And here you broke a style that was fine before.
> btsnoop_version = 1;
> btsnoop_type = 1002;
>
> @@ -895,6 +922,7 @@ static void usage(void)
> " -a, --ascii Dump data in ascii\n"
> " -x, --hex Dump data in hex\n"
> " -X, --ext Dump data in hex and ascii\n"
> + " -T, --tilogger=file Dump TI hci log data to file\n"
> " -R, --raw Dump raw data\n"
> " -C, --cmtp=psm PSM for CMTP\n"
> " -H, --hcrp=psm PSM for HCRP\n"
> @@ -936,6 +964,7 @@ static struct option main_options[] = {
> { "nopermcheck", 0, 0, 'Z' },
> { "ipv4", 0, 0, '4' },
> { "ipv6", 0, 0, '6' },
> + { "tilogger", 1, 0, 'T' },
> { "help", 0, 0, 'h' },
> { "version", 0, 0, 'v' },
> { 0 }
> @@ -952,7 +981,7 @@ int main(int argc, char *argv[])
> uint16_t obex_port;
>
> while ((opt = getopt_long(argc, argv,
> - "i:l:p:m:w:r:d:taxXRC:H:O:P:S:D:A:YZ46hv",
> + "i:l:p:m:w:r:d:taxT:XRC:H:O:P:S:D:A:YZ46hv",
> main_options, NULL)) != -1) {
> switch(opt) {
> case 'i':
> @@ -1009,6 +1038,12 @@ int main(int argc, char *argv[])
> flags |= DUMP_RAW;
> break;
>
> + case 'T':
> + mode = WRITE;
> + dump_file = strdup(optarg);
> + flags |= DUMP_TILOGGER;
> + break;
> +
> case 'C':
> set_proto(0, atoi(optarg), 0, SDP_UUID_CMTP);
> break;
> @@ -1101,7 +1136,8 @@ int main(int argc, char *argv[])
> break;
>
> case WRITE:
> - flags |= DUMP_BTSNOOP;
> + if ((flags & DUMP_TILOGGER) == 0)
> + flags |= DUMP_BTSNOOP;
There are all else if check. So why is needed? You might better use a
tilogger_file instead using the global file.
> process_frames(device, open_socket(device, flags),
> open_file(dump_file, mode, flags), flags);
> break;
Regards
Marcel
^ permalink raw reply
* [PATCH BlueZ 6/6] AVRCP: Fix not checking for media_player_controller_create
From: Luiz Augusto von Dentz @ 2012-12-23 15:24 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1356276298-13795-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Now that the MediaPlayer1 interface is experimental the interface
registration may fail which return NULL, in that case there is no
point on register to any notifications.
---
profiles/audio/avrcp.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 4e3d31d..ce070cd 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -1987,6 +1987,11 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn,
count = pdu->params[1];
+ path = device_get_path(session->dev->btd_dev);
+ mp = media_player_controller_create(path);
+ if (mp == NULL)
+ return FALSE;
+
for (; count > 0; count--) {
uint8_t event = pdu->params[1 + count];
@@ -2001,8 +2006,6 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn,
}
}
- path = device_get_path(session->dev->btd_dev);
- mp = media_player_controller_create(path);
media_player_set_callbacks(mp, &ct_cbs, player);
player->user_data = mp;
player->destroy = (GDestroyNotify) media_player_destroy;
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 5/6] player: Enable MediaPlayer1 interface as experimental
From: Luiz Augusto von Dentz @ 2012-12-23 15:24 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1356276298-13795-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This enable MediaPlayer1 when GDBUS_EXPERIMENTAL=1
---
profiles/audio/player.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index 005d0d1..60c7a8a 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -298,9 +298,9 @@ struct media_player *media_player_controller_create(const char *path)
g_free, g_free);
mp->progress = g_timer_new();
-#if 0
- if (!g_dbus_register_interface(btd_get_dbus_connection(),
+ if (!g_dbus_register_interface_with_flags(btd_get_dbus_connection(),
mp->path, MEDIA_PLAYER_INTERFACE,
+ G_DBUS_INTERFACE_FLAG_EXPERIMENTAL,
media_player_methods,
media_player_signals,
media_player_properties, mp, NULL)) {
@@ -308,7 +308,7 @@ struct media_player *media_player_controller_create(const char *path)
media_player_destroy(mp);
return NULL;
}
-#endif
+
DBG("%s", mp->path);
return mp;
@@ -410,7 +410,6 @@ void media_player_set_status(struct media_player *mp, const char *status)
static gboolean process_metadata_changed(void *user_data)
{
-#if 0
struct media_player *mp = user_data;
DBusMessage *signal;
DBusMessageIter iter, dict;
@@ -439,7 +438,7 @@ static gboolean process_metadata_changed(void *user_data)
dbus_message_iter_close_container(&iter, &dict);
g_dbus_send_message(btd_get_dbus_connection(), signal);
-#endif
+
return FALSE;
}
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 4/6] gdbus: Call check_signals when sending signals with g_dbus_send_message
From: Luiz Augusto von Dentz @ 2012-12-23 15:24 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1356276298-13795-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If message passed to g_dbus_send_message is a signal verify if it is a
valid and there really exists an interface with respective signal name.
---
gdbus/object.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/gdbus/object.c b/gdbus/object.c
index 510763a..6951171 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -1475,6 +1475,15 @@ gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message)
if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_METHOD_CALL)
dbus_message_set_no_reply(message, TRUE);
+ else {
+ const char *path = dbus_message_get_path(message);
+ const char *interface = dbus_message_get_interface(message);
+ const char *name = dbus_message_get_member(message);
+ const GDBusArgInfo *args;
+
+ if (!check_signal(connection, path, interface, name, &args))
+ return FALSE;
+ }
result = dbus_connection_send(connection, message, NULL);
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 3/6] gdbus: Introduce GDBusInterfaceFlags
From: Luiz Augusto von Dentz @ 2012-12-23 15:24 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1356276298-13795-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The flags should be passed in g_dbus_register_interface_with_flags,
currently there only one flag which is G_DBUS_INTERFACE_FLAG_EXPERIMENTAL
which works similarly to G_DBUS_METHOD_FLAG_EXPERIMENTAL but for the
whole interface.
---
gdbus/gdbus.h | 13 +++++++++++++
gdbus/object.c | 20 ++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index 64f5d62..f49d9f0 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -31,6 +31,7 @@ extern "C" {
#include <dbus/dbus.h>
#include <glib.h>
+typedef enum GDBusInterfaceFlags GDBusInterfaceFlags;
typedef enum GDBusMethodFlags GDBusMethodFlags;
typedef enum GDBusSignalFlags GDBusSignalFlags;
typedef enum GDBusPropertyFlags GDBusPropertyFlags;
@@ -88,6 +89,10 @@ typedef void (* GDBusSecurityFunction) (DBusConnection *connection,
gboolean interaction,
GDBusPendingReply pending);
+enum GDBusInterfaceFlags {
+ G_DBUS_INTERFACE_FLAG_EXPERIMENTAL = (1 << 0),
+};
+
enum GDBusMethodFlags {
G_DBUS_METHOD_FLAG_DEPRECATED = (1 << 0),
G_DBUS_METHOD_FLAG_NOREPLY = (1 << 1),
@@ -211,6 +216,14 @@ gboolean g_dbus_register_interface(DBusConnection *connection,
const GDBusPropertyTable *properties,
void *user_data,
GDBusDestroyFunction destroy);
+gboolean g_dbus_register_interface_with_flags(DBusConnection *connection,
+ const char *path, const char *name,
+ GDBusInterfaceFlags flags,
+ const GDBusMethodTable *methods,
+ const GDBusSignalTable *signals,
+ const GDBusPropertyTable *properties,
+ void *user_data,
+ GDBusDestroyFunction destroy);
gboolean g_dbus_unregister_interface(DBusConnection *connection,
const char *path, const char *name);
diff --git a/gdbus/object.c b/gdbus/object.c
index 180d48c..510763a 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -1350,6 +1350,26 @@ gboolean g_dbus_register_interface(DBusConnection *connection,
return TRUE;
}
+gboolean g_dbus_register_interface_with_flags(DBusConnection *connection,
+ const char *path, const char *name,
+ GDBusInterfaceFlags flags,
+ const GDBusMethodTable *methods,
+ const GDBusSignalTable *signals,
+ const GDBusPropertyTable *properties,
+ void *user_data,
+ GDBusDestroyFunction destroy)
+{
+ if (flags & G_DBUS_INTERFACE_FLAG_EXPERIMENTAL) {
+ const char *env = g_getenv("GDBUS_EXPERIMENTAL");
+ if (g_strcmp0(env, "1") != 0)
+ return FALSE;
+ }
+
+ return g_dbus_register_interface(connection, path, name, methods,
+ signals, properties, user_data,
+ destroy);
+}
+
gboolean g_dbus_unregister_interface(DBusConnection *connection,
const char *path, const char *name)
{
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 2/6] media: Enable RegisterPlayer and UnregisterPlayer methods as experimental
From: Luiz Augusto von Dentz @ 2012-12-23 15:24 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1356276298-13795-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
profiles/audio/media.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index f728460..e4206e3 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -868,7 +868,6 @@ static DBusMessage *unregister_endpoint(DBusConnection *conn, DBusMessage *msg,
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
-#if 0
static struct media_player *media_adapter_find_player(
struct media_adapter *adapter,
const char *sender,
@@ -1533,7 +1532,6 @@ static DBusMessage *unregister_player(DBusConnection *conn, DBusMessage *msg,
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
-#endif
static const GDBusMethodTable media_methods[] = {
{ GDBUS_METHOD("RegisterEndpoint",
@@ -1541,14 +1539,12 @@ static const GDBusMethodTable media_methods[] = {
NULL, register_endpoint) },
{ GDBUS_METHOD("UnregisterEndpoint",
GDBUS_ARGS({ "endpoint", "o" }), NULL, unregister_endpoint) },
-#if 0
- { GDBUS_METHOD("RegisterPlayer",
+ { GDBUS_EXPERIMENTAL_METHOD("RegisterPlayer",
GDBUS_ARGS({ "player", "o" }, { "properties", "a{sv}" },
{ "metadata", "a{sv}" }),
NULL, register_player) },
- { GDBUS_METHOD("UnregisterPlayer",
+ { GDBUS_EXPERIMENTAL_METHOD("UnregisterPlayer",
GDBUS_ARGS({ "player", "o" }), NULL, unregister_player) },
-#endif
{ },
};
@@ -1559,10 +1555,8 @@ static void path_free(void *data)
while (adapter->endpoints)
release_endpoint(adapter->endpoints->data);
-#if 0
while (adapter->players)
media_player_destroy(adapter->players->data);
-#endif
adapters = g_slist_remove(adapters, adapter);
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 1/6] gdbus: Introduce G_DBUS_METHOD_FLAG_EXPERIMENTAL
From: Luiz Augusto von Dentz @ 2012-12-23 15:24 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This flag can be used to mark methods as experimental, the marked
methods with this flag can be enabled by setting the environment variable
GDBUS_EXPERIMENTAL=1
---
gdbus/gdbus.h | 21 ++++++++++++++++++---
gdbus/object.c | 17 +++++++++++++++++
2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index 0e5c012..64f5d62 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -89,9 +89,10 @@ typedef void (* GDBusSecurityFunction) (DBusConnection *connection,
GDBusPendingReply pending);
enum GDBusMethodFlags {
- G_DBUS_METHOD_FLAG_DEPRECATED = (1 << 0),
- G_DBUS_METHOD_FLAG_NOREPLY = (1 << 1),
- G_DBUS_METHOD_FLAG_ASYNC = (1 << 2),
+ G_DBUS_METHOD_FLAG_DEPRECATED = (1 << 0),
+ G_DBUS_METHOD_FLAG_NOREPLY = (1 << 1),
+ G_DBUS_METHOD_FLAG_ASYNC = (1 << 2),
+ G_DBUS_METHOD_FLAG_EXPERIMENTAL = (1 << 3),
};
enum GDBusSignalFlags {
@@ -173,6 +174,20 @@ struct GDBusSecurityTable {
.function = _function, \
.flags = G_DBUS_METHOD_FLAG_ASYNC | G_DBUS_METHOD_FLAG_DEPRECATED
+#define GDBUS_EXPERIMENTAL_METHOD(_name, _in_args, _out_args, _function) \
+ .name = _name, \
+ .in_args = _in_args, \
+ .out_args = _out_args, \
+ .function = _function, \
+ .flags = G_DBUS_METHOD_FLAG_EXPERIMENTAL
+
+#define GDBUS_EXPERIMENTAL_ASYNC_METHOD(_name, _in_args, _out_args, _function) \
+ .name = _name, \
+ .in_args = _in_args, \
+ .out_args = _out_args, \
+ .function = _function, \
+ .flags = G_DBUS_METHOD_FLAG_ASYNC | G_DBUS_METHOD_FLAG_EXPERIMENTAL
+
#define GDBUS_NOREPLY_METHOD(_name, _in_args, _out_args, _function) \
.name = _name, \
.in_args = _in_args, \
diff --git a/gdbus/object.c b/gdbus/object.c
index 776d35e..180d48c 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -129,6 +129,14 @@ static void generate_interface_xml(GString *gstr, struct interface_data *iface)
G_DBUS_METHOD_FLAG_DEPRECATED;
gboolean noreply = method->flags &
G_DBUS_METHOD_FLAG_NOREPLY;
+ gboolean experimental = method->flags &
+ G_DBUS_METHOD_FLAG_EXPERIMENTAL;
+
+ if (experimental) {
+ const char *env = g_getenv("GDBUS_EXPERIMENTAL");
+ if (g_strcmp0(env, "1") != 0)
+ return;
+ }
if (!deprecated && !noreply &&
!(method->in_args && method->in_args->name) &&
@@ -1022,10 +1030,19 @@ static DBusHandlerResult generic_message(DBusConnection *connection,
for (method = iface->methods; method &&
method->name && method->function; method++) {
+ gboolean experimental = method->flags &
+ G_DBUS_METHOD_FLAG_EXPERIMENTAL;
+
if (dbus_message_is_method_call(message, iface->name,
method->name) == FALSE)
continue;
+ if (experimental) {
+ const char *env = g_getenv("GDBUS_EXPERIMENTAL");
+ if (g_strcmp0(env, "1") != 0)
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
if (g_dbus_args_have_signature(method->in_args,
message) == FALSE)
continue;
--
1.7.11.7
^ permalink raw reply related
* Re: [PATCH hcidump] Add TI Logger dump support
From: Arik Nemtsov @ 2012-12-23 14:30 UTC (permalink / raw)
To: chen.ganir; +Cc: marcel, linux-bluetooth
In-Reply-To: <CA+XVXfcm5k7qN_tgbX6zVtWjxo_5w+FNmmbhthw3+UtrH3tnYg@mail.gmail.com>
On Sun, Dec 23, 2012 at 4:11 PM, Arik Nemtsov <arik@wizery.com> wrote:
> On Sun, Dec 23, 2012 at 2:07 PM, <chen.ganir@ti.com> wrote:
>> From: Chen Ganir <chen.ganir@ti.com>
>>
>> Texas Instruments controllers can be configured to send the
>> internal firmware log through a vendor specific HCI event on
>> the hci transport.
>> This patch allows capturing those log events, and writing them
>> to a file, which can then be used with the latest TI Logger
>> application to read and show the logs.
>>
>> This is usefull in case there is no other way to get the TI log
>> (for example, the lack of a connection to the controller Log TX
>> hardware line).
> [...]
>> @@ -300,7 +308,24 @@ static int process_frames(int dev, int sock, int fd, unsigned long flags)
> [...]
>> + char out[2];
>> + int i;
>> +
>> + for(i = 0;i < tp->size-2;i++) {
>> + sprintf(out,"%02X",tp->data[i]);
>> + if (write_n(fd, out, 2) < 0) {
>
> Seems to me this can overflow when tp->size - 2 > sizeof(out) ?
I'm sorry. I misread the code - but there's still an off-by-one here,
since 3 bytes are written to out (the null terminator).
Arik
^ permalink raw reply
* Re: [PATCH hcidump] Add TI Logger dump support
From: Arik Nemtsov @ 2012-12-23 14:11 UTC (permalink / raw)
To: chen.ganir; +Cc: marcel, linux-bluetooth
In-Reply-To: <1356264452-21200-1-git-send-email-chen.ganir@ti.com>
On Sun, Dec 23, 2012 at 2:07 PM, <chen.ganir@ti.com> wrote:
> From: Chen Ganir <chen.ganir@ti.com>
>
> Texas Instruments controllers can be configured to send the
> internal firmware log through a vendor specific HCI event on
> the hci transport.
> This patch allows capturing those log events, and writing them
> to a file, which can then be used with the latest TI Logger
> application to read and show the logs.
>
> This is usefull in case there is no other way to get the TI log
> (for example, the lack of a connection to the controller Log TX
> hardware line).
[...]
> @@ -300,7 +308,24 @@ static int process_frames(int dev, int sock, int fd, unsigned long flags)
[...]
> + char out[2];
> + int i;
> +
> + for(i = 0;i < tp->size-2;i++) {
> + sprintf(out,"%02X",tp->data[i]);
> + if (write_n(fd, out, 2) < 0) {
Seems to me this can overflow when tp->size - 2 > sizeof(out) ?
Arik
^ permalink raw reply
* [PATCH hcidump] Add TI Logger dump support
From: chen.ganir @ 2012-12-23 12:07 UTC (permalink / raw)
To: marcel, linux-bluetooth; +Cc: Chen Ganir
From: Chen Ganir <chen.ganir@ti.com>
Texas Instruments controllers can be configured to send the
internal firmware log through a vendor specific HCI event on
the hci transport.
This patch allows capturing those log events, and writing them
to a file, which can then be used with the latest TI Logger
application to read and show the logs.
This is usefull in case there is no other way to get the TI log
(for example, the lack of a connection to the controller Log TX
hardware line).
---
parser/parser.h | 1 +
src/hcidump.c | 44 ++++++++++++++++++++++++++++++++++++++++----
2 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/parser/parser.h b/parser/parser.h
index f8f7009..d4fecf0 100644
--- a/parser/parser.h
+++ b/parser/parser.h
@@ -63,6 +63,7 @@ struct frame {
#define DUMP_BTSNOOP 0x1000
#define DUMP_PKTLOG 0x2000
#define DUMP_NOVENDOR 0x4000
+#define DUMP_TILOGGER 0x8000
#define DUMP_TYPE_MASK (DUMP_ASCII | DUMP_HEX | DUMP_EXT)
/* Parser filter */
diff --git a/src/hcidump.c b/src/hcidump.c
index 18ae64e..3daf2b6 100644
--- a/src/hcidump.c
+++ b/src/hcidump.c
@@ -110,6 +110,14 @@ struct pktlog_hdr {
} __attribute__ ((packed));
#define PKTLOG_HDR_SIZE (sizeof(struct pktlog_hdr))
+struct tilogger_pkt {
+ uint8_t type;
+ uint8_t vendor;
+ uint8_t size;
+ uint16_t opcode;
+ uint8_t data[0]; /* Packet Data */
+} __attribute__ ((packed));
+
static inline int read_n(int fd, char *buf, int len)
{
int t = 0, w;
@@ -300,7 +308,24 @@ static int process_frames(int dev, int sock, int fd, unsigned long flags)
case WRITE:
case SERVER:
/* Save or send dump */
- if (flags & DUMP_BTSNOOP) {
+ if (flags & DUMP_TILOGGER && mode == WRITE) {
+ struct tilogger_pkt *tp = frm.ptr;
+ if (tp->type == HCI_EVENT_PKT &&
+ tp->vendor == 0xFF &&
+ tp->opcode == 0x0400) {
+ char out[2];
+ int i;
+
+ for(i = 0;i < tp->size-2;i++) {
+ sprintf(out,"%02X",tp->data[i]);
+ if (write_n(fd, out, 2) < 0) {
+ perror("Write error");
+ return -1;
+ }
+ }
+ }
+ continue;
+ } else if (flags & DUMP_BTSNOOP) {
uint64_t ts;
uint8_t pkt_type = ((uint8_t *) frm.data)[0];
dp->size = htonl(frm.data_len);
@@ -542,7 +567,9 @@ static int open_file(char *file, int mode, unsigned long flags)
return fd;
}
} else {
- if (flags & DUMP_BTSNOOP) {
+ if (flags & DUMP_TILOGGER) {
+ printf ("TI Logger dump\n");
+ } else if (flags & DUMP_BTSNOOP) {
btsnoop_version = 1;
btsnoop_type = 1002;
@@ -895,6 +922,7 @@ static void usage(void)
" -a, --ascii Dump data in ascii\n"
" -x, --hex Dump data in hex\n"
" -X, --ext Dump data in hex and ascii\n"
+ " -T, --tilogger=file Dump TI hci log data to file\n"
" -R, --raw Dump raw data\n"
" -C, --cmtp=psm PSM for CMTP\n"
" -H, --hcrp=psm PSM for HCRP\n"
@@ -936,6 +964,7 @@ static struct option main_options[] = {
{ "nopermcheck", 0, 0, 'Z' },
{ "ipv4", 0, 0, '4' },
{ "ipv6", 0, 0, '6' },
+ { "tilogger", 1, 0, 'T' },
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'v' },
{ 0 }
@@ -952,7 +981,7 @@ int main(int argc, char *argv[])
uint16_t obex_port;
while ((opt = getopt_long(argc, argv,
- "i:l:p:m:w:r:d:taxXRC:H:O:P:S:D:A:YZ46hv",
+ "i:l:p:m:w:r:d:taxT:XRC:H:O:P:S:D:A:YZ46hv",
main_options, NULL)) != -1) {
switch(opt) {
case 'i':
@@ -1009,6 +1038,12 @@ int main(int argc, char *argv[])
flags |= DUMP_RAW;
break;
+ case 'T':
+ mode = WRITE;
+ dump_file = strdup(optarg);
+ flags |= DUMP_TILOGGER;
+ break;
+
case 'C':
set_proto(0, atoi(optarg), 0, SDP_UUID_CMTP);
break;
@@ -1101,7 +1136,8 @@ int main(int argc, char *argv[])
break;
case WRITE:
- flags |= DUMP_BTSNOOP;
+ if ((flags & DUMP_TILOGGER) == 0)
+ flags |= DUMP_BTSNOOP;
process_frames(device, open_socket(device, flags),
open_file(dump_file, mode, flags), flags);
break;
--
1.7.10.4
^ permalink raw reply related
* [PATCH hcidump] Add TI Logger dump support
From: chen.ganir @ 2012-12-23 11:58 UTC (permalink / raw)
To: marcel, linux-bluetooth; +Cc: Chen Ganir
From: Chen Ganir <chen.ganir@ti.com>
Texas Instruments controllers can be configured to send the
internal firmware log through a vendor specific HCI event on
the hci transport.
This patch allows capturing those log events, and writing them
to a file, which can then be used with the latest TI Logger
application to read and show the logs.
This is usefull in case there is no other way to get the TI log
(for example, the lack of a connection to the controller Log TX
hardware line).
---
parser/parser.h | 1 +
src/hcidump.c | 44 ++++++++++++++++++++++++++++++++++++++++----
2 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/parser/parser.h b/parser/parser.h
index f8f7009..d4fecf0 100644
--- a/parser/parser.h
+++ b/parser/parser.h
@@ -63,6 +63,7 @@ struct frame {
#define DUMP_BTSNOOP 0x1000
#define DUMP_PKTLOG 0x2000
#define DUMP_NOVENDOR 0x4000
+#define DUMP_TILOGGER 0x8000
#define DUMP_TYPE_MASK (DUMP_ASCII | DUMP_HEX | DUMP_EXT)
/* Parser filter */
diff --git a/src/hcidump.c b/src/hcidump.c
index 18ae64e..3daf2b6 100644
--- a/src/hcidump.c
+++ b/src/hcidump.c
@@ -110,6 +110,14 @@ struct pktlog_hdr {
} __attribute__ ((packed));
#define PKTLOG_HDR_SIZE (sizeof(struct pktlog_hdr))
+struct tilogger_pkt {
+ uint8_t type;
+ uint8_t vendor;
+ uint8_t size;
+ uint16_t opcode;
+ uint8_t data[0]; /* Packet Data */
+} __attribute__ ((packed));
+
static inline int read_n(int fd, char *buf, int len)
{
int t = 0, w;
@@ -300,7 +308,24 @@ static int process_frames(int dev, int sock, int fd, unsigned long flags)
case WRITE:
case SERVER:
/* Save or send dump */
- if (flags & DUMP_BTSNOOP) {
+ if (flags & DUMP_TILOGGER && mode == WRITE) {
+ struct tilogger_pkt *tp = frm.ptr;
+ if (tp->type == HCI_EVENT_PKT &&
+ tp->vendor == 0xFF &&
+ tp->opcode == 0x0400) {
+ char out[2];
+ int i;
+
+ for(i = 0;i < tp->size-2;i++) {
+ sprintf(out,"%02X",tp->data[i]);
+ if (write_n(fd, out, 2) < 0) {
+ perror("Write error");
+ return -1;
+ }
+ }
+ }
+ continue;
+ } else if (flags & DUMP_BTSNOOP) {
uint64_t ts;
uint8_t pkt_type = ((uint8_t *) frm.data)[0];
dp->size = htonl(frm.data_len);
@@ -542,7 +567,9 @@ static int open_file(char *file, int mode, unsigned long flags)
return fd;
}
} else {
- if (flags & DUMP_BTSNOOP) {
+ if (flags & DUMP_TILOGGER) {
+ printf ("TI Logger dump\n");
+ } else if (flags & DUMP_BTSNOOP) {
btsnoop_version = 1;
btsnoop_type = 1002;
@@ -895,6 +922,7 @@ static void usage(void)
" -a, --ascii Dump data in ascii\n"
" -x, --hex Dump data in hex\n"
" -X, --ext Dump data in hex and ascii\n"
+ " -T, --tilogger=file Dump TI hci log data to file\n"
" -R, --raw Dump raw data\n"
" -C, --cmtp=psm PSM for CMTP\n"
" -H, --hcrp=psm PSM for HCRP\n"
@@ -936,6 +964,7 @@ static struct option main_options[] = {
{ "nopermcheck", 0, 0, 'Z' },
{ "ipv4", 0, 0, '4' },
{ "ipv6", 0, 0, '6' },
+ { "tilogger", 1, 0, 'T' },
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'v' },
{ 0 }
@@ -952,7 +981,7 @@ int main(int argc, char *argv[])
uint16_t obex_port;
while ((opt = getopt_long(argc, argv,
- "i:l:p:m:w:r:d:taxXRC:H:O:P:S:D:A:YZ46hv",
+ "i:l:p:m:w:r:d:taxT:XRC:H:O:P:S:D:A:YZ46hv",
main_options, NULL)) != -1) {
switch(opt) {
case 'i':
@@ -1009,6 +1038,12 @@ int main(int argc, char *argv[])
flags |= DUMP_RAW;
break;
+ case 'T':
+ mode = WRITE;
+ dump_file = strdup(optarg);
+ flags |= DUMP_TILOGGER;
+ break;
+
case 'C':
set_proto(0, atoi(optarg), 0, SDP_UUID_CMTP);
break;
@@ -1101,7 +1136,8 @@ int main(int argc, char *argv[])
break;
case WRITE:
- flags |= DUMP_BTSNOOP;
+ if ((flags & DUMP_TILOGGER) == 0)
+ flags |= DUMP_BTSNOOP;
process_frames(device, open_socket(device, flags),
open_file(dump_file, mode, flags), flags);
break;
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH BlueZ] core: Fix memory leak from pending UUID removal
From: Johan Hedberg @ 2012-12-23 9:31 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <1356217161-3787-1-git-send-email-anderson.lizardo@openbossa.org>
Hi Lizardo,
On Sat, Dec 22, 2012, Anderson Lizardo wrote:
> When bluetoothd is shutting down, profile cleanup will usually issue
> many "Remove UUID" management commands. These may not complete before
> the process exits, resulting on this memory leak:
>
> ==2461== 144 (8 direct, 136 indirect) bytes in 1 blocks are definitely
> lost in loss record 153 of 176
> ==2461== at 0x402BE68: malloc (in
> /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
> ==2461== by 0x40869AA: standard_malloc (gmem.c:85)
> ==2461== by 0x4086E42: g_malloc (gmem.c:159)
> ==2461== by 0x409B26D: g_slice_alloc (gslice.c:1003)
> ==2461== by 0x409C659: g_slist_append (gslist.c:222)
> ==2461== by 0x80B5E12: mgmt_remove_uuid (mgmt.c:1034)
> ==2461== by 0x80A734E: adapter_service_remove (adapter.c:708)
> ==2461== by 0x80994B4: sdp_record_remove (sdpd-database.c:272)
> ==2461== by 0x8098CC0: remove_record_from_server (sdpd-service.c:290)
> ==2461== by 0x8062B5B: avrcp_unregister (avrcp.c:2354)
> ==2461== by 0x409C797: g_slist_foreach (gslist.c:840)
> ==2461== by 0x80A7D77: adapter_remove (adapter.c:1630)
>
> The leak seems to only happen during bluetoothd shutdown, because the
> list of pending UUIDs is cleared when controller is removed. Therefore,
> only cleanup the list on shutdown path.
> ---
> src/mgmt.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
Applied. Thanks.
Johan
^ permalink raw reply
* [PATCH BlueZ] core: Fix memory leak from pending UUID removal
From: Anderson Lizardo @ 2012-12-22 22:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
When bluetoothd is shutting down, profile cleanup will usually issue
many "Remove UUID" management commands. These may not complete before
the process exits, resulting on this memory leak:
==2461== 144 (8 direct, 136 indirect) bytes in 1 blocks are definitely
lost in loss record 153 of 176
==2461== at 0x402BE68: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2461== by 0x40869AA: standard_malloc (gmem.c:85)
==2461== by 0x4086E42: g_malloc (gmem.c:159)
==2461== by 0x409B26D: g_slice_alloc (gslice.c:1003)
==2461== by 0x409C659: g_slist_append (gslist.c:222)
==2461== by 0x80B5E12: mgmt_remove_uuid (mgmt.c:1034)
==2461== by 0x80A734E: adapter_service_remove (adapter.c:708)
==2461== by 0x80994B4: sdp_record_remove (sdpd-database.c:272)
==2461== by 0x8098CC0: remove_record_from_server (sdpd-service.c:290)
==2461== by 0x8062B5B: avrcp_unregister (avrcp.c:2354)
==2461== by 0x409C797: g_slist_foreach (gslist.c:840)
==2461== by 0x80A7D77: adapter_remove (adapter.c:1630)
The leak seems to only happen during bluetoothd shutdown, because the
list of pending UUIDs is cleared when controller is removed. Therefore,
only cleanup the list on shutdown path.
---
src/mgmt.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/mgmt.c b/src/mgmt.c
index 52441e8..ae4a95c 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -2231,6 +2231,17 @@ fail:
void mgmt_cleanup(void)
{
+ int index;
+
+ for (index = 0; index <= max_index; index++) {
+ struct controller_info *info = &controllers[index];
+
+ if (!info->valid)
+ continue;
+
+ g_slist_free_full(info->pending_uuids, g_free);
+ }
+
g_free(controllers);
controllers = NULL;
max_index = -1;
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH BlueZ 4/4] hog: Remove pre-existing suspend FIFO
From: Marcel Holtmann @ 2012-12-22 19:56 UTC (permalink / raw)
To: Joao Paulo Rechi Vita; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CAAngNMbS0oDkxe0TQEu2mrxrf7dyViYcHZFeKgtREDd1jtp-yA@mail.gmail.com>
Hi Joao Paulo,
> >> If bluetoothd crashes the exit routine of the suspend plugin will not be
> >> executed, leaving the suspend FIFO behind and preventing the plugin load
> >> on subsequent executions. This commit checks for pre-existence of the
> >> suspend FIFO and tries to remove and re-create it.
> >> ---
> >> profiles/input/suspend-dummy.c | 16 ++++++++++++++++
> >> 1 file changed, 16 insertions(+)
> >>
> >> diff --git a/profiles/input/suspend-dummy.c b/profiles/input/suspend-dummy.c
> >> index 33b790a..43384c0 100644
> >> --- a/profiles/input/suspend-dummy.c
> >> +++ b/profiles/input/suspend-dummy.c
> >> @@ -119,6 +119,22 @@ int suspend_init(suspend_event suspend, resume_event resume)
> >>
> >> if (mkfifo(HOG_SUSPEND_FIFO, S_IRWXU) < 0) {
> >> int err = -errno;
> >> +
> >> + if (err == -EEXIST) {
> >> + DBG("FIFO (%s) already exists, trying to remove",
> >> + HOG_SUSPEND_FIFO);
> >> +
> >> + /* remove pre-existing FIFO and retry */
> >> + if (remove(HOG_SUSPEND_FIFO) < 0) {
> >
> > you are looking for unlink() to use here.
> >
>
> What's the problem with remove()? From the manpage it's part of
> stdio.h and calls unlink() for files, and rmdir() for directories.
> From my understanding if someone else created a directory on the FIFO
> path, unlink() will return with EISDIR and we would need to handle
> this error as well.
if it accidentally has been a directory with that name, then I want to
see a big fat error. Not some magic to make it work.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH BlueZ 4/4] hog: Remove pre-existing suspend FIFO
From: Joao Paulo Rechi Vita @ 2012-12-22 18:41 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CAAngNMbS0oDkxe0TQEu2mrxrf7dyViYcHZFeKgtREDd1jtp-yA@mail.gmail.com>
On Sat, Dec 22, 2012 at 3:39 PM, Joao Paulo Rechi Vita
<jprvita@openbossa.org> wrote:
> On Sat, Dec 22, 2012 at 1:36 PM, Marcel Holtmann <marcel@holtmann.org> wr=
ote:
>> Hi Joao Paulo,
>>
>>> If bluetoothd crashes the exit routine of the suspend plugin will not b=
e
>>> executed, leaving the suspend FIFO behind and preventing the plugin loa=
d
>>> on subsequent executions. This commit checks for pre-existence of the
>>> suspend FIFO and tries to remove and re-create it.
>>> ---
>>> profiles/input/suspend-dummy.c | 16 ++++++++++++++++
>>> 1 file changed, 16 insertions(+)
>>>
>>> diff --git a/profiles/input/suspend-dummy.c b/profiles/input/suspend-du=
mmy.c
>>> index 33b790a..43384c0 100644
>>> --- a/profiles/input/suspend-dummy.c
>>> +++ b/profiles/input/suspend-dummy.c
>>> @@ -119,6 +119,22 @@ int suspend_init(suspend_event suspend, resume_eve=
nt resume)
>>>
>>> if (mkfifo(HOG_SUSPEND_FIFO, S_IRWXU) < 0) {
>>> int err =3D -errno;
>>> +
>>> + if (err =3D=3D -EEXIST) {
>>> + DBG("FIFO (%s) already exists, trying to remove",
>>> + HOG_SUSPEND_FIFO)=
;
>>> +
>>> + /* remove pre-existing FIFO and retry */
>>> + if (remove(HOG_SUSPEND_FIFO) < 0) {
>>
>> you are looking for unlink() to use here.
>>
>
> What's the problem with remove()? From the manpage it's part of
> stdio.h and calls unlink() for files, and rmdir() for directories.
> From my understanding if someone else created a directory on the FIFO
> path, unlink() will return with EISDIR and we would need to handle
> this error as well.
>
And BTW, remove() is also been used on suspend_exit().
--
Jo=C3=A3o Paulo Rechi Vita
Openbossa Labs - INdT
^ permalink raw reply
* Re: [PATCH BlueZ 4/4] hog: Remove pre-existing suspend FIFO
From: Joao Paulo Rechi Vita @ 2012-12-22 18:39 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1356194171.29264.14.camel@aeonflux>
On Sat, Dec 22, 2012 at 1:36 PM, Marcel Holtmann <marcel@holtmann.org> wrot=
e:
> Hi Joao Paulo,
>
>> If bluetoothd crashes the exit routine of the suspend plugin will not be
>> executed, leaving the suspend FIFO behind and preventing the plugin load
>> on subsequent executions. This commit checks for pre-existence of the
>> suspend FIFO and tries to remove and re-create it.
>> ---
>> profiles/input/suspend-dummy.c | 16 ++++++++++++++++
>> 1 file changed, 16 insertions(+)
>>
>> diff --git a/profiles/input/suspend-dummy.c b/profiles/input/suspend-dum=
my.c
>> index 33b790a..43384c0 100644
>> --- a/profiles/input/suspend-dummy.c
>> +++ b/profiles/input/suspend-dummy.c
>> @@ -119,6 +119,22 @@ int suspend_init(suspend_event suspend, resume_even=
t resume)
>>
>> if (mkfifo(HOG_SUSPEND_FIFO, S_IRWXU) < 0) {
>> int err =3D -errno;
>> +
>> + if (err =3D=3D -EEXIST) {
>> + DBG("FIFO (%s) already exists, trying to remove",
>> + HOG_SUSPEND_FIFO);
>> +
>> + /* remove pre-existing FIFO and retry */
>> + if (remove(HOG_SUSPEND_FIFO) < 0) {
>
> you are looking for unlink() to use here.
>
What's the problem with remove()? From the manpage it's part of
stdio.h and calls unlink() for files, and rmdir() for directories.
>From my understanding if someone else created a directory on the FIFO
path, unlink() will return with EISDIR and we would need to handle
this error as well.
--
Jo=C3=A3o Paulo Rechi Vita
Openbossa Labs - INdT
^ permalink raw reply
* Re: setting BT connection over RFCOMM
From: Kevin Wilson @ 2012-12-22 17:22 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <CAGXs5wXEEnO084sg1Er-SgB3-TU+W5HtjsKnY7CdT9Hsw+jjew@mail.gmail.com>
Hi all,
Please ignore my question. It turns out that
CONFIG_BT_RFCOMM_TTY was not set.
As a result, there was an error on the server
which prevented connection establishment,
Now after setting CONFIG_BT_RFCOMM_TTY,
it works.
rgs
Kevin
On Sat, Dec 22, 2012 at 6:48 AM, Kevin Wilson <wkevils@gmail.com> wrote:
> connect rfcomm0
^ 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