wifi: refactor config generation in run script

Now sophisticated test scripts can be easily generated like documented.
This commit is contained in:
Christian Helmuth 2019-02-08 16:01:55 +01:00 committed by Norman Feske
parent 2b1732bdec
commit 193c1aa533

View File

@ -10,6 +10,50 @@ proc wifi_psk { } {
return $::env(GENODE_WIFI_PSK)
}
#
# widi_drv config generator (supporting a network list)
#
# You may script your tests with this function in the dynamic_rom config below.
# The syntax for the networks parameter is
#
# { ssid protection passphrase explicit_scan }
#
# Example dynamic_rom config:
#
# {<inline description="auto-connect both networks">
# } [wifi_config 30 5 no [list "net1 WPA2 net1_psk no" "net2 WPA2 net2_psk no"]] {
# </inline>
# <inline description="aquto-connect both, but net2 explicitly">
# } [wifi_config 30 5 no [list "net1 WPA2 net1_psk no" "net2 WPA2 net2_psk yes"]] {
# </inline>}
set wifi_verbose false
set wifi_verbose_state false
proc wifi_config { connected_scan_interval scan_interval rfkill networks } {
global wifi_verbose
global wifi_verbose_state
set config "<wifi_config"
append config " verbose=\"$wifi_verbose\""
append config " verbose_state=\"$wifi_verbose_state\""
append config " connected_scan_interval=\"$connected_scan_interval\""
append config " scan_interval=\"$scan_interval\""
append config " rfkill=\"$rfkill\""
append config ">\n"
foreach n $networks {
append config " <network"
append config " ssid=\"[lindex $n 0]\""
append config " protection=\"[lindex $n 1]\""
append config " passphrase=\"[lindex $n 2]\""
append config " explicit_scan=\"[lindex $n 3]\""
append config "/>\n"
}
append config "</wifi_config>\n"
return $config
}
#
# Restrict platforms
#
@ -78,7 +122,7 @@ append config {
</config>
</start>
<start name="scan_report_rom">
<start name="state_report_rom">
<binary name="report_rom"/>
<resource name="RAM" quantum="2M"/>
<provides> <service name="Report"/> <service name="ROM"/> </provides>
@ -99,25 +143,19 @@ append config {
<config verbose="yes">
<rom name="wifi_config">
<inline description="disconnect">
<wifi_config connected_scan_interval="30" scan_interval="5" rfkill="no" verbose="no" verbose_state="no"/>
} [wifi_config 30 5 no {}] {
</inline>
<sleep milliseconds="15000"/>
<inline description="connect">
<wifi_config connected_scan_interval="30" scan_interval="5" rfkill="no" verbose="no" verbose_state="no">
<network ssid="} [wifi_ssid] {" protection="WPA2" explicit_scan="true" passphrase="} [wifi_psk] {"/>
</wifi_config>
} [wifi_config 30 5 no [list "[wifi_ssid] WPA2 [wifi_psk] yes"]] {
</inline>
<sleep milliseconds="60000"/>
<inline description="rfkill block">
<wifi_config connected_scan_interval="30" scan_interval="5" rfkill="yes" verbose="no" verbose_state="no">
<network ssid="} [wifi_ssid] {" protection="WPA2" explicit_scan="true" passphrase="} [wifi_psk] {"/>
</wifi_config>
} [wifi_config 30 5 yes [list "[wifi_ssid] WPA2 [wifi_psk] yes"]] {
</inline>
<sleep milliseconds="30000"/>
<inline description="rfkill unblock">
<wifi_config connected_scan_interval="30" scan_interval="5" rfkill="no" verbose="no" verbose_state="no">
<network ssid="} [wifi_ssid] {" protection="WPA2" explicit_scan="true" passphrase="} [wifi_psk] {"/>
</wifi_config>
} [wifi_config 30 5 no [list "[wifi_ssid] WPA2 [wifi_psk] yes"]] {
</inline>
<sleep milliseconds="30000"/>
</rom>
@ -139,7 +177,7 @@ append config {
<route>
<service name="Rtc"> <any-child/> </service>
<service name="Report" label="accesspoints"> <child name="accesspoints_report_rom"/> </service>
<service name="Report" label="state"> <child name="scan_report_rom"/> </service>
<service name="Report" label="state"> <child name="state_report_rom"/> </service>
<service name="ROM" label="wifi_config"> <child name="config_rom"/> </service>
<any-service> <parent/> <any-child/> </any-service>
</route>