Mobly WiFi controller module for using Python code to operate network devices in Mobly tests.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mobly_wifi-1.3.0.tar.gz.
File metadata
- Download URL: mobly_wifi-1.3.0.tar.gz
- Upload date:
- Size: 73.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49197100eef0ec2081c6f81d5f7b98ce60c3aa76eabb8d5cd95f4b848d62b43f
|
|
| MD5 |
f57ab20ea64a72efcc48ba3ace6adf11
|
|
| BLAKE2b-256 |
49d9ee1406ddadd818dd5b729a6d5ee2809494486d210e2cfd863f0d529e1043
|
File details
Details for the file mobly_wifi-1.3.0-py3-none-any.whl.
File metadata
- Download URL: mobly_wifi-1.3.0-py3-none-any.whl
- Upload date:
- Size: 96.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a98bdffcdb8eb4418e376b9e17df468e78d1366c50fe00381ac61b84dca50bb
|
|
| MD5 |
cae717e600ba446937dea658d117ab40
|
|
| BLAKE2b-256 |
cc8cd6504272fe612d7c409413f17159c9692204290192cb29ed2fcf1339305c
|