Commit Graph

259 Commits

Author SHA1 Message Date
Sheldon Demario
28d393d7a2 Add sec-level option to interactive gattool 2011-02-24 18:34:34 -03:00
Bruna Moreira
6904e0f137 Add Write Request in interactive gatttool 2011-02-24 18:34:26 -03:00
Bruna Moreira
d3a5c56882 Move attr_data_from_string() to utils.c
The attr_data_from_string() function will be used in interactive and
usual gatttool so this function was moved to common file utils.c.
2011-02-24 18:33:57 -03:00
Sheldon Demario
607c54cbd9 Add characteristics read options in interactive gatttool 2011-02-24 18:33:48 -03:00
Sheldon Demario
91aed1d751 Add Characteristics Descriptor Discovery option in interactive gatttool 2011-02-24 18:33:40 -03:00
Sheldon Demario
7aff2ceaf7 Create a helper function to deal with handles on interactive gatttool 2011-02-24 18:33:22 -03:00
Vinicius Costa Gomes
a2e3157116 gatttool: Remove extra reference to the connection IO Channel
As we want the connection to be closed when the last GAttrib
reference is dropped, we don't need to keep this reference.
2011-02-24 17:43:35 -03:00
Vinicius Costa Gomes
6682df6dae Add support for GATT client timeouts
This patch adds support to destroying the GATT connection
when a GATT server doesn't respond for more than 30 seconds.

A function to destroy the GAttrib is introduced and it is used
in the timeout case and when the last GAttrib reference is
dropped.
2011-02-24 17:43:16 -03:00
Vinicius Costa Gomes
33e09781d7 Fix gattrib.c coding style
Just remove an extra empty line.
2011-02-24 17:41:23 -03:00
Anderson Lizardo
c3717e3420 Add read/write callbacks to attribute server
These callbacks will allow profiles to act before an attribute is read
and after it is written, to e.g. update the attribute value to/from an
external source.

Note that by the time the callback is called, the necessary security
checks (attribute permissions, authentication and encryption) were
already performed by the core attribute server.

