Commit graph

529 commits

Author SHA1 Message Date
Georgij Cernysiov 23b64b0d35 drivers: modem: receiver: correct device bind error type
Log possible uart device binding error and change
the error type to a more correct one.

Signed-off-by: Georgij Cernysiov <g.cernysiov@elco-automation.de>
2019-03-01 09:46:48 +01:00
Tomasz Bursztyka 854045c14d drivers/modem: Switch wncm14a2a driver to new net_pkt API
It is a bit awkward that ip/proto headers have to be rebuilt (with fake
data in it though). Let's see in future if that's really needed,
offload device handles already ip/proto headers by themselves so we
should not care.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-21 09:30:57 -05:00
Michael Scott aa226eb528 drivers: modem: wncm14a2a: stop reading when bytes read is 0
Let's also check for bytes_read == 0 after calling mdm_receiver_recv()
and if so, break the loop so we don't endlessly loop.

Signed-off-by: Michael Scott <mike@foundries.io>
2019-02-20 10:46:54 -06:00
Krzysztof Chruscinski 3605e48c44 shell: Modify subcommands to use SHELL_STATIC_SUBCMD_SET_CREATE
It is planned to deprecate SHELL_CREATE_STATIC_SUBCMD_SET macro
which is replaced by SHELL_STATIC_SUBCMD_SET_CREATE.

Additionally, removed irrelevant comments about alphabetical
ordering which is no longer needed.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-02-20 07:31:35 -05:00
Kumar Gala b0e7d312db modem: Fix LOG Kconfig typo
LOG_LEVEL should be set to CONFIG_MODEM_LOG_LEVEL not
CONFIG_LOG_MODEM_LEVEL.  In cleaning this up use
LOG_MODULE_REGISTER(x,y) form to reduce 3 lines to 1.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-12 07:50:06 -05:00
Tomasz Bursztyka 4b78a251d7 net/context: Make recv_cb providing the ip and protocol headers
If status is 0, both ip_hdr and proto_hdr will own a pointer to the
relevant IP and Protocol headers. In order to know which of ipv4/ipv6
and udp/tcp one will need to use respectively net_pkt_family(pkt) and
net_context_get_ip_proto(context).

Having access to those headers directly, many callbacks will not need
to parse the packet again no get the src/dst addresses or the src/dst
ports. This will be change after this commit.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Michael Scott 1e0a7116bd drivers: modem: wncm14a2a: allow more time for getting IMEI data
Every now and then the 100ms delay for collecting IMEI data from the
modem, wasn't long enough and this presents a bad user experience.

Let's set it to 500ms which seems to be working all the time.

Signed-off-by: Michael Scott <mike@foundries.io>
2019-01-30 10:25:52 -06:00
Michael Scott 4fcab1ef1a drivers: modem: wncm14a2a: wait for modem init
During development of the WNC-M14A2A modem driver, I felt like the
initialization took too long to make the user wait.  However, due
to the addition of other drivers such as OpenThread where delays
during startup are noticable, the modem startup time isn't so bad.

Let's remove the delay work which allows Zephyr to startup before
the modem is fully initialized.

NOTE: This also fixes a long standing bug where samples using the
modem would never know when it was ready (without waiting for the
interface up event).  This change makes it always ready once the
sample starts.

Signed-off-by: Michael Scott <mike@foundries.io>
2019-01-30 10:25:52 -06:00
Kumar Gala 3e8fc3c0c1 modem: wncm14a2a: Convert to new DT_<COMPAT>_<INSTANCE> defines
Convert wncm14a2a driver to use new defines so we can remove the
dts_fixup.h code for it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-01-29 14:21:56 -06:00
Georgij Cernysiov bed7fb3df0 drivers: modem: modem receiver dependencies adaptation
Moved UART interrupt dependencies from concrete driver to
the modem receiver as it uses UART interrupt functions within.
This allows developing other UART interrupt based modems without
the need to depend on the aforementioned features explicitly.

