Commit graph

15745 commits

Author SHA1 Message Date
Alberto Escolar Piedras 56dc20eb1d Kconfig: Tidy up dependants of NATIVE_APPLICATION
So they depend or select on the right NATIVE_BUILD
instead of NATIVE_APPLICATION.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-05 07:01:19 -04:00
Robert Lubos e1964b8a82 net: wifi: shell: Fix unsafe pointer casts
parse_number() helper function accepts long * pointer or the output,
however in several places, an address of a variable of incompatible
type was passed to the function (for example an address of a bool
variable was cast to (long *) and provided to the function). This
could cause memory overwrites or other unexpected behaviour.

Fix this, by defining a helper variable of type long, and use it with
the parse_number() function. Only after successful parsing, the value is
then assigned to the proper destination.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-07-05 11:17:42 +02:00
Seppo Takalo aaa9cedf18 net: lwm2m: Update next event timestamp on PMAX change
When PMAX value is changed, it should update all events.
I believe there is a bug that caused the code only to update
events that are ongoing (to be send).

Now if PMAX changes, next event timestamp is recalculated.

Fixes #59397

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-07-05 11:16:06 +02:00
Arkadiusz Kozdra 82d8f09de1 bluetooth: host: track connection type enum
The enum used for connection types gets named bt_conn_type to guard
against accidental usage of generic integers with relation to it.

The added default case in several switch statements avoids warnings
against unhandled enum values.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-07-05 09:15:48 +02:00
Arkadiusz Kozdra 0885416b60 bluetooth: host: add checks for connection types
Fail gracefully if an HCI event of one type arrives for a handle of a
different connection type.  The requested types are currently based on
what fields are used, not on the usage context, in order to keep every
correct use so far still working.

A warning is logged if the connection identified by the handle does not
match the requested connection type.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-07-05 09:15:48 +02:00
Arnaud Pouliquen 85fe3c45fd ipc_service: rename virtio_xxx static functions
The "virtio_" prefix is used by the open-amp library API.
Rename local functions using "ipc_virtio_" prefix to avoid
function redefinition.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2023-07-05 09:15:08 +02:00
Mariusz Skamra 7c21a9c189 Bluetooth: ascs: Make sure idle state can be always read
Instead of waiting for ase_buf to be available, the read of an
ASE in IDLE state can be handled without using ase_buf.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-05 09:14:37 +02:00
Mariusz Skamra 12c89edc39 Bluetooth: ascs: Fix return without state change nor response
This fixes missing control point status and ASE status change, when
failed to disconnect the CIS. As the server may, but does not have to
disconnect the CIS, the operation should not be considered as failed
when it happens.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-05 09:13:45 +02:00
Aleksandr Khromykh 25bfbb1caf Bluetooth: Mesh: instantiate cdb and core keys
PR instantiates cdb and core keys to prevent scenario
when key is changed over cdb API and gets new ID but
core still operates with old ID(potentially invalid).

Known issue the keys will be desynchronized
during\after key refresh procedure.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-07-04 11:01:47 +00:00
Szymon Czapracki 42a402abe3 bluetooth: audio: Rework PACS notify system
This commits eliminates the old way of
pacs notifications, replacing k_work with
simple bt_gatt_notify.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2023-07-04 11:00:38 +00:00
Emil Gydesen b20ef863cd Bluetooth: OTS: Add explicit ignore of ret error when reset dir_list
When doing the bt_ots_dir_list_reset_anchor we now explicitly ignore
the return value of bt_gatt_ots_obj_manager_first_obj_get
to fix a coverity issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-04 09:30:01 +02:00
Carles Cufi 9e0e2be765 Bluetooth: controller: Fix indent in calls to ticker_stop()
Follow-up from #59602.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-07-03 16:56:26 +00:00
Mateusz Kusiak 4337675436 Bluetooth: Controller: Ignore ticker_stop() return value
Cast ticker_stop() calls to void where return value is not checked.
This is to satisfy coverity and indicate that return value is not
important.

Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
2023-07-03 16:14:34 +02:00
Florian Grandel 0341d67625 net: l2: ieee802154: readability: one-letter names
This change replaces one letter variable names with considerable
variable spans by much more readable alternatives that ease code
maintenance and help human reviewers to catch semantic errors.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-03 14:09:32 +00:00
Florian Grandel 0d5eba7900 net: l2: ieee802154: readability: f_ctx -> frag_ctx
The f_ctx variable renamed in this change has a considerable variable
span. This makes the code hard to read as the variable name is neither
defined in the IEEE 802.15.4 standard nor can it be deduced from the
variable name.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-03 14:09:32 +00:00
Florian Grandel 805ca4dde6 net: l2: ieee802154: readability: ar -> ack_requested
The 'ar' abbreviation has a well defined meaning in IEEE 802.15.4 which
is NOT the meaning of the local "ar" variable being renamed in this
change (see the comparison to the actual MHR ar field in this change
set).

