title: org.bluez.error.inprogress error with bluetooth
body: <p>I have an issue where the Bluetooth got disconnected after 1-2s of connection, the master side will show the following error:</p>
  
  <pre><code>org.bluez.error.inprogress 
  </code></pre>
  
  <p>tracing to the log I saw it will enter the following func:</p>
  
  <pre><code>un 11 16:23:46 rap bluetoothd[21474]: src/device.c:search_cb() 00:0E:8E:8B:CA:9D: No service update
  Jun 11 16:23:46 rap bluetoothd[21474]: src/device.c:device_svc_resolved() /org/bluez/hci0/dev_00_0E_8E_8B_CA_9D err 0
  Jun 11 16:23:46 rap bluetoothd[21474]: src/device.c:connect_profiles() /org/bluez/hci0/dev_00_0E_8E_8B_CA_9D (all), client :1.394
  ...
  Jun 11 16:23:49 rap kernel: [12110.003903] bluetooth:l2cap_sock_release:1197: sock 0000000078f38a7c, sk 00000000f306c001
  Jun 11 16:23:49 rap  kernel: [12110.003907] bluetooth:l2cap_sock_shutdown:1113: sock 0000000078f38a7c, sk 00000000f306c001
  Jun 11 16:23:49 rap kernel: [12110.003910] bluetooth:l2cap_sock_shutdown:1123: Handling sock shutdown
  Jun 11 16:23:49 rap kernel: [12110.003913] bluetooth:l2cap_chan_hold:489: chan 0000000093211dd1 orig refcnt 3
  Jun 11 16:23:49 rap kernel: [12110.003916] bluetooth:l2cap_sock_shutdown:1132: chan 0000000093211dd1 state BT_CONNECTED
  Jun 11 16:23:49 rap kernel: [12110.003921] bluetooth:l2cap_chan_close:732: chan 0000000093211dd1 state BT_CONNECTED
  Jun 11 16:23:49 rap  kernel: [12110.003924] bluetooth:l2cap_chan_hold:489: chan 0000000093211dd1 orig refcnt 4
  Jun 11 16:23:49 rap kernel: [12110.003930] bluetooth:l2cap_build_cmd:2931: conn 000000003e9a2ca4, code 0x06, ident 0x05, len 4
  Jun 11 16:23:49 rap kernel: [12110.003936] bluetooth:l2cap_send_cmd:865: code 0x06
  </code></pre>
  
  <p>and tracing to the code in blueZ:</p>
  
  <pre><code>static DBusMessage *connect_profiles(struct btd_device *dev, uint8_t bdaddr_type,
                      DBusMessage *msg, const char *uuid)
  {
      struct bearer_state *state = get_state(dev, bdaddr_type);
      int err;
  
      DBG("%s %s, client %s", dev-&gt;path, uuid ? uuid : "(all)",
                          dbus_message_get_sender(msg));
  
      if (dev-&gt;pending || dev-&gt;connect || dev-&gt;browse)
          return btd_error_in_progress(msg);  &lt;------------------ HERE
  ...
  }
  </code></pre>
  
  <p>My question can I somehow know which condition (pending/connect/browse) is causing this error without adding editing the code as I dont have permission to do that ? and how come the blueZ will try to connect to the profile if any of this condition is in progress?</p>