Commit graph

21541 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
0bd05c0ed9 Bluetooth: Controller: Rename CPR mutual exclusion functions
Rename CPR mutual exclusion function to not sound similar to
OS mutex interfaces.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-01 13:30:50 -04:00
Vinayak Kariappa Chettimada
a8d4c062fa Bluetooth: Controller: Use inline functions for CPR mutex operations
Use inline functions for CPR mutex operations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-01 13:30:50 -04:00
Vinayak Kariappa Chettimada
d518337835 Bluetooth: Controller: Cleanup mutual exclusion in CPR implementation
Minor cleanup of the implementation of mutual exclusion
of LE Connection Parameter Request amongst active
connections.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-01 13:30:50 -04:00
Pieter De Gendt
13d5894e46 net: openthread: Implement otPlatAssertFail
Add a platform implementation for OpenThread's otPlatAssertFail
and enable it by default.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2021-07-01 13:22:01 -04:00
Lingao Meng
cc0abee3db Bluetooth: Mesh: Check the CID field before opcode compare
Bluetooth Mesh Vendor model hava company id field.

Accordin MeshPRFV1.0.1 3.7.3.1 Operation codes.

The 3-octet opcodes are used for manufacturer-specific opcodes.
The company identifiers are 16-bit values defined by the
Bluetooth SIG and are coded into the second and third octets of
the 3-octet opcodes.

Therefore, we can speed up the search process by checking whether
CID fields match, rather than comparing opcodes one by one.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-06-29 17:08:02 -04:00
Vinayak Kariappa Chettimada
d3c27aeb8f Bluetooth: Controller: Fix Data Length Update node Rx reservations
Reserve a minimum node rx of 2 that can happen when local
central initiated PHY Update reserves 2 node rx, one for PHY
Update complete and another for Data Length Update complete
notification. Otherwise, a peripheral only needs 1
additional node rx to generate Data Length Update complete
when PHY Update completes.

Relates to #36381.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-29 17:05:20 -04:00
Vinayak Kariappa Chettimada
6810facffa Bluetooth: Controller: Fix free rx buffer MFIFO enqueue
Replace the post decrement in loop's conditional into
explicit decrement inside the loop so as to avoid
decrementing the maximum count without enqueueing free rx
buffers into the free rx buffer MFIFO.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-29 17:05:20 -04:00
Vinayak Kariappa Chettimada
ecf7106177 Bluetooth: Controller: Minor change to use IS_ENABLED
Minor changes to use IS_ENABLED and updates to comments in
code.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-29 17:05:20 -04:00
Vlad Tuhut
7580623a36 net: mqtt: Add custom transport type
Add new custom transport type.
This allows user defined transport for MQTT communication.
The user must implement the transport procedure.

Fixes **#27015**

Signed-off-by: Vlad Tuhut <vlad.tuhut@raptor-technologies.ro>
2021-06-29 11:34:57 -04:00
Pieter De Gendt
a5ec72418c net: openthread: Convert API worker thread to a work queue
Direct openthread API usage requires explicit locking,
which is also used internally.
Exposing a work queue through the openthread context allows
work to be submitted without the need to block other threads.

In particular with CONFIG_OPENTHREAD_MANUAL_START, application
logic can offload work which otherwise would need to wait for
the lock to become available.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2021-06-29 11:27:54 -04:00
Emil Gydesen
50cea984b8 Bluetooth: ISO: Only remove CIG as central
The hci_le_remove_cig command shall only be sent as the
master/central. Implemented this by early termination in
bt_iso_cleanup as the slave/peripheral.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-29 10:38:14 -04:00
Pieter De Gendt
cdf7d314fe net: coap: Fix coap client observe out-of-order messages
coap_response_received returned NULL if the observe option was out of
order, however it makes more sense to return the coap_reply handler
without actually calling it.

Additionally the reorder check has been modified to partially match
the RFC.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2021-06-29 10:27:22 -04:00
Piotr Mienkowski
ccc0999b80 net: refactor tftp library
- bugfix: Accept initial tftp server reply from a port different than
  the one used to establish the connection (typically 69) as mandated
  by RFC 1350. Previous implementation was not standard compliant.
- bugfix: close socket in case of error or timeout.
- bugfix: Reset retransmit counter after receipt of a good packet.
- bugfix: Use CONFIG_TFTP_LOG_LEVEL to set log level.
- api: upon successful receipt of the file set `client.user_buf_size`
  to the size of the file received.
- Restructure the code, comments.
- Limit usage of global variables.
- Limit usage of `goto`.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2021-06-29 09:15:55 -04:00
Vinayak Kariappa Chettimada
5627ce32c7 Bluetooth: Controller: Fix peripheral tx, rx and time reservations
Fix peripheral maximum transmit time, maximum receive time
and radio event length time reservations when connection
established using Extended Advertisements.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-28 11:58:45 -04:00
Vinayak Kariappa Chettimada
bb50284676 Bluetooth: Controller: Fix central tx, rx and time reservations
Fix central maximum transmit time, maximum receive time
and radio event length time reservations when connection
established using Extended Advertisements.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-28 11:58:45 -04:00
Trond Einar Snekvik
534177b2ca Bluetooth: Mesh: Fix regression in PB-ADV
After #35702, the provisioner is unable to mark a link as closed, as
it depends on the send_end callback to be called, so it can start its
timer. PB-Adv keeps a reference to the buffers of reliable messages,
which prevents this callback to be invoked, as the buffer destructor is
never called.

Move scheduling of the retransmit timer to the initial transmission, and
replace the timer based LINK_CLOSE message tx duration with a message
counting solution.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-06-27 19:51:47 +03:00
Eduardo Montoya
0f73fbdbfe drivers: ieee802154: add CSL receiver for nRF5
Implement CSL receiver functionality in nRF5 radio driver.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-06-24 11:31:24 -04:00
Emil Gydesen
141620519b Bluetooth: Audio: AICS client add function to get conn pointer
Add a function that returns the bluetooth connection
pointer of a given AICS client instance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 11:31:04 -04:00
Emil Gydesen
7e6d927467 Bluetooth: Audio: AICS remove need for bt_conn pointer
Remove the bt_conn pointer from the AICS API, as the
instance pointer is enough to determine if it is a client
and perform client operations on the cached connection pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 11:31:04 -04:00
Trond Einar Snekvik
c6945fbb1d Bluetooth: Mesh: Ensure proxy_send's attribute is always set
Initializes proxy_send's attr pointer, which in theory could be
uninitialized if neither gatt proxy or PB GATT is enabled while proxy.c
is enabled.

This scenario is not really possible with the current kconfig structure,
but is reported as a potential error by Coverity, and should be fixed
for future proofing purposes.

Fixes #36314.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-06-24 11:30:26 -04:00
Pieter De Gendt
72985d5f32 net: openthread: Protect OT API calls during initialization
The openthread initialization in turn calls platform specific
functions, lock the API during this step.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2021-06-24 11:29:50 -04:00
Emil Gydesen
cefaba47f8 Bluetooth: Audio: Fix MICS client deref of null pointer
The mute_val pointer could be NULL when dereferenced in the
callback. Change to be a simple value which is just assigned
instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 11:29:34 -04:00
Emil Gydesen
c42a511d39 Bluetooth: Audio: VCS update client check in API functions
Update the check if the instance is a client to be
a more simple check.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:35:07 +02:00
Emil Gydesen
5d4992ae25 Bluetooth: Audio: VCS client add function to get conn pointer
Add a function for the VCS client that gets the bluetooth
connection pointer if a given VCS client instance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:35:07 +02:00
Emil Gydesen
946013e25f Bluetooth: Audio: VCS register return if already registered
Change how bt_vcs_register works if VCS has already been
registered.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:35:07 +02:00
Emil Gydesen
0043c741a5 Bluetooth: Audio: Update VCS API to use bt_vcs
Update the VCS API to use the bt_vcs struct instead
of the bt_conn. This is create a more simple API
that uses a, remote or loca, instance pointer, rather
than a specified connection (for remote) or NULL (for
local) operations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:35:07 +02:00
Emil Gydesen
a1c7a48ee3 Bluetooth: Audio: VCS client change to use bt_vcs instead of bt_vcs_client
Change to use the generic bt_vcs struct instead of the bt_vcs_client
struct, to align better with the future API change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:35:07 +02:00
Emil Gydesen
65f59e73dd Bluetooth: Audio: VCS use bt_vcs struct instead of bt_vcs_server
Change the type of the vcs_inst in vcs.c to bt_vcs instead
of bt_vcs_server to align better with the future API change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:35:07 +02:00
Emil Gydesen
c7375079cc Bluetooth: Audio: VCS client return pointer to instance on discover
Add return of instance pointer in bt_vcs_discover so that a client
will get a bt_vcs pointer when doing discover, which will be
used going forward in the API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:35:07 +02:00
Emil Gydesen
db025e26a6 Bluetooth: Audio: VCS introduce opaque bt_vcs struct
Add a bt_vcs struct that represents a VCS instance,
either a local (server) or remote (client) instance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:35:07 +02:00
Emil Gydesen
973e88104f Bluetooth: Audio: MICS client add function to get conn pointer
Add a function that returns the bluetooth connection
pointer of a given MICS client instance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:34:37 +02:00
Emil Gydesen
12103771af Bluetooth: Audio: MICS register return if already registered
Change how bt_mics_register works if MICS has already been
registered.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:34:37 +02:00
Emil Gydesen
3c9f943fa7 Bluetooth: Audio: Update MICS API to use bt_mics
Update the MICS API to use the bt_mics struct instead
of the bt_conn. This is create a more simple API
that uses a, remote or loca, instance pointer, rather
than a specified connection (for remote) or NULL (for
local) operations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:34:37 +02:00
Emil Gydesen
f7ca9b4afa Bluetooth: Audio: MICS client change to use bt_mics
Change to use the generic bt_mics struct instead of the
bt_mics_client struct, to align better with the future
API change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:34:37 +02:00
Emil Gydesen
8ca8dabc19 Bluetooth: Audio: MICS use bt_mics struct instead of bt_mics_server
Change the type of the mics_inst in mics.c to bt_mics instead
of bt_mics_server to align better with the future API change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:34:37 +02:00
Emil Gydesen
f42d6c475c Bluetooth: Audio: MICS client return pointer to instance on discover
Add return of instance pointer in bt_mics_discover so that a client
will get a bt_mics pointer when doing discover, which will be
used going forward in the API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:34:37 +02:00
Emil Gydesen
d6fd79f65d Bluetooth: Audio: MICS introduce opaque bt_mics struct
Add a bt_mics struct that represents a MICS instance,
either a local (server) or remote (client) instance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:34:37 +02:00
Mark Wang
5daf0b2fad bluetooth: rfcomm: fix the coverity 203443 memory corruptions
- Coverity think it is out-of-bound writing
because the codes write two bytes to address (&hdr->length)
that hdr->length is uint8_t. Coverity doesn't think about
the one more byte after the hdr->length.
- Use net_buf_push to resolve this issue.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2021-06-24 11:57:33 +03:00
Dominik Ermel
f06902cc69 fs/littlefs: Remove deprecated *_MEM_POOL_* Kconfig options
The following options, marked to be deprecated in release 2.5, have
been finally removed from Kconfig:
 FS_LITTLEFS_FC_MEM_POOL_MIN_SIZE
 FS_LITTLEFS_FC_MEM_POOL_MAX_SIZE
 FS_LITTLEFS_FC_MEM_POOL_NUM_BLOCKS

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-06-23 10:03:14 -05:00
Dominik Ermel
86b1dc340e fs/littlefs: Completely switch from mem pool to heap
The LittleFS file cache has been completely switched from k_mem_slab
to heap allocated.  The *_MEM_POOL_* kconfig variables no longer
affect the code.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-06-23 10:03:14 -05:00
Pavel Vasilyev
5513b86864 Bluetooth: Mesh: Update SNB beacon before sending it
Authentication value must be recalculated before sending it.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-06-23 08:02:38 -04:00
John Power
3138d89fd9 net: lwm2m: notify timeout handling
Added notify_timeout_cb to struct lwm2m_ctx to allow application to
 handle notify timeout
Added lwm2m_rd_client_update to lwm2m.h to allow application to
 trigger registration update
Added notify_message_timeout_cb which calls notify_timeout_cb from
 struct lwm2m_ctx and logs an error message

Fixes #31499

Signed-off-by: John Power <john.power@xylem.com>
2021-06-23 08:02:06 -04:00
Maksim Masalski
ab3a207baf testsuite: suppress usage of setjmp in a testcode
According to the rule MISRAC-2012 21.4.b the standard header
file <setjmp.h> shall not be used. Suppress it, because it raises
violation in a testcode, not in a runtime code.
Tag suppresses reporting of violation for the current file,
starting from the line where the suppression is located.

Found as a coding guideline violation (MISRA R21.4.b) by static
coding scanning tool.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2021-06-22 10:08:02 -04:00
Joakim Andersson
b4ce2ba481 Bluetooth: host: Add helper function to find an attribute from its uuid
Expose a helper function to the application that searches the local
database for the given attribute from its UUID.
Provide arguments to limit the search that matches the service
declaration to make it easy to limit the search to a specific service.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-06-22 09:06:00 -04:00
Joakim Andersson
3ad3a72caf Bluetooth: host: Allow attribute as NULL with notify / indicate by UUID
Allow to pass attribute as NULL pointer when using notify or indicate by
UUID. This will use the entire handle value range to search for an
attribute with a matching UUID.
Document optional parameters, and clarify attr and uuid usage in the
variable declaration in the struct for clarification.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-06-22 09:06:00 -04:00
Vinayak Kariappa Chettimada
d76baf9bbb Bluetooth: Controller: Fix ticker ops count for extended initiator
Increase the ticker operations count in ULL high context
when Extended Advertising Connection Establishment on Coded
PHY is supported.

This fixes assertion in Controller when initiating a
connection on Coded PHY, wherein two scan instance ticker,
one window stop ticker, and a new connection instance
ticker operations needs to be enqueued.

Relates to commit a6b8eba7c5 ("Bluetooth: controller:
Implement disabling the other PHY initiator").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-22 08:24:00 -04:00
Przemyslaw Bida
976c413d75 openthread: fix not working ot diag repeat command
This commit fixes diag repeat command port by fixing issue with
incorrectly handled repeat timer.

Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2021-06-22 08:21:41 -04:00
Emil Gydesen
a1cf45b26e Bluetooth: ISO: Split connected and broadcast ISO Kconfig
Add a new Kconfig option, BT_ISO_UNICAST, to make it possible
either configure unicast only, broadcast only or both.

This results in some code being moved, but not modified, and
should not effect anything.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-22 08:21:00 -04:00
Jukka Rissanen
07bbc9045d net: context: Check null pointer access in check_used_port()
There is a small window between when socket is created and
before it is bound to a local address, where the local address
pointer might be NULL.

Fixes #36276

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-06-21 18:46:41 -04:00
Krzysztof Kopyściński
e62c3c533a Bluetooth: gatt: allow writing long device name
BT_DEVICE_NAME_MAX can be up to 248 bytes. This may exceed ATT MTU size,
which will cause the offset in write_name() to be non zere, resulting in
BT_ATT_ERR_INVALID_OFFSET. However, device name should be writable up to
it's defined size, using subsequent prepare write requests. Error should
be returned if offset exceeds size of device name, and if total size of
new value exceeds BT_DEVICE_NAME_MAX, BT_ATT_ERR_INVALID_ATTRIBUTE_LEN
shall be returned.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2021-06-19 16:55:56 -05:00