title: Android 4.3 Bluetooth Low Energy unstable
body: <p>I am currently developing an application that will use Bluetooth Low Energy (testing on the Nexus 4). After getting started with the official BLE APIs in Android 4.3, I have noticed that after I connect a device for the first time I am rarely able to successfully connect to / communicate with that device or any other device again.</p>
  
  <p>Following the guide <a href="http://developer.android.com/guide/topics/connectivity/bluetooth-le.html">here</a>, I can successfully connect to a device, scan services and characteristics, and read/write/receive notifications without any issues. However, after disconnecting and re-connecting, I am often unable to either scan services/characteristics or unable to complete a read/write. I can't find anything in the logs to indicate why this is happening.</p>
  
  <p>Once this happens I have to uninstall the application, disable Bluetooth, and restart the phone before it will start working again.</p>
  
  <p>Whenever a device is disconnected I make sure to call close() on the BluetoothGatt object and set it to null. Any insights?</p>
  
  <hr>
  
  <p>EDIT:<br>
  Log dumps: For these logs I rooted my phone and upped the trace levels of related items in /etc/bluetooth/bt_stack.conf</p>
  
  <p><a href="http://pastebin.com/wWrqsywZ">Successful connection</a> - First attempt after rebooting the phone and installing the app. I am able to connect, discover all services/characteristics, and read/write.</p>
  
  <p><a href="http://pastebin.com/AhZq17bU">Failed Attempt 1</a> - This is the next attempt after disconnecting from the successful connection above. It seems I was able to discover characteristics, but the first attempt to read returned a null value and disconnected soon thereafter.</p>
  
  <p><a href="http://pastebin.com/w0XjwDMW">Failed Attempt 2</a> - An example where I am not even able to discover services/characteristics.</p>
  
  <hr>
  
  <p>EDIT 2:<br>
  The device to which I am trying to connect is based on TI's CC2541 chip. I obtained a <a href="http://www.ti.com/ww/en/wireless_connectivity/sensortag/index.shtml?DCMP=sensortag&amp;HQS=sensortag-bn">TI SensorTag</a> (also based on the CC2541) to play around with and discovered that TI released <a href="http://www.ti.com/tool/sensortag-sw?DCMP=lprf-stdroid&amp;HQS=sensortag-app-android">an android app</a> for the SensorTag yesterday. However, this app has <b>the same problem.</b> I tested this on two other Nexus 4s with the same result: Connection to the SensorTag is successful the first or second time, but (according to the logs) fails to discover services thereafter, causing all sorts of crashes. I'm starting to wonder if it's an issue with this specific chip?</p>