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
0 commit comments