B2G/Wifi Direct

From MozillaWiki
< B2G
Jump to: navigation, search

Current Status

Wifi Direct is currently an opt-out feature on B2G. To enable Wifi Direct, you have to add 'ro.moz.wifi.p2p_supported' to your system/build.prop. However, there is still no gaia app to work with Wifi Direct. If you want to develop features on Wifi Direct, please refer to this gaia remote to see how to Wifi Direct APIs.

Flame has been verified capable of Wifi Direct. As for other configurations:

  • Wifi Direct is NOT confirmed supported on KK-based devices. (tracked by Bug 1049460)
  • Nexus 4 was verified to support but hasn't been verified with the latest m-c.

Web IDL

MozWifiP2pManager.webidl

Introduction

Wifi Direct is a peer-to-peer communication method based on Wifi technology. Two phones could connect to each other without the existence of access points. Wifi Direct is a pure software feature so it requires no hardware upgrade. The communication speed is as fast as regular Wifi speed so it's pretty appropriate to be used to transfer a large file.

As compared to another WiFi peer-to-peer technology, ad-hoc mode, Wifi Direct has some advantages over ad-host mode such as the security, the speed and the ease of use. However, Wifi Direct is difficult to build a complicated topology of network. The most common use case is only two phones connecting to each other. In this case, one phone will be a so-called "group owner" and the other will be "client". The participants in the network formed by Wifi Direct will be addressed in the following section.

Architecture

There are two main files to implement the internal Wifi Direct machinery:

  • dom/wifi/WifiP2pManager.jsm
    • Responsible for communicating with wpa_supplicant and notifying the observer important events such as "peer found", "peer connecting", and "peer connected".
  • dom/wifi/WifiP2pWorkerObserver.jsm
    • Receives/sends DOM events and dispatches to WifiP2pManager to handle. It also translates chrome objects to DOM-facing objects.

Other than the mentioned files, dom/wifi/StateMachine.jsm is a helper to build a Wifi Direct state machine; dom/wifi/DOMWifiP2pManager.jsm would sit in each window (may has multiple instances) to work with internal modules by message manager (ppmm/cpmm).

The relationship between DOM, WifiWorker.js and the Wifi Direct modules can be represented in the following figure:

Wifi Direct Diagram.png

Note that there is no explicit dependency between WifiP2pManager and WifiP2pWorkerObserver. They are implicitly depending on each other through two implicit interfaces: IWifiP2pObserver and IWifiP2pDOMMsgResponder.

TODOs