Skip to main content

Mobly WiFi Controller

Mobly WiFi controller module for using Python code to operate network devices in Mobly tests.

Requirements

  • Python 3.11+
  • Mobly 1.12.2+

Installation

pip install mobly-wifi

Start to Use

Mobly WiFi controller is an add-on module to control OpenWrt AP devices in Mobly. To learn more about Mobly, visit Getting started with Mobly.

Ensure the AP device is reachable via SSH

Mobly tests run on a single host computer.

To use an AP device in Mobly tests, connect it to your local network and confirm SSH access from the host machine.

Write Mobly Device Configs

Write a testbed config to specify the information of the device under test. For example:

sample_config.yaml

TestBeds:
- Name: SampleOpenWrtTestbed
  Controllers:
    OpenWrtDevice:
    -  hostname: 'IP_ADDRESS'

NOTE: Replace IP_ADDRESS with the IP address of the AP device.

Write a Hello World Mobly Test

This example test starts a 5G Wi-Fi network on the given AP device.

hello_world_test.py

"""A basic Mobly Test with OpenWrt AP device."""

import time

from mobly import base_test
from mobly import test_runner
from mobly.controllers.wifi import openwrt_device
from mobly.controllers.wifi.lib import wifi_configs

 
class HelloWorldTest(base_test.BaseTestClass):
 
  def setup_class(self):
    # Register controller for the AP device
    self.openwrt = self.register_controller(openwrt_device)[0]
 
  def test_start_5g_wifi(self):
    # Start Wi-Fi network with channel=36
    config = wifi_configs.WiFiConfig(channel=36)
    wifi_info = self.openwrt.start_wifi(config=config)
    self.openwrt.log.info(
        'Now you can connect your device to WiFi "%s" with password "%s"!',
        wifi_info.ssid,
        wifi_info.password,
    )
    # Sleep a while, you can manually connect your device to the WiFi.
    time.sleep(60)
 
if __name__ == '__main__':
  test_runner.main()

Execute the Test

python hello_world_test.py -c sample_config.yaml

Configure Android devices in Mobly tests

To use Android devices together with AP devices, you need to configure them in testbed config.

Following testbed uses one AP device and all Android devices connected with your host computer:

TestBeds:
- Name: SampleOpenWrtTestbed
  Controllers:
    OpenWrtDevice:
    - hostname: 'IP_ADDRESS'
    # Use all Android devices detectable by adb
    AndroidDevice: '*'

Following testbed uses one AP device and Android devices with serial number abc and xyz.

TestBeds:
- Name: SampleOpenWrtTestbed
  Controllers:
    OpenWrtDevice:
    - hostname: 'IP_ADDRESS'
    AndroidDevice: '*'
    - serial: abc
    - serial: xyz

More Examples

See examples folder for more examples.

Metadata

Release files for mobly-wifi 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mobly-wifi 1.4.0
File Size Uploaded
mobly_wifi-1.4.0.tar.gz 115.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mobly-wifi 1.4.0
File Interpreter ABI Platform
mobly_wifi-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 263.2 kB

Release files / mobly_wifi-1.4.0.tar.gz

Download URL mobly_wifi-1.4.0.tar.gz
Size 115.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2626692037888f7acfaafe2764f7225a099a38c7cdcc9986e77dfdcf3404bf9e
BLAKE2b-256 checksum
How to use checksums
7b025d49213acdc261da15d80b86042b8baa8df5267394fa37588c118367cbe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / mobly_wifi-1.4.0-py3-none-any.whl

Download URL mobly_wifi-1.4.0-py3-none-any.whl
Size 148.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba22a19eda0cbcc67b379b3184c5ae1e7a3ff466f9fc4648fa7f7ff248e77374
BLAKE2b-256 checksum
How to use checksums
0bbb0ede9b693d64bac599f283c2cb85c64a45cc152790f67698aca3e2a97c80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page