To avoid confusion, a non-abbreviated variable name is introduced
instead.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-03 14:09:32 +00:00
Florian Grandel 06df0d4a7d net: l2: ieee802154: readability: af -> address_field
The 'af' abbreviation is nowhere standardized in IEEE 802.15.4 and makes
the source code unnecessarily hard to read. It is replaced by a readable
long name.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-03 14:09:32 +00:00
Florian Grandel a7338b33d5 net: l2: ieee802154: readability: LL header length
Several distinct naming conventions existed within the IEEE 802.15.4
stack wrt header length. This change converges to a single naming
convention, the one that is less ambiguous and already most used.

The change also makes the distinction between L2 (link layer/LL) header
length and 6LoWPAN fragmentation header length to avoid confusion.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-03 14:09:32 +00:00
Florian Grandel 48456d32d5 net: l2: ieee802154: rename comp to has_pan_id
This change is in preparation for the newer frame version's more
complex compression algorithm that may compress both, the source
and the destination PAN independently.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-03 14:09:32 +00:00
Florian Grandel 0ce47c7a8d net: l2: ieee802154: readability: buf -> pkt_buf
This change renames buf to pkt_buf in one very specific instance to
distinguish the packet buffer from the frame buffer which is kept in the
same local scope. In all other instances the meaning of "buf" should be
obvious from context, not so here, though

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-03 14:09:32 +00:00
Vinayak Kariappa Chettimada bc60619b90 Bluetooth: Controller: Fix coverity issue 248393
[Coverity CID: 248393] Explicit null dereferenced in
subsys/bluetooth/controller/ll_sw/ull_scan_aux.c

Fixes #58942.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-07-03 13:43:46 +02:00
Vinayak Kariappa Chettimada 7366dfd1cc Bluetooth: Controller: Fix coverity issue 318804
[Coverity CID: 318804] Copy-paste error in
subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central_iso.c

Fixes #59512.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-07-03 09:34:30 +02:00
Vinayak Kariappa Chettimada 80632b50c7 Bluetooth: Controller: Fix coverity issue 318644
[Coverity CID: 318644] Unused value in
subsys/bluetooth/controller/ll_sw/ull_central_iso.c.

Fixes #58999.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-07-03 09:33:22 +02:00
Vinayak Kariappa Chettimada 41cfe217b2 Bluetooth: Controller: Fix coverity issue 318626
[Coverity CID: 318626] Unintended sign extension in
subsys/bluetooth/controller/ll_sw/ull_adv_iso.c.

