2018-10-17 22:04:13

by Barry Byford

[permalink] [raw]
Subject: Register HID Profile

Hello,

I am still experiencing difficulties registering a profile and getting
BlueZ to call the NewConnection method when a connection attempt is
made to it.
When I try to connect from another computer, it connects briefly
before disconnecting again.

I am starting the server with the input plugin removed using:
sudo /usr/lib/bluetooth/bluetoothd -P input

A btmon log of the session is available at:
https://drive.google.com/uc?authuser=0&id=1CgPcEtj1g3Um-1qBuQ8hEImKR28bVmnx&export=download

I have looked through the log but there is nothing in there that I am
understanding to be an indicator of the issue.

I have had some success if I set up the sockets to listen for
connections with the code below. However I still don't get the
NewConnection method called in the profile I have setup.

Any guidance would be greatly appreciated.

Thanks,
Barry


print('Waiting for connections')
self.scontrol = socket.socket(socket.AF_BLUETOOTH,
socket.SOCK_SEQPACKET,
socket.BTPROTO_L2CAP)
self.scontrol.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.sinterrupt = socket.socket(socket.AF_BLUETOOTH,
socket.SOCK_SEQPACKET,
socket.BTPROTO_L2CAP)
self.sinterrupt.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# bind these sockets to a port
self.scontrol.bind((self.address, self.P_CTRL))
self.sinterrupt.bind((self.address, self.P_INTR ))

# Start listening on the server sockets
self.scontrol.listen(1) # Limit of 1 connection
self.sinterrupt.listen(1)

self.ccontrol, cinfo = self.scontrol.accept()
print('Got a connection on the control channel from ' + cinfo[0])

self.cinterrupt, cinfo = self.sinterrupt.accept()
print('Got a connection on the interrupt channel from ' + cinfo[0])