• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#
3#   Copyright 2016 - The Android Open Source Project
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16
17import time
18
19from queue import Empty
20from datetime import datetime
21from acts.controllers.anritsu_lib import band_constants
22from acts.controllers.anritsu_lib._anritsu_utils import AnritsuUtils
23from acts.controllers.anritsu_lib.md8475a import BtsNumber
24from acts.controllers.anritsu_lib.md8475a import BtsNwNameEnable
25from acts.controllers.anritsu_lib.md8475a import BtsServiceState
26from acts.controllers.anritsu_lib.md8475a import BtsTechnology
27from acts.controllers.anritsu_lib.md8475a import CsfbType
28from acts.controllers.anritsu_lib.md8475a import ImsCscfCall
29from acts.controllers.anritsu_lib.md8475a import ImsCscfStatus
30from acts.controllers.anritsu_lib.md8475a import MD8475A
31from acts.controllers.anritsu_lib.md8475a import ReturnToEUTRAN
32from acts.controllers.anritsu_lib.md8475a import VirtualPhoneStatus
33from acts.controllers.anritsu_lib.md8475a import TestProcedure
34from acts.controllers.anritsu_lib.md8475a import TestPowerControl
35from acts.controllers.anritsu_lib.md8475a import TestMeasurement
36from acts.controllers.anritsu_lib.md8475a import Switch
37from acts.controllers.anritsu_lib.md8475a import BtsPacketRate
38from acts_contrib.test_utils.tel.tel_defines import CALL_TEARDOWN_PHONE
39from acts_contrib.test_utils.tel.tel_defines import CALL_TEARDOWN_REMOTE
40from acts_contrib.test_utils.tel.tel_defines import MAX_WAIT_TIME_CALL_DROP
41from acts_contrib.test_utils.tel.tel_defines import RAT_1XRTT
42from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_IN_CALL
43from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_IN_CALL_LONG
44from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_IN_CALL_FOR_IMS
45from acts_contrib.test_utils.tel.tel_defines import EventCmasReceived
46from acts_contrib.test_utils.tel.tel_defines import EventEtwsReceived
47from acts_contrib.test_utils.tel.tel_defines import EventSmsDeliverSuccess
48from acts_contrib.test_utils.tel.tel_defines import EventSmsSentSuccess
49from acts_contrib.test_utils.tel.tel_defines import EventSmsReceived
50from acts_contrib.test_utils.tel.tel_test_utils import ensure_phone_idle
51from acts_contrib.test_utils.tel.tel_test_utils import hangup_call
52from acts_contrib.test_utils.tel.tel_test_utils import initiate_call
53from acts_contrib.test_utils.tel.tel_test_utils import wait_and_answer_call
54from acts_contrib.test_utils.tel.tel_test_utils import wait_for_droid_not_in_call
55
56# Timers
57# Time to wait after registration before sending a command to Anritsu
58# to ensure the phone has sufficient time to reconfigure based on new
59# network in Anritsu
60WAIT_TIME_ANRITSU_REG_AND_OPER = 10
61# Time to wait after registration to ensure the phone
62# has sufficient time to reconfigure based on new network in Anritsu
63WAIT_TIME_ANRITSU_REG_AND_CALL = 10
64# Max time to wait for Anritsu's virtual phone state change
65MAX_WAIT_TIME_VIRTUAL_PHONE_STATE = 45
66# Time to wait for Anritsu's IMS CSCF state change
67MAX_WAIT_TIME_IMS_CSCF_STATE = 30
68# Time to wait for before aSRVCC
69WAIT_TIME_IN_ALERT = 5
70
71# SIM card names
72P0250Ax = "P0250Ax"
73VzW12349 = "VzW12349"
74P0135Ax = "P0135Ax"
75FiTMO = "FiTMO"
76FiSPR = "FiSPR"
77FiUSCC = "FiUSCC"
78
79# Test PLMN information
80TEST_PLMN_LTE_NAME = "MD8475A_LTE"
81TEST_PLMN_WCDMA_NAME = "MD8475A_WCDMA"
82TEST_PLMN_GSM_NAME = "MD8475A_GSM"
83TEST_PLMN_1X_NAME = "MD8475A_1X"
84TEST_PLMN_1_MCC = "001"
85TEST_PLMN_1_MNC = "01"
86DEFAULT_MCC = "310"
87DEFAULT_MNC = "260"
88DEFAULT_RAC = 1
89DEFAULT_LAC = 1
90VzW_MCC = "311"
91VzW_MNC = "480"
92TMO_MCC = "310"
93TMO_MNC = "260"
94Fi_TMO_MCC = "310"
95Fi_TMO_MNC = "260"
96Fi_SPR_MCC = "310"
97Fi_SPR_MNC = "120"
98Fi_USCC_MCC = "311"
99Fi_USCC_MNC = "580"
100
101# IP address information for internet sharing
102#GATEWAY_IPV4_ADDR = "192.168.137.1"
103#UE_IPV4_ADDR_1 = "192.168.137.2"
104#UE_IPV4_ADDR_2 = "192.168.137.3"
105#UE_IPV4_ADDR_3 = "192.168.137.4"
106#DNS_IPV4_ADDR = "192.168.137.1"
107#CSCF_IPV4_ADDR = "192.168.137.1"
108
109# Default IP address in Smart Studio, work for Internet Sharing with and
110# without WLAN ePDG server. Remember to add 192.168.1.2 to Ethernet 0
111# on MD8475A after turn on Windows' Internet Coonection Sharing
112GATEWAY_IPV4_ADDR = "192.168.1.2"
113UE_IPV4_ADDR_1 = "192.168.1.1"
114UE_IPV4_ADDR_2 = "192.168.1.11"
115UE_IPV4_ADDR_3 = "192.168.1.21"
116UE_IPV6_ADDR_1 = "2001:0:0:1::1"
117UE_IPV6_ADDR_2 = "2001:0:0:2::1"
118UE_IPV6_ADDR_3 = "2001:0:0:3::1"
119DNS_IPV4_ADDR = "192.168.1.12"
120CSCF_IPV4_ADDR = "192.168.1.2"
121CSCF_IPV6_ADDR = "2001:0:0:1::2"
122CSCF_IPV6_ADDR_2 = "2001:0:0:2::2"
123CSCF_IPV6_ADDR_3 = "2001:0:0:3::2"
124
125# Google Fi IP Config:
126
127Fi_GATEWAY_IPV4_ADDR_Data = "100.107.235.94"
128Fi_GATEWAY_IPV6_ADDR_Data = "fe80::aef2:c5ff:fe71:4b9"
129Fi_GATEWAY_IPV4_ADDR_IMS_911 = "192.168.1.2"
130Fi_GATEWAY_IPV6_ADDR_IMS_911 = "2001:0:0:1::2"
131
132Fi_UE_IPV4_ADDR_Data = "100.107.235.81"
133Fi_UE_IPV4_ADDR_IMS = "192.168.1.1"
134Fi_UE_IPV4_ADDR_911 = "192.168.1.11"
135Fi_UE_IPV6_ADDR_Data = "2620::1000:1551:1140:c0f9:d6a8:44eb"
136Fi_UE_IPV6_ADDR_IMS = "2001:0:0:1::1"
137Fi_UE_IPV6_ADDR_911 = "2001:0:0:2::1"
138
139Fi_DNS_IPV4_ADDR_Pri = "8.8.8.8"
140Fi_DNS_IPV4_ADDR_Sec = "8.8.8.4"
141Fi_DNS_IPV6_ADDR = "2001:4860:4860::8888"
142
143Fi_CSCF_IPV4_ADDR_Data = "192.168.1.2"
144Fi_CSCF_IPV6_ADDR_Data = "2001:0:0:1::2"
145Fi_CSCF_IPV4_ADDR_IMS = "192.168.1.2"
146Fi_CSCF_IPV6_ADDR_IMS = "2001:0:0:1::3"
147Fi_CSCF_IPV4_ADDR_911 = "192.168.1.12"
148Fi_CSCF_IPV6_ADDR_911 = "2001:0:0:2::2"
149
150# Default Cell Parameters
151DEFAULT_OUTPUT_LEVEL = -30
152DEFAULT_1X_OUTPUT_LEVEL = -35
153DEFAULT_INPUT_LEVEL = 0
154DEFAULT_LTE_BAND = [2, 4]
155Fi_LTE_TMO_BAND = [4]
156Fi_LTE_SPR_BAND = [25]
157Fi_LTE_USCC_BAND = [12]
158Fi_GSM_TMO_BAND = band_constants.GSM_BAND_PGSM900
159DEFAULT_WCDMA_BAND = 1
160DEFAULT_WCDMA_PACKET_RATE = BtsPacketRate.WCDMA_DLHSAUTO_REL7_ULHSAUTO
161DEFAULT_GSM_BAND = band_constants.GSM_BAND_GSM850
162
163#Google Fi CDMA Bands
164
165Fi_USCC1X_MCC = 209
166Fi_USCC1X_BAND = 1
167Fi_USCC1X_CH = 600
168Fi_USCC1X_SID = 5
169Fi_USCC1X_NID = 21
170
171Fi_SPR1X_MCC = 320
172Fi_SPR1X_BAND = 1
173Fi_SPR1X_CH = 600
174Fi_SPR1X_SID = 4183
175Fi_SPR1X_NID = 233
176
177Fi_EVDO_BAND = 1
178Fi_EVDO_CH = 625
179Fi_EVDO_SECTOR_ID = "00000000,00000000,00000000,00000000"
180
181DEFAULT_CDMA1X_BAND = 0
182DEFAULT_CDMA1X_CH = 356
183DEFAULT_CDMA1X_SID = 0
184DEFAULT_CDMA1X_NID = 65535
185DEFAULT_EVDO_BAND = 0
186DEFAULT_EVDO_CH = 356
187DEFAULT_EVDO_SECTOR_ID = "00000000,00000000,00000000,00000000"
188VzW_CDMA1x_BAND = 1
189VzW_CDMA1x_CH = 150
190VzW_CDMA1X_SID = 26
191VzW_CDMA1X_NID = 65535
192VzW_EVDO_BAND = 0
193VzW_EVDO_CH = 384
194VzW_EVDO_SECTOR_ID = "12345678,00000000,00000000,00000000"
195DEFAULT_T_MODE = "TM1"
196DEFAULT_DL_ANTENNA = 1
197
198# CMAS Message IDs
199CMAS_MESSAGE_PRESIDENTIAL_ALERT = hex(0x1112)
200CMAS_MESSAGE_EXTREME_IMMEDIATE_OBSERVED = hex(0x1113)
201CMAS_MESSAGE_EXTREME_IMMEDIATE_LIKELY = hex(0x1114)
202CMAS_MESSAGE_EXTREME_EXPECTED_OBSERVED = hex(0x1115)
203CMAS_MESSAGE_EXTREME_EXPECTED_LIKELY = hex(0x1116)
204CMAS_MESSAGE_SEVERE_IMMEDIATE_OBSERVED = hex(0x1117)
205CMAS_MESSAGE_SEVERE_IMMEDIATE_LIKELY = hex(0x1118)
206CMAS_MESSAGE_SEVERE_EXPECTED_OBSERVED = hex(0x1119)
207CMAS_MESSAGE_SEVERE_EXPECTED_LIKELY = hex(0x111A)
208CMAS_MESSAGE_CHILD_ABDUCTION_EMERGENCY = hex(0x111B)
209CMAS_MESSAGE_MONTHLY_TEST = hex(0x111C)
210CMAS_MESSAGE_CMAS_EXECERCISE = hex(0x111D)
211
212# ETWS Message IDs
213ETWS_WARNING_EARTHQUAKE = hex(0x1100)
214ETWS_WARNING_TSUNAMI = hex(0x1101)
215ETWS_WARNING_EARTHQUAKETSUNAMI = hex(0x1102)
216ETWS_WARNING_TEST_MESSAGE = hex(0x1103)
217ETWS_WARNING_OTHER_EMERGENCY = hex(0x1104)
218
219# C2K CMAS Message Constants
220CMAS_C2K_CATEGORY_PRESIDENTIAL = "Presidential"
221CMAS_C2K_CATEGORY_EXTREME = "Extreme"
222CMAS_C2K_CATEGORY_SEVERE = "Severe"
223CMAS_C2K_CATEGORY_AMBER = "AMBER"
224CMAS_C2K_CATEGORY_CMASTEST = "CMASTest"
225
226CMAS_C2K_PRIORITY_NORMAL = "Normal"
227CMAS_C2K_PRIORITY_INTERACTIVE = "Interactive"
228CMAS_C2K_PRIORITY_URGENT = "Urgent"
229CMAS_C2K_PRIORITY_EMERGENCY = "Emergency"
230
231CMAS_C2K_RESPONSETYPE_SHELTER = "Shelter"
232CMAS_C2K_RESPONSETYPE_EVACUATE = "Evacuate"
233CMAS_C2K_RESPONSETYPE_PREPARE = "Prepare"
234CMAS_C2K_RESPONSETYPE_EXECUTE = "Execute"
235CMAS_C2K_RESPONSETYPE_MONITOR = "Monitor"
236CMAS_C2K_RESPONSETYPE_AVOID = "Avoid"
237CMAS_C2K_RESPONSETYPE_ASSESS = "Assess"
238CMAS_C2K_RESPONSETYPE_NONE = "None"
239
240CMAS_C2K_SEVERITY_EXTREME = "Extreme"
241CMAS_C2K_SEVERITY_SEVERE = "Severe"
242
243CMAS_C2K_URGENCY_IMMEDIATE = "Immediate"
244CMAS_C2K_URGENCY_EXPECTED = "Expected"
245
246CMAS_C2K_CERTIANTY_OBSERVED = "Observed"
247CMAS_C2K_CERTIANTY_LIKELY = "Likely"
248
249#PDN Numbers
250PDN_NO_1 = 1
251PDN_NO_2 = 2
252PDN_NO_3 = 3
253PDN_NO_4 = 4
254PDN_NO_5 = 5
255
256# IMS Services parameters
257DEFAULT_VNID = 1
258NDP_NIC_NAME = '"Intel(R) 82577LM Gigabit Network Connection"'
259CSCF_Monitoring_UA_URI = '"sip:+11234567890@test.3gpp.com"'
260TMO_CSCF_Monitoring_UA_URI = '"sip:001010123456789@msg.lab.t-mobile.com"'
261CSCF_Virtual_UA_URI = '"sip:+11234567891@test.3gpp.com"'
262TMO_CSCF_Virtual_UA_URI = '"sip:0123456789@ims.mnc01.mcc001.3gppnetwork.org"'
263CSCF_HOSTNAME = '"ims.mnc01.mcc001.3gppnetwork.org"'
264TMO_USERLIST_NAME = "310260123456789@msg.lab.t-mobile.com"
265VZW_USERLIST_NAME = "001010123456789@test.3gpp.com"
266
267# Google Fi IMS Services parameters
268Fi_CSCF_Monitoring_UA_URI = '"sip:310260971239432@ims.mnc260.mcc310.3gppnetwork.org"'
269Fi_CSCF_Virtual_UA_URI = '"sip:0123456789@msg.pc.t-mobile.com"'
270Fi_CSCF_HOSTNAME = '"ims.mnc260.mcc310.3gppnetwork.org"'
271Fi_USERLIST_NAME = "310260971239432@msg.pc.t-mobile.com"
272
273#Cell Numbers
274CELL_1 = 1
275CELL_2 = 2
276
277# default ims virtual network id for Anritsu ims call test.
278DEFAULT_IMS_VIRTUAL_NETWORK_ID = 1
279
280def cb_serial_number():
281    """ CMAS/ETWS serial number generator """
282    i = 0x3000
283    while True:
284        yield i
285        i += 1
286
287
288def set_usim_parameters(anritsu_handle, sim_card):
289    """ set USIM parameters in MD8475A simulationn parameter
290
291    Args:
292        anritsu_handle: anritusu device object.
293        sim_card : "P0250Ax" or "12349"
294
295    Returns:
296        None
297    """
298    if sim_card == P0250Ax:
299        anritsu_handle.usim_key = "000102030405060708090A0B0C0D0E0F"
300    elif sim_card == P0135Ax:
301        anritsu_handle.usim_key = "00112233445566778899AABBCCDDEEFF"
302    elif sim_card == VzW12349:
303        anritsu_handle.usim_key = "465B5CE8B199B49FAA5F0A2EE238A6BC"
304        anritsu_handle.send_command("IMSI 311480012345678")
305        anritsu_handle.send_command("SECURITY3G MILENAGE")
306        anritsu_handle.send_command(
307            "MILENAGEOP 5F1D289C5D354D0A140C2548F5F3E3BA")
308    elif sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
309        anritsu_handle.usim_key = "000102030405060708090A0B0C0D0E0F"
310
311
312def save_anritsu_log_files(anritsu_handle, test_name, user_params):
313    """ saves the anritsu smart studio log files
314        The logs should be saved in Anritsu system. Need to provide
315        log folder path in Anritsu system
316
317    Args:
318        anritsu_handle: anritusu device object.
319        test_name: test case name
320        user_params : user supplied parameters list
321
322    Returns:
323        None
324    """
325    md8475a_log_folder = user_params["anritsu_log_file_path"]
326    file_name = getfilenamewithtimestamp(test_name)
327    seq_logfile = "{}\\{}_seq.csv".format(md8475a_log_folder, file_name)
328    msg_logfile = "{}\\{}_msg.csv".format(md8475a_log_folder, file_name)
329    trace_logfile = "{}\\{}_trace.lgex".format(md8475a_log_folder, file_name)
330    anritsu_handle.save_sequence_log(seq_logfile)
331    anritsu_handle.save_message_log(msg_logfile)
332    anritsu_handle.save_trace_log(trace_logfile, "BINARY", 1, 0, 0)
333    anritsu_handle.clear_sequence_log()
334    anritsu_handle.clear_message_log()
335
336
337def getfilenamewithtimestamp(test_name):
338    """ Gets the test name appended with current time
339
340    Args:
341        test_name : test case name
342
343    Returns:
344        string of test name appended with current time
345    """
346    time_stamp = datetime.now().strftime("%m-%d-%Y_%H-%M-%S")
347    return "{}_{}".format(test_name, time_stamp)
348
349
350def _init_lte_bts(bts, user_params, cell_no, sim_card):
351    """ initializes the LTE BTS
352        All BTS parameters should be set here
353
354    Args:
355        bts: BTS object.
356        user_params: pointer to user supplied parameters
357        cell_no: specify the cell number this BTS is configured
358        Anritsu supports two cells. so cell_1 or cell_2
359
360    Returns:
361        None
362    """
363    bts.nw_fullname_enable = BtsNwNameEnable.NAME_ENABLE
364    bts.nw_fullname = TEST_PLMN_LTE_NAME
365    bts.mcc = get_lte_mcc(user_params, cell_no, sim_card)
366    bts.mnc = get_lte_mnc(user_params, cell_no, sim_card)
367    bts.band = get_lte_band(user_params, cell_no, sim_card)
368    bts.transmode = get_transmission_mode(user_params, cell_no)
369    bts.dl_antenna = get_dl_antenna(user_params, cell_no)
370    bts.output_level = DEFAULT_OUTPUT_LEVEL
371    bts.input_level = DEFAULT_INPUT_LEVEL
372
373
374def _init_wcdma_bts(bts, user_params, cell_no, sim_card):
375    """ initializes the WCDMA BTS
376        All BTS parameters should be set here
377
378    Args:
379        bts: BTS object.
380        user_params: pointer to user supplied parameters
381        cell_no: specify the cell number this BTS is configured
382        Anritsu supports two cells. so cell_1 or cell_2
383
384    Returns:
385        None
386    """
387    bts.nw_fullname_enable = BtsNwNameEnable.NAME_ENABLE
388    bts.nw_fullname = TEST_PLMN_WCDMA_NAME
389    bts.mcc = get_wcdma_mcc(user_params, cell_no, sim_card)
390    bts.mnc = get_wcdma_mnc(user_params, cell_no, sim_card)
391    bts.band = get_wcdma_band(user_params, cell_no)
392    bts.rac = get_wcdma_rac(user_params, cell_no)
393    bts.lac = get_wcdma_lac(user_params, cell_no)
394    bts.output_level = DEFAULT_OUTPUT_LEVEL
395    bts.input_level = DEFAULT_INPUT_LEVEL
396    bts.packet_rate = DEFAULT_WCDMA_PACKET_RATE
397
398
399def _init_gsm_bts(bts, user_params, cell_no, sim_card):
400    """ initializes the GSM BTS
401        All BTS parameters should be set here
402
403    Args:
404        bts: BTS object.
405        user_params: pointer to user supplied parameters
406        cell_no: specify the cell number this BTS is configured
407        Anritsu supports two cells. so cell_1 or cell_2
408
409    Returns:
410        None
411    """
412    bts.nw_fullname_enable = BtsNwNameEnable.NAME_ENABLE
413    bts.nw_fullname = TEST_PLMN_GSM_NAME
414    bts.mcc = get_gsm_mcc(user_params, cell_no, sim_card)
415    bts.mnc = get_gsm_mnc(user_params, cell_no, sim_card)
416    bts.band = get_gsm_band(user_params, cell_no, sim_card)
417    bts.rac = get_gsm_rac(user_params, cell_no)
418    bts.lac = get_gsm_lac(user_params, cell_no)
419    bts.output_level = DEFAULT_OUTPUT_LEVEL
420    bts.input_level = DEFAULT_INPUT_LEVEL
421
422
423def _init_1x_bts(bts, user_params, cell_no, sim_card):
424    """ initializes the 1X BTS
425        All BTS parameters should be set here
426
427    Args:
428        bts: BTS object.
429        user_params: pointer to user supplied parameters
430        cell_no: specify the cell number this BTS is configured
431        Anritsu supports two cells. so cell_1 or cell_2
432
433    Returns:
434        None
435    """
436    bts.sector1_mcc = get_1x_mcc(user_params, cell_no, sim_card)
437    bts.band = get_1x_band(user_params, cell_no, sim_card)
438    bts.dl_channel = get_1x_channel(user_params, cell_no, sim_card)
439    bts.sector1_sid = get_1x_sid(user_params, cell_no, sim_card)
440    bts.sector1_nid = get_1x_nid(user_params, cell_no, sim_card)
441    bts.output_level = DEFAULT_1X_OUTPUT_LEVEL
442
443
444def _init_evdo_bts(bts, user_params, cell_no, sim_card):
445    """ initializes the EVDO BTS
446        All BTS parameters should be set here
447
448    Args:
449        bts: BTS object.
450        user_params: pointer to user supplied parameters
451        cell_no: specify the cell number this BTS is configured
452        Anritsu supports two cells. so cell_1 or cell_2
453
454    Returns:
455        None
456    """
457    bts.band = get_evdo_band(user_params, cell_no, sim_card)
458    bts.dl_channel = get_evdo_channel(user_params, cell_no, sim_card)
459    bts.evdo_sid = get_evdo_sid(user_params, cell_no, sim_card)
460    bts.output_level = DEFAULT_1X_OUTPUT_LEVEL
461
462
463def _init_PDN(anritsu_handle,
464              sim_card,
465              pdn,
466              ipv4,
467              ipv6,
468              ims_binding,
469              vnid_number=DEFAULT_VNID):
470    """ initializes the PDN parameters
471        All PDN parameters should be set here
472
473    Args:
474        anritsu_handle: anritusu device object.
475        pdn: pdn object
476        ip_address : UE IP address
477        ims_binding: to bind with IMS VNID(1) or not
478
479    Returns:
480        None
481    """
482    # Setting IP address for internet connection sharing
483    # Google Fi _init_PDN
484    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
485        pdn.ue_address_ipv4 = ipv4
486        pdn.ue_address_ipv6 = ipv6
487        if ims_binding:
488            pdn.pdn_ims = Switch.ENABLE
489            pdn.pdn_vnid = vnid_number
490            pdn.pdn_DG_selection = 'USER'
491            pdn.pdn_gateway_ipv4addr = Fi_GATEWAY_IPV4_ADDR_IMS_911
492            pdn.pdn_gateway_ipv6addr = Fi_GATEWAY_IPV6_ADDR_IMS_911
493
494        else:
495            anritsu_handle.gateway_ipv4addr = Fi_GATEWAY_IPV4_ADDR_Data
496            anritsu_handle.gateway_ipv6addr = Fi_GATEWAY_IPV6_ADDR_Data
497            pdn.primary_dns_address_ipv4 = Fi_DNS_IPV4_ADDR_Pri
498            pdn.secondary_dns_address_ipv4 = Fi_DNS_IPV4_ADDR_Sec
499            pdn.dns_address_ipv6 = Fi_DNS_IPV6_ADDR
500            pdn.cscf_address_ipv4 = Fi_CSCF_IPV4_ADDR_Data
501            pdn.cscf_address_ipv6 = Fi_CSCF_IPV6_ADDR_Data
502    # Pixel Lab _init_PDN_
503    else:
504        anritsu_handle.gateway_ipv4addr = GATEWAY_IPV4_ADDR
505        pdn.ue_address_ipv4 = ipv4
506        pdn.ue_address_ipv6 = ipv6
507        if ims_binding:
508            pdn.pdn_ims = Switch.ENABLE
509            pdn.pdn_vnid = vnid_number
510        else:
511            pdn.primary_dns_address_ipv4 = DNS_IPV4_ADDR
512            pdn.secondary_dns_address_ipv4 = DNS_IPV4_ADDR
513            pdn.cscf_address_ipv4 = CSCF_IPV4_ADDR
514
515
516def _init_IMS(anritsu_handle,
517              vnid,
518              sim_card=None,
519              ipv4_address=CSCF_IPV4_ADDR,
520              ipv6_address=CSCF_IPV6_ADDR,
521              ip_type="IPV4V6",
522              auth=False):
523    """ initializes the IMS VNID parameters
524        All IMS parameters should be set here
525
526    Args:
527        anritsu_handle: anritusu device object.
528        vnid: IMS Services object
529
530    Returns:
531        None
532    """
533    # vnid.sync = Switch.ENABLE # supported in 6.40a release
534    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
535        vnid.cscf_address_ipv4 = ipv4_address
536        vnid.cscf_address_ipv6 = ipv6_address
537        vnid.imscscf_iptype = ip_type
538        vnid.dns = Switch.DISABLE
539        vnid.ndp_nic = NDP_NIC_NAME
540        vnid.ndp_prefix = ipv6_address
541        if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
542            vnid.cscf_monitoring_ua = Fi_CSCF_Monitoring_UA_URI
543            vnid.cscf_virtual_ua = Fi_CSCF_Virtual_UA_URI
544            vnid.cscf_host_name = Fi_CSCF_HOSTNAME
545            vnid.cscf_ims_authentication = "ENABLE"
546            if auth:
547                vnid.cscf_ims_authentication = "ENABLE"
548                vnid.fi_cscf_userslist_add = Fi_USERLIST_NAME
549        else:
550            vnid.cscf_monitoring_ua = CSCF_Monitoring_UA_URI
551        vnid.psap = Switch.ENABLE
552        vnid.psap_auto_answer = Switch.ENABLE
553    else:
554        vnid.cscf_address_ipv4 = CSCF_IPV4_ADDR
555        vnid.cscf_address_ipv6 = ipv6_address
556        vnid.imscscf_iptype = ip_type
557        vnid.dns = Switch.DISABLE
558        vnid.ndp_nic = NDP_NIC_NAME
559        vnid.ndp_prefix = ipv6_address
560        if sim_card == P0135Ax:
561            vnid.cscf_monitoring_ua = TMO_CSCF_Monitoring_UA_URI
562            vnid.cscf_virtual_ua = TMO_CSCF_Virtual_UA_URI
563            vnid.cscf_host_name = CSCF_HOSTNAME
564            vnid.cscf_precondition = "ENABLE"
565            vnid.cscf_ims_authentication = "DISABLE"
566            if auth:
567                vnid.cscf_ims_authentication = "ENABLE"
568                vnid.tmo_cscf_userslist_add = TMO_USERLIST_NAME
569        elif sim_card == VzW12349:
570            vnid.cscf_monitoring_ua = CSCF_Monitoring_UA_URI
571            vnid.cscf_virtual_ua = CSCF_Virtual_UA_URI
572            vnid.cscf_ims_authentication = "DISABLE"
573            if auth:
574                vnid.cscf_ims_authentication = "ENABLE"
575                vnid.vzw_cscf_userslist_add = VZW_USERLIST_NAME
576        else:
577            vnid.cscf_monitoring_ua = CSCF_Monitoring_UA_URI
578        vnid.psap = Switch.ENABLE
579        vnid.psap_auto_answer = Switch.ENABLE
580
581
582def set_system_model_lte_lte(anritsu_handle, user_params, sim_card):
583    """ Configures Anritsu system for LTE and LTE simulation
584
585    Args:
586        anritsu_handle: anritusu device object.
587        user_params: pointer to user supplied parameters
588
589    Returns:
590        Lte and Wcdma BTS objects
591    """
592    anritsu_handle.set_simulation_model(BtsTechnology.LTE,
593                                        BtsTechnology.LTE)
594    # setting BTS parameters
595    lte1_bts = anritsu_handle.get_BTS(BtsNumber.BTS1)
596    lte2_bts = anritsu_handle.get_BTS(BtsNumber.BTS2)
597    _init_lte_bts(lte1_bts, user_params, CELL_1, sim_card)
598    _init_lte_bts(lte2_bts, user_params, CELL_2, sim_card)
599    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
600        pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
601        pdn2 = anritsu_handle.get_PDN(PDN_NO_2)
602        pdn3 = anritsu_handle.get_PDN(PDN_NO_3)
603        pdn4 = anritsu_handle.get_PDN(PDN_NO_4)
604        pdn5 = anritsu_handle.get_PDN(PDN_NO_5)
605
606        # Initialize PDN IP address for internet connection sharing
607        _init_PDN(anritsu_handle, sim_card, pdn1, Fi_UE_IPV4_ADDR_Data,
608                  Fi_UE_IPV6_ADDR_Data, False)
609        _init_PDN(anritsu_handle, sim_card, pdn2, Fi_UE_IPV4_ADDR_Data,
610                  Fi_UE_IPV6_ADDR_Data, False)
611        _init_PDN(anritsu_handle, sim_card, pdn3, Fi_UE_IPV4_ADDR_Data,
612                  Fi_UE_IPV6_ADDR_Data, False)
613        _init_PDN(anritsu_handle, sim_card, pdn4, Fi_UE_IPV4_ADDR_IMS,
614                  Fi_UE_IPV6_ADDR_IMS,
615                  True)
616        _init_PDN(anritsu_handle, sim_card, pdn5, Fi_UE_IPV4_ADDR_911,
617                  Fi_UE_IPV6_ADDR_911,
618                  True)
619        vnid1 = anritsu_handle.get_IMS(1)
620        vnid2 = anritsu_handle.get_IMS(2)
621        # _init_IMS(
622        #     anritsu_handle,
623        #     vnid1,
624        #     sim_card,
625        #     ipv4_address=CSCF_IPV4_ADDR,
626        #     ipv6_address=CSCF_IPV6_ADDR,
627        #     auth=False)
628        _init_IMS(
629            anritsu_handle,
630            vnid1,
631            sim_card,
632            ipv4_address=Fi_CSCF_IPV4_ADDR_IMS,
633            ipv6_address=Fi_CSCF_IPV6_ADDR_IMS,
634            auth=True)
635        _init_IMS(
636            anritsu_handle,
637            vnid2,
638            sim_card,
639            ipv4_address=Fi_CSCF_IPV4_ADDR_911,
640            ipv6_address=Fi_CSCF_IPV6_ADDR_911,
641            auth=False)
642    else:
643        _init_lte_bts(lte1_bts, user_params, CELL_1, sim_card)
644        _init_lte_bts(lte2_bts, user_params, CELL_2, sim_card)
645        pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
646        pdn2 = anritsu_handle.get_PDN(PDN_NO_2)
647        pdn3 = anritsu_handle.get_PDN(PDN_NO_3)
648        # Initialize PDN IP address for internet connection sharing
649        _init_PDN(anritsu_handle, sim_card, pdn1, UE_IPV4_ADDR_1, UE_IPV6_ADDR_1, True)
650        _init_PDN(anritsu_handle, sim_card, pdn2, UE_IPV4_ADDR_2, UE_IPV6_ADDR_2, False)
651        _init_PDN(anritsu_handle, sim_card, pdn3, UE_IPV4_ADDR_3, UE_IPV6_ADDR_3, True)
652        vnid1 = anritsu_handle.get_IMS(DEFAULT_VNID)
653        if sim_card == P0135Ax:
654            vnid2 = anritsu_handle.get_IMS(2)
655            vnid3 = anritsu_handle.get_IMS(3)
656            _init_IMS(
657                anritsu_handle,
658                vnid1,
659                sim_card,
660                ipv6_address=CSCF_IPV6_ADDR,
661                auth=True)
662            _init_IMS(
663                anritsu_handle,
664                vnid2,
665                sim_card,
666                ipv6_address=CSCF_IPV6_ADDR_2,
667                ip_type="IPV6")
668            _init_IMS(
669                anritsu_handle,
670                vnid3,
671                sim_card,
672                ipv6_address=CSCF_IPV6_ADDR_3,
673                ip_type="IPV6")
674        elif sim_card == VzW12349:
675            _init_IMS(anritsu_handle, vnid1, sim_card, auth=True)
676        else:
677            _init_IMS(anritsu_handle, vnid1, sim_card)
678        return [lte1_bts, lte2_bts]
679
680
681def set_system_model_wcdma_wcdma(anritsu_handle, user_params, sim_card):
682    """ Configures Anritsu system for WCDMA and WCDMA simulation
683
684    Args:
685        anritsu_handle: anritusu device object.
686        user_params: pointer to user supplied parameters
687
688    Returns:
689        Lte and Wcdma BTS objects
690    """
691    anritsu_handle.set_simulation_model(BtsTechnology.WCDMA,
692                                        BtsTechnology.WCDMA)
693    # setting BTS parameters
694    wcdma1_bts = anritsu_handle.get_BTS(BtsNumber.BTS1)
695    wcdma2_bts = anritsu_handle.get_BTS(BtsNumber.BTS2)
696    _init_wcdma_bts(wcdma1_bts, user_params, CELL_1, sim_card)
697    _init_wcdma_bts(wcdma2_bts, user_params, CELL_2, sim_card)
698    pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
699    # Initialize PDN IP address for internet connection sharing
700    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
701        _init_PDN(anritsu_handle, sim_card, pdn1, Fi_UE_IPV4_ADDR_Data, Fi_UE_IPV6_ADDR_Data,
702                  False)
703    else:
704        _init_PDN(anritsu_handle, sim_card, pdn1, UE_IPV4_ADDR_1, UE_IPV6_ADDR_1, False)
705    return [wcdma1_bts, wcdma2_bts]
706
707
708def set_system_model_lte_wcdma(anritsu_handle, user_params, sim_card):
709    """ Configures Anritsu system for LTE and WCDMA simulation
710
711    Args:
712        anritsu_handle: anritusu device object.
713        user_params: pointer to user supplied parameters
714
715    Returns:
716        Lte and Wcdma BTS objects
717    """
718    anritsu_handle.set_simulation_model(BtsTechnology.LTE, BtsTechnology.WCDMA)
719    # setting BTS parameters
720    lte_bts = anritsu_handle.get_BTS(BtsNumber.BTS1)
721    wcdma_bts = anritsu_handle.get_BTS(BtsNumber.BTS2)
722    _init_lte_bts(lte_bts, user_params, CELL_1, sim_card)
723    _init_wcdma_bts(wcdma_bts, user_params, CELL_2, sim_card)
724    pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
725    pdn2 = anritsu_handle.get_PDN(PDN_NO_2)
726    pdn3 = anritsu_handle.get_PDN(PDN_NO_3)
727    # Initialize PDN IP address for internet connection sharing
728    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
729        pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
730        pdn2 = anritsu_handle.get_PDN(PDN_NO_2)
731        pdn3 = anritsu_handle.get_PDN(PDN_NO_3)
732        pdn4 = anritsu_handle.get_PDN(PDN_NO_4)
733        pdn5 = anritsu_handle.get_PDN(PDN_NO_5)
734        # Initialize PDN IP address.
735        _init_PDN(anritsu_handle, sim_card, pdn1, Fi_UE_IPV4_ADDR_Data,
736                  Fi_UE_IPV6_ADDR_Data, False)
737        _init_PDN(anritsu_handle, sim_card, pdn2, Fi_UE_IPV4_ADDR_Data,
738                  Fi_UE_IPV6_ADDR_Data, False)
739        _init_PDN(anritsu_handle, sim_card, pdn3, Fi_UE_IPV4_ADDR_Data,
740                  Fi_UE_IPV6_ADDR_Data, False)
741        _init_PDN(anritsu_handle, sim_card, pdn4, Fi_UE_IPV4_ADDR_IMS,
742                  Fi_UE_IPV6_ADDR_IMS,
743                  True)
744        _init_PDN(anritsu_handle, sim_card, pdn5, Fi_UE_IPV4_ADDR_911,
745                  Fi_UE_IPV6_ADDR_911,
746                  True)
747        vnid1 = anritsu_handle.get_IMS(1)
748        vnid2 = anritsu_handle.get_IMS(2)
749        _init_IMS(
750            anritsu_handle,
751            vnid1,
752            sim_card,
753            ipv4_address=Fi_CSCF_IPV4_ADDR_IMS,
754            ipv6_address=Fi_CSCF_IPV6_ADDR_IMS,
755            auth=True)
756        _init_IMS(
757            anritsu_handle,
758            vnid2,
759            sim_card,
760            ipv4_address=Fi_CSCF_IPV4_ADDR_911,
761            ipv6_address=Fi_CSCF_IPV6_ADDR_911,
762            auth=False)
763        return [lte_bts, wcdma_bts]
764    else:
765        _init_PDN(anritsu_handle, sim_card, pdn1, UE_IPV4_ADDR_1, UE_IPV6_ADDR_1, True)
766        _init_PDN(anritsu_handle, sim_card, pdn2, UE_IPV4_ADDR_2, UE_IPV6_ADDR_2, False)
767        _init_PDN(anritsu_handle, sim_card, pdn3, UE_IPV4_ADDR_3, UE_IPV6_ADDR_3, True)
768        vnid1 = anritsu_handle.get_IMS(DEFAULT_VNID)
769        if sim_card == P0135Ax:
770            vnid2 = anritsu_handle.get_IMS(2)
771            vnid3 = anritsu_handle.get_IMS(3)
772            _init_IMS(
773                anritsu_handle,
774                vnid1,
775                sim_card,
776                ipv6_address=CSCF_IPV6_ADDR,
777                auth=True)
778            _init_IMS(
779                anritsu_handle,
780                vnid2,
781                sim_card,
782                ipv6_address=CSCF_IPV6_ADDR_2,
783                ip_type="IPV6")
784            _init_IMS(
785                anritsu_handle,
786                vnid3,
787                sim_card,
788                ipv6_address=CSCF_IPV6_ADDR_3,
789                ip_type="IPV6")
790        elif sim_card == VzW12349:
791            _init_IMS(anritsu_handle, vnid1, sim_card, auth=True)
792        else:
793            _init_IMS(anritsu_handle, vnid1, sim_card)
794    return [lte_bts, wcdma_bts]
795
796
797def set_system_model_lte_gsm(anritsu_handle, user_params, sim_card):
798    """ Configures Anritsu system for LTE and GSM simulation
799
800    Args:
801        anritsu_handle: anritusu device object.
802        user_params: pointer to user supplied parameters
803
804    Returns:
805        Lte and Wcdma BTS objects
806    """
807    anritsu_handle.set_simulation_model(BtsTechnology.LTE, BtsTechnology.GSM)
808    # setting BTS parameters
809    lte_bts = anritsu_handle.get_BTS(BtsNumber.BTS1)
810    gsm_bts = anritsu_handle.get_BTS(BtsNumber.BTS2)
811    _init_lte_bts(lte_bts, user_params, CELL_1, sim_card)
812    _init_gsm_bts(gsm_bts, user_params, CELL_2, sim_card)
813    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
814        pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
815        pdn2 = anritsu_handle.get_PDN(PDN_NO_2)
816        pdn3 = anritsu_handle.get_PDN(PDN_NO_3)
817        pdn4 = anritsu_handle.get_PDN(PDN_NO_4)
818        pdn5 = anritsu_handle.get_PDN(PDN_NO_5)
819        # Initialize PDN IP address.
820        _init_PDN(anritsu_handle, sim_card, pdn1, Fi_UE_IPV4_ADDR_Data,
821                  Fi_UE_IPV6_ADDR_Data, False)
822        _init_PDN(anritsu_handle, sim_card, pdn2, Fi_UE_IPV4_ADDR_Data,
823                  Fi_UE_IPV6_ADDR_Data, False)
824        _init_PDN(anritsu_handle, sim_card, pdn3, Fi_UE_IPV4_ADDR_Data,
825                  Fi_UE_IPV6_ADDR_Data, False)
826        _init_PDN(anritsu_handle, sim_card, pdn4, Fi_UE_IPV4_ADDR_IMS,
827                  Fi_UE_IPV6_ADDR_IMS,
828                  True)
829        _init_PDN(anritsu_handle, sim_card, pdn5, Fi_UE_IPV4_ADDR_911,
830                  Fi_UE_IPV6_ADDR_911,
831                  True)
832        vnid1 = anritsu_handle.get_IMS(1)
833        vnid2 = anritsu_handle.get_IMS(2)
834        _init_IMS(
835            anritsu_handle,
836            vnid1,
837            sim_card,
838            ipv4_address=Fi_CSCF_IPV4_ADDR_IMS,
839            ipv6_address=Fi_CSCF_IPV6_ADDR_IMS,
840            auth=True)
841        _init_IMS(
842            anritsu_handle,
843            vnid2,
844            sim_card,
845            ipv4_address=Fi_CSCF_IPV4_ADDR_911,
846            ipv6_address=Fi_CSCF_IPV6_ADDR_911,
847            auth=False)
848        return [lte_bts, gsm_bts]
849    else:
850        pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
851        pdn2 = anritsu_handle.get_PDN(PDN_NO_2)
852        pdn3 = anritsu_handle.get_PDN(PDN_NO_3)
853        # Initialize PDN IP address for internet connection sharing
854        _init_PDN(anritsu_handle, sim_card, pdn1, UE_IPV4_ADDR_1, UE_IPV6_ADDR_1, True)
855        _init_PDN(anritsu_handle, sim_card, pdn2, UE_IPV4_ADDR_2, UE_IPV6_ADDR_2, False)
856        _init_PDN(anritsu_handle, sim_card, pdn3, UE_IPV4_ADDR_3, UE_IPV6_ADDR_3, True)
857        vnid1 = anritsu_handle.get_IMS(DEFAULT_VNID)
858        if sim_card == P0135Ax:
859            vnid2 = anritsu_handle.get_IMS(2)
860            vnid3 = anritsu_handle.get_IMS(3)
861            _init_IMS(
862                anritsu_handle,
863                vnid1,
864                sim_card,
865                ipv6_address=CSCF_IPV6_ADDR,
866                auth=True)
867            _init_IMS(
868                anritsu_handle,
869                vnid2,
870                sim_card,
871                ipv6_address=CSCF_IPV6_ADDR_2,
872                ip_type="IPV6")
873            _init_IMS(
874                anritsu_handle,
875                vnid3,
876                sim_card,
877                ipv6_address=CSCF_IPV6_ADDR_3,
878                ip_type="IPV6")
879        elif sim_card == VzW12349:
880            _init_IMS(anritsu_handle, vnid1, sim_card, auth=True)
881        else:
882            _init_IMS(anritsu_handle, vnid1, sim_card)
883    return [lte_bts, gsm_bts]
884
885
886def set_system_model_lte_1x(anritsu_handle, user_params, sim_card):
887    """ Configures Anritsu system for LTE and 1x simulation
888
889    Args:
890        anritsu_handle: anritusu device object.
891        user_params: pointer to user supplied parameters
892
893    Returns:
894        Lte and 1x BTS objects
895    """
896    anritsu_handle.set_simulation_model(BtsTechnology.LTE,
897                                        BtsTechnology.CDMA1X)
898    # setting BTS parameters
899    lte_bts = anritsu_handle.get_BTS(BtsNumber.BTS1)
900    cdma1x_bts = anritsu_handle.get_BTS(BtsNumber.BTS2)
901    _init_lte_bts(lte_bts, user_params, CELL_1, sim_card)
902    _init_1x_bts(cdma1x_bts, user_params, CELL_2, sim_card)
903    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
904        pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
905        pdn2 = anritsu_handle.get_PDN(PDN_NO_2)
906        pdn3 = anritsu_handle.get_PDN(PDN_NO_3)
907        pdn4 = anritsu_handle.get_PDN(PDN_NO_4)
908        pdn5 = anritsu_handle.get_PDN(PDN_NO_5)
909        # Initialize PDN IP address.
910        _init_PDN(anritsu_handle, sim_card, pdn1, Fi_UE_IPV4_ADDR_Data,
911                  Fi_UE_IPV6_ADDR_Data, False)
912        _init_PDN(anritsu_handle, sim_card, pdn2, Fi_UE_IPV4_ADDR_Data,
913                  Fi_UE_IPV6_ADDR_Data, False)
914        _init_PDN(anritsu_handle, sim_card, pdn3, Fi_UE_IPV4_ADDR_Data,
915                  Fi_UE_IPV6_ADDR_Data, False)
916        _init_PDN(anritsu_handle, sim_card, pdn4, Fi_UE_IPV4_ADDR_IMS,
917                  Fi_UE_IPV6_ADDR_IMS,
918                  True)
919        _init_PDN(anritsu_handle, sim_card, pdn5, Fi_UE_IPV4_ADDR_911,
920                  Fi_UE_IPV6_ADDR_911,
921                  True)
922        vnid1 = anritsu_handle.get_IMS(1)
923        vnid2 = anritsu_handle.get_IMS(2)
924        _init_IMS(
925            anritsu_handle,
926            vnid1,
927            sim_card,
928            ipv4_address=Fi_CSCF_IPV4_ADDR_IMS,
929            ipv6_address=Fi_CSCF_IPV6_ADDR_IMS,
930            auth=True)
931        _init_IMS(
932            anritsu_handle,
933            vnid2,
934            sim_card,
935            ipv4_address=Fi_CSCF_IPV4_ADDR_911,
936            ipv6_address=Fi_CSCF_IPV6_ADDR_911,
937            auth=False)
938        return [lte_bts, cdma1x_bts]
939    else:
940        pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
941        pdn2 = anritsu_handle.get_PDN(PDN_NO_2)
942        pdn3 = anritsu_handle.get_PDN(PDN_NO_3)
943        # Initialize PDN IP address for internet connection sharing
944        _init_PDN(anritsu_handle, sim_card, pdn1, UE_IPV4_ADDR_1, UE_IPV6_ADDR_1, True)
945        _init_PDN(anritsu_handle, sim_card, pdn2, UE_IPV4_ADDR_2, UE_IPV6_ADDR_2, False)
946        _init_PDN(anritsu_handle, sim_card, pdn3, UE_IPV4_ADDR_3, UE_IPV6_ADDR_3, True)
947        vnid1 = anritsu_handle.get_IMS(DEFAULT_VNID)
948        if sim_card == P0135Ax:
949            vnid2 = anritsu_handle.get_IMS(2)
950            vnid3 = anritsu_handle.get_IMS(3)
951            _init_IMS(
952                anritsu_handle,
953                vnid1,
954                sim_card,
955                ipv6_address=CSCF_IPV6_ADDR,
956                auth=True)
957            _init_IMS(
958                anritsu_handle,
959                vnid2,
960                sim_card,
961                ipv6_address=CSCF_IPV6_ADDR_2,
962                ip_type="IPV6")
963            _init_IMS(
964                anritsu_handle,
965                vnid3,
966                sim_card,
967                ipv6_address=CSCF_IPV6_ADDR_3,
968                ip_type="IPV6")
969        elif sim_card == VzW12349:
970            _init_IMS(anritsu_handle, vnid1, sim_card, auth=True)
971        else:
972            _init_IMS(anritsu_handle, vnid1, sim_card)
973    return [lte_bts, cdma1x_bts]
974
975
976def set_system_model_lte_evdo(anritsu_handle, user_params, sim_card):
977    """ Configures Anritsu system for LTE and EVDO simulation
978
979    Args:
980        anritsu_handle: anritusu device object.
981        user_params: pointer to user supplied parameters
982
983    Returns:
984        Lte and 1x BTS objects
985    """
986    anritsu_handle.set_simulation_model(BtsTechnology.LTE, BtsTechnology.EVDO)
987    # setting BTS parameters
988    lte_bts = anritsu_handle.get_BTS(BtsNumber.BTS1)
989    evdo_bts = anritsu_handle.get_BTS(BtsNumber.BTS2)
990    _init_lte_bts(lte_bts, user_params, CELL_1, sim_card)
991    _init_evdo_bts(evdo_bts, user_params, CELL_2, sim_card)
992    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
993        pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
994        pdn2 = anritsu_handle.get_PDN(PDN_NO_2)
995        pdn3 = anritsu_handle.get_PDN(PDN_NO_3)
996        pdn4 = anritsu_handle.get_PDN(PDN_NO_4)
997        pdn5 = anritsu_handle.get_PDN(PDN_NO_5)
998        # Initialize PDN IP address.
999        _init_PDN(anritsu_handle, sim_card, pdn1, Fi_UE_IPV4_ADDR_Data,
1000                  Fi_UE_IPV6_ADDR_Data, False)
1001        _init_PDN(anritsu_handle, sim_card, pdn2, Fi_UE_IPV4_ADDR_Data,
1002                  Fi_UE_IPV6_ADDR_Data, False)
1003        _init_PDN(anritsu_handle, sim_card, pdn3, Fi_UE_IPV4_ADDR_Data,
1004                  Fi_UE_IPV6_ADDR_Data, False)
1005        _init_PDN(anritsu_handle, sim_card, pdn4, Fi_UE_IPV4_ADDR_IMS,
1006                  Fi_UE_IPV6_ADDR_IMS,
1007                  True)
1008        _init_PDN(anritsu_handle, sim_card, pdn5, Fi_UE_IPV4_ADDR_911,
1009                  Fi_UE_IPV6_ADDR_911,
1010                  True)
1011        vnid1 = anritsu_handle.get_IMS(1)
1012        vnid2 = anritsu_handle.get_IMS(2)
1013        _init_IMS(
1014            anritsu_handle,
1015            vnid1,
1016            sim_card,
1017            ipv4_address=Fi_CSCF_IPV4_ADDR_IMS,
1018            ipv6_address=Fi_CSCF_IPV6_ADDR_IMS,
1019            auth=True)
1020        _init_IMS(
1021            anritsu_handle,
1022            vnid2,
1023            sim_card,
1024            ipv4_address=Fi_CSCF_IPV4_ADDR_911,
1025            ipv6_address=Fi_CSCF_IPV6_ADDR_911,
1026            auth=False)
1027        return [lte_bts, evdo_bts]
1028    else:
1029        pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
1030        pdn2 = anritsu_handle.get_PDN(PDN_NO_2)
1031        pdn3 = anritsu_handle.get_PDN(PDN_NO_3)
1032        # Initialize PDN IP address for internet connection sharing
1033        _init_PDN(anritsu_handle, sim_card, pdn1, UE_IPV4_ADDR_1, UE_IPV6_ADDR_1, True)
1034        _init_PDN(anritsu_handle, sim_card, pdn2, UE_IPV4_ADDR_2, UE_IPV6_ADDR_2, False)
1035        _init_PDN(anritsu_handle, sim_card, pdn3, UE_IPV4_ADDR_3, UE_IPV6_ADDR_3, True)
1036        vnid1 = anritsu_handle.get_IMS(DEFAULT_VNID)
1037        if sim_card == P0135Ax:
1038            vnid2 = anritsu_handle.get_IMS(2)
1039            vnid3 = anritsu_handle.get_IMS(3)
1040            _init_IMS(
1041                anritsu_handle,
1042                vnid1,
1043                sim_card,
1044                ipv6_address=CSCF_IPV6_ADDR,
1045                auth=True)
1046            _init_IMS(
1047                anritsu_handle,
1048                vnid2,
1049                sim_card,
1050                ipv6_address=CSCF_IPV6_ADDR_2,
1051                ip_type="IPV6")
1052            _init_IMS(
1053                anritsu_handle,
1054                vnid3,
1055                sim_card,
1056                ipv6_address=CSCF_IPV6_ADDR_3,
1057                ip_type="IPV6")
1058        elif sim_card == VzW12349:
1059            _init_IMS(anritsu_handle, vnid1, sim_card, auth=True)
1060        else:
1061            _init_IMS(anritsu_handle, vnid1, sim_card)
1062    return [lte_bts, evdo_bts]
1063
1064
1065def set_system_model_wcdma_gsm(anritsu_handle, user_params, sim_card):
1066    """ Configures Anritsu system for WCDMA and GSM simulation
1067
1068    Args:
1069        anritsu_handle: anritusu device object.
1070        user_params: pointer to user supplied parameters
1071
1072    Returns:
1073        Wcdma and Gsm BTS objects
1074    """
1075    anritsu_handle.set_simulation_model(BtsTechnology.WCDMA, BtsTechnology.GSM)
1076    # setting BTS parameters
1077    wcdma_bts = anritsu_handle.get_BTS(BtsNumber.BTS1)
1078    gsm_bts = anritsu_handle.get_BTS(BtsNumber.BTS2)
1079    _init_wcdma_bts(wcdma_bts, user_params, CELL_1, sim_card)
1080    _init_gsm_bts(gsm_bts, user_params, CELL_2, sim_card)
1081    pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
1082    # Initialize PDN IP address for internet connection sharing
1083    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
1084        _init_PDN(anritsu_handle, sim_card, pdn1, Fi_UE_IPV4_ADDR_Data,
1085                  Fi_UE_IPV6_ADDR_Data, False)
1086    else:
1087        _init_PDN(anritsu_handle, sim_card, pdn1, UE_IPV4_ADDR_1, UE_IPV6_ADDR_1, False)
1088    return [wcdma_bts, gsm_bts]
1089
1090
1091def set_system_model_gsm_gsm(anritsu_handle, user_params, sim_card):
1092    """ Configures Anritsu system for GSM and GSM simulation
1093
1094    Args:
1095        anritsu_handle: anritusu device object.
1096        user_params: pointer to user supplied parameters
1097
1098    Returns:
1099        Wcdma and Gsm BTS objects
1100    """
1101    anritsu_handle.set_simulation_model(BtsTechnology.GSM, BtsTechnology.GSM)
1102    # setting BTS parameters
1103    gsm1_bts = anritsu_handle.get_BTS(BtsNumber.BTS1)
1104    gsm2_bts = anritsu_handle.get_BTS(BtsNumber.BTS2)
1105    _init_gsm_bts(gsm1_bts, user_params, CELL_1, sim_card)
1106    _init_gsm_bts(gsm2_bts, user_params, CELL_2, sim_card)
1107    pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
1108    # Initialize PDN IP address for internet connection sharing
1109    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
1110        _init_PDN(anritsu_handle,sim_card, pdn1, Fi_UE_IPV4_ADDR_Data,
1111                  Fi_UE_IPV6_ADDR_Data, False)
1112    else:
1113        _init_PDN(anritsu_handle,sim_card, pdn1, UE_IPV4_ADDR_1, UE_IPV6_ADDR_1, False)
1114    return [gsm1_bts, gsm2_bts]
1115
1116
1117def set_system_model_lte(anritsu_handle, user_params, sim_card):
1118    """ Configures Anritsu system for LTE simulation
1119
1120    Args:
1121        anritsu_handle: anritusu device object.
1122        user_params: pointer to user supplied parameters
1123
1124    Returns:
1125        Lte BTS object
1126    """
1127    anritsu_handle.set_simulation_model(BtsTechnology.LTE)
1128    # setting Fi BTS parameters
1129    lte_bts = anritsu_handle.get_BTS(BtsNumber.BTS1)
1130    _init_lte_bts(lte_bts, user_params, CELL_1, sim_card)
1131
1132    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
1133        pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
1134        pdn2 = anritsu_handle.get_PDN(PDN_NO_2)
1135        pdn3 = anritsu_handle.get_PDN(PDN_NO_3)
1136        pdn4 = anritsu_handle.get_PDN(PDN_NO_4)
1137        pdn5 = anritsu_handle.get_PDN(PDN_NO_5)
1138    # Initialize PDN IP address.
1139        _init_PDN(anritsu_handle,sim_card, pdn1, Fi_UE_IPV4_ADDR_Data,
1140                  Fi_UE_IPV6_ADDR_Data, False)
1141        _init_PDN(anritsu_handle,sim_card, pdn2, Fi_UE_IPV4_ADDR_Data,
1142                  Fi_UE_IPV6_ADDR_Data, False)
1143        _init_PDN(anritsu_handle,sim_card, pdn3, Fi_UE_IPV4_ADDR_Data,
1144                  Fi_UE_IPV6_ADDR_Data, False)
1145        _init_PDN(anritsu_handle, sim_card, pdn4, Fi_UE_IPV4_ADDR_IMS,
1146                  Fi_UE_IPV6_ADDR_IMS,
1147                  True)
1148        _init_PDN(anritsu_handle, sim_card, pdn5, Fi_UE_IPV4_ADDR_911,
1149                  Fi_UE_IPV6_ADDR_911,
1150                  True)
1151        vnid1 = anritsu_handle.get_IMS(1)
1152        vnid2 = anritsu_handle.get_IMS(2)
1153        _init_IMS(
1154            anritsu_handle,
1155            vnid1,
1156            sim_card,
1157            ipv4_address=Fi_CSCF_IPV4_ADDR_IMS,
1158            ipv6_address=Fi_CSCF_IPV6_ADDR_IMS,
1159            auth=True)
1160        _init_IMS(
1161            anritsu_handle,
1162            vnid2,
1163            sim_card,
1164            ipv4_address=Fi_CSCF_IPV4_ADDR_911,
1165            ipv6_address=Fi_CSCF_IPV6_ADDR_911,
1166            auth=False)
1167        return [lte_bts]
1168    else:
1169        # setting BTS parameters
1170        pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
1171        pdn2 = anritsu_handle.get_PDN(PDN_NO_2)
1172        pdn3 = anritsu_handle.get_PDN(PDN_NO_3)
1173        # Initialize PDN IP address for internet connection sharing
1174        _init_PDN(anritsu_handle,sim_card, pdn1, UE_IPV4_ADDR_1, UE_IPV6_ADDR_1, True)
1175        _init_PDN(anritsu_handle,sim_card, pdn2, UE_IPV4_ADDR_2, UE_IPV6_ADDR_2, False)
1176        _init_PDN(anritsu_handle,sim_card, pdn3, UE_IPV4_ADDR_3, UE_IPV6_ADDR_3, True)
1177        vnid1 = anritsu_handle.get_IMS(DEFAULT_VNID)
1178        if sim_card == P0135Ax:
1179            vnid2 = anritsu_handle.get_IMS(2)
1180            vnid3 = anritsu_handle.get_IMS(3)
1181            _init_IMS(
1182                anritsu_handle,
1183                vnid1,
1184                sim_card,
1185                ipv6_address=CSCF_IPV6_ADDR,
1186                auth=True)
1187            _init_IMS(
1188                anritsu_handle,
1189                vnid2,
1190                sim_card,
1191                ipv6_address=CSCF_IPV6_ADDR_2,
1192                ip_type="IPV6")
1193            _init_IMS(
1194                anritsu_handle,
1195                vnid3,
1196                sim_card,
1197                ipv6_address=CSCF_IPV6_ADDR_3,
1198                ip_type="IPV6")
1199        elif sim_card == VzW12349:
1200            _init_IMS(anritsu_handle, vnid1, sim_card, auth=True)
1201        else:
1202            _init_IMS(anritsu_handle, vnid1, sim_card)
1203        return [lte_bts]
1204
1205
1206def set_system_model_wcdma(anritsu_handle, user_params, sim_card):
1207    """ Configures Anritsu system for WCDMA simulation
1208
1209    Args:
1210        anritsu_handle: anritusu device object.
1211        user_params: pointer to user supplied parameters
1212
1213    Returns:
1214        Wcdma BTS object
1215    """
1216    anritsu_handle.set_simulation_model(BtsTechnology.WCDMA)
1217    # setting BTS parameters
1218    wcdma_bts = anritsu_handle.get_BTS(BtsNumber.BTS1)
1219    _init_wcdma_bts(wcdma_bts, user_params, CELL_1, sim_card)
1220    pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
1221    # Initialize PDN IP address for internet connection sharing
1222    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
1223        _init_PDN(anritsu_handle,sim_card, pdn1, Fi_UE_IPV4_ADDR_Data,
1224                  Fi_UE_IPV6_ADDR_Data, False)
1225    else:
1226        _init_PDN(anritsu_handle,sim_card, pdn1, UE_IPV4_ADDR_1, UE_IPV6_ADDR_1, False)
1227    return [wcdma_bts]
1228
1229
1230def set_system_model_gsm(anritsu_handle, user_params, sim_card):
1231    """ Configures Anritsu system for GSM simulation
1232
1233    Args:
1234        anritsu_handle: anritusu device object.
1235        user_params: pointer to user supplied parameters
1236
1237    Returns:
1238        Gsm BTS object
1239    """
1240    anritsu_handle.set_simulation_model(BtsTechnology.GSM)
1241    # setting BTS parameters
1242    gsm_bts = anritsu_handle.get_BTS(BtsNumber.BTS1)
1243    _init_gsm_bts(gsm_bts, user_params, CELL_1, sim_card)
1244    pdn1 = anritsu_handle.get_PDN(PDN_NO_1)
1245    # Initialize PDN IP address for internet connection sharing
1246    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
1247        _init_PDN(anritsu_handle,sim_card, pdn1, Fi_UE_IPV4_ADDR_Data,
1248                  Fi_UE_IPV6_ADDR_Data, False)
1249    else:
1250        _init_PDN(anritsu_handle,sim_card, pdn1, UE_IPV4_ADDR_1, UE_IPV6_ADDR_1, False)
1251    return [gsm_bts]
1252
1253
1254def set_system_model_1x(anritsu_handle, user_params, sim_card):
1255    """ Configures Anritsu system for CDMA 1X simulation
1256
1257    Args:
1258        anritsu_handle: anritusu device object.
1259        user_params: pointer to user supplied parameters
1260
1261    Returns:
1262        Cdma 1x BTS object
1263    """
1264    PDN_ONE = 1
1265    anritsu_handle.set_simulation_model(BtsTechnology.CDMA1X)
1266    # setting BTS parameters
1267    cdma1x_bts = anritsu_handle.get_BTS(BtsNumber.BTS1)
1268    _init_1x_bts(cdma1x_bts, user_params, CELL_1, sim_card)
1269    pdn1 = anritsu_handle.get_PDN(PDN_ONE)
1270    # Initialize PDN IP address for internet connection sharing
1271    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
1272        _init_PDN(anritsu_handle,sim_card, pdn1, Fi_UE_IPV4_ADDR_Data,
1273                  Fi_UE_IPV6_ADDR_Data, False)
1274    else:
1275        _init_PDN(anritsu_handle,sim_card, pdn1, UE_IPV4_ADDR_1, UE_IPV6_ADDR_1, False)
1276    return [cdma1x_bts]
1277
1278
1279def set_system_model_1x_evdo(anritsu_handle, user_params, sim_card):
1280    """ Configures Anritsu system for CDMA 1X simulation
1281
1282    Args:
1283        anritsu_handle: anritusu device object.
1284        user_params: pointer to user supplied parameters
1285
1286    Returns:
1287        Cdma 1x BTS object
1288    """
1289    PDN_ONE = 1
1290    anritsu_handle.set_simulation_model(BtsTechnology.CDMA1X,
1291                                        BtsTechnology.EVDO)
1292    # setting BTS parameters
1293    cdma1x_bts = anritsu_handle.get_BTS(BtsNumber.BTS1)
1294    evdo_bts = anritsu_handle.get_BTS(BtsNumber.BTS2)
1295    _init_1x_bts(cdma1x_bts, user_params, CELL_1, sim_card)
1296    _init_evdo_bts(evdo_bts, user_params, CELL_2, sim_card)
1297    pdn1 = anritsu_handle.get_PDN(PDN_ONE)
1298    # Initialize PDN IP address for internet connection sharing
1299    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
1300        _init_PDN(anritsu_handle,sim_card, pdn1, Fi_UE_IPV4_ADDR_Data,
1301                  Fi_UE_IPV6_ADDR_Data, False)
1302    else:
1303        _init_PDN(anritsu_handle,sim_card, pdn1, UE_IPV4_ADDR_1, UE_IPV6_ADDR_1, False)
1304    return [cdma1x_bts]
1305
1306
1307def wait_for_bts_state(log, btsnumber, state, timeout=30):
1308    """ Waits for BTS to be in the specified state ("IN" or "OUT")
1309
1310    Args:
1311        btsnumber: BTS number.
1312        state: expected state
1313
1314    Returns:
1315        True for success False for failure
1316    """
1317    #  state value are "IN" and "OUT"
1318    status = False
1319    sleep_interval = 1
1320    wait_time = timeout
1321
1322    if state == "IN":
1323        service_state = BtsServiceState.SERVICE_STATE_IN
1324    elif state == "OUT":
1325        service_state = BtsServiceState.SERVICE_STATE_OUT
1326    else:
1327        log.info("wrong state value")
1328        return status
1329
1330    if btsnumber.service_state is service_state:
1331        log.info("BTS state is already in {}".format(state))
1332        return True
1333
1334    # set to desired service state
1335    btsnumber.service_state = service_state
1336
1337    while wait_time > 0:
1338        if service_state == btsnumber.service_state:
1339            status = True
1340            break
1341        time.sleep(sleep_interval)
1342        wait_time = wait_time - sleep_interval
1343
1344    if not status:
1345        log.info("Timeout: Expected BTS state is not received.")
1346    return status
1347
1348
1349class _CallSequenceException(Exception):
1350    pass
1351
1352
1353def call_mo_setup_teardown(
1354        log,
1355        ad,
1356        anritsu_handle,
1357        callee_number,
1358        teardown_side=CALL_TEARDOWN_PHONE,
1359        is_emergency=False,
1360        wait_time_in_call=WAIT_TIME_IN_CALL_LONG,
1361        is_ims_call=False,
1362        ims_virtual_network_id=DEFAULT_IMS_VIRTUAL_NETWORK_ID):
1363    """ Makes a MO call and tear down the call
1364
1365    Args:
1366        ad: Android device object.
1367        anritsu_handle: Anritsu object.
1368        callee_number: Number to be called.
1369        teardown_side: the side to end the call (Phone or remote).
1370        is_emergency: is the call an emergency call.
1371        wait_time_in_call: Time to wait when phone in call.
1372        is_ims_call: is the call expected to be ims call.
1373        ims_virtual_network_id: ims virtual network id.
1374
1375    Returns:
1376        True for success False for failure
1377    """
1378
1379    log.info("Making Call to " + callee_number)
1380    virtual_phone_handle = anritsu_handle.get_VirtualPhone()
1381
1382    try:
1383        # for an IMS call we either check CSCF or *nothing* (no virtual phone).
1384        if is_ims_call:
1385            # we only need pre-call registration in a non-emergency case
1386            if not is_emergency:
1387                if not wait_for_ims_cscf_status(log, anritsu_handle,
1388                                                ims_virtual_network_id,
1389                                                ImsCscfStatus.SIPIDLE.value):
1390                    raise _CallSequenceException(
1391                        "Phone IMS status is not idle.")
1392        else:
1393            if not wait_for_virtualphone_state(log, virtual_phone_handle,
1394                                               VirtualPhoneStatus.STATUS_IDLE):
1395                raise _CallSequenceException("Virtual Phone not idle.")
1396
1397        if not initiate_call(log, ad, callee_number, is_emergency):
1398            raise _CallSequenceException("Initiate call failed.")
1399
1400        if is_ims_call:
1401            if not wait_for_ims_cscf_status(log, anritsu_handle,
1402                                            ims_virtual_network_id,
1403                                            ImsCscfStatus.CALLING.value):
1404                raise _CallSequenceException(
1405                    "Phone IMS status is not calling.")
1406            if not wait_for_ims_cscf_status(log, anritsu_handle,
1407                                            ims_virtual_network_id,
1408                                            ImsCscfStatus.CONNECTED.value):
1409                raise _CallSequenceException(
1410                    "Phone IMS status is not connected.")
1411        else:
1412            # check Virtual phone answered the call
1413            if not wait_for_virtualphone_state(
1414                    log, virtual_phone_handle,
1415                    VirtualPhoneStatus.STATUS_VOICECALL_INPROGRESS):
1416                raise _CallSequenceException("Virtual Phone not in call.")
1417
1418        time.sleep(wait_time_in_call)
1419
1420        if not ad.droid.telecomIsInCall():
1421            raise _CallSequenceException("Call ended before delay_in_call.")
1422
1423        if teardown_side is CALL_TEARDOWN_REMOTE:
1424            log.info("Disconnecting the call from Remote")
1425            if is_ims_call:
1426                anritsu_handle.ims_cscf_call_action(ims_virtual_network_id,
1427                                                    ImsCscfCall.END.value)
1428            else:
1429                virtual_phone_handle.set_voice_on_hook()
1430            if not wait_for_droid_not_in_call(log, ad,
1431                                              MAX_WAIT_TIME_CALL_DROP):
1432                raise _CallSequenceException("DUT call not drop.")
1433        else:
1434            log.info("Disconnecting the call from DUT")
1435            if not hangup_call(log, ad, is_emergency):
1436                raise _CallSequenceException(
1437                    "Error in Hanging-Up Call on DUT.")
1438
1439        if is_ims_call:
1440            if not wait_for_ims_cscf_status(log, anritsu_handle,
1441                                            ims_virtual_network_id,
1442                                            ImsCscfStatus.SIPIDLE.value):
1443                raise _CallSequenceException("Phone IMS status is not idle.")
1444        else:
1445            if not wait_for_virtualphone_state(log, virtual_phone_handle,
1446                                               VirtualPhoneStatus.STATUS_IDLE):
1447                raise _CallSequenceException(
1448                    "Virtual Phone not idle after hangup.")
1449        return True
1450
1451    except _CallSequenceException as e:
1452        log.error(e)
1453        return False
1454    finally:
1455        try:
1456            if ad.droid.telecomIsInCall():
1457                ad.droid.telecomEndCall()
1458        except Exception as e:
1459            log.error(str(e))
1460
1461
1462def handover_tc(log,
1463                anritsu_handle,
1464                wait_time=0,
1465                s_bts=BtsNumber.BTS1,
1466                t_bts=BtsNumber.BTS2,
1467                timeout=60):
1468    """ Setup and perform a handover test case in MD8475A
1469
1470    Args:
1471        anritsu_handle: Anritsu object.
1472        s_bts: Serving (originating) BTS
1473        t_bts: Target (destination) BTS
1474        wait_time: time to wait before handover
1475
1476    Returns:
1477        True for success False for failure
1478    """
1479    log.info("Starting HO test case procedure")
1480    log.info("Serving BTS = {}, Target BTS = {}".format(s_bts, t_bts))
1481    time.sleep(wait_time)
1482    ho_tc = anritsu_handle.get_AnritsuTestCases()
1483    ho_tc.procedure = TestProcedure.PROCEDURE_HO
1484    ho_tc.bts_direction = (s_bts, t_bts)
1485    ho_tc.power_control = TestPowerControl.POWER_CONTROL_DISABLE
1486    ho_tc.measurement_LTE = TestMeasurement.MEASUREMENT_DISABLE
1487    anritsu_handle.start_testcase()
1488    status = anritsu_handle.get_testcase_status()
1489    timer = 0
1490    while status == "0":
1491        time.sleep(1)
1492        status = anritsu_handle.get_testcase_status()
1493        timer += 1
1494        if timer > timeout:
1495            return "Handover Test Case time out in {} sec!".format(timeout)
1496    return status
1497
1498
1499def make_ims_call(log,
1500                  ad,
1501                  anritsu_handle,
1502                  callee_number,
1503                  is_emergency=False,
1504                  check_ims_reg=True,
1505                  check_ims_calling=True,
1506                  mo=True,
1507                  ims_virtual_network_id=DEFAULT_IMS_VIRTUAL_NETWORK_ID):
1508    """ Makes a MO call after IMS registred
1509
1510    Args:
1511        ad: Android device object.
1512        anritsu_handle: Anritsu object.
1513        callee_number: Number to be called.
1514        check_ims_reg: check if Anritsu cscf server state is "SIPIDLE".
1515        check_ims_calling: check if Anritsu cscf server state is "CALLING".
1516        mo: Mobile originated call
1517        ims_virtual_network_id: ims virtual network id.
1518
1519    Returns:
1520        True for success False for failure
1521    """
1522
1523    try:
1524        # confirm ims registration
1525        if check_ims_reg:
1526            if not wait_for_ims_cscf_status(log, anritsu_handle,
1527                                            ims_virtual_network_id,
1528                                            ImsCscfStatus.SIPIDLE.value):
1529                raise _CallSequenceException("IMS/CSCF status is not idle.")
1530        if mo:  # make MO call
1531            log.info("Making Call to " + callee_number)
1532            if not initiate_call(log, ad, callee_number, is_emergency):
1533                raise _CallSequenceException("Initiate call failed.")
1534            if not wait_for_ims_cscf_status(log, anritsu_handle,
1535                                            ims_virtual_network_id,
1536                                            ImsCscfStatus.CALLING.value):
1537                raise _CallSequenceException(
1538                    "Phone IMS status is not calling.")
1539        else:  # make MT call
1540            log.info("Making IMS Call to UE from MD8475A...")
1541            anritsu_handle.ims_cscf_call_action(ims_virtual_network_id,
1542                                                ImsCscfCall.MAKE.value)
1543            if not wait_for_ims_cscf_status(log, anritsu_handle,
1544                                            ims_virtual_network_id,
1545                                            ImsCscfStatus.RINGING.value):
1546                raise _CallSequenceException(
1547                    "Phone IMS status is not ringing.")
1548            # answer the call on the UE
1549            if not wait_and_answer_call(log, ad):
1550                raise _CallSequenceException("UE Answer call Fail")
1551
1552        if not wait_for_ims_cscf_status(log, anritsu_handle,
1553                                        ims_virtual_network_id,
1554                                        ImsCscfStatus.CONNECTED.value):
1555            raise _CallSequenceException(
1556                "MD8475A IMS status is not connected.")
1557        return True
1558
1559    except _CallSequenceException as e:
1560        log.error(e)
1561        return False
1562
1563
1564def tear_down_call(log,
1565                   ad,
1566                   anritsu_handle,
1567                   ims_virtual_network_id=DEFAULT_IMS_VIRTUAL_NETWORK_ID):
1568    """ Check and End a VoLTE call
1569
1570    Args:
1571        ad: Android device object.
1572        anritsu_handle: Anritsu object.
1573        ims_virtual_network_id: ims virtual network id.
1574
1575    Returns:
1576        True for success False for failure
1577    """
1578    try:
1579        # end the call from phone
1580        log.info("Disconnecting the call from DUT")
1581        if not hangup_call(log, ad):
1582            raise _CallSequenceException("Error in Hanging-Up Call on DUT.")
1583        # confirm if CSCF status is back to idle
1584        if not wait_for_ims_cscf_status(log, anritsu_handle,
1585                                        ims_virtual_network_id,
1586                                        ImsCscfStatus.SIPIDLE.value):
1587            raise _CallSequenceException("IMS/CSCF status is not idle.")
1588        return True
1589
1590    except _CallSequenceException as e:
1591        log.error(e)
1592        return False
1593    finally:
1594        try:
1595            if ad.droid.telecomIsInCall():
1596                ad.droid.telecomEndCall()
1597        except Exception as e:
1598            log.error(str(e))
1599
1600
1601# This procedure is for VoLTE mobility test cases
1602def ims_call_ho(log,
1603                ad,
1604                anritsu_handle,
1605                callee_number,
1606                is_emergency=False,
1607                check_ims_reg=True,
1608                check_ims_calling=True,
1609                mo=True,
1610                wait_time_in_volte=WAIT_TIME_IN_CALL_FOR_IMS,
1611                ims_virtual_network_id=DEFAULT_IMS_VIRTUAL_NETWORK_ID):
1612    """ Makes a MO call after IMS registred, then handover
1613
1614    Args:
1615        ad: Android device object.
1616        anritsu_handle: Anritsu object.
1617        callee_number: Number to be called.
1618        check_ims_reg: check if Anritsu cscf server state is "SIPIDLE".
1619        check_ims_calling: check if Anritsu cscf server state is "CALLING".
1620        mo: Mobile originated call
1621        wait_time_in_volte: Time for phone in VoLTE call, not used for SRLTE
1622        ims_virtual_network_id: ims virtual network id.
1623
1624    Returns:
1625        True for success False for failure
1626    """
1627
1628    try:
1629        # confirm ims registration
1630        if check_ims_reg:
1631            if not wait_for_ims_cscf_status(log, anritsu_handle,
1632                                            ims_virtual_network_id,
1633                                            ImsCscfStatus.SIPIDLE.value):
1634                raise _CallSequenceException("IMS/CSCF status is not idle.")
1635        if mo:  # make MO call
1636            log.info("Making Call to " + callee_number)
1637            if not initiate_call(log, ad, callee_number, is_emergency):
1638                raise _CallSequenceException("Initiate call failed.")
1639            if not wait_for_ims_cscf_status(log, anritsu_handle,
1640                                            ims_virtual_network_id,
1641                                            ImsCscfStatus.CALLING.value):
1642                raise _CallSequenceException(
1643                    "Phone IMS status is not calling.")
1644        else:  # make MT call
1645            log.info("Making IMS Call to UE from MD8475A...")
1646            anritsu_handle.ims_cscf_call_action(ims_virtual_network_id,
1647                                                ImsCscfCall.MAKE.value)
1648            if not wait_for_ims_cscf_status(log, anritsu_handle,
1649                                            ims_virtual_network_id,
1650                                            ImsCscfStatus.RINGING.value):
1651                raise _CallSequenceException(
1652                    "Phone IMS status is not ringing.")
1653            # answer the call on the UE
1654            if not wait_and_answer_call(log, ad):
1655                raise _CallSequenceException("UE Answer call Fail")
1656
1657        if not wait_for_ims_cscf_status(log, anritsu_handle,
1658                                        ims_virtual_network_id,
1659                                        ImsCscfStatus.CONNECTED.value):
1660            raise _CallSequenceException("Phone IMS status is not connected.")
1661        log.info(
1662            "Wait for {} seconds before handover".format(wait_time_in_volte))
1663        time.sleep(wait_time_in_volte)
1664
1665        # Once VoLTE call is connected, then Handover
1666        log.info("Starting handover procedure...")
1667        result = handover_tc(anritsu_handle, BtsNumber.BTS1, BtsNumber.BTS2)
1668        log.info("Handover procedure ends with result code {}".format(result))
1669        log.info(
1670            "Wait for {} seconds after handover".format(wait_time_in_volte))
1671        time.sleep(wait_time_in_volte)
1672
1673        # check if the phone stay in call
1674        if not ad.droid.telecomIsInCall():
1675            raise _CallSequenceException("Call ended before delay_in_call.")
1676        # end the call from phone
1677        log.info("Disconnecting the call from DUT")
1678        if not hangup_call(log, ad, is_emergency):
1679            raise _CallSequenceException("Error in Hanging-Up Call on DUT.")
1680        # confirm if CSCF status is back to idle
1681        if not wait_for_ims_cscf_status(log, anritsu_handle,
1682                                        ims_virtual_network_id,
1683                                        ImsCscfStatus.SIPIDLE.value):
1684            raise _CallSequenceException("IMS/CSCF status is not idle.")
1685
1686        return True
1687
1688    except _CallSequenceException as e:
1689        log.error(e)
1690        return False
1691    finally:
1692        try:
1693            if ad.droid.telecomIsInCall():
1694                ad.droid.telecomEndCall()
1695        except Exception as e:
1696            log.error(str(e))
1697
1698
1699# This procedure is for SRLTE CSFB and SRVCC test cases
1700def ims_call_cs_teardown(
1701        log,
1702        ad,
1703        anritsu_handle,
1704        callee_number,
1705        teardown_side=CALL_TEARDOWN_PHONE,
1706        is_emergency=False,
1707        check_ims_reg=True,
1708        check_ims_calling=True,
1709        srvcc=None,
1710        mo=True,
1711        wait_time_in_volte=WAIT_TIME_IN_CALL_FOR_IMS,
1712        wait_time_in_cs=WAIT_TIME_IN_CALL,
1713        wait_time_in_alert=WAIT_TIME_IN_ALERT,
1714        ims_virtual_network_id=DEFAULT_IMS_VIRTUAL_NETWORK_ID):
1715    """ Makes a MO call after IMS registred, transit to CS, tear down the call
1716
1717    Args:
1718        ad: Android device object.
1719        anritsu_handle: Anritsu object.
1720        callee_number: Number to be called.
1721        teardown_side: the side to end the call (Phone or remote).
1722        is_emergency: to make emergency call on the phone.
1723        check_ims_reg: check if Anritsu cscf server state is "SIPIDLE".
1724        check_ims_calling: check if Anritsu cscf server state is "CALLING".
1725        srvcc: is the test case a SRVCC call.
1726        mo: Mobile originated call
1727        wait_time_in_volte: Time for phone in VoLTE call, not used for SRLTE
1728        wait_time_in_cs: Time for phone in CS call.
1729        ims_virtual_network_id: ims virtual network id.
1730
1731    Returns:
1732        True for success False for failure
1733    """
1734
1735    virtual_phone_handle = anritsu_handle.get_VirtualPhone()
1736
1737    try:
1738        # confirm ims registration
1739        if check_ims_reg:
1740            if not wait_for_ims_cscf_status(log, anritsu_handle,
1741                                            ims_virtual_network_id,
1742                                            ImsCscfStatus.SIPIDLE.value):
1743                raise _CallSequenceException("IMS/CSCF status is not idle.")
1744        # confirm virtual phone in idle
1745        if not wait_for_virtualphone_state(log, virtual_phone_handle,
1746                                           VirtualPhoneStatus.STATUS_IDLE):
1747            raise _CallSequenceException("Virtual Phone not idle.")
1748        if mo:  # make MO call
1749            log.info("Making Call to " + callee_number)
1750            if not initiate_call(log, ad, callee_number, is_emergency):
1751                raise _CallSequenceException("Initiate call failed.")
1752        else:  # make MT call
1753            log.info("Making IMS Call to UE from MD8475A...")
1754            anritsu_handle.ims_cscf_call_action(ims_virtual_network_id,
1755                                                ImsCscfCall.MAKE.value)
1756        # if check ims calling is required
1757        if check_ims_calling:
1758            if mo:
1759                if not wait_for_ims_cscf_status(log, anritsu_handle,
1760                                                ims_virtual_network_id,
1761                                                ImsCscfStatus.CALLING.value):
1762                    raise _CallSequenceException(
1763                        "Phone IMS status is not calling.")
1764            else:
1765                if not wait_for_ims_cscf_status(log, anritsu_handle,
1766                                                ims_virtual_network_id,
1767                                                ImsCscfStatus.RINGING.value):
1768                    raise _CallSequenceException(
1769                        "Phone IMS status is not ringing.")
1770
1771            # if SRVCC, check if VoLTE call is connected, then Handover
1772            if srvcc != None:
1773                if srvcc == "InCall":
1774                    if not wait_for_ims_cscf_status(
1775                            log, anritsu_handle, ims_virtual_network_id,
1776                            ImsCscfStatus.CONNECTED.value):
1777                        raise _CallSequenceException(
1778                            "Phone IMS status is not connected.")
1779                    # stay in call for "wait_time_in_volte" seconds
1780                    time.sleep(wait_time_in_volte)
1781                elif srvcc == "Alert":
1782                    # ring for WAIT_TIME_IN_ALERT seconds
1783                    time.sleep(WAIT_TIME_IN_ALERT)
1784                # SRVCC by handover test case procedure
1785                srvcc_tc = anritsu_handle.get_AnritsuTestCases()
1786                srvcc_tc.procedure = TestProcedure.PROCEDURE_HO
1787                srvcc_tc.bts_direction = (BtsNumber.BTS1, BtsNumber.BTS2)
1788                srvcc_tc.power_control = TestPowerControl.POWER_CONTROL_DISABLE
1789                srvcc_tc.measurement_LTE = TestMeasurement.MEASUREMENT_DISABLE
1790                anritsu_handle.start_testcase()
1791                time.sleep(5)
1792        if not mo:
1793            # answer the call on the UE
1794            if not wait_and_answer_call(log, ad):
1795                raise _CallSequenceException("UE Answer call Fail")
1796        # check if Virtual phone in the call
1797        if not wait_for_virtualphone_state(
1798                log, virtual_phone_handle,
1799                VirtualPhoneStatus.STATUS_VOICECALL_INPROGRESS):
1800            raise _CallSequenceException("Virtual Phone not in call.")
1801        # stay in call for "wait_time_in_cs" seconds
1802        time.sleep(wait_time_in_cs)
1803        # check if the phone stay in call
1804        if not ad.droid.telecomIsInCall():
1805            raise _CallSequenceException("Call ended before delay_in_call.")
1806        # end the call
1807        if teardown_side is CALL_TEARDOWN_REMOTE:
1808            log.info("Disconnecting the call from Remote")
1809            virtual_phone_handle.set_voice_on_hook()
1810            if not wait_for_droid_not_in_call(log, ad,
1811                                              MAX_WAIT_TIME_CALL_DROP):
1812                raise _CallSequenceException("DUT call not drop.")
1813        else:
1814            log.info("Disconnecting the call from DUT")
1815            if not hangup_call(log, ad, is_emergency):
1816                raise _CallSequenceException(
1817                    "Error in Hanging-Up Call on DUT.")
1818        # confirm if virtual phone status is back to idle
1819        if not wait_for_virtualphone_state(log, virtual_phone_handle,
1820                                           VirtualPhoneStatus.STATUS_IDLE):
1821            raise _CallSequenceException(
1822                "Virtual Phone not idle after hangup.")
1823        return True
1824
1825    except _CallSequenceException as e:
1826        log.error(e)
1827        return False
1828    finally:
1829        try:
1830            if ad.droid.telecomIsInCall():
1831                ad.droid.telecomEndCall()
1832        except Exception as e:
1833            log.error(str(e))
1834
1835
1836def call_mt_setup_teardown(log,
1837                           ad,
1838                           virtual_phone_handle,
1839                           caller_number=None,
1840                           teardown_side=CALL_TEARDOWN_PHONE,
1841                           rat=""):
1842    """ Makes a call from Anritsu Virtual phone to device and tear down the call
1843
1844    Args:
1845        ad: Android device object.
1846        virtual_phone_handle: Anritsu virtual phone handle
1847        caller_number =  Caller number
1848        teardown_side = specifiy the side to end the call (Phone or remote)
1849
1850    Returns:
1851        True for success False for failure
1852    """
1853    log.info("Receive MT Call - Making a call to the phone from remote")
1854    try:
1855        if not wait_for_virtualphone_state(log, virtual_phone_handle,
1856                                           VirtualPhoneStatus.STATUS_IDLE):
1857            raise Exception("Virtual Phone is not in a state to start call")
1858        if caller_number is not None:
1859            if rat == RAT_1XRTT:
1860                virtual_phone_handle.id_c2k = caller_number
1861            else:
1862                virtual_phone_handle.id = caller_number
1863        virtual_phone_handle.set_voice_off_hook()
1864
1865        if not wait_and_answer_call(log, ad, caller_number):
1866            raise Exception("Answer call Fail")
1867
1868        time.sleep(WAIT_TIME_IN_CALL)
1869
1870        if not ad.droid.telecomIsInCall():
1871            raise Exception("Call ended before delay_in_call.")
1872    except Exception:
1873        return False
1874
1875    if ad.droid.telecomIsInCall():
1876        if teardown_side is CALL_TEARDOWN_REMOTE:
1877            log.info("Disconnecting the call from Remote")
1878            virtual_phone_handle.set_voice_on_hook()
1879        else:
1880            log.info("Disconnecting the call from Phone")
1881            ad.droid.telecomEndCall()
1882
1883    wait_for_virtualphone_state(log, virtual_phone_handle,
1884                                VirtualPhoneStatus.STATUS_IDLE)
1885    ensure_phone_idle(log, ad)
1886
1887    return True
1888
1889
1890def wait_for_sms_deliver_success(log, ad, time_to_wait=60):
1891    sms_deliver_event = EventSmsDeliverSuccess
1892    sleep_interval = 2
1893    status = False
1894    event = None
1895
1896    try:
1897        event = ad.ed.pop_event(sms_deliver_event, time_to_wait)
1898        status = True
1899    except Empty:
1900        log.info("Timeout: Expected event is not received.")
1901    return status
1902
1903
1904def wait_for_sms_sent_success(log, ad, time_to_wait=60):
1905    sms_sent_event = EventSmsSentSuccess
1906    sleep_interval = 2
1907    status = False
1908    event = None
1909
1910    try:
1911        event = ad.ed.pop_event(sms_sent_event, time_to_wait)
1912        log.info(event)
1913        status = True
1914    except Empty:
1915        log.info("Timeout: Expected event is not received.")
1916    return status
1917
1918
1919def wait_for_incoming_sms(log, ad, time_to_wait=60):
1920    sms_received_event = EventSmsReceived
1921    sleep_interval = 2
1922    status = False
1923    event = None
1924
1925    try:
1926        event = ad.ed.pop_event(sms_received_event, time_to_wait)
1927        log.info(event)
1928        status = True
1929    except Empty:
1930        log.info("Timeout: Expected event is not received.")
1931    return status, event
1932
1933
1934def verify_anritsu_received_sms(log, vp_handle, receiver_number, message, rat):
1935    if rat == RAT_1XRTT:
1936        receive_sms = vp_handle.receiveSms_c2k()
1937    else:
1938        receive_sms = vp_handle.receiveSms()
1939
1940    if receive_sms == "NONE":
1941        return False
1942    split = receive_sms.split('&')
1943    text = ""
1944    if rat == RAT_1XRTT:
1945        # TODO: b/26296388 There is some problem when retrieving message with é
1946        # from Anritsu.
1947        return True
1948    for i in range(len(split)):
1949        if split[i].startswith('Text='):
1950            text = split[i][5:]
1951            text = AnritsuUtils.gsm_decode(text)
1952            break
1953    # TODO: b/26296388 Verify Phone number
1954    if text != message:
1955        log.error("Wrong message received")
1956        return False
1957    return True
1958
1959
1960def sms_mo_send(log, ad, vp_handle, receiver_number, message, rat=""):
1961    try:
1962        if not wait_for_virtualphone_state(log, vp_handle,
1963                                           VirtualPhoneStatus.STATUS_IDLE):
1964            raise Exception("Virtual Phone is not in a state to receive SMS")
1965        log.info("Sending SMS to " + receiver_number)
1966        ad.droid.smsSendTextMessage(receiver_number, message, False)
1967        log.info("Waiting for SMS sent event")
1968        test_status = wait_for_sms_sent_success(log, ad)
1969        if not test_status:
1970            raise Exception("Failed to send SMS")
1971        if not verify_anritsu_received_sms(log, vp_handle, receiver_number,
1972                                           message, rat):
1973            raise Exception("Anritsu didn't receive message")
1974    except Exception as e:
1975        log.error("Exception :" + str(e))
1976        return False
1977    return True
1978
1979
1980def sms_mt_receive_verify(log, ad, vp_handle, sender_number, message, rat=""):
1981    ad.droid.smsStartTrackingIncomingMessage()
1982    try:
1983        if not wait_for_virtualphone_state(log, vp_handle,
1984                                           VirtualPhoneStatus.STATUS_IDLE):
1985            raise Exception("Virtual Phone is not in a state to receive SMS")
1986        log.info("Waiting for Incoming SMS from " + sender_number)
1987        if rat == RAT_1XRTT:
1988            vp_handle.sendSms_c2k(sender_number, message)
1989        else:
1990            vp_handle.sendSms(sender_number, message)
1991        test_status, event = wait_for_incoming_sms(log, ad)
1992        if not test_status:
1993            raise Exception("Failed to receive SMS")
1994        log.info("Incoming SMS: Sender " + event['data']['Sender'])
1995        log.info("Incoming SMS: Message " + event['data']['Text'])
1996        if event['data']['Sender'] != sender_number:
1997            raise Exception("Wrong sender Number")
1998        if event['data']['Text'] != message:
1999            raise Exception("Wrong message")
2000    except Exception as e:
2001        log.error("exception: " + str(e))
2002        return False
2003    finally:
2004        ad.droid.smsStopTrackingIncomingMessage()
2005    return True
2006
2007
2008def wait_for_ims_cscf_status(log,
2009                             anritsu_handle,
2010                             virtual_network_id,
2011                             status,
2012                             timeout=MAX_WAIT_TIME_IMS_CSCF_STATE):
2013    """ Wait for IMS CSCF to be in expected state.
2014
2015    Args:
2016        log: log object
2017        anritsu_handle: anritsu object
2018        virtual_network_id: virtual network id to be monitored
2019        status: expected status
2020        timeout: wait time
2021    """
2022    sleep_interval = 1
2023    wait_time = timeout
2024    while wait_time > 0:
2025        if status == anritsu_handle.get_ims_cscf_status(virtual_network_id):
2026            return True
2027        time.sleep(sleep_interval)
2028        wait_time = wait_time - sleep_interval
2029    return False
2030
2031
2032def wait_for_virtualphone_state(log,
2033                                vp_handle,
2034                                state,
2035                                timeout=MAX_WAIT_TIME_VIRTUAL_PHONE_STATE):
2036    """ Waits for Anritsu Virtual phone to be in expected state
2037
2038    Args:
2039        ad: Android device object.
2040        vp_handle: Anritus virtual phone handle
2041        state =  expected state
2042
2043    Returns:
2044        True for success False for failure
2045    """
2046    status = False
2047    sleep_interval = 1
2048    wait_time = timeout
2049    while wait_time > 0:
2050        if vp_handle.status == state:
2051            log.info(vp_handle.status)
2052            status = True
2053            break
2054        time.sleep(sleep_interval)
2055        wait_time = wait_time - sleep_interval
2056
2057    if not status:
2058        log.info("Timeout: Expected state is not received.")
2059    return status
2060
2061
2062# There is a difference between CMAS/ETWS message formation in LTE/WCDMA and CDMA 1X
2063# LTE and CDMA : 3GPP
2064# CDMA 1X: 3GPP2
2065# hence different functions
2066def cmas_receive_verify_message_lte_wcdma(
2067        log, ad, anritsu_handle, serial_number, message_id, warning_message):
2068    """ Makes Anritsu to send a CMAS message and phone and verifies phone
2069        receives the message on LTE/WCDMA
2070
2071    Args:
2072        ad: Android device object.
2073        anritsu_handle: Anritus device object
2074        serial_number =  serial number of CMAS message
2075        message_id =  CMAS message ID
2076        warning_message =  CMAS warning message
2077
2078    Returns:
2079        True for success False for failure
2080    """
2081    status = False
2082    event = None
2083    ad.droid.smsStartTrackingGsmEmergencyCBMessage()
2084    anritsu_handle.send_cmas_lte_wcdma(
2085        hex(serial_number), message_id, warning_message)
2086    try:
2087        log.info("Waiting for CMAS Message")
2088        event = ad.ed.pop_event(EventCmasReceived, 60)
2089        status = True
2090        log.info(event)
2091        if warning_message != event['data']['message']:
2092            log.info("Wrong warning messgae received")
2093            status = False
2094        if message_id != hex(event['data']['serviceCategory']):
2095            log.info("Wrong warning messgae received")
2096            status = False
2097    except Empty:
2098        log.info("Timeout: Expected event is not received.")
2099
2100    ad.droid.smsStopTrackingGsmEmergencyCBMessage()
2101    return status
2102
2103
2104def cmas_receive_verify_message_cdma1x(
2105        log,
2106        ad,
2107        anritsu_handle,
2108        message_id,
2109        service_category,
2110        alert_text,
2111        response_type=CMAS_C2K_RESPONSETYPE_SHELTER,
2112        severity=CMAS_C2K_SEVERITY_EXTREME,
2113        urgency=CMAS_C2K_URGENCY_IMMEDIATE,
2114        certainty=CMAS_C2K_CERTIANTY_OBSERVED):
2115    """ Makes Anritsu to send a CMAS message and phone and verifies phone
2116        receives the message on CDMA 1X
2117
2118    Args:
2119        ad: Android device object.
2120        anritsu_handle: Anritus device object
2121        serial_number =  serial number of CMAS message
2122        message_id =  CMAS message ID
2123        warning_message =  CMAS warning message
2124
2125    Returns:
2126        True for success False for failure
2127    """
2128    status = False
2129    event = None
2130    ad.droid.smsStartTrackingCdmaEmergencyCBMessage()
2131    anritsu_handle.send_cmas_etws_cdma1x(message_id, service_category,
2132                                         alert_text, response_type, severity,
2133                                         urgency, certainty)
2134    try:
2135        log.info("Waiting for CMAS Message")
2136        event = ad.ed.pop_event(EventCmasReceived, 60)
2137        status = True
2138        log.info(event)
2139        if alert_text != event['data']['message']:
2140            log.info("Wrong alert messgae received")
2141            status = False
2142
2143        if event['data']['cmasResponseType'].lower() != response_type.lower():
2144            log.info("Wrong response type received")
2145            status = False
2146
2147        if event['data']['cmasUrgency'].lower() != urgency.lower():
2148            log.info("Wrong cmasUrgency received")
2149            status = False
2150
2151        if event['data']['cmasSeverity'].lower() != severity.lower():
2152            log.info("Wrong cmasSeverity received")
2153            status = False
2154    except Empty:
2155        log.info("Timeout: Expected event is not received.")
2156
2157    ad.droid.smsStopTrackingCdmaEmergencyCBMessage()
2158    return status
2159
2160
2161def etws_receive_verify_message_lte_wcdma(
2162        log, ad, anritsu_handle, serial_number, message_id, warning_message):
2163    """ Makes Anritsu to send a ETWS message and phone and verifies phone
2164        receives the message on LTE/WCDMA
2165
2166    Args:
2167        ad: Android device object.
2168        anritsu_handle: Anritus device object
2169        serial_number =  serial number of ETWS message
2170        message_id =  ETWS message ID
2171        warning_message =  ETWS warning message
2172
2173    Returns:
2174        True for success False for failure
2175    """
2176    status = False
2177    event = None
2178    if message_id == ETWS_WARNING_EARTHQUAKE:
2179        warning_type = "Earthquake"
2180    elif message_id == ETWS_WARNING_EARTHQUAKETSUNAMI:
2181        warning_type = "EarthquakeandTsunami"
2182    elif message_id == ETWS_WARNING_TSUNAMI:
2183        warning_type = "Tsunami"
2184    elif message_id == ETWS_WARNING_TEST_MESSAGE:
2185        warning_type = "test"
2186    elif message_id == ETWS_WARNING_OTHER_EMERGENCY:
2187        warning_type = "other"
2188    ad.droid.smsStartTrackingGsmEmergencyCBMessage()
2189    anritsu_handle.send_etws_lte_wcdma(
2190        hex(serial_number), message_id, warning_type, warning_message, "ON",
2191        "ON")
2192    try:
2193        log.info("Waiting for ETWS Message")
2194        event = ad.ed.pop_event(EventEtwsReceived, 60)
2195        status = True
2196        log.info(event)
2197        # TODO: b/26296388 Event data verification
2198    except Empty:
2199        log.info("Timeout: Expected event is not received.")
2200
2201    ad.droid.smsStopTrackingGsmEmergencyCBMessage()
2202    return status
2203
2204
2205def etws_receive_verify_message_cdma1x(log, ad, anritsu_handle, serial_number,
2206                                       message_id, warning_message):
2207    """ Makes Anritsu to send a ETWS message and phone and verifies phone
2208        receives the message on CDMA1X
2209
2210    Args:
2211        ad: Android device object.
2212        anritsu_handle: Anritus device object
2213        serial_number =  serial number of ETWS message
2214        message_id =  ETWS message ID
2215        warning_message =  ETWS warning message
2216
2217    Returns:
2218        True for success False for failure
2219    """
2220    status = False
2221    event = None
2222    # TODO: b/26296388 need to add logic to check etws.
2223    return status
2224
2225
2226def read_ue_identity(log, ad, anritsu_handle, identity_type):
2227    """ Get the UE identity IMSI, IMEI, IMEISV
2228
2229    Args:
2230        ad: Android device object.
2231        anritsu_handle: Anritus device object
2232        identity_type: Identity type(IMSI/IMEI/IMEISV)
2233
2234    Returns:
2235        Requested Identity value
2236    """
2237    return anritsu_handle.get_ue_identity(identity_type)
2238
2239
2240def get_transmission_mode(user_params, cell_no):
2241    """ Returns the TRANSMODE to be used from the user specified parameters
2242        or default value
2243
2244    Args:
2245        user_params: pointer to user supplied parameters
2246        cell_no: specify the cell number this BTS is configured
2247        Anritsu supports two cells. so cell_1 or cell_2
2248
2249    Returns:
2250        TM to be used
2251    """
2252    key = "cell{}_transmission_mode".format(cell_no)
2253    transmission_mode = user_params.get(key, DEFAULT_T_MODE)
2254    return transmission_mode
2255
2256
2257def get_dl_antenna(user_params, cell_no):
2258    """ Returns the DL ANTENNA to be used from the user specified parameters
2259        or default value
2260
2261    Args:
2262        user_params: pointer to user supplied parameters
2263        cell_no: specify the cell number this BTS is configured
2264        Anritsu supports two cells. so cell_1 or cell_2
2265
2266    Returns:
2267        number of DL ANTENNAS to be used
2268    """
2269    key = "cell{}_dl_antenna".format(cell_no)
2270    dl_antenna = user_params.get(key, DEFAULT_DL_ANTENNA)
2271    return dl_antenna
2272
2273
2274def get_lte_band(user_params, cell_no, sim_card):
2275    """ Returns the LTE BAND to be used from the user specified parameters
2276        or default value
2277
2278    Args:
2279        user_params: pointer to user supplied parameters
2280        cell_no: specify the cell number this BTS is configured
2281        Anritsu supports two cells. so cell_1 or cell_2
2282
2283    Returns:
2284        LTE BAND to be used
2285    """
2286    key = "cell{}_lte_band".format(cell_no)
2287    if sim_card == FiTMO:
2288        band = Fi_LTE_TMO_BAND[cell_no - 1]
2289    elif sim_card == FiSPR:
2290        band = Fi_LTE_SPR_BAND[cell_no - 1]
2291    elif sim_card == FiUSCC:
2292        band = Fi_LTE_USCC_BAND[cell_no - 1]
2293    else:
2294        band = DEFAULT_LTE_BAND[cell_no - 1]
2295    return user_params.get(key, band)
2296
2297
2298def get_wcdma_band(user_params, cell_no):
2299    """ Returns the WCDMA BAND to be used from the user specified parameters
2300        or default value
2301
2302    Args:
2303        user_params: pointer to user supplied parameters
2304        cell_no: specify the cell number this BTS is configured
2305        Anritsu supports two cells. so cell_1 or cell_2
2306
2307    Returns:
2308        WCDMA BAND to be used
2309    """
2310    key = "cell{}_wcdma_band".format(cell_no)
2311    wcdma_band = user_params.get(key, DEFAULT_WCDMA_BAND)
2312    return wcdma_band
2313
2314
2315def get_gsm_band(user_params, cell_no, sim_card):
2316    """ Returns the GSM BAND to be used from the user specified parameters
2317        or default value
2318
2319    Args:
2320        user_params: pointer to user supplied parameters
2321        cell_no: specify the cell number this BTS is configured
2322        Anritsu supports two cells. so cell_1 or cell_2
2323
2324    Returns:
2325        GSM BAND to be used
2326    """
2327    key = "cell{}_gsm_band".format(cell_no)
2328    if sim_card == FiTMO:
2329        gsm_band = Fi_GSM_TMO_BAND
2330    else:
2331        gsm_band = user_params.get(key, DEFAULT_GSM_BAND)
2332    return gsm_band
2333
2334
2335def get_1x_band(user_params, cell_no, sim_card):
2336    """ Returns the 1X BAND to be used from the user specified parameters
2337        or default value
2338
2339    Args:
2340        user_params: pointer to user supplied parameters
2341        cell_no: specify the cell number this BTS is configured
2342        Anritsu supports two cells. so cell_1 or cell_2
2343
2344    Returns:
2345        1X BAND to be used
2346    """
2347    key = "cell{}_1x_band".format(cell_no)
2348    if sim_card == FiSPR:
2349        band = Fi_SPR1X_BAND
2350    elif sim_card == FiUSCC:
2351        band = Fi_USCC1X_BAND
2352    elif sim_card == VzW12349:
2353        band = VzW_CDMA1x_BAND
2354    else:
2355        band = DEFAULT_CDMA1X_BAND
2356    return user_params.get(key, band)
2357
2358
2359def get_evdo_band(user_params, cell_no, sim_card):
2360    """ Returns the EVDO BAND to be used from the user specified parameters
2361        or default value
2362
2363    Args:
2364        user_params: pointer to user supplied parameters
2365        cell_no: specify the cell number this BTS is configured
2366        Anritsu supports two cells. so cell_1 or cell_2
2367
2368    Returns:
2369        EVDO BAND to be used
2370    """
2371    key = "cell{}_evdo_band".format(cell_no)
2372    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
2373        band = Fi_EVDO_BAND
2374    elif sim_card == VzW12349:
2375        band = VzW_EVDO_BAND
2376    else:
2377         band = DEFAULT_EVDO_BAND
2378    return user_params.get(key, band)
2379
2380
2381def get_wcdma_rac(user_params, cell_no):
2382    """ Returns the WCDMA RAC to be used from the user specified parameters
2383        or default value
2384
2385    Args:
2386        user_params: pointer to user supplied parameters
2387        cell_no: specify the cell number this BTS is configured
2388        Anritsu supports two cells. so cell_1 or cell_2
2389
2390    Returns:
2391        WCDMA RAC to be used
2392    """
2393    key = "cell{}_wcdma_rac".format(cell_no)
2394    try:
2395        wcdma_rac = user_params[key]
2396    except KeyError:
2397        wcdma_rac = DEFAULT_RAC
2398    return wcdma_rac
2399
2400
2401def get_gsm_rac(user_params, cell_no):
2402    """ Returns the GSM RAC to be used from the user specified parameters
2403        or default value
2404
2405    Args:
2406        user_params: pointer to user supplied parameters
2407        cell_no: specify the cell number this BTS is configured
2408        Anritsu supports two cells. so cell_1 or cell_2
2409
2410    Returns:
2411        GSM RAC to be used
2412    """
2413    key = "cell{}_gsm_rac".format(cell_no)
2414    try:
2415        gsm_rac = user_params[key]
2416    except KeyError:
2417        gsm_rac = DEFAULT_RAC
2418    return gsm_rac
2419
2420
2421def get_wcdma_lac(user_params, cell_no):
2422    """ Returns the WCDMA LAC to be used from the user specified parameters
2423        or default value
2424
2425    Args:
2426        user_params: pointer to user supplied parameters
2427        cell_no: specify the cell number this BTS is configured
2428        Anritsu supports two cells. so cell_1 or cell_2
2429
2430    Returns:
2431        WCDMA LAC to be used
2432    """
2433    key = "cell{}_wcdma_lac".format(cell_no)
2434    try:
2435        wcdma_lac = user_params[key]
2436    except KeyError:
2437        wcdma_lac = DEFAULT_LAC
2438    return wcdma_lac
2439
2440
2441def get_gsm_lac(user_params, cell_no):
2442    """ Returns the GSM LAC to be used from the user specified parameters
2443        or default value
2444
2445    Args:
2446        user_params: pointer to user supplied parameters
2447        cell_no: specify the cell number this BTS is configured
2448        Anritsu supports two cells. so cell_1 or cell_2
2449
2450    Returns:
2451        GSM LAC to be used
2452    """
2453    key = "cell{}_gsm_lac".format(cell_no)
2454    try:
2455        gsm_lac = user_params[key]
2456    except KeyError:
2457        gsm_lac = DEFAULT_LAC
2458    return gsm_lac
2459
2460
2461def get_lte_mcc(user_params, cell_no, sim_card):
2462    """ Returns the LTE MCC to be used from the user specified parameters
2463        or default value
2464
2465    Args:
2466        user_params: pointer to user supplied parameters
2467        cell_no: specify the cell number this BTS is configured
2468        Anritsu supports two cells. so cell_1 or cell_2
2469
2470    Returns:
2471        LTE MCC to be used
2472    """
2473
2474    key = "cell{}_lte_mcc".format(cell_no)
2475    if sim_card == FiTMO:
2476        mcc = Fi_TMO_MCC
2477    elif sim_card == FiSPR:
2478        mcc = Fi_SPR_MCC
2479    elif sim_card == FiUSCC:
2480        mcc = Fi_USCC_MCC
2481    elif sim_card == VzW12349:
2482        mcc = VzW_MCC
2483    else:
2484        mcc = DEFAULT_MCC
2485    return user_params.get(key, mcc)
2486
2487
2488def get_lte_mnc(user_params, cell_no, sim_card):
2489    """ Returns the LTE MNC to be used from the user specified parameters
2490        or default value
2491
2492    Args:
2493        user_params: pointer to user supplied parameters
2494        cell_no: specify the cell number this BTS is configured
2495        Anritsu supports two cells. so cell_1 or cell_2
2496
2497    Returns:
2498        LTE MNC to be used
2499    """
2500    key = "cell{}_lte_mnc".format(cell_no)
2501    if sim_card == FiTMO:
2502        mnc = Fi_TMO_MNC
2503    elif sim_card == FiSPR:
2504        mnc = Fi_SPR_MNC
2505    elif sim_card == FiUSCC:
2506        mnc = Fi_USCC_MNC
2507    elif sim_card == VzW12349:
2508        mnc = VzW_MNC
2509    else:
2510        mnc = DEFAULT_MNC
2511    return user_params.get(key, mnc)
2512
2513
2514def get_wcdma_mcc(user_params, cell_no, sim_card):
2515    """ Returns the WCDMA MCC to be used from the user specified parameters
2516        or default value
2517
2518    Args:
2519        user_params: pointer to user supplied parameters
2520        cell_no: specify the cell number this BTS is configured
2521        Anritsu supports two cells. so cell_1 or cell_2
2522
2523    Returns:
2524        WCDMA MCC to be used
2525    """
2526    key = "cell{}_wcdma_mcc".format(cell_no)
2527    mcc = VzW_MCC if sim_card == VzW12349 else DEFAULT_MCC
2528    return user_params.get(key, mcc)
2529
2530
2531def get_wcdma_mnc(user_params, cell_no, sim_card):
2532    """ Returns the WCDMA MNC to be used from the user specified parameters
2533        or default value
2534
2535    Args:
2536        user_params: pointer to user supplied parameters
2537        cell_no: specify the cell number this BTS is configured
2538        Anritsu supports two cells. so cell_1 or cell_2
2539
2540    Returns:
2541        WCDMA MNC to be used
2542    """
2543    key = "cell{}_wcdma_mnc".format(cell_no)
2544    mnc = VzW_MNC if sim_card == VzW12349 else DEFAULT_MNC
2545    return user_params.get(key, mnc)
2546
2547
2548def get_gsm_mcc(user_params, cell_no, sim_card):
2549    """ Returns the GSM MCC to be used from the user specified parameters
2550        or default value
2551
2552    Args:
2553        user_params: pointer to user supplied parameters
2554        cell_no: specify the cell number this BTS is configured
2555        Anritsu supports two cells. so cell_1 or cell_2
2556
2557    Returns:
2558        GSM MCC to be used
2559    """
2560    key = "cell{}_gsm_mcc".format(cell_no)
2561    mcc = VzW_MCC if sim_card == VzW12349 else DEFAULT_MCC
2562    return user_params.get(key, mcc)
2563
2564
2565def get_gsm_mnc(user_params, cell_no, sim_card):
2566    """ Returns the GSM MNC to be used from the user specified parameters
2567        or default value
2568
2569    Args:
2570        user_params: pointer to user supplied parameters
2571        cell_no: specify the cell number this BTS is configured
2572        Anritsu supports two cells. so cell_1 or cell_2
2573
2574    Returns:
2575        GSM MNC to be used
2576    """
2577    key = "cell{}_gsm_mnc".format(cell_no)
2578    mnc = VzW_MNC if sim_card == VzW12349 else DEFAULT_MNC
2579    return user_params.get(key, mnc)
2580
2581
2582def get_1x_mcc(user_params, cell_no, sim_card):
2583    """ Returns the 1X MCC to be used from the user specified parameters
2584        or default value
2585
2586    Args:
2587        user_params: pointer to user supplied parameters
2588        cell_no: specify the cell number this BTS is configured
2589        Anritsu supports two cells. so cell_1 or cell_2
2590
2591    Returns:
2592        1X MCC to be used
2593    """
2594    key = "cell{}_1x_mcc".format(cell_no)
2595    if sim_card == FiSPR:
2596        mcc = Fi_SPR1X_MCC
2597    elif sim_card == FiUSCC:
2598        mcc = Fi_USCC1X_MCC
2599    elif sim_card == VzW12349:
2600        mcc = VzW_MCC
2601    else:
2602        mcc = DEFAULT_MCC
2603    return user_params.get(key, mcc)
2604
2605
2606def get_1x_channel(user_params, cell_no, sim_card):
2607    """ Returns the 1X Channel to be used from the user specified parameters
2608        or default value
2609
2610    Args:
2611        user_params: pointer to user supplied parameters
2612        cell_no: specify the cell number this BTS is configured
2613        Anritsu supports two cells. so cell_1 or cell_2
2614
2615    Returns:
2616        1X Channel to be used
2617    """
2618    key = "cell{}_1x_channel".format(cell_no)
2619    if sim_card == FiSPR:
2620        ch = Fi_SPR1X_CH
2621    elif sim_card == FiUSCC:
2622        ch = Fi_USCC1X_CH
2623    elif sim_card == VzW12349:
2624        ch = VzW_CDMA1x_CH
2625    else:
2626        ch = DEFAULT_CDMA1X_CH
2627    return user_params.get(key, ch)
2628
2629
2630def get_1x_sid(user_params, cell_no, sim_card):
2631    """ Returns the 1X SID to be used from the user specified parameters
2632        or default value
2633
2634    Args:
2635        user_params: pointer to user supplied parameters
2636        cell_no: specify the cell number this BTS is configured
2637        Anritsu supports two cells. so cell_1 or cell_2
2638
2639    Returns:
2640        1X SID to be used
2641    """
2642    key = "cell{}_1x_sid".format(cell_no)
2643    if sim_card == FiSPR:
2644        sid = Fi_SPR1X_SID
2645    elif sim_card == FiUSCC:
2646        sid = Fi_USCC1X_SID
2647    elif sim_card == VzW12349:
2648        sid = VzW_CDMA1X_SID
2649    else:
2650        sid = DEFAULT_CDMA1X_SID
2651    return user_params.get(key, sid)
2652
2653
2654def get_1x_nid(user_params, cell_no, sim_card):
2655    """ Returns the 1X NID to be used from the user specified parameters
2656        or default value
2657
2658    Args:
2659        user_params: pointer to user supplied parameters
2660        cell_no: specify the cell number this BTS is configured
2661        Anritsu supports two cells. so cell_1 or cell_2
2662
2663    Returns:
2664        1X NID to be used
2665    """
2666    key = "cell{}_1x_nid".format(cell_no)
2667    if sim_card == FiSPR:
2668        nid = Fi_SPR1X_NID
2669    elif sim_card == FiUSCC:
2670        nid = Fi_USCC1X_NID
2671    elif sim_card == VzW12349:
2672        nid = VzW_CDMA1X_NID
2673    else:
2674        nid = DEFAULT_CDMA1X_NID
2675    return user_params.get(key, nid)
2676
2677
2678def get_evdo_channel(user_params, cell_no, sim_card):
2679    """ Returns the EVDO Channel to be used from the user specified parameters
2680        or default value
2681
2682    Args:
2683        user_params: pointer to user supplied parameters
2684        cell_no: specify the cell number this BTS is configured
2685        Anritsu supports two cells. so cell_1 or cell_2
2686
2687    Returns:
2688        EVDO Channel to be used
2689    """
2690    key = "cell{}_evdo_channel".format(cell_no)
2691    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
2692        ch = Fi_EVDO_CH
2693    elif sim_card == VzW12349:
2694        ch = VzW_EVDO_CH
2695    else:
2696        ch = DEFAULT_EVDO_CH
2697    return user_params.get(key, ch)
2698
2699
2700def get_evdo_sid(user_params, cell_no, sim_card):
2701    """ Returns the EVDO SID to be used from the user specified parameters
2702        or default value
2703
2704    Args:
2705        user_params: pointer to user supplied parameters
2706        cell_no: specify the cell number this BTS is configured
2707        Anritsu supports two cells. so cell_1 or cell_2
2708
2709    Returns:
2710        EVDO SID to be used
2711    """
2712    key = "cell{}_evdo_sid".format(cell_no)
2713    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
2714        sid = Fi_EVDO_SECTOR_ID
2715    elif sim_card == VzW12349:
2716        sid = VzW_EVDO_SECTOR_ID
2717    else:
2718        sid = DEFAULT_EVDO_SECTOR_ID
2719    return user_params.get(key, sid)
2720
2721
2722def get_csfb_type(user_params):
2723    """ Returns the CSFB Type to be used from the user specified parameters
2724        or default value
2725
2726    Args:
2727        user_params: pointer to user supplied parameters
2728        cell_no: specify the cell number this BTS is configured
2729        Anritsu supports two cells. so cell_1 or cell_2
2730
2731    Returns:
2732        CSFB Type to be used
2733    """
2734    try:
2735        csfb_type = user_params["csfb_type"]
2736    except KeyError:
2737        csfb_type = CsfbType.CSFB_TYPE_REDIRECTION
2738    return csfb_type
2739
2740
2741def set_post_sim_params(anritsu_handle, user_params, sim_card):
2742    if sim_card == FiTMO or sim_card == FiSPR or sim_card == FiUSCC:
2743        anritsu_handle.send_command("PDNCHECKAPN 1,h2g2")
2744        anritsu_handle.send_command("PDNCHECKAPN 2,n.nv.ispsn")
2745        anritsu_handle.send_command("PDNCHECKAPN 3,fast.t-mobile.com")
2746        anritsu_handle.send_command("PDNCHECKAPN 4,ims")
2747        anritsu_handle.send_command("PDNCHECKAPN 5,*")
2748        anritsu_handle.send_command("PDNIMS 1,DISABLE")
2749        anritsu_handle.send_command("PDNIMS 2,DISABLE")
2750        anritsu_handle.send_command("PDNIMS 3,DISABLE")
2751        anritsu_handle.send_command("PDNIMS 4,ENABLE")
2752        anritsu_handle.send_command("PDNVNID 4,1")
2753        anritsu_handle.send_command("PDNIMS 5,ENABLE")
2754        anritsu_handle.send_command("PDNVNID 5,2")
2755    if sim_card == P0135Ax:
2756        anritsu_handle.send_command("PDNCHECKAPN 1,ims")
2757        anritsu_handle.send_command("PDNCHECKAPN 2,fast.t-mobile.com")
2758        anritsu_handle.send_command("PDNIMS 1,ENABLE")
2759        anritsu_handle.send_command("PDNVNID 1,1")
2760        anritsu_handle.send_command("PDNIMS 2,ENABLE")
2761        anritsu_handle.send_command("PDNIMS 3,ENABLE")
2762        anritsu_handle.send_command("PDNVNID 3,1")
2763    if sim_card == VzW12349:
2764        anritsu_handle.send_command("PDNCHECKAPN 1,IMS")
2765        anritsu_handle.send_command("PDNCHECKAPN 2,VZWINTERNET")
2766        anritsu_handle.send_command("PDNIMS 1,ENABLE")
2767        anritsu_handle.send_command("PDNVNID 1,1")
2768        anritsu_handle.send_command("PDNIMS 3,ENABLE")
2769        anritsu_handle.send_command("PDNVNID 3,1")
2770