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>
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>
conn was never set in struct flush_data passed to flush_cb.
Change-Id: I2a16479bf7660a96f705d1194245da02ee6eeff5
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
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>
Call attribute write callback taking into account the signature length
so only the actual data is used.
Note: It still don't support validating the signature because that depend
on storing CRSK key.
Change-Id: I93973e2997f57e5715080ef56ad85e0eaf11d0fe
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This reduces the amount of code necessary to check minimum size and
to generate error responses.
Note that not every response can be generate using this method since in
some cases the handle must be set to indicate what attribute has failed.
Change-Id: I0dde7461d97e451407935d5ec3cbfedf6542d5e6
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This checks if connection encrypt flag is set if attribute requires
encryption and in case the connection is already encrypted return
success.
Change-Id: I8af4e9786b63a21f478b3aa9f6df448d7f5760c5
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Respond with an error if attribute read/write return an error.
Change-Id: I9c2f98ac4b73bca5d3714339a47290ca9ae2391b
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This checks attribute permission returning an error in case they don't
match.
Change-Id: I56a85ad594cb1ac535b03cdbceb43af84dc6604f
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Invalid peer address was being passed since the conn pointer was not
initialized properly.
Change-Id: Ib64584f1eb8bc534389bd4fa057c58dd00ffbd6d
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
To implement CCC properly it is required to know the remote address since
it is per client, futhermore bt_gatt_notify requires an address where to
send the notification.
Change-Id: I9d9fdf72d668831bed76e2aef06816af3620f4b8
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Bluetooth fibers must have their stacks properly aligned.
Change-Id: Id46b376abb46400c563050b4c8393ab3983ff045
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
Read attributes matching value and handle range generating a proper
response:
< ACL Data TX: Handle 3585 flags 0x00 dlen 9
ATT: Find By Type Value Response (0x07) len 4
Handle range: 0x0001-0x0005
Change-Id: I8001afa2b22e804bef3778d0509d17b01a8d597c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Read attributes matching UUID and handle range generating a proper
response:
< ACL Data TX: Handle 3585 flags 0x00 dlen 20
ATT: Read By Type Response (0x09) len 15
Attribute data length: 7
Attribute data list: 2 entries
Handle: 0x0002
Value: 020300002a
Handle: 0x0004
Value: 020500012a
Change-Id: Iaf4b0c963765a7769a17144a4d394dce8555c2d3
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This replace the old code that could only compare 16 bits UUID with
bt_uuid_cmp which can expand to 128 bits if types don't match.
Change-Id: I84219d451d8c95baf6f7e42b92629cb106428ccf
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds initial API and definitions to create a database.
Change-Id: I69d5b3f5fd2f04cc309c2f76a84581673aa54e7b
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This properly init the MTU to default upon new connection and properly
store the new value in case of Exchange MTU request.
Change-Id: I561f5b1756fd8833244cdd2a986e561c16fc8471
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
UUID defines, etc, will be needed by multiple files including GATT.
Change-Id: I855d3934242f54a8b5bf31652a4f8b9dfb63ef06
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Now that we have the connected/disconnected callbacks available for
L2CAP channels we can use these to associate the bt_conn with a
respective protocol-specific context.
Change-Id: I7c4d9a54f73ae7029a73372a1b0c93d473b28881
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
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>
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>
Now that bt_buf_add() returns 'void *' there's no need to explicitly
type cast its return value anymore.
Change-Id: I6d5c9d323dc08cb5a2b928977c1bbf3d741e5d8e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Remove the memcpy code and instead use bt_buf_pull_le16 for unaligned
access and byte order conversion.
Change-Id: I0216042566e27d6a513b302ae1ea78b49f2f1c31
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Both Write Command and Signed Write command should use their respective
packed struct.
Change-Id: Id786d1e0ee0327f662c68fa1d2f3d3bf19a237fc
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The code should always warn about unkown PDUs since it could be causing
unexpected behavior or that something is missing.
Change-Id: Idc608ca221c5ff6e440f90fa24c2cd6a3e6437fc
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
We want to be able to do fine-grained enabling of debug logs for the
various Bluetooth sub-modules. They all default to 'n' so an app
writer would need to go and enable the specific ones that they're
interested in.
Change-Id: I17105adf133d441dfc811bdd66a00be015813679
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This adds the defines for Execute Write PDUs along with initial code to
parse them.
Change-Id: Ifa8229b9f3bf0a60d9abe553263b32397d1ba881
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds the defines for Prepare Write PDUs along with initial code to
parse them.
Change-Id: Ia7210dbe4662afbebe742b5b1a7b8f08999adf2a
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds the defines for Signed Write Command along with initial code
to parse it.
Change-Id: I2071163c8468a6580d9a9305095187a140c80a43
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds the defines for Write Command along with initial code to parse
it.
Change-Id: Ifabcfa8efb54b5135a540718fb60d9a656cd088c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds the defines for Write PDUs along with initial code to parse
them.
Change-Id: I69d2002b3e6da80037c058f42f543a0ab4765958
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds the defines for Read by Group Type PDUs along with initial
code to parse them:
> ACL Data RX: Handle 3585 flags 0x02 dlen 11
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0001-0xffff
Attribute group type: Primary Service (0x2800)
< ACL Data TX: Handle 3585 flags 0x00 dlen 9
ATT: Error Response (0x01) len 4
Read By Group Type Request (0x10)
Handle: 0x0001
Error: Attribute Not Found (0x0a)
Change-Id: Iebc84e7a9c405fa58b7984602d2d27f79d6033a7
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds the defines for Read Multiple PDUs along with initial code to
parse them.
Change-Id: I34f597881e3bdb9325ffbf2bda42b7ae6710c3ae
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds the defines for Read Blob PDUs along with initial code to
parse them.
Change-Id: I5a2a2e2e32bf44d98ce928b3d57ad7f05059a927
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds the defines for Read PDUs along with initial code to parse
them.
Change-Id: I3ec54a0bf2394b54bd8b08957533f0826bf4a23a
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds the defines for Read by Type Value PDUs along with initial
code to parse them:
> ACL Data RX: Handle 3585 flags 0x02 dlen 11
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0001-0xffff
Attribute type: Characteristic (0x2803)
< ACL Data TX: Handle 3585 flags 0x00 dlen 9
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0001
Error: Attribute Not Found (0x0a)
Change-Id: I0b4371b8decebf33710a949552a11c80c544b5f8
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds the defines for Find Information by Type Value PDUs along
with initial code to parse them.
Change-Id: I9eaf2df390ca6f78530df7f1ae606b588d1fcb2e
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds the defines for Find Information PDUs along with initial code
to parse them.
Change-Id: If34533cca4a1a554ca3f119c7639a1167dae0ff2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix bug printing ATT code in bt_att_recv()
Change-Id: I21fe9cb1272428e618412e98b09e8d786132eef6
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Add code to respond to BT_ATT_OP_MTU_REQ with BT_ATT_OP_MTU_RSP
selecting the MTU based on the amount of room bt_buf has:
< ACL Data RX: Handle 39 flags 0x02 dlen 7
ATT: Exchange MTU Response (0x03) len 2
Server RX MTU: 65
Change-Id: I47b8179fcee0d6adff5761abc37cfcb1ed636d65
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add bt_att_create_pdu which works similarly to bt_l2cap_create_pdu
eliminating some duplicated when generating ATT PDUs.
Change-Id: I30b89effbae887f4032ba1d1e380a763c3556869
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>