Fixes #58984.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-07-03 09:32:47 +02:00
Emil Gydesen 915a649392 Bluetooth: CSIP: Add missing input validation for csis_int_by_handle
The bt_csip_set_coordinator_csis_inst_by_handle did not check the input
parameters and could call lookup_instance_by_handle with handle == 0
which triggers an ASSERT.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:13:27 +02:00
Emil Gydesen 11b12ae905 Bluetooth: MICP: Return if AICS inst count is 0
In the prepare_aics_inst the loop
should not run if the count is 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:13:04 +02:00
Emil Gydesen 92d612e79d Bluetooth: VCP: Return if VOCS/AICS inst count is 0
In the prepare_aics_inst and prepare_vocs_inst the loops
should not run if the count is 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:13:04 +02:00
Emil Gydesen 3d53a75180 Bluetooth: BAP: Shell: Register CAP callbacks if CAP initiator
If we are use the shell as a CAP initiator, then we need to
register the stream callbacks for the CAP streams as well, as
CAP will use the BAP callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:12:48 +02:00
Emil Gydesen f1a3b7d7e2 Bluetooth: CAP: Add null check for free_conn
When populating the conns array in
bt_cap_initiator_codec_configured, coverity did not like just
having the __ASSERT, so modified the checks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:12:30 +02:00
Emil Gydesen 4e15a09083 Bluetooth: BAP: Filter PA data duplicates by default
When syncing via the broadcast sink or the scan delegator
it makes more sense to filter on duplicates, as the expected
data rarely changes.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:12:13 +02:00
Emil Gydesen c6632d65d8 Bluetooth: BAP: Shell: Add runtime config of recv_stats_interval
The internval of how often we report
receive stats can now be configured via the cmd_recv_stats
command.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:11:57 +02:00
Emil Gydesen 6e066b4683 Bluetooth: BAP: Shell: Improve recv statistics
Add more information when we print the recv every 100th
packet, and remove all per-recv printing.

This also resets all information on stream start. This does,
however, no properly support multiple streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:11:57 +02:00
Emil Gydesen 49a70aa1bb Bluetooth: TMAP: Add TMAP shell module
Add simple TMAP shell module that supports the TMAP
discovery.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:10:51 +02:00
Emil Gydesen 43ef100a22 Bluetooth: TMAP: Make callback const
The callback should not be modified by the stack,
and should thus be const.

Also fixes a missing include of conn.h.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:10:51 +02:00
Georges Oates_Larsen ad6fdaf2c2 net: conn_mgr: Bulk convenience functions
To further reduce the need for networking boilerplate in applications,
provide bulk versions of net_if_up, net_if_down, conn_mgr_if_connect,
and conn_mgr_if_disconnect that affect all available / eligible ifaces
at once.

Since it is not intuitive whether these functions should affect ifaces
which conn_mgr is ignoring, these functions take an argument that allows
this to be specified by the application.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-06-30 16:10:23 +02:00
Georges Oates_Larsen b65613e79c net: conn_mgr: Support Auto-Down
To reduce the amount of boiler-plate needed in applications, this commit
grants conn_mgr the ability to automatically take ifaces that have given
up on connecting into the admin-down state.

Tests adjusted as appropriate.

This behavior can be disabled globally by disabling
NET_CONNECTION_MANAGER_AUTO_IF_DOWN, or disabled per-iface using the
CONN_MGR_IF_NO_AUTO_DOWN flag.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-06-30 16:10:23 +02:00
Georges Oates_Larsen f3d75c4c65 net: conn_mgr: Support Auto-Connect
To reduce the need for boilerplate in application code, conn_mgr now
supports an auto-connect feature on all ifaces with connectivity
bindings.

conn_mgr will automatically call conn_mgr_if_connect on any iface with a
connectivity binding that enters the admin-up state, unless the newly
added CONN_MGR_IF_NO_AUTO_CONNECT flag has been set for that iface.

Also adjust automated tests to account for and take advantage of this
behavior.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-06-30 16:10:23 +02:00
Georges Oates_Larsen 8785a9f424 net: conn_mgr: Minor fixes
- Add missing event sleep after taking all ifaces up in
  test_connect_disconnect.
- Add missing event sleep after resetting ifaces in conn_mgr_conn_before
- Fix typo in comment for internal state flags.
- Add missing NET_MGMT_EVENT_BIT to conn_mgr_connectivity event
  definitions.
- Missing net_mgmt.h include in conn_mgr_connectivity.h
- Split conn_mgr_conn iface reset into network and state resets, before
  and after event sleep, so that triggered events do not corrupt the
  state reset.
