Commit graph

41120 commits

Author SHA1 Message Date
Szymon Janc
66413dad20 Bluetooth: L2CAP: Fix not sending all bytes of SDU
There are always 2 additional bytes for SDU length in first packet
and those needs to be taken into account.

Change-Id: I3c202cd969524036b42d919bc001e75b8c2faaa0
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:28 -05:00
Szymon Janc
47f0279502 Bluetooth: samples/shell: Fix printk modifier
Use %d for printing signed integer.

Change-Id: I6fbf387969e97561430ea0d2d422842c599f1457
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:28 -05:00
Szymon Janc
719e8e4710 Bluetooth: Fix not updating LE keys on Key Refresh Event
If link is already encrypted controller issues "Encryption Key
Refresh Complete" for "LE Start Encryption".

Failing to update keys resulted in invalid security level being set.

Change-Id: I8d8dd1682937bd35a35111366ec6ebdaa619db7c
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:28 -05:00
Johan Hedberg
56ba2ffb6b Bluetooth: Remove unused bt_uuid_copy() API
There are no more users of this API, and the only user it had in the
past was quite a special corner case. Just remove it for the time
being.

Change-Id: I696139b493f9ca75530665de25a4a4e03fc0ac5b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:28 -05:00
Johan Hedberg
d5e23e86d2 Bluetooth: UUID: Introduce new API
Introduce new UUID API with bt_uuid, bt_uuid_16 and bt_uuid_32
structs. The specific size structs are derived from the common bt_uuid
struct to make it possible to use CONTAINER_OF().

Change-Id: I9cb03c73406acb7768d410fdf29eae75d252163c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:28 -05:00
Szymon Janc
4e29c31512 Bluetooth: L2CAP: Fix not calling disconnect callback
Destination CID identifies the channel endpoint on the device
sending the response. So in disconnection response DCID matches
CID used for TX.

Change-Id: Id42d61536bcc208e868ac889c738e7c40bcf5a9a
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:28 -05:00
Andrei Emeltchenko
81b4ffbf93 Bluetooth: bttester: Trivial style correction
Change-Id: I39e2c414ec1e972112bda0ba3ca1d1626c32bb18
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:28 -05:00
Luiz Augusto von Dentz
60ea587c59 Bluetooth: L2CAP: Fix bt_l2cap_chan_send
The l2cap_chan_le_send_sdu code was not taking into account that
bt_l2cap_send adds its on headers which means buf->len != ret won't
stop once the last remaining segment is sent since it reuses the
original buffer len is not consumed.

Change-Id: I774da976fb4f71127ae30adf1e02d52946fb9592
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:28 -05:00
Luiz Augusto von Dentz
23ac865f33 Bluetooth: L2CAP: Fix bt_l2cap_chan_send documentation
bt_l2cap_chan_send does actually return the number of bytes sent.

Change-Id: I9dd79da992577f2e1e8d30d42eeb0c398e48ff33
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:28 -05:00
Luiz Augusto von Dentz
5506ec6f09 Bluetooth: Shell: Fix l2cap-send
bt_l2cap_chan_send does actually return the number of bytes sent.

Change-Id: I862a8519c752c6b26250a21be02a927a9326617c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:28 -05:00
Andrei Emeltchenko
ca57c08e0f Bluetooth: nble: Implement get_version_rsp()
Implementing on_ble_get_version_rsp() allows to check firmware version
of Nordic BLE chip.
Current output is (stripped):
...
bt: on_ble_get_version_rsp: VERSION: 0.0.0 ATP1BLE000-1604C5546
...

Change-Id: I98d3cd659cbed86b31eb90aac0e3ae876daf616a
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:28 -05:00
Luiz Augusto von Dentz
bcea32a2ca Bluetooth: shell: Don't call bt_enable blocking
Now that nble driver is supported bt_enable cannot be called blocking
since it is not supported, futhermore the call to bt_gatt_register
should be done after bt_enable is complete.

Change-Id: I404f8cd8b8339dba0fd26d24edeb718eba4bf225
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:27 -05:00
Andrei Emeltchenko
26e152f734 Bluetooth: doc: Add notes for building with NBLE enabled
Change-Id: I77f4c25bacd4f6233152d44d36f3057f4ac108e7
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:27 -05:00
Szymon Janc
dfb9441221 Bluetooth: L2CAP: Fix missing unref if link was disconnected
Buffer returned by l2cap_chan_create_seg should be unreffed if
disconnected.

Change-Id: Ib794ecc98618eddc9d92b2dc2edf829c50123418
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:27 -05:00
Andrei Emeltchenko
4124327525 Bluetooth: nble: Correct platform name for Arduino 101
This enables this test case for arduino_101 platform.

Change-Id: I2a94fb90f4c57022ddf1ec11ab06bb5e59de9b6e
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:27 -05:00
Andrei Emeltchenko
af6d20461b Bluetooth: tests: Remove extra board definition for NBLE
Board already defined in platform_whitelist

Change-Id: I2fed4b3c0663fd15d43ee697837a89439f7bd07a
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:27 -05:00
Anas Nashif
4414d2f308 Do not set BT config options if NBLE is not enabled
!BLUETOOTH is almost always when not using BLE, so depend
on NBLE being configured as well to set various options.

Change-Id: Idc61cee277fe0f09086a9f2ed6eb419aee5fd69c
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:25:27 -05:00
Johan Hedberg
44541091dc Bluetooth: GATT: Remove unnecessary usage of full UUID structs
To access the 16-bit value of GATT UUIDs it's quite overkill to first
create anonymous UUID structs and then access the value member from
them. We can simplify this a lot with the help of the recently added
UUID value definitions.

Change-Id: Ib58012c20d07b3e60e5911cea6feb73301d1323c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:27 -05:00
Johan Hedberg
f448b6810d Bluetooth: UUID: Add value definitions
In some cases we need the raw 16-bit UUID value instead of a full UUID
object. Add definitions of these values so that the code doesn't need
to do complicated tricks to get hold of them.

Change-Id: I98f276402f20fe03fea2777743f15ca7fcae42c6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:27 -05:00
Szymon Janc
92e84bbfb8 Bluetooth: samples/shell: Fix use of NULL net buffer
Don't use NULL pointer if aquiring net buffer failed.

Change-Id: I11a22b832d1da9559b90abe0cb83eed56d14722f
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:27 -05:00
Mariusz Skamra
71472f8aca Bluetooth: tester: Convert advertising data
This adds conversion of advertising data (adv_data) to be used by
bt_le_adv_start function.

Change-Id: I403ff7ebed89dbf763d258b5dcdabfbb2cb68260
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:27 -05:00
Andrei Emeltchenko
1636eca4cb Bluetooth: shell: Add NBLE shell test to sanitycheck
Test can be verified with

$ sanitycheck -s bluetooth/shell/test_nble -v
arduino_101  bluetooth/shell/test_nble  PASSED

Change-Id: Icfc5892524041d169973bd6eb7d23b6ecffb98fc
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:27 -05:00
Andrei Emeltchenko
d5d9e081c6 Bluetooth: shell: Add Nordic BLE configuration
Allow to build shell for NBLE.

Change-Id: Icbd019ee1947f2dcf3bc358685024f22c6a5de34
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:27 -05:00
Andrei Emeltchenko
355146d2aa Bluetooth: shell: Fix usage of BREDR functions
Fix compiler errors when CONFIG_BLUETOOTH_BREDR is not enabled.

Change-Id: I003985a9769120b3314eaf1b9563a3bf9712e32a
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:27 -05:00
Andrei Emeltchenko
e4777eca2c Bluetooth: shell: Make buf_data local
Move buf_data to the place it is used reducing errors when dynamic
channels are disabled.

Change-Id: I82f640ffa8046e1c9b5805658e69cb722856d445
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:27 -05:00
Andrei Emeltchenko
06d9e61dd6 Bluetooth: shell: Fix dynamic channel usage
Fix wrong dynamic channel usage in shell

Change-Id: Ieb6505b4c5ce1d380af4ac0b5ef788b16a2eeb4d
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:27 -05:00
Luiz Augusto von Dentz
59a4e2eaea Bluetooth: tester: Add support for testing with nble driver
Change-Id: I4c996d30da30d8f3b88d7ba9efe974872f902e0a
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:27 -05:00
Luiz Augusto von Dentz
dab10c414b drivers/nble: Add UUID support
This reuses the existing code since that is not driver specific, with
this samples such as tester can be build using nble driver.

Change-Id: I6d9f3edf8deb2e84fce233ef02d1cd0ad6f52526
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:27 -05:00
Luiz Augusto von Dentz
7834061d12 Bluetooth: ATT: Check mask instead of specific permission
This enables simpler permissions as it is not longer needed to include
BT_GATT_PERM_READ or BT_GATT_PERM_WRITE.

Change-Id: I0c749b75bedb125bda8ea451474c82eec13d3c38
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:27 -05:00
Andrei Emeltchenko
eea10dd425 Bluetooth: test: Use correct target for Arduino
Current quark_se target is not specified in
scripts/sanity_chk/arches/x86.ini list and apparently this is the
reason tests were not executed, change it to arduino_101.

Change-Id: Ifedcf08cc9b25839d389bd7eb92ed42012e9075a
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:27 -05:00
Andrei Emeltchenko
6c988ba401 Bluetooth: beacon: Correct arduino target
Putting right target allows to build for arduino_101.

Change-Id: Ib11244c7f024c72f0ab0b15549be57c576bdef3c
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:27 -05:00
Andrei Emeltchenko
a166d5fd6d Bluetooth: nble: Include right platform
Currently it is not possible to build for Arduino since wrong platform
was specified.

Change-Id: I85ff6f5adb003db9a0905d6afa04bb5dfbd55d53
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:27 -05:00
Luiz Augusto von Dentz
16f398ddf7 Bluetooth: UUID: Fix conversion to 128 bit format
The current format used is a swap of RFC 4122 thus the 16 bit values do
come at the end not at the beggining and data need to be swapped.

Change-Id: I38a27cdf82a28d28e47675f719772278d85deaaa
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:27 -05:00
Luiz Augusto von Dentz
9e74b5171f Bluetooth: beacon: Add support for testing with nble driver
In addition to having a different CONF_FILE bt_enable needs to be given
a callback since nble driver cannot block while initializing.

Change-Id: I8bd2c79d0620e93dbecfef25c49c5529ff1ee954
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:27 -05:00
Andrei Emeltchenko
f4c5c9808a Bluetooth: nble: Fix missing format specifier
Change-Id: I6adbd6e19462b15644d32714ae7d454fac0ece32
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:27 -05:00
Andrei Emeltchenko
5da3fbdaf4 Bluetooth: att: Use correct format specification for size
Change-Id: Ida06f2d34bfd41256a98c79200717329497667ac
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:27 -05:00
Andrei Emeltchenko
bab5744358 Bluetooth: nble: Allow to build UART driver for nanokernel
Change-Id: I9901942521c376a22a6990835bce8ed7752a4b1a
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:27 -05:00
Arkadiusz Lichwa
2dc833880e Bluetooth: BR/EDR: Rename encr_mode to encr_enabled
Adjusts encryption state name in connection complete event.

Change-Id: Ib7e6b2c5738ca9f5832e0e277d8f5718050f4bef
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:27 -05:00
Szymon Janc
e6f0356df7 Bluetooth: SMP: Fix legacy passkey entry for central role
In legacy passkey entry method confirm value is sent first.

Change-Id: Ic379650dab64715be6d281fa8d3389f5ff34a978
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:27 -05:00
Szymon Janc
04f6d80ff3 Bluetooth: SMP: Fix not initializing context correctly
Use uint8_t for pointer arithmetic when clearing SMP context so that
correct memory is cleared.

Change-Id: I8b88bc4c2eb181397bce5fb80a6ab250086cb17d
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:26 -05:00
Andrei Emeltchenko
44e311ed19 Bluetooth: nble: Limit number tries when reading from UART
There are situations when nble_read() might stuck reading from UART when
there is no data. Limit number of tries to 10.

Change-Id: I23380b622439ce9fa72b05f4eb527f03c749fce8
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:26 -05:00
Andrei Emeltchenko
e8ffda4a73 Bluetooth: nble: Implement ble_log
Implement using printf(), to make correct stack use define check.

Change-Id: I81894ccb511f921a5fcff37d85790191251d683f
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:26 -05:00
Andrei Emeltchenko
f8f24d7661 Bluetooth: nble: Clean up code making it consistent
Change-Id: Icfd4f245a2674d865cb670d6c4549cd39d31ca6b
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:26 -05:00
Andrei Emeltchenko
9c3de9ebca Bluetooth: nble: Use weak functions printing debug info
Since the headers defining RPC with Nordic chip changes frequently
define weak functions printing BT_WARN("Not implemented") if
function is not defined.
Weak function symbol is marked with "W" as viewed by nm.

Change-Id: Ia39b64c6e89fdddc65683711fd192a235fe754d4
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:26 -05:00
Johan Hedberg
53dd3ba2e0 drivers/nble: Implement bt_le_adv_start()
Change-Id: I169a2bc2f0e48473fbb50bdf8e651623e446c231
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:26 -05:00
Johan Hedberg
278d320f71 drivers/nble: Increase TX & RX buffer count to 2
This lowers the chance of running out of buffers when sending or
receiving a lot of data.

Change-Id: Ifedc5652f993fa54f7aded87aef545ffb49e7581
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:26 -05:00
Johan Hedberg
733f837aae drivers/nble: Fix passing correct length to poll_out()
The RPC code is not net_buf aware so it will not update the net_buf
length when encoding data into it. We have to therefore do it
ourselves.

Change-Id: I7d7d3c09007a2a9bce822625607dbf7470a7ea0b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:26 -05:00
Johan Hedberg
3e9bfe5119 Bluetooth: Add missing nanokernel.h dependency to log.h
Change-Id: Ifcdc2d44dc9223833dc628613fada3d2cf7daa8f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:26 -05:00
Andrei Emeltchenko
8dbd03a5f5 Bluetooth: nble: Make GATT coding style consistent
Make code readable removing extra spaces.

Change-Id: I61e3486e1d301ff7d36fd2e34243ff6e9111e54d
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:26 -05:00
Andrei Emeltchenko
64b1989f56 Bluetooth: nble: Make GAP coding style consistent
Remove extra spaces and make code readable

Change-Id: I3e57a5440476eb0143d19ce9865d3a76c58b90d1
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:26 -05:00