From: Marcin Kraglak <marcin.kraglak@tieto.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: ERAMOTO Masaya <eramoto.masaya@jp.fujitsu.com>,
"linux-bluetooth@vger.kernel.org"
<linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH 1/4] shared/bt_shell: Add initial implementation
Date: Mon, 06 Nov 2017 14:24:08 +0100 [thread overview]
Message-ID: <1509974648.26101.1.camel@tieto.com> (raw)
In-Reply-To: <CABBYNZJLU=mkTU8cFJOk6pejPJoG2q7BMNfN+Xt2a8=o-Mu9Tw@mail.gmail.com>
Hi Luiz,
On Mon, 2017-10-23 at 14:42 +0300, Luiz Augusto von Dentz wrote:
> Hi Marcin,
>
> On Fri, Sep 22, 2017 at 10:52 AM, Marcin Kraglak
> <marcin.kraglak@tieto.com> wrote:
> > Hi Luiz Eramoto,
> >
> > On 22 September 2017 at 03:42, Luiz Augusto von Dentz
> > <luiz.dentz@gmail.com> wrote:
> > > Hi Eramoto, Marcin,
> > >
> > > On Fri, Sep 22, 2017 at 9:27 AM, ERAMOTO Masaya
> > > <eramoto.masaya@jp.fujitsu.com> wrote:
> > > > Hi Marcin,
> > > >
> > > > > +#ifdef HAVE_CONFIG_H
> > > > > +#include <config.h>
> > > > > +#endif
> > > > > +
> > > > > +#include <stdio.h>
> > > > > +#include "src/shared/util.h"
> > > > > +#include "src/shared/queue.h"
> > > > > +#include "src/shared/bt_shell.h"
> > > > > +
> > > > > +#define CMD_LENGTH 48
> > > > > +
> > > > > +static struct {
> > > > > + const struct bt_shell_menu_entry *current;
> > > > > +} bt_shell_data;
> > > > > +
> > > > > +bool bt_shell_init(const struct bt_shell_menu_entry *menu)
> > > > > +{
> > > > > + if (bt_shell_data.current || !menu)
> > > > > + return false;
> > > > > +
> > > > > + bt_shell_data.current = menu;
> > > > > +
> > > > > + return true;
> > > > > +}
> > > > > +
> > > > > +void bt_shell_cleanup(void)
> > > > > +{
> > > > > + bt_shell_data.current = NULL;
> > > > > +}
> > > > > +
> > > > > +void bt_shell_process(const char *cmd, const char *arg)
> > > > > +{
> > > > > + const struct bt_shell_menu_entry *entry;
> > > > > +
> > > > > + if (!bt_shell_data.current || !cmd)
> > > > > + return;
> > > > > +
> > > > > + for (entry = bt_shell_data.current; entry->cmd;
> > > > > entry++) {
> > > > > + if (strcmp(cmd, entry->cmd))
> > > > > + continue;
> > > > > +
> > > > > + if (entry->func) {
> > > > > + entry->func(arg);
> > > > > + return;
> > > > > + }
> > > > > + }
> > > > > +
> > > > > + if (strcmp(cmd, "help")) {
> > > > > + printf("Invalid command\n");
> > > > > + return;
> > > > > + }
> > > > > +
> > > > > + bt_shell_print_menu();
> > > > > +}
> > > > > +
> > > > > +void bt_shell_print_menu(void)
> > > > > +{
> > > > > + const struct bt_shell_menu_entry *entry;
> > > > > +
> > > > > + if (!bt_shell_data.current)
> > > > > + return;
> > > > > +
> > > > > + printf("Available commands:\n");
> > > > > + for (entry = bt_shell_data.current; entry->cmd;
> > > > > entry++) {
> > > > > + printf(" %s %-*s %s\n", entry->cmd,
> > > > > + (int)(CMD_LENGTH -
> > > > > strlen(entry->cmd)),
> > > > > + entry->arg ? : "",
> > > > > entry->desc ? : "");
> > > >
> > > >
> > > > I think that it is better to
> > > > - add some white-spaces
> > > > or
> > > > - add a new line
> > > > between the argument string and the description string, because
> > > > it is a little
> > > > difficult for the help of register-characteristic to read as
> > > > below:
> > > >
> > > > [bluetooth]# help
> > > > Available commands:
> > > > ...
> > > > unregister-service
> > > > <UUID/object> Unregister application service
> > > > register-characteristic <UUID> <Flags=read,write,notify...>
> > > > Register application characteristic
> > > > unregister-characteristic
> > > > <UUID/object> Unregister application characteristic
> > > > register-descriptor <UUID> <Flags=read,write...> Register
> > > > application descriptor
> > >
> > > It should probably have the same formatting as bluetoothctl:
> > >
> > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/client/ma
> > > in.c#n2677
> > >
> > > --
> > > Luiz Augusto von Dentz
> >
> > Yes, I'll correct it
>
> Are you still working on this?
>
No, unfortunatelly I don't have enough time to finish it.
BR
Marcin
next prev parent reply other threads:[~2017-11-06 13:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-22 4:59 [PATCH 0/4] Move common client code to bt_shell Marcin Kraglak
2017-09-22 4:59 ` [PATCH 1/4] shared/bt_shell: Add initial implementation Marcin Kraglak
2017-09-22 6:27 ` ERAMOTO Masaya
2017-09-22 7:42 ` Luiz Augusto von Dentz
2017-09-22 7:52 ` Marcin Kraglak
2017-10-23 11:42 ` Luiz Augusto von Dentz
2017-11-06 13:24 ` Marcin Kraglak [this message]
2017-11-06 13:25 ` Luiz Augusto von Dentz
2017-11-06 13:52 ` Marcel Holtmann
2017-11-06 13:59 ` Luiz Augusto von Dentz
2017-09-22 5:00 ` [PATCH 2/4] client: Use bt_shell to process commands Marcin Kraglak
2017-09-22 5:00 ` [PATCH 3/4] shared/bt_shell: Add bt_shell_completion Marcin Kraglak
2017-09-22 5:00 ` [PATCH 4/4] client: Use bt_shell_completion Marcin Kraglak
2017-09-22 7:47 ` Luiz Augusto von Dentz
2017-09-22 8:00 ` Marcin Kraglak
2017-09-22 8:09 ` Luiz Augusto von Dentz
2017-11-06 12:34 ` [PATCH 0/4] Move common client code to bt_shell Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1509974648.26101.1.camel@tieto.com \
--to=marcin.kraglak@tieto.com \
--cc=eramoto.masaya@jp.fujitsu.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.