From: Andrei Emeltchenko <[email protected]>
---
android/adapter.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index af461b8..fdac82e 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -1017,13 +1017,14 @@ static void send_adapter_address(void)
g_free(ev);
}
-static bool get_name(void)
+static bool send_adapter_name(void)
{
- DBG("Not implemented");
+ if (!adapter->name)
+ return false;
- /* TODO: Add implementation */
+ adapter_name_changed((uint8_t *) adapter->name);
- return false;
+ return true;
}
static bool get_uuids(void)
@@ -1098,7 +1099,7 @@ static bool get_property(void *buf, uint16_t len)
send_adapter_address();
return true;
case HAL_PROP_ADAPTER_NAME:
- return get_name();
+ return send_adapter_name();
case HAL_PROP_ADAPTER_UUIDS:
return get_uuids();
case HAL_PROP_ADAPTER_CLASS:
--
1.7.10.4
Hi Andrei,
On Mon, Nov 04, 2013, Andrei Emeltchenko wrote:
> Use adapter_name_changed for get_property call.
> ---
> android/adapter.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
All four patches have been applied. Thanks.
Johan
From: Andrei Emeltchenko <[email protected]>
Make function name consistent with the rest of the code.
---
android/adapter.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index 3e43d44..c2a6bf3 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -995,7 +995,7 @@ static bool set_discoverable(uint8_t mode, uint16_t timeout)
return false;
}
-static void send_adapter_address(void)
+static void get_address(void)
{
struct hal_ev_adapter_props_changed *ev;
int len;
@@ -1096,7 +1096,7 @@ static bool get_property(void *buf, uint16_t len)
switch (cmd->type) {
case HAL_PROP_ADAPTER_ADDR:
- send_adapter_address();
+ get_address();
return true;
case HAL_PROP_ADAPTER_NAME:
return get_name();
--
1.7.10.4
From: Andrei Emeltchenko <[email protected]>
Android use the full string returned even if we terminate it with '\0'.
---
android/adapter.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index c2a6bf3..45b2d4a 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -145,8 +145,8 @@ static void scan_mode_changed(void)
static void adapter_name_changed(const uint8_t *name)
{
struct hal_ev_adapter_props_changed *ev;
- uint8_t buf[sizeof(*ev) + sizeof(struct hal_property) +
- HAL_MAX_NAME_LENGTH];
+ size_t len = strlen((const char *) name);
+ uint8_t buf[sizeof(*ev) + sizeof(struct hal_property) + len];
memset(buf, 0, sizeof(buf));
ev = (void *) buf;
@@ -154,10 +154,11 @@ static void adapter_name_changed(const uint8_t *name)
ev->num_props = 1;
ev->status = HAL_STATUS_SUCCESS;
ev->props[0].type = HAL_PROP_ADAPTER_NAME;
- ev->props[0].len = HAL_MAX_NAME_LENGTH;
- memcpy(ev->props->val, name, HAL_MAX_NAME_LENGTH);
+ /* Android expects value without NULL terminator */
+ ev->props[0].len = len;
+ memcpy(ev->props->val, name, len);
- DBG("Adapter name changed to: %s", ev->props->val);
+ DBG("Adapter name changed to: %s", name);
ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
HAL_EV_ADAPTER_PROPS_CHANGED, sizeof(buf), ev, -1);
--
1.7.10.4
From: Andrei Emeltchenko <[email protected]>
Use adapter_name_changed for get_property call.
---
android/adapter.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index af461b8..3e43d44 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -1019,11 +1019,12 @@ static void send_adapter_address(void)
static bool get_name(void)
{
- DBG("Not implemented");
+ if (!adapter->name)
+ return false;
- /* TODO: Add implementation */
+ adapter_name_changed((uint8_t *) adapter->name);
- return false;
+ return true;
}
static bool get_uuids(void)
--
1.7.10.4
From: Andrei Emeltchenko <[email protected]>
Android passes not NULL terminated strings.
---
android/client/textconv.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/android/client/textconv.c b/android/client/textconv.c
index 8e6bdb9..9a2f7e6 100644
--- a/android/client/textconv.c
+++ b/android/client/textconv.c
@@ -258,7 +258,8 @@ char *btproperty2str(const bt_property_t *property)
switch (property->type) {
case BT_PROPERTY_BDNAME:
case BT_PROPERTY_REMOTE_FRIENDLY_NAME:
- sprintf(p, "%s", ((bt_bdname_t *) property->val)->name);
+ snprintf(p, property->len + 1, "%s",
+ ((bt_bdname_t *) property->val)->name);
break;
case BT_PROPERTY_BDADDR:
--
1.7.10.4
Hi Luiz,
On Mon, Nov 04, 2013 at 01:17:35PM +0200, Luiz Augusto von Dentz wrote:
> Hi Andrei,
>
> On Mon, Nov 4, 2013 at 12:49 PM, Andrei Emeltchenko
> <[email protected]> wrote:
> > From: Andrei Emeltchenko <[email protected]>
> >
> > ---
> > android/adapter.c | 11 ++++++-----
> > 1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/android/adapter.c b/android/adapter.c
> > index af461b8..fdac82e 100644
> > --- a/android/adapter.c
> > +++ b/android/adapter.c
> > @@ -1017,13 +1017,14 @@ static void send_adapter_address(void)
> > g_free(ev);
> > }
> >
> > -static bool get_name(void)
> > +static bool send_adapter_name(void)
> > {
> > - DBG("Not implemented");
> > + if (!adapter->name)
> > + return false;
> >
> > - /* TODO: Add implementation */
> > + adapter_name_changed((uint8_t *) adapter->name);
> >
> > - return false;
> > + return true;
> > }
> >
> > static bool get_uuids(void)
> > @@ -1098,7 +1099,7 @@ static bool get_property(void *buf, uint16_t len)
> > send_adapter_address();
> > return true;
> > case HAL_PROP_ADAPTER_NAME:
> > - return get_name();
> > + return send_adapter_name();
>
> Not sure why you are changing the name here, all the other properties
> is using the same format as get_<name of property>.
I am following style, look at previous function: send_adapter_address. So
shall I change that one also in a separate patch?
Best regards
Andrei Emeltchenko
Hi Andrei,
On Mon, Nov 4, 2013 at 12:49 PM, Andrei Emeltchenko
<[email protected]> wrote:
> From: Andrei Emeltchenko <[email protected]>
>
> ---
> android/adapter.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/android/adapter.c b/android/adapter.c
> index af461b8..fdac82e 100644
> --- a/android/adapter.c
> +++ b/android/adapter.c
> @@ -1017,13 +1017,14 @@ static void send_adapter_address(void)
> g_free(ev);
> }
>
> -static bool get_name(void)
> +static bool send_adapter_name(void)
> {
> - DBG("Not implemented");
> + if (!adapter->name)
> + return false;
>
> - /* TODO: Add implementation */
> + adapter_name_changed((uint8_t *) adapter->name);
>
> - return false;
> + return true;
> }
>
> static bool get_uuids(void)
> @@ -1098,7 +1099,7 @@ static bool get_property(void *buf, uint16_t len)
> send_adapter_address();
> return true;
> case HAL_PROP_ADAPTER_NAME:
> - return get_name();
> + return send_adapter_name();
Not sure why you are changing the name here, all the other properties
is using the same format as get_<name of property>.
--
Luiz Augusto von Dentz
From: Andrei Emeltchenko <[email protected]>
Android use the full string returned even if we terminate it with '\0'.
---
android/adapter.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index fdac82e..1b84956 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -145,8 +145,8 @@ static void scan_mode_changed(void)
static void adapter_name_changed(const uint8_t *name)
{
struct hal_ev_adapter_props_changed *ev;
- uint8_t buf[sizeof(*ev) + sizeof(struct hal_property) +
- HAL_MAX_NAME_LENGTH];
+ size_t len = strlen((const char *) name);
+ uint8_t buf[sizeof(*ev) + sizeof(struct hal_property) + len];
memset(buf, 0, sizeof(buf));
ev = (void *) buf;
@@ -154,10 +154,11 @@ static void adapter_name_changed(const uint8_t *name)
ev->num_props = 1;
ev->status = HAL_STATUS_SUCCESS;
ev->props[0].type = HAL_PROP_ADAPTER_NAME;
- ev->props[0].len = HAL_MAX_NAME_LENGTH;
- memcpy(ev->props->val, name, HAL_MAX_NAME_LENGTH);
+ /* Android expects value without NULL terminator */
+ ev->props[0].len = len;
+ memcpy(ev->props->val, name, len);
- DBG("Adapter name changed to: %s", ev->props->val);
+ DBG("Adapter name changed to: %s", name);
ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
HAL_EV_ADAPTER_PROPS_CHANGED, sizeof(buf), ev, -1);
--
1.7.10.4