mozilla

Revision 435089 of WifiManager

  • Revision slug: Web/API/WifiManager
  • Revision title: WifiManager
  • Revision id: 435089
  • 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);
};

Properties

{{domxref("WifiManager.enabled")}}
Indicates whether the wifi is on.
{{domxref("WifiManager.macAddress")}}
The wifi adapter 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 an 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 MozWifiStatusChangeEvent instance. It's status property can be one of:
{{domxref("WifiManager.connectionInfoUpdate")}}
A handler for the {{event("connectionInfoUpdate")}} event; Triggered anytime the connection information changes. The event object is a 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 is we  but does not have an IP address yet);
  • {{event("connected")}} (when the device is fully connected via wifi and ready).

Methods

{{domxref("WifiManager.getNetworks()")}}
Returns a {{domxref("DOMRequest")}}; the success value is an object which property names are the SSID and the values are surrounding wifi network descriptors... or maybe an array?

Specification

Not part of any specification

See also

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);
};
</pre>
<h2 id="Properties">Properties</h2>
<dl>
  <dt>
    {{domxref("WifiManager.enabled")}}</dt>
  <dd>
    Indicates whether the wifi is on.</dd>
  <dt>
    {{domxref("WifiManager.macAddress")}}</dt>
  <dd>
    The wifi adapter <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 connectionInformation object with the same information found in an <code>MozWifiConnectionInfoEvent</code> (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 <code>MozWifiStatusChangeEvent</code> instance. It's <code>status</code> property can be one of:</dd>
  <dt>
    {{domxref("WifiManager.connectionInfoUpdate")}}</dt>
  <dd>
    A handler for the {{event("connectionInfoUpdate")}} event; Triggered anytime the connection information changes. The event object is a <code>MozWifiConnectionInfoEvent</code> instance.</dd>
</dl>
<h4>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))<code>;</code></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 is we&nbsp; but does not have an IP address yet);</li>
  <li>{{event("connected")}} (when the device is fully connected via wifi and ready)<code>.</code></li>
</ul>
<h2 id="Methods">Methods</h2>
<dl>
  <dt>
    {{domxref("WifiManager.getNetworks()")}}</dt>
  <dd>
    Returns a {{domxref("DOMRequest")}}; the success value is an object which property names are 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>
</dl>
<h2>Specification</h2>
<p>Not part of any specification</p>
<h2>See also</h2>
Revert to this revision