Commit graph

99014 commits

Author SHA1 Message Date
Luiz Augusto von Dentz
602367e708 Bluetooth: Increase BLUETOOTH_HCI_EVT_COUNT
Some controller may actually generate more than 6 events simultaneously
as it seems to be tied with the number of buffers increase it to 8
whenever BLUETOOTH_CONN is selected otherwise default to 4.

Change-Id: I907847f56c2eb2d756513da171ff780aeb544259
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:47 -05:00
Arkadiusz Lichwa
bd92608d0d Bluetooth: Kconfig: Require LE support whenever Bluetooth is enabled
Enforce enabling LE support whenever Bluetooth support has been selected.
Currently building Bluetooth support without LE is not supported.

Change-Id: I90acabfa06db6045ee24173f62719a776efde740
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:24:47 -05:00
Arkadiusz Lichwa
9e868b39b9 Bluetooth: Kconfig: Add BR/EDR option
Enables turn on classic BR/EDR core support in the stack.

Change-Id: If078a23e38857081538c52e24689bfa423db2307
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:24:47 -05:00
Johan Hedberg
fd4d439d72 Bluetooth: samples/shell: Remove dependency on CONFIG_EXPERIMENTAL
There's no reason to depend on this config option, in fact it looks
like it doesn't even exist.

Change-Id: I3e072466700ca7115dfde5af09b08f98707062bb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:47 -05:00
Arkadiusz Lichwa
cb29e6135d Bluetooth: Kconfig: Change topmost option
Refactors existing menu by putting as topmost selectable option
general bluetooth subsystem support instead so far Low Energy (LE).
Implication of the change is introduction of new BLUETOOTH_LE config
flag. The flag needs to be propagated to all existing bluetooth
related apps to make them buildable.

Change-Id: I608c1baad038e0ee4cccf44a3e597e16ae1f7f54
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:24:47 -05:00
Jukka Rissanen
7e3301fc62 net: Fix checkpatch warnings
Change-Id: Ife0db49300ee7d0cdc4805d9e50c81feb397d8c6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:47 -05:00
Jukka Rissanen
33ab70cebc net: Use the correct fifo get timeout function
The fifo get timeout functions must be called in proper execution
context. Because of this requirement, we must use correct fifo
get timeout function depending on whether the net_receive()
was called from a fiber or from a task.

Change-Id: Ibf4637d0e647a441de59a1cbb9fdf3c0abe0eb09
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:47 -05:00
Jukka Rissanen
cc88aa3918 net: Rename net_init.c to net_core.c
As the file contains networking core routines and not just
init functions, the file is renamed.

Change-Id: Id633bae49296dfb4b14f1dd3a5064059f0418475
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:47 -05:00
Mariusz Skamra
619ad22c38 Bluetooth: gatt: Fix possible NULL pointer dereference
Change-Id: Ica534a516725597c1fae8c8a9f652d85b720774c
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:47 -05:00
Mariusz Skamra
7dc3d35da6 Bluetooth: gatt: Unsubscribe notification from callback directly
With this patch application can unsubscribe notifications
from Subscribe value callback directly, if BT_GATT_ITER_STOP
is returned.

Change-Id: I7873594f5dbe6e8c5bef11bf397a74cdc870a464
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:47 -05:00
Mariusz Skamra
d42a70288b Bluetooth: gatt: Refactor read of attributes as a gatt client
This patch refactor reading of attribute values as a client.
Current MTU size is taken into account to determine if read
procedure has been completed or not.
For now, read procedure will be continued until whole is read,
or stopped by client.
Core Specification says that "The Read Blob Request is repeated
until the Read Blob Response’s Part Attribute Value parameter is
shorter than (ATT_MTU – 1)." (Vol 3, Part G 4.8.3)
Because application didn't know the current MTU value,
there was no way to determine if data received is complete.

Change-Id: I9d0e3f8638b58c3a4e39060333aedc133b775e3d
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:46 -05:00
Jukka Rissanen
13b939cb64 net: contiki: Proper rtimer implementation was missing
Real timer implementation in Contiki was always returning 0
which was incorrect.

Change-Id: I63d5f2b5914e1952a04addc200fe1f0f4a95a5ed
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:46 -05:00
Jukka Rissanen
14c30a3504 net: contiki: Remove obsolete spi.h file
This file should not be here as it is not used in Zephyr.

Change-Id: I4be96e5b03e4522af80e48da285a1509bccc60df
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:46 -05:00
Jukka Rissanen
809f8ca16e net: apps: Fix compile error of coap-observe-client
Include path was missing.