- Reduce SIMULATED_EVENT_DELAY to 100ms to avoid timeouts on real-time
  targets.
- Use macro for simulated event wait times.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-06-30 16:10:23 +02:00
Emil Gydesen cd78331c23 Bluetooth: Shell: Only print PAST peer if there is one
Only print the "PAST peer" string if there is an actual
PAST peer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:08:17 +02:00
Aleksander Wasaznik e61ac77119 Bluetooth: Shell: Restore missing bt_addr_le_to_str in scan_recv
This restores a line of code that was accidentally deleted in
5580cb4391. This fixes an uninitialized
`le_addr` getting printed and producing garbage output in the scan
results.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-06-30 16:07:44 +02:00
Jai Arora cf0ff30b53 bluetooth: ots: Fix bt_ots_init paramter struct naming
Patch to rename struct bt_ots_init to struct bt_ots_init_param
to avoid duplicating the name bt_ots_init.

Fix for issue#45968

Signed-off-by: Jai Arora <infolinesoni@gmail.com>
2023-06-30 16:06:08 +02:00
Emil Gydesen 69f7fd9cb2 Bluetooth: Audio: Rename bt_codec to bt_audio_codec_{cap, conf, data}
Rename the bt_codec struct to bt_audio_codec_conf or
to the new struct bt_audio_codec_cap.
Rename the bt_codec_data to bt_audio_codec_data.

The purpose of this is to split the codec specific configuration
and codec capabilities into seperate structs, as they do not
reflect the same values, or used for the same purpose.

This commit depends on the preset macros workings on either
type of struct (for now), but will be modified in future updates.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 12:39:50 +02:00
Marcin Niestroj 40d2240226 net: context: set default offloaded iface during net_context_get()
Set default offloaded interface during net_context_get() call, so that
net_context_recv() can be called before net_context_connect(). There is
already an assumption about using default network interface, so this should
not be harmful.

Fixes: 2c75070360 ("net: sockets: tcp: Fix possible race between
  connect/recv")
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-06-29 21:08:05 +02:00
Mariusz Skamra 17223f136f Bluetooth: audio: Fix metadata length checks
This fixes metadata length checks for BT_AUDIO_METADATA_TYPE_EXTENDED
and BT_AUDIO_METADATA_TYPE_VENDOR that should be at least 2 bytes long.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-29 21:06:58 +02:00
Mariusz Skamra db5767e50f Bluetooth: audio: Accept empty CCID list in audio metadata
The CCID list can be empty, as the Assigned Numbers is not strict
regarding it's minimum length.

Fixes: #59666
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-29 21:06:58 +02:00
Emil Gydesen a32ba627ce Bluetooth: BAP: Shell: Improve printing of the BASE
Add offsets for each layer in the BASE and add printing
of the presentation delay.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-29 21:06:46 +02:00
Mariusz Skamra 7b94d57b32 Bluetooth: unicast_client: Drop ISO PDUs if ASE is not in streaming state
This fixes missing drop of ISO Data PDUs received in non-streaming state.
The client shall indicate first it's readiness to receive the ISO Data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-29 21:06:31 +02:00
Mariusz Skamra 9694e85614 Bluetooth: ascs: Drop ISO PDUs if ASE is not in streaming state
This fixes missing drop of ISO Data PDUs received in non-streaming state.
The server shall indicate first it's readiness to receive the ISO Data
by calling bt_bap_stream_start that triggers state transition from
Enabling to Streaming state.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-29 21:06:31 +02:00
Emil Gydesen f4550dbda8 Bluetooth: TBS: Guard check for MAX_TBS_INSTANCES
Add check for CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 1 before
comparing inst_cnt, as otherwise it was always false which
caused a coverity issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-29 21:06:14 +02:00
Ajay Parida 69fead1998 net: mgmt: Support for forced Passive scan
Default scan mode is Active. User can force the scan mode to passive
through Kconfig option or using 'passive' option from shell.
Using either of this option will override regulatory settings and
forces all scan channels to be passive only.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-06-29 21:05:41 +02:00