Commit graph

97 commits

Author SHA1 Message Date
Szymon Janc
9ecbd34f89 Bluetooth: Add support for disabling GATT client support
Binary size reduction of sample peripheral app:
45940 -> 45772

Change-Id: Ia8c463c9642a2928c2cb2ec48d9e9c4eeef20fe7
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:24 -05:00
Szymon Janc
9c2ad108b8 Bluetooth: Add option for disabling SMP support
This allows to not compile SMP support for devices that don't
require pairing. It is required to support SMP channel and reply
with error for any command received even if pairing is not supported.
To handle this cleanly a null smp implementation is used that case.

Change-Id: I656a52dac882839db904eee65f25a4e29ea2d8c2
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:24 -05:00
Luiz Augusto von Dentz
d87d1878b4 Bluetooth: ATT: Handle Indications
This adds the callback necessary to parse Indication PDU generating
proper Confirm response:

> ACL Data RX: Handle 3585 flags 0x02 dlen 8
      ATT: Handle Value Indication (0x1d) len 3
        Handle: 0x0014
          Data: 00
< ACL Data TX: Handle 3585 flags 0x00 dlen 5
      ATT: Handle Value Confirmation (0x1e) len 0

Change-Id: I277c1776f32cc05a55ffad7aa483ff1857c9fb9f
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:16:16 -05:00
Szymon Janc
cc261005f2 Bluetooth: Remove includes from internal headers
All required includes should be placed in source file that includes
internal header.

Change-Id: I161e7ebe2e62377ea4cf03f759d48f5900103076
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:16:16 -05:00
Arkadiusz Lichwa
348276044f Bluetooth: ATT: Fix write check permission
Writes to GATT attribute that has no write permission set, should
return write not permitted (BT_ATT_ERR_WRITE_NOT_PERMITTED)
in check permission routine.

Change-Id: I95f0988e171294cd98b79d3e7b518383ac47567d
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:16:16 -05:00
Szymon Janc
8b7097fd20 Bluetooth: Make parts of GATT API internal
Move parts of the API that are not usable for applications to
an internal header.

Change-Id: Idbcd3db8acda74375ea9deec2bf3d7eddc8a4ddb
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:16:16 -05:00
Grzegorz Kolodziejczyk
dabb5d49d5 Bluetooth: Fix read attr respond with invalid handle error
If no attribute with given handle is found in database then invalid
handle error should be set and returned. If attribute is found then
pre-set invalid handle error will be cleared.

Change-Id: I4119877bb72693e18003399f9b6764666f801fe4
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:16:16 -05:00
Luiz Augusto von Dentz
c74c6fd453 Bluetooth: ATT: Retry in case of recoverable error
If the remote response with encryption/authentication error attempt to
elevate the security and retry sending the request:

bt: bt_att_recv (0x00112e0c): Received ATT code 0x01 len 5
bt: att_error_rsp (0x00112e0c): request 0x0a handle 0x0018 error 0x0f
bt: security_changed (0x00112e0c): conn 0x0010f5ac level 1
bt: security_changed (0x00112e0c): Retrying
bt: bt_att_recv (0x00112e0c): Received ATT code 0x0b len 1
bt: att_handle_read_rsp (0x00112e0c):
bt: att_read_rsp (0x00112e0c): err 0x00

Change-Id: I9d74fb50385c39b2092357f4fd6912a3eb041442
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:16:16 -05:00
Luiz Augusto von Dentz
2045f0ab12 Bluetooth: ATT: Clone request buffer
Clone request buffer so it can later be used to validate the response.

Change-Id: I306f7b01a9a72a6c4b8e97c30789247b28428365
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:16:16 -05:00
Grzegorz Kolodziejczyk
798db87306 Bluetooth: Fix foreach attr lower range for att exec write
The minimal/start valid handle value is 1.