Signed-off-by: Georgij Cernysiov <g.cernysiov@elco-automation.de>
2019-01-25 17:36:59 -05:00
Paul Sokolovsky c885cb533e net: buf: linearize: Get rid of useless memset()
net_buf_linearize() used to clear the contents of output buffer,
just to fill it with data as the next step. The only effect that
would have is if less data was written to the output buffer. But
it's not reliable for a caller to rely on net_buf_linearize() for
that, instead callers should take care to handle any conditions
like that themselves. For example, a caller which wants to process
the data as zero-terminated string, must reserve a byte for it
in the output buffer explicitly (and set it to zero).

The only in-tree user which relied on clearing output buffer was
wncm14a2a.c. But either had buffer sizes calculated very precisely
to always accommodate extra trailing zero byte (without providing
code comments about this), or arguably could suffer from buffer
overruns (at least if data received from a modem was invalid and
filled up all destination buffer, leaving no space for trailing
zero).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-12 15:24:29 -06:00
Patrik Flykt 8ff96b5a57 drivers: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Tomasz Bursztyka ee9dedd5a7 net/iface: Finally remove the send function from net_if_api
And apply that to modem driver setting that pointer to NULL.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08:00
Michael Scott 0abd92266a drivers: modem: wncm14a2a: correct comment in on_cmd_sockdataind()
The comment was incorrect explaining why we were sending an
AT-command without waiting for a response (via a K_NO_WAIT timeout).

Let's correct the comment and avoid confusion.

Signed-off-by: Michael Scott <mike@foundries.io>
2018-11-28 15:34:19 -08:00
Michael Scott e8a690ff70 drivers: modem: wncm14a2a: remove socket_reading logic
Remove overly complicated logic to skip incoming data if we were
still waiting on a previous set of data to be read.

This fixes a bug where an error during data receive could end up
with the modem ignoring all incoming data.

Signed-off-by: Michael Scott <mike@foundries.io>
2018-11-28 15:34:19 -08:00
Michael Scott 39843617cb drivers: modem: WNCM14A2A select UART_INTERRUPT_DRIVEN
Modem driver for WNCM14A2A was erroneously leaving the
selection of UART_INTERRUPT_DRIVEN up to CONSOLE_HANDLER.
Now, with the move to the new SHELL backend, this is no
longer happening.

Let's select it from the modem driver, instead of depending
on it.

Let's also add a dependency on SERIAL_SUPPORT_INTERRUPT
which the serial drivers enable to let us know
UART_INTERRUPT_DRIVEN is available.

Signed-off-by: Michael Scott <mike@foundries.io>
2018-11-21 04:09:23 -06:00
Andrzej Głąbek 20202902f2 dts_fixups: Use DT_ prefix in all defined labels not related to Kconfig
These changes were obtained by running a script  created by
Ulf Magnusson <Ulf.Magnusson@nordicsemi.no> for the following
specification:

1. Read the contents of all dts_fixup.h files in Zephyr
2. Check the left-hand side of the #define macros (i.e. the X in
   #define X Y)
3. Check if that name is also the name of a Kconfig option
   3.a If it is, then do nothing
   3.b If it is not, then replace CONFIG_ with DT_ or add DT_ if it
       has neither of these two prefixes
4. Replace the use of the changed #define in the code itself
   (.c, .h, .ld)

Additionally, some tweaks had to be added to this script to catch some
of the macros used in the code in a parameterized form, e.g.:
- CONFIG_GPIO_STM32_GPIO##__SUFFIX##_BASE_ADDRESS
- CONFIG_UART_##idx##_TX_PIN
- I2C_SBCON_##_num##_BASE_ADDR
and to prevent adding DT_ prefix to the following symbols:
- FLASH_START
- FLASH_SIZE
- SRAM_START
- SRAM_SIZE
- _ROM_ADDR
- _ROM_SIZE
- _RAM_ADDR
- _RAM_SIZE
which are surprisingly also defined in some dts_fixup.h files.

