text: ##########################################################################
  # If not stated otherwise in this file or this component's Licenses.txt
  # file the following copyright and licenses apply:
  #
  # Copyright 2018 RDK Management
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  # http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  ##########################################################################
  '''
  <?xml version="1.0" encoding="UTF-8"?><xml>
    <id/>
    <version>1</version>
    <name>TS_WIFIHAL_5GHzSetApRtsThreshold</name>
    <primitive_test_id/>
    <primitive_test_name>WIFIHAL_GetOrSetParamBoolValue</primitive_test_name>
    <primitive_test_version>3</primitive_test_version>
    <status>FREE</status>
    <synopsis>To check if ApRtsThreshold is supported, if supported set the ApRtsThreshold for 5GHz</synopsis>
    <groups_id/>
    <execution_time>1</execution_time>
    <long_duration>false</long_duration>
    <advanced_script>false</advanced_script>
    <remarks/>
    <skip>false</skip>
    <box_types>
      <box_type>Broadband</box_type>
      <box_type>Emulator</box_type>
      <box_type>RPI</box_type>
    </box_types>
    <rdk_versions>
      <rdk_version>RDKB</rdk_version>
    </rdk_versions>
    <test_cases>
      <test_case_id>TC_WIFIHAL_186</test_case_id>
      <test_objective>To check if ApRtsThreshold is supported, if supported set the ApRtsThreshold for 5GHz</test_objective>
      <test_type>Positive</test_type>
      <test_setup>Broadband, Emulator, RPI</test_setup>
      <pre_requisite>1.Ccsp Components  should be in a running state else invoke cosa_start.sh manually that includes all the ccsp components and TDK Component
  2.TDK Agent should be in running state or invoke it through StartTdk.sh script</pre_requisite>
      <api_or_interface_used>wifi_getApRtsThresholdSupported()
  wifi_setApRtsThreshold()</api_or_interface_used>
      <input_parameters>methodName : getApRtsThresholdSupported
  methodName : setApRtsThreshold
  ApIndex : 1</input_parameters>
      <automation_approch>1. Load wifihal module
  2. Using WIFIHAL_GetOrSetParamBoolValue invoke wifi_getApRtsThresholdSupported()
  3. If it is supported, invoke
  wifi_setApRtsThreshold() using WIFIHAL_GetOrSetParamUIntValue and set a value
  4. Depending upon the return status, return SUCCESS or FAILURE
  5. Unload wifihal module</automation_approch>
      <except_output>Checkpoint:
  1. wifi_getApRtsThresholdSupported should be SUCCESS
  2. wifi_setApRtsThreshold should return SUCCESS</except_output>
      <priority>High</priority>
      <test_stub_interface>WIFIHAL</test_stub_interface>
      <test_script>TS_WIFIHAL_5GHzSetApRtsThreshold</test_script>
      <skipped>No</skipped>
      <release_version/>
      <remarks/>
    </test_cases>
  </xml>
  
  '''
  # use tdklib library,which provides a wrapper for tdk testcase script 
  import tdklib; 
  from wifiUtility import *;
  
  #Test component to be tested
  obj = tdklib.TDKScriptingLibrary("wifihal","1");
  
  #IP and Port of box, No need to change,
  #This will be replaced with correspoing Box Ip and port while executing script
  ip = <ipaddress>
  port = <port>
  obj.configureTestCase(ip,port,'TS_WIFIHAL_5GHzSetApRtsThreshold');
  
  #Get the result of connection with test component and DUT
  loadmodulestatus =obj.getLoadModuleResult();
  print "[LIB LOAD STATUS]  :  %s" %loadmodulestatus ;
  
  if "SUCCESS" in loadmodulestatus.upper():
      obj.setLoadModuleStatus("SUCCESS");
  
      expectedresult="SUCCESS";
      getMethod = "getApRtsThresholdSupported"
      apIndex = 1
      primitive = 'WIFIHAL_GetOrSetParamBoolValue'
  
      #Calling the method from wifiUtility to execute test case and set result status for the test.
      tdkTestObj, actualresult, details = ExecuteWIFIHalCallMethod(obj, primitive, apIndex, 0, getMethod)
  
      if expectedresult in actualresult:
          supportState = details.split(":")[1].strip()
          print "TEST STEP 1: Check if ApRtsThreshold ie, packet size threshold is supported"
          print "EXPECTED RESULT 1: getApRtsThresholdSupported should return SUCCESS"
          print "ACTUAL RESULT 1: getApRtsThresholdSupported is SUCCESS"
          tdkTestObj.setResultStatus("SUCCESS");
  
          if supportState == "Enabled":
              print "getApRtsThreshold is Supported"
              expectedresult="SUCCESS";
              setMethod = "setApRtsThreshold"
              apIndex = 1
              setThreshold = 1000
              primitive = 'WIFIHAL_GetOrSetParamUIntValue'
  
              #Calling the method from wifiUtility to execute test case and set result status for the test.
              tdkTestObj, actualresult, details = ExecuteWIFIHalCallMethod(obj, primitive, apIndex, setThreshold, setMethod)
  
              if expectedresult in actualresult:
                  print "TEST STEP 2: Set the ApRtsThreshold ie, packet size threshold in bytes to apply RTS/CTS backoff rules"
                  print "EXPECTED RESULT 2: Set operation should return SUCCESS"
                  print "ACTUAL RESULT 2: setApRtsThreshold is SUCCESS and sets aside ",setThreshold, "bytes to apply RTS/CTS backoff rules"
                  tdkTestObj.setResultStatus("SUCCESS");
  
              else:
                  print "TEST STEP 2: Set the ApRtsThreshold ie, packet size threshold in bytes to apply RTS/CTS backoff rules"
                  print "EXPECTED RESULT 2: Set operation should return SUCCESS"
                  print "ACTUAL RESULT 2: setApRtsThreshold FAILED"
                  tdkTestObj.setResultStatus("FAILURE");
  
          elif supportState == "Disabled":
              print "getApRtsThreshold is NOT Supported"
              tdkTestObj.setResultStatus("SUCCESS");
      else:
          print "TEST STEP 1: Check if ApRtsThreshold ie, packet size threshold is supported"
          print "EXPECTED RESULT 1: getApRtsThresholdSupported should return SUCCESS"
          print "ACTUAL RESULT 1: getApRtsThresholdSupported FAILED"
          tdkTestObj.setResultStatus("FAILURE");
      obj.unloadModule("wifihal");
  
  else:
      print "Failed to load wifi module";
      obj.setLoadModuleStatus("FAILURE");
  
  