Change-Id: Ief3be01d0bf76193350b7632aedebc559d368810
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:15:40 -05:00
Grzegorz Kolodziejczyk
e989683d83 Bluetooth: Fix setting proper conn data for read by type rsp
Att data structure passed to read_type callback wasn't set properly
with connection data. This cause parsing att struct set to 0 (casted
in cb, set in att_read_type_rsp). Wrong att data caused parsing wrong
mtu size and whole conn structure.

Change-Id: Ib0aa4b8edca4965afd746e7186a08cfa34e62cf3
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:15:39 -05:00
Grzegorz Kolodziejczyk
7b3e771c91 Bluetooth: Print 16-bit dbg uuid as 4-byte hex
UUID format in 4-byte hex is more readable format than unsigned int.

Change-Id: I5e7fa3771d628705b9991c0064c102313573b8e4
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:15:39 -05:00
Andrei Emeltchenko
7a504e9a62 Bluetooth: Fix wrong buffer allocation result
Change-Id: I5db2e320e3fb83b9ea41c03053c3ce5b0bbf2bcd
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:15:37 -05:00
Luiz Augusto von Dentz
a9d6a816e8 Bluetooth: ATT: Be more consistent with bt_buf variable names
This makes the code more consistent by always trying to name bt_buf
variables as buf.

Change-Id: I10d54260c5cf2f6aea5300668d5eb68f3da2a8ba
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:15:37 -05:00
Andrei Emeltchenko
0c6b6902fe Bluetooth: Refactor signed write command
Include all headers to signature verification process.

Change-Id: I14e152e8529bca380faeb8e9a1be00e4e8d84f9a
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:15:24 -05:00
Andrei Emeltchenko
8e48fa3fa4 Bluetooth: Verify Signed Write GATT command
Verify that message is signed correctly using early distributed CSRK
key.

Change-Id: I30b24e90f3503907449c310dd4f59f32e6acca6f
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:15:24 -05:00
Andrei Emeltchenko
f9cd4105da Bluetooth: Add GATT Signed Write command
Add support for signed write with sign parameter for write without
response.

Change-Id: I79008532d88b10d34db1f68898ad4258dd3e761b
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:15:24 -05:00
Luiz Augusto von Dentz
752315a082 Bluetooth: ATT: Add bt_att_get_mtu
This can be used to check what is the configured MTU for the given
connection.

Change-Id: I292b06dbe079fbd567cd8d39615cfbc3dad6b2a5
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:15:22 -05:00
Luiz Augusto von Dentz
2ee7df52f4 Bluetooth: ATT: Handle Execute Write response
This adds the callback necessary to parse Execute Write response PDU:

< ACL Data TX: Handle 3585 flags 0x00 dlen 6
      ATT: Execute Write Request (0x18) len 1
        Flags: Immediately write all pending values (0x01)
> ACL Data RX: Handle 3585 flags 0x02 dlen 5
      ATT: Execute Write Response (0x19) len 0

Change-Id: Ida1f73021097628bd5e60faa007441db9b92a38d
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:15:22 -05:00
Luiz Augusto von Dentz
fb0f86fd2b Bluetooth: ATT: Handle Prepare Write response
This adds the callback necessary to parse Prepare Write response PDU:

< ACL Data TX: Handle 3585 flags 0x00 dlen 10
      ATT: Prepare Write Request (0x16) len 5
        Handle: 0x0011
        Offset: 0x0001
          Data: 01
> ACL Data RX: Handle 3585 flags 0x02 dlen 10
      ATT: Prepare Write Response (0x17) len 5
        Handle: 0x0011
        Offset: 0x0001
          Data: 01

Change-Id: Iaa16ec1477f25a2ebdfbefa5c0056aa3177c930c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:15:22 -05:00
Andrei Emeltchenko
ae3c6c00c2 Bluetooth: Fix alignment
Change-Id: If6b3b426bbcb763e4e089d330930bf68d4843282
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:44 -05:00
Luiz Augusto von Dentz
9c17e83d68 Bluetooth: ATT: Fix using uninitialized conn at find_info_cb
This leads to unexpected responses where the data can be bigger than
the MTU negotiated.

