* [Bluez-devel] [GSoC2008]bluez-python status
@ 2008-06-29 16:22 Li Dongyang
0 siblings, 0 replies; 2+ messages in thread
From: Li Dongyang @ 2008-06-29 16:22 UTC (permalink / raw)
To: bluez-devel
hi, everyone,
This is Li Dongyang working on bluez-python as a GSoC 2008 project.
Now I'm at home and just pushed Agent to gitorious.
The git repo is here: http://gitorious.org/projects/bluez-python
and the wiki page is here: http://wiki.bluez.org/wiki/bluez-python
I update the wiki after every change.
so far we have done:
Manager, Adapter, Device and Agent classes according to the BlueZ 4.0 API.
every class(except Agent) have a method HandleSignal(handler, signal) to
make you deal with spec signals with your own handler.
Manager:
The Manager is a singleton since many managers won't make sense, If you
wanna have mainloop support, you should pass an arg to Manager's __init__
describing which mainloop you wanna have, like "manager =
bluez.Manager('gobject')" will have gobject support. Mainloops supported
currently are 'gobject', 'pyqt4' and 'ecore'.
Manager have a method called GetAdapter(pattern=None), if the pattern is
None by default, it will call the DefaultAdapter() on the bluez dbus
interface, init an instance of Adapter with the return value(object path of
the default adapter), then return the Adapter instance. Otherwise it will
call FindAdapter(pattern). the pattern could be 'hci0'
or "00:11:22:33:44:55".
and the ListAdapter() return a list of Agent instances, not object paths.
also a CreateAgent() for Agent usage, more details in the Agent section.
Adapter:
The methods return instance of Device instead of object path, also some
require instance of Device or Agent instead of object path, others act same
as doc/adapter-api.txt
Device:
add one more method GetObjectPath() to return object path. others same as
doc/device-api.txt
Agent:
add one more method GetObjectPath(), same as Device's
by default the Agent acts as hcid/simple-agent, you can inherit the Agent
and use AgentMethod decorator to define your own agent.
The CreateAgent(cls=Agent, obj_path='/org/bluez/Agent') of Manager is used
to init an agent, please notice the agent need mainloop support to init.
if you call CreateAgent() without args, it will give you the default Agent
instance and the object path is '/org/bluez/Agent'. if you wanna define your
own agent, you can do as follows:
import bluez
import gobject
class my_agent(bluez.Agent):
@bluez.AgentMethod
def ConfirmModeChange(self, mode):
print mode
manager = bluez.Manager('gobject')
adapter = manager.GetAdapter()
agent = manager.CreateAgent(my_agent)
adapter.RegisterAgent(agent)
mainloop = gobject.MainLoop()
try:
mainloop.run()
except KeyboardInterrupt:
mainloop.quit()
This example can make my_agent, and just overwrite the ConfirmModeChange()
method.
If you wish to overwrite agent method with async_callbacks, just do this:
class my_agent(bluez.Agent):
@AgentMethod
def ConfirmModeChange(self, mode, success_callback, error_callback)
and AgentMethod will check the arg of the method with inspect module, if the
len(arg) is 3 more than the in-signature(including the 'self'), it will build
up async_callbacks tuple and pass it to decorator dbus.service.method, that's
how the async_callbacks works.
If you have better ideas, or feed back, please do contact me, your suggestions
are really very important. Thanks in advance!
You can reach me at: Jerry87905@gmail.com
or missed at irc.freenode.org
ps: The ISP I use at home always reset my connection to freenode every 3-5
minutes, so the best way is to mail me.
Cheers,
Li Dongyang
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 2+ messages in thread* [Bluez-devel] [GSoC2008]bluez-python status
@ 2008-08-01 14:26 Li Dongyang
0 siblings, 0 replies; 2+ messages in thread
From: Li Dongyang @ 2008-08-01 14:26 UTC (permalink / raw)
To: bluez-devel
Hi, all
This is Li Dongyang working on bluez-python
And What's new from the last status report:
1.a fix that can make async call with CreatePairedDevice(), user should pass
reply_handler and error_handler
The reply_handler will receive a Device instance as the parameter, the
error_handler will receive an exception(our custom dbus exception, see
errors.py) as the parameter.
2.add the docstrings for all the methods, based on the docs in /doc/XXX-
api.txt
3.still some doc work, like license headers, and AUTHORS, ChangeLog, README,
COPYING file
and a setup script to make python package
What to be done is the plugin, My mentor and me are discussing which is the
best way to represent it, and make it can handler new plugins in the future.
Feel free to tell me if you have ideas about it ;-)
Cheers,
Li Dongyang
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-08-01 14:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-29 16:22 [Bluez-devel] [GSoC2008]bluez-python status Li Dongyang
-- strict thread matches above, loose matches on Subject: below --
2008-08-01 14:26 Li Dongyang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox