Similar to the ad_init that automatically adds advertising data
from other modules, pa_ad_init has been added to do the same
for periodic advertising.
The only use case so far is the BAP broadcast source
data, if enabled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The call to audio_ad_data_add will now either call
connectable_ad_data_add for connectable advertising, or
unconnectable_ad_data_add for unconnectbale advertising.
Most service UUIDs etc. does not make sense to advertise if
not connectable.
This also adds the BAP broadcast advertising data to
unconnectable.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If the advertising is connectable, and we have privacy,
then according to the HAP spec, we should not advertise
the HAS uuid.
This was done by simply truncating the advertising data, but
it was only truncated by 1, instead of by the size of the
UUID.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
As we are now compiling in parallel all apps, build errors
are not anymore next to the compile line, so let's tell
developers for app we are printing the build output
to ease debugging.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Not all toolchains support newlib so tests that require newlib need
to have a filter to we don't try and build those tests on those
testcases. Some newer tests are missing:
filter: TOOLCHAIN_HAS_NEWLIB == 1
so add that to testcases that needed.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
New LLCP will process the CIS establishement in the TX path, meaning it
will only process once every ACL connection interval.
If ACL connection interval is significantly longer than the ISO
interval, CIS packets corresponding to the ACL connection interval will
be lost. This may cause latency in audio rendition.
By processing the CIS establishment in the RX path, notification will be
sent immediately, and audio path is enabled fast to reduce latency.
When a CIS fails to establish, the controller shall complete the
procedure by sending a CIS_ESTABLISHED event containing the error.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Disconnect CIS immediately if event done extra status indicates MIC
failure. Return reason BT_HCI_ERR_TERM_DUE_TO_MIC_FAIL.
Fixes EBQ test /LL/CIS/PER/BV-27-C.
Signed-off-by: Morten Priess <mtpr@oticon.com>
When the 'instant' of a CIS is postponed by increasing the conn_event of
the CIS_RSP compared to CIS_REQ, the CIS offset shall be calculated as
an equivalent window offset by an integer number of ISO intervals.
This is obtained by increasing the CIS_Offset_Min and CIS_Offset_Max by
the modulus of the connection interval delay time.
Signed-off-by: Morten Priess <mtpr@oticon.com>
To be able to timely start the first CIS/CIG, if the requested instant
is the next connection event, call ull_peripheral_iso_start directly
from rp_cc_state_wait_rx_cis_ind instead of waiting for next time
through the state machine.
To enable ULL/LLL to prevent adding latency when LLCP is waiting for
instant, local- and remote procedures with instant now expose a function
for checking this state.
Fixed event_counter function to prevent one-off in RX path. Unified to
use single function ull_conn_event_counter.
Fixed LLCP unit tests and added new mock function.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Set the packing field when creating the broadcast source. This
is currently missing, and in uninitialized.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add test where privacy is enabled and where
the two devices are bonded and have exchanged IRK
before doing the periodic advertising sync.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Expand the periodic advertising tests with connections,
to verify that two devices can simultaneously be connected
and keep a periodic advertising sync.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds a test suite exclusively for testing
periodic advertising sync.
The first test added is a simple test that does a periodic
advertising sync, and passes afterwards.
The test suite will be expanded with testing PA syncs
with PAST (both from remote and local transfer) as well
as privacy handling.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the overlays usage for bsim mesh configurations instead of
multiple configurations that duplicate each other a lot.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
This change enables the ISR Hard Reset sent bits, so that
an interrupt is generated when a Hard Reset is sent or
the Hard Reset failed.
Signed-off-by: Sam Hurst <sbh1187@gmail.com>
The Hard Reset sent signal was tested twice in the same
"if else" structure but only handled in the last test. This
change removes the first detection so that Hard Reset can
be correctly detected.
Signed-off-by: Sam Hurst <sbh1187@gmail.com>
USB stack did leak memory on every SET ADDRESS request. UDC control
allocator could cope with up to 13 leaked allocations. Therefore,
issuing bus reset 13 times in a row (in addition to automatic reset
after connecting the USB cable) was enough to exhaust memory and
thus drive USB stack inoperable.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
On board stm32h747i_disco_m7, USB clock is updated to enable USB1ULPI
clock.
Doing so, it should not delete 48MHz domain clock setting.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
On STM32L4 that probvide HSI48 clock, use it as 48MHz domain clock.
This impacts following devices:
-SDMMC
-RNG
-USB
Otherwise, when HSI48 is not available MSI is used.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Validate the powered state and transitions for an arbitrary device
hanging off a power domain.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Only run the `PM_DEVICE_ACTION_TURN_ON` and `PM_DEVICE_ACTION_TURN_OFF`
actions for child devices that have refered to the domain via the
`power-domain` property.
This prevents multiple actions being run for devices that refer to
several power domains, e.g.
```
test_dev: test_dev {
compatible = "test-device-pm";
status = "okay";
power-domain = <&test_reg_1>;
alternate-domain = <&test_reg_chained>;
};
```
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
The struct sensor_value type does NOT require val2 to be positive. The
removed code is in fact a rather serious bug, probably put in place
because it makes printing sensor_values easier.
Signed-off-by: Benjamin Lindqvist <benjamin@eub.se>
The sink ASE does not have a disabling state, but since the
stream callbacks does not necessarily match the ASE states,
we need to do our own check to see if a sink ASE has been
disabled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Before this commit we simply always notified/indicated
all presets and active index to any bonded device, even
if they never subscribed to anything, or even if we never
registered HAS.
This commit modifies that, so that only the proper
connected clients will get the notifications/indications,
and that we only send them if something has changed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The security_changed callback may be called before
bt_has_register has been called, thus making the active_preset_work
handler uninitailized, causing an ASSERT when the work is submitted
in the security changed callback.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Calling bt_has_register multiple times would cause attempts
to register a HAS multiple times. Fixed by adding a check
and return with EALREADY if it is already registered.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
It's not necessary to busy wait 150 µs after changing register banks.
Nothing in the data sheet nor app note suggests this. ST's own HAL,
which is used by this driver, does not delay when changing banks. It
does a bank change around every function that accesses a non-user bank
register (it's quite inefficient).
So if it was necessary it would be broken now, as most of the bank
changes have no delay.
One of the few page changes that did have this delay are the those done
before and after reading a sensor sample. Which is where the speed is
significant and is limiting the update rate the driver is capable of.
Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
The code in the ST HAL does a read/modify/write to change the bits in
the LSM6DSO_FUNC_CFG_ACCESS register that control which register bank is
active.
All the other bits in the register are defined as zero. It's possible
to simply set the register to the desired value without reading the
contents first.
This bank switch needs to be done twice for every sensor read when the
sensor hub is used. The driver as it is can not keep up with the higher
update rates of the lsm6dso. So any speed increase in this code allows
for a higher update rate as well as reduced latency.
Previously, a read of the lsm6dso's accel and gyro on a 400 kHz I2C bus
with a 3-axis magnetometer on the sensor hub takes 2.69 ms. This drops
that to 2.26 ms. This is enough to support the 417 Hz ODR.
Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
There is a flaw with I2C communication to peripherals behind the shub
that causes sporadic failures. Especially calls to configure a device
after the lsm6dso initialization is finished, e.g. to set the ODR, can
fail to work correctly.
Access to shub peripheral registers is done by putting the parameters of
the operation into SLV0 and then waiting for the lsm6dso to perform the
xfer on the shub I2C bus. The lsm6dso does this in sync with the
accelerometer update rate. Once the shub is enabled, it peforms the
xfer repeatedly as the accelermeter is sampled.
The wait has a problem: It might detect that a previous shub xfer has
finished, which was done before SLV0 was programmed with new parameters.
The shub status register is read-to-clear. This isn't in the data sheet
or app note, but it is. By reading the status before enabling the
sensor and after programming SLV0, we can be sure when it becomes set it
has finished the current operation and not a previous one.
Also set the write-once flag before shub init. This causes the shub to
only perform I2C writes once instead of continuously. This was set at
the end of init, so any writes done during it would repeat until the
shub was disabled.
Put a timeout in the code that polls for the sensor hub op complete. It
could possibly poll forever. More importantly, if there is no device
connected to the sensor hub, the lsm6dso does not timeout on the
operation for ~13 seconds. Since the shub init does a probe for devices
on startup, this will happen if shub support is enabled but a lsm6dso
has no sensor hub devices. There could be multiple devices, some with
additional sensors and some without. Initialization of the devices
without additional sensors takes tens of seconds without this timeout
being added.
Add a 300 µs wait after disabling the sensor hub. This is necessary
according to the ST app note AN5192 §7.2.1.
Read the shub status from the main bank register instead of the shub
bank register. This avoids an extra bank switch before and after each
status poll. Actually two bank switches on each side, since the lsm6dso
driver switched banks and then the ST HAL function to get the status
register switches again.
The wait for the shub I2C transaction to finish is not needed when the
shub is enabled at the end of init. We aren't starting a new I2C write
or reading the result of a read.
Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
The lsm6dso initialization will fail if the device is not already set to
the user register bank. All the registers used will be the wrong ones
from whatever bank it is in, e.g. sensor hub bank. This includes the
registers to reset the device!
The bank will default to the user bank on reset, but the chip has no
hardware reset line. On a reboot it will be in whatever bank it was
last in. If the sensor hub is enabled, it will switch banks on every
sample, so it's entirely possible to reset or reboot when it happens
to be set to the sensor hub bank, which will cause the driver to
fail to initialize. It will not work again until the lsm6dso is power
cycled.
Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
Per an ST app note, the sensor hub I2C controller should be disabled
before doing a software reset. Possibly, this is because the sensor hub
could be in the middle of the an I2C transaction to a sensor when it is
reset. Disabling it and then waiting makes sure it has quiesced before
resetting.
Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
The initialization code would configure the lsm6dso interrupt, then
configure the rest of the chip. The chip init includes a reset that
would undo the register setting done during interrupt configuration.
It's also not a good idea to enable the interrupt on the SoC when the
lsm6dso has not yet been reset or configured. It might be generating
interrupts.
The lsm6dso has no hardware reset line, so it will not be reset on
reboot unless a power cycle is involved.
Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
The parameter doc string for hda was incorrect as the parameters
had been updated to take the IP base address, block size, and stream id
instead. Updates all doc string comments to account for the change.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
The DMA API contract specifies that start/stop may be called multiple
times. Prior to adding power management this was perfectly fine as it was.
In adding power management, there are additional side effects that can
cause issues. Instead check the state of the channel prior to start/stop
and do nothing if already in the desired state.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Ensures that the documented behavior of the API is met by implementations
through testing. By calling stop on a stopped channel the expectation is no
error occurs and is checked.
Calling start after a channel has been started is difficult to test for
as there is transfer timing involved. A once shot transfer may have
completed and the channel transition to an inactive state by itself by
the time the second start call is performed. This isn't supported by at
least gpdma today and isn't documented behaviorally so should not be
tested.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
The DMA API expects drivers in effect to maintain their own internal
state of channels. A channel that is already started may have dma_start
called on it again without effect. A channel that is already stopped may
have dma_stop called on it without effect.
In essence, start and stop are expected to act like events a DMA channels
finite state machine reacts to and if the state is already at the desired
one then nothing is to be done and no error has occurred.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Currently, the s32z270dc2_r52 board only supports running on RAM,
so samples or tests watchdogs that perform SoC reset will not produce
results. Set the build only for these samples and tests until the
reset SoC function is supported.
Signed-off-by: Quang Bui Trong <quang.buitrong@nxp.com>
`<fcntl.h>`, `<net/if.h>`, and `<netinet/tcp.h>` were missing
`extern "C" { .. }"` which is required to avoid C++ name
mangling.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
Add a trivial suite that simply ensures headers exist and that
they supply standard symbols and constants.
These tests are intended to be ordered exactly as the respective
feature appears in the respective specification at
https://pubs.opengroup.org/onlinepubs/9699919799
Over time, as POSIX support improves, we can enable additional
checks.
If `CONFIG_POSIX_API=n`, then we simply ensure that the header
can be included, that constants and structures exist, including
the existence of required fields in each structure.
We check that a constant exist, by comparing its value against
an arbitrary number. If the constant does not exist, it would
of course be a compile error.
```
zassert_not_equal(-1, POLLIN);
```
We check that a structure contains required fields by
comparing the field offset with an arbitrary number. If
the field does not exist, of course, there would be a
compile error.
```
zassert_not_equal(-1, offsetof(struct pollfd, fd));
```
For non-scalar constants, we simply attempt to assign
a value to the specific type:
```
struct in6_addr any6 = IN6ADDR_ANY_INIT;
```
If `CONFIG_POSIX_API=y`, then we additionally check that required
functions are non-NULL (limited to what is currently supported in
Zephyr).
```
zassert_not_null(pthread_create);
```
Note: functional verification tests should be done outside of this
test suite.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
The POSIX spec requires that `SO_LINGER`, `SO_RCVLOWAT`,
and `SO_SNDLOWAT`, and `SOMAXCONN` are defined in
`<sys/socket.h>`. However, most of the existing socket
options and related constants are defined in
`<zephyr/net/socket.h>`.
For now, we'll co-locate them. It would be
good to properly namespace things.
Additionally, a no-op for setsockopt for `SO_LINGER` to
make things Just Work (TM) for now.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
The `<netdb.h>` header typically defines `NI_MAXSERV` as a
reasonable default buffer size to use in applications that
use `getnameinfo()` to query a service name.
Most GNU and BSD systems define it by default so provide
it as a convenience so applications and 3rd-party libraries
do not encounter a compile error.
Signed-off-by: Chris Friedt <cfriedt@meta.com>