Commit graph

284 commits

Author SHA1 Message Date
Xavier Chapron f83bb02cbf drivers: modem: sara-r4: Replace snprintf calls by snprintk
Snprintf calls should be avoid when not necessary, instead snprintk
should be used as it offers the same functionnalities at a lower cost
in flash.

Signed-off-by: Xavier Chapron <xavier.chapron@stimio.fr>
2021-09-16 09:33:28 -04:00
Yong Cong Sin 495f6b7ccc drivers: modem: bg9x: Fix unused configs
Fix Kconfig so that unused configs won't be compiled.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-15 11:30:03 -04:00
Yong Cong Sin 293af9e823 drivers: modem: gsm_ppp: Fix ppp_dev
ppp_dev should be pointing to the net/ppp driver.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-08 10:49:45 -04:00
Ryan Erickson ef322d9e16 drivers: modem: hl7800 Add Site Survey
Add API to determine nearby cell towers and their signal
strength.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-09-01 12:33:29 -04:00
Ryan Erickson aba8a21001 drivers: modem: hl7800: Add Position over LTE (PoLTE)
Position over LTE (PoLTE) can be used to locate a device as
an alternative to GNSS.
Increase RX thread stack size for PoLTE processing.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-09-01 09:33:46 -04:00
Ryan Erickson f094346e18 drivers: modem: hl7800: Add GNSS support
Add API to use GNSS on the HL7800 modem.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-09-01 09:33:46 -04:00
Ryan Erickson e29dbf5d04 drivers: modem: hl7800: Add airplane mode
Add API to set HL7800 to airplane mode.
Also add option to boot into airplane mode.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-09-01 09:33:46 -04:00
Ryan Erickson 11e992099b drivers: modem: hl7800: Add delayed start
Allow application control for starting modem driver.
This allows network attach to be randomized.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-09-01 09:33:46 -04:00
Ryan Erickson 7cfedb915b drivers: modem: hl7800: fix COPS handler
Add support for handling the +COPS=? response
to the +COPS command handler.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-09-01 08:37:49 -04:00
Ryan Erickson 1c14a4b1ba modem: hl7800: reconfig IP connection on startup
For low power operation, set the IP connection reconfig
flag when receiving a startup report.
This will ensure the GPRS connection is reconfigured
before any socket operations take place.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-08-31 19:27:23 -04:00
Ryan Erickson ac751b7bcc drivers: modem: hl7800: Query IMSI
Add API to query SIM card IMSI.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-08-31 19:25:13 -04:00
Ryan Erickson d83aaef031 drivers: modem: hl7800: Add retries to get IP address info
Allow command retries when querying IP address info.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-08-31 17:34:53 -04:00
Yong Cong Sin 9d2f8a1124 drivers: modem: gsm_ppp: Use DTS
Convert the gsm_ppp driver to use DTS.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-08-31 17:33:34 -04:00
Ryan Erickson 61ef41fc24 drivers: modem: hl7800: Add query carrier config
Add API to query the carrier config of the HL7800.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-08-31 17:30:46 -04:00
Andrew Hedin 6fb6533a48 drivers: modem: hl7800: Fix generation of FOTA complete event
FOTA complete event is now generated and can be used by application.

Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
2021-08-31 17:30:15 -04:00
Andrew Hedin fd864c61bb drivers: modem: hl7800: Allow operation without a SIM card
Allow the driver to run if a SIM card is not present.
This allows public HL7800 APIs like firmware updates
to be used even if no network is available.
Remove duplicate query ICCID command.

Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
2021-08-31 16:29:31 -04:00
Ryan Erickson 2e045a0ed6 drivers: modem: hl7800: null terminate DNS server list
bugfix: NULL termination is required by
dns_resolve_reconfigure API so null terminate the DNS
server list.
Fix checkpatch warning.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-08-20 14:10:22 -05:00
Ryan Erickson 8d6832b256 drivers: modem: hl7800: socket RX could drop data
net_buf_skipcrlf() will remove all \r\n characters from the buffer.
If the data after CONNECT\r\n contained \r or \n it would
be removed, resulting in dropped data.
Fix this to only remove two bytes to ensure data is not dropped.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-08-20 06:33:31 -04:00
Ryan Erickson 6ef958c2e1 drivers: modem: hl7800: keep socket data if EOF not found
Change socket RX trailer (EOF) missing to warning and
keep socket RX data instead of discarding.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-08-20 06:33:31 -04:00
Martí Bolívar 3910c35193 dts: fix u-blox sara r4 compatible
It should be "u-blox,sara-r4", because the vendor prefix for this
company is "u-blox", not "ublox".

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-17 17:51:57 -04:00
Daniel Leung 0f0c17880e drivers: modem: build as static library
Instead of putting object files inside libzephyr.a,
simply build a separate static library as most other
driver types are doing this already.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-17 06:06:03 -04:00
Gerard Marull-Paretas 6d273f49bd pm: fix incorrect usages of PM_DEVICE_STATE_OFF
According to the documentation the OFF state has to be used when the
devices is fully turned off, ie, power removed. Most drivers were using
a sort of fall-through for all non-active states, leading to behaviors
not following the specifications.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas d41dadc569 pm: rename PM_DEVICE_STATE_SUSPEND to PM_DEVICE_STATE_SUSPENDED
The verb tense for the suspended state was not consistent with other
states. The likely reason: state was being used as a command/action.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 56a35e5682 pm: converge to suspend state for low power modes
The difference between low power and suspend states is a thin blur line
that is is not clear and most drivers have used indistinctly. This patch
converges to the usage of the suspend state for low power, since
contrary to the low power state, it is used by both system and runtime
device PM. The low power state is still kept, but its future is unclear
and needs some discussion.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Kumar Gala a1a895e331 drivers: modem: Fix compiler warning
When building tests/drivers/build_all/modem on native_posix_64 we get:

	modem_cmd_handler.c:545:9: error: ret may be used
	uninitialized in this function
	[-Werror=maybe-uninitialized]

