Commit Graph

585 Commits

Author SHA1 Message Date
Bjarki Arge Andreasen
638bf6b03d modem: cmux: Decouple modem cmux and cellular driver
The modem modules cmux module is currently directly coupled to the
presence of specific modems, rather than being selected by drivers
for whatever hardware wants to request the default MTU of 127 bytes.

This commit the makes the device drivers (for now, modem_cellular)
select the symbol, thus decoupling the modem modules from the
presence of any specific device.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-07-23 17:31:22 +01:00
Van Petrosyan
8eb2a9c507 drivers: modem_cellular: added APP RDY signal handling
Some modems (e.g. Quectel BG95/EG25-G, several SIMCom parts) print
“APP RDY” when the application core is ready.  Parse this line and
proceed from AWAIT_POWER_ON immediately, while keeping the existing
startup timeout as a fall-back.

* add MODEM_CELLULAR_EVENT_MODEM_READY + chat match
* open UART and attach chat in AWAIT_POWER_ON
* jump to SET_BAUDRATE / RUN_INIT_SCRIPT on event

Signed-off-by: Van Petrosyan <van.petrosyan@sensirion.com>
2025-07-19 13:45:15 -04:00
Van Petrosyan
3225b517d4 drivers: modem_cellular: Add autostarts support for BG95
Add optional autostarts boolean to the quectel,bg95 binding and make
MODEM_CELLULAR_DEFINE_INSTANCE() use it through DT_PROP_OR().
Boards that carry a BG95-M3 Mini-PCIe card—or any other variant that
boots at VCC can now declare the property and skip the PWRKEY pulse,
while existing designs continue to behave unchanged.

Signed-off-by: Van Petrosyan <van.petrosyan@sensirion.com>
2025-07-19 13:44:37 -04:00
Van Petrosyan
25cd0d6341 drivers: modem_cellular: use AT+QGMR to fetch FW version on BG95
Quectel BG9x returns only the base model string to AT+CGMR, while
AT+QGMR provides the true firmware build ID, e.g.

  AT+CGMR  → BG95M3LAR02A03
  AT+QGMR  → BG95M3LAR02A03_01.204.01.204

Replace CGMR with QGMR in the BG95 init script so that
cellular_get_modem_info(... FW_VERSION ...) reports the complete
version string.

Signed-off-by: Van Petrosyan <van.petrosyan@sensirion.com>
2025-07-19 13:44:20 -04:00
Van Petrosyan
06b4adda81 drivers: modem_cellular: Add shutdown script for BG95
Add quectel_bg95_shutdown_chat_script that issues AT+QPOWD=1 and
link it to MODEM_CELLULAR_DEVICE_QUECTEL_BG95 to enable a clean
software-initiated power-off path

Signed-off-by: Van Petrosyan <van.petrosyan@sensirion.com>
2025-07-19 13:44:09 -04:00
Van Petrosyan
4197953d3f drivers: modem_cellular: fix bg95dial cmd resp
bg95 modem should respond "CONNECT <text>" when run dial cmd
similar to eg25g

Signed-off-by: Van Petrosyan <van.petrosyan@sensirion.com>
2025-07-04 13:07:12 -05:00
Shan Pen
bd2f4ef946 drivers: modem_cellular: fix eg25g dial cmd response
eg25g modem should respond "CONNECT <text> " when run dial cmd "ATD"

Signed-off-by: Shan Pen <bricle031@gmail.com>
2025-06-30 15:16:48 -05:00
Daniel DeGrasse
c8c1bf4131 drivers: modem: modem_cellular: fix variable declaration for clang
Fix variable declaration so that this driver will compile with clang,
which does not support variable declarations within switch statements

