consts.MM_NETWORK_MODE_2G_ONLY: '02', consts.MM_NETWORK_MODE_3G_PREFERRED: '03', consts.MM_NETWORK_MODE_2G_PREFERRED: '04', } SIERRA_BAND_DICT = { consts.MM_NETWORK_BAND_EGSM: '03', # EGSM (900MHz) consts.MM_NETWORK_BAND_DCS: '03', # DCS (1800MHz) consts.MM_NETWORK_BAND_PCS: '04', # PCS (1900MHz) consts.MM_NETWORK_BAND_G850: '04', # GSM (850 MHz) consts.MM_NETWORK_BAND_U2100: '02', # WCDMA 2100Mhz (Class I) consts.MM_NETWORK_BAND_U800: '02', # WCDMA 3GPP UMTS800 (Class VI) consts.MM_NETWORK_BAND_ANY: '00', # any band } SIERRA_CMD_DICT = get_cmd_dict_copy() SIERRA_CMD_DICT['get_band'] = build_cmd_dict(re.compile( "\r\n\!BAND:\s?(?P<band>\d+)")) SIERRA_CMD_DICT['get_network_mode'] = build_cmd_dict(re.compile( "\r\n\!SELRAT:\s?(?P<mode>\d+)")) class SierraWrapper(WCDMAWrapper): """Wrapper for all Sierra cards""" def get_band(self): """Returns the current used band""" def get_band_cb(resp):
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 E2NAP_DISCONNECTED, E2NAP_CONNECTED, E2NAP_CONNECTING = 0, 1, 2 ERICSSON_CMD_DICT = get_cmd_dict_copy() 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""" \r\n \+COPS:\s+ ( (?P<error>\d) | \d,\d, # or followed by num,num,str,num "(?P<netname>[^"]*)", (?P<status>\d)
from twisted.internet.task import deferLater from wader.common import consts from wader.common.command import get_cmd_dict_copy from wader.common.hardware.base import WCDMACustomizer from wader.common.middleware import WCDMAWrapper from wader.common.plugin import DevicePlugin from wader.common.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"')
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 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 from twisted.trial import unittest from wader.common.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'
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
'U850': consts.MM_NETWORK_BAND_U850, 'U800': consts.MM_NETWORK_BAND_U850, 'U900': consts.MM_NETWORK_BAND_U900, 'U17IX': consts.MM_NETWORK_BAND_U17IX, } 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)) OPTION_CMD_DICT['get_network_mode'] = build_cmd_dict(re.compile(r""" _OPSYS:\s
'3,1': consts.MM_NETWORK_MODE_GPRS, '3,2': consts.MM_NETWORK_MODE_GPRS, '3,3': consts.MM_NETWORK_MODE_GPRS, '5,4': consts.MM_NETWORK_MODE_UMTS, '5,5': consts.MM_NETWORK_MODE_HSDPA, '5,6': consts.MM_NETWORK_MODE_HSUPA, '5,7': consts.MM_NETWORK_MODE_HSPA, '5,9': consts.MM_NETWORK_MODE_HSPA, # doc says HSPA+ } try: return mode_args_dict[args] except KeyError: return consts.MM_NETWORK_MODE_UNKNOWN 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'))