Fix by adding simple initialization of ret = 0 at start of function.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-08-02 11:32:02 -05:00
Marcin Niestroj 1a4cb7e0e3 drivers: modem: add modem_cmd_send_ext()
There are currently modem_cmd_send() and modem_cmd_send_nolock()
functions, each with slightly different behavior regarding acquiring (or
not) sem_tx_lock. Introduce a generic function that will allow caller to
select behavior using flags.

While at it, add possibility to disable setting and unsetting command
handlers. This will be useful in situations when there are multiple
replies expected one after the other coming as a response to single
command. This is the case for example with ESP-AT driver, which expects
following data as response to AT+CIPSEND command:

  OK
  >

where 'OK' is handled by static CMD_RESP (so releasing response
semaphore right away), while '>' is handled by dynamic
CMD_HANDLER (which is releasing another semaphore). Keeping command
handlers in place allows to receive '>' without race condition because
of small period of time where command handlers are not set.

Convert modem_cmd_send_nolock() and modem_cmd_send() to static inline
functions, as they are just a specific invocation of
modem_cmd_send_ext() function.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-07-28 21:08:51 -04:00
Marcin Niestroj 26bd4fb45e drivers: modem: operate on device pointers instead of names
So far modem API used UART device names / labels. Change API to operate
on device pointers instead, so that we stop using device_get_binding()
in modem core and in some DT compatible modem drivers.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2021-07-15 11:48:00 -04:00
Tahir Akram 608ad430f3 drivers: modem: RSSI measurement for PPP link
This PR addresses radio signal stength measurement during
and before PPP session. The PR provides provides facility
of readout for both +CSQ and +CESQ versions depending
upon the modems. This PR follows the idea of rssi readout
of PR#35496. Additionally, reliable Cell info update
is also ensured.

Signed-off-by: Tahir Akram <mtahirbutt@hotmail.com>
2021-07-14 21:06:30 -04:00
Gerard Marull-Paretas 26ad8376bd pm: remove callback from control function
The callback is not used anymore, so just delete it from the pm_control
callback signature.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-13 09:36:45 -04:00
Jukka Rissanen 2758aeedbc drivers: modem: gsm: Ignore semaphore take return value
We do not need the return value of k_sem_take() so ignore it.

Coverity-CID: 236602
Fixes #36313

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-06-16 22:12:40 -04:00
Hans Wilmers 0a345df211 drivers: modem: ublox-sara-r4: query for operator and cell info
Query the numerical network operator id, location area code (LAC)
and cell id. Following AT commands are used:

  AT+COPS?
  AT+CEREG?

Functionality is enabled by CONFIG_MODEM_CELL_INFO=y.

Tested with uBlox SARA-R410M-02B.

Signed-off-by: Hans Wilmers <hans@wilmers.no>
2021-06-14 15:19:13 +02:00
Hans Wilmers 09fd688d23 drivers: modem: gsm_ppp: query for operator and cell info
Query the numerical network operator id, location area code (LAC)
and cell id. Following AT commands are used:

  AT+COPS?
  AT+CEREG?

Functionality is enabled by CONFIG_MODEM_CELL_INFO=y.

Tested with uBlox SARA-R410M-02B.

