Commit Graph

479 Commits

Author SHA1 Message Date
Santiago Carot-Nemesio
c9548ebacf gatt-service: Delete attributes when service registration fails
Whenever a regitration operation fails, the attributes stored in the
data base of handles remain. This patches removes all attributes
registered by a service when the operation is not succesful. In this
way, either all service attributes are registered or none of them are
stored in the data base.
2012-01-09 14:28:29 +02:00
Santiago Carot-Nemesio
7188fe255e gatt-service: Add adapter in gatt_service_add function 2011-12-30 13:00:34 +02:00
Santiago Carot-Nemesio
6a1e46afaf attrib-server: Add adapter in attrib_db_add
Because of there can be many adapters plugged, the GATT servers must
provide the adapter in which the attributes will be registered.
2011-12-30 13:00:00 +02:00
Santiago Carot-Nemesio
bbc34269b0 attrib-server: Add adapter to attrib_db_find_avail function
Adapters manage their own list of handlers so we need to specify the
adapter where the handlers will be registered.
2011-12-30 12:59:09 +02:00
Claudio Takahasi
d6f93380ff attrib-client: Fix consecutive set value when disconnected
SetProperty for "Value" property needs to be queued when disconnected.
Registering ATTIO connection callback does not mean that the link is
established, GAttrib instance is assigned in the connection callback.
2011-12-27 12:05:20 +02:00
Claudio Takahasi
f583bef247 attrib-client: Fix GAttrib reference counting
Although ATT connection callbacks control GAttrib reference, each
entity using GAttrib should be increment the GAttrib reference to
keep the code standard.
2011-12-27 12:04:49 +02:00
Claudio Takahasi
6e4a000cab attrib-client: Remove unused SDP header includes 2011-12-27 12:03:19 +02:00
Johan Hedberg
b06899eace Fix device address type tracking 2011-12-23 13:00:55 +02:00
Santiago Carot-Nemesio
110f1830d7 att.h: Add client characteristic configuration bit fields 2011-12-15 13:16:51 +02:00
Santiago Carot-Nemesio
fc807dd254 Provide return status in gatt_service_add function
Service plugins using the new GATT API may need to know if their
attributes were successfully registered. In this way, plugins might
abort loading operation if they weren't registered.
2011-12-02 13:28:29 +02:00
Santiago Carot-Nemesio
9c535867ec Fix coding style issue regarding with pointer checks 2011-11-17 13:59:01 +02:00
Vinicius Costa Gomes
fffffad4b8 Add support for getting the handle of the CCC attribute 2011-11-14 21:09:36 +02:00
Anderson Lizardo
cdb0f1e52a Add GATT_OPT_CHR_VALUE_GET_HANDLE to gatt_service_add()
This new parameter accepts a pointer to a variable where the attribute
handle for the characteristic value is stored.
2011-11-14 21:09:22 +02:00
Anderson Lizardo
67cd2b0922 Implement high level GATT API for service registration
This new internal API can be used for implementing GATT services (server
role). It is built around the current attribute API (attrib_db_add() and
others).
2011-11-14 21:08:23 +02:00
Johan Hedberg
9b98a6c764 Add glib-compat.h to deal with issues in old GLib versions 2011-10-18 10:57:06 +03:00
Vinicius Costa Gomes
253f8a7c68 Fix using the attribute struct for encoding ATT pdus
The enconding and decoding of ATT pdus should be kept as much
free of dependences from other parts of the code as possible, so
it can be used in many contexts.

In this case, for encoding and decoding notifications and indications
we did have to pass an instance of an attribute instead of direct
values.
2011-10-07 19:52:32 +03:00
Vinicius Costa Gomes
eb41b504d0 Fix the attrib server trying to handle responses
The attribute server should only try to handle ATT requests, responses
and events should be handled by the client.
2011-09-22 20:25:25 +09:00
Anderson Lizardo
71d994a129 Refactor value assignments of bt_uuid_t variables
Prior to this commit, the assignments were made with memcpy(). This can
be unsafe and less readable, therefore it was replaced with code like:

<dst> = *src;

This also allows more compiler safety checks.
2011-09-22 20:01:30 +09:00
Anderson Lizardo
2acb6b1a3a Fix memory allocation of struct attribute
On commit 6a6da5de10 the struct
attribute "data[0]" member was replaced with a dynamically allocated
"data" pointer. This commit fixes remaining places where the old
allocation scheme was still assumed.
2011-09-22 20:01:28 +09:00
Anderson Lizardo
fef3e7c002 Remove empty line before declaration 2011-09-22 20:01:26 +09:00
Santiago Carot-Nemesio
3c4e447bdf Add valid range descriptor uuid 2011-09-16 11:34:04 +03:00
Vinicius Costa Gomes
6a6da5de10 Fix allocation of attribute values
Now that pointers to attribute are passed as reference to functions
we cannot have they change during run time, what g_try_realloc()
could do.
2011-09-16 11:32:40 +03:00
Claudio Takahasi
b3eea75304 Add on demand characteristic write
Changes the Generic Attribute registering a callback to request ATT
connection(if necessary) and write the characteristic value.
2011-07-27 10:32:40 +03:00
Claudio Takahasi
a0988557ea On demand connection for characteristics discovery
In the Generic Attribute API, when DiscoverCharacteristics is called
ATT connection should be requested if the link is not up. A query
list is required to control when the link can be disconnected since
the discover finishes after receiving all caracteristic declarations.
2011-07-27 10:32:17 +03:00
Claudio Takahasi
3177d97eed Register ATT connection callback based on watchers
In the Generic Attribute API, the ATT connection should be requested
on demand. In the case of watchers, the connection doesn't need to be
stay up if there isn't watcher registered.
2011-07-27 10:32:01 +03:00
Claudio Takahasi
8fb640ef60 Change GAttrib ref counting in Generic Attribute 2011-07-27 10:31:30 +03:00
Claudio Takahasi
e4a3edb111 Remove implicit connection from generic API
Generic attribute API should not actively manage L2CAP connections.
GAttrib instance is notified through registered callbacks. SetProperty
or DiscoverCharacteristic now returns NotConnected error if the link
is down.
2011-07-27 10:31:15 +03:00
Claudio Takahasi
95bf1f076a Register the ATT connection callbacks
Registers the ATT connection and disconnection callbacks in the generic
attribute API. First commit to remove implicit L2CAP connection
establishment.
2011-07-27 10:30:55 +03:00
Claudio Takahasi
3b010c0a14 Cleanup of primary service structs
Get rid of local structure to store all GATT primary services of a
given device. "primary" struct has been renamed to "gatt_service"
to avoid misinterpretation or confusion with "att_primary".
2011-07-27 10:30:25 +03:00
Claudio Takahasi
27347f58bd Cleanup of primary service registration 2011-07-27 10:30:13 +03:00
Claudio Takahasi
cdeb4dab7d Remove leftover D-Bus message in gatt_service 2011-07-27 10:29:58 +03:00
Claudio Takahasi
c34ccee6b8 Remove storing device path in gatt_service 2011-07-27 10:29:29 +03:00
Claudio Takahasi
c7b1f0bb28 Remove not necessary data from gatt_service
Bluetooth source and destination address can be obtained from the
device object. GATT service doesn't need to keep these addresses.
2011-07-27 10:28:47 +03:00
Marcel Holtmann
3f553a30ad Allow building with GLib 2.16 for now 2011-07-04 11:09:55 +02:00
Lucas De Marchi
fcb426c76a Fix common misspelled words
Accounting of misspelled words, as detected by codespell:

