# Check TX is stable in Host Driven mode

# TESTING_TIME unit is seconds
define!$TESTING_TIME!3600!
define!$WINDOW_TIME!60!

GetCurrentTime!$START_TIME!

wfa_control_agent_dut1!wlan_reset,interface,wl0!ID,$DUT_WTS_VERSION
wfa_control_agent_dut1!wlan_initiation,interface,wl0,mode,hostdriven!ID,$DUT_MAC_ADDR1
wfa_control_agent_dut1!detect_hd_start,send,enable,interval,100,hash,1a2b3c4d5e6f7980,datasize,1000,channel,6!ID,$DUT_WTS_VERSION

wfa_control_agent_dut2!wlan_reset,interface,wl0!ID,$DUT_WTS_VERSION
wfa_control_agent_dut2!wlan_initiation,interface,wl0,mode,hostdriven!ID,$DUT_MAC_ADDR2
wfa_control_agent_dut2!detect_hd_start,send,enable,interval,100,hash,1a2b3c4d5e6f7980,datasize,1000,channel,6!ID,$DUT_WTS_VERSION

GetCurrentTime!$ROUND_START_TIME!
wfa_control_agent_dut1!clear_detect_recv_buf!ID,$DUT_WTS_VERSION

GetCurrentTime!$CURRENT_TIME!
math!$CURRENT_TIME!-!$ROUND_START_TIME!
if!$CURRENT_TIME!<!$WINDOW_TIME!
sleep!1!
GotoLine!20!
endif!

wfa_control_agent_dut1!check_detect_recv_buf,macaddr,$DUT_MAC_ADDR2,hash,1a2b3c4d5e6f7980,datasize,1000!ID,$DETECT_RECV_CNT

define!$DETECT_BASELINE!600!
mexpr!$DETECT_BASELINE!%!90!
echo!$DETECT_RECV_CNT!
if!$DETECT_RECV_CNT!<!$DETECT_BASELINE!
r_info!Background packet loss higher than expected!
endif!

math!$LOOP_COUNTER!+!1!
echo!$LOOP_COUNTER!

GetCurrentTime!$CURRENT_TIME!
math!$CURRENT_TIME!-!$START_TIME!

if!$CURRENT_TIME!<!$TESTING_TIME!
GotoLine!17!
endif!
sleep!1!

wfa_control_agent_dut1!detect_hd_stop,interface,wl0!ID,$DUT_WTS_VERSION
wfa_control_agent_dut1!wlan_uninitiation,interface,wl0!ID,$DUT_WTS_VERSION

wfa_control_agent_dut2!detect_hd_stop,interface,wl0!ID,$DUT_WTS_VERSION
wfa_control_agent_dut2!wlan_uninitiation,interface,wl0!ID,$DUT_WTS_VERSION

sleep!1!

r_info!PASS!