Commit graph

41120 commits

Author SHA1 Message Date
Luiz Augusto von Dentz
29921c9e83 Bluetooth: Add support for testing nble driver with samples
This adds a test case that passes prj_nble.conf as CONF_FILE so that
the same code tested using HCI Bluetooth driver is also tested using
NBLE driver.

Change-Id: Ia4ad59d74b82c02007c55ea4fa8f53833d7a7fe5
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:20 -05:00
Luiz Augusto von Dentz
dc2c434ff7 drivers/nble: Add BLUETOOTH_MAX_PAIRED
This makes it easier to port samples which may use
CONFIG_BLUETOOTH_MAX_PAIRED.

Change-Id: I3e37df7cae63a4ac2219ce26408ae4d4f987645d
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:20 -05:00
Arkadiusz Lichwa
32a86ca351 Bluetooth: BR/EDR: Store new combination link key
Updates connection object keys using generated link key and mark the
key as legacy after successful pairing initiated by remote.

Change-Id: Idcd02ea12c45f6f19f6675a2d6161a8349dde170
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:20 -05:00
Arkadiusz Lichwa
cdd0d308c7 Bluetooth: BR/EDR: Add all legacy and SSP link key types
Adds all valid link keys types available during legacy and SSP
authentication.

Change-Id: I42f2aba0122d33a984bd84c56b7a6a290f5e9e1d
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:20 -05:00
Arkadiusz Lichwa
53de0818f9 Bluetooth: BR/EDR: Update keys management
Updates keys interfaces allowing to store and locate legacy link key
in keys database.

Change-Id: Ibd50edff890e998e3c6f80ee7f1442dff7a7c91f
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:20 -05:00
Luiz Augusto von Dentz
d65dcc5e4b Bluetooth: GATT: Replace handle with attribute object in bt_gatt_notify
This make more sense since the handles are normally self allocated by
the stack.

Change-Id: I198dd9c3ef6259cff8a0e528514918ec18990dea
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:20 -05:00
Luiz Augusto von Dentz
05da1e9b01 Bluetooth: Rename prj_x86.conf to prj.conf
There is no need to keep arch specific prj.conf for these samples are
they are always the same.

Change-Id: I0f93b5a47458f9800a6654cc45914b911b42b3e3
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:20 -05:00
Mariusz Skamra
6ccccc75a8 Bluetooth: btp: Make Configure Notify/Indicate cmds return status
These commmands don't have to return ATT error code, because
status BTP status is sufficient.

Change-Id: I5405bfbc0ad6fbac46eb3dab1ee63d3e18bf38fc
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:20 -05:00
Mariusz Skamra
cd69293bf6 Bluetooth: tester: Add Configure notifications/indications cmds
This patch adds implementation of handlers for Configure Notifications
and Configure Notifications BTP commands.

Change-Id: I92c40836c09e145ea405226f321dd752ac16fc9f
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:20 -05:00
Mariusz Skamra
0198c192ea Bluetooth: tester: Add notifications/indications struct defines
This patch adds noifications and indications commands and event
related structure defines to the tester application.

Change-Id: I532ab6471d2e7671213bfa526e7261308dd4b2f6
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:20 -05:00
Mariusz Skamra
7abc58cb1d Bluetooth: btp: Rename Configure Notifications cmd parameter
Enable seems to be more appropriate than Toggle.

Change-Id: I69ef509c47ddd7b76bc16684af60821328a7c647
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:20 -05:00
Mariusz Skamra
87a51595fc Bluetooth: tester: Add BTTESTER_DBG macro for logging
This adds BTTESTER_DBG logging macro.

Change-Id: I5a884ccb8ed50d1c663b4cc87b77e9680f9b9492
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:20 -05:00
Arkadiusz Lichwa
b713d8462f Bluetooth: samples/shell: Fix printing bluetooth address for BR/EDR
Adjust printing bluetooth address in auth_cancel() user callback.

Change-Id: Ic39eeac36394d73eaee27c04bcad17e32704bbe7
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:20 -05:00
Johan Hedberg
4668ba761a drivers/nble: Add stub for bt_gatt_attr_next()
Change-Id: I0a568c62a15100b12df187fb6b0205dfbae7cc0b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:20 -05:00
Luiz Augusto von Dentz
6517da9dc9 Bluetooth: tester: Fix using attribute _next
_next member, as the name suggest, is internal and shall not be used by
application directly instead application must use bt_gatt_attr_next.

Change-Id: I7c137eae555475d024098cd14a54d965cb397eae
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:20 -05:00
Luiz Augusto von Dentz
ea1534f100 Bluetooth: GATT: Add bt_gatt_attr_next function
This add bt_gatt_attr_next function that can be used to iterate to next
attribute which is convenient if original attribute is known and using
bt_gatt_foreach_attr would require a lookup and another function to pass
as callback.

Change-Id: I1bd522fd4ae784e08aa375b35320191cbfc03a54
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:20 -05:00
Andrei Emeltchenko
d2d857bac0 Bluetooth: samples/nble: Add debug output
Let us know that bt_enable() is successful.

Change-Id: I70581d950a9a922e809804bacfbfa039b2fec2fe
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:20 -05:00
Mariusz Skamra
21198af4b8 Bluetooth: Fix missing curly brackets
Change-Id: Ia984448040d68e0f8674295028c6982887420e6a
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:20 -05:00
Mariusz Skamra
4b7124b637 Bluetooth: GATT: Fix error response in Find by Type response
We shouldn't respond with an error if the read of UUID failed.
It's because we don't know if this UUID was the one that client
requested in the Find by Type Value request.

Change-Id: I34c336b9afc3520194fbddaaee8a44d51beabad5
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:20 -05:00
Mariusz Skamra
de6029ee25 Bluetooth: GATT: Fix Find by Type response
This fixes bug where wrong service handles have been sent while
discovering the primary services. We should skip Secondary Service
contained in range 0x0006-0x0009 in this case:

> ACL Data RX: Handle 64 flags 0x02 dlen 13    [hci0] 619772.398445
      ATT: Find By Type Value Request (0x06) len 8
        Handle range: 0x0001-0xffff
        Attribute type: Primary Service (0x2800)
          UUID: Generic Access Profile (0x1800)
< ACL Data TX: Handle 64 flags 0x00 dlen 9     [hci0] 619772.403821
      ATT: Find By Type Value Response (0x07) len 4
        Handle range: 0x0001-0x0009

With this patch:

> ACL Data RX: Handle 64 flags 0x02 dlen 13    [hci0] 618945.922607
      ATT: Find By Type Value Request (0x06) len 8
        Handle range: 0x0001-0xffff
        Attribute type: Primary Service (0x2800)
          UUID: Generic Access Profile (0x1800)
< ACL Data TX: Handle 64 flags 0x00 dlen 9     [hci0] 618945.927933
      ATT: Find By Type Value Response (0x07) len 4
        Handle range: 0x0001-0x0005

Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
Change-Id: I7bb743e8787bc294ba447be5e21e250f0128ec68
2016-02-05 20:25:20 -05:00
Luiz Augusto von Dentz
6e8ab42997 Bluetooth: Make peripheral sample use CONFIG_BLUETOOTH_GATT_DYNAMIC_DB
This makes sure the code behind CONFIG_BLUETOOTH_GATT_DYNAMIC_DB builds
properly and sanity_check is able to detect problems whenever there is
a change affecting it.

Change-Id: If46d1d9723f9daa494611e5a1799afd943e6519c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:20 -05:00
Luiz Augusto von Dentz
c44ef91e56 Bluetooth: GATT: Add support for static DB
This enable applications to build with a single table representing the
database where attributes don't have to store a pointer to the next
attribute thus reducing its size.

Change-Id: I4c84e2d50f9088a2f9879068890f0646e586e007
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:20 -05:00
Mariusz Skamra
66cb6b335e Bluetooth: GATT: Fix invalid att pointer dereference
This fixes invalid att pointer dereference to get the tx MTU size.

Change-Id: Ifc7911ee58fd4ddff10d1839aff5df9a6e805de8
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:20 -05:00
Mariusz Skamra
76bc832607 Bluetooth: GATT: Fix Read by Group Type response
This fixes bug where wrong service handles have been sent while
discovering the primary services. We should skip Secondary Service
contained in range 0x0006-0x0009 in this case:

      ATT: Read By Group Type Response (0x11) len 13
        Attribute data length: 6
        Attribute group list: 2 entries
        Handle range: 0x0001-0x0009
        UUID: Generic Access Profile (0x1800)
        Handle range: 0x000a-0x000e
        UUID: Unknown (0xaa50)

With this patch:

      ATT: Read By Group Type Response (0x11) len 13
        Attribute data length: 6
        Attribute group list: 2 entries
        Handle range: 0x0001-0x0005
        UUID: Generic Access Profile (0x1800)
        Handle range: 0x000a-0x000e
        UUID: Unknown (0xaa50)

Change-Id: I8121521e76476826296a2bedf9e18ef008f81363
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:19 -05:00
Andrei Emeltchenko
0190ba7abd Bluetooth: samples/nble: Disable ARC core
Disabling ARC core allows to flash only lakemont and decrease unneeded
debug output.

Change-Id: Ifb913274302d7c69f1fb9c2e1747742d7a810627
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:19 -05:00
Andrei Emeltchenko
0715bf057b quark_se: Add default configuration for Nordic BLE iface
Define configuration for Nordic chip connected to UART0.

Change-Id: Ia6007def747932e5f9fbd57f1ea8005892a2f793
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:19 -05:00
Andrei Emeltchenko
bdbd02bd26 Bluetooth: samples/nble: Only test on quark_se
Test Nordic BLE on platforms which has support for it, at least we
need a UART configured to be connected to the chip.

Change-Id: I040fbb33436ae6bf973b521d52bf7b971993559a
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg
f190371781 Bluetooth: Add stubs for directed advertising API
Add API definition and stubs for directed advertising.

Change-Id: Ib22d3acb6d2e76b0c638b26b8e07860cd189f640
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg
bc073cdb59 Bluetooth: Add bt_conn prefix for auth APIs
All of the authentication APIs deal with bt_conn objects. For
consistency it makes therefore sense to use the proper bt_conn name
space with them.

Change-Id: I47912d542373df511524cc6ad2532d6c9a76ca68
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg
d565ac5e1f drivers/nble: Move conn.h functions from gap.c to conn.c
Change-Id: I123e51f02e474ba1b0b7ac195a0da5900b523a53
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg
d72744984c Bluetooth: Move bt_auth_* implementation to conn.c
Change-Id: Ia73f898d782c3843d70a5186c21e22199bee593e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg
044dda711f Bluetooth: Move bt_le_set_auto_conn() to conn.c
Change-Id: I07763cab88c73eaf5cb3009651a6f20c9e9bb43d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg
25f6579016 Bluetooth: Move all bt_conn related APIs to conn.h
To have some proper split of conn.h and bluetooth.h APIs make sure all
bt_conn related ones are in conn.h. This also helps avoid forward
declarations for some upcoming patches where we need bluetooth.h
defines from within conn.h.

Change-Id: Ief3d32118a6749fb5785dab6cb3fee4ebb86ddb4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg
41e7ebfb72 Bluetooth: Return error if app gives invalid AD data
It's not a good idea to silently truncate the data if we got a too
large array from the app.

Change-Id: Ie4541599c6846efd53c81310c8d1e4dd5ec00cee
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg
02740a8083 Bluetooth: Refactor AD data HCI commands to helper function
The advertising data and scan response data HCI commands are almost
identical so we can save some code size by having a helper function
for them.

Change-Id: I9f80477ab7837c0a8efa0f9219552ea1426978d4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Luiz Augusto von Dentz
2d5dc34c94 Bluetooth: Kconfig: Add config option for dynamic GATT db
This option will be used to determine if bt_gatt_attr need to store the
next attribute or if it directly accessible by index.

Change-Id: I98fd43931d67d6c3be3b7a130e6fd2f97f2c4a3a
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:19 -05:00
Mariusz Skamra
3f58f09864 Bluetooth: tester: Increase gatt_buf buffer size
This is needed for GATT Server tests to implement larger attribute
databases.

Change-Id: Id160ac81b3e393697bdacd3e19033e9ff7c10fde
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg
672bf0d63c Bluetooth: SMP: Return errors from authentication APIs
This way we can pass any errors back to the application.

Change-Id: Ic53b858a73436e1c9c4d03e358aeffae7fd837ab
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg
432c2db4d8 Bluetooth: Add err/reason parameters to connected/disconnected calls
This is essential so that the application can be notified of
connection failures and also be able to know the reason for the
disconnection.

Change-Id: I30108958963f6aeac690612bb26738dc4c67ca80
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Szymon Janc
2dcde0fe04 Bluetooth: Fix registering LE fixed channels on BR/EDR link
This is a minimal fix as for now only LE fixed channels are supported.

Change-Id: Id88cae49f5cdbe3b9d3695995929d601a3b561bd
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:19 -05:00
Szymon Janc
66f0ad5335 Bluetooth: Fix updating SMP keys on BR/EDR
This should be done only for LE links.

Change-Id: I3037e5fbceb39de46ec0be389401f5e907837399
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:19 -05:00
Szymon Janc
28711287a5 Bluetooth: SMP: Remove not needed NULL check from bt_smp_update_keys
This function is always called with valid connection.

Change-Id: I756990a22f7c56939fd8e92c498d722a0467ab84
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:19 -05:00
Szymon Janc
ff6b44dfcf Bluetooth: ATT: Use l2cap channel callback for security check
There is no need for using conn security calback while l2cap
channel provides encryption callback.

Change-Id: I84872bca7a7b4334b52810bafd0faa2bb1e381de
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg
0df7a2fac6 Bluetooth: Add error return to authentication APIs
The authentication APIs may fail, so it's fair to give the application
a chance to catch these errors.

Change-Id: I323df86b94a823b201fe22d412e6bbcaa9029550
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg
8bf880a388 Bluetooth: Use smallest possible size for enums
Use __packed so that enums consume the smallest possible size (in our
case the same as uint8_t).

Change-Id: I0440113e88a24509f406375d99173ddb54890925
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg
3c47e9515c Bluetooth: Update advertising API
Update the advertising API according to what has recently been
discussed and agreed upon.

Naming-wise the most important change is the removal of "EIR" which
was confusing since this is mainly used with LE at the moment. The
Core Specification Supplement consistently uses the generic terms data
and data type to describe what we're dealing with here, so the new
names are bt_data and BT_DATA.

Another change is to detach the actual data from the struct by
converting it from an array to a pointer. This is not only essential
for supporting BR/EDR (which has a different length) but to also
minimize memory usage.

Another change is to require the caller of bt_le_adv_start() to
provide the array lengths of the ad and sd paramters. This way we
don't have to have the empty (8-byte) element at the end of each
array.

Lastly, the bt_le_adv_start() logic is slightly modified so that it
will always clear the respective data if necessary. Previously the
user might have been left with a previous callers data if it passed
NULL to the API.

Change-Id: I318026ceb1b52bb688edf4dcfed82613bd15c3e1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Arkadiusz Lichwa
7e9b66ae93 Bluetooth: samples/shell: Fix printing bluetooth address for BR/EDR
Uses proper bluetooth address during printing to standard output
when monitors connected, disconnected and security changed states
based on established connection transport type.

Change-Id: I87b54ee619c329ffa645bfbb5e453cf673b93181
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:19 -05:00
Andrei Emeltchenko
1310031915 Bluetooth: Make h4_dev static
Change-Id: I75a5655fafb8ccabbb096777ff0e2fb8be499e4f
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:19 -05:00
Andrei Emeltchenko
bd087e2bc9 Bluetooth: Change default board to Arduino 101
Change default board for nble app to arduino_101

Change-Id: I5f8cd57c9834e38125d9e17cd4c3a96427db702a
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:18 -05:00
Szymon Janc
b0ce61bedf Bluetooth: samples/shell: Fix BR/EDR legacy pairing in sec mode 3
If device is operating in security mode 3 PIN request callback
is called before connected.

Change-Id: Ie36363ae7af2398276f9cc4d07126344588b9ae6
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:18 -05:00