Commit graph

496 commits

Author SHA1 Message Date
Ryan Erickson 34ec42b8f3 modem: hl7800: sock_read len arg is not used
The static function sock_read does not need a length arg, remove it.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2024-02-08 07:03:12 +01:00
Parthiban Nallathambi fd85021718 modem: change log level of events prints to debug
info level is printed always to console and it's noisy.
Change to debug level, which can be enabled with
CONFIG_MODEM_MODULES_LOG_LEVEL_DBG

Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
2024-02-06 13:00:05 +01:00
Flavio Ceolin d4ba37739f drivers: modem/simcom: Unused variable
Make coverity happy and mark a variable as unused.

Fixes CID-248325
Fixes #58572

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-02-01 14:06:27 +01:00
Bjarki Arge Andreasen 27b0d4e3fe modem: chat: remove receive and transmit timeouts
Remove receive and transmit timeouts which are no
longer useful as the RECEIVE_READY and
TRANSMIT_IDLE events will be used to efficiently
manage timeouts between transmit/receive calls.

Then update the the in-tree drivers using the
modem_chat module to omit the process timeout
parameter.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-25 11:22:42 +01:00
Parthiban Nallathambi db429004fd drivers: modem: gsm fix rssi range
rssi 31 will be -51dBm or greater, where -51 is valid. Fix the
range by allowing until -51.

Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
2024-01-19 15:15:03 +00:00
Emil Lindqvist 342e10b0b8 modem_cellular: add RSRP & RSRQ to U-blox SARA-R5 modem
This commit implements parsing of the CESQ extended signal quality AT
command, extracting RSRP and RSRQ which is relevant for LTE connections.
It's used in the U-blox SARA-R5 modem instance. Furthermore, the IMEI,
IMSI is extracted in the same modem.

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2024-01-16 14:15:56 +00:00
Bjarki Arge Andreasen 1ee092673a modem: modem_cellular.c: Remove non standard QCCID handler
The QCCID handler is Quectel specific and as such may not be part
of the modem cellular driver which only supports commands defined
in 3GPP TS 27.007

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-03 10:21:18 +01:00
Bjarki Arge Andreasen 572c5e6d5a modem: modem_cellular: Rework cellular_get_signal implementation
The modem_cellular.c driver now uses a common script to get
signal strenght, which is run on demand. This is more efficient
than polling it, and simpler since every modem doesn't have to
define their own variant of the script.

Additionally, the CSQ handler now stores the "raw" rssi value
returned from AT+CSQ to be parsed by the cellular_modem_get_signal
implementation.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-03 10:21:18 +01:00
Bjarki Arge Andreasen f9491034be modem: modem_cellular: Update driver to implement cellular API
Move the implementations of the cellular API in modem_cellular.c
to an cellular_driver_structure, and implement this API structure
withing the device drivers.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-03 10:21:18 +01:00
Alessio Lei 733b81d2c7 drivers: modem: remove dependency of modem_socket
Fixed Kconfig to remove dependency between modem_socket and
modem_context, the two do not depend on each other and
should be possible to use independently

Signed-off-by: Alessio Lei <alelei94@yahoo.it>
2023-12-14 09:31:51 +01:00
Lucas Denefle d1ba79a070 drivers: cellular: add signal and modem_info API
Implement modem info pulling using the init and periodic chat scripts

Signed-off-by: Lucas Denefle <lucas.denefle@converge.io>
2023-12-12 19:09:33 +01:00
Ryan Erickson 8deaf18d8b drivers: modem: hl7800: fix low power modes
Do not allow the modem to sleep if the driver is busy.
Fix CTS filtering. Ignore small pulses on the CTS line.

Fix socket restoration. Restored sockets could be mismatched
with a wrong type.
UDP sockets could be duplicated during restore.

Improve IO debug mode. Use warning message for IO debug mode
to easily see IO transitions color coded in a terminal.

Ensure the UART is enabled whenever the driver needs to send
commands to the modem.

Ensure DNS resolver is re-initialized after the modem is powered off.

PROD-307

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2023-12-08 10:26:04 +00:00
Emil Lindqvist 1cd7c55af9 modem: modem_cellular: add U-blox SARA-R5 as modem
U-blox SARA-R4 already exists but the behavior is different,
requiring a separate driver instance. For instance, R5 autostarts,
so this commit also adds support for skipping power on pulse.

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2023-12-05 16:29:55 -06:00
Emil Lindqvist 79c2fafe6a modem: modem_cellular: add PAP authentication support
Some modems or networks require PAP authentication for successful
LCP handshake. Tested on U-blox SARA-R5 with zephyr,gsm-ppp.

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2023-12-01 10:51:24 +00:00
Jukka Rissanen f70e4c0f68 drivers: modem: Fix include paths
Set the include paths properly and unconditionally to needed
networking directories.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-21 08:48:04 +00:00
Benjamin Cabé f3b85ad92c drivers: modem: fix for possible non-null terminated string
Fix handling of strncpy in cgnsinf parsing function to avoid
potentially getting a non-null terminated string.
Fixes #58573 / CID: 248403

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-11-20 09:23:32 +01:00
Lucas Denefle f9d0a4c5cf drivers: modem: add Quectel EG25-G
This commit introduces support for the modem EG25-G from Quectel.

Signed-off-by: Lucas Denefle <lucas.denefle@converge.io>
2023-11-13 10:10:15 -06:00
Bjarki Arge Andreasen 5639bc0330 modem: modem_cellular: Fix build errors
Build errors where introduced by
c76d5b882c and are fixed with this
commit. They are trivial fixes of malformed lines.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-11-06 16:06:36 +01:00
Bjarki Arge Andreasen c76d5b882c drivers: modem: modem_cellular: Patch init scripts
The init scripts need a missing wait for OK after sending
AT+CGMM and the AT+CMUX command specifies more parameters
than nessesary, and in some cases incorrectly.

This commit adds the missing wait for OK and fixes the AT+CMUX
commands in the init scripts.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-11-06 10:09:48 +01:00
Jeff Welder 372216a3ea drivers: modem: modem_cellular: add Telit ME910G1
Added chat script and initial config to support Telit ME910G1.
Needed to edit power_pulse pin timing in accordance to datasheet.

Signed-off-by: Jeff Welder <Jeff.Welder@ellenbytech.com>
2023-11-02 08:34:50 +00:00
Jeff Welder ed8f0bc985 drivers: modem: Individualize Modem Device Macros
Refactor device macro to be custom for each modem
to allow custom configurations.

Signed-off-by: Jeff Welder <Jeff.Welder@ellenbytech.com>
2023-11-02 08:34:50 +00:00
Benedikt Schmidt ba49cb81f1 drivers: modem: fix thread function signatures
Fix thread function signatures to avoid stack corruption on thread exit.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
Tahir Akram 7c7c8f193e drivers: modem: introducing config for cereg/creg for gsm
This contribution addresses the support for various types of modems in
gsm driver. As some 4G modems have failed to return correct output
from AT+CREG?, so AT+CEREG? is the right AT command in such situation.
This commit provides the possibility for user to select one type of
AT command. This PR fixes zephyrproject-rtos#63917

Signed-off-by: Tahir Akram <mtahirbutt@hotmail.com>
2023-10-20 15:13:08 +02:00
Andrei Emeltchenko d661c86e35 drivers: modem_cellular: Fix missing break
There is no fallthrough statement or comment so I assume break is
missing.

Fixes build time warning from some tools.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-10-13 17:42:40 +03:00
Bjarki Arge Andreasen 0339f2d41f modem: modem_cellular: Adjust chat scripts
This commit adjust the chat scripts for the simcom
sim7080 and gsm_ppp compatibles to fix an issue found
when trying to use a sim7080 modem. The CMUX command
includes optional parameters which are not identical
for all modems, so the AT+CMUX command has been adjusted
to only contain the mandatory parameters.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-10-11 18:57:11 +03:00
Flavio Ceolin e7bd10ae71 random: Rename random header
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.

Rename it to random.h and get consistently with other
subsystems.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-10 14:23:50 +03:00
Bjarki Arge Andreasen 7cac905e57 drivers: modem: modem_cellular: extend CMUX timeout
This commit adds a timeout of 300ms to the generic (gsm_ppp) init
chat script. This delay is required for some modems (discovered on
a Telit ME910G1-WW) to allow it to enter CMUX mode. Without this
delay, the modem simply refuses to respond to any CMUX commands.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-03 15:13:47 +01:00
Ryan Erickson aaed347d60 drivers: modem: gsm: Mark as deprecated
The MODEM_GSM_PPP driver is now deprecated in favor of
using MODEM_CELLULAR.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2023-09-19 15:25:47 +01:00
Fabio Baltieri 196b1d6289 modem: hl7800: replace an snprintk with a strncpy
GCC format-truncation kicks in on this printk whenever the logging
configuration transforms the LOG_WRN below into a noop, and the snprintk
return argument become unused.

Fix that by switching to strncpy, fixes:

zephyrproject/zephyr/drivers/modem/hl7800.c:1786:74: warning: '%s'
directive output may be truncated writing up to 53 bytes into a region
of size 21 [-Wformat-truncation=]

reproduced with:

west build -p -b mg100 -T samples/net/telnet/sample.net.telnet

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-09-19 15:07:34 +01:00
Bjarki Arge Andreasen 328b588ceb drivers: modem: modem_cellular: Update script run function
This commit updates the modem_cellular driver to use the
new naming scheme for the modem_chat functions.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-09-18 14:11:40 +01:00
Bjarki Arge Andreasen 2d2d3ececd drivers/modem/modem_cellular.c: Improve bus pipe usage
This commit improves the usage of the bus pipe (connected
to UART) to only open it when the modem is actually
powered and ready, not when leaving the idle state. This
ensures the pipe is flushed before sending the init script,
and re-enables the UART driver if it is disabled due to
errors.

While building a test platform based on the nRF9160 and a
Quectel BG95, it was discovered that the nRF9160 correctly
throws UART errors if the RX is enabled while the UART RX
line is low (which was due to the modem being powered
down).

The improvements should also help help remove the
"<wrn> modem_chat: receive buffer overrun" warning which
would occur during startup as the pipe was opened, but
nothing was receiving the data, causing the buffer to
overflow.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-09-06 09:35:34 +02:00
Fabio Baltieri 5f0efb94fa modem: modem_chat,modem_cmux: fix mismatched CONTAINER_OF
Add a missing k_work_delayable_from_work to go from k_work to
k_work_delayable.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-09-04 16:54:56 +02:00
Carles Cufi 8c748fd005 kernel: Modify the signature of k_mem_slab_free()
Modify the signature of the k_mem_slab_free() function with a new one,
replacing the old void **mem with void *mem as a parameter.

The following function:
void k_mem_slab_free(struct k_mem_slab *slab, void **mem);

has the wrong signature. mem is only used as a regular pointer, so there
is no need to use a double-pointer. The correct signature should be:
void k_mem_slab_free(struct k_mem_slab *slab, void *mem);

The issue with the current signature, although functional, is that it is
extremely confusing. I myself, a veteran Zephyr developer, was confused
by this parameter when looking at it recently.

All in-tree uses of the function have been adapted.

Fixes #61888.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-09-03 18:20:59 -04:00
Bjarki Arge Andreasen b14c39f2c1 drivers/modem: Add generic cellular modem driver
The added cellular modem driver is a naive driver, which
shall serve as a template for implementing tailored
drivers for modems like the UBLOX-R4. It uses only
generic at commands, described in 3gpp, and protocols,
like CMUX and PPP.

