Exemplo n.º 1
0
# $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):
        # Select SIM storage
        self.sconn.send_at('AT+CPMS="SM","SM","SM"')
Exemplo n.º 2
0
#
# 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.

import re

from wader.common.consts import WADER_CONNTYPE_PCMCIA
from core.command import build_cmd_dict
from core.hardware.huawei import (HuaweiWCDMADevicePlugin,
                                          HuaweiWCDMACustomizer)

E620_CMD_DICT = HuaweiWCDMACustomizer.cmd_dict.copy()
E620_CMD_DICT['get_roaming_ids'] = build_cmd_dict(re.compile(
                                    """
                                    \r\n
                                    \+CPOL:\s(?P<index>\d+),"(?P<netid>\d+)"
                                    """, re.VERBOSE))


class HuaweiE620Customizer(HuaweiWCDMACustomizer):
    cmd_dict = E620_CMD_DICT


class HuaweiE620(HuaweiWCDMADevicePlugin):
    """:class:`~core.plugin.DevicePlugin` for Huawei's E620"""
    name = "Huawei E620"
    version = "0.1"
    author = u"Pablo Martí"
    custom = HuaweiE620Customizer()
Exemplo n.º 3
0
                                  HUAWEI_BAND_DICT, HUAWEI_CMD_DICT)
from core.middleware import WCDMAWrapper

ALLOWED_DICT = {
    consts.MM_ALLOWED_MODE_ANY: None,
    consts.MM_ALLOWED_MODE_2G_ONLY: None,
}

CONN_DICT = {
    consts.MM_NETWORK_MODE_ANY: None,
    consts.MM_NETWORK_MODE_2G_ONLY: None,
}

CMD_DICT = HUAWEI_CMD_DICT.copy()
CMD_DICT['get_radio_status'] = \
    build_cmd_dict(re.compile('\r\n\+CFUN:\s?(?P<status>\d)\r\n'))


class HuaweiK2540Wrapper(HuaweiWCDMAWrapper):
    """
    :class:`~core.hardware.huawei.HuaweiWCDMAWrapper` for the K2540
    """

    def _add_contact(self, name, number, index):
        """
        Adds a contact to the SIM card
        """
        raw = 0
        try:     # are all ascii chars
            name.encode('ascii')
        except:  # write in TS31.101 type 80 raw format
Exemplo n.º 4
0
    consts.MM_ALLOWED_MODE_ANY: None,
    consts.MM_ALLOWED_MODE_2G_ONLY: None,
}

ZTEK2525_CONN_DICT = {
    consts.MM_NETWORK_MODE_ANY: None,
    consts.MM_NETWORK_MODE_2G_ONLY: None,
}

ZTEK2525_CMD_DICT = ZTE_CMD_DICT.copy()

ZTEK2525_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 (fixed bearer)
                             "(?P<netname>[\w\S ]*)"
                             )      # end of group
                             \r\n
                             """, re.VERBOSE))

ZTEK2525_CMD_DICT['get_network_mode'] = build_cmd_dict(re.compile(r"""
                             \r\n
                             \+ZSNT=
                             (?P<only>\d+),
                             (?P<netsel>\d+),
                             (?P<order>\d+)
                             \r\n
                             """, re.VERBOSE))

ZTEK2525_CMD_DICT['get_network_names'] = build_cmd_dict(re.compile(r"""
Exemplo n.º 5
0
    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):
            band = resp[0].group('band')
            return revert_dict(self.custom.band_dict)[band]
Exemplo n.º 6
0
    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
        \+CMGL:\s*
        (?P<id>\d+),
        (?P<where>\d),
        (?P<alpha>"\w*?")?,
        \d+
        \r\n(?P<pdu>\w+)
Exemplo n.º 7
0
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'))

HUAWEI_CMD_DICT['check_pin'] = build_cmd_dict(re.compile(r"""
                        \r\n
                        \+CPIN:\s*
                        (?P<resp>
                        READY      |
                        SIM\sPIN2? |
Exemplo n.º 8
0
    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",
#           "U850","U800","U900","U17IX")
OPTION_CMD_DICT['get_bands'] = build_cmd_dict(re.compile(r"""
Exemplo n.º 9
0
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+),
    "(?P<number>[+0-9a-fA-F*#]+)",
    (?P<cat>\d+),
    "(?P<name>.*?)"
    (?P<ignored>,\S*)?
    """, re.X))

LONGCHEER_CMD_DICT['get_network_mode'] = build_cmd_dict(
Exemplo n.º 10
0
    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"""
                \r\n
                \+COPS:\s+
                (
                (?P<error>\d) |
                \d,\d,             # or followed by num,num,str,num
Exemplo n.º 11
0
    (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
                                            """, re.VERBOSE))


def zte_new_conn_mode(what, device):
    zpasr = re.search(r'"(?P<mode>.*?)"(?:,"(?P<domain>.*?)")?', what)