This fixes the following issue:
==8505== Syscall param socketcall.sendmsg(msg.msg_iov[i]) points to
uninitialised byte(s)
==8505== at 0x534133D: ??? (syscall-template.S:82)
==8505== by 0x7756346: hal_ipc_cmd (hal-ipc.c:359)
==8505== by 0x7750EB2: init (hal-health.c:206)
==8505== by 0x40DF7F: init_p (if-hl.c:86)
==8505== by 0x401961: main (haltest.c:417)
==8505== Address 0x7fefffb81 is on thread 1's stack
We prepare response by filling btgatt_response_t union's first member
only. The same thing is done by JNI in Android, which ignores second
member. There is also no parameter to tell which union member is set.
More to this, second union member seams to be redundant duplicate of
first member's inner member (broken API?). JNI method is always called
with auth_req set to 0 thus this parameter is omitted in haltest.
As we always send whole gatt_response_t struct through IPC,
but copy only cmd->len bytes, the rest should be initilised to 0.
This fixes the following issue:
==30585== Syscall param socketcall.sendmsg(msg.msg_iov[i]) points
to uninitialised byte(s)
==30585== at 0x534133D: ??? (syscall-template.S:82)
==30585== by 0x7756336: hal_ipc_cmd (hal-ipc.c:359)
==30585== by 0x77546DF: send_response.part.0 (hal-gatt.c:1247)
==30585== by 0x408119: gatts_send_response_p (if-gatt.c:1777)
==30585== by 0x40219F: process_line (haltest.c:293)
==30585== by 0x402552: terminal_action_enter (terminal.c:666)
==30585== by 0x403184: terminal_process_char (terminal.c:781)
==30585== by 0x401B90: stdin_handler (haltest.c:308)
==30585== by 0x402261: poll_dispatch_loop (pollhandler.c:60)
==30585== by 0x401870: main (haltest.c:441)
==30585== Address 0x7fefff2a3 is on thread 1's stack
This is in preparation for a set_leds_sysfs() function.
Make set_leds_hidraw() return void, as its return value is never used
by the caller: the setup_leds() callback has to always return FALSE.
If value and length was set by callback while gatt_db_read(), don't set
length to READ_PENDING. We have to set it only for async callbacks, then
length is still READ_INIT.
As from database point of view there are two data sources (db entry,
and callbacks), we need to perform 'find by type' in databse and filter
out entries with not matching values, before sending.
'Find by type and value' was handling only values written directly to
database and not those returned by callbacks or by Android Framework.
This replaces it with 'find by type' and leaves value verification to
the user.
This changes device info and gap services callbacks to use response queue.
It will allow them work with plain read and read by type as well.
This starts transition to single response data queue, which should be
filled by various read type functions and processed in one place. This
will unify the way that responses are send, regardless of data source
(value taken directly from database, returned by read callback or sent
from upper layers asynchronously).
We will also introduce 'getter' type functions, using handles to
retrieve data from database. This will make various read and find
operations return handles instead of their own custom structures,
different for every operation performed.
If value exists in database, return pointer to it instead of returning
false. It is needed because some attributes don't have read_cb callback
and their value can be read directly from database.
In the case that the remote starts connecting to us while we're waiting
for the timeout to discover we shouldn't just reset the basic time
keeping variables but also remove the timer.
This patch adds an API to monitor devices disconnections, including the
reason for the disconnection. It paves the way to allow creating a
policy for reconnecting when disconnected.