Commit graph

21541 commits

Author SHA1 Message Date
Chih Hung Yu
13b2e5bac4 net: ip: Fix assertion failure when tcp_send_data()
When tcp_send_data() is called to resend data, but there is no data
to resend, zero length packet is allocated and NULL net_buf is passed
to net_buf_frag_insert() in which assertion fails.

Fixes #36578

Signed-off-by: Chih Hung Yu <chyu313@gmail.com>
2021-07-12 20:08:01 -04:00
Vinayak Kariappa Chettimada
9bc9e15852 Bluetooth: Controller: Fix Periodic Sync setup with invalid channels
Fix Periodic Synchronization setup when handling invalid
number of channel count in Periodic Advertising's Sync Info
structure.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-12 17:23:51 +02:00
Vinayak Kariappa Chettimada
40374df24f Bluetooth: Controller: Use macros for SCA and Channel Map access
Use macros to access SCA and Channel Map fields in the Sync
Info structure in advertising PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-12 13:19:46 +02:00
Vinayak Kariappa Chettimada
71c6d11b08 Bluetooth: Controller: Minor fix debug message with channel map mask
Minor fix to channel map mask used in debug message to print
sync info fields.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-12 13:19:46 +02:00
Vinayak Kariappa Chettimada
53cd7f7152 Bluetooth: controller: Refactor sync_info population
Based on review comments, refactor out sync_info population
to be performed by the caller of the function that prepares
the extended advertising PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-12 13:19:46 +02:00
Vinayak Kariappa Chettimada
300f1bb6a0 Bluetooth: controller: Use set/clear to add/remove ACAD
Use the set/clear function to modify the common extended
header format in the PDU to add/remove ACAD.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-12 13:19:46 +02:00
Vinayak Kariappa Chettimada
693ae63145 Bluetooth: controller: Add/Remove ACAD on create/terminate BIG
Added implementation to add/remove ACAD field in the common
extended header format of the periodic advertising PDU on
create/terminate BIG.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-12 13:19:46 +02:00
Vinayak Kariappa Chettimada
f3d9808012 Bluetooth: Controller: Warn when building experimental features
Add CMake warning message when building experimental
features like Advertising Extensions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-10 14:53:26 -04:00
Andrzej Kaczmarek
9db0a18158 Bluetooth: controller: Remove adv_sync_hdr_set_clear
adv_sync_hdr_set_clear was just wrapped by ull_adv_sync_pdu_set_clear
so we can merge both into single function.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-07-10 12:44:33 -04:00
Andrzej Kaczmarek
678ec60f36 Bluetooth: controller: Add helper to update CTEInfo
This adds simple helper to update CTEInfo. It assumes proper periodic
adv PDU as input to simplify code.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-07-10 12:44:33 -04:00
Andrzej Kaczmarek
1ebecdf606 Bluetooth: controller: Add initial support to update AD in chain
This adds some initial support to update AD in chain. We still only
support placing AD in 1st PDU, but this will properly copy any linked
PDUs that may be added due to e.g. CTEInfo present.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-07-10 12:44:33 -04:00
Andrzej Kaczmarek
45ebbbf04b Bluetooth: controller: Add helper to initialize adv PDU from scratch
This adds adv_sync_pdu_init helper which initializes pdu_adv buffer
with contents of AUX_SYNC_IND/AUX_CHAIN_IND PDU. Extended header flags
can be specified to reserve required space for corresponding fields if
necessary.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-07-10 12:44:33 -04:00
Andrzej Kaczmarek
7c81ed71d0 Bluetooth: controller: Enable back-to-back chaining for periodic adv
This enables chaining ota for periodic advertising. AUX_CHAIN_IND PDUs
will be sent automatically if AuxPtr is detected in preceding PDU.
AuxPtr offset is always set to achieve minimal required frame spacing,
i.e. 300us (T_mafs). AuxPtr in all PDUs in advertising train are
updated on enqueue since PDU spacing is already known at that time so
we do not need to waste time in LLL.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-07-10 12:44:33 -04:00
Andrzej Kaczmarek
21892eecf1 Bluetooth: controller: Add support for linked adv PDUs
This adds support to allow advertising PDUs to be linked which is
required to send advertising trains, i.e. AUX_CHAIN_IND.

PDUs are linked with a simple single-linked list, the pointer to next
PDU is stored at the very end of PDU buffer. This prevents it from
being overwritten if PDU is modified and allows for build time offset
calculation.

There are few helpers added to make handling easier, e.g.:
- get next linked PDU
- get last linked PDU
- link one PDU to another
- link PDU at the end
- release all linked PDUs (except for 1st)

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-07-10 12:44:33 -04:00
Andrzej Kaczmarek
1e02d400e2 Bluetooth: controller: Optimize lll_adv_pdu_and_extra_data_alloc
This function is the same as lll_adv_pdu_alloc except it also allocates
extra data at the end - it can just use lll_adv_pdu_alloc call to avoid
extensive c&p.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-07-10 12:44:33 -04:00
Andrzej Kaczmarek
5af3e39574 Bluetooth: controller: Add helper to allocate new pdu_adv
This adds helper to always allocate advertising PDU either from memory
pool or pdu_free queue and does not reuse existing PDU in adv_pdu.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-07-10 12:44:33 -04:00
Andrzej Kaczmarek
67bfb2fb56 Bluetooth: controller: Fix PKT_AC_US macro
Advertising channel packets do not have MIC, there's no need to have
extra parameter which always has to be set to 0 anyway.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-07-10 12:44:33 -04:00
Emil Gydesen
f18bebd9de Bluetooth: Iso: Do not remove iso data path on disconnect
We previously removed the iso data path when the iso channel
disconnected. Since the iso data path is unique for a given
iso channel (by handle), it does not make sense to remove
it for a disconnected channel, as the channel is, in
a sense, not existing anymore.

This update is to better comply with the bluetooth
core spec, and to avoid getting errors from the
controller on disconnect.

Rather than removing the implementation of being able
to remove the data path, the function was made non-static
and moved to the internal header file, in case we ever
want to use it. This should not affect compile size.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-07-10 12:41:48 -04:00
Emil Gydesen
f50574a6a0 Bluetooth: host: Move bt_data_parse to hci_core.c
Move the function from scan.c to hci_core.c.
When in scan.c, the function is only available if
CONFIG_BT_OBSERVER was enabled. Since the function
can be used in other scenarioes where we need to parse
LTV data, it has been moved to a more generic place.

hci_core.c might not be the ideal place, but it is
where most other common bluetooth functions
are located.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-07-10 12:41:18 -04:00
Yuval Peress
8d2d296771 common: Add headers to support C++ style includes
When compiling existing libraries that are difficult to change, these
headers simplify the library's integration. This specifically was the
agreed upon fix for trying to compile Android's CHRE as a subsystem.
Making changes to the Android repo to use the C style includes would be
very difficult and would likely take a very long time.

Signed-off-by: Yuval Peress <peress@chromium.org>
2021-07-10 12:17:13 -04:00
Lingao Meng
3d2ad8e653 Bluetooth: Mesh: Split proxy.h to proxy.h and proxy_msg.h
The Bluetooth proxy feature includes proxy client and proxy server.
In addition to the proxy pdu message used above, pb-gatt also uses
the same proxy pdu message.

Currently zephyr bluetooth mesh couples them in one file.

A file at the separation is called gatt_services.c,
which is used to contain Mesh Provisioning Service and
Mesh Proxy Service.

Another file in the separation is called proxy_msg.c,
which is used to process Proxy pdu messages.

Also according to Trond's suggestion:

Rename CONFIG_BT_MESH_PROXY to CONFIG_BT_MESH_GATT.
Create an additional promptless entry CONFIG_BT_MESH_GATT_SERVER
that selects CONFIG_BT_MESH_GATT and is selected by
CONFIG_BT_MESH_GATT_PROXY or CONFIG_BT_MESH_PB_GATT.

Create additional CONFIG_BT_MESH_PROXY used to represent
proxy feature (also include proxy client).

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-07-09 17:56:16 +03:00
Lingao Meng
7b2e51881c Bluetooth: Mesh: Rename proxy.c to proxy_msg.c
The Bluetooth proxy feature includes proxy client
and proxy server. In addition to the proxy pdu
message used above, pb-gatt also uses the same
proxy pdu message.

Currently zephyr bluetooth mesh couples them in one file.

A file at the separation is called gatt_services.c,
which is used to contain Mesh Provisioning Service and
Mesh Proxy Service.

Another file in the separation is called proxy_msg.c,
which is used to process Proxy pdu messages.

Also according to Trond's suggestion:

Rename CONFIG_BT_MESH_PROXY to CONFIG_BT_MESH_GATT.
Create an additional promptless entry CONFIG_BT_MESH_GATT_SERVER
that selects CONFIG_BT_MESH_GATT and is selected by
CONFIG_BT_MESH_GATT_PROXY or CONFIG_BT_MESH_PB_GATT.

Create additional CONFIG_BT_MESH_PROXY used to represent
proxy feature (also include proxy client).

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-07-09 17:56:16 +03:00
Lingao Meng
3a559e972a Bluetooth: Mesh: Modularizing the proxy
The Bluetooth proxy feature includes proxy client
and proxy server. In addition to the proxy pdu
message used above, pb-gatt also uses the same
proxy pdu message.

Currently zephyr bluetooth mesh couples them in one file.

A file at the separation is called gatt_services.c,
which is used to contain Mesh Provisioning Service
and Mesh Proxy Service.
Another file in the separation is called proxy_msg.c,
which is used to process Proxy pdu messages.

Also according to Trond's suggestion:

Rename `CONFIG_BT_MESH_PROXY` to `CONFIG_BT_MESH_GATT`.
Create an additional promptless entry
`CONFIG_BT_MESH_GATT_SERVER` that selects
`CONFIG_BT_MESH_GATT` and is selected by
`CONFIG_BT_MESH_GATT_PROXY` or `CONFIG_BT_MESH_PB_GATT`.

Create additional `CONFIG_BT_MESH_PROXY` used to represent
proxy feature (also include proxy client).

see #36343

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-07-09 17:56:16 +03:00
Robert Lubos
942ece2a3d net: l2: ieee802154: Fix LL address handling on frame reception
6lowpan module can swap the original buffer with a newly allocated one
during decompression in case the decompressed header would not fit into
the original buffer. Therefore, storing the LL address offset and
restoring the pointer after decompression as it is done today is not
correct, as the new packet with decompressed IPv6 header will not
contain the LL header.

As the 6lowpan module doesn't deallocate the original buffer and
doesn't overwrite the LL header, its fine to use the original
pointers as they are.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-07-09 09:10:56 -04:00
Marcin Niestroj
611a1ae51a shell: modules: devmem: use strtoul instead of strtol
All variables for address, width and value are unsigned, so use strtoul
instead of strtol. This fixes an issue when 0xffffffff is about to be
assigned to specific address, which was truncated to 0x7fffffff so far.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-07-07 21:01:07 -04:00
Gerard Marull-Paretas
cc2f0e9c08 pm: use enum for device PM states
Move all PM_DEVICE_STATE_* definitions to an enum. The
PM_DEVICE_STATE_SET and PM_DEVICE_STATE_GET definitions have been kept
out of the enum since they do not represent any state. However, their
name has not been changed since they will be removed soon.

All drivers and tests have been adjusted accordingly.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-07 14:13:12 -04:00
Damian Krolik
bf3c6e7ba4 manifest: update openthread
Regular OpenThread upmerge to bring in a fix for a possible
infinite loop and support for DNS service subtypes.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2021-07-07 07:47:52 -05:00
Andrzej Głąbek
df1125a58c task_wdt: Fix the way the kernel timer is used
Do not use periodic executions of the timer handler, as in certain
circumstances (the fallback hardware watchdog used, one or more
task_wdt channel activated but none of them being ever fed) this
would lead to no callback/reset being executed for any channel.
Instead, schedule the next timeout from the timer handler function
when the function is executed for the dummy background channel or
for a channel that was deleted.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-07-07 07:44:22 -05:00
Robert Lubos
b369156e28 net: lwm2m: Fix how payload offset is calculated
Instead of manually computing payload offset, let the CoAP library do
the work, and use the payload pointer returned by the
`coap_packet_get_payload()` function instead.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-07-07 07:40:55 -05:00
Robert Lubos
0bc4e7619b net: coap: Fix coap_packet_get_payload function
The function did not work correct for packets generated with Zephyr
APIs, as `max_len` holds the entire buffer size, not the actual packet
size.

Additionally, unify how Payload Marker is handled in the calculation -
currently the coap parsing function adds it to the `opt_len` field,
which is counter-intuitive.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-07-07 07:40:55 -05:00
Robert Lubos
78e84eb3e7 net: coap: Adjust offset value after packet parsing
It is important that offset is set in the same manner, regardless of the
origin packet - it should indicate the final packet length in both
cases, when the packet is generated on the Zephyr side with CoAP APIs,
and when it's parsed from the UDP datagram. This allows for functions
like `coap_packet_get_payload()` to work correcty in both cases.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-07-07 07:40:55 -05:00
Vinayak Kariappa Chettimada
b81cecf8df Bluetooth: Controller: Use define for offset unit and SCA calculation
Use defines for offset unit and for calculation of Periodic
Advertising window widening using clock accuracy value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-06 18:51:51 -04:00
Vinayak Kariappa Chettimada
6684af11b9 Bluetooth: Controller: Fix clock accuracy calculation scanning Aux PDU
Fix clock accuracy value used in the calculation of window
widening applied when scanning for auxiliary PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-06 18:51:51 -04:00
Kamil Piszczek
bd7d28ef7d bluetooth: services: hrs: use template for logging configuration
Use template for logging configuration in Bluetooth HR service.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2021-07-05 14:34:25 +03:00
Kamil Piszczek
dd5a0d1997 bluetooth: services: hrs: add characteristic permission config
Added a configuration of characteristic access permissions for
Bluetooth Heart Rate service.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2021-07-05 14:34:25 +03:00
Robert Lubos
6d366093c8 net: sockets: socketpair: Rename read/write signals
Rename `write_signal` to `readable` and `read_signal` to `writeable`
which are more meaningful to the actual states they represent, and make
the code analysis easier.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-07-02 22:22:42 -04:00
Robert Lubos
e415518f5f net: sockets: socketpair: Fix poll signalling
In case read or write were called before the actual poll() call, the
poll() function was not signalled correctly about such events, which in
order could lead to a deadlock if the poll() was called with infinite
timeout.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-07-02 22:22:42 -04:00
Abe Kohandel
d6314fa456 bluetooth: ots: Add object name write capability
Add the ability to perform a write on the object name GATT
Characteristic with a notification callback to the application
that the name has been written.

