Commit Graph

509 Commits

Author SHA1 Message Date
Marcin Kraglak
ff797556da attrib: Fix discovering descriptors
Discover all attributes in given range. In same cases we ommited
last attribute in range.
2014-07-18 11:14:42 +02:00
Lukasz Rymanowski
514e224641 android/gatt: Fix signed write command encoding
As per spec (BT spec 4.1 Vol[3], Part F, chapter 3.4.5.4) we need to
take opcode, handle and parameters to generate signature.
In order to support it signing is moved to att.c, place where pdu is
encoded
2014-05-30 13:26:14 +03:00
Jakub Tyszkowski
111150d7e6 attrib: Fix minor whitespace issue
Replace spaces with tabs.
2014-05-27 22:46:49 +02:00
Lukasz Rymanowski
84bbaa3971 attrib: Add wrapper to send signed write command 2014-05-26 10:28:12 +02:00
Lukasz Rymanowski
d4026bb36e attrib: Add helpers to enc and dec signed write command 2014-05-26 10:27:21 +02:00
Andrzej Kaczmarek
9b9771ce8f gatt: Remove gatt_discover_char_desc
This function is no longer used since all code is changed to use
gatt_discover_desc instead.
2014-05-05 10:49:51 +03:00
Andrzej Kaczmarek
a2d69036e7 attrib: Discover descriptors using gatt_discover_desc 2014-05-05 10:48:55 +03:00
Andrzej Kaczmarek
93229d36d1 attrib: Add simpler call for descriptors discovery
This patch adds gatt_discover_desc() function which performs descriptor
discovery in a manner similar to gatt_discover_char(), i.e. it does
complete discovery procedure and returns list of descriptors found when
finished. For 16-bit UUIDs in addition to string UUID, short UUID is
provided.

It's also possible to specify single descriptor UUID to look for and
discovery procedure is interrupted as soon as UUID is found. This way
no more than one descriptor is returned which is useful when searching
for common descriptors like CCC.
2014-05-05 10:47:16 +03:00
Lukasz Rymanowski
7ecdd48ab7 attrib: Expose write execute
This is needed to cover Android API
2014-04-23 15:15:50 +02:00
Lukasz Rymanowski
a877e3a20b attrib: Add API for reliable write
Android expose to application api for reliable write. Therefore we need
to add this support to gattrib
2014-04-23 15:15:50 +02:00
Claudio Takahasi
2514293cd2 attrib: Improve Attribute Data length checking
According to Core SPEC, attribute data list must be grouped in elements
of the same size.
2014-04-03 10:20:39 +03:00
Jakub Tyszkowski
2620e5c7ab attrib/gatttool: Use define for UUID format check 2014-03-28 14:24:37 +02:00
Jakub Tyszkowski
1e11df4348 attrib: Use const source data pointer for write
Source buffer for write operations should be immutable.
2014-03-28 14:24:22 +02:00
Claudio Takahasi
f9648711cc attrib: Remove att_get_* and att_put_* helpers 2014-03-25 17:24:25 +02:00
Claudio Takahasi
f1956438cc gatt: Move Characteristic properties to attrib/gatt.h
Properties are defined by GATT specification. This patch moves and
renames the defines related to Characteristic properties bits from
attrib/att.h to attrib/gatt.h
2014-03-25 17:24:01 +02:00
Claudio Takahasi
f3e500b008 attrib: Minor code optimization 2014-03-24 22:19:01 +02:00
Claudio Takahasi
454a30731b Replace att_put_u16() by put_le16() 2014-03-24 22:11:28 +02:00
Claudio Takahasi
e13e1abb8b Replace att_put_uuid() by util.h helpers 2014-03-24 22:10:16 +02:00
Claudio Takahasi
1a1e9b4fa9 Replace att_get_uuid128() by bswap_128()
GATT/ATT use little-endian byte order format for 128-bit UUID. No matter
the system byte order representation, internally the core will handle
128-bit UUID on big-endian format.
2014-03-24 22:08:54 +02:00
Claudio Takahasi
91744cb56f Replace att_get_u16() by get_le16() 2014-03-24 22:08:20 +02:00
Claudio Takahasi
3f03ab5766 Replace att_get_uuid16() by get_le16() 2014-03-24 22:08:02 +02:00
Claudio Takahasi
0461b9d99c Replace att_put_uuid16() by put_le16() 2014-03-24 22:07:53 +02:00
Claudio Takahasi
5842f1b657 attrib: Use LE helpers defined in src/shared/util.h 2014-03-24 22:07:31 +02:00
Claudio Takahasi
6b7df0c117 attrib: Remove unneeded sdp.h header include 2014-03-24 21:58:29 +02:00
Johan Hedberg
62fa720891 attrib: Fix gatt_primary leaks when a failure occurs 2014-03-20 11:00:30 +02:00
Johan Hedberg
48f93f7619 attrib: Use destroy notify for included query 2014-03-19 19:28:51 +02:00
Johan Hedberg
b82916dadf attrib: Fix potential leaks with primary discovery context 2014-03-19 19:28:51 +02:00
Johan Hedberg
4d789940d8 gattrib: Fix pending command handling when getting disconnected 2014-03-19 19:28:50 +02:00
Johan Hedberg
a0d064bb71 core: Fix memory leaks with struct discover_char 2014-03-19 19:28:49 +02:00
Claudio Takahasi
67b976dc33 lib: Move GATT UUID to uuid.h
This patch moves GATT UUIDs definitions to a common header. uuid.h contains
helper functions to manipulate Bluetooth UUIDs and some common BR/EDR services
UUIDs.
2014-02-24 10:18:45 +02:00
Marcel Holtmann
6648e011a3 attrib: Make btio/btio.h include local 2014-01-25 20:32:57 -08:00
Marcel Holtmann
cf458ad28f attrib: Use full include path for header files 2014-01-25 20:10:00 -08:00
Anderson Lizardo
a3299e5b1e attrib: Add extra PDU checks when decoding Read by Type Response
These checks are needed to avoid invalid memory access on bogus PDUs.
2014-01-11 18:56:03 +02:00
Anderson Lizardo
cceb59d76b attrib: Fix PDU length check for Read by Type Request
PDU length must be either 7 or 21 octets.
2014-01-11 18:56:03 +02:00
Anderson Lizardo
88cdd5749c attrib: Reject incomplete PDU in dec_find_by_type_resp()
Otherwise, an incomplete PDU may be silently accepted (with any
remaining data discarded).
2014-01-11 18:56:03 +02:00
Anderson Lizardo
a9249eece7 attrib: Remove unnecessary local variables from dec_find_by_type_req()
Use number instead of "min_len", which is easier to review (with help of
the documented parameter sizes).