Signed-off-by: Daniel DeGrasse <ddegrasse@tenstorrent.com>
2025-06-27 18:28:22 -05:00
Jani Hirsimäki
4ec4351657 drivers: modem_cellular: changes due to net_link_addr struct changes
Recent changes to net_link_addr structure to not use pointers
have made it necessary to update the modem_cellular driver
to ensure compatibility with the new structure definition.
Otherwise, an assertion failure occurs in subsys/net/l2/ppp/ipv6cp.c:40.
This commit updates that link address is set to NET_LINK_ADDR_MAX_LENGTH
least significant bytes of IMEI instead of IMEI total length.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2025-06-27 14:15:03 +02:00
Jukka Rissanen
cdc6c324d7 net: dns: Save info about source when configuring DNS servers
Remember which DNS server was added by a source like DHCPv4 or v6
message. This will allow system to remove DNS servers that were added by
that source. Then when stopping for example DHCP, we can remove those
specific DNS servers and not leaving DNS servers hanging in the system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-26 14:08:19 +02:00
Emil Lindqvist
401ec8bae2 modem_cellular: lara_r6: add option to clear forbidden networks from SIM
SIM-cards remember which networks has rejected attach attempts. This is
not always desired if the user has control over which networks to allow.
This commit adds a Kconfig symbol which enables clearing of saved
forbidden networks from SIM-card on boot.

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2025-06-25 15:42:41 -10:00
Emil Lindqvist
e27c4ba718 modem_cellular: lara_r6: add choice of Radio Access Technology
Add a Kconfig choice to select which Radio Access Technology to be used

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2025-06-25 15:42:41 -10:00
Emil Lindqvist
bebfd879bf modem_cellular: lara_r6: disable modem's own LWM2M client
U-blox LARA-R6 LWM2M client is enabled by default. Not only causes this
the modem to connect to U-blox's server on its own, it also for some
reason causes the modem to reply "Destination unreachable" to DNS answers
from DNS requests that we send

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2025-06-25 15:42:41 -10:00
Jukka Rissanen
5a9a39caf3 net: mgmt: Convert the mgmt API to use 64-bit masks
Instead of using 32 bit enum values for event numbers, convert
the code to use 64 bit long bit fields. This means that the
user API is changed to use 64 bit event values instead of 32
bit event values.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-18 10:54:44 +02:00
Olivier Lalonde
afc481ab31 modem_cellular: Add support for the simcom a76xx modem
Add support for the simcom a76xx modem which is similar to the simcom 7080
but has a few key differences. Tested with a simcom A7672SA module but as
there is a single simcom A76XX AT commands manual, the driver should work
with other modems of the series.

Signed-off-by: Olivier Lalonde <o@syskall.com>
2025-05-28 16:37:53 +02:00
Vytautas Virvičius
087267a0ff drivers: modem: add support for Quectel EG800Q
Added support for Quectel EG800Q LTE Cat 1bis modem.

Signed-off-by: Vytautas Virvičius <vytautas@virvicius.dev>
2025-05-28 01:47:56 +02:00
Markus Lassila
28e40128aa modem_cellular: Close carrier with suspend
Fix regression introduced by dormant state, where the
carrier does not get closed when Cellular Modem driver
is suspended.

Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
2025-05-23 09:37:29 +02:00
Markus Lassila
5b6a865464 modem_cellular: Add dormant state to support network loss
Previously, it was expected that the modem would immediately
disconnect and close the PPP link, when the network was lost
(+CEREG: 4 is received). Failure to do so, would result in
modem attempting to chat with dlci2 channel, where as cellular
modem driver would drop to dlci1. This would show as dial
script timing out, which would freeze cellular modem driver.

Adding dormant state enables graceful disconnection of PPP-link
when the network is lost. This allows the modems which do
not automatically close with network link loss to close
based on PPP link closure.

Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
2025-05-14 14:10:21 +02:00
Joakim Andersson
b2bb1ffc1b drivers: modem: Use modem command await function
Use the modem command await function where appropriate.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2025-05-06 18:24:01 +02:00
Joakim Andersson
25341410a7 drivers: modem: Add function to wait for sem and handle error
Add a helper function that waits for a semaphore and handles the
error conditions that may arise.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2025-05-06 18:24:01 +02:00
Joakim Andersson
995440b706 drivers: modem: Use modem command send_data_nolock
Use the new modem command send_data_nolock function where it was
previously just written directly to the interface.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2025-05-06 18:24:01 +02:00
Joakim Andersson
0617b25126 drivers: modem: Add helper function to send data on modem cmd iface
Add helper function to send data on modem command handler interface.
This makes sure that when verbose logging is enabled all data is
actually logged.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2025-05-06 18:24:01 +02:00
Joakim Andersson
8cea4ce5da drivers: modem: Fix possible race condition, reset sem before data send
Fix possible race condition, reset the response semaphore before we send
any data. In case we don't get scheduled back before the response is
processed.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2025-05-06 18:24:01 +02:00
Seppo Takalo
c78081e5cf modem: modem_cellular: Configurable MTU for CMUX
Allow configuring MTU for CMUX.
Some AT manual and specification define this as a
frame size. Linux ldattach default to 127 bytes,
3GPP TS 27.010 defaults to 31.

We should limit our CMUX frames to a size that
remote end is capable of handling.
Linux silently drops oversized frames.

Also, remove MODEM_CELLULAR_CMUX_MAX_FRAME_SIZE as
this was only limiting a buffer sizes, and resulted
CMUX frames to be capped to same value.
Use MODEM_CMUX_WORK_BUFFER_SIZE and MODEM_CMUX_MTU instead.