In order for this operation to work the memory backing the
object name must be modifiable. To prevent forcing the user
to always allocate 120 bytes for the name, the maximum name
length is changed from a define to a configuration parameter.

Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
2021-07-02 22:22:24 -04:00
Patrick Rathje
cb6ef1328b Bluetooth: L2CAP: Fix missing net_buf_unref()
In case of non-recoverable errors (e.g. the connection breaks while
transmitting), the l2cap_chan_tx_process deques the net_buf but does
not unreference it. As this is inside a work queue thread, the sending
thread gets no information on this error, relying on the tx_process to
ultimately free the buffer.

Signed-off-by: Patrick Rathje <git@patrickrathje.de>
2021-07-02 22:22:02 -04:00
Krzysztof Chruscinski
e05aa6dc3e shell: Add option to bypass shell
Added api call that can set a callback that is called whenever
data is received on shell. When callback is set, shell processing
is bypassed and data is passed to that callback.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-07-02 13:35:18 -04:00
Henrik Brix Andersen
fe2075d140 shell: modules: promote edac mem shell subcommand to root shell command
Promote the "edac mem" shell subcommand to a generic "devmem" root shell
command. This command is useful for poking around registers and memory
outside of the EDAC drivers.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-07-02 13:21:25 -04:00
Vinayak Kariappa Chettimada
3cc8f31744 Bluetooth: Controller: Fix auxiliary scan context leak
Fix an auxiliary scan context leak when initiator
establishes a connection while there is another pending
auxliary PDU scheduled to be received. In this case, the
pending auxliary scan LLL context does an early abort
without generating a scan aux done event. Missing scan aux
done event caused the auxiliary scan context leak.

Fixes #36131.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-02 13:05:36 -04:00
Pavel Vasilyev
6c9411656c Bluetooth: Mesh: Restore default device configuration on reset
This commit fixes an issue where bt_mesh_reset() call just erases all
mesh flags set at the initialization instead of restoring them and
thus disabling some features until the board reboot.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-07-02 16:58:21 +03:00
Markus Rekdal
3221a1e8e7 net: lwm2m: Fix handling of multi instance resources with one instance
This will fix a bug caused by creating a multi instance resource with
only a single resource. Previously this was treated as a single instance
resource. This is now properly treated as a multi instance resource with
one instance
Signed-off-by: Markus Rekdal <markus.rekdal@nordicsemi.no>
2021-07-02 08:30:28 -04:00
Henrik Brix Andersen
d679037643 modules: canopennode: move glue code to modules directory
Move the Zephyr-specific interface and support code for CANopenNode into
the modules directory. Consolidate the CMakeLists.txt files into one.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-07-01 13:32:18 -04:00
Vinayak Kariappa Chettimada
aab30dad6f Bluetooth: controller: Use S8 encoding Tx chain delay
Minor update to calls to get Tx chain delay in extended
advertising and scanning to use S8 encoding delays.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-01 13:31:16 -04:00
Vinayak Kariappa Chettimada
c7dd004148 Bluetooth: controller: PA/LNA radio timing tuned
PA/LNA related timing calculations tuned for extended
advertising and scanning.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-01 13:31:16 -04:00
Vinayak Kariappa Chettimada
3f519fea17 Bluetooth: controller: Fix 1st connection event offset for peripheral
We need to take RX chain delay and PHY used to receive
CONNECT_IND into account when calculating 1st connection
event offset.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-01 13:31:16 -04:00
Vinayak Kariappa Chettimada
abc573e0f5 Bluetooth: Controller: Define a macro for active clock jitter value
Define a macro for active clock jitter value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-01 13:31:16 -04:00
Vinayak Kariappa Chettimada
d510351b4f Bluetooth: controller: Fix Tx-Rx switch delay calculation
In the Tx to Rx switch, fix the delay which should be the
Rx ready delay plus the Tx chain delay and plus 4 us active
clock jitter compensation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-01 13:31:16 -04:00