Revision 464039 of WifiManager

  • Revision slug: Web/API/WifiManager
  • Revision title: WifiManager
  • Revision id: 464039
  • Created:
  • Creator: Jeremie
  • Is current revision? No
  • Comment

Revision Content

{{ non-standard_header() }}

{{ B2GOnlyHeader2('certified') }}

Summary

The WifiManager API provides access to the wifi device capability.

Interface

interface WifiManager {
  readonly attribute boolean enabled;
  readonly attribute string macAddress;
  readonly attribute ? connection;
  readonly attribute ?? connectionInformation;

  attribute nsIDOMEventListener onenabled;
  attribute nsIDOMEventListener ondisabled;
  attribute nsIDOMEventListener onstatuschange;
  attribute nsIDOMEventListener connectionInfoUpdate;

  DOMRequest getNetworks();
  DOMRequest getKnownNetworks();
  DOMRequest associate( ? network);
  DOMRequest forget( ? network);
  DOMRequest wps( ? detail);
  DOMRequest setPowerSavingMode(boolean enabled);
  DOMRequest setStaticIpMode( ? network, ? info)
};

Properties

{{domxref("WifiManager.enabled")}}
A boolean Indicating whether the wifi is on (true) or off (false)
{{domxref("WifiManager.macAddress")}}
A string representing the wifi adapter's MAC address
{{domxref("WifiManager.connection")}}
A non-null object containing the following information:
status (one of "disconnected", "connecting", "associated", or "connected")
network
{{domxref("WifiManager.connectionInformation")}}
A connectionInformation object with the same information found in a {{domxref("MozWifiConnectionInfoEvent")}} (but without the network). This will be null if the device is not connected to the Wifi.

Event handlers

{{domxref("WifiManager.onenabled")}}
A handler for the {{event("enabled")}} event; It is triggered when the wifi has been turned on.
{{domxref("WifiManager.ondisabled")}}
A handler for the {{event("disabled")}} event; It is triggered when the wifi has been turned off.
{{domxref("WifiManager.onstatuschanged")}}
A handler for the {{event("statuschanged")}} event; The event object is a {{domxref("MozWifiStatusChangeEvent")}} instance.
{{domxref("WifiManager.connectionInfoUpdate")}}
A handler for the {{event("connectionInfoUpdate")}} event; Triggered any time the connection information changes. The event object is a {{domxref("MozWifiConnectionInfoEvent")}} instance.

Events

  • {{event("disconnected")}} (when the device either fails to connect to an access point (transition: associated -> disconnected) or when we were connected to a network but have disconnected for any reason (transition: connected -> disconnected))
  • {{event("connecting")}} (when the process of connecting to a network begins)
  • {{event("associated")}} (when the device is connected to an access point but does not have an IP address yet)
  • {{event("connected")}} (when the device is fully connected via wifi and ready)

Methods

{{domxref("WifiManager.associate()")}}
Returns a {{domxref("DOMRequest")}}
{{domxref("WifiManager.forget()")}}
Returns a {{domxref("DOMRequest")}}
{{domxref("WifiManager.getKnownNetworks()")}}
Returns a {{domxref("DOMRequest")}}
{{domxref("WifiManager.getNetworks()")}}
Returns a {{domxref("DOMRequest")}}; the success value is an object with property names being the SSID and the values are surrounding wifi network descriptors... or maybe an array?
{{domxref("WifiManager.setPowerSavingMode()")}}
Returns a {{domxref("DOMRequest")}}
{{domxref("WifiManager.setStaticIpMode()")}}
Returns a {{domxref("DOMRequest")}}
{{domxref("WifiManager.wps()")}}
Returns a {{domxref("DOMRequest")}}

Specification

Not part of any specification

See also

  • {{domxref("window.navigator.mozWifiManager","navigator.mozWifiManager")}}

Revision Source

<p>{{ non-standard_header() }}</p>
<p>{{ B2GOnlyHeader2('certified') }}</p>
<h2 id="Summary">Summary</h2>
<p>The WifiManager API provides access to the wifi device capability.</p>
<h2 id="Interface">Interface</h2>
<pre>
interface WifiManager {
  readonly attribute boolean enabled;
  readonly attribute string macAddress;
  readonly attribute ? connection;
  readonly attribute ?? connectionInformation;

  attribute nsIDOMEventListener onenabled;
  attribute nsIDOMEventListener ondisabled;
  attribute nsIDOMEventListener onstatuschange;
  attribute nsIDOMEventListener connectionInfoUpdate;