acording      2
ancilliary    1
appropiate    1
atribute      1
cant          1
comming       2
gracefull     1
lenght        1
mispelled     1
occured       1
occurences    1
ocurred       3
prefered      1
presense      1
reponse       1
seperate      1
succesful     1
successully   1
sucessfull    1
sucessfully   1
2011-07-03 14:36:14 +03:00
Luiz Augusto von Dentz
05cb01fc32 Make use of g_slist_free_full on attrib 2011-06-30 12:32:19 +03:00
Johan Hedberg
4b609b812f Add "quit" to gatttool supported commands 2011-06-08 09:59:20 +09:00
Szymon Janc
0c5f016867 Remove unused op variable from encode_discover_primary 2011-05-15 01:47:09 +03:00
Johan Hedberg
1f8969c043 Clean up ATT CID & PSM magic values & definititions
Use proper defines for the ATT CID and PSM. The values are really ATT
and not GATT specific so move them from gatt.h to att.h.
2011-04-26 21:13:49 +01:00
Claudio Takahasi
8447ce5c94 Remove btd_device_add_service function
btd_device_add_service is no longer necessary if the object paths for
the primary services can be returned during the registration.
2011-04-14 20:10:15 +03:00
Claudio Takahasi
612d020764 Register primary services exported over basic rate
This patch registers the object paths for primary services exported
through SDP. PSM, start and end handle information are available in
the Protocol Descriptor List.
2011-04-14 20:09:21 +03:00
Sheldon Demario
839adcd63d Fix race condition on gatttool
When the connect_cb() takes too long to be called the event_loop goes to
idle state and executes the callback too early
2011-04-14 20:05:23 +03:00
Claudio Takahasi
4b7da0b91d Add workaround to skip wrong OMTU for basic rate
This patch is required until the MTU kernel patch is integrated. Without
it the kernel returns zero for basic rate OMTU.
2011-04-09 10:46:06 -07:00
Sheldon Demario
6a3a89774c Fix Characteristic read by UUID on gatttool
The Characteristic read by UUID GATT procedure is not incremental, i.e.
it returns the entire list in a single Read By Type request. Therefore
it should not be called recursively.
2011-04-09 10:25:56 -07:00
Bruna Moreira
d0b675088a Remove deprecated attrib plugin
The attrib plugin is deprecated and it is not used anymore. Remove it
and all related configuration. Note that GATT utility (gatttool)
configuration item was moved to Makefile.tools and it is compiled when
--enable-tools is used in configure.
2011-04-01 16:43:11 +03:00
Claudio Takahasi
52727904b6 Remove "authen" and "autho" short versions for ATT constants 2011-03-30 19:38:46 +03:00
Anderson Lizardo
a3e9d397f0 Move GATT example server to a standalone plugin
The GATT example server was in the same plugin as the GATT client.
Moving it to a separate plugin will allow to easily disable it.
2011-03-30 19:19:29 +03:00
Vinicius Costa Gomes
a0b6c596e9 Add support for re-using the attrib channel
In some cases, when the device is already connected there's no need
to create another GAttrib instance.

This will allow the Attrib client to use the connection already
estabilished, this will be very useful when we support more
LE profiles.
2011-03-30 19:15:54 +03:00
Vinicius Costa Gomes
fc19dbe0d0 Remove _init and _exit methods from Attrib client
Now that Attrib client is being moved to the core, there's no
need to have explicit _init and _exit methods.

This also means that we need to pass the DBusConnection explicitly
to the registration method.
2011-03-30 19:15:52 +03:00
Vinicius Costa Gomes
279a538273 Register Attrib interface when loading device from storage
Now that the GATT client functionality is being moved to the
core we need to register the interface when the device is created.
2011-03-30 19:15:46 +03:00
Vinicius Costa Gomes
c6477c3ccc Move Attrib client to the core 2011-03-30 19:15:43 +03:00
Bruna Moreira
6fc92a5341 Add Exchange MTU in interactive gatttool 2011-03-18 11:22:45 +02:00
Bruna Moreira
1b07befa15 Add Exchange MTU operation in GATT library 2011-03-18 11:17:58 +02:00
Bruna Moreira
efcef2bd79 Use GAttrib buffer for ATT protocol PDUs
Prior to this commit, there were local buffers inside GATT functions.
Now, a single buffer is used, to make sure the MTU limit is respected.
2011-03-18 11:15:07 +02:00
Bruna Moreira
68887c2133 Add internal buffer to GAttrib struct
The new buffer is allocated in g_attrib_new() and it will be used to
send/receive PDUs. The buffer size is the MTU read from L2CAP channel
limited to ATT_MAX_MTU. Functions to handle the buffer size were also
created.
2011-03-18 11:14:35 +02:00
Sheldon Demario
922c5feb93 Add discover characteristics by UUID to gatttool
According to the specification the characteristics discover and
characteristics discover by UUID use the same opcode and the result
should be filtered by callback.
2011-03-17 14:50:59 +02:00
Johan Hedberg
c620d295f7 Remove redundant return statements from interactive gatttool 2011-03-15 22:27:00 +02:00
Elvis Pfützenreuter
a278db781a Use new UUID functions in GATT
This patch puts the new UUID functions into use for GATT-related
code, and adds some convenience functions to ATT API (att.h).
Example GATT server is also changed.
2011-03-15 19:36:48 +02:00
Vinicius Costa Gomes
6cb460ab9c Fix not returning an error when DiscoverCharacteristics() fails
When the connection fails an error should be returned to inform
the user.

This adds a field to store the DBusMessage that caused the error,
so we can send the correct reply.
2011-03-15 10:52:56 +02:00
Vinicius Costa Gomes
17c03b0de4 Fix the behaviour of the DiscoverCharacteristics method
The previous behaviour could lead to some problems, as it returned
as soon as possible. To avoid problems we return just after as the
characteristics are discovered, and to save a few round trips we
return the path of all characteristics that belong to this service.

After this method return it will try to read the characteristics
values.
2011-03-15 10:52:37 +02:00
Vinicius Costa Gomes
2663ca4207 Rename the Discover method to DiscoverCharacteristics 2011-03-15 10:52:23 +02:00
Sheldon Demario
cc2d6b4db8 Add indication/notification support to interactive gatttool 2011-03-11 12:55:54 +02:00
Claudio Takahasi
a37a95fe6d gatttool: Add Write Without Response option
Sub-procedure used to write a Characteristic Value to a server when
the client knows the Characteristic Value Handle and the client does
not need acknowledgement.
2011-03-10 11:20:33 +02:00
Claudio Takahasi
4fce91f1cf Extend Characteristic Write to support Write Without Response
If callback is not informed, Write Command will be used to execute
a Write Without Response sub-procedure. Error is not returned by the
server no matter the result of the operation.
2011-03-10 11:20:08 +02:00
Sheldon Demario
e880b7a554 Add option to pass adapter to interactive gatttool 2011-03-04 15:49:57 -03:00
Sheldon Demario
b2bd2cbc2a Add missing const to interactive() parameter in gatttool 2011-03-04 15:49:55 -03:00
Sheldon Demario
ed6e2d24ea Replace all strdup() with g_strdup() in gatttool 2011-03-04 15:49:53 -03:00
Sheldon Demario
adc7ca1ece Add offset option to characteristic read by handle
Some tests require an arbitrary offset.
2011-03-04 15:48:21 -03:00
Bruna Moreira
bd32dd623d Remove unused MTU variable in GAttrib struct
The MTU variable in GAttrib struct was not being used for any operation
so it should be removed.
2011-02-24 18:37:26 -03:00
Claudio Takahasi
448456a19f Coding standard change replacing malloc by glib functions
Use glib memory allocation functions instead of malloc for attribute
data list in ATT protocol utility functions.
2011-02-24 18:35:17 -03:00
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
Vinicius Costa Gomes
ed2fd82805 Add the btd_ prefix to device_add_service
This is needed to keep consistency, as device_add_service would be used
from outside the core bluetoothd.
2010-12-23 10:28:48 +02:00
Sheldon Demario
d3cb258b9b Move primary service storage to device.c
Discover All Primary Services has beed moved to device.c in order
to follow a similar approach of BR/EDR service records.
2010-12-23 00:34:04 +02:00
Vinicius Costa Gomes
5ffd0e6374 Fix attrib plugin deregistration
As the comparison method used for find what to de-register was
wrong, it was causing the btd_device reference that the attrib
plugin was keeping never to be dropped.
2010-12-22 13:50:17 +02:00
Brian Gix
7749241702 Add enc_read_blob_req() as defined in BT Core Spec v4.0 2010-12-19 14:10:40 +02:00
Claudio Takahasi
70ceea2eb9 Fix memory leak of gattrib commands queue 2010-12-16 11:25:02 +02:00
Gustavo F. Padovan
b684996b93 attrib: use btd_error_failed() 2010-12-14 10:31:17 +02:00
Bruna Moreira
d599b9e2b8 Check the security level on a per request base
Check security level on attribute server on each request, and update the
"encrypted" flag.
2010-12-09 15:59:46 +02:00
Claudio Takahasi
85d0be87c9 Remove automatic battery state change on attribute example
Legacy code implemented to test Indication and Notification
2010-12-07 23:53:17 +02:00
Gustavo F. Padovan
b7d1fc1f39 Add btd_error_not_authorized() 2010-12-07 23:13:16 +02:00
Gustavo F. Padovan
696c18c48f Create btd_error_invalid_args()
DBus error handling in BlueZ is a mess. This is the first patch to unify
all DBus error handling like in ConnMan and oFono. This unifies all
.InvalidArguments errors.
2010-12-07 22:58:32 +02:00
Vinicius Costa Gomes
1e35abda9f Fix writing to GAttrib socket without POLLOUT event
If the GIOChannel is in the buffered state (the default) the watch
function is called without receiving a POLLOUT from the socket. GLib
adds a G_IO_OUT condition just because there is space in the GIOChannel
internal buffer.

