普通文本  |  314行  |  12.69 KB

# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# TODO(pprabhu) Use ConfigObj for this configuration file.

# This is the default modem configuration file loaded by all modems.
# This file declares a series of python maps and lists. See comments before each
# declaration for details.
# This configuration is either replaced or ammended by modem specific
# configuration files.

# Name of the modemmanager plugin to be used with the current modem.
# This name is declared by the plugin in modemmanager during initialization.
#
# Modem configuration file may override this name.
mm_plugin = '"Generic"'

# This is a list of state machines loaded by wardmodem.
#
# This list is used *after* the plugin list has been loaded. So, the plugin list
# overrides this list.
state_machines = {
    'level_indicators_machine',
    'modem_power_level_machine',
    'network_identity_machine',
    'network_operator_machine',
    'network_registration_machine',
    'request_response',
}

# Fallback machine.
# If not None, |fallback_machine|.|fallback_function| is used to serve all
# requests for which there is no matching wardmodem action.
# Here, |fallback_machine| is the well-known-name of the machine to use, and
# |fallback_function| is the name of the function to use.
fallback_machine = 'request_response'
fallback_function = 'act_on'

# The AT commands between modemmanager and modem are prefixed and terminated
# slightly differently based on the modem. These are the defaults that work with
# the modems that we developed with. Override them if you need a different
# terminator.
mm_to_modem_at_prefix = ''
mm_to_modem_at_suffix = '\r\n'
modem_to_mm_at_prefix = '\r\n'
modem_to_mm_at_suffix = '\r\n'

# This map specifies the wardmodem action to be taken for AT commands from the
# external world.
#
# Format:
#   {at_command: (state_machine_name, function, (idx1, idx2, ...))}
#
#   Here,
#     - at_command [string] is the AT Command received,
#     - state_machine_name [string] is name of a state machine loaded by
#       wardmodem.
#     - function [string] is a function exported by the state machine mapped to
#       by state_machine_name
#     - (idx1, idx2, ...) [tuple of int] Optionally, lists the (int) indices of
#       the arguments that should be passed on from the AT command to the called
#       function.
#
#   Note: the at_command might use the special character '*' to indicate an
#   argument that should be ignored while matching.
#
# Modem configuration file ammends this map.
at_to_wm_action_map = {
    'AT+CFUN?': ('modem_power_level_machine', 'get_current_level'),
    'AT+CFUN=0': ('modem_power_level_machine', 'set_level_minimum'),
    'AT+CFUN=1': ('modem_power_level_machine', 'set_level_full'),
    'AT+CFUN=4': ('modem_power_level_machine', 'set_level_low'),
    # The following commands obtain information used by the network to identify
    # the user.
    'AT+CIMI': ('network_identity_machine', 'read_imsi_from_modem'),
    # Multiple commands that read information from the SIM.
    # @see ETSI_TS_127_V11.6.0 section 8.18
    # EF_AD:28589 @see ETSI_TS_151_V14.4.0 section 10.3.18
    'AT+CRSM=176,28589,*,*,*': ('network_identity_machine',
                                'read_sim_admin_data', (4)),
    # EF_IMSI:28423 @see ETSI_TS_151_V14.4.0 section 10.3.2
    'AT+CRSM=176,28423,*,*,*': ('network_identity_machine',
                                'read_sim_imsi', (4)),
    # EF_SPN:28486 @see ETSI_TS_151_V14.4.0 section 10.3.11
    'AT+CRSM=176,28486,*,*,*': ('network_identity_machine',
                                'read_service_provider_name', (4)),

    'AT+COPS=3,*': ('network_operator_machine',
                    'set_operator_format', (1)),
    'AT+COPS?': ('network_operator_machine', 'get_operator_name'),
    'AT+COPS=0': ('network_operator_machine', 'set_operator_autoselect'),

    'AT+CEREG=*': ('network_registration_machine',
                   'set_registration_change_message_verbosity', (0)),
    'AT+CEREG?': ('network_registration_machine',
                  'get_current_registration_status'),

    'AT+CIND?': ('level_indicators_machine',
                 'get_current_levels'),
}