Change-Id: I29c1b31143fe4d03cde5bd0cd63319960b817322
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:46 -05:00
Luiz Augusto von Dentz
7f6dd71e79 Bluetooth: L2CAP: Disconnect when receiving invalid data
When receiving invalid data the spec recommends disconnecting.

Change-Id: I13b043d4b7d7b5c9fc2fdd8e09077be948694a57
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:46 -05:00
Luiz Augusto von Dentz
8061ed1277 Bluetooth: Add l2cap-disconnect command to btshell
l2cap-disconnect can be used to disconnect or cancel a connection to
a server:

btshell> l2cap-disconnect
bt: bt_l2cap_chan_disconnect (0x0011260c): chan 0x0011065c scid 0x0040 dcid 0x0040
btshell> bt: bt_l2cap_recv (0x00114e00): Packet for CID 5 len 8
bt: l2cap_chan_recv (0x00114e00): chan 0x00111534 len 8
bt: l2cap_recv (0x00114e00): LE signaling code 0x07 ident 2 len 4
bt: le_disconn_rsp (0x00114e00): dcid 0x0040 scid 0x0040
bt: l2cap_chan_del (0x00114e00): conn 0x001111c0 chan 0x0011065c cid 0x0040
Channel 0011065c disconnected

Change-Id: If249748f98f9b006e4eb2f8722a6f698b372d959
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:46 -05:00
Luiz Augusto von Dentz
a983eff168 Bluetooth: L2CAP: Add bt_l2cap_chan_disconnect
This adds bt_l2cap_chan_disconnect which can be used to disconnect
dynamic channels resulting in the following trace:

< ACL Data TX: Handle 3585 flags 0x00 dlen 12
      LE L2CAP: Disconnection Request (0x06) ident 2 len 4
        Destination CID: 64
        Source CID: 64
> ACL Data RX: Handle 3585 flags 0x02 dlen 12
      LE L2CAP: Disconnection Response (0x07) ident 2 len 4
        Destination CID: 64
        Source CID: 64

Change-Id: I77ec29c8879a330b7f73e217621436045fa5163e
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:46 -05:00
Luiz Augusto von Dentz
2902d5c3c3 Bluetooth: Add l2cap-connect command to btshell
l2cap-connect can be used to connect to a server:

btshell> l2cap-connect 0080
bt: bt_l2cap_chan_connect (0x0011260c): conn 0x001111c0 chan 0x0011065c psm 0x0080
bt: l2cap_le_connect (0x0011260c): conn 0x001111c0 chan 0x0011065c psm 0x0080
bt: l2cap_chan_add (0x0011260c): conn 0x001111c0 chan 0x0011065c cid 0x0040
btshell> bt: bt_l2cap_recv (0x00114e00): Packet for CID 5 len 14
bt: l2cap_chan_recv (0x00114e00): chan 0x00111534 len 14
bt: l2cap_recv (0x00114e00): LE signaling code 0x15 ident 1 len 10
bt: le_conn_rsp (0x00114e00): dcid 0x0040 mtu 672 mps 230 credits 10 result 0x0000
Channel 0011065c connected

Change-Id: I8440615225e74d603c0f6bc3db4cf4bd46831841
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:46 -05:00
Luiz Augusto von Dentz
973bd0f4d7 Bluetooth: L2CAP: Add bt_l2cap_chan_connect
This adds bt_l2cap_chan_connect which can be used to connect dynamic
channels resulting in the following trace:

< ACL Data TX: Handle 3585 flags 0x00 dlen 18
      LE L2CAP: LE Connection Request (0x14) ident 1 len 10
        PSM: 128 (0x0080)
        Source CID: 64
        MTU: 63
        MPS: 65
        Credits: 4
> ACL Data RX: Handle 3585 flags 0x02 dlen 18
      LE L2CAP: LE Connection Response (0x15) ident 1 len 10
        Destination CID: 64
        MTU: 672
        MPS: 230
        Credits: 10
        Result: Connection successful (0x0000)

Change-Id: I73b2bd62fdca4a3ffa35577f0b66c2e6bb0083cd
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:46 -05:00
Luiz Augusto von Dentz
cbe71672e0 Bluetooth: L2CAP: Add defines for PSM range
This also change the start to allow creating server for fixed PSM.

Change-Id: I50054cc7a583111fe096181236cbf80d79d2585f
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:46 -05:00
Jukka Rissanen
d32b0004ee net: Kconfig: Refactor sanity test options
The loopback number test count should only be available when
we have network sanity tests enabled.

Change-Id: Ifd4fc1f6249dda62c195810cfef7dd8ff9d17f9c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:46 -05:00
Jukka Rissanen
8c3a15d5d4 net: Kconfig: Fix ethernet debug option
Show ethernet debug option only when user has selected
ethernet driver.