Signed-off-by: Hans Wilmers <hans@wilmers.no>
2021-06-14 15:19:13 +02:00
Hans Wilmers 120b2165ec drivers: modem: implement operator id and cell info
Implement numerical network operator id, location area code (LAC)
and cell id in modem context and modem shell.

Please note that the functionality to query these values must be
implemented in the modem driver.

Signed-off-by: Hans Wilmers <hans@wilmers.no>
2021-06-14 15:19:13 +02:00
Emil Lindqvist 9b7d9d43b8 drivers: modem: ublox-sara-r4: implement F_GETFL in ioctl
Zephyr sees fnctl as an alias of ioctl, and so the F_GETFL
request should be handled here as well.

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2021-05-27 15:44:03 +02:00
Ryan Erickson a1498f3e40 drivers: modem: hl7800: +KSRAT dependent on firmware version
The reboot option of the +KSRAT command is only
supported by newer firmware.
Add a check to determine what version of the command
to use when setting the RAT.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-05-19 08:09:37 -05:00
Ryan Erickson 62ccddb035 drivers: modem: hl7800: fix update RAT
The default behavior of the +KSRAT= command has
changed to not reboot the HL7800.
Adjust the command so the reboot takes place properly.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-05-14 08:25:49 -05:00
Flavio Ceolin 0c607adb63 pm: device: Align state names with system states
Change device pm states to the same pattern used by system power
management.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 18:35:12 -04:00
Kumar Gala 27e33e25c9 drivers: modem: Fix build errors on 64-bit platforms
If the modem drivers are built on a 64-bit platform we get errors with
the logging code due to use of size_t.  Update to use %zX to handle this
correctly between 32-bit and 64-bit platforms.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-05-07 16:08:09 -05:00
Emil Lindqvist f3f8af4cc2 drivers: modem: ublox-sara-r4: make reset pin optional
Remove reset pin requirement from devicetree as this
is not required for modem functionality, and is not
used in the driver anyways.

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2021-05-06 09:44:19 -05:00
Gerard Marull-Paretas 7988ab4a26 pm: rename device_set/get_power_state to pm_device_set/get
Make name consistent with other device PM APIs.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas 2c7b763e47 pm: replace DEVICE_PM_* states with PM_DEVICE_*
Prefix device PM states with PM.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas 3863be02a5 drivers: replace power/power.h with pm/device.h
Drivers need access to the device PM API, so just include pm/device.h.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Ryan Erickson 5af20cd258 drivers: modem: hl7800: fix fault with IPv6 address
If modem receives an IPv6 address, buffer overrun
would occur. Fix this by checking string length to
ensure what type of IP address needs to be parsed.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-05-05 13:39:50 -05:00
Ryan Erickson c9b8f89b80 drivers: modem: hl7800: fix potential buffer overrrun
Correct destination buffer size when processing
RX messages from modem.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-05-05 13:39:50 -05:00
Marcin Niestroj ba391b80b0 drivers: modem: hl7800: use dns_resolve_reconfigure() API
Use recently introduced API, which takes care of gracefully closing any
pending DNS requests and replacing existing DNS server list with new
one.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-04-29 08:00:09 -04:00
Gerard Marull-Paretas 126e1eead8 drivers: modem: remove usage of device_pm_control_nop
device_pm_control_nop is now deprecated in favour of NULL.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 12:25:24 -04:00
Yong Cong Sin 084a8b6bf4 drivers: modem: BG9X wait for RDY instead of polling AT.
BG9X wait for RDY instead of polling AT.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-04-21 17:04:40 +03:00
Johann Tael 5425700e74 drivers: modem: ublox-sara-r4: add TLS offload support
Currently it's able to connect to google iot. All other use cases are
untested.

Signed-off-by: Johann Tael <jntael@gmail.com>
2021-04-21 11:13:34 +03:00
Peter Bigot cc090726e6 drivers: modem: rote conversion of k_work API
Replace all existing deprecated API with the recommended alternative.

Be aware that this does not address architectural errors in the use
of the work API.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-14 07:07:40 -04:00
Benjamin Lindqvist 28ac1f70bf drivers: modem: gsm_ppp: proper attach retry
In a previous commit, a check was added to ensure modem was properly
attached to packet service before initializing PPP. Failure to perform
this check can lead to the dreaded 'NO CARRIER' issue.

While this is a nice idea, the implementation was lacking because when
the check failed, the entire modem initialization procedure was
restarted from square one. For modems/bearers that were slow to attach,
this is potentially disastrous. The proper solution is to loop only the
'AT+CGATT?' part until it succeeds, or fails N times.

This commit implements this looping behavior (using the work queue).

Signed-off-by: Benjamin Lindqvist <benjamin.lindqvist@endian.se>
2021-04-06 15:37:11 +03:00