Commit Graph

104 Commits

Author SHA1 Message Date
Jimmy Gysens ef7e5f016b huawei: send restore settings command on startup
When initializing a Huawei device, send the AT&F0 command to restore the
default AT settings on device restart.

Huawei stores all APN settings, which can cause issues when changing the
APN. The AT&F0 command makes sure the device starts from a clean state.
2020-06-25 11:36:20 -05:00
Jimmy Gysens d7d49eb1d5 huawei: Fix infinite loop on modem removal
After unplugging a Huawei USB dongle, the 'atoms' in oFono are removed
via 'flush_atoms'.  Every atom has a destruct function pointer, used as
destructor.  This includes the gprs_context atom that is currently
active.

The function calls are:
flush_atoms -> destruct -> gprs_context_remove ->
at_gprs_context_remove -> modem_disconnect

Because the device is physically removed, the IO channel for the AT
port is gone.  In 'at_gprs_context_remove', there is an attempt to
resume communication over that AT port, but that is not possible. This
is detected, and 'io_disconnect' (pointer to 'modem_disconnect') is
called. 'modem_disconnect' has the same atom and tries to remove it
again, so it calls the same destructor.  This continues infinitely.

This patch moves the GPRS context removal so that it only happens if the
modem port could be re-opened successfully.  If the port cannot be
re-opened (in the case of modem removal), the atom is already in the
process of being removed by the process kicked off in flush_atoms.

This fix is limited to Huawei devices and has been tested using the
following devices:

- E3531i-2
- E3372
- E3531s-2
- E369
- E1552
2019-11-21 21:12:53 -06:00
Denis Kenzior e0ac26458e huawei: Use at_util_open_device 2019-05-31 11:58:39 -05:00
Christophe Ronco ef3ebe5840 huawei: use VENDOR_HUAWEI quirk on gprs context creation 2018-07-25 14:11:58 -05:00
Christophe Ronco 26aba4612c huawei: reopen modem channel if it disconnects
On E3372 after a GPRS disconnection, modem AT channel (used by PPP) gets
disconnected (G_IO_HUP and G_IO_ERR are detected in received_data
in gatio.c).
After that all connection attempts fail because we are not able to send
any AT commands on modem channel (it is closed).

With this patch, when this behavior is detected, we close gprs context
driver, reopen AT channel and gprs context driver.
2017-02-21 11:13:51 -06:00
Forest Bond 692e59f108 huawei: Use AlwaysOnline for CDMA modems 2013-04-01 21:42:44 -05:00
Marcel Holtmann 2292753f4e huawei: Select USSD atom driver based on firmware mode 2012-01-12 06:02:27 +01:00
Marcel Holtmann 0043f4735e huawei: Setup CSCS after SIM card has been detected 2012-01-12 04:37:03 +01:00
Marcel Holtmann e0853c7f20 huawei: Print and store NDIS support results 2012-01-11 21:35:25 +01:00
Denis Kenzior 60890653e3 huawei: Refactor logic slightly 2012-01-11 06:49:46 -06:00
Guillaume Zajac b1eb2209ab huawei: Create sim atom for cdma modems
Don't create atom if sim is embedded.
Atom will use "atmodem-noef" drivers to support PIN management
and IMSI retrieval.
2012-01-11 06:46:38 -06:00
Denis Kenzior 908eadf4d1 huawei: Setup CSCS on both ports 2012-01-11 06:38:28 -06:00
Marcel Holtmann 8e110af6e1 huawei: Check for NDIS vs modem dial-up mode 2012-01-11 16:33:02 +01:00
Marcel Holtmann 57604ec2b7 huawei: Adapt to changed atom driver name for CDMA netreg 2012-01-06 19:56:46 -08:00
Marcel Holtmann c7ec6efa4e huawei: Use CFUN=5 for CDMA offline state handling
The Huawei CDMA modems only support CFUN=5 for offline mode and so
enforce this one if CDMA support has been detected. Even if the modem
would indicate AT^RFSWITCH support.
2012-01-06 19:16:43 -08:00
Marcel Holtmann 18a1fbca84 huawei: Handle modems with ROM based SIM cards
Some modem contain ROM based SIM cards indicated by SIM state 240 and
these need to be treated as SIM present.
2012-01-06 19:11:03 -08:00
Marcel Holtmann cdfea3601e huawei: Create CDMA atoms if support has been detected
In case the modem supports CDMA (+CIS707-A capability), then enable
CDMA atoms. However only enable if GSM support is not detected.
2012-01-06 19:08:13 -08:00
Marcel Holtmann 09c7a1cdd1 huawei: Create GSM/UMTS atoms only if support has been detected 2012-01-06 18:30:12 -08:00
Marcel Holtmann 991822cb61 huawei: Check for supported modem capabilities first
Use ATI and +GCAP response to determine supported modem capabilities
and check if modem does support GSM.
2012-01-06 13:31:38 -08:00
Marcel Holtmann cd4528e7a3 huawei: Change state variable name for voice support 2012-01-06 13:19:30 -08:00
Marcel Holtmann e0148bef6f huawei: Check for AT^RFSWITCH support to determine offline command
Using AT+CFUN=7 (if supported) to switch into offline mode has a problem
with older modems. Sending AT+CFUN=7 with a data connection active has
the problem that it never terminates with OK or ERROR.

