Commit graph

474 commits

Author SHA1 Message Date
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
Andrei Hutanu cf3df2b840 drivers: modem: quectel-bg9x: fix for bg95 pinout
The BG95 pin configuration does not internally ever use the reset pin.
Because of this, there is no need to make reset pin mandatory.
Commit removes reset pin dependency [e.g. in case of BG95].

Signed-off-by: Andrei Hutanu <andrei.hutanu.i@gmail.com>
2023-05-27 06:28:33 -04:00
Jordan Yates ec362d4a48 modem: modem_iface_uart_async: handle RX errors
Re-enable reception on the UART instance when `UART_RX_DISABLED`
triggers, which can happen when errors occur on the line.

This stops the driver permanently moving into an unresponsive state.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-05-08 16:42:58 +02:00
Alberto Escolar Piedras 0cd7fa31d3 drivers/modem sim7080 & ublox-sara: Fix link error
Fix link error when both modems' drivers are enabled
as they both define the same structure but did not
make it static.

This fixes the CI build failure of
tests/drivers/build_all/modem/drivers.modem.simcom_sim7080.build
on particle_boron

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-05-04 20:50:11 +02:00
Alberto Escolar Piedras fba4370a47 drivers/modem/ublox-sara: Fix build warning
Fix the following build warning:
include <fcntl.h> without CONFIG_POSIX_API
is deprecated. Please use CONFIG_POSIX_API
or #include <zephyr/posix/fcntl.h>

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-05-04 20:50:11 +02:00
Kumar Gala 4805d7b1ce modem: hl7800: Fix build issue with arm-clang
When building drivers.modem.build we get a link error since
log_source_id_get() is not defined when CONFIG_LOG_MODE_MINIMAL
is defined.

Change ifdef protection to be CONFIG_LOG_RUNTIME_FILTERING
instead of CONFIG_LOG in the code to handle this case.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-25 23:18:54 +09:00
Kumar Gala 1a5d47ef6d modem: wncm14a2a: fix warning with isalpha/isdigit
When building with arm-clang we get warnings of the type:

wncm14a2a.c:828:14: error: array subscript is of type
			   'char' [-Werror,-Wchar-subscripts]:
                } else if (isalpha(c2) != 0) {
                           ^~~~~~~~~~~

Fix this by adding explicit casts to (int) when callinng isalpha()
or isdigit().

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-25 12:19:21 +02:00
Gerard Marull-Paretas 667eeb11fb shell: fix MISRA 5.7 violations on struct shell
MISRA Rule 5.7 requires uniqueness of tag identifiers. Shell is
frequently problematic because many code uses `const struct shell
*shell`. This causes CI noise every time one of these shell files is
edited, so let's update all of them with `const struct shell *sh`
instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Bjarki Arge Andreasen b0d8f5ec7f drivers/modem/modem_socket: Updated API
The internal socket context struct modem_socket_config
currently has members accessed directly by user. The
modem_socket_init() function has been updated to take all
user configurations as args. Thus removing the need for
the user to directly access the internal context for
initialization.

The user also currently needs to know of internal modem
socket libary behavior to determine if a socket has been
allocated and assigned an id, this is documented, and is
not safe. The functions:
 modem_socket_is_allocated()
 modem_socket_id_is_assigned()
 modem_socket_id_assign()
have been added to the modem socket library API to perform
these checks, and to assign socket ids.

This commit makes use of the modem socket library safer and
adds documentation to the API.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-04-11 11:42:00 +02:00
Bjarki Arge Andreasen aa6ecc59d1 drivers/modem/modem_cmd_handler: Update API
There is currently not a clear separation between
user configuration and internal context when using the
modem_cmd_handler library. This update adds a clear
separation, placing user configuration in a seperate
struct passed to modem_cmd_handler_init alongside the
internal context modem_cmd_handler_data.

There is also a lack of documentation of the user
configurations, these have been added to the new config
struct.

The new API function modem_cmd_handler_process has been
added to remove the need for the user to directly access
the process member of the internal context. This ensures
that the user is not encouraged to access any internal
context members.

Some whitespace errors exist in the modem_cmd_handler.c
file, these are outside of the scope of this PR. These
can be addressed in a later PR as they are not functional
changes.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-04-11 11:42:00 +02:00
Bjarki Arge Andreasen a4afcf8c93 drivers/modem/modem_iface_uart: Update API
The UART IFACE API currently exposes the context struct
modem_iface_uart_data, expecting the user to fill in some
of the fields, with no documentation specifying which fields
and what they mean.

This API update moves all user configurable values in the context
out into a config struct, modem_iface_uart_config, within which
members are documented.

This prevents the user from interacting directly with the context
making use of the library safer and more readable.

The config structure helps make code readable by using "named args"
in a const struct instead of a long, nameless, parameter list passed
to the modem_iface_uart_init function.

The new API function modem_iface_uart_rx_wait is added to prevent the
user from having to interact with the rx sem in the context directly.

The context can now be safely interated with without direct access to
any of its members.

Pointers to the ring buffer params in the context have been moved to
config struct, as these are only useful during initialization of the
context.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-04-11 11:42:00 +02:00
Kumar Gala 77f6e0a501 wncm14a2a: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-04 13:48:09 +02:00
Henrik Brix Andersen c41dd36de2 drivers: kconfig: unify menuconfig title strings
Unify the drivers/*/Kconfig menuconfig title strings to the format
"<class> [(acronym)] [bus] drivers".

Including both the full name of the driver class and an acronym makes
menuconfig more user friendly as some of the acronyms are less well-known
than others. It also improves Kconfig search, both via menuconfig and via
the generated Kconfig documentation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-28 15:06:06 +02:00
Georges Oates_Larsen 3c6b7dc35a net: dummy L2 for offloaded ifaces
Adds dummy link layer for offloaded ifaces, allowing
ifaces to directly receive l2_enable calls

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-03-20 09:53:25 +01:00
Ryan Erickson 75926dacb3 modem: hl7800: Fix DNS resolver for all address families
Fix DNS resolver config for IPv6 only setup.
Check validity of the DNS addresses before trying to
configure the resolver.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2023-02-20 09:51:38 +01:00
Ryan Erickson dd195d6ea5 modem: hl7800: fix power off
Ensure DNS resolver is stopped if modem is turned off.
All IO connected to the HL7800 need to be de-asserted
in order for the HL7800 to power off.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2023-02-20 09:49:43 +01:00
Ryan Erickson bec12a098d modem: hl7800: fix low power mode
PSM hibernate mode would draw excessive current
because the UART would be enabled if CTS went low.
In hibernate mode, do not use CTS to power on the UART.

Fix reading of input pin states for low power by reading
the raw value.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2023-02-07 00:25:53 -08:00
Ryan Erickson 8aeb821a4e modem: hl7800: emit event on band change
Ensure an event is triggered any time the LTE bands change.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2023-02-07 00:25:53 -08:00
Ryan Erickson 6e58ba5dd8 modem: hl7800: Improve set bands API
Change the API to not block waiting for a reboot.
Reboot asynchronously.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2023-02-07 00:25:53 -08:00
Ryan Erickson 57b52adc15 modem: hl7800: Improve RAT API
Change the API to not block waiting for a reboot.
Reboot asynchronously.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2023-02-07 00:25:53 -08:00
Ryan Erickson fe76aa0959 modem: hl7800: Fix event lock
Change event callback lock to a semaphore to avoid
priority issues the mutexes can cause.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2023-02-07 00:25:53 -08:00
Marin Jurjević b99b66fba2 drivers: modem: gsm: fix RSSI check condition
Fixes invalid condition introduced in #48533 when FSM implementation
was added.

Signed-off-by: Marin Jurjević <marin.jurjevic@hotmail.com>
2022-12-27 15:32:07 +01:00
Maciej Zagrabski ec7237c38a drivers: gsm_ppp: replace DT_INST with DT_DRV_INST
Replace error prone DT_INST with proper DT_DRV_INST.

Signed-off-by: Maciej Zagrabski <mzi@trackunit.com>
2022-12-07 10:29:34 +00:00