Commit Graph

44 Commits

Author SHA1 Message Date
Sergei Golubtsov 39f70c29d1 quectel: adding support for the Quectel EC200 USB modem series
Support for the Quectel EC200 USB modem series has been added. The model
identification AT command has been added as the first step in the
communication with a Quectel USB modem.
2021-01-07 23:21:32 -06:00
Lars Poeschel 285fad8f39 quectel: Power on/off with a gpio pulse
Current implementation uses a gpio level of 1 for powering on quectel
modems using a gpio and a level of 0 for powering off.
Normally quectel modems are powered on or off by a gpio pulse on their
PWR_KEY pin. They turn on by the first pulse and turn then off by the
next pulse. The pulse length varies between different modems.
For power on the longest I could in the quectel hardware is "more than
2 seconds" from Quectel M95 Hardware Design Manual.
For Quectel EC21 this is ">= 100 ms".
For Quectel MC60 this is "recommended to be 100 ms".
For Quectel UC15 this is "at least 0.1 s".
For power off the four modems in question vary between a minimum pulse
length of 600-700ms.
This implements a 2100ms pulse for power on and 750ms for power off.

If you have some special circuitry that powers your modem by gpio level
and you need the old behaviour, you can switch to gpio level powering
by setting environment variable OFONO_QUECTEL_GPIO_LEVEL. The gpio goes
to high level for the modem to power on and to low level if it should
power off.
2020-10-06 15:42:46 -05:00
Lars Poeschel 4a098c724a quectel: Extend power-on timeout
More complicated modems emerge and they need longer start-up times. An
EC21 takes about 13 seconds to boot up. This is slightly longer than the
20 * 500 ms we have at the moment. This extends the retries to 30, so we
have 30 * 500 ms and this does successfully power up an EC21 modem.
2020-09-29 09:22:45 -05:00
Lars Poeschel a01613ad13 atmodem: Get strength and tech the quectel way on EC21
I had some trouble getting network strengh and access technology the
standard way on Quectel EC21. It does work - but only kind of. I did not
get URCs when I am sure I should. This way through CIEV, CIND and CMER
is also not documented in Quectel documentation, so I suspect this to be
unsupported.
This is now changed to the "quectelish" way of gettings those values and
this does work more fine-grained and reliable on the Quectel EC21.
2020-08-11 10:47:58 -05:00
Lars Poeschel 3401d9e29c Add a vendor OFONO_VENDOR_QUECTEL_EC2X
The distinction between OFONO_VENDOR_QUECTEL and
OFONO_VENDOR_QUECTEL_SERIAL does not suffice for EC21/EC25 in some
places, so introduce and use a new vendor:
OFONO_VENDOR_QUECTEL_EC2X
2020-08-11 10:47:36 -05:00
Lars Poeschel 446a5ae394 quectel: Try to update voltage only, when received "vbatt"
As there are some more sources of +QIND: activated, do now only update
voltage when we get the
+QIND: "vbatt",-1
but not on things like
+QIND: "act","LTE"
or
+QIND: "csq",20,99
2020-08-07 11:11:39 -05:00
Lars Poeschel ab8d482af1 quectel: Set URC port to uart1 on EC21
Set the URC port of the Quectel EC21 to uart1 when it is used through
it's serial port. This setting is saved to non-volatile storage by the
modem automatically.
2020-08-07 11:09:53 -05:00
Lars Poeschel a56976e2bb Revert "quectel: EC21 needs aux channel to be the first mux channel"
This reverts commit 1868dbf2b3.
Development for this was done on EC21 firmware version
EC21EFAR06A01M4G_BETA0318. It now turns out, that actual release
firmware versions for this modem again need the original mux order with
aux channel as the second mux channel. (We know for sure for firmware
version EC21EFAR06A03M4G.)
We do not know for sure when and for what firmware versions quectel did
the switch back on the mux order, but we suspect that the "BETA"
firmware is the only one with the reversed mux order. This "BETA"
firmware was only given out for development purposes and will not appear
"in the wild", so we revert the patch here and hope for the best.
2020-08-07 11:04:35 -05:00
Lars Poeschel 1868dbf2b3 quectel: EC21 needs aux channel to be the first mux channel
The Quectel EC21 does only work correctly, if the mux channel used for
aux is the first mux channel. It does only put it's URC messages in the
first mux channel, so this has to be the aux channel in our case.
To be flexible on the mux order we introduce two arrays here, that then
contain the initialization data in their needed order.
Initialization data is then applied by for-looping over this array.
2020-05-26 22:22:09 -05:00
Lars Poeschel 8ce74ba07b quectel: EC21 add ussd with atmodem driver 2020-05-21 08:28:30 -05:00
Lars Poeschel c7de38491d quectel: EC21 does not understand AT+QIURC
Because the Quectel EC21 does not understand the AT+QIURC command, we
leave that out during initialisation.
2020-05-21 08:28:09 -05:00
Lars Poeschel debd73639a quectel: Query the model before setting up the mux
This is a change for the EC21. It will require specific handling before
and right after setting up the mux. So this change prepares this. It
queries the modem model before the mux (CMUX) is activated.
2020-05-21 08:24:40 -05:00
Lars Poeschel c121ccebc2 quectel: use lte atom on EC21 2020-05-21 08:24:37 -05:00
Lars Poeschel 3c158ceee9 quectel: Add Quectel EC21 to known serial modems
This adds the Quectel EC21 to the known modems of the quectel driver and
therefore allows to use it with its serial interface.
2020-05-21 08:24:29 -05:00
Martin Hundebøll d0398b3965 quectel: support both internal and n_gsm muxes
The in-kernel implementation of gsm0710 causes deadlocks in the
kernel[1], so switch the default back to the user-space implementation
in ofono.

