# $NWBAND2: 18 WCDMA JAPAN 1700 band # $NWBAND2: 19 Reserved for WLAN # $NWBAND2: 20 Reserved for WLAN # $NWBAND2: 21 Reserved for WLAN # $NWBAND2: 22 Reserved for WLAN # $NWBAND2: 23 Reserved for WLAN # $NWBAND2: 24 Band Class 16 # $NWBAND2: 25 Reserved # $NWBAND2: 26 Reserved # $NWBAND2: 27 Reserved # $NWBAND2: 28 Reserved # $NWBAND2: 29 Reserved # $NWBAND2: 30 Persistent value from NV # $NWBAND2: 31 Reserved NOVATEL_CMD_DICT = get_cmd_dict_copy() NOVATEL_CMD_DICT['get_network_mode'] = build_cmd_dict( re.compile("\r\n\$NWRAT:\s?(?P<mode>\d,\d),\d\r\n")) NOVATEL_CMD_DICT['get_band'] = build_cmd_dict( re.compile("\r\n\$NWBAND:\s?(?P<band>[0-9A-Fa-f]+)")) class NovatelSIMClass(SIMBaseClass): """Novatel SIM Class""" def __init__(self, sconn): super(NovatelSIMClass, self).__init__(sconn) def setup_sms(self):
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. """Unittests for the command module""" import re import sys from twisted.trial import unittest sys.path.insert(0, '..') from core.command import get_cmd_dict_copy cmd_dict = get_cmd_dict_copy() class TestCommandsRegexps(unittest.TestCase): """Test for the regexps associated with at commands""" def test_check_pin_regexp(self): # [-] SENDING ATCMD 'AT+CPIN?\r\n' # [-] WAITING: DATA_RCV = '\r\n+CPIN: READY\r\n\r\nOK\r\n' extract = cmd_dict['check_pin']['extract'] text = '\r\n+CPIN: READY\r\n\r\nOK\r\n' match = extract.match(text) self.failIf(match is None) self.assertEqual(match.group('resp'), 'READY') # [-] WAITING: DATA_RCV = '\r\n+CPIN: SIM PIN\r\n\r\nOK\r\n' text2 = '\r\n+CPIN: SIM PIN\r\n\r\nOK\r\n'
return mode_args_dict[args] except KeyError: return consts.MM_NETWORK_MODE_UNKNOWN def huawei_new_rssi(args, device): try: strength = rssi_to_percentage(int(args)) except (ValueError, TypeError): return None device.sconn.updatecache(strength, 'signal') device.sconn.emit_rssi(strength) return None HUAWEI_CMD_DICT = get_cmd_dict_copy() HUAWEI_CMD_DICT['get_syscfg'] = build_cmd_dict(re.compile(r""" \r\n \^SYSCFG: (?P<modea>\d+), (?P<modeb>\d+), (?P<theband>[0-9A-F]*), (?P<roam>\d), (?P<srv>\d) \r\n """, re.VERBOSE)) HUAWEI_CMD_DICT['get_radio_status'] = build_cmd_dict( end=re.compile('\r\n\+CFUN:\s?\d\r\n'), extract=re.compile('\r\n\+CFUN:\s?(?P<status>\d)\r\n'))
consts.MM_ALLOWED_MODE_2G_PREFERRED: 2, consts.MM_ALLOWED_MODE_3G_PREFERRED: 3, } ICERA_MODE_DICT = { consts.MM_NETWORK_MODE_ANY: 5, consts.MM_NETWORK_MODE_2G_ONLY: 0, consts.MM_NETWORK_MODE_3G_ONLY: 1, consts.MM_NETWORK_MODE_2G_PREFERRED: 2, consts.MM_NETWORK_MODE_3G_PREFERRED: 3, } ICERA_BAND_DICT = { } ICERA_CMD_DICT = get_cmd_dict_copy() # \r\n+CPBR: (1-200),80,14,0,0,0\r\n\r\nOK\r\n ICERA_CMD_DICT['get_phonebook_size'] = build_cmd_dict( re.compile(r""" \r\n \+CPBR:\s \(\d+-(?P<size>\d+)\).* \r\n """, re.VERBOSE)) # \r\n+CMGL: 1,1,"616E64726577",23\r\n # 0791447758100650040C9144977162470100009011503195310004D436390C\r\n ICERA_CMD_DICT['list_sms'] = build_cmd_dict( re.compile(r""" \r\n
consts.MM_NETWORK_BAND_U900: 'U900', consts.MM_NETWORK_BAND_U17IX: 'U17IX', consts.MM_NETWORK_BAND_U1900: 'U1900', # Option has no U2600 } OPTION_CONN_DICT = { consts.MM_NETWORK_MODE_2G_ONLY: 0, consts.MM_NETWORK_MODE_3G_ONLY: 1, consts.MM_NETWORK_MODE_2G_PREFERRED: 2, consts.MM_NETWORK_MODE_3G_PREFERRED: 3, consts.MM_NETWORK_MODE_ANY: 5, } # Option devices like to append its serial number after the IMEI, ignore it OPTION_CMD_DICT = get_cmd_dict_copy() OPTION_CMD_DICT['get_imei'] = build_cmd_dict(re.compile( "\r\n(?P<imei>\d+),\S+\r\n", re.VERBOSE)) OPTION_CMD_DICT['get_sim_status'] = build_cmd_dict(re.compile(r""" _OBLS:\s(?P<sim>\d), (?P<contacts>\d), (?P<sms>\d) """, re.VERBOSE)) OPTION_CMD_DICT['get_band'] = build_cmd_dict(re.compile(r""" \r\n(?P<name>.*):\s+(?P<active>\d) """, re.VERBOSE)) # AT_OPBM=? # _OPBM: ("ANY","EGSM","DCS","PCS","G850","U2100","U1900","U1700","U17IV",
consts.MM_ALLOWED_MODE_ANY: '2', # 3g preferred consts.MM_ALLOWED_MODE_3G_ONLY: '1', consts.MM_ALLOWED_MODE_3G_PREFERRED: '2', consts.MM_ALLOWED_MODE_2G_ONLY: '3', consts.MM_ALLOWED_MODE_2G_PREFERRED: '4', } LONGCHEER_CONN_DICT = { consts.MM_NETWORK_MODE_ANY: '2', # 3g preferred consts.MM_NETWORK_MODE_3G_ONLY: '1', consts.MM_NETWORK_MODE_3G_PREFERRED: '2', consts.MM_NETWORK_MODE_2G_ONLY: '3', consts.MM_NETWORK_MODE_2G_PREFERRED: '4', } LONGCHEER_CMD_DICT = get_cmd_dict_copy() # +CPBR: 1,"+4917XXXXXX",145,"005400650073007400200053007400720069","",129,"" LONGCHEER_CMD_DICT['get_contact'] = build_cmd_dict(re.compile(r""" \r\n \+CPBR:\s(?P<id>\d+), "(?P<number>[+0-9a-fA-F*#]+)", (?P<cat>\d+), "(?P<name>.*?)" (?P<ignored>,\S*)? \r\n""", re.X)) LONGCHEER_CMD_DICT['list_contacts'] = build_cmd_dict( end=re.compile('(\r\n)?\r\n(OK)\r\n'), extract=re.compile(r""" \r\n \+CPBR:\s(?P<id>\d+),
from twisted.internet.task import deferLater from wader.common import consts from core.command import get_cmd_dict_copy from core.hardware.base import WCDMACustomizer from core.middleware import WCDMAWrapper from core.plugin import DevicePlugin from core.sim import SIMBaseClass # Gobi 2000 notes: # Unfortunately there is only one tty port available so it has to be # shared between data and status functions. # There also doesn't seem to be any way of specifying the bearer # preference for 3G only, 3G preferred, or 2G only. QUALCOMM_CMD_DICT = get_cmd_dict_copy() class QualcommSIMClass(SIMBaseClass): """Qualcomm SIM Class""" def __init__(self, sconn): super(QualcommSIMClass, self).__init__(sconn) def initialize(self, set_encoding=True): def init_callback(size): # make sure we are in most promiscuous mode before registration self.sconn.set_network_mode(consts.MM_NETWORK_MODE_ANY) # set SMS storage default self.sconn.send_at('AT+CPMS="SM","SM","SM"')
consts.MM_ALLOWED_MODE_2G_ONLY: 5, consts.MM_ALLOWED_MODE_3G_ONLY: 6, } ERICSSON_CONN_DICT = { consts.MM_NETWORK_MODE_ANY: 1, consts.MM_NETWORK_MODE_2G_ONLY: 5, consts.MM_NETWORK_MODE_3G_ONLY: 6, } ERINFO_2G_GPRS, ERINFO_2G_EGPRS = 1, 2 ERINFO_3G_UMTS, ERINFO_3G_HSDPA = 1, 2 ENAP_DISCONNECTED, ENAP_CONNECTED, ENAP_CONNECTING = 0, 1, 2 ERICSSON_CMD_DICT = get_cmd_dict_copy() # +CGDCONT: (1-10),("00490050"),,,(0-1),(0-1) ERICSSON_CMD_DICT['get_apn_range'] = build_cmd_dict(re.compile(r""" \r\n \+CGDCONT:\s*\((?P<lo4>\d+)-(?P<hi4>\d+)\), \((?P<ip4>(?:"IP")|(?:"00490050"))\)(?P<ignored>.*) """, re.VERBOSE)) ERICSSON_CMD_DICT['get_card_model'] = build_cmd_dict('\s*(?P<model>\S*)\r\n') # +CIND: 5,5,0,0,1,0,1,0,1,1,0,0 ERICSSON_CMD_DICT['get_signal_quality'] = build_cmd_dict( '\s*\+CIND:\s+[0-9]*,(?P<sig>[0-9]*),.*') ERICSSON_CMD_DICT['get_network_info'] = build_cmd_dict(re.compile(r"""
consts.MM_NETWORK_BAND_U2100 | consts.MM_NETWORK_BAND_EGSM | consts.MM_NETWORK_BAND_DCS): 3, (consts.MM_NETWORK_BAND_U850 | consts.MM_NETWORK_BAND_U1900 | consts.MM_NETWORK_BAND_G850 | consts.MM_NETWORK_BAND_PCS): 4, } # AT+ZBANDI=0 : Automatic (Auto) - Default # AT+ZBANDI=1 : UMTS 850 + GSM 900/1800 # AT+ZBANDI=2 : UMTS 2100 + GSM 900/1800 (Europe) # AT+ZBANDI=3 : UMTS 850/2100 + GSM 900/1800 # AT+ZBANDI=4 : UMTS 850/1900 + GSM 850/1900 ZTE_CMD_DICT = get_cmd_dict_copy() ZTE_CMD_DICT['get_band'] = build_cmd_dict(re.compile(r""" \r\n \+ZBANDI:\s? (?P<band>\d) \r\n """, re.VERBOSE)) ZTE_CMD_DICT['get_network_mode'] = build_cmd_dict(re.compile(r""" \r\n \+ZSNT:\s (?P<only>\d+), (?P<netsel>\d+), (?P<order>\d+) \r\n