A binding for the BG95 has been added, which replaces
the quectel,bg9x. This is neccesary since the BG95 does
not have a usable reset pin, the reset and powerkey are
internally connected to each other.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-08-30 13:48:51 +02:00
Nick Ward 2d65acca3a drivers: gpio: use gpio_is_ready_dt helper function
Update `struct gpio_dt_spec` use with gpio_is_ready_dt()

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-08-28 08:48:35 -05:00
Fabio Baltieri 2fea3fb0a9 drivers: modem: delay init priority
Change the default modem GSM init priority to make sure it's after
serial.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-24 15:35:37 +02:00
Bjarki Arge Andreasen f6fde45e09 drivers/modem/hl7800.c: Fix ictx reference
Use the symbol iface_ctx in place of ictx. This was
introduced seemingly by mistake in PR #61510

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-08-20 17:57:11 +01:00
Ryan Erickson 4885dae94d modem: hl7800: ensure the modem inits with radio on
Ensure the driver enables the LTE radio during init unless boot
in airplane mode is specified.
To ensure the settings applied during init are used, the LTE radio
is turned off during config.
Fix issue where PDP and GPRS connection config could have a mismatched APN.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2023-08-18 10:13:30 +02:00
Bjarki Arge Andreasen 12e79ca4ce drivers/modem/gsm_ppp.c: Remove direct call to PPP API
This commit removes the direct calls of the PPP API of the
network device used by gsm_ppp.c

These calls are now performed by the L2 PPP interface when it
is brought up or down using net_if_up() or net_if_down()

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-08-10 16:23:39 +00:00
Daniel Leung af325193b6 modem: renames shadow variables
Renames shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:43 +00:00
Willian Wang b7a4a927de drivers: modem: Remove unnecessary MODEM_SHELL dependency
MODEM_SIM_NUMBERS and MODEM_CELL_INFO don't depend on MODEM_SHELL.

Signed-off-by: Willian Wang <git@willian.wang>
2023-08-04 19:35:39 +00:00
Benjamin Cabé db53c3fd2c doc: Drop asterisk from Doxygen @param
The name for Doxygen params that are pointers should not include an
asterisk.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-07-13 13:25:28 +00:00
Jordan Yates 1c2dba2107 drivers: modem: cache delimiter string length
Cache the delimiter string length in `parse_params`, instead of
calculating it on each character in the match buffer.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-13 09:23:05 +02:00
Jordan Yates 76c1a2019a drivers: modem: skip quoted delimiters
Given the following response: `+CIPSTA:ip6ll:"FE80::EDC:7EFF:FEDD:110C"`

The response delimiter is `:`, but there is also a quoted string that
contains the delimiter character. These delimiters should not be
considered when searching for the end of a parameter.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-13 09:23:05 +02:00
Mark Kettner a0418f1821 modem_shell: fix compilation error.
fix error: 'struct modem_shell_user_data' has no member named 'shell'

Signed-off-by: Mark Kettner <mark@kettner.io>
2023-06-26 08:31:42 +00:00
Andrei Emeltchenko 0adfe5531e drivers: gsm_ppp: Fix possible NULL pointer dereference
Assign api value after NULL check.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-06-20 09:25:30 +02:00
Bjarki Arge Andreasen 22152915ab drivers/gsm_ppp: Update existing modules to use PPP L2
This commit replaces the workarounds spread around the
drivers and subsystems with the updated PPP L2
interface.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-06-17 07:46:21 -04:00
Nick Ward 941e4f000b drivers: modem: modem_receiver: fix wake PM
mdm_receiver_wake() needs to PM resume.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-06-01 10:04:14 -04:00
Andrei Hutanu 27ad7111cd drivers: modem: quectel-bg9x: fix reset BG95 mdm
In case of BG95 where there is no reset pin, reseting the board
which uses a BG95 modem could result in powering-off the modem
(as oposed to "reset" the modem). This commit is an attempt
to handle this case and re-power the modem.

Signed-off-by: Andrei Hutanu <andrei.hutanu.i@gmail.com>
2023-05-27 06:28:33 -04:00
Andrei Hutanu 3cf92bce11 drivers: modem: quectel-bg9x: mdm unsol ready
Using bg9x driver with bg95 specifically has the issue that BG95
modem replies with "RDY" when it's not fully initialized and AT
commands sent to the modem after this point would result in modem
reply of "ERROR". This commit adds a new prj.conf field in the build
configuration for custom unsolicited app ready string, with
the default being BG96 one ("RDY").

Signed-off-by: Andrei Hutanu <andrei.hutanu.i@gmail.com>
2023-05-27 06:28:33 -04:00