I have developped a HIDServer (bluetooth keyboard) with python on my computer. There are 2 Serversockets (psm 0x11 and 0x13) listening for connections.
When I try to connect my IPhone to my computer, I receive an incoming connection (as can be seen in hcidump), but somehow the connection is terminated by remote host. My sockets never get to accept a client connection. Can you help me please?
hcidumps:
After starting my programm:

HCI Event: Command Complete (0x0e) plen 4
      Write Extended Inquiry Response (0x03|0x0052) ncmd 1
      status 0x00

When trying to connect IPhone:

HCI Event: Connect Request (0x04) plen 10
      bdaddr 60:D9:C7:23:96:FF class 0x7a020c type ACL
HCI Event: Command Status (0x0f) plen 4
      Accept Connection Request (0x01|0x0009) status 0x00 ncmd 1
HCI Event: Connect Complete (0x03) plen 11
      status 0x00 handle 11 bdaddr 60:D9:C7:23:96:FF type ACL encrypt 0x00
HCI Event: Command Status (0x0f) plen 4
      Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1
HCI Event: Read Remote Supported Features (0x0b) plen 11
      status 0x00 handle 11
      Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
HCI Event: Command Status (0x0f) plen 4
      Read Remote Extended Features (0x01|0x001c) status 0x00 ncmd 1
HCI Event: Read Remote Extended Features (0x23) plen 13
      status 0x00 handle 11 page 1 max 2
      Features: 0x07 0x00 0x00 0x00 0x00 0x00 0x00 0x00
HCI Event: Command Status (0x0f) plen 4
      Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
HCI Event: Remote Name Req Complete (0x07) plen 255
      status 0x00 bdaddr 60:D9:C7:23:96:FF name 'iPhone'
HCI Event: Command Complete (0x0e) plen 10
      Link Key Request Reply (0x01|0x000b) ncmd 1
      status 0x00 bdaddr 60:D9:C7:23:96:FF
HCI Event: Encrypt Change (0x08) plen 4
      status 0x00 handle 11 encrypt 0x01
HCI Event: Disconn Complete (0x05) plen 4
      status 0x00 handle 11 reason 0x13
      Reason: Remote User Terminated Connection
Setting class of device in my programm in the first place did not work as it got reset. To make the HIDServer work on blueZ I had to set the class of device right before I wait for connections. I cannot say why it gets reset, but I know it does. Maybe somebody else can tell why.
Bluetooth Socket no incoming connection