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