Skip to content

Commit 18f2105

Browse files
committed
QuickTrack DUT ControlApp in Python first commit
0 parents  commit 18f2105

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+5654
-0
lines changed

Commands/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# flake8: noqa

Commands/afc_command_helper.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Copyright (c) 2023 Wi-Fi Alliance
2+
3+
# Permission to use, copy, modify, and/or distribute this software for any
4+
# purpose with or without fee is hereby granted, provided that the above
5+
# copyright notice and this permission notice appear in all copies.
6+
7+
# THE SOFTWARE IS PROVIDED 'AS IS' AND THE AUTHOR DISCLAIMS ALL
8+
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
9+
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
10+
# THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
11+
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
12+
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
13+
# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14+
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
15+
# SOFTWARE.
16+
17+
try:
18+
from .XXX_command_helper import XXX_CommandHelper as CommandHelper
19+
except ImportError:
20+
from .command_helper import CommandHelper
21+
from .shared_enums import CommandOperation, DebugLogLevel, QuickTrackRequestTLV, QuickTrackResponseTLV
22+
from .command_interpreter import CommandInterpreter
23+
from .command import Command
24+
from Commands.dut_logger import DutLogger, LogCategory
25+
26+
27+
class AfcCommandHelper:
28+
29+
@staticmethod
30+
def afc_configure(config: dict):
31+
if QuickTrackRequestTLV.AFC_SERVER_URL in config:
32+
server_url = config.get(QuickTrackRequestTLV.AFC_SERVER_URL)
33+
else:
34+
return None, "Missed TLV: AFC_SERVER_URL"
35+
36+
if QuickTrackRequestTLV.AFC_CA_CERT in config:
37+
ca_cert = config.get(QuickTrackRequestTLV.AFC_CA_CERT)
38+
else:
39+
return None, "Missed TLV: AFC_CA_CERT"
40+
41+
if QuickTrackRequestTLV.SECURITY_TYPE in config:
42+
security_type = config.get(QuickTrackRequestTLV.SECURITY_TYPE)
43+
44+
if QuickTrackRequestTLV.LOCATION_GEO_AREA in config:
45+
location_geo_area = config.get(QuickTrackRequestTLV.LOCATION_GEO_AREA)
46+
if location_geo_area == 0:
47+
center = config.get(QuickTrackRequestTLV.ELLIPSE_CENTER)
48+
major_axis = config.get(QuickTrackRequestTLV.ELLIPSE_MAJOR_AXIS)
49+
minor_axis = config.get(QuickTrackRequestTLV.ELLIPSE_MINOR_AXIS)
50+
orientation = config.get(QuickTrackRequestTLV.ELLIPSE_ORIENTATION)
51+
elif location_geo_area == 1:
52+
boundary = config.get(QuickTrackRequestTLV.LINEARPOLY_BOUNDARY)
53+
elif location_geo_area == 2:
54+
center = config.get(QuickTrackRequestTLV.RADIALPOLY_CENTER)
55+
boundary = config.get(QuickTrackRequestTLV.RADIALPOLY_BOUNDARY)
56+
57+
return "Successful", None
58+
59+
@staticmethod
60+
def afc_operation(config: dict):
61+
if QuickTrackRequestTLV.DEVICE_RESET in config:
62+
reset = config.get(QuickTrackRequestTLV.DEVICE_RESET)
63+
DutLogger.log(LogCategory.INFO, "Received AFC_OPERATION device_reset")
64+
65+
if QuickTrackRequestTLV.SEND_SPECTRUM_REQ in config:
66+
req_type = config.get(QuickTrackRequestTLV.SEND_SPECTRUM_REQ)
67+
if req_type == 0:
68+
DutLogger.log(LogCategory.INFO, "Send Spectrum request with Channel and Frequency based")
69+
elif req_type == 1:
70+
DutLogger.log(LogCategory.INFO, "Send Spectrum request with Channel based")
71+
elif req_type == 2:
72+
DutLogger.log(LogCategory.INFO, "Send Spectrum request with Frequency based")
73+
74+
if QuickTrackRequestTLV.POWER_CYCLE in config:
75+
power_cycle = config.get(QuickTrackRequestTLV.POWER_CYCLE)
76+
DutLogger.log(LogCategory.INFO, "Received AFC_OPERATION power_cycle")
77+
78+
if QuickTrackRequestTLV.SEND_TEST_FRAME in config:
79+
type = config.get(QuickTrackRequestTLV.SEND_TEST_FRAME)
80+
if type == 0:
81+
DutLogger.log(LogCategory.INFO, "Trigger DUT to send test frames for 20MHz bandwidth")
82+
elif type == 1:
83+
DutLogger.log(LogCategory.INFO, "Trigger DUT to send test frames for 40MHz bandwidth")
84+
elif type == 2:
85+
DutLogger.log(LogCategory.INFO, "Trigger DUT to send test frames for 80MHz bandwidth")
86+
elif type == 3:
87+
DutLogger.log(LogCategory.INFO, "Trigger DUT to send test frames for 160MHz bandwidth")
88+
89+
return "Successful", None
90+
91+
@staticmethod
92+
def afc_get_info():
93+
# Get current center channel
94+
channel = 39
95+
freq = 5950 + 5 * channel
96+
97+
info_dict = dict()
98+
info_dict[QuickTrackResponseTLV.OPER_CHANNEL] = channel
99+
info_dict[QuickTrackResponseTLV.OPER_FREQ] = freq
100+
101+
return info_dict

