Set the MOPL of RX and TX to `BT_OBEX_MIN_MTU` when registering OBEX
server.
Set the TX MOPL to `BT_OBEX_MIN_MTU` when sending OBEX connection
request.
Check if the MOPL of client exceeds MTU of transport when server
receives the connection request.
Check if the MOPL of server exceeds MTU of transport when client
receives the connection response.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Split the structure `struct bt_obex` into two parts.
Part 1 `struct bt_obex`, it is the common part and shared by all OBEX
sessions which share the same one transport.
Part 2 `struct bt_obex_server` and `struct bt_obex_client`. The
`struct bt_obex_server` is used to manage the OBEX session of server
role. The `struct bt_obex_client` is used to manage the OBEX session
of client role.
Add function `bt_obex_server_register()` to register the OBEX server
with specific uuid.
Add function `bt_obex_server_unregister()` to unregister the OBEX
server.
Add function `bt_obex_make_uuid()` to make UUID.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The receiving segmented L2CAP data can not be handled properly. Due to
the `struct bt_l2cap_chan_ops::alloc_buf` is NULL, the partial data
will be notified through callback `struct bt_l2cap_chan_ops::recv`.
The GOEP does not consider this issue and handles it as a completed
packet. It causes the L2CAP disconnecting due to the partial packet
cannot be processed by OBEX.
Add a RX pool, and set `struct bt_l2cap_chan_ops::alloc_buf`. The
L2CAP will allocate the buffer from the pool to buff the segmented
data. Only the completed packet will be notified through
`struct bt_l2cap_chan_ops::recv`.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Automatic advertiser resumption is publicly deprecated since
Zephyr 4.0 [1].
Options and parameters for this behavior have been removed,
and the internal bit flag BT_ADV_PERSIST is now always false.
The behavior it used to configure (to keep advertising after a
connection has been established as long as there are connections
available) has also been removed.
[1] Bluetooth: Deprecate adv auto-resume #73395
Signed-off-by: Christophe Dufaza <chris@openmarl.org>
Automatic advertiser resumption is publicly deprecated since
Zephyr 4.0 [1].
Options and parameters for this behavior have been removed,
as well as all calls to bt_le_adv_resume().
Also remove adv_get_options() whose bt_le_adv_resume()
is the only caller.
[1] Bluetooth: Deprecate adv auto-resume #73395
Signed-off-by: Christophe Dufaza <chris@openmarl.org>
Automatic advertiser resumption is publicly deprecated
since Zephyr 4.0 [1].
Options and parameters for this behavior have been removed.
[1] Bluetooth: Deprecate adv auto-resume #73395
Signed-off-by: Christophe Dufaza <chris@openmarl.org>
Automatic advertiser resumption is publicly deprecated since
Zephyr 4.0 [1].
Options and parameters for this behavior have been removed.
[1] Bluetooth: Deprecate adv auto-resume #73395
Signed-off-by: Christophe Dufaza <chris@openmarl.org>
In bt_conn_unref(), if we remove the last reference to the connection,
we notify listeners that a connection object has been freed
and can be taken, then immediately reuse this freed slot
to resume advertising.
This behavior is source of errors, and automatic advertiser resumption
is publicly deprecated since Zephyr 4.0 [1].
Options and parameters for this behavior have been removed.
[1] Bluetooth: Deprecate adv auto-resume #73395
Signed-off-by: Christophe Dufaza <chris@openmarl.org>
Automatic advertiser resumption is deprecated since Zephyr 4.0 [1].
To maintain the behavior during the deprecation period, internal
transitional symbols were introduced to replace the deprecated ones
in the implementation:
- _BT_LE_ADV_OPT_CONNECTABLE: same option bit
as BT_LE_ADV_OPT_CONNECTABLE (deprecated)
- _BT_LE_ADV_CONN_ONE_TIME: same option bit
as BT_LE_ADV_CONN_ONE_TIME (deprecated)
The only option for connectable advertising is now BT_LE_ADV_OPT_CONN,
whose value is _BT_LE_ADV_OPT_CONNECTABLE|_BT_LE_ADV_OPT_ONE_TIME.
We can assume _BT_LE_ADV_CONN_ONE_TIME is true for connectable
advertisers, and meaningless for non-connectable advertisers.
[1] Bluetooth: Deprecate adv auto-resume #73395
Signed-off-by: Christophe Dufaza <chris@openmarl.org>
Automatic advertiser resumption is deprecated since Zephyr 4.0 [1].
To maintain the behavior during the deprecation period, internal
transitional symbols were introduced to replace the deprecated ones
in the implementation:
- _BT_LE_ADV_OPT_CONNECTABLE: same option bit
as BT_LE_ADV_OPT_CONNECTABLE (deprecated)
- _BT_LE_ADV_CONN_ONE_TIME: same option bit
as BT_LE_ADV_CONN_ONE_TIME (deprecated)
The only option for connectable advertising is now BT_LE_ADV_OPT_CONN,
whose value is _BT_LE_ADV_OPT_CONNECTABLE|_BT_LE_ADV_OPT_ONE_TIME.
We can substitute BT_LE_ADV_OPT_CONN for _BT_LE_ADV_OPT_CONNECTABLE
when testing if an advertising set is connectable.
Note: to fix a ClangFormat warning raised by check_compliance.py,
this commit also includes a formatting change next to the lines
actually edited (subsys/bluetooth/host/id.c:810).
[1] Bluetooth: Deprecate adv auto-resume #73395
Signed-off-by: Christophe Dufaza <chris@openmarl.org>
The bt_conn_tx_processor logged connections not in the
connected state as LOG_WRN, but this is a case that is handled
and could occur during regular behavior.
For this reason the log statement was changed to LOG_DBG,
as the developer/user does not need to worry about it.
Also modifies the statement to log the conn->state for
debugging purposes.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add SDP discovery handlers for AVRCP CT/TG roles and corresponding
discovery parameters and a common result handling function.
Signed-off-by: Make Shi <make.shi@nxp.com>
Fix to improve decryption speed. Decryption starts after
payload reception, hence use fastest mode to decrypt PDUs.
nRF54Lx only supports decryption after payload reception,
this implementation was already there in the code.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reverts relaxed radio packet assignment deadline as it is
too risky and can cause invalid bits be transmitted and/or
cause MIC failures.
Reverts commit 4dbfb22a7e ("Bluetooth: Controller: Relax
radio packet pointer assignment deadline"), and
commit 230df77993 ("Bluetooth: Controller: Relax radio
packet pointer assignment deadline").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
bt_iso_chan_send and bt_iso_chan_send_ts would log
twice for each TX, which is unncessary. LOG_DBG statements
include the function name by default, so the 2nd log
statement was unncessary, and were removed.
Added logging of the ts in bt_iso_chan_send_ts which
would still make it possible to tell the 2 apart,
even if CONFIG_LOG_FUNC_NAME_PREFIX_DBG=n.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix implementation of Broadcast ISO Synchronized Receiver
using single switch timer to consider minimum compare value
requirement.
This fix reduces latencies to setup radio receptions and
fixes an assertion in lll_sync_iso when radio_tmr_start_us()
is checked for latencies.
Relates to commit 5dfc58cff9 ("Bluetooth: Controller: Fix
single switch timer minimum compare value").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
ll_length_req_send and ll_length_default_set were defined to return
a uint32_t, but only returned a uint8_t HCI error code and
was the return value was always stored as such.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
0-init some non-static global variables to avoid
issues with uninitialized values. Also modify
the printing of the broadcast sources found slightly.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When `CONFIG_NRF_SYS_EVENT` is enabled, route constant latency requests
through the reference counted API.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Adds assert for bt_bap_iso_bind_ep to ensure that endpoints
from different connection don't share a CIS (a bt_bap_iso).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a check that verifies that 2 endpoints from different
connection don't share a CIS, which would be invalid.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
We can actually already when we bind the endpoint to the stream
perform the call to bt_bap_iso_bind_ep, if the stream has been
added to a group.
If the stream has not yet been added to a group, then when
the stream is added to a group, then bt_bap_iso_bind_ep will
be done there (existing behavior).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix the issue reported by Coverity CID 487708. The LL_ASSERT was
performed on lll->ptc, which is a 4-bit bitfield and therefore always
succeeds. Instead, the computation (lll->nse - nse) should be checked
to ensure it falls within the 4-bit value range before assigning it
to lll->ptc.
Signed-off-by: Loic Domaigne <tech@domaigne.com>
Use default_unicast_group everywhere in the CAP shell, and mark
all creation of it as default_unicast_group.is_cap = true.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the function bap_ac_create_unicast_group to the CAP
shell, as that was the only user of it, and rename it to
cap_ac_create_unicast_group, and make it use the CAP API.
Also rename bap_unicast_ac_param to cap_unicast_ac_param
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a common unicast_group struct for both the BAP and
CAP shell, similar to the broadcast_source.
The purpose of this is to be able to use the appropriate type
for both the CAP and BAP shells, instead of using the BAP
unicast group for the CAP shell.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds support for the user defining their own channels within the
fixed L2CAP channel range. To make this possible, the
`bt_l2cap_fixed_chan` struct and `BT_L2CAP_CHANNEL_DEFINE` macro
needed to converted to public API. In the process of doing so, the
`_destroy` parameter was removed from the `BT_L2CAP_CHANNEL_DEFINE`
macro as it was never used (fixed channels will not be destroyed over
the lifetime of the connection). `BT_L2CAP_CHANNEL_DEFINE` is renamed
`BT_L2CAP_FIXED_CHANNEL_DEFINE` to avoid confusion
The `bt_l2cap_chan_send` function is updated to be able to send data
on fixed l2cap channels.
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
Rename the bt_bap_is_x_ep functions to better match the
modules where they are implemented.
Additionally modify the check to use IS_ARRAY_ELEMENT
in the broadcast sink and source for a stricter check.
IS_ARRAY_ELEMENT cannot easily be used in the unicast
client and server, as the endpoints are part of another
structure.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
We check for all other roles when checking whether
an endpoint can send or receive, except for the unicast server.
It is technically implied, but if the ep is not a valid pointer,
then we may access invalid memory.
Add check for bt_bap_ep_is_unicast_server (which uses the new
bt_ascs_has_ep function).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implement the broadcast to unicast handover procedure,
as per the Bluetooth CAP specificiation.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If stream->ep is NULL, which is really shouldn't be,
then we should not attempt to dereference it.
Add simple NULL check to ensure behavior, and make
Sonarcloud happy.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change 4c86a5cc8d moved a select
from Kconfig.asc to Kconfig.bap (amongst some other changes
from select to depends), but inverted the PAC_{SRC,SNK} from
ASCS_ASE_{SRC,SNK} condition.
Signed-off-by: Mike J. Chen <mjchen@google.com>
Fix inter-operability, when BT_PHY_UPDATE=n the feature bits
contained 2M and Coded PHY when Advertising Extensions where
enabled, and Central devices did not progress with any data
packet transfers when PHY_REQ was rejected as unknown PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In HFP PTS, cases run fail with the log 'unsupported unsolicited
format: +BSIR=0' and 'FAIL: Expected to receive +BSIR: 0'.
Fixed issue by changing +BSIR=0 to +BSIR: 0.
Signed-off-by: Jiawei Yang <jiawei.yang_1@nxp.com>
Handle the `bt_le_create_conn_cancel` call in the deferred worker
failing due to insufficient command buffers.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Fix some "All if ... else if constructs shall be terminated
with an else clause" (c:M23_112) issues reported by SonarQube.
Signed-off-by: Christophe Dufaza <chris@openmarl.org>
An assertion in bt_conn_unref() accesses the connection's state
after decrementing its reference count.
This is not consistent since, if we removed the last reference,
the Bluetooth Host stack may reuse the connection object
before the assertion is checked.
Instead, retrieve the connection property tested by the assertion
before decrementing the counter, as we do for other properties.
Simplify the code path by returning early when we did not remove
the last reference.
Remind that automatic advertiser resumption is deprecated.
Signed-off-by: Christophe Dufaza <chris@openmarl.org>
In bt_conn_unref(), a local variable is used as atomic target:
atomic_val_t old = atomic_dec(&conn->ref);
/* Prevent from accessing connection object */
bool deallocated = (atomic_get(&old) == 1);
Using atomic_get() to access a non-shared local variable
cannot prevent any data race on that variable,
and only causes confusion.
Moreover, this call to atomic_get() is incorrect: the API expects
an atomic_t* argument (target), not an atomic_val_t* (value).
This compiles and /works/ only because Zephyr defines both to be
the same integer type, and thus: atomic_get(&old) == old.
The equivalent C11 code, where _Atomic(T) and T are different types,
wouldn't compile.
Signed-off-by: Christophe Dufaza <chris@openmarl.org>
The only reason to keep these would be to enable conditional compilation
of some parts of the code. However, we can't see enough benefit in doing
this, particularly since the flash driver itself will conditionally
handle certain paths depending on erase caps, so the options are
deprecated to reduce complexity.
Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
This fully decouples blob_io_flash from specific flash device details,
by not reading the write block size from a hard-coded device tree node,
instead pulling this from the actual flash device used.
The block write routine has been updated to be more generic and fix a
few bugs:
* The write buffer is now sized based on a KConfig option instead of
basing it off the device tree - this makes the module usable with
any flash device, not just the internal memory. The configured value
is checked during initialization, to ensure that the configured size
will fit the write block size required by the device passed to the
init function.
* The erase value used to fill the buffer when using a device with
explicit erase is now pulled from the flash parameters instead of
being hard-coded to `0xff`.
* An additional write block sized piece of buffer is allocated - the
previous buffer sizing with rounding up only worked if
`BLOB_RX_CHUNK_SIZE % WRITE_BLOCK_SIZE` was 0 or 1 (which
coincidentally worked in all testing because the chunk size defaults
to 161, and for internal flash w/write block size of 4,
`161 % 4 == 1`).
* The choice of whether to just write the chunk as-is or to
write-block align it is now based on the erase cap pulled from the
flash parameters, instead of checking the type of memory in the SOC.
This means the module dos _not_ currently support the case where
memory has to be written write-block aligned, but the memory does
_not_ use explicit erase. It uses a trick of filling the write
buffer with the erase value to avoid overwriting existing chunks,
which will not work in this case. This trick is required to support
random ordered chunks while still writing write-block aligned.
* The code has been cleaned up a bit in general.
Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
Only erase a page when starting the first block on that page.
This fixes a bug where, if the block size is smaller than the page size,
the entire page would be erased upon start of each block when writing,
meaning only the final block on each page would be retained. This works
because blocks are always received in order.
Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>