The solution is disabling the internal buffer, which in turn, makes the
call of g_io_channel_flush() useless.
2010-12-07 22:57:22 +02:00
Bruna Moreira
dd7a2acf88 Initial attribute permission implementation
Add enums for attribute read/write requirements, which may be "none",
"authentication required" or "authorization required". Additionally, a
"not permitted" requirement means that operation is not permitted,
allowing read-only or write-only attributes.

The attrib_db_add() API was changed to allow setting these requirements,
and the example server was changed to set requirements for its
attributes.
2010-12-07 22:52:25 +02:00
Sheldon Demario
90dec87b5c Attrib server should truncate attribute value to pdu length
When the size of attribute value is greater than pdu size, it should be
truncated to the pdu length - 2
2010-11-29 19:24:07 +02:00
Claudio Takahasi
f68cb33e96 Don't trigger the discovering when registering the client
Discover All Primary Services should not be trigged by the attribute
client when a given device is registered. Discover services is now done
by the device entity.
2010-11-29 19:21:00 +02:00
Claudio Takahasi
dbe7a78109 Fix memory leak of sdp list in the attribute client 2010-11-29 19:20:45 +02:00
Claudio Takahasi
d49c4e8457 Implement primary service search when creating a device
Discover primary services implemented inside the device entity to allow
proper integration of attribute plugin. Implements a single entry point
to the attribute plugin no matter the transport(BR/EDR or LE), the device
probe callback is called for both types.

Add a new function to discover all primary services without additional
calls to fetch the remaining primary services, sub-procedure iterations
is handled inside this function.

The next action are: clean the attribute client removing implicity service
and characteristics discovery, issue the Discover Primary Service based on
the remote properties and fetch the characteristic on demand.
2010-11-29 19:18:33 +02:00
Johan Hedberg
20ccc578c8 Remove unused includes 2010-11-28 13:41:35 +02:00
Sheldon Demario
63beb887a6 Extend discover characteristic by UUID in gatttool to fetch all values
If the number of characteristics returned exceeds the MTU size, it will
be needed to ask for more data until the handle range is entirely
searched.
2010-11-25 14:19:41 +02:00
Sheldon Demario
ad0e7f2c5a Implement Characteristic Value Read using UUID in the gatttool
Sub-procedure used to read a Characteristic Value when the client
only knows the characteristic UUID and doesn't know the handle.
More than one handle and attribute value pair can be returned,
it is up to the user define the handles range based on the service
handles range.

