Commit graph

41120 commits

Author SHA1 Message Date
Johan Hedberg
7fb1900511 Bluetooth: Fix typo in LE GAP timer definitions
Change-Id: I390043bf44bab2e99fd5d58f52691b50a7763818
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:02 -05:00
Johan Hedberg
9533fbcfe1 Bluetooth: Add latency & timeout to LE conn param API
Change-Id: Icd6122b9056dd686d70a2d213a18dcab34f5e80a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:02 -05:00
Johan Hedberg
1a32d5ed55 Bluetooth: Add support for specifying connection parameters
Applications may want fine-grained control of connection parameters.
The two APIs to provide this through are bt_le_set_auto_conn() as well
as bt_conn_create_le().

Change-Id: If5cddbbf017b868d768d18d2a09daf4af8aa00d8
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:02 -05:00
Johan Hedberg
da86c397f1 Bluetooth: Fix LE connection interval type
Change-Id: I0fd1d400414afdd5f75ea8cc5a360330ce16c54b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:02 -05:00
Johan Hedberg
defd4aa4d5 Bluetooth: Update GAP timer definitions
Change-Id: I8376752e10d21289ebeef4e02a24759ec8352c67
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:02 -05:00
Szymon Janc
af2732202b Bluetooth: SMP: Use smp_error in bt_auth_passkey_entry
There is no need to lookup SMP context again from conn object if
SMP context is already found.

Change-Id: I47ed1da69dc3030021c16579f8039e376ba11320
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:02 -05:00
Szymon Janc
97fb4d2990 Bluetooth: SMP: Delay LE SC pairing until PublicKey is generated
If HCI based ECC is used we should delay sending local Public Key in
LE SC pairing until it is generated by controller.

Change-Id: Ic979fc8efa40a8089ac2b74cbcfac21bdca79bfe
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:02 -05:00
Szymon Janc
b2db881468 Bluetooth: SMP: Follow central-peripheral ifdefs rule
Use same ifdefs rule in all places in SMP code. This makes code
easier to read.

Change-Id: I6936ca6f7a0212fc1918ed18d247f3e6d73f0370
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:02 -05:00
Szymon Janc
52054bd8e3 Bluetooth: SMP: Refactor smp_public_key
SMP code is cutted by ifdefs for central and peripheral roles support.
To make code easier to understand we follow same rule for all code:

  if (conn->role == BT_HCI_ROLE_MASTER) {
    /* master specififc code */
    return;
  }

  /* slave specififc code */

This simple rule allows for covering all build options (only central,
only peripheral or both) in clean way.

Change-Id: I37e65e7444090860069bfa6e9adc5cae07f0c0b9
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:02 -05:00
Szymon Janc
57f54ccabe Bluetooth: SMP: Add helper for generating passkey in LE SC
This allow to reuse same code in follow-up patch.

Change-Id: Ie057943f72b0c3c77d44590b56dd5ff9aa53005f
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:01 -05:00
Szymon Janc
c8e5d429c2 Bluetooth: SMP: Add helper for DHKey generation
This makes code easier to read.

Change-Id: Id63589760530505bb0ea5ef667909260114fdf0d
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
70669756ff Bluetooth: Add convenience macros for defined GAP timers
Change-Id: I6315c7791249d07fa2df0682decc0049718b5a06
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
6891b94357 Bluetooth: Add missing check for valid filter_dup value
Change-Id: I58375618d572ba5d412eaf18b73bf7d620964f6e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
266721018d Bluetooth: Add proper defines for scan enable parameters
Change-Id: I2d915517986007356c14e805eaed60a0f4290109
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
4956d5630e Bluetooth: samples/shell: Add "select" command
Add command for choosing the default connection.

Change-Id: Id100320f31cb0e99ab48b162b466f52f6273018a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
2f76a721fd Bluetooth: samples/shell: Support disconnecting non-default device
Change-Id: If9d0c601e02b9bbf4b48bf6f2e06b45d2ab5bce2
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
160489a595 Bluetooth: samples/shell: Add "auto-conn" command
Change-Id: Id81b760efa74eb6cd802289f200231bd020fbe94
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
37a4326aa1 Bluetooth: Fix stopping scanning when clearing auto-conn
Change-Id: I127fcc38d16c068f22fede1e1fe37e41477c2cb1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
914b553382 Bluetooth: Fix setting CONNECT_SCAN state for connections.
The state of auto-connectable bt_conn objects needs to be set to
CONNECT_SCAN after init as well as whenever bt_le_set_auto_conn is
called.

Change-Id: Iad2ca32a00ee1b4259196dd20651d5bf94ba9f26
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
fb576fee7f Bluetooth: Start background scanning if necessary in bt_init
If the app loaded the stack with some devices to auto-connect to we
should start the background scanning at the end of bt_init().

Change-Id: Ifd06b66b53639344bdca391eb0ed2d3643ee5a07
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
e148a3fb12 Bluetooth: Fix bt_le_scan_update dependency on CONFIG_BLUETOOTH_CENTRAL
This function should depend on BLUETOOTH_CENTRAL and not on
BLUETOOTH_CONN. It should also at least be capable of disabling
scanning even if BLUETOOTH_CENTRAL is not set.

Change-Id: Ic6ccd7ddf07ac6529c64889257dc9f9dfb34b531
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
5a5061ef97 Bluetooth: Convert bt_conn_set_auto_conn to bt_le_set_auto_conn
Once we start persistently storing the addresses of devices we want to
reconnect to we also need a way to reload them to the stack. Since we
don't have a connection object at this point the API cannot take that
as a parameter. Instead rename the function and have it take
bt_addr_le_t as a parameter.

The feature was also lacking proper reference counting for the
connection, which this patch now adds (the flag itself owns a
reference). The function is now also possible to call before bt_init()
so that if we load the stack with multiple devices the HCI doesn't get
bombarded with lots of scan enable/disable commands.

Change-Id: I9072bf061eb64f2ecec96f74fb176be13e5bdaee
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
f443be7205 Bluetooth: Add flag to track Bluetooth readiness
Change-Id: I1251eccdf474d0f113bde77d7e65f02eef39bade
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
a2276b6fce Bluetooth: Use fast scanning only for initial connection attempt
Change-Id: I68303f1fb98b7ed17eec166639811866df024ea9
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
4daa7ca6bc Bluetooth: Use more reasonable background scanning window & interval
Change-Id: If1f76050998e84c646919439afc827de9426c925
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
3226780a3c Bluetooth: Add LE scan interval & window to bt_le_scan_param
Change-Id: If2ae26625b98485c3495f4f4f48e49600a1ffd14
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
610d32311e Bluetooth: Add LE scan type to bt_le_scan_param
This way the app can start passive scanning if it wants.

Change-Id: Iab3e60863d5a1a013a5f069a98664628c7b14418
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
d5bf48b001 Bluetooth: Add scan window & interval to LE scan helper
Change-Id: I8219dbfd21aeeb95ce644a3361e2e6cdc4ab3c00
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
784489b457 Bluetooth: Rename LE scan helper to something shorter
We'll soon add many more parameters, so having a shorter name helps
with readability.

Change-Id: If6384ab0dbb883ea19fa1ad6c81e99432aabd576
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
b748f87243 Bluetooth: Simplify duplicate filtering tracking
Change-Id: If797c382eed87fc2c2a54a94bc1fa6ec5dad1914
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
8b5bb4dbf9 Bluetooth: Split implicit (background) and explicit scan functions
For background/implicit/reconnection scanning we have fixed internal
parameters that we want to use. For explicit scanning on the other
hand the parameters come from the application. It makes therefore
sense to split the functions responsible for starting each scanning
type.

Change-Id: I0e89a1ce89aca61870f789c7f1e5ad81f97cd00e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
9862a25584 Bluetooth: Disallow outgoing LE connections during explicit scan
The explicit scan API should be thought of as the user taking control
of the scanning policy. In this case the stack shouldn't try to
second-guess and create connections in between.

Change-Id: I47cc5d70660706d6657deac50aa0619cbe4bf727
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
6df50d474e Bluetooth: Create dedicated flag for explicit scanning
Change-Id: I0d7548c755a277e7741cf0b3a1b97e127ea1d382
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
93af450977 Bluetooth: Group bt_dev flags more sensibly
Change-Id: I03399604fb95d4856d8e4b4141bce508d6b2558f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg
dd353487c4 Bluetooth: Create active scanning helper macro
All current user just want basic active scanning so a corresponding
macro makes more sense than something based on duplicate filtering.

Change-Id: I97787be24b89fad66f2a952c5d53ab76f4e062fb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Mariusz Skamra
59719970cc Bluetooth: tester: Increase BTP_MTU size
Current MTU size was not sufficient to test GATT Client, where lower
tester requires to send data of length 512 +opcode +BT address.
This exceeds current BTP_MTU size.

Change-Id: I090c47975ecfe9a657d6ff1158b5dc764c8a78a1
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:00 -05:00
Johan Hedberg
38b5be06a7 Bluetooth: samples/central: Use consistent scan type
Both places in the central app that enable scanning should do
duplicate filtering.

Change-Id: If7086667c78878355dc246aa3d0b5ebcbdd0ac7b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Luiz Augusto von Dentz
095da440cd Bluetooth: GATT: Make use of BT_UUID_DECLARE_16
This uses BT_UUID_DECLARE_16 in macros that can only be of 16 bits
format.

Change-Id: I45d4bcca9859a2e279b1199546891df75a039589
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:00 -05:00
Luiz Augusto von Dentz
2cd5f53d86 Bluetooth: UUID: Add macros to declare 16 and 128 bits UUIDS
This makes it easier to declare 16 and 128 bits UUIDS and also save space
in case of 16 bits.

Change-Id: I5790afd9504ee0cca4a951be6bc542685d0a35fb
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:00 -05:00
Johan Hedberg
f5a238b665 Bluetooth: Add ability to specify dedicated LE advertising parameters
We'll need to have a much more flexible LE advertising API. This is a
first step in that direction. A convenience BT_LE_ADV() macro is
provided to ease converting application code.

Change-Id: I74854487bbdfb4b1cf1bee0b6351d1750a56ff86
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Johan Hedberg
6f470dcbce Bluetooth: Add ability to specify dedicated LE scan parameters
We'll need to have a much more flexible LE scanning API. This is a
first step towards it. The existing BT_LE_SCAN_FILTER_DUP_* enum
values are converted to macros to avoid having to update application
code at this point.

Change-Id: I0c8d29dc156bad67cddc9401c0d72aee8ec6d8de
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Johan Hedberg
52989aeecc Bluetooth: Move bt_le_scan_cb_t definition to better place
Change-Id: I9b17d2237654e651465d054f60f6c4e44576250b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Johan Hedberg
055cc491c9 Bluetooth: Add missing check for advertising in bt_le_adv_start()
The function cannot do what it's intended to do if we're already
advertising.

Change-Id: I3dabb24591f655c5faf48da9395e826b2b61cfe9
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Szymon Janc
70ed77861e Bluetooth: SMP: Fix LE SC JustWorks pairing as slave
In JustWorks/PasskeyConfirmation pairing slave doesn't check remote
confirmation value (as it doesn't receive one). Factor out confirmation
check to helper and use it only when needed. This keeps code easy to
understand.

Change-Id: Ifb31bc3f2b53586a9c92b29b01e9832c124b0951
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:00 -05:00
Szymon Janc
d9322c58d5 Bluetooth: SMP: Fix LE SC Passkey Confirmation on Big Endian
Issue causing crash is already fixed so now proper BE to cpu convertion
can be used.

Change-Id: If07ed6f3b342b9e6a58e62c9a6f5fee9bc11133a
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:00 -05:00
Johan Hedberg
f1d4b686b6 Bluetooth: Rename bt_bredr_* prefix to bt_br_*
bt_br_* is equally understandable and the same length as the
corresponding bt_le_* prefix on the LE side.

Change-Id: I1820f9b9fab6363b696072f6b70d57c0bc780078
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Johan Hedberg
5619d1114b Bluetooth: Rename LE scan & advertising APIs for consistency
To have a clear split between LE & BR/EDR rename these APIs with the
appropriate prefixes.

Change-Id: I983df2b5880947d96f0ad289d12f3383f44894be
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Mariusz Skamra
65e917c9ab Bluetooth: GATT: Fix calculation of max data allowed in write req
This patch fixes the calculation of maximum data that can be sent
by Write Request.
Maximum data is MTU reduced by size of handle and command opcode.

Change-Id: I2abeef9adffd65e24a2489ad084bfa3b810e4acf
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:00 -05:00
Mariusz Skamra
6e28748e3e Bluetooth: GATT: Minor fix in warning message
This patch fixes warning that ATT MTU exceeded. An opcode size should
be taken into account.

Change-Id: Ia69c9514a59767542cca0ef36fc77d896d20db28
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:00 -05:00
Luiz Augusto von Dentz
962462629e Bluetooth: Fix scan data of IPSP Application
The data length was incorrect which caused the name to be truncated.

Change-Id: Ieaca7745fff89f0f5689b6d15bfc0386f59add47
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:00 -05:00