Commit graph

217 commits

Author SHA1 Message Date
Joakim Andersson b30b480c7c Bluetooth: UUID: Expose bt_uuid_to_str to application
Expose the bt_uuid_to_str function as an API to the application.
This aligns this function with the bt_addr_to_str function call. This
allows the application to use this function without having to enable
the BT_DEBUG option.

Move the in-place bt_uuid_str to internal logging, this is mainly done
due to the limitation in the log_strdup that shouldn't be exposed to the
application.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-12-09 17:15:05 +02:00
Johan Hedberg 39291fbbbe Bluetooth: Remove usage of BT_BUF_USER_DATA_MIN
This define is not of use anymore since there's a global net_buf user
data Kconfig variable and its definition already guarantees a
sufficient minimum for Bluetooth.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-11-28 13:35:11 +02:00
Stephane D'Alu 6ba1fcec3f Bluetooth: shell: Fix missing return statement for name command
Return once bt name has been displayed

Signed-off-by: Stephane D'Alu <sdalu@sdalu.com>
2019-11-17 21:03:24 +02:00
Andy Ross 8892406c1d kernel/sys_clock.h: Deprecate and convert uses of old conversions
Mark the old time conversion APIs deprecated, leave compatibility
macros in place, and replace all usage with the new API.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-11-08 11:08:58 +01:00
Ulf Magnusson bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Joakim Andersson 23e8e6891b Bluetooth: Shell: Disallow GATT commands when params are in use
GATT parameters need to remain valid while the procedure is active.
Disallow GATT commands while the procedure is active to avoid asserting.

Fixes: #20232

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-11-04 14:41:15 +01:00
Luiz Augusto von Dentz 03b9ce487c Bluetooth: GATT: Add support to setting permission on CCCD
This adds support to set different permissions to CCCD so security can
be checked when enabling notification which conforms to:

BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part G page 2360:

  '3.3.3.3 Client Characteristic Configuration

   Authentication and authorization may be required by the server to
   write the configuration descriptor.'

In addition to that also ensure that notification are not re-enabled
until the proper security level is reached to conform to the following
statement:

  '10.3.1.1 Handling of GATT indications and notifications

   A client “requests” a server to send indications and notifications
   by appropriately configuring the server via a Client Characteristic
   Configuration Descriptor. Since the configuration is persistent
   across a disconnection and reconnection, security requirements must
   be checked against the configuration upon a reconnection before
   sending indications or notifications. When a server reconnects to a
   client to send an indication or notification for which security is
   required, the server shall initiate or request encryption with the
   client prior to sending an indication or notification. If the client
   does not have an LTK indicating that the client has lost the bond,
   enabling encryption will fail.'

Fixes #17983

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-09-19 21:12:39 +03:00
Joakim Andersson 8f75cf732d Bluetooth: Shell: Fix shell build dependencies
Fix shell build dependencies, subsys/bluetooth/controller is only added
for CONFIG_BT_LL_SW_SPLIT or CONFIG_BT_LL_SW_LEGACY.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-09-07 15:48:35 +03:00
Joakim Andersson 3e9888105e Bluetooth: Host: Rename API function to initiate bluetooth security.
Rename bt_conn_security to bt_conn_set_security, this makes the API
naming more consistent.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-27 15:13:25 +02:00
Joakim Andersson 1c48757d94 Bluetooth: Host: Rename security level enum
Rename security level enum, using level and number instead of low,
medium, high and fips.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-27 15:13:25 +02:00
Joakim Andersson 545f090d8b Bluetooth: Shell: Add pairing failed and complete to OOB handling
Add pairing failed and complete callback to OOB authentication handlers.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-26 13:12:49 +02:00
Joakim Andersson bc19e241f9 Bluetooth: Shell: Add force-pair option to bt security command
Add shell argument to use bt_conn_security force pairing functionality.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-26 13:12:49 +02:00
Joakim Andersson 6d4b842a10 Bluetooth: Host: Add error to security changed callback
Add security error to security_changed callback. Call this callback when
security has failed and provide current security level and error.
Reason for failure can be.
 - Pairing procedure failed, pairing aborted before link encryption.
 - Link encrypt procedure failed
 - Link key refresh procedure failed.