The change also removes the timeout-callback used to defer disabling the
n_gsm line discipline, as that is no longer needed[2]

To enable use of the kernel line discipline, add an udev env entry with
OFONO_QUECTEL_MUX="n_gsm".

[1] https://lore.kernel.org/lkml/4b2455c0-25ba-0187-6df6-c63b4ccc6a6e@geanix.com/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7030082a7415d18e3befdf1f9ec05b3d5de98de4
2019-10-11 12:19:20 -05:00
Martin Hundebøll ad73e590e2 quectel: rework sim detection
Use at_util_sim_state_query_new() to query the sim inserted state. Once
that returns, the locked state is queried by issuing a AT+CPIN? command.

If not locked, a timer is started to query the quectel init status of
the sim. Once the init status is ready, the sim atom is created, and the
modem is set to powered, and the sim is signaled both inserted, and
initialized.

If locked, the modem is set to powered, and the sim atom is created.
This allows users to enter the pin to unlock the sim. Once the sim is
unlocked, a +CPIN: READY indication is caught to query the quectel
init status. Once the init status is ready, the sim is signaled
initialized.

All the above is needed, because the modem indicated +CPIN: READY before
the sim is really ready. The only way to be certain, is to wait for the
quectel init status to be ready. Even signaling the sim inserted
prematurely can cause to modem to hang during the initial AT+CRSM
commands.
2019-10-11 12:10:21 -05:00
Martin Hundebøll c8fdff395a quectel: remove leftover reset of wakeup command 2019-09-26 16:38:52 -05:00
Richard Röjfors d57900b1cb plugins: quectel: Fix compiler warning
plugins/quectel.c: In function ‘quectel_pre_sim’:
plugins/quectel.c:1150:20: error: unused variable ‘sim’ [-Werror=unused-variable]
  struct ofono_sim *sim;
2019-09-24 09:53:45 -05:00
Martin Hundebøll 31cad076a4 quectel: handle sim states
The quectel M95 and MC60 modems are picky about when the sim is properly
initialized, so the logic to detect this needs to be in the quectel
plugin.

After doing basic initialization, a CPIN query is issued to detect sim
state.

If the sim is unlocked and ready, a timer is created to wait for the
modem state (AT+QINISTAT) to complete. At this point ofono is notified
about the initialized sim.

If the sim is locked, a listener for "+CPIN: READY" is set up to
know when a pin is entered. Once the indication is received, the timer
is set up as if the sim was unlocked from the beginning.

If the sim is busy/resetting, the CPIN query is issued again.
2019-09-10 08:41:12 -05:00
Martin Hundebøll 62e8e3c1e2 quectel: swap cmuxed ports
According to the manual, when using CMUX on the UC15, it outputs
unsolicited indications on port 2 (i.e. /dev/gsmtty2), so the quectel
plugin must use this when registering for such.
2019-09-02 16:25:43 -05:00
Martin Hundebøll bff7de9552 quectel: convert power event reasons to lower case 2019-08-13 05:48:47 -05:00
Martin Hundebøll 61cca1809a quectel: replace g_at_chat_set_wakeup_command() with g_at_chat_retry()
If the modem isn't powered on, the use of g_at_chat_set_wakeup_command()
makes ofono send out AT strings in an endless loop. Avoid this by using
g_at_chat_retry() in a timer instead.
2019-08-13 02:09:22 -05:00
Marcel Holtmann a4e7e8788a quectel: Add missing include for sys/socket.h 2019-08-12 20:02:34 +02:00
Martin Hundebøll 1107d3cbc3 quectel: implement dbus signals for modem power notifications
The Quectel modems issues unsolicited strings in case of power related
events. The UC15 uses +QIND: for the events, while M95 and MC60 uses
descriptive strings. (UC15 also uses a string for normal power down).