The callback can optionally return an ATT status code, which will be
sent to the client using an Error Response PDU.
2011-02-24 15:41:47 -03:00
Claudio Takahasi
1847ffb1b6 Don't register GATT related SDP records if attrib server is disabled
GATT related SDP records should not be added if "AttributeServer" option
is false in the configuration file. Problem happens only when attribute
plugin is enabled.
2011-02-24 15:28:30 -03:00
Anderson Lizardo
30b24e4153 Fix typo on DBG() string format 2011-02-23 11:50:18 -03:00
Elvis Pfützenreuter
de9dfe2051 Check malformed notification/indication PDU
This patch implements discard of obviously malformed
GATT notification/indication PDUs.
2011-02-23 11:48:37 -03:00
Sheldon Demario
d576392d03 Add Characteristics Discovery option to interactive gatttool 2011-02-23 00:02:08 -03:00
Sheldon Demario
7877285534 Improve help messages in interactive gatttool
Includes the parameters info on help.
2011-02-23 00:01:24 -03:00
Brian Gix
646cc43be8 Add missing UUID16 field to Included Svc Attribute 2011-02-20 15:26:14 -03:00
Brian Gix
475dd53450 Add SDP registration of Primary GATT services
Add capability to register SDP record for Primary Services.
2011-02-19 12:14:00 -03:00
Elvis Pfützenreuter
74de4d7c6c Add UUID property to GATT service object 2011-02-18 12:09:26 -03:00
Sheldon Demario
78ed16f407 Add Primary Discovery Services option to interactive gatttool 2011-02-18 11:52:44 -03:00
Sheldon Demario
0cc2459963 Use PSM value to select LE or BR/EDR transport on gatttool
Removes "le" parameter of gatt_connect() as well the global variables
used to store the le option. LE is now the default transport, if a PSM
value different than zero is given BR/EDR will be selected
2011-02-17 15:50:15 -03:00
Sheldon Demario
eb4e1d6d4b Move do_connect() to a common file between interactive.c and gatttool.c
Since do_connect() is used in both interactive.c and gatttool.c
files, it was moved to a new file that should hold all common functions
2011-02-17 15:48:43 -03:00
Brian Gix
dba40c880f Fix Min MTU to reflect values for both L2CAP & LE 2011-02-16 18:21:45 -03:00
Claudio Takahasi
0439aea808 Fix wrong header include on interactive gatttool
This wrong include is triggering compiler warning: implicit declaration
of function 'strdup'.
2011-02-16 16:05:14 -03:00
Sheldon Demario
2c8df748ac Add connect/disconnect options on interactive mode of gatttool 2011-02-15 14:19:03 -03:00
Sheldon Demario
a523620a36 Add an initial interactive mode to gatttool
Mode required to allow better GATT procedures control. Some scenarios
require sequential commands without disconnection and delay between
operations. It is also desirable to change some connection parameters
of an active connection.
2011-02-15 14:17:37 -03:00
Bruna Moreira
48f7473068 Add Write Request operation in gatttool
Add option and callbacks for Write Request operation in gatttool.
2011-02-15 11:48:05 -03:00
Bruna Moreira
ec141a423b Add encode/decode for write response
The encode/decode functions for Write Response operations were created
to keep consistency with the rest of GATT API.
2011-02-15 11:47:40 -03:00
Andre Dieb Martins
2fab731d89 Fix GATT listen mode updating
Update gatt's listen-mode flag whenever connect_cb() is called again.
2011-02-08 15:07:23 -08:00
Bruna Moreira
240fcdb006 Fix invalid read after list concatenation
g_slist_concat uses the items from second list directly so they should
not be freed.
2011-02-04 06:55:02 +02:00
Elvis Pfützenreuter
05133a40fd Fix parameter type in att_put_u32 2011-02-04 06:53:35 +02:00
Brian Gix
8865beb9a3 Fix incoming attrib-server connection MTUs
It is important for the Attribute Server to be aware of and completely
fill response packets up to the full MTU when reading long attributes.
Some remote devices will only request additional (READ_BLOB) data if the
preceding read sent the maximum amount of data.

Incoming connections are identified as L2CAP or LE by pointers to the
Service IO channel the incoming connection was recieved on in the
user_data parameter. L2CAP channels are set to the BR/EDR minimum MTU of
48, and LE channels to the LE payload size of 23.
2011-01-21 12:19:12 +05:30
Bruna Moreira
4ca8ed4d50 Fix duplicate characteristics
The Discover() operation (from DBus API) was registering the same
characteristics after running several times. This can be checked using
test-attrib.
2011-01-21 12:15:17 +05:30
Brian Gix
8648c3b198 Add READ_BLOB_REQUEST support to attribute server 2011-01-20 15:04:15 +05:30
Bruna Moreira
46be88cb8b Move common code from Discover all Characteristics to GATT library
The attribute client (attrib/client.c) and gatttool share similar code
to parse the PDU coming from server. This commit moves this common code
to attrib/gatt.c, and simplifies the callbacks implemented by the
clients. The client callbacks are now called just once and get a GSList
of characteristics, instead of the raw PDU.
2011-01-19 20:41:11 +05:30
Bruna Moreira
e04efbaddf Rename gatt_primary_t to more generic name
The gatt_primary_t typedef was renamed to gatt_cb_t because it will be
used for primary and characteristic callbacks.
2011-01-19 20:40:56 +05:30
Claudio Takahasi
5399423bd6 Move interactive code of Discover Primary to gatt.c
Initial patch to move the shared code related to Discover All Primary
Services and Discover Primary Services by UUID to gatt.c.
2011-01-08 11:02:38 +02:00
Anderson Lizardo
952b5ca7d3 Move GATT service to attribute server core
GATT service (like GAP one) should be moved to the core attribute server
because there can be only one instance of it.

