function connectToDevice(address) {
    var deviceOrPromise = connectedDevices.get(address) || null;
    if (deviceOrPromise !== null)
      return Promise.resolve(deviceOrPromise);

    var promise = adapter_broker.getAdapterBroker()
                      .then(function(adapterBroker) {
                        return adapterBroker.connectToDevice(address);
                      })
                      .then(function(device) {
                        connectedDevices.set(address, device);

                        device.ptr.setConnectionErrorHandler(function() {
                          connectedDevices.delete(address);
                        });

                        return device;
                      })
                      .catch(function(error) {
                        connectedDevices.delete(address);
                        throw error;
                      });

    connectedDevices.set(address, promise);
    return promise;
  }
/**
   * Creates a GATT connection to the device with |address|. If a connection to
   * the device already exists, the promise is resolved with the existing
   * DevicePtr. If a connection is in progress, the promise resolves when
   * the existing connection request promise is fulfilled.
   * @param {string} address
   * @return {!Promise<!bluetooth.mojom.DevicePtr>}
   */
Creates a GATT connection to the device with |address|. If a connection to
the device already exists, the promise is resolved with the existing
DevicePtr. If a connection is in progress, the promise resolves when
the existing connection request promise is fulfilled.
@param {string} address
@return {!Promise}
Creates a GATT connection to the device with |address| . If a connection to the device already exists the promise is resolved with the existing DevicePtr . If a connection is in progress the promise resolves when the existing connection request promise is fulfilled . @param { string } address @return { !Promise }
function connectToDevice(address) {
    var deviceOrPromise = connectedDevices.get(address) || null;
    if (deviceOrPromise !== null)
      return Promise.resolve(deviceOrPromise);
    var promise = adapter_broker.getAdapterBroker()
                      .then(function(adapterBroker) {
                        return adapterBroker.connectToDevice(address);
                      })
                      .then(function(device) {
                        connectedDevices.set(address, device);
                        device.ptr.setConnectionErrorHandler(function() {
                          connectedDevices.delete(address);
                        });
                        return device;
                      })
                      .catch(function(error) {
                        connectedDevices.delete(address);
                        throw error;
                      });
    connectedDevices.set(address, promise);
    return promise;
  }
function connectToDevice ( address ) { var deviceOrPromise = connectedDevices . get ( address ) || null ; if ( deviceOrPromise !== null ) return Promise . resolve ( deviceOrPromise ) ; var promise = adapter_broker . getAdapterBroker ( ) . then ( function ( adapterBroker ) { return adapterBroker . connectToDevice ( address ) ; } ) . then ( function ( device ) { connectedDevices . set ( address , device ) ; device . ptr . setConnectionErrorHandler ( function ( ) { connectedDevices . delete ( address ) ; } ) ; return device ; } ) . catch ( function ( error ) { connectedDevices . delete ( address ) ; throw error ; } ) ; connectedDevices . set ( address , promise ) ; return promise ; }
Creates a GATT connection to the device with |address|.
Creates a GATT connection to the device with |address| .