Register listeners for these strings/codes. The handler emits an
appropriate dbus signal, and closes down the modem if needed.
2019-07-22 02:40:00 -05:00
Martin Hundebøll 133233845e quectel: add dbus hardware interface
For now the interface only exposes the modem supply voltage, but is
added as a preparation for signaling power events.
2019-07-22 02:37:56 -05:00
Martin Hundebøll 9b681d7a27 quectel: pass vendor id to gprs and gprs-context
The gprs-context does special casing on the quectel serial modem when
probing the supported layer 2 protocols, so pass the vendor id when
setting up the atoms.
2019-07-19 10:34:32 -05:00
Martin Hundebøll e98af8127f quectel: add support for the Quectel MC60 modem
The modem is AT-compatible with the Quectel M95 modem, but also features
a GNSS module.
2019-07-17 10:27:31 -05:00
Martin Hundebøll 5a255d6e62 quectel: store model id in private data
Some Quectel models supports different features such as GNSS or
different URC strings. Add a field in the quectel data structure to be
used when adding support for said features.
2019-07-17 10:26:53 -05:00
Martin Hundebøll bac8a9cf8d quectel: enable call volume settings 2019-07-17 10:26:16 -05:00
Martin Hundebøll 8be2adc908 atmodem: rename OFONO_VENDOR_QUECTEL_M95
Other serial connected modems (i.e the MC60 model) from is AT-compatible
with the M95 model, so rename the M95 vendor id to be common for both.
2019-07-17 10:25:51 -05:00
Martin Hundebøll 57b4aa3678 quectel: initialize call, phonebook and sms when ready
The Quectel M95 modem issues a "Call ready" notification when call and
phonebook are ready, so set up a listener for that.

The only way to know when sms is ready is to issue QINITSTAT queries.
Since sms is always ready after call and phonebook, the queries are
initiated after creating call/phonebook.
2019-07-12 11:00:52 -05:00
Martin Hundebøll ded2915fd5 quectel: query device model to enable vendor quirks 2019-07-12 11:00:48 -05:00
Martin Hundebøll 47f6e8c3ad quectel: configure flow control when enabled 2019-07-12 10:54:21 -05:00
Martin Hundebøll 2f58421b64 quectel: support gpio to power on/off the modem
This adds support for configuring a gpio in udev to control the modem
power.

To enable gpio control, specify OFONO_QUECTEL_GPIO_CHIP and
OFONO_QUECTEL_GPIO_OFFSET in the udev environment, for example:

KERNEL=="ttymxc0", ENV{OFONO_DRIVER}="quectel", \
        ENV{OFONO_QUECTEL_GPIO_CHIP}="gpiochip2", \
        ENV{OFONO_QUECTEL_GPIO_OFFSET}="26"
2019-07-12 10:50:51 -05:00
Martin Hundebøll 23a09f8559 quectel: add basic support for serial connected modems
Setup GSM 07.10 multiplexing using the kernel n_gsm line discpline
driver, and use the virtual tty devices as Aux and Modem channels.

The driver supports rts/cts on the underlying serial device. This is
enabled with OFONO_QUECTED_RTSCTS udev environment, e.g.:

KERNEL=="ttymxc0", ENV{OFONO_DRIVER}="quectel", \
        ENV{OFONO_QUECTEL_RTSCTS}="on"
2019-07-12 10:47:10 -05:00
Martin Hundebøll e41252d00b quectel: replace glib uses with ell 2019-07-12 10:17:12 -05:00
Martin Hundebøll 4fe04add08 quectel: unwrap call to at_util_open_device() 2019-07-12 10:16:45 -05:00
Martin Hundebøll a0a93da0f9 quectel: always print modem pointer in debug messages 2019-07-12 09:42:43 -05:00
Martin Hundebøll 47021f9950 quectel: fix initial channel/device configuration
The three-commands-in-one-go results in error on some quectel devices
(e.g. m95). Add semicolons between the commands to fix it.
2019-07-05 17:28:04 -05:00
Martin Hundebøll db74f0998a quectel: improve coding style 2019-07-05 17:17:47 -05:00
Denis Kenzior d493c7cc10 quectel: Use at_util_open_device 2019-05-31 11:58:39 -05:00
Denis Kenzior 1f3e30f1ba quectel: Minor style cleanup 2014-07-08 08:44:21 -05:00
Denis Kenzior 7ab4034bf4 quectel: Remove unneeded VENDOR flags
Only the sim atom has QUECTEL specific code
2014-07-08 08:43:01 -05:00
Philip Paeps bb1984cabb plugins: add a new driver for Quectel UC15 modems 2014-07-08 08:42:05 -05:00