WifiManager

  • Revision slug: Web/API/WifiManager
  • Revision title: WifiManager
  • Revision id: 433581
  • Created:
  • Creator: dbruant
  • Is current revision? No
  • Comment getNetworks, lol?

Revision Content

{{ non-standard_header() }}

{{ B2GOnlyHeader2('installed') }}

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

  • "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));
  • "connecting" (when the process of connecting to a network begins);
  • "associated" (when the device is connected to an access point is we  but does not have an IP address yet);
  • "connected" (when the device is fully connected via wifi and ready).
{{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.

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.
 

Revision Source

<p>{{ non-standard_header() }}</p>
<p>{{ B2GOnlyHeader2('installed') }}</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>
<ul>
  <li><code>"disconnected"</code> (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><code>"connecting" </code>(when the process of connecting to a network begins);</li>
  <li><code>"associated"</code> (when the device is connected to an access point is we&nbsp; but does not have an IP address yet);</li>
  <li><code>"connected"</code> (when the device is fully connected via wifi and ready)<code>.</code></li>
</ul>
<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>
<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.</dd>
  <dt>
    &nbsp;</dt>
</dl>
Revert to this revision