This API is available on Firefox OS for internal applications only.
Summary
The wps
method is used to handle a WPS connection with networks supporting that feature.
A network supporting a WPS connection has the string WPS
available within the WifiManager.capabilities
Array.
A WPS connection is a simpler way to connect a device to a network. It requires less knowledge from the user and makes things easier for him. Basically, when a user has a WPS-enabled WiFi router, he can choose that method to connect his device to the network instead of typing its password.
There are two ways of initiating a WPS connection up to the user:
- The easiest one is by pressing a dedicated button on the WiFi router.
- An alternative is by entering a PIN number provided by the WiFi router. There are two use cases here:
- The WiFi router will send a PIN number to the device and the user has to type it on the WiFi router interface.
- The WiFi router expects the user to type a PIN number on his device (usually, such a PIN number is displayed on the WiFi router itself).
Syntax
var request = navigator.mozWifiManager.wps(param);
Parameters
- param
- A configuration object with the following properties:
method
: A string, one of the following:cancel
to abort a WPS connection attempt.pbs
to try a connection by pushing the physical button on the WiFi router.pin
to try a connection with a pin number.
bssid
: A string representing the bssid of the network to connect to. It is mandatory if themethod
property is set topin
.pin
: A string representing the pin number typed by the user. It is mandatory if themethod
property is set topin
and the user had to type the pin on his device.
Returns
It returns a DOMRequest
to handle the success or error of the operation.
When the method
property is set to pin
, if the operation is successful and if the user must type a pin number on his WiFi router interface, the request's result
is a string representing the PIN number to type.
Example
var wifi = navigator.mozWifiManager; var request = wifi.getNetworks(); request.onsuccess = function () { // Let's get the first network var network = this.result[0]; var isWPSEnabled = network.capabilities.indexOf('WPS') > -1; var wpsRequest; if (isWPSEnabled) { if (comfirm('Do you want to use the push button to connect your device?')) { wpsRequest = wifi.wps({ method : 'pbs' }); } else if (confirm('Do you want to type a PIN number on your WiFI router interface?')){ wpsRequest = wifi.wps({ method : 'pin', bssid : network.bssid }) wpsRequest.onsuccess = function () { alert('Please, type that number on your WiFi router interface: ' + this.result) } } else { wpsRequest = wifi.wps({ method : 'pin', bssid : network.bssid pin : prompt('Please, provide the PIN number of your WiFi router.') }) } } }
Specification
Not part of any specification.