Change-Id: I0bc34e4034d978cb6fb9dce0e5b2e8fd87e9dc3b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:46 -05:00
Jukka Rissanen
77c73fdee4 net: coap: Add statistics prints for CoAP traffic
Change-Id: I6bac21eb15335da55d8690e3eda548a2e8eaa8e9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:46 -05:00
Jukka Rissanen
0179583391 net: Fix the include paths in Contiki sources
Fix the include paths in Contiki sources so that we do not
have to create links to include directories during compilation.

Change-Id: I9316f1e90474e0ee563557deadd0bdc321cbb0fa
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:46 -05:00
Jukka Rissanen
59e27cc9f8 net: Print more useful debug in dummy 15.4 driver
If the uart sending fails, then print more detailed info
so we can pin point the exact location where this sending failed.

Change-Id: I5548fb9af96455c60b58c7b956ebe01fe78da3ff
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:46 -05:00
Jukka Rissanen
31e5fccf30 net: Enable L2 buffers only when 802.15.4 is enabled
Because the L2 buffers are only used by 802.15.4 sub-system,
we must not compile and link them to the kernel.

Change-Id: Iab0352582ac1c57e0dd8f54ca8e757e47e4df3be
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:46 -05:00
Jukka Rissanen
2272312b8d net: Refactor code to use new generic net_buf API
Change-Id: Id008bbf43062ca0641a76edaabef47c650287444
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:46 -05:00
Mariusz Skamra
5fc0533414 Bluetooth: tester: Handle add descriptor command
This command will be used to add a descriptor to attributes database.

 >> send 2 4 0 02000302cccc
Received: hdr:  header(svc_id='\x02', op='\x04', ctrl_index='\x00',
							data_len=2)
Received data (hex): 04 00
Received data (ascii): ('\x04\x00',)

> ACL Data RX: Handle 64 flags 0x02 dlen 9
      ATT: Find Information Request (0x04) len 4
        Handle range: 0x0004-0x0004
< ACL Data TX: Handle 64 flags 0x00 dlen 10
      ATT: Find Information Response (0x05) len 5
        Format: UUID-16 (0x01)
        Handle: 0x0004
        UUID: Unknown (0xcccc)

Change-Id: I64b77ce735e2dff10ae15290fb174b7f99876014
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:46 -05:00
Mariusz Skamra
f83809991c Bluetooth: tester: Handle add included service command
This command is used by the tester to include service.
Service that is going to be included has to be already present
in the gatt database.

> ACL Data RX: Handle 64 flags 0x02 dlen 11
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0001-0xffff
        Attribute type: Include (0x2802)
< ACL Data TX: Handle 64 flags 0x00 dlen 14
      ATT: Read By Type Response (0x09) len 9
        Attribute data length: 8
        Attribute data list: 1 entry
        Handle: 0x0007
        Value: 01000500aaaa

Change-Id: I12e1790be946c3cf10105c66a852da1cb23cf4bd
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:46 -05:00
Mariusz Skamra
6f047a7040 Bluetooth: Refactor adding attributes to the gatt database
This patch changes the way the attributes are added to the database.
From now, attributes will be registered one by one in gatt_db_add function.
This change is needed, because the handle of the attribute is assigned
in bt_gatt_register, and the tester application has to respond to the
command with valid attribute handles.
Moreover, Set Value command rely on the attribute handle, based on which
it looks for an attribute with handle spacified by tester to set it's
value.

Change-Id: I1f251f9bd5579bde2a52ebe3f1997da49c1b1721
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:46 -05:00
Mariusz Skamra
723405d685 Bluetooth: Add command to set the required Encryption Key Size
This will be needed to pass tests that require Insufficient Encryption
Key Size error response.

Change-Id: Ie358686d3a9843527e0c3dbd3918daed4e4d2f4c
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:46 -05:00
Grzegorz Kolodziejczyk
2e77f815f0 Bluetooth: Correct Device Disconnect Event opcode
The same opcode was used to Device Connected event.

Change-Id: I51640ed81822311817e82e43998c476795a28d49
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:24:46 -05:00
Grzegorz Kolodziejczyk
7c49f209b1 Bluetooth: Add possible values of addr type for GAP conn/disconn
This patch adds valid address types parameter for connect, disconnect
commands.

Change-Id: Ia54d503795c1ff04549f9813e197a1de923ef0bb
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:24:46 -05:00
Luiz Augusto von Dentz
bb27219ecb Bluetooth: ATT: Fix not releasing buffer before calling the callback
The cloned buffer is used to retry in case a security error happen but
since the buffer pool is now limited the callback may actually block if
it creates a new request which would need 2 buffers (original + clone)
but only one is available since the previous request clone is not
released yet.