Change-Id: I395f85ce8b132b3c1727978eed8491ae4745b078
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:44 -05:00
Luiz Augusto von Dentz
fac5df2bae Bluetooth: GATT: Add bt_gatt_subscribe
This adds bt_gatt_subscribe which can used to subscribe to attribute
value notification using CCC handle.

Change-Id: I0983843836b0c2253f750b34b7765dd880cb10a0
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:43 -05:00
Luiz Augusto von Dentz
d354059ad4 Bluetooth: ATT: Handle Value Notification
This adds function handler for Handle Value Notification PDU:

> ACL Data RX: Handle 3585 flags 0x02 dlen 8
      ATT: Handle Value Notification (0x1b) len 3
        Handle: 0x0014
          Data: 00

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

< ACL Data TX: Handle 3585 flags 0x00 dlen 8
      ATT: Write Request (0x12) len 3
        Handle: 0x0011
          Data: 01
> ACL Data RX: Handle 3585 flags 0x02 dlen 5
      ATT: Write Response (0x13) len 0

Change-Id: Iea323bc37044822de034f92c8f9ef1d43276ec86
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:41 -05:00
Arkadiusz Lichwa
70c7e8825c Bluetooth: GATT: Add bt_gatt_read_multiple
Introduction of GATT client API to enable read attributes
determined by set of handles.

< ACL Data TX: Handle 64 flags 0x00 dlen 21
      ATT: Read Multiple Request (0x0e) len 16
        Handle: 0x0001
        Handle: 0x0002
        Handle: 0x0003
        Handle: 0x0004
        Handle: 0x0005
        Handle: 0x0006
        Handle: 0x000a
        Handle: 0x000b
> ACL Data RX: Handle 64 flags 0x02 dlen 27
      ATT: Read Multiple Response (0x0f) len 22
        00 18 02 03 00 00 2a 54 65 73 74 20 70 65 72 69  ......
        70 68 65 72 61 6c

Change-Id: Ic8e6edcf79a63bc52cb4c657e5b09529fa87879e
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.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
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
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
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
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
Luiz Augusto von Dentz
8ee4a9e93d Bluetooth: GATT: Simplify handling of Read Multiple Request
This process handle by handle instead of first parsing the full PDU
storing the result in another variable to only then process the handles.

Change-Id: I5b6d5d7db4a78a03b34bc1c7e5217bbcd7f4c96b
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:36 -05:00
Luiz Augusto von Dentz
e24f6684cb Bluetooth: ATT: Use BT_ASSERT to check context
Check conn->att context at bt_att_recv and log an error.

Change-Id: Id49e941bdf55529b517b6962fe0d401bd9295c38
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:36 -05:00
Johan Hedberg
d87232b2a1 Bluetooth: att: Fix minor coding style issues
Change-Id: I36019a726187363e41ab72d9a26b2b8ae5c7f4bb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:36 -05:00
Luiz Augusto von Dentz
330846b39a Bluetooth: ATT: Handle Read By Type response
This adds function handler for Read By Type Response PDU which call the
request callback:

> ACL Data TX: Handle 3585 flags 0x00 dlen 11
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0010-0x0011
        Attribute type: Characteristic (0x2803)
> ACL Data RX: Handle 3585 flags 0x02 dlen 13
      ATT: Read By Type Response (0x09) len 8
        Attribute data length: 7
        Attribute data list: 1 entry
        Handle: 0x0010
        Value: 081100392a
< ACL Data TX: Handle 3585 flags 0x00 dlen 11
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0011-0x0011
        Attribute type: Characteristic (0x2803)
