Al Johnson <[email protected]> writes:
> emtooth is a bluetooth manager that supports FSO. blueman is a bluetooth
> manager that doesn't now abut FSO, so needs to be wrapped with fsoraw. I
> don't
> want to have to start such an app just to have bluetooth running, so I would
> go via Settings, quick-settings or even a script that toggles bluetooth
> policy
> between auto and enabled.
>
>> As I said in my response to Al, I don't fully understand what the scope
>> of emtooth is, and where the dividing line is between emtooth and
>> shr-settings. Could you explain your vision of that?
>>
>> E.g. is emtooth for setting discoverability, and managing pairing; or
>> could it also be the place for configuring particular services such
>> as GPS?
>
> emtooth is (I think) aiming more for functionality like blueman, but with a
> finger-friendly interface. It covers discoverability and pairing, but goes
> somewhat further to cover things like OBEX. I haven't looked at a recent
> version to see how far down that road it has come.
>
> I guess that puts it beyond the scope of Settings, though I suppose that
> could
> check to see which bluetooth managers were installed and include a button to
> invoke one.
Thanks for explaining those points. On reflection, perhaps it's best -
rather than putting the BtGPS function inside shr-settings - to wait a
bit to see how the bluetooth managers pan out. After all, BtGPS is
already pretty accessible, as an icon on the home page.
For now, therefore, I've just cleaned up (IMO) BtGPS.py a bit, and my
latest version is attached. The changes with respect to Angus's version
are:
- No GUI buttons. The GPS function is simply started when the app is
launched, and stopped when the window is destroyed.
- Separation of the Bt/GPS code from the GUI code. This has no
immediate effect, but makes things clearer and enables a possible
future non-GUI version.
- Use gpspipex (also attached) instead of gpspipe.
It could also do with an incantation to start bluetoothd if it isn't
already running, but I haven't done that yet (and am not immediately
sure how to code it).
Regards,
Neil
#!/usr/bin/python
#
# Copyright (C) 2008 Angus Ainslie <[email protected]>.
# Copyright (C) 2011 Neil Jerram <[email protected]>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import sys
import pygtk
pygtk.require('2.0')
import gtk
import os
import time
import dbus
import subprocess
import os, sys
from stat import *
VERSION = 0.5
class BtGPS:
def __init__(self):
self.bus = dbus.SystemBus()
obj = self.bus.get_object('org.freesmartphone.ousaged', '/org/freesmartphone/Usage')
self.usageIf = dbus.Interface(obj, 'org.freesmartphone.Usage' )
self.usageIf.RequestResource( "Bluetooth" )
self.usageIf.RequestResource( "GPS" )
time.sleep( 2.0 )
self.powerOnBT()
out = os.system( "lsusb" )
print out
obj = self.bus.get_object('org.bluez', '/')
self.manager = dbus.Interface(obj, 'org.bluez.Manager')
self.adapterPath = self.manager.DefaultAdapter()
obj = self.bus.get_object('org.bluez', self.adapterPath )
self.adapter = dbus.Interface(obj, 'org.bluez.Adapter')
props = self.adapter.GetProperties()
print "Props ", props
self.powerOnBT()
out = os.system( "lsusb" )
print out
self.start()
def powerOnBT( self ) :
while not self.CheckForUSBDev( '0a12', '0001' ) :
time.sleep( 0.5 )
def CheckForUSBDev( self, idVendor, idProduct ):
sys_path = '/sys/bus/usb/devices/'
print "Checking ", idVendor, idProduct
for f in os.listdir(sys_path):
vendor = False
product = False
pathname = os.path.join( sys_path , f )
mode = os.stat(pathname)[ST_MODE]
if S_ISDIR(mode):
# It's a directory, recurse into it
vendorPath = os.path.join( pathname , 'idVendor' )
mode = os.stat( vendorPath )[ST_MODE]
if S_ISREG(mode):
# It's a file, call the callback function
vendorFd = os.open( vendorPath, os.O_RDONLY )
id = os.read( vendorFd, 4 )
os.close( vendorFd )
if id == idVendor :
vendor = True
productPath = os.path.join( pathname , 'idProduct' )
mode = os.stat( productPath )[ST_MODE]
if S_ISREG(mode):
# It's a file, call the callback function
productFd = os.open( productPath, os.O_RDONLY )
id = os.read( productFd, 4 )
os.close( productFd )
if id == idProduct :
product = True
if idProduct and idVendor :
print "Found"
return True
print "Not Found"
return False
def start( self ):
self.adapter.SetProperty( "Discoverable", True )
# This is overkill but if the is an rfcomm process running
# on /dev/rfcomm0 this script will get badly hungup
os.system( "killall rfcomm" )
os.system( "killall gpspipex" )
subprocess.Popen( "/usr/bin/sdptool add SP", shell = True )
self.pid = subprocess.Popen( 'rfcomm -r watch 0 1 sh -c "gpspipex -r >/dev/rfcomm0" &', shell = True )
def destroy(self):
os.system( "killall rfcomm" )
os.system( "killall gpspipex" )
self.usageIf.ReleaseResource( "Bluetooth" )
self.usageIf.ReleaseResource( "GPS" )
class BtGPSGUI:
def __init__(self):
self.gps = BtGPS()
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("destroy", self.destroy)
self.window.set_title( "Bluetooth GPS" )
self.window.set_border_width(10)
self.window.set_size_request(400, 300)
self.scrolled_window = gtk.ScrolledWindow()
self.scrolled_window.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC )
self.vBox = gtk.VBox( False, 1 )
self.window.add( self.scrolled_window )
self.scrolled_window.add_with_viewport( self.vBox )
self.label = gtk.Label("BtGPS")
self.vBox.pack_start(self.label)
self.vBox.show()
self.label.show()
self.scrolled_window.show()
self.window.show()
gtk.main()
def destroy(self, widget, data=None):
self.gps.destroy()
gtk.main_quit()
if __name__ == "__main__":
BtGPSGUI()
#!/bin/sh
(
echo "r+"
while true; do sleep 60; done
) | nc localhost 2947
_______________________________________________
Shr-User mailing list
[email protected]
http://lists.shr-project.org/mailman/listinfo/shr-user