2011-06-14 07:19:40

by Dmitriy Paliy

[permalink] [raw]
Subject: [PATCH 0/1] Add capability option to simple-agent

Hi,

The patch adds capability option (-c, --capability) to simple-agent.

There is one point of concern as
'optparse module is deprecated since version 2.7: The optparse module
is deprecated and will not be developed further; development will
continue with the argparse module.'

Any comments regarding use of this module are appreciated.

BR,
Dmitriy



2011-06-15 20:02:33

by Dmitriy Paliy

[permalink] [raw]
Subject: Re: [PATCH] Add capability option to simple-agent

Hi Johan,

On Wed, Jun 15, 2011 at 3:48 PM, Johan Hedberg <[email protected]> wrote:
> Applied, thanks. I think you could also fix the mandatory adapter
> argument to be consistent with the rest of the test scripts so that
> "./simple-agent <addr>" is equivalent to "./simple-agent -i hci0 <addr>".
> And please look into this argparser thing to see if we can convert all
> our scripts to use it (one pre-requisite is that it's present in the
> python versions of latest mainstream distro releases).

Thanks, sounds wise. It looks to me that bonding types would be quite
useful in simple-agent. However, how to fit those is not very clear
yet. Any opinions would be appreciated.

BR,
Dmitriy

2011-06-15 12:48:47

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH] Add capability option to simple-agent

Hi Dmitriy,

On Tue, Jun 14, 2011, Dmitriy Paliy wrote:
> A new option is added to simple-agent facilitating use of "DisplayOnly",
> "DisplayYesNo", "KeyboardOnly" and "NoInputNoOutput" agent capabilities.
> ---
> test/simple-agent | 24 +++++++++++++++++-------
> 1 files changed, 17 insertions(+), 7 deletions(-)

Applied, thanks. I think you could also fix the mandatory adapter
argument to be consistent with the rest of the test scripts so that
"./simple-agent <addr>" is equivalent to "./simple-agent -i hci0 <addr>".
And please look into this argparser thing to see if we can convert all
our scripts to use it (one pre-requisite is that it's present in the
python versions of latest mainstream distro releases).

Johan

2011-06-14 07:19:41

by Dmitriy Paliy

[permalink] [raw]
Subject: [PATCH] Add capability option to simple-agent

A new option is added to simple-agent facilitating use of "DisplayOnly",
"DisplayYesNo", "KeyboardOnly" and "NoInputNoOutput" agent capabilities.
---
test/simple-agent | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/test/simple-agent b/test/simple-agent
index f2cc3dd..8d65860 100755
--- a/test/simple-agent
+++ b/test/simple-agent
@@ -6,6 +6,7 @@ import sys
import dbus
import dbus.service
import dbus.mainloop.glib
+from optparse import OptionParser

class Rejected(dbus.DBusException):
_dbus_error_name = "org.bluez.Error.Rejected"
@@ -88,8 +89,17 @@ if __name__ == '__main__':
manager = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.bluez.Manager")

- if len(sys.argv) > 1:
- path = manager.FindAdapter(sys.argv[1])
+ capability = "DisplayYesNo"
+
+ parser = OptionParser()
+ parser.add_option("-c", "--capability", action="store",
+ type="string", dest="capability")
+ (options, args) = parser.parse_args()
+ if options.capability:
+ capability = options.capability
+
+ if len(args) > 0:
+ path = manager.FindAdapter(args[0])
else:
path = manager.DefaultAdapter()

@@ -101,17 +111,17 @@ if __name__ == '__main__':

mainloop = gobject.MainLoop()

- if len(sys.argv) > 2:
- if len(sys.argv) > 3:
- device = adapter.FindDevice(sys.argv[2])
+ if len(args) > 1:
+ if len(args) > 2:
+ device = adapter.FindDevice(args[1])
adapter.RemoveDevice(device)

agent.set_exit_on_release(False)
- adapter.CreatePairedDevice(sys.argv[2], path, "DisplayYesNo",
+ adapter.CreatePairedDevice(args[1], path, capability,
reply_handler=create_device_reply,
error_handler=create_device_error)
else:
- adapter.RegisterAgent(path, "DisplayYesNo")
+ adapter.RegisterAgent(path, capability)
print "Agent registered"

mainloop.run()
--
1.7.4.1