There was a "Attribute Opcodes Supported" characteristic inside the GATT
service in attrib/example.c which is not defined by the Core
specification and was removed before moving the code.
2011-01-07 22:28:26 +02:00
Anderson Lizardo
8a07d7e4d1 Move GAP service registration to src/attrib-server.c
GAP service shall be registered only once, so it makes sense to move it
to the core attribute server code.

The GAP "Device Name" characteristic was always "Example Device" on the
example server. This has been changed to use the Name attribute from
main.conf.
2011-01-07 22:28:24 +02:00
Anderson Lizardo
a5797b18a3 Refactor example server to use att_put_u16()
The original code was written before att_put_u16() was implemented.
2011-01-07 22:28:21 +02:00
Brian Gix
acdc181a5d Fix gatt_read_char() to support long Attrib Values
Fix gatt_read_char() to support long Attribute Values by recognizing
that results longer that 21 octets may include data beyond
what has been returned with the first read. Extra data is
obtained by issuing READ_BLOB requests until either a
result is returned shorter than 22 octets, or an error
is recieved indicating that no further data is available.
The API for this function has not changed.
2011-01-07 21:31:34 +02:00
Brian Gix
7f0b31cbb4 Fix g_attrib_send() to include a new ID parameter
Overall purpose of change is to enable a GATT procedure to be
executed atomically, even if it requires multiple ATT
request/response transactions.

Fix g_attrib_send() to include an ID parameter, if the pkt to
be sent should be added to the Head of the pkt queue.  If the
ID is Zero, legacy functionality is maintained, and the pkt will
be added at the tail of the queuer, and a new ID will be generated,
and returned to the caller. If ID is non-zero, the pkt will be
added to the head of the queue, with the ID value requested, which
will also be returned to the caller.

Fix received_data() to not service the send queue until after the
received data has been processed by calling the cmd->func()
callback, to allow the callback to insert another pkt on the head
of the queue.

Fix all callers of g_attrib_send() to include new parameter.
2011-01-07 21:31:31 +02:00
Claudio Takahasi
08a9c3ce7d Change security level on demand when reading characteristic descriptor 2011-01-05 14:04:56 +02:00
Claudio Takahasi
41d3eb82b8 Change security level on demand when reading characteristic value
If a characteristic requires a higher security level, change it on
demand and re-send the GATT Charateristic Value Read. Request will not
be sent until the SMP negotiation finishes. This change doesn't affect
GATT over BR/EDR, since encryption is mandatory for BR/EDR.
2011-01-05 14:04:51 +02:00
Vinicius Costa Gomes
adbfb31ab2 Add GetProperties method the Service Interface
For now this interface just includes the path that each characteristic
is registered at.
2010-12-23 10:32:25 +02:00
Vinicius Costa Gomes
87b140440a Add support for adding services to the Services property
We need to fill the devices property as each service path gets
registered in the DBus system bus.
2010-12-23 10:32:11 +02:00
Vinicius Costa Gomes
b33922d99e Remove GetCharacteristics DBus method
This method was not documented in the API, and it has the same
functionality as getting the Characteristics property.
2010-12-23 10:31:42 +02:00
Vinicius Costa Gomes
a1b0fda9a0 Add a Discover method to the GATT Client
This methods allows users to actively start the discovery of characteristics
presents in a service.
2010-12-23 10:31:05 +02:00
Vinicius Costa Gomes
463dbe1bea Add support for making LE connections to GATT client
Now GATT client should be able to make LE connections. The information
used to determine if we should make a LE connection is the psm stored
in the gatt_service structure.
2010-12-23 10:30:45 +02:00
Vinicius Costa Gomes
60987f4afa Clean up the primary service D-Bus registration
Now, that much of this funcionality was moved to the core, we can go
straight to the registration of D-Bus interfaces.
2010-12-23 10:30:27 +02:00
Vinicius Costa Gomes
5418e09a27 Remove duplicated code for discovering GATT services
Most of this functionality was moved to src/device.c. Since that move
this code doesn't work. Some ugly hack were added to avoid breaking
the build.
2010-12-23 10:29:22 +02:00