- adds support for hidhost
- adds tab completion for hidhost
- adds help for hidhost
- magic number to #define change for buffer sizes
Jerzy Kasenberg (3):
android: Add definition of buffer sizes to haltest
android: Add calls to hidhost interface to haltest
android: Add help to hidhost in haltest
Makefile.android | 2 +
android/Android.mk | 1 +
android/client/haltest.c | 1 +
android/client/if-bt.c | 10 +-
android/client/if-hh.c | 431 +++++++++++++++++++++++++++++++++++++++++++++
android/client/if-main.h | 2 +
android/client/textconv.c | 2 +-
android/client/textconv.h | 2 +
8 files changed, 445 insertions(+), 6 deletions(-)
create mode 100644 android/client/if-hh.c
--
1.7.9.5
Hi Jerzy,
On Tue, Oct 22, 2013, Jerzy Kasenberg wrote:
> - adds support for hidhost
> - adds tab completion for hidhost
> - adds help for hidhost
> - magic number to #define change for buffer sizes
>
> Jerzy Kasenberg (3):
> android: Add definition of buffer sizes to haltest
> android: Add calls to hidhost interface to haltest
> android: Add help to hidhost in haltest
>
> Makefile.android | 2 +
> android/Android.mk | 1 +
> android/client/haltest.c | 1 +
> android/client/if-bt.c | 10 +-
> android/client/if-hh.c | 431 +++++++++++++++++++++++++++++++++++++++++++++
> android/client/if-main.h | 2 +
> android/client/textconv.c | 2 +-
> android/client/textconv.h | 2 +
> 8 files changed, 445 insertions(+), 6 deletions(-)
> create mode 100644 android/client/if-hh.c
All three patches have been applied. Thanks.
Johan
This patch adds code so hidhost interface can be tested.
---
Makefile.android | 2 +
android/Android.mk | 1 +
android/client/haltest.c | 1 +
android/client/if-bt.c | 2 +-
android/client/if-hh.c | 365 ++++++++++++++++++++++++++++++++++++++++++++++
android/client/if-main.h | 2 +
6 files changed, 372 insertions(+), 1 deletion(-)
create mode 100644 android/client/if-hh.c
diff --git a/Makefile.android b/Makefile.android
index aebc715..720df69 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -48,6 +48,7 @@ android_haltest_SOURCES = android/client/haltest.c \
android/client/textconv.c \
android/client/tabcompletion.c \
android/client/if-bt.c \
+ android/client/if-hh.c \
android/client/hwmodule.c
android_haltest_LDADD = android/libhal-internal.la
@@ -73,6 +74,7 @@ EXTRA_DIST += android/client/terminal.c \
android/client/pollhandler.c \
android/client/history.c \
android/client/if-bt.c \
+ android/client/if-hh.c \
android/client/textconv.c \
android/client/tabcompletion.c \
android/client/textconv.h \
diff --git a/android/Android.mk b/android/Android.mk
index 679c12b..c4b0621 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -83,6 +83,7 @@ LOCAL_SRC_FILES := \
client/textconv.c \
client/tabcompletion.c \
client/if-bt.c \
+ client/if-hh.c \
LOCAL_SHARED_LIBRARIES := libhardware
diff --git a/android/client/haltest.c b/android/client/haltest.c
index 4864de1..2894565 100644
--- a/android/client/haltest.c
+++ b/android/client/haltest.c
@@ -31,6 +31,7 @@
const struct interface *interfaces[] = {
&bluetooth_if,
+ &hh_if,
NULL
};
diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index f65e5f0..5f88a64 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -805,7 +805,7 @@ static void get_profile_interface_p(int argc, const char **argv)
else if (strcmp(BT_PROFILE_SOCKETS_ID, id) == 0)
pif = &dummy; /* TODO: change when if_sock is there */
else if (strcmp(BT_PROFILE_HIDHOST_ID, id) == 0)
- pif = &dummy; /* TODO: change when if_hh is there */
+ pif = (const void **)&if_hh;
else if (strcmp(BT_PROFILE_PAN_ID, id) == 0)
pif = &dummy; /* TODO: change when if_pan is there */
else if (strcmp(BT_PROFILE_AV_RC_ID, id) == 0)
diff --git a/android/client/if-hh.c b/android/client/if-hh.c
new file mode 100644
index 0000000..09eaf9c
--- /dev/null
+++ b/android/client/if-hh.c
@@ -0,0 +1,365 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <ctype.h>
+
+#include <hardware/bluetooth.h>
+#include <hardware/bt_hh.h>
+
+#include "if-main.h"
+#include "pollhandler.h"
+
+const bthh_interface_t *if_hh = NULL;
+
+SINTMAP(bthh_protocol_mode_t, -1, "(unknown)")
+ DELEMENT(BTHH_REPORT_MODE),
+ DELEMENT(BTHH_BOOT_MODE),
+ DELEMENT(BTHH_UNSUPPORTED_MODE),
+ENDMAP
+
+SINTMAP(bthh_report_type_t, -1, "(unknown)")
+ DELEMENT(BTHH_INPUT_REPORT),
+ DELEMENT(BTHH_OUTPUT_REPORT),
+ DELEMENT(BTHH_FEATURE_REPORT),
+ENDMAP
+
+SINTMAP(bthh_connection_state_t, -1, "(unknown)")
+ DELEMENT(BTHH_CONN_STATE_CONNECTED),
+ DELEMENT(BTHH_CONN_STATE_CONNECTING),
+ DELEMENT(BTHH_CONN_STATE_DISCONNECTED),
+ DELEMENT(BTHH_CONN_STATE_DISCONNECTING),
+ DELEMENT(BTHH_CONN_STATE_FAILED_MOUSE_FROM_HOST),
+ DELEMENT(BTHH_CONN_STATE_FAILED_KBD_FROM_HOST),
+ DELEMENT(BTHH_CONN_STATE_FAILED_TOO_MANY_DEVICES),
+ DELEMENT(BTHH_CONN_STATE_FAILED_NO_BTHID_DRIVER),
+ DELEMENT(BTHH_CONN_STATE_FAILED_GENERIC),
+ DELEMENT(BTHH_CONN_STATE_UNKNOWN),
+ENDMAP
+
+SINTMAP(bthh_status_t, -1, "(unknown)")
+ DELEMENT(BTHH_OK),
+ DELEMENT(BTHH_HS_HID_NOT_READY),
+ DELEMENT(BTHH_HS_INVALID_RPT_ID),
+ DELEMENT(BTHH_HS_TRANS_NOT_SPT),
+ DELEMENT(BTHH_HS_INVALID_PARAM),
+ DELEMENT(BTHH_HS_ERROR),
+ DELEMENT(BTHH_ERR),
+ DELEMENT(BTHH_ERR_SDP),
+ DELEMENT(BTHH_ERR_PROTO),
+ DELEMENT(BTHH_ERR_DB_FULL),
+ DELEMENT(BTHH_ERR_TOD_UNSPT),
+ DELEMENT(BTHH_ERR_NO_RES),
+ DELEMENT(BTHH_ERR_AUTH_FAILED),
+ DELEMENT(BTHH_ERR_HDL),
+ENDMAP
+
+/*
+ * Callback for connection state change.
+ * state will have one of the values from bthh_connection_state_t
+ */
+static void connection_state_cb(bt_bdaddr_t *bd_addr,
+ bthh_connection_state_t state)
+{
+ char addr[MAX_ADDR_STR_LEN];
+
+ haltest_info("%s: bd_addr=%s connection_state=%s\n", __func__,
+ bt_bdaddr_t2str(bd_addr, addr),
+ bthh_connection_state_t2str(state));
+}
+
+/*
+ * Callback for virtual unplug api.
+ * the status of the virtual unplug
+ */
+static void virtual_unplug_cb(bt_bdaddr_t *bd_addr, bthh_status_t hh_status)
+{
+ char addr[MAX_ADDR_STR_LEN];
+
+ haltest_info("%s: bd_addr=%s hh_status=%s\n", __func__,
+ bt_bdaddr_t2str(bd_addr, addr),
+ bthh_status_t2str(hh_status));
+}
+
+/*
+ * Callback for get hid info
+ * hid_info will contain attr_mask, sub_class, app_id, vendor_id, product_id,
+ * version, ctry_code, len
+ */
+static void hid_info_cb(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info)
+{
+ char addr[MAX_ADDR_STR_LEN];
+
+ /* TODO: print actual hid_info */
+ haltest_info("%s: bd_addr=%s\n", __func__,
+ bt_bdaddr_t2str(bd_addr, addr));
+}
+
+/*
+ * Callback for get/set protocol api.
+ * the protocol mode is one of the value from bthh_protocol_mode_t
+ */
+static void protocol_mode_cb(bt_bdaddr_t *bd_addr, bthh_status_t hh_status,
+ bthh_protocol_mode_t mode)
+{
+ char addr[MAX_ADDR_STR_LEN];
+
+ haltest_info("%s: bd_addr=%s hh_status=%s mode=%s\n", __func__,
+ bt_bdaddr_t2str(bd_addr, addr),
+ bthh_status_t2str(hh_status),
+ bthh_protocol_mode_t2str(mode));
+}
+
+/*
+ * Callback for get/set_idle_time api.
+ */
+static void idle_time_cb(bt_bdaddr_t *bd_addr, bthh_status_t hh_status,
+ int idle_rate)
+{
+ char addr[MAX_ADDR_STR_LEN];
+
+ haltest_info("%s: bd_addr=%s hh_status=%s idle_rate=%d\n", __func__,
+ bt_bdaddr_t2str(bd_addr, addr),
+ bthh_status_t2str(hh_status), idle_rate);
+}
+
+
+/*
+ * Callback for get report api.
+ * if status is ok rpt_data contains the report data
+ */
+static void get_report_cb(bt_bdaddr_t *bd_addr, bthh_status_t hh_status,
+ uint8_t *rpt_data, int rpt_size)
+{
+ char addr[MAX_ADDR_STR_LEN];
+
+ /* TODO: print actual report */
+ haltest_info("%s: bd_addr=%s hh_status=%s rpt_size=%d\n", __func__,
+ bt_bdaddr_t2str(bd_addr, addr),
+ bthh_status_t2str(hh_status), rpt_size);
+}
+
+static bthh_callbacks_t bthh_callbacks = {
+ .size = sizeof(bthh_callbacks),
+ .connection_state_cb = connection_state_cb,
+ .hid_info_cb = hid_info_cb,
+ .protocol_mode_cb = protocol_mode_cb,
+ .idle_time_cb = idle_time_cb,
+ .get_report_cb = get_report_cb,
+ .virtual_unplug_cb = virtual_unplug_cb
+};
+
+/* init */
+
+static void init_p(int argc, const char **argv)
+{
+ RETURN_IF_NULL(if_hh);
+
+ EXEC(if_hh->init, &bthh_callbacks);
+}
+
+/* connect */
+
+static void connect_p(int argc, const char **argv)
+{
+ bt_bdaddr_t addr;
+
+ RETURN_IF_NULL(if_hh);
+ VERIFY_ADDR_ARG(2, &addr);
+
+ EXEC(if_hh->connect, &addr);
+}
+
+/* disconnect */
+
+static void disconnect_p(int argc, const char **argv)
+{
+ bt_bdaddr_t addr;
+
+ RETURN_IF_NULL(if_hh);
+ VERIFY_ADDR_ARG(2, &addr);
+
+ EXEC(if_hh->disconnect, &addr);
+}
+
+/* virtual_unplug */
+
+static void virtual_unplug_p(int argc, const char **argv)
+{
+ bt_bdaddr_t addr;
+
+ RETURN_IF_NULL(if_hh);
+ VERIFY_ADDR_ARG(2, &addr);
+
+ EXEC(if_hh->virtual_unplug, &addr);
+}
+
+/* set_info */
+
+static void set_info_p(int argc, const char **argv)
+{
+ bt_bdaddr_t addr;
+ bthh_hid_info_t hid_info;
+
+ RETURN_IF_NULL(if_hh);
+ VERIFY_ADDR_ARG(2, &addr);
+ /* TODO: not implemented yet */
+
+ EXEC(if_hh->set_info, &addr, hid_info);
+}
+
+/* get_protocol */
+
+static void get_protocol_p(int argc, const char **argv)
+{
+ bt_bdaddr_t addr;
+ bthh_protocol_mode_t protocolMode;
+
+ RETURN_IF_NULL(if_hh);
+ VERIFY_ADDR_ARG(2, &addr);
+
+ if (argc < 4) {
+ haltest_error("No protocol mode specified\n");
+ return;
+ }
+ protocolMode = str2bthh_protocol_mode_t(argv[3]);
+
+ EXEC(if_hh->get_protocol, &addr, protocolMode);
+}
+
+/* set_protocol */
+
+static void set_protocol_p(int argc, const char **argv)
+{
+ bt_bdaddr_t addr;
+ bthh_protocol_mode_t protocolMode;
+
+ RETURN_IF_NULL(if_hh);
+ VERIFY_ADDR_ARG(2, &addr);
+
+ if (argc < 4) {
+ haltest_error("No protocol mode specified\n");
+ return;
+ }
+ protocolMode = str2bthh_protocol_mode_t(argv[3]);
+
+ EXEC(if_hh->set_protocol, &addr, protocolMode);
+}
+
+/* get_report */
+
+static void get_report_p(int argc, const char **argv)
+{
+ bt_bdaddr_t addr;
+ bthh_report_type_t reportType;
+ uint8_t reportId;
+ int bufferSize;
+
+ RETURN_IF_NULL(if_hh);
+ VERIFY_ADDR_ARG(2, &addr);
+
+ if (argc < 4) {
+ haltest_error("No report type specified\n");
+ return;
+ }
+ reportType = str2bthh_report_type_t(argv[3]);
+
+ if (argc < 5) {
+ haltest_error("No reportId specified\n");
+ return;
+ }
+ reportId = (uint8_t) atoi(argv[4]);
+
+ if (argc < 6) {
+ haltest_error("No bufferSize specified\n");
+ return;
+ }
+ bufferSize = atoi(argv[5]);
+
+ EXEC(if_hh->get_report, &addr, reportType, reportId, bufferSize);
+}
+
+/* set_report */
+
+static void set_report_p(int argc, const char **argv)
+{
+ bt_bdaddr_t addr;
+ bthh_report_type_t reportType;
+
+ RETURN_IF_NULL(if_hh);
+ VERIFY_ADDR_ARG(2, &addr);
+
+ if (argc <= 3) {
+ haltest_error("No report type specified\n");
+ return;
+ }
+ reportType = str2bthh_report_type_t(argv[3]);
+
+ if (argc <= 4) {
+ haltest_error("No report specified\n");
+ return;
+ }
+
+ EXEC(if_hh->set_report, &addr, reportType, (char *) argv[4]);
+}
+
+/* send_data */
+
+static void send_data_p(int argc, const char **argv)
+{
+ bt_bdaddr_t addr;
+
+ RETURN_IF_NULL(if_hh);
+ VERIFY_ADDR_ARG(2, &addr);
+
+ if (argc <= 3) {
+ haltest_error("No data to send specified\n");
+ return;
+ }
+
+ EXEC(if_hh->send_data, &addr, (char *) argv[3]);
+}
+
+/* cleanup */
+
+static void cleanup_p(int argc, const char **argv)
+{
+ RETURN_IF_NULL(if_hh);
+
+ EXECV(if_hh->cleanup);
+}
+
+/* Methods available in bthh_interface_t */
+static struct method methods[] = {
+ STD_METHOD(init),
+ STD_METHOD(connect),
+ STD_METHOD(disconnect),
+ STD_METHOD(virtual_unplug),
+ STD_METHOD(set_info),
+ STD_METHOD(get_protocol),
+ STD_METHOD(set_protocol),
+ STD_METHOD(get_report),
+ STD_METHOD(set_report),
+ STD_METHOD(send_data),
+ STD_METHOD(cleanup),
+ END_METHOD
+};
+
+const struct interface hh_if = {
+ .name = "hidhost",
+ .methods = methods
+};
diff --git a/android/client/if-main.h b/android/client/if-main.h
index 6d2b0cb..f8430cf 100644
--- a/android/client/if-main.h
+++ b/android/client/if-main.h
@@ -41,6 +41,7 @@
/* Interfaces from hal that can be populated during application lifetime */
extern const bt_interface_t *if_bluetooth;
+extern const bthh_interface_t *if_hh;
/*
* Structure defines top level interfaces that can be used in test tool
@@ -52,6 +53,7 @@ struct interface {
};
extern const struct interface bluetooth_if;
+extern const struct interface hh_if;
/* Interfaces that will show up in tool (first part of command line) */
extern const struct interface *interfaces[];
--
1.7.9.5
This patch adds help to methods of hidhost interface.
This also adds tab completion for hidhost.
---
android/client/if-hh.c | 86 ++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 76 insertions(+), 10 deletions(-)
diff --git a/android/client/if-hh.c b/android/client/if-hh.c
index 09eaf9c..e23e4d5 100644
--- a/android/client/if-hh.c
+++ b/android/client/if-hh.c
@@ -68,6 +68,7 @@ SINTMAP(bthh_status_t, -1, "(unknown)")
DELEMENT(BTHH_ERR_HDL),
ENDMAP
+static char connected_device_addr[MAX_ADDR_STR_LEN];
/*
* Callback for connection state change.
* state will have one of the values from bthh_connection_state_t
@@ -80,6 +81,8 @@ static void connection_state_cb(bt_bdaddr_t *bd_addr,
haltest_info("%s: bd_addr=%s connection_state=%s\n", __func__,
bt_bdaddr_t2str(bd_addr, addr),
bthh_connection_state_t2str(state));
+ if (state == BTHH_CONN_STATE_CONNECTED)
+ strcpy(connected_device_addr, addr);
}
/*
@@ -104,7 +107,7 @@ static void hid_info_cb(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info)
{
char addr[MAX_ADDR_STR_LEN];
- /* TODO: print actual hid_info */
+ /* TODO: bluedroid does not seem to ever call this callback */
haltest_info("%s: bd_addr=%s\n", __func__,
bt_bdaddr_t2str(bd_addr, addr));
}
@@ -174,6 +177,15 @@ static void init_p(int argc, const char **argv)
/* connect */
+static void connect_c(int argc, const const char **argv,
+ enum_func *penum_func, void **puser)
+{
+ if (argc == 3) {
+ *puser = (void *) connected_device_addr;
+ *penum_func = enum_one_string;
+ }
+}
+
static void connect_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
@@ -186,6 +198,9 @@ static void connect_p(int argc, const char **argv)
/* disconnect */
+/* Same completion as connect_c */
+#define disconnect_c connect_c
+
static void disconnect_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
@@ -198,6 +213,9 @@ static void disconnect_p(int argc, const char **argv)
/* virtual_unplug */
+/* Same completion as connect_c */
+#define virtual_unplug_c connect_c
+
static void virtual_unplug_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
@@ -217,13 +235,25 @@ static void set_info_p(int argc, const char **argv)
RETURN_IF_NULL(if_hh);
VERIFY_ADDR_ARG(2, &addr);
- /* TODO: not implemented yet */
+ /* TODO: set_info does not seem to be called anywhere */
EXEC(if_hh->set_info, &addr, hid_info);
}
/* get_protocol */
+static void get_protocol_c(int argc, const const char **argv,
+ enum_func *penum_func, void **puser)
+{
+ if (argc == 3) {
+ *puser = connected_device_addr;
+ *penum_func = enum_one_string;
+ } else if (argc == 4) {
+ *puser = TYPE_ENUM(bthh_protocol_mode_t);
+ *penum_func = enum_defines;
+ }
+}
+
static void get_protocol_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
@@ -243,6 +273,9 @@ static void get_protocol_p(int argc, const char **argv)
/* set_protocol */
+/* Same completion as get_protocol_c */
+#define set_protocol_c get_protocol_c
+
static void set_protocol_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
@@ -262,6 +295,18 @@ static void set_protocol_p(int argc, const char **argv)
/* get_report */
+static void get_report_c(int argc, const const char **argv,
+ enum_func *penum_func, void **puser)
+{
+ if (argc == 3) {
+ *puser = connected_device_addr;
+ *penum_func = enum_one_string;
+ } else if (argc == 4) {
+ *puser = TYPE_ENUM(bthh_report_type_t);
+ *penum_func = enum_defines;
+ }
+}
+
static void get_report_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
@@ -295,6 +340,18 @@ static void get_report_p(int argc, const char **argv)
/* set_report */
+static void set_report_c(int argc, const const char **argv,
+ enum_func *penum_func, void **puser)
+{
+ if (argc == 3) {
+ *puser = connected_device_addr;
+ *penum_func = enum_one_string;
+ } else if (argc == 4) {
+ *puser = TYPE_ENUM(bthh_report_type_t);
+ *penum_func = enum_defines;
+ }
+}
+
static void set_report_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
@@ -319,6 +376,15 @@ static void set_report_p(int argc, const char **argv)
/* send_data */
+static void send_data_c(int argc, const const char **argv,
+ enum_func *penum_func, void **puser)
+{
+ if (argc == 3) {
+ *puser = connected_device_addr;
+ *penum_func = enum_one_string;
+ }
+}
+
static void send_data_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
@@ -346,15 +412,15 @@ static void cleanup_p(int argc, const char **argv)
/* Methods available in bthh_interface_t */
static struct method methods[] = {
STD_METHOD(init),
- STD_METHOD(connect),
- STD_METHOD(disconnect),
- STD_METHOD(virtual_unplug),
+ STD_METHODCH(connect, "<addr>"),
+ STD_METHODCH(disconnect, "<addr>"),
+ STD_METHODCH(virtual_unplug, "<addr>"),
STD_METHOD(set_info),
- STD_METHOD(get_protocol),
- STD_METHOD(set_protocol),
- STD_METHOD(get_report),
- STD_METHOD(set_report),
- STD_METHOD(send_data),
+ STD_METHODCH(get_protocol, "<addr> <mode>"),
+ STD_METHODCH(set_protocol, "<addr> <mode>"),
+ STD_METHODCH(get_report, "<addr> <type> <report_id> <size>"),
+ STD_METHODCH(set_report, "<addr> <type> <hex_encoded_report>"),
+ STD_METHODCH(send_data, "<addr> <hex_encoded_data>"),
STD_METHOD(cleanup),
END_METHOD
};
--
1.7.9.5
This patch adds definition of sizes needed for text representation
of bluetooth address and uuid, this remove usage of magic numbers.
---
android/client/if-bt.c | 8 ++++----
android/client/textconv.c | 2 +-
android/client/textconv.h | 2 ++
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index 30b41cd..f65e5f0 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -31,14 +31,14 @@ const bt_interface_t *if_bluetooth;
static char *bdaddr2str(const bt_bdaddr_t *bd_addr)
{
- static char buf[18];
+ static char buf[MAX_ADDR_STR_LEN];
return bt_bdaddr_t2str(bd_addr, buf);
}
static char *btuuid2str(const bt_uuid_t *uuid)
{
- static char buf[39];
+ static char buf[MAX_UUID_STR_LEN];
return bt_uuid_t2str(uuid, buf);
}
@@ -239,7 +239,7 @@ void add_remote_device(const bt_bdaddr_t *addr)
const char *enum_devices(void *v, int i)
{
- static char buf[19];
+ static char buf[MAX_ADDR_STR_LEN];
if (i >= remote_devices_cnt)
return NULL;
@@ -310,7 +310,7 @@ static void discovery_state_changed_cb(bt_discovery_state_t state)
* Buffer for remote addres that came from one of bind request.
* It's stored for command completion.
*/
-static char last_remote_addr[18];
+static char last_remote_addr[MAX_ADDR_STR_LEN];
static bt_ssp_variant_t last_ssp_variant = (bt_ssp_variant_t)-1;
static void pin_request_cb(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *bd_name,
diff --git a/android/client/textconv.c b/android/client/textconv.c
index 3493b1c..de7e23c 100644
--- a/android/client/textconv.c
+++ b/android/client/textconv.c
@@ -137,7 +137,7 @@ char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf)
{
const char *p = (const char *) bd_addr;
- snprintf(buf, 18, "%02x:%02x:%02x:%02x:%02x:%02x",
+ snprintf(buf, MAX_ADDR_STR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x",
p[0], p[1], p[2], p[3], p[4], p[5]);
return buf;
diff --git a/android/client/textconv.h b/android/client/textconv.h
index 88da641..056e706 100644
--- a/android/client/textconv.h
+++ b/android/client/textconv.h
@@ -99,9 +99,11 @@ static struct int2str __##type##2str[] = {
#define DELEMENT(s) {s, #s}
/* End of mapping section */
+#define MAX_ADDR_STR_LEN 18
char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf);
void str2bt_bdaddr_t(const char *str, bt_bdaddr_t *bd_addr);
+#define MAX_UUID_STR_LEN 37
char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf);
void str2bt_uuid_t(const char *str, bt_uuid_t *uuid);
--
1.7.9.5