valuelen is redundant as *vlen can be used directly.
2014-01-11 18:56:03 +02:00
Anderson Lizardo
a8b353da80 attrib: Remove unnecessary NULL checks on dec_find_by_type_req()
Just assume that the caller will pass non-NULL pointers as arguments
(which is true for the only current caller of this function).
2014-01-11 18:56:03 +02:00
Anderson Lizardo
ef97296c20 attrib: Add extra PDU checks when decoding Read by Group Type Response
These checks are needed to avoid invalid memory access on bogus PDUs.
2014-01-11 18:56:03 +02:00
Anderson Lizardo
a5e6aafdf7 attrib: Fix PDU length check for Read by Group Type Request
PDU length must be either 7 or 21 octets.
2014-01-11 18:56:03 +02:00
Anderson Lizardo
22cf3b76d1 attrib: Remove unnecessary checks for PDU length on ATT encoding
Both userspace and kernel enforce a minimum ATT MTU of 23 octets, which
is also used as minimum size for buffers passed to ATT encoding
functions. Therefore, it is unnecessary to perform these checks on ATT
requests that are guaranteed to fit into 23 octets.

Also document ATT parameter lengths where a constant is being used for
calculating the PDU length.
2014-01-11 18:56:03 +02:00
Anderson Lizardo
95b8a4ec80 attrib: Use att_put_u16() instead of htobs() + memcpy() 2014-01-11 18:56:03 +02:00
Anderson Lizardo
2704b4c83b attrib: Modify gatt_cb_t signature
Use standard C types instead of GLib ones (which are unnecessary here)
and move the "status" parameter to the first position, so it is
consistent with other callbacks.
2014-01-11 18:56:03 +02:00
Andrei Emeltchenko
c64fd37802 codingstyle: Change __FUNCTION__ to __func__
The __func__ macro is part of the C99 standard whereas __FUNCTION__ is a
legacy gcc specific alias for it:

	http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html

Additionally, checkpatch.pl that's commonly used to verify coding style
also recommends to use __func__ instead of __FUNCTION__.
2013-09-11 13:22:08 +03:00
Dirk-Jan C. Binnema
fabd565565 attrib: Add support for 128-bit characteristic UUIDs in gatt_service_add
Custom GATT services typically use 128-bits UUIDs; this patch allows for
using gatt_service_add to define such services by adding a new option
GATT_OPT_CHR_UUID, which allows for passing bt_uuid_t* values. Note, a
previous patch renamed the old GATT_OPT_CHR_UUID into
GATT_OPT_CHR_UUID16.
2013-07-30 12:59:15 +03:00
Dirk-Jan C. Binnema
1208266dcc attrib: Rename GATT_OPT_CHR_UUID into GATT_OPT_CHR_UUID16
Rename the option for all in-tree users. This frees up GATT_OPT_CHR_UUID to be used
for UUIDs of type bt_uuid_t* (in a next patch).
2013-07-30 12:59:12 +03:00
Dirk-Jan C. Binnema
f3e175bd78 attrib: Update gatt_service_add size assert for dealing with 128-bit UUIDs
To paraphrase Anderson Lizardo: "h" was overflowing for 128-bit services
because the handle is incremented after each attribute is added so at
the end we had: 0xffff + 1 == 0 (h is uint16_t).

As it seems more complex to try to remove the overflow without affecting
the logic too much, we update the assertion.
2013-07-30 12:59:12 +03:00
Anderson Lizardo
d1abf2b7d8 attrib: Reduce scope of variable declarations in char_discovered_cb()
This makes it easy to identify where variables are being used.
2013-07-24 08:44:07 -07:00
Anderson Lizardo
638790716f attrib: Allow dec_read_resp() to just check if PDU is valid
If a NULL "value" parameter is given, only check whether PDU is valid,
without copying attribute value to a buffer.
2013-07-24 08:43:17 -07:00
Alvaro Silva
1ed64821ac attrib: Add encode/decode execute write support
Add functions for encoding/decoding Execute Write Request PDUs.
2013-07-24 08:43:05 -07:00
Alvaro Silva
38487a9915 attrib: Add encode/decode prepare write support
Add functions for encoding/decoding Prepare Write Request PDUs.
2013-07-24 08:42:43 -07:00