Data Mocking System
Relevant source files
The following files were used as context for generating this wiki page:
The Data Mocking System provides a simulated OpenWrt environment for the LuCI Mobile application. It uses a set of static JSON files to mimic responses from the LuCI RPC (Remote Procedure Call) interface. This system enables "Reviewer Mode" or demo functionality without requiring a physical OpenWrt router connection.
The system encapsulates various router states including network interface status, DHCP leases, firewall rules, and wireless association lists. These mock files are bundled directly as application assets to ensure availability during development and testing phases.
Sources: pubspec.yaml:70-71, README.md:14-16
Architecture and Configuration
The Flutter application explicitly includes the mocking directory within its asset bundle. This configuration allows the application to load JSON data as if it were a network response from a LuCI-enabled device.
The diagram shows how the application branches between live network calls and local asset loading for data.
Sources: pubspec.yaml:70-71, README.md:112-115
Mock Data Categories
The system simulates several key OpenWrt sub-systems. Each sub-system corresponds to a specific JSON file located in the assets/mock/ directory.
Network and DHCP
The system provides detailed network configuration including interface dumps and DHCP lease information. The interface_dump.json file defines statuses for WAN, LAN, and Guest interfaces, including IPv4/IPv6 addresses and DNS servers.
| Feature | Source File | Key Data Points |
|---|---|---|
| Interface Status | interface_dump.json | IP addresses, protocols (dhcp, static), device names (eth0, br-lan). |
| DHCP Leases | dhcp_leases.json | MAC addresses, IP assignments, and client hostnames in stdout format. |
| Host Hints | host_hints.json | MAC-to-hostname mappings and IP address arrays. |
Sources: assets/mock/interface_dump.json, assets/mock/dhcp_leases.json, assets/mock/host_hints.json
Unified Configuration Interface (UCI)
The mock system replicates the OpenWrt UCI structure. This is used for testing configuration edits such as firewall rules or system hostnames.
- Firewall: Defines zones (lan, wan), defaults (syn_flood, input/output policies), and specific rules like blocking MAC addresses.
- System: Stores the hostname (e.g., "LuCIMobile"), description ("Demo router"), and NTP time server configurations.
- DHCP: Contains
dnsmasqsettings, interface range limits, and static host assignments.
Sources: assets/mock/uci_firewall.json, assets/mock/uci_system.json, assets/mock/uci_dhcp.json
Wireless Diagnostics
Wireless client monitoring is simulated via association lists. The assoclist_wlan0.json file mimics the output of wireless diagnostic tools, providing signal strength (dBm), noise levels, and transmission/reception rates for multiple devices.
The diagram represents the relationship between a wireless client and its physical layer performance data found in the mock files.
Sources: assets/mock/assoclist_wlan0.json
Implementation Details
Mock File Structure
Mock files typically follow one of two formats:
- Direct UCI Objects: Objects keyed by
values, reflecting the output ofuci.get_all. - Command Output: Objects containing
stdoutandstderrstrings, mimicking shell execution via RPC (e.g., reading/tmp/dhcp.leases).
Example: UCI Firewall Mock
{
"values": {
"defaults": {
"syn_flood": "1",
"input": "ACCEPT",
"forward": "REJECT"
},
"luci_mobile_block_ccddee98765a": {
".type": "rule",
"name": "Block Baby-Monitor (LuCI Mobile)",
"src_mac": "CC:DD:EE:98:76:54",
"target": "REJECT"
}
}
}
Sources: assets/mock/uci_firewall.json:2-10, assets/mock/uci_firewall.json:44-52
Summary
The Data Mocking System is a critical component for the LuCI Mobile development workflow. By simulating the LuCI RPC interface through localized JSON assets, it allows developers to test complex UI behaviors—such as firewall rule management and real-time wireless signal tracking—without the overhead of hardware dependency. This system ensures that the application remains functional for demonstration purposes and provides a consistent baseline for unit and integration testing.
Sources: README.md:14-17, CONTRIBUTING.md:146-149