Convert gsm_finalize_connection into a work so that the caller
work won't have to run again when gsm_finalize_connection
reschedule gsm_configure_work on error.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Currently the mux_setup set the state to the next one after
uart_mux_alloc is successful even if the mux_setup fails which
can be a problem.
Set the state after both mux_setup & uart_mux_alloc are
successful.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Remove redundant mux_enabled checks, the code execution will
not reach here if mux_enabled is false in the first place.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Customize the error logs in each connection finalization steps
so that it is easier to trace the error.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
The gsm_configure will return if it fails to perform mux_enable,
therefore the disable part of the log will not be printed.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
The `setup_done` and `mux_setup_done` aren't being used
anywhere in the driver, therefore should be removed.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Initializing rssi_work_handle on gsm_start would (re)init it
unnecessarily everytime the gsm_start is invoked, we only need
to initialize it once in the gsm_init.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Use CTS input to monitor HL7800 sleep state
when in SLEEP mode.
When CTS is high, shutdown the UART to
save power.
Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
The +CGATT: is followed by 'OK' or 'ERROR', so its handler
should not set error code and give sem_response.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Add a name for the choice of gsm modem so that it can be
default to a certain type in board's Kconfig.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
When sleep modes are used, configure sockets
to restore on boot. Letting the HL7800 manage
this means the driver does not have to do it.
Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
The driver enabled extended error code (AT+CMEE=1) during
setup but is missing a handler for the +CME ERROR, fix that.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Waits until the network interface goes down before switching the
GSM_MUX. It uses the NET_MGMT_EVENT to signal a semaphore to
contiue when closed. This allows for the LCP state machine to
properly terminate. When skipping this wait, the second time
connecting, the connection might fail.
Tested on a real modem.
Fixes GSM PPP behavior in combination with: #41802
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Only TCP sockets should send a NULL packet
if the server closes the connection or there
is a socket error.
UDP sockets do not need to do this because
they are connectionless.
Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
Fix hard fault due to NULL being passed as argument into
rssi_handler, which now derives the gsm_modem struct pointer from
the argument.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
gsm_ppp_stop should cancel possible running work items.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Signed-off-by: Wouter Cappelle <wouter.cappelle@crodeon.com>
The 'work' argument of a delayable work's handler should be
converted to delayable work before passing into the CONTAINER_OF
macro.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
The driver performs AT commands configurations using the
system workqueue, this can delay the workqueue by up to 6
seconds to wait for the modem replies, which isn't ideal.
This PR creates a dedicated workqueue for the gsm, and
provides a helper function to reschedule work items to the
gsm workqueue.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Implemented driver for the simcom sim7080 modem.
This driver features Socket offloading, TCP, UDP, DNS,
SMS, GPS and FTP.
Signed-off-by: Lukas Gehreke <lk.gehreke@gmail.com>
The device PM subsystem _depends_ on device, not vice-versa. Devices
only hold a reference to struct pm_device now, and initialize this
reference with the value provided in Z_DEVICE_DEFINE. This requirement
can be solved with a forward struct declaration, meaning there is no
need to include device PM headers.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Since drivers implement a callback based on action and not the state,
we should be using the API based on the action instead of the one based
on the state.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The modem sockets poll implementation does not allow
a combination of poll on modem sockets and on other sockets
like eventfd. This blocks trivial application signalling. Current
users are using a poll timeout, which needs to check if other
work needs to be done in the thread (eg: lwm2m engine).
To allow proper signalling with eventfd, the non offload poll
methods needs to work for the modem sockets.
This commit is implementing this for POLLIN.
Signed-off-by: Wouter Cappelle <wouter.cappelle@crodeon.com>
The previous bf68b67 commit incorrectly passes minfo.mdm_rssi
value to the modem context data_rssi member during the driver
initialization which causes the `modem info` shell command
to return 0 as RSSI value. Fix that by changing data_rssi
modem ctx member to a pointer that is assigned to the RSSI
variable stored within the modem driver context structure.
Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
CONFIG_UART_MUX_DEVICE_NAME is used as a prefix for the uart muxes
name. Pointer comparison will always return false
Fix#39774
Signed-off-by: Guillaume Lager <g.lager@innoseis.com>
drivers: modem: gsm: Quectel EC21 and BG9x act as a gsm modem without
problem, but COPS commands can returns just one value with 'mode'.
Format and oper are not mandatory. This modification reads 'mode'.
Also a modification on modem_cmd_read_cops_cmd is needed.
Signed-off-by: Jair Jack <jack@icatorze.com.br>
Add RSSI member into gsm_ppp_modem_info structure in order to
get that information using the gsm_ppp_modem_info function.
Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
Make modem_info structure public in order to allow the user
to get modem information using gsm_ppp_modem_info function.
Move modem info query commands into separate function
that's called only once during gsm configuring because
there is no necessity to re-querying modem since
they should not change.
Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
With the introduction of `EXPERIMENTAL` and `WARN_EXPERIMENTAL` in
Zephyr all drivers settings having `[EXPERIMENTAL]` in their
prompt has has been updated to include `select EXPERIMENTAL` so that
developers can enable warnings when experimental features are enabled.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The current modem sockets poll implementation has 2 limitations
as of today:
- not following posix spec wrt timeout of -1 (should be forever,
but as today it's was returning immediately)
- not able to poll from multiple threads on different sockets
on the same modem.
This pull request should implement these limitations.
Signed-off-by: Wouter Cappelle <wouter.cappelle@crodeon.com>
When creating a socket, be sure to check the address
family and set the correct address family option in
the AT command.
Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
Allow the user to register function callbacks that
are executed during gsm modem configuring and stopping.
Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
Changes the modem_context_sprint_ip addr to write into a provided
buffer. This approach fixes a referencing to a non existing stack
variable, without using a lot of stack space.
Tested using the by building all used modems and tested on HW using
IPv4.
Fixes: #38459
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
When creating a socket, all of the registered socket implementation are
processed in a sequence, allowing to find appropriate socket
implementation for specified family/type/protocol. So far however,
the order of processing was not clearly defined, leaving ambiguity if
multiple implmentations supported the same set of parameters.
Fix this, by registering socket priority along with implementation. This
makes the processing order of particular socket implementations
explicit, giving more flexibility to the user, for example when it's
neeed to prioritze one implementation over another if they support the
same set of parameters.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fixes: #38403
Removing unneeded `imply GPIO` and `CONFIG_GPIO=y` occurrences where no
files are added to the gpio zephyr library.
Also removed `CONFIG_GPIO=y` occurences where this is handled by
defconfigs for the soc or board.
Selection of GPIO without selecting any drivers results in the warning:
> No SOURCES given to Zephyr library: drivers__gpio
>
> Excluding target from build.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The interrupt config flags for an IO should be separate
from the standard IO configs because the interrupt config
is a separate API.
Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
Add support for Quectel modem in gsm_ppp modem driver.
The CMUX cmd is based on MUX application notes v1.0(2020-09-22)
for BG95, BG77 and BG600L. Tested and working on EC21e.
As the gsm_ppp doesn't do power control, it is required to power
on the modem manually in the application.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Ensure the GPRS connection APN settings match the PDP
context. This it best to ensure proper IP connectivity.
Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>