Usage example:
$gatttool --char-read --uuid=2a00 -i hcix -b xx:xx:xx:xx:xx:xx
2010-11-19 17:25:30 +02:00
Claudio Takahasi
f9523a9bf5 Implement Discover Primary Service by Service UUID in the gatttool
Implement only the first interaction of the discovery procedure. If the
response doesn't fit in the MTU, "start" and "end" options can be used
to discover the handles ranges of the remaining primary service instances.
UUID16 and UUID128 are supported in the uuid option.

Usage example:
$gatttool -i hcix -b xx:xx:xx:xx:xx:xx --uuid=1801 --primary
2010-11-18 22:00:02 +02:00
Claudio Takahasi
8022b94b05 Add an extra parameter in the discovery primary to specify the UUID
Extends discover primary function to perform discover by UUID. UUID
parameter defines which procedure will be executed: Discover All
Primary Services or Discover Primary Service by Service UUID.
2010-11-18 21:58:22 +02:00
Claudio Takahasi
2b3f200f29 Add Find By Type Value Response encoding/decoding functions
Find by type operation is used by Discover Primary Service by Service
UUID. Find By Type Value Response shall contain one or more group handles.
2010-11-18 21:53:54 +02:00
Bruna Moreira
b0d8865493 Implement Find by Type request encode/decoding 2010-11-18 16:44:19 +02:00
Sheldon Demario
e55509e013 Adding a new option to specify security level for gatttool 2010-11-18 14:20:11 +02:00
Claudio Takahasi
34d052348e Use reference counting of the device object while discovering services 2010-11-11 12:08:24 +02:00
Claudio Takahasi
1d723ac244 Fix invalid reference to GATT service structure 2010-11-05 07:00:44 +02:00
Claudio Takahasi
b9b0e471f2 Enable GATT over LE link on the attribute client 2010-11-05 07:00:42 +02:00
Anderson Lizardo
0a70694d3a Add support for Attribute Write Request
Implement encoders/decoders for Write Request/Response and the handling
on attribute server. The attribute client still uses the Write Command
because currently SetProperty() has no means to wait for the server
response.
2010-10-09 18:22:09 +03:00
Claudio Takahasi
e91886e6f8 Change Battery Service on attribute sample server
Add an optional Client Characteristic Configuration attribute for
Battery State to control which clients want notification/indication
when this attribute value changes.
2010-10-06 23:39:08 +02:00
Claudio Takahasi
b597e74fd9 Add PSM option for GATT/ATT over BR/EDR on gatttool 2010-10-05 22:26:37 +02:00
Johan Hedberg
89c9634c10 gatttool: fix trying to read beyond the last handle 2010-10-05 13:50:03 +02:00
Johan Hedberg
fa58d42ae6 Fix ATT OP codes to match spec 2010-10-05 11:27:15 +02:00
Anderson Lizardo
6352f7b918 Modify dec_read_req() to get PDU length as parameter
This is consistent with other att.h functions, and allows length checks.
2010-10-04 21:15:56 +02:00
Anderson Lizardo
dbad6fdb75 Replace hardcoded minimum length values with constants 2010-10-04 21:15:54 +02:00
Anderson Lizardo
69409f28f8 Remove typecast from att_get_u16() calls
att_get_u16() already does a cast of the void* parameter to uint16_t*.
2010-10-04 21:15:52 +02:00
Anderson Lizardo
805d059af3 Fix constness of att_get_u{8,16,32}() functions 2010-10-04 21:15:50 +02:00
Anderson Lizardo
19c8e31032 Allow errors to propagate from connection callback
This fix makes gatttool exit with non-zero return code on any error.
2010-10-04 17:06:49 +02:00
Anderson Lizardo
5b7b8ca746 Fix and refactor characteristic value update code 2010-10-04 17:06:49 +02:00
Bruna Moreira
a25fb7211b Implement characteristic_write callback in gatttool 2010-10-04 17:06:48 +02:00
Bruna Moreira
6f9ddeda63 Add new option for char value write in gatttool
Add new option --char-write for char value write (write without
response). Reuse current handle option and create the -n for new value.
Update variable names and help messages.

