From: Andrei Emeltchenko <[email protected]>
---
android/hal-health.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/android/hal-health.c b/android/hal-health.c
index ac6e87f..0d9136d 100644
--- a/android/hal-health.c
+++ b/android/hal-health.c
@@ -116,8 +116,7 @@ static bt_status_t register_application(bthl_reg_param_t *reg, int *app_id)
cmd->len = off;
status = hal_ipc_cmd(HAL_SERVICE_ID_HEALTH, HAL_OP_HEALTH_REG_APP,
sizeof(*cmd) + cmd->len, buf,
- &rsp_len, &rsp, NULL);
-
+ &rsp_len, &rsp, NULL);
if (status != BT_STATUS_SUCCESS)
return status;
--
1.8.3.2
Hi Andrei,
On Tuesday 24 of June 2014 15:11:52 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <[email protected]>
>
> ---
> android/hal-health.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/android/hal-health.c b/android/hal-health.c
> index ac6e87f..0d9136d 100644
> --- a/android/hal-health.c
> +++ b/android/hal-health.c
> @@ -116,8 +116,7 @@ static bt_status_t register_application(bthl_reg_param_t *reg, int *app_id)
> cmd->len = off;
> status = hal_ipc_cmd(HAL_SERVICE_ID_HEALTH, HAL_OP_HEALTH_REG_APP,
> sizeof(*cmd) + cmd->len, buf,
> - &rsp_len, &rsp, NULL);
> -
> + &rsp_len, &rsp, NULL);
> if (status != BT_STATUS_SUCCESS)
> return status;
>
>
All patches applied, thanks.
--
Best regards,
Szymon Janc
From: Andrei Emeltchenko <[email protected]>
Function will be used in other places as well.
---
android/health.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/android/health.c b/android/health.c
index a9287f6..c4df17a 100644
--- a/android/health.c
+++ b/android/health.c
@@ -1252,6 +1252,18 @@ static int get_mdep(struct health_channel *channel)
get_mdep_cb, channel, NULL, 0);
}
+static bool set_mcl_cb(struct mcap_mcl *mcl, gpointer user_data, GError **err)
+{
+ return mcap_mcl_set_cb(mcl, user_data, err,
+ MCAP_MDL_CB_CONNECTED, mcap_mdl_connected_cb,
+ MCAP_MDL_CB_CLOSED, mcap_mdl_closed_cb,
+ MCAP_MDL_CB_DELETED, mcap_mdl_deleted_cb,
+ MCAP_MDL_CB_ABORTED, mcap_mdl_aborted_cb,
+ MCAP_MDL_CB_REMOTE_CONN_REQ, mcap_mdl_conn_req_cb,
+ MCAP_MDL_CB_REMOTE_RECONN_REQ, mcap_mdl_reconn_req_cb,
+ MCAP_MDL_CB_INVALID);
+}
+
static void create_mcl_cb(struct mcap_mcl *mcl, GError *err, gpointer data)
{
struct health_channel *channel = data;
@@ -1271,14 +1283,7 @@ static void create_mcl_cb(struct mcap_mcl *mcl, GError *err, gpointer data)
channel->dev->mcl_conn = true;
info("MCL connected");
- ret = mcap_mcl_set_cb(channel->dev->mcl, channel, &gerr,
- MCAP_MDL_CB_CONNECTED, mcap_mdl_connected_cb,
- MCAP_MDL_CB_CLOSED, mcap_mdl_closed_cb,
- MCAP_MDL_CB_DELETED, mcap_mdl_deleted_cb,
- MCAP_MDL_CB_ABORTED, mcap_mdl_aborted_cb,
- MCAP_MDL_CB_REMOTE_CONN_REQ, mcap_mdl_conn_req_cb,
- MCAP_MDL_CB_REMOTE_RECONN_REQ, mcap_mdl_reconn_req_cb,
- MCAP_MDL_CB_INVALID);
+ ret = set_mcl_cb(channel->dev->mcl, channel->dev, &gerr);
if (!ret) {
error("health: error setting mdl callbacks on mcl");
g_error_free(gerr);
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
---
android/mcap-lib.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/android/mcap-lib.c b/android/mcap-lib.c
index 346688e..2a86416 100644
--- a/android/mcap-lib.c
+++ b/android/mcap-lib.c
@@ -2654,12 +2654,14 @@ static gboolean get_all_clocks(struct mcap_mcl *mcl, uint32_t *btclock,
while (latency > caps(mcl)->preempt_thresh && --retry >= 0) {
- clock_gettime(CLK, &t0);
+ if (clock_gettime(CLK, &t0) < 0)
+ return FALSE;
if (!read_btclock(mcl, btclock, &btres))
continue;
- clock_gettime(CLK, base_time);
+ if (clock_gettime(CLK, base_time) < 0)
+ return FALSE;
/*
* Tries to detect preemption between clock_gettime
@@ -2668,6 +2670,9 @@ static gboolean get_all_clocks(struct mcap_mcl *mcl, uint32_t *btclock,
latency = time_us(base_time) - time_us(&t0);
}
+ if (retry < 0)
+ return FALSE;
+
*timestamp = mcap_get_timestamp(mcl, base_time);
return TRUE;
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
---
android/mcap-lib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/mcap-lib.c b/android/mcap-lib.c
index be9ce79..346688e 100644
--- a/android/mcap-lib.c
+++ b/android/mcap-lib.c
@@ -2357,7 +2357,7 @@ void mcap_sync_stop(struct mcap_mcl *mcl)
static uint64_t time_us(struct timespec *tv)
{
- return tv->tv_sec * 1000000 + tv->tv_nsec / 1000;
+ return tv->tv_sec * 1000000ll + tv->tv_nsec / 1000ll;
}
static int64_t bt2us(int bt)
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
---
android/health.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/android/health.c b/android/health.c
index 4ff4356..a9287f6 100644
--- a/android/health.c
+++ b/android/health.c
@@ -1453,6 +1453,7 @@ static struct health_channel *get_channel(uint16_t app_id,
return create_channel(app_id, mdep_index, dev);
}
+
static void bt_health_connect_channel(const void *buf, uint16_t len)
{
const struct hal_cmd_health_connect_channel *cmd = buf;
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
create_device() should not search for apps again since we have searched
already, and we do not have always app_id.
---
android/health.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/android/health.c b/android/health.c
index 2613ca6..df97848 100644
--- a/android/health.c
+++ b/android/health.c
@@ -1352,12 +1352,11 @@ static int connect_mcl(struct health_channel *channel)
search_cb, channel, NULL, 0);
}
-static struct health_device *create_device(uint16_t app_id, const uint8_t *addr)
+static struct health_device *create_device(struct health_app *app,
+ const uint8_t *addr)
{
- struct health_app *app;
struct health_device *dev;
- app = queue_find(apps, app_by_app_id, INT_TO_PTR(app_id));
if (!app)
return NULL;
@@ -1367,7 +1366,6 @@ static struct health_device *create_device(uint16_t app_id, const uint8_t *addr)
return NULL;
android2bdaddr(addr, &dev->dst);
- dev->app_id = app_id;
dev->channels = queue_new();
if (!dev->channels) {
free_health_device(dev);
@@ -1397,7 +1395,11 @@ static struct health_device *get_device(uint16_t app_id, const uint8_t *addr)
if (dev)
return dev;
- return create_device(app_id, addr);
+ dev = create_device(app, addr);
+ if (dev)
+ dev->app_id = app_id;
+
+ return dev;
}
static struct health_channel *create_channel(uint16_t app_id,
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
---
android/health.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/android/health.c b/android/health.c
index 361e052..a1ae292 100644
--- a/android/health.c
+++ b/android/health.c
@@ -1566,7 +1566,6 @@ bool bt_health_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode)
mcl_disconnected, mcl_uncached,
NULL, /* CSP is not used right now */
NULL, &err);
-
if (!mcap) {
error("health: MCAP instance creation failed %s", err->message);
g_error_free(err);
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
gerr is always set on error condition.
---
android/health.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/android/health.c b/android/health.c
index a1ae292..4ff4356 100644
--- a/android/health.c
+++ b/android/health.c
@@ -1281,10 +1281,7 @@ static void create_mcl_cb(struct mcap_mcl *mcl, GError *err, gpointer data)
MCAP_MDL_CB_INVALID);
if (!ret) {
error("health: error setting mdl callbacks on mcl");
-
- if (gerr)
- g_error_free(gerr);
-
+ g_error_free(gerr);
goto fail;
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
For incoming connection NULL is passed as argument since application is
not known yet.
---
android/health.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/android/health.c b/android/health.c
index df97848..7281dd5 100644
--- a/android/health.c
+++ b/android/health.c
@@ -1020,6 +1020,9 @@ static void mcap_mdl_deleted_cb(struct mcap_mdl *mdl, void *data)
DBG("");
+ if (!channel)
+ return;
+
dev = channel->dev;
/* mdl == NULL means, delete all mdls */
if (!mdl) {
@@ -1540,12 +1543,30 @@ static const struct ipc_handler cmd_handlers[] = {
static void mcl_connected(struct mcap_mcl *mcl, gpointer data)
{
- DBG("Not implemented");
+ GError *gerr = NULL;
+ bool ret;
+
+ DBG("");
+
+ ret = set_mcl_cb(mcl, NULL, &gerr);
+ if (!ret) {
+ error("health: error setting mcl callbacks: %s", gerr->message);
+ g_error_free(gerr);
+ }
}
static void mcl_reconnected(struct mcap_mcl *mcl, gpointer data)
{
- DBG("Not implemented");
+ GError *gerr = NULL;
+ bool ret;
+
+ DBG("");
+
+ ret = set_mcl_cb(mcl, NULL, &gerr);
+ if (!ret) {
+ error("health: error setting mcl callbacks: %s", gerr->message);
+ g_error_free(gerr);
+ }
}
static void mcl_disconnected(struct mcap_mcl *mcl, gpointer data)
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
---
android/health.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/health.c b/android/health.c
index c4df17a..2613ca6 100644
--- a/android/health.c
+++ b/android/health.c
@@ -1285,7 +1285,7 @@ static void create_mcl_cb(struct mcap_mcl *mcl, GError *err, gpointer data)
ret = set_mcl_cb(channel->dev->mcl, channel->dev, &gerr);
if (!ret) {
- error("health: error setting mdl callbacks on mcl");
+ error("health: error setting mdl callbacks: %s", gerr->message);
g_error_free(gerr);
goto fail;
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
In case of error err is always set so the check is not needed.
---
android/health.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/android/health.c b/android/health.c
index f45ae51..361e052 100644
--- a/android/health.c
+++ b/android/health.c
@@ -1324,10 +1324,7 @@ static void search_cb(sdp_list_t *recs, int err, gpointer data)
if (!mcap_create_mcl(mcap, &channel->dev->dst, channel->dev->ccpsm,
create_mcl_cb, channel, NULL, &gerr)) {
error("health: error creating mcl %s", gerr->message);
-
- if (gerr)
- g_error_free(gerr);
-
+ g_error_free(gerr);
goto fail;
}
--
1.8.3.2