B2G/Bluetooth/WebBluetooth-v2/BluetoothManager: Difference between revisions

Line 53: Line 53:
; Parameter
; Parameter
: ''aAttributeEvent''
: ''aAttributeEvent''
:: The event is a [[B2G/Bluetooth/WebBluetooth-v2/BluetoothAttributeEvent#Interface|BluetoothAttributeEvent]] with property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothAttributeEvent#attr|attr]] as a [[B2G/Bluetooth/WebBluetooth-v2/BluetoothManager#BluetoothManagerAttribute|BluetoothManagerAttribute]].
:: The event is a [[B2G/Bluetooth/WebBluetooth-v2/BluetoothAttributeEvent#Interface|BluetoothAttributeEvent]] with property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothAttributeEvent#attrs|attrs]] that contains a [[B2G/Bluetooth/WebBluetooth-v2/BluetoothManager#BluetoothManagerAttribute|BluetoothManagerAttribute]].


; Sample
; Sample
  var manager = navigator.mozBluetooth;
  var manager = navigator.mozBluetooth;
  manager.onattributechanged = function onManagerAttributeChanged(evt) {
  manager.onattributechanged = function onManagerAttributeChanged(evt) {
   var attr = evt.attr;
   for (var attr in evt.attrs) {
  var value = evt.value;
    switch (attr) {
      case BluetoothManagerAttribute.defaultAdapter:
  switch (attr) {
        console.log("defaultAdapter changed. address:", manager.defaultAdapter.address);
    case BluetoothManagerAttribute.defaultAdapter:
        break;
      console.log("defaultAdapter changed. address:", value.address);
      default:
      break;
        break;
    default:
    }
      break;
   }
   }
  }
  }
Confirmed users
891

edits