Finally, some manual corrections had to be done as well:
- name##_IRQ -> DT_##name##_IRQ in uart_stm32.c

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-11-13 10:44:42 -06:00
Michael Scott 25d5736e69 drivers: modem: wncm14a2a: fix void ptr math warning
I have no idea what I was thinking when I wrote this.
But, it's an easy fix to remove the void * entirely.

Signed-off-by: Michael Scott <mike@foundries.io>
2018-10-29 09:14:26 -04:00
Michael Scott 38bdc9f532 drivers: modem: migrate modem shell to new shell API
Convert modem-shell to use the new shell API.

Signed-off-by: Michael Scott <mike@foundries.io>
2018-10-29 08:40:40 -04:00
Anas Nashif 5c76143bcd drivers: modem: register logging module
Add missing registration for modem driver.

Fixes #10518

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-15 10:48:11 -04:00
Anas Nashif ecc050e69e drivers: modem: move to new logger
Move driver to new logger.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-10 10:22:01 -04:00
Krzysztof Chruscinski 527256501f shell: Rename shell to legacy_shell
New shell implementation is on the way. For now old one and all
references are kept to be gradually replaced by new shell.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-09-19 09:30:29 -04:00
Flavio Ceolin da49f2e440 coccicnelle: Ignore return of memset
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.

The only directory excluded directory was ext/* since it contains
only imported code.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-14 16:55:37 -04:00
Mieszko Mierunski 4f6aac1a67 dts: nrf5: Changed GPIO and GPIOTE define names
Changed names using nrf5 to nrf for consistency with other drivers.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2018-08-17 07:29:14 -07:00
Michael Scott 65af15bcc2 boards: arm: nrf52840_pca10056: add settings for WNC-M14A2A modem
These settings enable use of the WNC-M14A2A LTE-M modem as the default
network interface for the nRF52840-DK board (nrf52840_pca10056).

They include the following settings when MODEM_WNCM14A2A is selected:
- UARTE1 pin setup
- DTS / DTS fixup additions for WNC-M14A2A
- Kconfig settings for modem driver

Signed-off-by: Michael Scott <mike@foundries.io>
2018-08-06 10:43:46 +03:00
Michael Scott 01745c3844 boards: arm: frdm_k64f: add settings to use WNC-M14A2A LTE-M modem
These settings enable use of the WNC-M14A2A LTE-M modem as the default
network interface instead of ethernet.

They include the following settings when MODEM_WNCM14A2A is selected:
- UART 2 setup
- Avoid ETH_0 setup due to pin conflicts
- DTS addition for WNC-M14A2A
- Kconfig settings for modem driver

Signed-off-by: Michael Scott <mike@foundries.io>
2018-08-06 10:43:46 +03:00
Michael Scott 8b3d4ab6b8 drivers: modem: add modem shell extension
Add a set of modem shell commands to support modem development.

Start with:
modem list: Lists all registered modems and related information
modem send <modem receiver index> <command>: Send command to modem

Signed-off-by: Michael Scott <mike@foundries.io>
2018-08-06 10:43:46 +03:00
Michael Scott 042d79e86c drivers: modem: add Wistron WNC-M14A2A LTE-M Modem Driver
The WNC-M14A2A (LTE / LTE-M) modem is presented as an Arduino-
compatible shield via AT&T's IoT Starter Kit v1.0.  It was
originally intended to work with the FRDM-K64F board, but
in theory as long as the right pins are configured it can
work with any board that supports Arduino-compatible headers.

The driver utilizes the CONFIG_NET_OFFLOAD setting to avoid the
normal handling of IP packets, and instead uses a socket-like
UART interface to handle incoming and outgoing data.

Signed-off-by: Michael Scott <mike@foundries.io>
2018-08-06 10:43:46 +03:00
Michael Scott 9182d2e59c drivers: modem: add modem receiver (tty) driver
Modem drivers need a fast buffer-based receiver for passing data
back and forth from the UART to the driver.  This provides an
efficient configuarable driver which merely sends and receives
but doesn't process the data, that's left up to the modem driver.

Signed-off-by: Michael Scott <mike@foundries.io>
2018-08-06 10:43:46 +03:00