Note: characteristics_write callback is empty.
2010-10-04 17:06:48 +02:00
Bruna Moreira
2b80d7bf27 Make handle parameter mandatory in gatttool
If the characteristic read option (--char-read) is used, the handle
option (-a) must be provided.
2010-10-04 17:06:48 +02:00
Bruna Moreira
8d536ccf2b Use g_slist_foreach() instead of a for loop 2010-10-04 17:06:48 +02:00
Bruna Moreira
420d5b3313 Write new value for characteristic value
Note only client is implemented by now. The server implementation will
be done later.
2010-10-04 17:06:48 +02:00
Bruna Moreira
8edb7f03cf Move connection common code to l2cap_connect()
Common code for connection operations were moved to l2cap_connect()
function. This way, register_watchers() and set_value() can use it.
2010-10-04 17:06:48 +02:00
Anderson Lizardo
10840e3c30 Remove unnecessary check for watcher path 2010-10-04 17:06:48 +02:00
Bruna Moreira
b1514662a0 Implement Write command in GATT API 2010-10-04 17:06:48 +02:00
Bruna Moreira
48b01d5006 Add encoders/decoders for the Write command 2010-10-04 17:06:48 +02:00
Marcel Holtmann
d7f6fd397e The attribute protocol assigned PSM is 0x1f 2010-10-04 11:04:43 +02:00
Claudio Takahasi
2cbc3e1ba9 Add characteristic SetProperty implementation
Initial implementation of SetProperty. Add D-Bus method declaration and
extracts the arguments. The new requested characteristic value is not being
sent to the remote device yet.
2010-09-30 17:26:55 -03:00
Vinicius Costa Gomes
b3d33e592d Add "Services" property in the org.bluez.Device interface
Add a new property "Services" representing the object paths of the
available GATT primary services. "Services" is an array of D-Bus object
paths.
2010-09-30 17:26:55 -03:00
Vinicius Costa Gomes
7d13035153 Fix ValueChanged not being called on registered agents
The removed check was trying to verify that the watcher path was
the same as the characteristic being updated, which does not make
much sense.
2010-09-30 17:26:55 -03:00
Bruna Moreira
399d968958 Use bt_io_connect in gatttool
The gatttool was migrated to use bt_io_connect() instead of making
connections manually.
2010-09-30 17:26:55 -03:00
Vinicius Costa Gomes
dd714804cf Add support for LE connections to gatttool 2010-09-30 17:26:55 -03:00
Claudio Takahasi
e7b1d878d1 Fix coding style issues in attribute client code 2010-09-22 16:33:15 -04:00
Claudio Takahasi
d74b6fd61f Remove the timeout source function when the example server exits 2010-09-22 16:00:04 -04:00
Claudio Takahasi
a66ccf347b Fix memory leak of characteristic and primary service lists 2010-09-22 16:00:04 -04:00
Claudio Takahasi
90e1990f85 Unregister the primary and characteristic objects
Removes memory leak. When the attribute client is unregistered
primary and characteristic D-Bus objects shall be unregistered.
2010-09-22 16:00:04 -04:00
Claudio Takahasi
4435515810 Add UnregisterCharacteristicsWatcher implementation 2010-09-22 16:00:04 -04:00
Claudio Takahasi
59cc5e1fd0 Fix seg fault if the watcher exit before the connection complete 2010-09-22 16:00:04 -04:00
Claudio Takahasi
2eb3b72ac4 Fix disconnection when multiple watchers are registered
GAttrib ref counter shall be used to control when the remote shall be
disconnected. Ref counter is incremented when the watcher is registered
and decremented when it leaves the bus.
2010-09-22 16:00:04 -04:00
Claudio Takahasi
6b2fea1f37 Increment GAttrib reference for each GATT/ATT request
When multiples requests are queued, GAttrib ref count shall be
incremented to control disconnection. Allowing to disconnect from the
remote only the last response is received. This approach allow to
address errors and continue to process queued requests.
2010-09-22 15:59:52 -04:00
Claudio Takahasi
d0bfd6eaa5 Use the destroy function to reset the GAttrib reference
In the client, after local or remote initiated disconnection the GAttrib
reference shall be set to NULL to allow a proper control of references
and further connections.
2010-09-22 15:55:18 -04:00
Claudio Takahasi
8545bdc1ea Add g_attrib_set_destroy_function in gattrib
Add a new function to notify the GAttrib "users" when the GAttrib has
beed destroyed. The disconnect function is called only for remote initiated
disconnections or external events(not unref).
2010-09-22 15:55:18 -04:00
Claudio Takahasi
a5e1be914b Fix uninitialised value warning 2010-09-22 22:34:27 +03:00
Claudio Takahasi
27be80c804 Remove forward declaration on gattrib source 2010-09-22 22:34:27 +03:00
Claudio Takahasi
1b21625fb0 Add missing response for handle value indication on attribute client 2010-09-22 22:34:27 +03:00
Claudio Takahasi
8204b2e818 Report attribute changes for the Battery Service
Thermometer Humidity Service contains <<Include>> attributes that it is
not supported at the momment. For this service, Characteristics D-Bus
paths are not being registered properly. This patch allows watchers
testing registered for Battery State changes.
2010-09-22 22:34:27 +03:00
Claudio Takahasi
3fd8fddef6 Change notification/indication output formating on gatttool 2010-09-22 22:34:27 +03:00
Vinicius Costa Gomes
a58f4d094a Add a way to unregister GAttrib events
This implements g_attrib_unregister and g_attrib_unregister_all, these
methods allow events to be unregistered.
2010-09-22 22:34:26 +03:00
Claudio Takahasi
cb91573bfd Watchers don't need to reply for characteristic value updates
Value method call doesn't need confirmation. Minor optimization to
not sending method return or error replies.
2010-09-22 22:34:26 +03:00
Claudio Takahasi
e4481c09c4 Add watcher's characteristic path verification before notify changes
Each registered watcher instance is associated with a characteristic
path. Value() method shall not be sent to all watchers, characteristic
path shall match.
2010-09-22 22:34:26 +03:00
Claudio Takahasi
8125506bc1 Return an error if the path doesn't exist when registering a watcher
In the register characteristic watcher method, the given parameter
(characteristic path) shall be validated before register the watcher.
2010-09-22 22:34:26 +03:00
Vinicius Costa Gomes
316f35e7d8 Add support for actively updating the watcher
This adds support for calling the ValueChanged() method on the registered
watcher, when a characteristic on the associated service gets updated.
For now this method will be called when we get a Notification or an
Indication from the server.
2010-09-22 22:34:26 +03:00
Vinicius Costa Gomes
d98a28dabf Add support for Indications to the client
When receiving a Indication from the server, the Characteristic Value
associated with that indication is updated.

