WebAPI/WebBluetooth: Difference between revisions

Line 67: Line 67:
  };
  };


  interface BluetoothAdapter : EventTarget
  enum BluetoothAdapterState
  {
  {
   readonly attribute DOMString      address;
   "disabled",
   readonly attribute unsigned long class;
  "disabling",
   readonly attribute boolean        discovering;
  "enabled",
   readonly attribute DOMString      name;
   "enabling"
   readonly attribute boolean        discoverable;
  };
   readonly attribute unsigned long discoverableTimeout; // in seconds
 
   
enum BluetoothAdapterAttribute
  // array of type BluetoothDevice[]
{
  [GetterThrows]
  "unknown",
   readonly attribute any            devices;
   "state",
  "address",
   // array of type DOMString[]
   "name",
  [GetterThrows]
   "discoverable",
   readonly attribute any            uuids;
   "discovering"
  };
            attribute EventHandler  ondevicefound;
 
  [CheckPermissions="bluetooth"]
   // Fired when pairing process is completed
interface BluetoothAdapter : EventTarget {
            attribute EventHandler  onpairedstatuschanged;
   readonly attribute BluetoothAdapterState  state;
   readonly attribute DOMString             address;
   readonly attribute DOMString              name;
  readonly attribute boolean                discoverable;
   readonly attribute boolean                discovering;
   
   
  [AvailableIn=CertifiedApps]
  readonly attribute BluetoothPairingListener pairingReqs;
 
   // Fired when a2dp connection status changed
   // Fired when a2dp connection status changed
             attribute EventHandler  ona2dpstatuschanged;
             attribute EventHandler  ona2dpstatuschanged;
Line 101: Line 108:
             attribute EventHandler  onrequestmediaplaystatus;
             attribute EventHandler  onrequestmediaplaystatus;
   
   
  // Fired when attributes of BluetoothAdapter changed
            attribute EventHandler  onattributechanged;
  // Fired when a remote device gets paired with the adapter
            attribute EventHandler  ondevicepaired;
  // Fired when a remote device gets unpaired from the adapter
            attribute EventHandler  ondeviceunpaired;
  /**
    * Enable/Disable a local bluetooth adapter by asynchronus methods and return
    * its result through a Promise.
    *
    * Several onattributechanged events would be triggered during processing the
    * request, and the last one would indicate adapter.state becomes
    * enabled/disabled.
  */
   [NewObject, Throws]
   [NewObject, Throws]
   DOMRequest setName(DOMString name);
   Promise<void> enable();
   [NewObject, Throws]
   [NewObject, Throws]
   DOMRequest setDiscoverable(boolean discoverable);
   Promise<void> disable();
   [NewObject, Throws]
   [NewObject, Throws]
   DOMRequest setDiscoverableTimeout(unsigned long timeout);
   Promise<void> setName(DOMString aName);
   [NewObject, Throws]
   [NewObject, Throws]
   DOMRequest startDiscovery();
   Promise<void> setDiscoverable(boolean aDiscoverable);
   [NewObject, Throws]
   [NewObject, Throws]
   DOMRequest stopDiscovery();
   Promise<BluetoothDiscoveryHandle> startDiscovery();
   [NewObject, Throws]
   [NewObject, Throws]
   DOMRequest pair(DOMString deviceAddress);
   Promise<void> stopDiscovery();
   [NewObject, Throws]
   [NewObject, Throws]
   DOMRequest unpair(DOMString deviceAddress);
   Promise<void> Promise pair(DOMString deviceAddress);
   [NewObject, Throws]
   [NewObject, Throws]
   DOMRequest getPairedDevices();
   Promise unpair(DOMString deviceAddress);
  sequence<BluetoothDevice> getPairedDevices();
   [NewObject, Throws]
   [NewObject, Throws]
   DOMRequest getConnectedDevices(unsigned short serviceUuid);
   DOMRequest getConnectedDevices(unsigned short serviceUuid);
  [NewObject, Throws]
  DOMRequest setPinCode(DOMString deviceAddress, DOMString pinCode);
  [NewObject, Throws]
  DOMRequest setPasskey(DOMString deviceAddress, unsigned long passkey);
  [NewObject, Throws]
  DOMRequest setPairingConfirmation(DOMString deviceAddress, boolean confirmation);
   
   
  /**
  /**
  * Connect/Disconnect to a specific service of a target remote device.
    * Connect/Disconnect to a specific service of a target remote device.
  * To check the value of service UUIDs, please check "Bluetooth Assigned
    * To check the value of service UUIDs, please check "Bluetooth Assigned
  * Numbers" / "Service Discovery Protocol" for more information.
    * Numbers" / "Service Discovery Protocol" for more information.
  *
    *
  * Note that service UUID is optional. If it isn't passed when calling
    * Note that service UUID is optional. If it isn't passed when calling
  * Connect, multiple profiles are tried sequentially based on the class of
    * Connect, multiple profiles are tried sequentially based on the class of
  * device (CoD). If it isn't passed when calling Disconnect, all connected
    * device (CoD). If it isn't passed when calling Disconnect, all connected
  * profiles are going to be closed.
    * profiles are going to be closed.
  *
    *
  * Reply success if the connection of any profile is successfully
    * Reply success if the connection of any profile is successfully
  * established/released; reply error if we failed to connect/disconnect all
    * established/released; reply error if we failed to connect/disconnect all
  * of the planned profiles.
    * of the planned profiles.
  *
    *
  * @param device Remote device
    * @param device Remote device
  * @param profile 2-octets service UUID. This is optional.
    * @param profile 2-octets service UUID. This is optional.
  */
    */
   [NewObject, Throws]
   [NewObject, Throws]
   DOMRequest connect(BluetoothDevice device, optional unsigned short serviceUuid);
   DOMRequest connect(BluetoothDevice device, optional unsigned short serviceUuid);
Line 165: Line 189:
   DOMRequest isScoConnected();
   DOMRequest isScoConnected();
   
   
  /**
  /**
  * Additional HFP methods to handle CDMA network.
    * Additional HFP methods to handle CDMA network.
  *
    *
  * In GSM network we observe call operations from RIL call state changes;
    * In GSM network we observe call operations from RIL call state changes;
  * however in CDMA network RIL call states do not change under some call
    * however in CDMA network RIL call states do not change under some call
  * operations, so we need these additional methods to be informed of these
    * operations, so we need these additional methods to be informed of these
  * operations from dialer.
    * operations from dialer.
  *
    *
  * For more information please refer to bug 912005 and 925638.
    * For more information please refer to bug 912005 and 925638.
  */
    */
   [NewObject, Throws]
   [NewObject, Throws]
   DOMRequest answerWaitingCall();
   DOMRequest answerWaitingCall();
Confirmed users
891

edits