By using the Zephyr-native zsock_ family of types and functions, these
drivers will be decoupled from NET_SOCKETS_POSIX_NAMES.
Signed-off-by: Adam Porter <porter.adam@gmail.com>
Used for permission validation when accessing the associated file
descriptors from user mode.
There often get defined in implementation code, expand the search
to look in drivers/ and subsys/net/.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
The implementation of offload_getaddrinfo in this driver failed
when the node it was called with was an IP address. This condition
was never detected, and as a consequence a DNS query was done on
the IP address instead of returning it directly.
Also, the port was set first after running the DNS query.
As a consequence, if the IP address would have been returned directly,
this would have been done without a port been set.
Both errors are fixed in this patch.
Signed-off-by: Hans Wilmers <hans@wilmers.no>
During communication initialisation, the IMSI of the inserted SIM
card is evaluated to determine the APN. This is done by comparing
the first 5 characters of the IMSI to a list of known providers.
The list can be given in Kconfig.
To enable this functionality, set following bool in Kconfig:
MODEM_UBLOX_SARA_AUTODETECT_APN
To set a list of providers, set following string:
MODEM_UBLOX_SARA_AUTODETECT_APN_PROFILES
If the provider can not be found in the list, the APN given in
following entry is used as a fallback:
MODEM_UBLOX_SARA_R4_APN
Signed-off-by: Hans Wilmers <hans@wilmers.no>
The modem type (Sara R410 or Sara U201) is detected automatically after
hardware initialisation of the modem. Further initialisation and
functionality is then chosen depending on the detected modem type.
To enable this functionality, set following bool in Kconfig:
MODEM_UBLOX_SARA_AUTODETECT_VARIANT
Signed-off-by: Hans Wilmers <hans@wilmers.no>
This fixes some cases where an integer timeout received as a parameter
was not converted to a timeout before being used in standard API.
Changes to the POSIX library were not included as that's being
reworked in a separate PR.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
TCP contexts are referenced twice,
once for the app and once for the stack.
Since TCP stack is not used for offload,
unref a second time to release the context.
Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
Following issue is addressed in this bugfix:
When using offloaded sockets with modem ublox_sara_r4,
the socket is only closed if it is in connected state
at the time of the function call. When using UDP sockets,
this leads to a socket never being closed.
Signed-off-by: Hans Wilmers <hans@wilmers.no>
Calculation of RSSI was done incorrectly for Sara U201.
When evaluating +CSQ command responses, the RSSI can be calculated
from the first value, which is <signal_strength>. Instead, the
RSSI was calculated from the second value, which is <qual>.
With the subsequent mapping to RSSI, this results in a wrong
value for RSSI.
This is now corrected by using value <signal_strength> to calculate
the RSSI.
Tested using Sara U201.
Signed-off-by: Hans Wilmers <hans@wilmers.no>
This commit references modem_pin() and modem_shell()
modem_pin(): use new gpio api
The existing pin driver does not respect gpio
configuration in device tree for active high / low
This commit allows for the device tree to determine the
active logic level.
modem_shell(): use correct string length
The ms_send macro uses iface.write() to send a string.
iface.write() requires the length of the string not the
size of the string.
This commit corrects the string length.
drivers: ublox-sara-r4: fix vint polling
This eliminates the implication that the enable and disable values can
be something other than 1 and 0, and fixes the code so it won't enter
an infinite loop if the GPIO read returns an error.
Signed-off-by: Steven Slupsky <sslupsky@gmail.com>
This is needed if muxing is enabled in which case we must
change the UART to muxing UART after the AT+CMUX command
has succeed.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Instead of using physical UART to connection to the modem, use
the GSM 07.10 muxing protocol and UART mux driver to create
virtual channels to the modem. This will allow simultaneous
PPP, AT and other type connections to the modem.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The net_buf subsystem is now fully compatible with the new timeout
API, so move the selection of the legacy API to those specific
subsystems that use net_buf and still need converting.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Run the int_literal_to_timeout Coccinelle script to fix places where
it is clear that an integer duration is being passed where a timeout
value is required.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
By changing the various *NET_DEVICE* macros. It is up to the device
drivers to either set a proper PM function or, if not supported or PM
disabled, to use device_pm_control_nop relevantly.
All existing macro calls are updated. Since no PM support was added so
far, device_pm_control_nop is used as the default everywhere.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Source and destination ports should be set properly
when assembling the receive socket data.
Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
Some commands need to be processed before a "\r\n" is available and
there might also be commands that have "\r\n" as data but doesn't mean
the end of the command.
To solve this a MODEM_CMD_DIRECT has been added. cmd_handler_process()
will look for matching direct commands before checking if a whole line
is available for matching the normal commands.
A direct command can return either -EAGAIN, meaning that more data is
needed or it will return the number of bytes to skip forward, ie the
length of the command that was handled.
Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
User is currently able to enable verbose packet debugging for
received packets. This commit enables the same for sent packets.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
pin is an unsigned variable so there is no meaning check if it is less
than zero.
CID :208407
CID :208408
CID :208410
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
usage of AT+UPSD command per UBX-17003787(R15) command reference is:
AT+UPSD=<profile_id>, <param_tag>, <param_val>
For AT+UPSD=0, 1, "<value>": we are setting value to MCCMNO, which
is technically incorrect. <param_tag> of 1 means:
1: APN - <param_val> defines the APN text string, e.g.
"apn.provider.com"; the maximum length is 99. The factory-programmed
value is an empty string.
Let's use APN here instead. This fixes a +CME ERROR: 113 when
connecting with U2 modem.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/22689
Signed-off-by: Michael Scott <mike@foundries.io>
Add Kconfig option that allows user to set MCC (Mobile Country
Code). If user does not set it, then automatic operator
registration is used.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Misc fixes / enhancements to the GSM driver:
* set the \r as a line ending character
* make gsm_init() static as there is no need to expose it
* print the gsm context pointer at init
* set buffer allocation timeout to modem context so that it is
not infinite
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Instead of using global static variable "gsm" everywhere,
store the context when calling DEVICE_INIT(). Then in the device
init function get the context from the device struct. This way
it is possible to use the same functions for implementing two
gsm modem instances. Currently this is not fully possible because
the context is not passed via uart_pipe API and modem_cmd
callbacks. So some future work would still be needed.
In practice this commit does not change anything, it just makes
it a little bit easier to have two instance of this modem which
might be quite unlikely case. Anyway, the driver now follows the
same style how some other drivers are done like Ethernet etc.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Now that the u-blox driver can let cmd_handler know that it hasn't
received enough data, let's disable the hex mode for readying
binary data.
On the SARA-R4 this mode limits the receiving MTU to 512 which is
unacceptable.
Signed-off-by: Michael Scott <mike@foundries.io>
Some modem commands can determine if they have enough data pulled from
the modem to continue or not. Let's allow those functions to return
EAGAIN which means there's more data needed from the modem.
Signed-off-by: Michael Scott <mike@foundries.io>
Modem commands are setup with arg_count to denote the number of params
to parse before returning. Let's honor that setting and return once
we've parse them.
This fixes a run-on bug where the parser would find as many of the
parameters via the supplied delimiter as it could.
Signed-off-by: Michael Scott <mike@foundries.io>
The original Ublox SARA-R4 driver was written for the net_context
APIs. As a result many of the return values are not POSIX standard.
Let's go through all of the socket offload functions and make sure
we return standard values (0 or -1) and set errno where appropriate.
Signed-off-by: Michael Scott <mike@foundries.io>
SARA-R4 has a max read limit of 512 when using binary hex formatting.
Otherwise the max read limit is 1024.
Signed-off-by: Michael Scott <mike@foundries.io>
New socket functions were introduced to hide some of the modem_socket
internals:
- modem_socket_next_packet_size()
- modem_socket_wait_data()
- modem_socket_data_ready()
Let's use them.
Signed-off-by: Michael Scott <mike@foundries.io>
Let's use sock->is_connected to check whether we need to clean up
the modem's socket. It may have already been closed via URC.
Signed-off-by: Michael Scott <mike@foundries.io>
SARA-R4 AT command manual states +USOCO has a max timeout of 120s.
Let's use that instead of the default 10s command timeout.
Signed-off-by: Michael Scott <mike@foundries.io>
The SARA R412M requires manual activation of the PDP context. It also
reports RSSI instead of RSRP when on 2G. An off-by-one in the RSRP
calculation was also fixed in this commit.
Signed-off-by: Göran Weinholt <goran.weinholt@endian.se>
The u-blox SARA modems have the ability to output the network status
on a GPIO pin. This can be used to light up a LED when the modem is
connected to the network.
Signed-off-by: Göran Weinholt <goran.weinholt@endian.se>
The U2 modem will sometimes not power off even if we have given it the
signal to do so. We now signal it continually until the modem
indicates that power is off with VINT=0.
Signed-off-by: Göran Weinholt <goran.weinholt@endian.se>