Also rename CONFIG_MODEM_CELLULAR_CHAT_BUFFER_SIZES to
CONFIG_MODEM_CELLULAR_CHAT_BUFFER_SIZE as it is now
only used as a Chat module. DLCI pipes use
CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2025-03-24 19:33:07 +01:00
Zafer SEN
7efbc7cde3 drivers: modem: modem_cellular: fix HL7800 communication timeout
HL7800 may enter sleep, blocking init without proper config.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2025-03-19 17:14:41 +01:00
Tom Hughes
f80f60f477 drivers: modem: Remove unused function
Building with clang warns:

drivers/modem/modem_cmd_handler.c:102:31: error: unused function
'read_rx_allocator' [-Werror,-Wunused-function]
static inline struct net_buf *read_rx_allocator(k_timeout_t timeout,
                              ^

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-02-12 02:25:33 +01:00
Ryan Erickson
522718d7fd modem: hl7800: optimize socket cleanup on boot
On boot cleanup any restored sockets if they exist.

Signed-off-by: Ryan Erickson <ryan.erickson@ezurio.com>
2025-01-20 11:15:57 +01:00
Ryan Erickson
8a1336ec87 modem: hl7800: Fix DNS in sleep mode
When sleep modes are used, sockets are restored from NV after boot.
If the network changes IP addresses, restore sockets maintain old network
info in the HL7800 firmware.
On boot, restored sockets should be closed to ensure new sockets
are created with updated network info.

Signed-off-by: Ryan Erickson <ryan.erickson@ezurio.com>
2025-01-20 11:15:57 +01:00
Ryan Erickson
adffb84329 modem: hl7800: improve AT command API
Update AT command API to return a response.
Add param to set the timeout when waiting for a response.
If the user does not desire a response, the response buffer can
be NULL.

Signed-off-by: Ryan Erickson <ryan.erickson@ezurio.com>
2025-01-20 11:15:57 +01:00
Ryan Erickson
7b9a0eb237 modem: hl7800: stay awake for firmware update
Ensure the HL7800 stays awake for the entire firmware update.

Signed-off-by: Ryan Erickson <ryan.erickson@ezurio.com>
2025-01-20 11:15:57 +01:00
Ryan Erickson
c73e164ed5 modem: hl7800: wake before firmware update
Ensure the HL7800 is awake before starting a firmware update.

Signed-off-by: Ryan Erickson <ryan.erickson@ezurio.com>
2025-01-20 11:15:57 +01:00
Ryan Erickson
5d27c9b298 modem: hl7800: Add new state event
The new state event allows a user to know the overall state of the
HL7800 driver.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2025-01-20 11:15:57 +01:00
Ryan Erickson
962179286f modem: hl7800: power off should generate events
When powering off the modem, appropriate state events
should be triggered.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2025-01-20 11:15:57 +01:00
Ryan Erickson
de83072776 modem: hl7800: reset API should be async
All other APIs that need to reset the modem do so in an async way.
Make the rest API async as well.
This fixes issues where modem events related to the reset
were not generated properly.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2025-01-20 11:15:57 +01:00
Ryan Erickson
39412e26c8 modem: hl7800: fix socket port byte order
Ensure the proper byte order is used for the network socket in the stack.
When sending the AT commands, the port needs to be converted to
host endianess.
TLS handshakes check that the remote address and port match
what is expected.

Signed-off-by: Ryan Erickson <ryan.erickson@ezurio.com>
2025-01-20 11:15:57 +01:00
Joakim Andersson
8d04e7e38c drivers: modem: Fix modem_socket returning object for fd zero after init
Fix bug in modem_socket where an unallocated object can be returned
for file descriptor zero before the object has been used one time.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2025-01-17 13:54:34 +01:00
Joakim Andersson
123adb2d7b drivers: modem: Modem socket does not build without NET_SOCKETS enabled
Modem socket does not build with NET_SOCKETS enabled.
Referencing socket_data in struct net_context.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2025-01-17 13:54:34 +01:00
Jilay Pandya
cb94a761de drivers: modem: modem_cellular: add missing break statement
add missing break statement to fix coverity issue

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2024-12-19 15:18:06 +01:00
Pieter De Gendt
b92ad8ae05 drivers: modem: cellular: Place API into iterable section
Add wrapper DEVICE_API macro to all cellular_driver_api instances.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-12-02 18:19:02 +01:00
Tomi Fontanilles
f380fcc52f drivers: modem_cellular: fix handling of +C*REG answers
`+C*REG:` may be received as AT read command answer
or unsolicited notification.
Their syntax differs, and even the overall parameter count varies
depending on what `<n>` is used in the `AT+CEREG=` write command.

To handle all cases properly, check the parameter count and
the presence of the `<tac>` parameter (which is a string and
thus begins with `"`) to figure out what is the position of `<stat>`.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-10-30 08:54:17 -05:00
Niklas Gürtler
50dbd8ba5a modem_cellular: Add support for the Telit ME310G1 LTE modem
Add support for the Telit ME310G1 LTE modem which is very similar to
the ME910G1. Re-use the ME910G1's AT command scripts but rename
them to mex10_xx and define a shutdown script (AT#SHDN).

Signed-off-by: Niklas Gürtler <niklas.guertler@e-obs.de>
2024-10-17 09:46:09 +02:00
Niklas Gürtler
93330b07f2 modem_cellular: Add support to define a shutdown script for cellular modems
Add support to define a shutdown script for cellular modems, i.e.
AT commands to shutdown the modem. This allows to shutdown the
modem much quicker compared to using a power pulse which saves power.

Signed-off-by: Niklas Gürtler <niklas.guertler@e-obs.de>
2024-10-17 09:46:09 +02:00
Robert Lubos
c4803752a8 net: Deprecate CONFIG_NET_SOCKETS_POLL_MAX
CONFIG_ZVFS_POLL_MAX is now used to control the maximum number of poll()
entires. Thereby, CONFIG_NET_SOCKETS_POLL_MAX is redundant and shall
be deprecated.

Modify the defaults for NET_SOCKETS_POLL_MAX and ZVS_POLL_MAX so that
the deprecation actually makes sense instead of symbol removal. In case
the application still sets the old config, it will modify the
ZVS_POLL_MAX default.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-10-14 13:01:51 +02:00
Henrik Brix Andersen
159f7dbbb1 lib: net_buf: rename header file from zephyr/net/buf.h to zephyr/net_buf.h
Move the network buffer header file from zephyr/net/buf.h to
zephyr/net_buf.h as the implementation now lives outside of the networking
subsystem.

Add (deprecated) zephyr/net/buf.h header to maintain compatibility with old
file path.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2024-09-07 11:19:05 -05:00
Emil Lindqvist
5520486e38 modem_cellular: adjust CMUX max frame size for LARA-R6
It has been observed that using a CMUX max frame size of 127
causes FCS errors; smaller or larger works. This commit sets the max
frame size to the modem's default value.

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2024-09-05 16:58:44 -04:00
Emil Lindqvist
621338ec78 modem_cellular: add U-Blox LARA-R6 and implement change of baudrate
U-Blox LARA-R6 was added to modem_cellular, and an additional state
was introduced where the UART baudrate is changed if the modem supports
it

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2024-09-05 16:58:44 -04:00
Ryan Erickson
bbcf23e95e drivers: modem: cellular: hl7800 fix enter cmux
The OK response should be processed before entering CMUX mode.

Use UART ISR mode by default.

Fix warnings and errors produced by the sample.

Signed-off-by: Ryan Erickson <ryan.erickson@ezurio.com>
2024-08-14 15:51:04 -05:00
Pisit Sawangvonganan
e6ca8d9d12 modem: modem_cellular: streamline instance configuration with new macro
Introduced `MODEM_CELLULAR_DEFINE_INSTANCE` macro to streamline
the definition and initialization of modem cellular instances.

This macro enables passing parameters that vary among modems, including:
`power_pulse_duration_ms`, `reset_pulse_duration_ms`, `startup_time_ms`,
`shutdown_time_ms`, `autostarts`, `init_chat_script`, `dial_chat_script`
and `periodic_chat_script`.

This will reduce the number of redundant lines in the code, aiming for
improved maintainability.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-08-14 14:46:00 -04:00
Pisit Sawangvonganan
1f2c898788 modem: modem_cellular: consolidated user pipe data in to single macro
Introduced the `MODEM_CELLULAR_DEFINE_AND_INIT_USER_PIPES` macro to
consolidate multiple user pipe data definitions into a single macro call.

This will reduce the number of redundant lines in the code, aiming for
improved maintainability.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-08-14 14:46:00 -04:00
Ryan Erickson
7bef3fd8af modem: hl7800: set RX socket remote address
Set the remote address of received sockets.
This is necessary for services that rely on the remote address.
DNS relies on the remote address to be set properly.

Signed-off-by: Ryan Erickson <ryan.erickson@ezurio.com>
2024-07-10 16:16:03 -04:00