-
Notifications
You must be signed in to change notification settings - Fork 76
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
Not receiving UNIX_FD property #54
Comments
Just stumbled upon this bug as well, is there any workaround? |
Implemented support here: master...molobrakos:unixfd |
Thanks @molobrakos for taking a look at this. I've had time to do some testing tonight. It is still not coming out as I've been using |
@ukBaz, thanks for testing! The file descriptor will be received as |
I could add a proper test case to the UUID_SPP = "00001101-0000-1000-8000-00805f9b34fb"
class Profile:
def __init__(self, read_callback):
_LOGGER.debug("Init profile")
self.read_callback = read_callback
self.fd = None
def Release(self):
_LOGGER.debug("Release")
def NewConnection(self, path, fd, properties):
_LOGGER.error("New connection %s %s %s",
path, fd, properties)
if self.fd != None:
_LOGGER.error("Should not happen")
self.fd = os.dup(fd)
_LOGGER.debug("Got fd %s, dup as %d", fd, self.fd)
def fd_read_callback(fd, conditions):
_LOGGER.debug("io cb on fd %d (self.fd: %d)", fd, self.fd)
assert(self.fd == fd)
data = os.read(fd, 1024)
_LOGGER.debug("Read %d bytes: %s: %s", len(data),
binascii.hexlify(data), data.decode("ascii"))
self.read_callback(path, data.decode("ascii"))
# We are done
# os.close(self.fd)
# gobject.source_remove(io_id)
# self.fd = None
return True
io_id = GObject.io_add_watch(self.fd,
GObject.PRIORITY_DEFAULT,
GObject.IO_IN | GObject.IO_PRI,
fd_read_callback)
def RequestDisconnection(self, path):
_LOGGER.debug("RequestDisconnection: %s", path)
if self.fd:
os.close(self.fd)
# gobject.source_remove(io_id)
self.fd = None
def register_spp_profile():
profile_path = "/foo/bar/profile"
opts = dict(
AutoConnect=pydbus.Variant("b", True),
Role=pydbus.Variant("s", "server"),
Channel=pydbus.Variant("q", 1),
RequireAuthorization=pydbus.Variant("b", False),
RequireAuthentication=pydbus.Variant("b", False),
Name=pydbus.Variant("s", "Foobar")
)
_LOGGER.info("Creating Serial Port Profile")
def read_cb(path, value):
_LOGGER.debug("Read value %s", value)
pydbus.SystemBus().register_object(
profile_path,
Profile(read_cb),
pathlib.Path(__file__).with_name("btspp.xml").read_text())
blus.profile_manager().RegisterProfile(
profile_path,
UUID_SPP, opts)
_LOGGER.info("Registered profile on %s", profile_path) (Btw, I don't think I have seen |
|
Any chance this has been merged in yet? I am looking to use something like this for accepting incoming RFCOMM connections passed in from BlueZ. |
This looks similar to #42 but the suggested modifications by @LEW21 do not seem to be having an effect. However I am right at the edge of my knowledge so apologies if this is a duplicate.
I am looking to implement the BlueZ Profile DBus APi
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/profile-api.txt#n104
I have implemented, published and registered the
NewConnection
methodWhen a new connection is made the the Bluetooth daemon calls the
NewConnection
method but the value of fd is wrong:I say wrong because it gives the tty of the terminal I'm running in and If I monitor the bus then I can see the bluetoothd sending the command with UNIX_FD = 4
To confirm what the sender is
Versions I am running
As I say, I am right on the edge of my knowledge so I am not sure how to fix this. If someone can give me some guidance then I am willing to do more on this.
The text was updated successfully, but these errors were encountered: