Commit graph

18576 commits

Author SHA1 Message Date
Johan Hedberg
e060c621d1 Bluetooth: Move le_conn_update() to conn.c
Change-Id: Iaaf1cce09aef2e09c0cb2cca3500368a5faec2ae
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Johan Hedberg
5f33744a4c Bluetooth: Move le_start_encryption to conn.c
Change-Id: Id9c042663e6f58aba6ec34165b7b244650317969
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Johan Hedberg
a33047f7a5 Bluetooth: Move bt_connect_le to conn.c and rename it appropriately
This function operates on bt_conn so it should be in conn.c and
exported through conn.h. Rename it with the appropriate bt_conn_*
prefix.

Change-Id: Id17c67f0e95cc1afb10aa7742b2d2ce0110ea616
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Johan Hedberg
e0e6416065 Bluetooth: Export bt_dev through hci_core.h
Rename the hci_core.c (previously internal) variable 'dev' to 'bt_dev'
and export it through hci_core.h. This way e.g. bt_conn doesn't need
to store an internal reference to it.

Change-Id: Ic1368c8f20d307c6a13a412f80d8183b56d7a76b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Johan Hedberg
7ed81c7a22 Bluetooth: Enhance bt_le_scan_update() for active scanning
Let bt_le_scan_update() perform all necessary changes to active
scanning so that it's even more helpful to the start/stop scanning
APIs as well as the bt_connect_le() API.

Change-Id: I8ee2daf96297749f782d364dfb66c7d0bbc48f5e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Johan Hedberg
824135122f Bluetooth: Move bt_disconnect to conn.[ch] and rename it appropriately
The bt_disconnect deals with the bt_conn object and should therefore
reside in conn.c and be exported through conn.h. It should also have
the appropriate bt_conn_* prefix.

Change-Id: I75eb648fd9aa8ced9a991d472c319d25f4b772af
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Luiz Augusto von Dentz
79eb002a06 Bluetooth: GATT: Fix not dropping buffer reference
In case bt_att_send fails the buffer reference need to be dropped
otherwise it will never return to the buffer poll.

Change-Id: I644a0af52d9f64fcb43a982cf121a0c51b676b90
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:40 -05:00
Luiz Augusto von Dentz
7ea33a436b Bluetooth: Add gatt-read command to btshell
This adds gatt-read which works as follow:

gatt-read <bdaddr> <bdaddr_type> <handle> [offset]
bt: bt_gatt_read (0x0010dca0): handle 0x0010
Read pending
btshell> bt: bt_att_recv (0x0010fe9c): Received ATT code 0x0b len 6
bt: att_handle_read_rsp (0x0010fe9c):
bt: att_read_rsp (0x0010fe9c): err 0x00
Read complete: err 0 length 5

Change-Id: I38686f0e592b38bf22a7bf76fab93676b375104d
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:40 -05:00
Luiz Augusto von Dentz
d982120a7e Bluetooth: GATT: Add bt_gatt_read
This adds bt_gatt_read which can used to read attribute values.
Note: Attributes which values are bigger than the MTU need to be read
multiple time until the end since the stack cannot cache any data.

Change-Id: I09c502eeb674a577673182c35a0e1a84519fd3b7
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:40 -05:00
Luiz Augusto von Dentz
569d5e6fe3 Bluetooth: ATT: Handle Read Blob response
This adds function handler for Read Blob Response PDU which call the
request callback:

< ACL Data TX: Handle 3585 flags 0x00 dlen 9
      ATT: Read Blob Request (0x0c) len 4
        Handle: 0x0010
        Offset: 0x0001
> ACL Data RX: Handle 3585 flags 0x02 dlen 9
      ATT: Read Blob Response (0x0d) len 4
        11 00 39 2a

Change-Id: I7e098649d35e46bfe24259bf6a2a3d5b35873977
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:40 -05:00
Luiz Augusto von Dentz
a02df0f64a Bluetooth: ATT: Handle Read response
This adds function handler for Read Response PDU which call the request
callback:

< ACL Data TX: Handle 3585 flags 0x00 dlen 7
      ATT: Read Request (0x0a) len 2
        Handle: 0x0010
> ACL Data RX: Handle 3585 flags 0x02 dlen 10
      ATT: Read Response (0x0b) len 5
        Value: 081100392a

Change-Id: I68de7c7bcd62e5697669b9ddb9403e8ccd1b470c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:40 -05:00
Johan Hedberg
776196d879 Bluetooth: Add "stop scan" functionality to bt_le_scan_update()
This makes it possible to take advantage of the function also from
bt_disconnect() in the CONNECT_SCAN state.

Change-Id: I8c740f2b49b7690b6020ffd5bff6f04f8f850a5d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Johan Hedberg
b8d8673dd2 Bluetooth: Rename trigger_scan() to bt_le_scan_update()
Prepare the function for more generic usage where it can also disable
scanning if necessary. Once all bt_conn related function are moved to
conn.c this needs to be exported, so use the proper bt_ prefix.

Change-Id: I07c1bc7981b25a516682a8d7e6566af36d3c1fd8
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Johan Hedberg
d0c31141cd Bluetooth: Clear AUTO_CONNECT for any state in bt_disconnect()
There's no state where we'd want the AUTO_CONNECT flag to stay enabled
when requesting explicit disconnection.

Change-Id: I76dc112071d30199bb5201e5d5633125e1035ad5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Mariusz Skamra
b210d53172 Bluetooth: Add initial auto connect support
Calling bt_conn_set_auto_conn one can decide if auto connect shall
be used. If so, everytime the connection is lost, passive scanning
will be enabled to listen for connectable advertisements from
remote device and re-establish the connection.

Auto connect can be disabled if one decide to disconnect from
this device using bt_disconnect or call bt_conn_set_auto_conn
with auto_conn flag set to false.

Change-Id: Ic9952e313cb8612ea6c72838be0755805daeffcf
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:40 -05:00
Mariusz Skamra
eb67b0f110 Bluetooth: Move hci_disconn_complete function
To avoid a forward declaration in a subsequent patch.

Change-Id: Ib3fc482af8f1fadda8e27af99811f73e64cd175a
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:40 -05:00
Arkadiusz Lichwa
c8b27ab8a5 Bluetooth: ATT: Update multiple read req object
Modifies ATT transport bt_att_read_mult_req type used in read multiple
request.
Internally now it's been declared as array of handles.
For ensuring validness of minimum PDU length being 4 octets wide for
multiple read request, new define is introduced and used instead of
type sizeof evaluation.

Change-Id: I8b0096497d456c0e6fa6b5b1eb88bb1b8079ae04
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:14:40 -05:00
Arkadiusz Lichwa
8f7c8a3969 Bluetooth: buf: Add bt_buf_add_le16() API
Enables directly add 16-bit value at the end of operational buffer.
Value is converted to little-endian format before is appended.
Position of buffer's tail is updated during addition.
Usage of bt_buf_add() call enables monitoring available limited room
in the buffer when CONFIG_BLUETOOTH_DEBUG is on.

Change-Id: Id7ac62cd3b11ef03302e94185a7faae747eccb20
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:14:40 -05:00
Johan Hedberg
5bb6b7b238 Bluetooth: buf: Take advantage of bt_buf_tail() helper macro
Change-Id: Ibd9d28e223be2e5299c8ae7e444cb19642bf8bc8
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Johan Hedberg
2cc87e319e Bluetooth: buf: Use appropriate macro for converting LE to CPU
Change-Id: I0f35c875bd2471d2e2279ae7c0a73a62c08cf080
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Ravi kumar Veeramally
6bb94745e0 net: apps: Update 802.15.4 test app makefile
Update test_15_4 makefile and prj files to support
CONFIG_NETWORKING_WITH_15_4_LOOPBACK_UART build.

Change-Id: I8247b67b1beac18f7c62349d049694cf5aa437ca
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:14:40 -05:00
Ravi kumar Veeramally
873271b7ec net: apps: Add README file for 802.15.4 test application
Add config and build instructions for test_15_4 sample application.

Change-Id: I9920c5da27d643c0faee506f1497d0d68ed7ca52
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:14:40 -05:00
Ravi kumar Veeramally
de67ecb58b net: 15.4: Add support for data Tx/Rx between two qemus
Add support for 802.15.4 dummy radio driver to send frames
through qemu uart and and receive frames through uart. So
two qemus can send and receive 802.15.4 frames.

Change-Id: I325281d04234f7ec07c66bf31691c18a9d7c4d93
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:14:40 -05:00
Luiz Augusto von Dentz
ebbe49b32e Bluetooth: Add gatt-discover-descriptor command to btshell
This adds gatt-discover-descriptor which works as follow:

btshell> gatt-discover-descriptor <bdaddr> <bdaddr_type> [UUID] [start_handle] [end_handle]
bt: bt_gatt_discover_descriptor (0x0010d6b0): start_handle 0x0011 end_handle 0x0011
Discover pending
btshell>bt: bt_att_recv (0x0010f8ac): Received ATT code 0x05 len 6
bt: att_handle_find_info_rsp (0x0010f8ac):
bt: att_find_info_rsp (0x0010f8ac): err 0x00
bt: att_find_info_rsp (0x0010f8ac): handle 0x0011
Discover found handle 17
Discover destroy

Change-Id: I6b95a3b9bfbbf57fb195f79db24216a1f8296079
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:40 -05:00
Luiz Augusto von Dentz
e0792a1ba2 Bluetooth: GATT: Add bt_gatt_discover_descriptor
This adds bt_gatt_discover_descriptors which can used to discover all
descriptors in the given range.

Change-Id: Idf93852ef9d8ba3bfce20dc0b95f4e11aa0dc73d
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:40 -05:00
Mariusz Skamra
b672324c16 Bluetooth: Look up connections only for connectable adv events
If the advertising event type is not connectable, we shouldn't
try to establish connection with this device.

Change-Id: I5be6427858856a6318553ddc0acf53aa2d991b7b
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:40 -05:00
Mariusz Skamra
eda6b7c0e4 Bluetooth: Use identity address to look up for connections
If we have IRK stored for device we try to connect to,
it means we should look up bt_conn based on identity address,
not the address from advertising or connection complete event.

Change-Id: Iccbd766acf9a62cfe5e967cf54597854881f37d5
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:40 -05:00
Mariusz Skamra
51e4fd4b8d Bluetooth: Rename device_found function
check_pending_conn gives more information about what this function
is actually doing.

Change-Id: Id21580e03bb1c341c7cf3671a666e385738fb3d4
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:39 -05:00
Arkadiusz Lichwa
9bf8ad20df Bluetooth: ATT: Check ATT payload len against MTU
During allocation ATT pdu buffer there's possibility to precheck
whether length of such buffer doesn't exceeds ATT MTU.

Change-Id: I7f729e4d7f7474d7f33e417ea61a00ceeb7426c5
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:14:39 -05:00
Mariusz Skamra
66cf2511f1 Bluetooth: SMP: Add BT_KEYS_SLAVE_LTK key in bt_smp_distribute_keys
Without this patch, we send LTK Request Negative Reply after reconnection.
It fails in le_ltk_request:

	if (conn->keys && (conn->keys->keys & BT_KEYS_SLAVE_LTK) &&
	    conn->keys->slave_ltk.rand == evt->rand &&
	    conn->keys->slave_ltk.ediv == evt->ediv) {
		bt_hci_cmd_send(BT_HCI_OP_LE_LTK_REQ_REPLY, buf);
	} else {
		bt_hci_cmd_send(BT_HCI_OP_LE_LTK_REQ_NEG_REPLY, buf);
	}

Change-Id: I9b926b7ba01743dcfa79f51650271f6e12cc2ff8
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:39 -05:00
Mariusz Skamra
81895bd738 Bluetooth: shell: Extend shell app functionality to turn off adverising
Change-Id: I5beb5abac3ecc982a154fd062eb34b1d5ee170e9
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:39 -05:00
Mariusz Skamra
f45bbec4a1 Bluetooth: hci: Add bt_stop_advertising
This adds above function to stop ongoing advertising.

Change-Id: I16b3913524a61e844a81cbe733f2b8e6072ab442
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:39 -05:00
Johan Hedberg
d0950676e8 Bluetooth: Add bt_keys_add_type() convenience API
When we already have bt_keys object and want to ensure that it
contains a certain key type it's wasteful to have to go and call
bt_keys_get_type() (because of the extra lookup it'll do).

Change-Id: I97831e6817e734d7e8b6aa18c7917736577f3438
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:39 -05:00
Luiz Augusto von Dentz
001d29218a Bluetooth: ATT: Handle Find Info response
This adds function handler for Find Info Response PDU which call the
request callback:

< ACL Data TX: Handle 3585 flags 0x00 dlen 9
      ATT: Find Information Request (0x04) len 4
        Handle range: 0x0010-0x0011
> ACL Data RX: Handle 3585 flags 0x02 dlen 14
      ATT: Find Information Response (0x05) len 9
        Format: UUID-16 (0x01)
        Handle: 0x0010
        UUID: Characteristic (0x2803)
        Handle: 0x0011
        UUID: Heart Rate Control Point (0x2a39)

Change-Id: I981e9efe75f6eb032d9468549272c82720cb133d
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:39 -05:00
Mariusz Skamra
fcda155262 Bluetooth: SMP: Fix invalid return from smp_pairing_master
With this patch, Identity Information and Identity Address
Information are properly received. There was a bug when
returning too early from smp_pairing_master function
and not setting BT_SMP_CMD_IDENT_INFO bit in allowed_cmds.

bt: bt_smp_recv (0x0010f054): Received SMP code 0x06 len 17
bt: smp_pairing_encrypt (0x0010f054):
bt: bt_smp_recv (0x0010f054): Received SMP code 0x07 len 11
bt: smp_pairing_master (0x0010f054):
bt: bt_smp_recv (0x0010f054): Received SMP code 0x08 len 17
bt: bt_smp_recv: Unexpected SMP code 0x08
bt: bt_smp_recv (0x0010f054): Received SMP code 0x09 len 8
bt: bt_smp_recv: Unexpected SMP code 0x09

The return should be after distributing LTK, EDIV and Rand if
IdKey was not set.

bt: bt_smp_recv (0x0010effc): Received SMP code 0x06 len 17
bt: smp_pairing_encrypt (0x0010effc):
bt: bt_smp_recv (0x0010effc): Received SMP code 0x07 len 11
bt: smp_pairing_master (0x0010effc):
bt: bt_smp_recv (0x0010effc): Received SMP code 0x08 len 17
bt: smp_ident_info (0x0010effc):
bt: bt_smp_recv (0x0010effc): Received SMP code 0x09 len 8
bt: smp_ident_addr_info (0x0010effc):
bt: smp_ident_addr_info (0x0010effc): identity 88:63:DF:88:0E:83 (public)
bt: bt_smp_disconnected (0x0010effc): conn 0x0010badc handle 64

Change-Id: Ic98cf6fd6ad2f7e41c6cd506d39fc9a9571a491f
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:39 -05:00
Johan Hedberg
410a8a8165 Bluetooth: Fix doxygen documentation for bt_connect_le()
Change-Id: Ib40d5a23ee60dad16686f43dee172a31c456e7e1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:39 -05:00
Johan Hedberg
47cb69458a Bluetooth: Remove unnecessary 'err' variable from bt_connect_le()
Instead of caring about stop_scanning() failure it's better to have
bt_connect_le() do "best effort" and simply try to continue in this
case.

Change-Id: I14896a4dfbe0bfd2564a190080743f0c9b05d174
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:39 -05:00
Johan Hedberg
7d8e97c9a1 Bluetooth: Fix potential bt_conn leaks
There's no need to check for BT_CONN_CONNECTED for these HCI events or
ACL data. Even if the connection is being disconnected the stack will
do the right thing when the disconnect_complete event occurs.
Furthermore, these branches were actually leaking the bt_conn if the
state wasn't connected after being looked up.

Change-Id: I2e22d67cb43a86e742663a896e853de02fe9e325
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:39 -05:00
Johan Hedberg
636415212a Bluetooth: Fix various coding style issues
Change-Id: Iffcc0db1dca5eba16ce10039d918175e72ac8f2f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:39 -05:00
Johan Hedberg
5ed9cb7b5b Bluetooth: Clean up bt_conn reference counting
Make the reference counting of bt_conn clearer by having the reference
taken by the first state transition and released by the last state
transition handled in the bt_conn_set_state() function.

Change-Id: Iee04758fcc7f770e6ccfd351f33be60e7d646f19
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:39 -05:00
Johan Hedberg
1732e81c58 Bluetooth: SMP: Rename PDU handlers for consistency
Change-Id: Ifb7489b0c0631c0ce4285da97ef09bc2db3200f9
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:39 -05:00
Rodrigo Caballero
f184a89610 Doxygen: Remove duplicate comment.
Removes a duplicated comment on the FIFO documentation.

Change-Id: Iff81fd0df67e23517c199c866542db28d12cc42a
Signed-off-by: Rodrigo Caballero <rodrigo.caballero.abraham@intel.com>
2016-02-05 20:14:39 -05:00
Peter Mitsis
b4e1f7154a sanity: Replace obsolete BSP_FLAG with PLATFORM_FLAG
The bluetooth regression script now refers to PLATFORM_FLAG instead of the
obsolete BSP_FLAG variable.

Change-Id: I8cafc01b66004c7bdd76c03d3f3b6aeba134565d
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:39 -05:00
Peter Mitsis
e6b8bc6477 Remove obsolete kernel references to BSP
BSP terminology is obsolete.

Change-Id: Ic23688fbaaf88e037e184c8bbfc7aaa0ba997b31
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:39 -05:00
Peter Mitsis
e2e68d3b9f Update comments in ctors.c
Updates the comments in ctors.c to more accurately reflect the current
state of constructors.

Change-Id: I8bea13ac9b56b4d7c6ce793f175666506fffa446
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:39 -05:00
Peter Mitsis
da299ecd47 Update nanokernel boot_time project
Removes references to old platform names.

Change-Id: I65baa148006fbda916904914844b1b347f8ec654
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:39 -05:00
Peter Mitsis
310c63e386 Update microkernel boot_time project
Removes references to old platform names.

Change-Id: I53e9994c794c6b4c292e776355a67b7923c2fdb8
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:39 -05:00
Peter Mitsis
2871ca32d3 Rename x86 platforms
Changes the the names of the x86 platforms so that they are more generic.
  generic_pc -> ia32
  quark -> ia32_pci

NOTE: it is expected that the two platforms will eventually be merged into one.
one. At present, the two platforms support different hardware.  For example,
the ia32 supports bluetooth whereas the ia32_pci does not, and the ia32_pci
supports both PCI and HPET whereas the ia32 does not.

Change-Id: I8a980aaef55be8c59f7d19ddeb7fafbf11253408
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:39 -05:00
Peter Mitsis
213db12fbf Move platforms to new arch/<arch>/platforms directory
Change-Id: I9ad5d51329d381c091aa47b482a8e38e7c194118
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:39 -05:00
Peter Mitsis
3019daba6a Cosmetic: Fix issues found by checkpatch
Change-Id: I6beb9ca93a98784d456740d76737996b50a65a71
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:39 -05:00