Fix missing bt_conn_unref on encryption key refresh with error status.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-26 13:12:49 +02:00
Joakim Andersson 1fb68828ef Bluetooth: SMP: Add pairing failed reason
Forward the pairing failed SMP status code to the application

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-26 13:12:49 +02:00
Luiz Augusto von Dentz 5f3595e47c Bluetooth: GATT: Fix using variable size storage for CCC
This removes the necessity of registering the storage for CCC and make
it part of the declaration itself.

Fixes #18547

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-08-22 15:14:39 +03:00
Joakim Andersson 513244afe2 Bluetooth: Shell: Add whitelist commands to shell
Add shell commands to add and remove devices from the shell.
Add commands and options to use whitelist for advertising, scanning,
and creating connections.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-09 16:26:10 +02:00
Joakim Andersson 0307f6cd83 Bluetooth: Host: Improve shell OOB handling
Add authentication method using only OOB authentication data.
Add command to clear OOB data.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-09 11:20:31 +02:00
Joakim Andersson 835b1c1425 Bluetooth: Shell: Update sec level help text and validate input
Update bluetooth help text to include FIPS level in help text.
Also validate input range for the different connection types
Bluetooth security level for LE is from 1-4, while BR/EDR is 0-3

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-09 11:20:31 +02:00
Joakim Andersson e242c250c4 Bluetooth: Shell: Use on-air addresses when checking for OOB data
Authentication using OOB data uses the on-air device addresses used
during connection setup. So we need to check against the on-air
addresses in the info object to see if we have correct OOB data.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-08 15:49:19 +02:00
Joakim Andersson 90706a8217 Bluetooth: shell: Handle error code of bt_conn_auth_cb_register
Fix issue with registering authentication callback handlers failing
without notifying the user of the shell.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-08 15:49:19 +02:00
Joakim Andersson 7f1e67ba75 Bluetooth: shell: Add info command to print connection information
Add command to print connection info object.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-08 15:49:19 +02:00
Vinayak Kariappa Chettimada 857bcd96bd Bluetooth: shell: Fix directed adv parameter check
Fix the mandatory and optional parameter counts for the
directed adv shell command definition. Also, refactor the
command for consistency.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-08-08 11:33:51 +02:00
Mariusz Skamra 7c60300753 Bluetooth: Shell: Fix unregister GATT Metrics vendor service
The 'registered' flag was not cleared when 'gatt metrics off'
was called so that one was unable to register the service again.
Remove 'registered' variable that is actually not needed as there
is no tracking if service is already registered in similar
cmd_register_test_svc command. If the service is already registered,
the host will log an error.

Fixes: #17882
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2019-08-05 21:50:41 +02:00
Joakim Andersson c1a754f665 Bluetooth: Host: Print error codes in hex
Error codes are listed in header files and in the core spec as hex
values. Always print them in hex in debug for easier error code
checking.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-05 12:18:17 +02:00
Vinayak Kariappa Chettimada f4eb03c538 Bluetooth: controller: Rename BT_LL_SW to BT_LL_SW_LEGACY
Rename the controller Kconfig option BT_LL_SW to
BT_LL_SW_LEGACY in preparation towards switch to new Link
Layer implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-07-22 14:23:42 +02:00
Mariusz Skamra 2809bdf8c6 Bluetooth: shell: Fix L2CAP connect parameters count
This fixes mandatory parameters count.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2019-07-17 16:46:32 +02:00
Joakim Andersson e03bdba8a7 Bluetooth: shell: Add support for LE SC OOB authentication in shell
Add support for for LE secure connection using OOB authentication in the
shell.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-07-16 12:44:18 +02:00
Joakim Andersson 0ac83180fd Bluetooth: host: Move address string parsing to bluetooth API
Bluetooth address parsing has been duplicated across the different
sub-shell files. Also missing parsing of identity/resolved addresses.
Move parsing of string close to parsing to string for a symmetrical API

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-07-16 12:44:18 +02:00
Joakim Andersson 7a93e948a9 kernel: lib: Add convert functions for hex strings and binary arrays
Move duplicate hex2bin and add bin2hex function so that application can
use the functions and avoid code duplication.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-07-16 12:44:18 +02:00
Joakim Andersson 479edc9b51 Bluetooth: shell: Fix argument count of bt clear shell command
The bt clear command accepts either 'all' or a bluetooth address.
If it is an LE address then type is also needed.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-07-15 15:42:36 +02:00
Anas Nashif 9ab2a56751 cleanup: include/: move misc/printk.h to sys/printk.h
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 5d001f3e41 cleanup: include/: move misc/byteorder.h to sys/byteorder.h
move misc/byteorder.h to sys/byteorder.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Luiz Augusto von Dentz 3408bfe211 Bluetooth: shell: gatt: Add discover command
This adds discover command which can be used to discover all attributes
using BT_GATT_DISCOVER_ATTRIBUTE:

uart:~$ gatt discover
Discover pending
Descriptor 2800 found: handle 1
Descriptor 2803 found: handle 2
Descriptor 2a00 found: handle 3
Descriptor 2803 found: handle 4
Descriptor 2a01 found: handle 5
Descriptor 2800 found: handle 6
Descriptor 2803 found: handle 7
Descriptor 2a05 found: handle 8
Descriptor 2902 found: handle 9
Descriptor 2803 found: handle a
Descriptor 2b29 found: handle b
Descriptor 2803 found: handle c
Descriptor 2b2a found: handle d
Descriptor 2803 found: handle e
Descriptor 2b2b found: handle f

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-06-24 12:16:49 +02:00
Johan Hedberg 4396dc9c71 Bluetooth: Simplify bt_gatt_notify_cb() API
This API had several issues:

 - The parameter types and order were inconsistent with e.g.
   bt_le_adv_start()
 - There were no real users of num_params, which just caused increased
   code size and memory consumption for no good reason.
 - The error handling policy was arbitrary: if one of the
   notifications would fail it would be impossible for the caller to
   know if some notifications succeeded, i.e. at what point the
   failure happened. Some callers might also want to make note of the
   failure but continue trying to notify for the remaining parameters.

The first issue is easily fixable, but because of the other two I
think it's best we don't have this code as part of the stack, rather
require whoever needs it to do the for loop themselves. It's just a
few lines of code, so the benefit of having this in the stack was
anyway quite minimal.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-06-15 10:37:19 +03:00
Luiz Augusto von Dentz ada05eaaf4 Bluetooth: shell: Add number of matches to gatt show-db
This adds number of matches as optional parameter to gatt show-db:

> gatt show-db 2803 1
attr 0x005065f0 handle 0x0002 uuid 2803 perm 0x01

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-06-12 20:09:29 +03:00
Anas Nashif 4c32258606 style: add braces around if/while statements
Per guidelines, all statements should have braces around them. We do not
have a CI check for this, so a few went in unnoticed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-06 15:20:21 +02:00
Vinayak Kariappa Chettimada d244ee878f Bluetooth: shell: Fix disconnect command argument count
Fix disconnect command optional argument count to permit the
supply of Bluetooth Address so as to be able to cancel a
pending central initiated connection creation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-06-05 16:29:06 +02:00
Vinayak Kariappa Chettimada a2c84ecf9e Bluetooth: Fix building of broadcaster or observer only
Fix conditional compilations to allow building broadcaster
and/or observer only applications.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-06-04 14:08:59 +02:00
Luiz Augusto von Dentz 2692f2e616 Bluetooth: Shell: Add gatt notify command
This adds gatt notify command which can be used to exercise the
bt_gatt_notify* APIs.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-06-04 09:52:47 +03:00
Luiz Augusto von Dentz 93dfa640dd Bluetooth: Shell: Fix having gatt unregister twice
Only one command handle shall be needed.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-06-04 09:52:47 +03:00
Luiz Augusto von Dentz 9bf61dac75 Bluetooth: shell: Make use of bt_gatt_foreach_attr_type
This make use of bt_gatt_foreach_attr_type in gatt show-db to match
attributes by UUID.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-06-04 09:52:47 +03:00
Luiz Augusto von Dentz f8f6e7e117 Bluetooth: shell: Print L2CAP channel status
This uses the new status callback to print the channel status
whenever it changes.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-05-29 16:31:03 +03:00
Luiz Augusto von Dentz 74135b3392 Bluetooth: shell: Add sent callback to L2CAP ops
This prints to the output when a packet finishes transmitting:

uart:~$ l2cap send 2
Outgoing data channel 0x005166a0 transmitted
Outgoing data channel 0x005166a0 transmitted

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-05-29 16:31:03 +03:00
Luiz Augusto von Dentz b65fe62719 Bluetooth: Add possibility to pass a user_data to conn_tx_cb_t
This allows setting a custom pointer to be passed back to the complete
callback at expense of increasing the buffers in 4 bytes.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-05-29 16:31:03 +03:00
Luiz Augusto von Dentz f9e89e5532 Bluetooth: shell: GATT: Make get command take a handle range
This enables get command to operate on a handle range so multiple
attributes values can be printed out:

uart:~$ gatt get 0x0001 0xffff
attr 0x00506600 uuid 2800 perm 0x01
00000000: 01 18
attr 0x00506600 uuid 2803 perm 0x01
00000000: 20 03 00 05 2A
attr 0x00506600 uuid 2a05 perm 0x00
attr 0x00506600 uuid 2902 perm 0x03
00000000: 00 00
attr 0x00506600 uuid 2803 perm 0x01
00000000: 0A 06 00 29 2B
attr 0x00506600 uuid 2b29 perm 0x03
00000000: 00
attr 0x00506600 uuid 2803 perm 0x01
00000000: 02 08 00 2A 2B
attr 0x00506600 uuid 2b2a perm 0x01
00000000: AA 2D 05 EB E8 1D D0 E5 F7 B9 C1 B6 3F 66 93 15
attr 0x00506600 uuid 2800 perm 0x01
00000000: 00 18
attr 0x00506600 uuid 2803 perm 0x01
00000000: 0A 0B 00 00 2A
attr 0x00506600 uuid 2a00 perm 0x09
00000000: 74 65 73 74 20 73 68 65 6C 6C
attr 0x00506600 uuid 2803 perm 0x01
00000000: 02 0D 00 01 2A
attr 0x00506600 uuid 2a01 perm 0x01
00000000: 00 00
attr 0x00506600 uuid 2803 perm 0x01
00000000: 02 0F 00 A6 2A
attr 0x00506600 uuid 2aa6 perm 0x01
00000000: 01
attr 0x00506600 uuid 2803 perm 0x01
00000000: 02 11 00 04 2A
attr 0x00506600 uuid 2a04 perm 0x01
00000000: 18 00 28 00 00 00 2A 00
attr 0x00506600 uuid 2800 perm 0x01
00000000: 0D 18
attr 0x00506600 uuid 2803 perm 0x01
00000000: 10 14 00 37 2A
attr 0x00506600 uuid 2a37 perm 0x00
attr 0x00506600 uuid 2902 perm 0x03
00000000: 00 00
attr 0x00506600 uuid 2803 perm 0x01
00000000: 02 17 00 38 2A
attr 0x00506600 uuid 2a38 perm 0x01
00000000: 00
attr 0x00506600 uuid 2803 perm 0x01
00000000: 08 19 00 39 2A
attr 0x00506600 uuid 2a39 perm 0x00

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-05-07 23:17:13 -04:00
Luiz Augusto von Dentz bd007141fd Bluetooth: GATT: Rename BT_GATT_DB to BT_GATT_DYNAMIC_DB
This should be clearer about the intent of the option.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-05-02 08:29:23 +03:00
Luiz Augusto von Dentz 2c4e5d5f16 Bluetooth: GATT: Disable dynamic database by default
This makes BT_GATT_DB default to n which reduces the ram required for
many samples.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-05-02 08:29:23 +03:00
Tedd Ho-Jeong An 6576efe038 Bluetooth: shell: Add command for Read Using Characteristic UUID
This patch adds a command for Read Using Characteristic UUID.

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-04-24 09:39:53 -07:00
Luiz Augusto von Dentz 2ba6146f66 Bluetooth: Shell: Add GATT command set
This introduces set command to GATT which can be used to write local
attributes:

uart:~$ gatt set 0x000b 62 6c 61 68
attr 0x004235a8 uuid 2a00 perm 0x09
00000000: 62 6C 61 68

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-04-18 17:50:16 -04:00
Luiz Augusto von Dentz 4c80bb57aa Bluetooth: Shell: Add GATT command get
This introduces get command to GATT which can be used to read the
local attributes:

uart:~$ gatt get 0x000b
attr 0x004235a8 uuid 2a00 perm 0x09
00000000: 74 65 73 74 20 73 68 65 6C 6C

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-04-18 17:50:16 -04:00
Luiz Augusto von Dentz 090f95d2ba Bluetooth: Shell: Add option UUID parameter to GATT show-db
This enables locating specific attribute in the database:

uart:~$ gatt show-db 0x2a00
attr 0x004235a8 handle 0x000b uuid 2a00 perm 0x09

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-04-18 17:50:16 -04:00
Luiz Augusto von Dentz 26fea23435 Bluetooth: shell: Make show-db print the total number of attributes
In addition to just print each attribute this also include the total
number of attribute and how much the database consumes:

uart:~$ gatt show-db
attr 0x00423460 handle 0x0001 uuid 2800 perm 0x01
attr 0x00423474 handle 0x0002 uuid 2803 perm 0x01
attr 0x00423488 handle 0x0003 uuid 2a05 perm 0x00
attr 0x0042349c handle 0x0004 uuid 2902 perm 0x03
attr 0x004234b0 handle 0x0005 uuid 2803 perm 0x01
attr 0x004234c4 handle 0x0006 uuid 2b29 perm 0x03
attr 0x004234d8 handle 0x0007 uuid 2803 perm 0x01
attr 0x004234ec handle 0x0008 uuid 2b2a perm 0x01
attr 0x00423580 handle 0x0009 uuid 2800 perm 0x01
attr 0x00423594 handle 0x000a uuid 2803 perm 0x01
attr 0x004235a8 handle 0x000b uuid 2a00 perm 0x09
attr 0x004235bc handle 0x000c uuid 2803 perm 0x01
attr 0x004235d0 handle 0x000d uuid 2a01 perm 0x01
attr 0x004235e4 handle 0x000e uuid 2803 perm 0x01
attr 0x004235f8 handle 0x000f uuid 2aa6 perm 0x01
attr 0x0042360c handle 0x0010 uuid 2803 perm 0x01
attr 0x00423620 handle 0x0011 uuid 2a04 perm 0x01
=================================================
Total: 2 services 17 attributes (476 bytes)

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-04-18 17:50:16 -04:00
Luiz Augusto von Dentz 09c06a1232 Bluetooth: Shell: Convert users of hexdump to shell_hexdump
This replaces the use of hexdump with shell_hexdump and removes the
former.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-04-18 17:50:16 -04:00
Jim Paris 7cdfe7f26f Bluetooth: shell: fix build warning if !BT_CENTRAL
Fixes:
  .../zephyr/subsys/bluetooth/shell/bt.c:906:12:
     warning: 'cmd_chan_map' defined but not used [-Wunused-function]

Signed-off-by: Jim Paris <jim@jtan.com>
2019-04-08 12:36:15 +03:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Carles Cufi 42fcaf2df4 Bluetooth: shell: Add missing include path
When building ticker.c from the shell, it requires include access to the
Nordic HAL, so add the relevant folder to the include path.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-03-26 10:18:59 -05:00
Jakub Rzeszutko 41ad9b716c shell: fix command bt scan
Command scan fixed in the way that it can take one mandatory parameter
and one optional. Previously it accepted only 2 mandatory parameters.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2019-03-25 20:38:35 +02:00
Jakub Rzeszutko 4557b6b2d1 shell: removed dead code in bt command
Removed automatic argument count checking in bt command. Now
it is possible to print a message that extra argument is not
recognized.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2019-03-25 20:38:35 +02:00
Jakub Rzeszutko b6fc1af6ba shell: unify bt commands return value
Repleaced magic number 1 with define SHELL_CMD_HELP_PRINTED

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2019-03-25 20:38:35 +02:00
Flavio Ceolin 23e75c1492 bluetooth: shell: Fix uninitialized variable
Variable evt_prop could be used without being initialized. This problem
was spotted by coverity.

CID 190970

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2019-03-01 09:19:31 +01:00
Krzysztof Chruscinski 3605e48c44 shell: Modify subcommands to use SHELL_STATIC_SUBCMD_SET_CREATE
It is planned to deprecate SHELL_CREATE_STATIC_SUBCMD_SET macro
which is replaced by SHELL_STATIC_SUBCMD_SET_CREATE.

Additionally, removed irrelevant comments about alphabetical
ordering which is no longer needed.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-02-20 07:31:35 -05:00
Carlos Stuart 75f77db432 include: misc: util.h: Rename min/max to MIN/MAX
There are issues using lowercase min and max macros when compiling a C++
application with a third-party toolchain such as GNU ARM Embedded when
using some STL headers i.e. <chrono>.

This is because there are actual C++ functions called min and max
defined in some of the STL headers and these macros interfere with them.
By changing the macros to UPPERCASE, which is consistent with almost all
other pre-processor macros this naming conflict is avoided.

All files that use these macros have been updated.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-14 22:16:03 -05:00
Vinayak Kariappa Chettimada 85d92923e2 Bluetooth: controller: Rename non-Kconfig option macros
Remove CONFIG_ prefix from non-Kconfig macro definitions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-02-13 09:20:26 -05:00
Vinayak Kariappa Chettimada 4c77bf6194 Bluetooth: controller: Remove redundant tmp role implementation
Remove the redundant proof of concept template temporary
role implementation from the repository.

Relates to #12860.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-02-05 15:00:08 +01:00
Vinayak Kariappa Chettimada 5478e82993 Bluetooth: shell: Updates related to new ULL LLL architecture
Updates related to new ULL LLL controller architecture.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-01-23 09:45:06 +01:00
Vinayak Kariappa Chettimada 254a97af93 Bluetooth: controller: Preliminary work in progress mesh ext.
Preliminary work done towards Mesh extensions on the old LL
architecture implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-01-23 09:45:06 +01:00
Luiz Augusto von Dentz 478b6b5381 Bluetooth: Shell: Add write-without-response-cb command
This adds write-without-response-cb command which can be used to
confirm the transmission of the PDU using bt_gatt_write_without_rsp_cb.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-01-16 21:43:53 -05:00
Johan Hedberg a886229c2b Bluetooth: shell: Fix incorrect indentation
This line was indented using four spaces instead of a tab.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-01-11 15:27:38 +02:00
Wenjie Xu ce43d428c0 Bluetooth: shell: Fix NULL shell context
On bt_ready, ctx_shell would be NULL if not initialized before
bt_enable.

Signed-off-by: Wenjie Xu <xuwenjie@huantengsmart.com>
2019-01-10 11:56:07 +01:00
Vinayak Kariappa Chettimada dfe415a912 Bluetooth: shell: Changes related to controller split preparation
Changes to Bluetooth shell application related to the
controller split architecture preparation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-01-07 13:42:01 +01:00
Vinayak Kariappa Chettimada 87fe440f01 Bluetooth: controller: Prepare to introduce LL split architecture
Preparation to introduce the Upper Link Layer (ULL) and
Lower Link Layer (LLL) split architecture.

- Move SoC dependent HAL to vendor specific folder.
- Preparation to split data structures into ULL and LLL
  types.
- Added more role and state conditional compilations.
- Added some work-in-progress implementation of advertising
  extensions, will be used as inspiration in the new split
  architecture work.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-01-07 13:42:01 +01:00
Jakub Rzeszutko f0b19181e0 bt_shell: fix command bt advertise valid argument count
Changed number of valid arguments from two required to
one required and one optional.

Command can be called with required <type: off, on, scan, nconn>
and optional <mode: discov, non_discov>".

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-18 18:52:00 +02:00
Jakub Rzeszutko b928b71756 shell: rename shell_help_print function
Function printing help has been renamed to shell_help.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Jakub Rzeszutko 3064ca4f2f shell: creating new module for help functionality
1. Created new shell module: shell_help.
2. Simplified command handlers with new shell print macros.
3. Removed help functions from command handlers.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Jakub Rzeszutko 5451ff2848 shell: remove "options" concept
Removing help "options" from shell API.

Currently SHELL_OPT macro is not used by users. What is more
commit: a89690d10f ignores possible options created in
command handler by the user. As a result they are not printed
in help message.

Second, currntly implemented "options" in command handlers options are
implemented without SHELL_OPT macro.

And last but not least this change will allow to implement
help handler in a way that user will not need to think about calling
functions printing help in a command handler.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Patrik Flykt b97db52de7 misra-c: Add 'U' to unsigned variable assignments in subsys/
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Luiz Augusto von Dentz 67e4710598 Bluetooth: shell: Make use of SHELL_CMD_ARG
Use SHELL_CMD_ARG to register commands.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-11-13 20:42:01 +02:00
Luiz Augusto von Dentz b7c6ea4971 Bluetooth: shell: Remove macros to print messages
Make use of shell_print and shell_error now that they are available.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-11-13 20:42:01 +02:00
Luiz Augusto von Dentz 4add794570 Bluetooth: shell: Remove auto selecting of SERIAL
This is no longer needed and the shell itself will take care of
selecting SERIAL.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-11-13 20:42:01 +02:00
Luiz Augusto von Dentz 75979397b2 Bluetooth: shell: Fix illegal access
BT_LE_ADV_CONN_DIR_LOW_DUTY declares a local variable so it cannot go
out of scope, so instead of assigning in the scope of the if statement
this rework the code to mantain the declaration in the same scope it is
used.

Fixes #10570

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-11-09 16:18:44 +02:00
Johan Hedberg 97141734f1 Bluetooth: shell/gatt: Fix unreachable code
The code had somehow gotten corrupt (yet in a way that it compiles) so
that an intended if-branch was missing.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-11-06 22:29:51 +02:00
Mariusz Skamra 74318e61ca Bluetooth: Change l2cap accept callback return error
This changes EKEYREJECTED to EPERM due to newlib dependencies
errors.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-10-26 16:56:01 +01:00
Mariusz Skamra c04b70469b Bluetooth: shell: Add possibility to reject L2CAP CoC conn request
This adds a possibility to reject incomming LE Connection request
due to insufficient authorization or encryption key size.
This is needed for qualification purposes

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-10-25 08:02:54 +01:00
Satya Bhattacharya 6063707662 bluetooth: shell: Uninitialized scalar variables
Initialize variables chan_map in bt.c
Pass NULL and 0 directly to bt_le_adv_start()
Coverity-CID: 188735
Coverity-CID: 188729

Fixes #10588 #10594

Signed-off-by: Satya Bhattacharya <satyacube@gmail.com>
2018-10-21 15:09:54 +03:00
Johan Hedberg 343c53e841 Bluetooth: Switch from SYS_LOG to logger-based logging
Initial conversion to use syslog instead of logger.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-10-19 14:50:22 +02:00
Jakub Rzeszutko 147122e77f shell: examples unification
Updating examples according to new return value of function
shell_cmd_precheck.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-10-19 13:35:56 +02:00
Anas Nashif 3aa2a1c6db flash: make flash shell generic
This shell command was tied to bluetooth and the bluetooth shell and
also had messages all related to nordic ICs.
Make it generic and put it under drivers/flash/ so it can be included by
anyone and independently of bluetooth.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-19 11:49:18 +02:00
Alberto Escolar Piedras 5f39dbb1b0 Bluetooth: Use new nrf COMPATIBLE options
To allow the BLE stack to be used both in the real nRF platforms
and simulated ones, change the used macros in the code to the
COMPATIBLE ones.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-10-15 09:36:37 -04:00
Radoslaw Koppel 152b15ab3b subsys: bluetooth: shell: bt: Add command to show LL address
This commit implements command in the shell to show current
link layer address.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
2018-10-04 10:35:06 +02:00
Luiz Augusto von Dentz 76714c1480 Bluetooth: Shell: Make error message for unknown parameter consistent
Also simplify it by having the 'unknown parameter:' as part of the
message format.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-10-03 09:49:58 +02:00
Luiz Augusto von Dentz ba545e0d3c Bluetooth: shell: Fix using \n with print/error
Those macros already contain line termination.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-10-03 09:49:58 +02:00
Carles Cufi 990ab2de70 Bluetooth: shell: Transition flash.c to the new shell
Convert the flash.c functions to the new shell format.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-10-02 18:41:11 +02:00
Carles Cufi 63f4d9f509 Bluetooth: shell: Transition ticker.c to the new shell
Convert the ticker.c functions to the new shell format.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-10-02 18:41:11 +02:00
Carles Cufi 5372950336 Bluetooth: shell: Transition ll.c to the new shell
Convert the ll.c functions to the new shell format.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-10-02 18:41:11 +02:00
Jakub Rzeszutko 0eea1ef212 subsys: shell: add int ret_val to command handlers
1. Command handler can return command exectution status as int.
2. Existing command handlers rework.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-10-02 14:44:25 +02:00
Luiz Augusto von Dentz 17558c9382 Bluetooth: shell: Use \r\n to terminate line
Shell expects each printed lined to be terminated with \r\n.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-10-01 11:10:46 +02:00
Luiz Augusto von Dentz fb4785d274 Bluetooth: shell: Split L2CAP commands
This splits L2CAP commands under 'bt' to 'l2cap' removing 'l2cap-'
prefix from the commands:

l2cap - Bluetooth L2CAP shell commands
Options:
  -h, --help  :Show command help.
Subcommands:
  connect     :<psm>
  disconnect  :[none]
  metrics     :<value on, off>
  recv        :[delay (in miliseconds)
  register    :<psm> [sec_level]
  send        :<number of packets>

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-10-01 11:10:46 +02:00
Luiz Augusto von Dentz 043a8b0202 Bluetooth: shell: Split GATT commands
This splits GATT command under 'bt' to 'gatt' removing 'gatt-' prefix
from commands:

gatt - Bluetooth GATT shell commands
Options:
  -h, --help  :Show command help.
Subcommands:
  discover-characteristic  :[UUID] [start handle] [end handle]
  discover-descriptor      :[UUID] [start handle] [end handle]
  discover-include         :[UUID] [start handle] [end handle]
  discover-primary         :[UUID] [start handle] [end handle]
  discover-secondary       :[UUID] [start handle] [end handle]
  exchange-mtu             :[none]
  read                     :<handle> [offset]
  read-multiple            :<handle 1> <handle 2> ...
  subscribe                :<CCC handle> <value handle> [ind]
  write                    :<handle> <offset> <data> [length]
  write-without-response   :<handle> <data> [length] [repeat]
  write-signed             :<handle> <data> [length] [repeat]
  unsubscribe              :[none]
  metrics                  :register vendr char and measure rx
			    [value on, off]
  register                 :register pre-predefined test service
  show-db                  :[none]
  unregister               :unregister pre-predefined test service

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-10-01 11:10:46 +02:00
Luiz Augusto von Dentz bcfc9939e4 Bluetooth: shell: Split RFCOMM commands
This splits RFCOMM command under 'br' to 'rfcomm' removing 'rfcomm-'
prefix from commands:

rfcomm - Bluetooth RFCOMM shell commands
Options:
  -h, --help  :Show command help.
Subcommands:
  register    :<channel>
  connect     :<channel>
  disconnect  :[none]
  send        :<number of packets>

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-10-01 11:10:46 +02:00