> ACL Data RX: Handle 3585 flags 0x02 dlen 9
      ATT: Error Response (0x01) len 4
        Read By Type Request (0x08)
        Handle: 0x0011
        Error: Attribute Not Found (0x0a)

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

< ACL Data TX: Handle 3585 flags 0x00 dlen 13
      ATT: Find By Type Value Request (0x06) len 8
        Handle range: 0x000a-0xffff
        Attribute type: Primary Service (0x2800)
          UUID: Heart Rate (0x180d)
> ACL Data RX: Handle 3585 flags 0x02 dlen 9
      ATT: Find By Type Value Response (0x07) len 4
        Handle range: 0x000a-0x0011
< ACL Data TX: Handle 3585 flags 0x00 dlen 13
      ATT: Find By Type Value Request (0x06) len 8
        Handle range: 0x0011-0xffff
        Attribute type: Primary Service (0x2800)
          UUID: Heart Rate (0x180d)
> ACL Data RX: Handle 3585 flags 0x02 dlen 9
      ATT: Error Response (0x01) len 4
        Find By Type Value Request (0x06)
        Handle: 0x0011
        Error: Attribute Not Found (0x0a)

Change-Id: Ib5799d0530c8de40b7c7170f1b32312a42456484
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:35 -05:00
Luiz Augusto von Dentz
f6f64c2cda Bluetooth: ATT: Fix missing new line in BT_DBG
Change-Id: I1a9643e3d5d22cfc23baa0ebf2e5722777eaf213
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:35 -05:00
Luiz Augusto von Dentz
92477f7f65 Bluetooth: Handle ATT Exchange MTU Respose PDU
This adds function handler for Exchange MTU PDU which parses MTU received
and call the request callback:

< ACL Data TX: Handle 3585 flags 0x00 dlen 7
      ATT: Exchange MTU Request (0x02) len 2
        Client RX MTU: 65
> ACL Data RX: Handle 3585 flags 0x02 dlen 7
      ATT: Exchange MTU Response (0x03) len 2
        Server RX MTU: 517

Change-Id: I8daf0e32c1e1b838c45dc488fdef68a01451d55d
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:34 -05:00
Luiz Augusto von Dentz
18f2299f24 Bluetooth: Handle ATT Error Response PDU
This adds function handler for Error Response PDU which parses the
error code and call the request callback:

< ACL Data TX: Handle 3585 flags 0x00 dlen 5
      ATT: Exchange MTU Request (0x02) len 0
        invalid size
> ACL Data RX: Handle 3585 flags 0x02 dlen 9
      ATT: Error Response (0x01) len 4
        Exchange MTU Request (0x02)
        Handle: 0x0000
        Error: Invalid PDU (0x04)

Change-Id: I149dc20421690e63250d3e2ec388407a5600e089
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:34 -05:00
Luiz Augusto von Dentz
8fe7db3e17 Bluetooth: Add bt_att_send API
This adds bt_att_send which will be used by GATT client API to send
requests.

Note: bt_att_send can only handle one request at time but once the
requirements are clarified it will probably be extended to support
more requests to attend multiple applications probably using a fifo.

Change-Id: If9e89f7f6f0d3827a7f11c8feb4f1f1045d800be
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:31 -05:00
Luiz Augusto von Dentz
016f6e7d6a Bluetooth: Replace peer address with conn in GATT API
Now that bt_conn is public using it directly is much more convenient
and in some cases save a lookup by address.

Change-Id: Ia489948634984fe4f1a430da553f8a2a740fb531
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:30 -05:00
Luiz Augusto von Dentz
afc6628c26 Bluetooth: Use hexadecimal format when printing GATT handles
hexadecimal is the usual format when defining GATT handles values so
printing in the same format makes it easier to debug.

Change-Id: I6babcadaf5a4cffbac73db29c155343540cee120
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:23 -05:00
Luiz Augusto von Dentz
168446d058 Bluetooth: Disable GATT notifications while disconnected
Once disconnected disable CCC configuration and enabling it back once
reconnected:

bt: bt_gatt_disconnected (0x0010c610): conn 0x0010a1f4
bt: disconnected_cb (0x0010c610): ccc 0x00108e44 reseted
Disconnected
Connected
bt: bt_gatt_connected (0x0010c610): conn 0x0010a1f4
bt: gatt_ccc_changed (0x0010c610): ccc 0x00108e44 value 0x0001

Change-Id: Ia4ac6793176f80ea9c6f255a4d151f9080660b0d
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg
939544b75d Bluetooth: Move logging helpers to a dedicated header file
To make it clearer that these helpers are intended only for
Bluetooth-subsystem internal code, move them to a separate file.

Change-Id: Iea64780f5c61c1c96e12c9df378676bc49498fe4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Luiz Augusto von Dentz
801c09757e Bluetooth: Add support for ATT Read Multiple
This adds parsing for ATT Read Multiple Request and Response:

> ACL Data RX: Handle 3585 flags 0x02 dlen 11
      ATT: Read Multiple Request (0x0e) len 6
        Handle: 0x0001
        Handle: 0x0002
        Handle: 0x0003
< ACL Data TX: Handle 3585 flags 0x00 dlen 27
      ATT: Read Multiple Response (0x0f) len 22
        00 18 02 03 00 00 2a 54 65 73 74 20 70 65 72 69  ......*Test peri
        70 68 65 72 61 6c                                pheral

Change-Id: I08efe2b73342423634c156f95baa2bba84bd50a9
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg
651e9a4b2e Bluetooth: Rename conn.h to conn_internal.h
We'll have a public conn.h header file soon, so to avoid confusion
rename the existing conn.h to conn_internal.h.

Change-Id: I5e5c89ec184a0a2de63e244b034c55a3d97af9dc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Szymon Janc
b47d14a273 Bluetooth: Fix NULL pointer dereference in flush_cb
conn was never set in struct flush_data passed to flush_cb.

Change-Id: I2a16479bf7660a96f705d1194245da02ee6eeff5
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
2016-02-05 20:14:19 -05:00
Luiz Augusto von Dentz
14ff92cea0 Bluetooth: Handle ATT execute write request
This introduce a new callback called flush to bt_gatt_attr to indicate
when and attribute can cache data, the data is automatically flushed if
regular write request happens and in case of prepare write it checks if
flush is supported otherwise return an error, then upon receiving an
execute write it perform flush over the entire database and respond
with result:

< ACL Data TX: Handle 42 flags 0x00 dlen 6
      ATT: Execute Write Request (0x18) len 1
        Flags: Immediately write all pending values (0x01)
> ACL Data RX: Handle 42 flags 0x02 dlen 5
      ATT: Execute Write Response (0x19) len 0

Change-Id: I2c47f962858b8a741bf40509a648fe2cd6755691
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:19 -05:00
Luiz Augusto von Dentz
186b133028 Bluetooth: Handle ATT prepare write command
Call attribute write callback taking into account the offset and
generate proper responses:

> ACL Data TX: Handle 42 flags 0x00 dlen 69
      ATT: Prepare Write Request (0x16) len 64
        Handle: 0x0021
        Offset: 0x0000
          Data: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
< ACL Data RX: Handle 42 flags 0x01 dlen 15
      ATT: Prepare Write Response (0x17) len 64
        Handle: 0x0021
        Offset: 0x0000
          Data: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
> ACL Data TX: Handle 42 flags 0x00 dlen 23
      ATT: Prepare Write Request (0x16) len 18
        Handle: 0x0021
        Offset: 0x003c
          Data: 0000000000000000000000000000
< ACL Data RX: Handle 42 flags 0x02 dlen 23
      ATT: Prepare Write Response (0x17) len 18
        Handle: 0x0021
        Offset: 0x003c
          Data: 0000000000000000000000000000

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