-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bluetooth not detected #1
Comments
ran into the same thing. Looks like in the newer version of pybluez, they took out some of the functions like "DefaultAdapter", so it errors in the try/catch as "Please turn on bluetooth". Is there a known version of pybluez where this works or an update coming. This looks pretty polished and I'd like to see it working. |
I met the same problem. |
I'm also interested in seeing this work. I'll see if I can modify it myself and make a pull-request. |
Fixed that problem, so I'll include the patch. Unfortunately since this was written in such an old version of Bluez I'm sure there's other problems. For now I think this is the best option: Patch for this issue included below diff --git a/Bluetooth.py b/Bluetooth.py
index 2c47609..6d2267b 100644
--- a/Bluetooth.py
+++ b/Bluetooth.py
@@ -1,5 +1,8 @@
from bluetooth import *
import dbus # Used to set up the SDP record
+import sys
+import os
+
class Bluetooth:
"""docstring for Gamepad"""
HOST = 0
@@ -17,21 +20,26 @@ class Bluetooth:
self.sockinter.bind(("",Bluetooth.P_INTR))
self.bus = dbus.SystemBus()
- try:
- self.manager = dbus.Interface(self.bus.get_object("org.bluez", "/"), "org.bluez.Manager")
- adapter_path = self.manager.DefaultAdapter()
- self.service = dbus.Interface(self.bus.get_object("org.bluez", adapter_path),"org.bluez.Service")
- except Exception, e:
- sys.exit("Please turn on bluetooth")
+ self.manager = dbus.Interface(self.bus.get_object("org.bluez", "/org/bluez"), "org.bluez.ProfileManager1")
+
try:
fh = open(sdp,"r")
except Exception, e:
- sys.exit("Cannot open sdp_record file")
+ sys.exit("Cannot open sdp_record file, " + str(e))
+
self.service_record = fh.read()
+
+ opts = {
+ "ServiceRecord":self.service_record,
+ "Role":"server",
+ "RequireAuthentication":False,
+ "RequireAuthorization":False
+ }
+
+ self.manager.RegisterProfile("/bluez/profile", self.UUID, opts)
fh.close()
def listen(self):
- self.service.handle = self.service.AddRecord(self.service_record)
os.system("sudo hciconfig hci0 class "+self.classname)
os.system("sudo hciconfig hci0 name "+self.devname)
self.soccontrol.listen(1) |
BTGamepad always return " Please turn on bluetooth " after the choice of gamepad or keyboard on ubuntu 16
The text was updated successfully, but these errors were encountered: