* [PATCH BlueZ] device: Fix probing service twice
@ 2018-02-19 15:49 Luiz Augusto von Dentz
2018-02-19 15:49 ` [PATCH BlueZ] shared/shell: Add non-interactive mode Luiz Augusto von Dentz
2018-02-20 14:58 ` [PATCH BlueZ] device: Fix probing service twice Luiz Augusto von Dentz
0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2018-02-19 15:49 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If there is already a service for a given profile there is no point in
probing it again.
---
src/device.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/device.c b/src/device.c
index 1acecce33..0da4184f6 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4202,6 +4202,7 @@ static struct btd_service *probe_service(struct btd_device *device,
struct btd_profile *profile,
GSList *uuids)
{
+ GSList *l;
struct btd_service *service;
if (profile->device_probe == NULL)
@@ -4210,6 +4211,10 @@ static struct btd_service *probe_service(struct btd_device *device,
if (!device_match_profile(device, profile, uuids))
return NULL;
+ l = find_service_with_profile(device->services, profile);
+ if (l)
+ return l->data;
+
service = service_create(device, profile);
if (service_probe(service)) {
--
2.14.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH BlueZ] shared/shell: Add non-interactive mode
2018-02-19 15:49 [PATCH BlueZ] device: Fix probing service twice Luiz Augusto von Dentz
@ 2018-02-19 15:49 ` Luiz Augusto von Dentz
2018-02-20 14:58 ` [PATCH BlueZ] device: Fix probing service twice Luiz Augusto von Dentz
1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2018-02-19 15:49 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This detects if any command was given as parameter, execute it and
exit disabling all other outputs:
bluetoothctl list
Controller 00:1B:DC:07:31:88 Vudentz's T460s #1 [default]
Controller B8:8A:60:D8:17:D7 BlueZ-1
---
src/shared/shell.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/src/shared/shell.c b/src/shared/shell.c
index 12330ff53..01a62074f 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -55,6 +55,9 @@
cmd, (int)(CMD_LENGTH - strlen(cmd)), "", desc)
static GMainLoop *main_loop;
+static int exec_argc;
+static char **exec_argv;
+static bool interactive;
struct bt_shell_env {
char *name;
@@ -373,6 +376,9 @@ void bt_shell_printf(const char *fmt, ...)
char *saved_line;
int saved_point;
+ if (!interactive)
+ return;
+
save_input = !RL_ISSTATE(RL_STATE_DONE);
if (save_input) {
@@ -784,6 +790,9 @@ void bt_shell_init(int argc, char **argv, const struct bt_shell_opt *opt)
} else
snprintf(optstr, sizeof(optstr), "+hv");
+ exec_argc = --argc;
+ exec_argv = &argv[1];
+
while ((c = getopt_long(argc, argv, optstr, options, &index)) != -1) {
switch (c) {
case 'v':
@@ -876,7 +885,7 @@ bool bt_shell_add_submenu(const struct bt_shell_menu *menu)
void bt_shell_set_prompt(const char *string)
{
- if (!main_loop)
+ if (!main_loop || !interactive)
return;
rl_set_prompt(string);
@@ -899,6 +908,16 @@ bool bt_shell_attach(int fd)
if (data.input)
return false;
+ if (exec_argc > 0) {
+ interactive = true;
+ shell_exec(exec_argc, exec_argv);
+ interactive = false;
+
+ g_main_loop_quit(main_loop);
+
+ return false;
+ }
+
io = io_new(fd);
io_set_read_handler(io, input_read, NULL, NULL);
--
2.14.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH BlueZ] device: Fix probing service twice
2018-02-19 15:49 [PATCH BlueZ] device: Fix probing service twice Luiz Augusto von Dentz
2018-02-19 15:49 ` [PATCH BlueZ] shared/shell: Add non-interactive mode Luiz Augusto von Dentz
@ 2018-02-20 14:58 ` Luiz Augusto von Dentz
1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2018-02-20 14:58 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
Hi,
On Mon, Feb 19, 2018 at 5:49 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> If there is already a service for a given profile there is no point in
> probing it again.
> ---
> src/device.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/src/device.c b/src/device.c
> index 1acecce33..0da4184f6 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -4202,6 +4202,7 @@ static struct btd_service *probe_service(struct btd_device *device,
> struct btd_profile *profile,
> GSList *uuids)
> {
> + GSList *l;
> struct btd_service *service;
>
> if (profile->device_probe == NULL)
> @@ -4210,6 +4211,10 @@ static struct btd_service *probe_service(struct btd_device *device,
> if (!device_match_profile(device, profile, uuids))
> return NULL;
>
> + l = find_service_with_profile(device->services, profile);
> + if (l)
> + return l->data;
> +
> service = service_create(device, profile);
>
> if (service_probe(service)) {
> --
> 2.14.3
Applied, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-20 14:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-19 15:49 [PATCH BlueZ] device: Fix probing service twice Luiz Augusto von Dentz
2018-02-19 15:49 ` [PATCH BlueZ] shared/shell: Add non-interactive mode Luiz Augusto von Dentz
2018-02-20 14:58 ` [PATCH BlueZ] device: Fix probing service twice Luiz Augusto von Dentz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).