Example #1
0
    def send_pin(self, pin):
        """
        Sends ``pin`` to authenticate

        We need to encode the PIN in the correct way, but also wait a little,
        as Ericsson devices return straight away on unlock but an immediate
        call to +CPIN? will still show the device as locked.
        """
        from wader.common.startup import attach_to_serial_port
        d = attach_to_serial_port(self.device)

        def _get_charset(_):
            if hasattr(self.device, 'sim') and \
                    hasattr(self.device.sim, 'charset'):
                return defer.succeed(self.device.sim.charset)
            else:
                return self.get_charset()

        d.addCallback(_get_charset)

        def _send_pin(charset, pin):
            if 'UCS2' in charset:
                pin = pack_ucs2_bytes(pin)
            return super(EricssonWrapper, self).send_pin(pin)

        d.addCallback(_send_pin, pin)
        d.addCallback(lambda x: deferLater(reactor, 1, lambda y: y, x))
        return d
Example #2
0
    def send_pin(self, pin):
        """
        Sends ``pin`` to authenticate

        Most devices need some time to settle after a successful auth
        it is the caller's responsability to give at least 15 seconds
        to the device to settle, this time varies from device to device
        """
        from wader.common.startup import attach_to_serial_port
        d = attach_to_serial_port(self.device)
        d.addCallback(lambda _: super(WCDMAWrapper, self).send_pin(pin))
        d.addCallback(lambda response: response[0].group('resp'))
        return d
Example #3
0
    def _do_enable_device(self):
        if self.device.status >= MM_MODEM_STATE_ENABLED:
            return defer.succeed(self.device)

        if self.device.status == MM_MODEM_STATE_ENABLING:
            raise E.SimBusy()

        self.device.set_status(MM_MODEM_STATE_ENABLING)

        def signals(resp):
            self.connect_to_signals()
            # XXX: This netreg notification seems to be unrelated to enable,
            #      perhaps it should be moved?
            self.device.sconn.set_netreg_notification(1)
            if self.device.status < MM_MODEM_STATE_ENABLED:
                self.device.set_status(MM_MODEM_STATE_ENABLED)

            return resp

        from wader.common.startup import attach_to_serial_port

        def process_device_and_initialize(device):
            self.device = device
            auth_klass = self.device.custom.auth_klass
            authsm = auth_klass(self.device)

            def set_status(failure):
                self.device.set_status(MM_MODEM_STATE_DISABLED)
                failure.raiseException()  # re-raise

            d = authsm.start_auth()
            # if auth is ready, the device will initialize straight away
            # if auth isn't ready the callback chain won't be executed and
            # will just return the given exception
            d.addErrback(set_status)
            d.addCallback(self.device.initialize)
            d.addCallback(signals)
            return d

        d = attach_to_serial_port(self.device)
        d.addCallback(process_device_and_initialize)
        return d