Commands/afc_commands.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Copyright (c) 2023 Wi-Fi Alliance
2+
3+
# Permission to use, copy, modify, and/or distribute this software for any
4+
# purpose with or without fee is hereby granted, provided that the above
5+
# copyright notice and this permission notice appear in all copies.
6+
7+
# THE SOFTWARE IS PROVIDED 'AS IS' AND THE AUTHOR DISCLAIMS ALL
8+
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
9+
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
10+
# THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
11+
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
12+
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
13+
# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14+
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
15+
# SOFTWARE.
16+
17+
from .shared_enums import QuickTrackRequestTLV, QuickTrackResponseTLV
18+
from .command import ApiInterface, ApiReturnStatus, Command
19+
try:
20+
from .XXX_afc_command_helper import XXX_AfcCommandHelper as AfcCommandHelper
21+
except ImportError:
22+
from .afc_command_helper import AfcCommandHelper
23+
from Commands.dut_logger import DutLogger, LogCategory
24+
25+
class AFCD_CONFIGURE(ApiInterface):
26+
def execute(self):
27+
"""Method to execute the AFC configure command."""
28+
self.std_out, self.std_err = AfcCommandHelper.afc_configure(self.params)
29+
30+
def get_return_status(self):
31+
"""Method to return the return status of AFC configure based on the std_err."""
32+
if self.std_err is None:
33+
return ApiReturnStatus(0, "AFC configure completed : " + str(self.std_out))
34+
else:
35+
return ApiReturnStatus(
36+
1, "Unable to configure AFC commands.[" + str(self.std_err) + "]"
37+
)
38+
39+
class AFCD_OPERATION(ApiInterface):
40+
def execute(self):
41+
"""Method to execute the AFC operation command."""
42+
self.std_out, self.std_err = AfcCommandHelper.afc_operation(self.params)
43+
44+
def get_return_status(self):
45+
"""Method to return the return status of AFC operation based on the std_err."""
46+
if self.std_err is None:
47+
return ApiReturnStatus(0, "AFC operation completed : " + str(self.std_out))
48+
else:
49+
return ApiReturnStatus(
50+
1, "Unable to execute AFC operation commands. [" + str(self.std_err) + "]"
51+
)
52+
53+
class AFCD_GET_INFO(ApiInterface):
54+
def execute(self):
55+
"""Method to execute and get the AFC required information ."""
56+
57+
self.std_out = AfcCommandHelper.afc_get_info()
58+
if QuickTrackResponseTLV.OPER_CHANNEL not in self.std_out:
59+
self.std_err = "failed to get operation channel info"
60+
return
61+
62+
if QuickTrackResponseTLV.OPER_FREQ not in self.std_out:
63+
self.std_err = "failed to get operation frequency info"
64+
65+
def get_return_status(self):
66+
"""Returns the return status with the status code with following description.
67+
68+
status code:
69+
0 - success, returns successful.
70+
1- Failure, unable to get the AFC information, returns None."""
71+
if self.std_err is None:
72+
return ApiReturnStatus(
73+
0,
74+
"Successful to get AFC required information",
75+
self.std_out
76+
)
77+
else:
78+
return ApiReturnStatus(1, str(self.std_err))

0 commit comments

Comments
 (0)