Commit Graph

10 Commits

Author SHA1 Message Date
Arkadiusz Lichwa 134ae99d35 Bluetooth: Refactor LE Connection Params validator
Move le_validate_conn_params() interface to internal HCI
header to be commonly shared between HCI and L2CAP layers.
Refactor the interface and its users and rename related to Connection
Parameters Update procedure values used for validation.

< ACL Data TX: Handle 42 flags 0x00 dlen 16                                                                                                                          [hci1] 2832.387859
      LE L2CAP: Connection Parameter Update Request (0x12) ident 1 len 8
        Min interval: 40
        Max interval: 56
        Slave latency: 0
        Timeout multiplier: 0
@ Device Connected: 00:AA:01:00:00:23 (1) flags 0x0000
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2                                                                                                     [hci0] 2832.389374
        Handle: 42
> ACL Data RX: Handle 42 flags 0x02 dlen 16                                                                                                                          [hci0] 2832.389437
      LE L2CAP: Connection Parameter Update Request (0x12) ident 1 len 8
        Min interval: 40
        Max interval: 56
        Slave latency: 0
        Timeout multiplier: 0
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                               [hci1] 2832.389440
        Num handles: 1
        Handle: 42
        Count: 1
> HCI Event: Command Status (0x0f) plen 4                                                                                                                            [hci0] 2832.389443
      LE Read Remote Used Features (0x08|0x0016) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 12                                                                                                                            [hci0] 2832.389444
      LE Read Remote Used Features (0x04)
        Status: Success (0x00)
        Handle: 42
        Features: 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00
          LE Encryption
          Connection Parameter Request Procedure

< ACL Data TX: Handle 42 flags 0x00 dlen 10                                                                                                                          [hci0] 2832.393154
      LE L2CAP: Connection Parameter Update Response (0x13) ident 1 len 2
        Result: Connection Parameters rejected (0x0001)
> ACL Data RX: Handle 42 flags 0x02 dlen 10                                                                                                                          [hci1] 2832.393181
      LE L2CAP: Connection Parameter Update Response (0x13) ident 1 len 2
        Result: Connection Parameters rejected (0x0001)

Rejected due to Timeout multiplier: 0.

Change-Id: Idaf4f452f560ff71d9637ec5d793154190e94b35
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:15:38 -05:00
Mariusz Skamra 7682d1579f Bluetooth: Make bt_l2cap_update_conn_param to be non-void function
Makes bt_l2cap_update_conn_param to return an error if command was not
sent.

Change-Id: Ie7351040bd371bb161afc2f2a2c10e015bcdc8e4
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:15:37 -05:00
Andrei Emeltchenko a7de88f972 Bluetooth: Propagate SMP & L2CAP init failures
Checking error returned by L2CAP & SMP allows to fail Bluetooth
initialization in case something goes wrong.

Change-Id: Ie1c796eb64bcdee0f9dc99638c79fd4d7c05e456
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:41 -05:00
Johan Hedberg 451b105978 Bluetooth: Use __packed instead of the deprecated PACK_STRUCT
The PACK_STRUCT macro will be removed soon and __packed is what all
code should use. Convert all the usages in Bluetooth code.

Change-Id: Id5c724566565f67fa8167b61398c508194ece89b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:18 -05:00
Johan Hedberg 7650dabdab Bluetooth: Add L2CAP callbacks for connection state changes
Add callbacks to notify L2CAP channels of connections, disconnections
and changes in the encryption state.

Change-Id: I66f86f20f551f01459abdbec6ccd214992828470
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:03 -05:00
Johan Hedberg 0b099acb4c Bluetooth: Add registration mechanism for L2CAP channels
We'll either way need various callbacks as well as get rid of the
channel-specific contexts in conn.h, so add a dynamic way of
registering fixed channels. The LE signaling channel is handled in the
same way as any other channel.

Change-Id: I5f8c1af3c8e3d107212becf507a5a6485838e081
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:03 -05:00
Johan Hedberg 44e67698a6 Bluetooth: Move L2CAP header encoding to sending stage
Encoding the L2CAP header when allocating the buffer means that we
must know the final size up-front. This is not always possible, so
move the header encoding to bt_l2cap_send() and only have the
bt_l2cap_create_pdu() function reserve enough headroom without
actually encoding anything.

Change-Id: Ic1c3b6b72c265cd0db4e835790fa915e0acd9388
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:02 -05:00
Andrei Emeltchenko 69f94f2484 Bluetooth: Add skeleton for SMP handling
Add support for Security Manager Protocol fixed channel. SMP handling
would be done in smp.c.

Change-Id: I26d3d098c6b1c3d03aad958d83dfee09e03add1d
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Johan Hedberg c31237aa82 Bluetooth: Add basic L2CAP support
This patch adds basic L2CAP functions, including support for the LE
signaling channel as well as performing a connection parameter update
in slave (peripheral) role.

Change-Id: Ie1f9751475adcf26576e9587bf6d68d15d6a2569
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:49 -05:00
Johan Hedberg 4831529193 Bluetooth: Add connection abstration
This patch adds a new bt_conn struct which abstracts the details of an
connection. Each connection has two fibers: one for incoming and
another for outgoing data. For now only one connection is supported.
The patch also adds a basic L2CAP header definition so that fragmented
ACL packets can be properly parsed.

Change-Id: Ida38b2657a0e908a18219c3aa2997eb314f2c8a1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:49 -05:00