Commit Graph

107 Commits

Author SHA1 Message Date
Vinicius Costa Gomes
b5b44ce5c8 Fix not dealing with situations with not enough memory
GAttrib should fail gracefully in situations when it is not able to
allocate memory, not just crash, which is what g_new() does.
2010-08-24 10:20:09 -04:00
Vinicius Costa Gomes
0db74b68e8 Remove gatttool unix socket transport support 2010-08-24 10:20:08 -04:00
Anderson Lizardo
30e62c9151 gatttool: add characteristic descriptor discovery support
The --start/--end options are reused to allow specifying the
starting/ending handles. Both 16-bit and 128-bit UUIDs are
pretty-printed using sdp_uuid2strn() function.
2010-08-24 10:20:08 -04:00
Bruna Moreira
a764906095 Add characteristics descriptor discovery option in gatttool
Only skeleton for new option was added (no callback).
2010-08-24 10:20:08 -04:00
Vinicius Costa Gomes
f9778e74d0 Add g_attrib_set_disconnect_function()
The function set will be called when GAttrib detects that the link
was cut off. This will allow apps to take the proper actions in this
situation.
2010-08-20 15:15:09 -03:00
Claudio Takahasi
a31269eb57 Add listen option for gatttool
Add new option --listen to watch for notifications and indications.
At the momment only notifications are supported.
2010-08-19 17:47:25 -03:00
Claudio Takahasi
4648613aba Change attribute example to test notifications
Dummy time-based notification. Thermometer humidity attribute value
is being changed every 10 seconds.
2010-08-19 17:47:25 -03:00
Claudio Takahasi
f3349f5766 Add attribute handle value notification
Initial changes in attribute server to send notifications to all
connected clients when an attribute has changed. Characteristic
Configuration descriptor is not being addressed yet.
2010-08-19 17:47:25 -03:00
Vinicius Costa Gomes
83ac94801b Fix gatttool to use the alignment safe access functions 2010-08-19 17:28:03 -03:00
Vinicius Costa Gomes
c27ffa545b Fix alignment issues on the GATT Client
Makes use of the alignment safe functions in the GATT Client.
2010-08-19 17:28:03 -03:00
Vinicius Costa Gomes
5d82240f49 Fix alignment access issues during encoding/decoding
When encoding/decoding PDU fields, we have to be careful and use
alignment safe functions to load/store the values.

These functions will be exported so other parts of the code can reuse
them.
2010-08-19 17:28:03 -03:00
Vinicius Costa Gomes
1944301bb4 Fix wrong byte order on the Error Response handle 2010-08-11 13:54:08 -03:00
Vinicius Costa Gomes
80c5a1887b Fix reading the Characteristic value multiple times
We only need to read each characteristic value one time, for example,
at the time that try to discover if that characteristic has any descriptor.
2010-08-11 13:54:08 -03:00
Vinicius Costa Gomes
f70c6722f0 Fix using the wrong start handle for Desc. Discovery
When doing the Descriptor Discovery procedure, the wrong starting
handle was being used (the characteristic value handle). This is what
the spec mandates:

"The Attribute Protocol Find Information Request shall be used with the
Starting Handle set to the handle of the specified characteristic value
+ 1 and the Ending Handle set to the ending handle of the specified
characteristic."
2010-08-11 13:54:08 -03:00
Vinicius Costa Gomes
97a1889bac Fix memory leaks on g_attrib_unref()
We must clean up the event list and the command queue when we destroy
GAttrib, it could be that something is still there.
2010-08-11 13:54:08 -03:00
Vinicius Costa Gomes
f01213d025 Add support for cancelling commands
This adds support for cancelling commands. In case the command to be removed
is the first in the queue, cancelling it would cause its ResultFunc to not be
called. In the other cases, it will be removed from the queue.
2010-08-11 13:54:08 -03:00
Vinicius Costa Gomes
92d367140b Fix the opcode verification code being too cryptic
We need to be more specific about what is the expected response opcode
(if any) for each request command and about if some command is already a
response.
2010-08-11 13:47:54 -03:00
Bruna Moreira
84b6027450 Fix memory leaks in gatttool
Unix channel reference count must be decremented before exiting. Do not
exit main loop on recursive callbacks, thus allowing queued
g_attrib_send() commands to be finished. Free memory allocated for
opt_src/opt_dst.
2010-08-11 13:47:54 -03:00
Bruna Moreira
ac81ac5175 Exiting gatttool if no option is chosen
If no operation is chosen, print usage help and exit gatttool.
2010-08-09 18:06:50 -04:00
Vinicius Costa Gomes
e43827833a Fix g_attrib_new() to always create a read watcher
In order to simplify the code we can always add that watcher when GAttrib is
created and ignore the PDU's that aren't expected.
2010-08-09 18:06:50 -04:00
Vinicius Costa Gomes
8307634aa6 Update copyright information of GATT library/tools 2010-08-09 18:06:49 -04:00
Vinicius Costa Gomes
95620eae34 Add support for reading Char values and descriptors
When the characteristic is read for the first time, we read and update
its value and its descriptors.
2010-08-09 18:06:49 -04:00
Vinicius Costa Gomes
c2b9e70040 Add support for discovering all the descriptors
All descriptors associated to every characteristic are discovered, which means,
that we know its handle and type. With this information we can later read the
values of the descriptors that we find interesting.
2010-08-09 18:06:49 -04:00
Vinicius Costa Gomes
c4fe3b3a0b Add helper functions to send Find Information requests
This function allows one to send Find Information requests without
having to build the PDU by hand each time.
2010-08-09 18:06:49 -04:00
Vinicius Costa Gomes
eabdd736c6 Add encoders and decoders for the Find Information PDU's 2010-08-09 18:06:49 -04:00
Vinicius Costa Gomes
c606feeb48 Add the GetCharacteristics() DBus method
This method allows the retrieval of every known information about the
characteristics beloging to a Service.
2010-08-09 18:06:49 -04:00
Vinicius Costa Gomes
a9a4e52bee Fix wrong paths for the Services objects
When restoring the Service information from storage, the path was created
before reading the information from storage.
2010-08-09 18:06:49 -04:00
Anderson Lizardo
08e83df251 gatttool: simplify characteristic discovery output 2010-08-09 18:06:49 -04:00
Anderson Lizardo
4dc133a198 gatttool: Replace --char-value-read with generic --char-read option
The new option is useful for reading either characteristic values or
descriptors, which use the same Read Request. This commit also fixes a
few errors related to the handle options.
2010-08-09 18:06:49 -04:00
Bruna Moreira
cafebc60e7 Remove multiple calls for g_idle_add() in gatttool 2010-08-09 18:06:49 -04:00
Bruna Moreira
0e7aa8f0ac Move connection operations to main in gatttool
The connection operations (do_connect) were moved to main. So, the
internal call to do_connect() were removed and GAttrib structure is
initialized/freed in main. All callbacks receive the GAttrib structure
through the user_data parameter.
2010-08-09 18:06:49 -04:00
Anderson Lizardo
a3f410d1f2 gatttool: coding style fixes 2010-08-09 18:06:49 -04:00
Bruna Moreira
eaef3c6c2c Add function to open connections in gatttool
The do_connect() function was created to open unix/l2cap sockets. It is
used by primary, characteristics and characteristics value options.
2010-08-09 18:06:48 -04:00
Bruna Moreira
6489a249a5 Change client to use dec_read_by_grp_resp() 2010-08-09 18:06:48 -04:00
Bruna Moreira
af40b52994 Change gatttool to use dec_read_by_grp_resp()
The primary callback in gatttool was updated to use
dec_read_by_grp_resp() function. Also, the printed message was updated
to use same spec nomenclature.
2010-08-09 18:06:48 -04:00
Claudio Takahasi
b862c11182 Remove unused parameter for register_characteristics function 2010-08-09 18:06:48 -04:00
Claudio Takahasi
754fce193b Initial implementation of characteristics GetProperties()
Returns a dictionary of characteristic properties. Format, Value and
Representation are not supported yet.
2010-08-09 18:06:48 -04:00
Vinicius Costa Gomes
68299d1d74 Fix some memory leaks when closing a GATT connection 2010-08-09 18:06:48 -04:00
Vinicius Costa Gomes
1e1434c1b7 Fix coding style issues
Some lines were passing the 79 columns limit.
2010-08-09 18:06:48 -04:00
Vinicius Costa Gomes
ee2b848176 Add support for the GAttrib queue to the client plugin
Now, that we have a proper queue for command serialization, we can remove
the previous hacks to implement a partial serialization in the client.
2010-08-09 18:06:48 -04:00
Vinicius Costa Gomes
79cb696f56 Fix the last group of characteristic not being stored
The characteristic group beloging to the last service was not being stored,
because the condition to trigger the storage was missing that last group.
2010-08-09 18:06:48 -04:00
Vinicius Costa Gomes
d7b3bbbd6e Add a Queue to serialize the GATT PDU's
With this queue we can have more control about which commands are sent, and
be sure that what is received is what we expect.
2010-08-09 18:06:48 -04:00
Anderson Lizardo
765b7e0e56 Implement characteristic value read in gatttool 2010-08-09 18:06:48 -04:00
Anderson Lizardo
262323b597 Implement characteristic value read on attribute server 2010-08-09 18:06:48 -04:00
Bruna Moreira
d8827654f9 Add characteristics value read option in gatttool
Only skeleton for new option was added (empty callback and options). The
characteristics value readi must receive a handle.
2010-08-09 18:06:48 -04:00
Bruna Moreira
416809f34b Change discover characteristics output
Make the discover characteristics output more readable (the result
values were split in permission, characteristic value handle and uuid).
2010-08-09 18:06:48 -04:00
Bruna Moreira
765a807fdc Fix memory leaks in gatttool 2010-08-09 18:06:48 -04:00
Claudio Takahasi
253ccc6d4a Remove dynamic memory allocation for uuid_t of the primary service 2010-08-09 18:06:48 -04:00
Vinicius Costa Gomes
de731d19c9 Fix wrong value for each characteristic end handle 2010-08-09 18:06:47 -04:00
Vinicius Costa Gomes
baa95be886 Fix the byte order of some of the examples handles
Some of the handles of the example's attributes were in the wrong order.
2010-08-09 18:06:47 -04:00