There's still no support for updating Characteristic Descriptors in
case they arrive, primarily because we don't know if it makes sense.
2010-09-22 22:34:26 +03:00
Vinicius Costa Gomes
1bacf59916 Add support for Indications to gatttool
Now gatttol is able to receive indication events and repond to them.
For now, this response is just sending the confirmation response back
to the server and printing the received update.
2010-09-22 22:34:26 +03:00
Vinicius Costa Gomes
9041deab65 Add encoders/decoders for Indication/Confirmation 2010-09-22 22:34:26 +03:00
Claudio Takahasi
37e3aa41e8 Update characteristic value when a notification is received
Changes the internal characteristic value in attribute client side.
Messages to notify the watchers are not being sent yet.
2010-09-22 22:34:26 +03:00
Johan Hedberg
797f8e1491 Fix coding style issues in attribute code 2010-09-22 00:09:32 +03:00
Claudio Takahasi
fb94142b19 Fix GIOChannel and GAttrib memory leak 2010-09-21 23:53:36 +03:00
Claudio Takahasi
b1f39ceabd Reconnect the BR/EDR L2CAP connection when a watcher is registered
When there is watcher active, the client shall set the Client
Characteristic Configuration attribute to receive Notifications or
Indications. This patch introduces the initial changes to re-connect and
watch for events.
2010-09-21 23:53:36 +03:00