title: Reconnecting BLE
body: <p>We have a device that connects using BLE.</p>
  
  <p>The first connection is successful.</p>
  
  <p>But when the signal is lost, reconnection does not happen</p>
  
  <p>Connected:</p>
  
  <pre><code>ble.connect (deviceAddress, connectSuccess, connectFailed);
  </code></pre>
  
  <p>If the connection is successful, I add an event to the button</p>
  
  <pre><code>function connectSuccess (characteristic) {
      log ("connectSuccess to" + characteristic.name);
  
      var fieldState = document.getElementById ("fieldState");
      fieldState.addEventListener ("click",
          function () {readData (uuids1.StateState, "field State", "textField"); });
  }
  </code></pre>
  
  <p>When the connection fails, I interrogate the device every 10 seconds</p>
  
  <pre><code>function connectFailed (characteristic) {
      log ("connectFailed to" + characteristic.name);
      ble.disconnect (deviceAddress);
      reconnect = setTimeout (function tryToBack () {
          ble.connect (deviceAddress, sc, connectFailed);
          log ("Try Connecting !!");
          reconnect = setTimeout (tryToBack, 10000);
          },
      100);
  }
  
  function sc (data) {
      clearTimeout (reconnect);
      log ("Success reconnect to" + data.name);
      log ("with address" + deviceAddress);
      connectSuccess (data)
  }
  </code></pre>
  
  <p>But when the device is in sight, it is connected but does not respond to a button click.</p>