Devices that support AT^RFSWITCH are known to handle this properly. So
only when that command is supported, use AT+CFUN=7 for offline mode. If
it is not supported, then keep using AT+CFUN=5 to switch the device into
offline mode.
2011-08-04 14:01:03 +02:00
Marcel Holtmann 93186f6939 huawei: Add TOO MANY PARAMETERS terminator 2011-08-04 13:27:29 +02:00
Marcel Holtmann 8cfab5328c huawei: Fix race condition with enable polling 2011-08-03 14:26:23 +02:00
Marcel Holtmann 0ac3ccfa9b huawei: Fix race condition with online enable polling 2011-08-03 14:23:21 +02:00
Marcel Holtmann d998989e9c huawei: Fix stale PCUI channel after hot-unplug 2011-07-29 15:20:53 +02:00
Marcel Holtmann 43c5b442b2 huawei: Style cleanup for comments 2011-07-29 15:20:31 +02:00
Marcel Holtmann 3055bc112b huawei: Shutdown the modem within disable callback 2011-07-29 14:56:41 +02:00
Marcel Holtmann 158b8331bd huawei: Complete rewrite to better support state transitions
When switching from offline into online mode, the SIM card access
gets temporarily disabled by the modem firmware. To work around
this limitation poll the SIM card state.
2011-07-28 22:06:29 +02:00
Bertrand Aygon 4179c87069 huawei: add a debug info to help debugging. 2011-07-27 15:54:09 +02:00
Marcel Holtmann e2bac24cb5 huawei: Remove leftover from HasVoice flag 2011-07-25 01:35:02 +02:00
Marcel Holtmann e0f1249fcc huawei: Remove broken handling for NDIS support 2011-07-25 01:34:41 +02:00
Marcel Holtmann 626612a8bf huawei: Check supported offline mode and fix error behavior 2011-07-24 22:31:15 +02:00
Marcel Holtmann 49b8d24f3b huawei: Set slave channel for NW DEACT notifications 2011-07-24 14:50:12 +02:00
Marcel Holtmann 7ed56d6844 huawei: Use AT&C0 to disable data carrier detect
When the DCD is disabled the modem does not hangup anymore after the
data connection. So all workarounds due to TTY hangup can be removed.
2011-07-24 12:59:14 +02:00
Marcel Holtmann 6094556558 huawei: Use correct command for setting offline mode
According to some Huawei related documentation it is better to use
AT+CFUN=7 for offline mode instead of AT+CFUN=5.
2011-07-11 15:06:02 +02:00
Caiwen Zhang 00e5f0a6ca huawei: NDIS port doesn't depend on modem port
When creating the NDIS gprs context, do not check the existence of the
modem port.
2011-06-02 16:02:42 -05:00
Denis Kenzior abebab53d4 huawei: Minor tweaks to debug messages 2011-06-02 16:02:04 -05:00
Caiwen Zhang afc894e6b4 huawei: reopen once if open device failed
Sometimes when we try to open the modem (PPP) device, it may fail.
If opening the tty failed, retry once one second later.
2011-06-02 15:59:03 -05:00
Marcel Holtmann 9245f6850f huawei: Remove usage of unused netreg variable 2011-05-27 10:08:16 -07:00
Martin Xu eaf6f64879 huawei: Switch to offline mode only if offline 2011-04-26 14:55:55 -05:00
Martin Xu d38fa75518 huawei: Check that the modem device is open
Don't create the gprs atom if the modem device was not opened
successfully.  Otherwise ofonod will crash.
2011-04-26 14:51:57 -05:00
Martin Xu a9f75b3f23 huawei: Fix huawei_disconnect function issue
huawei_disconnect is used to recovery the io and gprs context when
io error happends, see commit 39382730d7
However, io error not only happends at PPP disconnect, in theory it
can happends at any situation. I also observed that it happens when modem
go into offline mode at my Huawei EM770W modem. in this case, gprs should
not be reopened.
2011-03-15 13:54:59 -05:00
Andras Domokos 4a36b93d6a ssn: remove SSN atom completely 2011-03-11 13:08:51 -06:00
Lucas De Marchi 42ecf16c29 huawei: do not check for NULL pointer
cb_data_new() uses g_new0(), hence there's no need to check the return
value being NULL.
2011-03-04 05:14:02 -08:00
Marcel Holtmann a5e83f5668 huawei: Move SMS support into post_sim stage 2011-01-29 10:30:03 +01:00
Lucas De Marchi a72115510a huawei: do not query sim state on pre_sim
Sim state is already known after modem is enabled and there's no need to
query it again. Before this patch, query_sim_state() was called upon
huawei_enable() and huawei_pre_sim(). Both functions might call
notify_sim_state() with a valid state. Hence we could eventually end up
sending AT+CFUN=5 command twice.
2011-01-19 15:39:49 +01:00
Lucas De Marchi edaff4b505 huawei: do not set timer more than once
If a "^SYSINFO" arrives after the timer for query_sim_locked() has been
set up, it'd would set a new timer, signaling a sim state change more
than once.
2011-01-19 14:21:29 +01:00
Lucas De Marchi 4c2920d8a5 huawei: use VENDOR_HUAWEI quirk on sim creation 2011-01-10 15:38:42 -06:00
Lucas De Marchi d90fd381b5 huawei: cancel poll when going to a valid state 2010-12-21 17:21:21 -06:00
Denis Kenzior b22d2109da huawei: Move radio_settings to post_sim 2010-12-21 16:31:11 -06:00