# This map specifies the AT commands to be sent back to the external world upon
# responses from the wardmodem.
#
# Format:
#   {response_function: at_response}
#
#   Here,
#     - response_function [string] is the wardmodem response function
#     - at_response [string] is the AT response to be sent to modemmanager.
#       Once again, '*' included in at_response is interpreted as a placeholder
#       and will be replaced by the arguments provided by wardmodem.
#
#   Example: If the map contains a row {'wm_says_hello': 'AT+Ur0sum=*,*,cats'}
#   Then for wardmodem response ('wm_says_hello', 'my', 2) is interpreted as the
#   AT response 'AT+Ur0sum=my,2,cats'.
#
# Modem configuration file ammends this map.
wm_response_to_at_map = {
    'wm_response_ok': 'OK',
    'wm_response_error': 'ERROR',
    # Some modems respond with a RING for error conditions sometimes.
    'wm_response_ring': 'RING',
    # Some responses don't have any AT command prefix at all. For those.
    'wm_response_text_only': '*',

    # Responses from modem_power_level_machine
    'wm_response_power_level_minimum': '+CFUN: 0',
    'wm_response_power_level_full': '+CFUN: 1',
    'wm_response_power_level_low': '+CFUN: 4',
    'wm_response_power_level_factory_test': '+CFUN: 5',
    'wm_response_power_level_offline': '+CFUN: 7',

    # Responses from network_identity_machine
    'wm_response_sim_info_success': '+CRSM: 144,0,"*"',
    'wm_response_sim_info_error_too_long': '+CRSM: 103,0,""',

    # Operator name responses
    'wm_response_operator_name': '+COPS: 2,*,"*",0',
    'wm_response_operator_name_none': '+COPS: 2,*,"Unknown",0',

    # Network registration status reporting.
    'wm_response_network_registration_status_not_registered': '+CEREG: *,0',
    'wm_response_network_registration_status_0': '+CEREG: 0, *',
    'wm_response_network_registration_status_1': '+CEREG: 1, *',
    'wm_response_network_registration_status_2': '+CEREG: 2, *, *, *, *',

    # Level indicators reporting.
    'wm_response_level_indicators': '+CIND: *,*,*,*,*,*,*,*',
}

# Request Response map.
# These are the properties used by the RequestResponse state machine to cater to
# informational queries about the modem.
#
# Format:
#   {incoming_at: (outgoing_ok, outgoing_error)}
#
#   Here,
#     - incoming_at: The incoming AT command to respond to
#     - outgoing_ok: The exact response to be returned, if the machine is
#       enabled. This can be a "string" or a "list of strings".
#       Example: If |outgoing_ok| is ['AT1', 'AT2']. The response sent is:
#       'AT1'
#       'AT2'
#       'OK'
#       Example: If |outgoing_ok| is 'AT1'. The response sent is (no trailing
#       'OK'):
#       'AT1'
#       This mode is required sometimes for responses from the modem that are
#       not followed by an 'OK'.
#
#     - outgoing_error: The exact response to be returned, if the machine is
#       disabled. This may be omitted. In that case, the default ERROR
#       command is returned. If included, it must be of type str.
#
# Any entry from modem configuration file overrides the entry here.
wm_request_response_map = {
    # #########################################################################
    # The following AT request-response pairs are tied down to a modem firmware.
    # They are static across the lifetime of the modem.

    # These commands belong to the basic Hayes AT command set.
    'ATE0': 'OK',
    'ATV1': 'OK',
    'AT+CMEE=1': 'OK',
    'ATX4': 'OK',
    'AT&C1': 'OK',
    'ATZ': 'OK',
    'ATI': ['All the modem information in the world'],
    # These commands are from ITU recommendation V.250
    'AT+GCAP': ['LTE2, +CGSM, +CIS707-A, CIS-856-A, +MS, +ES, +DS, +FCLASS, '
               '+CLTE0'],
    # These commands are from ETSI_TS_127_007_V11.6.0
    # Name of the modem vendor
    'AT+CGMI': ['Bearded Yeti Intergalactic'],
    # Name of the modem model
    'AT+CGMM': ['Bearded Snow Leopard'],
    # Firmware revision
    'AT+CGMR': ['Bearded infinity'],
    # The mobile device IMEI (Bound to the mobile device)
    'AT+CGSN': ['123456789012345'],
    # Queries regarding supported technologies
    'AT*CNTI=2': ['GSM, GPRS, EDGE, UMTS, HSDPA, HSPA, LTE, 1xRTT, EvDO, EvDO, '
                 'Rel0, EvDO RelA'],
    'AT+WS46=?': ['+WS46: (12,22,25)'],
    # List the allowed power level settings.
    'AT+CFUN=?': ['+CFUN: (0-1,4-7),(0-1)'],
    # List the allowed PDP context ranges.
    'AT+CGDCONT=?': ['+CGDCONT: (1-16),"IP",,,(0-2),(0-4)',
                     '+CGDCONT: (1-16),"PPP",,,(0-2),(0-4)',
                     '+CGDCONT: (1-16),"IPV6",,,(0-2),(0-4)'],
    # Read the ICCID from the SIM.
    'AT+CRSM=176,12258,0,0,10': ['+CRSM: 144,0,"98765432100123456789"'],
    # List allowed facility locks:
    'AT+CLCK=?': ['+CLCK: ("AB","AC","AG","AI","AO","IR","OI","OX","PN","PU"'
                  ',"PP","SC")'],
    # List of supported USSD operations.
    # 0: Disable response from network
    # 1: Enable response from network
    # 2: Cancel an ongoing session. This may not be supported by older modems.
    'AT+CUSD=?': ['+CUSD: (0-2)'],
    # List of supported character set encodings.
    'AT+CSCS=?': ['+CSCS: ("IRA","GSM","UCS2")'],
    # List of supported indicators
    'AT+CIND=?': ['+CIND: ("battchg",(0-5)),("signal",(0-5)),("service",(0-1))'
                  ',("call",(0-1)),("roam",(0-1)),("smsfull",(0-1)),'
                  '("GPRS coverage",(0-1)),("callsetup",(0-3))'],
    # List of supported SMS forwarding modes.
    'AT+CNMI=?': ['+CNMI: (0,1,2),(0,1,2,3),(0,2),(0,1,2),(0,1)'],
    # List of supported preferred SMS storage commands.
    'AT+CPMS=?': ['+CPMS: ("SM","SR"),("SM","SR"),("SM","SR")'],
    # List of supported SMS modes
    'AT+CMGF=?': ['+CMGF: (0-1)'],

    # ##########################################################################
    # These AT commands should actually be handled in some other state machine.
    # They are here temporarily till those machines can be implemented.
    # TODO(pprabhu) Implement these state machines as needed by tests.
    # Here till pin-locking is implemented.
    'AT+CPIN?': ['+CPIN: READY'],
    # Here till event reporting is implemented.
    'AT+CMER=3,0,0,1': 'OK',
    # Here till we actually need a character encoding.
    'AT+CSCS="IRA"': 'OK',
    'AT+CSCS?': ['+CSCS: "IRA"'],
    # Here till SMS support is implemented.
    'AT+CMGF=0': 'OK',
    'AT+CMGL=4': 'OK',
    'AT+CPMS="","SM","SM"': ['+CPMS: 0,15,0,15,0,15'],
    'AT+CPMS="SM",': ['+CPMS: 0,15,0,15,0,15'],
    'AT+CPMS="SR",': ['+CPMS: 0,15,0,15,0,15'],
    'AT+CNMI=2,1,2,1,0': 'ERROR',
    # Here till USSD support is implemented.
    'AT+CUSD=1': 'OK',
    'AT+CUSD=0': 'OK',
    # Here till we implemnt varying signal strength.
    'AT+CSQ': ['+CSQ: 0,0'],
    # Here till we implement facility locks.
    'AT+CLCK="SC",2': ['+CLCK: 0'],
    'AT+CLCK="PN",2': ['+CLCK: 0'],
    'AT+CLCK="PU",2': ['+CLCK: 0'],
    'AT+CLCK="PP",2': ['+CLCK: 0'],

}