Change-Id: Ife508b09c4b326b8213fd0b130ebf3c2e7fe47c9
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
b85593fb09 Bluetooth: Increase ATT buffers to count for buffer cloning
When sending ATT packets we may need to clone the original buffer.
Because of this one buffer per connection is not enough. Add one extra
buffer to the pool to cover for this.

Change-Id: I9fd9cb806f79ff99f1415a0fd7293ef0baf1d3f9
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
72e3b3fdb2 Bluetooth: uart: Simplify bt_uart_discard() with the help of min()
There's no need to do manual minumum calculation when there's the
min() helper available.

Change-Id: I4d5cfb088d9e6499750664680419ab4beb56e0d5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
1d92308078 Bluetooth: uart: Simplify send callback logic
We can remove the need for the extra 1-byte headroom by simply
directly writing the H:4 header with uart_poll_out(). Also the
separate uart_out() function can be removed by taking advantage of the
counters already present in the net_buf.

Change-Id: I54bd852e28f416b3de250cd9f8a126269cccfc14
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
f3214d3a1f Bluetooth: Kconfig: Add missing help texts
All user visible options should have at least some help text to them.

Change-Id: I97db035f2a4939b4d3c26b7260ad1a39351664b2
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
ec147cebfe Bluetooth: Kconfig: Fix comment about outgoing buffers
There's no BLUETOOTH_ACL_OUT_COUNT configuration option anymore so
update the text accordingly.

Change-Id: I431e3d63b8a3e9aebe855e4b5c0083e7d5e50f8b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
d6d8c3193a Bluetooth: Kconfig: Move BLUETOOTH_CONN selectors to a better place
It's move intuitive to have the BLUETOOTH_CONN selectors right before
the section for choosing options that depend on them.

Change-Id: If3d1a1fcb9c78d715b502b58fba9293ca69d0835
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
600a3d3f8b Bluetooth: Kconfig: Move debug options into separate section
This makes it easier to visualize all debug options under a single
sub-menu.

Change-Id: If69a71138450a4cae24ede2c110f42ced9ee762f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
4810bb1b16 Bluetooth: Kconfig: Clean up and remove redundancies
Clean up and remove redundancies in Kconfig. Many 'depends on'
statements can be removed by moving entries behind common if-endif
blocks.

Change-Id: Iaa1c4e717e8353f4c09e991413588cf840281c5d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
9af971ac0a Bluetooth: Clean up hci_core.c include order
The stack.h will eventually be moved to a generic place. Also separate
BLUETOOTH_CONN includes clearly.

Change-Id: I52bf657ac6458c3a7c99a462d17e4a0d420d709f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
bf0dd9a969 Bluetooth: Fix using right define for event buffer size
The right size for event buffers is EVT_BUF_SIZE.

Change-Id: I7cc9c43b6699aafac8b8deccfe87f5390c09ccfa
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Jukka Rissanen
0b9736dce4 net: contiki: Add debug function to print buffer content
Change-Id: I04c76798394651f9026d869e3a9491c4e452b396
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:45 -05:00
Jukka Rissanen
a2a702a986 net: 802.15.4: Dummy radio driver must reset status on error
In order to avoid memory corruption, the dummy 802.15.4 radio
must reset its internal state when there is an error when
reading packet data from UART.

Change-Id: Ifeba5181f014426b95d21e5726c638eae555b649
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
c9f1ce2639 Bluetooth: Increase default ATT MTU when possible
The 23 bytes default is quite limiting. When SMP has been enabled we
can do a bit better since we know that we can fit two complete ACL
packets to the buffers (23 bytes payload in the first, and 27 in the
second).

Change-Id: I71d9c484c962b1ff46d325f7182511f168608b8e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
3bc43254e0 Bluetooth: Use event/cmd lengths instead of buffer sizes in KConfig
It's more intuitive to specify needed command or event lengths rather
than the raw buffer size in Kconfig. The exact buffer size calculation
can be done in the code itself.

Change-Id: I2760cc1182a689b26405e4c2b1428f140b4aa88a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
8167ababe0 Bluetooth: Make Kconfig buffer sizes follow MTU sizes
It's more intuitive to specify needed MTU sizes instead of raw buffer
sizes. The exact buffer size calculations can instead be made
internally in the code (using the BT_L2CAP_BUF_SIZE helper macro).

Change-Id: I0637340a7d99e04020f57f49ecd8e6dcfcc4bcf4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
50256ea514 Bluetooth: Move BT_L2CAP_BUF_SIZE to a more appropriate place
This doesn't need to be exposed in the public API.

Change-Id: Ib6d4336684620bd1e03d128765f289b5ebd744ef
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00