1# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5"""Constants, enums, and basic types for cellular base station emulation.""" 6 7DEFAULT_TIMEOUT = 10 8 9 10def Enum(enum_name, items): 11 """Build a class with a member for each item. 12 13 Arguments: 14 members: A list of items for the enum. They must be valid python 15 identifiers 16 """ 17 class output(object): 18 pass 19 20 for item in items: 21 setattr(output, item, enum_name + ':' + item) 22 23 return output 24 25 26Technology = Enum('Technology', [ 27 'GPRS', 28 'EGPRS', 29 'WCDMA', 30 'HSDPA', 31 'HSUPA', 32 'HSDUPA', 33 'HSPA_PLUS', 34 'CDMA_2000', 35 'EVDO_1X', 36 'LTE' 37]) 38 39TechnologyFamily = Enum('TechnologyFamily', [ 40 'UMTS', 41 'CDMA', 42 'LTE' 43]) 44 45TechnologyToFamily = { 46 Technology.GPRS: TechnologyFamily.UMTS, 47 Technology.EGPRS: TechnologyFamily.UMTS, 48 Technology.WCDMA: TechnologyFamily.UMTS, 49 Technology.HSDPA: TechnologyFamily.UMTS, 50 Technology.HSUPA: TechnologyFamily.UMTS, 51 Technology.HSDUPA: TechnologyFamily.UMTS, 52 Technology.HSPA_PLUS: TechnologyFamily.UMTS, 53 Technology.CDMA_2000: TechnologyFamily.CDMA, 54 Technology.EVDO_1X: TechnologyFamily.CDMA, 55 Technology.LTE: TechnologyFamily.LTE, 56} 57 58 59UeGsmDataStatus = Enum('GsmDataStatus', [ 60 'NONE', 61 'IDLE', 62 'ATTACHING', 63 'ATTACHED', 64 'DETACHING', 65 'PDP_ACTIVATING', 66 'PDP_ACTIVE', 67 'PDP_DEACTIVATING', 68]) 69 70UeC2kDataStatus = Enum('C2kDataStatus', [ 71 'OFF', 72 'DORMANT', 73 'DATA_CONNECTED', 74]) 75 76UeEvdoDataStatus = Enum('EvdoDataStatus', [ 77 'CONNECTION_CLOSING', 78 'CONNECTION_NEGOTIATE', 79 'CONNECTION_REQUEST', 80 'DATA_CONNECTED', 81 'DORMANT', 82 'HANDOFF', 83 'IDLE', 84 'PAGING', 85 'SESSION_CLOSING', 86 'SESSION_NEGOTIATE', 87 'SESSION_OPEN', 88 'UATI_REQUEST', 89]) 90 91# todo(byronk): Move this LTE specific data into the LTE call_box object 92UeLteDataStatus = Enum('LteDataStatus', [ 93 'OFF', 94 'IDLE', 95 'CONNECTED', 96 'REGISTERED', 97 'LOOPBACK', 98 'RELEASE', 99 'UNAVAILABLE', 100]) 101 102# Each cell technology has a different connection state machine. For 103# generic tests, we want to abstract that away. UeGenericDataStatus 104# is this abstraction, and RatToGenericDataStatus is a map from 105# specific states to this generic status. 106 107 108# TODO(rochberg): Do we need connecting/disconnecting for this level of test? 109UeGenericDataStatus = Enum('UeGenericDataStatus', [ 110 'NONE', # UE not seen or in transition to/from REGISTERED 111 'REGISTERED', # Network knows about UE 112 'CONNECTED', # Data can be sent 113 'CONNECTING', 114 'DISCONNECTING', 115]) 116 117 118RatToGenericDataStatus = { 119 UeGsmDataStatus.NONE: UeGenericDataStatus.NONE, 120 UeGsmDataStatus.IDLE: UeGenericDataStatus.NONE, 121 UeGsmDataStatus.ATTACHING: UeGenericDataStatus.NONE, # Transition 122 UeGsmDataStatus.ATTACHED: UeGenericDataStatus.REGISTERED, 123 UeGsmDataStatus.DETACHING: UeGenericDataStatus.NONE, # Transition 124 UeGsmDataStatus.PDP_ACTIVATING: UeGenericDataStatus.CONNECTING, 125 UeGsmDataStatus.PDP_ACTIVE: UeGenericDataStatus.CONNECTED, 126 UeGsmDataStatus.PDP_DEACTIVATING: UeGenericDataStatus.DISCONNECTING, 127 128 UeC2kDataStatus.OFF: UeGenericDataStatus.NONE, 129 UeC2kDataStatus.DORMANT: UeGenericDataStatus.CONNECTED, 130 UeC2kDataStatus.DATA_CONNECTED: UeGenericDataStatus.CONNECTED, 131 132 UeEvdoDataStatus.CONNECTION_CLOSING: UeGenericDataStatus.DISCONNECTING, 133 UeEvdoDataStatus.CONNECTION_NEGOTIATE: UeGenericDataStatus.CONNECTING, 134 UeEvdoDataStatus.CONNECTION_REQUEST: UeGenericDataStatus.CONNECTING, 135 UeEvdoDataStatus.DATA_CONNECTED: UeGenericDataStatus.CONNECTED, 136 UeEvdoDataStatus.DORMANT: UeGenericDataStatus.CONNECTED, 137 UeEvdoDataStatus.HANDOFF: UeGenericDataStatus.CONNECTING, 138 UeEvdoDataStatus.IDLE: UeGenericDataStatus.CONNECTED, 139 UeEvdoDataStatus.PAGING: UeGenericDataStatus.CONNECTED, 140 UeEvdoDataStatus.SESSION_CLOSING: UeGenericDataStatus.DISCONNECTING, 141 UeEvdoDataStatus.SESSION_NEGOTIATE: UeGenericDataStatus.CONNECTING, 142 UeEvdoDataStatus.SESSION_OPEN: UeGenericDataStatus.REGISTERED, 143 UeEvdoDataStatus.UATI_REQUEST: UeGenericDataStatus.NONE, 144 UeLteDataStatus.OFF: UeGenericDataStatus.NONE, 145 UeLteDataStatus.IDLE: UeGenericDataStatus.NONE, 146 UeLteDataStatus.CONNECTED: UeGenericDataStatus.CONNECTED, 147 UeLteDataStatus.REGISTERED: UeGenericDataStatus.REGISTERED, 148 UeLteDataStatus.LOOPBACK: UeGenericDataStatus.NONE, 149 UeLteDataStatus.RELEASE: UeGenericDataStatus.DISCONNECTING, 150 UeLteDataStatus.UNAVAILABLE: UeGenericDataStatus.NONE 151} 152 153 154class Power(object): 155 """Useful power levels, in dBm.""" 156 OFF = -200 157 DEFAULT = -35 158 159 160class SmsAddress(object): 161 def __init__(self, address, address_type='INAT', address_plan='ISDN'): 162 """Constructs an SMS address. 163 164 For expediency, the address type arguments come from the GPIB 165 commands for the Agilent 8960. See 166 http://wireless.agilent.com/rfcomms/refdocs/ 167 gsmgprs/gprsla_hpib_sms.html#CIHDGBIH 168 169 Arguments: 170 address: 1-10 octets 171 address_type: INAT, NAT, NET, SUBS, ALPH, ABBR, RES 172 address_plan: ISDN, DATA, TEL, SCS1, SCS2, PRIV, NATional, 173 ERMes, RES 174 """ 175 self.address = address 176 self.address_type = address_type 177 self.address_plan = address_plan 178 179 180class TestEnvironment(object): 181 def __init__(self, event_loop): 182 pass 183 184 def RequestBaseStations(self, 185 configuration, 186 requirements_list): 187 """Requests a set of base stations that satisfy the given requirements. 188 189 Arguments: 190 configuration: configuration dictionary 191 requirements_list: A list of lists of technologies that must be 192 supported 193 194 Returns: a list of base stations. 195 """ 196 pass 197 198 def TimedOut(self): 199 """Called by base stations when an expected event hasn't occurred.""" 200 pass 201