# ##############################################################################
# This section contains configuration information used by specific state
# machines.

##### modem_power_level_state_machine

# A list of allowed power levels.
modem_power_level_allowed_levels = ['MINIMUM', 'FULL', 'LOW']

# The initial state in which the state machine is created.
# This is how the modem comes up upon creation.
modem_power_level_initial_level = 'FULL'

# Default behaviour wrt to modem power level changes.
# If True, the modem is reset before changing power level.
modem_power_level_reset_by_default = False

##### network_identification_machine

# Parts of IMSI
# This is usually 15 digit long.
network_identity_default_mcc = '311'  # USA country code
network_identity_default_mnc = '480'  # Verizon network code
network_identity_default_msin = '123456789'  # Arbitrary unique ID.
network_identity_default_mdn = '6500000000'

##### network_operator_machine
# This is a list of operators. Each entry is a list with the
# long_alphanumeric, short_alphanumeric and numeric representation of the
# operator name, and the access technology supported  by this operator.
# Viz: [['Long name of an operator', 'shortname', '666', '7']]
network_operators = [
    {'LONG_ALPHANUMERIC': 'Verizon Wireless',
     'SHORT_ALPHANUMERIC': 'VZW',
     'NUMERIC': '311480',
     'TECHNOLOGY': 'E_UTRAN'},
]

# The index of the operator in the list above to choose when automatic
# selelction mode is set.
network_operator_default_index = 0

##### level_indicators_machine
level_indicators_items = ['battchg', 'signal', 'service', 'call', 'roam',
                          'smsfull', 'gprs_coverage', 'call_setup']
level_indicators_defaults = [5, 5, 1, 0, 0, 0, 0, 0]