The callbacks could result with the reference count dropping to 0 and
the object being freed. This patch fixes the issue by adding one extra
reference for the duration of the timeout function.
23 octets is the default (and minimum) ATT_MTU value. If someone tries
to set ATT_MTU less than 23 octets g_attrib_set_mtu should fail (return
FALSE). Additionally, there is no constraint regarding the maximum value
of ATT_MTU, so we should not check for it.
Also, we should not change the L2CAP ATT fixed channel MTU. bt_io_set
call will always fail since we are not supposed to change L2CAP MTU
after connection is established.
GAttrib buffer should be allocated according to ATT_MTU value. Over
BR/EDR, ATT_MTU should be set to the L2CAP imtu negotiated during
L2CAP configuration phase. Over LE, ATT_MTU should be 23 octets.
A timer is set when a response is expected. The timer is removed when
data is received, regardless of whether or not the data is a response.
As a result, the timer may be cleared even though a response was not
received and there would be no way to detect a command timeout.
Fix this by clearing the timer only after verifying a response was
received.
Application error codes start off with 0x80 onwards. In CSSv2 the range
0xE0-0xFF is reserved for "Common Profile Error Codes" so we should
ensure not to mix that with our own definitions.
If we get an insufficient encryption error for ATT it doesn't
necessarily mean that we need to have high secirity. If we have an
unauthenticated key and are unencrypted it could also mean that we just
need to encrypt the link (medium security). Always requiring high
security would make the connection fail for unauthenticated keys.
This patch fixes command timeout handling. Previously attrib_destroy was
explicitly called which ignored any reference holders. This patch fixes
the issue by first passing errors to command callbacks and after that
marking the GAttrib object as stale so no further operations can be
done.
This patch fix unneeded discover characteristics transaction when the
last characteristic declaration contains the handle number equals to the
end handle of the primary service.
New requests and responses are never sent if a request was sent and the
response for it hasn't been received yet. As a result, if both end
points send requests at the same time, a deadlock could occur. This
could happen, for instance, if the client sends a read request and the
server sends an indication before responding to the read request.
Fix this by introducing an additional queue for responses. Responses may
be sent while there's still a pending request/indication.
This patch renames the constants related to Client Characteristic
Configuration bit field to use a proper name since it is related to
GATT instead of ATT.
Addressing types can be either BR/EDR, BLE public or BLE random so the
entries in the "attributes" file did not contain enough information to
distinguish which addressing type it's supposed to be. Entries will now
contain both address number and address type as a single key in every
entry in the file.
GATT can use BR/EDR or BLE as transport. Addressing types can be either
BR/EDR, BLE public or BLE random so the entries in the "characteristics"
file did not contain enough information to distinguish which addressing
type it's supposed to be. Entries will now contain both address number
and address type as a single key in every entry in the file.
This patch makes possible to specify LE address type.
After advertising cache was removed from kernel we should always specify
address type for LE link when calling bt_io_connect() as otherwise random
will always be used.
LE address type can be specified either by 'addr-type' or 't' command line
parameter or as additional parameter to 'connect' command in interactive mode.
Possible values are 'public' (default) and 'random'.
watcher_free() will be automatically called when removing the D-Bus
watch (it was set as the destroy callback when adding the watch),
therefore it is only necessary to remove the watch.
When registering a watcher, it is attempted to add an attio callback.
Therefore, when the watcher is unregistered or exits, this attio should
be removed if there are no other users.
This is already done when unregistering a watcher, it just missed when
it exits without unregistering.
On Generic Attribute, Discover All Characteristics of a Service can be
started immediately if already connected, without registering a ATTIO
connection callback.
On Generic Attribute, register only one ATTIO connection callback to
centralize the connection management.
Also make sure the connection reference is properly dropped only if
there is no pending operation.
In interactive mode, when connection is lost, the prompt used to remain
in "connected" state. This patch fixes that case, by always showing the
actual connection state.
We need to provide the service uuid because of GATT server should group
16-bit uuid services together and 128-bit uuid services together,
(Bluetooth 4.0, Vol 3, Part G, 3.1).
UUID services in GATT should be either 16-bit or 128-bit. Current
GATT interface does not allow to provide 128-bit ones. This patch
enables plugins to register services using 128-bit UUIDs.
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.
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.
Although ATT connection callbacks control GAttrib reference, each
entity using GAttrib should be increment the GAttrib reference to
keep the code standard.
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.
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).
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.
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.
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.
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.
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.
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.
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".
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.
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.
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.
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.
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.
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.
According to the specification the characteristics discover and
characteristics discover by UUID use the same opcode and the result
should be filtered by callback.