  DOMRequest getNetworks();
  DOMRequest getKnownNetworks();
  DOMRequest associate( ? network);
  DOMRequest forget( ? network);
  DOMRequest wps( ? detail);
  DOMRequest setPowerSavingMode(boolean enabled);
  DOMRequest setStaticIpMode( ? network, ? info)
};
</pre>
<h2 id="Properties">Properties</h2>
<dl>
  <dt>
    {{domxref("WifiManager.enabled")}}</dt>
  <dd>
    A boolean Indicating whether the wifi is on (<code>true</code>) or off (<code>false</code>)</dd>
  <dt>
    {{domxref("WifiManager.macAddress")}}</dt>
  <dd>
    A string representing the wifi adapter's <a href="http://en.wikipedia.org/wiki/MAC_address" title="http://en.wikipedia.org/wiki/MAC_address">MAC address</a></dd>
  <dt>
    {{domxref("WifiManager.connection")}}</dt>
  <dd>
    A non-<code>null</code> object containing the following information:</dd>
  <dd>
    <strong>status</strong> (one of<code> "disconnected"</code>, <code>"connecting"</code>, <code>"associated"</code>, or <code>"connected"</code>)<br />
    <strong>network</strong></dd>
  <dt>
    {{domxref("WifiManager.connectionInformation")}}</dt>
  <dd>
    A <code>connectionInformation</code> object with the same information found in a {{domxref("MozWifiConnectionInfoEvent")}} (but without the <code>network</code>). This will be <code>null</code> if the device is not connected to the Wifi.</dd>
</dl>
<h3 id="Event_handlers">Event handlers</h3>
<dl>
  <dt>
    {{domxref("WifiManager.onenabled")}}</dt>
  <dd>
    A handler for the {{event("enabled")}} event; It is triggered when the wifi has been turned on.</dd>
  <dt>
    {{domxref("WifiManager.ondisabled")}}</dt>
  <dd>
    A handler for the {{event("disabled")}} event; It is triggered when the wifi has been turned off.</dd>
  <dt>
    {{domxref("WifiManager.onstatuschanged")}}</dt>
  <dd>
    A handler for the {{event("statuschanged")}} event; The event object is a {{domxref("MozWifiStatusChangeEvent")}} instance.</dd>
  <dt>
    {{domxref("WifiManager.connectionInfoUpdate")}}</dt>
  <dd>
    A handler for the {{event("connectionInfoUpdate")}} event; Triggered any time the connection information changes. The event object is a {{domxref("MozWifiConnectionInfoEvent")}} instance.</dd>
</dl>
<h4 id="Events">Events</h4>
<ul>
  <li>{{event("disconnected")}} (when the device either fails to connect to an access point (transition: associated -&gt; disconnected) or when we were connected to a network but have disconnected for any reason (transition: connected -&gt; disconnected))</li>
  <li>{{event("connecting")}} (when the process of connecting to a network begins)</li>
  <li>{{event("associated")}} (when the device is connected to an access point but does not have an IP address yet)</li>
  <li>{{event("connected")}} (when the device is fully connected via wifi and ready)</li>
</ul>
<h2 id="Methods">Methods</h2>
<dl>
  <dt>
    {{domxref("WifiManager.associate()")}}</dt>
  <dd>
    Returns a {{domxref("DOMRequest")}}</dd>
  <dt>
    {{domxref("WifiManager.forget()")}}</dt>
  <dd>
    Returns a {{domxref("DOMRequest")}}</dd>
  <dt>
    {{domxref("WifiManager.getKnownNetworks()")}}</dt>
  <dd>
    Returns a {{domxref("DOMRequest")}}</dd>
  <dt>
    {{domxref("WifiManager.getNetworks()")}}</dt>
  <dd>
    Returns a {{domxref("DOMRequest")}}; the success value is an object with property names being the SSID and the values are surrounding wifi network descriptors... <a href="https://github.com/mozilla-b2g/gaia/blob/079b57f45f2e272ceb4e0f3f067cc3d829b3f2b4/apps/settings/js/wifi.js#L331-L334" title="https://github.com/mozilla-b2g/gaia/blob/079b57f45f2e272ceb4e0f3f067cc3d829b3f2b4/apps/settings/js/wifi.js#L331-L334">or maybe an array</a>?</dd>
  <dt>
    {{domxref("WifiManager.setPowerSavingMode()")}}</dt>
  <dd>
    Returns a {{domxref("DOMRequest")}}</dd>
  <dt>
    {{domxref("WifiManager.setStaticIpMode()")}}</dt>
  <dd>
    Returns a {{domxref("DOMRequest")}}</dd>
  <dt>
    {{domxref("WifiManager.wps()")}}</dt>
  <dd>
    Returns a {{domxref("DOMRequest")}}</dd>
</dl>
<h2 id="Specification">Specification</h2>
<p>Not part of any specification</p>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{domxref("window.navigator.mozWifiManager","navigator.mozWifiManager")}}</li>
</ul>
Revert to this revision