am d9e5b349: (-s ours) Update RFCOMM socket code to use list data structure.
* commit 'd9e5b3490bf41f912823af920cc616e57e0fec28':
Update RFCOMM socket code to use list data structure.
diff --git a/Android.mk b/Android.mk
index f0f6970..dbe1b1f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,15 +1,18 @@
LOCAL_PATH := $(call my-dir)
+bdroid_CFLAGS := -Wno-unused-parameter
+
# Setup bdroid local make variables for handling configuration
ifneq ($(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR),)
bdroid_C_INCLUDES := $(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR)
- bdroid_CFLAGS := -DHAS_BDROID_BUILDCFG
+ bdroid_CFLAGS += -DHAS_BDROID_BUILDCFG
else
bdroid_C_INCLUDES :=
- bdroid_CFLAGS := -DHAS_NO_BDROID_BUILDCFG
+ bdroid_CFLAGS += -DHAS_NO_BDROID_BUILDCFG
endif
bdroid_CFLAGS += -Wall -Werror
+bdroid_CFLAGS += -DBTA_AVK_INCLUDED
include $(call all-subdir-makefiles)
diff --git a/audio_a2dp_hw/Android.mk b/audio_a2dp_hw/Android.mk
index fb509e7..c5a07e6 100644
--- a/audio_a2dp_hw/Android.mk
+++ b/audio_a2dp_hw/Android.mk
@@ -6,6 +6,9 @@
audio_a2dp_hw.c
LOCAL_C_INCLUDES+= . $(LOCAL_PATH)/../utils/include
+LOCAL_CFLAGS := -Wno-unused-parameter
+
+LOCAL_CFLAGS += -std=c99
LOCAL_CFLAGS += -std=c99
@@ -16,7 +19,7 @@
libpower
LOCAL_MODULE := audio.a2dp.default
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_MODULE_TAGS := optional
diff --git a/audio_a2dp_hw/audio_a2dp_hw.c b/audio_a2dp_hw/audio_a2dp_hw.c
index bfd2226..60feaba 100644
--- a/audio_a2dp_hw/audio_a2dp_hw.c
+++ b/audio_a2dp_hw/audio_a2dp_hw.c
@@ -25,6 +25,7 @@
*****************************************************************************/
#include <errno.h>
+#include <inttypes.h>
#include <pthread.h>
#include <stdint.h>
#include <sys/time.h>
@@ -47,7 +48,7 @@
#define LOG_TAG "audio_a2dp_hw"
/* #define LOG_NDEBUG 0 */
-#include <cutils/log.h>
+#include <log/log.h>
/*****************************************************************************
** Constants & Macros
@@ -78,10 +79,12 @@
AUDIO_A2DP_STATE_STANDBY /* allows write to autoresume */
} a2dp_state_t;
+struct a2dp_stream_in;
struct a2dp_stream_out;
struct a2dp_audio_device {
struct audio_hw_device device;
+ struct a2dp_stream_in *input;
struct a2dp_stream_out *output;
};
@@ -93,18 +96,23 @@
/* move ctrl_fd outside output stream and keep open until HAL unloaded ? */
-struct a2dp_stream_out {
- struct audio_stream_out stream;
+struct a2dp_stream_common {
pthread_mutex_t lock;
int ctrl_fd;
int audio_fd;
size_t buffer_sz;
- a2dp_state_t state;
struct a2dp_config cfg;
+ a2dp_state_t state;
+};
+
+struct a2dp_stream_out {
+ struct audio_stream_out stream;
+ struct a2dp_stream_common common;
};
struct a2dp_stream_in {
- struct audio_stream_in stream;
+ struct audio_stream_in stream;
+ struct a2dp_stream_common common;
};
/*****************************************************************************
@@ -188,14 +196,14 @@
**
*****************************************************************************/
-static int skt_connect(struct a2dp_stream_out *out, char *path)
+static int skt_connect(char *path, size_t buffer_sz)
{
int ret;
int skt_fd;
struct sockaddr_un remote;
int len;
- INFO("connect to %s (sz %d)", path, out->buffer_sz);
+ INFO("connect to %s (sz %zu)", path, buffer_sz);
skt_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
@@ -207,7 +215,7 @@
return -1;
}
- len = out->buffer_sz;
+ len = buffer_sz;
ret = setsockopt(skt_fd, SOL_SOCKET, SO_SNDBUF, (char*)&len, (int)sizeof(len));
/* only issue warning if failed */
@@ -219,6 +227,38 @@
return skt_fd;
}
+static int skt_read(int fd, void *p, size_t len, int us_timeout)
+{
+ int read;
+ struct pollfd pfd;
+ struct timespec ts;
+
+ FNLOG();
+
+ pfd.fd = fd;
+ pfd.events = POLLIN;
+
+ ts.tv_sec = us_timeout / 1000000;
+ ts.tv_nsec = (us_timeout % 1000000) * 1000;
+
+ ts_log("skt_read ppoll", len, NULL);
+
+ /* read time out */
+ if (ppoll(&pfd, 1, &ts, NULL) == 0) {
+ return 0;
+ }
+
+ ts_log("skt_read recv", len, NULL);
+
+ if ((read = recv(fd, p, len, MSG_NOSIGNAL)) == -1)
+ {
+ ERROR("write failed with errno=%d\n", errno);
+ return -1;
+ }
+
+ return read;
+}
+
static int skt_write(int fd, const void *p, size_t len)
{
int sent;
@@ -266,44 +306,53 @@
**
*****************************************************************************/
-static int a2dp_command(struct a2dp_stream_out *out, char cmd)
+static int a2dp_ctrl_receive(struct a2dp_stream_common *common, void* buffer, int length)
+{
+ int ret = recv(common->ctrl_fd, buffer, length, MSG_NOSIGNAL);
+ if (ret < 0)
+ {
+ ERROR("ack failed (%s)", strerror(errno));
+ if (errno == EINTR)
+ {
+ /* retry again */
+ ret = recv(common->ctrl_fd, buffer, length, MSG_NOSIGNAL);
+ if (ret < 0)
+ {
+ ERROR("ack failed (%s)", strerror(errno));
+ skt_disconnect(common->ctrl_fd);
+ common->ctrl_fd = AUDIO_SKT_DISCONNECTED;
+ return -1;
+ }
+ }
+ else
+ {
+ skt_disconnect(common->ctrl_fd);
+ common->ctrl_fd = AUDIO_SKT_DISCONNECTED;
+ return -1;
+
+ }
+ }
+ return ret;
+}
+
+static int a2dp_command(struct a2dp_stream_common *common, char cmd)
{
char ack;
DEBUG("A2DP COMMAND %s", dump_a2dp_ctrl_event(cmd));
/* send command */
- if (send(out->ctrl_fd, &cmd, 1, MSG_NOSIGNAL) == -1)
+ if (send(common->ctrl_fd, &cmd, 1, MSG_NOSIGNAL) == -1)
{
ERROR("cmd failed (%s)", strerror(errno));
- skt_disconnect(out->ctrl_fd);
- out->ctrl_fd = AUDIO_SKT_DISCONNECTED;
+ skt_disconnect(common->ctrl_fd);
+ common->ctrl_fd = AUDIO_SKT_DISCONNECTED;
return -1;
}
/* wait for ack byte */
- if (recv(out->ctrl_fd, &ack, 1, MSG_NOSIGNAL) < 0)
- {
- ERROR("ack failed (%s)", strerror(errno));
- if (errno == EINTR)
- {
- /* retry again */
- if (recv(out->ctrl_fd, &ack, 1, MSG_NOSIGNAL) < 0)
- {
- ERROR("ack failed (%s)", strerror(errno));
- skt_disconnect(out->ctrl_fd);
- out->ctrl_fd = AUDIO_SKT_DISCONNECTED;
- return -1;
- }
- }
- else
- {
- skt_disconnect(out->ctrl_fd);
- out->ctrl_fd = AUDIO_SKT_DISCONNECTED;
- return -1;
-
- }
- }
+ if (a2dp_ctrl_receive(common, &ack, 1) < 0)
+ return -1;
DEBUG("A2DP COMMAND %s DONE STATUS %d", dump_a2dp_ctrl_event(cmd), ack);
@@ -313,13 +362,74 @@
return 0;
}
+static int check_a2dp_ready(struct a2dp_stream_common *common)
+{
+ if (a2dp_command(common, A2DP_CTRL_CMD_CHECK_READY) < 0)
+ {
+ ERROR("check a2dp ready failed");
+ return -1;
+ }
+ return 0;
+}
+
+static int a2dp_read_audio_config(struct a2dp_stream_common *common)
+{
+ char cmd = A2DP_CTRL_GET_AUDIO_CONFIG;
+ uint32_t sample_rate;
+ uint8_t channel_count;
+
+ if (a2dp_command(common, A2DP_CTRL_GET_AUDIO_CONFIG) < 0)
+ {
+ ERROR("check a2dp ready failed");
+ return -1;
+ }
+
+ if (a2dp_ctrl_receive(common, &sample_rate, 4) < 0)
+ return -1;
+ if (a2dp_ctrl_receive(common, &channel_count, 1) < 0)
+ return -1;
+
+ common->cfg.channel_flags = (channel_count == 1 ? AUDIO_CHANNEL_IN_MONO : AUDIO_CHANNEL_IN_STEREO);
+ common->cfg.format = AUDIO_STREAM_DEFAULT_FORMAT;
+ common->cfg.rate = sample_rate;
+
+ INFO("got config %d %d", common->cfg.format, common->cfg.rate);
+
+ return 0;
+}
+
+static void a2dp_open_ctrl_path(struct a2dp_stream_common *common)
+{
+ int i;
+
+ /* retry logic to catch any timing variations on control channel */
+ for (i = 0; i < CTRL_CHAN_RETRY_COUNT; i++)
+ {
+ /* connect control channel if not already connected */
+ if ((common->ctrl_fd = skt_connect(A2DP_CTRL_PATH, common->buffer_sz)) > 0)
+ {
+ /* success, now check if stack is ready */
+ if (check_a2dp_ready(common) == 0)
+ break;
+
+ ERROR("error : a2dp not ready, wait 250 ms and retry");
+ usleep(250000);
+ skt_disconnect(common->ctrl_fd);
+ common->ctrl_fd = AUDIO_SKT_DISCONNECTED;
+ }
+
+ /* ctrl channel not ready, wait a bit */
+ usleep(250000);
+ }
+}
+
/*****************************************************************************
**
** AUDIO DATA PATH
**
*****************************************************************************/
-static void a2dp_stream_out_init(struct a2dp_stream_out *out)
+static void a2dp_stream_common_init(struct a2dp_stream_common *common)
{
pthread_mutexattr_t lock_attr;
@@ -327,124 +437,109 @@
pthread_mutexattr_init(&lock_attr);
pthread_mutexattr_settype(&lock_attr, PTHREAD_MUTEX_RECURSIVE);
- pthread_mutex_init(&out->lock, &lock_attr);
+ pthread_mutex_init(&common->lock, &lock_attr);
- out->ctrl_fd = AUDIO_SKT_DISCONNECTED;
- out->audio_fd = AUDIO_SKT_DISCONNECTED;
- out->state = AUDIO_A2DP_STATE_STOPPED;
-
- out->cfg.channel_flags = AUDIO_STREAM_DEFAULT_CHANNEL_FLAG;
- out->cfg.format = AUDIO_STREAM_DEFAULT_FORMAT;
- out->cfg.rate = AUDIO_STREAM_DEFAULT_RATE;
+ common->ctrl_fd = AUDIO_SKT_DISCONNECTED;
+ common->audio_fd = AUDIO_SKT_DISCONNECTED;
+ common->state = AUDIO_A2DP_STATE_STOPPED;
/* manages max capacity of socket pipe */
- out->buffer_sz = AUDIO_STREAM_OUTPUT_BUFFER_SZ;
+ common->buffer_sz = AUDIO_STREAM_OUTPUT_BUFFER_SZ;
}
-static int start_audio_datapath(struct a2dp_stream_out *out)
+static int start_audio_datapath(struct a2dp_stream_common *common)
{
- int oldstate = out->state;
+ int oldstate = common->state;
- INFO("state %d", out->state);
+ INFO("state %d", common->state);
- if (out->ctrl_fd == AUDIO_SKT_DISCONNECTED)
+ if (common->ctrl_fd == AUDIO_SKT_DISCONNECTED) {
+ INFO("AUDIO_SKT_DISCONNECTED");
return -1;
+ }
- out->state = AUDIO_A2DP_STATE_STARTING;
+ common->state = AUDIO_A2DP_STATE_STARTING;
- if (a2dp_command(out, A2DP_CTRL_CMD_START) < 0)
+ if (a2dp_command(common, A2DP_CTRL_CMD_START) < 0)
{
ERROR("audiopath start failed");
- out->state = oldstate;
+ common->state = oldstate;
return -1;
}
/* connect socket if not yet connected */
- if (out->audio_fd == AUDIO_SKT_DISCONNECTED)
+ if (common->audio_fd == AUDIO_SKT_DISCONNECTED)
{
- out->audio_fd = skt_connect(out, A2DP_DATA_PATH);
-
- if (out->audio_fd < 0)
+ common->audio_fd = skt_connect(A2DP_DATA_PATH, common->buffer_sz);
+ if (common->audio_fd < 0)
{
- out->state = oldstate;
+ common->state = oldstate;
return -1;
}
- out->state = AUDIO_A2DP_STATE_STARTED;
+ common->state = AUDIO_A2DP_STATE_STARTED;
}
return 0;
}
-static int stop_audio_datapath(struct a2dp_stream_out *out)
+static int stop_audio_datapath(struct a2dp_stream_common *common)
{
- int oldstate = out->state;
+ int oldstate = common->state;
- INFO("state %d", out->state);
+ INFO("state %d", common->state);
- if (out->ctrl_fd == AUDIO_SKT_DISCONNECTED)
+ if (common->ctrl_fd == AUDIO_SKT_DISCONNECTED)
return -1;
/* prevent any stray output writes from autostarting the stream
while stopping audiopath */
- out->state = AUDIO_A2DP_STATE_STOPPING;
+ common->state = AUDIO_A2DP_STATE_STOPPING;
- if (a2dp_command(out, A2DP_CTRL_CMD_STOP) < 0)
+ if (a2dp_command(common, A2DP_CTRL_CMD_STOP) < 0)
{
ERROR("audiopath stop failed");
- out->state = oldstate;
+ common->state = oldstate;
return -1;
}
- out->state = AUDIO_A2DP_STATE_STOPPED;
+ common->state = AUDIO_A2DP_STATE_STOPPED;
/* disconnect audio path */
- skt_disconnect(out->audio_fd);
- out->audio_fd = AUDIO_SKT_DISCONNECTED;
+ skt_disconnect(common->audio_fd);
+ common->audio_fd = AUDIO_SKT_DISCONNECTED;
return 0;
}
-static int suspend_audio_datapath(struct a2dp_stream_out *out, bool standby)
+static int suspend_audio_datapath(struct a2dp_stream_common *common, bool standby)
{
- INFO("state %d", out->state);
+ INFO("state %d", common->state);
- if (out->ctrl_fd == AUDIO_SKT_DISCONNECTED)
+ if (common->ctrl_fd == AUDIO_SKT_DISCONNECTED)
return -1;
- if (out->state == AUDIO_A2DP_STATE_STOPPING)
+ if (common->state == AUDIO_A2DP_STATE_STOPPING)
return -1;
- if (a2dp_command(out, A2DP_CTRL_CMD_SUSPEND) < 0)
+ if (a2dp_command(common, A2DP_CTRL_CMD_SUSPEND) < 0)
return -1;
if (standby)
- out->state = AUDIO_A2DP_STATE_STANDBY;
+ common->state = AUDIO_A2DP_STATE_STANDBY;
else
- out->state = AUDIO_A2DP_STATE_SUSPENDED;
+ common->state = AUDIO_A2DP_STATE_SUSPENDED;
/* disconnect audio path */
- skt_disconnect(out->audio_fd);
+ skt_disconnect(common->audio_fd);
- out->audio_fd = AUDIO_SKT_DISCONNECTED;
+ common->audio_fd = AUDIO_SKT_DISCONNECTED;
return 0;
}
-static int check_a2dp_ready(struct a2dp_stream_out *out)
-{
- INFO("state %d", out->state);
-
- if (a2dp_command(out, A2DP_CTRL_CMD_CHECK_READY) < 0)
- {
- ERROR("check a2dp ready failed");
- return -1;
- }
- return 0;
-}
-
/*****************************************************************************
**
@@ -458,52 +553,52 @@
struct a2dp_stream_out *out = (struct a2dp_stream_out *)stream;
int sent;
- DEBUG("write %d bytes (fd %d)", bytes, out->audio_fd);
+ DEBUG("write %zu bytes (fd %d)", bytes, out->common.audio_fd);
- if (out->state == AUDIO_A2DP_STATE_SUSPENDED)
+ if (out->common.state == AUDIO_A2DP_STATE_SUSPENDED)
{
DEBUG("stream suspended");
return -1;
}
/* only allow autostarting if we are in stopped or standby */
- if ((out->state == AUDIO_A2DP_STATE_STOPPED) ||
- (out->state == AUDIO_A2DP_STATE_STANDBY))
+ if ((out->common.state == AUDIO_A2DP_STATE_STOPPED) ||
+ (out->common.state == AUDIO_A2DP_STATE_STANDBY))
{
- pthread_mutex_lock(&out->lock);
+ pthread_mutex_lock(&out->common.lock);
- if (start_audio_datapath(out) < 0)
+ if (start_audio_datapath(&out->common) < 0)
{
/* emulate time this write represents to avoid very fast write
failures during transition periods or remote suspend */
- int us_delay = calc_audiotime(out->cfg, bytes);
+ int us_delay = calc_audiotime(out->common.cfg, bytes);
DEBUG("emulate a2dp write delay (%d us)", us_delay);
usleep(us_delay);
- pthread_mutex_unlock(&out->lock);
+ pthread_mutex_unlock(&out->common.lock);
return -1;
}
- pthread_mutex_unlock(&out->lock);
+ pthread_mutex_unlock(&out->common.lock);
}
- else if (out->state != AUDIO_A2DP_STATE_STARTED)
+ else if (out->common.state != AUDIO_A2DP_STATE_STARTED)
{
ERROR("stream not in stopped or standby");
return -1;
}
- sent = skt_write(out->audio_fd, buffer, bytes);
+ sent = skt_write(out->common.audio_fd, buffer, bytes);
if (sent == -1)
{
- skt_disconnect(out->audio_fd);
- out->audio_fd = AUDIO_SKT_DISCONNECTED;
- out->state = AUDIO_A2DP_STATE_STOPPED;
+ skt_disconnect(out->common.audio_fd);
+ out->common.audio_fd = AUDIO_SKT_DISCONNECTED;
+ out->common.state = AUDIO_A2DP_STATE_STOPPED;
}
- DEBUG("wrote %d bytes out of %d bytes", sent, bytes);
+ DEBUG("wrote %d bytes out of %zu bytes", sent, bytes);
return sent;
}
@@ -512,16 +607,16 @@
{
struct a2dp_stream_out *out = (struct a2dp_stream_out *)stream;
- DEBUG("rate %d", out->cfg.rate);
+ DEBUG("rate %" PRIu32,out->common.cfg.rate);
- return out->cfg.rate;
+ return out->common.cfg.rate;
}
static int out_set_sample_rate(struct audio_stream *stream, uint32_t rate)
{
struct a2dp_stream_out *out = (struct a2dp_stream_out *)stream;
- DEBUG("out_set_sample_rate : %d", rate);
+ DEBUG("out_set_sample_rate : %" PRIu32, rate);
if (rate != AUDIO_STREAM_DEFAULT_RATE)
{
@@ -529,7 +624,7 @@
return -1;
}
- out->cfg.rate = rate;
+ out->common.cfg.rate = rate;
return 0;
}
@@ -538,25 +633,25 @@
{
struct a2dp_stream_out *out = (struct a2dp_stream_out *)stream;
- DEBUG("buffer_size : %d", out->buffer_sz);
+ DEBUG("buffer_size : %zu", out->common.buffer_sz);
- return out->buffer_sz;
+ return out->common.buffer_sz;
}
static uint32_t out_get_channels(const struct audio_stream *stream)
{
struct a2dp_stream_out *out = (struct a2dp_stream_out *)stream;
- DEBUG("channels 0x%x", out->cfg.channel_flags);
+ DEBUG("channels 0x%" PRIx32, out->common.cfg.channel_flags);
- return out->cfg.channel_flags;
+ return out->common.cfg.channel_flags;
}
static audio_format_t out_get_format(const struct audio_stream *stream)
{
struct a2dp_stream_out *out = (struct a2dp_stream_out *)stream;
- DEBUG("format 0x%x", out->cfg.format);
- return out->cfg.format;
+ DEBUG("format 0x%x", out->common.cfg.format);
+ return out->common.cfg.format;
}
static int out_set_format(struct audio_stream *stream, audio_format_t format)
@@ -574,13 +669,13 @@
FNLOG();
- pthread_mutex_lock(&out->lock);
+ pthread_mutex_lock(&out->common.lock);
- if (out->state == AUDIO_A2DP_STATE_STARTED)
- retVal = suspend_audio_datapath(out, true);
+ if (out->common.state == AUDIO_A2DP_STATE_STARTED)
+ retVal = suspend_audio_datapath(&out->common, true);
else
retVal = 0;
- pthread_mutex_unlock (&out->lock);
+ pthread_mutex_unlock(&out->common.lock);
return retVal;
}
@@ -601,9 +696,9 @@
int retval;
int status = 0;
- INFO("state %d", out->state);
+ INFO("state %d", out->common.state);
- pthread_mutex_lock(&out->lock);
+ pthread_mutex_lock(&out->common.lock);
parms = str_parms_create_str(kvpairs);
@@ -617,7 +712,7 @@
if (strcmp(keyval, "true") == 0)
{
DEBUG("stream closing, disallow any writes");
- out->state = AUDIO_A2DP_STATE_STOPPING;
+ out->common.state = AUDIO_A2DP_STATE_STOPPING;
}
}
@@ -627,21 +722,21 @@
{
if (strcmp(keyval, "true") == 0)
{
- if (out->state == AUDIO_A2DP_STATE_STARTED)
- status = suspend_audio_datapath(out, false);
+ if (out->common.state == AUDIO_A2DP_STATE_STARTED)
+ status = suspend_audio_datapath(&out->common, false);
}
else
{
/* Do not start the streaming automatically. If the phone was streaming
* prior to being suspended, the next out_write shall trigger the
* AVDTP start procedure */
- if (out->state == AUDIO_A2DP_STATE_SUSPENDED)
- out->state = AUDIO_A2DP_STATE_STANDBY;
+ if (out->common.state == AUDIO_A2DP_STATE_SUSPENDED)
+ out->common.state = AUDIO_A2DP_STATE_STANDBY;
/* Irrespective of the state, return 0 */
}
}
- pthread_mutex_unlock(&out->lock);
+ pthread_mutex_unlock(&out->common.lock);
str_parms_destroy(parms);
return status;
@@ -667,9 +762,9 @@
FNLOG();
- latency_us = ((out->buffer_sz * 1000 ) /
+ latency_us = ((out->common.buffer_sz * 1000 ) /
audio_stream_frame_size(&out->stream.common) /
- out->cfg.rate) * 1000;
+ out->common.cfg.rate) * 1000;
return (latency_us / 1000) + 200;
@@ -725,19 +820,22 @@
static uint32_t in_get_sample_rate(const struct audio_stream *stream)
{
- UNUSED(stream);
+ struct a2dp_stream_in *in = (struct a2dp_stream_in *)stream;
FNLOG();
- return 8000;
+ return in->common.cfg.rate;
}
static int in_set_sample_rate(struct audio_stream *stream, uint32_t rate)
{
- UNUSED(stream);
- UNUSED(rate);
+ struct a2dp_stream_in *in = (struct a2dp_stream_in *)stream;
FNLOG();
- return 0;
+
+ if (in->common.cfg.rate > 0 && in->common.cfg.rate == rate)
+ return 0;
+ else
+ return -1;
}
static size_t in_get_buffer_size(const struct audio_stream *stream)
@@ -750,10 +848,10 @@
static uint32_t in_get_channels(const struct audio_stream *stream)
{
- UNUSED(stream);
+ struct a2dp_stream_in *in = (struct a2dp_stream_in *)stream;
FNLOG();
- return AUDIO_CHANNEL_IN_MONO;
+ return in->common.cfg.channel_flags;
}
static audio_format_t in_get_format(const struct audio_stream *stream)
@@ -770,7 +868,10 @@
UNUSED(format);
FNLOG();
- return 0;
+ if (format == AUDIO_FORMAT_PCM_16_BIT)
+ return 0;
+ else
+ return -1;
}
static int in_standby(struct audio_stream *stream)
@@ -821,12 +922,60 @@
static ssize_t in_read(struct audio_stream_in *stream, void* buffer,
size_t bytes)
{
- UNUSED(stream);
- UNUSED(buffer);
- UNUSED(bytes);
+ struct a2dp_stream_in *in = (struct a2dp_stream_in *)stream;
+ int read;
- FNLOG();
- return bytes;
+ DEBUG("read %zu bytes, state: %d", bytes, in->common.state);
+
+ if (in->common.state == AUDIO_A2DP_STATE_SUSPENDED)
+ {
+ DEBUG("stream suspended");
+ return -1;
+ }
+
+ int us_delay = calc_audiotime(in->common.cfg, bytes);
+
+ /* only allow autostarting if we are in stopped or standby */
+ if ((in->common.state == AUDIO_A2DP_STATE_STOPPED) ||
+ (in->common.state == AUDIO_A2DP_STATE_STANDBY))
+ {
+ pthread_mutex_lock(&in->common.lock);
+
+ if (start_audio_datapath(&in->common) < 0)
+ {
+ /* emulate time this write represents to avoid very fast write
+ failures during transition periods or remote suspend */
+
+ DEBUG("emulate a2dp read delay (%d us)", us_delay);
+
+ usleep(us_delay);
+ pthread_mutex_unlock(&in->common.lock);
+ return -1;
+ }
+
+ pthread_mutex_unlock(&in->common.lock);
+ }
+ else if (in->common.state != AUDIO_A2DP_STATE_STARTED)
+ {
+ ERROR("stream not in stopped or standby");
+ return -1;
+ }
+
+ read = skt_read(in->common.audio_fd, buffer, bytes, us_delay);
+
+ if (read == -1)
+ {
+ skt_disconnect(in->common.audio_fd);
+ in->common.audio_fd = AUDIO_SKT_DISCONNECTED;
+ in->common.state = AUDIO_A2DP_STATE_STOPPED;
+ } else if (read == 0) {
+ DEBUG("read time out - return zeros");
+ memset(buffer, 0, bytes);
+ read = bytes;
+ }
+
+ DEBUG("read %d bytes out of %zu bytes", read, bytes);
+ return read;
}
static uint32_t in_get_input_frames_lost(struct audio_stream_in *stream)
@@ -897,7 +1046,11 @@
out->stream.get_render_position = out_get_render_position;
/* initialize a2dp specifics */
- a2dp_stream_out_init(out);
+ a2dp_stream_common_init(&out->common);
+
+ out->common.cfg.channel_flags = AUDIO_STREAM_DEFAULT_CHANNEL_FLAG;
+ out->common.cfg.format = AUDIO_STREAM_DEFAULT_FORMAT;
+ out->common.cfg.rate = AUDIO_STREAM_DEFAULT_RATE;
/* set output config values */
if (config)
@@ -909,26 +1062,8 @@
*stream_out = &out->stream;
a2dp_dev->output = out;
- /* retry logic to catch any timing variations on control channel */
- for (i = 0; i < CTRL_CHAN_RETRY_COUNT; i++)
- {
- /* connect control channel if not already connected */
- if ((out->ctrl_fd = skt_connect(out, A2DP_CTRL_PATH)) > 0)
- {
- /* success, now check if stack is ready */
- if (check_a2dp_ready(out) == 0)
- break;
-
- ERROR("error : a2dp not ready, wait 250 ms and retry");
- usleep(250000);
- skt_disconnect(out->ctrl_fd);
- }
-
- /* ctrl channel not ready, wait a bit */
- usleep(250000);
- }
-
- if (out->ctrl_fd == AUDIO_SKT_DISCONNECTED)
+ a2dp_open_ctrl_path(&out->common);
+ if (out->common.ctrl_fd == AUDIO_SKT_DISCONNECTED)
{
ERROR("ctrl socket failed to connect (%s)", strerror(errno));
ret = -1;
@@ -952,12 +1087,12 @@
struct a2dp_audio_device *a2dp_dev = (struct a2dp_audio_device *)dev;
struct a2dp_stream_out *out = (struct a2dp_stream_out *)stream;
- INFO("closing output (state %d)", out->state);
+ INFO("closing output (state %d)", out->common.state);
- if ((out->state == AUDIO_A2DP_STATE_STARTED) || (out->state == AUDIO_A2DP_STATE_STOPPING))
- stop_audio_datapath(out);
+ if ((out->common.state == AUDIO_A2DP_STATE_STARTED) || (out->common.state == AUDIO_A2DP_STATE_STOPPING))
+ stop_audio_datapath(&out->common);
- skt_disconnect(out->ctrl_fd);
+ skt_disconnect(out->common.ctrl_fd);
free(stream);
a2dp_dev->output = NULL;
@@ -975,7 +1110,7 @@
ERROR("ERROR: set param called even when stream out is null");
return retval;
}
- INFO("state %d", out->state);
+ INFO("state %d", out->common.state);
retval = out->stream.common.set_parameters((struct audio_stream *)out, kvpairs);
@@ -1075,7 +1210,7 @@
struct audio_config *config,
struct audio_stream_in **stream_in)
{
- struct a2dp_audio_device *ladev = (struct a2dp_audio_device *)dev;
+ struct a2dp_audio_device *a2dp_dev = (struct a2dp_audio_device *)dev;
struct a2dp_stream_in *in;
int ret;
UNUSED(handle);
@@ -1105,24 +1240,54 @@
in->stream.read = in_read;
in->stream.get_input_frames_lost = in_get_input_frames_lost;
+ /* initialize a2dp specifics */
+ a2dp_stream_common_init(&in->common);
+
*stream_in = &in->stream;
+ a2dp_dev->input = in;
+
+ a2dp_open_ctrl_path(&in->common);
+ if (in->common.ctrl_fd == AUDIO_SKT_DISCONNECTED)
+ {
+ ERROR("ctrl socket failed to connect (%s)", strerror(errno));
+ ret = -1;
+ goto err_open;
+ }
+
+ if (a2dp_read_audio_config(&in->common) < 0) {
+ ERROR("a2dp_read_audio_config failed (%s)", strerror(errno));
+ ret = -1;
+ goto err_open;
+ }
+
+ DEBUG("success");
return 0;
err_open:
free(in);
*stream_in = NULL;
+ a2dp_dev->input = NULL;
+ ERROR("failed");
return ret;
}
static void adev_close_input_stream(struct audio_hw_device *dev,
- struct audio_stream_in *in)
+ struct audio_stream_in *stream)
{
- UNUSED(dev);
- UNUSED(in);
+ struct a2dp_audio_device *a2dp_dev = (struct a2dp_audio_device *)dev;
+ struct a2dp_stream_in* in = (struct a2dp_stream_in *)stream;
+ a2dp_state_t state = in->common.state;
- FNLOG();
+ INFO("closing input (state %d)", state);
- return;
+ if ((state == AUDIO_A2DP_STATE_STARTED) || (state == AUDIO_A2DP_STATE_STOPPING))
+ stop_audio_datapath(&in->common);
+
+ skt_disconnect(in->common.ctrl_fd);
+ free(stream);
+ a2dp_dev->input = NULL;
+
+ DEBUG("done");
}
static int adev_dump(const audio_hw_device_t *device, int fd)
diff --git a/audio_a2dp_hw/audio_a2dp_hw.h b/audio_a2dp_hw/audio_a2dp_hw.h
index 2015591..b4ac85d 100644
--- a/audio_a2dp_hw/audio_a2dp_hw.h
+++ b/audio_a2dp_hw/audio_a2dp_hw.h
@@ -46,7 +46,8 @@
A2DP_CTRL_CMD_CHECK_READY,
A2DP_CTRL_CMD_START,
A2DP_CTRL_CMD_STOP,
- A2DP_CTRL_CMD_SUSPEND
+ A2DP_CTRL_CMD_SUSPEND,
+ A2DP_CTRL_GET_AUDIO_CONFIG,
} tA2DP_CTRL_CMD;
typedef enum {
diff --git a/bta/Android.mk b/bta/Android.mk
index b8f8790..572cf75 100644
--- a/bta/Android.mk
+++ b/bta/Android.mk
@@ -1,5 +1,3 @@
-ifneq ($(TARGET_SIMULATOR),true)
-
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
@@ -39,6 +37,14 @@
./ag/bta_ag_cmd.c \
./ag/bta_ag_ci.c \
./ag/bta_ag_at.c \
+ ./hf_client/bta_hf_client_act.c \
+ ./hf_client/bta_hf_client_api.c \
+ ./hf_client/bta_hf_client_main.c \
+ ./hf_client/bta_hf_client_rfc.c \
+ ./hf_client/bta_hf_client_at.c \
+ ./hf_client/bta_hf_client_sdp.c \
+ ./hf_client/bta_hf_client_sco.c \
+ ./hf_client/bta_hf_client_cmd.c \
./hh/bta_hh_cfg.c \
./hh/bta_hh_act.c \
./hh/bta_hh_api.c \
@@ -84,6 +90,7 @@
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := libcutils libc
+LOCAL_MULTILIB := 32
LOCAL_C_INCLUDES+= . \
$(LOCAL_PATH)/include \
@@ -104,5 +111,3 @@
include $(BUILD_STATIC_LIBRARY)
-
-endif # TARGET_SIMULATOR != true
diff --git a/bta/ag/bta_ag_api.c b/bta/ag/bta_ag_api.c
index 07dceb9..c80ba8f 100644
--- a/bta/ag/bta_ag_api.c
+++ b/bta/ag/bta_ag_api.c
@@ -71,9 +71,7 @@
}
/* register with BTA system manager */
- GKI_sched_lock();
bta_sys_register(BTA_ID_AG, &bta_ag_reg);
- GKI_sched_unlock();
if ((p_buf = (tBTA_AG_API_ENABLE *) GKI_getbuf(sizeof(tBTA_AG_API_ENABLE))) != NULL)
{
diff --git a/bta/ag/bta_ag_main.c b/bta/ag/bta_ag_main.c
index 712e50e..7eaec30 100644
--- a/bta/ag/bta_ag_main.c
+++ b/bta/ag/bta_ag_main.c
@@ -713,9 +713,7 @@
}
/* De-register with BTA system manager */
- GKI_sched_lock();
bta_sys_deregister(BTA_ID_AG);
- GKI_sched_unlock();
for (i = 0; i < BTA_AG_NUM_SCB; i++, p_scb++)
{
diff --git a/bta/av/bta_av_aact.c b/bta/av/bta_av_aact.c
index fed838a..00564fa 100644
--- a/bta/av/bta_av_aact.c
+++ b/bta/av/bta_av_aact.c
@@ -193,6 +193,7 @@
0 /* AVDT_DELAY_REPORT_CFM_EVT */
};
+void bta_av_stream_data_cback(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UINT8 m_pt);
static void bta_av_stream0_cback(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p_data);
static void bta_av_stream1_cback(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p_data);
#if BTA_AV_NUM_STRS > 2
@@ -225,6 +226,48 @@
,bta_av_stream5_cback
#endif
};
+/***********************************************
+**
+** Function bta_get_scb_handle
+**
+** Description gives the registered AVDT handle.by checking with sep_type.
+**
+**
+** Returns void
+***********************************************/
+UINT8 bta_av_get_scb_handle ( tBTA_AV_SCB *p_scb, UINT8 local_sep )
+{
+ UINT8 xx =0;
+ for (xx = 0; xx<BTA_AV_MAX_SEPS; xx++)
+ {
+ if ((p_scb->seps[xx].tsep == local_sep) &&
+ (p_scb->seps[xx].codec_type == p_scb->codec_type))
+ return (p_scb->seps[xx].av_handle);
+ }
+ APPL_TRACE_DEBUG0(" bta_av_get_scb_handle appropiate sep_type not found")
+ return 0; /* return invalid handle */
+}
+
+/***********************************************
+**
+** Function bta_av_get_scb_sep_type
+**
+** Description gives the sep type by cross-checking with AVDT handle
+**
+**
+** Returns void
+***********************************************/
+UINT8 bta_av_get_scb_sep_type ( tBTA_AV_SCB *p_scb, UINT8 tavdt_handle)
+{
+ UINT8 xx =0;
+ for (xx = 0; xx<BTA_AV_MAX_SEPS; xx++)
+ {
+ if (p_scb->seps[xx].av_handle == tavdt_handle)
+ return (p_scb->seps[xx].tsep);
+ }
+ APPL_TRACE_DEBUG0(" bta_av_get_scb_sep_type appropiate handle not found")
+ return 3; /* return invalid sep type */
+}
/*******************************************************************************
**
@@ -320,12 +363,19 @@
int i;
tAVDT_GETCAP_REQ *p_req;
BOOLEAN sent_cmd = FALSE;
+ UINT16 uuid_int = p_scb->uuid_int;
+ UINT8 sep_requested = 0;
+
+ if(uuid_int == UUID_SERVCLASS_AUDIO_SOURCE)
+ sep_requested = AVDT_TSEP_SNK;
+ else if(uuid_int == UUID_SERVCLASS_AUDIO_SINK)
+ sep_requested = AVDT_TSEP_SRC;
for (i = p_scb->sep_info_idx; i < p_scb->num_seps; i++)
{
/* steam not in use, is a sink, and is the right media type (audio/video) */
if ((p_scb->sep_info[i].in_use == FALSE) &&
- (p_scb->sep_info[i].tsep == AVDT_TSEP_SNK) &&
+ (p_scb->sep_info[i].tsep == sep_requested) &&
(p_scb->sep_info[i].media_type == p_scb->media_type))
{
p_scb->sep_info_idx = i;
@@ -509,6 +559,39 @@
/*******************************************************************************
**
+** Function bta_av_stream_data_cback
+**
+** Description This is the AVDTP callback function for stream events.
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_av_stream_data_cback(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UINT8 m_pt)
+{
+ int index = 0;
+ tBTA_AV_SCB *p_scb ;
+ APPL_TRACE_DEBUG3("bta_av_stream_data_cback avdt_handle: %d pkt_len=0x%x ofst = 0x%x", handle,p_pkt->len,p_pkt->offset);
+ APPL_TRACE_DEBUG1(" Number of frames 0x%x",*((UINT8*)(p_pkt + 1) + p_pkt->offset));
+ APPL_TRACE_DEBUG1("Sequence Number 0x%x",p_pkt->layer_specific);
+ /* Get SCB and correct sep type*/
+ for(index = 0; index < BTA_AV_NUM_STRS;index ++ )
+ {
+ p_scb = bta_av_cb.p_scb[index];
+ if((p_scb->avdt_handle == handle)&&(p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK))
+ break;
+ }
+ if(index == BTA_AV_NUM_STRS) /* cannot find correct handler */
+ {
+ GKI_freebuf(p_pkt);
+ return;
+ }
+ p_pkt->event = BTA_AV_MEDIA_DATA_EVT;
+ p_scb->seps[p_scb->sep_idx].p_app_data_cback(BTA_AV_MEDIA_DATA_EVT, (tBTA_AV_MEDIA*)p_pkt);
+ GKI_freebuf(p_pkt); /* a copy of packet had been delivered, we free this buffer */
+}
+
+/*******************************************************************************
+**
** Function bta_av_stream0_cback
**
** Description This is the AVDTP callback function for stream events.
@@ -650,16 +733,16 @@
** Returns
**
*******************************************************************************/
-static void bta_av_adjust_seps_idx(tBTA_AV_SCB *p_scb)
+static void bta_av_adjust_seps_idx(tBTA_AV_SCB *p_scb, UINT8 avdt_handle)
{
- int xx;
-
+ int xx;
APPL_TRACE_DEBUG1("bta_av_adjust_seps_idx codec_type: %d", p_scb->codec_type);
for(xx=0; xx<BTA_AV_MAX_SEPS; xx++)
{
APPL_TRACE_DEBUG2("av_handle: %d codec_type: %d",
p_scb->seps[xx].av_handle, p_scb->seps[xx].codec_type);
- if(p_scb->seps[xx].av_handle && p_scb->codec_type == p_scb->seps[xx].codec_type)
+ if((p_scb->seps[xx].av_handle && p_scb->codec_type == p_scb->seps[xx].codec_type)
+ && (p_scb->seps[xx].av_handle == avdt_handle))
{
p_scb->sep_idx = xx;
p_scb->avdt_handle = p_scb->seps[xx].av_handle;
@@ -781,6 +864,10 @@
av_open.chnl = p_scb->chnl;
av_open.hndl = p_scb->hndl;
start.status = BTA_AV_FAIL_ROLE;
+ if(p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC )
+ av_open.sep = AVDT_TSEP_SNK;
+ else if(p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK )
+ av_open.sep = AVDT_TSEP_SRC;
(*bta_av_cb.p_cback)(BTA_AV_OPEN_EVT, (tBTA_AV *)&av_open);
}
else
@@ -830,6 +917,7 @@
UINT16 attr_list[] = {ATTR_ID_SERVICE_CLASS_ID_LIST,
ATTR_ID_PROTOCOL_DESC_LIST,
ATTR_ID_BT_PROFILE_DESC_LIST};
+ UINT16 sdp_uuid = 0; /* UUID for which SDP has to be done */
APPL_TRACE_DEBUG3("bta_av_do_disc_a2d use_rc: %d rs:%d, oc:%d",
p_data->api_open.use_rc, p_data->api_open.switch_res, bta_av_cb.audio_open_cnt);
@@ -891,13 +979,13 @@
if (bta_av_cb.features & BTA_AV_FEAT_MASTER)
{
- L2CA_SetDesireRole(L2CAP_ROLE_DISALLOW_SWITCH);
+ L2CA_SetDesireRole(L2CAP_ROLE_DISALLOW_SWITCH);
- if (bta_av_cb.audio_open_cnt == 1)
- {
- /* there's already an A2DP connection. do not allow switch */
- bta_sys_clear_default_policy(BTA_ID_AV, HCI_ENABLE_MASTER_SLAVE_SWITCH);
- }
+ if (bta_av_cb.audio_open_cnt == 1)
+ {
+ /* there's already an A2DP connection. do not allow switch */
+ bta_sys_clear_default_policy(BTA_ID_AV, HCI_ENABLE_MASTER_SLAVE_SWITCH);
+ }
}
/* store peer addr other parameters */
bta_av_save_addr(p_scb, p_data->api_open.bd_addr);
@@ -922,8 +1010,14 @@
db_params.num_attr = 3;
db_params.p_db = p_scb->p_disc_db;
db_params.p_attrs = attr_list;
+ p_scb->uuid_int = p_data->api_open.uuid;
+ if (p_scb->uuid_int == UUID_SERVCLASS_AUDIO_SINK)
+ sdp_uuid = UUID_SERVCLASS_AUDIO_SOURCE;
+ else if (p_scb->uuid_int == UUID_SERVCLASS_AUDIO_SOURCE)
+ sdp_uuid = UUID_SERVCLASS_AUDIO_SINK;
- if(A2D_FindService(UUID_SERVCLASS_AUDIO_SINK, p_scb->peer_addr, &db_params,
+ APPL_TRACE_DEBUG2("uuid_int 0x%x, Doing SDP For 0x%x", p_scb->uuid_int, sdp_uuid);
+ if(A2D_FindService(sdp_uuid, p_scb->peer_addr, &db_params,
bta_av_a2d_sdp_cback) == A2D_SUCCESS)
{
return;
@@ -1021,8 +1115,12 @@
tAVDT_SEP_INFO *p_info;
tAVDT_CFG *p_evt_cfg = &p_data->str_msg.cfg;
UINT8 psc_mask = (p_evt_cfg->psc_mask | p_scb->cfg.psc_mask);
+ UINT8 local_sep; /* sep type of local handle on which connection was received */
+ UINT8 count = 0;
+ tBTA_AV_STR_MSG *p_msg = (tBTA_AV_STR_MSG *)p_data;
UNUSED(p_data);
+ local_sep = bta_av_get_scb_sep_type(p_scb, p_msg->handle);
p_scb->avdt_label = p_data->str_msg.msg.hdr.label;
memcpy(p_scb->cfg.codec_info, p_evt_cfg->codec_info, AVDT_CODEC_SIZE);
p_scb->codec_type = p_evt_cfg->codec_info[BTA_AV_CODEC_TYPE_IDX];
@@ -1048,7 +1146,13 @@
p_info->in_use = 0;
p_info->media_type = p_scb->media_type;
p_info->seid = p_data->str_msg.msg.config_ind.int_seid;
- p_info->tsep = AVDT_TSEP_SNK;
+
+ /* Sep type of Peer will be oppsite role to our local sep */
+ if (local_sep == AVDT_TSEP_SRC)
+ p_info->tsep = AVDT_TSEP_SNK;
+ else if (local_sep == AVDT_TSEP_SNK)
+ p_info->tsep = AVDT_TSEP_SRC;
+
p_scb->role |= BTA_AV_ROLE_AD_ACP;
p_scb->cur_psc_mask = p_evt_cfg->psc_mask;
if (bta_av_cb.features & BTA_AV_FEAT_RCTG)
@@ -1059,13 +1163,29 @@
p_scb->num_seps = 1;
p_scb->sep_info_idx = 0;
APPL_TRACE_DEBUG3("bta_av_config_ind: SEID: %d use_rc: %d cur_psc_mask:0x%x", p_info->seid, p_scb->use_rc, p_scb->cur_psc_mask);
-
- p_scb->p_cos->setcfg(p_scb->hndl, p_scb->codec_type,
+ /* in case of A2DP SINK this is the first time peer data is being sent to co functions */
+ if (local_sep == AVDT_TSEP_SNK)
+ {
+ p_scb->p_cos->setcfg(p_scb->hndl, p_scb->codec_type,
p_evt_cfg->codec_info,
p_info->seid,
p_scb->peer_addr,
p_evt_cfg->num_protect,
- p_evt_cfg->protect_info);
+ p_evt_cfg->protect_info,
+ AVDT_TSEP_SNK,
+ p_msg->handle);
+ }
+ else
+ {
+ p_scb->p_cos->setcfg(p_scb->hndl, p_scb->codec_type,
+ p_evt_cfg->codec_info,
+ p_info->seid,
+ p_scb->peer_addr,
+ p_evt_cfg->num_protect,
+ p_evt_cfg->protect_info,
+ AVDT_TSEP_SRC,
+ p_msg->handle);
+ }
}
}
@@ -1153,12 +1273,21 @@
void bta_av_setconfig_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
{
UINT8 num = p_data->ci_setconfig.num_seid + 1;
+ UINT8 avdt_handle = p_data->ci_setconfig.avdt_handle;
UINT8 *p_seid = p_data->ci_setconfig.p_seid;
int i;
+ UINT8 local_sep;
/* we like this codec_type. find the sep_idx */
- bta_av_adjust_seps_idx(p_scb);
+ local_sep = bta_av_get_scb_sep_type(p_scb,avdt_handle);
+ bta_av_adjust_seps_idx(p_scb, avdt_handle);
APPL_TRACE_DEBUG2("bta_av_setconfig_rsp: sep_idx: %d cur_psc_mask:0x%x", p_scb->sep_idx, p_scb->cur_psc_mask);
+ if ((AVDT_TSEP_SNK == local_sep) && (p_data->ci_setconfig.err_code == AVDT_SUCCESS) &&
+ (p_scb->seps[p_scb->sep_idx].p_app_data_cback != NULL))
+ p_scb->seps[p_scb->sep_idx].p_app_data_cback(BTA_AV_MEDIA_SINK_CFG_EVT,
+ (tBTA_AV_MEDIA*)p_scb->cfg.codec_info);
+
+
AVDT_ConfigRsp(p_scb->avdt_handle, p_scb->avdt_label, p_data->ci_setconfig.err_code,
p_data->ci_setconfig.category);
@@ -1182,8 +1311,11 @@
if (p_scb->codec_type == BTA_AV_CODEC_SBC || num > 1)
{
/* if SBC is used by the SNK as INT, discover req is not sent in bta_av_config_ind.
- * call disc_res now */
- p_scb->p_cos->disc_res(p_scb->hndl, num, num, p_scb->peer_addr);
+ * call disc_res now */
+ /* this is called in A2DP SRC path only, In case of SINK we don't need it */
+ if (local_sep == AVDT_TSEP_SRC)
+ p_scb->p_cos->disc_res(p_scb->hndl, num, num, 0, p_scb->peer_addr,
+ UUID_SERVCLASS_AUDIO_SOURCE);
}
else
{
@@ -1202,7 +1334,9 @@
p_scb->sep_info[i].media_type = p_scb->media_type;
p_scb->sep_info[i].seid = p_seid[i-1];
}
- bta_av_next_getcap(p_scb, p_data);
+ /* only in case of local sep as SRC we need to look for other SEPs, In case of SINK we don't */
+ if (local_sep == AVDT_TSEP_SRC)
+ bta_av_next_getcap(p_scb, p_data);
}
}
@@ -1275,6 +1409,11 @@
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
bta_ar_avdt_conn(BTA_ID_AV, open.bd_addr);
#endif
+ if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC )
+ open.sep = AVDT_TSEP_SNK;
+ else if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK )
+ open.sep = AVDT_TSEP_SRC;
+
(*bta_av_cb.p_cback)(BTA_AV_OPEN_EVT, (tBTA_AV *) &open);
if(open.starting)
{
@@ -1436,8 +1575,11 @@
*******************************************************************************/
void bta_av_disc_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
{
- UINT8 num_snks = 0, i;
+ UINT8 num_snks = 0, num_srcs =0, i;
+ /* our uuid in case we initiate connection */
+ UINT16 uuid_int = p_scb->uuid_int;
+ APPL_TRACE_DEBUG1(" initiator UUID 0x%x", uuid_int);
/* store number of stream endpoints returned */
p_scb->num_seps = p_data->str_msg.msg.discover_cfm.num_seps;
@@ -1445,15 +1587,23 @@
{
/* steam not in use, is a sink, and is audio */
if ((p_scb->sep_info[i].in_use == FALSE) &&
- (p_scb->sep_info[i].tsep == AVDT_TSEP_SNK) &&
(p_scb->sep_info[i].media_type == p_scb->media_type))
{
- num_snks++;
+ if((p_scb->sep_info[i].tsep == AVDT_TSEP_SNK) &&
+ (uuid_int == UUID_SERVCLASS_AUDIO_SOURCE))
+ num_snks++;
+
+ if((p_scb->sep_info[i].tsep == AVDT_TSEP_SRC) &&
+ (uuid_int == UUID_SERVCLASS_AUDIO_SINK))
+ num_srcs++;
+
}
}
- p_scb->p_cos->disc_res(p_scb->hndl, p_scb->num_seps, num_snks, p_scb->peer_addr);
+ p_scb->p_cos->disc_res(p_scb->hndl, p_scb->num_seps, num_snks, num_srcs, p_scb->peer_addr,
+ uuid_int);
p_scb->num_disc_snks = num_snks;
+ p_scb->num_disc_srcs = num_srcs;
/* if we got any */
if (p_scb->num_seps > 0)
@@ -1501,9 +1651,10 @@
num_snks++;
}
}
-
- p_scb->p_cos->disc_res(p_scb->hndl, p_scb->num_seps, num_snks, p_scb->peer_addr);
+ p_scb->p_cos->disc_res(p_scb->hndl, p_scb->num_seps, num_snks, 0, p_scb->peer_addr,
+ UUID_SERVCLASS_AUDIO_SOURCE);
p_scb->num_disc_snks = num_snks;
+ p_scb->num_disc_srcs = 0;
/* if we got any */
if (p_scb->num_seps > 0)
@@ -1648,6 +1799,11 @@
/* set the state back to initial state */
bta_av_set_scb_sst_init(p_scb);
+ if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC )
+ open.sep = AVDT_TSEP_SNK;
+ else if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK )
+ open.sep = AVDT_TSEP_SRC;
+
(*bta_av_cb.p_cback)(BTA_AV_OPEN_EVT, (tBTA_AV *) &open);
}
@@ -1674,6 +1830,7 @@
tAVDT_CFG cfg;
UINT8 media_type;
tAVDT_SEP_INFO *p_info = &p_scb->sep_info[p_scb->sep_info_idx];
+ UINT16 uuid_int; /* UUID for which connection was initiatied */
memcpy(&cfg, &p_scb->cfg, sizeof(tAVDT_CFG));
cfg.num_codec = 1;
@@ -1702,11 +1859,26 @@
/* save copy of codec type and configuration */
p_scb->codec_type = cfg.codec_info[BTA_AV_CODEC_TYPE_IDX];
memcpy(&p_scb->cfg, &cfg, sizeof(tAVDT_CFG));
- bta_av_adjust_seps_idx(p_scb);
+
+ uuid_int = p_scb->uuid_int;
+ APPL_TRACE_DEBUG1(" initiator UUID = 0x%x ", uuid_int);
+ if (uuid_int == UUID_SERVCLASS_AUDIO_SOURCE)
+ bta_av_adjust_seps_idx(p_scb, bta_av_get_scb_handle(p_scb, AVDT_TSEP_SRC));
+ else if (uuid_int == UUID_SERVCLASS_AUDIO_SINK)
+ bta_av_adjust_seps_idx(p_scb, bta_av_get_scb_handle(p_scb, AVDT_TSEP_SNK));
+
/* use only the services peer supports */
cfg.psc_mask &= p_scb->p_cap->psc_mask;
p_scb->cur_psc_mask = cfg.psc_mask;
+ if ((uuid_int == UUID_SERVCLASS_AUDIO_SINK) &&
+ (p_scb->seps[p_scb->sep_idx].p_app_data_cback != NULL))
+ {
+ APPL_TRACE_DEBUG0(" Configure Deoder for Sink Connection ");
+ p_scb->seps[p_scb->sep_idx].p_app_data_cback(BTA_AV_MEDIA_SINK_CFG_EVT,
+ (tBTA_AV_MEDIA*)p_scb->cfg.codec_info);
+ }
+
/* open the stream */
AVDT_OpenReq(p_scb->seps[p_scb->sep_idx].av_handle, p_scb->peer_addr,
p_scb->sep_info[p_scb->sep_info_idx].seid, &cfg);
@@ -1738,9 +1910,12 @@
void bta_av_setconfig_rej (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
{
tBTA_AV_REJECT reject;
+ UINT8 avdt_handle = p_data->ci_setconfig.avdt_handle;
- APPL_TRACE_DEBUG0("bta_av_setconfig_rej");
- AVDT_ConfigRsp(p_data->str_msg.handle, p_data->str_msg.msg.hdr.label, AVDT_ERR_BAD_STATE, 0);
+ bta_av_adjust_seps_idx(p_scb, avdt_handle);
+ APPL_TRACE_DEBUG1("bta_av_setconfig_rej: sep_idx: %d",p_scb->sep_idx);
+ AVDT_ConfigRsp(p_scb->avdt_handle, p_scb->avdt_label, AVDT_ERR_UNSUP_CFG, 0);
+
bdcpy(reject.bd_addr, p_data->str_msg.bd_addr);
reject.hndl = p_scb->hndl;
(*bta_av_cb.p_cback)(BTA_AV_REJECT_EVT, (tBTA_AV *) &reject);
@@ -2129,6 +2304,13 @@
if (new_role & BTA_AV_ROLE_START_INT)
initiator = TRUE;
+ /* for A2DP SINK we do not send get_caps */
+ if ((p_scb->avdt_handle == p_scb->seps[p_scb->sep_idx].av_handle)
+ &&(p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK))
+ {
+ p_scb->wait &= ~(BTA_AV_WAIT_ACP_CAPS_ON);
+ APPL_TRACE_DEBUG1(" Local SEP type is SNK new wait is 0x%x",p_scb->wait);
+ }
if (p_scb->wait & BTA_AV_WAIT_ROLE_SW_FAILED)
{
/* role switch has failed */
@@ -2170,15 +2352,15 @@
p_scb->q_tag = BTA_AV_Q_TAG_START;
}
- if (p_scb->wait & BTA_AV_WAIT_ACP_CAPS_ON)
- {
- p_scb->wait |= BTA_AV_WAIT_ACP_CAPS_STARTED;
- }
-
if (p_scb->wait)
{
- APPL_TRACE_DEBUG2("wait:x%x q_tag:%d- not started", p_scb->wait, p_scb->q_tag);
- return;
+ APPL_TRACE_ERROR2("wait:x%x q_tag:%d- not started", p_scb->wait, p_scb->q_tag);
+ /* Clear first bit of p_scb->wait and not to return from this point else
+ * HAL layer gets blocked. And if there is delay in Get Capability response as
+ * first bit of p_scb->wait is cleared hence it ensures bt_av_start_ok is not called
+ * again from bta_av_save_caps.
+ */
+ p_scb->wait &= ~BTA_AV_WAIT_ACP_CAPS_ON;
}
/* tell role manager to check M/S role */
@@ -2322,6 +2504,12 @@
data.open.status = p_scb->open_status;
data.open.chnl = p_scb->chnl;
data.open.hndl = p_scb->hndl;
+
+ if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC )
+ data.open.sep = AVDT_TSEP_SNK;
+ else if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK )
+ data.open.sep = AVDT_TSEP_SRC;
+
event = BTA_AV_OPEN_EVT;
p_scb->open_status = BTA_AV_SUCCESS;
@@ -2683,7 +2871,7 @@
{
UNUSED(p_data);
- APPL_TRACE_DEBUG1("bta_av_rcfg_open, num_disc_snks = %d", p_scb->num_disc_snks);
+ APPL_TRACE_DEBUG1("bta_av_rcfg_open, num_disc_snks = %d", p_scb->num_disc_snks);
if (p_scb->num_disc_snks == 0)
{
@@ -2699,7 +2887,7 @@
memcpy(p_scb->cfg.codec_info, p_scb->p_cap->codec_info, AVDT_CODEC_SIZE);
/* we may choose to use a different SEP at reconfig.
* adjust the sep_idx now */
- bta_av_adjust_seps_idx(p_scb);
+ bta_av_adjust_seps_idx(p_scb, bta_av_get_scb_handle(p_scb, AVDT_TSEP_SRC));
/* open the stream with the new config */
p_scb->sep_info_idx = p_scb->rcfg_idx;
diff --git a/bta/av/bta_av_act.c b/bta/av/bta_av_act.c
index 4408874..54e7aba 100644
--- a/bta/av/bta_av_act.c
+++ b/bta/av/bta_av_act.c
@@ -870,7 +870,7 @@
BOOLEAN is_inquiry = ((p_data->rc_msg.msg.hdr.ctype == AVRC_CMD_SPEC_INQ) || p_data->rc_msg.msg.hdr.ctype == AVRC_CMD_GEN_INQ);
#if (AVRC_METADATA_INCLUDED == TRUE)
tAVRC_STS res;
- UINT8 ctype;
+ UINT8 ctype = 0;
tAVRC_RESPONSE rc_rsp;
rc_rsp.rsp.status = BTA_AV_STS_NO_RSP;
@@ -1996,6 +1996,11 @@
#endif
bta_av_del_sdp_rec(&p_cb->sdp_a2d_handle);
bta_sys_remove_uuid(UUID_SERVCLASS_AUDIO_SOURCE);
+
+#ifdef BTA_AVK_INCLUDED
+ bta_av_del_sdp_rec(&p_cb->sdp_a2d_snk_handle);
+ bta_sys_remove_uuid(UUID_SERVCLASS_AUDIO_SINK);
+#endif
}
}
else
diff --git a/bta/av/bta_av_api.c b/bta/av/bta_av_api.c
index 98718fd..47cc2aa 100644
--- a/bta/av/bta_av_api.c
+++ b/bta/av/bta_av_api.c
@@ -63,9 +63,7 @@
tBTA_AV_API_ENABLE *p_buf;
/* register with BTA system manager */
- GKI_sched_lock();
bta_sys_register(BTA_ID_AV, &bta_av_reg);
- GKI_sched_unlock();
if ((p_buf = (tBTA_AV_API_ENABLE *) GKI_getbuf(sizeof(tBTA_AV_API_ENABLE))) != NULL)
{
@@ -111,7 +109,7 @@
** Returns void
**
*******************************************************************************/
-void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id)
+void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback)
{
tBTA_AV_API_REG *p_buf;
@@ -130,6 +128,7 @@
p_buf->p_service_name[0] = 0;
}
p_buf->app_id = app_id;
+ p_buf->p_app_data_cback = p_data_cback;
bta_sys_sendmsg(p_buf);
}
}
@@ -166,7 +165,8 @@
** Returns void
**
*******************************************************************************/
-void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle, BOOLEAN use_rc, tBTA_SEC sec_mask)
+void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle, BOOLEAN use_rc, tBTA_SEC sec_mask,
+ UINT16 uuid)
{
tBTA_AV_API_OPEN *p_buf;
@@ -178,6 +178,7 @@
p_buf->use_rc = use_rc;
p_buf->sec_mask = sec_mask;
p_buf->switch_res = BTA_AV_RS_NONE;
+ p_buf->uuid = uuid;
bta_sys_sendmsg(p_buf);
}
}
@@ -246,6 +247,31 @@
/*******************************************************************************
**
+** Function BTA_AvEnable_Sink
+**
+** Description Enable/Disable A2DP Sink..
+**
+** Returns void
+**
+*******************************************************************************/
+void BTA_AvEnable_Sink(int enable)
+{
+ BT_HDR *p_buf;
+
+#ifdef BTA_AVK_INCLUDED
+ if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+ {
+ p_buf->event = BTA_AV_API_SINK_ENABLE_EVT;
+ p_buf->layer_specific = enable;
+ bta_sys_sendmsg(p_buf);
+ }
+#else
+ return;
+#endif
+}
+
+/*******************************************************************************
+**
** Function BTA_AvStop
**
** Description Stop audio/video stream data transfer.
diff --git a/bta/av/bta_av_ci.c b/bta/av/bta_av_ci.c
index a1c2ac0..2da1d97 100644
--- a/bta/av/bta_av_ci.c
+++ b/bta/av/bta_av_ci.c
@@ -68,7 +68,7 @@
**
*******************************************************************************/
void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code, UINT8 category,
- UINT8 num_seid, UINT8 *p_seid, BOOLEAN recfg_needed)
+ UINT8 num_seid, UINT8 *p_seid, BOOLEAN recfg_needed, UINT8 avdt_handle)
{
tBTA_AV_CI_SETCONFIG *p_buf;
@@ -81,6 +81,7 @@
p_buf->category = category;
p_buf->recfg_needed = recfg_needed;
p_buf->num_seid = num_seid;
+ p_buf->avdt_handle= avdt_handle;
if(p_seid && num_seid)
{
p_buf->p_seid = (UINT8 *)(p_buf + 1);
diff --git a/bta/av/bta_av_int.h b/bta/av/bta_av_int.h
index cd22bcb..bbef8c5 100644
--- a/bta/av/bta_av_int.h
+++ b/bta/av/bta_av_int.h
@@ -96,6 +96,9 @@
BTA_AV_AVRC_CLOSE_EVT,
BTA_AV_CONN_CHG_EVT,
BTA_AV_DEREG_COMP_EVT,
+#ifdef BTA_AVK_INCLUDED
+ BTA_AV_API_SINK_ENABLE_EVT,
+#endif
#if (AVDT_REPORTING == TRUE)
BTA_AV_AVDT_RPT_CONN_EVT,
#endif
@@ -156,16 +159,15 @@
/* function types for call-out functions */
typedef BOOLEAN (*tBTA_AV_CO_INIT) (UINT8 *p_codec_type, UINT8 *p_codec_info,
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index);
-
typedef void (*tBTA_AV_CO_DISC_RES) (tBTA_AV_HNDL hndl, UINT8 num_seps,
- UINT8 num_snk, BD_ADDR addr);
-
+ UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local);
typedef UINT8 (*tBTA_AV_CO_GETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid,
UINT8 *p_num_protect, UINT8 *p_protect_info);
typedef void (*tBTA_AV_CO_SETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
- UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr,
- UINT8 num_protect, UINT8 *p_protect_info);
+ UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr,
+ UINT8 num_protect, UINT8 *p_protect_info,
+ UINT8 t_local_sep, UINT8 avdt_handle);
typedef void (*tBTA_AV_CO_OPEN) (tBTA_AV_HNDL hndl,
tBTA_AV_CODEC codec_type, UINT8 *p_codec_info,
UINT16 mtu);
@@ -206,6 +208,7 @@
BT_HDR hdr;
char p_service_name[BTA_SERVICE_NAME_LEN+1];
UINT8 app_id;
+ tBTA_AV_DATA_CBACK *p_app_data_cback;
} tBTA_AV_API_REG;
@@ -225,6 +228,7 @@
BOOLEAN use_rc;
tBTA_SEC sec_mask;
tBTA_AV_RS_RES switch_res;
+ UINT16 uuid; /* uuid of initiator */
} tBTA_AV_API_OPEN;
/* data type for BTA_AV_API_STOP_EVT */
@@ -319,6 +323,7 @@
UINT8 num_seid;
UINT8 *p_seid;
BOOLEAN recfg_needed;
+ UINT8 avdt_handle; /* local sep type for which this stream will be set up */
} tBTA_AV_CI_SETCONFIG;
/* data type for all stream events from AVDTP */
@@ -376,8 +381,10 @@
/* type for SEP control block */
typedef struct
{
- UINT8 av_handle; /* AVDTP handle */
- tBTA_AV_CODEC codec_type; /* codec type */
+ UINT8 av_handle; /* AVDTP handle */
+ tBTA_AV_CODEC codec_type; /* codec type */
+ UINT8 tsep; /* SEP type of local SEP */
+ tBTA_AV_DATA_CBACK *p_app_data_cback; /* Application callback for media packets */
} tBTA_AV_SEP;
@@ -483,6 +490,7 @@
UINT8 hdi; /* the index to SCB[] */
UINT8 num_seps; /* number of seps returned by stream discovery */
UINT8 num_disc_snks; /* number of discovered snks */
+ UINT8 num_disc_srcs; /* number of discovered srcs */
UINT8 sep_info_idx; /* current index into sep_info */
UINT8 sep_idx; /* current index into local seps[] */
UINT8 rcfg_idx; /* reconfig requested index into sep_info */
@@ -505,6 +513,7 @@
UINT8 wait; /* set 0x1, when getting Caps as ACP, set 0x2, when started */
UINT8 q_tag; /* identify the associated q_info union member */
BOOLEAN no_rtp_hdr; /* TRUE if add no RTP header*/
+ UINT16 uuid_int; /*intended UUID of Initiator to connect to */
} tBTA_AV_SCB;
#define BTA_AV_RC_ROLE_MASK 0x10
@@ -554,6 +563,9 @@
TIMER_LIST_ENT sig_tmr; /* link timer */
TIMER_LIST_ENT acp_sig_tmr; /* timer to monitor signalling when accepting */
UINT32 sdp_a2d_handle; /* SDP record handle for audio src */
+#ifdef BTA_AVK_INCLUDED
+ UINT32 sdp_a2d_snk_handle; /* SDP record handle for audio snk */
+#endif
UINT32 sdp_vdp_handle; /* SDP record handle for video src */
tBTA_AV_FEAT features; /* features mask */
tBTA_SEC sec_mask; /* security mask */
@@ -601,6 +613,7 @@
extern const tBTA_AV_CO_FUNCTS bta_av_a2d_cos;
extern const tBTA_AV_SACT bta_av_vdp_action[];
extern tAVDT_CTRL_CBACK * const bta_av_dt_cback[];
+extern void bta_av_stream_data_cback(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UINT8 m_pt);
/*****************************************************************************
** Function prototypes
diff --git a/bta/av/bta_av_main.c b/bta/av/bta_av_main.c
index 25c40a5..20ed161 100644
--- a/bta/av/bta_av_main.c
+++ b/bta/av/bta_av_main.c
@@ -41,6 +41,8 @@
*****************************************************************************/
/* AVDTP protocol timeout values */
+#define BTIF_AVK_SERVICE_NAME "Advanced Audio Sink"
+
#ifndef BTA_AV_RET_TOUT
#define BTA_AV_RET_TOUT 4
#endif
@@ -150,6 +152,9 @@
typedef void (*tBTA_AV_NSM_ACT)(tBTA_AV_DATA *p_data);
static void bta_av_api_enable(tBTA_AV_DATA *p_data);
static void bta_av_api_register(tBTA_AV_DATA *p_data);
+#ifdef BTA_AVK_INCLUDED
+static void bta_av_api_sink_enable(tBTA_AV_DATA *p_data);
+#endif
static void bta_av_ci_data(tBTA_AV_DATA *p_data);
#if (AVDT_REPORTING == TRUE)
static void bta_av_rpc_conn(tBTA_AV_DATA *p_data);
@@ -175,6 +180,9 @@
bta_av_rc_closed, /* BTA_AV_AVRC_CLOSE_EVT */
bta_av_conn_chg, /* BTA_AV_CONN_CHG_EVT */
bta_av_dereg_comp, /* BTA_AV_DEREG_COMP_EVT */
+#ifdef BTA_AVK_INCLUDED
+ bta_av_api_sink_enable, /* BTA_AV_API_SINK_ENABLE_EVT */
+#endif
#if (AVDT_REPORTING == TRUE)
bta_av_rpc_conn, /* BTA_AV_AVDT_RPT_CONN_EVT */
#endif
@@ -459,6 +467,49 @@
}
#endif
+#ifdef BTA_AVK_INCLUDED
+/*******************************************************************************
+**
+** Function bta_av_api_sink_enable
+**
+** Description activate, deactive A2DP Sink,
+**
+** Returns void
+**
+*******************************************************************************/
+
+static void bta_av_api_sink_enable(tBTA_AV_DATA *p_data)
+{
+ UINT16 activate_sink = 0;
+ activate_sink = p_data->hdr.layer_specific;
+ APPL_TRACE_DEBUG1("bta_av_api_sink_enable %d ", activate_sink)
+ char p_service_name[BTA_SERVICE_NAME_LEN+1];
+ BCM_STRNCPY_S(p_service_name, sizeof(p_service_name),
+ BTIF_AVK_SERVICE_NAME, BTA_SERVICE_NAME_LEN);
+
+ if(activate_sink)
+ {
+ AVDT_SINK_Activate();
+ if (bta_av_cb.sdp_a2d_snk_handle == 0)
+ {
+ bta_av_cb.sdp_a2d_snk_handle = SDP_CreateRecord();
+ A2D_AddRecord(UUID_SERVCLASS_AUDIO_SINK, p_service_name, NULL,
+ A2D_SUPF_PLAYER, bta_av_cb.sdp_a2d_snk_handle);
+ bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SINK);
+ }
+ }
+ else
+ {
+ AVDT_SINK_Deactivate();
+ if (bta_av_cb.sdp_a2d_snk_handle != 0)
+ {
+ SDP_DeleteRecord(bta_av_cb.sdp_a2d_snk_handle);
+ bta_av_cb.sdp_a2d_snk_handle = 0;
+ bta_sys_remove_uuid(UUID_SERVCLASS_AUDIO_SINK);
+ }
+ }
+}
+#endif
/*******************************************************************************
**
** Function bta_av_api_register
@@ -480,6 +531,8 @@
tBTA_AV_CODEC codec_type;
tBTA_UTL_COD cod;
UINT8 index = 0;
+ char p_avk_service_name[BTA_SERVICE_NAME_LEN+1];
+ BCM_STRNCPY_S(p_avk_service_name, sizeof(p_avk_service_name), BTIF_AVK_SERVICE_NAME, BTA_SERVICE_NAME_LEN);
memset(&cs,0,sizeof(tAVDT_CS));
@@ -534,7 +587,11 @@
}
/* Set the Capturing service class bit */
+#ifdef BTA_AVK_INCLUDED
+ cod.service = BTM_COD_SERVICE_CAPTURING | BTM_COD_SERVICE_RENDERING;
+#else
cod.service = BTM_COD_SERVICE_CAPTURING;
+#endif
utl_set_device_class(&cod, BTA_UTL_SET_COD_SERVICE_CLASS);
} /* if 1st channel */
@@ -594,9 +651,27 @@
(*bta_av_a2d_cos.init)(&codec_type, cs.cfg.codec_info,
&cs.cfg.num_protect, cs.cfg.protect_info, index) == TRUE)
{
+
+#ifdef BTA_AVK_INCLUDED
+ if(index == 1)
+ {
+ cs.tsep = AVDT_TSEP_SNK;
+ cs.p_data_cback = bta_av_stream_data_cback;
+ }
+ APPL_TRACE_DEBUG1(" SEP Type = %d",cs.tsep);
+#endif
if(AVDT_CreateStream(&p_scb->seps[index].av_handle, &cs) == AVDT_SUCCESS)
{
p_scb->seps[index].codec_type = codec_type;
+
+#ifdef BTA_AVK_INCLUDED
+ p_scb->seps[index].tsep = cs.tsep;
+ if(cs.tsep == AVDT_TSEP_SNK)
+ p_scb->seps[index].p_app_data_cback = p_data->api_reg.p_app_data_cback;
+ else
+ p_scb->seps[index].p_app_data_cback = NULL; /* In case of A2DP SOURCE we don't need a callback to handle media packets */
+#endif
+
APPL_TRACE_DEBUG3("audio[%d] av_handle: %d codec_type: %d",
index, p_scb->seps[index].av_handle, p_scb->seps[index].codec_type);
index++;
@@ -613,6 +688,12 @@
A2D_SUPF_PLAYER, bta_av_cb.sdp_a2d_handle);
bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SOURCE);
+#ifdef BTA_AVK_INCLUDED
+ bta_av_cb.sdp_a2d_snk_handle = SDP_CreateRecord();
+ A2D_AddRecord(UUID_SERVCLASS_AUDIO_SINK, p_avk_service_name, NULL,
+ A2D_SUPF_PLAYER, bta_av_cb.sdp_a2d_snk_handle);
+ bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SINK);
+#endif
/* start listening when A2DP is registered */
if (bta_av_cb.features & BTA_AV_FEAT_RCTG)
bta_av_rc_create(&bta_av_cb, AVCT_ACP, 0, BTA_AV_NUM_LINKS + 1);
@@ -1318,6 +1399,9 @@
case BTA_AV_AVRC_CLOSE_EVT: return "AVRC_CLOSE";
case BTA_AV_CONN_CHG_EVT: return "CONN_CHG";
case BTA_AV_DEREG_COMP_EVT: return "DEREG_COMP";
+#ifdef BTA_AVK_INCLUDED
+ case BTA_AV_API_SINK_ENABLE_EVT: return "SINK_ENABLE";
+#endif
#if (AVDT_REPORTING == TRUE)
case BTA_AV_AVDT_RPT_CONN_EVT: return "RPT_CONN";
#endif
diff --git a/bta/av/bta_av_sbc.c b/bta/av/bta_av_sbc.c
index a570375..af1b3ec 100644
--- a/bta/av/bta_av_sbc.c
+++ b/bta/av/bta_av_sbc.c
@@ -511,6 +511,78 @@
/*******************************************************************************
**
+** Function bta_av_sbc_cfg_matches_cap
+**
+** Description This function checks whether an SBC codec configuration
+** matched with capabilities. Here we check subset.
+**
+** Returns 0 if ok, nonzero if error.
+**
+*******************************************************************************/
+UINT8 bta_av_sbc_cfg_matches_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap)
+{
+ UINT8 status = 0;
+ tA2D_SBC_CIE cfg_cie;
+
+ /* parse configuration */
+ if ((status = A2D_ParsSbcInfo(&cfg_cie, p_cfg, TRUE)) != 0)
+ {
+ APPL_TRACE_ERROR1(" bta_av_sbc_cfg_matches_cap Parsing Failed %d", status);
+ return status;
+ }
+
+ /* verify that each parameter is in range */
+
+ APPL_TRACE_DEBUG2(" FREQ peer: 0%x, capability 0%x", cfg_cie.samp_freq, p_cap->samp_freq);
+ APPL_TRACE_DEBUG2(" CH_MODE peer: 0%x, capability 0%x", cfg_cie.ch_mode, p_cap->ch_mode);
+ APPL_TRACE_DEBUG2(" BLOCK_LEN peer: 0%x, capability 0%x", cfg_cie.block_len, p_cap->block_len);
+ APPL_TRACE_DEBUG2(" SUB_BAND peer: 0%x, capability 0%x", cfg_cie.num_subbands, p_cap->num_subbands);
+ APPL_TRACE_DEBUG2(" ALLOC_MTHD peer: 0%x, capability 0%x", cfg_cie.alloc_mthd, p_cap->alloc_mthd);
+ APPL_TRACE_DEBUG2(" MAX_BitPool peer: 0%x, capability 0%x", cfg_cie.max_bitpool, p_cap->max_bitpool);
+ APPL_TRACE_DEBUG2(" Min_bitpool peer: 0%x, capability 0%x", cfg_cie.min_bitpool, p_cap->min_bitpool);
+
+ /* sampling frequency */
+ if ((cfg_cie.samp_freq & p_cap->samp_freq) == 0)
+ {
+ status = A2D_NS_SAMP_FREQ;
+ }
+ /* channel mode */
+ else if ((cfg_cie.ch_mode & p_cap->ch_mode) == 0)
+ {
+ status = A2D_NS_CH_MODE;
+ }
+ /* block length */
+ else if ((cfg_cie.block_len & p_cap->block_len) == 0)
+ {
+ status = A2D_BAD_BLOCK_LEN;
+ }
+ /* subbands */
+ else if ((cfg_cie.num_subbands & p_cap->num_subbands) == 0)
+ {
+ status = A2D_NS_SUBBANDS;
+ }
+ /* allocation method */
+ else if ((cfg_cie.alloc_mthd & p_cap->alloc_mthd) == 0)
+ {
+ status = A2D_NS_ALLOC_MTHD;
+ }
+ /* max bitpool */
+ else if (cfg_cie.max_bitpool > p_cap->max_bitpool)
+ {
+ status = A2D_NS_MAX_BITPOOL;
+ }
+ /* min bitpool */
+ else if (cfg_cie.min_bitpool < p_cap->min_bitpool)
+ {
+ status = A2D_NS_MIN_BITPOOL;
+ }
+
+ return status;
+}
+
+
+/*******************************************************************************
+**
** Function bta_av_sbc_cfg_in_cap
**
** Description This function checks whether an SBC codec configuration
@@ -532,6 +604,7 @@
/* verify that each parameter is in range */
+
/* sampling frequency */
if ((cfg_cie.samp_freq & p_cap->samp_freq) == 0)
{
diff --git a/bta/av/bta_av_ssm.c b/bta/av/bta_av_ssm.c
index 407146e..5756c88 100644
--- a/bta/av/bta_av_ssm.c
+++ b/bta/av/bta_av_ssm.c
@@ -162,7 +162,7 @@
/* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
/* SRC_DATA_READY_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
/* CI_SETCONFIG_OK_EVT */ {BTA_AV_SETCONFIG_RSP, BTA_AV_ST_RC_TIMER, BTA_AV_INCOMING_SST },
-/* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SETCONFIG_RSP, BTA_AV_CLEANUP, BTA_AV_INIT_SST },
+/* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SETCONFIG_REJ, BTA_AV_CLEANUP, BTA_AV_INIT_SST },
/* SDP_DISC_OK_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
/* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
/* STR_DISC_OK_EVT */ {BTA_AV_DISC_RES_AS_ACP,BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
diff --git a/bta/dm/bta_dm_act.c b/bta/dm/bta_dm_act.c
index 3a9ddde..cf05a80 100644
--- a/bta/dm/bta_dm_act.c
+++ b/bta/dm/bta_dm_act.c
@@ -38,6 +38,7 @@
#include "l2c_api.h"
#include "wbt_api.h"
#include "utl.h"
+#include "gap_api.h" /* For GAP_BleReadPeerPrefConnParams */
#include <string.h>
#if (GAP_INCLUDED == TRUE)
@@ -111,6 +112,7 @@
#endif
static void bta_dm_observe_results_cb (tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir);
static void bta_dm_observe_cmpl_cb (void * p_result);
+static void bta_dm_ctrl_features_rd_cmpl_cback(tBTM_STATUS result);
#ifndef BTA_DM_BLE_ADV_CHNL_MAP
#define BTA_DM_BLE_ADV_CHNL_MAP (BTM_BLE_ADV_CHNL_37|BTM_BLE_ADV_CHNL_38|BTM_BLE_ADV_CHNL_39)
@@ -240,26 +242,6 @@
/*******************************************************************************
**
-** Function bta_dm_app_ready_timer_cback
-**
-** Description allow sending EIR to controller
-**
-**
-** Returns void
-**
-*******************************************************************************/
-#if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&(BTA_EIR_CANNED_UUID_LIST != TRUE)
-static void bta_dm_app_ready_timer_cback (TIMER_LIST_ENT *p_tle)
-{
- UNUSED(p_tle);
- bta_dm_set_eir (NULL);
-}
-#else
-#define bta_dm_app_ready_timer_cback (x)
-#endif
-
-/*******************************************************************************
-**
** Function bta_dm_enable
**
** Description Initialises the BT device manager
@@ -415,28 +397,6 @@
bta_sys_policy_register((tBTA_SYS_CONN_CBACK*)bta_dm_policy_cback);
-
- // BLUEDROID REMOVE ??
-#if 0
-#if 1
- /* Create broadcom primary DI record */
- if(WBT_ExtCreateRecord())
- {
-#if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&( BTA_EIR_CANNED_UUID_LIST != TRUE )
- /* while app_ready_timer is running, BTA DM doesn't send EIR to controller */
- bta_dm_cb.app_ready_timer.p_cback = (TIMER_CBACK*)&bta_dm_app_ready_timer_cback;
- bta_sys_start_timer(&bta_dm_cb.app_ready_timer, 0, 100);
-
- bta_sys_add_uuid(UUID_SERVCLASS_PNP_INFORMATION);
-#endif
- bta_dm_di_cb.di_handle[bta_dm_di_cb.di_num] = 0; /* primary DI record */
- bta_dm_di_cb.di_num ++;
- }
-#else /* Eventually implement pin code */
- if (WBT_ExtCreateRecord())
- WBT_ExtAddPinCode();
-#endif
-#endif
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
memset (&app_uuid.uu.uuid128, 0x87, LEN_UUID_128);
bta_dm_gattc_register();
@@ -3208,6 +3168,10 @@
if(bta_dm_cb.p_sec_cback)
bta_dm_cb.p_sec_cback(BTA_DM_ENABLE_EVT, &sec_event);
+
+#if ( BLE_INCLUDED == TRUE)
+ BTM_BleReadControllerFeatures (bta_dm_ctrl_features_rd_cmpl_cback);
+#endif
}
/*******************************************************************************
@@ -5201,7 +5165,7 @@
/*Save the callback to be called when a scan results are available */
bta_dm_search_cb.p_scan_cback = p_data->ble_observe.p_cback;
if ((status = BTM_BleObserve(TRUE, p_data->ble_observe.duration,
- bta_dm_observe_results_cb, bta_dm_observe_cmpl_cb))!= BTM_SUCCESS)
+ bta_dm_observe_results_cb, bta_dm_observe_cmpl_cb))!= BTM_CMD_STARTED)
{
tBTA_DM_SEARCH data;
APPL_TRACE_WARNING2(" %s BTM_BleObserve failed. status %d",__FUNCTION__,status);
@@ -5246,8 +5210,16 @@
*******************************************************************************/
void bta_dm_ble_set_adv_config (tBTA_DM_MSG *p_data)
{
- BTM_BleWriteAdvData(p_data->ble_set_adv_data.data_mask,
- (tBTM_BLE_ADV_DATA *)p_data->ble_set_adv_data.p_adv_cfg);
+ tBTA_STATUS status = BTA_FAILURE;
+
+ if (BTM_BleWriteAdvData(p_data->ble_set_adv_data.data_mask,
+ (tBTM_BLE_ADV_DATA *)p_data->ble_set_adv_data.p_adv_cfg) == BTM_SUCCESS)
+ {
+ status = BTA_SUCCESS;
+ }
+
+ if (p_data->ble_set_adv_data.p_adv_data_cback)
+ (*p_data->ble_set_adv_data.p_adv_data_cback)(status);
}
/*******************************************************************************
@@ -5261,8 +5233,16 @@
*******************************************************************************/
void bta_dm_ble_set_scan_rsp (tBTA_DM_MSG *p_data)
{
- BTM_BleWriteScanRsp(p_data->ble_set_adv_data.data_mask,
- (tBTM_BLE_ADV_DATA *)p_data->ble_set_adv_data.p_adv_cfg);
+ tBTA_STATUS status = BTA_FAILURE;
+
+ if(BTM_BleWriteScanRsp(p_data->ble_set_adv_data.data_mask,
+ (tBTM_BLE_ADV_DATA *)p_data->ble_set_adv_data.p_adv_cfg) == BTM_SUCCESS)
+ {
+ status = BTA_SUCCESS;
+ }
+
+ if (p_data->ble_set_adv_data.p_adv_data_cback)
+ (*p_data->ble_set_adv_data.p_adv_data_cback)(status);
}
/*******************************************************************************
@@ -5279,6 +5259,71 @@
BTM_BleBroadcast(p_data->ble_observe.start);
}
+/*******************************************************************************
+**
+** Function bta_dm_ble_multi_adv_enb
+**
+** Description This function enables a single advertising instance
+**
+** Parameters:
+**
+*******************************************************************************/
+void bta_dm_ble_multi_adv_enb(tBTA_DM_MSG *p_data)
+{
+#if BLE_MULTI_ADV_INCLUDED == TRUE
+ BTM_BleEnableAdvInstance((tBTM_BLE_ADV_PARAMS*)p_data->ble_multi_adv_enb.p_params,
+ p_data->ble_multi_adv_enb.p_cback,p_data->ble_multi_adv_enb.p_ref);
+#endif
+}
+/*******************************************************************************
+**
+** Function bta_dm_ble_multi_adv_param_upd
+**
+** Description This function updates multiple advertising instance parameters
+**
+** Parameters:
+**
+*******************************************************************************/
+void bta_dm_ble_multi_adv_upd_param(tBTA_DM_MSG *p_data)
+{
+#if BLE_MULTI_ADV_INCLUDED == TRUE
+ BTM_BleUpdateAdvInstParam(p_data->ble_multi_adv_param.inst_id,
+ (tBTM_BLE_ADV_PARAMS*)p_data->ble_multi_adv_param.p_params);
+#endif
+}
+/*******************************************************************************
+**
+** Function bta_dm_ble_multi_adv_data
+**
+** Description This function write multiple advertising instance adv data
+** or scan response data
+**
+** Parameters:
+**
+*******************************************************************************/
+void bta_dm_ble_multi_adv_data(tBTA_DM_MSG *p_data)
+{
+#if BLE_MULTI_ADV_INCLUDED == TRUE
+ BTM_BleCfgAdvInstData(p_data->ble_multi_adv_data.inst_id,p_data->ble_multi_adv_data.is_scan_rsp,
+ p_data->ble_multi_adv_data.data_mask,(tBTM_BLE_ADV_DATA*)p_data->ble_multi_adv_data.p_data);
+#endif
+}
+/*******************************************************************************
+**
+** Function btm_dm_ble_multi_adv_disable
+**
+** Description This function disable a single adv instance
+**
+** Parameters:
+**
+*******************************************************************************/
+void btm_dm_ble_multi_adv_disable(tBTA_DM_MSG *p_data)
+{
+#if BLE_MULTI_ADV_INCLUDED == TRUE
+ BTM_BleDisableAdvInstance(p_data->ble_multi_adv_disable.inst_id);
+#endif
+}
+
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
#ifndef BTA_DM_GATT_CLOSE_DELAY_TOUT
#define BTA_DM_GATT_CLOSE_DELAY_TOUT 1000
@@ -5657,4 +5702,30 @@
bta_sys_vs_hdl(BTA_VS_BLE_SCAN_PF_COND_EVT, (void *)¶m);
}
#endif /* BLE_ANDROID_CONTROLLER_SCAN_FILTER */
+
+/*******************************************************************************
+**
+** Function bta_dm_ctrl_features_rd_cmpl_cback
+**
+** Description callback to handle controller feature read complete
+**
+** Parameters:
+**
+*******************************************************************************/
+static void bta_dm_ctrl_features_rd_cmpl_cback(tBTM_STATUS result)
+{
+ APPL_TRACE_DEBUG2("%s status = %d ", __FUNCTION__, result);
+ if (result == BTM_SUCCESS)
+ {
+ if(bta_dm_cb.p_sec_cback)
+ bta_dm_cb.p_sec_cback(BTA_DM_LE_FEATURES_READ, NULL);
+ }
+ else
+ {
+ APPL_TRACE_ERROR2("%s Ctrl BLE feature read failed: status :%d",__FUNCTION__, result);
+ }
+
+}
+
+
#endif /* BLE_INCLUDED */
diff --git a/bta/dm/bta_dm_api.c b/bta/dm/bta_dm_api.c
index 89e2cce..798ef96 100644
--- a/bta/dm/bta_dm_api.c
+++ b/bta/dm/bta_dm_api.c
@@ -71,15 +71,12 @@
memset(&bta_dm_cb, 0, sizeof(bta_dm_cb));
- GKI_sched_lock();
bta_sys_register (BTA_ID_DM, &bta_dm_reg );
bta_sys_register (BTA_ID_DM_SEARCH, &bta_dm_search_reg );
/* if UUID list is not provided as static data */
bta_sys_eir_register(bta_dm_eir_update_uuid);
- GKI_sched_unlock();
-
if ((p_msg = (tBTA_DM_API_ENABLE *) GKI_getbuf(sizeof(tBTA_DM_API_ENABLE))) != NULL)
{
p_msg->hdr.event = BTA_DM_API_ENABLE_EVT;
@@ -179,14 +176,7 @@
*******************************************************************************/
BOOLEAN BTA_DmIsDeviceUp(void)
{
-
- BOOLEAN status;
-
- GKI_sched_lock();
- status = BTM_IsDeviceUp();
- GKI_sched_unlock();
- return status;
-
+ return BTM_IsDeviceUp();
}
/*******************************************************************************
@@ -1102,6 +1092,22 @@
}
/*******************************************************************************
+**
+** Function BTA_DmGetConnectionState
+**
+** Description Returns whether the remote device is currently connected.
+**
+** Returns 0 if the device is NOT connected.
+**
+*******************************************************************************/
+UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr )
+{
+ tBTA_DM_PEER_DEVICE * p_dev = bta_dm_find_peer_device(bd_addr);
+ return (p_dev && p_dev->conn_state == BTA_DM_CONNECTED);
+}
+
+
+/*******************************************************************************
** Device Identification (DI) Server Functions
*******************************************************************************/
/*******************************************************************************
@@ -1515,19 +1521,26 @@
**
** Description This function is called to override the BTA default ADV parameters.
**
-** Parameters Pointer to User defined ADV data structure
+** Parameters data_mask: adv data mask.
+** p_adv_cfg: Pointer to User defined ADV data structure. This
+** memory space can not be freed until p_adv_data_cback
+** is received.
+** p_adv_data_cback: set adv data complete callback.
**
** Returns None
**
*******************************************************************************/
-void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg)
+void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg,
+ tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
{
tBTA_DM_API_SET_ADV_CONFIG *p_msg;
- if ((p_msg = (tBTA_DM_API_SET_ADV_CONFIG *) GKI_getbuf(sizeof(tBTA_DM_API_SET_ADV_CONFIG))) != NULL)
+ if ((p_msg = (tBTA_DM_API_SET_ADV_CONFIG *)
+ GKI_getbuf(sizeof(tBTA_DM_API_SET_ADV_CONFIG))) != NULL)
{
p_msg->hdr.event = BTA_DM_API_BLE_SET_ADV_CONFIG_EVT;
p_msg->data_mask = data_mask;
+ p_msg->p_adv_data_cback = p_adv_data_cback;
p_msg->p_adv_cfg = p_adv_cfg;
bta_sys_sendmsg(p_msg);
@@ -1545,14 +1558,17 @@
** Returns None
**
*******************************************************************************/
-BTA_API extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg)
+BTA_API extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg,
+ tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
{
tBTA_DM_API_SET_ADV_CONFIG *p_msg;
- if ((p_msg = (tBTA_DM_API_SET_ADV_CONFIG *) GKI_getbuf(sizeof(tBTA_DM_API_SET_ADV_CONFIG))) != NULL)
+ if ((p_msg = (tBTA_DM_API_SET_ADV_CONFIG *)
+ GKI_getbuf(sizeof(tBTA_DM_API_SET_ADV_CONFIG))) != NULL)
{
p_msg->hdr.event = BTA_DM_API_BLE_SET_SCAN_RSP_EVT;
p_msg->data_mask = data_mask;
+ p_msg->p_adv_data_cback = p_adv_data_cback;
p_msg->p_adv_cfg = p_adv_cfg;
bta_sys_sendmsg(p_msg);
@@ -1810,10 +1826,186 @@
*******************************************************************************/
void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable)
{
+#if BLE_INCLUDED == TRUE
+#if BLE_VND_INCLUDED == TRUE && BLE_PRIVACY_SPT == TRUE
+ tBTA_DM_API_LOCAL_PRIVACY *p_msg;
+
+ if ((p_msg = (tBTA_DM_API_LOCAL_PRIVACY *) GKI_getbuf(sizeof(tBTA_DM_API_ENABLE_PRIVACY))) != NULL)
+ {
+ memset (p_msg, 0, sizeof(tBTA_DM_API_LOCAL_PRIVACY));
+
+ p_msg->hdr.event = BTA_DM_API_LOCAL_PRIVACY_EVT;
+ p_msg->privacy_enable = privacy_enable;
+
+ bta_sys_sendmsg(p_msg);
+ }
+#endif
+#else
UNUSED(privacy_enable);
+#endif
}
#endif
+#if BLE_INCLUDED == TRUE
+/*******************************************************************************
+**
+** Function BTA_BleEnableAdvInstance
+**
+** Description This function enable a Multi-ADV instance with the specififed
+** adv parameters
+**
+** Parameters p_params: pointer to the adv parameter structure.
+** p_cback: callback function associated to this adv instance.
+** p_ref: reference data pointer to this adv instance.
+**
+** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
+**
+*******************************************************************************/
+tBTA_STATUS BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
+ tBTA_BLE_MULTI_ADV_CBACK *p_cback,
+ void *p_ref)
+{
+ tBTA_DM_API_BLE_MULTI_ADV_ENB *p_msg;
+ UINT16 len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_ENB);
+
+ APPL_TRACE_API0 ("BTA_BleEnableAdvInstance");
+
+ if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_ENB *) GKI_getbuf(len)) != NULL)
+ {
+ memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_ENB));
+
+ p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_ENB_EVT;
+ p_msg->p_cback = (void *)p_cback;
+ if (p_params != NULL)
+ {
+ p_msg->p_params = (void *)(p_msg + 1);
+ memcpy(p_msg->p_params, p_params, sizeof(tBTA_BLE_ADV_PARAMS));
+ }
+ p_msg->p_ref = p_ref;
+
+ bta_sys_sendmsg(p_msg);
+
+ return BTA_SUCCESS;
+ }
+ return BTA_FAILURE;
+}
+
+/*******************************************************************************
+**
+** Function BTA_BleUpdateAdvInstParam
+**
+** Description This function update a Multi-ADV instance with the specififed
+** adv parameters.
+**
+** Parameters inst_id: Adv instance to update the parameter.
+** p_params: pointer to the adv parameter structure.
+**
+** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
+**
+*******************************************************************************/
+tBTA_STATUS BTA_BleUpdateAdvInstParam (UINT8 inst_id, tBTA_BLE_ADV_PARAMS *p_params)
+{
+ tBTA_DM_API_BLE_MULTI_ADV_PARAM *p_msg;
+ UINT16 len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM);
+
+ APPL_TRACE_API0 ("BTA_BleUpdateAdvInstParam");
+ if (inst_id <= BTM_BLE_MULTI_ADV_MAX && inst_id != BTA_BLE_MULTI_ADV_ILLEGAL)
+ {
+ if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_PARAM *) GKI_getbuf(len)) != NULL)
+ {
+ memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM));
+
+ p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT;
+ p_msg->inst_id = inst_id;
+ p_msg->p_params = (void *)(p_msg + 1);
+ memcpy(p_msg->p_params, p_params, sizeof(tBTA_BLE_ADV_PARAMS));
+
+ bta_sys_sendmsg(p_msg);
+
+ return BTA_SUCCESS;
+ }
+ }
+ return BTA_FAILURE;
+}
+
+/*******************************************************************************
+**
+** Function BTA_BleCfgAdvInstData
+**
+** Description This function configure a Multi-ADV instance with the specififed
+** adv data or scan response data.
+**
+** Parameter inst_id: Adv instance to configure the adv data or scan response.
+** is_scan_rsp: is the data scan response or adv data.
+** data_mask: adv data type as bit mask.
+** p_data: pointer to the ADV data structure tBTA_BLE_ADV_DATA. This
+** memory space can not be freed until BTA_BLE_MULTI_ADV_DATA_EVT
+** is sent to application.
+**
+** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
+**
+*******************************************************************************/
+tBTA_STATUS BTA_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
+ tBTA_BLE_AD_MASK data_mask,
+ tBTA_BLE_ADV_DATA *p_data)
+{
+ tBTA_DM_API_BLE_MULTI_ADV_DATA *p_msg;
+ UINT16 len = sizeof(tBTA_DM_API_BLE_MULTI_ADV_DATA) ;
+
+ APPL_TRACE_API0 ("BTA_BleCfgAdvInstData");
+
+ if (inst_id <= BTM_BLE_MULTI_ADV_MAX && inst_id != BTA_BLE_MULTI_ADV_ILLEGAL)
+ {
+ if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_DATA *) GKI_getbuf(len)) != NULL)
+ {
+ memset(p_msg, 0, len);
+
+ p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_DATA_EVT;
+ p_msg->inst_id = inst_id;
+ p_msg->is_scan_rsp = is_scan_rsp;
+ p_msg->data_mask = data_mask;
+ p_msg->p_data = p_data;
+
+ bta_sys_sendmsg(p_msg);
+
+ return BTA_SUCCESS;
+ }
+ }
+ return BTA_FAILURE;
+}
+
+/*******************************************************************************
+**
+** Function BTA_BleDisableAdvInstance
+**
+** Description This function disable a Multi-ADV instance.
+**
+** Parameter inst_id: instance ID to disable.
+**
+** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
+**
+*******************************************************************************/
+tBTA_STATUS BTA_BleDisableAdvInstance (UINT8 inst_id)
+{
+ tBTA_DM_API_BLE_MULTI_ADV_DISABLE *p_msg;
+
+ APPL_TRACE_API1 ("BTA_BleDisableAdvInstance: %d", inst_id);
+
+ if (inst_id <= BTM_BLE_MULTI_ADV_MAX && inst_id != BTA_BLE_MULTI_ADV_ILLEGAL)
+ {
+ if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_DISABLE *)
+ GKI_getbuf(sizeof(tBTA_DM_API_BLE_MULTI_ADV_DISABLE))) != NULL)
+ {
+ memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_DISABLE));
+ p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT;
+ p_msg->inst_id = inst_id;
+ bta_sys_sendmsg(p_msg);
+ return BTA_SUCCESS;
+ }
+ }
+ return BTA_FAILURE;
+}
+
/*******************************************************************************
**
** Function BTA_DmBleUpdateConnectionParams
@@ -1832,7 +2024,6 @@
void BTA_DmBleUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int, UINT16 max_int,
UINT16 latency, UINT16 timeout)
{
-#if BLE_INCLUDED == TRUE
tBTA_DM_API_UPDATE_CONN_PARAM *p_msg;
if ((p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) GKI_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM))) != NULL)
@@ -1848,8 +2039,8 @@
bta_sys_sendmsg(p_msg);
}
-#endif
}
+#endif
/*******************************************************************************
**
@@ -1946,8 +2137,6 @@
BTA_API extern void BTA_DmBleObserve(BOOLEAN start, UINT8 duration,
tBTA_DM_SEARCH_CBACK *p_results_cb)
{
-#if BLE_INCLUDED == TRUE
-
tBTA_DM_API_BLE_OBSERVE *p_msg;
APPL_TRACE_API1("BTA_DmBleObserve:start = %d ", start);
@@ -1963,6 +2152,5 @@
bta_sys_sendmsg(p_msg);
}
-#endif
}
#endif
diff --git a/bta/dm/bta_dm_cfg.c b/bta/dm/bta_dm_cfg.c
index e4a1681..fd7e551 100644
--- a/bta/dm/bta_dm_cfg.c
+++ b/bta/dm/bta_dm_cfg.c
@@ -111,9 +111,9 @@
tBTA_DM_RM *p_bta_dm_rm_cfg = (tBTA_DM_RM *)&bta_dm_rm_cfg;
#if BLE_INCLUDED == TRUE
-#define BTA_DM_NUM_PM_ENTRY (17+BTA_DM_NUM_JV_ID) /* number of entries in bta_dm_pm_cfg except the first */
+#define BTA_DM_NUM_PM_ENTRY (19+BTA_DM_NUM_JV_ID) /* number of entries in bta_dm_pm_cfg except the first */
#else
-#define BTA_DM_NUM_PM_ENTRY (15+BTA_DM_NUM_JV_ID) /* number of entries in bta_dm_pm_cfg except the first */
+#define BTA_DM_NUM_PM_ENTRY (17+BTA_DM_NUM_JV_ID) /* number of entries in bta_dm_pm_cfg except the first */
#endif
tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_CFG bta_dm_pm_cfg[] =
@@ -135,24 +135,27 @@
{BTA_ID_MSE, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
{BTA_ID_JV, BTA_JV_PM_ID_1, 6}, /* app BTA_JV_PM_ID_1, reuse ftc spec table */
{BTA_ID_JV, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
- {BTA_ID_HL, BTA_ALL_APP_ID, 8} /* reuse fts spec table */
+ {BTA_ID_HL, BTA_ALL_APP_ID, 8}, /* reuse fts spec table */
+ {BTA_ID_HS, BTA_ALL_APP_ID, 9}, /* HS spec table */
+ {BTA_ID_PAN, BTUI_PAN_ID_PANU, 10}, /* PANU spec table */
+ {BTA_ID_PAN, BTUI_PAN_ID_NAP, 11} /* NAP spec table */
#if BLE_INCLUDED == TRUE
- ,{BTA_ID_GATTC, BTA_ALL_APP_ID, 9} /* gattc spec table */
- ,{BTA_ID_GATTS, BTA_ALL_APP_ID, 10} /* gatts spec table */
+ ,{BTA_ID_GATTC, BTA_ALL_APP_ID, 12} /* gattc spec table */
+ ,{BTA_ID_GATTS, BTA_ALL_APP_ID, 13} /* gatts spec table */
#endif
};
#if BLE_INCLUDED == TRUE /* add GATT PM entry for GATT over BR/EDR */
#ifdef BTE_SIM_APP /* For Insight builds only, see the detail below */
-#define BTA_DM_NUM_PM_SPEC (11 + 2) /* additional two */
+#define BTA_DM_NUM_PM_SPEC (14 + 2) /* additional two */
#else
-#define BTA_DM_NUM_PM_SPEC 11 /* additional JV*/
+#define BTA_DM_NUM_PM_SPEC 14 /* additional JV*/
#endif
#else
#ifdef BTE_SIM_APP /* For Insight builds only, see the detail below */
-#define BTA_DM_NUM_PM_SPEC (9 + 2) /* additional two */
+#define BTA_DM_NUM_PM_SPEC (12 + 2) /* additional two */
#else
-#define BTA_DM_NUM_PM_SPEC 9 /* additional JV*/
+#define BTA_DM_NUM_PM_SPEC 12 /* additional JV*/
#endif
#endif
@@ -166,12 +169,12 @@
(BTA_DM_PM_SSR2), /* the SSR entry */
#endif
{
- {{BTA_DM_PM_SNIFF, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
+ {{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
- {{BTA_DM_PM_SNIFF3, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */
- {{BTA_DM_PM_SNIFF, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */
+ {{BTA_DM_PM_SNIFF_SCO_OPEN_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */
+ {{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
{{BTA_DM_PM_RETRY, 5000}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
@@ -189,7 +192,7 @@
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
- {{BTA_DM_PM_SNIFF, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open sniff */
+ {{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open sniff */
{{BTA_DM_PM_PARK, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close park */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
@@ -223,14 +226,14 @@
(BTA_DM_PM_SSR3), /* the SSR entry */
#endif
{
- {{BTA_DM_PM_SNIFF4, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
+ {{BTA_DM_PM_SNIFF_HD_ACTIVE_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
- {{BTA_DM_PM_SNIFF2, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
- {{BTA_DM_PM_SNIFF4, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
+ {{BTA_DM_PM_SNIFF_HD_IDLE_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
+ {{BTA_DM_PM_SNIFF_HD_ACTIVE_IDX, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
}
},
@@ -242,13 +245,13 @@
(BTA_DM_PM_SSR2), /* the SSR entry */
#endif
{
- {{BTA_DM_PM_SNIFF, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
+ {{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
- {{BTA_DM_PM_SNIFF, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
+ {{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
}
@@ -261,14 +264,14 @@
(BTA_DM_PM_SSR1), /* the SSR entry */
#endif
{
- {{BTA_DM_PM_SNIFF2, 30000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
+ {{BTA_DM_PM_SNIFF_HH_OPEN_IDX, BTA_DM_PM_HH_OPEN_DELAY},{BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close, used for HH suspend */
- {{BTA_DM_PM_SNIFF2, 30000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
- {{BTA_DM_PM_SNIFF2, 30000}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
+ {{BTA_DM_PM_SNIFF_HH_IDLE_IDX, BTA_DM_PM_HH_IDLE_DELAY}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
+ {{BTA_DM_PM_SNIFF_HH_ACTIVE_IDX, BTA_DM_PM_HH_ACTIVE_DELAY}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
}
},
@@ -286,7 +289,7 @@
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
- {{BTA_DM_PM_SNIFF, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
+ {{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
}
@@ -305,7 +308,7 @@
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
- {{BTA_DM_PM_SNIFF, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
+ {{BTA_DM_PM_SNIFF_A2DP_IDX, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
}
@@ -318,7 +321,7 @@
(BTA_DM_PM_SSR2), /* the SSR entry */
#endif
{
- {{BTA_DM_PM_SNIFF, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
+ {{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
@@ -328,8 +331,64 @@
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
}
- }
+ },
+ /* PANU */
+ {
+ (BTA_DM_PM_SNIFF), /* allow sniff */
+#if (BTM_SSR_INCLUDED == TRUE)
+ (BTA_DM_PM_SSR2), /* the SSR entry */
+#endif
+ {
+ {{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
+ {{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
+ {{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
+ {{BTA_DM_PM_SNIFF_A2DP_IDX, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
+ {{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
+ }
+ },
+
+ /* NAP */
+ {
+ (BTA_DM_PM_SNIFF), /* allow sniff */
+#if (BTM_SSR_INCLUDED == TRUE)
+ (BTA_DM_PM_SSR2), /* the SSR entry */
+#endif
+ {
+ {{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
+ {{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
+ {{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
+ {{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
+ {{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
+ }
+ },
+
+ /* HS */
+ {
+ (BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
+#if (BTM_SSR_INCLUDED == TRUE)
+ (BTA_DM_PM_SSR2), /* the SSR entry */
+#endif
+ {
+ {{BTA_DM_PM_SNIFF, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
+ {{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
+ {{BTA_DM_PM_SNIFF3, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */
+ {{BTA_DM_PM_SNIFF, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */
+ {{BTA_DM_PM_SNIFF, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
+ {{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
+ {{BTA_DM_PM_RETRY, 7000}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
+ }
+ }
#if BLE_INCLUDED == TRUE
/* GATTC */
,{
@@ -338,13 +397,13 @@
(BTA_DM_PM_SSR2), /* the SSR entry */
#endif
{
- {{BTA_DM_PM_SNIFF, 10000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
+ {{BTA_DM_PM_SNIFF_A2DP_IDX, 10000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
- {{BTA_DM_PM_SNIFF, 10000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
+ {{BTA_DM_PM_SNIFF_A2DP_IDX, 10000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
#if (AMP_INCLUDED == TRUE)
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* amp */
@@ -387,21 +446,29 @@
#endif /* BTE_SIM_APP */
};
+/* Please refer to the SNIFF table definitions in bta_api.h.
+ *
+ * Adding to or Modifying the Table
+ * Additional sniff parameter entries can be added for BTA_DM_PM_SNIFF5 - BTA_DM_PM_SNIFF7.
+ * Overrides of additional table entries can be specified in bdroid_buildcfg.h. If additional
+ * sniff parameter entries are added or an override of an existing entry is specified in
+ * bdroid_buildcfg.h then the BTA_DM_PM_*_IDX defines in bta_api.h will need to be match the new
+ * ordering.
+ *
+ * Table Ordering
+ * Sniff Table entries must be ordered from highest latency (biggest interval) to lowest latency.
+ * If there is a conflict among the connected services the setting with the lowest latency will
+ * be selected.
+ */
tBTA_DM_PM_TYPE_QUALIFIER tBTM_PM_PWR_MD bta_dm_pm_md[] =
{
-/* more sniff parameter entries can be added for BTA_DM_PM_SNIFF3 - BTA_DM_PM_SNIFF7, if needed
-When entries are added or removed, BTA_DM_PM_PARK_IDX needs to be updated to reflect the actual index
-BTA_DM_PM_PARK_IDX is defined in bta_api.h and can be override by the bdroid_buildcfg.h settings.
-The SNIFF table entries must be in the order from highest latency (biggest interval) to lowest latency.
-If there's a conflict among the connected services, the setting with lowest latency wins.
-*/
/* sniff modes: max interval, min interval, attempt, timeout */
- {800, 400, 4, 1, BTM_PM_MD_SNIFF}, /*for BTA_DM_PM_SNIFF - A2DP */
- {400, 200, 4, 1, BTM_PM_MD_SNIFF}, /*for BTA_DM_PM_SNIFF1 */
- {180, 150, 4, 1, BTM_PM_MD_SNIFF}, /*for BTA_DM_PM_SNIFF2- HD idle */
- {150, 50, 4, 1, BTM_PM_MD_SNIFF}, /*for BTA_DM_PM_SNIFF3- SCO open */
- { 54, 30, 4, 1, BTM_PM_MD_SNIFF}, /*for BTA_DM_PM_SNIFF4- HD active*/
- {800, 400, 0, 0, BTM_PM_MD_PARK}
+ {BTA_DM_PM_SNIFF_MAX, BTA_DM_PM_SNIFF_MIN, BTA_DM_PM_SNIFF_ATTEMPT, BTA_DM_PM_SNIFF_TIMEOUT, BTM_PM_MD_SNIFF}, /*for BTA_DM_PM_SNIFF - A2DP */
+ {BTA_DM_PM_SNIFF1_MAX, BTA_DM_PM_SNIFF1_MIN, BTA_DM_PM_SNIFF1_ATTEMPT, BTA_DM_PM_SNIFF1_TIMEOUT, BTM_PM_MD_SNIFF}, /*for BTA_DM_PM_SNIFF1 */
+ {BTA_DM_PM_SNIFF2_MAX, BTA_DM_PM_SNIFF2_MIN, BTA_DM_PM_SNIFF2_ATTEMPT, BTA_DM_PM_SNIFF2_TIMEOUT, BTM_PM_MD_SNIFF}, /*for BTA_DM_PM_SNIFF2- HD idle */
+ {BTA_DM_PM_SNIFF3_MAX, BTA_DM_PM_SNIFF3_MIN, BTA_DM_PM_SNIFF3_ATTEMPT, BTA_DM_PM_SNIFF3_TIMEOUT, BTM_PM_MD_SNIFF}, /*for BTA_DM_PM_SNIFF3- SCO open */
+ {BTA_DM_PM_SNIFF4_MAX, BTA_DM_PM_SNIFF4_MIN, BTA_DM_PM_SNIFF4_ATTEMPT, BTA_DM_PM_SNIFF4_TIMEOUT, BTM_PM_MD_SNIFF}, /*for BTA_DM_PM_SNIFF4- HD active*/
+ {BTA_DM_PM_PARK_MAX, BTA_DM_PM_PARK_MIN, BTA_DM_PM_PARK_ATTEMPT, BTA_DM_PM_PARK_TIMEOUT, BTM_PM_MD_PARK}
#ifdef BTE_SIM_APP /* For Insight builds only */
/* Entries at the end of the bta_dm_pm_md table are user-defined (runtime configurable),
diff --git a/bta/dm/bta_dm_int.h b/bta/dm/bta_dm_int.h
index 03cb45f..9014501 100644
--- a/bta/dm/bta_dm_int.h
+++ b/bta/dm/bta_dm_int.h
@@ -100,6 +100,11 @@
BTA_DM_API_BLE_SCAN_PARAM_EVT,
BTA_DM_API_BLE_OBSERVE_EVT,
BTA_DM_API_UPDATE_CONN_PARAM_EVT,
+
+#if BLE_PRIVACY_SPT == TRUE
+ BTA_DM_API_LOCAL_PRIVACY_EVT,
+#endif
+
BTA_DM_API_BLE_ADV_PARAM_EVT,
BTA_DM_API_BLE_SET_ADV_CONFIG_EVT,
BTA_DM_API_BLE_SET_SCAN_RSP_EVT,
@@ -109,6 +114,10 @@
BTA_DM_API_CFG_FILTER_COND_EVT,
BTA_DM_API_ENABLE_SCAN_FILTER_EVT,
#endif
+ BTA_DM_API_BLE_MULTI_ADV_ENB_EVT,
+ BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT,
+ BTA_DM_API_BLE_MULTI_ADV_DATA_EVT,
+ BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT,
#endif
#if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&( BTA_EIR_CANNED_UUID_LIST != TRUE )&&(BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0)
@@ -540,11 +549,51 @@
typedef struct
{
BT_HDR hdr;
+ BOOLEAN enable;
+
+}tBTA_DM_API_BLE_FEATURE;
+
+/* multi adv data structure */
+typedef struct
+{
+ BT_HDR hdr;
+ void *p_cback;
+ void *p_ref;
+ tBTA_BLE_ADV_PARAMS *p_params;
+}tBTA_DM_API_BLE_MULTI_ADV_ENB;
+
+typedef struct
+{
+ BT_HDR hdr;
+ UINT8 inst_id;
+ tBTA_BLE_ADV_PARAMS *p_params;
+}tBTA_DM_API_BLE_MULTI_ADV_PARAM;
+
+typedef struct
+{
+ BT_HDR hdr;
+ UINT8 inst_id;
+ BOOLEAN is_scan_rsp;
+ tBTA_BLE_AD_MASK data_mask;
+ tBTA_BLE_ADV_DATA *p_data;
+}tBTA_DM_API_BLE_MULTI_ADV_DATA;
+
+typedef struct
+{
+ BT_HDR hdr;
+ UINT8 inst_id;
+}tBTA_DM_API_BLE_MULTI_ADV_DISABLE;
+
+
+typedef struct
+{
+ BT_HDR hdr;
UINT16 data_mask;
tBTA_BLE_ADV_DATA *p_adv_cfg;
+ tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback;
}tBTA_DM_API_SET_ADV_CONFIG;
-#endif
+#endif /* BLE_INCLUDED */
typedef struct
{
@@ -689,6 +738,10 @@
tBTA_DM_API_CFG_FILTER_COND ble_cfg_filter_cond;
#endif
tBTA_DM_API_UPDATE_CONN_PARAM ble_update_conn_params;
+ tBTA_DM_API_BLE_MULTI_ADV_ENB ble_multi_adv_enb;
+ tBTA_DM_API_BLE_MULTI_ADV_PARAM ble_multi_adv_param;
+ tBTA_DM_API_BLE_MULTI_ADV_DATA ble_multi_adv_data;
+ tBTA_DM_API_BLE_MULTI_ADV_DISABLE ble_multi_adv_disable;
#endif
tBTA_DM_API_SET_AFH_CHANNEL_ASSESSMENT set_afh_channel_assessment;
@@ -1048,6 +1101,9 @@
extern void bta_dm_close_gatt_conn(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_observe (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_update_conn_params (tBTA_DM_MSG *p_data);
+#if BLE_PRIVACY_SPT == TRUE
+extern void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data);
+#endif
extern void bta_dm_ble_set_adv_params (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_adv_config (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_scan_rsp (tBTA_DM_MSG *p_data);
@@ -1057,6 +1113,10 @@
extern void bta_dm_enable_scan_filter (tBTA_DM_MSG *p_data);
extern void bta_dm_cfg_filter_cond (tBTA_DM_MSG *p_data);
#endif
+extern void btm_dm_ble_multi_adv_disable(tBTA_DM_MSG *p_data);
+extern void bta_dm_ble_multi_adv_data(tBTA_DM_MSG *p_data);
+extern void bta_dm_ble_multi_adv_upd_param(tBTA_DM_MSG *p_data);
+extern void bta_dm_ble_multi_adv_enb(tBTA_DM_MSG *p_data);
#endif
extern void bta_dm_set_encryption(tBTA_DM_MSG *p_data);
diff --git a/bta/dm/bta_dm_main.c b/bta/dm/bta_dm_main.c
index 8f8c750..c68dac5 100644
--- a/bta/dm/bta_dm_main.c
+++ b/bta/dm/bta_dm_main.c
@@ -108,6 +108,10 @@
bta_dm_cfg_filter_cond, /* BTA_DM_API_CFG_FILTER_COND_EVT */
bta_dm_enable_scan_filter, /* BTA_DM_API_ENABLE_SCAN_FILTER_EVT */
#endif
+ bta_dm_ble_multi_adv_enb, /* BTA_DM_API_BLE_MULTI_ADV_ENB_EVT*/
+ bta_dm_ble_multi_adv_upd_param, /* BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT */
+ bta_dm_ble_multi_adv_data, /* BTA_DM_API_BLE_MULTI_ADV_DATA_EVT */
+ btm_dm_ble_multi_adv_disable, /* BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT */
#endif
#if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&( BTA_EIR_CANNED_UUID_LIST != TRUE )&&(BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0)
diff --git a/bta/gatt/bta_gattc_act.c b/bta/gatt/bta_gattc_act.c
index 1b3261b..2685bad 100644
--- a/bta/gatt/bta_gattc_act.c
+++ b/bta/gatt/bta_gattc_act.c
@@ -52,8 +52,8 @@
tGATT_CL_COMPLETE *p_data);
static void bta_gattc_deregister_cmpl(tBTA_GATTC_RCB *p_clreg);
-
static void bta_gattc_enc_cmpl_cback(tGATT_IF gattc_if, BD_ADDR bda);
+static void bta_gattc_cong_cback (UINT16 conn_id, BOOLEAN congested);
static tGATT_CBACK bta_gattc_cl_cback =
{
@@ -62,7 +62,8 @@
bta_gattc_disc_res_cback,
bta_gattc_disc_cmpl_cback,
NULL,
- bta_gattc_enc_cmpl_cback
+ bta_gattc_enc_cmpl_cback,
+ bta_gattc_cong_cback
};
/* opcode(tGATTC_OPTYPE) order has to be comply with internal event order */
@@ -1790,9 +1791,9 @@
p_buf->int_conn.transport = transport;
bdcpy(p_buf->int_conn.remote_bda, bda);
- bta_sys_sendmsg(p_buf);
- }
- }
+ bta_sys_sendmsg(p_buf);
+ }
+}
/*******************************************************************************
**
@@ -2128,6 +2129,33 @@
return;
}
+
+/*******************************************************************************
+**
+** Function bta_gattc_cong_cback
+**
+** Description congestion callback for BTA GATT client.
+**
+** Returns void
+**
+********************************************************************************/
+static void bta_gattc_cong_cback (UINT16 conn_id, BOOLEAN congested)
+{
+ tBTA_GATTC_CLCB *p_clcb;
+ tBTA_GATTC cb_data;
+
+ if ((p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id)) != NULL)
+ {
+ if (p_clcb->p_rcb->p_cback)
+ {
+ cb_data.congest.conn_id = conn_id;
+ cb_data.congest.congested = congested;
+
+ (*p_clcb->p_rcb->p_cback)(BTA_GATTC_CONGEST_EVT, &cb_data);
+ }
+ }
+}
+
#if BLE_INCLUDED == TRUE
/*******************************************************************************
**
@@ -2280,7 +2308,7 @@
{
tBTA_GATTC_RCB *p_clreg = bta_gattc_cl_get_regcb(p_msg->api_listen.client_if);
tBTA_GATTC cb_data;
- (void)(p_cb);
+ UNUSED(p_cb);
cb_data.reg_oper.client_if = p_msg->api_listen.client_if;
cb_data.reg_oper.status = BTM_BleBroadcast(p_msg->api_listen.start);
diff --git a/bta/gatt/bta_gattc_api.c b/bta/gatt/bta_gattc_api.c
index bfbaf63..be1163f 100644
--- a/bta/gatt/bta_gattc_api.c
+++ b/bta/gatt/bta_gattc_api.c
@@ -91,9 +91,7 @@
if (bta_sys_is_register(BTA_ID_GATTC) == FALSE)
{
- GKI_sched_lock();
bta_sys_register(BTA_ID_GATTC, &bta_gattc_reg);
- GKI_sched_unlock();
}
if ((p_buf = (tBTA_GATTC_API_REG *) GKI_getbuf(sizeof(tBTA_GATTC_API_REG))) != NULL)
@@ -417,7 +415,6 @@
memcpy(&p_descr_result->descr_id, &p_descr_result->char_id.char_id, sizeof(tBTA_GATT_ID));
memcpy(&p_descr_result->char_id, p_char_id, sizeof(tBTA_GATTC_CHAR_ID));
}
-
return status;
}
@@ -429,7 +426,7 @@
** of the characterisctic.
**
** Parameters conn_id: connection ID which identify the server.
-** p_start_descr_id: start the characteristic search from the next record
+** p_start_descr_id: start the descriptor search from the next record
** after the one identified by p_start_descr_id.
** p_descr_uuid_cond: Characteristic descriptor UUID, if NULL find
** the first available characteristic descriptor.
@@ -909,9 +906,6 @@
return status;
}
- /* lock other GKI task */
- GKI_sched_lock();
-
if ((p_clreg = bta_gattc_cl_get_regcb(client_if)) != NULL)
{
for (i = 0; i < BTA_GATTC_NOTIF_REG_MAX; i ++)
@@ -956,8 +950,6 @@
APPL_TRACE_ERROR1("Client_if: %d Not Registered", client_if);
}
- GKI_sched_unlock();
-
return status;
}
@@ -988,9 +980,6 @@
return status;
}
- /* lock other GKI task */
- GKI_sched_lock();
-
if ((p_clreg = bta_gattc_cl_get_regcb(client_if)) != NULL)
{
for (i = 0; i < BTA_GATTC_NOTIF_REG_MAX; i ++)
@@ -1017,8 +1006,6 @@
APPL_TRACE_ERROR1("Client_if: %d Not Registered", client_if);
}
- GKI_sched_unlock();
-
return status;
}
diff --git a/bta/gatt/bta_gattc_cache.c b/bta/gatt/bta_gattc_cache.c
index 64147e2..cf0cf95 100644
--- a/bta/gatt/bta_gattc_cache.c
+++ b/bta/gatt/bta_gattc_cache.c
@@ -1440,9 +1440,6 @@
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
tBTA_GATT_STATUS status = BTA_GATT_ILLEGAL_PARAMETER;
- /* lock other GKI task */
- GKI_sched_lock();
-
if (p_clcb != NULL )
{
if (p_clcb->state == BTA_GATTC_CONN_ST)
@@ -1476,7 +1473,6 @@
{
APPL_TRACE_ERROR1("Unknown conn ID: %d", conn_id);
}
- GKI_sched_unlock();
return status;
}
diff --git a/bta/gatt/bta_gattc_main.c b/bta/gatt/bta_gattc_main.c
index c917d4a..5ac6fea 100644
--- a/bta/gatt/bta_gattc_main.c
+++ b/bta/gatt/bta_gattc_main.c
@@ -322,8 +322,12 @@
if ((action = state_table[event][i]) != BTA_GATTC_IGNORE)
{
(*bta_gattc_action[action])(p_clcb, p_data);
- p_clcb->buf_held = FALSE;
- rt = FALSE;
+
+ if (p_clcb->buf_held)
+ {
+ p_clcb->buf_held = FALSE;
+ rt = FALSE;
+ }
}
else
{
diff --git a/bta/gatt/bta_gatts_act.c b/bta/gatt/bta_gatts_act.c
index 4a24d66..11ce53b 100644
--- a/bta/gatt/bta_gatts_act.c
+++ b/bta/gatt/bta_gatts_act.c
@@ -46,6 +46,8 @@
static void bta_gatts_send_request_cback (UINT16 conn_id,
UINT32 trans_id,
tGATTS_REQ_TYPE req_type, tGATTS_DATA *p_data);
+static void bta_gatts_cong_cback (UINT16 conn_id, BOOLEAN congested);
+
static tGATT_CBACK bta_gatts_cback =
{
bta_gatts_conn_cback,
@@ -53,7 +55,8 @@
NULL,
NULL,
bta_gatts_send_request_cback,
- NULL
+ NULL,
+ bta_gatts_cong_cback
};
tGATT_APPL_INFO bta_gatts_nv_cback =
@@ -633,10 +636,12 @@
void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
{
tBTA_GATTS_SRVC_CB *p_srvc_cb;
+ tBTA_GATTS_RCB *p_rcb = NULL;
tBTA_GATT_STATUS status = BTA_GATT_ILLEGAL_PARAMETER;
tGATT_IF gatt_if;
BD_ADDR remote_bda;
tBTA_TRANSPORT transport;
+ tBTA_GATTS cb_data;
p_srvc_cb = bta_gatts_find_srvc_cb_by_attr_id (p_cb, p_msg->api_indicate.attr_id);
@@ -645,6 +650,8 @@
if (GATT_GetConnectionInfor(p_msg->api_indicate.hdr.layer_specific,
&gatt_if, remote_bda, &transport))
{
+ p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if);
+
if (p_msg->api_indicate.need_confirm)
status = GATTS_HandleValueIndication (p_msg->api_indicate.hdr.layer_specific,
@@ -669,10 +676,14 @@
APPL_TRACE_ERROR1("Unknown connection ID: %d fail sending notification",
p_msg->api_indicate.hdr.layer_specific);
}
+
if ((status != GATT_SUCCESS || !p_msg->api_indicate.need_confirm) &&
- p_cb->rcb[p_srvc_cb->rcb_idx].p_cback)
+ p_rcb && p_cb->rcb[p_srvc_cb->rcb_idx].p_cback)
{
- (*p_cb->rcb[p_srvc_cb->rcb_idx].p_cback)(BTA_GATTS_CONF_EVT, (tBTA_GATTS *)&status);
+ cb_data.req_data.status = status;
+ cb_data.req_data.conn_id = p_msg->api_indicate.hdr.layer_specific;
+
+ (*p_rcb->p_cback)(BTA_GATTS_CONF_EVT, &cb_data);
}
}
else
@@ -940,4 +951,34 @@
APPL_TRACE_ERROR1("bta_gatts_conn_cback server_if=%d not found",gatt_if);
}
}
+
+/*******************************************************************************
+**
+** Function bta_gatts_cong_cback
+**
+** Description congestion callback.
+**
+** Returns none.
+**
+*******************************************************************************/
+static void bta_gatts_cong_cback (UINT16 conn_id, BOOLEAN congested)
+{
+ tBTA_GATTS_RCB *p_rcb;
+ tGATT_IF gatt_if;
+ tBTA_GATT_TRANSPORT transport;
+ tBTA_GATTS cb_data;
+
+ if (GATT_GetConnectionInfor(conn_id, &gatt_if, cb_data.req_data.remote_bda, &transport))
+ {
+ p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if);
+
+ if (p_rcb && p_rcb->p_cback)
+ {
+ cb_data.congest.conn_id = conn_id;
+ cb_data.congest.congested = congested;
+
+ (*p_rcb->p_cback)(BTA_GATTS_CONGEST_EVT, &cb_data);
+ }
+ }
+}
#endif /* BTA_GATT_INCLUDED */
diff --git a/bta/gatt/bta_gatts_api.c b/bta/gatt/bta_gatts_api.c
index 79eb6f9..86bb2f1 100644
--- a/bta/gatt/bta_gatts_api.c
+++ b/bta/gatt/bta_gatts_api.c
@@ -90,11 +90,9 @@
tBTA_GATTS_API_REG *p_buf;
/* register with BTA system manager */
- if (bta_sys_is_register(BTA_ID_GATTS) == FALSE)
- {
- GKI_sched_lock();
+ if (bta_sys_is_register(BTA_ID_GATTS) == FALSE)
+ {
bta_sys_register(BTA_ID_GATTS, &bta_gatts_reg);
- GKI_sched_unlock();
}
if ((p_buf = (tBTA_GATTS_API_REG *) GKI_getbuf(sizeof(tBTA_GATTS_API_REG))) != NULL)
diff --git a/bta/hf_client/bta_hf_client_act.c b/bta/hf_client/bta_hf_client_act.c
new file mode 100644
index 0000000..854260a
--- /dev/null
+++ b/bta/hf_client/bta_hf_client_act.c
@@ -0,0 +1,768 @@
+/******************************************************************************
+ *
+ * Copyright (c) 2014 The Android Open Source Project
+ * Copyright (C) 2003-2012 Broadcom 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.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains action functions for the handsfree client.
+ *
+ ******************************************************************************/
+
+#include "bta_api.h"
+#include "bd.h"
+#include "bta_hf_client_api.h"
+#include "bta_hf_client_int.h"
+#include "bta_dm_int.h"
+#include "l2c_api.h"
+#include "port_api.h"
+#include "bta_sys.h"
+#include "utl.h"
+#include "bt_utils.h"
+#include <string.h>
+
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+
+/* maximum length of data to read from RFCOMM */
+#define BTA_HF_CLIENT_RFC_READ_MAX 512
+
+/*******************************************************************************
+**
+** Function bta_hf_client_register
+**
+** Description This function initializes values of the scb and sets up
+** the SDP record for the services.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_register(tBTA_HF_CLIENT_DATA *p_data)
+{
+ tBTA_HF_CLIENT evt;
+ tBTA_UTL_COD cod;
+
+ memset(&evt, 0, sizeof(evt));
+
+ /* initialize control block */
+ bta_hf_client_scb_init();
+
+ bta_hf_client_cb.scb.serv_sec_mask = p_data->api_register.sec_mask;
+ bta_hf_client_cb.scb.features = p_data->api_register.features;
+
+ /* initialize AT control block */
+ bta_hf_client_at_init();
+
+ /* create SDP records */
+ bta_hf_client_create_record(p_data);
+
+ /* Set the Audio service class bit */
+ cod.service = BTM_COD_SERVICE_AUDIO;
+ utl_set_device_class(&cod, BTA_UTL_SET_COD_SERVICE_CLASS);
+
+ /* start RFCOMM server */
+ bta_hf_client_start_server();
+
+ /* call app callback with register event */
+ evt.reg.status = BTA_HF_CLIENT_SUCCESS;
+ (*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_REGISTER_EVT, &evt);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_deregister
+**
+** Description This function removes the sdp records, closes the RFCOMM
+** servers, and deallocates the service control block.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_deregister(tBTA_HF_CLIENT_DATA *p_data)
+{
+ bta_hf_client_cb.scb.deregister = TRUE;
+
+ /* remove sdp record */
+ bta_hf_client_del_record(p_data);
+
+ /* remove rfcomm server */
+ bta_hf_client_close_server();
+
+ /* disable */
+ bta_hf_client_scb_disable();
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_start_dereg
+**
+** Description Start a deregister event.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_start_dereg(tBTA_HF_CLIENT_DATA *p_data)
+{
+ bta_hf_client_cb.scb.deregister = TRUE;
+
+ /* remove sdp record */
+ bta_hf_client_del_record(p_data);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_start_close
+**
+** Description Start the process of closing SCO and RFCOMM connection.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_start_close(tBTA_HF_CLIENT_DATA *p_data)
+{
+ /* Take the link out of sniff and set L2C idle time to 0 */
+ bta_dm_pm_active(bta_hf_client_cb.scb.peer_addr);
+ L2CA_SetIdleTimeoutByBdAddr(bta_hf_client_cb.scb.peer_addr, 0);
+
+ /* if SCO is open close SCO and wait on RFCOMM close */
+ if (bta_hf_client_cb.scb.sco_state == BTA_HF_CLIENT_SCO_OPEN_ST)
+ {
+ bta_hf_client_cb.scb.sco_close_rfc = TRUE;
+ }
+ else
+ {
+ bta_hf_client_rfc_do_close(p_data);
+ }
+
+ /* always do SCO shutdown to handle all SCO corner cases */
+ bta_hf_client_sco_shutdown(NULL);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_start_open
+**
+** Description This starts an HF Client open.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_start_open(tBTA_HF_CLIENT_DATA *p_data)
+{
+ BD_ADDR pending_bd_addr;
+
+ /* store parameters */
+ if (p_data)
+ {
+ bdcpy(bta_hf_client_cb.scb.peer_addr, p_data->api_open.bd_addr);
+ bta_hf_client_cb.scb.cli_sec_mask = p_data->api_open.sec_mask;
+ }
+
+ /* Check if RFCOMM has any incoming connection to avoid collision. */
+ if (PORT_IsOpening (pending_bd_addr))
+ {
+ /* Let the incoming connection goes through. */
+ /* Issue collision for now. */
+ /* We will decide what to do when we find incoming connection later.*/
+ bta_hf_client_collision_cback (0, BTA_ID_HS, 0, bta_hf_client_cb.scb.peer_addr);
+ return;
+ }
+
+ /* close server */
+ bta_hf_client_close_server();
+
+ /* set role */
+ bta_hf_client_cb.scb.role = BTA_HF_CLIENT_INT;
+
+ /* do service search */
+ bta_hf_client_do_disc();
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_cback_open
+**
+** Description Send open callback event to application.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+static void bta_hf_client_cback_open(tBTA_HF_CLIENT_DATA *p_data, tBTA_HF_CLIENT_STATUS status)
+{
+ tBTA_HF_CLIENT evt;
+
+ memset(&evt, 0, sizeof(evt));
+
+ /* call app callback with open event */
+ evt.open.status = status;
+ if(p_data)
+ {
+ /* if p_data is provided then we need to pick the bd address from the open api structure */
+ bdcpy(evt.open.bd_addr, p_data->api_open.bd_addr);
+ }
+ else
+ {
+ bdcpy(evt.open.bd_addr, bta_hf_client_cb.scb.peer_addr);
+ }
+
+ (*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_OPEN_EVT, &evt);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_rfc_open
+**
+** Description Handle RFCOMM channel open.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_rfc_open(tBTA_HF_CLIENT_DATA *p_data)
+{
+ UNUSED(p_data);
+
+ bta_sys_conn_open(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);
+
+ bta_hf_client_cback_open(NULL, BTA_HF_CLIENT_SUCCESS);
+
+ /* start SLC procedure */
+ bta_hf_client_slc_seq(FALSE);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_rfc_acp_open
+**
+** Description Handle RFCOMM channel open when accepting connection.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_rfc_acp_open(tBTA_HF_CLIENT_DATA *p_data)
+{
+ UINT16 lcid;
+ int i;
+ BD_ADDR dev_addr;
+ int status;
+
+ /* set role */
+ bta_hf_client_cb.scb.role = BTA_HF_CLIENT_ACP;
+
+ APPL_TRACE_DEBUG2 ("bta_hf_client_rfc_acp_open: serv_handle = %d rfc.port_handle = %d",
+ bta_hf_client_cb.scb.serv_handle, p_data->rfc.port_handle);
+
+ /* get bd addr of peer */
+ if (PORT_SUCCESS != (status=PORT_CheckConnection(p_data->rfc.port_handle, dev_addr, &lcid)))
+ {
+ APPL_TRACE_DEBUG1 ("bta_hf_client_rfc_acp_open error PORT_CheckConnection returned status %d", status);
+ }
+
+ /* Collision Handling */
+ if (bta_hf_client_cb.scb.colli_tmr_on)
+ {
+ /* stop collision timer */
+ bta_hf_client_cb.scb.colli_tmr_on = FALSE;
+ bta_sys_stop_timer (&bta_hf_client_cb.scb.colli_timer);
+
+ if (bdcmp (dev_addr, bta_hf_client_cb.scb.peer_addr) == 0)
+ {
+ /* If incoming and outgoing device are same, nothing more to do. */
+ /* Outgoing conn will be aborted because we have successful incoming conn. */
+ }
+ else
+ {
+ /* Resume outgoing connection. */
+ bta_hf_client_resume_open ();
+ }
+ }
+
+ bdcpy (bta_hf_client_cb.scb.peer_addr, dev_addr);
+ bta_hf_client_cb.scb.conn_handle = p_data->rfc.port_handle;
+
+ /* do service discovery to get features */
+ bta_hf_client_do_disc();
+
+ /* continue with open processing */
+ bta_hf_client_rfc_open(p_data);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_rfc_fail
+**
+** Description RFCOMM connection failed.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_rfc_fail(tBTA_HF_CLIENT_DATA *p_data)
+{
+ UNUSED(p_data);
+
+ /* reinitialize stuff */
+ bta_hf_client_cb.scb.conn_handle = 0;
+ bta_hf_client_cb.scb.peer_features = 0;
+ bta_hf_client_cb.scb.chld_features = 0;
+ bta_hf_client_cb.scb.role = BTA_HF_CLIENT_ACP;
+ bta_hf_client_cb.scb.svc_conn = FALSE;
+ bta_hf_client_cb.scb.send_at_reply = FALSE;
+ bta_hf_client_cb.scb.negotiated_codec = BTM_SCO_CODEC_CVSD;
+
+ bta_hf_client_at_reset();
+
+ /* reopen server */
+ bta_hf_client_start_server();
+
+ /* call open cback w. failure */
+ bta_hf_client_cback_open(NULL, BTA_HF_CLIENT_FAIL_RFCOMM);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_disc_fail
+**
+** Description This function handles a discovery failure.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_disc_fail(tBTA_HF_CLIENT_DATA *p_data)
+{
+ UNUSED(p_data);
+
+ /* reopen server */
+ bta_hf_client_start_server();
+
+ /* reinitialize stuff */
+
+ /* call open cback w. failure */
+ bta_hf_client_cback_open(NULL, BTA_HF_CLIENT_FAIL_SDP);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_open_fail
+**
+** Description open connection failed.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_open_fail(tBTA_HF_CLIENT_DATA *p_data)
+{
+ /* call open cback w. failure */
+ bta_hf_client_cback_open(p_data, BTA_HF_CLIENT_FAIL_RESOURCES);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_rfc_close
+**
+** Description RFCOMM connection closed.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_rfc_close(tBTA_HF_CLIENT_DATA *p_data)
+{
+ int i, num_active_conn = 0;
+ UNUSED(p_data);
+
+ /* reinitialize stuff */
+ bta_hf_client_cb.scb.peer_features = 0;
+ bta_hf_client_cb.scb.chld_features = 0;
+ bta_hf_client_cb.scb.role = BTA_HF_CLIENT_ACP;
+ bta_hf_client_cb.scb.svc_conn = FALSE;
+ bta_hf_client_cb.scb.send_at_reply = FALSE;
+ bta_hf_client_cb.scb.negotiated_codec = BTM_SCO_CODEC_CVSD;
+
+ bta_hf_client_at_reset();
+
+ bta_sys_conn_close(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);
+
+ /* call close cback */
+ (*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_CLOSE_EVT, NULL);
+
+ /* if not deregistering reopen server */
+ if (bta_hf_client_cb.scb.deregister == FALSE)
+ {
+ /* Clear peer bd_addr so instance can be reused */
+ bdcpy(bta_hf_client_cb.scb.peer_addr, bd_addr_null);
+
+ /* start server as it might got closed on open*/
+ bta_hf_client_start_server();
+
+ bta_hf_client_cb.scb.conn_handle = 0;
+
+ /* Make sure SCO is shutdown */
+ bta_hf_client_sco_shutdown(NULL);
+
+ bta_sys_sco_unuse(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);
+ }
+ /* else close port and deallocate scb */
+ else
+ {
+ bta_hf_client_close_server();
+ bta_hf_client_scb_disable();
+ }
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_disc_int_res
+**
+** Description This function handles a discovery result when initiator.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_disc_int_res(tBTA_HF_CLIENT_DATA *p_data)
+{
+ UINT16 event = BTA_HF_CLIENT_DISC_FAIL_EVT;
+
+ APPL_TRACE_DEBUG1 ("bta_hf_client_disc_int_res: Status: %d", p_data->disc_result.status);
+
+ /* if found service */
+ if (p_data->disc_result.status == SDP_SUCCESS ||
+ p_data->disc_result.status == SDP_DB_FULL)
+ {
+ /* get attributes */
+ if (bta_hf_client_sdp_find_attr())
+ {
+ event = BTA_HF_CLIENT_DISC_OK_EVT;
+ }
+ }
+
+ /* free discovery db */
+ bta_hf_client_free_db(p_data);
+
+ /* send ourselves sdp ok/fail event */
+ bta_hf_client_sm_execute(event, p_data);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_disc_acp_res
+**
+** Description This function handles a discovery result when acceptor.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_disc_acp_res(tBTA_HF_CLIENT_DATA *p_data)
+{
+ /* if found service */
+ if (p_data->disc_result.status == SDP_SUCCESS ||
+ p_data->disc_result.status == SDP_DB_FULL)
+ {
+ /* get attributes */
+ bta_hf_client_sdp_find_attr();
+ }
+
+ /* free discovery db */
+ bta_hf_client_free_db(p_data);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_rfc_data
+**
+** Description Read and process data from RFCOMM.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_rfc_data(tBTA_HF_CLIENT_DATA *p_data)
+{
+ UINT16 len;
+ char buf[BTA_HF_CLIENT_RFC_READ_MAX];
+ UNUSED(p_data);
+
+ memset(buf, 0, sizeof(buf));
+
+ /* read data from rfcomm; if bad status, we're done */
+ while (PORT_ReadData(bta_hf_client_cb.scb.conn_handle, buf, BTA_HF_CLIENT_RFC_READ_MAX, &len) == PORT_SUCCESS)
+ {
+ /* if no data, we're done */
+ if (len == 0)
+ {
+ break;
+ }
+
+ bta_hf_client_at_parse(buf, len);
+
+ /* no more data to read, we're done */
+ if (len < BTA_HF_CLIENT_RFC_READ_MAX)
+ {
+ break;
+ }
+ }
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_svc_conn_open
+**
+** Description Service level connection opened
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_svc_conn_open(tBTA_HF_CLIENT_DATA *p_data)
+{
+ tBTA_HF_CLIENT evt;
+ UNUSED(p_data);
+
+ memset(&evt, 0, sizeof(evt));
+
+ if (!bta_hf_client_cb.scb.svc_conn)
+ {
+ /* set state variable */
+ bta_hf_client_cb.scb.svc_conn = TRUE;
+
+ /* call callback */
+ evt.conn.peer_feat = bta_hf_client_cb.scb.peer_features;
+ evt.conn.chld_feat = bta_hf_client_cb.scb.chld_features;
+
+ (*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_CONN_EVT, &evt);
+ }
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_cback_ind
+**
+** Description Send indicator callback event to application.
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_ind(tBTA_HF_CLIENT_IND_TYPE type, UINT16 value)
+{
+ tBTA_HF_CLIENT evt;
+
+ memset(&evt, 0, sizeof(evt));
+
+ evt.ind.type = type;
+ evt.ind.value = value;
+
+ (*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_IND_EVT, &evt);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_evt_val
+**
+** Description Send event to application.
+** This is a generic helper for events with common data.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_evt_val(tBTA_HF_CLIENT_EVT type, UINT16 value)
+{
+ tBTA_HF_CLIENT evt;
+
+ memset(&evt, 0, sizeof(evt));
+
+ evt.val.value = value;
+
+ (*bta_hf_client_cb.p_cback)(type, &evt);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_operator_name
+**
+** Description Send operator name event to application.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_operator_name(char *name)
+{
+ tBTA_HF_CLIENT evt;
+
+ memset(&evt, 0, sizeof(evt));
+
+ strlcpy(evt.operator.name, name, BTA_HF_CLIENT_OPERATOR_NAME_LEN + 1);
+ evt.operator.name[BTA_HF_CLIENT_OPERATOR_NAME_LEN] = '\0';
+
+ (*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_OPERATOR_NAME_EVT, &evt);
+}
+
+
+/*******************************************************************************
+**
+** Function bta_hf_client_clip
+**
+** Description Send CLIP event to application.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_clip(char *number)
+{
+ tBTA_HF_CLIENT evt;
+
+ memset(&evt, 0, sizeof(evt));
+
+ strlcpy(evt.number.number, number, BTA_HF_CLIENT_NUMBER_LEN + 1);
+ evt.number.number[BTA_HF_CLIENT_NUMBER_LEN] = '\0';
+
+ (*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_CLIP_EVT, &evt);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_ccwa
+**
+** Description Send CLIP event to application.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_ccwa(char *number)
+{
+ tBTA_HF_CLIENT evt;
+
+ memset(&evt, 0, sizeof(evt));
+
+ strlcpy(evt.number.number, number, BTA_HF_CLIENT_NUMBER_LEN + 1);
+ evt.number.number[BTA_HF_CLIENT_NUMBER_LEN] = '\0';
+
+ (*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_CCWA_EVT, &evt);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_at_result
+**
+** Description Send AT result event to application.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_at_result(tBTA_HF_CLIENT_AT_RESULT_TYPE type, UINT16 cme)
+{
+ tBTA_HF_CLIENT evt;
+
+ memset(&evt, 0, sizeof(evt));
+
+ evt.result.type = type;
+ evt.result.cme = cme;
+
+ (*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_AT_RESULT_EVT, &evt);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_clcc
+**
+** Description Send clcc event to application.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_clcc(UINT32 idx, BOOLEAN incoming, UINT8 status, BOOLEAN mpty, char *number)
+{
+ tBTA_HF_CLIENT evt;
+
+ memset(&evt, 0, sizeof(evt));
+
+ evt.clcc.idx = idx;
+ evt.clcc.inc = incoming;
+ evt.clcc.status = status;
+ evt.clcc.mpty = mpty;
+
+ if (number)
+ {
+ evt.clcc.number_present = TRUE;
+ strlcpy(evt.clcc.number, number, BTA_HF_CLIENT_NUMBER_LEN + 1);
+ evt.clcc.number[BTA_HF_CLIENT_NUMBER_LEN] = '\0';
+ }
+
+ (*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_CLCC_EVT, &evt);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_cnum
+**
+** Description Send cnum event to application.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_cnum(char *number, UINT16 service)
+{
+ tBTA_HF_CLIENT evt;
+
+ memset(&evt, 0, sizeof(evt));
+
+ evt.cnum.service = service;
+ strlcpy(evt.cnum.number, number, BTA_HF_CLIENT_NUMBER_LEN + 1);
+ evt.cnum.number[BTA_HF_CLIENT_NUMBER_LEN] = '\0';
+
+ (*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_CNUM_EVT, &evt);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_binp
+**
+** Description Send BINP event to application.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_binp(char *number)
+{
+ tBTA_HF_CLIENT evt;
+
+ memset(&evt, 0, sizeof(evt));
+
+ strlcpy(evt.number.number, number, BTA_HF_CLIENT_NUMBER_LEN + 1);
+ evt.number.number[BTA_HF_CLIENT_NUMBER_LEN] = '\0';
+
+ (*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_BINP_EVT, &evt);
+}
diff --git a/bta/hf_client/bta_hf_client_api.c b/bta/hf_client/bta_hf_client_api.c
new file mode 100644
index 0000000..a7c6255
--- /dev/null
+++ b/bta/hf_client/bta_hf_client_api.c
@@ -0,0 +1,289 @@
+/******************************************************************************
+ *
+ * Copyright (c) 2014 The Android Open Source Project
+ * Copyright (C) 2003-2012 Broadcom 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.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This is the implementation of the API for the handsfree (HF role)
+ * subsystem of BTA
+ *
+ ******************************************************************************/
+
+#include <string.h>
+#include "bta_hf_client_api.h"
+#include "bta_hf_client_int.h"
+#include "bd.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+static const tBTA_SYS_REG bta_hf_client_reg =
+{
+ bta_hf_client_hdl_event,
+ BTA_HfClientDisable
+};
+
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function BTA_HfClientEnable
+**
+** Description Enable the HF CLient service. When the enable
+** operation is complete the callback function will be
+** called with a BTA_HF_CLIENT_ENABLE_EVT. This function must
+** be called before other function in the HF CLient API are
+** called.
+**
+** Returns BTA_SUCCESS if OK, BTA_FAILURE otherwise.
+**
+*******************************************************************************/
+BTA_API tBTA_STATUS BTA_HfClientEnable(tBTA_HF_CLIENT_CBACK *p_cback)
+{
+ tBTA_HF_CLIENT_API_ENABLE *p_buf;
+ UINT8 idx;
+
+ if (bta_sys_is_register (BTA_ID_HS))
+ {
+ APPL_TRACE_ERROR0("BTA HF Client is already enabled, ignoring ...");
+ return BTA_FAILURE;
+ }
+
+ /* register with BTA system manager */
+ bta_sys_register(BTA_ID_HS, &bta_hf_client_reg);
+
+ if ((p_buf = (tBTA_HF_CLIENT_API_ENABLE *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_API_ENABLE))) != NULL)
+ {
+ p_buf->hdr.event = BTA_HF_CLIENT_API_ENABLE_EVT;
+ p_buf->p_cback = p_cback;
+ bta_sys_sendmsg(p_buf);
+ }
+
+ return BTA_SUCCESS;
+}
+
+/*******************************************************************************
+**
+** Function BTA_HfClientDisable
+**
+** Description Disable the HF Client service
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HfClientDisable(void)
+{
+ BT_HDR *p_buf;
+
+ if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+ {
+ p_buf->event = BTA_HF_CLIENT_API_DISABLE_EVT;
+ bta_sys_sendmsg(p_buf);
+ }
+}
+
+/*******************************************************************************
+**
+** Function BTA_HfClientRegister
+**
+** Description Register an HF Client service.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HfClientRegister(tBTA_SEC sec_mask, tBTA_HF_CLIENT_FEAT features,
+ char *p_service_name)
+{
+ tBTA_HF_CLIENT_API_REGISTER *p_buf;
+
+ if ((p_buf = (tBTA_HF_CLIENT_API_REGISTER *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_API_REGISTER))) != NULL)
+ {
+ p_buf->hdr.event = BTA_HF_CLIENT_API_REGISTER_EVT;
+ p_buf->features = features;
+ p_buf->sec_mask = sec_mask;
+ if(p_service_name)
+ {
+ BCM_STRNCPY_S(p_buf->name, BTA_SERVICE_NAME_LEN+1, p_service_name, BTA_SERVICE_NAME_LEN);
+ p_buf->name[BTA_SERVICE_NAME_LEN] = 0;
+ }
+ else
+ {
+ p_buf->name[0] = '\0';
+ }
+ bta_sys_sendmsg(p_buf);
+ }
+}
+
+/*******************************************************************************
+**
+** Function BTA_HfClientDeregister
+**
+** Description Deregister an HF Client service.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HfClientDeregister(UINT16 handle)
+{
+ BT_HDR *p_buf;
+
+ if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+ {
+ p_buf->event = BTA_HF_CLIENT_API_DEREGISTER_EVT;
+ p_buf->layer_specific = handle;
+ bta_sys_sendmsg(p_buf);
+ }
+}
+
+/*******************************************************************************
+**
+** Function BTA_HfClientOpen
+**
+** Description Opens a connection to an audio gateway.
+** When connection is open callback function is called
+** with a BTA_AG_OPEN_EVT. Only the data connection is
+** opened. The audio connection is not opened.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HfClientOpen(UINT16 handle, BD_ADDR bd_addr, tBTA_SEC sec_mask)
+{
+ tBTA_HF_CLIENT_API_OPEN *p_buf;
+
+ if ((p_buf = (tBTA_HF_CLIENT_API_OPEN *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_API_OPEN))) != NULL)
+ {
+ p_buf->hdr.event = BTA_HF_CLIENT_API_OPEN_EVT;
+ p_buf->hdr.layer_specific = handle;
+ bdcpy(p_buf->bd_addr, bd_addr);
+ p_buf->sec_mask = sec_mask;
+ bta_sys_sendmsg(p_buf);
+ }
+}
+
+/*******************************************************************************
+**
+** Function BTA_HfClientClose
+**
+** Description Close the current connection to an audio gateway.
+** Any current audio connection will also be closed
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HfClientClose(UINT16 handle)
+{
+ BT_HDR *p_buf;
+
+ if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+ {
+ p_buf->event = BTA_HF_CLIENT_API_CLOSE_EVT;
+ p_buf->layer_specific = handle;
+ bta_sys_sendmsg(p_buf);
+ }
+}
+
+/*******************************************************************************
+**
+** Function BTA_HfCllientAudioOpen
+**
+** Description Opens an audio connection to the currently connected
+** audio gateway
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HfClientAudioOpen(UINT16 handle)
+{
+ BT_HDR *p_buf;
+
+ if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+ {
+ p_buf->event = BTA_HF_CLIENT_API_AUDIO_OPEN_EVT;
+ p_buf->layer_specific = handle;
+ bta_sys_sendmsg(p_buf);
+ }
+}
+
+/*******************************************************************************
+**
+** Function BTA_HfClientAudioClose
+**
+** Description Close the currently active audio connection to an audio
+** gateway. The data connection remains open
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HfClientAudioClose(UINT16 handle)
+{
+ BT_HDR *p_buf;
+
+ if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+ {
+ p_buf->event = BTA_HF_CLIENT_API_AUDIO_CLOSE_EVT;
+ p_buf->layer_specific = handle;
+ bta_sys_sendmsg(p_buf);
+ }
+}
+
+/*******************************************************************************
+**
+** Function BTA_HfClientSendAT
+**
+** Description send AT command
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HfClientSendAT(UINT16 handle, tBTA_HF_CLIENT_AT_CMD_TYPE at, UINT32 val1, UINT32 val2, const char *str)
+{
+ tBTA_HF_CLIENT_DATA_VAL *p_buf;
+
+ if ((p_buf = (tBTA_HF_CLIENT_DATA_VAL *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_DATA_VAL))) != NULL)
+ {
+ p_buf->hdr.event = BTA_HF_CLIENT_SEND_AT_CMD_EVT;
+ p_buf->uint8_val = at;
+ p_buf->uint32_val1 = val1;
+ p_buf->uint32_val2 = val2;
+
+ if (str)
+ {
+ strlcpy(p_buf->str, str, BTA_HF_CLIENT_NUMBER_LEN + 1);
+ p_buf->str[BTA_HF_CLIENT_NUMBER_LEN] = '\0';
+ }
+ else
+ {
+ p_buf->str[0] = '\0';
+ }
+
+ p_buf->hdr.layer_specific = handle;
+ bta_sys_sendmsg(p_buf);
+ }
+}
diff --git a/bta/hf_client/bta_hf_client_at.c b/bta/hf_client/bta_hf_client_at.c
new file mode 100644
index 0000000..4f061ba
--- /dev/null
+++ b/bta/hf_client/bta_hf_client_at.c
@@ -0,0 +1,1816 @@
+/******************************************************************************
+ *
+ * Copyright (c) 2014 The Android Open Source Project
+ * Copyright (C) 2003-2012 Broadcom 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 <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include "bta_hf_client_api.h"
+#include "bta_hf_client_int.h"
+#include "port_api.h"
+
+/* Uncomment to enable AT traffic dumping */
+/* #define BTA_HF_CLIENT_AT_DUMP 1 */
+
+/* minimum length of AT event */
+#define BTA_HF_CLIENT_AT_EVENT_MIN_LEN 3
+
+/* timeout for AT response */
+#define BTA_HF_CLIENT_AT_TIMEOUT 29989
+
+/* timeout for AT hold timer */
+#define BTA_HF_CLIENT_AT_HOLD_TIMEOUT 41
+
+/******************************************************************************
+**
+** DATA TYPES AND CONTAINERS
+**
+*******************************************************************************/
+/* BRSF: store received values here */
+extern tBTA_HF_CLIENT_CB bta_hf_client_cb;
+
+/******************************************************************************
+** SUPPORTED EVENT MESSAGES
+*******************************************************************************/
+
+/* CIND: supported indicator names */
+#define BTA_HF_CLIENT_INDICATOR_BATTERYCHG "battchg"
+#define BTA_HF_CLIENT_INDICATOR_SIGNAL "signal"
+#define BTA_HF_CLIENT_INDICATOR_SERVICE "service"
+#define BTA_HF_CLIENT_INDICATOR_CALL "call"
+#define BTA_HF_CLIENT_INDICATOR_ROAM "roam"
+#define BTA_HF_CLIENT_INDICATOR_CALLSETUP "callsetup"
+#define BTA_HF_CLIENT_INDICATOR_CALLHELD "callheld"
+
+/* CIND: represents each indicators boundaries */
+typedef struct
+{
+ char* name;
+ UINT8 min;
+ UINT8 max;
+ UINT8 namelen;
+} tBTA_HF_CLIENT_INDICATOR;
+
+#define BTA_HF_CLIENT_AT_SUPPORTED_INDICATOR_COUNT 7
+
+/* CIND: storage room for indicators value range and their statuses */
+static const tBTA_HF_CLIENT_INDICATOR bta_hf_client_indicators[BTA_HF_CLIENT_AT_SUPPORTED_INDICATOR_COUNT] =
+{
+ /* name | min | max | name length - used by parser */
+ {BTA_HF_CLIENT_INDICATOR_BATTERYCHG, 0, 5, sizeof(BTA_HF_CLIENT_INDICATOR_BATTERYCHG)},
+ {BTA_HF_CLIENT_INDICATOR_SIGNAL, 0, 5, sizeof(BTA_HF_CLIENT_INDICATOR_SIGNAL)},
+ {BTA_HF_CLIENT_INDICATOR_SERVICE, 0, 1, sizeof(BTA_HF_CLIENT_INDICATOR_SERVICE)},
+ {BTA_HF_CLIENT_INDICATOR_CALL, 0, 1, sizeof(BTA_HF_CLIENT_INDICATOR_CALL)},
+ {BTA_HF_CLIENT_INDICATOR_ROAM, 0, 1, sizeof(BTA_HF_CLIENT_INDICATOR_ROAM)},
+ {BTA_HF_CLIENT_INDICATOR_CALLSETUP, 0, 3, sizeof(BTA_HF_CLIENT_INDICATOR_CALLSETUP)},
+ {BTA_HF_CLIENT_INDICATOR_CALLHELD, 0, 2, sizeof(BTA_HF_CLIENT_INDICATOR_CALLHELD)}
+};
+
+/* +VGM/+VGS - gain min/max values */
+#define BTA_HF_CLIENT_VGS_MIN 0
+#define BTA_HF_CLIENT_VGS_MAX 15
+#define BTA_HF_CLIENT_VGM_MIN 0
+#define BTA_HF_CLIENT_VGM_MAX 15
+
+UINT32 service_index = 0;
+BOOLEAN service_availability = TRUE;
+/* helper functions for handling AT commands queueing */
+
+static void bta_hf_client_clear_queued_at(void)
+{
+ tBTA_HF_CLIENT_AT_QCMD *cur = bta_hf_client_cb.scb.at_cb.queued_cmd;
+ tBTA_HF_CLIENT_AT_QCMD *next;
+
+ while (cur != NULL) {
+ next = cur->next;
+ GKI_freebuf(cur);
+ cur = next;
+ }
+
+ bta_hf_client_cb.scb.at_cb.queued_cmd = NULL;
+}
+
+static void bta_hf_client_queue_at(tBTA_HF_CLIENT_AT_CMD cmd, const char *buf, UINT16 buf_len)
+{
+ tBTA_HF_CLIENT_AT_QCMD *new_cmd;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if ((new_cmd = (tBTA_HF_CLIENT_AT_QCMD *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_AT_QCMD))) != NULL)
+ {
+ new_cmd->cmd = cmd;
+ new_cmd->buf_len = buf_len;
+ new_cmd->next = NULL;
+ memcpy(new_cmd->buf, buf, buf_len);
+
+ if (bta_hf_client_cb.scb.at_cb.queued_cmd != NULL)
+ {
+ tBTA_HF_CLIENT_AT_QCMD *qcmd = bta_hf_client_cb.scb.at_cb.queued_cmd;
+
+ while (qcmd->next != NULL)
+ qcmd = qcmd->next;
+
+ qcmd->next = new_cmd;
+ }
+ else
+ {
+ bta_hf_client_cb.scb.at_cb.queued_cmd = new_cmd;
+ }
+ }
+}
+
+static void bta_hf_client_at_resp_timer_cback (TIMER_LIST_ENT *p_tle)
+{
+ if (p_tle)
+ {
+ bta_hf_client_cb.scb.at_cb.resp_timer_on = FALSE;
+
+ APPL_TRACE_ERROR0("HFPClient: AT response timeout, disconnecting");
+
+ bta_hf_client_sm_execute(BTA_HF_CLIENT_API_CLOSE_EVT, NULL);
+ }
+}
+
+static void bta_hf_client_stop_at_resp_timer(void)
+{
+ if (bta_hf_client_cb.scb.at_cb.resp_timer_on)
+ {
+ bta_hf_client_cb.scb.at_cb.resp_timer_on = FALSE;
+ bta_sys_stop_timer (&bta_hf_client_cb.scb.at_cb.resp_timer);
+ }
+}
+
+static void bta_hf_client_start_at_resp_timer(void)
+{
+ if (bta_hf_client_cb.scb.at_cb.resp_timer_on)
+ {
+ bta_sys_stop_timer (&bta_hf_client_cb.scb.at_cb.resp_timer);
+ }
+
+ bta_hf_client_cb.scb.at_cb.resp_timer.p_cback = (TIMER_CBACK*)&bta_hf_client_at_resp_timer_cback;
+ bta_sys_start_timer(&bta_hf_client_cb.scb.at_cb.resp_timer, 0, BTA_HF_CLIENT_AT_TIMEOUT);
+ bta_hf_client_cb.scb.at_cb.resp_timer_on = TRUE;
+}
+
+static void bta_hf_client_send_at(tBTA_HF_CLIENT_AT_CMD cmd, char *buf, UINT16 buf_len)
+{
+ if ((bta_hf_client_cb.scb.at_cb.current_cmd == BTA_HF_CLIENT_AT_NONE ||
+ bta_hf_client_cb.scb.svc_conn == FALSE) &&
+ bta_hf_client_cb.scb.at_cb.hold_timer_on == FALSE)
+ {
+ UINT16 len;
+
+#ifdef BTA_HF_CLIENT_AT_DUMP
+ APPL_TRACE_DEBUG3("%s %.*s", __FUNCTION__, buf_len - 1, buf);
+#endif
+
+ bta_hf_client_cb.scb.at_cb.current_cmd = cmd;
+ PORT_WriteData(bta_hf_client_cb.scb.conn_handle, buf, buf_len, &len);
+
+ bta_hf_client_start_at_resp_timer();
+
+ return;
+ }
+
+ bta_hf_client_queue_at(cmd, buf, buf_len);
+}
+
+static void bta_hf_client_send_queued_at(void)
+{
+ tBTA_HF_CLIENT_AT_QCMD *cur = bta_hf_client_cb.scb.at_cb.queued_cmd;
+ tBTA_HF_CLIENT_AT_QCMD *next;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (cur != NULL)
+ {
+ next = cur->next;
+
+ bta_hf_client_send_at(cur->cmd, cur->buf, cur->buf_len);
+
+ GKI_freebuf(cur);
+
+ bta_hf_client_cb.scb.at_cb.queued_cmd = next;
+ }
+}
+
+static void bta_hf_client_at_hold_timer_cback(TIMER_LIST_ENT *p_tle)
+{
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (p_tle)
+ {
+ bta_hf_client_cb.scb.at_cb.hold_timer_on = FALSE;
+ bta_hf_client_send_queued_at();
+ }
+}
+
+static void bta_hf_client_stop_at_hold_timer(void)
+{
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (bta_hf_client_cb.scb.at_cb.hold_timer_on)
+ {
+ bta_hf_client_cb.scb.at_cb.hold_timer_on = FALSE;
+ bta_sys_stop_timer (&bta_hf_client_cb.scb.at_cb.hold_timer);
+ }
+}
+
+static void bta_hf_client_start_at_hold_timer(void)
+{
+ TIMER_LIST_ENT *timer = &bta_hf_client_cb.scb.at_cb.hold_timer;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (bta_hf_client_cb.scb.at_cb.hold_timer_on)
+ {
+ bta_sys_stop_timer (timer);
+ }
+
+ timer->p_cback = (TIMER_CBACK*)&bta_hf_client_at_hold_timer_cback;
+ bta_sys_start_timer(timer, 0, BTA_HF_CLIENT_AT_HOLD_TIMEOUT);
+ bta_hf_client_cb.scb.at_cb.hold_timer_on = TRUE;
+}
+
+/******************************************************************************
+**
+** COMMON AT EVENT HANDLING FUNCTIONS
+**
+** Receives data (strings, ints, etc.) from the parser and processes this data.
+** No buffer parsing is being done here.
+*******************************************************************************/
+
+static void bta_hf_client_handle_ok()
+{
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ bta_hf_client_stop_at_resp_timer();
+
+ if (!bta_hf_client_cb.scb.svc_conn)
+ {
+ bta_hf_client_slc_seq(FALSE);
+ return;
+ }
+
+ switch(bta_hf_client_cb.scb.at_cb.current_cmd)
+ {
+ case BTA_HF_CLIENT_AT_BIA:
+ case BTA_HF_CLIENT_AT_BCC:
+ break;
+ case BTA_HF_CLIENT_AT_BCS:
+ bta_hf_client_start_at_hold_timer();
+ bta_hf_client_cb.scb.at_cb.current_cmd = BTA_HF_CLIENT_AT_NONE;
+ return;
+ case BTA_HF_CLIENT_AT_CLIP: //last cmd is post slc seq
+ if (bta_hf_client_cb.scb.send_at_reply == FALSE)
+ {
+ bta_hf_client_cb.scb.send_at_reply = TRUE;
+ }
+ break;
+ case BTA_HF_CLIENT_AT_NONE:
+ bta_hf_client_stop_at_hold_timer();
+ break;
+ default:
+ if (bta_hf_client_cb.scb.send_at_reply)
+ {
+ bta_hf_client_at_result(BTA_HF_CLIENT_AT_RESULT_OK, 0);
+ }
+ break;
+ }
+
+ bta_hf_client_cb.scb.at_cb.current_cmd = BTA_HF_CLIENT_AT_NONE;
+
+ bta_hf_client_send_queued_at();
+}
+
+static void bta_hf_client_handle_error(tBTA_HF_CLIENT_AT_RESULT_TYPE type, UINT16 cme)
+{
+ APPL_TRACE_DEBUG3("%s %u %u", __FUNCTION__, type, cme);
+
+ bta_hf_client_stop_at_resp_timer();
+
+ if (!bta_hf_client_cb.scb.svc_conn)
+ {
+ bta_hf_client_slc_seq(TRUE);
+ return;
+ }
+
+ switch(bta_hf_client_cb.scb.at_cb.current_cmd)
+ {
+ case BTA_HF_CLIENT_AT_BIA:
+ break;
+ case BTA_HF_CLIENT_AT_BCC:
+ case BTA_HF_CLIENT_AT_BCS:
+ bta_hf_client_cback_sco(BTA_HF_CLIENT_AUDIO_CLOSE_EVT);
+ break;
+ case BTA_HF_CLIENT_AT_CLIP: //last cmd is post slc seq
+ if (bta_hf_client_cb.scb.send_at_reply == FALSE)
+ {
+ bta_hf_client_cb.scb.send_at_reply = TRUE;
+ }
+ break;
+ default:
+ if (bta_hf_client_cb.scb.send_at_reply)
+ {
+ bta_hf_client_at_result(type, cme);
+ }
+ break;
+ }
+
+ bta_hf_client_cb.scb.at_cb.current_cmd = BTA_HF_CLIENT_AT_NONE;
+
+ bta_hf_client_send_queued_at();
+}
+
+static void bta_hf_client_handle_ring()
+{
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+ bta_hf_client_evt_val(BTA_HF_CLIENT_RING_INDICATION,0);
+}
+
+static void bta_hf_client_handle_brsf(UINT32 value)
+{
+ APPL_TRACE_DEBUG2("%s 0x%x", __FUNCTION__, value);
+ bta_hf_client_cb.scb.peer_features = value;
+}
+
+/* handles a single indicator descriptor - registers it for value changing events */
+static void bta_hf_client_handle_cind_list_item(char *name, UINT32 min, UINT32 max, UINT32 index)
+{
+
+ UINT8 i = 0;
+
+ APPL_TRACE_DEBUG5("%s %lu.%s <%lu:%lu>", __FUNCTION__, index, name, min, max);
+
+ /* look for a matching indicator on list of supported ones */
+ for(i = 0; i < BTA_HF_CLIENT_AT_SUPPORTED_INDICATOR_COUNT; i++)
+ {
+ if (strcmp(name,BTA_HF_CLIENT_INDICATOR_SERVICE) == 0)
+ {
+ service_index = index;
+ }
+ /* look for a match - search one sign further than indicators name to check for string end */
+ /* It will distinguish 'callheld' which could be matched by strncmp as 'call'. */
+ if (strncmp(name, bta_hf_client_indicators[i].name, bta_hf_client_indicators[i].namelen) != 0)
+ continue;
+
+ /* index - enumerates value position in the incoming sequence */
+ /* if name matches one of the known indicators, add its incoming position */
+ /* to lookup table for easy value->indicator matching later, when only values come */
+ bta_hf_client_cb.scb.at_cb.indicator_lookup[index] = i;
+
+ return;
+ }
+}
+
+static void bta_hf_client_handle_cind_value(UINT32 index, UINT32 value)
+{
+ APPL_TRACE_DEBUG3("%s index: %u value: %u", __FUNCTION__, index, value);
+
+ if (index >= BTA_HF_CLIENT_AT_INDICATOR_COUNT)
+ {
+ return;
+ }
+
+ if (service_index == index)
+ {
+ if (value == 0)
+ {
+ service_availability = FALSE;
+ }
+ else
+ {
+ service_availability = TRUE;
+ }
+ }
+ if (bta_hf_client_cb.scb.at_cb.indicator_lookup[index] == -1)
+ {
+ return;
+ }
+
+ /* get the real array index from lookup table */
+ index = bta_hf_client_cb.scb.at_cb.indicator_lookup[index];
+
+ /* Ignore out of range values */
+ if(value > bta_hf_client_indicators[index].max ||
+ value < bta_hf_client_indicators[index].min)
+ {
+ return;
+ }
+
+ /* tBTA_HF_CLIENT_IND_TYPE match index in bta_hf_client_indicators */
+ bta_hf_client_ind(index, value);
+}
+
+static void bta_hf_client_handle_chld(UINT32 mask)
+{
+ APPL_TRACE_DEBUG2("%s 0x%x", __FUNCTION__, mask);
+
+ bta_hf_client_cb.scb.chld_features |= mask;
+}
+
+static void bta_hf_client_handle_ciev(UINT32 index, UINT32 value)
+{
+ INT8 realind = -1;
+
+ APPL_TRACE_DEBUG3("%s index: %u value: %u", __FUNCTION__, index, value);
+
+ if(index == 0 || index >= BTA_HF_CLIENT_AT_INDICATOR_COUNT)
+ {
+ return;
+ }
+
+ realind = bta_hf_client_cb.scb.at_cb.indicator_lookup[index - 1];
+
+ if(realind >= 0 && realind < BTA_HF_CLIENT_AT_SUPPORTED_INDICATOR_COUNT)
+ {
+ /* get the real in-array index from lookup table by index it comes at */
+ /* if there is no bug it should automatically be correctly calculated */
+ if(value > bta_hf_client_indicators[realind].max || value < bta_hf_client_indicators[realind].min)
+ {
+ return;
+ }
+
+ /* tBTA_HF_CLIENT_IND_TYPE match index in bta_hf_client_indicators */
+ bta_hf_client_ind(realind, value);
+ }
+}
+
+static void bta_hf_client_handle_bcs(UINT32 codec)
+{
+ APPL_TRACE_DEBUG2("%s %u", __FUNCTION__, codec);
+
+ if (codec == BTM_SCO_CODEC_CVSD ||
+ (codec == BTM_SCO_CODEC_MSBC && bta_hf_client_cb.msbc_enabled == TRUE))
+ {
+ bta_hf_client_cb.scb.negotiated_codec = codec;
+ bta_hf_client_send_at_bcs(codec);
+ }
+ else
+ {
+ bta_hf_client_cb.scb.negotiated_codec = BTM_SCO_CODEC_CVSD;
+ bta_hf_client_send_at_bac();
+ }
+}
+
+static void bta_hf_client_handle_bsir(UINT32 provided)
+{
+ APPL_TRACE_DEBUG2("%s %u", __FUNCTION__, provided);
+
+ bta_hf_client_evt_val(BTA_HF_CLIENT_BSIR_EVT, provided);
+}
+
+static void bta_hf_client_handle_cmeerror(UINT32 code)
+{
+ bta_hf_client_handle_error(BTA_HF_CLIENT_AT_RESULT_CME, code);
+}
+
+static void bta_hf_client_handle_vgm(UINT32 value)
+{
+ APPL_TRACE_DEBUG2("%s %lu", __FUNCTION__, value);
+
+ if(value <= BTA_HF_CLIENT_VGM_MAX)
+ {
+ bta_hf_client_evt_val(BTA_HF_CLIENT_MIC_EVT, value);
+ }
+}
+
+static void bta_hf_client_handle_vgs(UINT32 value)
+{
+ APPL_TRACE_DEBUG2("%s %lu", __FUNCTION__, value);
+
+ if(value <= BTA_HF_CLIENT_VGS_MAX)
+ {
+ bta_hf_client_evt_val(BTA_HF_CLIENT_SPK_EVT, value);
+ }
+}
+
+static void bta_hf_client_handle_bvra(UINT32 value)
+{
+ APPL_TRACE_DEBUG2("%s %lu", __FUNCTION__, value);
+
+ if (value > 1)
+ {
+ return;
+ }
+
+ bta_hf_client_evt_val(BTA_HF_CLIENT_VOICE_REC_EVT, value);
+}
+
+static void bta_hf_client_handle_clip(char *numstr, UINT32 type)
+{
+ APPL_TRACE_DEBUG3("%s %u %s", __FUNCTION__, type, numstr);
+
+ bta_hf_client_clip(numstr);
+}
+
+static void bta_hf_client_handle_ccwa(char *numstr, UINT32 type)
+{
+ APPL_TRACE_DEBUG3("%s %u %s", __FUNCTION__, type, numstr);
+
+ bta_hf_client_ccwa(numstr);
+}
+
+static void bta_hf_client_handle_cops(char *opstr, UINT32 mode)
+{
+ APPL_TRACE_DEBUG3("%s %u %s", __FUNCTION__, mode, opstr);
+
+ bta_hf_client_operator_name(opstr);
+}
+
+static void bta_hf_client_handle_binp(char *numstr)
+{
+ APPL_TRACE_DEBUG2("%s %s", __FUNCTION__, numstr);
+
+ bta_hf_client_binp(numstr);
+}
+
+static void bta_hf_client_handle_clcc(UINT16 idx, UINT16 dir, UINT16 status, UINT16 mode, UINT16 mpty, char *numstr, UINT16 type)
+{
+ APPL_TRACE_DEBUG6("%s idx: %u dir: %u status: %u mode: %u mpty: %u",
+ __FUNCTION__, idx, dir, status, mode, mpty);
+
+ if (numstr)
+ {
+ APPL_TRACE_DEBUG3("%s number: %s type: %u", __FUNCTION__, numstr, type);
+ }
+
+ bta_hf_client_clcc(idx, dir, status, mpty, numstr);
+}
+
+static void bta_hf_client_handle_cnum( char *numstr, UINT16 type, UINT16 service)
+{
+ APPL_TRACE_DEBUG4("%s number: %s type: %u service: %u", __FUNCTION__, numstr, type, service);
+
+ /* TODO: should number be modified according to type? */
+ bta_hf_client_cnum(numstr, service);
+}
+
+static void bta_hf_client_handle_btrh( UINT16 code)
+{
+ APPL_TRACE_DEBUG2("%s %lu", __FUNCTION__, code);
+
+ bta_hf_client_evt_val(BTA_HF_CLIENT_BTRH_EVT, code);
+}
+
+/******************************************************************************
+**
+** COMMON AT EVENTS PARSING FUNCTIONS
+**
+*******************************************************************************/
+
+/* Check if prefix match and skip spaces if any */
+#define AT_CHECK_EVENT(buf, event) \
+ if (strncmp("\r\n"event, buf,sizeof("\r\n"event) - 1) != 0) return buf; \
+ buf += sizeof("\r\n"event) - 1; \
+ while (*buf == ' ') buf++;
+
+/* check for <cr><lf> and forward buffer if match */
+#define AT_CHECK_RN(buf) \
+ if (strncmp("\r\n", buf, sizeof("\r\n") - 1) != 0) { \
+ APPL_TRACE_DEBUG1("%s missing end <cr><lf>", __FUNCTION__); \
+ return NULL;} \
+ buf += sizeof("\r\n") - 1;
+
+/* skip rest of AT string up to <cr> */
+#define AT_SKIP_REST(buf) while(*buf != '\r') buf++;
+
+static char *bta_hf_client_parse_ok(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "OK");
+ AT_CHECK_RN(buffer);
+
+ bta_hf_client_handle_ok();
+
+ return buffer;
+}
+
+static char *bta_hf_client_parse_error(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "ERROR");
+ AT_CHECK_RN(buffer);
+
+ bta_hf_client_handle_error(BTA_HF_CLIENT_AT_RESULT_ERROR, 0);
+
+ return buffer;
+}
+
+static char *bta_hf_client_parse_ring(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "RING");
+ AT_CHECK_RN(buffer);
+
+ bta_hf_client_handle_ring();
+
+ return buffer;
+}
+
+/* generic uint32 parser */
+static char *bta_hf_client_parse_uint32(char *buffer, void (*handler_callback)(UINT32))
+{
+ UINT32 value;
+ int res;
+ int offset;
+
+ res = sscanf(buffer, "%u%n", &value, &offset);
+ if (res < 1)
+ {
+ return NULL;
+ }
+
+ buffer += offset;
+
+ AT_CHECK_RN(buffer);
+
+ handler_callback(value);
+ return buffer;
+}
+
+static char *bta_hf_client_parse_brsf(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "+BRSF:");
+
+ return bta_hf_client_parse_uint32(buffer, bta_hf_client_handle_brsf);
+}
+
+static char *bta_hf_client_parse_cind_values(char *buffer)
+{
+ /* value and its position */
+ UINT16 index = 0;
+ UINT32 value = 0;
+
+ int offset;
+ int res;
+
+ while((res = sscanf(buffer, "%u%n", &value, &offset)) > 0)
+ {
+ /* decides if its valid index and value, if yes stores it */
+ bta_hf_client_handle_cind_value(index, value);
+
+ buffer += offset;
+
+ /* check if more values are present */
+ if (*buffer != ',')
+ {
+ break;
+ }
+
+ index++;
+ buffer++;
+ }
+
+ if (res > 0)
+ {
+ AT_CHECK_RN(buffer);
+ return buffer;
+ }
+
+ return NULL;
+}
+
+static char *bta_hf_client_parse_cind_list(char *buffer)
+{
+ int offset;
+ char name[129];
+ UINT32 min, max;
+ UINT32 index = 0;
+ int res;
+
+ while ((res = sscanf(buffer, "(\"%128[^\"]\",(%u%*[-,]%u))%n", name, &min, &max, &offset)) > 2)
+ {
+ bta_hf_client_handle_cind_list_item(name, min, max, index);
+ buffer += offset;
+ index++;
+
+ if (*buffer != ',')
+ {
+ break;
+ }
+
+ buffer++;
+ }
+
+ if (res > 2)
+ {
+ AT_CHECK_RN(buffer);
+ return buffer;
+ }
+
+ return NULL;
+}
+
+static char *bta_hf_client_parse_cind(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "+CIND:");
+
+ if(*buffer == '(')
+ return bta_hf_client_parse_cind_list(buffer);
+
+ return bta_hf_client_parse_cind_values(buffer);
+}
+
+static char *bta_hf_client_parse_chld(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "+CHLD:");
+
+ if (*buffer != '(')
+ {
+ return NULL;
+ }
+
+ buffer++;
+
+ while(*buffer != '\0')
+ {
+ if(strncmp("0",buffer, 1) == 0)
+ {
+ bta_hf_client_handle_chld(BTA_HF_CLIENT_CHLD_REL);
+ buffer++;
+ }
+ else if(strncmp("1x",buffer, 2) == 0)
+ {
+ bta_hf_client_handle_chld(BTA_HF_CLIENT_CHLD_REL_X);
+ buffer += 2;
+ }
+ else if(strncmp("1",buffer, 1) == 0)
+ {
+ bta_hf_client_handle_chld(BTA_HF_CLIENT_CHLD_REL_ACC);
+ buffer++;
+ }
+ else if(strncmp("2x",buffer, 2) == 0)
+ {
+ bta_hf_client_handle_chld(BTA_HF_CLIENT_CHLD_PRIV_X);
+ buffer += 2;
+ }
+ else if(strncmp("2",buffer, 1) == 0)
+ {
+ bta_hf_client_handle_chld(BTA_HF_CLIENT_CHLD_HOLD_ACC);
+ buffer++;
+ }
+ else if(strncmp("3",buffer, 1) == 0)
+ {
+ bta_hf_client_handle_chld(BTA_HF_CLIENT_CHLD_MERGE);
+ buffer++;
+ }
+ else if(strncmp("4",buffer, 1) == 0)
+ {
+ bta_hf_client_handle_chld(BTA_HF_CLIENT_CHLD_MERGE_DETACH);
+ buffer++;
+ }
+ else
+ {
+ return NULL;
+ }
+
+ if (*buffer == ',')
+ {
+ buffer++;
+ continue;
+ }
+
+ if (*buffer == ')')
+ {
+ buffer++;
+ break;
+ }
+
+ return NULL;
+ }
+
+ AT_CHECK_RN(buffer);
+
+ return buffer;
+}
+
+static char *bta_hf_client_parse_ciev(char *buffer)
+{
+ UINT32 index, value;
+ int res;
+ int offset;
+
+ AT_CHECK_EVENT(buffer, "+CIEV:");
+
+ res = sscanf(buffer, "%u,%u%n", &index, &value, &offset);
+ if(res < 2)
+ {
+ return NULL;
+ }
+
+ buffer += offset;
+
+ AT_CHECK_RN(buffer);
+
+ bta_hf_client_handle_ciev(index, value);
+ return buffer;
+}
+
+static char *bta_hf_client_parse_bcs(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "+BCS:");
+
+ return bta_hf_client_parse_uint32(buffer, bta_hf_client_handle_bcs);
+}
+
+static char *bta_hf_client_parse_bsir(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "+BSIR:");
+
+ return bta_hf_client_parse_uint32(buffer, bta_hf_client_handle_bsir);
+}
+
+static char *bta_hf_client_parse_cmeerror(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "+CME ERROR:");
+
+ return bta_hf_client_parse_uint32(buffer, bta_hf_client_handle_cmeerror);
+}
+
+static char *bta_hf_client_parse_vgm(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "+VGM:");
+
+ return bta_hf_client_parse_uint32(buffer, bta_hf_client_handle_vgm);
+}
+
+static char *bta_hf_client_parse_vgme(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "+VGM=");
+
+ return bta_hf_client_parse_uint32(buffer, bta_hf_client_handle_vgm);
+}
+
+static char *bta_hf_client_parse_vgs(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "+VGS:");
+
+ return bta_hf_client_parse_uint32(buffer, bta_hf_client_handle_vgs);
+}
+
+static char *bta_hf_client_parse_vgse(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "+VGS=");
+
+ return bta_hf_client_parse_uint32(buffer, bta_hf_client_handle_vgs);
+}
+
+static char *bta_hf_client_parse_bvra(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "+BVRA:");
+
+ return bta_hf_client_parse_uint32(buffer, bta_hf_client_handle_bvra);
+}
+
+static char *bta_hf_client_parse_clip(char *buffer)
+{
+ /* spec forces 32 chars, plus \0 here */
+ char number[33];
+ UINT32 type = 0;
+ int res;
+ int offset;
+
+ AT_CHECK_EVENT(buffer, "+CLIP:");
+
+ /* there might be something more after %lu but HFP doesn't care */
+ res = sscanf(buffer, "\"%32[^\"]\",%u%n", number, &type, &offset);
+ if(res < 2)
+ {
+ return NULL;
+ }
+
+ buffer += offset;
+
+ AT_SKIP_REST(buffer);
+
+ AT_CHECK_RN(buffer);
+
+ bta_hf_client_handle_clip(number, type);
+ return buffer;
+}
+
+/* in HFP context there is no difference between ccwa and clip */
+static char *bta_hf_client_parse_ccwa(char *buffer)
+{
+ /* ac to spec 32 chars max, plus \0 here */
+ char number[33];
+ UINT32 type = 0;
+ int res ;
+ int offset;
+
+ AT_CHECK_EVENT(buffer, "+CCWA:");
+
+ /* there might be something more after %lu but HFP doesn't care */
+ res = sscanf(buffer, "\"%32[^\"]\",%u%n", number, &type, &offset);
+ if(res < 2)
+ {
+ return NULL;
+ }
+
+ buffer += offset;
+
+ AT_SKIP_REST(buffer);
+
+ AT_CHECK_RN(buffer);
+
+ bta_hf_client_handle_ccwa(number, type);
+ return buffer;
+}
+
+static char *bta_hf_client_parse_cops(char *buffer)
+{
+ UINT8 mode;
+ /* spec forces 16 chars max, plus \0 here */
+ char opstr[17];
+ int res;
+ int offset;
+
+ AT_CHECK_EVENT(buffer, "+COPS:");
+
+ /* TODO: Not sure if operator string actually can contain escaped " char inside */
+ res = sscanf(buffer, "%hhi,0,\"%16[^\"]\"%n", &mode, opstr, &offset);
+ if(res < 2)
+ {
+ return NULL;
+ }
+
+ buffer += offset;
+
+ AT_SKIP_REST(buffer);
+
+ AT_CHECK_RN(buffer);
+
+ bta_hf_client_handle_cops(opstr, mode);
+ return buffer;
+}
+
+static char *bta_hf_client_parse_binp(char *buffer)
+{
+ /* HFP only supports phone number as BINP data */
+ /* phone number is 32 chars plus one for \0*/
+ char numstr[33];
+ int res;
+ int offset;
+
+ AT_CHECK_EVENT(buffer, "+BINP:");
+
+ res = sscanf(buffer, "\"%32[^\"]\"\r\n%n", numstr, &offset);
+ if(res < 1)
+ {
+ return NULL;
+ }
+
+ buffer += offset;
+
+ /* some phones might sent type as well, just skip it */
+ AT_SKIP_REST(buffer);
+
+ AT_CHECK_RN(buffer);
+
+ bta_hf_client_handle_binp(numstr);
+ return buffer;
+}
+
+static char *bta_hf_client_parse_clcc(char *buffer)
+{
+ UINT16 idx, dir, status, mode, mpty;
+ char numstr[33]; /* spec forces 32 chars, plus one for \0*/
+ UINT16 type;
+ int res;
+ int offset;
+
+ AT_CHECK_EVENT(buffer, "+CLCC:");
+
+ res = sscanf(buffer, "%hu,%hu,%hu,%hu,%hu%n",
+ &idx, &dir, &status, &mode, &mpty, &offset);
+ if (res < 5)
+ {
+ return NULL;
+ }
+
+ buffer += offset;
+
+ /* check optional part */
+ if (*buffer == ',')
+ {
+ int res2;
+
+ res2 = sscanf(buffer, ",\"%32[^\"]\",%hu%n", numstr, &type, &offset);
+ if (res2 < 0)
+ {
+ return NULL;
+ }
+
+ if (res2 == 0)
+ {
+ res2 = sscanf(buffer, ",\"\",%hu%n", &type, &offset);
+ if (res < 0)
+ {
+ return NULL;
+ }
+
+ /* numstr is not matched in second attempt, correct this */
+ res2++;
+ numstr[0] = '\0';
+ }
+
+ if (res2 < 2)
+ {
+ return NULL;
+ }
+
+ res += res2;
+ buffer += offset;
+ }
+
+ AT_CHECK_RN(buffer);
+
+ if(res > 6)
+ {
+ /* we also have last two optional parameters */
+ bta_hf_client_handle_clcc(idx, dir, status, mode, mpty, numstr, type);
+ }
+ else
+ {
+ /* we didn't get the last two parameters */
+ bta_hf_client_handle_clcc(idx, dir, status, mode, mpty, NULL, 0);
+ }
+
+ return buffer;
+}
+
+static char *bta_hf_client_parse_cnum(char *buffer)
+{
+ char numstr[33]; /* spec forces 32 chars, plus one for \0*/
+ UINT16 type;
+ UINT16 service = 0; /* 0 in case this optional parameter is not being sent */
+ int res;
+ int offset;
+
+ AT_CHECK_EVENT(buffer, "+CNUM:");
+
+ res = sscanf(buffer, ",\"%32[^\"]\",%hu,,%hu%n", numstr, &type, &service, &offset);
+ if(res < 0)
+ {
+ return NULL;
+ }
+
+ if (res == 0)
+ {
+ res = sscanf(buffer, ",\"\",%hu,,%hu%n", &type, &service, &offset);
+ if (res < 0)
+ {
+ return NULL;
+ }
+
+ /* numstr is not matched in second attempt, correct this */
+ res++;
+ numstr[0] = '\0';
+ }
+
+ if (res < 3)
+ {
+ return NULL;
+ }
+
+ buffer += offset;
+
+ AT_CHECK_RN(buffer);
+
+ /* service is optional */
+ if(res == 2)
+ {
+ bta_hf_client_handle_cnum(numstr, type, service);
+ return buffer;
+ }
+
+ if (service != 4 && service != 5)
+ {
+ return NULL;
+ }
+
+ bta_hf_client_handle_cnum(numstr, type, service);
+ return buffer;
+}
+
+static char *bta_hf_client_parse_btrh(char *buffer)
+{
+ UINT16 code = 0;
+ int res;
+ int offset;
+
+ AT_CHECK_EVENT(buffer, "+BTRH:");
+
+ res = sscanf(buffer, "%hu%n", &code, &offset);
+ if(res < 1)
+ {
+ return NULL;
+ }
+
+ buffer += offset;
+
+ AT_CHECK_RN(buffer);
+
+ bta_hf_client_handle_btrh(code);
+ return buffer;
+}
+
+static char *bta_hf_client_parse_busy(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "BUSY");
+ AT_CHECK_RN(buffer);
+
+ bta_hf_client_handle_error(BTA_HF_CLIENT_AT_RESULT_BUSY, 0);
+
+ return buffer;
+}
+
+static char *bta_hf_client_parse_delayed(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "DELAYED");
+ AT_CHECK_RN(buffer);
+
+ bta_hf_client_handle_error(BTA_HF_CLIENT_AT_RESULT_DELAY, 0);
+
+ return buffer;
+}
+
+static char *bta_hf_client_parse_no_carrier(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "NO CARRIER");
+ AT_CHECK_RN(buffer);
+
+ bta_hf_client_handle_error(BTA_HF_CLIENT_AT_RESULT_NO_CARRIER, 0);
+
+ return buffer;
+}
+
+static char *bta_hf_client_parse_no_answer(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "NO ANSWER");
+ AT_CHECK_RN(buffer);
+
+ bta_hf_client_handle_error(BTA_HF_CLIENT_AT_RESULT_NO_ANSWER, 0);
+
+ return buffer;
+}
+
+static char *bta_hf_client_parse_blacklisted(char *buffer)
+{
+ AT_CHECK_EVENT(buffer, "BLACKLISTED");
+ AT_CHECK_RN(buffer);
+
+ bta_hf_client_handle_error(BTA_HF_CLIENT_AT_RESULT_BLACKLISTED, 0);
+
+ return buffer;
+}
+
+static char *bta_hf_client_skip_unknown(char *buffer)
+{
+ char *start;
+ char *tmp;
+
+ tmp = strstr(buffer, "\r\n");
+ if (tmp == NULL)
+ {
+ return NULL;
+ }
+
+ buffer += 2;
+ start = buffer;
+
+ tmp = strstr(buffer, "\r\n");
+ if (tmp == NULL)
+ {
+ return NULL;
+ }
+
+ buffer = tmp + 2;
+
+ APPL_TRACE_DEBUG3("%s %.*s", __FUNCTION__, buffer - start - 2, start);
+
+ return buffer;
+}
+
+
+/******************************************************************************
+** SUPPORTED EVENT MESSAGES
+*******************************************************************************/
+
+/* returned values are as follow:
+ * != NULL && != buf : match and parsed ok
+ * == NULL : match but parse failed
+ * != NULL && == buf : no match
+ */
+typedef char* (*tBTA_HF_CLIENT_PARSER_CALLBACK)(char*);
+
+static const tBTA_HF_CLIENT_PARSER_CALLBACK bta_hf_client_parser_cb[] =
+{
+ bta_hf_client_parse_ok,
+ bta_hf_client_parse_error,
+ bta_hf_client_parse_ring,
+ bta_hf_client_parse_brsf,
+ bta_hf_client_parse_cind,
+ bta_hf_client_parse_ciev,
+ bta_hf_client_parse_chld,
+ bta_hf_client_parse_bcs,
+ bta_hf_client_parse_bsir,
+ bta_hf_client_parse_cmeerror,
+ bta_hf_client_parse_vgm,
+ bta_hf_client_parse_vgme,
+ bta_hf_client_parse_vgs,
+ bta_hf_client_parse_vgse,
+ bta_hf_client_parse_bvra,
+ bta_hf_client_parse_clip,
+ bta_hf_client_parse_ccwa,
+ bta_hf_client_parse_cops,
+ bta_hf_client_parse_binp,
+ bta_hf_client_parse_clcc,
+ bta_hf_client_parse_cnum,
+ bta_hf_client_parse_btrh,
+ bta_hf_client_parse_busy,
+ bta_hf_client_parse_delayed,
+ bta_hf_client_parse_no_carrier,
+ bta_hf_client_parse_no_answer,
+ bta_hf_client_parse_blacklisted,
+ bta_hf_client_skip_unknown
+};
+
+/* calculate supported event list length */
+static const UINT16 bta_hf_client_psraser_cb_count =
+ sizeof(bta_hf_client_parser_cb) / sizeof(bta_hf_client_parser_cb[0]);
+
+#ifdef BTA_HF_CLIENT_AT_DUMP
+static void bta_hf_client_dump_at(void)
+{
+ char dump[(4 * BTA_HF_CLIENT_AT_PARSER_MAX_LEN) + 1];
+ char *p1, *p2;
+
+ p1 = bta_hf_client_cb.scb.at_cb.buf;
+ p2 = dump;
+
+ while (*p1 != '\0')
+ {
+ if (*p1 == '\r')
+ {
+ strlcpy(p2, "<cr>", 4);
+ p2 += 4;
+ }
+ else if (*p1 == '\n')
+ {
+ strlcpy(p2, "<lf>", 4);
+ p2 += 4;
+ }
+ else
+ {
+ *p2 = *p1;
+ p2++;
+ }
+ p1++;
+ }
+
+ *p2 = '\0';
+
+ APPL_TRACE_DEBUG2("%s %s", __FUNCTION__, dump);
+}
+#endif
+
+static void bta_hf_client_at_parse_start(void)
+{
+ char *buf = bta_hf_client_cb.scb.at_cb.buf;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+#ifdef BTA_HF_CLIENT_AT_DUMP
+ bta_hf_client_dump_at();
+#endif
+
+ while(*buf != '\0')
+ {
+ int i;
+ char *tmp = NULL;
+
+ for(i = 0; i < bta_hf_client_psraser_cb_count; i++)
+ {
+ tmp = bta_hf_client_parser_cb[i](buf);
+ if (tmp == NULL)
+ {
+ APPL_TRACE_ERROR0("HFPCient: AT event/reply parsing failed, skipping");
+ tmp = bta_hf_client_skip_unknown(buf);
+ break;
+ }
+
+ /* matched or unknown skipped, if unknown failed tmp is NULL so
+ this is also handled */
+ if (tmp != buf)
+ {
+ buf = tmp;
+ break;
+ }
+ }
+
+ /* could not skip unknown (received garbage?)... disconnect */
+ if (tmp == NULL)
+ {
+ APPL_TRACE_ERROR0("HFPCient: could not skip unknown AT event, disconnecting");
+ bta_hf_client_at_reset();
+ bta_hf_client_sm_execute(BTA_HF_CLIENT_API_CLOSE_EVT, NULL);
+ return;
+ }
+
+ buf = tmp;
+ }
+}
+
+static BOOLEAN bta_hf_client_check_at_complete(void)
+{
+ BOOLEAN ret = FALSE;
+ tBTA_HF_CLIENT_AT_CB *at_cb = &bta_hf_client_cb.scb.at_cb;
+
+ if (at_cb->offset >= BTA_HF_CLIENT_AT_EVENT_MIN_LEN)
+ {
+ if (at_cb->buf[at_cb->offset - 2] == '\r' && at_cb->buf[at_cb->offset - 1] == '\n')
+ {
+ ret = TRUE;
+ }
+ }
+
+ APPL_TRACE_DEBUG2("%s %d", __FUNCTION__, ret);
+
+ return ret;
+}
+
+static void bta_hf_client_at_clear_buf(void)
+{
+ memset(bta_hf_client_cb.scb.at_cb.buf, 0, sizeof(bta_hf_client_cb.scb.at_cb.buf));
+ bta_hf_client_cb.scb.at_cb.offset = 0;
+}
+
+/******************************************************************************
+**
+** MAIN PARSING FUNCTION
+**
+**
+*******************************************************************************/
+void bta_hf_client_at_parse(char *buf, unsigned int len)
+{
+ APPL_TRACE_DEBUG3("%s offset: %u len: %u", __FUNCTION__, bta_hf_client_cb.scb.at_cb.offset, len);
+
+ if (len + bta_hf_client_cb.scb.at_cb.offset > BTA_HF_CLIENT_AT_PARSER_MAX_LEN)
+ {
+ char tmp_buff[BTA_HF_CLIENT_AT_PARSER_MAX_LEN];
+ unsigned int tmp = bta_hf_client_cb.scb.at_cb.offset;
+ unsigned int space_left = BTA_HF_CLIENT_AT_PARSER_MAX_LEN - bta_hf_client_cb.scb.at_cb.offset;
+
+ APPL_TRACE_DEBUG1("%s overrun, trying to recover", __FUNCTION__);
+
+ /* fill up parser buffer */
+ memcpy(bta_hf_client_cb.scb.at_cb.buf + bta_hf_client_cb.scb.at_cb.offset, buf, space_left);
+ len -= space_left;
+ buf += space_left;
+ bta_hf_client_cb.scb.at_cb.offset += space_left;
+
+ /* find end of last complete command before proceeding */
+ while(bta_hf_client_check_at_complete() == FALSE)
+ {
+ if (bta_hf_client_cb.scb.at_cb.offset == 0) {
+ APPL_TRACE_ERROR0("HFPClient: AT parser buffer overrun, disconnecting");
+
+ bta_hf_client_at_reset();
+ bta_hf_client_sm_execute(BTA_HF_CLIENT_API_CLOSE_EVT, NULL);
+ return;
+ }
+
+ bta_hf_client_cb.scb.at_cb.offset--;
+ }
+
+ /* cut buffer to complete AT event and keep cut data */
+ tmp += space_left - bta_hf_client_cb.scb.at_cb.offset;
+ memcpy(tmp_buff, bta_hf_client_cb.scb.at_cb.buf + bta_hf_client_cb.scb.at_cb.offset, tmp);
+ bta_hf_client_cb.scb.at_cb.buf[bta_hf_client_cb.scb.at_cb.offset] = '\0';
+
+ /* parse */
+ bta_hf_client_at_parse_start();
+ bta_hf_client_at_clear_buf();
+
+ /* recover cut data */
+ memcpy(bta_hf_client_cb.scb.at_cb.buf, tmp_buff, tmp);
+ bta_hf_client_cb.scb.at_cb.offset += tmp;
+ }
+
+ memcpy(bta_hf_client_cb.scb.at_cb.buf + bta_hf_client_cb.scb.at_cb.offset, buf, len);
+ bta_hf_client_cb.scb.at_cb.offset += len;
+
+ /* If last event is complete, parsing can be started */
+ if (bta_hf_client_check_at_complete() == TRUE)
+ {
+ bta_hf_client_at_parse_start();
+ bta_hf_client_at_clear_buf();
+ }
+}
+
+void bta_hf_client_send_at_brsf(void)
+{
+ char buf[BTA_HF_CLIENT_AT_MAX_LEN];
+ int at_len;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ at_len = snprintf(buf, sizeof(buf), "AT+BRSF=%u\r", bta_hf_client_cb.scb.features);
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_BRSF , buf, at_len);
+}
+
+void bta_hf_client_send_at_bac(void)
+{
+ char *buf;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (bta_hf_client_cb.msbc_enabled)
+ {
+ buf = "AT+BAC=1,2\r";
+ }
+ else
+ {
+ buf = "AT+BAC=1\r";
+ }
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_BAC, buf, strlen(buf));
+}
+
+void bta_hf_client_send_at_bcs(UINT32 codec)
+{
+ char buf[BTA_HF_CLIENT_AT_MAX_LEN];
+ int at_len;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ at_len = snprintf(buf, sizeof(buf), "AT+BCS=%u\r", codec);
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_BCS, buf, at_len);
+}
+
+void bta_hf_client_send_at_cind(BOOLEAN status)
+{
+ char *buf;
+ tBTA_HF_CLIENT_AT_CMD cmd;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (status)
+ {
+ buf = "AT+CIND?\r";
+ cmd = BTA_HF_CLIENT_AT_CIND_STATUS;
+ }
+ else
+ {
+ buf = "AT+CIND=?\r";
+ cmd = BTA_HF_CLIENT_AT_CIND;
+ }
+
+ bta_hf_client_send_at(cmd, buf, strlen(buf));
+}
+
+void bta_hf_client_send_at_cmer(BOOLEAN activate)
+{
+ char *buf;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (activate)
+ buf = "AT+CMER=3,0,0,1\r";
+ else
+ buf = "AT+CMER=3,0,0,0\r";
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_CMER, buf, strlen(buf));
+}
+
+void bta_hf_client_send_at_chld(char cmd, UINT32 idx)
+{
+ char buf[BTA_HF_CLIENT_AT_MAX_LEN];
+ int at_len;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (idx > 0)
+ at_len = snprintf(buf, sizeof(buf), "AT+CHLD=%c%u\r", cmd, idx);
+ else
+ at_len = snprintf(buf, sizeof(buf), "AT+CHLD=%c\r", cmd);
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_CHLD, buf, at_len);
+}
+
+void bta_hf_client_send_at_clip(BOOLEAN activate)
+{
+ char *buf;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (activate)
+ buf = "AT+CLIP=1\r";
+ else
+ buf = "AT+CLIP=0\r";
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_CLIP, buf, strlen(buf));
+}
+
+void bta_hf_client_send_at_ccwa(BOOLEAN activate)
+{
+ char *buf;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (activate)
+ buf = "AT+CCWA=1\r";
+ else
+ buf = "AT+CCWA=0\r";
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_CCWA, buf, strlen(buf));
+}
+
+
+void bta_hf_client_send_at_cmee(BOOLEAN activate)
+{
+ char *buf;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (activate)
+ buf = "AT+CMEE=1\r";
+ else
+ buf = "AT+CMEE=0\r";
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_CMEE, buf, strlen(buf));
+}
+
+void bta_hf_client_send_at_cops(BOOLEAN query)
+{
+ char *buf;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (!service_availability)
+ {
+ APPL_TRACE_DEBUG0("Skip AT+COPS no service");
+ return;
+ }
+ if (query)
+ buf = "AT+COPS?\r";
+ else
+ buf = "AT+COPS=3,0\r";
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_COPS, buf, strlen(buf));
+}
+
+void bta_hf_client_send_at_clcc(void)
+{
+ char *buf;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ buf = "AT+CLCC\r";
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_CLCC, buf, strlen(buf));
+}
+
+void bta_hf_client_send_at_bvra(BOOLEAN enable)
+{
+ char *buf;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (enable)
+ buf = "AT+BVRA=1\r";
+ else
+ buf = "AT+BVRA=0\r";
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_BVRA, buf, strlen(buf));
+}
+
+void bta_hf_client_send_at_vgs(UINT32 volume)
+{
+ char buf[BTA_HF_CLIENT_AT_MAX_LEN];
+ int at_len;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ at_len = snprintf(buf, sizeof(buf), "AT+VGS=%u\r", volume);
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_VGS, buf, at_len);
+}
+
+void bta_hf_client_send_at_vgm(UINT32 volume)
+{
+ char buf[BTA_HF_CLIENT_AT_MAX_LEN];
+ int at_len;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ at_len = snprintf(buf, sizeof(buf), "AT+VGM=%u\r", volume);
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_VGM, buf, at_len);
+}
+
+void bta_hf_client_send_at_atd(char *number, UINT32 memory)
+{
+ char buf[BTA_HF_CLIENT_AT_MAX_LEN];
+ int at_len;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (number[0] != '\0')
+ {
+ at_len = snprintf(buf, sizeof(buf), "ATD%s;\r", number);
+ }
+ else
+ {
+ at_len = snprintf(buf, sizeof(buf), "ATD>%u;\r", memory);
+ }
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_ATD, buf, at_len);
+}
+
+void bta_hf_client_send_at_bldn(void)
+{
+ char *buf;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ buf = "AT+BLDN\r";
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_BLDN, buf, strlen(buf));
+}
+
+void bta_hf_client_send_at_ata(void)
+{
+ char *buf;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ buf = "ATA\r";
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_ATA, buf, strlen(buf));
+}
+
+void bta_hf_client_send_at_chup(void)
+{
+ char *buf;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ buf = "AT+CHUP\r";
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_CHUP, buf, strlen(buf));
+}
+
+void bta_hf_client_send_at_btrh(BOOLEAN query, UINT32 val)
+{
+ char buf[BTA_HF_CLIENT_AT_MAX_LEN];
+ int at_len;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (query == TRUE)
+ {
+ at_len = snprintf(buf, sizeof(buf), "AT+BTRH?\r");
+ }
+ else
+ {
+ at_len = snprintf(buf, sizeof(buf), "AT+BTRH=%u\r", val);
+ }
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_BTRH, buf, at_len);
+}
+
+void bta_hf_client_send_at_vts(char code)
+{
+ char buf[BTA_HF_CLIENT_AT_MAX_LEN];
+ int at_len;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ at_len = snprintf(buf, sizeof(buf), "AT+VTS=%c\r", code);
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_VTS, buf, at_len);
+}
+
+void bta_hf_client_send_at_bcc(void)
+{
+ char *buf;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ buf = "AT+BCC\r";
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_BCC, buf, strlen(buf));
+}
+
+void bta_hf_client_send_at_cnum(void)
+{
+ char *buf;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (!service_availability)
+ {
+ APPL_TRACE_DEBUG0("Skip AT+CNUM no Service");
+ return;
+ }
+ buf = "AT+CNUM\r";
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_CNUM, buf, strlen(buf));
+}
+
+void bta_hf_client_send_at_nrec(void)
+{
+ char *buf;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (!(bta_hf_client_cb.scb.peer_features & BTA_HF_CLIENT_PEER_FEAT_ECNR))
+ {
+ APPL_TRACE_DEBUG0("Remote does not support NREC.");
+ return;
+ }
+
+ buf = "AT+NREC=0\r";
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_NREC, buf, strlen(buf));
+}
+
+void bta_hf_client_send_at_binp(UINT32 action)
+{
+ char buf[BTA_HF_CLIENT_AT_MAX_LEN];
+ int at_len;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ at_len = snprintf(buf, sizeof(buf), "AT+BINP=%u\r", action);
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_BINP, buf, at_len);
+}
+
+void bta_hf_client_send_at_bia(void)
+{
+ char buf[BTA_HF_CLIENT_AT_MAX_LEN];
+ int at_len;
+ int i;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+ if (bta_hf_client_cb.scb.peer_version < HFP_VERSION_1_6)
+ {
+ APPL_TRACE_DEBUG0("Remote does not Support AT+BIA");
+ return;
+ }
+
+ at_len = snprintf(buf, sizeof(buf), "AT+BIA=");
+
+ for(i = 0; i < BTA_HF_CLIENT_AT_INDICATOR_COUNT; i++)
+ {
+ int sup = bta_hf_client_cb.scb.at_cb.indicator_lookup[i] == -1 ? 0 : 1;
+
+ at_len += snprintf(buf + at_len, sizeof(buf) - at_len, "%u,", sup);
+ }
+
+ buf[at_len - 1] = '\r';
+
+ bta_hf_client_send_at(BTA_HF_CLIENT_AT_BIA, buf, at_len);
+}
+
+void bta_hf_client_at_init(void)
+{
+ memset(&bta_hf_client_cb.scb.at_cb, 0, sizeof(tBTA_HF_CLIENT_AT_CB));
+ bta_hf_client_at_reset();
+}
+
+void bta_hf_client_at_reset(void)
+{
+ int i;
+
+ bta_hf_client_stop_at_resp_timer();
+ bta_hf_client_stop_at_hold_timer();
+
+ bta_hf_client_clear_queued_at();
+
+ bta_hf_client_at_clear_buf();
+
+ for (i = 0; i < BTA_HF_CLIENT_AT_INDICATOR_COUNT; i++)
+ {
+ bta_hf_client_cb.scb.at_cb.indicator_lookup[i] = -1;
+ }
+
+ bta_hf_client_cb.scb.at_cb.current_cmd = BTA_HF_CLIENT_AT_NONE;
+}
diff --git a/bta/hf_client/bta_hf_client_at.h b/bta/hf_client/bta_hf_client_at.h
new file mode 100644
index 0000000..917c605
--- /dev/null
+++ b/bta/hf_client/bta_hf_client_at.h
@@ -0,0 +1,117 @@
+/******************************************************************************
+ *
+ * Copyright (c) 2014 The Android Open Source Project
+ * Copyright (C) 2003-2012 Broadcom 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.
+ *
+ ******************************************************************************/
+
+/*****************************************************************************
+** Data types
+*****************************************************************************/
+
+/* ASCII character string of arguments to the AT command */
+#define BTA_HF_CLIENT_AT_MAX_LEN 512
+
+/* AT command table element */
+typedef struct
+{
+ const char *p_cmd; /* AT command string */
+ UINT8 arg_type; /* allowable argument type syntax */
+ UINT8 fmt; /* whether arg is int or string */
+ UINT8 min; /* minimum value for int arg */
+ INT16 max; /* maximum value for int arg */
+} tBTA_AG_AT_CMD;
+
+/* callback function executed when command is parsed */
+typedef void (tBTA_AG_AT_CMD_CBACK)(void *p_user, UINT16 cmd, UINT8 arg_type,
+ char *p_arg, INT16 int_arg);
+
+/* callback function executed to send "ERROR" result code */
+typedef void (tBTA_AG_AT_ERR_CBACK)(void *p_user, BOOLEAN unknown, char *p_arg);
+
+enum
+{
+ BTA_HF_CLIENT_AT_NONE,
+ BTA_HF_CLIENT_AT_BRSF,
+ BTA_HF_CLIENT_AT_BAC,
+ BTA_HF_CLIENT_AT_CIND,
+ BTA_HF_CLIENT_AT_CIND_STATUS,
+ BTA_HF_CLIENT_AT_CMER,
+ BTA_HF_CLIENT_AT_CHLD,
+ BTA_HF_CLIENT_AT_CMEE,
+ BTA_HF_CLIENT_AT_BIA,
+ BTA_HF_CLIENT_AT_CLIP,
+ BTA_HF_CLIENT_AT_CCWA,
+ BTA_HF_CLIENT_AT_COPS,
+ BTA_HF_CLIENT_AT_CLCC,
+ BTA_HF_CLIENT_AT_BVRA,
+ BTA_HF_CLIENT_AT_VGS,
+ BTA_HF_CLIENT_AT_VGM,
+ BTA_HF_CLIENT_AT_ATD,
+ BTA_HF_CLIENT_AT_BLDN,
+ BTA_HF_CLIENT_AT_ATA,
+ BTA_HF_CLIENT_AT_CHUP,
+ BTA_HF_CLIENT_AT_BTRH,
+ BTA_HF_CLIENT_AT_VTS,
+ BTA_HF_CLIENT_AT_BCC,
+ BTA_HF_CLIENT_AT_BCS,
+ BTA_HF_CLIENT_AT_CNUM,
+ BTA_HF_CLIENT_AT_NREC,
+ BTA_HF_CLIENT_AT_BINP,
+};
+
+typedef UINT8 tBTA_HF_CLIENT_AT_CMD;
+
+/* Maximum combined buffer for received AT events string */
+#define BTA_HF_CLIENT_AT_PARSER_MAX_LEN 4096
+
+/* This structure holds prepared AT command queued for sending */
+struct queued_at_cmd{
+ tBTA_HF_CLIENT_AT_CMD cmd;
+ char buf[BTA_HF_CLIENT_AT_MAX_LEN];
+ UINT16 buf_len;
+ struct queued_at_cmd *next;
+};
+typedef struct queued_at_cmd tBTA_HF_CLIENT_AT_QCMD;
+
+/* Maximum number of indicators */
+#define BTA_HF_CLIENT_AT_INDICATOR_COUNT 20
+
+/* AT command parsing control block */
+typedef struct
+{
+ char buf[BTA_HF_CLIENT_AT_PARSER_MAX_LEN + 1]; /* extra byte to always have \0 at the end */
+ unsigned int offset;
+ tBTA_HF_CLIENT_AT_CMD current_cmd;
+ tBTA_HF_CLIENT_AT_QCMD *queued_cmd;
+
+ TIMER_LIST_ENT resp_timer; /* AT response timer */
+ BOOLEAN resp_timer_on; /* TRUE if AT response timer is active */
+
+ TIMER_LIST_ENT hold_timer; /* AT hold timer */
+ BOOLEAN hold_timer_on; /* TRUE if AT hold timer is active */
+
+ /* CIND: lookup table to store the sequence of incoming indicators and their values
+ so when their values come later, we know which value in sequence match certain indicator */
+ int indicator_lookup[BTA_HF_CLIENT_AT_INDICATOR_COUNT];
+
+} tBTA_HF_CLIENT_AT_CB;
+
+/*****************************************************************************
+** Functions
+*****************************************************************************/
+
+void bta_hf_client_at_init(void);
+void bta_hf_client_at_reset(void);
diff --git a/bta/hf_client/bta_hf_client_cmd.c b/bta/hf_client/bta_hf_client_cmd.c
new file mode 100644
index 0000000..f71fce7
--- /dev/null
+++ b/bta/hf_client/bta_hf_client_cmd.c
@@ -0,0 +1,88 @@
+/******************************************************************************
+ *
+ * Copyright (c) 2014 The Android Open Source Project
+ * Copyright (C) 2003-2012 Broadcom 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 "bta_hf_client_int.h"
+#include "stdio.h"
+
+void bta_hf_client_send_at_cmd(tBTA_HF_CLIENT_DATA *p_data)
+{
+ tBTA_HF_CLIENT_DATA_VAL *p_val = (tBTA_HF_CLIENT_DATA_VAL *)p_data;
+ char buf[BTA_HF_CLIENT_AT_MAX_LEN];
+
+ switch(p_val->uint8_val)
+ {
+ case BTA_HF_CLIENT_AT_CMD_VTS:
+ bta_hf_client_send_at_vts((char)p_val->uint32_val1);
+ break;
+ case BTA_HF_CLIENT_AT_CMD_BTRH:
+ bta_hf_client_send_at_btrh(FALSE, p_val->uint32_val1);
+ break;
+ case BTA_HF_CLIENT_AT_CMD_CHUP:
+ bta_hf_client_send_at_chup();
+ break;
+ case BTA_HF_CLIENT_AT_CMD_CHLD:
+ /* expects ascii code for command */
+ bta_hf_client_send_at_chld('0' + p_val->uint32_val1, p_val->uint32_val2);
+ break;
+ case BTA_HF_CLIENT_AT_CMD_BCC:
+ bta_hf_client_send_at_bcc();
+ break;
+ case BTA_HF_CLIENT_AT_CMD_CNUM:
+ bta_hf_client_send_at_cnum();
+ break;
+ case BTA_HF_CLIENT_AT_CMD_ATA:
+ bta_hf_client_send_at_ata();
+ break;
+ case BTA_HF_CLIENT_AT_CMD_COPS:
+ bta_hf_client_send_at_cops(TRUE);
+ break;
+ case BTA_HF_CLIENT_AT_CMD_ATD:
+ bta_hf_client_send_at_atd(p_val->str, p_val->uint32_val1);
+ break;
+ case BTA_HF_CLIENT_AT_CMD_VGM:
+ bta_hf_client_send_at_vgm(p_val->uint32_val1);
+ break;
+ case BTA_HF_CLIENT_AT_CMD_VGS:
+ bta_hf_client_send_at_vgs(p_val->uint32_val1);
+ break;
+ case BTA_HF_CLIENT_AT_CMD_BVRA:
+ bta_hf_client_send_at_bvra(p_val->uint32_val1 == 0 ? FALSE : TRUE);
+ break;
+ case BTA_HF_CLIENT_AT_CMD_CLCC:
+ bta_hf_client_send_at_clcc();
+ break;
+ case BTA_HF_CLIENT_AT_CMD_BINP:
+ bta_hf_client_send_at_binp(p_val->uint32_val1);
+ break;
+ case BTA_HF_CLIENT_AT_CMD_BLDN:
+ bta_hf_client_send_at_bldn();
+ break;
+ case BTA_HF_CLIENT_AT_CMD_NREC:
+ bta_hf_client_send_at_nrec();
+ break;
+ default:
+ APPL_TRACE_ERROR0("Default case");
+ snprintf(buf,BTA_HF_CLIENT_AT_MAX_LEN,
+ "Cmd %d 1st arg %u 2nd arg %u string arg %s",
+ p_val->uint8_val, p_val->uint32_val1,
+ p_val->uint32_val2, p_val->str);
+ APPL_TRACE_ERROR1("%s ", buf);
+ break;
+ }
+}
diff --git a/bta/hf_client/bta_hf_client_int.h b/bta/hf_client/bta_hf_client_int.h
new file mode 100644
index 0000000..fbd5082
--- /dev/null
+++ b/bta/hf_client/bta_hf_client_int.h
@@ -0,0 +1,294 @@
+/******************************************************************************
+ *
+ * Copyright (c) 2014 The Android Open Source Project
+ * Copyright (C) 2003-2012 Broadcom 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 "bta_sys.h"
+#include "bta_api.h"
+#include "bta_hf_client_api.h"
+#include "bta_hf_client_at.h"
+
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+#define HFP_VERSION_1_1 0x0101
+#define HFP_VERSION_1_5 0x0105
+#define HFP_VERSION_1_6 0x0106
+
+/* RFCOMM MTU SIZE */
+#define BTA_HF_CLIENT_MTU 256
+
+/* profile role for connection */
+#define BTA_HF_CLIENT_ACP 0 /* accepted connection */
+#define BTA_HF_CLIENT_INT 1 /* initiating connection */
+
+/* Timer to wait for retry in case of collision */
+#ifndef BTA_HF_CLIENT_COLLISION_TIMER
+#define BTA_HF_CLIENT_COLLISION_TIMER 2411
+#endif
+
+enum
+{
+ /* these events are handled by the state machine */
+ BTA_HF_CLIENT_API_REGISTER_EVT = BTA_SYS_EVT_START(BTA_ID_HS),
+ BTA_HF_CLIENT_API_DEREGISTER_EVT,
+ BTA_HF_CLIENT_API_OPEN_EVT,
+ BTA_HF_CLIENT_API_CLOSE_EVT,
+ BTA_HF_CLIENT_API_AUDIO_OPEN_EVT,
+ BTA_HF_CLIENT_API_AUDIO_CLOSE_EVT,
+ BTA_HF_CLIENT_RFC_OPEN_EVT,
+ BTA_HF_CLIENT_RFC_CLOSE_EVT,
+ BTA_HF_CLIENT_RFC_SRV_CLOSE_EVT,
+ BTA_HF_CLIENT_RFC_DATA_EVT,
+ BTA_HF_CLIENT_DISC_ACP_RES_EVT,
+ BTA_HF_CLIENT_DISC_INT_RES_EVT,
+ BTA_HF_CLIENT_DISC_OK_EVT,
+ BTA_HF_CLIENT_DISC_FAIL_EVT,
+ BTA_HF_CLIENT_SCO_OPEN_EVT,
+ BTA_HF_CLIENT_SCO_CLOSE_EVT,
+ BTA_HF_CLIENT_SEND_AT_CMD_EVT,
+ BTA_HF_CLIENT_MAX_EVT,
+
+ /* these events are handled outside of the state machine */
+ BTA_HF_CLIENT_API_ENABLE_EVT,
+ BTA_HF_CLIENT_API_DISABLE_EVT
+};
+
+/*****************************************************************************
+** Data types
+*****************************************************************************/
+
+/* data type for BTA_HF_CLIENT_API_ENABLE_EVT */
+typedef struct
+{
+ BT_HDR hdr;
+ tBTA_HF_CLIENT_CBACK *p_cback;
+} tBTA_HF_CLIENT_API_ENABLE;
+
+/* data type for BTA_HF_CLIENT_API_REGISTER_EVT */
+typedef struct
+{
+ BT_HDR hdr;
+ tBTA_HF_CLIENT_CBACK *p_cback;
+ tBTA_SEC sec_mask;
+ tBTA_HF_CLIENT_FEAT features;
+ char name[BTA_SERVICE_NAME_LEN+1];
+} tBTA_HF_CLIENT_API_REGISTER;
+
+/* data type for BTA_HF_CLIENT_API_OPEN_EVT */
+typedef struct
+{
+ BT_HDR hdr;
+ BD_ADDR bd_addr;
+ tBTA_SEC sec_mask;
+} tBTA_HF_CLIENT_API_OPEN;
+
+/* data type for BTA_HF_CLIENT_DISC_RESULT_EVT */
+typedef struct
+{
+ BT_HDR hdr;
+ UINT16 status;
+} tBTA_HF_CLIENT_DISC_RESULT;
+
+/* data type for RFCOMM events */
+typedef struct
+{
+ BT_HDR hdr;
+ UINT16 port_handle;
+} tBTA_HF_CLIENT_RFC;
+
+/* generic purpose data type for other events */
+typedef struct
+{
+ BT_HDR hdr;
+ BOOLEAN bool_val;
+ UINT8 uint8_val;
+ UINT32 uint32_val1;
+ UINT32 uint32_val2;
+ char str[BTA_HF_CLIENT_NUMBER_LEN + 1];
+} tBTA_HF_CLIENT_DATA_VAL;
+
+/* union of all event datatypes */
+typedef union
+{
+ BT_HDR hdr;
+ tBTA_HF_CLIENT_API_ENABLE api_enable;
+ tBTA_HF_CLIENT_API_REGISTER api_register;
+ tBTA_HF_CLIENT_API_OPEN api_open;
+ tBTA_HF_CLIENT_DISC_RESULT disc_result;
+ tBTA_HF_CLIENT_RFC rfc;
+ tBTA_HF_CLIENT_DATA_VAL val;
+
+} tBTA_HF_CLIENT_DATA;
+
+/* type for each service control block */
+typedef struct
+{
+ UINT16 serv_handle; /* RFCOMM server handle */
+ BD_ADDR peer_addr; /* peer bd address */
+ tSDP_DISCOVERY_DB *p_disc_db; /* pointer to discovery database */
+ UINT16 conn_handle; /* RFCOMM handle of connected service */
+ tBTA_SEC serv_sec_mask; /* server security mask */
+ tBTA_SEC cli_sec_mask; /* client security mask */
+ tBTA_HF_CLIENT_FEAT features; /* features registered by application */
+ tBTA_HF_CLIENT_PEER_FEAT peer_features; /* peer device features */
+ tBTA_HF_CLIENT_CHLD_FEAT chld_features; /* call handling features */
+ UINT16 peer_version; /* profile version of peer device */
+ UINT8 peer_scn; /* peer scn */
+ UINT8 role; /* initiator/acceptor role */
+ UINT16 sco_idx; /* SCO handle */
+ UINT8 sco_state; /* SCO state variable */
+ BOOLEAN sco_close_rfc; /* TRUE if also close RFCOMM after SCO */
+ BOOLEAN retry_with_sco_only;
+ BOOLEAN deregister; /* TRUE if service shutting down */
+ BOOLEAN svc_conn; /* set to TRUE when service level connection is up */
+ BOOLEAN send_at_reply; /* set to TRUE to notify framework about AT results */
+ tBTA_HF_CLIENT_AT_CB at_cb; /* AT Parser control block */
+ UINT8 state; /* state machine state */
+ tBTM_SCO_CODEC_TYPE negotiated_codec; /* negotiated codec */
+ TIMER_LIST_ENT colli_timer; /* Collision timer */
+ BOOLEAN colli_tmr_on; /* TRUE if collision timer is active */
+} tBTA_HF_CLIENT_SCB;
+
+/* sco states */
+enum
+{
+ BTA_HF_CLIENT_SCO_SHUTDOWN_ST, /* no listening, no connection */
+ BTA_HF_CLIENT_SCO_LISTEN_ST, /* listening */
+ BTA_HF_CLIENT_SCO_OPENING_ST, /* connection opening */
+ BTA_HF_CLIENT_SCO_OPEN_CL_ST, /* opening connection being closed */
+ BTA_HF_CLIENT_SCO_OPEN_ST, /* open */
+ BTA_HF_CLIENT_SCO_CLOSING_ST, /* closing */
+ BTA_HF_CLIENT_SCO_CLOSE_OP_ST, /* closing sco being opened */
+ BTA_HF_CLIENT_SCO_SHUTTING_ST /* sco shutting down */
+};
+
+/* type for AG control block */
+typedef struct
+{
+ tBTA_HF_CLIENT_SCB scb; /* service control block */
+ UINT32 sdp_handle;
+ UINT8 scn;
+ tBTA_HF_CLIENT_CBACK *p_cback; /* application callback */
+ BOOLEAN msbc_enabled;
+} tBTA_HF_CLIENT_CB;
+
+/*****************************************************************************
+** Global data
+*****************************************************************************/
+
+/* control block declaration */
+extern tBTA_HF_CLIENT_CB bta_hf_client_cb;
+
+/*****************************************************************************
+** Function prototypes
+*****************************************************************************/
+
+/* main functions */
+extern void bta_hf_client_scb_init(void);
+extern void bta_hf_client_scb_disable(void);
+extern BOOLEAN bta_hf_client_hdl_event(BT_HDR *p_msg);
+extern void bta_hf_client_sm_execute(UINT16 event,
+ tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_slc_seq(BOOLEAN error);
+extern void bta_hf_client_collision_cback (tBTA_SYS_CONN_STATUS status, UINT8 id,
+ UINT8 app_id, BD_ADDR peer_addr);
+extern void bta_hf_client_resume_open ();
+
+/* SDP functions */
+extern BOOLEAN bta_hf_client_add_record(char *p_service_name,
+ UINT8 scn, tBTA_HF_CLIENT_FEAT features,
+ UINT32 sdp_handle);
+extern void bta_hf_client_create_record(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_del_record(tBTA_HF_CLIENT_DATA *p_data);
+extern BOOLEAN bta_hf_client_sdp_find_attr(void);
+extern void bta_hf_client_do_disc(void);
+extern void bta_hf_client_free_db(tBTA_HF_CLIENT_DATA *p_data);
+
+/* RFCOMM functions */
+extern void bta_hf_client_setup_port(UINT16 handle);
+extern void bta_hf_client_start_server(void);
+extern void bta_hf_client_close_server(void);
+extern void bta_hf_client_rfc_do_open(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_rfc_do_close(tBTA_HF_CLIENT_DATA *p_data);
+
+/* SCO functions */
+extern void bta_hf_client_sco_listen(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_sco_shutdown(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_sco_conn_open(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_sco_conn_close(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_sco_open(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_sco_close(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_cback_sco(UINT8 event);
+
+/* AT command functions */
+extern void bta_hf_client_at_parse(char *buf, unsigned int len);
+extern void bta_hf_client_send_at_brsf(void);
+extern void bta_hf_client_send_at_bac(void);
+extern void bta_hf_client_send_at_cind(BOOLEAN status);
+extern void bta_hf_client_send_at_cmer(BOOLEAN activate);
+extern void bta_hf_client_send_at_chld(char cmd, UINT32 idx);
+extern void bta_hf_client_send_at_clip(BOOLEAN activate);
+extern void bta_hf_client_send_at_ccwa(BOOLEAN activate);
+extern void bta_hf_client_send_at_cmee(BOOLEAN activate);
+extern void bta_hf_client_send_at_cops(BOOLEAN query);
+extern void bta_hf_client_send_at_clcc(void);
+extern void bta_hf_client_send_at_bvra(BOOLEAN enable);
+extern void bta_hf_client_send_at_vgs(UINT32 volume);
+extern void bta_hf_client_send_at_vgm(UINT32 volume);
+extern void bta_hf_client_send_at_atd(char *number, UINT32 memory);
+extern void bta_hf_client_send_at_bldn(void);
+extern void bta_hf_client_send_at_ata(void);
+extern void bta_hf_client_send_at_chup(void);
+extern void bta_hf_client_send_at_btrh(BOOLEAN query, UINT32 val);
+extern void bta_hf_client_send_at_vts(char code);
+extern void bta_hf_client_send_at_bcc(void);
+extern void bta_hf_client_send_at_bcs(UINT32 codec);
+extern void bta_hf_client_send_at_cnum(void);
+extern void bta_hf_client_send_at_nrec(void);
+extern void bta_hf_client_send_at_binp(UINT32 action);
+extern void bta_hf_client_send_at_bia(void);
+
+/* Action functions */
+extern void bta_hf_client_register(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_deregister(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_start_dereg(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_start_close(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_start_open(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_rfc_acp_open(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_rfc_open(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_rfc_fail(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_disc_fail(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_open_fail(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_rfc_close(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_disc_acp_res(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_rfc_data(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_disc_int_res(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_svc_conn_open(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_ind(tBTA_HF_CLIENT_IND_TYPE type, UINT16 value);
+extern void bta_hf_client_evt_val(tBTA_HF_CLIENT_EVT type, UINT16 value);
+extern void bta_hf_client_operator_name(char *name);
+extern void bta_hf_client_clip(char *number);
+extern void bta_hf_client_ccwa(char *number);
+extern void bta_hf_client_at_result(tBTA_HF_CLIENT_AT_RESULT_TYPE type, UINT16 cme);
+extern void bta_hf_client_clcc(UINT32 idx, BOOLEAN incoming, UINT8 status, BOOLEAN mpty, char *number);
+extern void bta_hf_client_cnum(char *number, UINT16 service);
+extern void bta_hf_client_binp(char *number);
+
+/* Commands handling functions */
+extern void bta_hf_client_dial(tBTA_HF_CLIENT_DATA *p_data);
+extern void bta_hf_client_send_at_cmd(tBTA_HF_CLIENT_DATA *p_data);
diff --git a/bta/hf_client/bta_hf_client_main.c b/bta/hf_client/bta_hf_client_main.c
new file mode 100644
index 0000000..8311183
--- /dev/null
+++ b/bta/hf_client/bta_hf_client_main.c
@@ -0,0 +1,668 @@
+/******************************************************************************
+ *
+ * Copyright (c) 2014 The Android Open Source Project
+ * Copyright (C) 2003-2012 Broadcom 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 <string.h>
+#include <stdlib.h>
+#include <cutils/properties.h>
+#include "bt_utils.h"
+#include "bta_api.h"
+#include "bta_sys.h"
+#include "bta_hf_client_api.h"
+#include "bta_hf_client_int.h"
+
+/* uncomment to enable extra debug */
+/* #define BTA_HF_CLIENT_DEBUG TRUE */
+
+#ifndef BTA_HF_CLIENT_DEBUG
+#define BTA_HF_CLIENT_DEBUG FALSE
+#endif
+
+#if BTA_HF_CLIENT_DEBUG == TRUE
+static char *bta_hf_client_evt_str(UINT16 event);
+static char *bta_hf_client_state_str(UINT8 state);
+#endif
+
+/* state machine states */
+enum
+{
+ BTA_HF_CLIENT_INIT_ST,
+ BTA_HF_CLIENT_OPENING_ST,
+ BTA_HF_CLIENT_OPEN_ST,
+ BTA_HF_CLIENT_CLOSING_ST
+};
+
+/* state machine action enumeration list */
+enum
+{
+ BTA_HF_CLIENT_REGISTER,
+ BTA_HF_CLIENT_DEREGISTER,
+ BTA_HF_CLIENT_START_DEREG,
+ BTA_HF_CLIENT_RFC_DO_CLOSE,
+ BTA_HF_CLIENT_START_CLOSE,
+ BTA_HF_CLIENT_START_OPEN,
+ BTA_HF_CLIENT_RFC_ACP_OPEN,
+ BTA_HF_CLIENT_SCO_LISTEN,
+ BTA_HF_CLIENT_SCO_CONN_OPEN,
+ BTA_HF_CLIENT_SCO_CONN_CLOSE,
+ BTA_HF_CLIENT_SCO_OPEN,
+ BTA_HF_CLIENT_SCO_CLOSE,
+ BTA_HF_CLIENT_SCO_SHUTDOWN,
+ BTA_HF_CLIENT_FREE_DB,
+ BTA_HF_CLIENT_OPEN_FAIL,
+ BTA_HF_CLIENT_RFC_OPEN,
+ BTA_HF_CLIENT_RFC_FAIL,
+ BTA_HF_CLIENT_DISC_INT_RES,
+ BTA_HF_CLIENT_RFC_DO_OPEN,
+ BTA_HF_CLIENT_DISC_FAIL,
+ BTA_HF_CLIENT_RFC_CLOSE,
+ BTA_HF_CLIENT_RFC_DATA,
+ BTA_HF_CLIENT_DISC_ACP_RES,
+ BTA_HF_CLIENT_SVC_CONN_OPEN,
+ BTA_HF_CLIENT_SEND_AT_CMD,
+ BTA_HF_CLIENT_NUM_ACTIONS,
+};
+
+#define BTA_HF_CLIENT_IGNORE BTA_HF_CLIENT_NUM_ACTIONS
+
+/* type for action functions */
+typedef void (*tBTA_HF_CLIENT_ACTION)(tBTA_HF_CLIENT_DATA *p_data);
+
+/* action functions table, indexed with action enum */
+const tBTA_HF_CLIENT_ACTION bta_hf_client_action[] =
+{
+/* BTA_HF_CLIENT_REGISTER */ bta_hf_client_register,
+/* BTA_HF_CLIENT_DEREGISTER */ bta_hf_client_deregister,
+/* BTA_HF_CLIENT_START_DEREG */ bta_hf_client_start_dereg,
+/* BTA_HF_CLIENT_RFC_DO_CLOSE */ bta_hf_client_rfc_do_close,
+/* BTA_HF_CLIENT_START_CLOSE */ bta_hf_client_start_close,
+/* BTA_HF_CLIENT_START_OPEN */ bta_hf_client_start_open,
+/* BTA_HF_CLIENT_RFC_ACP_OPEN */ bta_hf_client_rfc_acp_open,
+/* BTA_HF_CLIENT_SCO_LISTEN */ bta_hf_client_sco_listen,
+/* BTA_HF_CLIENT_SCO_CONN_OPEN */ bta_hf_client_sco_conn_open,
+/* BTA_HF_CLIENT_SCO_CONN_CLOSE*/ bta_hf_client_sco_conn_close,
+/* BTA_HF_CLIENT_SCO_OPEN */ bta_hf_client_sco_open,
+/* BTA_HF_CLIENT_SCO_CLOSE */ bta_hf_client_sco_close,
+/* BTA_HF_CLIENT_SCO_SHUTDOWN */ bta_hf_client_sco_shutdown,
+/* BTA_HF_CLIENT_FREE_DB */ bta_hf_client_free_db,
+/* BTA_HF_CLIENT_OPEN_FAIL */ bta_hf_client_open_fail,
+/* BTA_HF_CLIENT_RFC_OPEN */ bta_hf_client_rfc_open,
+/* BTA_HF_CLIENT_RFC_FAIL */ bta_hf_client_rfc_fail,
+/* BTA_HF_CLIENT_DISC_INT_RES */ bta_hf_client_disc_int_res,
+/* BTA_HF_CLIENT_RFC_DO_OPEN */ bta_hf_client_rfc_do_open,
+/* BTA_HF_CLIENT_DISC_FAIL */ bta_hf_client_disc_fail,
+/* BTA_HF_CLIENT_RFC_CLOSE */ bta_hf_client_rfc_close,
+/* BTA_HF_CLIENT_RFC_DATA */ bta_hf_client_rfc_data,
+/* BTA_HF_CLIENT_DISC_ACP_RES */ bta_hf_client_disc_acp_res,
+/* BTA_HF_CLIENT_SVC_CONN_OPEN */ bta_hf_client_svc_conn_open,
+/* BTA_HF_CLIENT_SEND_AT_CMD */ bta_hf_client_send_at_cmd,
+};
+
+/* state table information */
+#define BTA_HF_CLIENT_ACTIONS 2 /* number of actions */
+#define BTA_HF_CLIENT_NEXT_STATE 2 /* position of next state */
+#define BTA_HF_CLIENT_NUM_COLS 3 /* number of columns in state tables */
+
+/* state table for init state */
+const UINT8 bta_hf_client_st_init[][BTA_HF_CLIENT_NUM_COLS] =
+{
+/* Event Action 1 Action 2 Next state */
+/* API_REGISTER_EVT */ {BTA_HF_CLIENT_REGISTER, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* API_DEREGISTER_EVT */ {BTA_HF_CLIENT_DEREGISTER, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* API_OPEN_EVT */ {BTA_HF_CLIENT_START_OPEN, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
+/* API_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* API_AUDIO_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* API_AUDIO_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* RFC_OPEN_EVT */ {BTA_HF_CLIENT_RFC_ACP_OPEN, BTA_HF_CLIENT_SCO_LISTEN, BTA_HF_CLIENT_OPEN_ST},
+/* RFC_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* RFC_SRV_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* RFC_DATA_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* DISC_ACP_RES_EVT */ {BTA_HF_CLIENT_FREE_DB, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* DISC_INT_RES_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* DISC_OK_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* DISC_FAIL_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* SCO_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* SCO_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+};
+
+/* state table for opening state */
+const UINT8 bta_hf_client_st_opening[][BTA_HF_CLIENT_NUM_COLS] =
+{
+/* Event Action 1 Action 2 Next state */
+/* API_REGISTER_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
+/* API_DEREGISTER_EVT */ {BTA_HF_CLIENT_RFC_DO_CLOSE, BTA_HF_CLIENT_START_DEREG, BTA_HF_CLIENT_CLOSING_ST},
+/* API_OPEN_EVT */ {BTA_HF_CLIENT_OPEN_FAIL, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
+/* API_CLOSE_EVT */ {BTA_HF_CLIENT_RFC_DO_CLOSE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+/* API_AUDIO_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
+/* API_AUDIO_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
+/* RFC_OPEN_EVT */ {BTA_HF_CLIENT_RFC_OPEN, BTA_HF_CLIENT_SCO_LISTEN, BTA_HF_CLIENT_OPEN_ST},
+/* RFC_CLOSE_EVT */ {BTA_HF_CLIENT_RFC_FAIL, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* RFC_SRV_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
+/* RFC_DATA_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
+/* DISC_ACP_RES_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
+/* DISC_INT_RES_EVT */ {BTA_HF_CLIENT_DISC_INT_RES, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
+/* DISC_OK_EVT */ {BTA_HF_CLIENT_RFC_DO_OPEN, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
+/* DISC_FAIL_EVT */ {BTA_HF_CLIENT_DISC_FAIL, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* SCO_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
+/* SCO_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
+/* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
+};
+
+/* state table for open state */
+const UINT8 bta_hf_client_st_open[][BTA_HF_CLIENT_NUM_COLS] =
+{
+/* Event Action 1 Action 2 Next state */
+/* API_REGISTER_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
+/* API_DEREGISTER_EVT */ {BTA_HF_CLIENT_START_CLOSE, BTA_HF_CLIENT_START_DEREG, BTA_HF_CLIENT_CLOSING_ST},
+/* API_OPEN_EVT */ {BTA_HF_CLIENT_OPEN_FAIL, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
+/* API_CLOSE_EVT */ {BTA_HF_CLIENT_START_CLOSE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+/* API_AUDIO_OPEN_EVT */ {BTA_HF_CLIENT_SCO_OPEN, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
+/* API_AUDIO_CLOSE_EVT */ {BTA_HF_CLIENT_SCO_CLOSE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
+/* RFC_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
+/* RFC_CLOSE_EVT */ {BTA_HF_CLIENT_RFC_CLOSE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* RFC_SRV_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
+/* RFC_DATA_EVT */ {BTA_HF_CLIENT_RFC_DATA, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
+/* DISC_ACP_RES_EVT */ {BTA_HF_CLIENT_DISC_ACP_RES, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
+/* DISC_INT_RES_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
+/* DISC_OK_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
+/* DISC_FAIL_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
+/* SCO_OPEN_EVT */ {BTA_HF_CLIENT_SCO_CONN_OPEN, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
+/* SCO_CLOSE_EVT */ {BTA_HF_CLIENT_SCO_CONN_CLOSE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
+/* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_SEND_AT_CMD, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
+};
+
+/* state table for closing state */
+const UINT8 bta_hf_client_st_closing[][BTA_HF_CLIENT_NUM_COLS] =
+{
+/* Event Action 1 Action 2 Next state */
+/* API_REGISTER_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+/* API_DEREGISTER_EVT */ {BTA_HF_CLIENT_START_DEREG, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+/* API_OPEN_EVT */ {BTA_HF_CLIENT_OPEN_FAIL, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+/* API_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+/* API_AUDIO_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+/* API_AUDIO_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+/* RFC_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+/* RFC_CLOSE_EVT */ {BTA_HF_CLIENT_RFC_CLOSE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* RFC_SRV_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+/* RFC_DATA_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+/* DISC_ACP_RES_EVT */ {BTA_HF_CLIENT_FREE_DB, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+/* DISC_INT_RES_EVT */ {BTA_HF_CLIENT_FREE_DB, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
+/* DISC_OK_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+/* DISC_FAIL_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+/* SCO_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+/* SCO_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+/* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
+};
+
+/* type for state table */
+typedef const UINT8 (*tBTA_HF_CLIENT_ST_TBL)[BTA_HF_CLIENT_NUM_COLS];
+
+/* state table */
+const tBTA_HF_CLIENT_ST_TBL bta_hf_client_st_tbl[] =
+{
+ bta_hf_client_st_init,
+ bta_hf_client_st_opening,
+ bta_hf_client_st_open,
+ bta_hf_client_st_closing
+};
+
+/* HF Client control block */
+tBTA_HF_CLIENT_CB bta_hf_client_cb;
+
+/*******************************************************************************
+**
+** Function bta_hf_client_scb_init
+**
+** Description Initialize an HF_Client service control block.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_scb_init(void)
+{
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ memset(&bta_hf_client_cb.scb, 0, sizeof(tBTA_HF_CLIENT_SCB));
+ bta_hf_client_cb.scb.sco_idx = BTM_INVALID_SCO_INDEX;
+ bta_hf_client_cb.scb.negotiated_codec = BTM_SCO_CODEC_CVSD;
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_scb_disable
+**
+** Description Disable a service control block.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_scb_disable(void)
+{
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ bta_hf_client_scb_init();
+
+ (*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_DISABLE_EVT, NULL);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_resume_open
+**
+** Description Resume opening process.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_resume_open (void)
+{
+ APPL_TRACE_DEBUG1 ("%s", __FUNCTION__);
+
+ /* resume opening process. */
+ if (bta_hf_client_cb.scb.state == BTA_HF_CLIENT_INIT_ST)
+ {
+ bta_hf_client_cb.scb.state = BTA_HF_CLIENT_OPENING_ST;
+ bta_hf_client_start_open (NULL);
+ }
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_colli_timer_cback
+**
+** Description HF Client connection collision timer callback
+**
+**
+** Returns void
+**
+*******************************************************************************/
+static void bta_hf_client_colli_timer_cback (TIMER_LIST_ENT *p_tle)
+{
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (p_tle)
+ {
+ bta_hf_client_cb.scb.colli_tmr_on = FALSE;
+
+ /* If the peer haven't opened connection, restart opening process */
+ bta_hf_client_resume_open ();
+ }
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_collision_cback
+**
+** Description Get notified about collision.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_collision_cback (tBTA_SYS_CONN_STATUS status, UINT8 id,
+ UINT8 app_id, BD_ADDR peer_addr)
+{
+ UNUSED(status);
+ UNUSED(app_id);
+ UNUSED(peer_addr);
+
+ if (bta_hf_client_cb.scb.state == BTA_HF_CLIENT_OPENING_ST)
+ {
+ if (id == BTA_ID_SYS) /* ACL collision */
+ {
+ APPL_TRACE_WARNING0 ("HF Client found collision (ACL) ...");
+ }
+ else if (id == BTA_ID_HS) /* RFCOMM collision */
+ {
+ APPL_TRACE_WARNING0 ("HF Client found collision (RFCOMM) ...");
+ }
+ else
+ {
+ APPL_TRACE_WARNING0 ("HF Client found collision (\?\?\?) ...");
+ }
+
+ bta_hf_client_cb.scb.state = BTA_HF_CLIENT_INIT_ST;
+
+ /* Cancel SDP if it had been started. */
+ if(bta_hf_client_cb.scb.p_disc_db)
+ {
+ (void)SDP_CancelServiceSearch (bta_hf_client_cb.scb.p_disc_db);
+ bta_hf_client_free_db(NULL);
+ }
+
+ /* reopen registered server */
+ /* Collision may be detected before or after we close servers. */
+ bta_hf_client_start_server();
+
+ /* Start timer to handle connection opening restart */
+ bta_hf_client_cb.scb.colli_timer.p_cback = (TIMER_CBACK*)&bta_hf_client_colli_timer_cback;
+ bta_sys_start_timer(&bta_hf_client_cb.scb.colli_timer, 0, BTA_HF_CLIENT_COLLISION_TIMER);
+ bta_hf_client_cb.scb.colli_tmr_on = TRUE;
+ }
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_api_enable
+**
+** Description Handle an API enable event.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+static void bta_hf_client_api_enable(tBTA_HF_CLIENT_DATA *p_data)
+{
+ char value[PROPERTY_VALUE_MAX];
+
+ /* initialize control block */
+ memset(&bta_hf_client_cb, 0, sizeof(tBTA_HF_CLIENT_CB));
+
+ /* store callback function */
+ bta_hf_client_cb.p_cback = p_data->api_enable.p_cback;
+
+ /* check if mSBC support enabled */
+ property_get("ro.bluetooth.hfp.ver", value, "0");
+ if (strcmp(value,"1.6") == 0)
+ {
+ bta_hf_client_cb.msbc_enabled = TRUE;
+ }
+
+ bta_hf_client_cb.scb.negotiated_codec = BTM_SCO_CODEC_CVSD;
+
+ /* set same setting as AG does */
+ BTM_WriteVoiceSettings(AG_VOICE_SETTINGS);
+
+ bta_sys_collision_register (BTA_ID_HS, bta_hf_client_collision_cback);
+
+ /* call callback with enable event */
+ (*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_ENABLE_EVT, NULL);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_api_disable
+**
+** Description Handle an API disable event.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+static void bta_hf_client_api_disable(tBTA_HF_CLIENT_DATA *p_data)
+{
+ if (!bta_sys_is_register (BTA_ID_HS))
+ {
+ APPL_TRACE_ERROR0("BTA HF Client is already disabled, ignoring ...");
+ return;
+ }
+
+ /* De-register with BTA system manager */
+ bta_sys_deregister(BTA_ID_HS);
+
+ bta_hf_client_sm_execute(BTA_HF_CLIENT_API_DEREGISTER_EVT, p_data);
+
+ bta_sys_collision_register (BTA_ID_HS, NULL);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_hdl_event
+**
+** Description Data HF Client main event handling function.
+**
+**
+** Returns BOOLEAN
+**
+*******************************************************************************/
+BOOLEAN bta_hf_client_hdl_event(BT_HDR *p_msg)
+{
+#if BTA_HF_CLIENT_DEBUG == TRUE
+ APPL_TRACE_DEBUG2("bta_hf_client_hdl_event %s (0x%x)", bta_hf_client_evt_str(p_msg->event), p_msg->event);
+#endif
+
+ switch (p_msg->event)
+ {
+ /* handle enable event */
+ case BTA_HF_CLIENT_API_ENABLE_EVT:
+ bta_hf_client_api_enable((tBTA_HF_CLIENT_DATA *) p_msg);
+ break;
+
+ /* handle disable event */
+ case BTA_HF_CLIENT_API_DISABLE_EVT:
+ bta_hf_client_api_disable((tBTA_HF_CLIENT_DATA *) p_msg);
+ break;
+
+ default:
+ bta_hf_client_sm_execute(p_msg->event, (tBTA_HF_CLIENT_DATA *) p_msg);
+ break;
+ }
+ return TRUE;
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_sm_execute
+**
+** Description State machine event handling function for HF Client
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_sm_execute(UINT16 event, tBTA_HF_CLIENT_DATA *p_data)
+{
+ tBTA_HF_CLIENT_ST_TBL state_table;
+ UINT8 action;
+ int i;
+
+#if BTA_HF_CLIENT_DEBUG == TRUE
+ UINT16 in_event = event;
+ UINT8 in_state = bta_hf_client_cb.scb.state;
+
+ /* Ignore displaying of AT results when not connected (Ignored in state machine) */
+ if (bta_hf_client_cb.scb.state == BTA_HF_CLIENT_OPEN_ST)
+ {
+ APPL_TRACE_EVENT4("HF Client evt : State %d (%s), Event 0x%04x (%s)",
+ bta_hf_client_cb.scb.state,
+ bta_hf_client_state_str(bta_hf_client_cb.scb.state),
+ event, bta_hf_client_evt_str(event));
+ }
+#endif
+
+ event &= 0x00FF;
+ if (event >= (BTA_HF_CLIENT_MAX_EVT & 0x00FF))
+ {
+ APPL_TRACE_ERROR0("HF Client evt out of range, ignoring...");
+ return;
+ }
+
+ /* look up the state table for the current state */
+ state_table = bta_hf_client_st_tbl[bta_hf_client_cb.scb.state];
+
+ /* set next state */
+ bta_hf_client_cb.scb.state = state_table[event][BTA_HF_CLIENT_NEXT_STATE];
+
+ /* execute action functions */
+ for (i = 0; i < BTA_HF_CLIENT_ACTIONS; i++)
+ {
+ if ((action = state_table[event][i]) != BTA_HF_CLIENT_IGNORE)
+ {
+ (*bta_hf_client_action[action])(p_data);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+#if BTA_HF_CLIENT_DEBUG == TRUE
+ if (bta_hf_client_cb.scb.state != in_state)
+ {
+ APPL_TRACE_EVENT3("BTA HF Client State Change: [%s] -> [%s] after Event [%s]",
+ bta_hf_client_state_str(in_state),
+ bta_hf_client_state_str(bta_hf_client_cb.scb.state),
+ bta_hf_client_evt_str(in_event));
+ }
+#endif
+}
+
+static void send_post_slc_cmd(void)
+{
+ bta_hf_client_cb.scb.at_cb.current_cmd = BTA_HF_CLIENT_AT_NONE;
+
+ bta_hf_client_send_at_bia();
+ bta_hf_client_send_at_ccwa(TRUE);
+ bta_hf_client_send_at_cmee(TRUE);
+ bta_hf_client_send_at_cops(FALSE);
+ bta_hf_client_send_at_btrh(TRUE, 0);
+ bta_hf_client_send_at_clip(TRUE);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_slc_seq
+**
+** Description Handles AT commands sequence required for SLC creation
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_slc_seq(BOOLEAN error)
+{
+ APPL_TRACE_DEBUG1("bta_hf_client_slc_seq cmd: %u", bta_hf_client_cb.scb.at_cb.current_cmd);
+
+ if (error) {
+ /* SLC establishment error, sent close rfcomm event */
+ APPL_TRACE_ERROR1("HFPClient: Failed to create SLC due to AT error, disconnecting (%u)",
+ bta_hf_client_cb.scb.at_cb.current_cmd);
+
+ bta_hf_client_sm_execute(BTA_HF_CLIENT_API_CLOSE_EVT, NULL);
+ return;
+ }
+
+ if (bta_hf_client_cb.scb.svc_conn)
+ return;
+
+ switch (bta_hf_client_cb.scb.at_cb.current_cmd)
+ {
+ case BTA_HF_CLIENT_AT_NONE:
+ bta_hf_client_send_at_brsf();
+ break;
+
+ case BTA_HF_CLIENT_AT_BRSF:
+ if (bta_hf_client_cb.scb.peer_features & BTA_HF_CLIENT_PEER_CODEC)
+ {
+ bta_hf_client_send_at_bac();
+ break;
+ }
+
+ bta_hf_client_send_at_cind(FALSE);
+ break;
+
+ case BTA_HF_CLIENT_AT_BAC:
+ bta_hf_client_send_at_cind(FALSE);
+ break;
+
+ case BTA_HF_CLIENT_AT_CIND:
+ bta_hf_client_send_at_cind(TRUE);
+ break;
+
+ case BTA_HF_CLIENT_AT_CIND_STATUS:
+ bta_hf_client_send_at_cmer(TRUE);
+ break;
+
+ case BTA_HF_CLIENT_AT_CMER:
+ if (bta_hf_client_cb.scb.peer_features & BTA_HF_CLIENT_PEER_FEAT_3WAY)
+ {
+ bta_hf_client_send_at_chld('?', 0);
+ }
+ else
+ {
+ bta_hf_client_svc_conn_open(NULL);
+ send_post_slc_cmd();
+ }
+ break;
+
+ case BTA_HF_CLIENT_AT_CHLD:
+ bta_hf_client_svc_conn_open(NULL);
+ send_post_slc_cmd();
+ break;
+
+ default:
+ /* If happen there is a bug in SLC creation procedure... */
+ APPL_TRACE_ERROR1("HFPClient: Failed to create SLCdue to unexpected AT command, disconnecting (%u)",
+ bta_hf_client_cb.scb.at_cb.current_cmd);
+
+ bta_hf_client_sm_execute(BTA_HF_CLIENT_API_CLOSE_EVT, NULL);
+ break;
+ }
+}
+
+#if BTA_HF_CLIENT_DEBUG == TRUE
+
+#ifndef CASE_RETURN_STR
+#define CASE_RETURN_STR(const) case const: return #const;
+#endif
+
+static char *bta_hf_client_evt_str(UINT16 event)
+{
+ switch (event)
+ {
+ CASE_RETURN_STR(BTA_HF_CLIENT_API_REGISTER_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_API_DEREGISTER_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_API_OPEN_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_API_CLOSE_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_API_AUDIO_OPEN_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_API_AUDIO_CLOSE_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_RFC_OPEN_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_RFC_CLOSE_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_RFC_SRV_CLOSE_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_RFC_DATA_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_DISC_ACP_RES_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_DISC_INT_RES_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_DISC_OK_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_DISC_FAIL_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_API_ENABLE_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_API_DISABLE_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_SCO_OPEN_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_SCO_CLOSE_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_SEND_AT_CMD_EVT)
+ default:
+ return "Unknown HF Client Event";
+ }
+}
+
+static char *bta_hf_client_state_str(UINT8 state)
+{
+ switch (state)
+ {
+ CASE_RETURN_STR(BTA_HF_CLIENT_INIT_ST)
+ CASE_RETURN_STR(BTA_HF_CLIENT_OPENING_ST)
+ CASE_RETURN_STR(BTA_HF_CLIENT_OPEN_ST)
+ CASE_RETURN_STR(BTA_HF_CLIENT_CLOSING_ST)
+ default:
+ return "Unknown HF Client State";
+ }
+}
+#endif
diff --git a/bta/hf_client/bta_hf_client_rfc.c b/bta/hf_client/bta_hf_client_rfc.c
new file mode 100644
index 0000000..b71f919
--- /dev/null
+++ b/bta/hf_client/bta_hf_client_rfc.c
@@ -0,0 +1,268 @@
+/******************************************************************************
+ *
+ * Copyright (c) 2014 The Android Open Source Project
+ * Copyright (C) 2004-2012 Broadcom 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.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the audio gateway functions controlling the RFCOMM
+ * connections.
+ *
+ ******************************************************************************/
+
+#include <string.h>
+#include "bta_api.h"
+#include "bta_hf_client_int.h"
+#include "port_api.h"
+#include "bd.h"
+#include "bt_utils.h"
+
+/*******************************************************************************
+**
+** Function bta_hf_client_port_cback
+**
+** Description RFCOMM Port callback
+**
+**
+** Returns void
+**
+*******************************************************************************/
+static void bta_hf_client_port_cback(UINT32 code, UINT16 port_handle)
+{
+ BT_HDR *p_buf;
+ UNUSED(code);
+
+ /* ignore port events for port handles other than connected handle */
+ if (port_handle != bta_hf_client_cb.scb.conn_handle)
+ {
+ APPL_TRACE_DEBUG2("bta_hf_client_port_cback ignoring handle:%d conn_handle = %d",
+ port_handle, bta_hf_client_cb.scb.conn_handle);
+ return;
+ }
+
+ if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+ {
+ p_buf->event = BTA_HF_CLIENT_RFC_DATA_EVT;
+ bta_sys_sendmsg(p_buf);
+ }
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_mgmt_cback
+**
+** Description RFCOMM management callback
+**
+**
+** Returns void
+**
+*******************************************************************************/
+static void bta_hf_client_mgmt_cback(UINT32 code, UINT16 port_handle)
+{
+ tBTA_HF_CLIENT_RFC *p_buf;
+ UINT16 event;
+
+ APPL_TRACE_DEBUG4("bta_hf_client_mgmt_cback : code = %d, port_handle = %d, conn_handle = %d, serv_handle = %d",
+ code, port_handle, bta_hf_client_cb.scb.conn_handle, bta_hf_client_cb.scb.serv_handle);
+
+ /* ignore close event for port handles other than connected handle */
+ if ((code != PORT_SUCCESS) && (port_handle != bta_hf_client_cb.scb.conn_handle))
+ {
+ APPL_TRACE_DEBUG1("bta_hf_client_mgmt_cback ignoring handle:%d", port_handle);
+ return;
+ }
+
+ if (code == PORT_SUCCESS)
+ {
+ if ((bta_hf_client_cb.scb.conn_handle && (port_handle == bta_hf_client_cb.scb.conn_handle)) || /* outgoing connection */
+ (port_handle == bta_hf_client_cb.scb.serv_handle)) /* incoming connection */
+ {
+ event = BTA_HF_CLIENT_RFC_OPEN_EVT;
+ }
+ else
+ {
+ APPL_TRACE_ERROR1 ("bta_hf_client_mgmt_cback: PORT_SUCCESS, ignoring handle = %d", port_handle);
+ return;
+ }
+ }
+ /* distinguish server close events */
+ else if (port_handle == bta_hf_client_cb.scb.conn_handle)
+ {
+ event = BTA_HF_CLIENT_RFC_CLOSE_EVT;
+ }
+ else
+ {
+ event = BTA_HF_CLIENT_RFC_SRV_CLOSE_EVT;
+ }
+
+ if ((p_buf = (tBTA_HF_CLIENT_RFC *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_RFC))) != NULL)
+ {
+ p_buf->hdr.event = event;
+ p_buf->port_handle = port_handle;
+ bta_sys_sendmsg(p_buf);
+ }
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_setup_port
+**
+** Description Setup RFCOMM port for use by HF Client.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_setup_port(UINT16 handle)
+{
+ PORT_SetEventMask(handle, PORT_EV_RXCHAR);
+ PORT_SetEventCallback(handle, bta_hf_client_port_cback);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_start_server
+**
+** Description Setup RFCOMM server for use by HF Client.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_start_server(void)
+{
+ int i;
+ int port_status;
+
+ if (bta_hf_client_cb.scb.serv_handle > 0)
+ {
+ APPL_TRACE_DEBUG2("%s already started, handle: %d", __FUNCTION__, bta_hf_client_cb.scb.serv_handle);
+ return;
+ }
+
+ BTM_SetSecurityLevel(FALSE, "", BTM_SEC_SERVICE_HF_HANDSFREE, bta_hf_client_cb.scb.serv_sec_mask,
+ BT_PSM_RFCOMM, BTM_SEC_PROTO_RFCOMM, bta_hf_client_cb.scn);
+
+ port_status = RFCOMM_CreateConnection(UUID_SERVCLASS_HF_HANDSFREE, bta_hf_client_cb.scn,
+ TRUE, BTA_HF_CLIENT_MTU, (UINT8 *) bd_addr_any, &(bta_hf_client_cb.scb.serv_handle),
+ bta_hf_client_mgmt_cback);
+
+ if (port_status == PORT_SUCCESS)
+ {
+ bta_hf_client_setup_port(bta_hf_client_cb.scb.serv_handle);
+ }
+ else
+ {
+ /* TODO: can we handle this better? */
+ APPL_TRACE_DEBUG1("bta_hf_client_start_server: RFCOMM_CreateConnection returned error:%d", port_status);
+ }
+
+ APPL_TRACE_DEBUG1("bta_hf_client_start_server handle: %d", bta_hf_client_cb.scb.serv_handle);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_close_server
+**
+** Description Close RFCOMM server port for use by HF Client.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_close_server(void)
+{
+ APPL_TRACE_DEBUG2("%s %d", __FUNCTION__, bta_hf_client_cb.scb.serv_handle);
+
+ if (bta_hf_client_cb.scb.serv_handle == 0)
+ {
+ APPL_TRACE_DEBUG1("%s already stopped", __FUNCTION__);
+ return;
+ }
+
+ RFCOMM_RemoveServer(bta_hf_client_cb.scb.serv_handle);
+ bta_hf_client_cb.scb.serv_handle = 0;
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_rfc_do_open
+**
+** Description Open an RFCOMM connection to the peer device.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_rfc_do_open(tBTA_HF_CLIENT_DATA *p_data)
+{
+ BTM_SetSecurityLevel(TRUE, "", BTM_SEC_SERVICE_HF_HANDSFREE,
+ bta_hf_client_cb.scb.cli_sec_mask, BT_PSM_RFCOMM,
+ BTM_SEC_PROTO_RFCOMM, bta_hf_client_cb.scb.peer_scn);
+
+ if (RFCOMM_CreateConnection(UUID_SERVCLASS_HF_HANDSFREE, bta_hf_client_cb.scb.peer_scn,
+ FALSE, BTA_HF_CLIENT_MTU, bta_hf_client_cb.scb.peer_addr, &(bta_hf_client_cb.scb.conn_handle),
+ bta_hf_client_mgmt_cback) == PORT_SUCCESS)
+ {
+ bta_hf_client_setup_port(bta_hf_client_cb.scb.conn_handle);
+ APPL_TRACE_DEBUG1("bta_hf_client_rfc_do_open : conn_handle = %d", bta_hf_client_cb.scb.conn_handle);
+ }
+ /* RFCOMM create connection failed; send ourselves RFCOMM close event */
+ else
+ {
+ bta_hf_client_sm_execute(BTA_HF_CLIENT_RFC_CLOSE_EVT, p_data);
+ }
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_rfc_do_close
+**
+** Description Close RFCOMM connection.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_rfc_do_close(tBTA_HF_CLIENT_DATA *p_data)
+{
+ tBTA_HF_CLIENT_RFC *p_buf;
+ UNUSED(p_data);
+
+ if (bta_hf_client_cb.scb.conn_handle)
+ {
+ RFCOMM_RemoveConnection(bta_hf_client_cb.scb.conn_handle);
+ }
+ else
+ {
+ /* Close API was called while HF Client is in Opening state. */
+ /* Need to trigger the state machine to send callback to the app */
+ /* and move back to INIT state. */
+ if ((p_buf = (tBTA_HF_CLIENT_RFC *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_RFC))) != NULL)
+ {
+ p_buf->hdr.event = BTA_HF_CLIENT_RFC_CLOSE_EVT;
+ bta_sys_sendmsg(p_buf);
+ }
+
+ /* Cancel SDP if it had been started. */
+ if(bta_hf_client_cb.scb.p_disc_db)
+ {
+ (void)SDP_CancelServiceSearch (bta_hf_client_cb.scb.p_disc_db);
+ bta_hf_client_free_db(NULL);
+ }
+ }
+}
diff --git a/bta/hf_client/bta_hf_client_sco.c b/bta/hf_client/bta_hf_client_sco.c
new file mode 100644
index 0000000..224dcc6
--- /dev/null
+++ b/bta/hf_client/bta_hf_client_sco.c
@@ -0,0 +1,734 @@
+/******************************************************************************
+ *
+ * Copyright (c) 2014 The Android Open Source Project
+ * Copyright (C) 2004-2012 Broadcom 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 "bta_hf_client_int.h"
+#include <bt_trace.h>
+#include <bd.h>
+#include <string.h>
+#include "bt_utils.h"
+
+#define BTA_HF_CLIENT_NO_EDR_ESCO (BTM_SCO_PKT_TYPES_MASK_NO_2_EV3 | \
+ BTM_SCO_PKT_TYPES_MASK_NO_3_EV3 | \
+ BTM_SCO_PKT_TYPES_MASK_NO_2_EV5 | \
+ BTM_SCO_PKT_TYPES_MASK_NO_3_EV5)
+
+static const tBTM_ESCO_PARAMS bta_hf_client_esco_params[] = {
+ /* SCO CVSD */
+ {
+ .rx_bw = BTM_64KBITS_RATE,
+ .tx_bw = BTM_64KBITS_RATE,
+ .max_latency = 10,
+ .voice_contfmt = BTM_VOICE_SETTING_CVSD,
+ .packet_types = (BTM_SCO_LINK_ONLY_MASK |
+ BTM_SCO_PKT_TYPES_MASK_NO_2_EV3 |
+ BTM_SCO_PKT_TYPES_MASK_NO_3_EV3 |
+ BTM_SCO_PKT_TYPES_MASK_NO_2_EV5 |
+ BTM_SCO_PKT_TYPES_MASK_NO_3_EV5),
+ .retrans_effort = BTM_ESCO_RETRANS_POWER,
+ },
+ /* ESCO CVSD */
+ {
+ .rx_bw = BTM_64KBITS_RATE,
+ .tx_bw = BTM_64KBITS_RATE,
+ .max_latency = 10,
+ .voice_contfmt = BTM_VOICE_SETTING_CVSD,
+ /* Allow controller to use all types available except 5-slot EDR */
+ .packet_types = (BTM_SCO_LINK_ALL_PKT_MASK |
+ BTM_SCO_PKT_TYPES_MASK_NO_2_EV5 |
+ BTM_SCO_PKT_TYPES_MASK_NO_3_EV5),
+ .retrans_effort = BTM_ESCO_RETRANS_POWER,
+ },
+ /* ESCO mSBC */
+ {
+ .rx_bw = BTM_64KBITS_RATE,
+ .tx_bw = BTM_64KBITS_RATE,
+ .max_latency = 13,
+ .voice_contfmt = BTM_VOICE_SETTING_TRANS,
+ /* Packet Types : EV3 + 2-EV3 */
+ .packet_types = (BTM_SCO_PKT_TYPES_MASK_EV3 |
+ BTM_SCO_PKT_TYPES_MASK_NO_3_EV3 |
+ BTM_SCO_PKT_TYPES_MASK_NO_2_EV5 |
+ BTM_SCO_PKT_TYPES_MASK_NO_3_EV5),
+ .retrans_effort = BTM_ESCO_RETRANS_QUALITY,
+ }
+};
+
+enum
+{
+ BTA_HF_CLIENT_SCO_LISTEN_E,
+ BTA_HF_CLIENT_SCO_OPEN_E, /* open request */
+ BTA_HF_CLIENT_SCO_CLOSE_E, /* close request */
+ BTA_HF_CLIENT_SCO_SHUTDOWN_E, /* shutdown request */
+ BTA_HF_CLIENT_SCO_CONN_OPEN_E, /* sco opened */
+ BTA_HF_CLIENT_SCO_CONN_CLOSE_E, /* sco closed */
+};
+
+/*******************************************************************************
+**
+** Function bta_hf_client_remove_sco
+**
+** Description Removes the specified SCO from the system.
+** If only_active is TRUE, then SCO is only removed if connected
+**
+** Returns BOOLEAN - TRUE if Sco removal was started
+**
+*******************************************************************************/
+static BOOLEAN bta_hf_client_sco_remove(BOOLEAN only_active)
+{
+ BOOLEAN removed_started = FALSE;
+ tBTM_STATUS status;
+
+ APPL_TRACE_DEBUG2("%s %d", __FUNCTION__, only_active);
+
+ if (bta_hf_client_cb.scb.sco_idx != BTM_INVALID_SCO_INDEX)
+ {
+ status = BTM_RemoveSco(bta_hf_client_cb.scb.sco_idx);
+
+ APPL_TRACE_DEBUG3("%s idx 0x%04x, status:0x%x", __FUNCTION__, bta_hf_client_cb.scb.sco_idx, status);
+
+ if (status == BTM_CMD_STARTED)
+ {
+ removed_started = TRUE;
+ }
+ /* If no connection reset the sco handle */
+ else if ( (status == BTM_SUCCESS) || (status == BTM_UNKNOWN_ADDR) )
+ {
+ bta_hf_client_cb.scb.sco_idx = BTM_INVALID_SCO_INDEX;
+ }
+ }
+ return removed_started;
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_cback_sco
+**
+** Description Call application callback function with SCO event.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_cback_sco(UINT8 event)
+{
+ tBTA_HF_CLIENT evt;
+
+ memset(&evt, 0, sizeof(evt));
+
+ /* call app cback */
+ (*bta_hf_client_cb.p_cback)(event, (tBTA_HF_CLIENT *) &evt);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_sco_conn_rsp
+**
+** Description Process the SCO connection request
+**
+**
+** Returns void
+**
+*******************************************************************************/
+static void bta_hf_client_sco_conn_rsp(tBTM_ESCO_CONN_REQ_EVT_DATA *p_data)
+{
+ tBTM_ESCO_PARAMS resp;
+ UINT8 hci_status = HCI_SUCCESS;
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ if (bta_hf_client_cb.scb.sco_state == BTA_HF_CLIENT_SCO_LISTEN_ST)
+ {
+ if (p_data->link_type == BTM_LINK_TYPE_SCO)
+ {
+ resp = bta_hf_client_esco_params[0];
+ }
+ else
+ {
+ resp = bta_hf_client_esco_params[bta_hf_client_cb.scb.negotiated_codec];
+ }
+
+ /* tell sys to stop av if any */
+ bta_sys_sco_use(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);
+ }
+ else
+ {
+ hci_status = HCI_ERR_HOST_REJECT_DEVICE;
+ }
+
+ BTM_EScoConnRsp(p_data->sco_inx, hci_status, &resp);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_sco_connreq_cback
+**
+** Description BTM eSCO connection requests and eSCO change requests
+** Only the connection requests are processed by BTA.
+**
+** Returns void
+**
+*******************************************************************************/
+static void bta_hf_client_esco_connreq_cback(tBTM_ESCO_EVT event, tBTM_ESCO_EVT_DATA *p_data)
+{
+ APPL_TRACE_DEBUG2("%s %d", __FUNCTION__, event);
+
+ if (event != BTM_ESCO_CONN_REQ_EVT)
+ {
+ return;
+ }
+
+ /* TODO check remote bdaddr, should allow connect only from device with
+ * active SLC */
+
+ bta_hf_client_cb.scb.sco_idx = p_data->conn_evt.sco_inx;
+
+ bta_hf_client_sco_conn_rsp(&p_data->conn_evt);
+
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_OPENING_ST;
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_sco_conn_cback
+**
+** Description BTM SCO connection callback.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+static void bta_hf_client_sco_conn_cback(UINT16 sco_idx)
+{
+ BT_HDR *p_buf;
+ UINT8 *rem_bd;
+
+ APPL_TRACE_DEBUG2("%s %d", __FUNCTION__, sco_idx);
+
+ rem_bd = BTM_ReadScoBdAddr(sco_idx);
+
+ if (rem_bd && bdcmp(bta_hf_client_cb.scb.peer_addr, rem_bd) == 0 &&
+ bta_hf_client_cb.scb.svc_conn && bta_hf_client_cb.scb.sco_idx == sco_idx)
+ {
+ if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+ {
+ p_buf->event = BTA_HF_CLIENT_SCO_OPEN_EVT;
+ p_buf->layer_specific = bta_hf_client_cb.scb.conn_handle;
+ bta_sys_sendmsg(p_buf);
+ }
+ }
+ /* no match found; disconnect sco, init sco variables */
+ else
+ {
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTDOWN_ST;
+ BTM_RemoveSco(sco_idx);
+ }
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_sco_disc_cback
+**
+** Description BTM SCO disconnection callback.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+static void bta_hf_client_sco_disc_cback(UINT16 sco_idx)
+{
+ BT_HDR *p_buf;
+
+ APPL_TRACE_DEBUG2("%s %d", __FUNCTION__, sco_idx);
+
+ if (bta_hf_client_cb.scb.sco_idx == sco_idx)
+ {
+ if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+ {
+ p_buf->event = BTA_HF_CLIENT_SCO_CLOSE_EVT;
+ p_buf->layer_specific = bta_hf_client_cb.scb.conn_handle;;
+ bta_sys_sendmsg(p_buf);
+ }
+ }
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_create_sco
+**
+** Description
+**
+**
+** Returns void
+**
+*******************************************************************************/
+static void bta_hf_client_sco_create(BOOLEAN is_orig)
+{
+ tBTM_STATUS status;
+ UINT8 *p_bd_addr = NULL;
+ tBTM_ESCO_PARAMS params;
+
+ APPL_TRACE_DEBUG2("%s %d", __FUNCTION__, is_orig);
+
+ /* Make sure this sco handle is not already in use */
+ if (bta_hf_client_cb.scb.sco_idx != BTM_INVALID_SCO_INDEX)
+ {
+ APPL_TRACE_WARNING2("%s: Index 0x%04x already in use", __FUNCTION__,
+ bta_hf_client_cb.scb.sco_idx);
+ return;
+ }
+
+ params = bta_hf_client_esco_params[1];
+
+ /* if initiating set current scb and peer bd addr */
+ if (is_orig)
+ {
+ /* Attempt to use eSCO if remote host supports HFP >= 1.5 */
+ if (bta_hf_client_cb.scb.peer_version >= HFP_VERSION_1_5 && !bta_hf_client_cb.scb.retry_with_sco_only)
+ {
+ BTM_SetEScoMode(BTM_LINK_TYPE_ESCO, ¶ms);
+ /* If ESCO or EDR ESCO, retry with SCO only in case of failure */
+ if((params.packet_types & BTM_ESCO_LINK_ONLY_MASK)
+ ||!((params.packet_types & ~(BTM_ESCO_LINK_ONLY_MASK | BTM_SCO_LINK_ONLY_MASK)) ^ BTA_HF_CLIENT_NO_EDR_ESCO))
+ {
+ bta_hf_client_cb.scb.retry_with_sco_only = TRUE;
+ APPL_TRACE_API0("Setting retry_with_sco_only to TRUE");
+ }
+ }
+ else
+ {
+ if(bta_hf_client_cb.scb.retry_with_sco_only)
+ APPL_TRACE_API0("retrying with SCO only");
+ bta_hf_client_cb.scb.retry_with_sco_only = FALSE;
+
+ BTM_SetEScoMode(BTM_LINK_TYPE_SCO, ¶ms);
+ }
+
+ /* tell sys to stop av if any */
+ bta_sys_sco_use(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);
+ }
+ else
+ {
+ bta_hf_client_cb.scb.retry_with_sco_only = FALSE;
+ }
+
+ p_bd_addr = bta_hf_client_cb.scb.peer_addr;
+
+ status = BTM_CreateSco(p_bd_addr, is_orig, params.packet_types,
+ &bta_hf_client_cb.scb.sco_idx, bta_hf_client_sco_conn_cback,
+ bta_hf_client_sco_disc_cback);
+ if (status == BTM_CMD_STARTED && !is_orig)
+ {
+ if(!BTM_RegForEScoEvts(bta_hf_client_cb.scb.sco_idx, bta_hf_client_esco_connreq_cback))
+ APPL_TRACE_DEBUG1("%s SCO registration success", __FUNCTION__);
+ }
+
+ APPL_TRACE_API5("%s: orig %d, inx 0x%04x, status 0x%x, pkt types 0x%04x",
+ __FUNCTION__, is_orig, bta_hf_client_cb.scb.sco_idx,
+ status, params.packet_types);
+}
+
+
+/*******************************************************************************
+**
+** Function bta_hf_client_sco_event
+**
+** Description Handle SCO events
+**
+**
+** Returns void
+**
+*******************************************************************************/
+static void bta_hf_client_sco_event(UINT8 event)
+{
+ APPL_TRACE_DEBUG3("%s state: %d event: %d", __FUNCTION__,
+ bta_hf_client_cb.scb.sco_state, event);
+
+ switch (bta_hf_client_cb.scb.sco_state)
+ {
+ case BTA_HF_CLIENT_SCO_SHUTDOWN_ST:
+ switch (event)
+ {
+ case BTA_HF_CLIENT_SCO_LISTEN_E:
+ /* create sco listen connection */
+ bta_hf_client_sco_create(FALSE);
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_LISTEN_ST;
+ break;
+
+ default:
+ APPL_TRACE_WARNING1("BTA_HF_CLIENT_SCO_SHUTDOWN_ST: Ignoring event %d", event);
+ break;
+ }
+ break;
+
+ case BTA_HF_CLIENT_SCO_LISTEN_ST:
+ switch (event)
+ {
+ case BTA_HF_CLIENT_SCO_LISTEN_E:
+ /* create sco listen connection (Additional channel) */
+ bta_hf_client_sco_create(FALSE);
+ break;
+
+ case BTA_HF_CLIENT_SCO_OPEN_E:
+ /* remove listening connection */
+ bta_hf_client_sco_remove(FALSE);
+
+ /* create sco connection to peer */
+ bta_hf_client_sco_create(TRUE);
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_OPENING_ST;
+ break;
+
+ case BTA_HF_CLIENT_SCO_SHUTDOWN_E:
+ /* remove listening connection */
+ bta_hf_client_sco_remove(FALSE);
+
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTDOWN_ST;
+ break;
+
+ case BTA_HF_CLIENT_SCO_CLOSE_E:
+ /* remove listening connection */
+ /* Ignore the event. We need to keep listening SCO for the active SLC */
+ APPL_TRACE_WARNING1("BTA_HF_CLIENT_SCO_LISTEN_ST: Ignoring event %d", event);
+ break;
+
+ case BTA_HF_CLIENT_SCO_CONN_CLOSE_E:
+ /* sco failed; create sco listen connection */
+ bta_hf_client_sco_create(FALSE);
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_LISTEN_ST;
+ break;
+
+ default:
+ APPL_TRACE_WARNING1("BTA_HF_CLIENT_SCO_LISTEN_ST: Ignoring event %d", event);
+ break;
+ }
+ break;
+
+ case BTA_HF_CLIENT_SCO_OPENING_ST:
+ switch (event)
+ {
+ case BTA_HF_CLIENT_SCO_CLOSE_E:
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_OPEN_CL_ST;
+ break;
+
+ case BTA_HF_CLIENT_SCO_SHUTDOWN_E:
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTTING_ST;
+ break;
+
+ case BTA_HF_CLIENT_SCO_CONN_OPEN_E:
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_OPEN_ST;
+ break;
+
+ case BTA_HF_CLIENT_SCO_CONN_CLOSE_E:
+ /* sco failed; create sco listen connection */
+ bta_hf_client_sco_create(FALSE);
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_LISTEN_ST;
+ break;
+
+ default:
+ APPL_TRACE_WARNING1("BTA_HF_CLIENT_SCO_OPENING_ST: Ignoring event %d", event);
+ break;
+ }
+ break;
+
+ case BTA_HF_CLIENT_SCO_OPEN_CL_ST:
+ switch (event)
+ {
+ case BTA_HF_CLIENT_SCO_OPEN_E:
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_OPENING_ST;
+ break;
+
+ case BTA_HF_CLIENT_SCO_SHUTDOWN_E:
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTTING_ST;
+ break;
+
+ case BTA_HF_CLIENT_SCO_CONN_OPEN_E:
+ /* close sco connection */
+ bta_hf_client_sco_remove(TRUE);
+
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_CLOSING_ST;
+ break;
+
+ case BTA_HF_CLIENT_SCO_CONN_CLOSE_E:
+ /* sco failed; create sco listen connection */
+
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_LISTEN_ST;
+ break;
+
+ default:
+ APPL_TRACE_WARNING1("BTA_HF_CLIENT_SCO_OPEN_CL_ST: Ignoring event %d", event);
+ break;
+ }
+ break;
+
+ case BTA_HF_CLIENT_SCO_OPEN_ST:
+ switch (event)
+ {
+ case BTA_HF_CLIENT_SCO_CLOSE_E:
+ /* close sco connection if active */
+ if (bta_hf_client_sco_remove(TRUE))
+ {
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_CLOSING_ST;
+ }
+ break;
+
+ case BTA_HF_CLIENT_SCO_SHUTDOWN_E:
+ /* remove all listening connections */
+ bta_hf_client_sco_remove(FALSE);
+
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTTING_ST;
+ break;
+
+ case BTA_HF_CLIENT_SCO_CONN_CLOSE_E:
+ /* peer closed sco; create sco listen connection */
+ bta_hf_client_sco_create(FALSE);
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_LISTEN_ST;
+ break;
+
+ default:
+ APPL_TRACE_WARNING1("BTA_HF_CLIENT_SCO_OPEN_ST: Ignoring event %d", event);
+ break;
+ }
+ break;
+
+ case BTA_HF_CLIENT_SCO_CLOSING_ST:
+ switch (event)
+ {
+ case BTA_HF_CLIENT_SCO_OPEN_E:
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_CLOSE_OP_ST;
+ break;
+
+ case BTA_HF_CLIENT_SCO_SHUTDOWN_E:
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTTING_ST;
+ break;
+
+ case BTA_HF_CLIENT_SCO_CONN_CLOSE_E:
+ /* peer closed sco; create sco listen connection */
+ bta_hf_client_sco_create(FALSE);
+
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_LISTEN_ST;
+ break;
+
+ default:
+ APPL_TRACE_WARNING1("BTA_HF_CLIENT_SCO_CLOSING_ST: Ignoring event %d", event);
+ break;
+ }
+ break;
+
+ case BTA_HF_CLIENT_SCO_CLOSE_OP_ST:
+ switch (event)
+ {
+ case BTA_HF_CLIENT_SCO_CLOSE_E:
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_CLOSING_ST;
+ break;
+
+ case BTA_HF_CLIENT_SCO_SHUTDOWN_E:
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTTING_ST;
+ break;
+
+ case BTA_HF_CLIENT_SCO_CONN_CLOSE_E:
+ /* open sco connection */
+ bta_hf_client_sco_create(TRUE);
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_OPENING_ST;
+ break;
+
+ default:
+ APPL_TRACE_WARNING1("BTA_HF_CLIENT_SCO_CLOSE_OP_ST: Ignoring event %d", event);
+ break;
+ }
+ break;
+
+ case BTA_HF_CLIENT_SCO_SHUTTING_ST:
+ switch (event)
+ {
+ case BTA_HF_CLIENT_SCO_CONN_OPEN_E:
+ /* close sco connection; wait for conn close event */
+ bta_hf_client_sco_remove(TRUE);
+ break;
+
+ case BTA_HF_CLIENT_SCO_CONN_CLOSE_E:
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTDOWN_ST;
+ break;
+
+ case BTA_HF_CLIENT_SCO_SHUTDOWN_E:
+ bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTDOWN_ST;
+ break;
+
+ default:
+ APPL_TRACE_WARNING1("BTA_HF_CLIENT_SCO_SHUTTING_ST: Ignoring event %d", event);
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_sco_listen
+**
+** Description Initialize SCO listener
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_sco_listen(tBTA_HF_CLIENT_DATA *p_data)
+{
+ UNUSED(p_data);
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ bta_hf_client_sco_event(BTA_HF_CLIENT_SCO_LISTEN_E);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_sco_shutdown
+**
+** Description
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_sco_shutdown(tBTA_HF_CLIENT_DATA *p_data)
+{
+ UNUSED(p_data);
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ bta_hf_client_sco_event(BTA_HF_CLIENT_SCO_SHUTDOWN_E);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_sco_conn_open
+**
+** Description
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_sco_conn_open(tBTA_HF_CLIENT_DATA *p_data)
+{
+ UNUSED(p_data);
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ bta_hf_client_sco_event(BTA_HF_CLIENT_SCO_CONN_OPEN_E);
+
+ bta_sys_sco_open(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);
+
+ if (bta_hf_client_cb.scb.negotiated_codec == BTM_SCO_CODEC_MSBC)
+ {
+ bta_hf_client_cback_sco(BTA_HF_CLIENT_AUDIO_MSBC_OPEN_EVT);
+ }
+ else
+ {
+ bta_hf_client_cback_sco(BTA_HF_CLIENT_AUDIO_OPEN_EVT);
+ }
+
+ bta_hf_client_cb.scb.retry_with_sco_only = FALSE;
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_sco_conn_close
+**
+** Description
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_sco_conn_close(tBTA_HF_CLIENT_DATA *p_data)
+{
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ /* clear current scb */
+ bta_hf_client_cb.scb.sco_idx = BTM_INVALID_SCO_INDEX;
+
+ /* retry_with_sco_only, will be set only when initiator
+ ** and HFClient is first trying to establish an eSCO connection */
+ if (bta_hf_client_cb.scb.retry_with_sco_only && bta_hf_client_cb.scb.svc_conn)
+ {
+ bta_hf_client_sco_create(TRUE);
+ }
+ else
+ {
+ bta_hf_client_sco_event(BTA_HF_CLIENT_SCO_CONN_CLOSE_E);
+
+ bta_sys_sco_close(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);
+
+ bta_sys_sco_unuse(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);
+
+ /* call app callback */
+ bta_hf_client_cback_sco(BTA_HF_CLIENT_AUDIO_CLOSE_EVT);
+
+ if (bta_hf_client_cb.scb.sco_close_rfc == TRUE)
+ {
+ bta_hf_client_cb.scb.sco_close_rfc = FALSE;
+ bta_hf_client_rfc_do_close(p_data);
+ }
+ }
+ bta_hf_client_cb.scb.retry_with_sco_only = FALSE;
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_sco_open
+**
+** Description
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_sco_open(tBTA_HF_CLIENT_DATA *p_data)
+{
+ UNUSED(p_data);
+
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
+
+ bta_hf_client_sco_event(BTA_HF_CLIENT_SCO_OPEN_E);
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_sco_close
+**
+** Description
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_sco_close(tBTA_HF_CLIENT_DATA *p_data)
+{
+ UNUSED(p_data);
+
+ APPL_TRACE_DEBUG2("%s 0x%x", __FUNCTION__, bta_hf_client_cb.scb.sco_idx);
+
+ if (bta_hf_client_cb.scb.sco_idx != BTM_INVALID_SCO_INDEX)
+ {
+ bta_hf_client_sco_event(BTA_HF_CLIENT_SCO_CLOSE_E);
+ }
+}
diff --git a/bta/hf_client/bta_hf_client_sdp.c b/bta/hf_client/bta_hf_client_sdp.c
new file mode 100644
index 0000000..f967fbf
--- /dev/null
+++ b/bta/hf_client/bta_hf_client_sdp.c
@@ -0,0 +1,383 @@
+/******************************************************************************
+ *
+ * Copyright (c) 2014 The Android Open Source Project
+ * Copyright (C) 2003-2012 Broadcom 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.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the audio gateway functions performing SDP
+ * operations.
+ *
+ ******************************************************************************/
+
+#include <string.h>
+#include "bta_api.h"
+#include "bta_sys.h"
+#include "bt_utils.h"
+#include "bta_hf_client_api.h"
+#include "bta_hf_client_int.h"
+
+/* Number of protocol elements in protocol element list. */
+#define BTA_HF_CLIENT_NUM_PROTO_ELEMS 2
+
+/* Number of elements in service class id list. */
+#define BTA_HF_CLIENT_NUM_SVC_ELEMS 2
+
+/*******************************************************************************
+**
+** Function bta_hf_client_sdp_cback
+**
+** Description SDP callback function.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+static void bta_hf_client_sdp_cback(UINT16 status)
+{
+ tBTA_HF_CLIENT_DISC_RESULT *p_buf;
+ UINT16 event;
+
+ APPL_TRACE_DEBUG1("bta_hf_client_sdp_cback status:0x%x", status);
+
+ /* set event according to int/acp */
+ if (bta_hf_client_cb.scb.role == BTA_HF_CLIENT_ACP)
+ {
+ event = BTA_HF_CLIENT_DISC_ACP_RES_EVT;
+ }
+ else
+ {
+ event = BTA_HF_CLIENT_DISC_INT_RES_EVT;
+ }
+
+ if ((p_buf = (tBTA_HF_CLIENT_DISC_RESULT *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_DISC_RESULT))) != NULL)
+ {
+ p_buf->hdr.event = event;
+ p_buf->status = status;
+ bta_sys_sendmsg(p_buf);
+ }
+}
+
+/******************************************************************************
+**
+** Function bta_hf_client_add_record
+**
+** Description This function is called by a server application to add
+** HFP Client information to an SDP record. Prior to
+** calling this function the application must call
+** SDP_CreateRecord() to create an SDP record.
+**
+** Returns TRUE if function execution succeeded,
+** FALSE if function execution failed.
+**
+******************************************************************************/
+BOOLEAN bta_hf_client_add_record(char *p_service_name, UINT8 scn,
+ tBTA_HF_CLIENT_FEAT features, UINT32 sdp_handle)
+{
+ tSDP_PROTOCOL_ELEM proto_elem_list[BTA_HF_CLIENT_NUM_PROTO_ELEMS];
+ UINT16 svc_class_id_list[BTA_HF_CLIENT_NUM_SVC_ELEMS];
+ UINT16 browse_list[] = {UUID_SERVCLASS_PUBLIC_BROWSE_GROUP};
+ UINT16 version;
+ UINT16 profile_uuid;
+ BOOLEAN result = TRUE;
+ BOOLEAN codec_supported = FALSE;
+ UINT8 buf[2];
+ UINT16 sdp_features = 0;
+
+ APPL_TRACE_DEBUG0("bta_hf_client_add_record");
+
+ memset( proto_elem_list, 0 , BTA_HF_CLIENT_NUM_PROTO_ELEMS*sizeof(tSDP_PROTOCOL_ELEM));
+
+ /* add the protocol element sequence */
+ proto_elem_list[0].protocol_uuid = UUID_PROTOCOL_L2CAP;
+ proto_elem_list[0].num_params = 0;
+ proto_elem_list[1].protocol_uuid = UUID_PROTOCOL_RFCOMM;
+ proto_elem_list[1].num_params = 1;
+ proto_elem_list[1].params[0] = scn;
+ result &= SDP_AddProtocolList(sdp_handle, BTA_HF_CLIENT_NUM_PROTO_ELEMS, proto_elem_list);
+
+ /* add service class id list */
+ svc_class_id_list[0] = UUID_SERVCLASS_HF_HANDSFREE;
+ svc_class_id_list[1] = UUID_SERVCLASS_GENERIC_AUDIO;
+ result &= SDP_AddServiceClassIdList(sdp_handle, BTA_HF_CLIENT_NUM_SVC_ELEMS, svc_class_id_list);
+
+ /* add profile descriptor list */
+ profile_uuid = UUID_SERVCLASS_HF_HANDSFREE;
+ version = HFP_VERSION_1_6;
+
+ result &= SDP_AddProfileDescriptorList(sdp_handle, profile_uuid, version);
+
+ /* add service name */
+ if (p_service_name != NULL && p_service_name[0] != 0)
+ {
+ result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE,
+ (UINT32)(strlen(p_service_name)+1), (UINT8 *) p_service_name);
+ }
+
+ /* add features */
+ if (features & BTA_HF_CLIENT_FEAT_ECNR)
+ sdp_features |= BTA_HF_CLIENT_FEAT_ECNR;
+
+ if (features & BTA_HF_CLIENT_FEAT_3WAY)
+ sdp_features |= BTA_HF_CLIENT_FEAT_3WAY;
+
+ if (features & BTA_HF_CLIENT_FEAT_CLI)
+ sdp_features |= BTA_HF_CLIENT_FEAT_CLI;
+
+ if (features & BTA_HF_CLIENT_FEAT_VREC)
+ sdp_features |= BTA_HF_CLIENT_FEAT_VREC;
+
+ if (features & BTA_HF_CLIENT_FEAT_VOL)
+ sdp_features |= BTA_HF_CLIENT_FEAT_VOL;
+
+ /* Codec bit position is different in SDP (bit 5) and in BRSF (bit 7) */
+ if (features & BTA_HF_CLIENT_FEAT_CODEC)
+ sdp_features |= 0x0020;
+
+ UINT16_TO_BE_FIELD(buf, sdp_features);
+ result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE, 2, buf);
+
+ /* add browse group list */
+ result &= SDP_AddUuidSequence(sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, browse_list);
+
+ return result;
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_create_record
+**
+** Description Create SDP record for registered service.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_create_record(tBTA_HF_CLIENT_DATA *p_data)
+{
+ /* add sdp record if not already registered */
+ if (bta_hf_client_cb.sdp_handle == 0)
+ {
+ bta_hf_client_cb.sdp_handle = SDP_CreateRecord();
+ bta_hf_client_cb.scn = BTM_AllocateSCN();
+ bta_hf_client_add_record(p_data->api_register.name,
+ bta_hf_client_cb.scn,
+ p_data->api_register.features,
+ bta_hf_client_cb.sdp_handle);
+
+ bta_sys_add_uuid(UUID_SERVCLASS_HF_HANDSFREE);
+ }
+
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_del_record
+**
+** Description Delete SDP record for registered service.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_del_record(tBTA_HF_CLIENT_DATA *p_data)
+{
+ UNUSED(p_data);
+
+ APPL_TRACE_DEBUG0("bta_hf_client_del_record");
+
+ if (bta_hf_client_cb.sdp_handle != 0)
+ {
+ SDP_DeleteRecord(bta_hf_client_cb.sdp_handle);
+ bta_hf_client_cb.sdp_handle = 0;
+ BTM_FreeSCN(bta_hf_client_cb.scn);
+ BTM_SecClrService(BTM_SEC_SERVICE_HF_HANDSFREE);
+ bta_sys_remove_uuid(UUID_SERVCLASS_HF_HANDSFREE);
+ }
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_sdp_find_attr
+**
+** Description Process SDP discovery results to find requested attribute
+**
+**
+** Returns TRUE if results found, FALSE otherwise.
+**
+*******************************************************************************/
+BOOLEAN bta_hf_client_sdp_find_attr(void)
+{
+ tSDP_DISC_REC *p_rec = NULL;
+ tSDP_DISC_ATTR *p_attr;
+ tSDP_PROTOCOL_ELEM pe;
+ BOOLEAN result = FALSE;
+
+ bta_hf_client_cb.scb.peer_version = HFP_VERSION_1_1; /* Default version */
+
+ /* loop through all records we found */
+ while (TRUE)
+ {
+ /* get next record; if none found, we're done */
+ if ((p_rec = SDP_FindServiceInDb(bta_hf_client_cb.scb.p_disc_db, UUID_SERVCLASS_AG_HANDSFREE, p_rec)) == NULL)
+ {
+ break;
+ }
+
+ /* get scn from proto desc list if initiator */
+ if (bta_hf_client_cb.scb.role == BTA_HF_CLIENT_INT)
+ {
+ if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe))
+ {
+ bta_hf_client_cb.scb.peer_scn = (UINT8) pe.params[0];
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ /* get profile version (if failure, version parameter is not updated) */
+ SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_HF_HANDSFREE, &bta_hf_client_cb.scb.peer_version);
+
+ /* get features */
+ if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SUPPORTED_FEATURES)) != NULL)
+ {
+ /* Found attribute. Get value. */
+ /* There might be race condition between SDP and BRSF. */
+ /* Do not update if we already received BRSF. */
+ if (bta_hf_client_cb.scb.peer_features == 0)
+ {
+ bta_hf_client_cb.scb.peer_features = p_attr->attr_value.v.u16;
+
+ /* SDP and BRSF WBS bit are different, correct it if set */
+ if (bta_hf_client_cb.scb.peer_features & 0x0020)
+ {
+ bta_hf_client_cb.scb.peer_features &= ~0x0020;
+ bta_hf_client_cb.scb.peer_features |= BTA_HF_CLIENT_PEER_CODEC;
+ }
+
+ /* get network for ability to reject calls */
+ if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_NETWORK)) != NULL)
+ {
+ if (p_attr->attr_value.v.u16 == 0x01)
+ {
+ bta_hf_client_cb.scb.peer_features |= BTA_HF_CLIENT_PEER_REJECT;
+ }
+ }
+ }
+ }
+
+ /* found what we needed */
+ result = TRUE;
+ break;
+ }
+
+ APPL_TRACE_DEBUG3("%s peer_version=0x%x peer_features=0x%x",
+ __FUNCTION__, bta_hf_client_cb.scb.peer_version,
+ bta_hf_client_cb.scb.peer_features);
+
+ return result;
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_do_disc
+**
+** Description Do service discovery.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_do_disc(void)
+{
+ tSDP_UUID uuid_list[2];
+ UINT16 num_uuid = 1;
+ UINT16 attr_list[4];
+ UINT8 num_attr;
+ BOOLEAN db_inited = FALSE;
+
+ /* initiator; get proto list and features */
+ if (bta_hf_client_cb.scb.role == BTA_HF_CLIENT_INT)
+ {
+ attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
+ attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
+ attr_list[2] = ATTR_ID_BT_PROFILE_DESC_LIST;
+ attr_list[3] = ATTR_ID_SUPPORTED_FEATURES;
+ num_attr = 4;
+ uuid_list[0].uu.uuid16 = UUID_SERVCLASS_AG_HANDSFREE;
+ }
+ /* acceptor; get features */
+ else
+ {
+ attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
+ attr_list[1] = ATTR_ID_BT_PROFILE_DESC_LIST;
+ attr_list[2] = ATTR_ID_SUPPORTED_FEATURES;
+ num_attr = 3;
+ uuid_list[0].uu.uuid16 = UUID_SERVCLASS_AG_HANDSFREE;
+ }
+
+ /* allocate buffer for sdp database */
+ bta_hf_client_cb.scb.p_disc_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(GKI_MAX_BUF_SIZE);
+
+ if (bta_hf_client_cb.scb.p_disc_db)
+ {
+ /* set up service discovery database; attr happens to be attr_list len */
+ uuid_list[0].len = LEN_UUID_16;
+ uuid_list[1].len = LEN_UUID_16;
+ db_inited = SDP_InitDiscoveryDb(bta_hf_client_cb.scb.p_disc_db, GKI_MAX_BUF_SIZE, num_uuid,
+ uuid_list, num_attr, attr_list);
+ }
+
+ if (db_inited)
+ {
+ /*Service discovery not initiated */
+ db_inited = SDP_ServiceSearchAttributeRequest(bta_hf_client_cb.scb.peer_addr,
+ bta_hf_client_cb.scb.p_disc_db, bta_hf_client_sdp_cback);
+ }
+
+ if (!db_inited)
+ {
+ /*free discover db */
+ bta_hf_client_free_db(NULL);
+ /* sent failed event */
+ bta_hf_client_sm_execute(BTA_HF_CLIENT_DISC_FAIL_EVT, NULL);
+ }
+
+}
+
+/*******************************************************************************
+**
+** Function bta_hf_client_free_db
+**
+** Description Free discovery database.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hf_client_free_db(tBTA_HF_CLIENT_DATA *p_data)
+{
+ UNUSED(p_data);
+
+ if (bta_hf_client_cb.scb.p_disc_db != NULL)
+ {
+ GKI_freebuf(bta_hf_client_cb.scb.p_disc_db);
+ bta_hf_client_cb.scb.p_disc_db = NULL;
+ }
+}
diff --git a/bta/hh/bta_hh_api.c b/bta/hh/bta_hh_api.c
index df41a52..e7672d9 100644
--- a/bta/hh/bta_hh_api.c
+++ b/bta/hh/bta_hh_api.c
@@ -63,9 +63,7 @@
tBTA_HH_API_ENABLE *p_buf;
/* register with BTA system manager */
- GKI_sched_lock();
bta_sys_register(BTA_ID_HH, &bta_hh_reg);
- GKI_sched_unlock();
APPL_TRACE_ERROR0("Calling BTA_HhEnable");
p_buf = (tBTA_HH_API_ENABLE *)GKI_getbuf((UINT16)sizeof(tBTA_HH_API_ENABLE));
diff --git a/bta/hh/bta_hh_le.c b/bta/hh/bta_hh_le.c
index f2bba4a..75e74bb 100644
--- a/bta/hh/bta_hh_le.c
+++ b/bta/hh/bta_hh_le.c
@@ -500,7 +500,7 @@
UINT8 i;
#if BTA_HH_DEBUG == TRUE
- APPL_TRACE_DEBUG2("bta_hh_le_find_rpt_by_idtype: r_tpye: %d rpt_id: %d", r_type, rpt_id);
+ APPL_TRACE_DEBUG2("bta_hh_le_find_rpt_by_idtype: r_type: %d rpt_id: %d", r_type, rpt_id);
#endif
for (i = 0 ; i < BTA_HH_LE_RPT_MAX; i ++, p_rpt++)
@@ -908,7 +908,7 @@
{
BTA_GATTC_WriteCharDescr(p_cb->conn_id,
&descr_id,
- BTA_GATTC_TYPE_WRITE_NO_RSP,
+ BTA_GATTC_TYPE_WRITE,
&value,
BTA_GATT_AUTH_REQ_NONE);
@@ -1828,6 +1828,7 @@
hs_data.status = BTA_HH_OK;
p_buf->len = p_data->p_value->unformat.len + 1;
p_buf->layer_specific = 0;
+ p_buf->offset = 0;
/* attach report ID as the first byte of the report before sending it to USB HID driver */
pp = (UINT8*)(p_buf + 1);
@@ -2262,7 +2263,7 @@
else if (p_data->char_id.char_id.uuid.uu.uuid16 == GATT_UUID_HID_BT_KB_INPUT)
app_id = BTA_HH_APP_ID_KB;
- APPL_TRACE_ERROR1("Notification received on report ID: %d", p_rpt->rpt_id);
+ APPL_TRACE_DEBUG1("Notification received on report ID: %d", p_rpt->rpt_id);
/* need to append report ID to the head of data */
if (p_rpt->rpt_id != 0)
diff --git a/bta/hh/bta_hh_utils.c b/bta/hh/bta_hh_utils.c
index 6130a88..629281b 100644
--- a/bta/hh/bta_hh_utils.c
+++ b/bta/hh/bta_hh_utils.c
@@ -413,8 +413,6 @@
tBTA_HH_CB *p_cb = &bta_hh_cb;
UINT8 i;
UINT16 ssr_max_latency;
- /* lock other GKI task */
- GKI_sched_lock();
for (i = 0; i < BTA_HH_MAX_KNOWN; i ++)
{
if (memcmp(p_cb->kdev[i].addr, bd_addr, BD_ADDR_LEN) == 0)
@@ -449,7 +447,6 @@
break;
}
}
- GKI_sched_unlock();
return status;
}
diff --git a/bta/hl/bta_hl_api.c b/bta/hl/bta_hl_api.c
index 6f5572b..53b822d 100644
--- a/bta/hl/bta_hl_api.c
+++ b/bta/hl/bta_hl_api.c
@@ -63,9 +63,7 @@
tBTA_HL_API_ENABLE *p_buf;
/* register with BTA system manager */
- GKI_sched_lock();
bta_sys_register(BTA_ID_HL, &bta_hl_reg);
- GKI_sched_unlock();
if ((p_buf = (tBTA_HL_API_ENABLE *)GKI_getbuf(sizeof(tBTA_HL_API_ENABLE))) != NULL)
{
diff --git a/bta/hl/bta_hl_utils.c b/bta/hl/bta_hl_utils.c
index 6a08b74..bc37807 100644
--- a/bta/hl/bta_hl_utils.c
+++ b/bta/hl/bta_hl_utils.c
@@ -1462,6 +1462,8 @@
tBTA_HL_MDL_CFG *p_mdl;
UINT8 i ;
BOOLEAN found=FALSE;
+
+ *p_mdl_cfg_idx = 0;
for (i=0; i< BTA_HL_NUM_MDL_CFGS; i++)
{
p_mdl = BTA_HL_GET_MDL_CFG_PTR(app_idx, i);
@@ -2725,6 +2727,11 @@
}
success = TRUE;
}
+ else
+ {
+ p_cfg->mtu = L2CAP_DEFAULT_MTU;
+ p_cfg->fcs = BTA_HL_L2C_NO_FCS;
+ }
#if BTA_HL_DEBUG == TRUE
if (!success)
diff --git a/bta/include/bta_api.h b/bta/include/bta_api.h
index b8fcddc..1035bac 100644
--- a/bta/include/bta_api.h
+++ b/bta/include/bta_api.h
@@ -336,8 +336,9 @@
#define BTA_DM_BLE_AD_BIT_SERVICE_128SOL BTM_BLE_AD_BIT_SERVICE_128SOL
#define BTA_DM_BLE_AD_BIT_PUBLIC_ADDR BTM_BLE_AD_BIT_PUBLIC_ADDR
#define BTA_DM_BLE_AD_BIT_RANDOM_ADDR BTM_BLE_AD_BIT_RANDOM_ADDR
+#define BTA_DM_BLE_AD_BIT_SERVICE_128 BTM_BLE_AD_BIT_SERVICE_128 /*128-bit Service UUIDs*/
-typedef UINT16 tBTA_BLE_AD_MASK;
+typedef tBTM_BLE_AD_MASK tBTA_BLE_AD_MASK;
/* slave preferred connection interval range */
typedef struct
@@ -378,15 +379,68 @@
typedef struct
{
- tBTA_BLE_MANU manu; /* manufactuer data */
- tBTA_BLE_INT_RANGE int_range; /* slave prefered conn interval range */
- tBTA_BLE_SERVICE services; /* services */
- UINT16 appearance; /* appearance data */
- UINT8 flag;
- tBTA_BLE_PROPRIETARY *p_proprietary;
+ tBT_UUID service_uuid;
+ UINT8 len;
+ UINT8 *p_val;
+}tBTA_BLE_SERVICE_DATA;
+typedef tBTM_BLE_128SERVICE tBTA_BLE_128SERVICE;
+typedef tBTM_BLE_32SERVICE tBTA_BLE_32SERVICE;
+
+typedef struct
+{
+ tBTA_BLE_INT_RANGE int_range; /* slave prefered conn interval range */
+ tBTA_BLE_MANU *p_manu; /* manufacturer data */
+ tBTA_BLE_SERVICE *p_services; /* 16 bits services */
+ tBTA_BLE_128SERVICE *p_services_128b; /* 128 bits service */
+ tBTA_BLE_32SERVICE *p_service_32b; /* 32 bits Service UUID */
+ tBTA_BLE_SERVICE *p_sol_services; /* 16 bits services Solicitation UUIDs */
+ tBTA_BLE_32SERVICE *p_sol_service_32b; /* List of 32 bit Service Solicitation UUIDs */
+ tBTA_BLE_128SERVICE *p_sol_service_128b;/* List of 128 bit Service Solicitation UUIDs */
+ tBTA_BLE_PROPRIETARY *p_proprietary; /* proprietary data */
+ tBTA_BLE_SERVICE_DATA *p_service_data; /* service data */
+ UINT16 appearance; /* appearance data */
+ UINT8 flag;
+ UINT8 tx_power;
}tBTA_BLE_ADV_DATA;
+typedef void (tBTA_SET_ADV_DATA_CMPL_CBACK) (tBTA_STATUS status);
+
+/* advertising channel map */
+#define BTA_BLE_ADV_CHNL_37 BTM_BLE_ADV_CHNL_37
+#define BTA_BLE_ADV_CHNL_38 BTM_BLE_ADV_CHNL_38
+#define BTA_BLE_ADV_CHNL_39 BTM_BLE_ADV_CHNL_39
+typedef tBTM_BLE_ADV_CHNL_MAP tBTA_BLE_ADV_CHNL_MAP; /* use as a bit mask */
+
+/* advertising filter policy */
+typedef tBTM_BLE_AFP tBTA_BLE_AFP;
+
+/* adv event type */
+#define BTA_BLE_CONNECT_EVT BTM_BLE_CONNECT_EVT /* Connectable undirected advertising */
+#define BTA_BLE_CONNECT_DIR_EVT BTM_BLE_CONNECT_DIR_EVT /* Connectable directed advertising */
+#define BTA_BLE_DISCOVER_EVT BTM_BLE_DISCOVER_EVT /* Scannable undirected advertising */
+#define BTA_BLE_NON_CONNECT_EVT BTM_BLE_NON_CONNECT_EVT /* Non connectable undirected advertising */
+typedef UINT8 tBTA_BLE_ADV_EVT;
+
+/* adv tx power level */
+#define BTA_BLE_ADV_TX_POWER_MIN 0 /* minimum tx power */
+#define BTA_BLE_ADV_TX_POWER_LOW 1 /* low tx power */
+#define BTA_BLE_ADV_TX_POWER_MID 2 /* middle tx power */
+#define BTA_BLE_ADV_TX_POWER_UPPER 3 /* upper tx power */
+#define BTA_BLE_ADV_TX_POWER_MAX 4 /* maximum tx power */
+typedef UINT8 tBTA_BLE_ADV_TX_POWER;
+
+/* advertising instance parameters */
+typedef struct
+{
+ UINT16 adv_int_min; /* minimum adv interval */
+ UINT16 adv_int_max; /* maximum adv interval */
+ tBTA_BLE_ADV_EVT adv_type; /* adv event type */
+ tBTA_BLE_ADV_CHNL_MAP channel_map; /* adv channel map */
+ tBTA_BLE_AFP adv_filter_policy; /* advertising filter policy */
+ tBTA_BLE_ADV_TX_POWER tx_power; /* adv tx power */
+}tBTA_BLE_ADV_PARAMS;
+
/* These are the fields returned in each device adv packet. It
** is returned in the results callback if registered.
*/
@@ -537,6 +591,7 @@
// btla-specific --
#define BTA_DM_DEV_UNPAIRED_EVT 23
#define BTA_DM_HW_ERROR_EVT 24 /* BT Chip H/W error */
+#define BTA_DM_LE_FEATURES_READ 25 /* Cotroller specific LE features are read */
typedef UINT8 tBTA_DM_SEC_EVT;
/* Structure associated with BTA_DM_ENABLE_EVT */
@@ -843,6 +898,21 @@
/* Security callback */
typedef void (tBTA_DM_SEC_CBACK)(tBTA_DM_SEC_EVT event, tBTA_DM_SEC *p_data);
+#define BTA_BLE_MULTI_ADV_MAX BTM_BLE_MULTI_ADV_MAX
+#define BTA_BLE_MULTI_ADV_ILLEGAL 0
+
+/* multi adv callback event */
+#define BTA_BLE_MULTI_ADV_ENB_EVT 1
+#define BTA_BLE_MULTI_ADV_DISABLE_EVT 2
+#define BTA_BLE_MULTI_ADV_PARAM_EVT 3
+#define BTA_BLE_MULTI_ADV_DATA_EVT 4
+
+typedef UINT8 tBTA_BLE_MULTI_ADV_EVT;
+
+/* multi adv callback */
+typedef void (tBTA_BLE_MULTI_ADV_CBACK)(tBTA_BLE_MULTI_ADV_EVT event,
+ UINT8 inst_id, void *p_ref, tBTA_STATUS status);
+
/* Vendor Specific Command Callback */
typedef tBTM_VSC_CMPL_CB tBTA_VENDOR_CMPL_CBACK;
@@ -996,6 +1066,96 @@
#define BTA_DM_PM_PARK_IDX 5 /* the actual index to bta_dm_pm_md[] for PARK mode */
#endif
+#ifndef BTA_DM_PM_SNIFF_A2DP_IDX
+#define BTA_DM_PM_SNIFF_A2DP_IDX BTA_DM_PM_SNIFF
+#endif
+
+#ifndef BTA_DM_PM_SNIFF_HD_IDLE_IDX
+#define BTA_DM_PM_SNIFF_HD_IDLE_IDX BTA_DM_PM_SNIFF2
+#endif
+
+#ifndef BTA_DM_PM_SNIFF_SCO_OPEN_IDX
+#define BTA_DM_PM_SNIFF_SCO_OPEN_IDX BTA_DM_PM_SNIFF3
+#endif
+
+#ifndef BTA_DM_PM_SNIFF_HD_ACTIVE_IDX
+#define BTA_DM_PM_SNIFF_HD_ACTIVE_IDX BTA_DM_PM_SNIFF4
+#endif
+
+#ifndef BTA_DM_PM_SNIFF_HH_OPEN_IDX
+#define BTA_DM_PM_SNIFF_HH_OPEN_IDX BTA_DM_PM_SNIFF2
+#endif
+
+#ifndef BTA_DM_PM_SNIFF_HH_ACTIVE_IDX
+#define BTA_DM_PM_SNIFF_HH_ACTIVE_IDX BTA_DM_PM_SNIFF2
+#endif
+
+#ifndef BTA_DM_PM_SNIFF_HH_IDLE_IDX
+#define BTA_DM_PM_SNIFF_HH_IDLE_IDX BTA_DM_PM_SNIFF2
+#endif
+
+
+#ifndef BTA_DM_PM_HH_OPEN_DELAY
+#define BTA_DM_PM_HH_OPEN_DELAY 30000
+#endif
+
+#ifndef BTA_DM_PM_HH_ACTIVE_DELAY
+#define BTA_DM_PM_HH_ACTIVE_DELAY 30000
+#endif
+
+#ifndef BTA_DM_PM_HH_IDLE_DELAY
+#define BTA_DM_PM_HH_IDLE_DELAY 30000
+#endif
+
+/* The Sniff Parameters defined below must be ordered from highest
+ * latency (biggest interval) to lowest latency. If there is a conflict
+ * among the connected services the setting with the lowest latency will
+ * be selected. If a device should override a sniff parameter then it
+ * must insure that order is maintained.
+ */
+#ifndef BTA_DM_PM_SNIFF_MAX
+#define BTA_DM_PM_SNIFF_MAX 800
+#define BTA_DM_PM_SNIFF_MIN 400
+#define BTA_DM_PM_SNIFF_ATTEMPT 4
+#define BTA_DM_PM_SNIFF_TIMEOUT 1
+#endif
+
+#ifndef BTA_DM_PM_SNIFF1_MAX
+#define BTA_DM_PM_SNIFF1_MAX 400
+#define BTA_DM_PM_SNIFF1_MIN 200
+#define BTA_DM_PM_SNIFF1_ATTEMPT 4
+#define BTA_DM_PM_SNIFF1_TIMEOUT 1
+#endif
+
+#ifndef BTA_DM_PM_SNIFF2_MAX
+#define BTA_DM_PM_SNIFF2_MAX 180
+#define BTA_DM_PM_SNIFF2_MIN 150
+#define BTA_DM_PM_SNIFF2_ATTEMPT 4
+#define BTA_DM_PM_SNIFF2_TIMEOUT 1
+#endif
+
+#ifndef BTA_DM_PM_SNIFF3_MAX
+#define BTA_DM_PM_SNIFF3_MAX 150
+#define BTA_DM_PM_SNIFF3_MIN 50
+#define BTA_DM_PM_SNIFF3_ATTEMPT 4
+#define BTA_DM_PM_SNIFF3_TIMEOUT 1
+#endif
+
+#ifndef BTA_DM_PM_SNIFF4_MAX
+#define BTA_DM_PM_SNIFF4_MAX 54
+#define BTA_DM_PM_SNIFF4_MIN 30
+#define BTA_DM_PM_SNIFF4_ATTEMPT 4
+#define BTA_DM_PM_SNIFF4_TIMEOUT 1
+#endif
+
+#ifndef BTA_DM_PM_PARK_MAX
+#define BTA_DM_PM_PARK_MAX 800
+#define BTA_DM_PM_PARK_MIN 400
+#define BTA_DM_PM_PARK_ATTEMPT 0
+#define BTA_DM_PM_PARK_TIMEOUT 0
+#endif
+
+
/* Switch callback events */
#define BTA_DM_SWITCH_CMPL_EVT 0 /* Completion of the Switch API */
@@ -1564,6 +1724,17 @@
*******************************************************************************/
BTA_API extern BOOLEAN BTA_DmUseSsr( BD_ADDR bd_addr );
+/*******************************************************************************
+**
+** Function BTA_DmGetConnectionState
+**
+** Description Returns whether the remote device is currently connected.
+**
+** Returns 0 if the device is NOT connected.
+**
+*******************************************************************************/
+BTA_API extern UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr );
+
/*******************************************************************************
**
@@ -1999,7 +2170,8 @@
**
*******************************************************************************/
BTA_API extern void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask,
- tBTA_BLE_ADV_DATA *p_adv_cfg);
+ tBTA_BLE_ADV_DATA *p_adv_cfg,
+ tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
/*******************************************************************************
**
@@ -2013,7 +2185,8 @@
**
*******************************************************************************/
BTA_API extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask,
- tBTA_BLE_ADV_DATA *p_adv_cfg);
+ tBTA_BLE_ADV_DATA *p_adv_cfg,
+ tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
/*******************************************************************************
**
@@ -2028,6 +2201,66 @@
*******************************************************************************/
BTA_API extern void BTA_DmBleBroadcast (BOOLEAN start);
+
+/*******************************************************************************
+**
+** Function BTA_BleEnableAdvInstance
+**
+** Description This function enables the Multi ADV instance feature
+**
+** Parameters p_params Pointer to ADV param user defined structure
+** p_cback Pointer to Multi ADV callback structure
+** p_ref - Reference pointer
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern tBTA_STATUS BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
+ tBTA_BLE_MULTI_ADV_CBACK *p_cback,void *p_ref);
+
+/*******************************************************************************
+**
+** Function BTA_BleUpdateAdvInstParam
+**
+** Description This function updates the Multi ADV instance params
+**
+** Parameters inst_id Instance ID
+** p_params Pointer to ADV param user defined structure
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern tBTA_STATUS BTA_BleUpdateAdvInstParam (UINT8 inst_id,
+ tBTA_BLE_ADV_PARAMS *p_params);
+
+/*******************************************************************************
+**
+** Function BTA_BleCfgAdvInstData
+**
+** Description This function is called to configure the ADV instance data
+**
+** Parameters inst_id - Instance ID
+** is_scan_rsp - Boolean value Scan response
+** Pointer to User defined ADV data structure
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern tBTA_STATUS BTA_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
+ tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_data);
+
+/*******************************************************************************
+**
+** Function BTA_BleDisableAdvInstance
+**
+** Description This function is called to disable the ADV instance
+**
+** Parameters inst_id - Instance ID to be disabled
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern tBTA_STATUS BTA_BleDisableAdvInstance(UINT8 inst_id);
+
/*******************************************************************************
**
** Function BTA_DmBleUpdateConnectionParams
diff --git a/bta/include/bta_av_api.h b/bta/include/bta_av_api.h
index 1ea570c..22ee91c 100644
--- a/bta/include/bta_av_api.h
+++ b/bta/include/bta_av_api.h
@@ -249,8 +249,11 @@
#define BTA_AV_META_MSG_EVT 17 /* metadata messages */
#define BTA_AV_REJECT_EVT 18 /* incoming connection rejected */
#define BTA_AV_RC_FEAT_EVT 19 /* remote control channel peer supported features update */
+#define BTA_AV_MEDIA_SINK_CFG_EVT 20 /* command to configure codec */
+#define BTA_AV_MEDIA_DATA_EVT 21 /* sending data to Media Task */
/* Max BTA event */
-#define BTA_AV_MAX_EVT 20
+#define BTA_AV_MAX_EVT 22
+
typedef UINT8 tBTA_AV_EVT;
@@ -282,6 +285,7 @@
tBTA_AV_STATUS status;
BOOLEAN starting;
tBTA_AV_EDR edr; /* 0, if peer device does not support EDR */
+ UINT8 sep; /* sep type of peer device */
} tBTA_AV_OPEN;
/* data associated with BTA_AV_CLOSE_EVT */
@@ -446,6 +450,13 @@
tBTA_AV_RC_FEAT rc_feat;
} tBTA_AV;
+/* union of data associated with AV Media callback */
+typedef union
+{
+ BT_HDR *p_data;
+ UINT8 *codec_info;
+} tBTA_AV_MEDIA;
+
#define BTA_AVC_PACKET_LEN AVRC_PACKET_LEN
#define BTA_VENDOR_DATA_OFFSET 6
@@ -464,6 +475,7 @@
/* AV callback */
typedef void (tBTA_AV_CBACK)(tBTA_AV_EVT event, tBTA_AV *p_data);
+typedef void (tBTA_AV_DATA_CBACK)(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data);
/* type for stream state machine action functions */
typedef void (*tBTA_AV_ACT)(void *p_cb, void *p_data);
@@ -548,7 +560,7 @@
**
*******************************************************************************/
BTA_API void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name,
- UINT8 app_id);
+ UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback);
/*******************************************************************************
**
@@ -573,7 +585,7 @@
**
*******************************************************************************/
BTA_API void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle,
- BOOLEAN use_rc, tBTA_SEC sec_mask);
+ BOOLEAN use_rc, tBTA_SEC sec_mask, UINT16 uuid);
/*******************************************************************************
**
@@ -599,6 +611,17 @@
/*******************************************************************************
**
+** Function BTA_AvEnable_Sink
+**
+** Description Enable/Disable A2DP Sink.
+**
+** Returns void
+**
+*******************************************************************************/
+void BTA_AvEnable_Sink(int enable);
+
+/*******************************************************************************
+**
** Function BTA_AvStart
**
** Description Start audio/video stream data transfer.
diff --git a/bta/include/bta_av_ci.h b/bta/include/bta_av_ci.h
index 63668a9..faad260 100644
--- a/bta/include/bta_av_ci.h
+++ b/bta/include/bta_av_ci.h
@@ -63,7 +63,7 @@
*******************************************************************************/
BTA_API extern void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code,
UINT8 category, UINT8 num_seid, UINT8 *p_seid,
- BOOLEAN recfg_needed);
+ BOOLEAN recfg_needed, UINT8 avdt_handle);
#ifdef __cplusplus
diff --git a/bta/include/bta_av_co.h b/bta/include/bta_av_co.h
index 862ac5e..ed11c50 100644
--- a/bta/include/bta_av_co.h
+++ b/bta/include/bta_av_co.h
@@ -100,7 +100,7 @@
**
*******************************************************************************/
BTA_API extern void bta_av_co_audio_disc_res(tBTA_AV_HNDL hndl, UINT8 num_seps,
- UINT8 num_snk, BD_ADDR addr);
+ UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local);
/*******************************************************************************
**
@@ -162,7 +162,7 @@
*******************************************************************************/
BTA_API extern void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr,
- UINT8 num_protect, UINT8 *p_protect_info);
+ UINT8 num_protect, UINT8 *p_protect_info,UINT8 t_local_sep, UINT8 avdt_handle);
/*******************************************************************************
**
diff --git a/bta/include/bta_av_sbc.h b/bta/include/bta_av_sbc.h
index 98eb6ae..d7cfa89 100644
--- a/bta/include/bta_av_sbc.h
+++ b/bta/include/bta_av_sbc.h
@@ -194,6 +194,18 @@
/*******************************************************************************
**
+** Function bta_av_sbc_cfg_matches_cap
+**
+** Description This function checks whether an SBC codec configuration
+** matched with capabilities. Here we check subset.
+**
+** Returns 0 if ok, nonzero if error.
+**
+*******************************************************************************/
+extern UINT8 bta_av_sbc_cfg_matches_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap);
+
+/*******************************************************************************
+**
** Function bta_av_sbc_bld_hdr
**
** Description This function builds the packet header for MPF1.
diff --git a/bta/include/bta_gatt_api.h b/bta/include/bta_gatt_api.h
index 3fec4a0..49af191 100644
--- a/bta/include/bta_gatt_api.h
+++ b/bta/include/bta_gatt_api.h
@@ -93,10 +93,11 @@
#define BTA_GATT_ENCRYPED_MITM GATT_ENCRYPED_MITM /* GATT_SUCCESS */
#define BTA_GATT_ENCRYPED_NO_MITM GATT_ENCRYPED_NO_MITM /* 0x8d */
#define BTA_GATT_NOT_ENCRYPTED GATT_NOT_ENCRYPTED /* 0x8e */
+#define BTA_GATT_CONGESTED GATT_CONGESTED /* 0x8f */
-#define BTA_GATT_DUP_REG 0x8f /* 0x8f */
-#define BTA_GATT_ALREADY_OPEN 0x90 /* 0x90 */
-#define BTA_GATT_CANCEL 0x91 /* 0x91 */
+#define BTA_GATT_DUP_REG 0x90 /* 0x90 */
+#define BTA_GATT_ALREADY_OPEN 0x91 /* 0x91 */
+#define BTA_GATT_CANCEL 0x92 /* 0x92 */
/* 0xE0 ~ 0xFC reserved for future use */
#define BTA_GATT_CCC_CFG_ERR GATT_CCC_CFG_ERR /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */
@@ -128,6 +129,12 @@
#define BTA_GATTC_LISTEN_EVT 16 /* listen event */
#define BTA_GATTC_ENC_CMPL_CB_EVT 17 /* encryption complete callback event */
#define BTA_GATTC_CFG_MTU_EVT 18 /* configure MTU complete event */
+#define BTA_GATTC_ADV_DATA_EVT 19 /* ADV data event */
+#define BTA_GATTC_MULT_ADV_ENB_EVT 20 /* Enable Multi ADV event */
+#define BTA_GATTC_MULT_ADV_UPD_EVT 21 /* Update parameter event */
+#define BTA_GATTC_MULT_ADV_DATA_EVT 22 /* Multi ADV data event */
+#define BTA_GATTC_MULT_ADV_DIS_EVT 23 /* Disable Multi ADV event */
+#define BTA_GATTC_CONGEST_EVT 24 /* Congestion event */
typedef UINT8 tBTA_GATTC_EVT;
@@ -360,6 +367,12 @@
BOOLEAN is_notify;
}tBTA_GATTC_NOTIFY;
+typedef struct
+{
+ UINT16 conn_id;
+ BOOLEAN congested; /* congestion indicator */
+}tBTA_GATTC_CONGEST;
+
// btla-specific ++
typedef struct
{
@@ -392,6 +405,7 @@
tBTA_GATTC_ENC_CMPL_CB enc_cmpl;
BD_ADDR remote_bda; /* service change event */
tBTA_GATTC_CFG_MTU cfg_mtu; /* configure MTU operation */
+ tBTA_GATTC_CONGEST congest;
} tBTA_GATTC;
/* GATTC enable callback function */
@@ -423,6 +437,7 @@
#define BTA_GATTS_CANCEL_OPEN_EVT 17
#define BTA_GATTS_CLOSE_EVT 18
#define BTA_GATTS_LISTEN_EVT 19
+#define BTA_GATTS_CONGEST_EVT 20
typedef UINT8 tBTA_GATTS_EVT;
typedef tGATT_IF tBTA_GATTS_IF;
@@ -508,6 +523,7 @@
typedef struct
{
+ tBTA_GATT_STATUS status;
BD_ADDR remote_bda;
UINT32 trans_id;
UINT16 conn_id;
@@ -564,19 +580,32 @@
tBTA_GATT_TRANSPORT transport;
}tBTA_GATTS_CONN;
+typedef struct
+{
+ UINT16 conn_id;
+ BOOLEAN congested; /* report channel congestion indicator */
+}tBTA_GATTS_CONGEST;
+
+typedef struct
+{
+ UINT16 conn_id; /* connection ID */
+ tBTA_GATT_STATUS status; /* notification/indication status */
+}tBTA_GATTS_CONF;
+
/* GATTS callback data */
typedef union
{
tBTA_GATTS_REG_OPER reg_oper;
tBTA_GATTS_CREATE create;
tBTA_GATTS_SRVC_OPER srvc_oper;
- tBTA_GATT_STATUS status; /* BTA_GATTS_CONF_EVT or BTA_GATTS_LISTEN_EVT */
+ tBTA_GATT_STATUS status; /* BTA_GATTS_LISTEN_EVT */
tBTA_GATTS_ADD_RESULT add_result; /* add included service: BTA_GATTS_ADD_INCL_SRVC_EVT
add char : BTA_GATTS_ADD_CHAR_EVT
add char descriptor: BTA_GATTS_ADD_CHAR_DESCR_EVT */
tBTA_GATTS_REQ req_data;
tBTA_GATTS_CONN conn; /* BTA_GATTS_CONN_EVT */
-
+ tBTA_GATTS_CONGEST congest; /* BTA_GATTS_CONGEST_EVT callback data */
+ tBTA_GATTS_CONF confirm; /* BTA_GATTS_CONF_EVT callback data */
}tBTA_GATTS;
/* GATTS enable callback function */
diff --git a/bta/include/bta_hf_client_api.h b/bta/include/bta_hf_client_api.h
new file mode 100644
index 0000000..8ef42f4
--- /dev/null
+++ b/bta/include/bta_hf_client_api.h
@@ -0,0 +1,382 @@
+/******************************************************************************
+ *
+ * Copyright (c) 2014 The Android Open Source Project
+ * Copyright (C) 2003-2012 Broadcom 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.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This is the public interface file for the handsfree (HF role) subsystem
+ *
+ ******************************************************************************/
+#ifndef BTA_HF_CLIENT_API_H
+#define BTA_HF_CLIENT_API_H
+
+#include "bta_api.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+
+/* HFP peer (AG) features*/
+#define BTA_HF_CLIENT_PEER_FEAT_3WAY 0x00000001 /* Three-way calling */
+#define BTA_HF_CLIENT_PEER_FEAT_ECNR 0x00000002 /* Echo cancellation and/or noise reduction */
+#define BTA_HF_CLIENT_PEER_FEAT_VREC 0x00000004 /* Voice recognition */
+#define BTA_HF_CLIENT_PEER_INBAND 0x00000008 /* In-band ring tone */
+#define BTA_HF_CLIENT_PEER_VTAG 0x00000010 /* Attach a phone number to a voice tag */
+#define BTA_HF_CLIENT_PEER_REJECT 0x00000020 /* Ability to reject incoming call */
+#define BTA_HF_CLIENT_PEER_ECS 0x00000040 /* Enhanced Call Status */
+#define BTA_HF_CLIENT_PEER_ECC 0x00000080 /* Enhanced Call Control */
+#define BTA_HF_CLIENT_PEER_EXTERR 0x00000100 /* Extended error codes */
+#define BTA_HF_CLIENT_PEER_CODEC 0x00000200 /* Codec Negotiation */
+
+typedef UINT16 tBTA_HF_CLIENT_PEER_FEAT;
+
+/* HFP HF features */
+#define BTA_HF_CLIENT_FEAT_ECNR 0x00000001 /* Echo cancellation and/or noise reduction */
+#define BTA_HF_CLIENT_FEAT_3WAY 0x00000002 /* Call waiting and three-way calling */
+#define BTA_HF_CLIENT_FEAT_CLI 0x00000004 /* Caller ID presentation capability */
+#define BTA_HF_CLIENT_FEAT_VREC 0x00000008 /* Voice recognition activation */
+#define BTA_HF_CLIENT_FEAT_VOL 0x00000010 /* Remote volume control */
+#define BTA_HF_CLIENT_FEAT_ECS 0x00000020 /* Enhanced Call Status */
+#define BTA_HF_CLIENT_FEAT_ECC 0x00000040 /* Enhanced Call Control */
+#define BTA_HF_CLIENT_FEAT_CODEC 0x00000080 /* Codec Negotiation */
+
+/* HFP HF extended call handling - masks not related to any spec */
+#define BTA_HF_CLIENT_CHLD_REL 0x00000001 /* 0 Release waiting call or held calls */
+#define BTA_HF_CLIENT_CHLD_REL_ACC 0x00000002 /* 1 Release active calls and accept other (waiting or held) cal */
+#define BTA_HF_CLIENT_CHLD_REL_X 0x00000004 /* 1x Release x call*/
+#define BTA_HF_CLIENT_CHLD_HOLD_ACC 0x00000008 /* 2 Active calls on hold and accept other call */
+#define BTA_HF_CLIENT_CHLD_PRIV_X 0x00000010 /* 2x Active multiparty call on hold except call x */
+#define BTA_HF_CLIENT_CHLD_MERGE 0x00000020 /* 3 Add held call to multiparty */
+#define BTA_HF_CLIENT_CHLD_MERGE_DETACH 0x00000040 /* 4 Add held call to multiparty */
+
+typedef UINT16 tBTA_HF_CLIENT_CHLD_FEAT;
+
+/* HFP AG errors ot OK sent to HF Unit */
+#define BTA_HF_CLIENT_AT_RESULT_OK 0
+#define BTA_HF_CLIENT_AT_RESULT_ERROR 1
+#define BTA_HF_CLIENT_AT_RESULT_NO_CARRIER 2
+#define BTA_HF_CLIENT_AT_RESULT_BUSY 3
+#define BTA_HF_CLIENT_AT_RESULT_NO_ANSWER 4
+#define BTA_HF_CLIENT_AT_RESULT_DELAY 5
+#define BTA_HF_CLIENT_AT_RESULT_BLACKLISTED 6
+#define BTA_HF_CLIENT_AT_RESULT_CME 7
+
+typedef UINT8 tBTA_HF_CLIENT_AT_RESULT_TYPE;
+
+/* HF Client callback events */
+#define BTA_HF_CLIENT_ENABLE_EVT 0 /* HF Client enabled */
+#define BTA_HF_CLIENT_REGISTER_EVT 1 /* HF Client registered */
+#define BTA_HF_CLIENT_OPEN_EVT 2 /* HF Client connection open */
+#define BTA_HF_CLIENT_CLOSE_EVT 3 /* HF Client connection closed */
+#define BTA_HF_CLIENT_CONN_EVT 4 /* Service level connection opened */
+#define BTA_HF_CLIENT_AUDIO_OPEN_EVT 5 /* Audio connection open */
+#define BTA_HF_CLIENT_AUDIO_MSBC_OPEN_EVT 6 /* Audio connection with mSBC codec open */
+#define BTA_HF_CLIENT_AUDIO_CLOSE_EVT 7 /* Audio connection closed */
+#define BTA_HF_CLIENT_SPK_EVT 8 /* Speaker volume changed */
+#define BTA_HF_CLIENT_MIC_EVT 9 /* Microphone volume changed */
+#define BTA_HF_CLIENT_IND_EVT 10 /* Indicator */
+#define BTA_HF_CLIENT_VOICE_REC_EVT 11 /* AG changed voice recognition setting */
+#define BTA_HF_CLIENT_OPERATOR_NAME_EVT 12 /* Operator name acquired */
+#define BTA_HF_CLIENT_CLIP_EVT 13 /* Calling line identification event */
+#define BTA_HF_CLIENT_CCWA_EVT 14 /* Call waiting notification */
+#define BTA_HF_CLIENT_AT_RESULT_EVT 15 /* Call waiting notification */
+#define BTA_HF_CLIENT_CLCC_EVT 16 /* current call event */
+#define BTA_HF_CLIENT_CNUM_EVT 17 /* subscriber information event */
+#define BTA_HF_CLIENT_BTRH_EVT 18 /* bluetooth response and hold event */
+#define BTA_HF_CLIENT_BSIR_EVT 19 /* in-band ring tone setting changed event */
+#define BTA_HF_CLIENT_BINP_EVT 20 /* binp number event */
+#define BTA_HF_CLIENT_RING_INDICATION 21 /* HF Client ring indication */
+#define BTA_HF_CLIENT_DISABLE_EVT 30 /* HF Client disabled */
+
+typedef UINT8 tBTA_HF_CLIENT_EVT;
+
+/* HF Client open status */
+#define BTA_HF_CLIENT_SUCCESS 0 /* Connection successfully opened */
+#define BTA_HF_CLIENT_FAIL_SDP 1 /* Open failed due to SDP */
+#define BTA_HF_CLIENT_FAIL_RFCOMM 2 /* Open failed due to RFCOMM */
+#define BTA_HF_CLIENT_FAIL_RESOURCES 3 /* out of resources failure */
+
+typedef UINT8 tBTA_HF_CLIENT_STATUS;
+
+/* indicator type */
+#define BTA_HF_CLIENT_IND_BATTCH 0 /* Battery charge indicator */
+#define BTA_HF_CLIENT_IND_SIGNAL 1 /* Signal Strength indicator */
+#define BTA_HF_CLIENT_IND_SERVICE 2 /* Service availability indicator */
+#define BTA_HF_CLIENT_IND_CALL 3 /* Standard call status indicator*/
+#define BTA_HF_CLIENT_IND_ROAM 4 /* Roaming status indicator */
+#define BTA_HF_CLIENT_IND_CALLSETUP 5 /* Call setup status indicator */
+#define BTA_HF_CLIENT_IND_CALLHELD 6 /* Call hold status indicator */
+
+typedef UINT8 tBTA_HF_CLIENT_IND_TYPE;
+
+/* AT commands */
+#define BTA_HF_CLIENT_AT_CMD_VTS 0
+#define BTA_HF_CLIENT_AT_CMD_BTRH 1
+#define BTA_HF_CLIENT_AT_CMD_CHUP 2
+#define BTA_HF_CLIENT_AT_CMD_CHLD 3
+#define BTA_HF_CLIENT_AT_CMD_BCC 4
+#define BTA_HF_CLIENT_AT_CMD_CNUM 5
+#define BTA_HF_CLIENT_AT_CMD_ATA 6
+#define BTA_HF_CLIENT_AT_CMD_COPS 7
+#define BTA_HF_CLIENT_AT_CMD_ATD 8
+#define BTA_HF_CLIENT_AT_CMD_VGM 9
+#define BTA_HF_CLIENT_AT_CMD_VGS 10
+#define BTA_HF_CLIENT_AT_CMD_BVRA 11
+#define BTA_HF_CLIENT_AT_CMD_CLCC 12
+#define BTA_HF_CLIENT_AT_CMD_BINP 13
+#define BTA_HF_CLIENT_AT_CMD_BLDN 14
+#define BTA_HF_CLIENT_AT_CMD_NREC 15
+
+typedef UINT8 tBTA_HF_CLIENT_AT_CMD_TYPE;
+
+/* data associated with most non-AT events */
+/* placeholder, if not needed should be removed*/
+typedef struct
+{
+} tBTA_HF_CLIENT_HDR;
+
+/* data associated with BTA_HF_CLIENT_REGISTER_EVT */
+typedef struct
+{
+ tBTA_HF_CLIENT_HDR hdr;
+ UINT16 handle;
+ tBTA_HF_CLIENT_STATUS status;
+} tBTA_HF_CLIENT_REGISTER;
+
+/* data associated with BTA_HF_CLIENT_OPEN_EVT */
+typedef struct
+{
+ tBTA_HF_CLIENT_HDR hdr;
+ BD_ADDR bd_addr;
+ tBTA_HF_CLIENT_STATUS status;
+} tBTA_HF_CLIENT_OPEN;
+
+/* data associated with BTA_HF_CLIENT_CONN_EVT */
+typedef struct
+{
+ tBTA_HF_CLIENT_HDR hdr;
+ tBTA_HF_CLIENT_PEER_FEAT peer_feat;
+ tBTA_HF_CLIENT_CHLD_FEAT chld_feat;
+} tBTA_HF_CLIENT_CONN;
+
+/* data associated with BTA_HF_CLIENT_IND_EVT event */
+typedef struct
+{
+ tBTA_HF_CLIENT_HDR hdr;
+ tBTA_HF_CLIENT_IND_TYPE type;
+ UINT16 value;
+} tBTA_HF_CLIENT_IND;
+
+/* data associated with BTA_HF_CLIENT_OPERATOR_NAME_EVT */
+#define BTA_HF_CLIENT_OPERATOR_NAME_LEN 16
+typedef struct
+{
+ char name[BTA_HF_CLIENT_OPERATOR_NAME_LEN + 1];
+} tBTA_HF_CLIENT_OPERATOR_NAME;
+
+/* data associated with BTA_HF_CLIENT_CLIP_EVT and BTA_HF_CLIENT_CCWA_EVT*/
+#define BTA_HF_CLIENT_NUMBER_LEN 32
+typedef struct
+{
+ char number[BTA_HF_CLIENT_NUMBER_LEN + 1];
+} tBTA_HF_CLIENT_NUMBER;
+
+/* data associated with BTA_HF_CLIENT_AT_RESULT_EVT event */
+typedef struct
+{
+ tBTA_HF_CLIENT_AT_RESULT_TYPE type;
+ UINT16 cme;
+} tBTA_HF_CLIENT_AT_RESULT;
+
+/* data associated with BTA_HF_CLIENT_CLCC_EVT event */
+typedef struct
+{
+ UINT32 idx;
+ BOOLEAN inc;
+ UINT8 status;
+ BOOLEAN mpty;
+ BOOLEAN number_present;
+ char number[BTA_HF_CLIENT_NUMBER_LEN + 1];
+} tBTA_HF_CLIENT_CLCC;
+
+/* data associated with BTA_HF_CLIENT_CNUM_EVT event */
+typedef struct
+{
+ UINT16 service;
+ char number[BTA_HF_CLIENT_NUMBER_LEN + 1];
+} tBTA_HF_CLIENT_CNUM;
+
+/* data associated with other events */
+typedef struct
+{
+ UINT16 value;
+} tBTA_HF_CLIENT_VAL;
+
+/* union of data associated with AG callback */
+typedef union
+{
+ tBTA_HF_CLIENT_HDR hdr;
+ tBTA_HF_CLIENT_REGISTER reg;
+ tBTA_HF_CLIENT_OPEN open;
+ tBTA_HF_CLIENT_CONN conn;
+ tBTA_HF_CLIENT_IND ind;
+ tBTA_HF_CLIENT_VAL val;
+ tBTA_HF_CLIENT_OPERATOR_NAME operator;
+ tBTA_HF_CLIENT_NUMBER number;
+ tBTA_HF_CLIENT_AT_RESULT result;
+ tBTA_HF_CLIENT_CLCC clcc;
+ tBTA_HF_CLIENT_CNUM cnum;
+} tBTA_HF_CLIENT;
+
+typedef UINT32 tBTA_HF_CLIENT_FEAT;
+
+/* HF Client callback */
+typedef void (tBTA_HF_CLIENT_CBACK)(tBTA_HF_CLIENT_EVT event, tBTA_HF_CLIENT *p_data);
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function BTA_HfClientEnable
+**
+** Description Enable the HF CLient service. When the enable
+** operation is complete the callback function will be
+** called with a BTA_HF_CLIENT_ENABLE_EVT. This function must
+** be called before other function in the HF CLient API are
+** called.
+**
+** Returns BTA_SUCCESS if OK, BTA_FAILURE otherwise.
+**
+*******************************************************************************/
+BTA_API tBTA_STATUS BTA_HfClientEnable(tBTA_HF_CLIENT_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function BTA_HfClientDisable
+**
+** Description Disable the HF Client service
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HfClientDisable(void);
+
+/*******************************************************************************
+**
+** Function BTA_HfClientRegister
+**
+** Description Register an HF Client service.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HfClientRegister(tBTA_SEC sec_mask, tBTA_HF_CLIENT_FEAT features,
+ char *p_service_name);
+
+/*******************************************************************************
+**
+** Function BTA_HfClientDeregister
+**
+** Description Deregister an HF Client service.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HfClientDeregister(UINT16 handle);
+
+/*******************************************************************************
+**
+** Function BTA_HfClientOpen
+**
+** Description Opens a connection to an audio gateway.
+** When connection is open callback function is called
+** with a BTA_HF_CLIENT_OPEN_EVT. Only the data connection is
+** opened. The audio connection is not opened.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HfClientOpen(UINT16 handle, BD_ADDR bd_addr, tBTA_SEC sec_mask);
+
+/*******************************************************************************
+**
+** Function BTA_HfClientClose
+**
+** Description Close the current connection to an audio gateway.
+** Any current audio connection will also be closed
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HfClientClose(UINT16 handle);
+
+/*******************************************************************************
+**
+** Function BTA_HfCllientAudioOpen
+**
+** Description Opens an audio connection to the currently connected
+** audio gateway
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HfClientAudioOpen(UINT16 handle);
+
+/*******************************************************************************
+**
+** Function BTA_HfClientAudioClose
+**
+** Description Close the currently active audio connection to an audio
+** gateway. The data connection remains open
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HfClientAudioClose(UINT16 handle);
+
+/*******************************************************************************
+**
+** Function BTA_HfClientSendAT
+**
+** Description send AT command
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HfClientSendAT(UINT16 handle, tBTA_HF_CLIENT_AT_CMD_TYPE at, UINT32 val1, UINT32 val2, const char *str);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_HF_CLIENT_API_H */
diff --git a/bta/jv/bta_jv_act.c b/bta/jv/bta_jv_act.c
index f9569b3..03d8901 100644
--- a/bta/jv/bta_jv_act.c
+++ b/bta/jv/bta_jv_act.c
@@ -285,8 +285,8 @@
return BTA_JV_FAILURE;
}
APPL_TRACE_DEBUG6("bta_jv_free_sr_rfc_cb: max_sess:%d, curr_sess:%d, p_pcb:%p, user:"
- "%d, state:%d, jv handle: 0x%x" ,p_cb->max_sess, p_cb->curr_sess, p_pcb,
- (int)p_pcb->user_data, p_pcb->state, p_pcb->handle);
+ "%p, state:%d, jv handle: 0x%x" ,p_cb->max_sess, p_cb->curr_sess, p_pcb,
+ p_pcb->user_data, p_pcb->state, p_pcb->handle);
if (p_cb->curr_sess <= 0)
return BTA_JV_SUCCESS;
@@ -296,32 +296,32 @@
case BTA_JV_ST_CL_CLOSING:
case BTA_JV_ST_SR_CLOSING:
APPL_TRACE_WARNING4("bta_jv_free_sr_rfc_cb: return on closing, port state:%d, "
- "scn:%d, p_pcb:%p, user_data:%d", p_pcb->state, p_cb->scn, p_pcb,
- (int)p_pcb->user_data);
+ "scn:%d, p_pcb:%p, user_data:%p", p_pcb->state, p_cb->scn, p_pcb,
+ p_pcb->user_data);
status = BTA_JV_FAILURE;
return status;
case BTA_JV_ST_CL_OPEN:
case BTA_JV_ST_CL_OPENING:
APPL_TRACE_DEBUG3("bta_jv_free_sr_rfc_cb: state: %d, scn:%d,"
- " user_data:%d", p_pcb->state, p_cb->scn, (int)p_pcb->user_data);
+ " user_data:%p", p_pcb->state, p_cb->scn, p_pcb->user_data);
p_pcb->state = BTA_JV_ST_CL_CLOSING;
break;
case BTA_JV_ST_SR_LISTEN:
p_pcb->state = BTA_JV_ST_SR_CLOSING;
remove_server = TRUE;
APPL_TRACE_DEBUG2("bta_jv_free_sr_rfc_cb: state: BTA_JV_ST_SR_LISTEN, scn:%d,"
- " user_data:%d", p_cb->scn, (int)p_pcb->user_data);
+ " user_data:%p", p_cb->scn, p_pcb->user_data);
break;
case BTA_JV_ST_SR_OPEN:
p_pcb->state = BTA_JV_ST_SR_CLOSING;
APPL_TRACE_DEBUG2("bta_jv_free_sr_rfc_cb: state: BTA_JV_ST_SR_OPEN, scn:%d,"
- " user_data:%d", p_cb->scn, (int)p_pcb->user_data);
+ " user_data:%p", p_cb->scn, p_pcb->user_data);
break;
default:
APPL_TRACE_WARNING6("bta_jv_free_sr_rfc_cb():failed, ignore port state:%d, scn:"
- "%d, p_pcb:%p, jv handle: 0x%x, port_handle: %d, user_data:%d",
+ "%d, p_pcb:%p, jv handle: 0x%x, port_handle: %d, user_data:%p",
p_pcb->state, p_cb->scn, p_pcb, p_pcb->handle, p_pcb->port_handle,
- (int)p_pcb->user_data);
+ p_pcb->user_data);
status = BTA_JV_FAILURE;
break;
}
@@ -1475,65 +1475,6 @@
}
}
-/*******************************************************************************
-**
-** Function bta_jv_l2cap_client_cback
-**
-** Description handles the l2cap client events
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_jv_l2cap_client_cback(UINT16 gap_handle, UINT16 event)
-{
- UNUSED(gap_handle);
- UNUSED(event);
-#if 0
- tBTA_JV_L2C_CB *p_cb = &bta_jv_cb.l2c_cb[gap_handle];
- tBTA_JV evt_data;
-
- if(gap_handle >= BTA_JV_MAX_L2C_CONN && !p_cb->p_cback)
- return;
-
- APPL_TRACE_DEBUG2( "bta_jv_l2cap_client_cback: %d evt:x%x",
- gap_handle, event);
- evt_data.l2c_open.status = BTA_JV_SUCCESS;
- evt_data.l2c_open.handle = gap_handle;
- switch (event)
- {
- case GAP_EVT_CONN_OPENED:
- bdcpy(evt_data.l2c_open.rem_bda, GAP_ConnGetRemoteAddr(gap_handle));
- evt_data.l2c_open.tx_mtu = GAP_ConnGetRemMtuSize(gap_handle);
- p_cb->state = BTA_JV_ST_CL_OPEN;
- p_cb->p_cback(BTA_JV_L2CAP_OPEN_EVT, &evt_data);
- break;
-
- case GAP_EVT_CONN_CLOSED:
- p_cb->state = BTA_JV_ST_NONE;
- bta_jv_free_sec_id(&p_cb->sec_id);
- evt_data.l2c_close.async = TRUE;
- p_cb->p_cback(BTA_JV_L2CAP_CLOSE_EVT, &evt_data);
- p_cb->p_cback = NULL;
- break;
-
- case GAP_EVT_CONN_DATA_AVAIL:
- evt_data.handle = gap_handle;
- p_cb->p_cback(BTA_JV_L2CAP_DATA_IND_EVT, &evt_data);
- break;
-
- case GAP_EVT_CONN_CONGESTED:
- case GAP_EVT_CONN_UNCONGESTED:
- p_cb->cong = (event == GAP_EVT_CONN_CONGESTED) ? TRUE : FALSE;
- evt_data.l2c_cong.cong = p_cb->cong;
- p_cb->p_cback(BTA_JV_L2CAP_CONG_EVT, &evt_data);
- break;
-
- default:
- break;
- }
-#endif
-}
-
#if SDP_FOR_JV_INCLUDED == TRUE
/*******************************************************************************
**
@@ -1712,67 +1653,6 @@
/*******************************************************************************
**
-** Function bta_jv_l2cap_server_cback
-**
-** Description handles the l2cap server callback
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_jv_l2cap_server_cback(UINT16 gap_handle, UINT16 event)
-{
- UNUSED(gap_handle);
- UNUSED(event);
-#if 0
- tBTA_JV_L2C_CB *p_cb = &bta_jv_cb.l2c_cb[gap_handle];
- tBTA_JV evt_data;
- tBTA_JV_L2CAP_CBACK *p_cback;
-
- if(gap_handle >= BTA_JV_MAX_L2C_CONN && !p_cb->p_cback)
- return;
-
- APPL_TRACE_DEBUG2( "bta_jv_l2cap_server_cback: %d evt:x%x",
- gap_handle, event);
- evt_data.l2c_open.status = BTA_JV_SUCCESS;
- evt_data.l2c_open.handle = gap_handle;
-
- switch (event)
- {
- case GAP_EVT_CONN_OPENED:
- bdcpy(evt_data.l2c_open.rem_bda, GAP_ConnGetRemoteAddr(gap_handle));
- evt_data.l2c_open.tx_mtu = GAP_ConnGetRemMtuSize(gap_handle);
- p_cb->state = BTA_JV_ST_SR_OPEN;
- p_cb->p_cback(BTA_JV_L2CAP_OPEN_EVT, &evt_data);
- break;
-
- case GAP_EVT_CONN_CLOSED:
- evt_data.l2c_close.async = TRUE;
- evt_data.l2c_close.handle = p_cb->handle;
- p_cback = p_cb->p_cback;
- evt_data.l2c_close.status = bta_jv_free_l2c_cb(p_cb);
- p_cback(BTA_JV_L2CAP_CLOSE_EVT, &evt_data);
- break;
-
- case GAP_EVT_CONN_DATA_AVAIL:
- evt_data.handle = gap_handle;
- p_cb->p_cback(BTA_JV_L2CAP_DATA_IND_EVT, &evt_data);
- break;
-
- case GAP_EVT_CONN_CONGESTED:
- case GAP_EVT_CONN_UNCONGESTED:
- p_cb->cong = (event == GAP_EVT_CONN_CONGESTED) ? TRUE : FALSE;
- evt_data.l2c_cong.cong = p_cb->cong;
- p_cb->p_cback(BTA_JV_L2CAP_CONG_EVT, &evt_data);
- break;
-
- default:
- break;
- }
-#endif
-}
-
-/*******************************************************************************
-**
** Function bta_jv_l2cap_start_server
**
** Description starts an L2CAP server
@@ -2246,39 +2126,6 @@
/*******************************************************************************
**
-** Function bta_jv_get_num_rfc_listen
-**
-** Description when a RFCOMM connection goes down, make sure that there's only
-** one port stays listening on this scn.
-**
-** Returns
-**
-*******************************************************************************/
-static UINT8 bta_jv_get_num_rfc_listen(tBTA_JV_RFC_CB *p_cb)
-{
- UINT8 i, listen=1;
- tBTA_JV_PCB *p_pcb;
-
- if (p_cb->max_sess > 1)
- {
- listen = 0;
- for (i=0; i<p_cb->max_sess; i++)
- {
- if (p_cb->rfc_hdl[i] != 0)
- {
- p_pcb = &bta_jv_cb.port_cb[p_cb->rfc_hdl[i] - 1];
- if (BTA_JV_ST_SR_LISTEN == p_pcb->state)
- {
- listen++;
- }
- }
- }
- }
- return listen;
-}
-
-/*******************************************************************************
-**
** Function bta_jv_port_mgmt_sr_cback
**
** Description callback for port mamangement function of rfcomm
@@ -2585,7 +2432,7 @@
tBTA_JV_API_RFCOMM_SERVER *ls = &(p_data->rfcomm_server);
tBTA_JV_RFC_CB *p_cb = NULL;
tBTA_JV_PCB *p_pcb = NULL;
- APPL_TRACE_ERROR0("bta_jv_rfcomm_stop_server");
+ APPL_TRACE_DEBUG0("bta_jv_rfcomm_stop_server");
if(!ls->handle)
{
APPL_TRACE_ERROR0("bta_jv_rfcomm_stop_server, jv handle is null");
diff --git a/bta/jv/bta_jv_api.c b/bta/jv/bta_jv_api.c
index ad0b694..c91eacf 100644
--- a/bta/jv/bta_jv_api.c
+++ b/bta/jv/bta_jv_api.c
@@ -74,9 +74,7 @@
}
/* register with BTA system manager */
- GKI_sched_lock();
bta_sys_register(BTA_ID_JV, &bta_jv_reg);
- GKI_sched_unlock();
if (p_cback && (p_buf = (tBTA_JV_API_ENABLE *) GKI_getbuf(sizeof(tBTA_JV_API_ENABLE))) != NULL)
{
diff --git a/bta/pan/bta_pan_act.c b/bta/pan/bta_pan_act.c
index b01e95a..fbb4147 100644
--- a/bta/pan/bta_pan_act.c
+++ b/bta/pan/bta_pan_act.c
@@ -43,6 +43,40 @@
#define BTA_PAN_TX_MASK 0xF0
/*******************************************************************************
+ **
+ ** Function bta_pan_pm_conn_busy
+ **
+ ** Description set pan pm connection busy state
+ **
+ ** Params p_scb: state machine control block of pan connection
+ **
+ ** Returns void
+ **
+ *******************************************************************************/
+static void bta_pan_pm_conn_busy(tBTA_PAN_SCB *p_scb)
+{
+ if ((p_scb != NULL) && (p_scb->state != BTA_PAN_IDLE_ST))
+ bta_sys_busy(BTA_ID_PAN, p_scb->app_id, p_scb->bd_addr);
+}
+
+/*******************************************************************************
+ **
+ ** Function bta_pan_pm_conn_idle
+ **
+ ** Description set pan pm connection idle state
+ **
+ ** Params p_scb: state machine control block of pan connection
+ **
+ ** Returns void
+ **
+ *******************************************************************************/
+static void bta_pan_pm_conn_idle(tBTA_PAN_SCB *p_scb)
+{
+ if ((p_scb != NULL) && (p_scb->state != BTA_PAN_IDLE_ST))
+ bta_sys_idle(BTA_ID_PAN, p_scb->app_id, p_scb->bd_addr);
+}
+
+/*******************************************************************************
**
** Function bta_pan_conn_state_cback
**
@@ -457,6 +491,8 @@
bta_pan_scb_dealloc(p_scb);
bdcpy(data.bd_addr, p_data->api_open.bd_addr);
data.status = BTA_PAN_FAIL;
+ data.local_role = p_data->api_open.local_role;
+ data.peer_role = p_data->api_open.peer_role;
bta_pan_cb.p_cback(BTA_PAN_OPEN_EVT, (tBTA_PAN *)&data);
}
@@ -625,12 +661,14 @@
/* if data path configured for tx pull */
if ((bta_pan_cb.flow_mask & BTA_PAN_TX_MASK) == BTA_PAN_TX_PULL)
{
+ bta_pan_pm_conn_busy(p_scb);
/* call application callout function for tx path */
bta_pan_co_tx_path(p_scb->handle, p_scb->app_id);
/* free data that exceeds queue level */
while(p_scb->data_queue.count > bta_pan_cb.q_level)
GKI_freebuf(GKI_dequeue(&p_scb->data_queue));
+ bta_pan_pm_conn_idle(p_scb);
}
/* if configured for zero copy push */
else if ((bta_pan_cb.flow_mask & BTA_PAN_TX_MASK) == BTA_PAN_TX_PUSH_BUF)
@@ -702,6 +740,7 @@
{
if ((bta_pan_cb.flow_mask & BTA_PAN_RX_MASK) == BTA_PAN_RX_PUSH_BUF)
{
+ bta_pan_pm_conn_busy(p_scb);
PAN_WriteBuf (p_scb->handle,
((tBTA_PAN_DATA_PARAMS *)p_data)->dst,
@@ -709,6 +748,7 @@
((tBTA_PAN_DATA_PARAMS *)p_data)->protocol,
(BT_HDR *)p_data,
((tBTA_PAN_DATA_PARAMS *)p_data)->ext);
+ bta_pan_pm_conn_idle(p_scb);
}
}
diff --git a/bta/pan/bta_pan_api.c b/bta/pan/bta_pan_api.c
index 6588230..0a69b0f 100644
--- a/bta/pan/bta_pan_api.c
+++ b/bta/pan/bta_pan_api.c
@@ -25,8 +25,6 @@
#include "bt_target.h"
-#if defined(BTA_PAN_INCLUDED) && (BTA_PAN_INCLUDED == TRUE)
-
#include "bta_api.h"
#include "bta_sys.h"
#include "pan_api.h"
@@ -35,6 +33,9 @@
#include "bta_pan_int.h"
#include "bd.h"
#include <string.h>
+#include "bt_utils.h"
+
+#if defined(BTA_PAN_INCLUDED) && (BTA_PAN_INCLUDED == TRUE)
static const tBTA_SYS_REG bta_pan_reg =
{
@@ -59,9 +60,7 @@
tBTA_PAN_API_ENABLE *p_buf;
/* register with BTA system manager */
- GKI_sched_lock();
bta_sys_register(BTA_ID_PAN, &bta_pan_reg);
- GKI_sched_unlock();
if ((p_buf = (tBTA_PAN_API_ENABLE *) GKI_getbuf(sizeof(tBTA_PAN_API_ENABLE))) != NULL)
{
@@ -211,4 +210,36 @@
bta_sys_sendmsg(p_buf);
}
}
+#else
+
+void BTA_PanEnable(tBTA_PAN_CBACK p_cback)
+{
+ UNUSED(p_cback);
+}
+
+void BTA_PanDisable(void)
+{
+}
+
+void BTA_PanSetRole(tBTA_PAN_ROLE role, tBTA_PAN_ROLE_INFO *p_user_info, tBTA_PAN_ROLE_INFO *p_gn_info,
+ tBTA_PAN_ROLE_INFO *p_nap_info)
+{
+ UNUSED(role);
+ UNUSED(p_user_info);
+ UNUSED(p_gn_info);
+ UNUSED(p_nap_info);
+}
+
+void BTA_PanOpen(BD_ADDR bd_addr, tBTA_PAN_ROLE local_role, tBTA_PAN_ROLE peer_role)
+{
+ UNUSED(bd_addr);
+ UNUSED(local_role);
+ UNUSED(peer_role);
+}
+
+void BTA_PanClose(UINT16 handle)
+{
+ UNUSED(handle);
+}
+
#endif /* BTA_PAN_INCLUDED */
diff --git a/bta/pan/bta_pan_ci.c b/bta/pan/bta_pan_ci.c
index f8e5832..7e67477 100644
--- a/bta/pan/bta_pan_ci.c
+++ b/bta/pan/bta_pan_ci.c
@@ -24,8 +24,6 @@
#include "bt_target.h"
-#if defined(BTA_PAN_INCLUDED) && (BTA_PAN_INCLUDED == TRUE)
-
#include <string.h>
#include "gki.h"
@@ -35,7 +33,9 @@
#include "bta_pan_api.h"
#include "bta_pan_ci.h"
#include "bta_pan_int.h"
+#include "bt_utils.h"
+#if defined(BTA_PAN_INCLUDED) && (BTA_PAN_INCLUDED == TRUE)
/*******************************************************************************
**
@@ -256,5 +256,61 @@
PAN_SetProtocolFilters(handle, num_filters, p_start_array, p_end_array );
}
+#else
+
+void bta_pan_ci_tx_ready(UINT16 handle)
+{
+ UNUSED(handle);
+}
+
+void bta_pan_ci_rx_ready(UINT16 handle)
+{
+ UNUSED(handle);
+}
+
+void bta_pan_ci_tx_flow(UINT16 handle, BOOLEAN enable)
+{
+ UNUSED(handle);
+ UNUSED(enable);
+}
+
+void bta_pan_ci_rx_writebuf(UINT16 handle, BD_ADDR src, BD_ADDR dst, UINT16 protocol, BT_HDR *p_buf, BOOLEAN ext)
+{
+ UNUSED(handle);
+ UNUSED(src);
+ UNUSED(dst);
+ UNUSED(protocol);
+ UNUSED(p_buf);
+ UNUSED(ext);
+}
+
+BT_HDR * bta_pan_ci_readbuf(UINT16 handle, BD_ADDR src, BD_ADDR dst, UINT16 *p_protocol,
+ BOOLEAN* p_ext, BOOLEAN* p_forward)
+{
+ UNUSED(handle);
+ UNUSED(src);
+ UNUSED(dst);
+ UNUSED(p_protocol);
+ UNUSED(p_ext);
+ UNUSED(p_forward);
+ return NULL;
+}
+
+void bta_pan_ci_set_pfilters(UINT16 handle, UINT16 num_filters, UINT16 *p_start_array, UINT16 *p_end_array)
+{
+ UNUSED(handle);
+ UNUSED(num_filters);
+ UNUSED(p_start_array);
+ UNUSED(p_end_array);
+}
+
+void bta_pan_ci_set_mfilters(UINT16 handle, UINT16 num_mcast_filters, UINT8 *p_start_array,
+ UINT8 *p_end_array)
+{
+ UNUSED(handle);
+ UNUSED(num_mcast_filters);
+ UNUSED(p_start_array);
+ UNUSED(p_end_array);
+}
#endif /* BTA_PAN_API */
diff --git a/bta/pan/bta_pan_int.h b/bta/pan/bta_pan_int.h
index 1667e57..bd75311 100644
--- a/bta/pan/bta_pan_int.h
+++ b/bta/pan/bta_pan_int.h
@@ -56,6 +56,14 @@
BTA_PAN_API_OPEN_EVT
};
+/* state machine states */
+enum
+{
+ BTA_PAN_IDLE_ST,
+ BTA_PAN_OPEN_ST,
+ BTA_PAN_CLOSING_ST
+};
+
diff --git a/bta/pan/bta_pan_main.c b/bta/pan/bta_pan_main.c
index 5ed545f..7d42bfe 100644
--- a/bta/pan/bta_pan_main.c
+++ b/bta/pan/bta_pan_main.c
@@ -84,14 +84,6 @@
#define BTA_PAN_NUM_COLS 2 /* number of columns in state tables */
-/* state machine states */
-enum
-{
- BTA_PAN_IDLE_ST,
- BTA_PAN_OPEN_ST,
- BTA_PAN_CLOSING_ST
-};
-
/* state table for listen state */
const UINT8 bta_pan_st_idle[][BTA_PAN_NUM_COLS] =
diff --git a/btif/co/bta_av_co.c b/btif/co/bta_av_co.c
index fecf621..a0cc344 100644
--- a/btif/co/bta_av_co.c
+++ b/btif/co/bta_av_co.c
@@ -67,7 +67,7 @@
/* SCMS-T protect info */
const UINT8 bta_av_co_cp_scmst[BTA_AV_CP_INFO_LEN] = "\x02\x02\x00";
-/* SBC codec capabilities */
+/* SBC SRC codec capabilities */
const tA2D_SBC_CIE bta_av_co_sbc_caps =
{
(A2D_SBC_IE_SAMP_FREQ_44), /* samp_freq */
@@ -79,6 +79,18 @@
A2D_SBC_IE_MIN_BITPOOL /* min_bitpool */
};
+/* SBC SINK codec capabilities */
+const tA2D_SBC_CIE bta_av_co_sbc_sink_caps =
+{
+ (A2D_SBC_IE_SAMP_FREQ_48 | A2D_SBC_IE_SAMP_FREQ_44), /* samp_freq */
+ (A2D_SBC_IE_CH_MD_MONO | A2D_SBC_IE_CH_MD_STEREO | A2D_SBC_IE_CH_MD_JOINT | A2D_SBC_IE_CH_MD_DUAL), /* ch_mode */
+ (A2D_SBC_IE_BLOCKS_16 | A2D_SBC_IE_BLOCKS_12 | A2D_SBC_IE_BLOCKS_8 | A2D_SBC_IE_BLOCKS_4), /* block_len */
+ (A2D_SBC_IE_SUBBAND_4 | A2D_SBC_IE_SUBBAND_8), /* num_subbands */
+ (A2D_SBC_IE_ALLOC_MD_L | A2D_SBC_IE_ALLOC_MD_S), /* alloc_mthd */
+ A2D_SBC_IE_MAX_BITPOOL, /* max_bitpool */
+ A2D_SBC_IE_MIN_BITPOOL /* min_bitpool */
+};
+
#if !defined(BTIF_AV_SBC_DEFAULT_SAMP_FREQ)
#define BTIF_AV_SBC_DEFAULT_SAMP_FREQ A2D_SBC_IE_SAMP_FREQ_44
#endif
@@ -113,17 +125,23 @@
{
BD_ADDR addr; /* address of audio/video peer */
tBTA_AV_CO_SINK snks[BTIF_SV_AV_AA_SEP_INDEX]; /* array of supported sinks */
+ tBTA_AV_CO_SINK srcs[BTIF_SV_AV_AA_SEP_INDEX]; /* array of supported srcs */
UINT8 num_snks; /* total number of sinks at peer */
+ UINT8 num_srcs; /* total number of srcs at peer */
UINT8 num_seps; /* total number of seids at peer */
UINT8 num_rx_snks; /* number of received sinks */
+ UINT8 num_rx_srcs; /* number of received srcs */
UINT8 num_sup_snks; /* number of supported sinks in the snks array */
+ UINT8 num_sup_srcs; /* number of supported srcs in the srcs array */
tBTA_AV_CO_SINK *p_snk; /* currently selected sink */
+ tBTA_AV_CO_SINK *p_src; /* currently selected src */
UINT8 codec_cfg[AVDT_CODEC_SIZE]; /* current codec configuration */
BOOLEAN cp_active; /* current CP configuration */
BOOLEAN acp; /* acceptor */
BOOLEAN recfg_needed; /* reconfiguration is needed */
BOOLEAN opened; /* opened */
UINT16 mtu; /* maximum transmit unit size */
+ UINT16 uuid_to_connect; /* uuid of peer device */
} tBTA_AV_CO_PEER;
typedef struct
@@ -152,7 +170,8 @@
static BOOLEAN bta_av_co_audio_sink_has_scmst(const tBTA_AV_CO_SINK *p_sink);
static BOOLEAN bta_av_co_audio_peer_supports_codec(tBTA_AV_CO_PEER *p_peer, UINT8 *p_snk_index);
static BOOLEAN bta_av_co_audio_media_supports_config(UINT8 codec_type, const UINT8 *p_codec_cfg);
-
+static BOOLEAN bta_av_co_audio_sink_supports_config(UINT8 codec_type, const UINT8 *p_codec_cfg);
+static BOOLEAN bta_av_co_audio_peer_src_supports_codec(tBTA_AV_CO_PEER *p_peer, UINT8 *p_src_index);
@@ -284,7 +303,7 @@
switch (index)
{
case BTIF_SV_AV_AA_SBC_INDEX:
- /* Set up for SBC codec */
+ /* Set up for SBC codec for SRC*/
*p_codec_type = BTA_AV_CODEC_SBC;
/* This should not fail because we are using constants for parameters */
@@ -292,8 +311,16 @@
/* Codec is valid */
return TRUE;
+#ifdef BTA_AVK_INCLUDED
+ case BTIF_SV_AV_AA_SBC_SINK_INDEX:
+ *p_codec_type = BTA_AV_CODEC_SBC;
+ /* This should not fail because we are using constants for parameters */
+ A2D_BldSbcInfo(AVDT_MEDIA_AUDIO, (tA2D_SBC_CIE *) &bta_av_co_sbc_sink_caps, p_codec_info);
+ /* Codec is valid */
+ return TRUE;
+#endif
default:
/* Not valid */
return FALSE;
@@ -313,14 +340,14 @@
**
*******************************************************************************/
BTA_API void bta_av_co_audio_disc_res(tBTA_AV_HNDL hndl, UINT8 num_seps, UINT8 num_snk,
- BD_ADDR addr)
+ UINT8 num_src, BD_ADDR addr, UINT16 uuid_local)
{
tBTA_AV_CO_PEER *p_peer;
FUNC_TRACE();
- APPL_TRACE_DEBUG3("bta_av_co_audio_disc_res h:x%x num_seps:%d num_snk:%d",
- hndl, num_seps, num_snk);
+ APPL_TRACE_DEBUG4("bta_av_co_audio_disc_res h:x%x num_seps:%d num_snk:%d num_src:%d",
+ hndl, num_seps, num_snk, num_src);
/* Find the peer info */
p_peer = bta_av_co_get_peer(hndl);
@@ -339,13 +366,220 @@
/* Copy the discovery results */
bdcpy(p_peer->addr, addr);
p_peer->num_snks = num_snk;
+ p_peer->num_srcs = num_src;
p_peer->num_seps = num_seps;
p_peer->num_rx_snks = 0;
+ p_peer->num_rx_srcs = 0;
p_peer->num_sup_snks = 0;
+ if (uuid_local == UUID_SERVCLASS_AUDIO_SINK)
+ p_peer->uuid_to_connect = UUID_SERVCLASS_AUDIO_SOURCE;
+ else if (uuid_local == UUID_SERVCLASS_AUDIO_SOURCE)
+ p_peer->uuid_to_connect = UUID_SERVCLASS_AUDIO_SINK;
}
/*******************************************************************************
**
+ ** Function bta_av_build_src_cfg
+ **
+ ** Description This function will build preferred config from src capabilities
+ **
+ **
+ ** Returns Pass or Fail for current getconfig.
+ **
+ *******************************************************************************/
+void bta_av_build_src_cfg (UINT8 *p_pref_cfg, UINT8 *p_src_cap)
+{
+ tA2D_SBC_CIE src_cap;
+ tA2D_SBC_CIE pref_cap;
+ UINT8 status = 0;
+
+ /* initialize it to default SBC configuration */
+ A2D_BldSbcInfo(AVDT_MEDIA_AUDIO, (tA2D_SBC_CIE *) &btif_av_sbc_default_config, p_pref_cfg);
+ /* now try to build a preferred one */
+ /* parse configuration */
+ if ((status = A2D_ParsSbcInfo(&src_cap, p_src_cap, TRUE)) != 0)
+ {
+ APPL_TRACE_DEBUG1(" Cant parse src cap ret = %d", status);
+ return ;
+ }
+
+ if (src_cap.samp_freq & A2D_SBC_IE_SAMP_FREQ_48)
+ pref_cap.samp_freq = A2D_SBC_IE_SAMP_FREQ_48;
+ else if (src_cap.samp_freq & A2D_SBC_IE_SAMP_FREQ_44)
+ pref_cap.samp_freq = A2D_SBC_IE_SAMP_FREQ_44;
+
+ if (src_cap.ch_mode & A2D_SBC_IE_CH_MD_JOINT)
+ pref_cap.ch_mode = A2D_SBC_IE_CH_MD_JOINT;
+ else if (src_cap.ch_mode & A2D_SBC_IE_CH_MD_STEREO)
+ pref_cap.ch_mode = A2D_SBC_IE_CH_MD_STEREO;
+ else if (src_cap.ch_mode & A2D_SBC_IE_CH_MD_DUAL)
+ pref_cap.ch_mode = A2D_SBC_IE_CH_MD_DUAL;
+ else if (src_cap.ch_mode & A2D_SBC_IE_CH_MD_MONO)
+ pref_cap.ch_mode = A2D_SBC_IE_CH_MD_MONO;
+
+ if (src_cap.block_len & A2D_SBC_IE_BLOCKS_16)
+ pref_cap.block_len = A2D_SBC_IE_BLOCKS_16;
+ else if (src_cap.block_len & A2D_SBC_IE_BLOCKS_12)
+ pref_cap.block_len = A2D_SBC_IE_BLOCKS_12;
+ else if (src_cap.block_len & A2D_SBC_IE_BLOCKS_8)
+ pref_cap.block_len = A2D_SBC_IE_BLOCKS_8;
+ else if (src_cap.block_len & A2D_SBC_IE_BLOCKS_4)
+ pref_cap.block_len = A2D_SBC_IE_BLOCKS_4;
+
+ if (src_cap.num_subbands & A2D_SBC_IE_SUBBAND_8)
+ pref_cap.num_subbands = A2D_SBC_IE_SUBBAND_8;
+ else if(src_cap.num_subbands & A2D_SBC_IE_SUBBAND_4)
+ pref_cap.num_subbands = A2D_SBC_IE_SUBBAND_4;
+
+ if (src_cap.alloc_mthd & A2D_SBC_IE_ALLOC_MD_L)
+ pref_cap.alloc_mthd = A2D_SBC_IE_ALLOC_MD_L;
+ else if(src_cap.alloc_mthd & A2D_SBC_IE_ALLOC_MD_S)
+ pref_cap.alloc_mthd = A2D_SBC_IE_ALLOC_MD_S;
+
+ pref_cap.max_bitpool = src_cap.max_bitpool;
+ pref_cap.min_bitpool = src_cap.min_bitpool;
+
+ A2D_BldSbcInfo(AVDT_MEDIA_AUDIO, (tA2D_SBC_CIE *) &pref_cap, p_pref_cfg);
+}
+
+/*******************************************************************************
+ **
+ ** Function bta_av_audio_sink_getconfig
+ **
+ ** Description This callout function is executed by AV to retrieve the
+ ** desired codec and content protection configuration for the
+ ** A2DP Sink audio stream in Initiator.
+ **
+ **
+ ** Returns Pass or Fail for current getconfig.
+ **
+ *******************************************************************************/
+UINT8 bta_av_audio_sink_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
+ UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid, UINT8 *p_num_protect,
+ UINT8 *p_protect_info)
+{
+
+ UINT8 result = A2D_FAIL;
+ BOOLEAN supported;
+ tBTA_AV_CO_PEER *p_peer;
+ tBTA_AV_CO_SINK *p_src;
+ UINT8 codec_cfg[AVDT_CODEC_SIZE];
+ UINT8 pref_cfg[AVDT_CODEC_SIZE];
+ UINT8 index;
+
+ FUNC_TRACE();
+
+ APPL_TRACE_DEBUG3("bta_av_audio_sink_getconfig handle:0x%x codec_type:%d seid:%d",
+ hndl, codec_type, seid);
+ APPL_TRACE_DEBUG4("num_protect:0x%02x protect_info:0x%02x%02x%02x",
+ *p_num_protect, p_protect_info[0], p_protect_info[1], p_protect_info[2]);
+
+ /* Retrieve the peer info */
+ p_peer = bta_av_co_get_peer(hndl);
+ if (p_peer == NULL)
+ {
+ APPL_TRACE_ERROR0("bta_av_audio_sink_getconfig could not find peer entry");
+ return A2D_FAIL;
+ }
+
+ APPL_TRACE_DEBUG4("bta_av_audio_sink_getconfig peer(o=%d,n_snks=%d,n_rx_snks=%d,n_sup_snks=%d)",
+ p_peer->opened, p_peer->num_srcs, p_peer->num_rx_srcs, p_peer->num_sup_srcs);
+
+ p_peer->num_rx_srcs++;
+
+ /* Check if this is a supported configuration */
+ supported = FALSE;
+ switch (codec_type)
+ {
+ case BTA_AV_CODEC_SBC:
+ supported = TRUE;
+ break;
+
+ default:
+ break;
+ }
+
+ if (supported)
+ {
+ /* If there is room for a new one */
+ if (p_peer->num_sup_srcs < BTA_AV_CO_NUM_ELEMENTS(p_peer->srcs))
+ {
+ p_src = &p_peer->srcs[p_peer->num_sup_srcs++];
+
+ APPL_TRACE_DEBUG6("bta_av_audio_sink_getconfig saved caps[%x:%x:%x:%x:%x:%x]",
+ p_codec_info[1], p_codec_info[2], p_codec_info[3],
+ p_codec_info[4], p_codec_info[5], p_codec_info[6]);
+
+ memcpy(p_src->codec_caps, p_codec_info, AVDT_CODEC_SIZE);
+ p_src->codec_type = codec_type;
+ p_src->sep_info_idx = *p_sep_info_idx;
+ p_src->seid = seid;
+ p_src->num_protect = *p_num_protect;
+ memcpy(p_src->protect_info, p_protect_info, BTA_AV_CP_INFO_LEN);
+ }
+ else
+ {
+ APPL_TRACE_ERROR0("bta_av_audio_sink_getconfig no more room for SRC info");
+ }
+ }
+
+ /* If last SNK get capabilities or all supported codec caps retrieved */
+ if ((p_peer->num_rx_srcs == p_peer->num_srcs) ||
+ (p_peer->num_sup_srcs == BTA_AV_CO_NUM_ELEMENTS(p_peer->srcs)))
+ {
+ APPL_TRACE_DEBUG0("bta_av_audio_sink_getconfig last SRC reached");
+
+ /* Protect access to bta_av_co_cb.codec_cfg */
+ GKI_disable();
+
+ /* Find a src that matches the codec config */
+ if (bta_av_co_audio_peer_src_supports_codec(p_peer, &index))
+ {
+ APPL_TRACE_DEBUG0(" Codec Supported ");
+ p_src = &p_peer->srcs[index];
+
+ /* Build the codec configuration for this sink */
+ {
+ /* Save the new configuration */
+ p_peer->p_src = p_src;
+ /* get preferred config from src_caps */
+ bta_av_build_src_cfg(pref_cfg, p_src->codec_caps);
+ memcpy(p_peer->codec_cfg, pref_cfg, AVDT_CODEC_SIZE);
+
+ APPL_TRACE_DEBUG6("bta_av_audio_sink_getconfig p_codec_info[%x:%x:%x:%x:%x:%x]",
+ p_peer->codec_cfg[1], p_peer->codec_cfg[2], p_peer->codec_cfg[3],
+ p_peer->codec_cfg[4], p_peer->codec_cfg[5], p_peer->codec_cfg[6]);
+ /* By default, no content protection */
+ *p_num_protect = 0;
+
+#if defined(BTA_AV_CO_CP_SCMS_T) && (BTA_AV_CO_CP_SCMS_T == TRUE)
+ /* Check if this sink supports SCMS */
+ if (bta_av_co_audio_sink_has_scmst(p_sink))
+ {
+ p_peer->cp_active = TRUE;
+ bta_av_co_cb.cp.active = TRUE;
+ *p_num_protect = BTA_AV_CP_INFO_LEN;
+ memcpy(p_protect_info, bta_av_co_cp_scmst, BTA_AV_CP_INFO_LEN);
+ }
+ else
+ {
+ p_peer->cp_active = FALSE;
+ bta_av_co_cb.cp.active = FALSE;
+ }
+#endif
+
+ *p_sep_info_idx = p_src->sep_info_idx;
+ memcpy(p_codec_info, p_peer->codec_cfg, AVDT_CODEC_SIZE);
+ result = A2D_SUCCESS;
+ }
+ }
+ /* Protect access to bta_av_co_cb.codec_cfg */
+ GKI_enable();
+ }
+ return result;
+}
+/*******************************************************************************
+ **
** Function bta_av_co_audio_getconfig
**
** Description This callout function is executed by AV to retrieve the
@@ -370,10 +604,6 @@
FUNC_TRACE();
- APPL_TRACE_DEBUG3("bta_av_co_audio_getconfig handle:0x%x codec_type:%d seid:%d", hndl, codec_type, seid);
- APPL_TRACE_DEBUG4("num_protect:0x%02x protect_info:0x%02x%02x%02x",
- *p_num_protect, p_protect_info[0], p_protect_info[1], p_protect_info[2]);
-
/* Retrieve the peer info */
p_peer = bta_av_co_get_peer(hndl);
if (p_peer == NULL)
@@ -382,10 +612,20 @@
return A2D_FAIL;
}
+ if (p_peer->uuid_to_connect == UUID_SERVCLASS_AUDIO_SOURCE)
+ {
+ result = bta_av_audio_sink_getconfig(hndl, codec_type, p_codec_info, p_sep_info_idx,
+ seid, p_num_protect, p_protect_info);
+ return result;
+ }
+ APPL_TRACE_DEBUG3("bta_av_co_audio_getconfig handle:0x%x codec_type:%d seid:%d",
+ hndl, codec_type, seid);
+ APPL_TRACE_DEBUG4("num_protect:0x%02x protect_info:0x%02x%02x%02x",
+ *p_num_protect, p_protect_info[0], p_protect_info[1], p_protect_info[2]);
+
APPL_TRACE_DEBUG4("bta_av_co_audio_getconfig peer(o=%d,n_snks=%d,n_rx_snks=%d,n_sup_snks=%d)",
p_peer->opened, p_peer->num_snks, p_peer->num_rx_snks, p_peer->num_sup_snks);
- /* Increment the number of received sinks capabilities */
p_peer->num_rx_snks++;
/* Check if this is a supported configuration */
@@ -510,13 +750,15 @@
**
*******************************************************************************/
BTA_API void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
- UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr, UINT8 num_protect, UINT8 *p_protect_info)
+ UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr, UINT8 num_protect, UINT8 *p_protect_info,
+ UINT8 t_local_sep, UINT8 avdt_handle)
{
tBTA_AV_CO_PEER *p_peer;
UINT8 status = A2D_SUCCESS;
UINT8 category = A2D_SUCCESS;
BOOLEAN recfg_needed = FALSE;
+ BOOLEAN codec_cfg_supported = FALSE;
UNUSED(seid);
UNUSED(addr);
@@ -535,9 +777,11 @@
APPL_TRACE_ERROR0("bta_av_co_audio_setconfig could not find peer entry");
/* Call call-in rejecting the configuration */
- bta_av_ci_setconfig(hndl, A2D_BUSY, AVDT_ASC_CODEC, 0, NULL, FALSE);
+ bta_av_ci_setconfig(hndl, A2D_BUSY, AVDT_ASC_CODEC, 0, NULL, FALSE, avdt_handle);
return;
}
+ APPL_TRACE_DEBUG4("bta_av_co_audio_setconfig peer(o=%d,n_snks=%d,n_rx_snks=%d,n_sup_snks=%d)",
+ p_peer->opened, p_peer->num_snks, p_peer->num_rx_snks, p_peer->num_sup_snks);
/* Sanity check: should not be opened at this point */
if (p_peer->opened)
@@ -568,9 +812,20 @@
#endif
if (status == A2D_SUCCESS)
{
- /* Check if codec configuration is supported */
- if (bta_av_co_audio_media_supports_config(codec_type, p_codec_info))
+ if(AVDT_TSEP_SNK == t_local_sep)
{
+ codec_cfg_supported = bta_av_co_audio_sink_supports_config(codec_type, p_codec_info);
+ APPL_TRACE_DEBUG0(" Peer is A2DP SRC ");
+ }
+ if(AVDT_TSEP_SRC == t_local_sep)
+ {
+ codec_cfg_supported = bta_av_co_audio_media_supports_config(codec_type, p_codec_info);
+ APPL_TRACE_DEBUG0(" Peer is A2DP SINK ");
+ }
+ /* Check if codec configuration is supported */
+ if (codec_cfg_supported)
+ {
+
/* Protect access to bta_av_co_cb.codec_cfg */
GKI_disable();
@@ -595,6 +850,13 @@
bta_av_co_cb.codec_cfg_setconfig.id = BTIF_AV_CODEC_SBC;
memcpy(bta_av_co_cb.codec_cfg_setconfig.info, p_codec_info, AVDT_CODEC_SIZE);
+ if(AVDT_TSEP_SNK == t_local_sep)
+ {
+ /* If Peer is SRC, and our cfg subset matches with what is requested by peer, then
+ just accept what peer wants */
+ memcpy(bta_av_co_cb.codec_cfg.info, p_codec_info, AVDT_CODEC_SIZE);
+ recfg_needed = FALSE;
+ }
break;
@@ -618,7 +880,7 @@
APPL_TRACE_DEBUG2("bta_av_co_audio_setconfig reject s=%d c=%d", status, category);
/* Call call-in rejecting the configuration */
- bta_av_ci_setconfig(hndl, status, category, 0, NULL, FALSE);
+ bta_av_ci_setconfig(hndl, status, category, 0, NULL, FALSE, avdt_handle);
}
else
{
@@ -629,7 +891,7 @@
APPL_TRACE_DEBUG1("bta_av_co_audio_setconfig accept reconf=%d", recfg_needed);
/* Call call-in accepting the configuration */
- bta_av_ci_setconfig(hndl, A2D_SUCCESS, A2D_SUCCESS, 0, NULL, recfg_needed);
+ bta_av_ci_setconfig(hndl, A2D_SUCCESS, A2D_SUCCESS, 0, NULL, recfg_needed, avdt_handle);
}
}
@@ -1094,13 +1356,89 @@
/*******************************************************************************
**
- ** Function bta_av_co_audio_media_supports_config
+ ** Function bta_av_co_audio_peer_src_supports_codec
+ **
+ ** Description Check if a peer acting as src supports codec config
+ **
+ ** Returns TRUE if the connection supports this codec, FALSE otherwise
+ **
+ *******************************************************************************/
+static BOOLEAN bta_av_co_audio_peer_src_supports_codec(tBTA_AV_CO_PEER *p_peer, UINT8 *p_src_index)
+{
+ int index;
+ UINT8 codec_type;
+ FUNC_TRACE();
+
+ /* Configure the codec type to look for */
+ codec_type = bta_av_co_cb.codec_cfg.id;
+
+
+ for (index = 0; index < p_peer->num_sup_srcs; index++)
+ {
+ if (p_peer->srcs[index].codec_type == codec_type)
+ {
+ switch (bta_av_co_cb.codec_cfg.id)
+ {
+ case BTIF_AV_CODEC_SBC:
+ if (p_src_index) *p_src_index = index;
+ if (0 == bta_av_sbc_cfg_matches_cap((UINT8 *)p_peer->srcs[index].codec_caps,
+ (tA2D_SBC_CIE *)&bta_av_co_sbc_sink_caps))
+ {
+ return TRUE;
+ }
+ break;
+
+ default:
+ APPL_TRACE_ERROR1("peer_src_supports_codec: unsupported codec id %d",
+ bta_av_co_cb.codec_cfg.id);
+ return FALSE;
+ break;
+ }
+ }
+ }
+ return FALSE;
+}
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_audio_sink_supports_config
**
** Description Check if the media source supports a given configuration
**
** Returns TRUE if the media source supports this config, FALSE otherwise
**
*******************************************************************************/
+static BOOLEAN bta_av_co_audio_sink_supports_config(UINT8 codec_type, const UINT8 *p_codec_cfg)
+{
+ FUNC_TRACE();
+
+ switch (codec_type)
+ {
+ case BTA_AV_CODEC_SBC:
+ if (bta_av_sbc_cfg_in_cap((UINT8 *)p_codec_cfg, (tA2D_SBC_CIE *)&bta_av_co_sbc_sink_caps))
+ {
+ return FALSE;
+ }
+ break;
+
+
+ default:
+ APPL_TRACE_ERROR1("bta_av_co_audio_media_supports_config unsupported codec type %d", codec_type);
+ return FALSE;
+ break;
+ }
+ return TRUE;
+}
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_audio_media_supports_config
+ **
+ ** Description Check if the media sink supports a given configuration
+ **
+ ** Returns TRUE if the media source supports this config, FALSE otherwise
+ **
+ *******************************************************************************/
static BOOLEAN bta_av_co_audio_media_supports_config(UINT8 codec_type, const UINT8 *p_codec_cfg)
{
FUNC_TRACE();
diff --git a/btif/co/bta_gatts_co.c b/btif/co/bta_gatts_co.c
index d030075..c061a28 100644
--- a/btif/co/bta_gatts_co.c
+++ b/btif/co/bta_gatts_co.c
@@ -61,97 +61,6 @@
}
}
-static BOOLEAN btif_gatts_srv_chg(tBTA_GATTS_SRV_CHG_CMD cmd,
- tBTA_GATTS_SRV_CHG_REQ *p_req,
- tBTA_GATTS_SRV_CHG_RSP *p_rsp)
-{
- BOOLEAN status = TRUE;
- BOOLEAN found = FALSE;
- UINT8 i, j, idx, last_idx;
- btif_gatts_srv_chg_cb_t *p_cb = &btif_gatts_srv_chg_cb;
-
- btif_gatts_check_init();
-
- switch (cmd)
- {
- case BTA_GATTS_SRV_CHG_CMD_ADD_CLIENT:
-
- if (p_cb->num_clients < BTIF_GATTS_MAX_SRV_CHG_CLT_SIZE)
- {
- memcpy(&p_cb->srv_chg[p_cb->num_clients], &p_req->srv_chg, sizeof(tBTA_GATTS_SRV_CHG));
- p_cb->num_clients++;
- } else {
- status = FALSE;
- }
- break;
-
- case BTA_GATTS_SRV_CHG_CMD_UPDATE_CLIENT:
-
- for (i=0; i != p_cb->num_clients; ++i)
- {
- if (!memcmp(p_cb->srv_chg[i].bda, p_req->srv_chg.bda, sizeof(BD_ADDR)))
- {
- found = TRUE;
- memcpy(&p_cb->srv_chg[i], &p_req->srv_chg, sizeof(tBTA_GATTS_SRV_CHG));
- break;
- }
- }
-
- if (!found)
- status = FALSE;
- break;
-
- case BTA_GATTS_SRV_CHG_CMD_REMOVE_CLIENT:
-
- for (i=0; i != p_cb->num_clients; ++i)
- {
- if (!memcmp(p_cb->srv_chg[i].bda, p_req->srv_chg.bda, sizeof(BD_ADDR)))
- {
- found = TRUE;
- last_idx = p_cb->num_clients - 1;
-
- if (i != last_idx )
- {
- /* Update the array so there is no gap */
- for (j=i; j != last_idx; ++j )
- {
- memcpy(&p_cb->srv_chg[j], &p_cb->srv_chg[j+1], sizeof(tBTA_GATTS_SRV_CHG));
- }
-
- }
-
- /* Reset the last client and update num_clients */
- memset(&p_cb->srv_chg[last_idx], 0, sizeof(tBTA_GATTS_SRV_CHG));
- p_cb->num_clients--;
- break;
- }
- }
-
- if (!found)
- status = FALSE;
- break;
-
- case BTA_GATTS_SRV_CHG_CMD_READ_NUM_CLENTS:
- p_rsp->num_clients = p_cb->num_clients;
- break;
-
- case BTA_GATTS_SRV_CHG_CMD_READ_CLENT:
- idx = p_req->client_read_index - 1;
-
- if (idx < p_cb->num_clients )
- memcpy(&p_rsp->srv_chg, &p_cb->srv_chg[idx], sizeof(tBTA_GATTS_SRV_CHG));
- else
- status = FALSE;
- break;
-
- default:
- status = FALSE;
- break;
- }
-
- return status;
-}
-
/*****************************************************************************
** Externally called functions
*****************************************************************************/
diff --git a/btif/include/btif_api.h b/btif/include/btif_api.h
index 3a5607f..80a74d0 100644
--- a/btif/include/btif_api.h
+++ b/btif/include/btif_api.h
@@ -232,6 +232,17 @@
/*******************************************************************************
**
+** Function btif_dm_get_connection_state
+**
+** Description Returns whether the remote device is currently connected
+**
+** Returns 0 if not connected
+**
+*******************************************************************************/
+uint16_t btif_dm_get_connection_state(const bt_bdaddr_t *bd_addr);
+
+/*******************************************************************************
+**
** Function btif_dm_pin_reply
**
** Description BT legacy pairing - PIN code reply
diff --git a/btif/include/btif_av.h b/btif/include/btif_av.h
index 9e537cd..12174c9 100644
--- a/btif/include/btif_av.h
+++ b/btif/include/btif_av.h
@@ -44,7 +44,7 @@
BTIF_AV_START_STREAM_REQ_EVT,
BTIF_AV_STOP_STREAM_REQ_EVT,
BTIF_AV_SUSPEND_STREAM_REQ_EVT,
- BTIF_AV_RECONFIGURE_REQ_EVT,
+ BTIF_AV_SINK_CONFIG_REQ_EVT,
} btif_av_sm_event_t;
diff --git a/btif/include/btif_av_co.h b/btif/include/btif_av_co.h
index 20e9a1e..a6a5bfa 100644
--- a/btif/include/btif_av_co.h
+++ b/btif/include/btif_av_co.h
@@ -28,6 +28,7 @@
enum
{
BTIF_SV_AV_AA_SBC_INDEX = 0,
+ BTIF_SV_AV_AA_SBC_SINK_INDEX,
BTIF_SV_AV_AA_SEP_INDEX /* Last index */
};
diff --git a/btif/include/btif_common.h b/btif/include/btif_common.h
index f11b629..111b90c 100644
--- a/btif/include/btif_common.h
+++ b/btif/include/btif_common.h
@@ -1,5 +1,6 @@
/******************************************************************************
*
+ * Copyright (c) 2014 The Android Open Source Project
* Copyright (C) 2009-2012 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,6 +50,7 @@
#define BTIF_HFP 2
#define BTIF_AV 3
#define BTIF_PAN 4
+#define BTIF_HF_CLIENT 5
extern bt_callbacks_t *bt_hal_cbacks;
@@ -116,6 +118,9 @@
BTIF_PAN_CB_START = BTIF_SIG_CB_START(BTIF_PAN),
BTIF_PAN_CB_DISCONNECTING, /* PAN Disconnect has been sent to BTA successfully */
+
+ BTIF_HF_CLIENT_CLIENT_CB_START = BTIF_SIG_CB_START(BTIF_HF_CLIENT),
+ BTIF_HF_CLIENT_CB_AUDIO_CONNECTING, /* AUDIO connect has been sent to BTA successfully */
};
/* Macro definitions for BD ADDR persistence */
diff --git a/btif/include/btif_gatt_multi_adv_util.h b/btif/include/btif_gatt_multi_adv_util.h
new file mode 100644
index 0000000..2fef449
--- /dev/null
+++ b/btif/include/btif_gatt_multi_adv_util.h
@@ -0,0 +1,87 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 Broadcom 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.
+ *
+ ******************************************************************************/
+
+
+#ifndef BTIF_GATT_MULTI_ADV_UTIL_H
+#define BTIF_GATT_MULTI_ADV_UTIL_H
+
+#include <hardware/bluetooth.h>
+#include "bta_api.h"
+
+#define CLNT_IF_IDX 0
+#define INST_ID_IDX 1
+#define INVALID_ADV_INST -1
+#define STD_ADV_INSTID 0
+#define ADV_FLAGS 0x02
+
+typedef struct
+{
+ int client_if;
+ BOOLEAN set_scan_rsp;
+ BOOLEAN include_name;
+ BOOLEAN include_txpower;
+ int min_interval;
+ int max_interval;
+ int appearance;
+ uint16_t manufacturer_len;
+ uint8_t* p_manufacturer_data;
+ uint16_t service_data_len;
+ uint8_t* p_service_data;
+ uint16_t service_uuid_len;
+ uint8_t* p_service_uuid;
+} btif_adv_data_t;
+
+typedef struct
+{
+ UINT8 inst_id;
+ BOOLEAN is_scan_rsp;
+ UINT8 client_if;
+ UINT16 service_uuid_len;
+ tBTA_BLE_AD_MASK mask;
+ tBTA_BLE_ADV_DATA data;
+ tBTA_BLE_ADV_PARAMS param;
+}btgatt_multi_adv_inst_cb;
+
+typedef struct
+{
+ INT8 clntif_map[BTM_BLE_MULTI_ADV_MAX][INST_ID_IDX+1];
+ // Includes the stored data for standard LE instance
+ btgatt_multi_adv_inst_cb inst_cb[BTM_BLE_MULTI_ADV_MAX+1];
+} btgatt_multi_adv_common_data;
+
+extern btgatt_multi_adv_common_data *btif_obtain_multi_adv_data_cb();
+extern void btif_gattc_init_multi_adv_cb(void);
+extern void btif_gattc_destroy_multi_adv_cb();
+extern int btif_multi_adv_add_instid_map(int client_if, int inst_id,
+ BOOLEAN gen_temp_instid);
+extern int btif_multi_adv_instid_for_clientif(int client_if);
+extern int btif_gattc_obtain_idx_for_datacb(int value, int arrindex);
+extern void btif_gattc_clear_clientif(int client_if);
+extern void btif_gattc_cleanup_inst_cb(int inst_id);
+extern void btif_gattc_cleanup_multi_inst_cb(btgatt_multi_adv_inst_cb *p_inst_cb);
+extern BOOLEAN btif_gattc_copy_datacb(int arrindex, btif_adv_data_t *p_adv_data,
+ BOOLEAN bInstData);
+extern void btif_gattc_adv_data_packager(int client_if, bool set_scan_rsp,
+ bool include_name, bool include_txpower, int min_interval, int max_interval,
+ int appearance, uint16_t manufacturer_len, char* manufacturer_data,
+ uint16_t service_data_len, char* service_data, uint16_t service_uuid_len,
+ char* service_uuid, btif_adv_data_t *p_multi_adv_inst);
+
+#endif
+
+
diff --git a/btif/include/btif_media.h b/btif/include/btif_media.h
index 4cdbb8c..f01286b 100644
--- a/btif/include/btif_media.h
+++ b/btif/include/btif_media.h
@@ -90,8 +90,13 @@
tBTIF_AV_FEEDING_MODE feeding_mode;
tBTIF_AV_MEDIA_FEEDINGS feeding;
} tBTIF_MEDIA_INIT_AUDIO_FEEDING;
-#endif
+typedef struct
+{
+ BT_HDR hdr;
+ UINT8 codec_info[AVDT_CODEC_SIZE];
+} tBTIF_MEDIA_SINK_CFG_UPDATE;
+#endif
/*******************************************************************************
** Public functions
@@ -154,7 +159,16 @@
*******************************************************************************/
extern BOOLEAN btif_media_task_stop_aa_req(void);
-
+/*******************************************************************************
+ **
+ ** Function btif_media_task_aa_rx_flush_req
+ **
+ ** Description Request to flush audio decoding pipe
+ **
+ ** Returns TRUE is success
+ **
+ *******************************************************************************/
+extern BOOLEAN btif_media_task_aa_rx_flush_req(void);
/*******************************************************************************
**
** Function btif_media_task_aa_tx_flush_req
@@ -179,6 +193,19 @@
/*******************************************************************************
**
+ ** Function btif_media_sink_enque_buf
+ **
+ ** Description This function is called by the av_co to fill A2DP Sink Queue
+ **
+ **
+ ** Returns size of the queue
+ *******************************************************************************/
+ UINT8 btif_media_sink_enque_buf(BT_HDR *p_buf);
+
+
+
+/*******************************************************************************
+ **
** Function btif_media_aa_writebuf
**
** Description Enqueue a Advance Audio media GKI buffer to be processed by btif media task.
@@ -243,5 +270,13 @@
void btif_a2dp_on_suspend(void);
void btif_a2dp_on_suspended(tBTA_AV_SUSPEND *p_av);
void btif_a2dp_set_tx_flush(BOOLEAN enable);
+void btif_a2dp_set_rx_flush(BOOLEAN enable);
+void btif_media_check_iop_exceptions(UINT8 *peer_bda);
+void btif_reset_decoder(UINT8 *p_av);
+BOOLEAN btif_media_task_start_decoding_req(void);
+
+int btif_a2dp_get_track_frequency(UINT8 frequency);
+int btif_a2dp_get_track_channel_count(UINT8 channeltype);
+void btif_a2dp_set_peer_sep(UINT8 sep);
#endif
diff --git a/btif/include/btif_profile_queue.h b/btif/include/btif_profile_queue.h
index e05c97a..b586575 100644
--- a/btif/include/btif_profile_queue.h
+++ b/btif/include/btif_profile_queue.h
@@ -27,7 +27,7 @@
#ifndef BTIF_PROFILE_QUEUE_H
#define BTIF_PROFILE_QUEUE_H
-typedef bt_status_t (*btif_connect_cb_t)(bt_bdaddr_t *bda);
+typedef bt_status_t (*btif_connect_cb_t) (bt_bdaddr_t *bda, uint16_t uuid);
bt_status_t btif_queue_connect(uint16_t uuid, const bt_bdaddr_t *bda, btif_connect_cb_t connect_cb);
void btif_queue_advance();
diff --git a/btif/include/btif_util.h b/btif/include/btif_util.h
index 95969dd..4f1a9cc 100644
--- a/btif/include/btif_util.h
+++ b/btif/include/btif_util.h
@@ -1,5 +1,6 @@
/******************************************************************************
*
+ * Copyright (c) 2014 The Android Open Source Project
* Copyright (C) 2009-2012 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -50,6 +51,7 @@
const char* dump_dm_search_event(UINT16 event);
const char* dump_dm_event(UINT16 event);
const char* dump_hf_event(UINT16 event);
+const char* dump_hf_client_event(UINT16 event);
const char* dump_hh_event(UINT16 event);
const char* dump_hf_conn_state(UINT16 event);
const char* dump_hf_call_state(bthf_call_state_t call_state);
diff --git a/btif/src/bluetooth.c b/btif/src/bluetooth.c
index fe4182f..a88a40c 100644
--- a/btif/src/bluetooth.c
+++ b/btif/src/bluetooth.c
@@ -30,6 +30,7 @@
#include <hardware/bluetooth.h>
#include <hardware/bt_hf.h>
+#include <hardware/bt_hf_client.h>
#include <hardware/bt_av.h>
#include <hardware/bt_sock.h>
#include <hardware/bt_hh.h>
@@ -60,6 +61,9 @@
bt_callbacks_t *bt_hal_cbacks = NULL;
+/** Operating System specific callouts for resource management */
+bt_os_callouts_t *bt_os_callouts = NULL;
+
/************************************************************************************
** Static functions
************************************************************************************/
@@ -72,8 +76,11 @@
/* handsfree profile */
extern bthf_interface_t *btif_hf_get_interface();
+/* handsfree profile - client */
+extern bthf_client_interface_t *btif_hf_client_get_interface();
/* advanced audio profile */
-extern btav_interface_t *btif_av_get_interface();
+extern btav_interface_t *btif_av_get_src_interface();
+extern btav_interface_t *btif_av_get_sink_interface();
/*rfc l2cap*/
extern btsock_interface_t *btif_sock_get_interface();
/* hid host profile */
@@ -86,8 +93,10 @@
/* gatt */
extern btgatt_interface_t *btif_gatt_get_interface();
#endif
-/* avrc */
+/* avrc target */
extern btrc_interface_t *btif_rc_get_interface();
+/* avrc controller */
+extern btrc_interface_t *btif_rc_ctrl_get_interface();
/************************************************************************************
** Functions
@@ -280,6 +289,15 @@
return btif_dm_remove_bond(bd_addr);
}
+static int get_connection_state(const bt_bdaddr_t *bd_addr)
+{
+ /* sanity check */
+ if (interface_ready() == FALSE)
+ return 0;
+
+ return btif_dm_get_connection_state(bd_addr);
+}
+
static int pin_reply(const bt_bdaddr_t *bd_addr, uint8_t accept,
uint8_t pin_len, bt_pin_code_t *pin_code)
{
@@ -312,6 +330,9 @@
if (is_profile(profile_id, BT_PROFILE_HANDSFREE_ID))
return btif_hf_get_interface();
+ if (is_profile(profile_id, BT_PROFILE_HANDSFREE_CLIENT_ID))
+ return btif_hf_client_get_interface();
+
if (is_profile(profile_id, BT_PROFILE_SOCKETS_ID))
return btif_sock_get_interface();
@@ -319,7 +340,10 @@
return btif_pan_get_interface();
if (is_profile(profile_id, BT_PROFILE_ADVANCED_AUDIO_ID))
- return btif_av_get_interface();
+ return btif_av_get_src_interface();
+
+ if (is_profile(profile_id, BT_PROFILE_ADVANCED_AUDIO_SINK_ID))
+ return btif_av_get_sink_interface();
if (is_profile(profile_id, BT_PROFILE_HIDHOST_ID))
return btif_hh_get_interface();
@@ -335,6 +359,9 @@
if (is_profile(profile_id, BT_PROFILE_AV_RC_ID))
return btif_rc_get_interface();
+ if (is_profile(profile_id, BT_PROFILE_AV_RC_CTRL_ID))
+ return btif_rc_ctrl_get_interface();
+
return NULL;
}
@@ -384,6 +411,11 @@
return btif_config_hci_snoop_log(enable);
}
+static int set_os_callouts(bt_os_callouts_t *callouts) {
+ bt_os_callouts = callouts;
+ return BT_STATUS_SUCCESS;
+}
+
static const bt_interface_t bluetoothInterface = {
sizeof(bluetoothInterface),
init,
@@ -403,6 +435,7 @@
create_bond,
remove_bond,
cancel_bond,
+ get_connection_state,
pin_reply,
ssp_reply,
get_profile_interface,
@@ -413,7 +446,8 @@
#else
NULL,
#endif
- config_hci_snoop_log
+ config_hci_snoop_log,
+ set_os_callouts,
};
const bt_interface_t* bluetooth__get_bluetooth_interface ()
diff --git a/btif/src/btif_av.c b/btif/src/btif_av.c
index f893c9e..28d0d66 100644
--- a/btif/src/btif_av.c
+++ b/btif/src/btif_av.c
@@ -26,6 +26,7 @@
*****************************************************************************/
#include <hardware/bluetooth.h>
+#include <system/audio.h>
#include "hardware/bt_av.h"
#define LOG_TAG "BTIF_AV"
@@ -77,17 +78,32 @@
btif_sm_handle_t sm_handle;
UINT8 flags;
tBTA_AV_EDR edr;
+ UINT8 peer_sep; /* sep type of peer device */
} btif_av_cb_t;
+typedef struct
+{
+ bt_bdaddr_t *target_bda;
+ uint16_t uuid;
+} btif_av_connect_req_t;
+
+typedef struct
+{
+ int sample_rate;
+ int channel_count;
+} btif_av_sink_config_req_t;
+
/*****************************************************************************
** Static variables
******************************************************************************/
-static btav_callbacks_t *bt_av_callbacks = NULL;
+static btav_callbacks_t *bt_av_src_callbacks = NULL;
+static btav_callbacks_t *bt_av_sink_callbacks = NULL;
static btif_av_cb_t btif_av_cb;
static TIMER_LIST_ENT tle_av_open_on_rc;
/* both interface and media task needs to be ready to alloc incoming request */
-#define CHECK_BTAV_INIT() if ((bt_av_callbacks == NULL) || (btif_av_cb.sm_handle == NULL))\
+#define CHECK_BTAV_INIT() if (((bt_av_src_callbacks == NULL) &&(bt_av_sink_callbacks == NULL)) \
+ || (btif_av_cb.sm_handle == NULL))\
{\
BTIF_TRACE_WARNING1("%s: BTAV not initialized", __FUNCTION__);\
return BT_STATUS_NOT_READY;\
@@ -179,8 +195,7 @@
CASE_RETURN_STR(BTIF_AV_START_STREAM_REQ_EVT)
CASE_RETURN_STR(BTIF_AV_STOP_STREAM_REQ_EVT)
CASE_RETURN_STR(BTIF_AV_SUSPEND_STREAM_REQ_EVT)
- CASE_RETURN_STR(BTIF_AV_RECONFIGURE_REQ_EVT)
-
+ CASE_RETURN_STR(BTIF_AV_SINK_CONFIG_REQ_EVT)
default: return "UNKNOWN_EVENT";
}
}
@@ -203,11 +218,15 @@
{
BD_ADDR peer_addr;
UNUSED(tle);
-
+ btif_av_connect_req_t connect_req;
+ UNUSED(tle);
/* is there at least one RC connection - There should be */
if (btif_rc_get_connected_peer(peer_addr)) {
BTIF_TRACE_DEBUG1("%s Issuing connect to the remote RC peer", __FUNCTION__);
- btif_sm_dispatch(btif_av_cb.sm_handle, BTIF_AV_CONNECT_REQ_EVT, (void*)&peer_addr);
+ /* In case of AVRCP connection request, we will initiate SRC connection */
+ connect_req.target_bda = (bt_bdaddr_t*)&peer_addr;
+ connect_req.uuid = UUID_SERVCLASS_AUDIO_SOURCE;
+ btif_sm_dispatch(btif_av_cb.sm_handle, BTIF_AV_CONNECT_REQ_EVT, (char*)&connect_req);
}
else
{
@@ -219,9 +238,27 @@
** Static functions
******************************************************************************/
+static void btif_report_connection_state(btav_connection_state_t state, bt_bdaddr_t *bd_addr)
+{
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SRC && bt_av_sink_callbacks != NULL) {
+ HAL_CBACK(bt_av_sink_callbacks, connection_state_cb, state, bd_addr);
+ } else if (btif_av_cb.peer_sep == AVDT_TSEP_SNK && bt_av_src_callbacks != NULL) {
+ HAL_CBACK(bt_av_src_callbacks, connection_state_cb, state, bd_addr);
+ }
+}
+
+static void btif_report_audio_state(btav_audio_state_t state, bt_bdaddr_t *bd_addr)
+{
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SRC && bt_av_sink_callbacks != NULL) {
+ HAL_CBACK(bt_av_sink_callbacks, audio_state_cb, state, bd_addr);
+ } else if (btif_av_cb.peer_sep == AVDT_TSEP_SNK && bt_av_src_callbacks != NULL) {
+ HAL_CBACK(bt_av_src_callbacks, audio_state_cb, state, bd_addr);
+ }
+}
+
/*****************************************************************************
**
-** Function btif_av_state_idle_handler
+** Function btif_av_state_idle_handler
**
** Description State managing disconnected AV link
**
@@ -259,14 +296,17 @@
{
if (event == BTIF_AV_CONNECT_REQ_EVT)
{
- memcpy(&btif_av_cb.peer_bda, (bt_bdaddr_t*)p_data, sizeof(bt_bdaddr_t));
+ memcpy(&btif_av_cb.peer_bda, ((btif_av_connect_req_t*)p_data)->target_bda,
+ sizeof(bt_bdaddr_t));
+ BTA_AvOpen(btif_av_cb.peer_bda.address, btif_av_cb.bta_handle,
+ TRUE, BTA_SEC_NONE, ((btif_av_connect_req_t*)p_data)->uuid);
}
else if (event == BTA_AV_PENDING_EVT)
{
bdcpy(btif_av_cb.peer_bda.address, ((tBTA_AV*)p_data)->pend.bd_addr);
+ BTA_AvOpen(btif_av_cb.peer_bda.address, btif_av_cb.bta_handle,
+ TRUE, BTA_SEC_NONE, UUID_SERVCLASS_AUDIO_SOURCE);
}
- BTA_AvOpen(btif_av_cb.peer_bda.address, btif_av_cb.bta_handle,
- TRUE, BTA_SEC_NONE);
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_OPENING);
} break;
@@ -332,13 +372,18 @@
{
case BTIF_SM_ENTER_EVT:
/* inform the application that we are entering connecting state */
- HAL_CBACK(bt_av_callbacks, connection_state_cb,
- BTAV_CONNECTION_STATE_CONNECTING, &(btif_av_cb.peer_bda));
+ btif_report_connection_state(BTAV_CONNECTION_STATE_CONNECTING, &(btif_av_cb.peer_bda));
break;
case BTIF_SM_EXIT_EVT:
break;
+ case BTA_AV_REJECT_EVT:
+ BTIF_TRACE_DEBUG0(" Received BTA_AV_REJECT_EVT ");
+ btif_report_connection_state(BTAV_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
+ btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_IDLE);
+ break;
+
case BTA_AV_OPEN_EVT:
{
tBTA_AV *p_bta_data = (tBTA_AV*)p_data;
@@ -352,6 +397,9 @@
state = BTAV_CONNECTION_STATE_CONNECTED;
av_state = BTIF_AV_STATE_OPENED;
btif_av_cb.edr = p_bta_data->open.edr;
+
+ btif_av_cb.peer_sep = p_bta_data->open.sep;
+ btif_a2dp_set_peer_sep(p_bta_data->open.sep);
}
else
{
@@ -362,16 +410,39 @@
}
/* inform the application of the event */
- HAL_CBACK(bt_av_callbacks, connection_state_cb,
- state, &(btif_av_cb.peer_bda));
+ btif_report_connection_state(state, &(btif_av_cb.peer_bda));
/* change state to open/idle based on the status */
btif_sm_change_state(btif_av_cb.sm_handle, av_state);
- /* if queued PLAY command, send it now */
- btif_rc_check_handle_pending_play(p_bta_data->open.bd_addr,
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SNK)
+ {
+ /* if queued PLAY command, send it now */
+ btif_rc_check_handle_pending_play(p_bta_data->open.bd_addr,
(p_bta_data->open.status == BTA_AV_SUCCESS));
+ }
+ else if (btif_av_cb.peer_sep == AVDT_TSEP_SRC)
+ {
+ /* if queued PLAY command, send it now */
+ btif_rc_check_handle_pending_play(p_bta_data->open.bd_addr, FALSE);
+ /* Bring up AVRCP connection too */
+ BTA_AvOpenRc(btif_av_cb.bta_handle);
+ }
btif_queue_advance();
} break;
+ case BTIF_AV_SINK_CONFIG_REQ_EVT:
+ {
+ btif_av_sink_config_req_t req;
+ // copy to avoid alignment problems
+ memcpy(&req, p_data, sizeof(req));
+
+ BTIF_TRACE_WARNING2("BTIF_AV_SINK_CONFIG_REQ_EVT %d %d", req.sample_rate,
+ req.channel_count);
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SRC && bt_av_sink_callbacks != NULL) {
+ HAL_CBACK(bt_av_sink_callbacks, audio_config_cb, &(btif_av_cb.peer_bda),
+ req.sample_rate, req.channel_count);
+ }
+ } break;
+
CHECK_RC_EVENT(event, p_data);
default:
@@ -403,20 +474,32 @@
switch (event)
{
case BTIF_SM_ENTER_EVT:
-
- /* immediately stop transmission of frames */
- btif_a2dp_set_tx_flush(TRUE);
- /* wait for audioflinger to stop a2dp */
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SNK)
+ {
+ /* immediately stop transmission of frames */
+ btif_a2dp_set_tx_flush(TRUE);
+ /* wait for audioflinger to stop a2dp */
+ }
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SRC)
+ {
+ btif_a2dp_set_rx_flush(TRUE);
+ }
break;
case BTA_AV_STOP_EVT:
case BTIF_AV_STOP_STREAM_REQ_EVT:
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SNK)
+ {
/* immediately flush any pending tx frames while suspend is pending */
btif_a2dp_set_tx_flush(TRUE);
+ }
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SRC)
+ {
+ btif_a2dp_set_rx_flush(TRUE);
+ }
- btif_a2dp_on_stopped(NULL);
-
- break;
+ btif_a2dp_on_stopped(NULL);
+ break;
case BTIF_SM_EXIT_EVT:
break;
@@ -424,8 +507,7 @@
case BTA_AV_CLOSE_EVT:
/* inform the application that we are disconnecting */
- HAL_CBACK(bt_av_callbacks, connection_state_cb,
- BTAV_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
+ btif_report_connection_state(BTAV_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_IDLE);
break;
@@ -480,6 +562,12 @@
break;
case BTIF_AV_START_STREAM_REQ_EVT:
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SRC)
+ {
+ BTA_AvStart();
+ btif_av_cb.flags |= BTIF_AV_FLAG_PENDING_START;
+ break;
+ }
btif_a2dp_setup_codec();
BTA_AvStart();
btif_av_cb.flags |= BTIF_AV_FLAG_PENDING_START;
@@ -493,19 +581,30 @@
if ((p_av->start.status == BTA_SUCCESS) && (p_av->start.suspending == TRUE))
return TRUE;
- if (btif_a2dp_on_started(&p_av->start,
- ((btif_av_cb.flags & BTIF_AV_FLAG_PENDING_START) != 0))) {
- /* only clear pending flag after acknowledgement */
- btif_av_cb.flags &= ~BTIF_AV_FLAG_PENDING_START;
+ /* In case peer is A2DP SRC we do not want to ack commands on UIPC*/
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SNK)
+ {
+ if (btif_a2dp_on_started(&p_av->start,
+ ((btif_av_cb.flags & BTIF_AV_FLAG_PENDING_START) != 0)))
+ {
+ /* only clear pending flag after acknowledgement */
+ btif_av_cb.flags &= ~BTIF_AV_FLAG_PENDING_START;
+ }
}
/* remain in open state if status failed */
if (p_av->start.status != BTA_AV_SUCCESS)
return FALSE;
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SRC)
+ {
+ btif_a2dp_set_rx_flush(FALSE); /* remove flush state, ready for streaming*/
+ }
+
/* change state to started, send acknowledgement if start is pending */
if (btif_av_cb.flags & BTIF_AV_FLAG_PENDING_START) {
- btif_a2dp_on_started(NULL, TRUE);
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SNK)
+ btif_a2dp_on_started(NULL, TRUE);
/* pending start flag will be cleared when exit current state */
}
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_STARTED);
@@ -514,20 +613,20 @@
case BTIF_AV_DISCONNECT_REQ_EVT:
BTA_AvClose(btif_av_cb.bta_handle);
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SRC) {
+ BTA_AvCloseRc(btif_av_cb.bta_handle);
+ }
/* inform the application that we are disconnecting */
- HAL_CBACK(bt_av_callbacks, connection_state_cb,
- BTAV_CONNECTION_STATE_DISCONNECTING, &(btif_av_cb.peer_bda));
+ btif_report_connection_state(BTAV_CONNECTION_STATE_DISCONNECTING, &(btif_av_cb.peer_bda));
break;
case BTA_AV_CLOSE_EVT:
-
- /* avdtp link is closed */
+ /* avdtp link is closed */
btif_a2dp_on_stopped(NULL);
/* inform the application that we are disconnected */
- HAL_CBACK(bt_av_callbacks, connection_state_cb,
- BTAV_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
+ btif_report_connection_state(BTAV_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
/* change state to idle, send acknowledgement if start is pending */
if (btif_av_cb.flags & BTIF_AV_FLAG_PENDING_START) {
@@ -586,8 +685,7 @@
/* we are again in started state, clear any remote suspend flags */
btif_av_cb.flags &= ~BTIF_AV_FLAG_REMOTE_SUSPEND;
- HAL_CBACK(bt_av_callbacks, audio_state_cb,
- BTAV_AUDIO_STATE_STARTED, &(btif_av_cb.peer_bda));
+ btif_report_audio_state(BTAV_AUDIO_STATE_STARTED, &(btif_av_cb.peer_bda));
/* increase the a2dp consumer task priority temporarily when start
** audio playing, to avoid overflow the audio packet queue. */
@@ -603,7 +701,8 @@
case BTIF_AV_START_STREAM_REQ_EVT:
/* we were remotely started, just ack back the local request */
- btif_a2dp_on_started(NULL, TRUE);
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SNK)
+ btif_a2dp_on_started(NULL, TRUE);
break;
/* fixme -- use suspend = true always to work around issue with BTA AV */
@@ -618,8 +717,16 @@
always overrides */
btif_av_cb.flags &= ~BTIF_AV_FLAG_REMOTE_SUSPEND;
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SNK)
+ {
/* immediately stop transmission of frames while suspend is pending */
- btif_a2dp_set_tx_flush(TRUE);
+ btif_a2dp_set_tx_flush(TRUE);
+ }
+
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SRC) {
+ btif_a2dp_set_rx_flush(TRUE);
+ btif_a2dp_on_stopped(NULL);
+ }
BTA_AvStop(TRUE);
break;
@@ -628,10 +735,12 @@
/* request avdtp to close */
BTA_AvClose(btif_av_cb.bta_handle);
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SRC) {
+ BTA_AvCloseRc(btif_av_cb.bta_handle);
+ }
/* inform the application that we are disconnecting */
- HAL_CBACK(bt_av_callbacks, connection_state_cb,
- BTAV_CONNECTION_STATE_DISCONNECTING, &(btif_av_cb.peer_bda));
+ btif_report_connection_state(BTAV_CONNECTION_STATE_DISCONNECTING, &(btif_av_cb.peer_bda));
/* wait in closing state until fully closed */
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_CLOSING);
@@ -650,8 +759,11 @@
{
btif_av_cb.flags &= ~BTIF_AV_FLAG_LOCAL_SUSPEND_PENDING;
+ if (btif_av_cb.peer_sep == AVDT_TSEP_SNK)
+ {
/* suspend failed, reset back tx flush state */
- btif_a2dp_set_tx_flush(FALSE);
+ btif_a2dp_set_tx_flush(FALSE);
+ }
return FALSE;
}
@@ -665,13 +777,11 @@
if ((btif_av_cb.flags & BTIF_AV_FLAG_LOCAL_SUSPEND_PENDING) == 0)
btif_av_cb.flags |= BTIF_AV_FLAG_REMOTE_SUSPEND;
- HAL_CBACK(bt_av_callbacks, audio_state_cb,
- BTAV_AUDIO_STATE_REMOTE_SUSPEND, &(btif_av_cb.peer_bda));
+ btif_report_audio_state(BTAV_AUDIO_STATE_REMOTE_SUSPEND, &(btif_av_cb.peer_bda));
}
else
{
- HAL_CBACK(bt_av_callbacks, audio_state_cb,
- BTAV_AUDIO_STATE_STOPPED, &(btif_av_cb.peer_bda));
+ btif_report_audio_state(BTAV_AUDIO_STATE_STOPPED, &(btif_av_cb.peer_bda));
}
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_OPENED);
@@ -683,11 +793,9 @@
case BTA_AV_STOP_EVT:
btif_av_cb.flags |= BTIF_AV_FLAG_PENDING_STOP;
-
btif_a2dp_on_stopped(&p_av->suspend);
- HAL_CBACK(bt_av_callbacks, audio_state_cb,
- BTAV_AUDIO_STATE_STOPPED, &(btif_av_cb.peer_bda));
+ btif_report_audio_state(BTAV_AUDIO_STATE_STOPPED, &(btif_av_cb.peer_bda));
/* if stop was successful, change state to open */
if (p_av->suspend.status == BTA_AV_SUCCESS)
@@ -700,12 +808,10 @@
btif_av_cb.flags |= BTIF_AV_FLAG_PENDING_STOP;
/* avdtp link is closed */
-
btif_a2dp_on_stopped(NULL);
/* inform the application that we are disconnected */
- HAL_CBACK(bt_av_callbacks, connection_state_cb,
- BTAV_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
+ btif_report_connection_state(BTAV_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_IDLE);
break;
@@ -737,6 +843,43 @@
(char*)p_data, sizeof(tBTA_AV), NULL);
}
+static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
+{
+ btif_sm_state_t state;
+ UINT8 que_len;
+ tA2D_STATUS a2d_status;
+ tA2D_SBC_CIE sbc_cie;
+ btif_av_sink_config_req_t config_req;
+
+ if (event == BTA_AV_MEDIA_DATA_EVT)/* Switch to BTIF_MEDIA context */
+ {
+ state= btif_sm_get_state(btif_av_cb.sm_handle);
+ if ( (state == BTIF_AV_STATE_STARTED) || /* send SBC packets only in Started State */
+ (state == BTIF_AV_STATE_OPENED) )
+ {
+ que_len = btif_media_sink_enque_buf((BT_HDR *)p_data);
+ BTIF_TRACE_DEBUG1(" Packets in Que %d",que_len);
+ }
+ else
+ return;
+ }
+
+ if (event == BTA_AV_MEDIA_SINK_CFG_EVT) {
+ /* send a command to BT Media Task */
+ btif_reset_decoder((UINT8*)p_data);
+
+ a2d_status = A2D_ParsSbcInfo(&sbc_cie, (UINT8 *)p_data, FALSE);
+ if (a2d_status == A2D_SUCCESS) {
+ /* Switch to BTIF context */
+ config_req.sample_rate = btif_a2dp_get_track_frequency(sbc_cie.samp_freq);
+ config_req.channel_count = btif_a2dp_get_track_channel_count(sbc_cie.ch_mode);
+ btif_transfer_context(btif_av_handle_event, BTIF_AV_SINK_CONFIG_REQ_EVT,
+ (char*)&config_req, sizeof(config_req), NULL);
+ } else {
+ APPL_TRACE_ERROR1("ERROR dump_codec_info A2D_ParsSbcInfo fail:%d", a2d_status);
+ }
+ }
+}
/*******************************************************************************
**
** Function btif_av_init
@@ -747,8 +890,10 @@
**
*******************************************************************************/
-bt_status_t btif_av_init(void)
+bt_status_t btif_av_init()
{
+ btif_av_cb.sm_handle = NULL;
+
if (btif_av_cb.sm_handle == NULL)
{
if (btif_a2dp_start_media_task() != GKI_SUCCESS)
@@ -761,7 +906,7 @@
btif_a2dp_on_init();
- return BT_STATUS_SUCCESS;
+ return BT_STATUS_SUCCESS;
}
return BT_STATUS_DONE;
@@ -769,27 +914,63 @@
/*******************************************************************************
**
-** Function init
+** Function init_src
**
-** Description Initializes the AV interface
+** Description Initializes the AV interface for source mode
**
** Returns bt_status_t
**
*******************************************************************************/
-static bt_status_t init(btav_callbacks_t* callbacks )
+static bt_status_t init_src(btav_callbacks_t* callbacks)
{
- int status;
+ bt_status_t status;
BTIF_TRACE_EVENT1("%s", __FUNCTION__);
- if (bt_av_callbacks)
- return BT_STATUS_DONE;
+ if (bt_av_sink_callbacks != NULL) {
+ // already did btif_av_init()
+ status = BT_STATUS_SUCCESS;
+ } else {
+ status = btif_av_init();
+ }
- bt_av_callbacks = callbacks;
- btif_av_cb.sm_handle = NULL;
+ if (status == BT_STATUS_SUCCESS) {
+ bt_av_src_callbacks = callbacks;
+ }
- return btif_av_init();
+ return status;
+}
+
+/*******************************************************************************
+**
+** Function init_sink
+**
+** Description Initializes the AV interface for sink mode
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+
+static bt_status_t init_sink(btav_callbacks_t* callbacks)
+{
+ bt_status_t status;
+
+ BTIF_TRACE_EVENT1("%s", __FUNCTION__);
+
+ if (bt_av_src_callbacks != NULL) {
+ // already did btif_av_init()
+ status = BT_STATUS_SUCCESS;
+ } else {
+ status = btif_av_init();
+ }
+
+ if (status == BT_STATUS_SUCCESS) {
+ bt_av_sink_callbacks = callbacks;
+ BTA_AvEnable_Sink(TRUE);
+ }
+
+ return status;
}
/*******************************************************************************
@@ -802,16 +983,19 @@
**
*******************************************************************************/
-static bt_status_t connect_int(bt_bdaddr_t *bd_addr)
+static bt_status_t connect_int(bt_bdaddr_t *bd_addr, uint16_t uuid)
{
+ btif_av_connect_req_t connect_req;
+ connect_req.target_bda = bd_addr;
+ connect_req.uuid = uuid;
BTIF_TRACE_EVENT1("%s", __FUNCTION__);
- btif_sm_dispatch(btif_av_cb.sm_handle, BTIF_AV_CONNECT_REQ_EVT, (char*)bd_addr);
+ btif_sm_dispatch(btif_av_cb.sm_handle, BTIF_AV_CONNECT_REQ_EVT, (char*)&connect_req);
return BT_STATUS_SUCCESS;
}
-static bt_status_t connect(bt_bdaddr_t *bd_addr)
+static bt_status_t src_connect_sink(bt_bdaddr_t *bd_addr)
{
BTIF_TRACE_EVENT1("%s", __FUNCTION__);
CHECK_BTAV_INIT();
@@ -819,6 +1003,14 @@
return btif_queue_connect(UUID_SERVCLASS_AUDIO_SOURCE, bd_addr, connect_int);
}
+static bt_status_t sink_connect_src(bt_bdaddr_t *bd_addr)
+{
+ BTIF_TRACE_EVENT1("%s", __FUNCTION__);
+ CHECK_BTAV_INIT();
+
+ return btif_queue_connect(UUID_SERVCLASS_AUDIO_SINK, bd_addr, connect_int);
+}
+
/*******************************************************************************
**
** Function disconnect
@@ -852,26 +1044,51 @@
{
BTIF_TRACE_EVENT1("%s", __FUNCTION__);
- if (bt_av_callbacks)
- {
- btif_a2dp_stop_media_task();
+ btif_a2dp_stop_media_task();
- btif_disable_service(BTA_A2DP_SERVICE_ID);
- bt_av_callbacks = NULL;
+ btif_disable_service(BTA_A2DP_SERVICE_ID);
- /* Also shut down the AV state machine */
- btif_sm_shutdown(btif_av_cb.sm_handle);
- btif_av_cb.sm_handle = NULL;
- }
- return;
+ /* Also shut down the AV state machine */
+ btif_sm_shutdown(btif_av_cb.sm_handle);
+ btif_av_cb.sm_handle = NULL;
}
-static const btav_interface_t bt_av_interface = {
+static void cleanup_src(void) {
+ BTIF_TRACE_EVENT1("%s", __FUNCTION__);
+
+ if (bt_av_src_callbacks)
+ {
+ bt_av_src_callbacks = NULL;
+ if (bt_av_sink_callbacks == NULL)
+ cleanup();
+ }
+}
+
+static void cleanup_sink(void) {
+ BTIF_TRACE_EVENT1("%s", __FUNCTION__);
+
+ if (bt_av_sink_callbacks)
+ {
+ bt_av_sink_callbacks = NULL;
+ if (bt_av_src_callbacks == NULL)
+ cleanup();
+ }
+}
+
+static const btav_interface_t bt_av_src_interface = {
sizeof(btav_interface_t),
- init,
- connect,
+ init_src,
+ src_connect_sink,
disconnect,
- cleanup,
+ cleanup_src,
+};
+
+static const btav_interface_t bt_av_sink_interface = {
+ sizeof(btav_interface_t),
+ init_sink,
+ sink_connect_src,
+ disconnect,
+ cleanup_sink,
};
/*******************************************************************************
@@ -995,7 +1212,7 @@
BTA_AvEnable(BTA_SEC_AUTHENTICATE, (BTA_AV_FEAT_RCTG | BTA_AV_FEAT_NO_SCO_SSPD),
bte_av_callback);
#endif
- BTA_AvRegister(BTA_AV_CHNL_AUDIO, BTIF_AV_SERVICE_NAME, 0);
+ BTA_AvRegister(BTA_AV_CHNL_AUDIO, BTIF_AV_SERVICE_NAME, 0, bte_av_media_callback);
}
else {
BTA_AvDeregister(btif_av_cb.bta_handle);
@@ -1006,17 +1223,32 @@
/*******************************************************************************
**
-** Function btif_av_get_interface
+** Function btif_av_get_src_interface
**
-** Description Get the AV callback interface
+** Description Get the AV callback interface for A2DP source profile
**
** Returns btav_interface_t
**
*******************************************************************************/
-const btav_interface_t *btif_av_get_interface(void)
+const btav_interface_t *btif_av_get_src_interface(void)
{
BTIF_TRACE_EVENT1("%s", __FUNCTION__);
- return &bt_av_interface;
+ return &bt_av_src_interface;
+}
+
+/*******************************************************************************
+**
+** Function btif_av_get_sink_interface
+**
+** Description Get the AV callback interface for A2DP sink profile
+**
+** Returns btav_interface_t
+**
+*******************************************************************************/
+const btav_interface_t *btif_av_get_sink_interface(void)
+{
+ BTIF_TRACE_EVENT1("%s", __FUNCTION__);
+ return &bt_av_sink_interface;
}
/*******************************************************************************
diff --git a/btif/src/btif_config.c b/btif/src/btif_config.c
index e7809a7..06035cf 100644
--- a/btif/src/btif_config.c
+++ b/btif/src/btif_config.c
@@ -93,7 +93,6 @@
static void cfg_cmd_callback(int cmd_fd, int type, int flags, uint32_t user_id);
static inline short alloc_node(cfg_node* p, short grow);
static inline void free_node(cfg_node* p);
-static inline void free_inode(cfg_node* p, int child);
static inline short find_inode(const cfg_node* p, const char* name);
static cfg_node* find_node(const char* section, const char* key, const char* name);
static int remove_node(const char* section, const char* key, const char* name);
@@ -104,7 +103,6 @@
static int save_cfg();
static void load_cfg();
static short find_next_node(const cfg_node* p, short start, char* name, int* bytes);
-static int create_dir(const char* path);
#ifdef UNIT_TEST
static void cfg_test_load();
static void cfg_test_write();
diff --git a/btif/src/btif_core.c b/btif/src/btif_core.c
index 77381ef..9b432cd 100644
--- a/btif/src/btif_core.c
+++ b/btif/src/btif_core.c
@@ -608,11 +608,9 @@
/* callback to HAL */
if (status == BTA_SUCCESS)
{
-#if (BLE_INCLUDED == TRUE && BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE)
+#if (BLE_INCLUDED == TRUE )
BTA_BrcmInit();
#endif
- /* initialize a2dp service */
- btif_av_init();
/* init rfcomm & l2cap api */
btif_sock_init();
@@ -1026,7 +1024,32 @@
prop.type = p_req->read_req.type;
prop.val = (void*)buf;
prop.len = sizeof(buf);
- status = btif_storage_get_adapter_property(&prop);
+ if (prop.type == BT_PROPERTY_LOCAL_LE_FEATURES)
+ {
+ #if (BLE_INCLUDED == TRUE)
+ tBTM_BLE_VSC_CB cmn_vsc_cb;
+ bt_local_le_features_t local_le_features;
+
+ /* LE features are not stored in storage. Should be retrived from stack */
+ BTM_BleGetVendorCapabilities(&cmn_vsc_cb);
+ local_le_features.local_privacy_enabled = BTM_BleLocalPrivacyEnabled();
+
+ prop.len = sizeof (bt_local_le_features_t);
+ if (cmn_vsc_cb.filter_support == 1)
+ local_le_features.max_adv_filter_supported = cmn_vsc_cb.max_filter;
+ else
+ local_le_features.max_adv_filter_supported = 0;
+ local_le_features.max_adv_instance = cmn_vsc_cb.adv_inst_max;
+ local_le_features.max_irk_list_size = cmn_vsc_cb.max_irk_list_sz;
+ local_le_features.rpa_offload_supported = cmn_vsc_cb.rpa_offloading;
+ local_le_features.scan_result_storage_size = cmn_vsc_cb.tot_scan_results_strg;
+ memcpy(prop.val, &local_le_features, prop.len);
+ #endif
+ }
+ else
+ {
+ status = btif_storage_get_adapter_property(&prop);
+ }
HAL_CBACK(bt_hal_cbacks, adapter_properties_cb, status, 1, &prop);
} break;
diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c
index 3688bb9..fd96bb9 100644
--- a/btif/src/btif_dm.c
+++ b/btif/src/btif_dm.c
@@ -158,6 +158,7 @@
extern bt_status_t btif_hf_execute_service(BOOLEAN b_enable);
extern bt_status_t btif_av_execute_service(BOOLEAN b_enable);
extern bt_status_t btif_hh_execute_service(BOOLEAN b_enable);
+extern bt_status_t btif_hf_client_execute_service(BOOLEAN b_enable);
extern int btif_hh_connect(bt_bdaddr_t *bd_addr);
extern void bta_gatt_convert_uuid16_to_uuid128(UINT8 uuid_128[LEN_UUID_128], UINT16 uuid_16);
@@ -185,7 +186,10 @@
{
btif_hh_execute_service(b_enable);
}break;
-
+ case BTA_HFP_HS_SERVICE_ID:
+ {
+ btif_hf_client_execute_service(b_enable);
+ }break;
default:
BTIF_TRACE_ERROR1("%s: Unknown service being enabled", __FUNCTION__);
return BT_STATUS_FAIL;
@@ -450,23 +454,6 @@
HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
status, &bdaddr, num_properties, properties);
}
-/*******************************************************************************
-**
-** Function hid_remote_name_cback
-**
-** Description Remote name callback for HID device. Called in stack context
-** Special handling for HID devices
-**
-** Returns void
-**
-*******************************************************************************/
-static void hid_remote_name_cback(void *p_param)
-{
- BTIF_TRACE_DEBUG1("%s", __FUNCTION__);
-
- btif_transfer_context(btif_dm_generic_evt, BTIF_DM_CB_HID_REMOTE_NAME,
- (char *)p_param, sizeof(tBTM_REMOTE_DEV_NAME), NULL);
-}
/*******************************************************************************
**
@@ -567,6 +554,20 @@
/*******************************************************************************
**
+** Function btif_dm_get_connection_state
+**
+** Description Returns whether the remote device is currently connected
+**
+** Returns 0 if not connected
+**
+*******************************************************************************/
+uint16_t btif_dm_get_connection_state(const bt_bdaddr_t *bd_addr)
+{
+ return BTA_DmGetConnectionState((UINT8 *)bd_addr->address);
+}
+
+/*******************************************************************************
+**
** Function search_devices_copy_cb
**
** Description Deep copy callback for search devices event
@@ -1370,6 +1371,12 @@
btif_storage_load_autopair_device_list();
btif_enable_bluetooth_evt(p_data->enable.status, p_data->enable.bd_addr);
+
+ #if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
+ /* Enable local privacy */
+ /*TODO Should this call be exposed to JAVA...? */
+ BTA_DmBleConfigLocalPrivacy(TRUE);
+ #endif
}
break;
@@ -1619,6 +1626,34 @@
BTIF_TRACE_DEBUG0("BTA_DM_BLE_KEY_EVT. ");
btif_dm_ble_auth_cmpl_evt(&p_data->auth_cmpl);
break;
+
+ case BTA_DM_LE_FEATURES_READ:
+ {
+ tBTM_BLE_VSC_CB cmn_vsc_cb;
+ bt_local_le_features_t local_le_features;
+ char buf[512];
+ bt_property_t prop;
+ prop.type = BT_PROPERTY_LOCAL_LE_FEATURES;
+ prop.val = (void*)buf;
+ prop.len = sizeof(buf);
+
+ /* LE features are not stored in storage. Should be retrived from stack */
+ BTM_BleGetVendorCapabilities(&cmn_vsc_cb);
+ local_le_features.local_privacy_enabled = BTM_BleLocalPrivacyEnabled();
+
+ prop.len = sizeof (bt_local_le_features_t);
+ if (cmn_vsc_cb.filter_support == 1)
+ local_le_features.max_adv_filter_supported = cmn_vsc_cb.max_filter;
+ else
+ local_le_features.max_adv_filter_supported = 0;
+ local_le_features.max_adv_instance = cmn_vsc_cb.adv_inst_max;
+ local_le_features.max_irk_list_size = cmn_vsc_cb.max_irk_list_sz;
+ local_le_features.rpa_offload_supported = cmn_vsc_cb.rpa_offloading;
+ local_le_features.scan_result_storage_size = cmn_vsc_cb.tot_scan_results_strg;
+ memcpy(prop.val, &local_le_features, prop.len);
+ HAL_CBACK(bt_hal_cbacks, adapter_properties_cb, BT_STATUS_SUCCESS, 1, &prop);
+ break;
+ }
#endif
case BTA_DM_AUTHORIZE_EVT:
diff --git a/btif/src/btif_gatt_client.c b/btif/src/btif_gatt_client.c
index 3d6d097..9dc151b 100644
--- a/btif/src/btif_gatt_client.c
+++ b/btif/src/btif_gatt_client.c
@@ -38,7 +38,7 @@
#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
-#include "gki.h"
+#include "btif_gatt_multi_adv_util.h"
#include <hardware/bt_gatt.h>
#include "bta_api.h"
#include "bta_gatt_api.h"
@@ -58,14 +58,12 @@
** Constants & Macros
********************************************************************************/
-#define ADV_FLAGS 0x02
-
#define CHECK_BTGATT_INIT() if (bt_gatt_callbacks == NULL)\
{\
- ALOGW("%s: BTGATT not initialized", __FUNCTION__);\
+ BTIF_TRACE_WARNING1("%s: BTGATT not initialized", __FUNCTION__);\
return BT_STATUS_NOT_READY;\
} else {\
- ALOGD("%s", __FUNCTION__);\
+ BTIF_TRACE_DEBUG1("%s", __FUNCTION__);\
}
@@ -97,7 +95,12 @@
BTIF_GATTC_CONFIGURE_MTU,
BTIF_GATTC_SCAN_FILTER_ENABLE,
BTIF_GATTC_SCAN_FILTER_CONFIG,
- BTIF_GATTC_SCAN_FILTER_CLEAR
+ BTIF_GATTC_SCAN_FILTER_CLEAR,
+ BTIF_GATTC_SET_SCAN_PARAMS,
+ BTIF_GATTC_ADV_INSTANCE_ENABLE,
+ BTIF_GATTC_ADV_INSTANCE_UPDATE,
+ BTIF_GATTC_ADV_INSTANCE_SET_DATA,
+ BTIF_GATTC_ADV_INSTANCE_DISABLE
} btif_gattc_event_t;
#define BTIF_GATT_MAX_OBSERVED_DEV 40
@@ -112,14 +115,8 @@
typedef struct
{
- tBTA_BLE_AD_MASK mask;
- tBTA_BLE_ADV_DATA data;
-} btgatt_adv_data;
-
-typedef struct
-{
uint8_t value[BTGATT_MAX_ATTR_LEN];
- btgatt_adv_data adv_data;
+ uint8_t inst_id;
bt_bdaddr_t bd_addr;
btgatt_srvc_id_t srvc_id;
btgatt_srvc_id_t incl_srvc_id;
@@ -130,6 +127,8 @@
uint16_t conn_id;
uint16_t len;
uint16_t mask;
+ uint16_t scan_interval;
+ uint16_t scan_window;
uint8_t client_if;
uint8_t action;
uint8_t is_direct;
@@ -255,7 +254,6 @@
{
memset(p_dev_cb, 0, sizeof(btif_gattc_dev_cb_t));
}
-
static void btif_gattc_add_remote_bdaddr (BD_ADDR p_bda, uint8_t addr_type)
{
BOOLEAN found=FALSE;
@@ -267,7 +265,7 @@
memcpy(p_dev_cb->remote_dev[i].bd_addr.address, p_bda, BD_ADDR_LEN);
p_dev_cb->addr_type = addr_type;
p_dev_cb->remote_dev[i].in_use = TRUE;
- ALOGD("%s device added idx=%d", __FUNCTION__, i );
+ BTIF_TRACE_DEBUG2("%s device added idx=%d", __FUNCTION__, i );
break;
}
}
@@ -278,7 +276,7 @@
memcpy(p_dev_cb->remote_dev[i].bd_addr.address, p_bda, BD_ADDR_LEN);
p_dev_cb->addr_type = addr_type;
p_dev_cb->remote_dev[i].in_use = TRUE;
- ALOGD("%s device overwrite idx=%d", __FUNCTION__, i );
+ BTIF_TRACE_DEBUG2("%s device overwrite idx=%d", __FUNCTION__, i );
p_dev_cb->next_storage_idx++;
if(p_dev_cb->next_storage_idx >= BTIF_GATT_MAX_OBSERVED_DEV)
p_dev_cb->next_storage_idx = 0;
@@ -316,10 +314,10 @@
if(p_eir_remote_name)
{
- memcpy(bdname.name, p_eir_remote_name, remote_name_len);
- bdname.name[remote_name_len]='\0';
+ memcpy(bdname.name, p_eir_remote_name, remote_name_len);
+ bdname.name[remote_name_len]='\0';
- ALOGD("%s BLE device name=%s len=%d dev_type=%d", __FUNCTION__, bdname.name,
+ BTIF_TRACE_DEBUG4("%s BLE device name=%s len=%d dev_type=%d", __FUNCTION__, bdname.name,
remote_name_len, p_btif_cb->device_type );
btif_dm_update_ble_remote_properties( p_btif_cb->bd_addr.address, bdname.name,
p_btif_cb->device_type);
@@ -330,7 +328,7 @@
static void btif_gattc_upstreams_evt(uint16_t event, char* p_param)
{
- ALOGD("%s: Event %d", __FUNCTION__, event);
+ BTIF_TRACE_EVENT2("%s: Event %d", __FUNCTION__, event);
tBTA_GATTC *p_data = (tBTA_GATTC*)p_param;
switch (event)
@@ -472,7 +470,7 @@
}
case BTA_GATTC_ACL_EVT:
- ALOGD("BTA_GATTC_ACL_EVT: status = %d", p_data->status);
+ BTIF_TRACE_EVENT1("BTA_GATTC_ACL_EVT: status = %d", p_data->status);
/* Ignore for now */
break;
@@ -551,6 +549,7 @@
, p_data->cfg_mtu.status , p_data->cfg_mtu.mtu);
break;
}
+
case BTIF_GATTC_SCAN_FILTER_EVT:
{
btif_gattc_cb_t *p_btif_cb = (btif_gattc_cb_t*)p_param;
@@ -559,8 +558,66 @@
break;
}
+ case BTA_GATTC_MULT_ADV_ENB_EVT:
+ {
+ btif_gattc_cb_t *p_btif_cb = (btif_gattc_cb_t*)p_param;
+ btif_multi_adv_add_instid_map(p_btif_cb->client_if,
+ p_btif_cb->inst_id,false);
+ HAL_CBACK(bt_gatt_callbacks, client->multi_adv_enable_cb
+ , p_btif_cb->client_if
+ , p_btif_cb->status
+ );
+ break;
+ }
+
+ case BTA_GATTC_MULT_ADV_UPD_EVT:
+ {
+ btif_gattc_cb_t *p_btif_cb = (btif_gattc_cb_t*)p_param;
+ HAL_CBACK(bt_gatt_callbacks, client->multi_adv_update_cb
+ , p_btif_cb->client_if
+ , p_btif_cb->status
+ );
+ break;
+ }
+
+ case BTA_GATTC_MULT_ADV_DATA_EVT:
+ {
+ btif_gattc_cb_t *p_btif_cb = (btif_gattc_cb_t*)p_param;
+ btif_gattc_cleanup_inst_cb(p_btif_cb->inst_id);
+ HAL_CBACK(bt_gatt_callbacks, client->multi_adv_data_cb
+ , p_btif_cb->client_if
+ , p_btif_cb->status
+ );
+ break;
+ }
+
+ case BTA_GATTC_MULT_ADV_DIS_EVT:
+ {
+ btif_gattc_cb_t *p_btif_cb = (btif_gattc_cb_t*)p_param;
+ btif_gattc_clear_clientif(p_btif_cb->client_if);
+ HAL_CBACK(bt_gatt_callbacks, client->multi_adv_disable_cb
+ , p_btif_cb->client_if
+ , p_btif_cb->status
+ );
+ break;
+ }
+
+ case BTA_GATTC_ADV_DATA_EVT:
+ {
+ btif_gattc_cleanup_inst_cb(STD_ADV_INSTID);
+ /* No HAL callback available */
+ break;
+ }
+
+ case BTA_GATTC_CONGEST_EVT:
+ HAL_CBACK(bt_gatt_callbacks, client->congestion_cb
+ , p_data->congest.conn_id
+ , p_data->congest.congested
+ );
+ break;
+
default:
- ALOGE("%s: Unhandled event (%d)!", __FUNCTION__, event);
+ BTIF_TRACE_ERROR2("%s: Unhandled event (%d)!", __FUNCTION__, event);
break;
}
@@ -574,6 +631,66 @@
ASSERTC(status == BT_STATUS_SUCCESS, "Context transfer failed!", status);
}
+static void bta_gattc_multi_adv_cback(tBTA_BLE_MULTI_ADV_EVT event, UINT8 inst_id,
+ void *p_ref, tBTA_STATUS call_status)
+{
+ btif_gattc_cb_t btif_cb;
+ tBTA_GATTC_EVT upevt;
+ uint8_t client_if = 0;
+
+ if(NULL == p_ref)
+ {
+ BTIF_TRACE_ERROR1("%s Invalid p_ref received",__FUNCTION__);
+ return;
+ }
+
+ client_if = *(UINT8 *)p_ref;
+ BTIF_TRACE_DEBUG4("%s -Inst ID %d, Status:%x, client_if:%d",__FUNCTION__,inst_id, call_status,
+ client_if);
+
+ btif_cb.status = call_status;
+ btif_cb.client_if = client_if;
+ btif_cb.inst_id = inst_id;
+
+ switch(event)
+ {
+ case BTA_BLE_MULTI_ADV_ENB_EVT:
+ {
+ upevt = BTA_GATTC_MULT_ADV_ENB_EVT;
+ break;
+ }
+
+ case BTA_BLE_MULTI_ADV_DISABLE_EVT:
+ upevt = BTA_GATTC_MULT_ADV_DIS_EVT;
+ break;
+
+ case BTA_BLE_MULTI_ADV_PARAM_EVT:
+ upevt = BTA_GATTC_MULT_ADV_UPD_EVT;
+ break;
+
+ case BTA_BLE_MULTI_ADV_DATA_EVT:
+ upevt = BTA_GATTC_MULT_ADV_DATA_EVT;
+ break;
+
+ default:
+ return;
+ }
+
+ bt_status_t status = btif_transfer_context(btif_gattc_upstreams_evt, (uint16_t) upevt,
+ (char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL);
+ ASSERTC(status == BT_STATUS_SUCCESS, "Context transfer failed!", status);
+}
+
+static void bta_gattc_set_adv_data_cback(tBTA_STATUS call_status)
+{
+ UNUSED(call_status);
+ btif_gattc_cb_t btif_cb;
+ btif_cb.status = call_status;
+ btif_cb.action = 0;
+ btif_transfer_context(btif_gattc_upstreams_evt, BTA_GATTC_ADV_DATA_EVT,
+ (char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL);
+}
+
static void bta_scan_results_cb (tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data)
{
btif_gattc_cb_t btif_cb;
@@ -651,19 +768,37 @@
tBTA_GATTC_INCL_SVC_ID out_incl_svc_id;
tBTA_GATT_UNFMT descr_val;
- btif_gattc_cb_t* p_cb = (btif_gattc_cb_t*)p_param;
- if (!p_cb) return;
+ btif_gattc_cb_t* p_cb = NULL;
+ btif_adv_data_t *p_adv_data = NULL;
+ btgatt_multi_adv_inst_cb *p_inst_cb = NULL;
- ALOGD("%s: Event %d", __FUNCTION__, event);
+ if(BTIF_GATTC_ADV_INSTANCE_ENABLE == event || BTIF_GATTC_ADV_INSTANCE_DISABLE == event ||
+ BTIF_GATTC_ADV_INSTANCE_UPDATE == event)
+ {
+ p_inst_cb = (btgatt_multi_adv_inst_cb*)p_param;
+ }
+ else
+ {
+ if(BTIF_GATTC_ADV_INSTANCE_SET_DATA == event || BTIF_GATTC_SET_ADV_DATA == event)
+ p_adv_data = (btif_adv_data_t*)p_param;
+ else
+ p_cb = (btif_gattc_cb_t*)p_param;
+ }
+
+ if (!p_cb && !p_adv_data && !p_inst_cb) return;
+
+ BTIF_TRACE_EVENT2("%s: Event %d", __FUNCTION__, event);
switch (event)
{
case BTIF_GATTC_REGISTER_APP:
btif_to_bta_uuid(&uuid, &p_cb->uuid);
+ btif_gattc_init_multi_adv_cb();
BTA_GATTC_AppRegister(&uuid, bta_gattc_cback);
break;
case BTIF_GATTC_UNREGISTER_APP:
+ btif_gattc_destroy_multi_adv_cb();
BTA_GATTC_AppDeregister(p_cb->client_if);
break;
@@ -1000,7 +1135,7 @@
}
default:
- ALOGE("%s: Unknown filter type (%d)!", __FUNCTION__, p_cb->action);
+ BTIF_TRACE_ERROR2("%s: Unknown filter type (%d)!", __FUNCTION__, p_cb->action);
break;
}
break;
@@ -1023,45 +1158,116 @@
case BTIF_GATTC_SET_ADV_DATA:
{
- if (p_cb->start == 0)
- BTA_DmBleSetAdvConfig(p_cb->adv_data.mask, &p_cb->adv_data.data);
- else
- BTA_DmBleSetScanRsp(p_cb->adv_data.mask, &p_cb->adv_data.data);
-
- // Cleanup ...
-
- // ... manufacturer data
- if (p_cb->adv_data.data.manu.p_val != NULL)
- GKI_freebuf(p_cb->adv_data.data.manu.p_val);
-
- // ... service data
- if (p_cb->adv_data.data.p_proprietary != NULL)
+ int cbindex = CLNT_IF_IDX;
+ if(cbindex >= 0 && NULL != p_adv_data)
{
- int i = 0;
- tBTA_BLE_PROP_ELEM *p_elem = p_cb->adv_data.data.p_proprietary->p_elem;
- while (i++ != p_cb->adv_data.data.p_proprietary->num_elem && p_elem)
+ btgatt_multi_adv_common_data *p_multi_adv_data_cb = btif_obtain_multi_adv_data_cb();
+ if(!btif_gattc_copy_datacb(cbindex, p_adv_data, false))
+ return;
+
+ if (!p_adv_data->set_scan_rsp)
{
- if (p_elem->p_val != NULL)
- GKI_freebuf(p_elem->p_val);
- ++p_elem;
+ BTA_DmBleSetAdvConfig(p_multi_adv_data_cb->inst_cb[cbindex].mask,
+ &p_multi_adv_data_cb->inst_cb[cbindex].data, bta_gattc_set_adv_data_cback);
}
- if (p_cb->adv_data.data.p_proprietary->p_elem != NULL)
- GKI_freebuf(p_cb->adv_data.data.p_proprietary->p_elem);
- GKI_freebuf(p_cb->adv_data.data.p_proprietary);
+ else
+ {
+ BTA_DmBleSetScanRsp(p_multi_adv_data_cb->inst_cb[cbindex].mask,
+ &p_multi_adv_data_cb->inst_cb[cbindex].data, bta_gattc_set_adv_data_cback);
+ }
+ break;
}
+ }
- // ... service list
- if (p_cb->adv_data.data.services.p_uuid != NULL)
- GKI_freebuf(p_cb->adv_data.data.services.p_uuid);
+ case BTIF_GATTC_ADV_INSTANCE_ENABLE:
+ {
+ if(NULL == p_inst_cb)
+ return;
+ int arrindex = btif_multi_adv_add_instid_map(p_inst_cb->client_if,INVALID_ADV_INST,
+ true);
+ int cbindex = btif_gattc_obtain_idx_for_datacb(p_inst_cb->client_if, CLNT_IF_IDX);
+ if(cbindex >= 0 && arrindex >= 0)
+ {
+ btgatt_multi_adv_common_data *p_multi_adv_data_cb = btif_obtain_multi_adv_data_cb();
+ memcpy(&p_multi_adv_data_cb->inst_cb[cbindex].param,
+ &p_inst_cb->param, sizeof(tBTA_BLE_ADV_PARAMS));
+
+ BTA_BleEnableAdvInstance(&(p_multi_adv_data_cb->inst_cb[cbindex].param),
+ bta_gattc_multi_adv_cback,
+ &(p_multi_adv_data_cb->clntif_map[arrindex][CLNT_IF_IDX]));
+ }
+ else
+ BTIF_TRACE_ERROR1("%s invalid index in BTIF_GATTC_ENABLE_ADV",__FUNCTION__);
break;
}
+
+ case BTIF_GATTC_ADV_INSTANCE_UPDATE:
+ {
+ if(NULL == p_inst_cb)
+ return;
+
+ int inst_id = btif_multi_adv_instid_for_clientif(p_inst_cb->client_if);
+ int cbindex = btif_gattc_obtain_idx_for_datacb(p_inst_cb->client_if, CLNT_IF_IDX);
+ if(inst_id >= 0 && cbindex >= 0 && NULL != p_inst_cb)
+ {
+ btgatt_multi_adv_common_data *p_multi_adv_data_cb = btif_obtain_multi_adv_data_cb();
+ memcpy(&p_multi_adv_data_cb->inst_cb[cbindex].param, &p_inst_cb->param,
+ sizeof(tBTA_BLE_ADV_PARAMS));
+ BTA_BleUpdateAdvInstParam((UINT8)inst_id,
+ &(p_multi_adv_data_cb->inst_cb[cbindex].param));
+ }
+ else
+ BTIF_TRACE_ERROR1("%s invalid index in BTIF_GATTC_UPDATE_ADV", __FUNCTION__);
+ break;
+ }
+
+ case BTIF_GATTC_ADV_INSTANCE_SET_DATA:
+ {
+ if(NULL == p_adv_data)
+ return;
+
+ int cbindex = btif_gattc_obtain_idx_for_datacb(p_adv_data->client_if, CLNT_IF_IDX);
+ int inst_id = btif_multi_adv_instid_for_clientif(p_adv_data->client_if);
+ if(inst_id < 0 || cbindex < 0)
+ {
+ BTIF_TRACE_ERROR1("%s invalid index in BTIF_GATTC_SETADV_INST_DATA", __FUNCTION__);
+ return;
+ }
+
+ if(!btif_gattc_copy_datacb(cbindex, p_adv_data, true))
+ return;
+
+ btgatt_multi_adv_common_data *p_multi_adv_data_cb = btif_obtain_multi_adv_data_cb();
+ BTA_BleCfgAdvInstData((UINT8)inst_id, p_multi_adv_data_cb->inst_cb[cbindex].is_scan_rsp,
+ p_multi_adv_data_cb->inst_cb[cbindex].mask,
+ &p_multi_adv_data_cb->inst_cb[cbindex].data);
+ break;
+ }
+
+ case BTIF_GATTC_ADV_INSTANCE_DISABLE:
+ {
+ if(NULL == p_inst_cb)
+ return;
+
+ int inst_id = btif_multi_adv_instid_for_clientif(p_inst_cb->client_if);
+ if(inst_id >=0)
+ BTA_BleDisableAdvInstance((UINT8)inst_id);
+ else
+ BTIF_TRACE_ERROR1("%s invalid instance ID in BTIF_GATTC_DISABLE_ADV",__FUNCTION__);
+ break;
+ }
+
case BTIF_GATTC_CONFIGURE_MTU:
BTA_GATTC_ConfigureMTU(p_cb->conn_id, p_cb->len);
break;
+ case BTIF_GATTC_SET_SCAN_PARAMS:
+ BTM_BleSetScanParams(p_cb->scan_interval, p_cb->scan_window, BTM_BLE_SCAN_MODE_ACTI);
+ break;
+
default:
- ALOGE("%s: Unknown event (%d)!", __FUNCTION__, event);
+ BTIF_TRACE_ERROR2("%s: Unknown event (%d)!", __FUNCTION__, event);
break;
}
}
@@ -1088,11 +1294,10 @@
(char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL);
}
-static bt_status_t btif_gattc_scan( int client_if, bool start )
+static bt_status_t btif_gattc_scan( bool start )
{
CHECK_BTGATT_INIT();
btif_gattc_cb_t btif_cb;
- btif_cb.client_if = (uint8_t) client_if;
return btif_transfer_context(btgattc_handle_event, start ? BTIF_GATTC_SCAN_START : BTIF_GATTC_SCAN_STOP,
(char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL);
}
@@ -1138,161 +1343,28 @@
uint16_t service_uuid_len, char* service_uuid)
{
CHECK_BTGATT_INIT();
- btif_gattc_cb_t btif_cb;
- memset(&btif_cb, 0, sizeof(btif_gattc_cb_t));
- memset(&btif_cb.adv_data, 0, sizeof(btgatt_adv_data));
+ bt_status_t status =0;
- btif_cb.client_if = (uint8_t) client_if;
- btif_cb.start = set_scan_rsp ? 1 : 0;
+ btif_adv_data_t adv_data;
- if (!set_scan_rsp)
- {
- btif_cb.adv_data.mask = BTM_BLE_AD_BIT_FLAGS;
- btif_cb.adv_data.data.flag = ADV_FLAGS;
- }
+ btif_gattc_adv_data_packager(client_if, set_scan_rsp, include_name,
+ include_txpower, min_interval, max_interval, appearance, manufacturer_len,
+ manufacturer_data, service_data_len, service_data, service_uuid_len, service_uuid,
+ &adv_data);
- if (include_name)
- btif_cb.adv_data.mask |= BTM_BLE_AD_BIT_DEV_NAME;
+ status = btif_transfer_context(btgattc_handle_event, BTIF_GATTC_SET_ADV_DATA,
+ (char*) &adv_data, sizeof(btif_adv_data_t), NULL);
- if (include_txpower)
- btif_cb.adv_data.mask |= BTM_BLE_AD_BIT_TX_PWR;
+ if (NULL != adv_data.p_service_data)
+ GKI_freebuf(adv_data.p_service_data);
- if (min_interval > 0 && max_interval > 0 && max_interval > min_interval)
- {
- btif_cb.adv_data.mask |= BTM_BLE_AD_BIT_INT_RANGE;
- btif_cb.adv_data.data.int_range.low = min_interval;
- btif_cb.adv_data.data.int_range.hi = max_interval;
- }
+ if (NULL != adv_data.p_service_uuid)
+ GKI_freebuf(adv_data.p_service_uuid);
- if (appearance != 0)
- {
- btif_cb.adv_data.mask |= BTM_BLE_AD_BIT_APPEARANCE;
- btif_cb.adv_data.data.appearance = appearance;
- }
+ if (NULL != adv_data.p_manufacturer_data)
+ GKI_freebuf(adv_data.p_manufacturer_data);
- if (manufacturer_len > 0 && manufacturer_data != NULL)
- {
- btif_cb.adv_data.data.manu.p_val = GKI_getbuf(manufacturer_len);
- if (btif_cb.adv_data.data.manu.p_val != NULL)
- {
- btif_cb.adv_data.mask |= BTM_BLE_AD_BIT_MANU;
- btif_cb.adv_data.data.manu.len = manufacturer_len;
- memcpy(btif_cb.adv_data.data.manu.p_val, manufacturer_data, manufacturer_len);
- }
- }
-
- tBTA_BLE_PROP_ELEM *p_elem_service_data = NULL;
- tBTA_BLE_PROP_ELEM *p_elem_service_128 = NULL;
-
- if (service_data_len > 0 && service_data != NULL)
- {
- p_elem_service_data = GKI_getbuf(sizeof(tBTA_BLE_PROP_ELEM));
- if (p_elem_service_data != NULL)
- {
- p_elem_service_data->p_val = GKI_getbuf(service_data_len);
- if (p_elem_service_data->p_val != NULL)
- {
- p_elem_service_data->adv_type = BTM_BLE_AD_TYPE_SERVICE_DATA;
- p_elem_service_data->len = service_data_len;
- memcpy(p_elem_service_data->p_val, service_data, service_data_len);
-
- } else {
- GKI_freebuf(p_elem_service_data);
- p_elem_service_data = NULL;
- }
- }
- }
-
- if (service_uuid_len > 0 && service_uuid != NULL)
- {
- btif_cb.adv_data.data.services.list_cmpl = FALSE;
- btif_cb.adv_data.data.services.num_service = 0;
-
- btif_cb.adv_data.data.services.p_uuid =
- GKI_getbuf(service_uuid_len / LEN_UUID_128 * LEN_UUID_16);
- if (btif_cb.adv_data.data.services.p_uuid != NULL)
- {
- UINT16 *p_uuid_out = btif_cb.adv_data.data.services.p_uuid;
- while (service_uuid_len >= LEN_UUID_128)
- {
- bt_uuid_t uuid;
- memset(&uuid, 0, sizeof(bt_uuid_t));
- memcpy(&uuid.uu, service_uuid, LEN_UUID_128);
-
- tBT_UUID bt_uuid;
- memset(&bt_uuid, 0, sizeof(tBT_UUID));
- btif_to_bta_uuid(&bt_uuid, &uuid);
-
- if (bt_uuid.len == LEN_UUID_16)
- {
- btif_cb.adv_data.mask |= BTM_BLE_AD_BIT_SERVICE;
- ++btif_cb.adv_data.data.services.num_service;
- *p_uuid_out++ = bt_uuid.uu.uuid16;
-
- } else if (bt_uuid.len == LEN_UUID_128 && p_elem_service_128 == NULL) {
- /* Currently, only one 128-bit UUID is supported */
- p_elem_service_128 = GKI_getbuf(sizeof(tBTA_BLE_PROP_ELEM));
- if (p_elem_service_128 != NULL)
- {
- p_elem_service_128->p_val = GKI_getbuf(LEN_UUID_128);
- if (p_elem_service_128->p_val != NULL)
- {
- p_elem_service_128->adv_type = BTM_BLE_AD_TYPE_128SRV_PART;
- p_elem_service_128->len = LEN_UUID_128;
- memcpy(p_elem_service_128->p_val, bt_uuid.uu.uuid128, LEN_UUID_128);
-
- } else {
- GKI_freebuf(p_elem_service_128);
- p_elem_service_128 = NULL;
- }
- }
- }
-
- service_uuid += LEN_UUID_128;
- service_uuid_len -= LEN_UUID_128;
- }
- }
- }
-
- if (p_elem_service_data != NULL || p_elem_service_128 != NULL)
- {
- btif_cb.adv_data.data.p_proprietary = GKI_getbuf(sizeof(tBTA_BLE_PROPRIETARY));
- if (btif_cb.adv_data.data.p_proprietary != NULL)
- {
- tBTA_BLE_PROPRIETARY *p_prop = btif_cb.adv_data.data.p_proprietary;
- tBTA_BLE_PROP_ELEM *p_elem = NULL;
- p_prop->num_elem = 0;
- btif_cb.adv_data.mask |= BTM_BLE_AD_BIT_PROPRIETARY;
-
- if (p_elem_service_128 != NULL)
- ++p_prop->num_elem;
-
- if (p_elem_service_data != NULL)
- ++p_prop->num_elem;
-
- p_prop->p_elem = GKI_getbuf(sizeof(tBTA_BLE_PROP_ELEM) * p_prop->num_elem);
- p_elem = p_prop->p_elem;
-
- if (p_elem_service_128 != NULL)
- {
- memcpy(p_elem++, p_elem_service_128, sizeof(tBTA_BLE_PROP_ELEM));
- GKI_freebuf(p_elem_service_128);
- }
-
- if (p_elem_service_data != NULL)
- {
- memcpy(p_elem++, p_elem_service_data, sizeof(tBTA_BLE_PROP_ELEM));
- GKI_freebuf(p_elem_service_data);
- }
- }
- }
-
-#if (defined(BLE_PERIPHERAL_ADV_NAME) && (BLE_PERIPHERAL_ADV_NAME == TRUE))
- btif_cb.adv_data.mask |= BTM_BLE_AD_BIT_DEV_NAME;
-#endif
-
- return btif_transfer_context(btgattc_handle_event, BTIF_GATTC_SET_ADV_DATA,
- (char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL);
+ return status;
}
static bt_status_t btif_gattc_refresh( int client_if, const bt_bdaddr_t *bd_addr )
@@ -1541,6 +1613,16 @@
(char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL);
}
+static bt_status_t btif_gattc_set_scan_parameters(int scan_interval, int scan_window)
+{
+ CHECK_BTGATT_INIT();
+ btif_gattc_cb_t btif_cb;
+ btif_cb.scan_interval = scan_interval;
+ btif_cb.scan_window = scan_window;
+ return btif_transfer_context(btgattc_handle_event, BTIF_GATTC_SET_SCAN_PARAMS,
+ (char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL);
+}
+
static int btif_gattc_get_device_type( const bt_bdaddr_t *bd_addr )
{
int device_type = 0;
@@ -1552,6 +1634,84 @@
return 0;
}
+static bt_status_t btif_gattc_multi_adv_enable(int client_if, int min_interval, int max_interval,
+ int adv_type, int chnl_map, int tx_power)
+{
+ CHECK_BTGATT_INIT();
+ btgatt_multi_adv_inst_cb adv_cb;
+ adv_cb.client_if = (uint8_t) client_if;
+
+ adv_cb.param.adv_int_min = min_interval;
+ adv_cb.param.adv_int_max = max_interval;
+ adv_cb.param.adv_type = adv_type;
+ adv_cb.param.channel_map = chnl_map;
+ adv_cb.param.adv_filter_policy = 0;
+ adv_cb.param.tx_power = tx_power;
+ return btif_transfer_context(btgattc_handle_event, BTIF_GATTC_ADV_INSTANCE_ENABLE,
+ (char*) &adv_cb, sizeof(btgatt_multi_adv_inst_cb), NULL);
+}
+
+static bt_status_t btif_gattc_multi_adv_update(int client_if, int min_interval, int max_interval,
+ int adv_type, int chnl_map,int tx_power)
+{
+ CHECK_BTGATT_INIT();
+ btgatt_multi_adv_inst_cb adv_cb;
+ adv_cb.client_if = (uint8_t) client_if;
+
+ adv_cb.param.adv_int_min = min_interval;
+ adv_cb.param.adv_int_max = max_interval;
+ adv_cb.param.adv_type = adv_type;
+ adv_cb.param.channel_map = chnl_map;
+ adv_cb.param.adv_filter_policy = 0;
+ adv_cb.param.tx_power = tx_power;
+ return btif_transfer_context(btgattc_handle_event, BTIF_GATTC_ADV_INSTANCE_UPDATE,
+ (char*) &adv_cb, sizeof(btgatt_multi_adv_inst_cb), NULL);
+}
+
+static bt_status_t btif_gattc_multi_adv_setdata(int client_if, bool set_scan_rsp,
+ bool include_name, bool incl_txpower,
+ int appearance, uint16_t manufacturer_len,
+ char* manufacturer_data,
+ uint16_t service_data_len,
+ char* service_data, uint16_t service_uuid_len,
+ char* service_uuid)
+{
+ CHECK_BTGATT_INIT();
+
+ int min_interval = 0, max_interval = 0;
+ bt_status_t status =0;
+
+ btif_adv_data_t multi_adv_data_inst;
+
+ btif_gattc_adv_data_packager(client_if, set_scan_rsp, include_name, incl_txpower,
+ min_interval, max_interval, appearance, manufacturer_len, manufacturer_data,
+ service_data_len, service_data, service_uuid_len, service_uuid, &multi_adv_data_inst);
+
+ status = btif_transfer_context(btgattc_handle_event, BTIF_GATTC_ADV_INSTANCE_SET_DATA,
+ (char*) &multi_adv_data_inst, sizeof(btif_adv_data_t), NULL);
+
+ if (NULL != multi_adv_data_inst.p_service_data)
+ GKI_freebuf(multi_adv_data_inst.p_service_data);
+
+ if (NULL != multi_adv_data_inst.p_service_uuid)
+ GKI_freebuf(multi_adv_data_inst.p_service_uuid);
+
+ if (NULL != multi_adv_data_inst.p_manufacturer_data)
+ GKI_freebuf(multi_adv_data_inst.p_manufacturer_data);
+
+ return status;
+}
+
+static bt_status_t btif_gattc_multi_adv_disable(int client_if)
+{
+ CHECK_BTGATT_INIT();
+ btgatt_multi_adv_inst_cb adv_cb;
+ adv_cb.client_if = (uint8_t) client_if;
+
+ return btif_transfer_context(btgattc_handle_event, BTIF_GATTC_ADV_INSTANCE_DISABLE,
+ (char*) &adv_cb, sizeof(btgatt_multi_adv_inst_cb), NULL);
+}
+
extern bt_status_t btif_gattc_test_command_impl(int command, btgatt_test_params_t* params);
static bt_status_t btif_gattc_test_command(int command, btgatt_test_params_t* params)
@@ -1586,6 +1746,11 @@
btif_gattc_get_device_type,
btif_gattc_set_adv_data,
btif_gattc_configure_mtu,
+ btif_gattc_set_scan_parameters,
+ btif_gattc_multi_adv_enable,
+ btif_gattc_multi_adv_update,
+ btif_gattc_multi_adv_setdata,
+ btif_gattc_multi_adv_disable,
btif_gattc_test_command
};
diff --git a/btif/src/btif_gatt_multi_adv_util.c b/btif/src/btif_gatt_multi_adv_util.c
new file mode 100644
index 0000000..58d067f
--- /dev/null
+++ b/btif/src/btif_gatt_multi_adv_util.c
@@ -0,0 +1,541 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 Broadcom 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.
+ *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ *
+ * Filename: btif_gatt_multi_adv_util.c
+ *
+ * Description: Multi ADV helper implementation
+ *
+ *******************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "bt_target.h"
+
+#define LOG_TAG "BtGatt.btif"
+#if (BLE_INCLUDED == TRUE)
+
+#include "btif_gatt_multi_adv_util.h"
+#include "btif_common.h"
+#include <hardware/bt_gatt.h>
+#include "bta_gatt_api.h"
+#include "btif_gatt_util.h"
+
+/*******************************************************************************
+** Static variables
+********************************************************************************/
+static int multi_adv_enable_count = 0;
+static btgatt_multi_adv_common_data *p_multi_adv_com_data_cb = NULL;
+
+btgatt_multi_adv_common_data *btif_obtain_multi_adv_data_cb()
+{
+ if(p_multi_adv_com_data_cb == NULL)
+ p_multi_adv_com_data_cb = GKI_getbuf(sizeof(btgatt_multi_adv_common_data));
+ return p_multi_adv_com_data_cb;
+}
+
+void btif_gattc_init_multi_adv_cb(void)
+{
+ int i;
+ btgatt_multi_adv_common_data *p_multi_adv_data_cb = btif_obtain_multi_adv_data_cb();
+
+ if(NULL == p_multi_adv_data_cb)
+ return;
+
+ if(multi_adv_enable_count == 0)
+ {
+ memset(p_multi_adv_data_cb,0,sizeof(btgatt_multi_adv_common_data));
+
+ for (i=0; i < BTM_BLE_MULTI_ADV_MAX; i++)
+ {
+ p_multi_adv_data_cb->clntif_map[i][CLNT_IF_IDX] = INVALID_ADV_INST;
+ p_multi_adv_data_cb->clntif_map[i][INST_ID_IDX] = INVALID_ADV_INST;
+ }
+ }
+ multi_adv_enable_count++;
+}
+
+void btif_gattc_destroy_multi_adv_cb()
+{
+ if(multi_adv_enable_count > 0)
+ multi_adv_enable_count --;
+ if(multi_adv_enable_count == 0)
+ {
+ GKI_freebuf(p_multi_adv_com_data_cb);
+ p_multi_adv_com_data_cb = NULL;
+ }
+}
+
+int btif_multi_adv_add_instid_map(int client_if, int inst_id, BOOLEAN gen_temp_instid)
+{
+ int i=0;
+
+ btgatt_multi_adv_common_data *p_multi_adv_data_cb = btif_obtain_multi_adv_data_cb();
+
+ if(NULL == p_multi_adv_data_cb)
+ return INVALID_ADV_INST;
+
+ for(i=0; i < BTM_BLE_MULTI_ADV_MAX; i++)
+ {
+ if(client_if == p_multi_adv_data_cb->clntif_map[i][CLNT_IF_IDX])
+ {
+ if(!gen_temp_instid)
+ {
+ // Write the final inst_id value obtained from stack layer
+ p_multi_adv_data_cb->clntif_map[i][INST_ID_IDX] = inst_id;
+ BTIF_TRACE_DEBUG3("%s -Index: %d, Found client_if: %d", __FUNCTION__,
+ i, p_multi_adv_data_cb->clntif_map[i][CLNT_IF_IDX]);
+ break;
+ }
+ else
+ {
+ //Store the passed in inst_id value
+ if(inst_id != INVALID_ADV_INST)
+ p_multi_adv_data_cb->clntif_map[i][INST_ID_IDX] = inst_id;
+ else
+ p_multi_adv_data_cb->clntif_map[i][INST_ID_IDX] = (i + 1);
+ BTIF_TRACE_DEBUG3("%s - Index:%d,Found client_if: %d", __FUNCTION__,
+ i, p_multi_adv_data_cb->clntif_map[i][CLNT_IF_IDX]);
+ break;
+ }
+ }
+ }
+
+ if(i < BTM_BLE_MULTI_ADV_MAX)
+ return i;
+
+ // If client ID if is not found, then write both values
+ for(i=0; i < BTM_BLE_MULTI_ADV_MAX; i++)
+ {
+ if(INVALID_ADV_INST == p_multi_adv_data_cb->clntif_map[i][CLNT_IF_IDX])
+ {
+ p_multi_adv_data_cb->clntif_map[i][CLNT_IF_IDX] = client_if;
+ if(inst_id != INVALID_ADV_INST)
+ p_multi_adv_data_cb->clntif_map[i][INST_ID_IDX] = inst_id;
+ else
+ p_multi_adv_data_cb->clntif_map[i][INST_ID_IDX] = (i + 1);
+ BTIF_TRACE_DEBUG4("%s -Not found - Index:%d, client_if: %d, Inst ID: %d",
+ __FUNCTION__,i,
+ p_multi_adv_data_cb->clntif_map[i][CLNT_IF_IDX],
+ p_multi_adv_data_cb->clntif_map[i][INST_ID_IDX]);
+ break;
+ }
+ }
+
+ if(i < BTM_BLE_MULTI_ADV_MAX)
+ return i;
+ return INVALID_ADV_INST;
+}
+
+int btif_multi_adv_instid_for_clientif(int client_if)
+{
+ int i=0, ret = INVALID_ADV_INST;
+
+ btgatt_multi_adv_common_data *p_multi_adv_data_cb = btif_obtain_multi_adv_data_cb();
+
+ if(NULL == p_multi_adv_data_cb)
+ return INVALID_ADV_INST;
+
+ // Retrieve the existing inst_id for the client_if value
+ for(i=0; i < BTM_BLE_MULTI_ADV_MAX; i++)
+ {
+ if(client_if == p_multi_adv_data_cb->clntif_map[i][CLNT_IF_IDX])
+ ret = p_multi_adv_data_cb->clntif_map[i][INST_ID_IDX];
+ }
+
+ if(ret != INVALID_ADV_INST)
+ return ret;
+
+ return INVALID_ADV_INST;
+}
+
+
+int btif_gattc_obtain_idx_for_datacb(int value, int arrindex)
+{
+ int i=0;
+
+ btgatt_multi_adv_common_data *p_multi_adv_data_cb = btif_obtain_multi_adv_data_cb();
+
+ if(NULL == p_multi_adv_data_cb)
+ return INVALID_ADV_INST;
+
+ // Retrieve the array index for the inst_id value
+ for(i=0; i < BTM_BLE_MULTI_ADV_MAX; i++)
+ {
+ if(value == p_multi_adv_data_cb->clntif_map[i][arrindex])
+ break;
+ }
+
+ if(i < BTM_BLE_MULTI_ADV_MAX)
+ {
+ BTIF_TRACE_DEBUG2("%s, %d",__FUNCTION__,i+1);
+ return (i + 1);
+ }
+
+ BTIF_TRACE_DEBUG1("%s Invalid instance",__FUNCTION__);
+ return INVALID_ADV_INST;
+}
+
+
+void btif_gattc_adv_data_packager(int client_if, bool set_scan_rsp,
+ bool include_name, bool include_txpower, int min_interval, int max_interval,
+ int appearance, uint16_t manufacturer_len, char* manufacturer_data,
+ uint16_t service_data_len, char* service_data, uint16_t service_uuid_len,
+ char* service_uuid, btif_adv_data_t *p_multi_adv_inst)
+{
+ memset(p_multi_adv_inst, 0 , sizeof(btif_adv_data_t));
+
+ p_multi_adv_inst->client_if = (uint8_t) client_if;
+ p_multi_adv_inst->set_scan_rsp = set_scan_rsp;
+ p_multi_adv_inst->include_name = include_name;
+ p_multi_adv_inst->include_txpower = include_txpower;
+ p_multi_adv_inst->min_interval = min_interval;
+ p_multi_adv_inst->max_interval = max_interval;
+ p_multi_adv_inst->appearance = appearance;
+ p_multi_adv_inst->manufacturer_len = manufacturer_len;
+
+ if(manufacturer_len > 0)
+ {
+ p_multi_adv_inst->p_manufacturer_data = GKI_getbuf(manufacturer_len);
+ memcpy(p_multi_adv_inst->p_manufacturer_data, manufacturer_data, manufacturer_len);
+ }
+
+ p_multi_adv_inst->service_data_len = service_data_len;
+ if(service_data_len > 0)
+ {
+ p_multi_adv_inst->p_service_data = GKI_getbuf(service_data_len);
+ memcpy(p_multi_adv_inst->p_service_data, service_data, service_data_len);
+ }
+
+ p_multi_adv_inst->service_uuid_len = service_uuid_len;
+ if(service_uuid_len > 0)
+ {
+ p_multi_adv_inst->p_service_uuid = GKI_getbuf(service_uuid_len);
+ memcpy(p_multi_adv_inst->p_service_uuid, service_uuid, service_uuid_len);
+ }
+}
+
+BOOLEAN btif_gattc_copy_datacb(int cbindex, btif_adv_data_t *p_adv_data, BOOLEAN bInstData)
+{
+ int i=0;
+ btgatt_multi_adv_common_data *p_multi_adv_data_cb = btif_obtain_multi_adv_data_cb();
+ if(NULL == p_multi_adv_data_cb || cbindex < 0)
+ return false;
+
+ BTIF_TRACE_DEBUG1("%s", __FUNCTION__);
+ memset(&p_multi_adv_data_cb->inst_cb[cbindex],0, sizeof(btgatt_multi_adv_inst_cb));
+ memset(&p_multi_adv_data_cb->inst_cb[cbindex].data, 0, sizeof(tBTA_BLE_ADV_DATA));
+
+ if (!p_adv_data->set_scan_rsp)
+ {
+ p_multi_adv_data_cb->inst_cb[cbindex].is_scan_rsp = p_adv_data->set_scan_rsp ? 1 : 0;
+ p_multi_adv_data_cb->inst_cb[cbindex].mask = BTM_BLE_AD_BIT_FLAGS;
+ p_multi_adv_data_cb->inst_cb[cbindex].data.flag = ADV_FLAGS;
+ }
+
+ if (p_adv_data->include_name)
+ p_multi_adv_data_cb->inst_cb[cbindex].mask |= BTM_BLE_AD_BIT_DEV_NAME;
+
+ if (p_adv_data->include_txpower)
+ p_multi_adv_data_cb->inst_cb[cbindex].mask |= BTM_BLE_AD_BIT_TX_PWR;
+
+ if (false == bInstData && p_adv_data->min_interval > 0 && p_adv_data->max_interval > 0 &&
+ p_adv_data->max_interval > p_adv_data->min_interval)
+ {
+ p_multi_adv_data_cb->inst_cb[cbindex].mask |= BTM_BLE_AD_BIT_INT_RANGE;
+ p_multi_adv_data_cb->inst_cb[cbindex].data.int_range.low =
+ p_adv_data->min_interval;
+ p_multi_adv_data_cb->inst_cb[cbindex].data.int_range.hi =
+ p_adv_data->max_interval;
+ }
+ else
+ if(true == bInstData)
+ {
+ if (p_multi_adv_data_cb->inst_cb[cbindex].param.adv_int_min > 0 &&
+ p_multi_adv_data_cb->inst_cb[cbindex].param.adv_int_max > 0 &&
+ p_multi_adv_data_cb->inst_cb[cbindex].param.adv_int_max >
+ p_multi_adv_data_cb->inst_cb[cbindex].param.adv_int_min)
+ {
+ p_multi_adv_data_cb->inst_cb[cbindex].data.int_range.low =
+ p_multi_adv_data_cb->inst_cb[cbindex].param.adv_int_min;
+ p_multi_adv_data_cb->inst_cb[cbindex].data.int_range.hi =
+ p_multi_adv_data_cb->inst_cb[cbindex].param.adv_int_max;
+ }
+
+ if (p_adv_data->include_txpower)
+ {
+ p_multi_adv_data_cb->inst_cb[cbindex].data.tx_power =
+ p_multi_adv_data_cb->inst_cb[cbindex].param.tx_power;
+ }
+ }
+
+ if (p_adv_data->appearance != 0)
+ {
+ p_multi_adv_data_cb->inst_cb[cbindex].mask |= BTM_BLE_AD_BIT_APPEARANCE;
+ p_multi_adv_data_cb->inst_cb[cbindex].data.appearance = p_adv_data->appearance;
+ }
+
+ if (p_adv_data->manufacturer_len > 0 && p_adv_data->p_manufacturer_data != NULL)
+ {
+ p_multi_adv_data_cb->inst_cb[cbindex].data.p_manu =
+ GKI_getbuf(sizeof(tBTA_BLE_MANU));
+ if(p_multi_adv_data_cb->inst_cb[cbindex].data.p_manu != NULL)
+ {
+ p_multi_adv_data_cb->inst_cb[cbindex].data.p_manu->p_val =
+ GKI_getbuf(p_adv_data->manufacturer_len);
+ if (p_multi_adv_data_cb->inst_cb[cbindex].data.p_manu->p_val != NULL)
+ {
+ p_multi_adv_data_cb->inst_cb[cbindex].mask |= BTM_BLE_AD_BIT_MANU;
+ p_multi_adv_data_cb->inst_cb[cbindex].data.p_manu->len =
+ p_adv_data->manufacturer_len;
+ memcpy(p_multi_adv_data_cb->inst_cb[cbindex].data.p_manu->p_val,
+ p_adv_data->p_manufacturer_data, p_adv_data->manufacturer_len);
+ }
+ }
+ }
+
+ tBTA_BLE_PROP_ELEM *p_elem_service_data = NULL;
+ tBTA_BLE_PROP_ELEM *p_elem_service_128 = NULL;
+
+ if (p_adv_data->service_data_len > 0 && p_adv_data->p_service_data != NULL)
+ {
+ BTIF_TRACE_DEBUG1("%s - In service_data", __FUNCTION__);
+ p_elem_service_data = GKI_getbuf(sizeof(tBTA_BLE_PROP_ELEM));
+ if (p_elem_service_data != NULL)
+ {
+ p_elem_service_data->p_val = GKI_getbuf(p_adv_data->service_data_len);
+ if (p_elem_service_data->p_val != NULL)
+ {
+ p_elem_service_data->adv_type = BTM_BLE_AD_TYPE_SERVICE_DATA;
+ p_elem_service_data->len = p_adv_data->service_data_len;
+ memcpy(p_elem_service_data->p_val, p_adv_data->p_service_data,
+ p_adv_data->service_data_len);
+ } else {
+ GKI_freebuf(p_elem_service_data);
+ p_elem_service_data = NULL;
+ }
+ }
+ }
+
+ if (p_adv_data->service_uuid_len > 0 && p_adv_data->p_service_uuid != NULL)
+ {
+ p_multi_adv_data_cb->inst_cb[cbindex].data.p_services =
+ GKI_getbuf(sizeof(tBTA_BLE_SERVICE));
+ p_multi_adv_data_cb->inst_cb[cbindex].data.p_services->list_cmpl = FALSE;
+ p_multi_adv_data_cb->inst_cb[cbindex].data.p_services->num_service = 0;
+ p_multi_adv_data_cb->inst_cb[cbindex].data.p_services->p_uuid =
+ GKI_getbuf(p_adv_data->service_uuid_len / LEN_UUID_128 * LEN_UUID_16);
+ if (p_multi_adv_data_cb->inst_cb[cbindex].data.p_services->p_uuid != NULL)
+ {
+ UINT16 *p_uuid_out = p_multi_adv_data_cb->inst_cb[cbindex].data.p_services->p_uuid;
+ while (p_adv_data->service_uuid_len >= LEN_UUID_128)
+ {
+ bt_uuid_t uuid;
+ memset(&uuid, 0, sizeof(bt_uuid_t));
+ memcpy(&uuid.uu, p_adv_data->p_service_uuid, LEN_UUID_128);
+ tBT_UUID bt_uuid;
+ memset(&bt_uuid, 0, sizeof(tBT_UUID));
+ btif_to_bta_uuid(&bt_uuid, &uuid);
+
+ if (bt_uuid.len == LEN_UUID_16)
+ {
+ p_multi_adv_data_cb->inst_cb[cbindex].mask |= BTM_BLE_AD_BIT_SERVICE;
+ ++p_multi_adv_data_cb->inst_cb[cbindex].data.p_services->num_service;
+ *p_uuid_out++ = bt_uuid.uu.uuid16;
+ } else if (bt_uuid.len == LEN_UUID_128 && p_elem_service_128 == NULL) {
+ /* Currently, only one 128-bit UUID is supported */
+ p_elem_service_128 = GKI_getbuf(sizeof(tBTA_BLE_PROP_ELEM));
+ if (p_elem_service_128 != NULL)
+ {
+ p_elem_service_128->p_val = GKI_getbuf(LEN_UUID_128);
+ if (p_elem_service_128->p_val != NULL)
+ {
+ p_elem_service_128->adv_type = BTM_BLE_AD_TYPE_128SRV_PART;
+ p_elem_service_128->len = LEN_UUID_128;
+ memcpy(p_elem_service_128->p_val, bt_uuid.uu.uuid128, LEN_UUID_128);
+ } else {
+ GKI_freebuf(p_elem_service_128);
+ p_elem_service_128 = NULL;
+ }
+ }
+ }
+ p_adv_data->p_service_uuid += LEN_UUID_128;
+ p_adv_data->service_uuid_len -= LEN_UUID_128;
+ }
+ }
+ }
+
+ if (p_elem_service_data != NULL || p_elem_service_128 != NULL)
+ {
+ p_multi_adv_data_cb->inst_cb[cbindex].data.p_proprietary =
+ GKI_getbuf(sizeof(tBTA_BLE_PROPRIETARY));
+ if (p_multi_adv_data_cb->inst_cb[cbindex].data.p_proprietary != NULL)
+ {
+ tBTA_BLE_PROPRIETARY *p_prop = p_multi_adv_data_cb->inst_cb[cbindex].
+ data.p_proprietary;
+ tBTA_BLE_PROP_ELEM *p_elem = NULL;
+ p_prop->num_elem = 0;
+ p_multi_adv_data_cb->inst_cb[cbindex].mask |= BTM_BLE_AD_BIT_PROPRIETARY;
+ if (p_elem_service_128 != NULL)
+ ++p_prop->num_elem;
+ if (p_elem_service_data != NULL)
+ ++p_prop->num_elem;
+ p_prop->p_elem = GKI_getbuf(sizeof(tBTA_BLE_PROP_ELEM) * p_prop->num_elem);
+ p_elem = p_prop->p_elem;
+ if (p_elem_service_128 != NULL)
+ {
+ memcpy(p_elem++, p_elem_service_128, sizeof(tBTA_BLE_PROP_ELEM));
+ GKI_freebuf(p_elem_service_128);
+ }
+ if (p_elem_service_data != NULL)
+ {
+ memcpy(p_elem++, p_elem_service_data, sizeof(tBTA_BLE_PROP_ELEM));
+ GKI_freebuf(p_elem_service_data);
+ }
+ }
+ }
+
+#if (defined(BLE_PERIPHERAL_ADV_NAME) && (BLE_PERIPHERAL_ADV_NAME == TRUE))
+ p_multi_adv_data_cb->inst_cb[cbindex].mask |= BTM_BLE_AD_BIT_DEV_NAME;
+#endif
+ return true;
+}
+
+void btif_gattc_clear_clientif(int client_if)
+{
+ int i=0;
+
+ btgatt_multi_adv_common_data *p_multi_adv_data_cb = btif_obtain_multi_adv_data_cb();
+
+ if(NULL == p_multi_adv_data_cb)
+ return;
+
+ // Clear both the inst_id and client_if values
+ for(i=0; i < BTM_BLE_MULTI_ADV_MAX; i++)
+ {
+ if(client_if == p_multi_adv_data_cb->clntif_map[i][CLNT_IF_IDX])
+ {
+ p_multi_adv_data_cb->clntif_map[i][INST_ID_IDX] = INVALID_ADV_INST;
+ p_multi_adv_data_cb->clntif_map[i][CLNT_IF_IDX] = INVALID_ADV_INST;
+ BTIF_TRACE_DEBUG2("Cleaning up index %d for clnt_if :%d,", i, client_if);
+ break;
+ }
+ }
+}
+
+void btif_gattc_cleanup_inst_cb(int inst_id)
+{
+ int cbindex = 0;
+ // Check for invalid instance id
+ if (inst_id < 0 || inst_id > BTM_BLE_MULTI_ADV_MAX)
+ return;
+
+ btgatt_multi_adv_common_data *p_multi_adv_data_cb = btif_obtain_multi_adv_data_cb();
+
+ if(NULL == p_multi_adv_data_cb)
+ return;
+
+ if(inst_id > 0)
+ {
+ cbindex = btif_gattc_obtain_idx_for_datacb(inst_id, INST_ID_IDX);
+ if (cbindex < 0)
+ return;
+ }
+ else
+ if(STD_ADV_INSTID == inst_id)
+ cbindex = STD_ADV_INSTID;
+
+ BTIF_TRACE_DEBUG2("Cleaning up multi_inst_cb for inst_id %d, cbindex %d", inst_id, cbindex);
+ btif_gattc_cleanup_multi_inst_cb(&p_multi_adv_data_cb->inst_cb[cbindex]);
+}
+
+void btif_gattc_cleanup_multi_inst_cb(btgatt_multi_adv_inst_cb *p_multi_inst_cb)
+{
+ // Manufacturer data cleanup
+ if (p_multi_inst_cb->data.p_manu != NULL)
+ {
+ if (p_multi_inst_cb->data.p_manu->p_val != NULL)
+ GKI_freebuf(p_multi_inst_cb->data.p_manu->p_val);
+ GKI_freebuf(p_multi_inst_cb->data.p_manu);
+ }
+
+ // Proprietary data cleanup
+ if (p_multi_inst_cb->data.p_proprietary != NULL)
+ {
+ int i = 0;
+ tBTA_BLE_PROP_ELEM *p_elem = p_multi_inst_cb->data.p_proprietary->p_elem;
+ while (i++ != p_multi_inst_cb->data.p_proprietary->num_elem
+ && p_elem)
+ {
+ if (p_elem->p_val != NULL)
+ GKI_freebuf(p_elem->p_val);
+ ++p_elem;
+ }
+
+ if (p_multi_inst_cb->data.p_proprietary->p_elem != NULL)
+ GKI_freebuf(p_multi_inst_cb->data.p_proprietary->p_elem);
+ GKI_freebuf(p_multi_inst_cb->data.p_proprietary);
+ }
+
+ // Service list cleanup
+ if (p_multi_inst_cb->data.p_services != NULL)
+ {
+ if (p_multi_inst_cb->data.p_services->p_uuid != NULL)
+ GKI_freebuf(p_multi_inst_cb->data.p_services->p_uuid);
+ GKI_freebuf(p_multi_inst_cb->data.p_services);
+ }
+
+ // Service data cleanup
+ if (p_multi_inst_cb->data.p_service_data != NULL)
+ {
+ if (p_multi_inst_cb->data.p_service_data->p_val != NULL)
+ GKI_freebuf(p_multi_inst_cb->data.p_service_data->p_val);
+ GKI_freebuf(p_multi_inst_cb->data.p_service_data);
+ }
+
+ if (p_multi_inst_cb->data.p_services_128b != NULL)
+ GKI_freebuf(p_multi_inst_cb->data.p_services_128b);
+
+ if (p_multi_inst_cb->data.p_service_32b != NULL)
+ {
+ if (p_multi_inst_cb->data.p_service_32b->p_uuid != NULL)
+ GKI_freebuf(p_multi_inst_cb->data.p_service_32b->p_uuid);
+ GKI_freebuf(p_multi_inst_cb->data.p_service_32b);
+ }
+
+ if (p_multi_inst_cb->data.p_sol_services != NULL)
+ {
+ if (p_multi_inst_cb->data.p_sol_services->p_uuid != NULL)
+ GKI_freebuf(p_multi_inst_cb->data.p_sol_services->p_uuid);
+ GKI_freebuf(p_multi_inst_cb->data.p_sol_services);
+ }
+
+ if (p_multi_inst_cb->data.p_sol_service_32b != NULL)
+ {
+ if (p_multi_inst_cb->data.p_sol_service_32b->p_uuid != NULL)
+ GKI_freebuf(p_multi_inst_cb->data.p_sol_service_32b->p_uuid);
+ GKI_freebuf(p_multi_inst_cb->data.p_sol_service_32b);
+ }
+
+ if(p_multi_inst_cb->data.p_sol_service_128b != NULL)
+ GKI_freebuf(p_multi_inst_cb->data.p_sol_service_128b);
+}
+
+#endif
diff --git a/btif/src/btif_gatt_server.c b/btif/src/btif_gatt_server.c
index f5ad0f5..7010bee 100644
--- a/btif/src/btif_gatt_server.c
+++ b/btif/src/btif_gatt_server.c
@@ -321,6 +321,18 @@
break;
}
+ case BTA_GATTS_CONF_EVT:
+ HAL_CBACK(bt_gatt_callbacks, server->indication_sent_cb,
+ p_data->req_data.conn_id, p_data->req_data.status);
+ break;
+
+ case BTA_GATTS_CONGEST_EVT:
+ HAL_CBACK(bt_gatt_callbacks, server->congestion_cb
+ , p_data->congest.conn_id
+ , p_data->congest.congested
+ );
+ break;
+
case BTA_GATTS_MTU_EVT:
case BTA_GATTS_OPEN_EVT:
case BTA_GATTS_CANCEL_OPEN_EVT:
diff --git a/btif/src/btif_gatt_test.c b/btif/src/btif_gatt_test.c
index def2753..4d71ad9 100644
--- a/btif/src/btif_gatt_test.c
+++ b/btif/src/btif_gatt_test.c
@@ -206,6 +206,7 @@
btif_test_discovery_result_cback,
btif_test_discovery_complete_cback,
NULL,
+ NULL,
NULL
};
@@ -233,15 +234,15 @@
case 0x02: /* Connect */
{
- ALOGD("%s: CONNECT - device=%02x:%02x:%02x:%02x:%02x:%02x (dev_type=%d)",
+ ALOGD("%s: CONNECT - device=%02x:%02x:%02x:%02x:%02x:%02x (dev_type=%d, addr_type=%d)",
__FUNCTION__,
params->bda1->address[0], params->bda1->address[1],
params->bda1->address[2], params->bda1->address[3],
params->bda1->address[4], params->bda1->address[5],
- params->u1);
+ params->u1, params->u2);
if (params->u1 == BT_DEVICE_TYPE_BLE)
- BTM_SecAddBleDevice(params->bda1->address, NULL, BT_DEVICE_TYPE_BLE, 0);
+ BTM_SecAddBleDevice(params->bda1->address, NULL, BT_DEVICE_TYPE_BLE, params->u2);
if ( !GATT_Connect(test_cb.gatt_if, params->bda1->address, TRUE, BT_TRANSPORT_LE) )
{
diff --git a/btif/src/btif_gatt_util.c b/btif/src/btif_gatt_util.c
index 4facdef..bde76ef 100644
--- a/btif/src/btif_gatt_util.c
+++ b/btif/src/btif_gatt_util.c
@@ -43,7 +43,7 @@
#define GATTC_READ_VALUE_TYPE_VALUE 0x0000 /* Attribute value itself */
#define GATTC_READ_VALUE_TYPE_AGG_FORMAT 0x2905 /* Characteristic Aggregate Format*/
-static char BASE_UUID[16] = {
+static unsigned char BASE_UUID[16] = {
0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
diff --git a/btif/src/btif_hf.c b/btif/src/btif_hf.c
index d2e8354..1b826ae 100644
--- a/btif/src/btif_hf.c
+++ b/btif/src/btif_hf.c
@@ -675,7 +675,7 @@
** Returns bt_status_t
**
*******************************************************************************/
-static bt_status_t connect_int( bt_bdaddr_t *bd_addr )
+static bt_status_t connect_int(bt_bdaddr_t *bd_addr, uint16_t uuid)
{
CHECK_BTHF_INIT();
int i;
diff --git a/btif/src/btif_hf_client.c b/btif/src/btif_hf_client.c
new file mode 100644
index 0000000..98a73d8
--- /dev/null
+++ b/btif/src/btif_hf_client.c
@@ -0,0 +1,985 @@
+/******************************************************************************
+ *
+ * Copyright (c) 2014 The Android Open Source Project
+ * Copyright (C) 2009-2012 Broadcom 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.
+ *
+ ******************************************************************************/
+
+/************************************************************************************
+ *
+ * Filename: btif_hf_client.c
+ *
+ * Description: Handsfree Profile (HF role) Bluetooth Interface
+ *
+ *
+ ***********************************************************************************/
+
+#include <hardware/bluetooth.h>
+#include <hardware/bt_hf_client.h>
+#include <stdlib.h>
+#include <cutils/properties.h>
+
+#define LOG_TAG "BTIF_HF_CLIENT"
+#include "btif_common.h"
+#include "btif_util.h"
+#include "btif_profile_queue.h"
+#include "bt_utils.h"
+#include "bd.h"
+#include "bta_hf_client_api.h"
+
+/************************************************************************************
+** Constants & Macros
+************************************************************************************/
+
+#ifndef BTIF_HF_CLIENT_SERVICE_NAME
+#define BTIF_HF_CLIENT_SERVICE_NAME ("Handsfree")
+#endif
+
+#ifndef BTIF_HF_CLIENT_SECURITY
+#define BTIF_HF_CLIENT_SECURITY (BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)
+#endif
+
+#ifndef BTIF_HF_CLIENT_FEATURES
+#define BTIF_HF_CLIENT_FEATURES ( BTA_HF_CLIENT_FEAT_ECNR | \
+ BTA_HF_CLIENT_FEAT_3WAY | \
+ BTA_HF_CLIENT_FEAT_CLI | \
+ BTA_HF_CLIENT_FEAT_VREC | \
+ BTA_HF_CLIENT_FEAT_VOL | \
+ BTA_HF_CLIENT_FEAT_ECS | \
+ BTA_HF_CLIENT_FEAT_ECC | \
+ BTA_HF_CLIENT_FEAT_CODEC)
+#endif
+
+/************************************************************************************
+** Local type definitions
+************************************************************************************/
+
+/************************************************************************************
+** Static variables
+************************************************************************************/
+static bthf_client_callbacks_t *bt_hf_client_callbacks = NULL;
+char btif_hf_client_version[PROPERTY_VALUE_MAX];
+static UINT32 btif_hf_client_features = 0;
+
+
+#define CHECK_BTHF_CLIENT_INIT() if (bt_hf_client_callbacks == NULL)\
+ {\
+ BTIF_TRACE_WARNING1("BTHF CLIENT: %s: not initialized", __FUNCTION__);\
+ return BT_STATUS_NOT_READY;\
+ }\
+ else\
+ {\
+ BTIF_TRACE_EVENT1("BTHF CLIENT: %s", __FUNCTION__);\
+ }
+
+#define CHECK_BTHF_CLIENT_SLC_CONNECTED() if (bt_hf_client_callbacks == NULL)\
+ {\
+ BTIF_TRACE_WARNING1("BTHF CLIENT: %s: not initialized", __FUNCTION__);\
+ return BT_STATUS_NOT_READY;\
+ }\
+ else if (btif_hf_client_cb.state != BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED)\
+ {\
+ BTIF_TRACE_WARNING2("BTHF CLIENT: %s: SLC connection not up. state=%s",\
+ __FUNCTION__, \
+ dump_hf_conn_state(btif_hf_client_cb.state));\
+ return BT_STATUS_NOT_READY;\
+ }\
+ else\
+ {\
+ BTIF_TRACE_EVENT1("BTHF CLIENT: %s", __FUNCTION__);\
+ }
+
+/* BTIF-HF control block to map bdaddr to BTA handle */
+typedef struct
+{
+ UINT16 handle;
+ bt_bdaddr_t connected_bda;
+ bthf_client_connection_state_t state;
+ bthf_client_vr_state_t vr_state;
+ tBTA_HF_CLIENT_PEER_FEAT peer_feat;
+ tBTA_HF_CLIENT_CHLD_FEAT chld_feat;
+} btif_hf_client_cb_t;
+
+static btif_hf_client_cb_t btif_hf_client_cb;
+
+
+/************************************************************************************
+** Static functions
+************************************************************************************/
+
+/*******************************************************************************
+**
+** Function btif_in_hf_client_generic_evt
+**
+** Description Processes generic events to be sent to JNI that are not triggered from the BTA.
+** Always runs in BTIF context
+**
+** Returns void
+**
+*******************************************************************************/
+static void btif_in_hf_client_generic_evt(UINT16 event, char *p_param)
+{
+ UNUSED(p_param);
+
+ BTIF_TRACE_EVENT2("%s: event=%d", __FUNCTION__, event);
+ switch (event) {
+ case BTIF_HF_CLIENT_CB_AUDIO_CONNECTING:
+ {
+ HAL_CBACK(bt_hf_client_callbacks, audio_state_cb, BTHF_AUDIO_STATE_CONNECTING,
+ &btif_hf_client_cb.connected_bda);
+ } break;
+ default:
+ {
+ BTIF_TRACE_WARNING2("%s : Unknown event 0x%x", __FUNCTION__, event);
+ }
+ break;
+ }
+}
+
+/************************************************************************************
+** Externs
+************************************************************************************/
+
+/************************************************************************************
+** Functions
+************************************************************************************/
+
+static void clear_state(void)
+{
+ memset(&btif_hf_client_cb, 0, sizeof(btif_hf_client_cb_t));
+}
+
+static BOOLEAN is_connected(bt_bdaddr_t *bd_addr)
+{
+ if (((btif_hf_client_cb.state == BTHF_CLIENT_CONNECTION_STATE_CONNECTED) ||
+ (btif_hf_client_cb.state == BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED))&&
+ ((bd_addr == NULL) || (bdcmp(bd_addr->address, btif_hf_client_cb.connected_bda.address) == 0)))
+ return TRUE;
+ return FALSE;
+}
+
+/*****************************************************************************
+** Section name (Group of functions)
+*****************************************************************************/
+
+/*****************************************************************************
+**
+** btif hf api functions (no context switch)
+**
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function btif_hf_client_init
+**
+** Description initializes the hf interface
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t init( bthf_client_callbacks_t* callbacks )
+{
+ BTIF_TRACE_EVENT1("%s", __FUNCTION__);
+
+ bt_hf_client_callbacks = callbacks;
+
+ btif_enable_service(BTA_HFP_HS_SERVICE_ID);
+
+ clear_state();
+
+ return BT_STATUS_SUCCESS;
+}
+
+/*******************************************************************************
+**
+** Function connect
+**
+** Description connect to audio gateway
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t connect_int( bt_bdaddr_t *bd_addr, uint16_t uuid )
+{
+ if (is_connected(bd_addr))
+ return BT_STATUS_BUSY;
+
+ btif_hf_client_cb.state = BTHF_CLIENT_CONNECTION_STATE_CONNECTING;
+ bdcpy(btif_hf_client_cb.connected_bda.address, bd_addr->address);
+
+ BTA_HfClientOpen(btif_hf_client_cb.handle, btif_hf_client_cb.connected_bda.address,
+ BTIF_HF_CLIENT_SECURITY);
+
+ return BT_STATUS_SUCCESS;
+}
+
+static bt_status_t connect( bt_bdaddr_t *bd_addr )
+{
+ BTIF_TRACE_EVENT1("HFP Client version is %s", btif_hf_client_version);
+ CHECK_BTHF_CLIENT_INIT();
+ return btif_queue_connect(UUID_SERVCLASS_HF_HANDSFREE, bd_addr, connect_int);
+
+}
+
+/*******************************************************************************
+**
+** Function disconnect
+**
+** Description disconnect from audio gateway
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t disconnect( bt_bdaddr_t *bd_addr )
+{
+ CHECK_BTHF_CLIENT_INIT();
+
+ if (is_connected(bd_addr))
+ {
+ BTA_HfClientClose(btif_hf_client_cb.handle);
+ return BT_STATUS_SUCCESS;
+ }
+
+ return BT_STATUS_FAIL;
+}
+
+/*******************************************************************************
+**
+** Function connect_audio
+**
+** Description create an audio connection
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t connect_audio( bt_bdaddr_t *bd_addr )
+{
+ CHECK_BTHF_CLIENT_SLC_CONNECTED();
+
+ if (is_connected(bd_addr))
+ {
+ if (btif_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_CODEC)
+ {
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_BCC, 0, 0, NULL);
+ }
+ else
+ {
+ BTA_HfClientAudioOpen(btif_hf_client_cb.handle);
+ }
+
+ /* Inform the application that the audio connection has been initiated successfully */
+ btif_transfer_context(btif_in_hf_client_generic_evt, BTIF_HF_CLIENT_CB_AUDIO_CONNECTING,
+ (char *)bd_addr, sizeof(bt_bdaddr_t), NULL);
+ return BT_STATUS_SUCCESS;
+ }
+
+ return BT_STATUS_FAIL;
+}
+
+/*******************************************************************************
+**
+** Function disconnect_audio
+**
+** Description close the audio connection
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t disconnect_audio( bt_bdaddr_t *bd_addr )
+{
+ CHECK_BTHF_CLIENT_SLC_CONNECTED();
+
+ if (is_connected(bd_addr))
+ {
+ BTA_HfClientAudioClose(btif_hf_client_cb.handle);
+ return BT_STATUS_SUCCESS;
+ }
+
+ return BT_STATUS_FAIL;
+}
+
+/*******************************************************************************
+**
+** Function start_voice_recognition
+**
+** Description start voice recognition
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t start_voice_recognition()
+{
+ CHECK_BTHF_CLIENT_SLC_CONNECTED();
+
+ if (btif_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_FEAT_VREC)
+ {
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_BVRA, 1, 0, NULL);
+
+ return BT_STATUS_SUCCESS;
+ }
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+/*******************************************************************************
+**
+** Function stop_voice_recognition
+**
+** Description stop voice recognition
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t stop_voice_recognition()
+{
+ CHECK_BTHF_CLIENT_SLC_CONNECTED();
+
+ if (btif_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_FEAT_VREC)
+ {
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_BVRA, 0, 0, NULL);
+
+ return BT_STATUS_SUCCESS;
+ }
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+/*******************************************************************************
+**
+** Function volume_control
+**
+** Description volume control
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t volume_control(bthf_client_volume_type_t type, int volume)
+{
+ BOOLEAN speaker;
+
+ CHECK_BTHF_CLIENT_SLC_CONNECTED();
+
+ switch (type)
+ {
+ case BTHF_CLIENT_VOLUME_TYPE_SPK:
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_VGS, volume, 0, NULL);
+ break;
+ case BTHF_CLIENT_VOLUME_TYPE_MIC:
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_VGM, volume, 0, NULL);
+ break;
+ default:
+ return BT_STATUS_UNSUPPORTED;
+ }
+
+ return BT_STATUS_SUCCESS;
+}
+
+/*******************************************************************************
+**
+** Function dial
+**
+** Description place a call
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t dial(const char *number)
+{
+ CHECK_BTHF_CLIENT_SLC_CONNECTED();
+
+ if (number)
+ {
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_ATD, 0, 0, number);
+ }
+ else
+ {
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_BLDN, 0, 0, NULL);
+ }
+
+ return BT_STATUS_SUCCESS;
+}
+
+/*******************************************************************************
+**
+** Function dial_memory
+**
+** Description place a call with number specified by location (speed dial)
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t dial_memory(int location)
+{
+ CHECK_BTHF_CLIENT_SLC_CONNECTED();
+
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_ATD, location, 0, NULL);
+
+ return BT_STATUS_SUCCESS;
+}
+
+/*******************************************************************************
+**
+** Function handle_call_action
+**
+** Description handle specified call related action
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t handle_call_action(bthf_client_call_action_t action, int idx)
+{
+ CHECK_BTHF_CLIENT_SLC_CONNECTED();
+
+ switch (action)
+ {
+ case BTHF_CLIENT_CALL_ACTION_CHLD_0:
+ if (btif_hf_client_cb.chld_feat & BTA_HF_CLIENT_CHLD_REL)
+ {
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_CHLD, 0, 0, NULL);
+ break;
+ }
+ return BT_STATUS_UNSUPPORTED;
+ case BTHF_CLIENT_CALL_ACTION_CHLD_1:
+ // CHLD 1 is mandatory for 3 way calling
+ if (btif_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_FEAT_3WAY)
+ {
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_CHLD, 1, 0, NULL);
+ break;
+ }
+ return BT_STATUS_UNSUPPORTED;
+ case BTHF_CLIENT_CALL_ACTION_CHLD_2:
+ // CHLD 2 is mandatory for 3 way calling
+ if (btif_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_FEAT_3WAY)
+ {
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_CHLD, 2, 0, NULL);
+ break;
+ }
+ return BT_STATUS_UNSUPPORTED;
+ case BTHF_CLIENT_CALL_ACTION_CHLD_3:
+ if (btif_hf_client_cb.chld_feat & BTA_HF_CLIENT_CHLD_MERGE)
+ {
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_CHLD, 3, 0, NULL);
+ break;
+ }
+ return BT_STATUS_UNSUPPORTED;
+ case BTHF_CLIENT_CALL_ACTION_CHLD_4:
+ if (btif_hf_client_cb.chld_feat & BTA_HF_CLIENT_CHLD_MERGE_DETACH)
+ {
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_CHLD, 4, 0, NULL);
+ break;
+ }
+ return BT_STATUS_UNSUPPORTED;
+ case BTHF_CLIENT_CALL_ACTION_CHLD_1x:
+ if (btif_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_ECC)
+ {
+ if (idx < 1)
+ {
+ return BT_STATUS_FAIL;
+ }
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_CHLD, 1, idx, NULL);
+ break;
+ }
+ return BT_STATUS_UNSUPPORTED;
+ case BTHF_CLIENT_CALL_ACTION_CHLD_2x:
+ if (btif_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_ECC)
+ {
+ if (idx < 1)
+ {
+ return BT_STATUS_FAIL;
+ }
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_CHLD, 2, idx, NULL);
+ break;
+ }
+ return BT_STATUS_UNSUPPORTED;
+ case BTHF_CLIENT_CALL_ACTION_ATA:
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_ATA, 0, 0, NULL);
+ break;
+ case BTHF_CLIENT_CALL_ACTION_CHUP:
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_CHUP, 0, 0, NULL);
+ break;
+ case BTHF_CLIENT_CALL_ACTION_BTRH_0:
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_BTRH, 0, 0, NULL);
+ break;
+ case BTHF_CLIENT_CALL_ACTION_BTRH_1:
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_BTRH, 1, 0, NULL);
+ break;
+ case BTHF_CLIENT_CALL_ACTION_BTRH_2:
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_BTRH, 2, 0, NULL);
+ break;
+ default:
+ return BT_STATUS_FAIL;
+
+ }
+
+ return BT_STATUS_SUCCESS;
+}
+
+/*******************************************************************************
+**
+** Function query_current_calls
+**
+** Description query list of current calls
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t query_current_calls(void)
+{
+ CHECK_BTHF_CLIENT_SLC_CONNECTED();
+
+ if (btif_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_ECS)
+ {
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_CLCC, 0, 0, NULL);
+
+ return BT_STATUS_SUCCESS;
+ }
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+/*******************************************************************************
+**
+** Function query_current_operator_name
+**
+** Description query current selected operator name
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t query_current_operator_name(void)
+{
+ CHECK_BTHF_CLIENT_SLC_CONNECTED();
+
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_COPS, 0, 0, NULL);
+
+ return BT_STATUS_SUCCESS;
+}
+
+/*******************************************************************************
+**
+** Function retieve_subscriber_info
+**
+** Description retrieve subscriber number information
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t retrieve_subscriber_info(void)
+{
+ CHECK_BTHF_CLIENT_SLC_CONNECTED();
+
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_CNUM, 0, 0, NULL);
+
+ return BT_STATUS_SUCCESS;
+}
+
+/*******************************************************************************
+**
+** Function send_dtmf
+**
+** Description send dtmf
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t send_dtmf(char code)
+{
+ CHECK_BTHF_CLIENT_SLC_CONNECTED();
+
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_VTS, code, 0, NULL);
+
+ return BT_STATUS_SUCCESS;
+}
+
+/*******************************************************************************
+**
+** Function request_last_voice_tag_number
+**
+** Description Request number from AG for VR purposes
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t request_last_voice_tag_number(void)
+{
+ CHECK_BTHF_CLIENT_SLC_CONNECTED();
+
+ if (btif_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_VTAG)
+ {
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_BINP, 1, 0, NULL);
+
+ return BT_STATUS_SUCCESS;
+ }
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+/*******************************************************************************
+**
+** Function cleanup
+**
+** Description Closes the HF interface
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static void cleanup( void )
+{
+ BTIF_TRACE_EVENT1("%s", __FUNCTION__);
+
+ if (bt_hf_client_callbacks)
+ {
+ btif_disable_service(BTA_HFP_HS_SERVICE_ID);
+ bt_hf_client_callbacks = NULL;
+ }
+}
+
+/*******************************************************************************
+**
+** Function send_at_cmd
+**
+** Description Send requested AT command to rempte device.
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t send_at_cmd(int cmd,int val1,int val2,const char *arg)
+{
+ CHECK_BTHF_CLIENT_SLC_CONNECTED();
+ BTIF_TRACE_EVENT5("%s Cmd %d val1 %d val2 %d arg %s",
+ __FUNCTION__,cmd,val1,val2,arg);
+ BTA_HfClientSendAT(btif_hf_client_cb.handle, cmd, val1, val2, arg);
+
+ return BT_STATUS_SUCCESS;
+}
+
+static const bthf_client_interface_t bthfClientInterface = {
+ sizeof(bthf_client_interface_t),
+ .init = init,
+ .connect = connect,
+ .disconnect = disconnect,
+ .connect_audio = connect_audio,
+ .disconnect_audio = disconnect_audio,
+ .start_voice_recognition = start_voice_recognition,
+ .stop_voice_recognition = stop_voice_recognition,
+ .volume_control = volume_control,
+ .dial = dial,
+ .dial_memory = dial_memory,
+ .handle_call_action = handle_call_action,
+ .query_current_calls = query_current_calls,
+ .query_current_operator_name = query_current_operator_name,
+ .retrieve_subscriber_info = retrieve_subscriber_info,
+ .send_dtmf = send_dtmf,
+ .request_last_voice_tag_number = request_last_voice_tag_number,
+ .cleanup = cleanup,
+ .send_at_cmd = send_at_cmd,
+};
+
+static void process_ind_evt(tBTA_HF_CLIENT_IND *ind)
+{
+ switch (ind->type)
+ {
+ case BTA_HF_CLIENT_IND_CALL:
+ HAL_CBACK(bt_hf_client_callbacks, call_cb, ind->value);
+ break;
+
+ case BTA_HF_CLIENT_IND_CALLSETUP:
+ HAL_CBACK(bt_hf_client_callbacks, callsetup_cb, ind->value);
+ break;
+ case BTA_HF_CLIENT_IND_CALLHELD:
+ HAL_CBACK(bt_hf_client_callbacks, callheld_cb, ind->value);
+ break;
+
+ case BTA_HF_CLIENT_IND_SERVICE:
+ HAL_CBACK(bt_hf_client_callbacks, network_state_cb, ind->value);
+ break;
+
+ case BTA_HF_CLIENT_IND_SIGNAL:
+ HAL_CBACK(bt_hf_client_callbacks, network_signal_cb, ind->value);
+ break;
+
+ case BTA_HF_CLIENT_IND_ROAM:
+ HAL_CBACK(bt_hf_client_callbacks, network_roaming_cb, ind->value);
+ break;
+
+ case BTA_HF_CLIENT_IND_BATTCH:
+ HAL_CBACK(bt_hf_client_callbacks, battery_level_cb, ind->value);
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*******************************************************************************
+**
+** Function btif_hf_client_upstreams_evt
+**
+** Description Executes HF CLIENT UPSTREAMS events in btif context
+**
+** Returns void
+**
+*******************************************************************************/
+static void btif_hf_client_upstreams_evt(UINT16 event, char* p_param)
+{
+ tBTA_HF_CLIENT *p_data = (tBTA_HF_CLIENT *)p_param;
+ bdstr_t bdstr;
+
+ BTIF_TRACE_DEBUG3("%s: event=%s (%u)", __FUNCTION__, dump_hf_client_event(event), event);
+
+ switch (event)
+ {
+ case BTA_HF_CLIENT_ENABLE_EVT:
+ case BTA_HF_CLIENT_DISABLE_EVT:
+ break;
+
+ case BTA_HF_CLIENT_REGISTER_EVT:
+ btif_hf_client_cb.handle = p_data->reg.handle;
+ break;
+
+ case BTA_HF_CLIENT_OPEN_EVT:
+ if (p_data->open.status == BTA_HF_CLIENT_SUCCESS)
+ {
+ bdcpy(btif_hf_client_cb.connected_bda.address, p_data->open.bd_addr);
+ btif_hf_client_cb.state = BTHF_CLIENT_CONNECTION_STATE_CONNECTED;
+ btif_hf_client_cb.peer_feat = 0;
+ btif_hf_client_cb.chld_feat = 0;
+ //clear_phone_state();
+ }
+ else if (btif_hf_client_cb.state == BTHF_CLIENT_CONNECTION_STATE_CONNECTING)
+ {
+ btif_hf_client_cb.state = BTHF_CLIENT_CONNECTION_STATE_DISCONNECTED;
+ }
+ else
+ {
+ BTIF_TRACE_WARNING4("%s: HF CLient open failed, but another device connected. status=%d state=%d connected device=%s",
+ __FUNCTION__, p_data->open.status, btif_hf_client_cb.state, bd2str(&btif_hf_client_cb.connected_bda, &bdstr));
+ break;
+ }
+
+ HAL_CBACK(bt_hf_client_callbacks, connection_state_cb, btif_hf_client_cb.state,
+ 0, 0, &btif_hf_client_cb.connected_bda);
+
+ if (btif_hf_client_cb.state == BTHF_CLIENT_CONNECTION_STATE_DISCONNECTED)
+ bdsetany(btif_hf_client_cb.connected_bda.address);
+
+ if (p_data->open.status != BTA_HF_CLIENT_SUCCESS)
+ btif_queue_advance();
+ break;
+
+ case BTA_HF_CLIENT_CONN_EVT:
+ btif_hf_client_cb.peer_feat = p_data->conn.peer_feat;
+ btif_hf_client_cb.chld_feat = p_data->conn.chld_feat;
+ btif_hf_client_cb.state = BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED;
+
+ HAL_CBACK(bt_hf_client_callbacks, connection_state_cb, btif_hf_client_cb.state,
+ btif_hf_client_cb.peer_feat, btif_hf_client_cb.chld_feat,
+ &btif_hf_client_cb.connected_bda);
+
+ /* Inform the application about in-band ringtone */
+ if (btif_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_INBAND)
+ {
+ HAL_CBACK(bt_hf_client_callbacks, in_band_ring_tone_cb, BTHF_CLIENT_IN_BAND_RINGTONE_PROVIDED);
+ }
+
+ btif_queue_advance();
+ break;
+
+ case BTA_HF_CLIENT_CLOSE_EVT:
+ btif_hf_client_cb.state = BTHF_CLIENT_CONNECTION_STATE_DISCONNECTED;
+ HAL_CBACK(bt_hf_client_callbacks, connection_state_cb, btif_hf_client_cb.state,
+ 0, 0, &btif_hf_client_cb.connected_bda);
+ bdsetany(btif_hf_client_cb.connected_bda.address);
+ btif_hf_client_cb.peer_feat = 0;
+ btif_hf_client_cb.chld_feat = 0;
+ btif_queue_advance();
+ break;
+
+ case BTA_HF_CLIENT_IND_EVT:
+ process_ind_evt(&p_data->ind);
+ break;
+
+ case BTA_HF_CLIENT_MIC_EVT:
+ HAL_CBACK(bt_hf_client_callbacks, volume_change_cb, BTHF_CLIENT_VOLUME_TYPE_MIC, p_data->val.value);
+ break;
+
+ case BTA_HF_CLIENT_SPK_EVT:
+ HAL_CBACK(bt_hf_client_callbacks, volume_change_cb, BTHF_CLIENT_VOLUME_TYPE_SPK, p_data->val.value);
+ break;
+
+ case BTA_HF_CLIENT_VOICE_REC_EVT:
+ HAL_CBACK(bt_hf_client_callbacks, vr_cmd_cb, p_data->val.value);
+ break;
+
+ case BTA_HF_CLIENT_OPERATOR_NAME_EVT:
+ HAL_CBACK(bt_hf_client_callbacks, current_operator_cb, p_data->operator.name);
+ break;
+
+ case BTA_HF_CLIENT_CLIP_EVT:
+ HAL_CBACK(bt_hf_client_callbacks, clip_cb, p_data->number.number);
+ break;
+
+ case BTA_HF_CLIENT_BINP_EVT:
+ HAL_CBACK(bt_hf_client_callbacks, last_voice_tag_number_callback, p_data->number.number);
+ break;
+
+ case BTA_HF_CLIENT_CCWA_EVT:
+ HAL_CBACK(bt_hf_client_callbacks, call_waiting_cb, p_data->number.number);
+ break;
+
+ case BTA_HF_CLIENT_AT_RESULT_EVT:
+ HAL_CBACK(bt_hf_client_callbacks, cmd_complete_cb, p_data->result.type, p_data->result.cme);
+ break;
+
+ case BTA_HF_CLIENT_CLCC_EVT:
+ HAL_CBACK(bt_hf_client_callbacks, current_calls_cb, p_data->clcc.idx,
+ p_data->clcc.inc ? BTHF_CLIENT_CALL_DIRECTION_INCOMING : BTHF_CLIENT_CALL_DIRECTION_OUTGOING,
+ p_data->clcc.status,
+ p_data->clcc.mpty ? BTHF_CLIENT_CALL_MPTY_TYPE_MULTI : BTHF_CLIENT_CALL_MPTY_TYPE_SINGLE,
+ p_data->clcc.number_present ? p_data->clcc.number : NULL);
+ break;
+
+ case BTA_HF_CLIENT_CNUM_EVT:
+ if (p_data->cnum.service == 4)
+ {
+ HAL_CBACK(bt_hf_client_callbacks, subscriber_info_cb, p_data->cnum.number, BTHF_CLIENT_SERVICE_VOICE);
+ }
+ else if (p_data->cnum.service == 5)
+ {
+ HAL_CBACK(bt_hf_client_callbacks, subscriber_info_cb, p_data->cnum.number, BTHF_CLIENT_SERVICE_FAX);
+ }
+ else
+ {
+ HAL_CBACK(bt_hf_client_callbacks, subscriber_info_cb, p_data->cnum.number, BTHF_CLIENT_SERVICE_UNKNOWN);
+ }
+ break;
+
+ case BTA_HF_CLIENT_BTRH_EVT:
+ if (p_data->val.value <= BTRH_CLIENT_RESP_AND_HOLD_REJECT)
+ {
+ HAL_CBACK(bt_hf_client_callbacks, resp_and_hold_cb, p_data->val.value);
+ }
+ break;
+
+ case BTA_HF_CLIENT_BSIR_EVT:
+ if (p_data->val.value != 0)
+ {
+ HAL_CBACK(bt_hf_client_callbacks, in_band_ring_tone_cb, BTHF_CLIENT_IN_BAND_RINGTONE_PROVIDED);
+ }
+ else
+ {
+ HAL_CBACK(bt_hf_client_callbacks, in_band_ring_tone_cb, BTHF_CLIENT_IN_BAND_RINGTONE_NOT_PROVIDED);
+ }
+ break;
+
+ case BTA_HF_CLIENT_AUDIO_OPEN_EVT:
+ HAL_CBACK(bt_hf_client_callbacks, audio_state_cb, BTHF_CLIENT_AUDIO_STATE_CONNECTED, &btif_hf_client_cb.connected_bda);
+ break;
+
+ case BTA_HF_CLIENT_AUDIO_MSBC_OPEN_EVT:
+ HAL_CBACK(bt_hf_client_callbacks, audio_state_cb, BTHF_CLIENT_AUDIO_STATE_CONNECTED_MSBC, &btif_hf_client_cb.connected_bda);
+ break;
+
+ case BTA_HF_CLIENT_AUDIO_CLOSE_EVT:
+ HAL_CBACK(bt_hf_client_callbacks, audio_state_cb, BTHF_CLIENT_AUDIO_STATE_DISCONNECTED, &btif_hf_client_cb.connected_bda);
+ break;
+ case BTA_HF_CLIENT_RING_INDICATION:
+ HAL_CBACK(bt_hf_client_callbacks, ring_indication_cb);
+ break;
+ default:
+ BTIF_TRACE_WARNING2("%s: Unhandled event: %d", __FUNCTION__, event);
+ break;
+ }
+}
+
+/*******************************************************************************
+**
+** Function bte_hf_client_evt
+**
+** Description Switches context from BTE to BTIF for all HF Client events
+**
+** Returns void
+**
+*******************************************************************************/
+
+static void bte_hf_client_evt(tBTA_HF_CLIENT_EVT event, tBTA_HF_CLIENT *p_data)
+{
+ bt_status_t status;
+
+ /* switch context to btif task context (copy full union size for convenience) */
+ status = btif_transfer_context(btif_hf_client_upstreams_evt, (uint16_t)event, (void*)p_data, sizeof(*p_data), NULL);
+
+ /* catch any failed context transfers */
+ ASSERTC(status == BT_STATUS_SUCCESS, "context transfer failed", status);
+}
+
+/*******************************************************************************
+**
+** Function btif_hf_client_execute_service
+**
+** Description Initializes/Shuts down the service
+**
+** Returns BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_hf_client_execute_service(BOOLEAN b_enable)
+{
+ BTIF_TRACE_EVENT2("%s enable:%d", __FUNCTION__, b_enable);
+
+ property_get("ro.bluetooth.hfp.ver", btif_hf_client_version, "1.5");
+
+ if (b_enable)
+ {
+ /* Enable and register with BTA-HFClient */
+ BTA_HfClientEnable(bte_hf_client_evt);
+ if (strcmp(btif_hf_client_version, "1.6") == 0)
+ {
+ BTIF_TRACE_EVENT1("Support Codec Nego. %d ", BTIF_HF_CLIENT_FEATURES);
+ BTA_HfClientRegister(BTIF_HF_CLIENT_SECURITY, BTIF_HF_CLIENT_FEATURES,
+ BTIF_HF_CLIENT_SERVICE_NAME);
+ }
+ else
+ {
+ BTIF_TRACE_EVENT0("No Codec Nego Supported");
+ btif_hf_client_features = BTIF_HF_CLIENT_FEATURES;
+ btif_hf_client_features = btif_hf_client_features & (~BTA_HF_CLIENT_FEAT_CODEC);
+ BTIF_TRACE_EVENT1("btif_hf_client_features is %d", btif_hf_client_features);
+ BTA_HfClientRegister(BTIF_HF_CLIENT_SECURITY, btif_hf_client_features,
+ BTIF_HF_CLIENT_SERVICE_NAME);
+ }
+
+ }
+ else
+ {
+ BTA_HfClientDeregister(btif_hf_client_cb.handle);
+ BTA_HfClientDisable();
+ }
+ return BT_STATUS_SUCCESS;
+}
+
+/*******************************************************************************
+**
+** Function btif_hf_get_interface
+**
+** Description Get the hf callback interface
+**
+** Returns bthf_interface_t
+**
+*******************************************************************************/
+const bthf_client_interface_t *btif_hf_client_get_interface(void)
+{
+ BTIF_TRACE_EVENT1("%s", __FUNCTION__);
+ return &bthfClientInterface;
+}
diff --git a/btif/src/btif_hh.c b/btif/src/btif_hh.c
index 7690402..73bcb0c 100644
--- a/btif/src/btif_hh.c
+++ b/btif/src/btif_hh.c
@@ -337,29 +337,6 @@
/*******************************************************************************
**
-** Function btif_hh_find_dev_by_handle
-**
-** Description Return the device pointer of the specified device handle
-**
-** Returns Device entry pointer in the device table
-*******************************************************************************/
-static btif_hh_device_t *btif_hh_find_dev_by_handle(UINT8 handle)
-{
- UINT32 i;
- // LOGV("%s: handle = %d", __FUNCTION__, handle);
- for (i = 0; i < BTIF_HH_MAX_HID; i++) {
- if (btif_hh_cb.devices[i].dev_status != BTHH_CONN_STATE_UNKNOWN &&
- btif_hh_cb.devices[i].dev_handle == handle)
- {
- return &btif_hh_cb.devices[i];
- }
- }
- return NULL;
-}
-
-
-/*******************************************************************************
-**
** Function btif_hh_find_connected_dev_by_handle
**
** Description Return the connected device pointer of the specified device handle
@@ -870,16 +847,20 @@
BTIF_TRACE_DEBUG2("BTA_HH_GET_RPT_EVT: status = %d, handle = %d",
p_data->hs_data.status, p_data->hs_data.handle);
- /* p_rpt_data in HANDSHAKE response case */
- if (hdr) {
- data = (UINT8 *)(hdr + 1) + hdr->offset;
- len = hdr->len;
- }
p_dev = btif_hh_find_connected_dev_by_handle(p_data->hs_data.handle);
if (p_dev) {
- HAL_CBACK(bt_hh_callbacks, get_report_cb,
- (bt_bdaddr_t*) &(p_dev->bd_addr),
- (bthh_status_t) p_data->hs_data.status, data, len);
+ /* p_rpt_data is NULL in HANDSHAKE response case */
+ if (hdr) {
+ data = (UINT8 *)(hdr + 1) + hdr->offset;
+ len = hdr->len;
+ HAL_CBACK(bt_hh_callbacks, get_report_cb,
+ (bt_bdaddr_t*) &(p_dev->bd_addr),
+ (bthh_status_t) p_data->hs_data.status, data, len);
+ } else {
+ HAL_CBACK(bt_hh_callbacks, handshake_cb,
+ (bt_bdaddr_t*) &(p_dev->bd_addr),
+ (bthh_status_t) p_data->hs_data.status);
+ }
} else {
BTIF_TRACE_WARNING1("Error: cannot find device with handle %d", p_data->hs_data.handle);
}
@@ -888,6 +869,12 @@
case BTA_HH_SET_RPT_EVT:
BTIF_TRACE_DEBUG2("BTA_HH_SET_RPT_EVT: status = %d, handle = %d",
p_data->dev_status.status, p_data->dev_status.handle);
+ p_dev = btif_hh_find_connected_dev_by_handle(p_data->dev_status.handle);
+ if (p_dev != NULL) {
+ HAL_CBACK(bt_hh_callbacks, handshake_cb,
+ (bt_bdaddr_t*) &(p_dev->bd_addr),
+ (bthh_status_t) p_data->hs_data.status);
+ }
break;
case BTA_HH_GET_PROTO_EVT:
@@ -897,13 +884,27 @@
p_data->hs_data.rsp_data.proto_mode,
(p_data->hs_data.rsp_data.proto_mode == BTA_HH_PROTO_RPT_MODE) ? "Report Mode" :
(p_data->hs_data.rsp_data.proto_mode == BTA_HH_PROTO_BOOT_MODE) ? "Boot Mode" : "Unsupported");
- HAL_CBACK(bt_hh_callbacks, protocol_mode_cb,(bt_bdaddr_t*) &(p_dev->bd_addr), (bthh_status_t)p_data->hs_data.status,
- (bthh_protocol_mode_t) p_data->hs_data.rsp_data.proto_mode);
+ if (p_data->hs_data.rsp_data.proto_mode != BTA_HH_PROTO_UNKNOWN) {
+ HAL_CBACK(bt_hh_callbacks, protocol_mode_cb,
+ (bt_bdaddr_t*) &(p_dev->bd_addr),
+ (bthh_status_t)p_data->hs_data.status,
+ (bthh_protocol_mode_t) p_data->hs_data.rsp_data.proto_mode);
+ } else {
+ HAL_CBACK(bt_hh_callbacks, handshake_cb,
+ (bt_bdaddr_t*) &(p_dev->bd_addr),
+ (bthh_status_t)p_data->hs_data.status);
+ }
break;
case BTA_HH_SET_PROTO_EVT:
BTIF_TRACE_DEBUG2("BTA_HH_SET_PROTO_EVT: status = %d, handle = %d",
p_data->dev_status.status, p_data->dev_status.handle);
+ p_dev = btif_hh_find_connected_dev_by_handle(p_data->dev_status.handle);
+ if (p_dev) {
+ HAL_CBACK(bt_hh_callbacks, handshake_cb,
+ (bt_bdaddr_t*)&(p_dev->bd_addr),
+ (bthh_status_t)p_data->hs_data.status);
+ }
break;
case BTA_HH_GET_IDLE_EVT:
@@ -1378,75 +1379,6 @@
return BT_STATUS_SUCCESS;
}
-/*******************************************************************************
-**
-** Function get_idle_time
-**
-** Description Get the HID idle time
-**
-** Returns bt_status_t
-**
-*******************************************************************************/
-static bt_status_t get_idle_time(bt_bdaddr_t *bd_addr)
-{
- CHECK_BTHH_INIT();
- btif_hh_device_t *p_dev;
- BD_ADDR* bda = (BD_ADDR*) bd_addr;
-
- BTIF_TRACE_DEBUG6(" addr = %02X:%02X:%02X:%02X:%02X:%02X",
- (*bda)[0], (*bda)[1], (*bda)[2], (*bda)[3], (*bda)[4], (*bda)[5]);
-
- if (btif_hh_cb.status == BTIF_HH_DISABLED) {
- BTIF_TRACE_ERROR2("%s: Error, HH status = %d", __FUNCTION__, btif_hh_cb.status);
- return BT_STATUS_FAIL;
- }
-
- p_dev = btif_hh_find_connected_dev_by_bda(bd_addr);
- if (p_dev != NULL) {
- //BTA_HhGetIdle(p_dev->dev_handle);
- }
- else {
- return BT_STATUS_FAIL;
- }
- return BT_STATUS_SUCCESS;
-}
-
-/*******************************************************************************
-**
-** Function set_idle_time
-**
-** Description Set the HID idle time
-**
-** Returns bt_status_t
-**
-*******************************************************************************/
-static bt_status_t set_idle_time (bt_bdaddr_t *bd_addr, uint8_t idle_time)
-{
- UNUSED(idle_time);
-
- CHECK_BTHH_INIT();
- btif_hh_device_t *p_dev;
- BD_ADDR* bda = (BD_ADDR*) bd_addr;
-
- BTIF_TRACE_DEBUG6("addr = %02X:%02X:%02X:%02X:%02X:%02X",
- (*bda)[0], (*bda)[1], (*bda)[2], (*bda)[3], (*bda)[4], (*bda)[5]);
-
- if (btif_hh_cb.status == BTIF_HH_DISABLED) {
- BTIF_TRACE_ERROR2("%s: Error, HH status = %d", __FUNCTION__, btif_hh_cb.status);
- return BT_STATUS_FAIL;
- }
-
- p_dev = btif_hh_find_connected_dev_by_bda(bd_addr);
- if (p_dev == NULL) {
- BTIF_TRACE_WARNING6(" Error, device %02X:%02X:%02X:%02X:%02X:%02X not opened.",
- (*bda)[0], (*bda)[1], (*bda)[2], (*bda)[3], (*bda)[4], (*bda)[5]);
- return BT_STATUS_FAIL;
- }
- else {
- //BTA_HhSetIdle(p_dev->dev_handle, idle_time);
- }
- return BT_STATUS_SUCCESS;
-}
/*******************************************************************************
**
@@ -1626,7 +1558,7 @@
memset(hexbuf, 0, len);
//TODO
hex_bytes_filled = ascii_2_hex(report, len, hexbuf);
- ALOGI("Hex bytes filled, hex value: %d", hex_bytes_filled);
+ BTIF_TRACE_DEBUG1("Hex bytes filled, hex value: %d", hex_bytes_filled);
if (hex_bytes_filled) {
BT_HDR* p_buf = create_pbuf(hex_bytes_filled, hexbuf);
if (p_buf == NULL) {
diff --git a/btif/src/btif_hl.c b/btif/src/btif_hl.c
index cdf13b6..e0ae6fe 100644
--- a/btif/src/btif_hl.c
+++ b/btif/src/btif_hl.c
@@ -94,7 +94,6 @@
static int reg_counter;
static inline int btif_hl_select_wakeup(void);
-static inline int btif_hl_select_exit(void);
static inline int btif_hl_select_close_connected(void);
static inline int btif_hl_close_select_thread(void);
static UINT8 btif_hl_get_next_app_id(void);
@@ -189,6 +188,9 @@
btif_hl_mcl_cb_t *p_mcb;
UINT8 i, j;
BOOLEAN found=FALSE;
+
+ *p_app_idx = 0;
+ *p_mcl_idx = 0;
for (i=0; i < BTA_HL_NUM_APPS ; i ++)
{
p_acb =BTIF_HL_GET_APP_CB_PTR(i);
@@ -1002,6 +1004,8 @@
UINT8 i,j;
int mdl_cfg_channel_id;
+ *p_app_idx = 0;
+ *p_mdl_cfg_idx =0;
for (i=0; i < BTA_HL_NUM_APPS ; i ++)
{
p_acb =BTIF_HL_GET_APP_CB_PTR(i);
@@ -1125,6 +1129,9 @@
BOOLEAN found=FALSE;
UINT8 i,j,k;
+ *p_app_idx = 0;
+ *p_mcl_idx =0;
+ *p_mdl_idx = 0;
for (i=0; i < BTA_HL_NUM_APPS ; i ++)
{
p_acb =BTIF_HL_GET_APP_CB_PTR(i);
@@ -1228,51 +1235,6 @@
return found;
}
-/*******************************************************************************
-**
-** Function btif_hl_find_local_mdep_id
-**
-** Description Find the local MDEP ID from the MDEP configuration
-**
-** Returns BOOLEAN
-**
-*******************************************************************************/
-static BOOLEAN btif_hl_find_local_mdep_id(UINT8 app_id,
- tBTA_HL_MDEP_ROLE local_mdep_role,
- UINT16 mdep_data_type,
- tBTA_HL_MDEP_ID *p_local_mdep_id){
- UINT8 app_idx;
- btif_hl_app_cb_t *p_acb;
- UINT8 i,j;
- BOOLEAN found = FALSE;
-
- BTIF_TRACE_DEBUG1("%s", __FUNCTION__);
-
- if (btif_hl_find_app_idx(app_id, &app_idx) )
- {
- p_acb =BTIF_HL_GET_APP_CB_PTR(app_idx);
-
- for (i=0; i< p_acb->sup_feature.num_of_mdeps; i++)
- {
- if (p_acb->sup_feature.mdep[i].mdep_cfg.mdep_role == local_mdep_role )
- {
- for (j=0; j< p_acb->sup_feature.mdep[i].mdep_cfg.num_of_mdep_data_types; j++)
- {
- if ( p_acb->sup_feature.mdep[i].mdep_cfg.data_cfg[j].data_type == mdep_data_type)
- {
- found = TRUE;
- *p_local_mdep_id = p_acb->sup_feature.mdep[i].mdep_id;
- return found;
- }
- }
- }
- }
-
-
- }
- BTIF_TRACE_DEBUG2("found=%d local mdep id=%d", found, *p_local_mdep_id );
- return found;
-}
/*******************************************************************************
**
@@ -1324,6 +1286,7 @@
btif_hl_app_cb_t *p_acb =BTIF_HL_GET_APP_CB_PTR(app_idx);
btif_hl_mcl_cb_t *p_mcb;
+ *p_mcl_idx = 0;
for (i=0; i < BTA_HL_NUM_MCLS ; i ++)
{
p_mcb = BTIF_HL_GET_MCL_CB_PTR(app_idx, i);
@@ -1585,6 +1548,7 @@
*p = BTA_HL_MDEP_ROLE_SINK;
break;
default:
+ *p = BTA_HL_MDEP_ROLE_SOURCE;
status = FALSE;
break;
}
@@ -1744,6 +1708,7 @@
BOOLEAN found=FALSE;
UINT8 i;
+ *p_app_idx = 0;
for (i=0; i < BTA_HL_NUM_APPS ; i ++)
{
if (btif_hl_cb.acb[i].in_use &&
@@ -2026,6 +1991,7 @@
BOOLEAN found=FALSE;
UINT8 i;
+ *p_app_idx = 0;
for (i=0; i < BTA_HL_NUM_APPS ; i ++)
{
BTIF_TRACE_DEBUG1("btif_hl_find_app_idx_using_mdepId: MDEP-ID = %d",
@@ -2208,28 +2174,6 @@
/*******************************************************************************
**
-** Function btif_hl_proc_sdp_info_ind
-**
-** Description Process the SDP info indication
-**
-** Returns Nothing
-**
-*******************************************************************************/
-static void btif_hl_proc_sdp_info_ind(tBTA_HL *p_data)
-
-{
- btif_hl_app_cb_t *p_acb;
- UINT8 app_idx;
-
- BTIF_TRACE_DEBUG1("%s", __FUNCTION__);
- if (btif_hl_find_app_idx_using_handle(p_data->sdp_info_ind.app_handle, &app_idx))
- {
- p_acb = BTIF_HL_GET_APP_CB_PTR(app_idx);
- memcpy(&p_acb->sdp_info_ind, &p_data->sdp_info_ind, sizeof(tBTA_HL_SDP_INFO_IND));
- }
-}
-/*******************************************************************************
-**
** Function btif_hl_set_chan_cb_state
**
** Description set the channel callback state
@@ -2635,7 +2579,6 @@
BOOLEAN status = FALSE;
tBTA_HL_DCH_OPEN_PARAM dch_open;
-
BTIF_TRACE_DEBUG1("%s", __FUNCTION__);
if (btif_hl_find_app_idx_using_app_id(p_data->cch_open_cfm.app_id, &app_idx))
@@ -4131,7 +4074,7 @@
**
*******************************************************************************/
static bt_status_t destroy_channel(int channel_id){
- UINT8 app_idx, mcl_idx, mdl_idx, mdl_cfg_idx, app_id, mdep_cfg_idx;
+ UINT8 app_idx, mcl_idx, mdl_idx, mdl_cfg_idx, app_id, mdep_cfg_idx = 0;
bt_status_t status = BT_STATUS_SUCCESS;
btif_hl_mdl_cfg_t *p_mdl;
btif_hl_mcl_cb_t *p_mcb;
@@ -4491,45 +4434,6 @@
/*******************************************************************************
**
-** Function get_device_datatype
-**
-** Description Start SDP on remote device and look for Remote HDP Data type and role
-**
-** Returns bt_status_t
-**
-*******************************************************************************/
-static bt_status_t get_device_datatype(int app_id, bt_bdaddr_t *bd_addr){
- btif_hl_app_cb_t *p_acb;
- UINT8 app_idx;
- bt_status_t status = BT_STATUS_SUCCESS;
- BD_ADDR bda;
- UINT8 i;
-
- CHECK_BTHL_INIT();
- BTIF_TRACE_EVENT2("%s app_id=%d", __FUNCTION__, app_id);
- btif_hl_display_calling_process_name();
-
- for (i=0; i<6; i++)
- {
- bda[i] = (UINT8) bd_addr->address[i];
- }
-
- if (btif_hl_find_app_idx(((UINT8)app_id), &app_idx))
- {
- p_acb = BTIF_HL_GET_APP_CB_PTR(app_idx);
- BTA_HlSdpQuery(app_id,p_acb->app_handle,bda);
- }
- else
- {
- status = BT_STATUS_FAIL;
- }
-
- BTIF_TRACE_DEBUG1("de-reg return status=%d", status);
- return status;
-}
-
-/*******************************************************************************
-**
** Function init
**
** Description initializes the hl interface
diff --git a/btif/src/btif_media_task.c b/btif/src/btif_media_task.c
index 39eb705..7e29917 100644
--- a/btif/src/btif_media_task.c
+++ b/btif/src/btif_media_task.c
@@ -66,12 +66,32 @@
#include "btif_av.h"
#include "btif_sm.h"
#include "btif_util.h"
+#ifdef BTA_AVK_INCLUDED
+#include "oi_codec_sbc.h"
+#include "oi_status.h"
+#endif
+#include "stdio.h"
+#include <dlfcn.h>
+
+//#define DEBUG_MEDIA_AV_FLOW TRUE
+
+#ifdef BTA_AVK_INCLUDED
+OI_CODEC_SBC_DECODER_CONTEXT context;
+OI_UINT32 contextData[CODEC_DATA_WORDS(2, SBC_CODEC_FAST_FILTER_BUFFERS)];
+OI_INT16 pcmData[15*SBC_MAX_SAMPLES_PER_FRAME*SBC_MAX_CHANNELS];
+#endif
/*****************************************************************************
** Constants
*****************************************************************************/
-//#define DEBUG_MEDIA_AV_FLOW TRUE
+#ifndef AUDIO_CHANNEL_OUT_MONO
+#define AUDIO_CHANNEL_OUT_MONO 0x01
+#endif
+
+#ifndef AUDIO_CHANNEL_OUT_STEREO
+#define AUDIO_CHANNEL_OUT_STEREO 0x03
+#endif
/* BTIF media task gki event definition */
#define BTIF_MEDIA_TASK_CMD TASK_MBOX_0_EVT_MASK
@@ -81,8 +101,12 @@
#define BTIF_MEDIA_AA_TASK_TIMER_ID TIMER_0
#define BTIF_MEDIA_AV_TASK_TIMER_ID TIMER_1
+#define BTIF_MEDIA_AVK_TASK_TIMER_ID TIMER_2
+
#define BTIF_MEDIA_AA_TASK_TIMER TIMER_0_EVT_MASK
#define BTIF_MEDIA_AV_TASK_TIMER TIMER_1_EVT_MASK
+#define BTIF_MEDIA_AVK_TASK_TIMER TIMER_2_EVT_MASK
+
#define BTIF_MEDIA_TASK_CMD_MBOX TASK_MBOX_0 /* cmd mailbox */
#define BTIF_MEDIA_TASK_DATA_MBOX TASK_MBOX_1 /* data mailbox */
@@ -102,7 +126,11 @@
BTIF_MEDIA_FLUSH_AA_TX,
BTIF_MEDIA_FLUSH_AA_RX,
BTIF_MEDIA_AUDIO_FEEDING_INIT,
- BTIF_MEDIA_AUDIO_RECEIVING_INIT
+ BTIF_MEDIA_AUDIO_RECEIVING_INIT,
+ BTIF_MEDIA_AUDIO_SINK_CFG_UPDATE,
+ BTIF_MEDIA_AUDIO_SINK_START_DECODING,
+ BTIF_MEDIA_AUDIO_SINK_STOP_DECODING,
+ BTIF_MEDIA_AUDIO_SINK_CLEAR_TRACK
};
enum {
@@ -121,6 +149,8 @@
#define BTIF_MEDIA_TIME_TICK (20 * BTIF_MEDIA_NUM_TICK)
#define A2DP_DATA_READ_POLL_MS (BTIF_MEDIA_TIME_TICK / 2)
+#define BTIF_SINK_MEDIA_TIME_TICK (20 * BTIF_MEDIA_NUM_TICK)
+
/* buffer pool */
#define BTIF_MEDIA_AA_POOL_ID GKI_POOL_ID_3
@@ -183,6 +213,13 @@
#define RESET_RATE_COUNTER_THRESHOLD_MS 2000
//#define BTIF_MEDIA_VERBOSE_ENABLED
+/* In case of A2DP SINK, we will delay start by 5 AVDTP Packets*/
+#define MAX_A2DP_DELAYED_START_FRAME_COUNT 5
+#define PACKET_PLAYED_PER_TICK_48 8
+#define PACKET_PLAYED_PER_TICK_44 7
+#define PACKET_PLAYED_PER_TICK_32 5
+#define PACKET_PLAYED_PER_TICK_16 3
+
#ifdef BTIF_MEDIA_VERBOSE_ENABLED
#define VERBOSE(fmt, ...) \
@@ -195,6 +232,13 @@
/*****************************************************************************
** Data types
*****************************************************************************/
+typedef struct
+{
+ UINT16 num_frames_to_be_processed;
+ UINT16 len;
+ UINT16 offset;
+ UINT16 layer_specific;
+} tBT_SBC_HDR;
typedef struct
{
@@ -219,7 +263,9 @@
{
#if (BTA_AV_INCLUDED == TRUE)
BUFFER_Q TxAaQ;
+ BUFFER_Q RxSbcQ;
BOOLEAN is_tx_timer;
+ BOOLEAN is_rx_timer;
UINT16 TxAaMtuSize;
UINT32 timestamp;
UINT8 TxTranscoding;
@@ -231,6 +277,13 @@
void* av_sm_hdl;
UINT8 a2dp_cmd_pending; /* we can have max one command pending */
BOOLEAN tx_flush; /* discards any outgoing data when true */
+ BOOLEAN rx_flush; /* discards any incoming data when true */
+ UINT8 peer_sep;
+ BOOLEAN data_channel_open;
+ UINT8 frames_to_process;
+
+ UINT32 sample_rate;
+ UINT8 channel_count;
#endif
} tBTIF_MEDIA_CB;
@@ -259,13 +312,34 @@
static void btif_a2dp_ctrl_cb(tUIPC_CH_ID ch_id, tUIPC_EVENT event);
static void btif_a2dp_encoder_update(void);
const char* dump_media_event(UINT16 event);
+#ifdef BTA_AVK_INCLUDED
+extern OI_STATUS OI_CODEC_SBC_DecodeFrame(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ const OI_BYTE **frameData,
+ unsigned long *frameBytes,
+ OI_INT16 *pcmData,
+ unsigned long *pcmBytes);
+extern OI_STATUS OI_CODEC_SBC_DecoderReset(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ unsigned long *decoderData,
+ unsigned long decoderDataBytes,
+ OI_UINT8 maxChannels,
+ OI_UINT8 pcmStride,
+ OI_BOOL enhanced);
+#endif
+static void btif_media_flush_q(BUFFER_Q *p_q);
+static void btif_media_task_aa_handle_stop_decoding(void );
+static void btif_media_task_aa_rx_flush(void);
+static BOOLEAN btif_media_task_stop_decoding_req(void);
/*****************************************************************************
** Externs
*****************************************************************************/
static void btif_media_task_handle_cmd(BT_HDR *p_msg);
-static void btif_media_task_handle_media(BT_HDR *p_msg);
+static void btif_media_task_handle_media(BT_HDR*p_msg);
+/* Handle incoming media packets A2DP SINK streaming*/
+#ifdef BTA_AVK_INCLUDED
+static void btif_media_task_handle_inc_media(tBT_SBC_HDR*p_msg);
+#endif
#if (BTA_AV_INCLUDED == TRUE)
static void btif_media_send_aa_frame(void);
@@ -277,56 +351,18 @@
static void btif_media_task_audio_feeding_init(BT_HDR *p_msg);
static void btif_media_task_aa_tx_flush(BT_HDR *p_msg);
static void btif_media_aa_prep_2_send(UINT8 nb_frame);
+#ifdef BTA_AVK_INCLUDED
+static void btif_media_task_aa_handle_decoder_reset(BT_HDR *p_msg);
+static void btif_media_task_aa_handle_clear_track(void);
#endif
-
-
+static void btif_media_task_aa_handle_start_decoding(void );
+#endif
+BOOLEAN btif_media_task_start_decoding_req(void);
+BOOLEAN btif_media_task_clear_track(void);
/*****************************************************************************
** Misc helper functions
*****************************************************************************/
-static void tput_mon(int is_rx, int len, int reset)
-{
- /* only monitor one connection at a time for now */
- static t_stat cur_stat;
- struct timespec now;
- unsigned long long prev_us;
- unsigned long long now_us;
-
- if (reset == TRUE)
- {
- memset(&cur_stat, 0, sizeof(t_stat));
- return;
- }
-
- if (is_rx)
- {
- cur_stat.rx+=len;
- cur_stat.rx_tot+=len;
- }
- else
- {
- cur_stat.tx+=len;
- cur_stat.tx_tot+=len;
- }
- clock_gettime(CLOCK_MONOTONIC, &now);
-
- now_us = now.tv_sec*USEC_PER_SEC + now.tv_nsec/1000;
-
- if ((now_us - cur_stat.ts_prev_us) < TPUT_STATS_INTERVAL_US)
- return;
-
- APPL_TRACE_WARNING4("tput rx:%d, tx:%d (bytes/s) (tot : rx %d, tx %d bytes)",
- (cur_stat.rx*1000000)/((now_us - cur_stat.ts_prev_us)),
- (cur_stat.tx*1000000)/((now_us - cur_stat.ts_prev_us)),
- cur_stat.rx_tot, cur_stat.tx_tot);
-
- /* stats dumped. now reset stats for next interval */
- cur_stat.rx = 0;
- cur_stat.tx = 0;
- cur_stat.ts_prev_us = now_us;
-}
-
-
static void log_tstamps_us(char *comment)
{
#define USEC_PER_SEC 1000000L
@@ -361,6 +397,10 @@
CASE_RETURN_STR(BTIF_MEDIA_FLUSH_AA_RX)
CASE_RETURN_STR(BTIF_MEDIA_AUDIO_FEEDING_INIT)
CASE_RETURN_STR(BTIF_MEDIA_AUDIO_RECEIVING_INIT)
+ CASE_RETURN_STR(BTIF_MEDIA_AUDIO_SINK_CFG_UPDATE)
+ CASE_RETURN_STR(BTIF_MEDIA_AUDIO_SINK_START_DECODING)
+ CASE_RETURN_STR(BTIF_MEDIA_AUDIO_SINK_STOP_DECODING)
+ CASE_RETURN_STR(BTIF_MEDIA_AUDIO_SINK_CLEAR_TRACK)
default:
return "UNKNOWN MEDIA EVENT";
@@ -424,7 +464,6 @@
{
UINT8 cmd = 0;
int n;
-
n = UIPC_Read(UIPC_CH_ID_AV_CTRL, NULL, &cmd, 1);
/* detach on ctrl channel means audioflinger process was terminated */
@@ -472,6 +511,8 @@
/* post start event and wait for audio path to open */
btif_dispatch_sm_event(BTIF_AV_START_STREAM_REQ_EVT, NULL, 0);
+//FIXME
+ a2dp_cmd_acknowledge(A2DP_CTRL_ACK_SUCCESS);
}
else if (btif_av_stream_started_ready())
{
@@ -489,8 +530,7 @@
break;
case A2DP_CTRL_CMD_STOP:
-
- if (btif_media_cb.is_tx_timer == FALSE)
+ if (btif_media_cb.peer_sep == AVDT_TSEP_SNK && btif_media_cb.is_tx_timer == FALSE)
{
/* we are already stopped, just ack back */
a2dp_cmd_acknowledge(A2DP_CTRL_ACK_SUCCESS);
@@ -498,6 +538,7 @@
}
btif_dispatch_sm_event(BTIF_AV_STOP_STREAM_REQ_EVT, NULL, 0);
+ a2dp_cmd_acknowledge(A2DP_CTRL_ACK_SUCCESS);
break;
case A2DP_CTRL_CMD_SUSPEND:
@@ -515,6 +556,17 @@
}
break;
+ case A2DP_CTRL_GET_AUDIO_CONFIG:
+ {
+ uint32_t sample_rate = btif_media_cb.sample_rate;
+ uint8_t channel_count = btif_media_cb.channel_count;
+
+ a2dp_cmd_acknowledge(A2DP_CTRL_ACK_SUCCESS);
+ UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, (UINT8 *)&sample_rate, 4);
+ UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, &channel_count, 1);
+ break;
+ }
+
default:
APPL_TRACE_ERROR1("UNSUPPORTED CMD (%d)", cmd);
a2dp_cmd_acknowledge(A2DP_CTRL_ACK_FAILURE);
@@ -567,11 +619,15 @@
UIPC_Ioctl(UIPC_CH_ID_AV_AUDIO, UIPC_REG_REMOVE_ACTIVE_READSET, NULL);
UIPC_Ioctl(UIPC_CH_ID_AV_AUDIO, UIPC_SET_READ_POLL_TMO,
(void *)A2DP_DATA_READ_POLL_MS);
- /* Start the media task to encode SBC */
- btif_media_task_start_aa_req();
- /* make sure we update any changed sbc encoder params */
- btif_a2dp_encoder_update();
+ if (btif_media_cb.peer_sep == AVDT_TSEP_SNK) {
+ /* Start the media task to encode SBC */
+ btif_media_task_start_aa_req();
+
+ /* make sure we update any changed sbc encoder params */
+ btif_a2dp_encoder_update();
+ }
+ btif_media_cb.data_channel_open = TRUE;
/* ack back when media task is fully started */
break;
@@ -579,6 +635,7 @@
case UIPC_CLOSE_EVT:
a2dp_cmd_acknowledge(A2DP_CTRL_ACK_SUCCESS);
btif_audiopath_detached();
+ btif_media_cb.data_channel_open = FALSE;
break;
default :
@@ -822,11 +879,23 @@
void btif_a2dp_on_idle(void)
{
APPL_TRACE_EVENT0("## ON A2DP IDLE ##");
-
- /* Make sure media task is stopped */
- btif_media_task_stop_aa_req();
+ if (btif_media_cb.peer_sep == AVDT_TSEP_SNK)
+ {
+ /* Make sure media task is stopped */
+ btif_media_task_stop_aa_req();
+ }
bta_av_co_init();
+#ifdef BTA_AVK_INCLUDED
+ if (btif_media_cb.peer_sep == AVDT_TSEP_SRC)
+ {
+ btif_media_cb.rx_flush = TRUE;
+ btif_media_task_aa_rx_flush_req();
+ btif_media_task_stop_decoding_req();
+ btif_media_task_clear_track();
+ APPL_TRACE_DEBUG0("Stopped BT track");
+ }
+#endif
}
/*****************************************************************************
@@ -847,6 +916,113 @@
UIPC_Open(UIPC_CH_ID_AV_AUDIO, btif_a2dp_data_cb);
}
+/*******************************************************************************
+ **
+ ** Function btif_media_task_clear_track
+ **
+ ** Description
+ **
+ ** Returns TRUE is success
+ **
+ *******************************************************************************/
+BOOLEAN btif_media_task_clear_track(void)
+{
+ BT_HDR *p_buf;
+
+ if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR))))
+ {
+ return FALSE;
+ }
+
+ p_buf->event = BTIF_MEDIA_AUDIO_SINK_CLEAR_TRACK;
+
+ GKI_send_msg(BT_MEDIA_TASK, BTIF_MEDIA_TASK_CMD_MBOX, p_buf);
+ return TRUE;
+}
+/*******************************************************************************
+ **
+ ** Function btif_media_task_stop_decoding_req
+ **
+ ** Description
+ **
+ ** Returns TRUE is success
+ **
+ *******************************************************************************/
+BOOLEAN btif_media_task_stop_decoding_req(void)
+{
+ BT_HDR *p_buf;
+
+ if (!btif_media_cb.is_rx_timer)
+ return TRUE; /* if timer is not running no need to send message */
+
+ if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR))))
+ {
+ return FALSE;
+ }
+
+ p_buf->event = BTIF_MEDIA_AUDIO_SINK_STOP_DECODING;
+
+ GKI_send_msg(BT_MEDIA_TASK, BTIF_MEDIA_TASK_CMD_MBOX, p_buf);
+ return TRUE;
+}
+
+/*******************************************************************************
+ **
+ ** Function btif_media_task_start_decoding_req
+ **
+ ** Description
+ **
+ ** Returns TRUE is success
+ **
+ *******************************************************************************/
+BOOLEAN btif_media_task_start_decoding_req(void)
+{
+ BT_HDR *p_buf;
+
+ if(btif_media_cb.is_rx_timer)
+ return FALSE; /* if timer is already running no need to send message */
+
+ if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR))))
+ {
+ return FALSE;
+ }
+
+ p_buf->event = BTIF_MEDIA_AUDIO_SINK_START_DECODING;
+
+ GKI_send_msg(BT_MEDIA_TASK, BTIF_MEDIA_TASK_CMD_MBOX, p_buf);
+ return TRUE;
+}
+
+/*****************************************************************************
+**
+** Function btif_reset_decoder
+**
+** Description
+**
+** Returns
+**
+*******************************************************************************/
+
+void btif_reset_decoder(UINT8 *p_av)
+{
+ APPL_TRACE_EVENT0("btif_reset_decoder");
+ APPL_TRACE_DEBUG6("btif_reset_decoder p_codec_info[%x:%x:%x:%x:%x:%x]",
+ p_av[1], p_av[2], p_av[3],
+ p_av[4], p_av[5], p_av[6]);
+
+ tBTIF_MEDIA_SINK_CFG_UPDATE *p_buf;
+ if (NULL == (p_buf = GKI_getbuf(sizeof(tBTIF_MEDIA_SINK_CFG_UPDATE))))
+ {
+ APPL_TRACE_EVENT0("btif_reset_decoder No Buffer ");
+ return;
+ }
+
+ memcpy(p_buf->codec_info,p_av, AVDT_CODEC_SIZE);
+ p_buf->hdr.event = BTIF_MEDIA_AUDIO_SINK_CFG_UPDATE;
+
+ GKI_send_msg(BT_MEDIA_TASK, BTIF_MEDIA_TASK_CMD_MBOX, p_buf);
+}
+
/*****************************************************************************
**
** Function btif_a2dp_on_started
@@ -932,7 +1108,15 @@
void btif_a2dp_on_stopped(tBTA_AV_SUSPEND *p_av)
{
APPL_TRACE_EVENT0("## ON A2DP STOPPED ##");
-
+ if (btif_media_cb.peer_sep == AVDT_TSEP_SRC) /* Handling for A2DP SINK cases*/
+ {
+ btif_media_cb.rx_flush = TRUE;
+ btif_media_task_aa_rx_flush_req();
+ btif_media_task_stop_decoding_req();
+ UIPC_Close(UIPC_CH_ID_AV_AUDIO);
+ btif_media_cb.data_channel_open = FALSE;
+ return;
+ }
/* allow using this api for other than suspend */
if (p_av != NULL)
{
@@ -970,6 +1154,13 @@
void btif_a2dp_on_suspended(tBTA_AV_SUSPEND *p_av)
{
APPL_TRACE_EVENT0("## ON A2DP SUSPENDED ##");
+ if (btif_media_cb.peer_sep == AVDT_TSEP_SRC)
+ {
+ btif_media_cb.rx_flush = TRUE;
+ btif_media_task_aa_rx_flush_req();
+ btif_media_task_stop_decoding_req();
+ return;
+ }
/* check for status failures */
if (p_av->status != BTA_AV_SUCCESS)
@@ -987,6 +1178,13 @@
btif_media_task_stop_aa_req();
}
+/* when true media task discards any rx frames */
+void btif_a2dp_set_rx_flush(BOOLEAN enable)
+{
+ APPL_TRACE_EVENT1("## DROP RX %d ##", enable);
+ btif_media_cb.rx_flush = enable;
+}
+
/* when true media task discards any tx frames */
void btif_a2dp_set_tx_flush(BOOLEAN enable)
{
@@ -994,39 +1192,75 @@
btif_media_cb.tx_flush = enable;
}
-/*****************************************************************************
-**
-** Function btif_calc_pcmtime
-**
-** Description Calculates the pcmtime equivalent of a datapacket
-**
-** Returns microseconds
-**
-*******************************************************************************/
-
-static int btif_calc_pcmtime(UINT32 bytes_processed)
+#ifdef BTA_AVK_INCLUDED
+/*******************************************************************************
+ **
+ ** Function btif_media_task_avk_handle_timer
+ **
+ ** Description
+ **
+ ** Returns void
+ **
+ *******************************************************************************/
+static void btif_media_task_avk_handle_timer ( void )
{
- int pcm_time_us = 0;
- tBTIF_AV_MEDIA_FEED_CFG *p_cfg;
+ UINT8 count;
+ tBT_SBC_HDR *p_msg;
+ int num_sbc_frames;
+ int num_frames_to_process;
- p_cfg = &btif_media_cb.media_feeding.cfg;
-
- /* calculate corresponding pcm time based on data processed */
- switch(btif_media_cb.media_feeding.format)
+ count = btif_media_cb.RxSbcQ.count;
+ if (0 == count)
{
- case BTIF_AV_CODEC_PCM:
- pcm_time_us = (bytes_processed*1000000)/
- (p_cfg->pcm.num_channel*p_cfg->pcm.sampling_freq*p_cfg->pcm.bit_per_sample/8);
- break;
-
- default :
- APPL_TRACE_ERROR1("mediafeeding format invalid : %d", btif_media_cb.media_feeding.format);
- break;
+ APPL_TRACE_DEBUG0(" QUE EMPTY ");
}
+ else
+ {
+ if (btif_media_cb.rx_flush == TRUE)
+ {
+ btif_media_flush_q(&(btif_media_cb.RxSbcQ));
+ return;
+ }
- return pcm_time_us;
+ num_frames_to_process = btif_media_cb.frames_to_process;
+ APPL_TRACE_DEBUG0(" Process Frames + ");
+
+ do
+ {
+ p_msg = (tBT_SBC_HDR *)GKI_getfirst(&(btif_media_cb.RxSbcQ));
+ if (p_msg == NULL)
+ return;
+ num_sbc_frames = p_msg->num_frames_to_be_processed; /* num of frames in Que Packets */
+ APPL_TRACE_DEBUG1(" Frames left in topmost packet %d", num_sbc_frames);
+ APPL_TRACE_DEBUG1(" Remaining frames to process in tick %d", num_frames_to_process);
+ APPL_TRACE_DEBUG1(" Num of Packets in Que %d", btif_media_cb.RxSbcQ.count);
+
+ if ( num_sbc_frames > num_frames_to_process) /* Que Packet has more frames*/
+ {
+ p_msg->num_frames_to_be_processed= num_frames_to_process;
+ btif_media_task_handle_inc_media(p_msg);
+ p_msg->num_frames_to_be_processed = num_sbc_frames - num_frames_to_process;
+ num_frames_to_process = 0;
+ break;
+ }
+ else /* Que packet has less frames */
+ {
+ btif_media_task_handle_inc_media(p_msg);
+ p_msg = (tBT_SBC_HDR *)GKI_dequeue(&(btif_media_cb.RxSbcQ));
+ if( p_msg == NULL )
+ {
+ APPL_TRACE_ERROR0("Insufficient data in que ");
+ break;
+ }
+ num_frames_to_process = num_frames_to_process - p_msg->num_frames_to_be_processed;
+ GKI_freebuf(p_msg);
+ }
+ }while(num_frames_to_process > 0);
+
+ APPL_TRACE_DEBUG0(" Process Frames - ");
+ }
}
-
+#endif
/*******************************************************************************
**
@@ -1104,8 +1338,6 @@
#if (BTA_AV_INCLUDED == TRUE)
UIPC_Open(UIPC_CH_ID_AV_CTRL , btif_a2dp_ctrl_cb);
#endif
-
-
}
/*******************************************************************************
**
@@ -1152,6 +1384,7 @@
if (event & BTIF_MEDIA_TASK_DATA)
{
+ VERBOSE("================= Received Media Packets %d ===============", event);
/* Process all messages in the queue */
while ((p_msg = (BT_HDR *) GKI_read_mbox(BTIF_MEDIA_TASK_DATA_MBOX)) != NULL)
{
@@ -1165,6 +1398,15 @@
btif_media_task_aa_handle_timer();
}
+ if (event & BTIF_MEDIA_AVK_TASK_TIMER)
+ {
+#ifdef BTA_AVK_INCLUDED
+ /* advance audio timer expiration for a2dp sink */
+ btif_media_task_avk_handle_timer();
+#endif
+ }
+
+
VERBOSE("=============== MEDIA TASK EVENT %d DONE ============", event);
@@ -1223,7 +1465,7 @@
*******************************************************************************/
static void btif_media_flush_q(BUFFER_Q *p_q)
{
- while (GKI_IS_QUEUE_EMPTY(p_q) == FALSE)
+ while (GKI_queue_is_empty(p_q) == FALSE)
{
GKI_freebuf(GKI_dequeue(p_q));
}
@@ -1268,6 +1510,25 @@
case BTIF_MEDIA_UIPC_RX_RDY:
btif_media_task_aa_handle_uipc_rx_rdy();
break;
+ case BTIF_MEDIA_AUDIO_SINK_CFG_UPDATE:
+#ifdef BTA_AVK_INCLUDED
+ btif_media_task_aa_handle_decoder_reset(p_msg);
+#endif
+ break;
+ case BTIF_MEDIA_AUDIO_SINK_START_DECODING:
+ btif_media_task_aa_handle_start_decoding();
+ break;
+ case BTIF_MEDIA_AUDIO_SINK_CLEAR_TRACK:
+#ifdef BTA_AVK_INCLUDED
+ btif_media_task_aa_handle_clear_track();
+#endif
+ break;
+ case BTIF_MEDIA_AUDIO_SINK_STOP_DECODING:
+ btif_media_task_aa_handle_stop_decoding();
+ break;
+ case BTIF_MEDIA_FLUSH_AA_RX:
+ btif_media_task_aa_rx_flush();
+ break;
#endif
default:
APPL_TRACE_ERROR1("ERROR in btif_media_task_handle_cmd unknown event %d", p_msg->event);
@@ -1276,6 +1537,60 @@
VERBOSE("btif_media_task_handle_cmd : %s DONE", dump_media_event(p_msg->event));
}
+#ifdef BTA_AVK_INCLUDED
+/*******************************************************************************
+ **
+ ** Function btif_media_task_handle_inc_media
+ **
+ ** Description
+ **
+ ** Returns void
+ **
+ *******************************************************************************/
+static void btif_media_task_handle_inc_media(tBT_SBC_HDR*p_msg)
+{
+ UINT8 *sbc_start_frame = ((UINT8*)(p_msg + 1) + p_msg->offset + 1);
+ int count;
+ UINT32 pcmBytes, availPcmBytes;
+ OI_INT16 *pcmDataPointer = pcmData; /*Will be overwritten on next packet receipt*/
+ OI_STATUS status;
+ int num_sbc_frames = p_msg->num_frames_to_be_processed;
+ UINT32 sbc_frame_len = p_msg->len - 1;
+ availPcmBytes = 2*sizeof(pcmData);
+
+ if ((btif_media_cb.peer_sep == AVDT_TSEP_SNK) || (btif_media_cb.rx_flush))
+ {
+ APPL_TRACE_DEBUG0(" State Changed happened in this tick ");
+ return;
+ }
+
+ // ignore data if no one is listening
+ if (!btif_media_cb.data_channel_open)
+ return;
+
+ APPL_TRACE_DEBUG2("Number of sbc frames %d, frame_len %d", num_sbc_frames, sbc_frame_len);
+
+ for(count = 0; count < num_sbc_frames && sbc_frame_len != 0; count ++)
+ {
+ pcmBytes = availPcmBytes;
+ status = OI_CODEC_SBC_DecodeFrame(&context, (const OI_BYTE**)&sbc_start_frame,
+ (OI_UINT32 *)&sbc_frame_len,
+ (OI_INT16 *)pcmDataPointer,
+ (OI_UINT32 *)&pcmBytes);
+ if (!OI_SUCCESS(status)) {
+ APPL_TRACE_ERROR1("Decoding failure: %d\n", status);
+ break;
+ }
+ availPcmBytes -= pcmBytes;
+ pcmDataPointer += pcmBytes/2;
+ p_msg->offset += (p_msg->len - 1) - sbc_frame_len;
+ p_msg->len = sbc_frame_len + 1;
+ }
+
+ UIPC_Send(UIPC_CH_ID_AV_AUDIO, 0, (UINT8 *)pcmData, (2*sizeof(pcmData) - availPcmBytes));
+}
+#endif
+
/*******************************************************************************
**
** Function btif_media_task_handle_media
@@ -1285,16 +1600,11 @@
** Returns void
**
*******************************************************************************/
-static void btif_media_task_handle_media(BT_HDR *p_msg)
+static void btif_media_task_handle_media(BT_HDR*p_msg)
{
- APPL_TRACE_ERROR0("ERROR btif_media_task_handle_media: not in use");
-
+ APPL_TRACE_DEBUG0(" btif_media_task_handle_media ");
GKI_freebuf(p_msg);
}
-
-
-
-
#if (BTA_AV_INCLUDED == TRUE)
/*******************************************************************************
**
@@ -1414,6 +1724,32 @@
GKI_send_msg(BT_MEDIA_TASK, BTIF_MEDIA_TASK_CMD_MBOX, p_buf);
return TRUE;
}
+/*******************************************************************************
+ **
+ ** Function btif_media_task_aa_rx_flush_req
+ **
+ ** Description
+ **
+ ** Returns TRUE is success
+ **
+ *******************************************************************************/
+BOOLEAN btif_media_task_aa_rx_flush_req(void)
+{
+ BT_HDR *p_buf;
+
+ if (GKI_queue_is_empty(&(btif_media_cb.RxSbcQ))== TRUE) /* Que is already empty */
+ return TRUE;
+
+ if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR))))
+ {
+ return FALSE;
+ }
+
+ p_buf->event = BTIF_MEDIA_FLUSH_AA_RX;
+
+ GKI_send_msg(BT_MEDIA_TASK, BTIF_MEDIA_TASK_CMD_MBOX, p_buf);
+ return TRUE;
+}
/*******************************************************************************
**
@@ -1437,6 +1773,23 @@
GKI_send_msg(BT_MEDIA_TASK, BTIF_MEDIA_TASK_CMD_MBOX, p_buf);
return TRUE;
}
+/*******************************************************************************
+ **
+ ** Function btif_media_task_aa_rx_flush
+ **
+ ** Description
+ **
+ ** Returns void
+ **
+ *******************************************************************************/
+static void btif_media_task_aa_rx_flush(void)
+{
+ /* Flush all enqueued GKI SBC buffers (encoded) */
+ APPL_TRACE_DEBUG0("btif_media_task_aa_rx_flush");
+
+ btif_media_flush_q(&(btif_media_cb.RxSbcQ));
+}
+
/*******************************************************************************
**
@@ -1756,36 +2109,227 @@
}
}
+int btif_a2dp_get_track_frequency(UINT8 frequency) {
+ int freq = 48000;
+ switch (frequency) {
+ case A2D_SBC_IE_SAMP_FREQ_16:
+ freq = 16000;
+ break;
+ case A2D_SBC_IE_SAMP_FREQ_32:
+ freq = 32000;
+ break;
+ case A2D_SBC_IE_SAMP_FREQ_44:
+ freq = 44100;
+ break;
+ case A2D_SBC_IE_SAMP_FREQ_48:
+ freq = 48000;
+ break;
+ }
+ return freq;
+}
+
+int btif_a2dp_get_track_channel_count(UINT8 channeltype) {
+ int count = 1;
+ switch (channeltype) {
+ case A2D_SBC_IE_CH_MD_MONO:
+ count = 1;
+ break;
+ case A2D_SBC_IE_CH_MD_DUAL:
+ case A2D_SBC_IE_CH_MD_STEREO:
+ case A2D_SBC_IE_CH_MD_JOINT:
+ count = 2;
+ break;
+ }
+ return count;
+}
+
+void btif_a2dp_set_peer_sep(UINT8 sep) {
+ btif_media_cb.peer_sep = sep;
+}
+
/*******************************************************************************
**
- ** Function btif_media_task_uipc_cback
+ ** Function btif_media_task_aa_handle_stop_decoding
**
- ** Description UIPC call back function for synchronous mode only
+ ** Description
**
** Returns void
**
*******************************************************************************/
-static void btif_media_task_uipc_cback(BT_HDR *p_msg)
+static void btif_media_task_aa_handle_stop_decoding(void )
{
- /* Sanity check */
- if (NULL == p_msg)
- {
- return;
- }
-
- /* Just handle RX_EVT */
- if (p_msg->event != UIPC_RX_DATA_EVT)
- {
- return;
- }
-
- p_msg->event = BTIF_MEDIA_UIPC_RX_RDY;
-
- GKI_send_msg(BT_MEDIA_TASK, BTIF_MEDIA_TASK_CMD_MBOX, p_msg);
+ btif_media_cb.is_rx_timer = FALSE;
+ GKI_stop_timer(BTIF_MEDIA_AVK_TASK_TIMER_ID);
}
/*******************************************************************************
**
+ ** Function btif_media_task_aa_handle_start_decoding
+ **
+ ** Description
+ **
+ ** Returns void
+ **
+ *******************************************************************************/
+static void btif_media_task_aa_handle_start_decoding(void )
+{
+ if(btif_media_cb.is_rx_timer == TRUE)
+ return;
+ btif_media_cb.is_rx_timer = TRUE;
+ GKI_start_timer(BTIF_MEDIA_AVK_TASK_TIMER_ID, GKI_MS_TO_TICKS(BTIF_SINK_MEDIA_TIME_TICK), TRUE);
+}
+
+#ifdef BTA_AVK_INCLUDED
+
+static void btif_media_task_aa_handle_clear_track (void)
+{
+ APPL_TRACE_DEBUG0("btif_media_task_aa_handle_clear_track");
+}
+
+/*******************************************************************************
+ **
+ ** Function btif_media_task_aa_handle_decoder_reset
+ **
+ ** Description
+ **
+ ** Returns void
+ **
+ *******************************************************************************/
+static void btif_media_task_aa_handle_decoder_reset(BT_HDR *p_msg)
+{
+ tBTIF_MEDIA_SINK_CFG_UPDATE *p_buf = (tBTIF_MEDIA_SINK_CFG_UPDATE*) p_msg;
+ tA2D_STATUS a2d_status;
+ tA2D_SBC_CIE sbc_cie;
+ OI_STATUS status;
+ UINT32 freq_multiple = 48*20; /* frequency multiple for 20ms of data , initialize with 48K*/
+ UINT32 num_blocks = 16;
+ UINT32 num_subbands = 8;
+
+ APPL_TRACE_DEBUG6("btif_media_task_aa_handle_decoder_reset p_codec_info[%x:%x:%x:%x:%x:%x]",
+ p_buf->codec_info[1], p_buf->codec_info[2], p_buf->codec_info[3],
+ p_buf->codec_info[4], p_buf->codec_info[5], p_buf->codec_info[6]);
+
+ a2d_status = A2D_ParsSbcInfo(&sbc_cie, p_buf->codec_info, FALSE);
+ if (a2d_status != A2D_SUCCESS)
+ {
+ APPL_TRACE_ERROR1("ERROR dump_codec_info A2D_ParsSbcInfo fail:%d", a2d_status);
+ return;
+ }
+
+ btif_media_cb.sample_rate = btif_a2dp_get_track_frequency(sbc_cie.samp_freq);
+ btif_media_cb.channel_count = btif_a2dp_get_track_channel_count(sbc_cie.ch_mode);
+
+ btif_media_cb.rx_flush = FALSE;
+ APPL_TRACE_DEBUG0("Reset to sink role");
+ status = OI_CODEC_SBC_DecoderReset(&context, contextData, sizeof(contextData), 2, 2, FALSE);
+ if (!OI_SUCCESS(status)) {
+ APPL_TRACE_ERROR1("OI_CODEC_SBC_DecoderReset failed with error code %d\n", status);
+ }
+
+ UIPC_Open(UIPC_CH_ID_AV_AUDIO, btif_a2dp_data_cb);
+
+ switch(sbc_cie.samp_freq)
+ {
+ case A2D_SBC_IE_SAMP_FREQ_16:
+ APPL_TRACE_DEBUG1("\tsamp_freq:%d (16000)", sbc_cie.samp_freq);
+ freq_multiple = 16*20;
+ break;
+ case A2D_SBC_IE_SAMP_FREQ_32:
+ APPL_TRACE_DEBUG1("\tsamp_freq:%d (32000)", sbc_cie.samp_freq);
+ freq_multiple = 32*20;
+ break;
+ case A2D_SBC_IE_SAMP_FREQ_44:
+ APPL_TRACE_DEBUG1("\tsamp_freq:%d (44100)", sbc_cie.samp_freq);
+ freq_multiple = 441*2;
+ break;
+ case A2D_SBC_IE_SAMP_FREQ_48:
+ APPL_TRACE_DEBUG1("\tsamp_freq:%d (48000)", sbc_cie.samp_freq);
+ freq_multiple = 48*20;
+ break;
+ default:
+ APPL_TRACE_DEBUG0(" Unknown Frequency ");
+ break;
+ }
+
+ switch(sbc_cie.ch_mode)
+ {
+ case A2D_SBC_IE_CH_MD_MONO:
+ APPL_TRACE_DEBUG1("\tch_mode:%d (Mono)", sbc_cie.ch_mode);
+ break;
+ case A2D_SBC_IE_CH_MD_DUAL:
+ APPL_TRACE_DEBUG1("\tch_mode:%d (DUAL)", sbc_cie.ch_mode);
+ break;
+ case A2D_SBC_IE_CH_MD_STEREO:
+ APPL_TRACE_DEBUG1("\tch_mode:%d (STEREO)", sbc_cie.ch_mode);
+ break;
+ case A2D_SBC_IE_CH_MD_JOINT:
+ APPL_TRACE_DEBUG1("\tch_mode:%d (JOINT)", sbc_cie.ch_mode);
+ break;
+ default:
+ APPL_TRACE_DEBUG0(" Unknown Mode ");
+ break;
+ }
+
+ switch(sbc_cie.block_len)
+ {
+ case A2D_SBC_IE_BLOCKS_4:
+ APPL_TRACE_DEBUG1("\tblock_len:%d (4)", sbc_cie.block_len);
+ num_blocks = 4;
+ break;
+ case A2D_SBC_IE_BLOCKS_8:
+ APPL_TRACE_DEBUG1("\tblock_len:%d (8)", sbc_cie.block_len);
+ num_blocks = 8;
+ break;
+ case A2D_SBC_IE_BLOCKS_12:
+ APPL_TRACE_DEBUG1("\tblock_len:%d (12)", sbc_cie.block_len);
+ num_blocks = 12;
+ break;
+ case A2D_SBC_IE_BLOCKS_16:
+ APPL_TRACE_DEBUG1("\tblock_len:%d (16)", sbc_cie.block_len);
+ num_blocks = 16;
+ break;
+ default:
+ APPL_TRACE_DEBUG0(" Unknown BlockLen ");
+ break;
+ }
+
+ switch(sbc_cie.num_subbands)
+ {
+ case A2D_SBC_IE_SUBBAND_4:
+ APPL_TRACE_DEBUG1("\tnum_subbands:%d (4)", sbc_cie.num_subbands);
+ num_subbands = 4;
+ break;
+ case A2D_SBC_IE_SUBBAND_8:
+ APPL_TRACE_DEBUG1("\tnum_subbands:%d (8)", sbc_cie.num_subbands);
+ num_subbands = 8;
+ break;
+ default:
+ APPL_TRACE_DEBUG0(" Unknown SubBands ");
+ break;
+ }
+
+ switch(sbc_cie.alloc_mthd)
+ {
+ case A2D_SBC_IE_ALLOC_MD_S:
+ APPL_TRACE_DEBUG1("\talloc_mthd:%d (SNR)", sbc_cie.alloc_mthd);
+ break;
+ case A2D_SBC_IE_ALLOC_MD_L:
+ APPL_TRACE_DEBUG1("\talloc_mthd:%d (Loudness)", sbc_cie.alloc_mthd);
+ break;
+ default:
+ APPL_TRACE_DEBUG0(" Unknown Allocation Method");
+ break;
+ }
+
+ APPL_TRACE_DEBUG2("\tBit pool Min:%d Max:%d", sbc_cie.min_bitpool, sbc_cie.max_bitpool);
+
+ btif_media_cb.frames_to_process = ((freq_multiple)/(num_blocks*num_subbands)) + 1;
+ APPL_TRACE_DEBUG1(" Frames to be processed in 20 ms %d",btif_media_cb.frames_to_process);
+}
+#endif
+
+/*******************************************************************************
+ **
** Function btif_media_task_feeding_state_reset
**
** Description Reset the media feeding state
@@ -1931,6 +2475,49 @@
/*******************************************************************************
**
+ ** Function btif_media_sink_enque_buf
+ **
+ ** Description This function is called by the av_co to fill A2DP Sink Queue
+ **
+ **
+ ** Returns size of the queue
+ *******************************************************************************/
+UINT8 btif_media_sink_enque_buf(BT_HDR *p_pkt)
+{
+ tBT_SBC_HDR *p_msg;
+
+ if(btif_media_cb.rx_flush == TRUE) /* Flush enabled, do not enque*/
+ return btif_media_cb.RxSbcQ.count;
+ if(btif_media_cb.RxSbcQ.count == MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ)
+ {
+ GKI_freebuf(GKI_dequeue(&(btif_media_cb.RxSbcQ)));
+ }
+
+ BTIF_TRACE_VERBOSE0("btif_media_sink_enque_buf + ");
+ /* allocate and Queue this buffer */
+ if ((p_msg = (tBT_SBC_HDR *) GKI_getbuf(sizeof(tBT_SBC_HDR) +
+ p_pkt->offset+ p_pkt->len)) != NULL)
+ {
+ memcpy(p_msg, p_pkt, (sizeof(BT_HDR) + p_pkt->offset + p_pkt->len));
+ p_msg->num_frames_to_be_processed = (*((UINT8*)(p_msg + 1) + p_msg->offset)) & 0x0f;
+ BTIF_TRACE_VERBOSE1("btif_media_sink_enque_buf + ", p_msg->num_frames_to_be_processed);
+ GKI_enqueue(&(btif_media_cb.RxSbcQ), p_msg);
+ if(btif_media_cb.RxSbcQ.count == MAX_A2DP_DELAYED_START_FRAME_COUNT)
+ {
+ BTIF_TRACE_DEBUG0(" Initiate Decoding ");
+ btif_media_task_start_decoding_req();
+ }
+ }
+ else
+ {
+ /* let caller deal with a failed allocation */
+ BTIF_TRACE_VERBOSE0("btif_media_sink_enque_buf No Buffer left - ");
+ }
+ return btif_media_cb.RxSbcQ.count;
+}
+
+/*******************************************************************************
+ **
** Function btif_media_aa_readbuf
**
** Description This function is called by the av_co to get the next buffer to send
@@ -2385,3 +2972,4 @@
APPL_TRACE_DEBUG2("\tBit pool Min:%d Max:%d", sbc_cie.min_bitpool, sbc_cie.max_bitpool);
}
+
diff --git a/btif/src/btif_pan.c b/btif/src/btif_pan.c
index 26f77c7..f2a2834 100644
--- a/btif/src/btif_pan.c
+++ b/btif/src/btif_pan.c
@@ -214,16 +214,20 @@
static volatile int btpan_dev_local_role;
static tBTA_PAN_ROLE_INFO bta_panu_info = {PANU_SERVICE_NAME, 0, PAN_SECURITY};
-static tBTA_PAN_ROLE_INFO bta_pan_nap_info = {PAN_NAP_SERVICE_NAME, 0, PAN_SECURITY};
+static tBTA_PAN_ROLE_INFO bta_pan_nap_info = {PAN_NAP_SERVICE_NAME, 1, PAN_SECURITY};
static bt_status_t btpan_enable(int local_role)
{
int bta_pan_role;
BTIF_TRACE_DEBUG1("local_role:%d", local_role);
bta_pan_role = btpan_role_to_bta(local_role);
+#if BTA_PAN_INCLUDED == TRUE
BTA_PanSetRole(bta_pan_role, &bta_panu_info, NULL, &bta_pan_nap_info);
btpan_dev_local_role = local_role;
return BT_STATUS_SUCCESS;
+#else
+ return BT_STATUS_FAIL;
+#endif
}
static int btpan_get_local_role()
@@ -326,6 +330,16 @@
/* ifr.ifr_hwaddr.sa_data[0], ifr.ifr_hwaddr.sa_data[1], ifr.ifr_hwaddr.sa_data[2], */
/* ifr.ifr_hwaddr.sa_data[3], ifr.ifr_hwaddr.sa_data[4], ifr.ifr_hwaddr.sa_data[5]); */
+ /* The IEEE has specified that the most significant bit of the most significant byte is used to
+ * determine a multicast address. If its a 1, that means multicast, 0 means unicast.
+ * Kernel returns an error if we try to set a multicast address for the tun-tap ethernet interface.
+ * Mask this bit to avoid any issue with auto generated address.
+ */
+ if (ifr.ifr_hwaddr.sa_data[0] & 0x01) {
+ BTIF_TRACE_WARNING0("Not a unicast MAC address, force multicast bit flipping");
+ ifr.ifr_hwaddr.sa_data[0] &= ~0x01;
+ }
+
err = ioctl(sk, SIOCSIFHWADDR, (caddr_t)&ifr);
if (err < 0) {
@@ -524,12 +538,13 @@
memset(&p->peer, 0, 6);
}
-static inline int should_forward(tETH_HDR* hdr)
+static inline bool should_forward(tETH_HDR* hdr)
{
- if(ntohs(hdr->h_proto) == ETH_P_IP || ntohs(hdr->h_proto) == ETH_P_ARP)
- return TRUE;
- BTIF_TRACE_DEBUG1("unknown proto:%x", ntohs(hdr->h_proto));
- return FALSE;
+ uint16_t proto = ntohs(hdr->h_proto);
+ if(proto == ETH_P_IP || proto == ETH_P_ARP || proto == ETH_P_IPV6)
+ return true;
+ BTIF_TRACE_DEBUG1("unknown proto:%x", proto);
+ return false;
}
static int forward_bnep(tETH_HDR* eth_hdr, BT_HDR *hdr) {
diff --git a/btif/src/btif_profile_queue.c b/btif/src/btif_profile_queue.c
index b9bbe17..12cec2e 100644
--- a/btif/src/btif_profile_queue.c
+++ b/btif/src/btif_profile_queue.c
@@ -89,7 +89,7 @@
return BT_STATUS_SUCCESS;
p_head->busy = true;
- return p_head->connect_cb(&p_head->bda);
+ return p_head->connect_cb(&p_head->bda, p_head->uuid);
}
static void queue_int_handle_evt(UINT16 event, char *p_param) {
diff --git a/btif/src/btif_rc.c b/btif/src/btif_rc.c
index b3b6e3d..10da9f9 100644
--- a/btif/src/btif_rc.c
+++ b/btif/src/btif_rc.c
@@ -209,6 +209,7 @@
******************************************************************************/
static btif_rc_cb_t btif_rc_cb;
static btrc_callbacks_t *bt_rc_callbacks = NULL;
+static btrc_ctrl_callbacks_t *bt_rc_ctrl_callbacks = NULL;
/*****************************************************************************
** Static functions
@@ -423,6 +424,9 @@
bt_status_t result = BT_STATUS_SUCCESS;
int i;
char bd_str[18];
+#if (AVRC_CTLR_INCLUDED == TRUE)
+ bt_bdaddr_t rc_addr;
+#endif
if(p_rc_open->status == BTA_AV_SUCCESS)
{
@@ -443,6 +447,13 @@
{
init_uinput();
}
+#if (AVRC_CTLR_INCLUDED == TRUE)
+ bdcpy(rc_addr.address, btif_rc_cb.rc_addr);
+ /* report connection state if device is AVRCP target */
+ if (btif_rc_cb.rc_features & BTA_AV_FEAT_RCTG) {
+ HAL_CBACK(bt_rc_ctrl_callbacks, connection_state_cb, TRUE, &rc_addr);
+ }
+#endif
}
else
{
@@ -462,17 +473,34 @@
***************************************************************************/
void handle_rc_disconnect (tBTA_AV_RC_CLOSE *p_rc_close)
{
+#if (AVRC_CTLR_INCLUDED == TRUE)
+ bt_bdaddr_t rc_addr;
+ tBTA_AV_FEAT features;
+#endif
BTIF_TRACE_DEBUG2("%s: rc_handle: %d", __FUNCTION__, p_rc_close->rc_handle);
btif_rc_cb.rc_handle = 0;
btif_rc_cb.rc_connected = FALSE;
memset(btif_rc_cb.rc_addr, 0, sizeof(BD_ADDR));
memset(btif_rc_cb.rc_notif, 0, sizeof(btif_rc_cb.rc_notif));
+#if (AVRC_CTLR_INCLUDED == TRUE)
+ features = btif_rc_cb.rc_features;
+#endif
btif_rc_cb.rc_features = 0;
btif_rc_cb.rc_vol_label=MAX_LABEL;
btif_rc_cb.rc_volume=MAX_VOLUME;
init_all_transactions();
close_uinput();
+#if (AVRC_CTLR_INCLUDED == TRUE)
+ bdcpy(rc_addr.address, btif_rc_cb.rc_addr);
+#endif
+ memset(btif_rc_cb.rc_addr, 0, sizeof(BD_ADDR));
+#if (AVRC_CTLR_INCLUDED == TRUE)
+ /* report connection state if device is AVRCP target */
+ if (features & BTA_AV_FEAT_RCTG) {
+ HAL_CBACK(bt_rc_ctrl_callbacks, connection_state_cb, FALSE, &rc_addr);
+ }
+#endif
}
/***************************************************************************
@@ -575,6 +603,46 @@
p_remote_cmd->rc_id, status);
}
+/***************************************************************************
+ * Function handle_rc_passthrough_rsp
+ *
+ * - Argument: tBTA_AV_REMOTE_RSP passthrough command response
+ *
+ * - Description: Remote control passthrough response handler
+ *
+ ***************************************************************************/
+void handle_rc_passthrough_rsp ( tBTA_AV_REMOTE_RSP *p_remote_rsp)
+{
+#if (AVRC_CTLR_INCLUDED == TRUE)
+ const char *status;
+ if (btif_rc_cb.rc_features & BTA_AV_FEAT_RCTG)
+ {
+ int key_state;
+ if (p_remote_rsp->key_state == AVRC_STATE_RELEASE)
+ {
+ status = "released";
+ key_state = 1;
+ }
+ else
+ {
+ status = "pressed";
+ key_state = 0;
+ }
+
+ BTIF_TRACE_DEBUG3("%s: rc_id=%d status=%s", __FUNCTION__, p_remote_rsp->rc_id, status);
+
+ release_transaction(p_remote_rsp->label);
+ HAL_CBACK(bt_rc_ctrl_callbacks, passthrough_rsp_cb, p_remote_rsp->rc_id, key_state);
+ }
+ else
+ {
+ BTIF_TRACE_ERROR1("%s DUT does not support AVRCP controller role", __FUNCTION__);
+ }
+#else
+ BTIF_TRACE_ERROR1("%s AVRCP controller role is not enabled", __FUNCTION__);
+#endif
+}
+
void handle_uid_changed_notification(tBTA_AV_META_MSG *pmeta_msg, tAVRC_COMMAND *pavrc_command)
{
tAVRC_RESPONSE avrc_rsp = {0};
@@ -721,6 +789,15 @@
handle_rc_passthrough_cmd( (&p_data->remote_cmd) );
}
break;
+#if (AVRC_CTLR_INCLUDED == TRUE)
+ case BTA_AV_REMOTE_RSP_EVT:
+ {
+ BTIF_TRACE_DEBUG2("RSP: rc_id:0x%x key_state:%d", p_data->remote_rsp.rc_id,
+ p_data->remote_rsp.key_state);
+ handle_rc_passthrough_rsp( (&p_data->remote_rsp) );
+ }
+ break;
+#endif
case BTA_AV_RC_FEAT_EVT:
{
BTIF_TRACE_DEBUG1("Peer_features:%x", p_data->rc_feat.peer_features);
@@ -1135,6 +1212,32 @@
return result;
}
+/*******************************************************************************
+**
+** Function init_ctrl
+**
+** Description Initializes the AVRC interface
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+static bt_status_t init_ctrl(btrc_ctrl_callbacks_t* callbacks )
+{
+ BTIF_TRACE_EVENT1("## %s ##", __FUNCTION__);
+ bt_status_t result = BT_STATUS_SUCCESS;
+
+ if (bt_rc_ctrl_callbacks)
+ return BT_STATUS_DONE;
+
+ bt_rc_ctrl_callbacks = callbacks;
+ memset (&btif_rc_cb, 0, sizeof(btif_rc_cb));
+ btif_rc_cb.rc_vol_label=MAX_LABEL;
+ btif_rc_cb.rc_volume=MAX_VOLUME;
+ lbl_init();
+
+ return result;
+}
+
/***************************************************************************
**
** Function get_play_status_rsp
@@ -1479,6 +1582,42 @@
}
+static bt_status_t send_passthrough_cmd(bt_bdaddr_t *bd_addr, uint8_t key_code, uint8_t key_state)
+{
+ tAVRC_STS status = BT_STATUS_UNSUPPORTED;
+#if (AVRC_CTLR_INCLUDED == TRUE)
+ CHECK_RC_CONNECTED
+ rc_transaction_t *p_transaction=NULL;
+ BTIF_TRACE_DEBUG3("%s: key-code: %d, key-state: %d", __FUNCTION__,
+ key_code, key_state);
+ if (btif_rc_cb.rc_features & BTA_AV_FEAT_RCTG)
+ {
+ tAVRC_MSG_PASS avrc_cmd;
+ bt_status_t tran_status = get_transaction(&p_transaction);
+ if(BT_STATUS_SUCCESS == tran_status && NULL != p_transaction)
+ {
+ BTA_AvRemoteCmd(btif_rc_cb.rc_handle, p_transaction->lbl,
+ (tBTA_AV_RC)key_code, (tBTA_AV_STATE)key_state);
+ status = BT_STATUS_SUCCESS;
+ BTIF_TRACE_DEBUG1("%s: succesfully sent passthrough command to BTA", __FUNCTION__);
+ }
+ else
+ {
+ status = BT_STATUS_FAIL;
+ BTIF_TRACE_DEBUG1("%s: error in fetching transaction", __FUNCTION__);
+ }
+ }
+ else
+ {
+ status = BT_STATUS_FAIL;
+ BTIF_TRACE_DEBUG1("%s: feature not supported", __FUNCTION__);
+ }
+#else
+ BTIF_TRACE_DEBUG1("%s: feature not enabled", __FUNCTION__);
+#endif
+ return status;
+}
+
static const btrc_interface_t bt_rc_interface = {
sizeof(bt_rc_interface),
init,
@@ -1495,11 +1634,18 @@
cleanup,
};
+static const btrc_ctrl_interface_t bt_rc_ctrl_interface = {
+ sizeof(bt_rc_ctrl_interface),
+ init_ctrl,
+ send_passthrough_cmd,
+ cleanup,
+};
+
/*******************************************************************************
**
** Function btif_rc_get_interface
**
-** Description Get the AVRCP callback interface
+** Description Get the AVRCP Target callback interface
**
** Returns btav_interface_t
**
@@ -1511,6 +1657,21 @@
}
/*******************************************************************************
+**
+** Function btif_rc_ctrl_get_interface
+**
+** Description Get the AVRCP Controller callback interface
+**
+** Returns btav_interface_t
+**
+*******************************************************************************/
+const btrc_ctrl_interface_t *btif_rc_ctrl_get_interface(void)
+{
+ BTIF_TRACE_EVENT1("%s", __FUNCTION__);
+ return &bt_rc_ctrl_interface;
+}
+
+/*******************************************************************************
** Function initialize_transaction
**
** Description Initializes fields of the transaction structure
diff --git a/btif/src/btif_sock_rfc.c b/btif/src/btif_sock_rfc.c
index d03d7cc..f4a3052 100644
--- a/btif/src/btif_sock_rfc.c
+++ b/btif/src/btif_sock_rfc.c
@@ -102,9 +102,6 @@
static volatile int pth = -1; //poll thread handle
static void jv_dm_cback(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data);
static void cleanup_rfc_slot(rfc_slot_t* rs);
-static inline void close_rfc_connection(int rfc_handle, int server);
-static bt_status_t dm_get_remote_service_record(bt_bdaddr_t *remote_addr,
- bt_uuid_t *uuid);
static void *rfcomm_cback(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data);
static inline BOOLEAN send_app_scn(rfc_slot_t* rs);
static pthread_mutex_t slot_lock;
@@ -283,26 +280,35 @@
int open_handle, int new_listen_handle)
{
rfc_slot_t *accept_rs = alloc_rfc_slot(addr, srv_rs->service_name, srv_rs->service_uuid, srv_rs->scn, 0, FALSE);
- clear_slot_flag(&accept_rs->f);
- accept_rs->f.server = FALSE;
- accept_rs->f.connected = TRUE;
- accept_rs->security = srv_rs->security;
- accept_rs->mtu = srv_rs->mtu;
- accept_rs->role = srv_rs->role;
- accept_rs->rfc_handle = open_handle;
- accept_rs->rfc_port_handle = BTA_JvRfcommGetPortHdl(open_handle);
- //now update listen rfc_handle of server slot
- srv_rs->rfc_handle = new_listen_handle;
- srv_rs->rfc_port_handle = BTA_JvRfcommGetPortHdl(new_listen_handle);
- BTIF_TRACE_DEBUG4("create_srv_accept__rfc_slot(open_handle: 0x%x, new_listen_handle:"
- "0x%x) accept_rs->rfc_handle:0x%x, srv_rs_listen->rfc_handle:0x%x"
- ,open_handle, new_listen_handle, accept_rs->rfc_port_handle, srv_rs->rfc_port_handle);
- asrt(accept_rs->rfc_port_handle != srv_rs->rfc_port_handle);
- //now swap the slot id
- uint32_t new_listen_id = accept_rs->id;
- accept_rs->id = srv_rs->id;
- srv_rs->id = new_listen_id;
- return accept_rs;
+ if( accept_rs)
+ {
+ clear_slot_flag(&accept_rs->f);
+ accept_rs->f.server = FALSE;
+ accept_rs->f.connected = TRUE;
+ accept_rs->security = srv_rs->security;
+ accept_rs->mtu = srv_rs->mtu;
+ accept_rs->role = srv_rs->role;
+ accept_rs->rfc_handle = open_handle;
+ accept_rs->rfc_port_handle = BTA_JvRfcommGetPortHdl(open_handle);
+ //now update listen rfc_handle of server slot
+ srv_rs->rfc_handle = new_listen_handle;
+ srv_rs->rfc_port_handle = BTA_JvRfcommGetPortHdl(new_listen_handle);
+ BTIF_TRACE_DEBUG4("create_srv_accept__rfc_slot(open_handle: 0x%x, new_listen_handle:"
+ "0x%x) accept_rs->rfc_handle:0x%x, srv_rs_listen->rfc_handle:0x%x"
+ ,open_handle, new_listen_handle, accept_rs->rfc_port_handle, srv_rs->rfc_port_handle);
+ asrt(accept_rs->rfc_port_handle != srv_rs->rfc_port_handle);
+ //now swap the slot id
+ uint32_t new_listen_id = accept_rs->id;
+ accept_rs->id = srv_rs->id;
+ srv_rs->id = new_listen_id;
+
+ return accept_rs;
+ }
+ else
+ {
+ APPL_TRACE_ERROR1(" accept_rs is NULL %s", __FUNCTION__);
+ return NULL;
+ }
}
bt_status_t btsock_rfc_listen(const char* service_name, const uint8_t* service_uuid, int channel,
int* sock_fd, int flags)
@@ -334,7 +340,7 @@
if(rs)
{
APPL_TRACE_DEBUG1("BTA_JvCreateRecordByUser:%s", service_name);
- BTA_JvCreateRecordByUser((void *)rs->id);
+ BTA_JvCreateRecordByUser((void *)(intptr_t)rs->id);
*sock_fd = rs->app_fd;
rs->app_fd = -1; //the fd ownership is transferred to app
status = BT_STATUS_SUCCESS;
@@ -364,7 +370,7 @@
{
APPL_TRACE_DEBUG1("connecting to rfcomm channel:%d without service discovery", channel);
if(BTA_JvRfcommConnect(rs->security, rs->role, rs->scn, rs->addr.address,
- rfcomm_cback, (void*)rs->id) == BTA_JV_SUCCESS)
+ rfcomm_cback, (void*)(intptr_t)rs->id) == BTA_JV_SUCCESS)
{
if(send_app_scn(rs))
{
@@ -390,7 +396,7 @@
rfc_slot_t* rs_doing_sdp = find_rfc_slot_requesting_sdp();
if(rs_doing_sdp == NULL)
{
- BTA_JvStartDiscovery((UINT8*)bd_addr->address, 1, &sdp_uuid, (void*)rs->id);
+ BTA_JvStartDiscovery((UINT8*)bd_addr->address, 1, &sdp_uuid, (void*)(intptr_t)rs->id);
rs->f.pending_sdp_request = FALSE;
rs->f.doing_sdp_request = TRUE;
}
@@ -473,7 +479,7 @@
{
if(rs->f.server && !rs->f.closing && rs->rfc_handle)
{
- BTA_JvRfcommStopServer(rs->rfc_handle, (void*)rs->id);
+ BTA_JvRfcommStopServer(rs->rfc_handle, (void*)(uintptr_t)rs->id);
rs->rfc_handle = 0;
}
if(rs->f.server)
@@ -503,7 +509,7 @@
if(rs->rfc_handle && !rs->f.closing && !rs->f.server)
{
APPL_TRACE_DEBUG1("closing rfcomm connection, rfc_handle:0x%x", rs->rfc_handle);
- BTA_JvRfcommClose(rs->rfc_handle, (void*)rs->id);
+ BTA_JvRfcommClose(rs->rfc_handle, (void*)(uintptr_t)rs->id);
rs->rfc_handle = 0;
}
free_rfc_slot_scn(rs);
@@ -688,25 +694,25 @@
switch (event)
{
case BTA_JV_RFCOMM_START_EVT:
- on_srv_rfc_listen_started(&p_data->rfc_start, (uint32_t)user_data);
+ on_srv_rfc_listen_started(&p_data->rfc_start, (uintptr_t)user_data);
break;
case BTA_JV_RFCOMM_CL_INIT_EVT:
- on_cl_rfc_init(&p_data->rfc_cl_init, (uint32_t)user_data);
+ on_cl_rfc_init(&p_data->rfc_cl_init, (uintptr_t)user_data);
break;
case BTA_JV_RFCOMM_OPEN_EVT:
BTA_JvSetPmProfile(p_data->rfc_open.handle,BTA_JV_PM_ID_1,BTA_JV_CONN_OPEN);
- on_cli_rfc_connect(&p_data->rfc_open, (uint32_t)user_data);
+ on_cli_rfc_connect(&p_data->rfc_open, (uintptr_t)user_data);
break;
case BTA_JV_RFCOMM_SRV_OPEN_EVT:
BTA_JvSetPmProfile(p_data->rfc_srv_open.handle,BTA_JV_PM_ALL,BTA_JV_CONN_OPEN);
- new_user_data = (void*)on_srv_rfc_connect(&p_data->rfc_srv_open, (uint32_t)user_data);
+ new_user_data = (void*)(intptr_t)on_srv_rfc_connect(&p_data->rfc_srv_open, (uintptr_t)user_data);
break;
case BTA_JV_RFCOMM_CLOSE_EVT:
- APPL_TRACE_DEBUG1("BTA_JV_RFCOMM_CLOSE_EVT: user_data:%d", (uint32_t)user_data);
- on_rfc_close(&p_data->rfc_close, (uint32_t)user_data);
+ APPL_TRACE_DEBUG1("BTA_JV_RFCOMM_CLOSE_EVT: user_data:%d", (uintptr_t)user_data);
+ on_rfc_close(&p_data->rfc_close, (uintptr_t)user_data);
break;
case BTA_JV_RFCOMM_READ_EVT:
@@ -714,7 +720,7 @@
break;
case BTA_JV_RFCOMM_WRITE_EVT:
- on_rfc_write_done(&p_data->rfc_write, (uint32_t)user_data);
+ on_rfc_write_done(&p_data->rfc_write, (uintptr_t)user_data);
break;
case BTA_JV_RFCOMM_DATA_IND_EVT:
@@ -723,10 +729,10 @@
case BTA_JV_RFCOMM_CONG_EVT:
//on_rfc_cong(&p_data->rfc_cong);
- on_rfc_outgoing_congest(&p_data->rfc_cong, (uint32_t)user_data);
+ on_rfc_outgoing_congest(&p_data->rfc_cong, (uintptr_t)user_data);
break;
default:
- APPL_TRACE_ERROR2("unhandled event %d, slot id:%d", event, (uint32_t)user_data);
+ APPL_TRACE_ERROR2("unhandled event %d, slot id:%d", event, (uintptr_t)user_data);
break;
}
return new_user_data;
@@ -734,7 +740,7 @@
static void jv_dm_cback(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data)
{
- uint32_t id = (uint32_t)user_data;
+ uint32_t id = (uintptr_t)user_data;
APPL_TRACE_DEBUG2("jv_dm_cback: event:%d, slot id:%d", event, id);
switch(event)
{
@@ -746,7 +752,7 @@
{
//now start the rfcomm server after sdp & channel # assigned
BTA_JvRfcommStartServer(rs->security, rs->role, rs->scn, MAX_RFC_SESSION, rfcomm_cback,
- (void*)rs->id);
+ (void*)(uintptr_t)rs->id);
}
else if(rs)
{
@@ -769,7 +775,7 @@
if(rs && rs->f.doing_sdp_request)
{
if(BTA_JvRfcommConnect(rs->security, rs->role, p_data->disc_comp.scn, rs->addr.address,
- rfcomm_cback, (void*)rs->id) == BTA_JV_SUCCESS)
+ rfcomm_cback, (void*)(uintptr_t)rs->id) == BTA_JV_SUCCESS)
{
rs->scn = p_data->disc_comp.scn;
rs->f.doing_sdp_request = FALSE;
@@ -801,7 +807,7 @@
tSDP_UUID sdp_uuid;
sdp_uuid.len = 16;
memcpy(sdp_uuid.uu.uuid128, rs->service_uuid, sizeof(sdp_uuid.uu.uuid128));
- BTA_JvStartDiscovery((UINT8*)rs->addr.address, 1, &sdp_uuid, (void*)rs->id);
+ BTA_JvStartDiscovery((UINT8*)rs->addr.address, 1, &sdp_uuid, (void*)(uintptr_t)rs->id);
rs->f.pending_sdp_request = FALSE;
rs->f.doing_sdp_request = TRUE;
}
@@ -932,7 +938,7 @@
int bta_co_rfc_data_incoming(void *user_data, BT_HDR *p_buf)
{
- uint32_t id = (uint32_t)user_data;
+ uint32_t id = (uintptr_t)user_data;
int ret = 0;
lock_slot(&slot_lock);
rfc_slot_t* rs = find_rfc_slot_by_id(id);
@@ -968,7 +974,7 @@
}
int bta_co_rfc_data_outgoing_size(void *user_data, int *size)
{
- uint32_t id = (uint32_t)user_data;
+ uint32_t id = (uintptr_t)user_data;
int ret = FALSE;
*size = 0;
lock_slot(&slot_lock);
@@ -992,7 +998,7 @@
}
int bta_co_rfc_data_outgoing(void *user_data, UINT8* buf, UINT16 size)
{
- uint32_t id = (uint32_t)user_data;
+ uint32_t id = (uintptr_t)user_data;
int ret = FALSE;
lock_slot(&slot_lock);
rfc_slot_t* rs = find_rfc_slot_by_id(id);
diff --git a/btif/src/btif_sock_thread.c b/btif/src/btif_sock_thread.c
index 475b8de..18c961f 100644
--- a/btif/src/btif_sock_thread.c
+++ b/btif/src/btif_sock_thread.c
@@ -232,7 +232,7 @@
if(h >= 0)
{
init_poll(h);
- if((ts[h].thread_id = create_thread(sock_poll_thread, (void*)h)) != -1)
+ if((ts[h].thread_id = create_thread(sock_poll_thread, (void*)(uintptr_t)h)) != -1)
{
APPL_TRACE_DEBUG2("h:%d, thread id:%d", h, ts[h].thread_id);
ts[h].callback = callback;
@@ -556,7 +556,7 @@
{
struct pollfd pfds[MAX_POLL];
memset(pfds, 0, sizeof(pfds));
- int h = (int)arg;
+ int h = (intptr_t)arg;
for(;;)
{
prepare_poll_fds(h, pfds);
diff --git a/btif/src/btif_storage.c b/btif/src/btif_storage.c
index 8e03c05..b0c2826 100644
--- a/btif/src/btif_storage.c
+++ b/btif/src/btif_storage.c
@@ -1,5 +1,6 @@
/******************************************************************************
*
+ * Copyright (c) 2014 The Android Open Source Project
* Copyright (C) 2009-2012 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -41,7 +42,9 @@
#include "btif_storage.h"
#include "btif_util.h"
#include "bd.h"
+#include "config.h"
#include "gki.h"
+#include "osi.h"
#include "bta_hh_api.h"
#include "btif_hh.h"
@@ -81,9 +84,6 @@
#define BTIF_STORAGE_KEY_AUTOPAIR_DYNAMIC_BLACKLIST_ADDR "DynamicAddressBlacklist"
#define BTIF_AUTO_PAIR_CONF_VALUE_SEPARATOR ","
-#define BTIF_AUTO_PAIR_CONF_SPACE ' '
-#define BTIF_AUTO_PAIR_CONF_COMMENT '#'
-#define BTIF_AUTO_PAIR_CONF_KEY_VAL_DELIMETER "="
/* This is a local property to add a device found */
@@ -186,35 +186,6 @@
/*******************************************************************************
**
-** Function btif_in_make_filename
-**
-** Description Internal helper function to create NVRAM file path
-** from address and filename
-**
-** Returns NVRAM file path if successfull, NULL otherwise
-**
-*******************************************************************************/
-static char* btif_in_make_filename(bt_bdaddr_t *bd_addr, char *fname)
-{
- static char path[256];
- bdstr_t bdstr;
-
- if (fname == NULL)return NULL;
- if (bd_addr)
- {
- sprintf(path, "%s/%s/%s", BTIF_STORAGE_PATH_BLUEDROID,
- bd2str(bd_addr, &bdstr), fname);
- }
- else
- {
- /* local adapter */
- sprintf(path, "%s/LOCAL/%s", BTIF_STORAGE_PATH_BLUEDROID, fname);
- }
-
- return(char*)path;
-}
-/*******************************************************************************
-**
** Function btif_in_split_uuids_string_to_list
**
** Description Internal helper function to split the string of UUIDs
@@ -539,29 +510,6 @@
return BT_STATUS_SUCCESS;
}
-static int hex_str_to_int(const char* str, int size)
-{
- int n = 0;
- char c = *str++;
- while (size-- != 0)
- {
- n <<= 4;
- if (c >= '0' && c <= '9') {
- n |= c - '0';
- }
- else if (c >= 'a' && c <= 'z') {
- n |= c - 'a' + 10;
- }
- else // (c >= 'A' && c <= 'Z')
- {
- n |= c - 'A' + 10;
- }
-
- c = *str++;
- }
- return n;
-}
-
/************************************************************************************
** Externs
************************************************************************************/
@@ -654,6 +602,12 @@
p_uuid+num_uuids);
num_uuids++;
}break;
+ case BTA_HFP_HS_SERVICE_ID:
+ {
+ uuid16_to_uuid128(UUID_SERVCLASS_HF_HANDSFREE,
+ p_uuid+num_uuids);
+ num_uuids++;
+ }break;
}
}
}
@@ -1564,59 +1518,34 @@
** BT_STATUS_FAIL otherwise
**
*******************************************************************************/
-
-bt_status_t btif_storage_load_autopair_device_list()
-{
- char *key_name, *key_value;
- int i=0;
- char linebuf[BTIF_STORAGE_MAX_LINE_SZ];
- char *line;
- FILE *fp;
-
- if(!btif_config_exist("Local", BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST, NULL))
- {
- /* first time loading of auto pair blacklist configuration */
-
- fp = fopen (BTIF_AUTO_PAIR_CONF_FILE, "r");
-
- if (fp == NULL)
- {
- ALOGE("%s: Failed to open auto pair blacklist conf file at %s", __FUNCTION__,BTIF_AUTO_PAIR_CONF_FILE );
- return BT_STATUS_FAIL;
- }
-
- /* read through auto_pairing.conf file and create the key value pairs specific to auto pair blacklist devices */
- while (fgets(linebuf, BTIF_STORAGE_MAX_LINE_SZ, fp) != NULL)
- {
- /* trip leading white spaces */
- while (linebuf[i] == BTIF_AUTO_PAIR_CONF_SPACE)
- i++;
-
- /* skip commented lines */
- if (linebuf[i] == BTIF_AUTO_PAIR_CONF_COMMENT)
- continue;
-
- line = (char*)&(linebuf[i]);
-
- if (line == NULL)
- continue;
-
- key_name = strtok(line, BTIF_AUTO_PAIR_CONF_KEY_VAL_DELIMETER);
-
- if (key_name == NULL)
- continue;
- else if((strcmp(key_name, BTIF_STORAGE_KEY_AUTOPAIR_BLACKLIST_ADDR) == 0) ||
- (strcmp(key_name, BTIF_STORAGE_KEY_AUTOPAIR_BLACKLIST_EXACTNAME) ==0) ||
- (strcmp(key_name, BTIF_STORAGE_KEY_AUTOPAIR_FIXPIN_KBLIST) ==0 ) ||
- (strcmp(key_name, BTIF_STORAGE_KEY_AUTOPAIR_BLACKLIST_PARTIALNAME) == 0) ||
- (strcmp(key_name, BTIF_STORAGE_KEY_AUTOPAIR_DYNAMIC_BLACKLIST_ADDR) == 0))
- {
- key_value = strtok(NULL, BTIF_AUTO_PAIR_CONF_KEY_VAL_DELIMETER);
- btif_config_set_str("Local", BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST, key_name, key_value);
- }
- }
- fclose(fp);
+bt_status_t btif_storage_load_autopair_device_list() {
+ // Configuration has already been loaded. No need to reload.
+ if (btif_config_exist("Local", BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST, NULL)) {
+ return BT_STATUS_SUCCESS;
}
+
+ static const char *key_names[] = {
+ BTIF_STORAGE_KEY_AUTOPAIR_BLACKLIST_ADDR,
+ BTIF_STORAGE_KEY_AUTOPAIR_BLACKLIST_EXACTNAME,
+ BTIF_STORAGE_KEY_AUTOPAIR_FIXPIN_KBLIST,
+ BTIF_STORAGE_KEY_AUTOPAIR_BLACKLIST_PARTIALNAME,
+ BTIF_STORAGE_KEY_AUTOPAIR_DYNAMIC_BLACKLIST_ADDR,
+ };
+
+ config_t *config = config_new(BTIF_AUTO_PAIR_CONF_FILE);
+ if (!config) {
+ ALOGE("%s failed to open auto pair blacklist conf file '%s'.", __func__, BTIF_AUTO_PAIR_CONF_FILE);
+ return BT_STATUS_FAIL;
+ }
+
+ for (size_t i = 0; i < ARRAY_SIZE(key_names); ++i) {
+ const char *value = config_get_string(config, CONFIG_DEFAULT_SECTION, key_names[i], NULL);
+ if (value) {
+ btif_config_set_str("Local", BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST, key_names[i], value);
+ }
+ }
+
+ config_free(config);
return BT_STATUS_SUCCESS;
}
diff --git a/btif/src/btif_util.c b/btif/src/btif_util.c
index 12aa7a9..2a86e12 100644
--- a/btif/src/btif_util.c
+++ b/btif/src/btif_util.c
@@ -1,5 +1,6 @@
/******************************************************************************
*
+ * Copyright (c) 2014 The Android Open Source Project
* Copyright (C) 2009-2012 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -47,6 +48,7 @@
#include "bta_ag_api.h"
#include "bta_av_api.h"
#include "bta_hh_api.h"
+#include "bta_hf_client_api.h"
#include "avrc_defs.h"
@@ -326,6 +328,38 @@
}
}
+const char* dump_hf_client_event(UINT16 event)
+{
+ switch(event)
+ {
+ CASE_RETURN_STR(BTA_HF_CLIENT_ENABLE_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_REGISTER_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_OPEN_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_CLOSE_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_CONN_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_AUDIO_OPEN_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_AUDIO_MSBC_OPEN_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_AUDIO_CLOSE_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_SPK_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_MIC_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_DISABLE_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_IND_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_VOICE_REC_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_OPERATOR_NAME_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_CLIP_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_CCWA_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_AT_RESULT_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_CLCC_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_CNUM_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_BTRH_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_BSIR_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_BINP_EVT)
+ CASE_RETURN_STR(BTA_HF_CLIENT_RING_INDICATION)
+ default:
+ return "UNKNOWN MSG ID";
+ }
+}
+
const char* dump_hh_event(UINT16 event)
{
switch(event)
diff --git a/doc/btsnoop_net.md b/doc/btsnoop_net.md
new file mode 100644
index 0000000..efd1071
--- /dev/null
+++ b/doc/btsnoop_net.md
@@ -0,0 +1,15 @@
+btsnoop_net
+====
+btsnoop_net exposes Bluetooth snoop logs over a local TCP socket which enables
+real-time debugging of HCI data with hcidump.
+
+This feature is enabled by setting `BtSnoopLogOutput=true` in `bt_stack.conf`.
+Once it has been enabled and the stack restarted, bluedroid will listen for
+incoming TCP connections on port 8872.
+
+To use this feature with hcidump on a Linux host, you can run:
+
+```
+ $ adb forward tcp:8872 tcp:8872
+ $ nc localhost 8872 | hcidump -r /dev/stdin
+```
diff --git a/embdrv/Android.mk b/embdrv/Android.mk
new file mode 100755
index 0000000..6e92be4
--- /dev/null
+++ b/embdrv/Android.mk
@@ -0,0 +1,7 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(call all-subdir-makefiles)
+
+# Cleanup our locals
+#bdroid_C_INCLUDES :=
+#bdroid_CFLaGS :=
diff --git a/embdrv/sbc/Android.mk b/embdrv/sbc/Android.mk
new file mode 100755
index 0000000..6e92be4
--- /dev/null
+++ b/embdrv/sbc/Android.mk
@@ -0,0 +1,7 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(call all-subdir-makefiles)
+
+# Cleanup our locals
+#bdroid_C_INCLUDES :=
+#bdroid_CFLaGS :=
diff --git a/embdrv/sbc/decoder/Android.mk b/embdrv/sbc/decoder/Android.mk
new file mode 100755
index 0000000..68fd143
--- /dev/null
+++ b/embdrv/sbc/decoder/Android.mk
@@ -0,0 +1,28 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+# sbc decoder
+LOCAL_SRC_FILES+= \
+ ./srce/alloc.c \
+ ./srce/bitalloc.c \
+ ./srce/bitalloc-sbc.c \
+ ./srce/bitstream-decode.c \
+ ./srce/decoder-oina.c \
+ ./srce/decoder-private.c \
+ ./srce/decoder-sbc.c \
+ ./srce/dequant.c \
+ ./srce/framing.c \
+ ./srce/framing-sbc.c \
+ ./srce/oi_codec_version.c \
+ ./srce/synthesis-sbc.c \
+ ./srce/synthesis-dct8.c \
+ ./srce/synthesis-8-generated.c \
+
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/srce
+
+LOCAL_MODULE:= libbt-qcom_sbc_decoder
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := STATIC_LIBRARIES
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/embdrv/sbc/decoder/include/oi_assert.h b/embdrv/sbc/decoder/include/oi_assert.h
new file mode 100644
index 0000000..35d86cf
--- /dev/null
+++ b/embdrv/sbc/decoder/include/oi_assert.h
@@ -0,0 +1,86 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+#ifndef _OI_ASSERT_H
+#define _OI_ASSERT_H
+/** @file
+ This file provides macros and functions for compile-time and run-time assertions.
+
+ When the OI_DEBUG preprocessor value is defined, the macro OI_ASSERT is compiled into
+ the program, providing for a runtime assertion failure check.
+ C_ASSERT is a macro that can be used to perform compile time checks.
+*/
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+
+/** \addtogroup Debugging Debugging APIs */
+/**@{*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifdef OI_DEBUG
+
+/** The macro OI_ASSERT takes a condition argument. If the asserted condition
+ does not evaluate to true, the OI_ASSERT macro calls the host-dependent function,
+ OI_AssertFail(), which reports the failure and generates a runtime error.
+*/
+void OI_AssertFail(char* file, int line, char* reason);
+
+
+#define OI_ASSERT(condition) \
+ { if (!(condition)) OI_AssertFail(__FILE__, __LINE__, #condition); }
+
+#define OI_ASSERT_FAIL(msg) \
+ { OI_AssertFail(__FILE__, __LINE__, msg); }
+
+#else
+
+
+#define OI_ASSERT(condition)
+#define OI_ASSERT_FAIL(msg)
+
+#endif
+
+
+/**
+ C_ASSERT() can be used to perform many compile-time assertions: type sizes, field offsets, etc.
+ An assertion failure results in compile time error C2118: negative subscript.
+ Unfortunately, this elegant macro doesn't work with GCC, so it's all commented out
+ for now. Perhaps later.....
+*/
+
+#ifndef C_ASSERT
+// #define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
+// #define C_ASSERT(e)
+#endif
+
+
+/*****************************************************************************/
+#ifdef __cplusplus
+}
+#endif
+
+/**@}*/
+
+#endif /* _OI_ASSERT_H */
+
diff --git a/embdrv/sbc/decoder/include/oi_bitstream.h b/embdrv/sbc/decoder/include/oi_bitstream.h
new file mode 100644
index 0000000..df0c10f
--- /dev/null
+++ b/embdrv/sbc/decoder/include/oi_bitstream.h
@@ -0,0 +1,123 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+#ifndef _OI_BITSTREAM_H
+#define _OI_BITSTREAM_H
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+
+/**
+@file
+Function prototypes and macro definitions for manipulating input and output
+bitstreams.
+
+@ingroup codec_internal
+*/
+
+/**
+@addtogroup codec_internal
+@{
+*/
+
+#include "oi_codec_sbc_private.h"
+#include "oi_stddefs.h"
+
+INLINE void OI_BITSTREAM_ReadInit(OI_BITSTREAM *bs, const OI_BYTE *buffer);
+
+INLINE void OI_BITSTREAM_WriteInit(OI_BITSTREAM *bs, OI_BYTE *buffer);
+
+INLINE OI_UINT32 OI_BITSTREAM_ReadUINT(OI_BITSTREAM *bs, OI_UINT bits);
+
+INLINE OI_UINT8 OI_BITSTREAM_ReadUINT4Aligned(OI_BITSTREAM *bs);
+
+INLINE OI_UINT8 OI_BITSTREAM_ReadUINT8Aligned(OI_BITSTREAM *bs);
+
+INLINE void OI_BITSTREAM_WriteUINT(OI_BITSTREAM *bs,
+ OI_UINT16 value,
+ OI_UINT bits);
+
+/*
+ * Use knowledge that the bitstream is aligned to optimize the write of a byte
+ */
+PRIVATE void OI_BITSTREAM_WriteUINT8Aligned(OI_BITSTREAM *bs,
+ OI_UINT8 datum);
+
+/*
+ * Use knowledge that the bitstream is aligned to optimize the write pair of nibbles
+ */
+PRIVATE void OI_BITSTREAM_Write2xUINT4Aligned(OI_BITSTREAM *bs,
+ OI_UINT8 datum1,
+ OI_UINT8 datum2);
+
+/** Internally the bitstream looks ahead in the stream. When
+ * OI_SBC_ReadScalefactors() goes to temporarily break the abstraction, it will
+ * need to know where the "logical" pointer is in the stream.
+ */
+#define OI_BITSTREAM_GetWritePtr(bs) ((bs)->ptr.w - 3)
+#define OI_BITSTREAM_GetReadPtr(bs) ((bs)->ptr.r - 3)
+
+/** This is declared here as a macro because decoder.c breaks the bitsream
+ * encapsulation for efficiency reasons.
+ */
+#define OI_BITSTREAM_READUINT(result, bits, ptr, value, bitPtr) \
+do { \
+ OI_ASSERT((bits) <= 16); \
+ OI_ASSERT((bitPtr) < 16); \
+ OI_ASSERT((bitPtr) >= 8); \
+ \
+ result = (value) << (bitPtr); \
+ result >>= 32 - (bits); \
+ \
+ bitPtr += (bits); \
+ while (bitPtr >= 16) { \
+ value = ((value) << 8) | *ptr++; \
+ bitPtr -= 8; \
+ } \
+ OI_ASSERT((bits == 0) || (result < (1u << (bits)))); \
+} while (0)
+
+
+#define OI_BITSTREAM_WRITEUINT(ptr, value, bitPtr, datum, bits) \
+do {\
+ bitPtr -= bits;\
+ value |= datum << bitPtr;\
+ \
+ while (bitPtr <= 16) {\
+ bitPtr += 8;\
+ *ptr++ = (OI_UINT8)(value >> 24);\
+ value <<= 8;\
+ }\
+} while (0)
+
+#define OI_BITSTREAM_WRITEFLUSH(ptr, value, bitPtr) \
+do {\
+ while (bitPtr < 32) {\
+ bitPtr += 8;\
+ *ptr++ = (OI_UINT8)(value >> 24);\
+ value <<= 8;\
+ }\
+} while (0)
+
+/**
+@}
+*/
+
+#endif /* _OI_BITSTREAM_H */
diff --git a/embdrv/sbc/decoder/include/oi_bt_spec.h b/embdrv/sbc/decoder/include/oi_bt_spec.h
new file mode 100644
index 0000000..b98a582
--- /dev/null
+++ b/embdrv/sbc/decoder/include/oi_bt_spec.h
@@ -0,0 +1,229 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+#ifndef _OI_BT_SPEC_H
+#define _OI_BT_SPEC_H
+/**
+ * @file
+ *
+ * This file contains common definitions from the Bluetooth specification.
+ *
+ */
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+#include "oi_stddefs.h"
+
+/** \addtogroup Misc Miscellaneous APIs */
+/**@{*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** The maximum number of active slaves in a piconet. */
+#define OI_BT_MAX_ACTIVE_SLAVES 7
+
+/** the number of bytes in a Bluetooth device address (BD_ADDR) */
+#define OI_BD_ADDR_BYTE_SIZE 6
+
+/**
+ * 48-bit Bluetooth device address
+ *
+ * Because 48-bit integers may not be supported on all platforms, the
+ * address is defined as an array of bytes. This array is big-endian,
+ * meaning that
+ * - array[0] contains bits 47-40,
+ * - array[1] contains bits 39-32,
+ * - array[2] contains bits 31-24,
+ * - array[3] contains bits 23-16,
+ * - array[4] contains bits 15-8, and
+ * - array[5] contains bits 7-0.
+ */
+typedef struct {
+ OI_UINT8 addr[OI_BD_ADDR_BYTE_SIZE] ; /**< Bluetooth device address represented as an array of 8-bit values */
+} OI_BD_ADDR ;
+
+/**
+ * @name Data types for working with UUIDs
+ * UUIDs are 16 bytes (128 bits).
+ *
+ * To avoid having to pass around 128-bit values all the time, 32-bit and 16-bit
+ * UUIDs are defined, along with a mapping from the shorter versions to the full
+ * version.
+ *
+ * @{
+ */
+
+/**
+ * 16-bit representation of a 128-bit UUID
+ */
+typedef OI_UINT16 OI_UUID16;
+
+/**
+ * 32-bit representation of a 128-bit UUID
+ */
+typedef OI_UINT32 OI_UUID32;
+
+/**
+ * number of bytes in a 128 bit UUID
+ */
+#define OI_BT_UUID128_SIZE 16
+
+/**
+ * number of bytes in IPv6 style addresses
+ */
+#define OI_BT_IPV6ADDR_SIZE 16
+
+/**
+ * type definition for a 128-bit UUID
+ *
+ * To simplify conversion between 128-bit UUIDs and 16-bit and 32-bit UUIDs,
+ * the most significant 32 bits are stored with the same endian-ness as is
+ * native on the target (local) device. The remainder of the 128-bit UUID is
+ * stored as bytes in big-endian order.
+ */
+typedef struct {
+ OI_UINT32 ms32bits; /**< most significant 32 bits of 128-bit UUID */
+ OI_UINT8 base[OI_BT_UUID128_SIZE - sizeof(OI_UINT32)]; /**< remainder of 128-bit UUID, array of 8-bit values */
+} OI_UUID128;
+
+/** @} */
+
+/** number of bytes in a link key */
+#define OI_BT_LINK_KEY_SIZE 16
+
+/**
+ * type definition for a baseband link key
+ *
+ * Because 128-bit integers may not be supported on all platforms, we define
+ * link keys as an array of bytes. Unlike the Bluetooth device address,
+ * the link key is stored in little-endian order, meaning that
+ * - array[0] contains bits 0 - 7,
+ * - array[1] contains bits 8 - 15,
+ * - array[2] contains bits 16 - 23,
+ * - array[3] contains bits 24 - 31,
+ * - array[4] contains bits 32 - 39,
+ * - array[5] contains bits 40 - 47,
+ * - array[6] contains bits 48 - 55,
+ * - array[7] contains bits 56 - 63,
+ * - array[8] contains bits 64 - 71,
+ * - array[9] contains bits 72 - 79,
+ * - array[10] contains bits 80 - 87,
+ * - array[11] contains bits 88 - 95,
+ * - array[12] contains bits 96 - 103,
+ * - array[13] contains bits 104- 111,
+ * - array[14] contains bits 112- 119, and
+ * - array[15] contains bits 120- 127.
+ */
+typedef struct {
+ OI_UINT8 key[OI_BT_LINK_KEY_SIZE] ; /**< link key represented as an array of 8-bit values */
+} OI_LINK_KEY ;
+
+
+/** Out-of-band data size - C and R values are 16-bytes each */
+#define OI_BT_OOB_NUM_BYTES 16
+
+typedef struct {
+ OI_UINT8 value[OI_BT_OOB_NUM_BYTES] ; /**< same struct used for C and R values */
+} OI_OOB_DATA ;
+
+
+/**
+ * link key types
+ */
+typedef enum {
+ OI_LINK_KEY_TYPE_COMBO = 0, /**< combination key */
+ OI_LINK_KEY_TYPE_LOCAL_UNIT = 1, /**< local unit key */
+ OI_LINK_KEY_TYPE_REMOTE_UNIT = 2, /**< remote unit key */
+ OI_LINK_KEY_TYPE_DEBUG_COMBO = 3, /**< debug combination key */
+ OI_LINK_KEY_TYPE_UNAUTHENTICATED = 4, /**< Unauthenticated */
+ OI_LINK_KEY_TYPE_AUTHENTICATED = 5, /**< Authenticated */
+ OI_LINK_KEY_TYPE_CHANGED_COMBO = 6 /**< Changed */
+
+} OI_BT_LINK_KEY_TYPE ;
+
+
+/** amount of space allocated for a PIN (personal indentification number) in bytes */
+#define OI_BT_PIN_CODE_SIZE 16
+
+/** data type for a PIN (PINs are treated as strings, so endianness does not apply.) */
+typedef struct {
+ OI_UINT8 pin[OI_BT_PIN_CODE_SIZE] ; /**< PIN represented as an array of 8-bit values */
+} OI_PIN_CODE ;
+
+/** maximum number of SCO connections per device, which is 3 as of version 2.0+EDR
+ of the Bluetooth specification (see sec 4.3 of vol 2 part B) */
+#define OI_BT_MAX_SCO_CONNECTIONS 3
+
+/** data type for clock offset */
+typedef OI_UINT16 OI_BT_CLOCK_OFFSET ;
+
+/** data type for a LM handle */
+typedef OI_UINT16 OI_HCI_LM_HANDLE;
+
+/** opaque data type for a SCO or ACL connection handle */
+typedef struct _OI_HCI_CONNECTION *OI_HCI_CONNECTION_HANDLE;
+
+/** data type for HCI Error Code, as defined in oi_hcispec.h */
+typedef OI_UINT8 OI_HCI_ERROR_CODE ;
+
+/**
+ * The Bluetooth device type is indicated by a 24-bit bitfield, represented as a
+ * 32-bit number in the stack. The bit layout and values for device class are specified
+ * in the file oi_bt_assigned_nos.h and in the Bluetooth "Assigned Numbers" specification
+ * at http://www.bluetooth.org/assigned-numbers/.
+ */
+typedef OI_UINT32 OI_BT_DEVICE_CLASS ;
+
+#define OI_BT_DEV_CLASS_FORMAT_MASK 0x000003 /**< Bits 0-1 contain format type. */
+#define OI_BT_DEV_CLASS_MINOR_DEVICE_MASK 0x0000FC /**< Bits 2-7 contain minor device class value. */
+#define OI_BT_DEV_CLASS_MAJOR_DEVICE_MASK 0x001F00 /**< Bits 8-12 contain major device class value. */
+#define OI_BT_DEV_CLASS_MAJOR_SERVICE_MASK 0xFFE000 /**< Bits 13-23 contain major service class value. */
+
+/** There is currently only one device class format defined, type 00. */
+#define OI_BT_DEV_CLASS_FORMAT_TYPE 00
+
+/** Bit 13 in device class indicates limited discoverability mode (GAP v2.0+EDR, section 4.1.2.2) */
+#define OI_BT_DEV_CLASS_LIMITED_DISCO_BIT BIT13
+
+/** macro to test validity of the Device Class Format */
+#define OI_BT_VALID_DEVICE_CLASS_FORMAT(class) (OI_BT_DEV_CLASS_FORMAT_TYPE == ((class) & OI_BT_DEV_CLASS_FORMAT_MASK))
+
+/** the time between baseband clock ticks, currently 625 microseconds (one slot) */
+#define OI_BT_TICK 625
+/** some macros to convert to/from baseband clock ticks - use no floating point! */
+#define OI_SECONDS_TO_BT_TICKS(secs) ((secs)*1600)
+#define OI_BT_TICKS_TO_SECONDS(ticks) ((ticks)/1600)
+#define OI_MSECS_TO_BT_TICKS(msecs) (((msecs)*8)/5)
+#define OI_BT_TICKS_TO_MSECS(ticks) (((ticks)*5)/8)
+
+/** EIR byte order */
+#define OI_EIR_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/**@}*/
+
+/*****************************************************************************/
+#endif /* _OI_BT_SPEC_H */
diff --git a/embdrv/sbc/decoder/include/oi_codec_sbc.h b/embdrv/sbc/decoder/include/oi_codec_sbc.h
new file mode 100644
index 0000000..ff5e6c1
--- /dev/null
+++ b/embdrv/sbc/decoder/include/oi_codec_sbc.h
@@ -0,0 +1,484 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+#ifndef _OI_CODEC_SBC_CORE_H
+#define _OI_CODEC_SBC_CORE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+@file
+Declarations of codec functions, data types, and macros.
+
+@ingroup codec_lib
+*/
+
+/**
+@addtogroup codec_lib
+@{
+*/
+
+/* Non-BM3 users of of the codec must include oi_codec_sbc_bm3defs.h prior to
+ * including this file, or else these includes will fail because the BM3 SDK is
+ * not in the include path */
+#ifndef _OI_CODEC_SBC_BM3DEFS_H
+#include "oi_stddefs.h"
+#include "oi_status.h"
+#endif
+
+#include <stdint.h>
+
+#define SBC_MAX_CHANNELS 2
+#define SBC_MAX_BANDS 8
+#define SBC_MAX_BLOCKS 16
+#define SBC_MIN_BITPOOL 2 /**< Minimum size of the bit allocation pool used to encode the stream */
+#define SBC_MAX_BITPOOL 250 /**< Maximum size of the bit allocation pool used to encode the stream */
+#define SBC_MAX_ONE_CHANNEL_BPS 320000
+#define SBC_MAX_TWO_CHANNEL_BPS 512000
+
+
+#define SBC_WBS_BITRATE 62000
+#define SBC_WBS_BITPOOL 27
+#define SBC_WBS_NROF_BLOCKS 16
+#define SBC_WBS_FRAME_LEN 62
+#define SBC_WBS_SAMPLES_PER_FRAME 128
+
+
+#define SBC_HEADER_LEN 4
+#define SBC_MAX_FRAME_LEN (SBC_HEADER_LEN + \
+ ((SBC_MAX_BANDS * SBC_MAX_CHANNELS / 2) + \
+ (SBC_MAX_BANDS + SBC_MAX_BLOCKS * SBC_MAX_BITPOOL + 7)/8))
+#define SBC_MAX_SAMPLES_PER_FRAME (SBC_MAX_BANDS * SBC_MAX_BLOCKS)
+
+#define SBC_MAX_SCALEFACTOR_BYTES ((4*(SBC_MAX_CHANNELS * SBC_MAX_BANDS) + 7)/8)
+
+#define OI_SBC_SYNCWORD 0x9c
+#define OI_SBC_ENHANCED_SYNCWORD 0x9d
+
+/**@name Sampling frequencies */
+/**@{*/
+#define SBC_FREQ_16000 0 /**< The sampling frequency is 16 kHz. One possible value for the @a frequency parameter of OI_CODEC_SBC_EncoderConfigure() */
+#define SBC_FREQ_32000 1 /**< The sampling frequency is 32 kHz. One possible value for the @a frequency parameter of OI_CODEC_SBC_EncoderConfigure() */
+#define SBC_FREQ_44100 2 /**< The sampling frequency is 44.1 kHz. One possible value for the @a frequency parameter of OI_CODEC_SBC_EncoderConfigure() */
+#define SBC_FREQ_48000 3 /**< The sampling frequency is 48 kHz. One possible value for the @a frequency parameter of OI_CODEC_SBC_EncoderConfigure() */
+/**@}*/
+
+/**@name Channel modes */
+/**@{*/
+#define SBC_MONO 0 /**< The mode of the encoded channel is mono. One possible value for the @a mode parameter of OI_CODEC_SBC_EncoderConfigure() */
+#define SBC_DUAL_CHANNEL 1 /**< The mode of the encoded channel is dual-channel. One possible value for the @a mode parameter of OI_CODEC_SBC_EncoderConfigure() */
+#define SBC_STEREO 2 /**< The mode of the encoded channel is stereo. One possible value for the @a mode parameter of OI_CODEC_SBC_EncoderConfigure() */
+#define SBC_JOINT_STEREO 3 /**< The mode of the encoded channel is joint stereo. One possible value for the @a mode parameter of OI_CODEC_SBC_EncoderConfigure() */
+/**@}*/
+
+/**@name Subbands */
+/**@{*/
+#define SBC_SUBBANDS_4 0 /**< The encoded stream has 4 subbands. One possible value for the @a subbands parameter of OI_CODEC_SBC_EncoderConfigure()*/
+#define SBC_SUBBANDS_8 1 /**< The encoded stream has 8 subbands. One possible value for the @a subbands parameter of OI_CODEC_SBC_EncoderConfigure() */
+/**@}*/
+
+/**@name Block lengths */
+/**@{*/
+#define SBC_BLOCKS_4 0 /**< A block size of 4 blocks was used to encode the stream. One possible value for the @a blocks parameter of OI_CODEC_SBC_EncoderConfigure() */
+#define SBC_BLOCKS_8 1 /**< A block size of 8 blocks was used to encode the stream is. One possible value for the @a blocks parameter of OI_CODEC_SBC_EncoderConfigure() */
+#define SBC_BLOCKS_12 2 /**< A block size of 12 blocks was used to encode the stream. One possible value for the @a blocks parameter of OI_CODEC_SBC_EncoderConfigure() */
+#define SBC_BLOCKS_16 3 /**< A block size of 16 blocks was used to encode the stream. One possible value for the @a blocks parameter of OI_CODEC_SBC_EncoderConfigure() */
+/**@}*/
+
+/**@name Bit allocation methods */
+/**@{*/
+#define SBC_LOUDNESS 0 /**< The bit allocation method. One possible value for the @a loudness parameter of OI_CODEC_SBC_EncoderConfigure() */
+#define SBC_SNR 1 /**< The bit allocation method. One possible value for the @a loudness parameter of OI_CODEC_SBC_EncoderConfigure() */
+/**@}*/
+
+/**
+@}
+
+@addtogroup codec_internal
+@{
+*/
+
+typedef OI_INT16 SBC_BUFFER_T;
+
+
+/** Used internally. */
+typedef struct {
+ OI_UINT16 frequency; /**< The sampling frequency. Input parameter. */
+ OI_UINT8 freqIndex;
+
+ OI_UINT8 nrof_blocks; /**< The block size used to encode the stream. Input parameter. */
+ OI_UINT8 blocks;
+
+
+ OI_UINT8 nrof_subbands; /**< The number of subbands of the encoded stream. Input parameter. */
+ OI_UINT8 subbands;
+
+ OI_UINT8 mode; /**< The mode of the encoded channel. Input parameter. */
+ OI_UINT8 nrof_channels; /**< The number of channels of the encoded stream. */
+
+ OI_UINT8 alloc; /**< The bit allocation method. Input parameter. */
+ OI_UINT8 bitpool; /**< Size of the bit allocation pool used to encode the stream. Input parameter. */
+ OI_UINT8 crc; /**< Parity check byte used for error detection. */
+ OI_UINT8 join; /**< Whether joint stereo has been used. */
+ OI_UINT8 enhanced;
+ OI_UINT8 min_bitpool; /**< This value is only used when encoding. SBC_MAX_BITPOOL if variable
+ bitpools are disallowed, otherwise the minimum bitpool size that will
+ be used by the bit allocator. */
+
+ OI_UINT8 cachedInfo; /**< Information about the previous frame */
+} OI_CODEC_SBC_FRAME_INFO;
+
+/** Used internally. */
+typedef struct {
+ const OI_CHAR *codecInfo;
+ OI_CODEC_SBC_FRAME_INFO frameInfo;
+ OI_INT8 scale_factor[SBC_MAX_CHANNELS*SBC_MAX_BANDS];
+ OI_UINT32 frameCount;
+ OI_INT32 *subdata;
+
+ SBC_BUFFER_T *filterBuffer[SBC_MAX_CHANNELS];
+ OI_INT32 filterBufferLen;
+ OI_UINT filterBufferOffset;
+
+ union {
+ OI_UINT8 uint8[SBC_MAX_CHANNELS*SBC_MAX_BANDS];
+ OI_UINT32 uint32[SBC_MAX_CHANNELS*SBC_MAX_BANDS/4];
+ } bits;
+ OI_UINT8 maxBitneed; /**< Running maximum bitneed */
+ OI_BYTE formatByte;
+ OI_UINT8 pcmStride;
+ OI_UINT8 maxChannels;
+} OI_CODEC_SBC_COMMON_CONTEXT;
+
+
+/*
+ * A smaller value reduces RAM usage at the expense of increased CPU usage. Values in the range
+ * 27..50 are recommended, beyond 50 there is a diminishing return on reduced CPU usage.
+ */
+#define SBC_CODEC_MIN_FILTER_BUFFERS 16
+#define SBC_CODEC_FAST_FILTER_BUFFERS 27
+
+/* Expands to the number of OI_UINT32s needed to ensure enough memory to encode
+ * or decode streams of numChannels channels, using numBuffers buffers.
+ * Example:
+ * OI_UINT32 decoderData[CODEC_DATA_WORDS(SBC_MAX_CHANNELS, SBC_DECODER_FAST_SYNTHESIS_BUFFERS)];
+ * */
+#define CODEC_DATA_WORDS(numChannels, numBuffers) \
+ ((\
+ (sizeof(OI_INT32) * SBC_MAX_BLOCKS * numChannels * SBC_MAX_BANDS) \
+ + (sizeof(SBC_BUFFER_T) * SBC_MAX_CHANNELS * SBC_MAX_BANDS * numBuffers) \
+ + (sizeof (OI_UINT32) - 1) \
+ ) / sizeof(OI_UINT32))
+
+/** Opaque parameter to decoding functions; maintains decoder context. */
+typedef struct {
+ OI_CODEC_SBC_COMMON_CONTEXT common;
+ OI_UINT8 limitFrameFormat; /* Boolean, set by OI_CODEC_SBC_DecoderLimit() */
+ OI_UINT8 restrictSubbands;
+ OI_UINT8 enhancedEnabled;
+ OI_UINT8 bufferedBlocks;
+} OI_CODEC_SBC_DECODER_CONTEXT;
+
+typedef struct {
+ OI_UINT32 data[CODEC_DATA_WORDS(1, SBC_CODEC_FAST_FILTER_BUFFERS)];
+} OI_CODEC_SBC_CODEC_DATA_MONO;
+
+typedef struct {
+ OI_UINT32 data[CODEC_DATA_WORDS(2, SBC_CODEC_FAST_FILTER_BUFFERS)];
+} OI_CODEC_SBC_CODEC_DATA_STEREO;
+
+/**
+@}
+
+@addtogroup codec_lib
+@{
+*/
+
+/**
+ * This function resets the decoder. The context must be reset when
+ * changing streams, or if the following stream parameters change:
+ * number of subbands, stereo mode, or frequency.
+ *
+ * @param context Pointer to the decoder context structure to be reset.
+ *
+ * @param enhanced If true, enhanced SBC operation is enabled. If enabled,
+ * the codec will recognize the alternative syncword for
+ * decoding an enhanced SBC stream. Enhancements should not
+ * be enabled unless the stream is known to be generated
+ * by an enhanced encoder, or there is a small possibility
+ * for decoding glitches if synchronization were to be lost.
+ */
+OI_STATUS OI_CODEC_SBC_DecoderReset(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ OI_UINT32 *decoderData,
+ OI_UINT32 decoderDataBytes,
+ OI_UINT8 maxChannels,
+ OI_UINT8 pcmStride,
+ OI_BOOL enhanced);
+
+/**
+ * This function restricts the kind of SBC frames that the Decoder will
+ * process. Its use is optional. If used, it must be called after
+ * calling OI_CODEC_SBC_DecoderReset(). After it is called, any calls
+ * to OI_CODEC_SBC_DecodeFrame() with SBC frames that do not conform
+ * to the Subband and Enhanced SBC setting will be rejected with an
+ * OI_STATUS_INVALID_PARAMETERS return.
+ *
+ * @param context Pointer to the decoder context structure to be limited.
+ *
+ * @param enhanced If true, all frames passed to the decoder must be
+ * Enhanced SBC frames. If false, all frames must be
+ * standard SBC frames.
+ *
+ * @param subbands May be set to SBC_SUBBANDS_4 or SBC_SUBBANDS_8. All
+ * frames passed to the decoder must be encoded with
+ * the requested number of subbands.
+ *
+ */
+OI_STATUS OI_CODEC_SBC_DecoderLimit(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ OI_BOOL enhanced,
+ OI_UINT8 subbands);
+
+/**
+ * This function sets the decoder parameters for a raw decode where the decoder parameters are not
+ * available in the sbc data stream. OI_CODEC_SBC_DecoderReset must be called
+ * prior to calling this function.
+ *
+ * @param context Decoder context structure. This must be the context must be
+ * used each time a frame is decoded.
+ *
+ * @param enhanced Set to TRUE to enable Qualcomm proprietary
+ * quality enhancements.
+ *
+ * @param frequency One of SBC_FREQ_16000, SBC_FREQ_32000, SBC_FREQ_44100,
+ * SBC_FREQ_48000
+ *
+ * @param mode One of SBC_MONO, SBC_DUAL_CHANNEL, SBC_STEREO,
+ * SBC_JOINT_STEREO
+ *
+ * @param subbands One of SBC_SUBBANDS_4, SBC_SUBBANDS_8
+ *
+ * @param blocks One of SBC_BLOCKS_4, SBC_BLOCKS_8, SBC_BLOCKS_12,
+ * SBC_BLOCKS_16
+ *
+ * @param alloc One of SBC_LOUDNESS, SBC_SNR
+ *
+ * @param maxBitpool The maximum bitpool size for this context
+ */
+OI_STATUS OI_CODEC_SBC_DecoderConfigureRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ OI_BOOL enhanced,
+ OI_UINT8 frequency,
+ OI_UINT8 mode,
+ OI_UINT8 subbands,
+ OI_UINT8 blocks,
+ OI_UINT8 alloc,
+ OI_UINT8 maxBitpool);
+
+/**
+ * Decode one SBC frame. The frame has no header bytes. The context must have been previously
+ * initialized by calling OI_CODEC_SBC_DecoderConfigureRaw().
+ *
+ * @param context Pointer to a decoder context structure. The same context
+ * must be used each time when decoding from the same stream.
+ *
+ * @param bitpool The actual bitpool size for this frame. Must be <= the maxbitpool specified
+ * in the call to OI_CODEC_SBC_DecoderConfigureRaw(),
+ *
+ * @param frameData Address of a pointer to the SBC data to decode. This
+ * value will be updated to point to the next frame after
+ * successful decoding.
+ *
+ * @param frameBytes Pointer to a UINT32 containing the number of available
+ * bytes of frame data. This value will be updated to reflect
+ * the number of bytes remaining after a decoding operation.
+ *
+ * @param pcmData Address of an array of OI_INT16 pairs, which will be
+ * populated with the decoded audio data. This address
+ * is not updated.
+ *
+ * @param pcmBytes Pointer to a UINT32 in/out parameter. On input, it
+ * should contain the number of bytes available for pcm
+ * data. On output, it will contain the number of bytes
+ * written. Note that this differs from the semantics of
+ * frameBytes.
+ */
+OI_STATUS OI_CODEC_SBC_DecodeRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ OI_UINT8 bitpool,
+ const OI_BYTE **frameData,
+ OI_UINT32 *frameBytes,
+ OI_INT16 *pcmData,
+ OI_UINT32 *pcmBytes);
+
+/**
+ * Decode one SBC frame.
+ *
+ * @param context Pointer to a decoder context structure. The same context
+ * must be used each time when decoding from the same stream.
+ *
+ * @param frameData Address of a pointer to the SBC data to decode. This
+ * value will be updated to point to the next frame after
+ * successful decoding.
+ *
+ * @param frameBytes Pointer to a UINT32 containing the number of available
+ * bytes of frame data. This value will be updated to reflect
+ * the number of bytes remaining after a decoding operation.
+ *
+ * @param pcmData Address of an array of OI_INT16 pairs, which will be
+ * populated with the decoded audio data. This address
+ * is not updated.
+ *
+ * @param pcmBytes Pointer to a UINT32 in/out parameter. On input, it
+ * should contain the number of bytes available for pcm
+ * data. On output, it will contain the number of bytes
+ * written. Note that this differs from the semantics of
+ * frameBytes.
+ */
+OI_STATUS OI_CODEC_SBC_DecodeFrame(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ const OI_BYTE **frameData,
+ OI_UINT32 *frameBytes,
+ OI_INT16 *pcmData,
+ OI_UINT32 *pcmBytes);
+
+/**
+ * Calculate the number of SBC frames but don't decode. CRC's are not checked,
+ * but the Sync word is found prior to count calculation.
+ *
+ * @param frameData Pointer to the SBC data.
+ *
+ * @param frameBytes Number of bytes avaiable in the frameData buffer
+ *
+ */
+OI_UINT8 OI_CODEC_SBC_FrameCount(OI_BYTE *frameData,
+ OI_UINT32 frameBytes);
+
+/**
+ * Analyze an SBC frame but don't do the decode.
+ *
+ * @param context Pointer to a decoder context structure. The same context
+ * must be used each time when decoding from the same stream.
+ *
+ * @param frameData Address of a pointer to the SBC data to decode. This
+ * value will be updated to point to the next frame after
+ * successful decoding.
+ *
+ * @param frameBytes Pointer to a UINT32 containing the number of available
+ * bytes of frame data. This value will be updated to reflect
+ * the number of bytes remaining after a decoding operation.
+ *
+ */
+OI_STATUS OI_CODEC_SBC_SkipFrame(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ const OI_BYTE **frameData,
+ OI_UINT32 *frameBytes);
+
+/* Common functions */
+
+/**
+ Calculate the frame length.
+
+ @param frame The frame whose length to calculate
+
+ @return the length of an individual encoded frame in
+ bytes
+ */
+OI_UINT16 OI_CODEC_SBC_CalculateFramelen(OI_CODEC_SBC_FRAME_INFO *frame);
+
+
+/**
+ * Calculate the maximum bitpool size that fits within a given frame length.
+ *
+ * @param frame The frame to calculate the bitpool size for
+ * @param frameLen The frame length to fit the bitpool to
+ *
+ * @return the maximum bitpool that will fit in the specified frame length
+ */
+OI_UINT16 OI_CODEC_SBC_CalculateBitpool(OI_CODEC_SBC_FRAME_INFO *frame,
+ OI_UINT16 frameLen);
+
+/**
+ Calculate the bit rate.
+
+ @param frame The frame whose bit rate to calculate
+
+ @return the approximate bit rate in bits per second,
+ assuming that stream parameters are constant
+ */
+OI_UINT32 OI_CODEC_SBC_CalculateBitrate(OI_CODEC_SBC_FRAME_INFO *frame);
+
+/**
+ Calculate decoded audio data length for one frame.
+
+ @param frame The frame whose audio data length to calculate
+
+ @return length of decoded audio data for a
+ single frame, in bytes
+ */
+OI_UINT16 OI_CODEC_SBC_CalculatePcmBytes(OI_CODEC_SBC_COMMON_CONTEXT *common);
+
+/**
+ * Get the codec version text.
+ *
+ * @return pointer to text string containing codec version text
+ *
+ */
+OI_CHAR *OI_CODEC_Version(void);
+
+
+/**
+@}
+
+@addtogroup codec_internal
+@{
+*/
+
+extern const OI_CHAR* const OI_CODEC_SBC_FreqText[];
+extern const OI_CHAR* const OI_CODEC_SBC_ModeText[];
+extern const OI_CHAR* const OI_CODEC_SBC_SubbandsText[];
+extern const OI_CHAR* const OI_CODEC_SBC_BlocksText[];
+extern const OI_CHAR* const OI_CODEC_SBC_AllocText[];
+
+/**
+@}
+
+@addtogroup codec_lib
+@{
+*/
+
+#ifdef OI_DEBUG
+void OI_CODEC_SBC_DumpConfig(OI_CODEC_SBC_FRAME_INFO *frameInfo);
+#else
+#define OI_CODEC_SBC_DumpConfig(f)
+#endif
+
+/**
+@}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _OI_CODEC_SBC_CORE_H */
+
+
diff --git a/embdrv/sbc/decoder/include/oi_codec_sbc_private.h b/embdrv/sbc/decoder/include/oi_codec_sbc_private.h
new file mode 100644
index 0000000..d7489e7
--- /dev/null
+++ b/embdrv/sbc/decoder/include/oi_codec_sbc_private.h
@@ -0,0 +1,229 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+#ifndef _OI_CODEC_SBC_PRIVATE_H
+#define _OI_CODEC_SBC_PRIVATE_H
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+/**
+@file
+Function prototypes and macro definitions used internally by the codec.
+
+@ingroup codec_internal
+*/
+
+/**
+@addtogroup codec_internal
+@{
+*/
+
+#ifdef USE_RESTRICT_KEYWORD
+#define RESTRICT restrict
+#else
+#define RESTRICT
+#endif
+
+#ifdef CODEC_DEBUG
+#include <stdio.h>
+#define ERROR(x) do { printf x; printf("\n"); } while (0)
+#else
+#define ERROR(x)
+#endif
+
+#ifdef TRACE_EXECUTION
+#define TRACE(x) do { printf x; printf("\n"); } while (0)
+#else
+#define TRACE(x)
+#endif
+
+#ifndef PRIVATE
+#define PRIVATE
+#endif
+
+#ifndef INLINE
+#define INLINE
+#endif
+
+#include "oi_assert.h"
+#include "oi_codec_sbc.h"
+
+#ifndef OI_SBC_SYNCWORD
+#define OI_SBC_SYNCWORD 0x9c
+#endif
+
+#ifndef DIVIDE
+#define DIVIDE(a, b) ((a) / (b))
+#endif
+
+typedef union {
+ OI_UINT8 uint8[SBC_MAX_BANDS];
+ OI_UINT32 uint32[SBC_MAX_BANDS / 4];
+} BITNEED_UNION1;
+
+typedef union {
+ OI_UINT8 uint8[2 * SBC_MAX_BANDS];
+ OI_UINT32 uint32[2 * SBC_MAX_BANDS / 4];
+} BITNEED_UNION2;
+
+static const OI_UINT16 freq_values[] = { 16000, 32000, 44100, 48000 };
+static const OI_UINT8 block_values[] = { 4, 8, 12, 16 };
+static const OI_UINT8 channel_values[] = { 1, 2, 2, 2 };
+static const OI_UINT8 band_values[] = { 4, 8 };
+
+
+#define TEST_MODE_SENTINEL "OINA"
+#define TEST_MODE_SENTINEL_LENGTH 4
+
+/** Used internally. */
+typedef struct {
+ union {
+ const OI_UINT8 *r;
+ OI_UINT8 *w;
+ } ptr;
+ OI_UINT32 value;
+ OI_UINT bitPtr;
+} OI_BITSTREAM;
+
+
+#define VALID_INT16(x) (((x) >= OI_INT16_MIN) && ((x) <= OI_INT16_MAX))
+#define VALID_INT32(x) (((x) >= OI_INT32_MIN) && ((x) <= OI_INT32_MAX))
+
+#define DCTII_8_SHIFT_IN 0
+#define DCTII_8_SHIFT_OUT 16-DCTII_8_SHIFT_IN
+
+#define DCTII_8_SHIFT_0 (DCTII_8_SHIFT_OUT)
+#define DCTII_8_SHIFT_1 (DCTII_8_SHIFT_OUT)
+#define DCTII_8_SHIFT_2 (DCTII_8_SHIFT_OUT)
+#define DCTII_8_SHIFT_3 (DCTII_8_SHIFT_OUT)
+#define DCTII_8_SHIFT_4 (DCTII_8_SHIFT_OUT)
+#define DCTII_8_SHIFT_5 (DCTII_8_SHIFT_OUT)
+#define DCTII_8_SHIFT_6 (DCTII_8_SHIFT_OUT-1)
+#define DCTII_8_SHIFT_7 (DCTII_8_SHIFT_OUT-2)
+
+#define DCT_SHIFT 15
+
+#define DCTIII_4_SHIFT_IN 2
+#define DCTIII_4_SHIFT_OUT 15
+
+#define DCTIII_8_SHIFT_IN 3
+#define DCTIII_8_SHIFT_OUT 14
+
+OI_UINT computeBitneed(OI_CODEC_SBC_COMMON_CONTEXT *common,
+ OI_UINT8 *bitneeds,
+ OI_UINT ch,
+ OI_UINT *preferredBitpool);
+
+void oneChannelBitAllocation(OI_CODEC_SBC_COMMON_CONTEXT *common,
+ BITNEED_UNION1 *bitneeds,
+ OI_UINT ch,
+ OI_UINT bitcount);
+
+
+OI_INT adjustToFitBitpool(const OI_UINT bitpool,
+ OI_UINT32 *bitneeds,
+ const OI_UINT subbands,
+ OI_UINT bitcount,
+ OI_UINT *excess);
+
+INLINE OI_INT allocAdjustedBits(OI_UINT8 *dest,
+ OI_INT bits,
+ OI_INT excess);
+
+INLINE OI_INT allocExcessBits(OI_UINT8 *dest,
+ OI_INT excess);
+
+PRIVATE OI_UINT32 internal_CalculateBitrate(OI_CODEC_SBC_FRAME_INFO *frame);
+
+PRIVATE OI_UINT16 internal_CalculateFramelen(OI_CODEC_SBC_FRAME_INFO *frame);
+
+void monoBitAllocation(OI_CODEC_SBC_COMMON_CONTEXT *common);
+
+typedef void (*BIT_ALLOC)(OI_CODEC_SBC_COMMON_CONTEXT *common);
+
+PRIVATE OI_STATUS internal_DecodeRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ OI_UINT8 bitpool,
+ const OI_BYTE **frameData,
+ OI_UINT32 *frameBytes,
+ OI_INT16 *pcmData,
+ OI_UINT32 *pcmBytes);
+
+INLINE OI_STATUS internal_DecoderReset(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ OI_UINT32 *decoderData,
+ OI_UINT32 decoderDataBytes,
+ OI_BYTE maxChannels,
+ OI_BYTE pcmStride,
+ OI_BOOL enhanced);
+
+INLINE OI_UINT16 OI_SBC_CalculateFrameAndHeaderlen(OI_CODEC_SBC_FRAME_INFO *frame, OI_UINT *headerLen_);
+
+PRIVATE OI_UINT32 OI_SBC_MaxBitpool(OI_CODEC_SBC_FRAME_INFO *frame);
+
+PRIVATE void OI_SBC_ComputeBitAllocation(OI_CODEC_SBC_COMMON_CONTEXT *frame);
+PRIVATE OI_UINT8 OI_SBC_CalculateChecksum(OI_CODEC_SBC_FRAME_INFO *frame, OI_BYTE const *data);
+
+/* Transform functions */
+PRIVATE void shift_buffer(SBC_BUFFER_T *dest, SBC_BUFFER_T *src, OI_UINT wordCount);
+PRIVATE void cosineModulateSynth4(SBC_BUFFER_T * RESTRICT out, OI_INT32 const * RESTRICT in);
+PRIVATE void SynthWindow40_int32_int32_symmetry_with_sum(OI_INT16 *pcm, SBC_BUFFER_T buffer[80], OI_UINT strideShift);
+
+INLINE void dct3_4(OI_INT32 * RESTRICT out, OI_INT32 const * RESTRICT in);
+PRIVATE void analyze4_generated(SBC_BUFFER_T analysisBuffer[RESTRICT 40],
+ OI_INT16 *pcm,
+ OI_UINT strideShift,
+ OI_INT32 subband[4]);
+
+INLINE void dct3_8(OI_INT32 * RESTRICT out, OI_INT32 const * RESTRICT in);
+
+PRIVATE void analyze8_generated(SBC_BUFFER_T analysisBuffer[RESTRICT 80],
+ OI_INT16 *pcm,
+ OI_UINT strideShift,
+ OI_INT32 subband[8]);
+
+#ifdef SBC_ENHANCED
+PRIVATE void analyze8_enhanced_generated(SBC_BUFFER_T analysisBuffer[RESTRICT 112],
+ OI_INT16 *pcm,
+ OI_UINT strideShift,
+ OI_INT32 subband[8]);
+#endif
+
+/* Decoder functions */
+
+INLINE void OI_SBC_ReadHeader(OI_CODEC_SBC_COMMON_CONTEXT *common, const OI_BYTE *data);
+PRIVATE void OI_SBC_ReadScalefactors(OI_CODEC_SBC_COMMON_CONTEXT *common, const OI_BYTE *b, OI_BITSTREAM *bs);
+PRIVATE void OI_SBC_ReadSamples(OI_CODEC_SBC_DECODER_CONTEXT *common, OI_BITSTREAM *ob);
+PRIVATE void OI_SBC_ReadSamplesJoint(OI_CODEC_SBC_DECODER_CONTEXT *common, OI_BITSTREAM *global_bs);
+PRIVATE void OI_SBC_SynthFrame(OI_CODEC_SBC_DECODER_CONTEXT *context, OI_INT16 *pcm, OI_UINT start_block, OI_UINT nrof_blocks);
+INLINE OI_INT32 OI_SBC_Dequant(OI_UINT32 raw, OI_UINT scale_factor, OI_UINT bits);
+PRIVATE OI_BOOL OI_SBC_ExamineCommandPacket(OI_CODEC_SBC_DECODER_CONTEXT *context, const OI_BYTE *data, OI_UINT32 len);
+PRIVATE void OI_SBC_GenerateTestSignal(OI_INT16 pcmData[][2], OI_UINT32 sampleCount);
+
+PRIVATE void OI_SBC_ExpandFrameFields(OI_CODEC_SBC_FRAME_INFO *frame);
+PRIVATE OI_STATUS OI_CODEC_SBC_Alloc(OI_CODEC_SBC_COMMON_CONTEXT *common,
+ OI_UINT32 *codecDataAligned,
+ OI_UINT32 codecDataBytes,
+ OI_UINT8 maxChannels,
+ OI_UINT8 pcmStride);
+/**
+@}
+*/
+
+#endif /* _OI_CODEC_SBC_PRIVATE_H */
+
diff --git a/embdrv/sbc/decoder/include/oi_common.h b/embdrv/sbc/decoder/include/oi_common.h
new file mode 100644
index 0000000..c4169f9
--- /dev/null
+++ b/embdrv/sbc/decoder/include/oi_common.h
@@ -0,0 +1,43 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+#ifndef _OI_COMMON_H
+#define _OI_COMMON_H
+/**
+ * @file
+ *
+ * This file is used to group commonly used BLUEmagic 3.0 software
+ * header files.
+ *
+ * This file should be included in application source code along with the header
+ * files for the specific modules of the protocol stack being used.
+ */
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+#include "oi_bt_spec.h"
+#include "oi_stddefs.h"
+#include "oi_status.h"
+#include "oi_time.h"
+#include "oi_osinterface.h"
+
+
+/*****************************************************************************/
+#endif /* _OI_COMMON_H */
diff --git a/embdrv/sbc/decoder/include/oi_cpu_dep.h b/embdrv/sbc/decoder/include/oi_cpu_dep.h
new file mode 100644
index 0000000..da7473a
--- /dev/null
+++ b/embdrv/sbc/decoder/include/oi_cpu_dep.h
@@ -0,0 +1,505 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+#ifndef _OI_CPU_DEP_H
+#define _OI_CPU_DEP_H
+/**
+ * @file
+ * This file contains definitions for characteristics of the target CPU and
+ * compiler, including primitive data types and endianness.
+ *
+ * This file defines the byte order and primitive data types for various
+ * CPU families. The preprocessor symbol 'CPU' must be defined to be an
+ * appropriate value or this header will generate a compile-time error.
+ *
+ * @note The documentation for this header file uses the x86 family of processors
+ * as an illustrative example for CPU/compiler-dependent data type definitions.
+ * Go to the source code of this header file to see the details of primitive type
+ * definitions for each platform.
+ *
+ * Additional information is available in the @ref data_types_docpage section.
+ */
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** \addtogroup Misc Miscellaneous APIs */
+/**@{*/
+
+/** @name Definitions indicating family of target OI_CPU_TYPE
+ * @{
+ */
+
+#define OI_CPU_X86 1 /**< x86 processor family */
+#define OI_CPU_ARM 2 /**< ARM processor family.
+ @deprecated Use #OI_CPU_ARM7_LEND or
+ #OI_CPU_ARM7_BEND. */
+#define OI_CPU_ARC 3 /**< ARC processor family.
+ @deprecated Use #OI_CPU_ARC_LEND or
+ #OI_CPU_ARC_BEND. */
+#define OI_CPU_SH3 4 /**< Hitachi SH-3 processor family */
+#define OI_CPU_H8 5 /**< Hitachi H8 processor family */
+#define OI_CPU_MIPS 6 /**< MIPS processor family */
+#define OI_CPU_SPARC 7 /**< SPARC processor family */
+#define OI_CPU_M68000 8 /**< Motorola M68000 processor family */
+#define OI_CPU_PPC 9 /**< PowerPC (PPC) processor family */
+#define OI_CPU_SH4_7750 10 /**< Hitachi SH7750 series in SH-4 processor family */
+#define OI_CPU_SH2 11 /**< Hitachi SH-2 processor family */
+#define OI_CPU_ARM7_LEND 12 /**< ARM7, little-endian */
+#define OI_CPU_ARM7_BEND 13 /**< ARM7, big-endian */
+#define OI_CPU_GDM1202 14 /**< GCT GDM1202 */
+#define OI_CPU_ARC_LEND 15 /**< ARC processor family, little-endian */
+#define OI_CPU_ARC_BEND 16 /**< ARC processor family, big-endian */
+#define OI_CPU_M30833F 17 /**< Mitsubishi M308 processor family */
+#define OI_CPU_CR16C 18 /**< National Semiconductor 16 bit processor family */
+#define OI_CPU_M64111 19 /**< Renesas M64111 processor (M32R family) */
+#define OI_CPU_ARMV5_LEND 20 //*< ARM5, little-endian */
+
+#define OI_CPU_TYPE 12
+
+#ifndef OI_CPU_TYPE
+ #error "OI_CPU_TYPE type not defined"
+#endif
+
+/**@}*/
+
+
+/** @name Definitions indicating byte-wise endianness of target CPU
+ * @{
+ */
+
+#define OI_BIG_ENDIAN_BYTE_ORDER 0 /**< Multiple-byte values are stored in memory beginning with the most significant byte at the lowest address. */
+#define OI_LITTLE_ENDIAN_BYTE_ORDER 1 /**< Multiple-byte values are stored in memory beginning with the least significant byte at the lowest address. */
+
+/**@}*/
+
+
+/** @name CPU/compiler-independent primitive data type definitions
+ * @{
+ */
+
+typedef int OI_BOOL; /**< Boolean values use native integer data type for target CPU. */
+typedef int OI_INT; /**< Integer values use native integer data type for target CPU. */
+typedef unsigned int OI_UINT; /**< Unsigned integer values use native unsigned integer data type for target CPU. */
+typedef unsigned char OI_BYTE; /**< Raw bytes type uses native character data type for target CPU. */
+
+/**@}*/
+
+
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_X86
+
+#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER /**< x86 platform byte ordering is little-endian */
+
+/** @name CPU/compiler-dependent primitive data type definitions for x86 processor family
+ * @{
+ */
+typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for x86 processor. */
+typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for x86 processor. */
+typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for x86 processor. */
+typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for x86 processor. */
+typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for x86 processor. */
+typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for x86 processor. */
+
+typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
+
+/**@}*/
+
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_ARM
+/* This CPU type is deprecated (removed from use). Instead, use OI_CPU_ARM7_LEND or OI_CPU_ARM7_BEND for
+ little-endian or big-endian configurations of the ARM7, respectively. */
+#error OI_CPU_ARM is deprecated
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_ARC
+/* This CPU type is deprecated (removed from use). Instead, use OI_CPU_ARC_LEND or OI_CPU_ARC_BEND for
+ little-endian or big-endian configurations of the ARC, respectively. */
+#error OI_CPU_ARC is deprecated
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_SH3
+/* The Hitachi SH C compiler defines _LIT or _BIG, depending on the endianness
+ specified to the compiler on the command line. */
+#if defined(_LIT)
+ #define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER /**< If _LIT is defined, SH-3 platform byte ordering is little-endian. */
+#elif defined(_BIG)
+ #define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER /**< If _BIG is defined, SH-3 platform byte ordering is big-endian. */
+#else
+ #error SH compiler endianness undefined
+#endif
+
+/** @name CPU/compiler-dependent primitive data type definitions for SH-3 processor family
+ * @{
+ */
+
+typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for SH-3 processor. */
+typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for SH-3 processor. */
+typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for SH-3 processor. */
+typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for SH-3 processor. */
+typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for SH-3 processor. */
+typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for SH-3 processor. */
+
+typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
+
+/**@}*/
+
+#endif
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_SH2
+
+#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER /**< SH-2 platform byte ordering is big-endian. */
+
+/** @name CPU/compiler-dependent primitive data type definitions for SH-2 processor family
+ * @{
+ */
+
+typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for SH-2 processor. */
+typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for SH-2 processor. */
+typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for SH-2 processor. */
+typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for SH-2 processor. */
+typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for SH-2 processor. */
+typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for SH-2 processor. */
+
+typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
+
+/**@}*/
+
+#endif
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_H8
+#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
+#error basic types not defined
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_MIPS
+#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
+/** @name CPU/compiler-dependent primitive data type definitions for MIPS processor family
+ * @{
+ */
+typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for ARM7 processor. */
+typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for ARM7 processor. */
+typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for ARM7 processor. */
+typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for ARM7 processor. */
+typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for ARM7 processor. */
+typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for ARM7 processor. */
+
+typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
+
+/**@}*/
+
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_SPARC
+#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
+#error basic types not defined
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_M68000
+#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER /**< M68000 platform byte ordering is big-endian. */
+
+/** @name CPU/compiler-dependent primitive data type definitions for M68000 processor family
+ * @{
+ */
+
+typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for M68000 processor. */
+typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for M68000 processor. */
+typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for M68000 processor. */
+typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for M68000 processor. */
+typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for M68000 processor. */
+typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for M68000 processor. */
+
+typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
+
+/**@}*/
+
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_PPC
+#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
+
+
+/** @name CPU/compiler-dependent primitive data type definitions for PPC 8XX processor family
+ * @{
+ */
+
+typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for PPC8XX processor. */
+typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for PPC8XX processor. */
+typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for PPC8XX processor. */
+typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for PPC8XX processor. */
+typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for PPC8XX processor. */
+typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for PPC8XX processor. */
+
+typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
+
+/**@}*/
+
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_SH4_7750
+#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER /**< SH7750 platform byte ordering is big-endian. */
+
+/** @name CPU/compiler-dependent primitive data type definitions for SH7750 processor series of the SH-4 processor family
+ * @{
+ */
+
+typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for SH7750 SH-4 processor. */
+typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for SH7750 SH-4 processor. */
+typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for SH7750 SH-4 processor. */
+typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for SH7750 SH-4 processor. */
+typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for SH7750 SH-4 processor. */
+typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for SH7750 SH-4 processor. */
+
+typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
+
+/**@}*/
+
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_ARM7_LEND
+#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
+
+/** @name little-endian CPU/compiler-dependent primitive data type definitions for the ARM7 processor family
+ * @{
+ */
+
+typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for ARM7 processor. */
+typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for ARM7 processor. */
+typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for ARM7 processor. */
+typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for ARM7 processor. */
+typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for ARM7 processor. */
+typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for ARM7 processor. */
+
+typedef void * OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
+
+/**@}*/
+
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_ARM7_BEND
+#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
+/** @name big-endian CPU/compiler-dependent primitive data type definitions for the ARM7 processor family
+ * @{
+ */
+typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for ARM7 processor. */
+typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for ARM7 processor. */
+typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for ARM7 processor. */
+typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for ARM7 processor. */
+typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for ARM7 processor. */
+typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for ARM7 processor. */
+
+typedef void * OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
+
+/**@}*/
+
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_GDM1202
+#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
+
+typedef signed char OI_INT8; /**< 8-bit signed integer. */
+typedef signed short OI_INT16; /**< 16-bit signed integer. */
+typedef signed long OI_INT32; /**< 32-bit signed integer. */
+typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer. */
+typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer. */
+typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer. */
+
+typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
+
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_ARC_LEND
+
+#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
+
+/** @name CPU/compiler-dependent primitive data type definitions for ARC processor family
+ * @{
+ */
+
+typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for ARC processor. */
+typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for ARC processor. */
+typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for ARC processor. */
+typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for ARC processor. */
+typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for ARC processor. */
+typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for ARC processor. */
+
+typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
+
+/**@}*/
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_ARC_BEND
+
+#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
+
+/** @name CPU/compiler-dependent primitive data type definitions for ARC processor family
+ * @{
+ */
+
+typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for ARC processor. */
+typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for ARC processor. */
+typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for ARC processor. */
+typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for ARC processor. */
+typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for ARC processor. */
+typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for ARC processor. */
+
+typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
+
+/**@}*/
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_M30833F
+
+#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
+
+/** @name CPU/compiler-dependent primitive data type definitions for Mitsubishi M308 processor family
+ * @{
+ */
+
+typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for M308 processor. */
+typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for M308 processor. */
+typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for M308 processor. */
+typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for M308 processor. */
+typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for M308 processor. */
+typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for M308 processor. */
+
+typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
+
+/**@}*/
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_CR16C
+
+#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
+
+/** @name CPU/compiler-dependent primitive data type definitions for National Semicnductor processor family
+ * @{
+ */
+
+typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for CR16C processor. */
+typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for CR16C processor. */
+typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for CR16C processor. */
+typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for CR16C processor. */
+typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for CR16C processor. */
+typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for CR16C processor. */
+
+typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
+
+/**@}*/
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_M64111
+
+#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
+
+/** @name CPU/compiler-dependent primitive data type definitions for Renesas M32R processor family
+ * @{
+ */
+
+typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for M64111 processor. */
+typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for M64111 processor. */
+typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for M64111 processor. */
+typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for M64111 processor. */
+typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for M64111 processor. */
+typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for M64111 processor. */
+
+typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
+
+/**@}*/
+#endif
+
+/*********************************************************************************/
+
+#if OI_CPU_TYPE==OI_CPU_ARMV5_LEND
+#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
+
+/** @name little-endian CPU/compiler-dependent primitive data type definitions for the ARM7 processor family
+ * @{
+ */
+
+typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for ARM7 processor. */
+typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for ARM7 processor. */
+typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for ARM7 processor. */
+typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for ARM7 processor. */
+typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for ARM7 processor. */
+typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for ARM7 processor. */
+
+typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
+
+/**@}*/
+
+#endif
+
+/*********************************************************************************/
+
+
+#ifndef OI_CPU_BYTE_ORDER
+ #error "Byte order (endian-ness) not defined"
+#endif
+
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+/*********************************************************************************/
+#endif /* _OI_CPU_DEP_H */
diff --git a/embdrv/sbc/decoder/include/oi_modules.h b/embdrv/sbc/decoder/include/oi_modules.h
new file mode 100644
index 0000000..a0b68dd
--- /dev/null
+++ b/embdrv/sbc/decoder/include/oi_modules.h
@@ -0,0 +1,171 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+#ifndef _OI_MODULES_H
+#define _OI_MODULES_H
+/**
+ * @file
+ *
+ * Enumeration type defining the inidivual stack components.
+ *
+ */
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+
+/** \addtogroup Misc Miscellaneous APIs */
+/**@{*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * This enumeration lists constants for referencing the components of
+ * the BLUEmagic 3.0 protocol stack, profiles, and other functionalities.
+ *
+ * In order to distinguish types of modules, items are grouped with markers to
+ * delineate start and end of the groups
+ *
+ * The module type is used for various purposes:
+ * identification in debug print statements
+ * access to initialization flags
+ * access to the configuration table
+ */
+
+typedef enum {
+ /* profiles and protocols --> Updates to oi_debug.c and oi_config_table.c */
+
+ /* XX --> Keep Enum values up-to-date! */
+ OI_MODULE_AT, /**< 00 AT command processing */
+ OI_MODULE_A2DP, /**< 01 Advanced Audio Distribution Profile */
+ OI_MODULE_AVCTP, /**< 02 Audio-Visual Control Transport Profile */
+ OI_MODULE_AVDTP, /**< 03 Audio-Visual Distribution Protocol */
+ OI_MODULE_AVRCP, /**< 04 Audio-Visual Remote Control Profile */
+ OI_MODULE_BIP_CLI, /**< 05 Basic Imaging Profile protocol client */
+ OI_MODULE_BIP_SRV, /**< 06 Basic Imaging Profile protocol server */
+ OI_MODULE_BNEP, /**< 07 Bluetooth Network Encapsulation Protocol */
+ OI_MODULE_BPP_SENDER, /**< 08 Basic Printing Profile */
+ OI_MODULE_BPP_PRINTER, /**< 09 Basic Printing Profile */
+ OI_MODULE_CTP, /**< 10 Cordless Telephony Profile */
+ OI_MODULE_DUN, /**< 11 Dial-Up Networking Profile */
+ OI_MODULE_FAX, /**< 12 Fax Profile */
+ OI_MODULE_FTP_CLI, /**< 13 File Transfer Profile protocol client */
+ OI_MODULE_FTP_SRV, /**< 14 File Transfer Profile protocol server */
+ OI_MODULE_HANDSFREE, /**< 15 Hands-Free Profile */
+ OI_MODULE_HANDSFREE_AG, /**< 16 Hands-Free Profile */
+ OI_MODULE_HCRP_CLI, /**< 17 Hardcopy Cable Replacement Profile */
+ OI_MODULE_HCRP_SRV, /**< 18 Hardcopy Cable Replacement Profile */
+ OI_MODULE_HEADSET, /**< 19 Headset Profile */
+ OI_MODULE_HEADSET_AG, /**< 20 Headset Profile */
+ OI_MODULE_HID, /**< 21 Human Interface Device profile */
+ OI_MODULE_INTERCOM, /**< 22 Intercom Profile */
+ OI_MODULE_OBEX_CLI, /**< 23 OBEX protocol client, Generic Object Exchange Profile */
+ OI_MODULE_OBEX_SRV, /**< 24 OBEX protocol server, Generic Object Exchange Profile */
+ OI_MODULE_OPP_CLI, /**< 25 Object Push Profile protocol client */
+ OI_MODULE_OPP_SRV, /**< 26 Object Push Profile protocol server */
+ OI_MODULE_PAN, /**< 27 PAN profile */
+ OI_MODULE_PBAP_CLI, /**< 28 Phonebook Access Profile client */
+ OI_MODULE_PBAP_SRV, /**< 29 Phonebook Access Profile server */
+ OI_MODULE_SAP_CLI, /**< 30 SIM Access Profile */
+ OI_MODULE_SAP_SRV, /**< 31 SIM Access Profile */
+ OI_MODULE_SPP, /**< 32 Serial Port Profile */
+ OI_MODULE_SYNC_CLI, /**< 33 Synchronization Profile */
+ OI_MODULE_SYNC_SRV, /**< 34 Synchronization Profile */
+ OI_MODULE_SYNC_CMD_CLI, /**< 35 Synchronization Profile */
+ OI_MODULE_SYNC_CMD_SRV, /**< 36 Synchronization Profile */
+ OI_MODULE_SYNCML, /**< 37 SyncML Profile */
+ OI_MODULE_TCS, /**< 38 TCS Binary */
+ OI_MODULE_VDP, /**< 39 Video Distribution Profile */
+
+ /* corestack components --> Updates to oi_debug.c and oi_config_table.c */
+
+ OI_MODULE_COMMON_CONFIG, /**< 40 Common configuration, module has no meaning other than for config struct */
+ OI_MODULE_CMDCHAIN, /**< 41 Command chaining utility */
+ OI_MODULE_DISPATCH, /**< 42 Dispatcher */
+ OI_MODULE_DATAELEM, /**< 43 Data Elements, marshaller */
+ OI_MODULE_DEVMGR, /**< 44 Device Manager */
+ OI_MODULE_DEVMGR_MODES, /**< 45 Device Manager connectability/discoverability modes */
+ OI_MODULE_HCI, /**< 46 Host Controller Interface command layer */
+ OI_MODULE_L2CAP, /**< 47 L2CAP */
+ OI_MODULE_MEMMGR, /**< 48 modules that do memory management */
+ OI_MODULE_POLICYMGR, /**< 49 Policy Manager */
+ OI_MODULE_RFCOMM, /**< 50 RFCOMM */
+ OI_MODULE_RFCOMM_SD, /**< 51 RFCOMM Service discovery */
+ OI_MODULE_SDP_CLI, /**< 52 Service Discovery Protocol client */
+ OI_MODULE_SDP_SRV, /**< 53 Service Discovery Protocol server */
+ OI_MODULE_SDPDB, /**< 54 Service Discovery Protocol database */
+ OI_MODULE_SECMGR, /**< 55 Security Manager */
+ OI_MODULE_SNIFFLOG, /**< 56 sniff log */
+ OI_MODULE_SUPPORT, /**< 57 support functions, including CThru Dispatcher, time functions, and stack initialization */
+ OI_MODULE_TRANSPORT, /**< 58 transport layer between HCI command layer and driver */
+ OI_MODULE_TEST, /**< 59 used to debug output from internal test programs */
+ OI_MODULE_XML, /**< 60 XML/CSS parser */
+
+ OI_MODULE_DI, /**< 61 Device Identification Profile */
+
+ // bhapi components --> Updates to oi_debug.c
+
+ OI_MODULE_BHAPI, /**< 62 BLUEmagic Host API generic */
+ OI_MODULE_BHCLI, /**< 63 BLUEmagic Host API client side */
+ OI_MODULE_BHSRV, /**< 64 BLUEmagic Host API server side */
+ OI_MODULE_MSGQ, /**< 65 module that handles message queuing */
+ OI_MODULE_BHAPI_TRANSPORT, /**< 66 module that handles message queuing */
+ OI_MODULE_BLST_SRV, /**< 67 module that provides server side BHAPI Lightweight Serial Transport */
+ OI_MODULE_BLST_CLI, /**< 68 module that provides client side BHAPI Lightweight Serial Transport */
+
+ // OEM files --> Updates to oi_debug.c
+ OI_MODULE_OEM, /**< 69 Application Memory allocation */
+
+ // Application glue --> Updates to oi_debug.c
+ OI_MODULE_APP, /**< 70 Application Memory allocation */
+
+ /* various pieces of code depend on these last 2 elements occuring in a specific order:
+ OI_MODULE_ALL must be the 2nd to last element
+ OI_MODULE_UNKNOWN must be the last element
+ */
+ OI_MODULE_ALL, /**< 71 special value identifying all modules - used for control of debug print statements */
+ OI_MODULE_UNKNOWN /**< 72 special value - used for debug print statements */
+} OI_MODULE;
+
+/**
+ * This constant is the number of actual modules in the list. ALL and UNKNOWN are
+ * special values that are not actually modules.
+ * Used for debug print and memmgr profiling
+ */
+#define OI_NUM_MODULES OI_MODULE_ALL
+
+
+/**
+ * This constant is the number of profile and core components. It is used to size
+ * the initialization and configuration tables.
+ */
+#define OI_NUM_STACK_MODULES OI_MODULE_BHAPI
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/**@}*/
+
+#endif /* _OI_MODULES_H */
+
diff --git a/embdrv/sbc/decoder/include/oi_osinterface.h b/embdrv/sbc/decoder/include/oi_osinterface.h
new file mode 100644
index 0000000..7868041
--- /dev/null
+++ b/embdrv/sbc/decoder/include/oi_osinterface.h
@@ -0,0 +1,197 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+#ifndef _OI_OSINTERFACE_H
+#define _OI_OSINTERFACE_H
+/**
+ @file
+ * This file provides the platform-independent interface for functions for which
+ * implementation is platform-specific.
+ *
+ * The functions in this header file define the operating system or hardware
+ * services needed by the BLUEmagic 3.0 protocol stack. The
+ * actual implementation of these services is platform-dependent.
+ *
+ */
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+#include "oi_stddefs.h"
+#include "oi_time.h"
+#include "oi_status.h"
+#include "oi_modules.h"
+
+/** \addtogroup Misc Miscellaneous APIs */
+/**@{*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * Terminates execution.
+ *
+ * @param reason Reason for termination
+ */
+void OI_FatalError(OI_STATUS reason);
+
+/**
+ * This function logs an error.
+ *
+ * When built for release mode, BLUEmagic 3 errors are logged to
+ * this function. (in debug mode, errors are logged via
+ * OI_Print()).
+ *
+ * @param module Module in which the error was detected (see
+ * oi_modules.h)
+ * @param lineno Line number of the C file OI_SLOG_ERROR called
+ * @param status Status code associated with the error event
+ */
+void OI_LogError(OI_MODULE module, OI_INT lineno, OI_STATUS status);
+
+/**
+ * This function initializes the debug code handling.
+ *
+ * When built for debug mode, this function performs platform
+ * dependent initialization to handle message codes passed in
+ * via OI_SetMsgCode().
+ */
+void OI_InitDebugCodeHandler(void);
+
+
+/**
+ * This function reads the time from the real time clock.
+ *
+ * All timing in BM3 is relative, typically a granularity
+ * of 5 or 10 msecs is adequate.
+ *
+ * @param[out] now Pointer to the buffer to which the current
+ * time will be returned
+ */
+void OI_Time_Now(OI_TIME *now);
+
+/**
+ * This function causes the current thread to sleep for the
+ * specified amount of time. This function must be called
+ * without the stack access token.
+ *
+ * @note BM3 corestack and profiles never suspend and never call
+ * OI_Sleep. The use of OI_Sleep is limited to applications and
+ * platform-specific code.
+ *
+ * If your port and applications never use OI_Sleep, this function can be left unimplemented.
+ *
+ * @param milliseconds Number of milliseconds to sleep
+ */
+void OI_Sleep(OI_UINT32 milliseconds);
+
+
+/**
+ * Defines for message type codes.
+ */
+#define OI_MSG_CODE_APPLICATION 0 /**< Application output */
+#define OI_MSG_CODE_ERROR 1 /**< Error message output */
+#define OI_MSG_CODE_WARNING 2 /**< Warning message output */
+#define OI_MSG_CODE_TRACE 3 /**< User API function trace output */
+#define OI_MSG_CODE_PRINT1 4 /**< Catagory 1 debug print output */
+#define OI_MSG_CODE_PRINT2 5 /**< Catagory 2 debug print output */
+#define OI_MSG_CODE_HEADER 6 /**< Error/Debug output header */
+
+/**
+ * This function is used to indicate the type of text being output with
+ * OI_Print(). For the Linux and Win32 platforms, it will set
+ * the color of the text. Other possible uses could be to insert
+ * HTML style tags, add some other message type indication, or
+ * be completely ignored altogether.
+ *
+ * @param code OI_MSG_CODE_* indicating setting the message type.
+ */
+void OI_SetMsgCode(OI_UINT8 code);
+
+/**
+ * All output from OI_Printf() and all debug output is sent to OI_Print.
+ * Typically, if the platform has a console, OI_Print() is sent to stdout.
+ * Embedded platforms typically send OI_Print() output to a serial port.
+ *
+ * @param str String to print
+ */
+void OI_Print(OI_CHAR const *str);
+
+/**
+ * In cases where OI_Print() is sending output to a logfile in addition to console,
+ * it is desirable to also put console input into the logfile.
+ * This function can be called by the console input process.
+ *
+ * @note This is an optional API which is strictly
+ * between the platform-specific stack_console and osinterface
+ * modules. This API need only be implemented on those
+ * platforms where is serves a useful purpose, e.g., win32.
+ *
+ * @param str Console input string
+ */
+
+void OI_Print_ConsoleInput(OI_CHAR const *str);
+
+/**
+ * This function computes the CRC16 of the program image.
+ */
+OI_UINT16 OI_ProgramImageCRC16(void);
+
+/**
+ * Writes an integer to stdout in hex. This macro is intended
+ * for selective use when debugging in small memory
+ * configurations or other times when it is not possible to use
+ * OI_DBGPRINT.
+ *
+ * @param n the integer to print
+ */
+
+#define OI_Print_Int(n) \
+{ \
+ static const OI_CHAR _digits[] = "0123456789ABCDEF"; \
+ OI_CHAR _buf[9]; \
+ OI_CHAR *_str = &_buf[8]; \
+ OI_UINT32 _i = n; \
+ *_str = 0; \
+ do { *(--_str) = _digits[(_i & 0xF)]; _i >>= 4; } while (_i); \
+ OI_Print(_str); \
+}
+
+/**
+ * Application Dynamic Memory allocation.
+ *
+ * These APIs are provided for application use on those
+ * platforms which have no dynamic memory support. Memory is
+ * allocated from the pool-based heap managed by the stack's
+ * internal memory manager.
+ */
+void *OI_APP_Malloc(OI_INT32 size);
+void OI_APP_Free(void *ptr);
+
+/*****************************************************************************/
+#ifdef __cplusplus
+}
+#endif
+
+/**@}*/
+
+#endif /* _OI_OSINTERFACE_H */
+
diff --git a/embdrv/sbc/decoder/include/oi_status.h b/embdrv/sbc/decoder/include/oi_status.h
new file mode 100644
index 0000000..868d8dc
--- /dev/null
+++ b/embdrv/sbc/decoder/include/oi_status.h
@@ -0,0 +1,579 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+#ifndef _OI_STATUS_H
+#define _OI_STATUS_H
+/**
+ * @file
+ * This file contains status codes for BLUEmagic 3.0 software.
+ */
+
+#include "oi_stddefs.h"
+
+/** \addtogroup Misc Miscellaneous APIs */
+/**@{*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+ /** test it **/
+
+/**
+ * OI_STATUS must fit in 16 bits, so status codes can range from 0 to 66535, inclusive.
+ */
+
+typedef enum {
+ OI_STATUS_SUCCESS = 0, /**< function call succeeded alias for #OI_OK */
+ OI_OK = 0, /**< function call succeeded alias for #OI_STATUS_SUCCESS */
+ OI_STATUS_INVALID_PARAMETERS = 101, /**< invalid function input parameters */
+ OI_STATUS_NOT_IMPLEMENTED = 102, /**< attempt to use an unimplemented function */
+ OI_STATUS_NOT_INITIALIZED = 103, /**< data not initialized */
+ OI_STATUS_NO_RESOURCES = 104, /**< generic resource allocation failure status */
+ OI_STATUS_INTERNAL_ERROR = 105, /**< internal inconsistency */
+ OI_STATUS_OUT_OF_MEMORY = 106, /**< generally, OI_Malloc failed */
+ OI_ILLEGAL_REENTRANT_CALL = 107, /**< violation of non-reentrant module policy */
+ OI_STATUS_INITIALIZATION_FAILED = 108, /**< module initialization failed */
+ OI_STATUS_INITIALIZATION_PENDING = 109, /**< inititialization not yet complete */
+ OI_STATUS_NO_SCO_SUPPORT = 110, /**< SCO operation rejected; system not configured for SCO */
+ OI_STATUS_OUT_OF_STATIC_MEMORY = 111, /**< static malloc failed */
+ OI_TIMEOUT = 112, /**< generic timeout */
+ OI_OS_ERROR = 113, /**< some operating system error */
+ OI_FAIL = 114, /**< generic failure */
+ OI_STRING_FORMAT_ERROR = 115, /**< error in VarString formatting string */
+ OI_STATUS_PENDING = 116, /**< The operation is pending. */
+ OI_STATUS_INVALID_COMMAND = 117, /**< The command was invalid. */
+ OI_BUSY_FAIL = 118, /**< command rejected due to busy */
+ OI_STATUS_ALREADY_REGISTERED = 119, /**< The registration has already been performed. */
+ OI_STATUS_NOT_FOUND = 120, /**< The referenced resource was not found. */
+ OI_STATUS_NOT_REGISTERED = 121, /**< not registered */
+ OI_STATUS_NOT_CONNECTED = 122, /**< not connected */
+ OI_CALLBACK_FUNCTION_REQUIRED = 123, /**< A callback function parameter was required. */
+ OI_STATUS_MBUF_OVERFLOW = 124, /**< There is no room to add another buffer to an mbuf. */
+ OI_STATUS_MBUF_UNDERFLOW = 125, /**< There was an attempt to pull too many bytes from an mbuf. */
+ OI_STATUS_CONNECTION_EXISTS = 126, /**< connection exists */
+ OI_STATUS_NOT_CONFIGURED = 127, /**< module not configured */
+ OI_LOWER_STACK_ERROR = 128, /**< An error was reported by lower stack API. This is used for embedded platforms. */
+ OI_STATUS_RESET_IN_PROGRESS = 129, /**< Request failed/rejected because we're busy resetting. */
+ OI_STATUS_ACCESS_DENIED = 130, /**< Generic access denied error. */
+ OI_STATUS_DATA_ERROR = 131, /**< Generic data error. */
+ OI_STATUS_INVALID_ROLE = 132, /**< The requested role was invalid. */
+ OI_STATUS_ALREADY_CONNECTED = 133, /**< The requested connection is already established. */
+ OI_STATUS_PARSE_ERROR = 134, /**< Parse error */
+ OI_STATUS_END_OF_FILE = 135, /**< End of file */
+ OI_STATUS_READ_ERROR = 136, /**< Generic read error */
+ OI_STATUS_WRITE_ERROR = 137, /**< Generic write error */
+ OI_STATUS_NEGOTIATION_FAILURE = 138, /**< Error in negotiation */
+ OI_STATUS_READ_IN_PROGRESS = 139, /**< A read is already in progress */
+ OI_STATUS_ALREADY_INITIALIZED = 140, /**< Initialization has already been done */
+ OI_STATUS_STILL_CONNECTED = 141, /**< The service cannot be shutdown because there are still active connections. */
+ OI_STATUS_MTU_EXCEEDED = 142, /**< The packet is too big */
+ OI_STATUS_LINK_TERMINATED = 143, /**< The link was terminated */
+ OI_STATUS_PIN_CODE_TOO_LONG = 144, /**< Application gave us a pin code that is too long */
+ OI_STATUS_STILL_REGISTERED = 145, /**< The service cannot be shutdown because there are still active registrations. */
+ OI_STATUS_SPEC_VIOLATION = 146, /**< Some application behavior contrary to BT specifications */
+
+
+ OI_STATUS_PSM_ALREADY_REGISTERED = 402, /**< L2CAP: The specified PSM has already been registered. */
+ OI_STATUS_INVALID_CID = 403, /**< L2CAP: CID is invalid or no longer valid (connection terminated) */
+ OI_STATUS_CID_NOT_FOUND = 404, /**< L2CAP: CID does not represent a current connection */
+ OI_STATUS_CHANNEL_NOT_FOUND = 406, /**< L2CAP: CID does not represent a current connection */
+ OI_STATUS_PSM_NOT_FOUND = 407, /**< L2CAP: PSM not found */
+ OI_STATUS_INVALID_STATE = 408, /**< L2CAP: invalid state */
+ OI_STATUS_WRITE_IN_PROGRESS = 410, /**< L2CAP: write in progress */
+ OI_STATUS_INVALID_PACKET = 411, /**< L2CAP: invalid packet */
+ OI_STATUS_SEND_COMPLETE = 412, /**< L2CAP: send is complete */
+ OI_STATUS_INVALID_HANDLE = 414, /**< L2CAP: handle is invalid */
+ OI_STATUS_GROUP_FULL = 418, /**< L2CAP: No more members can be added to the specified group. */
+ OI_STATUS_DEVICE_ALREADY_IN_GROUP = 423, /**< L2CAP: The device already exists in the group. */
+ OI_STATUS_DUPLICATE_GROUP = 425, /**< L2CAP: attempt to add more than one group */
+ OI_STATUS_EMPTY_GROUP = 426, /**< L2CAP: group is empty */
+ OI_STATUS_PACKET_NOT_FOUND = 427, /**< L2CAP: packet not found */
+ OI_STATUS_BUFFER_TOO_SMALL = 428, /**< L2CAP: The buffer size is too small. */
+ OI_STATUS_IDENTIFIER_NOT_FOUND = 429, /**< L2CAP: identifier not found */
+
+ OI_L2CAP_DISCONNECT_LOWER_LAYER = 430, /**< L2CAP: The lower level forced a disconnect. */
+ OI_L2CAP_DISCONNECT_REMOTE_REQUEST = 431, /**< L2CAP: The remote device requested a disconnect. */
+ OI_L2CAP_GROUP_ADD_CONNECT_FAIL = 433, /**< L2CAP: Group add connect faiL */
+ OI_L2CAP_GROUP_REMOVE_FAILURE = 434, /**< L2CAP: Group remove failure */
+ OI_L2CAP_DATA_WRITE_ERROR_LINK_TERM = 435, /**< L2CAP: Data write error LINK_TERM */
+ OI_L2CAP_DISCONNECT_LOCAL_REQUEST = 436, /**< L2CAP: Disconnect local request */
+
+ OI_L2CAP_CONNECT_TIMEOUT = 437, /**< L2CAP: Connect timeout */
+ OI_L2CAP_DISCONNECT_TIMEOUT = 439, /**< L2CAP: Disconnect timeout */
+ OI_L2CAP_PING_TIMEOUT = 440, /**< L2CAP: Ping timeout */
+ OI_L2CAP_GET_INFO_TIMEOUT = 441, /**< L2CAP: Get info timeout */
+ OI_L2CAP_INVALID_ADDRESS = 444, /**< L2CAP: Invalid address */
+ OI_L2CAP_CMD_REJECT_RCVD = 445, /**< L2CAP: remote sent us 'command reject' response */
+
+ OI_L2CAP_CONNECT_BASE = 450, /**< L2CAP: Connect base */
+ OI_L2CAP_CONNECT_PENDING = 451, /**< L2CAP: Connect pending */
+ OI_L2CAP_CONNECT_REFUSED_INVALID_PSM = 452, /**< L2CAP: Connect refused invalid PSM */
+ OI_L2CAP_CONNECT_REFUSED_SECURITY = 453, /**< L2CAP: Connect refused security */
+ OI_L2CAP_CONNECT_REFUSED_NO_RESOURCES = 454, /**< L2CAP: Connect refused no resources */
+
+ OI_L2CAP_CONFIG_BASE = 460, /**< L2CAP: Config base */
+ OI_L2CAP_CONFIG_FAIL_INVALID_PARAMETERS= 461, /**< L2CAP: Config fail invalid parameters */
+ OI_L2CAP_CONFIG_FAIL_NO_REASON = 462, /**< L2CAP: Config fail no reason */
+ OI_L2CAP_CONFIG_FAIL_UNKNOWN_OPTIONS = 463, /**< L2CAP: Config fail unknown options */
+
+ OI_L2CAP_GET_INFO_BASE = 470, /**< L2CAP: Get info base */
+ OI_L2CAP_GET_INFO_NOT_SUPPORTED = 471, /**< L2CAP: Get info not supported */
+ OI_L2CAP_MTU_EXCEEDED = 472, /**< L2CAP: The MTU of the channel was exceeded */
+ OI_L2CAP_INVALID_PSM = 482, /**< L2CAP: Invalid PSM */
+ OI_L2CAP_INVALID_MTU = 483, /**< L2CAP: Invalid MTU */
+ OI_L2CAP_INVALID_FLUSHTO = 484, /**< L2CAP: Invalid flush timeout */
+
+ OI_HCI_NO_SUCH_CONNECTION = 601, /**< HCI: caller specified a non-existent connection handle */
+ OI_HCI_CB_LIST_FULL = 603, /**< HCI: callback list is full, cannot attempt to send command */
+ OI_HCI_EVENT_UNDERRUN = 605, /**< HCI: parsing event packet, premature end-of-parameters */
+ OI_HCI_UNKNOWN_EVENT_CODE = 607, /**< HCI: event received - event code is unknown */
+ OI_HCI_BAD_EVENT_PARM_LEN = 608, /**< HCI: event - parameter length is incorrect */
+ OI_HCI_CMD_QUEUE_FULL = 611, /**< HCI: command queue is full */
+ OI_HCI_SHORT_EVENT = 612, /**< HCI: event received, missing event code and/or parm len */
+ OI_HCI_TRANSMIT_NOT_READY = 613, /**< HCI: ACL/SCO transmit request failed - busy or no buffers available */
+ OI_HCI_ORPHAN_SENT_EVENT = 614, /**< HCI: got spurious 'sent' event from transport layer */
+ OI_HCI_CMD_TABLE_ERROR = 615, /**< HCI: inconsistency in the internal command table */
+ OI_HCI_UNKNOWN_CMD_ID = 616, /**< HCI: HciApi Command - unknown command id */
+ OI_HCI_UNEXPECTED_EVENT = 619, /**< HCI: event received which only occurs in response to our cmd */
+ OI_HCI_EVENT_TABLE_ERROR = 620, /**< HCI: inconsistency in the internal event table */
+ OI_HCI_EXPECTED_EVENT_TIMOUT = 621, /**< HCI: timed out waiting for an expected event */
+ OI_HCI_NO_CMD_DESC_FOR_OPCODE = 622, /**< HCI: event opcode is not known */
+ OI_HCI_INVALID_OPCODE_ERROR = 623, /**< HCI: command opcode is invalid */
+ OI_HCI_FLOW_CONTROL_DISABLED = 624, /**< HCI: can not use host flow control APIs if disabled in configuration */
+ OI_HCI_TX_COMPLETE = 625, /**< HCI: packet delivery to Host Controler complete */
+ OI_HCI_TX_ERROR = 626, /**< HCI: failed to deliver packet to Host Controler */
+ OI_HCI_DEVICE_NOT_INITIALIZED = 627, /**< HCI: commands from upper layers disallowed until device is up and running */
+ OI_HCI_UNSUPPORTED_COMMAND = 628, /**< HCI: command requested is not supported by local device */
+ OI_HCI_PASSTHROUGH_ERROR = 629, /**< HCI: Error processing passthrough command */
+ OI_HCI_PASSTHROUGH_ALREADY_SET = 630, /**< HCI: Passthrough mode already enabled */
+ OI_HCI_RESET_FAILURE = 631, /**< HCI: failed to reset the device/baseband */
+ OI_HCI_TRANSPORT_RESET = 632, /**< HCI: some operation failed because of a reset in the transport */
+ OI_HCIERR_HCIIFC_INIT_FAILURE = 633, /**< HCI: failed to initialize transport layer interface */
+
+ OI_HCIERR_FIRST_ERROR_VALUE = 701, /**< marker for first HCI protocol error */
+ OI_HCIERR_UNKNOWN_HCI_COMMAND = 701, /**< HCI: protocol error 0x01 */
+ OI_HCIERR_NO_CONNECTION = 702, /**< HCI: protocol error 0x02 */
+ OI_HCIERR_HARDWARE_FAILURE = 703, /**< HCI: protocol error 0x03 */
+ OI_HCIERR_PAGE_TIMEOUT = 704, /**< HCI: protocol error 0x04 */
+ OI_HCIERR_AUTHENTICATION_FAILURE = 705, /**< HCI: protocol error 0x05 */
+ OI_HCIERR_KEY_MISSING = 706, /**< HCI: protocol error 0x06 */
+ OI_HCIERR_MEMORY_FULL = 707, /**< HCI: protocol error 0x07 */
+ OI_HCIERR_CONNECTION_TIMEOUT = 708, /**< HCI: protocol error 0x08 */
+ OI_HCIERR_MAX_NUM_OF_CONNECTIONS = 709, /**< HCI: protocol error 0x09 */
+ OI_HCIERR_MAX_NUM_OF_SCO_CONNECTIONS = 710, /**< HCI: protocol error 0x0A */
+ OI_HCIERR_ACL_CONNECTION_ALREADY_EXISTS = 711, /**< HCI: protocol error 0x0B */
+ OI_HCIERR_COMMAND_DISALLOWED = 712, /**< HCI: protocol error 0x0C */
+ OI_HCIERR_HOST_REJECTED_RESOURCES = 713, /**< HCI: protocol error 0x0D */
+ OI_HCIERR_HOST_REJECTED_SECURITY = 714, /**< HCI: protocol error 0x0E */
+ OI_HCIERR_HOST_REJECTED_PERSONAL_DEVICE = 715, /**< HCI: protocol error 0x0F */
+ OI_HCIERR_HOST_TIMEOUT = 716, /**< HCI: protocol error 0x10 */
+ OI_HCIERR_UNSUPPORTED = 717, /**< HCI: protocol error 0x11 */
+ OI_HCIERR_INVALID_PARAMETERS = 718, /**< HCI: protocol error 0x12 */
+ OI_HCIERR_OTHER_END_USER_DISCONNECT = 719, /**< HCI: protocol error 0x13 */
+ OI_HCIERR_OTHER_END_LOW_RESOURCES = 720, /**< HCI: protocol error 0x14 */
+ OI_HCIERR_OTHER_END_POWERING_OFF = 721, /**< HCI: protocol error 0x15 */
+ OI_HCIERR_CONNECTION_TERMINATED_LOCALLY = 722, /**< HCI: protocol error 0x16 */
+ OI_HCIERR_REPEATED_ATTEMPTS = 723, /**< HCI: protocol error 0x17 */
+ OI_HCIERR_PAIRING_NOT_ALLOWED = 724, /**< HCI: protocol error 0x18 */
+ OI_HCIERR_UNKNOWN_LMP_PDU = 725, /**< HCI: protocol error 0x19 */
+ OI_HCIERR_UNSUPPORTED_REMOTE_FEATURE = 726, /**< HCI: protocol error 0x1A */
+ OI_HCIERR_SCO_OFFSET_REJECTED = 727, /**< HCI: protocol error 0x1B */
+ OI_HCIERR_SCO_INTERVAL_REJECTED = 728, /**< HCI: protocol error 0x1C */
+ OI_HCIERR_SCO_AIR_MODE_REJECTED = 729, /**< HCI: protocol error 0x1D */
+ OI_HCIERR_INVALID_LMP_PARMS = 730, /**< HCI: protocol error 0x1E */
+ OI_HCIERR_UNSPECIFIED_ERROR = 731, /**< HCI: protocol error 0x1F */
+ OI_HCIERR_UNSUPPORTED_LMP_PARAMETERS = 732, /**< HCI: protocol error 0x20 */
+ OI_HCIERR_ROLE_CHANGE_NOT_ALLOWED = 733, /**< HCI: protocol error 0x21 */
+ OI_HCIERR_LMP_RESPONSE_TIMEOUT = 734, /**< HCI: protocol error 0x22 */
+ OI_HCIERR_LMP_ERROR_TRANS_COLLISION = 735, /**< HCI: protocol error 0x23 */
+ OI_HCIERR_LMP_PDU_NOT_ALLOWED = 736, /**< HCI: protocol error 0x24 */
+ OI_HCIERR_ENCRYPTION_MODE_NOT_ACCEPTABLE = 737, /**< HCI: protocol error 0x25 */
+ OI_HCIERR_UNIT_KEY_USED = 738, /**< HCI: protocol error 0x26 */
+ OI_HCIERR_QOS_NOT_SUPPORTED = 739, /**< HCI: protocol error 0x27 */
+ OI_HCIERR_INSTANT_PASSED = 740, /**< HCI: protocol error 0x28 */
+ OI_HCIERR_UNIT_KEY_PAIRING_UNSUPPORTED = 741, /**< HCI: protocol error 0x29 */
+ OI_HCIERR_DIFFERENT_TRANS_COLLISION = 742, /**< HCI: protocol error 0x2A */
+ OI_HCIERR_RESERVED_2B = 743, /**< HCI: protocol error 0x2B */
+ OI_HCIERR_QOS_UNACCEPTABLE_PARAMETER = 744, /**< HCI: protocol error 0x2C */
+ OI_HCIERR_QOS_REJECTED = 745, /**< HCI: protocol error 0x2D */
+ OI_HCIERR_CHANNEL_CLASSIFICATION_NS = 746, /**< HCI: protocol error 0x2E */
+ OI_HCIERR_INSUFFICIENT_SECURITY = 747, /**< HCI: protocol error 0x2F */
+ OI_HCIERR_PARM_OUT_OF_MANDATORY_RANGE = 748, /**< HCI: protocol error 0x30 */
+ OI_HCIERR_RESERVED_31 = 749, /**< HCI: protocol error 0x31 */
+ OI_HCIERR_ROLE_SWITCH_PENDING = 750, /**< HCI: protocol error 0x32 */
+ OI_HCIERR_RESERVED_33 = 751, /**< HCI: protocol error 0x33 */
+ OI_HCIERR_RESERVED_SLOT_VIOLATION = 752, /**< HCI: protocol error 0x34 */
+ OI_HCIERR_ROLE_SWITCH_FAILED = 753, /**< HCI: protocol error 0x35 */
+ OI_HCIERR_EIR_TOO_LARGE = 754, /**< HCI: protocol error 0x36 */
+ OI_HCIERR_SSP_NOT_SUPPORTED_BY_HOST = 755, /**< HCI: protocol error 0x37 */
+ OI_HCIERR_HOST_BUSY_PAIRING = 756, /**< HCI: protocol error 0x38 */
+
+ OI_HCIERR_UNKNOWN_ERROR = 757, /**< HCI: unknown error code */
+ OI_HCIERR_LAST_ERROR_VALUE = 757, /**< marker for last HCI protocol error */
+
+ OI_SDP_SPEC_ERROR = 800, /**< SDP: Base error status for mapping OI_STATUS codes to SDP errors */
+ OI_SDP_INVALID_SERVICE_RECORD_HANDLE = (OI_SDP_SPEC_ERROR + 2), /**< SDP: protocol error Invalid Service Record Handle */
+ OI_SDP_INVALID_REQUEST_SYNTAX = (OI_SDP_SPEC_ERROR + 3), /**< SDP: protocol error Invalid Request Syntax */
+ OI_SDP_INVALID_PDU_SIZE = (OI_SDP_SPEC_ERROR + 4), /**< SDP: protocol error Invalid PDU Size */
+ OI_SDP_INVALID_CONTINUATION_STATE = (OI_SDP_SPEC_ERROR + 5), /**< SDP: protocol error Invalid Continuation State */
+ OI_SDP_INSUFFICIENT_RESOURCES = (OI_SDP_SPEC_ERROR + 6), /**< SDP: protocol error Insufficient Resources */
+ OI_SDP_ERROR = 807, /**< SDP: server returned an error code */
+ OI_SDP_CORRUPT_DATA_ELEMENT = 808, /**< SDP: Invalid or corrupt data element representation */
+ OI_SDP_SERVER_NOT_CONNECTED = 810, /**< SDP: Attempt to disconnect from an unconnected server */
+ OI_SDP_ACCESS_DENIED = 811, /**< SDP: Server denied access to server */
+ OI_SDP_ATTRIBUTES_OUT_OF_ORDER = 812, /**< SDP: Attributes in attribute list not in ascending order */
+ OI_SDP_DEVICE_DOES_NOT_SUPPORT_SDP = 813, /**< SDP: Tried to connect to a device that does not support SDP */
+ OI_SDP_NO_MORE_DATA = 815, /**< SDP: Server does not have more continuation data */
+ OI_SDP_REQUEST_PARAMS_TOO_LONG = 816, /**< SDP: Parameters for a request exceed the L2CAP buffer size */
+ OI_SDP_REQUEST_PENDING = 817, /**< SDP: Cannot make a request when another request is being processed */
+ OI_SDP_SERVER_CONNECT_FAILED = 819, /**< SDP: Failed attempt to connect to an SDP server */
+ OI_SDP_SERVER_TOO_MANY_CONNECTIONS = 821, /**< SDP: Exceeded maximum number of simultaneous server connections */
+ OI_SDP_NO_MATCHING_SERVICE_RECORD = 823, /**< SDP: No service record matched the UUID list */
+ OI_SDP_PARTIAL_RESPONSE = 824, /**< SDP: Internal use only */
+ OI_SDP_ILLEGAL_ARGUMENT = 825, /**< SDP: Illegal argument passed to an SDP function */
+ OI_SDP_ATTRIBUTE_NOT_FOUND = 826, /**< SDP: A requested attribute was not found in a service record */
+ OI_SDP_DATABASE_OUT_OF_RESOURCES = 827, /**< SDP: server database is out of memory */
+ OI_SDP_SHORT_PDU = 829, /**< SDP: Not enough bytes in the packet */
+ OI_SDP_TRANSACTION_ID_MISMATCH = 830, /**< SDP: Transaction Id was not as expected */
+ OI_SDP_UNEXPECTED_RESPONSE_PDU_ID = 831, /**< SDP: Did not expect this response PDU */
+ OI_SDP_REQUEST_TIMEOUT = 832, /**< SDP: Did not get a response within the timeout period */
+ OI_SDP_INVALID_RESPONSE_SYNTAX = 833, /**< SDP: Response is not correctly formatted */
+ OI_SDP_CONNECTION_TIMEOUT = 834, /**< SDP: Connection attempt timed out at a lower layer */
+ OI_SDP_RESPONSE_DATA_ERROR = 835, /**< SDP: Response to a service request appears to be corrupt */
+ OI_SDP_TOO_MANY_ATTRIBUTE_BYTES = 836, /**< SDP: Response contained more bytes than requested. */
+ OI_SDP_TOO_MANY_SERVICE_RECORDS = 837, /**< SDP: Response contained more service records than requested. */
+ OI_SDP_INVALID_CONNECTION_ID = 838, /**< SDP: Invalid connection ID in an SDP request */
+ OI_SDP_CANNOT_SET_ATTRIBUTE = 839, /**< SDP: Attempt to set a dynamic attribute value failed */
+ OI_SDP_BADLY_FORMED_ATTRIBUTE_VALUE = 840, /**< SDP: An attribute value has the wrong type or structure */
+ OI_SDP_NO_ATTRIBUTE_LIST_TO_REMOVE = 841, /**< SDP: Attempt to remove a non-existent attribute list from a service record */
+ OI_SDP_ATTRIBUTE_LIST_ALREADY_ADDED = 842, /**< SDP: An attribute list has already been added to the service record */
+ OI_SDP_DATA_ELEMENT_TRUNCATED = 843, /**< SDP: Data element truncated (too few bytes) */
+
+ OI_RFCOMM_WRITE_IN_PROGRESS = 901, /**< RFCOMM: Write in progress */
+ OI_RFCOMM_INVALID_BAUDRATE = 903, /**< RFCOMM: Invalid baudrate */
+ OI_RFCOMM_INVALID_DATABIT = 904, /**< RFCOMM: Invalid databit */
+ OI_RFCOMM_INVALID_STOPBIT = 905, /**< RFCOMM: Invalid stopbit */
+ OI_RFCOMM_INVALID_PARITY = 906, /**< RFCOMM: Invalid parity */
+ OI_RFCOMM_INVALID_PARITYTYPE = 907, /**< RFCOMM: Invalid paritytype */
+ OI_RFCOMM_INVALID_FLOWCONTROL = 908, /**< RFCOMM: Invalid flowcontrol */
+ OI_RFCOMM_SESSION_EXISTS = 909, /**< RFCOMM: Session exists */
+ OI_RFCOMM_INVALID_CHANNEL = 910, /**< RFCOMM: Invalid channel */
+ OI_RFCOMM_DLCI_EXISTS = 911, /**< RFCOMM: DLCI exists */
+ OI_RFCOMM_LINK_NOT_FOUND = 912, /**< RFCOMM: Link not found */
+ OI_RFCOMM_REMOTE_REJECT = 913, /**< RFCOMM: Remote reject */
+ OI_RFCOMM_TEST_IN_PROGRESS = 915, /**< RFCOMM: Test in progress */
+ OI_RFCOMM_SESSION_NOT_FOUND = 916, /**< RFCOMM: Session not found */
+ OI_RFCOMM_INVALID_PACKET = 917, /**< RFCOMM: Invalid packet */
+ OI_RFCOMM_FRAMESIZE_EXCEEDED = 918, /**< RFCOMM: Framesize exceeded */
+ OI_RFCOMM_INVALID_DLCI = 920, /**< RFCOMM: Invalid dlci */
+ OI_RFCOMM_SERVER_NOT_REGISTERED = 921, /**< RFCOMM: Server not registered */
+ OI_RFCOMM_CREDIT_ERROR = 922, /**< RFCOMM: Credit error */
+ OI_RFCOMM_NO_CHANNEL_NUMBER = 923, /**< RFCOMM: No channel number */
+ OI_RFCOMM_QUERY_IN_PROGRESS = 924, /**< RFCOMM: Query in progress */
+ OI_RFCOMM_SESSION_SHUTDOWN = 925, /**< RFCOMM: Session shutdown */
+ OI_RFCOMM_LOCAL_DEVICE_DISCONNECTED = 926, /**< RFCOMM: Local device disconnected */
+ OI_RFCOMM_REMOTE_DEVICE_DISCONNECTED = 927, /**< RFCOMM: Remote device disconnected */
+ OI_RFCOMM_OUT_OF_SERVER_CHANNELS = 928, /**< RFCOMM: Out of server channels */
+
+ OI_DISPATCH_INVALID_CB_HANDLE = 1001, /**< Dispatcher was handed an invalid callback handle */
+ OI_DISPATCH_TABLE_OVERFLOW = 1002, /**< Dispatcher table is full */
+
+ OI_TEST_UNKNOWN_TEST = 1101, /**< TEST: Unknown test */
+ OI_TEST_FAIL = 1102, /**< TEST: Fail */
+
+ OI_HCITRANS_CANNOT_CONNECT_TO_DEVICE = 1201, /**< TRANSPORT: Cannot connect to device */
+ OI_HCITRANS_BUFFER_TOO_SMALL = 1203, /**< TRANSPORT: Buffer too small */
+ OI_HCITRANS_NULL_DEVICE_HANDLE = 1204, /**< TRANSPORT: Null device handle */
+ OI_HCITRANS_IO_ERROR = 1205, /**< TRANSPORT: IO error */
+ OI_HCITRANS_DEVICE_NOT_READY = 1206, /**< TRANSPORT: Device not ready */
+ OI_HCITRANS_FUNCTION_NOT_SUPPORTED = 1207, /**< TRANSPORT: Function not supporteD */
+ OI_HCITRANS_ACCESS_DENIED = 1209, /**< TRANSPORT: win32 */
+ OI_HCITRANS_ACL_DATA_ERROR = 1210, /**< TRANSPORT: ACL data error */
+ OI_HCITRANS_SCO_DATA_ERROR = 1211, /**< TRANSPORT: SCO data error */
+ OI_HCITRANS_EVENT_DATA_ERROR = 1212, /**< TRANSPORT: HCI event data error */
+ OI_HCITRANS_INTERNAL_ERROR = 1214, /**< TRANSPORT: Internal error in the transport */
+ OI_HCITRANS_LINK_NOT_ACTIVE = 1215, /**< TRANSPORT: Link to the device is not currently active */
+ OI_HCITRANS_INITIALIZING = 1216, /**< TRANSPORT: Transport is initializing */
+
+ OI_DEVMGR_NO_CONNECTION = 1301, /**< DEVMGR: No connection */
+ OI_DEVMGR_HARDWARE_ERROR = 1305, /**< DEVMGR: error reported by HCI */
+ OI_DEVMGR_PENDING_CONNECT_LIST_FULL = 1307, /**< DEVMGR: Pending connect list full */
+ OI_DEVMGR_CONNECTION_LIST_FULL = 1309, /**< DEVMGR: Connection list full */
+ OI_DEVMGR_NO_SUCH_CONNECTION = 1310, /**< DEVMGR: No such connection */
+ OI_DEVMGR_INQUIRY_IN_PROGRESS = 1311, /**< DEVMGR: Inquiry in progress */
+ OI_DEVMGR_PERIODIC_INQUIRY_ACTIVE = 1312, /**< DEVMGR: Periodic inquiry active */
+ OI_DEVMGR_NO_INQUIRIES_ACTIVE = 1313, /**< DEVMGR: can not cancel/exit if not active */
+ OI_DEVMGR_DUPLICATE_CONNECTION = 1314, /**< DEVMGR: internal error */
+ OI_DEVMGR_DUPLICATE_EVENT_CALLBACK = 1316, /**< DEVMGR: attempt to register same callback twice */
+ OI_DEVMGR_EVENT_CALLBACK_LIST_FULL = 1317, /**< DEVMGR: can not register event callback, list is full */
+ OI_DEVMGR_EVENT_CALLBACK_NOT_FOUND = 1318, /**< DEVMGR: attempt to unregister callback failed */
+ OI_DEVMGR_BUSY = 1319, /**< DEVMGR: some operations can only execute one at a time */
+ OI_DEVMGR_ENUM_UNEXPECTED_INQ_COMPLETE = 1320, /**< DEVMGR: inquiry complete event in inappropriate enumeration state */
+ OI_DEVMGR_ENUM_UNEXPECTED_INQ_RESULT = 1321, /**< DEVMGR: inquiry result event in inappropriate enumeration state */
+ OI_DEVMGR_ENUM_DATABASE_FULL = 1322, /**< DEVMGR: device enumeration, database is full, couldn't add a new device */
+ OI_DEVMGR_ENUM_INQUIRIES_OVERLAP = 1323, /**< DEVMGR: device enumeration, periodic inquiries occurring too close together */
+ OI_DEVMGR_UNKNOWN_LINK_TYPE = 1324, /**< DEVMGR: HCI connect request with unkown link type */
+ OI_DEVMGR_PARAM_IO_ACTIVE = 1325, /**< DEVMGR: request for parameter read/write while param read/write active */
+ OI_DEVMGR_UNKNOWN_IAC_LAP = 1326, /**< DEVMGR: unrecognized IAC LAP */
+ OI_DEVMGR_SCO_ALREADY_REGISTERED = 1327, /**< DEVMGR: only one application can use SCO */
+ OI_DEVMGR_SCO_NOT_REGISTERED = 1328, /**< DEVMGR: SCO applications must register before using the API */
+ OI_DEVMGR_SCO_WITHOUT_ACL = 1329, /**< DEVMGR: Got SCO connection but there is no underlying ACL connection */
+ OI_DEVMGR_NO_SUPPORT = 1330, /**< DEVMGR: Request is not supported by the device */
+ OI_DEVMGR_WRITE_POLICY_FAILED = 1331, /**< DEVMGR: connection attempt failed - unable to write link policy */
+ OI_DEVMGR_NOT_IN_MASTER_MODE = 1332, /**< DEVMGR: OI_DEVMGR EndMasterMode without prior OI_DEVMGR_BeginMasterMode */
+ OI_DEVMGR_POLICY_VIOLATION = 1333, /**< DEVMGR: low-power request is rejected - link policy does not allow it */
+ OI_DEVMGR_BUSY_TIMEOUT = 1334, /**< DEVMGR: queued operation timed out while in the queue; \n
+ timeout configurable via @ref OI_CONFIG_DEVMGR::connectQueueTimeoutSecs "connectQueueTimeoutSecs" */
+ OI_DEVMGR_REENCRYPT_FAILED = 1335, /**< DEVMGR: failed to re-encrypt link after role switch */
+ OI_DEVMGR_ROLE_POLICY_CONFLICT = 1336, /**< DEVMGR: requested role conflicts with current policy */
+ OI_DEVMGR_BAD_INTERVAL = 1337, /**< DEVMGR: current linkTO outside range of requested min/max interval */
+ OI_DEVMGR_INVALID_SCO_HANDLE = 1338, /**< DEVMGR: HCI SCO event, invalid handle */
+ OI_DEVMGR_CONNECTION_OVERLAP = 1339, /**< DEVMGR: Connection failed due to race condition with remote side */
+ OI_DEVMGR_ORPHAN_SUBRATE_COMPLETE = 1340, /**< DEVMGR: sniff subrate complete, but no callback */
+ OI_DEVMGR_EIR_RESPONSE_2_LARGE = 1341, /**< DEVMGR: eir builder, response length would exceed spec max */
+
+ OI_SECMGR_NO_POLICY = 1401, /**< SECMGR: no security policy has been established */
+ OI_SECMGR_INTERNAL_ERROR = 1402, /**< SECMGR: internal inconsistency */
+ OI_SECMGR_ORPHANED_CALLBACK = 1403, /**< SECMGR: we've been called back, but CB context is gone */
+ OI_SECMGR_BUSY = 1404, /**< SECMGR: configure and access request cannot be concurrent */
+ OI_SECMGR_DEVICE_NOT_TRUSTED = 1405, /**< SECMGR: l2cap access denied - device is not trusted */
+ OI_SECMGR_DEVICE_ENCRYPT_FAIL = 1407, /**< SECMGR: l2cap access denied - failed to start encryption */
+ OI_SECMGR_DISCONNECTED_FAIL = 1408, /**< SECMGR: l2cap access denied - disconnected */
+ OI_SECMGR_ACCESS_PENDING = 1409, /**< SECMGR: l2cap access request is still pending */
+ OI_SECMGR_PIN_CODE_TOO_SHORT = 1410, /**< SECMGR: Higher-layer process gave us a pin code that is too short */
+ OI_SECMGR_UNKNOWN_ENCRYPT_VALUE = 1411, /**< SECMGR: got EncryptionChange event, unknown encryption enable value */
+ OI_SECMGR_INVALID_POLICY = 1412, /**< SECMGR: the specified security policy is not valid for security mode */
+ OI_SECMGR_AUTHORIZATION_FAILED = 1413, /**< SECMGR: device authorization failed */
+ OI_SECMGR_ENCRYPTION_FAILED = 1414, /**< SECMGR: device encryption failed */
+ OI_SECMGR_UNIT_KEY_UNSUPPORTED = 1415, /**< SECMGR: authentication failed due to non-support of unit keys */
+ OI_SECMGR_NOT_REGISTERED = 1416, /**< SECMGR: required registrations have not yet occurred */
+ OI_SECMGR_ILLEGAL_WRITE_SSP_MODE = 1417, /**< SECMGR: 2.1 HCI spec does not allow SSP mode to be disabled */
+ OI_SECMGR_INVALID_SEC_LEVEL = 1418, /**< SECMGR: security level for a service is not a valid value */
+ OI_SECMGR_INSUFFICIENT_LINK_KEY = 1419, /**< SECMGR: link key type is not sufficient to meet service requirements */
+ OI_SECMGR_INVALID_KEY_TYPE = 1420, /**< SECMGR: link key type is not a valid value */
+ OI_SECMGR_SSP_NOT_ENCRYPTED = 1421, /**< SECMGR: ssp required encryption on incoming link */
+ OI_SECMGR_ORPHAN_EVENT = 1422, /**< SECMGR: some HCI security event unrelated to current processes */
+ OI_SECMGR_NOT_BONDABLE = 1423, /**< SECMGR: not in bondable mode */
+
+ OI_TCS_INVALID_ELEMENT_TYPE = 1602, /**< TCS: element type is invalid */
+ OI_TCS_INVALID_PACKET = 1603, /**< TCS: packet is invalide */
+ OI_TCS_CALL_IN_PROGRESS = 1604, /**< TCS: call is in progress */
+ OI_TCS_NO_CALL_IN_PROGRESS = 1605, /**< TCS: no call in progress */
+
+ OI_OBEX_CONTINUE = 1701, /**< OBEX: Continue processing OBEX request */
+ OI_OBEX_COMMAND_ERROR = 1702, /**< OBEX: An unrecognized OBEX command opcode */
+ OI_OBEX_CONNECTION_TIMEOUT = 1703, /**< OBEX: Timeout waiting for a response to a request */
+ OI_OBEX_CONNECT_FAILED = 1704, /**< OBEX: An OBEX connection request did not succeed */
+ OI_OBEX_DISCONNECT_FAILED = 1705, /**< OBEX: A disconnect failed probably because the connection did not exist */
+ OI_OBEX_ERROR = 1706, /**< OBEX: Unspecified OBEX error */
+ OI_OBEX_INCOMPLETE_PACKET = 1707, /**< OBEX: Packet too short or corrupt */
+ OI_OBEX_LENGTH_REQUIRED = 1708, /**< OBEX: Length header required in OBEX command */
+ OI_OBEX_NOT_CONNECTED = 1709, /**< OBEX: No connection to OBEX server */
+ OI_OBEX_NO_MORE_CONNECTIONS = 1710, /**< OBEX: Reached max connections limit */
+ OI_OBEX_OPERATION_IN_PROGRESS = 1711, /**< OBEX: Another operation is still in progress on a connection */
+ OI_OBEX_PUT_RESPONSE_ERROR = 1712, /**< OBEX: An error in the response to a PUT command */
+ OI_OBEX_GET_RESPONSE_ERROR = 1713, /**< OBEX: An error in the response to a GET command */
+ OI_OBEX_REQUIRED_HEADER_NOT_FOUND = 1714, /**< OBEX: packet was missing a required header */
+ OI_OBEX_SERVICE_UNAVAILABLE = 1715, /**< OBEX: Unown OBEX target or required service */
+ OI_OBEX_TOO_MANY_HEADER_BYTES = 1716, /**< OBEX: Headers will not fit in single OBEX packet */
+ OI_OBEX_UNKNOWN_COMMAND = 1717, /**< OBEX: Unrecognized OBEX command */
+ OI_OBEX_UNSUPPORTED_VERSION = 1718, /**< OBEX: Version mismatch */
+ OI_OBEX_CLIENT_ABORTED_COMMAND = 1719, /**< OBEX: server received abort command */
+ OI_OBEX_BAD_PACKET = 1720, /**< OBEX: Any malformed OBEX packet */
+ OI_OBEX_BAD_REQUEST = 1721, /**< OBEX: Maps to OBEX response of the same name */
+ OI_OBEX_OBJECT_OVERFLOW = 1723, /**< OBEX: Too many bytes received. */
+ OI_OBEX_NOT_FOUND = 1724, /**< OBEX: Maps to obex response of same name */
+ OI_OBEX_ACCESS_DENIED = 1735, /**< OBEX: Object could not be read or written. */
+ OI_OBEX_VALUE_NOT_ACCEPTABLE = 1736, /**< OBEX: Value in a command was not in the acceptable range. */
+ OI_OBEX_PACKET_OVERFLOW = 1737, /**< OBEX: Buffer will not fit in a single OBEX packet. */
+ OI_OBEX_NO_SUCH_FOLDER = 1738, /**< OBEX: Error returned by a setpath operation. */
+ OI_OBEX_NAME_REQUIRED = 1739, /**< OBEX: Name must be non-null and non-empty. */
+ OI_OBEX_PASSWORD_TOO_LONG = 1740, /**< OBEX: Password exceeds implementation imposed length limit. */
+ OI_OBEX_PRECONDITION_FAILED = 1741, /**< OBEX: response Precondition Failed */
+ OI_OBEX_UNAUTHORIZED = 1742, /**< OBEX: authentication was not successful. */
+ OI_OBEX_NOT_IMPLEMENTED = 1743, /**< OBEX: Unimplemented feature. */
+ OI_OBEX_INVALID_AUTH_DIGEST = 1744, /**< OBEX: An authentication digest was bad. */
+ OI_OBEX_INVALID_OPERATION = 1745, /**< OBEX: Operation not allowed at this time. */
+ OI_OBEX_DATABASE_FULL = 1746, /**< OBEX: Sync database full. */
+ OI_OBEX_DATABASE_LOCKED = 1747, /**< OBEX: Sync database locked. */
+ OI_OBEX_INTERNAL_SERVER_ERROR = 1748, /**< OBEX: response Internal Server Error */
+ OI_OBEX_UNSUPPORTED_MEDIA_TYPE = 1749, /**< OBEX: response Unsupported Media Type */
+ OI_OBEX_PARTIAL_CONTENT = 1750, /**< OBEX: response Partial Content */
+ OI_OBEX_METHOD_NOT_ALLOWED = 1751, /**< OBEX: response Method Not Allowed */
+ OI_OBEXSRV_INCOMPLETE_GET = 1752, /**< OBEX: Indicates to a GET handler that the request phase is still in progress */
+ OI_OBEX_FOLDER_BROWSING_NOT_ALLOWED = 1753, /**< OBEX: Indicates that an FTP server does not allow folder browsing */
+ OI_OBEX_SERVER_FORCED_DISCONNECT = 1754, /**< OBEX: connection was forcibly terminated by the server */
+ OI_OBEX_OFS_ERROR = 1755, /**< OBEX: OPP object file system error occurred */
+ OI_OBEX_FILEOP_ERROR = 1756, /**< OBEX: FTP/PBAP file operation system error occurred */
+ OI_OBEX_USERID_TOO_LONG = 1757, /**< OBEX: User Id exceeds spec limited length limit. */
+
+ OI_HANDSFREE_EVENT_REPORTING_DISABLED = 1801, /**< HANDSFREE: Event reporting disabled */
+ OI_HANDSFREE_NOT_CONNECTED = 1802, /**< HANDSFREE: Not connected */
+ OI_HANDSFREE_SERVICE_NOT_STARTED = 1803, /**< HANDSFREE: Cannot connect to handsfree AG if handsfree service not started */
+ OI_HANDSFREE_AG_SERVICE_NOT_STARTED = 1804, /**< HANDSFREE: Cannot connect to handsfree device if handsfree AG service not started */
+ OI_HANDSFREE_COMMAND_IN_PROGRESS = 1805, /**< HANDSFREE: Cannot accept a command at this time */
+ OI_HANDSFREE_AUDIO_ALREADY_CONNECTED = 1806, /**< HANDSFREE: Audio is already connected */
+ OI_HANDSFREE_AUDIO_NOT_CONNECTED = 1807, /**< HANDSFREE: Audio is not connected */
+ OI_HANDSFREE_FEATURE_NOT_SUPPORTED = 1808, /**< HANDSFREE: Local or remote feature not supported for requested command */
+
+ OI_HEADSET_SERVICE_NOT_STARTED = 1901, /**< HEADSET: Cannot connect to headset AG if headset service not started */
+ OI_HEADSET_AG_SERVICE_NOT_STARTED = 1902, /**< HEADSET: Cannot connect to headset device if headset AG service not started */
+ OI_HEADSET_COMMAND_IN_PROGRESS = 1903, /**< HEADSET: Cannot accept a command at this time */
+
+ OI_BNEP_INVALID_MTU = 2001, /**< BNEP: The remote device cannot support the minimum BNEP MTU */
+ OI_BNEP_SETUP_TIMEOUT = 2002, /**< BNEP: The setup request timed out. */
+ OI_BNEP_SERVICE_NOT_REGISTERED = 2003, /**< BNEP: The requested service was not found. */
+ OI_BNEP_INVALID_HANDLE = 2004, /**< BNEP: The specified connection handle is not valid. */
+ OI_BNEP_RESPONSE_TIMEOUT = 2005, /**< BNEP: The timer for receiving a response has expired. */
+ OI_BNEP_INVALID_CONNECTION = 2006, /**< BNEP: Invalid connection */
+ OI_BNEP_INVALID_FILTER = 2007, /**< BNEP: The supplied filter was invalid. */
+ OI_BNEP_CONNECTION_EXISTS = 2008, /**< BNEP: An attempt was made to create a duplicate connection. */
+ OI_BNEP_NOT_INITIALIZED = 2009, /**< BNEP: Init has not been called */
+ OI_BNEP_CONNECT_BASE = 2010, /**< BNEP: connection response codes */
+ OI_BNEP_CONNECT_FAILED_INVALID_DEST_UUID = 2011, /**< BNEP: connect response code Invalid Dest UUID */
+ OI_BNEP_CONNECT_FAILED_INVALID_SOURCE_UUID = 2012, /**< BNEP: connect response code Invalid Source UUID */
+ OI_BNEP_CONNECT_FAILED_INVALID_UUID_SIZE = 2013, /**< BNEP: connect response code Invalid UUID Size */
+ OI_BNEP_CONNECT_FAILED_NOT_ALLOWED = 2014, /**< BNEP: connect response code Not Allowed */
+ OI_BNEP_FILTER_NET_BASE = 2020, /**< BNEP: filter response codes */
+ OI_BNEP_FILTER_NET_UNSUPPORTED_REQUEST = 2021, /**< BNEP: filter response code Unsupported Request */
+ OI_BNEP_FILTER_NET_FAILED_INVALID_PROTOCOL_TYPE = 2022, /**< BNEP: filter response code Invalid Protocol Type */
+ OI_BNEP_FILTER_NET_FAILED_MAX_LIMIT_REACHED = 2023, /**< BNEP: filter response code Max Limit Reached */
+ OI_BNEP_FILTER_NET_FAILED_SECURITY = 2024, /**< BNEP: filter response code Security */
+ OI_BNEP_FILTER_MULTI_BASE = 2030, /**< BNEP: multicast response codes */
+ OI_BNEP_FILTER_MULTI_UNSUPPORTED_REQUEST = 2031, /**< BNEP: multicast response code Unsupported Request */
+ OI_BNEP_FILTER_MULTI_FAILED_INVALID_ADDRESS = 2032, /**< BNEP: multicast response code Invalid Address */
+ OI_BNEP_FILTER_MULTI_FAILED_MAX_LIMIT_REACHED = 2033, /**< BNEP: multicast response code Max Limit Reached */
+ OI_BNEP_FILTER_MULTI_FAILED_SECURITY = 2034, /**< BNEP: multicast response code Security */
+ OI_BNEP_LOCAL_DEVICE_MUST_BE_MASTER = 2040, /**< BNEP: Device must be master of the piconet for this function */
+ OI_BNEP_PACKET_FILTERED_OUT = 2041, /**< BNEP: Packet did not pass current filters */
+
+ OI_NETIFC_UP_FAILED = 2101, /**< NETIFC: Could not bring up network interface */
+ OI_NETIFC_COULD_NOT_CREATE_THREAD = 2102, /**< NETIFC: Network interface could not create a read thread */
+ OI_NETIFC_INITIALIZATION_FAILED = 2103, /**< NETIFC: Error in network interface initialization */
+ OI_NETIFC_INTERFACE_ALREADY_UP = 2104, /**< NETIFC: Network interface is already up */
+ OI_NETIFC_INTERFACE_NOT_UP = 2105, /**< NETIFC: Network interface is not up */
+ OI_NETIFC_PACKET_TOO_BIG = 2106, /**< NETIFC: The packet is too big */
+
+ OI_PAN_ROLE_ALREADY_REGISTERED = 2201, /**< PAN: This PAN role was already registered */
+ OI_PAN_ROLE_NOT_ALLOWED = 2202, /**< PAN: The PAN role is not currently allowed */
+ OI_PAN_INCOMPATIBLE_ROLES = 2203, /**< PAN: Only certain local and remote role combinations are permitted */
+ OI_PAN_INVALID_ROLE = 2204, /**< PAN: Role specified is not one the defined PAN roles */
+ OI_PAN_CONNECTION_IN_PROGRESS = 2205, /**< PAN: A PAN connection is currently being established */
+ OI_PAN_USER_ALREADY_CONNECTED = 2206, /**< PAN: PAN user role only allows a single connection */
+ OI_PAN_DEVICE_CONNECTED = 2207, /**< PAN: A PAN connection already exists to specified device */
+
+ OI_CODEC_SBC_NO_SYNCWORD = 2301, /**< CODEC: Couldn't find an SBC SYNCWORD */
+ OI_CODEC_SBC_NOT_ENOUGH_HEADER_DATA = 2302, /**< CODEC: Not enough data provided to decode an SBC header */
+ OI_CODEC_SBC_NOT_ENOUGH_BODY_DATA = 2303, /**< CODEC: Decoded the header, but not enough data to contain the rest of the frame */
+ OI_CODEC_SBC_NOT_ENOUGH_AUDIO_DATA = 2304, /**< CODEC: Not enough audio data for this frame */
+ OI_CODEC_SBC_CHECKSUM_MISMATCH = 2305, /**< CODEC: The frame header didn't match the checksum */
+ OI_CODEC_SBC_PARTIAL_DECODE = 2306, /**< CODEC: Decoding was successful, but frame data still remains. Next call will provide audio without consuming input data. */
+
+ OI_FIFOQ_QUEUE_NOT_ALIGNED = 2401, /**< FIFOQ: queue must be 32-bit aligned */
+ OI_FIFOQ_INVALID_Q = 2402, /**< FIFOQ: queue parameter is not a valid queue */
+ OI_FIFOQ_BUF_TOO_LARGE = 2403, /**< FIFOQ: attempt to queue a buffer which is too large */
+ OI_FIFOQ_FULL = 2404, /**< FIFOQ: enqueue() failed, queue is full */
+ OI_FIFOQ_NOT_ALLOCATED = 2405, /**< FIFOQ: Enqueue QBuf() failed, buffer not allocated */
+ OI_FIFOQ_INVALID_DATA_PTR = 2406, /**< FIFOQ: Enqueue QBuf() failed, data pointer does not match */
+
+ OI_HID_HOST_SERVICE_NOT_STARTED = 2601, /**< HID: Cannot connect to a HID device unless HID host is started */
+ OI_HID_DEVICE_SERVICE_NOT_STARTED = 2602, /**< HID: Cannot connect to a HID host unless HID device is started */
+
+ OI_AT_ERROR = 2701, /**< AT: ERROR response */
+ OI_AT_NO_CARRIER = 2702, /**< AT: NO CARRIER response */
+ OI_AT_BUSY = 2703, /**< AT: BUSY response */
+ OI_AT_NO_ANSWER = 2704, /**< AT: NO ANSWER response */
+ OI_AT_DELAYED = 2705, /**< AT: DELAYED response */
+ OI_AT_BLACKLISTED = 2706, /**< AT: BLACKLISTED response */
+ OI_AT_CME_ERROR = 2707, /**< AT: +CME ERROR response */
+ OI_AT_CMS_ERROR = 2708, /**< AT: +CMS ERROR response */
+
+ OI_BLST_CHARACTER_TIMEOUT = 2801, /**< BLST: Timeout expired while waiting for a character from the client. */
+ OI_BLST_ACKNOWLDGE_TIMEOUT = 2802, /**< BLST: Timeout expired while waiting for event acknowledgment from the client */
+ OI_BLST_TX_NOT_READY = 2803, /**< BLST: BLST is not ready to send a BHAPI message to the client. */
+ OI_BLST_TX_BUSY = 2804, /**< BLST: BLST transmit buffer is in use. */
+
+ OI_AVDTP_CONNECTION_SEQ_ERROR = 2901, /**< AVDTP: sequencing of signalling/media channel connections broken. */
+ OI_AVDTP_OUT_OF_RESOURCES = 2902, /**< AVDTP: Tried to allocate too many endpoints or signalling channels. */
+
+ OI_PBAP_REPOSITORY_NOT_SET = 3001, /**< PBAP: Phonebook repository must be set for operation to complete. */
+ OI_PBAP_PHONEBOOK_NOT_SET = 3002, /**< PBAP: Phonebook be set for operation to complete. */
+
+ OI_AADP_BAD_ENDPOINT = 3101, /**< AADP: Invalid local endpoint specified */
+ OI_AADP_BAD_STATE = 3102, /**< AADP: AADP State is not correct for this operation. */
+
+ OI_UNICODE_INVALID_SOURCE = 3200, /**< Unicode Conversion: Source string has invalid character encoding. */
+ OI_UNICODE_SOURCE_EXHAUSTED = 3201, /**< Unicode Conversion: Incomplete Unicode character at end of source buffer. */
+ OI_UNICODE_DESTINATION_EXHAUSTED = 3202, /**< Unicode Conversion: Destination buffer not large enough to hold resulting Unicode string. */
+
+ OI_AVRCP_TOO_MANY_CONNECTIONS = 3300, /**< AVRCP: Exceeded maximum number of simultaneous AVCTP connections. */
+ OI_AVRCP_NOT_IMPLEMENTED = 3301, /**< AVRCP: The target does not implement the command specified by the opcode and operand. */
+ OI_AVRCP_REJECTED = 3302, /**< AVRCP: The target cannot respond because of invalid operands in command packet. */
+ OI_AVRCP_INVALID_RESPONSE = 3303, /**< AVRCP: The controller received the response with invalid parameters */
+ OI_AVRCP_RESPONSE_PACKET_OVERFLOW = 3304, /**< AVRCP: The response message does not fir in one AVRCP packet (512 bytes), has to be fragmented. */
+ OI_AVRCP_RESPONSE_INVALID_PDU = 3305, /**< AVRCP: Command rejected: target received a PDU that it did not understand. */
+ OI_AVRCP_RESPONSE_INVALID_PARAMETER = 3306, /**< AVRCP: Command rejected: target received a PDU with a parameter ID that it did not understand. */
+ OI_AVRCP_RESPONSE_PARAMETER_NOT_FOUND = 3307, /**< AVRCP: Command rejected: specified parameter not found, sent if the parameter ID is understood, but content is wrong or corrupted.*/
+ OI_AVRCP_RESPONSE_INTERNAL_ERROR = 3308, /**< AVRCP: Command rejected: target detected other error conditions. */
+ OI_MAX_BM3_STATUS_VAL, /* Maximum BM3 status code */
+
+ /* Status code values reserved for BM3 SDK platform-specific implementations */
+ OI_STATUS_RESERVED_FOR_BCOT = 9000,
+
+ /* Status code values reserved for BHAPI products */
+ OI_STATUS_RESERVED_FOR_BHAPI = 9200,
+
+ /* Status code values reserved for Soundabout products */
+ OI_STATUS_RESERVED_FOR_SOUNDABOUT= 9400,
+
+ /*
+ * Status code values greater than or equal to this value are reserved for use by applications.
+ * However, because of differences between compilers, and differences between 16-bit and 32-bit
+ * platforms custom status codes should be in the 16-bit range, so status codes can range from 0
+ * to 65534, inclusive (65535 is reserved)
+ */
+ OI_STATUS_RESERVED_FOR_APPS = 10000,
+
+
+
+ OI_STATUS_NONE = 0xffff /**< Special status code to indicate that there is no status. (Only to be used for special cases involving OI_SLOG_ERROR() and OI_SLOG_WARNING().) */
+
+} OI_STATUS;
+
+
+/* Remeber to update the #define below when new reserved blocks are added to
+ * the list above. */
+#define OI_NUM_RESERVED_STATUS_BLOCKS 4 /**< Number of status code blocks reserved, including user apps */
+
+
+/**
+ * Test for success
+ */
+#define OI_SUCCESS(x) ((x) == OI_OK)
+
+/*****************************************************************************/
+#ifdef __cplusplus
+}
+#endif
+
+/**@}*/
+
+#endif /* _OI_STATUS_H */
+
diff --git a/embdrv/sbc/decoder/include/oi_stddefs.h b/embdrv/sbc/decoder/include/oi_stddefs.h
new file mode 100644
index 0000000..ec8c453
--- /dev/null
+++ b/embdrv/sbc/decoder/include/oi_stddefs.h
@@ -0,0 +1,232 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+#ifndef OI_STDDEFS_H
+#define OI_STDDEFS_H
+/**
+ * @file
+ * This file contains BM3 standard type definitions.
+ *
+ */
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+#include "oi_cpu_dep.h"
+
+/** \addtogroup Misc Miscellaneous APIs */
+/**@{*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef FALSE
+#define FALSE 0 /**< This define statement sets FALSE as a preprocessor alias for 0. */
+#endif
+
+#ifndef TRUE
+#define TRUE (!FALSE) /**< This define statement sets TRUE as a preprocessor alias for !FALSE. */
+#endif
+
+#ifdef HEW_TOOLCHAIN
+ #ifdef NULL
+ #undef NULL /**< Override HEW toolchain NULL definition */
+ #endif
+ #define NULL 0 /**< HEW toolchain does not allow us to compare (void*) type to function pointer */
+#else
+ #ifndef NULL
+ #define NULL ((void*)0) /**< This define statement sets NULL as a preprocessor alias for (void*)0 */
+ #endif
+#endif
+
+/**
+ * @name Maximum and minimum values for basic types
+ * @{
+ */
+#define OI_INT8_MIN ((OI_INT8)0x80) /**< decimal value: -128 */
+#define OI_INT8_MAX ((OI_INT8)0x7F) /**< decimal value: 127 */
+#define OI_INT16_MIN ((OI_INT16)0x8000) /**< decimal value: -32768 */
+#define OI_INT16_MAX ((OI_INT16)0x7FFF) /**< decimal value: 32767 */
+#define OI_INT32_MIN ((OI_INT32)0x80000000) /**< decimal value: -2,147,483,648 */
+#define OI_INT32_MAX ((OI_INT32)0x7FFFFFFF) /**< decimal value: 2,147,483,647 */
+#define OI_UINT8_MIN ((OI_UINT8)0) /**< decimal value: 0 */
+#define OI_UINT8_MAX ((OI_UINT8)0xFF) /**< decimal value: 255 */
+#define OI_UINT16_MIN ((OI_UINT16)0) /**< decimal value: 0 */
+#define OI_UINT16_MAX ((OI_UINT16)0xFFFF) /**< decimal value: 65535 */
+#define OI_UINT32_MIN ((OI_UINT32)0) /**< decimal value: 0 */
+#define OI_UINT32_MAX ((OI_UINT32)0xFFFFFFFF) /**< decimal value: 4,294,967,295 */
+
+/**
+ * @}
+ */
+
+/**
+ * @name Integer types required by the Service Discovery Protocol
+ * @{
+ */
+
+/** unsigned 64-bit integer as a structure of two unsigned 32-bit integers */
+typedef struct {
+ OI_UINT32 I1; /**< most significant 32 bits */
+ OI_UINT32 I2; /**< least significant 32 bits */
+} OI_UINT64;
+
+#define OI_UINT64_MIN { (OI_UINT32)0x00000000, (OI_UINT32)0x00000000 }
+#define OI_UINT64_MAX { (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF }
+
+/** signed 64-bit integer as a structure of one unsigned 32-bit integer and one signed 32-bit integer */
+typedef struct {
+ OI_INT32 I1; /**< most significant 32 bits as a signed integer */
+ OI_UINT32 I2; /**< least significant 32 bits as an unsigned integer */
+} OI_INT64;
+
+#define OI_INT64_MIN { (OI_INT32)0x80000000, (OI_UINT32)0x00000000 }
+#define OI_INT64_MAX { (OI_INT32)0X7FFFFFFF, (OI_UINT32)0XFFFFFFFF }
+
+/** unsigned 128-bit integer as a structure of four unsigned 32-bit integers */
+typedef struct {
+ OI_UINT32 I1; /**< most significant 32 bits */
+ OI_UINT32 I2; /**< second-most significant 32 bits */
+ OI_UINT32 I3; /**< third-most significant 32 bits */
+ OI_UINT32 I4; /**< least significant 32 bits */
+} OI_UINT128;
+
+#define OI_UINT128_MIN { (OI_UINT32)0x00000000, (OI_UINT32)0x00000000, (OI_UINT32)0x00000000, (OI_UINT32)0x00000000 }
+#define OI_UINT128_MAX { (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF }
+
+/** signed 128-bit integer as a structure of three unsigned 32-bit integers and one signed 32-bit integer */
+typedef struct {
+ OI_INT32 I1; /**< most significant 32 bits as a signed integer */
+ OI_UINT32 I2; /**< second-most significant 32 bits as an unsigned integer */
+ OI_UINT32 I3; /**< third-most significant 32 bits as an unsigned integer */
+ OI_UINT32 I4; /**< least significant 32 bits as an unsigned integer */
+} OI_INT128;
+
+#define OI_INT128_MIN { (OI_UINT32)0x80000000, (OI_UINT32)0x00000000, (OI_UINT32)0x00000000, (OI_UINT32)0x00000000 }
+#define OI_INT128_MAX { (OI_UINT32)0X7FFFFFFF, (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF }
+
+/**
+ * @}
+ */
+
+
+/**
+ * type for ASCII character data items
+ */
+typedef char OI_CHAR;
+
+/**
+ * type for double-byte character data items
+ */
+typedef OI_UINT16 OI_CHAR16;
+
+/**
+ * types for UTF encoded strings.
+ */
+typedef OI_UINT8 OI_UTF8;
+typedef OI_UINT16 OI_UTF16;
+typedef OI_UINT32 OI_UTF32;
+
+
+/**
+ * @name Single-bit operation macros
+ * @{
+ * In these macros, x is the data item for which a bit is to be tested or set and y specifies which bit
+ * is to be tested or set.
+ */
+
+/** This macro's value is TRUE if the bit specified by y is set in data item x. */
+#define OI_BIT_TEST(x,y) ((x) & (y))
+
+/** This macro's value is TRUE if the bit specified by y is not set in data item x. */
+#define OI_BIT_CLEAR_TEST(x,y) (((x) & (y)) == 0)
+
+/** This macro sets the bit specified by y in data item x. */
+#define OI_BIT_SET(x,y) ((x) |= (y))
+
+/** This macro clears the bit specified by y in data item x. */
+#define OI_BIT_CLEAR(x,y) ((x) &= ~(y))
+
+/** @} */
+
+/**
+ * The OI_ARRAYSIZE macro is set to the number of elements in an array
+ * (instead of the number of bytes, which is returned by sizeof()).
+ */
+
+#ifndef OI_ARRAYSIZE
+#define OI_ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
+#endif
+
+/**
+ * @name Preprocessor aliases for individual bit positions
+ * Bits are defined here only if they are not already defined.
+ * @{
+ */
+
+#ifndef BIT0
+
+#define BIT0 0x00000001 /**< preprocessor alias for 32-bit value with bit 0 set, used to specify this single bit */
+#define BIT1 0x00000002 /**< preprocessor alias for 32-bit value with bit 1 set, used to specify this single bit */
+#define BIT2 0x00000004 /**< preprocessor alias for 32-bit value with bit 2 set, used to specify this single bit */
+#define BIT3 0x00000008 /**< preprocessor alias for 32-bit value with bit 3 set, used to specify this single bit */
+#define BIT4 0x00000010 /**< preprocessor alias for 32-bit value with bit 4 set, used to specify this single bit */
+#define BIT5 0x00000020 /**< preprocessor alias for 32-bit value with bit 5 set, used to specify this single bit */
+#define BIT6 0x00000040 /**< preprocessor alias for 32-bit value with bit 6 set, used to specify this single bit */
+#define BIT7 0x00000080 /**< preprocessor alias for 32-bit value with bit 7 set, used to specify this single bit */
+#define BIT8 0x00000100 /**< preprocessor alias for 32-bit value with bit 8 set, used to specify this single bit */
+#define BIT9 0x00000200 /**< preprocessor alias for 32-bit value with bit 9 set, used to specify this single bit */
+#define BIT10 0x00000400 /**< preprocessor alias for 32-bit value with bit 10 set, used to specify this single bit */
+#define BIT11 0x00000800 /**< preprocessor alias for 32-bit value with bit 11 set, used to specify this single bit */
+#define BIT12 0x00001000 /**< preprocessor alias for 32-bit value with bit 12 set, used to specify this single bit */
+#define BIT13 0x00002000 /**< preprocessor alias for 32-bit value with bit 13 set, used to specify this single bit */
+#define BIT14 0x00004000 /**< preprocessor alias for 32-bit value with bit 14 set, used to specify this single bit */
+#define BIT15 0x00008000 /**< preprocessor alias for 32-bit value with bit 15 set, used to specify this single bit */
+#define BIT16 0x00010000 /**< preprocessor alias for 32-bit value with bit 16 set, used to specify this single bit */
+#define BIT17 0x00020000 /**< preprocessor alias for 32-bit value with bit 17 set, used to specify this single bit */
+#define BIT18 0x00040000 /**< preprocessor alias for 32-bit value with bit 18 set, used to specify this single bit */
+#define BIT19 0x00080000 /**< preprocessor alias for 32-bit value with bit 19 set, used to specify this single bit */
+#define BIT20 0x00100000 /**< preprocessor alias for 32-bit value with bit 20 set, used to specify this single bit */
+#define BIT21 0x00200000 /**< preprocessor alias for 32-bit value with bit 21 set, used to specify this single bit */
+#define BIT22 0x00400000 /**< preprocessor alias for 32-bit value with bit 22 set, used to specify this single bit */
+#define BIT23 0x00800000 /**< preprocessor alias for 32-bit value with bit 23 set, used to specify this single bit */
+#define BIT24 0x01000000 /**< preprocessor alias for 32-bit value with bit 24 set, used to specify this single bit */
+#define BIT25 0x02000000 /**< preprocessor alias for 32-bit value with bit 25 set, used to specify this single bit */
+#define BIT26 0x04000000 /**< preprocessor alias for 32-bit value with bit 26 set, used to specify this single bit */
+#define BIT27 0x08000000 /**< preprocessor alias for 32-bit value with bit 27 set, used to specify this single bit */
+#define BIT28 0x10000000 /**< preprocessor alias for 32-bit value with bit 28 set, used to specify this single bit */
+#define BIT29 0x20000000 /**< preprocessor alias for 32-bit value with bit 29 set, used to specify this single bit */
+#define BIT30 0x40000000 /**< preprocessor alias for 32-bit value with bit 30 set, used to specify this single bit */
+#define BIT31 0x80000000 /**< preprocessor alias for 32-bit value with bit 31 set, used to specify this single bit */
+
+#endif /* BIT0 et al */
+
+
+/** @} */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/**@}*/
+
+/*****************************************************************************/
+#endif /* OI_STDDEFS_H */
diff --git a/embdrv/sbc/decoder/include/oi_string.h b/embdrv/sbc/decoder/include/oi_string.h
new file mode 100644
index 0000000..1b12b5a
--- /dev/null
+++ b/embdrv/sbc/decoder/include/oi_string.h
@@ -0,0 +1,208 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+#ifndef OI_STRING_H
+#define OI_STRING_H
+/**
+ * @file
+ * This file contains BM3 supplied portable string.h functions
+ *
+ */
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+#include "oi_cpu_dep.h"
+#include "oi_stddefs.h"
+
+#if defined(USE_NATIVE_MEMCPY) || defined(USE_NATIVE_MALLOC)
+#include <string.h>
+#endif
+
+/** \addtogroup Misc Miscellaneous APIs */
+/**@{*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*
+ * If we are using Native malloc(), we must also use
+ * native Ansi string.h functions for memory manipulation.
+ */
+#ifdef USE_NATIVE_MALLOC
+#ifndef USE_NATIVE_MEMCPY
+#define USE_NATIVE_MEMCPY
+#endif
+#endif
+
+#ifdef USE_NATIVE_MEMCPY
+
+#define OI_MemCopy(to, from, size) memcpy((to), (from), (size))
+#define OI_MemSet(block, val, size) memset((block), (val), (size))
+#define OI_MemZero(block, size) memset((block), 0, (size))
+#define OI_MemCmp(s1, s2, n) memcmp((s1), (s2), (n))
+#define OI_Strcpy(dest, src) strcpy((dest),(src))
+#define OI_Strcat(dest, src) strcat((dest),(src))
+#define OI_StrLen(str) strlen((str))
+#define OI_Strcmp(s1, s2) strcmp((s1), (s2))
+#define OI_Strncmp(s1, s2, n) strncmp((s1), (s2), (n))
+
+#else
+
+/*
+ * OI_MemCopy
+ *
+ * Copy an arbitrary number of bytes from one memory address to another.
+ * The underlying implementation is the ANSI memmove() or equivalant, so
+ * overlapping memory copies will work correctly.
+ */
+void OI_MemCopy(void *To, void const *From, OI_UINT32 Size);
+
+
+/*
+ * OI_MemSet
+ *
+ * Sets all bytes in a block of memory to the same value
+ */
+void OI_MemSet(void *Block, OI_UINT8 Val, OI_UINT32 Size);
+
+
+/*
+ * OI_MemZero
+ *
+ * Sets all bytes in a block of memory to zero
+ */
+void OI_MemZero(void *Block, OI_UINT32 Size);
+
+
+/*
+ * OI_MemCmp
+ *
+ * Compare two blocks of memory
+ *
+ * Returns:
+ * 0, if s1 == s2
+ * < 0, if s1 < s2
+ * > 0, if s2 > s2
+ */
+OI_INT OI_MemCmp(void const *s1, void const *s2, OI_UINT32 n);
+
+/*
+ * OI_Strcpy
+ *
+ * Copies the Null terminated string from pStr to pDest, and
+ * returns pDest.
+ */
+
+OI_CHAR* OI_Strcpy(OI_CHAR *pDest,
+ OI_CHAR const *pStr);
+
+/*
+ * OI_Strcat
+ *
+ * Concatonates the pStr string to the end of pDest, and
+ * returns pDest.
+ */
+
+OI_CHAR* OI_Strcat(OI_CHAR *pDest,
+ OI_CHAR const *pStr) ;
+
+/*
+ * OI_StrLen
+ *
+ * Calculates the number of OI_CHARs in pStr (not including
+ * the Null terminator) and returns the value.
+ */
+OI_UINT OI_StrLen(OI_CHAR const *pStr) ;
+
+/*
+ * OI_Strcmp
+ *
+ * Compares two Null terminated strings
+ *
+ * Returns:
+ * 0, if s1 == s2
+ * < 0, if s1 < s2
+ * > 0, if s2 > s2
+ */
+OI_INT OI_Strcmp(OI_CHAR const *s1,
+ OI_CHAR const *s2);
+
+/*
+ * OI_Strncmp
+ *
+ * Compares the first "len" OI_CHARs of strings s1 and s2.
+ *
+ * Returns:
+ * 0, if s1 == s2
+ * < 0, if s1 < s2
+ * > 0, if s2 > s2
+ */
+OI_INT OI_Strncmp(OI_CHAR const *s1,
+ OI_CHAR const *s2,
+ OI_UINT32 len);
+
+
+#endif /* USE_NATIVE_MEMCPY */
+
+/*
+ * OI_StrcmpInsensitive
+ *
+ * Compares two Null terminated strings, treating
+ * the Upper and Lower case of 'A' through 'Z' as
+ * equivilent.
+ *
+ * Returns:
+ * 0, if s1 == s2
+ * < 0, if s1 < s2
+ * > 0, if s2 > s2
+ */
+OI_INT OI_StrcmpInsensitive(OI_CHAR const *s1,
+ OI_CHAR const *s2);
+
+/*
+ * OI_StrncmpInsensitive
+ *
+ * Compares the first "len" OI_CHARs of strings s1 and s2,
+ * treating the Upper and Lower case of 'A' through 'Z' as
+ * equivilent.
+ *
+ *
+ * Returns:
+ * 0, if s1 == s2
+ * < 0, if s1 < s2
+ * > 0, if s2 > s2
+ */
+OI_INT OI_StrncmpInsensitive(OI_CHAR const *s1,
+ OI_CHAR const *s2,
+ OI_UINT len);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/** @} */
+
+/*****************************************************************************/
+#endif /* OI_STRING_H */
+
diff --git a/embdrv/sbc/decoder/include/oi_time.h b/embdrv/sbc/decoder/include/oi_time.h
new file mode 100644
index 0000000..40b8dfc
--- /dev/null
+++ b/embdrv/sbc/decoder/include/oi_time.h
@@ -0,0 +1,200 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+#ifndef _OI_TIME_H
+#define _OI_TIME_H
+/** @file
+ *
+ * This file provides time type definitions and interfaces to time-related functions.
+ *
+ * The stack maintains a 64-bit real-time millisecond clock. The choice of
+ * milliseconds is for convenience, not accuracy.
+ *
+ * Timeouts are specified as tenths of seconds in a 32-bit value. Timeout values
+ * specified by the Bluetooth specification are usually muliple seconds, so
+ * accuracy to a tenth of a second is more than adequate.
+ *
+ * This file also contains macros to convert between seconds and the Link
+ * Manager's 1.28-second units.
+ *
+ */
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+#include "oi_stddefs.h"
+
+
+/** \addtogroup Misc Miscellaneous APIs */
+/**@{*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+/**
+ * Within the core stack timeouts are specified in intervals of tenths of seconds
+ */
+
+typedef OI_UINT16 OI_INTERVAL;
+#define OI_INTERVALS_PER_SECOND 10
+#define MSECS_PER_OI_INTERVAL (1000 / OI_INTERVALS_PER_SECOND)
+
+/** maximum interval (54 min 36.7 sec) */
+#define OI_MAX_INTERVAL 0x7fff
+
+
+/**
+ * Macro to convert seconds to OI_INTERVAL time units
+ */
+
+#define OI_SECONDS(n) ((OI_INTERVAL) ((n) * OI_INTERVALS_PER_SECOND))
+
+/**
+ * Macro to convert milliseconds to OI_INTERVAL time units (Rounded Up)
+ */
+
+#define OI_MSECONDS(n) ((OI_INTERVAL) ((n + MSECS_PER_OI_INTERVAL - 1) / MSECS_PER_OI_INTERVAL))
+
+/**
+ * Macro to convert minutes to OI_INTERVAL time units
+ */
+
+#define OI_MINUTES(n) ((OI_INTERVAL) ((n) * OI_SECONDS(60)))
+
+/** Convert an OI_INTERVAL to milliseconds. */
+#define OI_INTERVAL_TO_MILLISECONDS(i) ((i) * MSECS_PER_OI_INTERVAL)
+
+/**
+ * The stack depends on relative not absolute time. Any mapping between the
+ * stack's real-time clock and absolute time and date is implementation-dependent.
+ */
+
+typedef struct {
+ OI_INT32 seconds;
+ OI_INT16 mseconds;
+} OI_TIME;
+
+/**
+ * Convert an OI_TIME to milliseconds.
+ *
+ * @param t the time to convert
+ *
+ * @return the time in milliseconds
+ */
+OI_UINT32 OI_Time_ToMS(OI_TIME *t);
+
+
+/**
+ * This function compares two time values.
+ *
+ * @param T1 first time to compare.
+ *
+ * @param T2 second time to compare.
+ *
+ * @return
+ @verbatim
+ -1 if t1 < t2
+ 0 if t1 = t2
+ +1 if t1 > t2
+ @endverbatim
+ */
+
+OI_INT16 OI_Time_Compare(OI_TIME *T1,
+ OI_TIME *T2);
+
+
+/**
+ * This function returns the interval between two times to a granularity of 0.1 seconds.
+ *
+ * @param Sooner a time value more recent that Later
+ *
+ * @param Later a time value later than Sooner
+ *
+ * @note The result is an OI_INTERVAL value so this function only works for time intervals
+ * that are less than about 71 minutes.
+ *
+ * @return the time interval between the two times = (Later - Sooner)
+ */
+
+OI_INTERVAL OI_Time_Interval(OI_TIME *Sooner,
+ OI_TIME *Later);
+
+
+
+/**
+ * This function returns the interval between two times to a granularity of milliseconds.
+ *
+ * @param Sooner a time value more recent that Later
+ *
+ * @param Later a time value later than Sooner
+ *
+ * @note The result is an OI_UINT32 value so this function only works for time intervals
+ * that are less than about 50 days.
+ *
+ * @return the time interval between the two times = (Later - Sooner)
+ */
+
+OI_UINT32 OI_Time_IntervalMsecs(OI_TIME *Sooner,
+ OI_TIME *Later);
+
+
+
+/**
+ * This function answers the question, Have we reached or gone past the target time?
+ *
+ * @param pTargetTime target time
+ *
+ * @return TRUE means time now is at or past target time
+ * FALSE means target time is still some time in the future
+ */
+
+OI_BOOL OI_Time_NowReachedTime(OI_TIME *pTargetTime);
+
+/**
+ * Convert seconds to the Link Manager 1.28-second units
+ * Approximate by using 1.25 conversion factor.
+ */
+
+#define OI_SECONDS_TO_LM_TIME_UNITS(lmUnits) ((lmUnits)<4?(lmUnits):(lmUnits)-((lmUnits)>>2))
+
+
+/**
+ * Convert Link Manager 1.28-second units to seconds.
+ * Approximate by using 1.25 conversion factor.
+ */
+
+#define OI_LM_TIME_UNITS_TO_SECONDS(lmUnits) ((lmUnits) + ((lmUnits)>>2))
+
+#ifdef __cplusplus
+}
+#endif
+
+/**@}*/
+
+/* Include for OI_Time_Now() prototype
+ * Must be included at end to obtain OI_TIME typedef
+ */
+#include "oi_osinterface.h"
+
+/*****************************************************************************/
+#endif /* _OI_TIME_H */
+
diff --git a/embdrv/sbc/decoder/include/oi_utils.h b/embdrv/sbc/decoder/include/oi_utils.h
new file mode 100644
index 0000000..5272259
--- /dev/null
+++ b/embdrv/sbc/decoder/include/oi_utils.h
@@ -0,0 +1,377 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+#ifndef _OI_UTILS_H
+#define _OI_UTILS_H
+/**
+ * @file
+ *
+ * This file provides the interface for utility functions.
+ * Among the utilities are strlen (string length), strcmp (string compare), and
+ * other string manipulation functions. These are provided for those plaforms
+ * where this functionality is not available in stdlib.
+ */
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+#include <stdarg.h>
+#include "oi_common.h"
+#include "oi_string.h"
+#include "oi_bt_spec.h"
+
+/** \addtogroup Misc Miscellaneous APIs */
+/**@{*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Opaque type for a callback function handle. See OI_ScheduleCallbackFunction()
+ */
+typedef OI_UINT32 OI_CALLBACK_HANDLE;
+
+
+/**
+ * Function prototype for a timed procedure callback.
+ *
+ * @param arg Value that was passed into the OI_ScheduleCallback() function
+ *
+ */
+typedef void (*OI_SCHEDULED_CALLBACK)(void *arg);
+
+
+/**
+ * Registers a function to be called when a timeout expires. This API uses BLUEmagic's internal
+ * function dispatch mechanism, so applications that make extensive use of this facility may need to
+ * increase the value of DispatchTableSize in the configuration block for the dispatcher (see
+ * oi_bt_stack_config.h).
+ *
+ * @param callbackFunction The function that will be called when the timeout expires
+ *
+ * @param arg Value that will be returned as the parameter to the callback function.
+ *
+ * @param timeout A timeout expressed in OI_INTERVALs (tenths of seconds). This can be
+ * zero in which case the callback function will be called as soon as
+ * possible.
+ *
+ * @param handle NULL or a pointer receive the callback handle.
+ *
+ * @return OI_OK if the function was reqistered, or an error status.
+ */
+OI_STATUS OI_ScheduleCallbackFunction(OI_SCHEDULED_CALLBACK callbackFunction,
+ void *arg,
+ OI_INTERVAL timeout,
+ OI_CALLBACK_HANDLE *handle);
+
+
+/**
+ * Cancels a function registered with OI_ScheduleCallbackFunction() before its timer expires.
+ *
+ * @param handle handle returned by OI_ScheduleCallbackFunction().
+ *
+ * @return OI_OK if the function was cancelled, or an error status.
+ */
+OI_STATUS OI_CancelCallbackFunction(OI_CALLBACK_HANDLE handle);
+
+
+/**
+ * Registers a function to be called when a timeout expires. This version does not return a handle
+ * so can only be canceled by calling OI_CancelCallback().
+ *
+ * @param callbackFunction The function that will be called when the timeout expires
+ *
+ * @param arg Value that will be returned as the parameter to the callback function.
+ *
+ * @param timeout A timeout expressed in OI_INTERVALs (tenths of seconds). This can be
+ * zero in which case the callback function will be called as soon as
+ * possible.
+ *
+ * @return OI_OK if the function was reqistered, or an error status.
+ */
+#define OI_ScheduleCallback(f, a, t) OI_ScheduleCallbackFunction(f, a, t, NULL);
+
+
+/**
+ * Cancels a function registered with OI_ScheduleCallback() before its timer expires. This
+ * function will cancel the first entry matches the indicated callback function pointer.
+ *
+ * @param callbackFunction The function that was originally registered
+ *
+ * @return OI_OK if the function was cancelled, or an error status.
+ */
+OI_STATUS OI_CancelCallback(OI_SCHEDULED_CALLBACK callbackFunction);
+
+
+/**
+ * Parse a Bluetooth device address from the specified string.
+ *
+ * @param str the string to parse
+ * @param addr the parsed address, if successful
+ *
+ * @return TRUE if an address was successfully parsed, FALSE otherwise
+ */
+
+OI_BOOL OI_ParseBdAddr(const OI_CHAR *str,
+ OI_BD_ADDR *addr) ;
+
+/**
+ * Printf function for platforms which have no stdio or printf available.
+ * OI_Printf supports the basic formatting types, with the exception of
+ * floating point types. Additionally, OI_Printf supports several formats
+ * specific to BLUEmagic 3.0 software:
+ *
+ * \%! prints the string for an #OI_STATUS value.
+ * @code OI_Printf("There was an error %!", status); @endcode
+ *
+ * \%@ prints a hex dump of a buffer.
+ * Requires a pointer to the buffer and a signed integer length
+ * (0 for default length). If the buffer is large, only an excerpt will
+ * be printed.
+ * @code OI_Printf("Contents of buffer %@", buffer, sizeof(buffer)); @endcode
+ *
+ * \%: prints a Bluetooth address in the form "HH:HH:HH:HH:HH:HH".
+ * Requires a pointer to an #OI_BD_ADDR.
+ * @code OI_Printf("Bluetooth address %:", &bdaddr); @endcode
+ *
+ * \%^ decodes and prints a data element as formatted XML.
+ * Requires a pointer to an #OI_DATAELEM.
+ * @code OI_Printf("Service attribute list is:\n%^", &attributes); @endcode
+ *
+ * \%/ prints the base file name of a path, that is, the final substring
+ * following a '/' or '\\' character. Requires a pointer to a null
+ * terminated string.
+ * @code OI_Printf("File %/", "c:\\dir1\\dir2\\file.txt"); @endcode
+ *
+ * \%~ prints a string, escaping characters as needed to display it in
+ * ASCII. Requires a pointer to an #OI_PSTR and an #OI_UNICODE_ENCODING
+ * parameter.
+ * @code OI_Printf("Identifier %~", &id, OI_UNICODE_UTF16_BE); @endcode
+ *
+ * \%[ inserts an ANSI color escape sequence. Requires a single character
+ * identifying the color to select. Colors are red (r/R), green (g/G),
+ * blue (b/B), yellow (y/Y), cyan (c/C), magenta (m/M), white (W),
+ * light-gray (l/L), dark-gray (d/D), and black (0). The lower case is
+ * dim, the upper case is bright (except in the case of light-gray and
+ * dark-gray, where bright and dim are identical). Any other value will
+ * select the default color.
+ * @code OI_Printf("%[red text %[black %[normal\n", 'r', '0', 0); @endcode
+ *
+ * \%a same as \%s, except '\\r' and '\\n' are output as "<cr>" and "<lf>".
+ * \%?a is valid, but \%la is not.
+ *
+ * \%b prints an integer in base 2.
+ * @code OI_Printf("Bits are %b", I); @endcode
+ *
+ * \%lb prints a long integer in base 2.
+ *
+ * \%?b prints the least significant N bits of an integer (or long integer)
+ * in base 2. Requires the integer and a length N.
+ * @code OI_Printf("Bottom 4 bits are: %?b", I, 4); @endcode
+ *
+ * \%B prints an integer as boolean text, "TRUE" or "FALSE".
+ * @code OI_Printf("The value 0 is %B, the value 1 is %B", 0, 1); @endcode
+ *
+ * \%?s prints a substring up to a specified maximum length.
+ * Requires a pointer to a string and a length parameter.
+ * @code OI_Printf("String prefix is %?s", str, 3); @endcode
+ *
+ * \%ls same as \%S.
+ *
+ * \%S prints a UTF16 string as UTF8 (plain ASCII, plus 8-bit char sequences
+ * where needed). Requires a pointer to #OI_CHAR16. \%?S is valid. The
+ * length parameter is in OI_CHAR16 characters.
+ *
+ * \%T prints time, formatted as "secs.msecs".
+ * Requires pointer to #OI_TIME struct, NULL pointer prints current time.
+ * @code OI_Printf("The time now is %T", NULL); @endcode
+ *
+ * @param format The format string
+ *
+ */
+void OI_Printf(const OI_CHAR *format, ...);
+
+
+/**
+ * Var-args version OI_Printf
+ *
+ * @param format Same as for OI_Printf.
+ *
+ * @param argp Var-args list.
+ */
+void OI_VPrintf(const OI_CHAR *format, va_list argp);
+
+
+/**
+ * Writes a formatted string to a buffer. This function supports the same format specifiers as
+ * OI_Printf().
+ *
+ * @param buffer Destination buffer for the formatted string.
+ *
+ * @param bufLen The length of the destination buffer.
+ *
+ * @param format The format string
+ *
+ * @return Number of characters written or -1 in the case of an error.
+ */
+OI_INT32 OI_SNPrintf(OI_CHAR *buffer,
+ OI_UINT16 bufLen,
+ const OI_CHAR* format, ...);
+
+
+/**
+ * Var-args version OI_SNPrintf
+ *
+ * @param buffer Destination buffer for the formatted string.
+ *
+ * @param bufLen The length of the destination buffer.
+ *
+ * @param format The format string
+ *
+ * @param argp Var-args list.
+ *
+ * @return Number of characters written or -1 in the case of an error.
+ */
+OI_INT32 OI_VSNPrintf(OI_CHAR *buffer,
+ OI_UINT16 bufLen,
+ const OI_CHAR *format, va_list argp);
+
+
+/**
+ * Convert a string to an integer.
+ *
+ * @param str the string to parse
+ *
+ * @return the integer value of the string or 0 if the string could not be parsed
+ */
+OI_INT OI_atoi(const OI_CHAR *str);
+
+
+/**
+ * Parse a signed integer in a string.
+ *
+ * Skips leading whitespace (space and tabs only) and parses a decimal or hex string. Hex string
+ * must be prefixed by "0x". Returns pointer to first character following the integer. Returns the
+ * pointer passed in if the string does not describe an integer.
+ *
+ * @param str String to parse.
+ *
+ * @param val Pointer to receive the parsed integer value.
+ *
+ * @return A pointer to the first character following the integer or the pointer passed in.
+ */
+const OI_CHAR* OI_ScanInt(const OI_CHAR *str,
+ OI_INT32 *val);
+
+
+/**
+ * Parse an unsigned integer in a string.
+ *
+ * Skips leading whitespace (space and tabs only) and parses a decimal or hex string. Hex string
+ * must be prefixed by "0x". Returns pointer to first character following the integer. Returns the
+ * pointer passed in if the string does not describe an integer.
+ *
+ * @param str String to parse.
+ *
+ * @param val Pointer to receive the parsed unsigned integer value.
+ *
+ * @return A pointer to the first character following the unsigned integer or the pointer passed in.
+ */
+const OI_CHAR* OI_ScanUInt(const OI_CHAR *str,
+ OI_UINT32 *val);
+
+/**
+ * Parse a whitespace delimited substring out of a string.
+ *
+ * @param str Input string to parse.
+ * @param outStr Buffer to return the substring
+ * @param len Length of outStr
+ *
+ *
+ * @return A pointer to the first character following the substring or the pointer passed in.
+ */
+const OI_CHAR* OI_ScanStr(const OI_CHAR *str,
+ OI_CHAR *outStr,
+ OI_UINT16 len);
+
+
+/**
+ * Parse a string for one of a set of alternative value. Skips leading whitespace (space and tabs
+ * only) and parses text matching one of the alternative strings. Returns pointer to first character
+ * following the matched text.
+ *
+ * @param str String to parse.
+ *
+ * @param alts Alternative matching strings separated by '|'
+ *
+ * @param index Pointer to receive the index of the matching alternative, return value is -1 if
+ * there is no match.
+ *
+ * @return A pointer to the first character following the matched value or the pointer passed in
+ * if there was no matching text.
+ */
+const OI_CHAR* OI_ScanAlt(const OI_CHAR *str,
+ const OI_CHAR *alts,
+ OI_INT *index);
+
+/**
+ * Parse a string for a BD Addr. Skips leading whitespace (space and tabs only) and parses a
+ * Bluetooth device address with nibbles optionally separated by colons. Return pointet to first
+ * character following the BD Addr.
+ *
+ * @param str String to parse.
+ *
+ * @param addr Pointer to receive the Bluetooth device address
+ *
+ * @return A pointer to the first character following the BD Addr or the pointer passed in.
+ */
+const OI_CHAR* OI_ScanBdAddr(const OI_CHAR *str,
+ OI_BD_ADDR *addr);
+
+
+/** Get a character from a digit integer value (0 - 9). */
+#define OI_DigitToChar(d) ((d) + '0')
+
+/**
+ * Determine Maximum and Minimum between two arguments.
+ *
+ * @param a 1st value
+ * @param b 2nd value
+ *
+ * @return the max or min value between a & b
+ */
+#define OI_MAX(a, b) (((a) < (b)) ? (b) : (a) )
+#define OI_MIN(a, b) (((a) > (b)) ? (b) : (a) )
+
+/**
+ * Compare two BD_ADDRs
+ * SAME_BD_ADDR - Boolean: TRUE if they are the same address
+ */
+
+#define SAME_BD_ADDR(x, y) (0 == OI_MemCmp((x),(y),OI_BD_ADDR_BYTE_SIZE) )
+
+#ifdef __cplusplus
+}
+#endif
+
+/**@}*/
+
+#endif /* _OI_UTILS_H */
+
diff --git a/embdrv/sbc/decoder/srce/alloc.c b/embdrv/sbc/decoder/srce/alloc.c
new file mode 100644
index 0000000..f8723f2
--- /dev/null
+++ b/embdrv/sbc/decoder/srce/alloc.c
@@ -0,0 +1,78 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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 <stdlib.h>
+#include <oi_codec_sbc_private.h>
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+PRIVATE OI_STATUS OI_CODEC_SBC_Alloc(OI_CODEC_SBC_COMMON_CONTEXT *common,
+ OI_UINT32 *codecDataAligned,
+ OI_UINT32 codecDataBytes,
+ OI_UINT8 maxChannels,
+ OI_UINT8 pcmStride)
+{
+ int i;
+ size_t filterBufferCount;
+ size_t subdataSize;
+ OI_BYTE *codecData = (OI_BYTE*)codecDataAligned;
+
+ if (maxChannels < 1 || maxChannels > 2) {
+ return OI_STATUS_INVALID_PARAMETERS;
+ }
+
+ if (pcmStride < 1 || pcmStride > maxChannels) {
+ return OI_STATUS_INVALID_PARAMETERS;
+ }
+
+ common->maxChannels = maxChannels;
+ common->pcmStride = pcmStride;
+
+ /* Compute sizes needed for the memory regions, and bail if we don't have
+ * enough memory for them. */
+ subdataSize = maxChannels * sizeof(common->subdata[0]) * SBC_MAX_BANDS * SBC_MAX_BLOCKS;
+ if (subdataSize > codecDataBytes) {
+ return OI_STATUS_OUT_OF_MEMORY;
+ }
+
+ filterBufferCount = (codecDataBytes - subdataSize) / (sizeof(common->filterBuffer[0][0]) * SBC_MAX_BANDS * maxChannels);
+ if (filterBufferCount < SBC_CODEC_MIN_FILTER_BUFFERS) {
+ return OI_STATUS_OUT_OF_MEMORY;
+ }
+ common->filterBufferLen = filterBufferCount * SBC_MAX_BANDS;
+
+ /* Allocate memory for the subband data */
+ common->subdata = (OI_INT32*)codecData;
+ codecData += subdataSize;
+ OI_ASSERT(codecDataBytes >= subdataSize);
+ codecDataBytes -= subdataSize;
+
+ /* Allocate memory for the synthesis buffers */
+ for (i = 0; i < maxChannels; ++i) {
+ size_t allocSize = common->filterBufferLen * sizeof(common->filterBuffer[0][0]);
+ common->filterBuffer[i] = (SBC_BUFFER_T*)codecData;
+ OI_ASSERT(codecDataBytes >= allocSize);
+ codecData += allocSize;
+ codecDataBytes -= allocSize;
+ }
+
+ return OI_OK;
+}
diff --git a/embdrv/sbc/decoder/srce/bitalloc-sbc.c b/embdrv/sbc/decoder/srce/bitalloc-sbc.c
new file mode 100644
index 0000000..8120298
--- /dev/null
+++ b/embdrv/sbc/decoder/srce/bitalloc-sbc.c
@@ -0,0 +1,165 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+/** @file
+@ingroup codec_internal
+*/
+
+/**@addgroup codec_internal*/
+/**@{*/
+
+#include <oi_codec_sbc_private.h>
+
+static void dualBitAllocation(OI_CODEC_SBC_COMMON_CONTEXT *common)
+{
+ OI_UINT bitcountL;
+ OI_UINT bitcountR;
+ OI_UINT bitpoolPreferenceL = 0;
+ OI_UINT bitpoolPreferenceR = 0;
+ BITNEED_UNION1 bitneedsL;
+ BITNEED_UNION1 bitneedsR;
+
+ bitcountL = computeBitneed(common, bitneedsL.uint8, 0, &bitpoolPreferenceL);
+ bitcountR = computeBitneed(common, bitneedsR.uint8, 1, &bitpoolPreferenceR);
+
+ oneChannelBitAllocation(common, &bitneedsL, 0, bitcountL);
+ oneChannelBitAllocation(common, &bitneedsR, 1, bitcountR);
+}
+
+static void stereoBitAllocation(OI_CODEC_SBC_COMMON_CONTEXT *common)
+{
+ const OI_UINT nrof_subbands = common->frameInfo.nrof_subbands;
+ BITNEED_UNION2 bitneeds;
+ OI_UINT excess;
+ OI_INT bitadjust;
+ OI_UINT bitcount;
+ OI_UINT sbL;
+ OI_UINT sbR;
+ OI_UINT bitpoolPreference = 0;
+
+ bitcount = computeBitneed(common, &bitneeds.uint8[0], 0, &bitpoolPreference);
+ bitcount += computeBitneed(common, &bitneeds.uint8[nrof_subbands], 1, &bitpoolPreference);
+
+ {
+ OI_UINT ex;
+ bitadjust = adjustToFitBitpool(common->frameInfo.bitpool, bitneeds.uint32, 2 * nrof_subbands, bitcount, &ex);
+ /* We want the compiler to put excess into a register */
+ excess = ex;
+ }
+ sbL = 0;
+ sbR = nrof_subbands;
+ while (sbL < nrof_subbands) {
+ excess = allocAdjustedBits(&common->bits.uint8[sbL], bitneeds.uint8[sbL] + bitadjust, excess);
+ ++sbL;
+ excess = allocAdjustedBits(&common->bits.uint8[sbR], bitneeds.uint8[sbR] + bitadjust, excess);
+ ++sbR;
+ }
+ sbL = 0;
+ sbR = nrof_subbands;
+ while (excess) {
+ excess = allocExcessBits(&common->bits.uint8[sbL], excess);
+ ++sbL;
+ if (!excess) {
+ break;
+ }
+ excess = allocExcessBits(&common->bits.uint8[sbR], excess);
+ ++sbR;
+ }
+
+}
+
+static const BIT_ALLOC balloc[] = {
+ monoBitAllocation, /* SBC_MONO */
+ dualBitAllocation, /* SBC_DUAL_CHANNEL */
+ stereoBitAllocation, /* SBC_STEREO */
+ stereoBitAllocation /* SBC_JOINT_STEREO */
+};
+
+
+PRIVATE void OI_SBC_ComputeBitAllocation(OI_CODEC_SBC_COMMON_CONTEXT *common)
+{
+ OI_ASSERT(common->frameInfo.bitpool <= OI_SBC_MaxBitpool(&common->frameInfo));
+ OI_ASSERT(common->frameInfo.mode < OI_ARRAYSIZE(balloc));
+
+ /*
+ * Using an array of function pointers prevents the compiler from creating a suboptimal
+ * monolithic inlined bit allocation function.
+ */
+ balloc[common->frameInfo.mode](common);
+}
+
+OI_UINT32 OI_CODEC_SBC_CalculateBitrate(OI_CODEC_SBC_FRAME_INFO *frame)
+{
+ return internal_CalculateBitrate(frame);
+}
+
+/*
+ * Return the current maximum bitneed and clear it.
+ */
+OI_UINT8 OI_CODEC_SBC_GetMaxBitneed(OI_CODEC_SBC_COMMON_CONTEXT *common)
+{
+ OI_UINT8 max = common->maxBitneed;
+
+ common->maxBitneed = 0;
+ return max;
+}
+
+/*
+ * Calculates the bitpool size for a given frame length
+ */
+OI_UINT16 OI_CODEC_SBC_CalculateBitpool(OI_CODEC_SBC_FRAME_INFO *frame,
+ OI_UINT16 frameLen)
+{
+ OI_UINT16 nrof_subbands = frame->nrof_subbands;
+ OI_UINT16 nrof_blocks = frame->nrof_blocks;
+ OI_UINT16 hdr;
+ OI_UINT16 bits;
+
+ if (frame->mode == SBC_JOINT_STEREO) {
+ hdr = 9 * nrof_subbands;
+ } else {
+ if (frame->mode == SBC_MONO) {
+ hdr = 4 * nrof_subbands;
+ } else {
+ hdr = 8 * nrof_subbands;
+ }
+ if (frame->mode == SBC_DUAL_CHANNEL) {
+ nrof_blocks *= 2;
+ }
+ }
+ bits = 8 * (frameLen - SBC_HEADER_LEN) - hdr;
+ return DIVIDE(bits, nrof_blocks);
+}
+
+OI_UINT16 OI_CODEC_SBC_CalculatePcmBytes(OI_CODEC_SBC_COMMON_CONTEXT *common)
+{
+ return sizeof(OI_INT16) * common->pcmStride * common->frameInfo.nrof_subbands * common->frameInfo.nrof_blocks;
+}
+
+
+OI_UINT16 OI_CODEC_SBC_CalculateFramelen(OI_CODEC_SBC_FRAME_INFO *frame)
+{
+ return internal_CalculateFramelen(frame);
+}
+
+/**@}*/
diff --git a/embdrv/sbc/decoder/srce/bitalloc.c b/embdrv/sbc/decoder/srce/bitalloc.c
new file mode 100644
index 0000000..544c470
--- /dev/null
+++ b/embdrv/sbc/decoder/srce/bitalloc.c
@@ -0,0 +1,392 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/**********************************************************************************
+ $Revision: #1 $
+ ***********************************************************************************/
+
+/**
+@file
+
+The functions in this file relate to the allocation of available bits to
+subbands within the SBC/eSBC frame, along with support functions for computing
+frame length and bitrate.
+
+@ingroup codec_internal
+*/
+
+/**
+@addtogroup codec_internal
+@{
+*/
+
+#include "oi_utils.h"
+#include <oi_codec_sbc_private.h>
+
+OI_UINT32 OI_SBC_MaxBitpool(OI_CODEC_SBC_FRAME_INFO *frame)
+{
+ switch (frame->mode) {
+ case SBC_MONO:
+ case SBC_DUAL_CHANNEL:
+ return 16 * frame->nrof_subbands;
+ case SBC_STEREO:
+ case SBC_JOINT_STEREO:
+ return 32 * frame->nrof_subbands;
+ }
+
+ ERROR(("Invalid frame mode %d", frame->mode));
+ OI_ASSERT(FALSE);
+ return 0; /* Should never be reached */
+}
+
+
+PRIVATE OI_UINT16 internal_CalculateFramelen(OI_CODEC_SBC_FRAME_INFO *frame)
+{
+ OI_UINT16 nbits = frame->nrof_blocks * frame->bitpool;
+ OI_UINT16 nrof_subbands = frame->nrof_subbands;
+ OI_UINT16 result = nbits;
+
+ if (frame->mode == SBC_JOINT_STEREO) {
+ result += nrof_subbands + (8 * nrof_subbands);
+ } else {
+ if (frame->mode == SBC_DUAL_CHANNEL) { result += nbits; }
+ if (frame->mode == SBC_MONO) { result += 4*nrof_subbands; } else { result += 8*nrof_subbands; }
+ }
+ return SBC_HEADER_LEN + (result + 7) / 8;
+}
+
+
+PRIVATE OI_UINT32 internal_CalculateBitrate(OI_CODEC_SBC_FRAME_INFO *frame)
+{
+ OI_UINT blocksbands;
+ blocksbands = frame->nrof_subbands * frame->nrof_blocks;
+
+ return DIVIDE(8 * internal_CalculateFramelen(frame) * frame->frequency, blocksbands);
+}
+
+
+INLINE OI_UINT16 OI_SBC_CalculateFrameAndHeaderlen(OI_CODEC_SBC_FRAME_INFO *frame, OI_UINT *headerLen_)
+{
+ OI_UINT headerLen = SBC_HEADER_LEN + frame->nrof_subbands * frame->nrof_channels/2;
+
+ if (frame->mode == SBC_JOINT_STEREO) { headerLen++; }
+
+ *headerLen_ = headerLen;
+ return internal_CalculateFramelen(frame);
+}
+
+
+#define MIN(x, y) ((x) < (y) ? (x) : (y))
+
+
+/*
+ * Computes the bit need for each sample and as also returns a counts of bit needs that are greater
+ * than one. This count is used in the first phase of bit allocation.
+ *
+ * We also compute a preferred bitpool value that this is the minimum bitpool needed to guarantee
+ * lossless representation of the audio data. The preferred bitpool may be larger than the bits
+ * actually required but the only input we have are the scale factors. For example, it takes 2 bits
+ * to represent values in the range -1 .. +1 but the scale factor is 0. To guarantee lossless
+ * representation we add 2 to each scale factor and sum them to come up with the preferred bitpool.
+ * This is not ideal because 0 requires 0 bits but we currently have no way of knowing this.
+ *
+ * @param bitneed Array to return bitneeds for each subband
+ *
+ * @param ch Channel 0 or 1
+ *
+ * @param preferredBitpool Returns the number of reserved bits
+ *
+ * @return The SBC bit need
+ *
+ */
+OI_UINT computeBitneed(OI_CODEC_SBC_COMMON_CONTEXT *common,
+ OI_UINT8 *bitneeds,
+ OI_UINT ch,
+ OI_UINT *preferredBitpool)
+{
+ static const OI_INT8 offset4[4][4] = {
+ { -1, 0, 0, 0 },
+ { -2, 0, 0, 1 },
+ { -2, 0, 0, 1 },
+ { -2, 0, 0, 1 }
+ };
+
+ static const OI_INT8 offset8[4][8] = {
+ { -2, 0, 0, 0, 0, 0, 0, 1 },
+ { -3, 0, 0, 0, 0, 0, 1, 2 },
+ { -4, 0, 0, 0, 0, 0, 1, 2 },
+ { -4, 0, 0, 0, 0, 0, 1, 2 }
+ };
+
+ const OI_UINT nrof_subbands = common->frameInfo.nrof_subbands;
+ OI_UINT sb;
+ OI_INT8 *scale_factor = &common->scale_factor[ch ? nrof_subbands : 0];
+ OI_UINT bitcount = 0;
+ OI_UINT8 maxBits = 0;
+ OI_UINT8 prefBits = 0;
+
+ if (common->frameInfo.alloc == SBC_SNR) {
+ for (sb = 0; sb < nrof_subbands; sb++) {
+ OI_INT bits = scale_factor[sb];
+ if (bits > maxBits) {
+ maxBits = bits;
+ }
+ if ((bitneeds[sb] = bits) > 1) {
+ bitcount += bits;
+ }
+ prefBits += 2 + bits;
+ }
+ } else {
+ const OI_INT8 *offset;
+ if (nrof_subbands == 4) {
+ offset = offset4[common->frameInfo.freqIndex];
+ } else {
+ offset = offset8[common->frameInfo.freqIndex];
+ }
+ for (sb = 0; sb < nrof_subbands; sb++) {
+ OI_INT bits = scale_factor[sb];
+ if (bits > maxBits) {
+ maxBits = bits;
+ }
+ prefBits += 2 + bits;
+ if (bits) {
+ bits -= offset[sb];
+ if (bits > 0) {
+ bits /= 2;
+ }
+ bits += 5;
+ }
+ if ((bitneeds[sb] = bits) > 1) {
+ bitcount += bits;
+ }
+ }
+ }
+ common->maxBitneed = OI_MAX(maxBits, common->maxBitneed);
+ *preferredBitpool += prefBits;
+ return bitcount;
+}
+
+
+/*
+ * Explanation of the adjustToFitBitpool inner loop.
+ *
+ * The inner loop computes the effect of adjusting the bit allocation up or
+ * down. Allocations must be 0 or in the range 2..16. This is accomplished by
+ * the following code:
+ *
+ * for (s = bands - 1; s >= 0; --s) {
+ * OI_INT bits = bitadjust + bitneeds[s];
+ * bits = bits < 2 ? 0 : bits;
+ * bits = bits > 16 ? 16 : bits;
+ * count += bits;
+ * }
+ *
+ * This loop can be optimized to perform 4 operations at a time as follows:
+ *
+ * Adjustment is computed as a 7 bit signed value and added to the bitneed.
+ *
+ * Negative allocations are zeroed by masking. (n & 0x40) >> 6 puts the
+ * sign bit into bit 0, adding this to 0x7F give us a mask of 0x80
+ * for -ve values and 0x7F for +ve values.
+ *
+ * n &= 0x7F + (n & 0x40) >> 6)
+ *
+ * Allocations greater than 16 are truncated to 16. Adjusted allocations are in
+ * the range 0..31 so we know that bit 4 indicates values >= 16. We use this bit
+ * to create a mask that zeroes bits 0 .. 3 if bit 4 is set.
+ *
+ * n &= (15 + (n >> 4))
+ *
+ * Allocations of 1 are disallowed. Add and shift creates a mask that
+ * eliminates the illegal value
+ *
+ * n &= ((n + 14) >> 4) | 0x1E
+ *
+ * These operations can be performed in 8 bits without overflowing so we can
+ * operate on 4 values at once.
+ */
+
+
+/*
+ * Encoder/Decoder
+ *
+ * Computes adjustment +/- of bitneeds to fill bitpool and returns overall
+ * adjustment and excess bits.
+ *
+ * @param bitpool The bitpool we have to work within
+ *
+ * @param bitneeds An array of bit needs (more acturately allocation prioritities) for each
+ * subband across all blocks in the SBC frame
+ *
+ * @param subbands The number of subbands over which the adkustment is calculated. For mono and
+ * dual mode this is 4 or 8, for stereo or joint stereo this is 8 or 16.
+ *
+ * @param bitcount A starting point for the adjustment
+ *
+ * @param excess Returns the excess bits after the adjustment
+ *
+ * @return The adjustment.
+ */
+OI_INT adjustToFitBitpool(const OI_UINT bitpool,
+ OI_UINT32 *bitneeds,
+ const OI_UINT subbands,
+ OI_UINT bitcount,
+ OI_UINT *excess)
+{
+ OI_INT maxBitadjust = 0;
+ OI_INT bitadjust = (bitcount > bitpool) ? -8 : 8;
+ OI_INT chop = 8;
+
+ /*
+ * This is essentially a binary search for the optimal adjustment value.
+ */
+ while ((bitcount != bitpool) && chop) {
+ OI_UINT32 total = 0;
+ OI_UINT count;
+ OI_UINT32 adjust4;
+ OI_INT i;
+
+ adjust4 = bitadjust & 0x7F;
+ adjust4 |= (adjust4 << 8);
+ adjust4 |= (adjust4 << 16);
+
+ for (i = (subbands / 4 - 1); i >= 0; --i) {
+ OI_UINT32 mask;
+ OI_UINT32 n = bitneeds[i] + adjust4;
+ mask = 0x7F7F7F7F + ((n & 0x40404040) >> 6);
+ n &= mask;
+ mask = 0x0F0F0F0F + ((n & 0x10101010) >> 4);
+ n &= mask;
+ mask = (((n + 0x0E0E0E0E) >> 4) | 0x1E1E1E1E);
+ n &= mask;
+ total += n;
+ }
+
+ count = (total & 0xFFFF) + (total >> 16);
+ count = (count & 0xFF) + (count >> 8);
+
+ chop >>= 1;
+ if (count > bitpool) {
+ bitadjust -= chop;
+ } else {
+ maxBitadjust = bitadjust;
+ bitcount = count;
+ bitadjust += chop;
+ }
+ }
+
+ *excess = bitpool - bitcount;
+
+ return maxBitadjust;
+}
+
+
+/*
+ * The bit allocator trys to avoid single bit allocations except as a last resort. So in the case
+ * where a bitneed of 1 was passed over during the adsjustment phase 2 bits are now allocated.
+ */
+INLINE OI_INT allocAdjustedBits(OI_UINT8 *dest,
+ OI_INT bits,
+ OI_INT excess)
+{
+ if (bits < 16) {
+ if (bits > 1) {
+ if (excess) {
+ ++bits;
+ --excess;
+ }
+ } else if ((bits == 1) && (excess > 1)) {
+ bits = 2;
+ excess -= 2;
+ } else {
+ bits = 0;
+ }
+ } else {
+ bits = 16;
+ }
+ *dest = (OI_UINT8)bits;
+ return excess;
+}
+
+
+/*
+ * Excess bits not allocated by allocaAdjustedBits are allocated round-robin.
+ */
+INLINE OI_INT allocExcessBits(OI_UINT8 *dest,
+ OI_INT excess)
+{
+ if (*dest < 16) {
+ *dest += 1;
+ return excess - 1;
+ } else {
+ return excess;
+ }
+}
+
+void oneChannelBitAllocation(OI_CODEC_SBC_COMMON_CONTEXT *common,
+ BITNEED_UNION1 *bitneeds,
+ OI_UINT ch,
+ OI_UINT bitcount)
+{
+ const OI_UINT8 nrof_subbands = common->frameInfo.nrof_subbands;
+ OI_UINT excess;
+ OI_UINT sb;
+ OI_INT bitadjust;
+ OI_UINT8 RESTRICT *allocBits;
+
+
+ {
+ OI_UINT ex;
+ bitadjust = adjustToFitBitpool(common->frameInfo.bitpool, bitneeds->uint32, nrof_subbands, bitcount, &ex);
+ /* We want the compiler to put excess into a register */
+ excess = ex;
+ }
+
+ /*
+ * Allocate adjusted bits
+ */
+ allocBits = &common->bits.uint8[ch ? nrof_subbands : 0];
+
+ sb = 0;
+ while (sb < nrof_subbands) {
+ excess = allocAdjustedBits(&allocBits[sb], bitneeds->uint8[sb] + bitadjust, excess);
+ ++sb;
+ }
+ sb = 0;
+ while (excess) {
+ excess = allocExcessBits(&allocBits[sb], excess);
+ ++sb;
+ }
+}
+
+
+void monoBitAllocation(OI_CODEC_SBC_COMMON_CONTEXT *common)
+{
+ BITNEED_UNION1 bitneeds;
+ OI_UINT bitcount;
+ OI_UINT bitpoolPreference = 0;
+
+ bitcount = computeBitneed(common, bitneeds.uint8, 0, &bitpoolPreference);
+
+ oneChannelBitAllocation(common, &bitneeds, 0, bitcount);
+}
+
+/**
+@}
+*/
diff --git a/embdrv/sbc/decoder/srce/bitstream-decode.c b/embdrv/sbc/decoder/srce/bitstream-decode.c
new file mode 100644
index 0000000..7eb2a90
--- /dev/null
+++ b/embdrv/sbc/decoder/srce/bitstream-decode.c
@@ -0,0 +1,92 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+/**
+@file
+Functions for manipulating input bitstreams.
+
+@ingroup codec_internal
+*/
+
+/**
+@addtogroup codec_internal
+@{
+*/
+
+#include "oi_stddefs.h"
+#include "oi_bitstream.h"
+#include "oi_assert.h"
+
+PRIVATE void OI_BITSTREAM_ReadInit(OI_BITSTREAM *bs,
+ const OI_BYTE *buffer)
+{
+ bs->value = ((OI_INT32)buffer[0] << 16) | ((OI_INT32)buffer[1] << 8) | (buffer[2]);
+ bs->ptr.r = buffer + 3;
+ bs->bitPtr = 8;
+}
+
+PRIVATE OI_UINT32 OI_BITSTREAM_ReadUINT(OI_BITSTREAM *bs, OI_UINT bits)
+{
+ OI_UINT32 result;
+
+ OI_BITSTREAM_READUINT(result, bits, bs->ptr.r, bs->value, bs->bitPtr);
+
+ return result;
+}
+
+PRIVATE OI_UINT8 OI_BITSTREAM_ReadUINT4Aligned(OI_BITSTREAM *bs)
+{
+ OI_UINT32 result;
+
+ OI_ASSERT(bs->bitPtr < 16);
+ OI_ASSERT(bs->bitPtr % 4 == 0);
+
+ if (bs->bitPtr == 8) {
+ result = bs->value << 8;
+ bs->bitPtr = 12;
+ } else {
+ result = bs->value << 12;
+ bs->value = (bs->value << 8) | *bs->ptr.r++;
+ bs->bitPtr = 8;
+ }
+ result >>= 28;
+ OI_ASSERT(result < (1u << 4));
+ return (OI_UINT8)result;
+}
+
+PRIVATE OI_UINT8 OI_BITSTREAM_ReadUINT8Aligned(OI_BITSTREAM *bs)
+{
+ OI_UINT32 result;
+ OI_ASSERT(bs->bitPtr == 8);
+
+ result = bs->value >> 16;
+ bs->value = (bs->value << 8) | *bs->ptr.r++;
+
+ return (OI_UINT8)result;
+}
+
+/**
+@}
+*/
+
+
diff --git a/embdrv/sbc/decoder/srce/decoder-oina.c b/embdrv/sbc/decoder/srce/decoder-oina.c
new file mode 100644
index 0000000..93d05ea
--- /dev/null
+++ b/embdrv/sbc/decoder/srce/decoder-oina.c
@@ -0,0 +1,140 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2006 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/**********************************************************************************
+ $Revision: #1 $
+ ***********************************************************************************/
+
+/**
+@file
+This file exposes OINA-specific interfaces to decoder functions.
+
+@ingroup codec_internal
+*/
+
+/**
+@addtogroup codec_internal
+@{
+*/
+
+
+#include <oi_codec_sbc_private.h>
+
+OI_STATUS OI_CODEC_SBC_DecoderConfigureRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ OI_BOOL enhanced,
+ OI_UINT8 frequency,
+ OI_UINT8 mode,
+ OI_UINT8 subbands,
+ OI_UINT8 blocks,
+ OI_UINT8 alloc,
+ OI_UINT8 maxBitpool)
+{
+ if (frequency > SBC_FREQ_48000) {
+ return OI_STATUS_INVALID_PARAMETERS;
+ }
+
+ if (enhanced) {
+#ifdef SBC_ENHANCED
+ if (subbands != SBC_SUBBANDS_8) {
+ return OI_STATUS_INVALID_PARAMETERS;
+ }
+#else
+ return OI_STATUS_INVALID_PARAMETERS;
+#endif
+ }
+
+ if (mode > SBC_JOINT_STEREO) {
+ return OI_STATUS_INVALID_PARAMETERS;
+ }
+
+ if (subbands > SBC_SUBBANDS_8) {
+ return OI_STATUS_INVALID_PARAMETERS;
+ }
+
+ if (blocks > SBC_BLOCKS_16) {
+ return OI_STATUS_INVALID_PARAMETERS;
+ }
+
+ if (alloc > SBC_SNR) {
+ return OI_STATUS_INVALID_PARAMETERS;
+ }
+
+#ifdef SBC_ENHANCED
+ context->common.frameInfo.enhanced = enhanced;
+#else
+ context->common.frameInfo.enhanced = FALSE;
+#endif
+ context->common.frameInfo.freqIndex = frequency;
+ context->common.frameInfo.mode = mode;
+ context->common.frameInfo.subbands = subbands;
+ context->common.frameInfo.blocks = blocks;
+ context->common.frameInfo.alloc = alloc;
+ context->common.frameInfo.bitpool = maxBitpool;
+
+ OI_SBC_ExpandFrameFields(&context->common.frameInfo);
+
+ if (context->common.frameInfo.nrof_channels >= context->common.pcmStride) {
+ return OI_STATUS_INVALID_PARAMETERS;
+ }
+
+ return OI_OK;
+}
+
+
+
+OI_STATUS OI_CODEC_SBC_DecodeRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ OI_UINT8 bitpool,
+ const OI_BYTE **frameData,
+ OI_UINT32 *frameBytes,
+ OI_INT16 *pcmData,
+ OI_UINT32 *pcmBytes)
+{
+ return internal_DecodeRaw(context,
+ bitpool,
+ frameData,
+ frameBytes,
+ pcmData,
+ pcmBytes);
+}
+
+OI_STATUS OI_CODEC_SBC_DecoderLimit(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ OI_BOOL enhanced,
+ OI_UINT8 subbands)
+{
+ if (enhanced)
+ {
+#ifdef SBC_ENHANCED
+ context->enhancedEnabled = TRUE;
+#else
+ context->enhancedEnabled = FALSE;
+#endif
+ }
+ else
+ {
+ context->enhancedEnabled = FALSE;
+ }
+ context->restrictSubbands = subbands;
+ context->limitFrameFormat = TRUE;
+ return OI_OK;
+}
+
+
+/**
+@}
+*/
diff --git a/embdrv/sbc/decoder/srce/decoder-private.c b/embdrv/sbc/decoder/srce/decoder-private.c
new file mode 100644
index 0000000..faccbf0
--- /dev/null
+++ b/embdrv/sbc/decoder/srce/decoder-private.c
@@ -0,0 +1,227 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/**********************************************************************************
+ $Revision: #1 $
+ ***********************************************************************************/
+
+/**
+@file
+This file drives SBC decoding.
+
+@ingroup codec_internal
+*/
+
+/**
+@addtogroup codec_internal
+@{
+*/
+
+#include "oi_codec_sbc_private.h"
+#include "oi_bitstream.h"
+#include <stdio.h>
+
+OI_CHAR * const OI_Codec_Copyright = "Copyright 2002-2007 Open Interface North America, Inc. All rights reserved";
+
+INLINE OI_STATUS internal_DecoderReset(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ OI_UINT32 *decoderData,
+ OI_UINT32 decoderDataBytes,
+ OI_BYTE maxChannels,
+ OI_BYTE pcmStride,
+ OI_BOOL enhanced)
+{
+ OI_UINT i;
+ OI_STATUS status;
+
+ for (i = 0; i < sizeof(*context); i++) {
+ ((char *)context)[i] = 0;
+ }
+
+#ifdef SBC_ENHANCED
+ context->enhancedEnabled = enhanced ? TRUE : FALSE;
+#else
+ context->enhancedEnabled = FALSE;
+ if (enhanced){
+ return OI_STATUS_INVALID_PARAMETERS;
+ }
+#endif
+
+ status = OI_CODEC_SBC_Alloc(&context->common, decoderData, decoderDataBytes, maxChannels, pcmStride);
+
+ if (!OI_SUCCESS(status)) {
+ return status;
+ }
+
+ context->common.codecInfo = OI_Codec_Copyright;
+ context->common.maxBitneed = 0;
+ context->limitFrameFormat = FALSE;
+ OI_SBC_ExpandFrameFields(&context->common.frameInfo);
+
+ /*PLATFORM_DECODER_RESET(context);*/
+
+ return OI_OK;
+}
+
+
+
+
+/**
+ * Read the SBC header up to but not including the joint stereo mask. The syncword has already been
+ * examined, and the enhanced mode flag set, by FindSyncword.
+ */
+INLINE void OI_SBC_ReadHeader(OI_CODEC_SBC_COMMON_CONTEXT *common, const OI_BYTE *data)
+{
+ OI_CODEC_SBC_FRAME_INFO *frame = &common->frameInfo;
+ OI_UINT8 d1;
+
+
+ OI_ASSERT(data[0] == OI_SBC_SYNCWORD || data[0] == OI_SBC_ENHANCED_SYNCWORD);
+
+ /* Avoid filling out all these strucutures if we already remember the values
+ * from last time. Just in case we get a stream corresponding to data[1] ==
+ * 0, DecoderReset is responsible for ensuring the lookup table entries have
+ * already been populated
+ */
+ d1 = data[1];
+ if (d1 != frame->cachedInfo) {
+
+ frame->freqIndex = (d1 & (BIT7 | BIT6)) >> 6;
+ frame->frequency = freq_values[frame->freqIndex];
+
+ frame->blocks = (d1 & (BIT5 | BIT4)) >> 4;
+ frame->nrof_blocks = block_values[frame->blocks];
+
+ frame->mode = (d1 & (BIT3 | BIT2)) >> 2;
+ frame->nrof_channels = channel_values[frame->mode];
+
+ frame->alloc = (d1 & BIT1) >> 1;
+
+ frame->subbands = (d1 & BIT0);
+ frame->nrof_subbands = band_values[frame->subbands];
+
+ frame->cachedInfo = d1;
+ }
+ /*
+ * For decode, the bit allocator needs to know the bitpool value
+ */
+ frame->bitpool = data[2];
+ frame->crc = data[3];
+}
+
+
+#define LOW(x) ((x)& 0xf)
+#define HIGH(x) ((x) >> 4)
+
+/*
+ * Read scalefactor values and prepare the bitstream for OI_SBC_ReadSamples
+ */
+PRIVATE void OI_SBC_ReadScalefactors(OI_CODEC_SBC_COMMON_CONTEXT *common,
+ const OI_BYTE *b,
+ OI_BITSTREAM *bs)
+{
+ OI_UINT i = common->frameInfo.nrof_subbands * common->frameInfo.nrof_channels;
+ OI_INT8 *scale_factor = common->scale_factor;
+ OI_UINT f;
+
+ if (common->frameInfo.nrof_subbands == 8 || common->frameInfo.mode != SBC_JOINT_STEREO) {
+ if (common->frameInfo.mode == SBC_JOINT_STEREO) {
+ common->frameInfo.join = *b++;
+ } else {
+ common->frameInfo.join = 0;
+ }
+ i /= 2;
+ do {
+ *scale_factor++ = HIGH(f = *b++);
+ *scale_factor++ = LOW(f);
+ } while (--i);
+ /*
+ * In this case we know that the scale factors end on a byte boundary so all we need to do
+ * is initialize the bitstream.
+ */
+ OI_BITSTREAM_ReadInit(bs, b);
+ } else {
+ OI_ASSERT(common->frameInfo.nrof_subbands == 4 && common->frameInfo.mode == SBC_JOINT_STEREO);
+ common->frameInfo.join = HIGH(f = *b++);
+ i = (i - 1) / 2;
+ do {
+ *scale_factor++ = LOW(f);
+ *scale_factor++ = HIGH(f = *b++);
+ } while (--i);
+ *scale_factor++ = LOW(f);
+ /*
+ * In 4-subband joint stereo mode, the joint stereo information ends on a half-byte
+ * boundary, so it's necessary to use the bitstream abstraction to read it, since
+ * OI_SBC_ReadSamples will need to pick up in mid-byte.
+ */
+ OI_BITSTREAM_ReadInit(bs, b);
+ *scale_factor++ = OI_BITSTREAM_ReadUINT4Aligned(bs);
+ }
+}
+
+/** Read quantized subband samples from the input bitstream and expand them. */
+PRIVATE void OI_SBC_ReadSamples(OI_CODEC_SBC_DECODER_CONTEXT *context, OI_BITSTREAM *global_bs)
+{
+ OI_CODEC_SBC_COMMON_CONTEXT *common = &context->common;
+ OI_UINT nrof_blocks = common->frameInfo.nrof_blocks;
+ OI_INT32 * RESTRICT s = common->subdata;
+ OI_UINT8 *ptr = global_bs->ptr.w;
+ OI_UINT32 value = global_bs->value;
+ OI_UINT bitPtr = global_bs->bitPtr;
+
+ const OI_UINT iter_count = common->frameInfo.nrof_channels * common->frameInfo.nrof_subbands / 4;
+ do {
+ OI_UINT i;
+ for (i = 0; i < iter_count; ++i) {
+ OI_UINT32 sf_by4 = ((OI_UINT32*)common->scale_factor)[i];
+ OI_UINT32 bits_by4 = common->bits.uint32[i];
+ OI_UINT n;
+ for (n = 0; n < 4; ++n) {
+ OI_INT32 dequant;
+ OI_UINT bits;
+ OI_INT sf;
+
+ if (OI_CPU_BYTE_ORDER == OI_LITTLE_ENDIAN_BYTE_ORDER) {
+ bits = bits_by4 & 0xFF;
+ bits_by4 >>= 8;
+ sf = sf_by4 & 0xFF;
+ sf_by4 >>= 8;
+ } else {
+ bits = (bits_by4 >> 24) & 0xFF;
+ bits_by4 <<= 8;
+ sf = (sf_by4 >> 24) & 0xFF;
+ sf_by4 <<= 8;
+ }
+ if (bits) {
+ OI_UINT32 raw;
+ OI_BITSTREAM_READUINT(raw, bits, ptr, value, bitPtr);
+ dequant = OI_SBC_Dequant(raw, sf, bits);
+ } else {
+ dequant = 0;
+ }
+ *s++ = dequant;
+ }
+ }
+ } while (--nrof_blocks);
+}
+
+
+
+/**
+@}
+*/
diff --git a/embdrv/sbc/decoder/srce/decoder-sbc.c b/embdrv/sbc/decoder/srce/decoder-sbc.c
new file mode 100644
index 0000000..2c3a98d
--- /dev/null
+++ b/embdrv/sbc/decoder/srce/decoder-sbc.c
@@ -0,0 +1,465 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2006 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/**********************************************************************************
+ $Revision: #1 $
+ ***********************************************************************************/
+
+/** @file
+@ingroup codec_internal
+*/
+
+/**@addtogroup codec_internal */
+/**@{*/
+
+#include "oi_codec_sbc_private.h"
+#include "oi_bitstream.h"
+
+#define SPECIALIZE_READ_SAMPLES_JOINT
+
+/**
+ * Scans through a buffer looking for a codec syncword. If the decoder has been
+ * set for enhanced operation using OI_CODEC_SBC_DecoderReset(), it will search
+ * for both a standard and an enhanced syncword.
+ */
+PRIVATE OI_STATUS FindSyncword(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ const OI_BYTE **frameData,
+ OI_UINT32 *frameBytes)
+{
+#ifdef SBC_ENHANCED
+ OI_BYTE search1 = OI_SBC_SYNCWORD;
+ OI_BYTE search2 = OI_SBC_ENHANCED_SYNCWORD;
+#endif // SBC_ENHANCED
+
+ if (*frameBytes == 0) {
+ return OI_CODEC_SBC_NOT_ENOUGH_HEADER_DATA;
+ }
+
+#ifdef SBC_ENHANCED
+ if (context->limitFrameFormat && context->enhancedEnabled){
+ /* If the context is restricted, only search for specified SYNCWORD */
+ search1 = search2;
+ } else if (context->enhancedEnabled == FALSE) {
+ /* If enhanced is not enabled, only search for classic SBC SYNCWORD*/
+ search2 = search1;
+ }
+ while (*frameBytes && (**frameData != search1) && (**frameData != search2)) {
+ (*frameBytes)--;
+ (*frameData)++;
+ }
+ if (*frameBytes) {
+ /* Syncword found, *frameData points to it, and *frameBytes correctly
+ * reflects the number of bytes available to read, including the
+ * syncword. */
+ context->common.frameInfo.enhanced = (**frameData == OI_SBC_ENHANCED_SYNCWORD);
+ return OI_OK;
+ } else {
+ /* No syncword was found anywhere in the provided input data.
+ * *frameData points past the end of the original input, and
+ * *frameBytes is 0. */
+ return OI_CODEC_SBC_NO_SYNCWORD;
+ }
+#else // SBC_ENHANCED
+ while (*frameBytes && (**frameData != OI_SBC_SYNCWORD)) {
+ (*frameBytes)--;
+ (*frameData)++;
+ }
+ if (*frameBytes) {
+ /* Syncword found, *frameData points to it, and *frameBytes correctly
+ * reflects the number of bytes available to read, including the
+ * syncword. */
+ context->common.frameInfo.enhanced = FALSE;
+ return OI_OK;
+ } else {
+ /* No syncword was found anywhere in the provided input data.
+ * *frameData points past the end of the original input, and
+ * *frameBytes is 0. */
+ return OI_CODEC_SBC_NO_SYNCWORD;
+ }
+#endif // SBC_ENHANCED
+}
+
+static OI_STATUS DecodeBody(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ const OI_BYTE *bodyData,
+ OI_INT16 *pcmData,
+ OI_UINT32 *pcmBytes,
+ OI_BOOL allowPartial)
+{
+ OI_BITSTREAM bs;
+ OI_UINT frameSamples = context->common.frameInfo.nrof_blocks * context->common.frameInfo.nrof_subbands;
+ OI_UINT decode_block_count;
+
+ /*
+ * Based on the header data, make sure that there is enough room to write the output samples.
+ */
+ if (*pcmBytes < (sizeof(OI_INT16) * frameSamples * context->common.pcmStride) && !allowPartial) {
+ /* If we're not allowing partial decodes, we need room for the entire
+ * codec frame */
+ TRACE(("-OI_CODEC_SBC_Decode: OI_CODEC_SBC_NOT_ENOUGH_AUDIO_DATA"));
+ return OI_CODEC_SBC_NOT_ENOUGH_AUDIO_DATA;
+ } else if (*pcmBytes < sizeof (OI_INT16) * context->common.frameInfo.nrof_subbands * context->common.pcmStride) {
+ /* Even if we're allowing partials, we can still only decode on a frame
+ * boundary */
+ return OI_CODEC_SBC_NOT_ENOUGH_AUDIO_DATA;
+ }
+
+ if (context->bufferedBlocks == 0) {
+ TRACE(("Reading scalefactors"));
+ OI_SBC_ReadScalefactors(&context->common, bodyData, &bs);
+
+ TRACE(("Computing bit allocation"));
+ OI_SBC_ComputeBitAllocation(&context->common);
+
+ TRACE(("Reading samples"));
+ if (context->common.frameInfo.mode == SBC_JOINT_STEREO) {
+ OI_SBC_ReadSamplesJoint(context, &bs);
+ } else {
+ OI_SBC_ReadSamples(context, &bs);
+ }
+
+ context->bufferedBlocks = context->common.frameInfo.nrof_blocks;
+ }
+
+ if (allowPartial) {
+ decode_block_count = *pcmBytes / sizeof(OI_INT16) / context->common.pcmStride / context->common.frameInfo.nrof_subbands;
+
+ if (decode_block_count > context->bufferedBlocks) {
+ decode_block_count = context->bufferedBlocks;
+ }
+
+ } else {
+ decode_block_count = context->common.frameInfo.nrof_blocks;
+ }
+
+ TRACE(("Synthesizing frame"));
+ {
+ OI_UINT start_block = context->common.frameInfo.nrof_blocks - context->bufferedBlocks;
+ OI_SBC_SynthFrame(context, pcmData, start_block, decode_block_count);
+ }
+
+ OI_ASSERT(context->bufferedBlocks >= decode_block_count);
+ context->bufferedBlocks -= decode_block_count;
+
+ frameSamples = decode_block_count * context->common.frameInfo.nrof_subbands;
+
+ /*
+ * When decoding mono into a stride-2 array, copy pcm data to second channel
+ */
+ if (context->common.frameInfo.nrof_channels == 1 && context->common.pcmStride == 2) {
+ OI_UINT i;
+ for (i = 0; i < frameSamples; ++i) {
+ pcmData[2*i+1] = pcmData[2*i];
+ }
+ }
+
+ /*
+ * Return number of pcm bytes generated by the decode operation.
+ */
+ *pcmBytes = frameSamples * sizeof(OI_INT16) * context->common.pcmStride;
+ if (context->bufferedBlocks > 0) {
+ return OI_CODEC_SBC_PARTIAL_DECODE;
+ } else {
+ return OI_OK;
+ }
+}
+
+PRIVATE OI_STATUS internal_DecodeRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ OI_UINT8 bitpool,
+ const OI_BYTE **frameData,
+ OI_UINT32 *frameBytes,
+ OI_INT16 *pcmData,
+ OI_UINT32 *pcmBytes)
+{
+ OI_STATUS status;
+ OI_UINT bodyLen;
+
+ TRACE(("+OI_CODEC_SBC_DecodeRaw"));
+
+ if (context->bufferedBlocks == 0) {
+ /*
+ * The bitallocator needs to know the bitpool value.
+ */
+ context->common.frameInfo.bitpool = bitpool;
+ /*
+ * Compute the frame length and check we have enough frame data to proceed
+ */
+ bodyLen = OI_CODEC_SBC_CalculateFramelen(&context->common.frameInfo) - SBC_HEADER_LEN;
+ if (*frameBytes < bodyLen) {
+ TRACE(("-OI_CODEC_SBC_Decode: OI_CODEC_SBC_NOT_ENOUGH_BODY_DATA"));
+ return OI_CODEC_SBC_NOT_ENOUGH_BODY_DATA;
+ }
+ } else {
+ bodyLen = 0;
+ }
+ /*
+ * Decode the SBC data. Pass TRUE to DecodeBody to allow partial decoding of
+ * tones.
+ */
+ status = DecodeBody(context, *frameData, pcmData, pcmBytes, TRUE);
+ if (OI_SUCCESS(status) || status == OI_CODEC_SBC_PARTIAL_DECODE) {
+ *frameData += bodyLen;
+ *frameBytes -= bodyLen;
+ }
+ TRACE(("-OI_CODEC_SBC_DecodeRaw: %d", status));
+ return status;
+}
+
+OI_STATUS OI_CODEC_SBC_DecoderReset(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ OI_UINT32 *decoderData,
+ OI_UINT32 decoderDataBytes,
+ OI_UINT8 maxChannels,
+ OI_UINT8 pcmStride,
+ OI_BOOL enhanced)
+{
+ return internal_DecoderReset(context, decoderData, decoderDataBytes, maxChannels, pcmStride, enhanced);
+}
+
+OI_STATUS OI_CODEC_SBC_DecodeFrame(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ const OI_BYTE **frameData,
+ OI_UINT32 *frameBytes,
+ OI_INT16 *pcmData,
+ OI_UINT32 *pcmBytes)
+{
+ OI_STATUS status;
+ OI_UINT framelen;
+ OI_UINT8 crc;
+
+ TRACE(("+OI_CODEC_SBC_DecodeFrame"));
+
+ TRACE(("Finding syncword"));
+ status = FindSyncword(context, frameData, frameBytes);
+ if (!OI_SUCCESS(status)) {
+ return status;
+ }
+
+ /* Make sure enough data remains to read the header. */
+ if (*frameBytes < SBC_HEADER_LEN) {
+ TRACE(("-OI_CODEC_SBC_DecodeFrame: OI_CODEC_SBC_NOT_ENOUGH_HEADER_DATA"));
+ return OI_CODEC_SBC_NOT_ENOUGH_HEADER_DATA;
+ }
+
+ TRACE(("Reading Header"));
+ OI_SBC_ReadHeader(&context->common, *frameData);
+
+ /*
+ * Some implementations load the decoder into RAM and use overlays for 4 vs 8 subbands. We need
+ * to ensure that the SBC parameters for this frame are compatible with the restrictions imposed
+ * by the loaded overlays.
+ */
+ if (context->limitFrameFormat && (context->common.frameInfo.subbands != context->restrictSubbands)) {
+ ERROR(("SBC parameters incompatible with loaded overlay"));
+ return OI_STATUS_INVALID_PARAMETERS;
+ }
+
+ if (context->common.frameInfo.nrof_channels > context->common.maxChannels) {
+ ERROR(("SBC parameters incompatible with number of channels specified during reset"));
+ return OI_STATUS_INVALID_PARAMETERS;
+ }
+
+ if (context->common.pcmStride < 1 || context->common.pcmStride > 2) {
+ ERROR(("PCM stride not set correctly during reset"));
+ return OI_STATUS_INVALID_PARAMETERS;
+ }
+
+ /*
+ * At this point a header has been read. However, it's possible that we found a false syncword,
+ * so the header data might be invalid. Make sure we have enough bytes to read in the
+ * CRC-protected header, but don't require we have the whole frame. That way, if it turns out
+ * that we're acting on bogus header data, we don't stall the decoding process by waiting for
+ * data that we don't actually need.
+ */
+ framelen = OI_CODEC_SBC_CalculateFramelen(&context->common.frameInfo);
+ if (*frameBytes < framelen) {
+ TRACE(("-OI_CODEC_SBC_DecodeFrame: OI_CODEC_SBC_NOT_ENOUGH_BODY_DATA"));
+ return OI_CODEC_SBC_NOT_ENOUGH_BODY_DATA;
+ }
+
+ TRACE(("Calculating checksum"));
+
+ crc = OI_SBC_CalculateChecksum(&context->common.frameInfo, *frameData);
+ if (crc != context->common.frameInfo.crc) {
+ TRACE(("CRC Mismatch: calc=%02x read=%02x\n", crc, context->common.frameInfo.crc));
+ TRACE(("-OI_CODEC_SBC_DecodeFrame: OI_CODEC_SBC_CHECKSUM_MISMATCH"));
+ return OI_CODEC_SBC_CHECKSUM_MISMATCH;
+ }
+
+#ifdef OI_DEBUG
+ /*
+ * Make sure the bitpool values are sane.
+ */
+ if ((context->common.frameInfo.bitpool < SBC_MIN_BITPOOL) && !context->common.frameInfo.enhanced) {
+ ERROR(("Bitpool too small: %d (must be >= 2)", context->common.frameInfo.bitpool));
+ return OI_STATUS_INVALID_PARAMETERS;
+ }
+ if (context->common.frameInfo.bitpool > OI_SBC_MaxBitpool(&context->common.frameInfo)) {
+ ERROR(("Bitpool too large: %d (must be <= %ld)", context->common.frameInfo.bitpool, OI_SBC_MaxBitpool(&context->common.frameInfo)));
+ return OI_STATUS_INVALID_PARAMETERS;
+ }
+#endif
+
+ /*
+ * Now decode the SBC data. Partial decode is not yet implemented for an SBC
+ * stream, so pass FALSE to decode body to have it enforce the old rule that
+ * you have to decode a whole packet at a time.
+ */
+ status = DecodeBody(context, *frameData + SBC_HEADER_LEN, pcmData, pcmBytes, FALSE);
+ if (OI_SUCCESS(status)) {
+ *frameData += framelen;
+ *frameBytes -= framelen;
+ }
+ TRACE(("-OI_CODEC_SBC_DecodeFrame: %d", status));
+
+ return status;
+}
+
+OI_STATUS OI_CODEC_SBC_SkipFrame(OI_CODEC_SBC_DECODER_CONTEXT *context,
+ const OI_BYTE **frameData,
+ OI_UINT32 *frameBytes)
+{
+ OI_STATUS status;
+ OI_UINT framelen;
+ OI_UINT headerlen;
+ OI_UINT8 crc;
+
+ status = FindSyncword(context, frameData, frameBytes);
+ if (!OI_SUCCESS(status)) {
+ return status;
+ }
+ if (*frameBytes < SBC_HEADER_LEN) {
+ return OI_CODEC_SBC_NOT_ENOUGH_HEADER_DATA;
+ }
+ OI_SBC_ReadHeader(&context->common, *frameData);
+ framelen = OI_SBC_CalculateFrameAndHeaderlen(&context->common.frameInfo, &headerlen);
+ if (*frameBytes < headerlen) {
+ return OI_CODEC_SBC_NOT_ENOUGH_HEADER_DATA;
+ }
+ crc = OI_SBC_CalculateChecksum(&context->common.frameInfo, *frameData);
+ if (crc != context->common.frameInfo.crc) {
+ return OI_CODEC_SBC_CHECKSUM_MISMATCH;
+ }
+ if (*frameBytes < framelen) {
+ return OI_CODEC_SBC_NOT_ENOUGH_BODY_DATA;
+ }
+ context->bufferedBlocks = 0;
+ *frameData += framelen;
+ *frameBytes -= framelen;
+ return OI_OK;
+}
+
+OI_UINT8 OI_CODEC_SBC_FrameCount(OI_BYTE *frameData,
+ OI_UINT32 frameBytes)
+{
+ OI_UINT8 mode;
+ OI_UINT8 blocks;
+ OI_UINT8 subbands;
+ OI_UINT8 frameCount = 0;
+ OI_UINT frameLen;
+
+ while (frameBytes){
+ while (frameBytes && ((frameData[0] & 0xFE) != 0x9C)){
+ frameData++;
+ frameBytes--;
+ }
+
+ if (frameBytes < SBC_HEADER_LEN) {
+ return frameCount;
+ }
+
+ /* Extract and translate required fields from Header */
+ subbands = mode = blocks = frameData[1];;
+ mode = (mode & (BIT3 | BIT2)) >> 2;
+ blocks = block_values[(blocks & (BIT5 | BIT4)) >> 4];
+ subbands = band_values[(subbands & BIT0)];
+
+ /* Inline logic to avoid corrupting context */
+ frameLen = blocks * frameData[2];
+ switch (mode){
+ case SBC_JOINT_STEREO:
+ frameLen += subbands + (8 * subbands);
+ break;
+
+ case SBC_DUAL_CHANNEL:
+ frameLen *= 2;
+ /* fall through */
+
+ default:
+ if (mode == SBC_MONO){
+ frameLen += 4*subbands;
+ } else {
+ frameLen += 8*subbands;
+ }
+ }
+
+ frameCount++;
+ frameLen = SBC_HEADER_LEN + (frameLen + 7) / 8;
+ if (frameBytes > frameLen){
+ frameBytes -= frameLen;
+ frameData += frameLen;
+ } else {
+ frameBytes = 0;
+ }
+ }
+ return frameCount;
+}
+
+/** Read quantized subband samples from the input bitstream and expand them. */
+
+#ifdef SPECIALIZE_READ_SAMPLES_JOINT
+
+PRIVATE void OI_SBC_ReadSamplesJoint4(OI_CODEC_SBC_DECODER_CONTEXT *context, OI_BITSTREAM *global_bs)
+{
+#define NROF_SUBBANDS 4
+#include "readsamplesjoint.inc"
+#undef NROF_SUBBANDS
+}
+
+PRIVATE void OI_SBC_ReadSamplesJoint8(OI_CODEC_SBC_DECODER_CONTEXT *context, OI_BITSTREAM *global_bs)
+{
+#define NROF_SUBBANDS 8
+#include "readsamplesjoint.inc"
+#undef NROF_SUBBANDS
+}
+
+typedef void (*READ_SAMPLES)(OI_CODEC_SBC_DECODER_CONTEXT *context, OI_BITSTREAM *global_bs);
+
+static const READ_SAMPLES SpecializedReadSamples[] = {
+ OI_SBC_ReadSamplesJoint4,
+ OI_SBC_ReadSamplesJoint8
+};
+
+#endif /* SPECIALIZE_READ_SAMPLES_JOINT */
+
+
+PRIVATE void OI_SBC_ReadSamplesJoint(OI_CODEC_SBC_DECODER_CONTEXT *context, OI_BITSTREAM *global_bs)
+{
+ OI_CODEC_SBC_COMMON_CONTEXT *common = &context->common;
+ OI_UINT nrof_subbands = common->frameInfo.nrof_subbands;
+#ifdef SPECIALIZE_READ_SAMPLES_JOINT
+ OI_ASSERT((nrof_subbands >> 3u) <= 1u);
+ SpecializedReadSamples[nrof_subbands >> 3](context, global_bs);
+#else
+
+#define NROF_SUBBANDS nrof_subbands
+#include "readsamplesjoint.inc"
+#undef NROF_SUBBANDS
+#endif /* SPECIALIZE_READ_SAMPLES_JOINT */
+}
+
+/**@}*/
+
diff --git a/embdrv/sbc/decoder/srce/dequant.c b/embdrv/sbc/decoder/srce/dequant.c
new file mode 100644
index 0000000..e06069c
--- /dev/null
+++ b/embdrv/sbc/decoder/srce/dequant.c
@@ -0,0 +1,210 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+/**
+ @file
+
+ Dequantizer for SBC decoder; reconstructs quantized representation of subband samples.
+
+ @ingroup codec_internal
+ */
+
+/**
+@addtogroup codec_internal
+@{
+*/
+
+/**
+ This function is a fixed-point approximation of a modification of the following
+ dequantization operation defined in the spec, as inferred from section 12.6.4:
+
+ @code
+ dequant = 2^(scale_factor+1) * ((raw * 2.0 + 1.0) / ((2^bits) - 1) - 1)
+
+ 2 <= bits <= 16
+ 0 <= raw < (2^bits)-1 (the -1 is because quantized values with all 1's are forbidden)
+
+ -65535 < dequant < 65535
+ @endcode
+
+ The code below computes the dequantized value divided by a scaling constant
+ equal to about 1.38. This constant is chosen to ensure that the entry in the
+ dequant_long_scaled table for 16 bits is as accurate as possible, since it has
+ the least relative precision available to it due to its small magnitude.
+
+ This routine outputs in Q16.15 format.
+
+ The helper array dequant_long is defined as follows:
+
+ @code
+ dequant_long_long[bits] = round(2^31 * 1/((2^bits - 1) / 1.38...) for 2 <= bits <= 16
+ @endcode
+
+
+ Additionally, the table entries have the following property:
+
+ @code
+ dequant_long_scaled[bits] <= 2^31 / ((2^bits - 1)) for 2 <= bits <= 16
+ @endcode
+
+ Therefore
+
+ @code
+ d = 2 * raw + 1 1 <= d <= 2^bits - 2
+
+ d' = d * dequant_long[bits]
+
+ d * dequant_long_scaled[bits] <= (2^bits - 2) * (2^31 / (2^bits - 1))
+ d * dequant_long_scaled[bits] <= 2^31 * (2^bits - 2)/(2^bits - 1) < 2^31
+ @endcode
+
+ Therefore, d' doesn't overflow a signed 32-bit value.
+
+ @code
+
+ d' =~ 2^31 * (raw * 2.0 + 1.0) / (2^bits - 1) / 1.38...
+
+ result = d' - 2^31/1.38... =~ 2^31 * ((raw * 2.0 + 1.0) / (2^bits - 1) - 1) / 1.38...
+
+ result is therefore a scaled approximation to dequant. It remains only to
+ turn 2^31 into 2^(scale_factor+1). Since we're aiming for Q16.15 format,
+ this is achieved by shifting right by (15-scale_factor):
+
+ (2^31 * x) >> (15-scale_factor) =~ 2^(31-15+scale_factor) * x = 2^15 * 2^(1+scale_factor) * x
+ @endcode
+
+ */
+
+#include <oi_codec_sbc_private.h>
+
+#ifndef SBC_DEQUANT_LONG_SCALED_OFFSET
+#define SBC_DEQUANT_LONG_SCALED_OFFSET 1555931970
+#endif
+
+#ifndef SBC_DEQUANT_LONG_UNSCALED_OFFSET
+#define SBC_DEQUANT_LONG_UNSCALED_OFFSET 2147483648
+#endif
+
+#ifndef SBC_DEQUANT_SCALING_FACTOR
+#define SBC_DEQUANT_SCALING_FACTOR 1.38019122262781f
+#endif
+
+const OI_UINT32 dequant_long_scaled[17];
+const OI_UINT32 dequant_long_unscaled[17];
+
+/** Scales x by y bits to the right, adding a rounding factor.
+ */
+#ifndef SCALE
+#define SCALE(x, y) (((x) + (1 <<((y)-1))) >> (y))
+#endif
+
+#ifdef DEBUG_DEQUANTIZATION
+
+#include <math.h>
+
+INLINE float dequant_float(OI_UINT32 raw, OI_UINT scale_factor, OI_UINT bits)
+{
+ float result = (1 << (scale_factor+1)) * ((raw * 2.0f + 1.0f) / ((1 << bits) - 1.0f) - 1.0f);
+
+ result /= SBC_DEQUANT_SCALING_FACTOR;
+
+ /* Unless the encoder screwed up, all correct dequantized values should
+ * satisfy this inequality. Non-compliant encoders which generate quantized
+ * values with all 1-bits set can, theoretically, trigger this assert. This
+ * is unlikely, however, and only an issue in debug mode.
+ */
+ OI_ASSERT(fabs(result) < 32768 * 1.6);
+
+ return result;
+}
+
+#endif
+
+
+INLINE OI_INT32 OI_SBC_Dequant(OI_UINT32 raw, OI_UINT scale_factor, OI_UINT bits)
+{
+ OI_UINT32 d;
+ OI_INT32 result;
+
+ OI_ASSERT(scale_factor <= 15);
+ OI_ASSERT(bits <= 16);
+
+ if (bits <= 1) {
+ return 0;
+ }
+
+ d = (raw * 2) + 1;
+ d *= dequant_long_scaled[bits];
+ result = d - SBC_DEQUANT_LONG_SCALED_OFFSET;
+
+#ifdef DEBUG_DEQUANTIZATION
+ {
+ OI_INT32 integerized_float_result;
+ float float_result;
+
+ float_result = dequant_float(raw, scale_factor, bits);
+ integerized_float_result = (OI_INT32)floor(0.5f+float_result * (1 << 15));
+
+ /* This detects overflow */
+ OI_ASSERT(((result >= 0) && (integerized_float_result >= 0)) ||
+ ((result <= 0) && (integerized_float_result <= 0)));
+ }
+#endif
+ return result >> (15 - scale_factor);
+}
+
+/* This version of Dequant does not incorporate the scaling factor of 1.38. It
+ * is intended for use with implementations of the filterbank which are
+ * hard-coded into a DSP. Output is Q16.4 format, so that after joint stereo
+ * processing (which leaves the most significant bit equal to the sign bit if
+ * the encoder is conformant) the result will fit a 24 bit fixed point signed
+ * value.*/
+
+INLINE OI_INT32 OI_SBC_Dequant_Unscaled(OI_UINT32 raw, OI_UINT scale_factor, OI_UINT bits)
+{
+ OI_UINT32 d;
+ OI_INT32 result;
+
+ OI_ASSERT(scale_factor <= 15);
+ OI_ASSERT(bits <= 16);
+
+
+ if (bits <= 1) {
+ return 0;
+ }
+ if (bits == 16) {
+ result = (raw << 16) + raw - 0x7fff7fff;
+ return SCALE(result, 24 - scale_factor);
+ }
+
+
+ d = (raw * 2) + 1;
+ d *= dequant_long_unscaled[bits];
+ result = d - 0x80000000;
+
+ return SCALE(result, 24 - scale_factor);
+}
+
+/**
+@}
+*/
diff --git a/embdrv/sbc/decoder/srce/framing-sbc.c b/embdrv/sbc/decoder/srce/framing-sbc.c
new file mode 100644
index 0000000..88cb2e2
--- /dev/null
+++ b/embdrv/sbc/decoder/srce/framing-sbc.c
@@ -0,0 +1,54 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+/** @file
+@ingroup codec_internal
+*/
+
+/**@addgroup codec_internal*/
+/**@{*/
+
+#include "oi_codec_sbc_private.h"
+
+const OI_CHAR* const OI_CODEC_SBC_FreqText[] = { "SBC_FREQ_16000", "SBC_FREQ_32000", "SBC_FREQ_44100", "SBC_FREQ_48000" };
+const OI_CHAR* const OI_CODEC_SBC_ModeText[] = { "SBC_MONO", "SBC_DUAL_CHANNEL", "SBC_STEREO", "SBC_JOINT_STEREO" };
+const OI_CHAR* const OI_CODEC_SBC_SubbandsText[] = { "SBC_SUBBANDS_4", "SBC_SUBBANDS_8" };
+const OI_CHAR* const OI_CODEC_SBC_BlocksText[] = { "SBC_BLOCKS_4", "SBC_BLOCKS_8", "SBC_BLOCKS_12", "SBC_BLOCKS_16" };
+const OI_CHAR* const OI_CODEC_SBC_AllocText[] = { "SBC_LOUDNESS", "SBC_SNR" };
+
+#ifdef OI_DEBUG
+void OI_CODEC_SBC_DumpConfig(OI_CODEC_SBC_FRAME_INFO *frameInfo)
+{
+ printf("SBC configuration\n");
+ printf(" enhanced: %s\n", frameInfo->enhanced ? "TRUE" : "FALSE");
+ printf(" frequency: %d\n", frameInfo->frequency);
+ printf(" subbands: %d\n", frameInfo->nrof_subbands);
+ printf(" blocks: %d\n", frameInfo->nrof_blocks);
+ printf(" channels: %d\n", frameInfo->nrof_channels);
+ printf(" mode: %s\n", OI_CODEC_SBC_ModeText[frameInfo->mode]);
+ printf(" alloc: %s\n", OI_CODEC_SBC_AllocText[frameInfo->alloc]);
+ printf(" bitpool: %d\n", frameInfo->bitpool);
+}
+#endif /* OI_DEBUG */
+
+/**@}*/
diff --git a/embdrv/sbc/decoder/srce/framing.c b/embdrv/sbc/decoder/srce/framing.c
new file mode 100644
index 0000000..c94ec90
--- /dev/null
+++ b/embdrv/sbc/decoder/srce/framing.c
@@ -0,0 +1,249 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+/**
+@file
+Checksum and header-related functions.
+
+@ingroup codec_internal
+*/
+
+/**
+@addtogroup codec_internal
+@{
+*/
+
+#include "oi_codec_sbc_private.h"
+#include "oi_assert.h"
+
+
+/* asdasd */
+
+#define USE_NIBBLEWISE_CRC
+
+/* #define PRINT_SAMPLES */
+/* #define PRINT_SCALEFACTORS */
+/* #define DEBUG_CRC */
+
+/*
+ * CRC-8 table for X^8 + X^4 + X^3 + X^2 + 1; byte-wise lookup
+ */
+#ifdef USE_WIDE_CRC
+/* Save space if a char is 16 bits, such as on the C54x */
+const OI_BYTE crc8_wide[128] = {
+ 0x001d, 0x3a27, 0x7469, 0x4e53, 0xe8f5, 0xd2cf, 0x9c81, 0xa6bb, 0xcdd0, 0xf7ea, 0xb9a4, 0x839e, 0x2538, 0x1f02, 0x514c, 0x6b76, 0x879a, 0xbda0, 0xf3ee, 0xc9d4, 0x6f72, 0x5548, 0x1b06, 0x213c, 0x4a57, 0x706d, 0x3e23, 0x0419, 0xa2bf, 0x9885, 0xd6cb, 0xecf1, 0x130e, 0x2934, 0x677a, 0x5d40, 0xfbe6, 0xc1dc, 0x8f92, 0xb5a8, 0xdec3, 0xe4f9, 0xaab7, 0x908d, 0x362b, 0x0c11, 0x425f, 0x7865, 0x9489, 0xaeb3, 0xe0fd, 0xdac7, 0x7c61, 0x465b, 0x0815, 0x322f, 0x5944, 0x637e, 0x2d30, 0x170a, 0xb1ac, 0x8b96, 0xc5d8, 0xffe2, 0x263b, 0x1c01, 0x524f, 0x6875, 0xced3, 0xf4e9, 0xbaa7, 0x809d, 0xebf6, 0xd1cc, 0x9f82, 0xa5b8, 0x031e, 0x3924, 0x776a, 0x4d50, 0xa1bc, 0x9b86, 0xd5c8, 0xeff2, 0x4954, 0x736e, 0x3d20, 0x071a, 0x6c71, 0x564b, 0x1805, 0x223f, 0x8499, 0xbea3, 0xf0ed, 0xcad7, 0x3528, 0x0f12, 0x415c, 0x7b66, 0xddc0, 0xe7fa, 0xa9b4, 0x938e, 0xf8e5, 0xc2df, 0x8c91, 0xb6ab, 0x100d, 0x2a37, 0x6479, 0x5e43, 0xb2af, 0x8895, 0xc6db, 0xfce1, 0x5a47, 0x607d, 0x2e33, 0x1409, 0x7f62, 0x4558, 0x0b16, 0x312c, 0x978a, 0xadb0, 0xe3fe, 0xd9c4,
+};
+#elif defined(USE_NIBBLEWISE_CRC)
+const OI_BYTE crc8_narrow[16] = {
+ 0x00, 0x1d, 0x3a, 0x27, 0x74, 0x69, 0x4e, 0x53, 0xe8, 0xf5, 0xd2, 0xcf, 0x9c, 0x81, 0xa6, 0xbb
+};
+#else
+const OI_BYTE crc8_narrow[256] = {
+ 0x00, 0x1d, 0x3a, 0x27, 0x74, 0x69, 0x4e, 0x53, 0xe8, 0xf5, 0xd2, 0xcf, 0x9c, 0x81, 0xa6, 0xbb, 0xcd, 0xd0, 0xf7, 0xea, 0xb9, 0xa4, 0x83, 0x9e, 0x25, 0x38, 0x1f, 0x02, 0x51, 0x4c, 0x6b, 0x76, 0x87, 0x9a, 0xbd, 0xa0, 0xf3, 0xee, 0xc9, 0xd4, 0x6f, 0x72, 0x55, 0x48, 0x1b, 0x06, 0x21, 0x3c, 0x4a, 0x57, 0x70, 0x6d, 0x3e, 0x23, 0x04, 0x19, 0xa2, 0xbf, 0x98, 0x85, 0xd6, 0xcb, 0xec, 0xf1, 0x13, 0x0e, 0x29, 0x34, 0x67, 0x7a, 0x5d, 0x40, 0xfb, 0xe6, 0xc1, 0xdc, 0x8f, 0x92, 0xb5, 0xa8, 0xde, 0xc3, 0xe4, 0xf9, 0xaa, 0xb7, 0x90, 0x8d, 0x36, 0x2b, 0x0c, 0x11, 0x42, 0x5f, 0x78, 0x65, 0x94, 0x89, 0xae, 0xb3, 0xe0, 0xfd, 0xda, 0xc7, 0x7c, 0x61, 0x46, 0x5b, 0x08, 0x15, 0x32, 0x2f, 0x59, 0x44, 0x63, 0x7e, 0x2d, 0x30, 0x17, 0x0a, 0xb1, 0xac, 0x8b, 0x96, 0xc5, 0xd8, 0xff, 0xe2, 0x26, 0x3b, 0x1c, 0x01, 0x52, 0x4f, 0x68, 0x75, 0xce, 0xd3, 0xf4, 0xe9, 0xba, 0xa7, 0x80, 0x9d, 0xeb, 0xf6, 0xd1, 0xcc, 0x9f, 0x82, 0xa5, 0xb8, 0x03, 0x1e, 0x39, 0x24, 0x77, 0x6a, 0x4d, 0x50, 0xa1, 0xbc, 0x9b, 0x86, 0xd5, 0xc8, 0xef, 0xf2, 0x49, 0x54, 0x73, 0x6e, 0x3d, 0x20, 0x07, 0x1a, 0x6c, 0x71, 0x56, 0x4b, 0x18, 0x05, 0x22, 0x3f, 0x84, 0x99, 0xbe, 0xa3, 0xf0, 0xed, 0xca, 0xd7, 0x35, 0x28, 0x0f, 0x12, 0x41, 0x5c, 0x7b, 0x66, 0xdd, 0xc0, 0xe7, 0xfa, 0xa9, 0xb4, 0x93, 0x8e, 0xf8, 0xe5, 0xc2, 0xdf, 0x8c, 0x91, 0xb6, 0xab, 0x10, 0x0d, 0x2a, 0x37, 0x64, 0x79, 0x5e, 0x43, 0xb2, 0xaf, 0x88, 0x95, 0xc6, 0xdb, 0xfc, 0xe1, 0x5a, 0x47, 0x60, 0x7d, 0x2e, 0x33, 0x14, 0x09, 0x7f, 0x62, 0x45, 0x58, 0x0b, 0x16, 0x31, 0x2c, 0x97, 0x8a, 0xad, 0xb0, 0xe3, 0xfe, 0xd9, 0xc4
+};
+#endif
+const OI_UINT32 dequant_long_scaled[17] = {
+ 0,
+ 0,
+ 0x1ee9e116, /* bits=2 0.24151243 1/3 * (1/1.38019122262781) (0x00000008)*/
+ 0x0d3fa99c, /* bits=3 0.10350533 1/7 * (1/1.38019122262781) (0x00000013)*/
+ 0x062ec69e, /* bits=4 0.04830249 1/15 * (1/1.38019122262781) (0x00000029)*/
+ 0x02fddbfa, /* bits=5 0.02337217 1/31 * (1/1.38019122262781) (0x00000055)*/
+ 0x0178d9f5, /* bits=6 0.01150059 1/63 * (1/1.38019122262781) (0x000000ad)*/
+ 0x00baf129, /* bits=7 0.00570502 1/127 * (1/1.38019122262781) (0x0000015e)*/
+ 0x005d1abe, /* bits=8 0.00284132 1/255 * (1/1.38019122262781) (0x000002bf)*/
+ 0x002e760d, /* bits=9 0.00141788 1/511 * (1/1.38019122262781) (0x00000582)*/
+ 0x00173536, /* bits=10 0.00070825 1/1023 * (1/1.38019122262781) (0x00000b07)*/
+ 0x000b9928, /* bits=11 0.00035395 1/2047 * (1/1.38019122262781) (0x00001612)*/
+ 0x0005cc37, /* bits=12 0.00017693 1/4095 * (1/1.38019122262781) (0x00002c27)*/
+ 0x0002e604, /* bits=13 0.00008846 1/8191 * (1/1.38019122262781) (0x00005852)*/
+ 0x000172fc, /* bits=14 0.00004422 1/16383 * (1/1.38019122262781) (0x0000b0a7)*/
+ 0x0000b97d, /* bits=15 0.00002211 1/32767 * (1/1.38019122262781) (0x00016150)*/
+ 0x00005cbe, /* bits=16 0.00001106 1/65535 * (1/1.38019122262781) (0x0002c2a5)*/
+};
+
+
+const OI_UINT32 dequant_long_unscaled[17] = {
+ 0,
+ 0,
+ 0x2aaaaaab, /* bits=2 0.33333333 1/3 (0x00000005)*/
+ 0x12492492, /* bits=3 0.14285714 1/7 (0x0000000e)*/
+ 0x08888889, /* bits=4 0.06666667 1/15 (0x0000001d)*/
+ 0x04210842, /* bits=5 0.03225806 1/31 (0x0000003e)*/
+ 0x02082082, /* bits=6 0.01587302 1/63 (0x0000007e)*/
+ 0x01020408, /* bits=7 0.00787402 1/127 (0x000000fe)*/
+ 0x00808081, /* bits=8 0.00392157 1/255 (0x000001fd)*/
+ 0x00402010, /* bits=9 0.00195695 1/511 (0x000003fe)*/
+ 0x00200802, /* bits=10 0.00097752 1/1023 (0x000007fe)*/
+ 0x00100200, /* bits=11 0.00048852 1/2047 (0x00000ffe)*/
+ 0x00080080, /* bits=12 0.00024420 1/4095 (0x00001ffe)*/
+ 0x00040020, /* bits=13 0.00012209 1/8191 (0x00003ffe)*/
+ 0x00020008, /* bits=14 0.00006104 1/16383 (0x00007ffe)*/
+ 0x00010002, /* bits=15 0.00003052 1/32767 (0x0000fffe)*/
+ 0x00008001, /* bits=16 0.00001526 1/65535 (0x0001fffc)*/
+};
+
+#if defined(OI_DEBUG) || defined(PRINT_SAMPLES) || defined(PRINT_SCALEFACTORS)
+#include <stdio.h>
+#endif
+
+#ifdef USE_WIDE_CRC
+INLINE OI_CHAR crc_iterate(OI_UINT8 oldcrc, OI_UINT8 next)
+{
+ OI_UINT crc;
+ OI_UINT idx;
+ idx = oldcrc^next;
+ crc = crc8_wide[idx >> 1];
+ if (idx%2) {
+ crc &= 0xff;
+ } else {
+ crc >>= 8;
+ }
+
+ return crc;
+}
+
+INLINE OI_CHAR crc_iterate_top4(OI_UINT8 oldcrc, OI_UINT8 next)
+{
+ OI_UINT crc;
+ OI_UINT idx;
+ idx = (oldcrc ^ next) >> 4;
+ crc = crc8_wide[idx>>1];
+ if (idx%2) {
+ crc &= 0xff;
+ } else {
+ crc >>= 8;
+ }
+
+ return (oldcrc << 4) ^ crc;
+}
+
+#else // USE_WIDE_CRC
+
+INLINE OI_UINT8 crc_iterate_top4(OI_UINT8 oldcrc, OI_UINT8 next)
+{
+ return (oldcrc << 4) ^ crc8_narrow[(oldcrc^next) >> 4];
+}
+
+#ifdef USE_NIBBLEWISE_CRC
+INLINE OI_UINT8 crc_iterate(OI_UINT8 crc, OI_UINT8 next)
+{
+ crc = (crc << 4) ^ crc8_narrow[(crc^next) >> 4];
+ crc = (crc << 4) ^ crc8_narrow[((crc>>4)^next)&0xf];
+
+ return crc;
+}
+
+#else // USE_NIBBLEWISE_CRC
+INLINE OI_UINT8 crc_iterate(OI_UINT8 crc, OI_UINT8 next)
+{
+ return crc8_narrow[crc^next];
+}
+
+#endif // USE_NIBBLEWISE_CRC
+
+#endif // USE_WIDE_CRC
+
+
+PRIVATE OI_UINT8 OI_SBC_CalculateChecksum(OI_CODEC_SBC_FRAME_INFO *frame, OI_BYTE const *data)
+{
+ OI_UINT i;
+ OI_UINT8 crc = 0x0f;
+ /* Count is the number of whole bytes subject to CRC. Actually, it's one
+ * more than this number, because data[3] is the CRC field itself, which is
+ * explicitly skipped. Since crc_iterate (should be) inlined, it's cheaper
+ * spacewise to include the check in the loop. This shouldn't be much of a
+ * bottleneck routine in the first place. */
+ OI_UINT count = (frame->nrof_subbands * frame->nrof_channels / 2u) + 4;
+
+ if (frame->mode == SBC_JOINT_STEREO && frame->nrof_subbands == 8) {
+ count++;
+ }
+
+ for (i = 1; i < count; i++) {
+ if (i != 3) {
+ crc = crc_iterate(crc,data[i]);
+ }
+ }
+
+ if (frame->mode == SBC_JOINT_STEREO && frame->nrof_subbands == 4) {
+ crc = crc_iterate_top4(crc, data[i]);
+ }
+
+ return crc;
+}
+
+void OI_SBC_ExpandFrameFields(OI_CODEC_SBC_FRAME_INFO *frame)
+{
+ frame->nrof_blocks = block_values[frame->blocks];
+ frame->nrof_subbands = band_values[frame->subbands];
+
+ frame->frequency = freq_values[frame->freqIndex];
+ frame->nrof_channels = channel_values[frame->mode];
+}
+
+/**
+ * Unrolled macro to copy 4 32-bit aligned 32-bit values backward in memory
+ */
+#define COPY4WORDS_BACK(_dest, _src) \
+ do { \
+ OI_INT32 _a, _b, _c, _d; \
+ _a = *--_src; \
+ _b = *--_src; \
+ _c = *--_src; \
+ _d = *--_src; \
+ *--_dest = _a; \
+ *--_dest = _b; \
+ *--_dest = _c; \
+ *--_dest = _d; \
+ } while (0)
+
+
+#if defined(USE_PLATFORM_MEMMOVE) || defined(USE_PLATFORM_MEMCPY)
+#include <string.h>
+#endif
+PRIVATE void shift_buffer(SBC_BUFFER_T *dest, SBC_BUFFER_T *src, OI_UINT wordCount)
+{
+#ifdef USE_PLATFORM_MEMMOVE
+ memmove(dest, src, wordCount * sizeof(SBC_BUFFER_T));
+#elif defined(USE_PLATFORM_MEMCPY)
+ OI_ASSERT(((OI_CHAR *)(dest) - (OI_CHAR *)(src)) >= wordCount*sizeof(*dest));
+ memcpy(dest, src, wordCount * sizeof(SBC_BUFFER_T));
+#else
+ OI_UINT n;
+ OI_INT32 *d;
+ OI_INT32 *s;
+ n = wordCount / 4 / (sizeof(OI_INT32)/sizeof(*dest));
+ OI_ASSERT((n * 4 * (sizeof(OI_INT32)/sizeof(*dest))) == wordCount);
+
+ d = (void*)(dest + wordCount);
+ s = (void*)(src + wordCount);
+
+ do {
+ COPY4WORDS_BACK(d, s);
+ } while (--n);
+#endif
+}
+/**
+@}
+*/
diff --git a/embdrv/sbc/decoder/srce/oi_codec_version.c b/embdrv/sbc/decoder/srce/oi_codec_version.c
new file mode 100644
index 0000000..25dc162
--- /dev/null
+++ b/embdrv/sbc/decoder/srce/oi_codec_version.c
@@ -0,0 +1,57 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/**
+@file
+This file contains a single function, which returns a string indicating the
+version number of the eSBC codec
+
+@ingroup codec_internal
+*/
+
+/**
+@addtogroup codec_internal
+@{
+*/
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+#include "oi_stddefs.h"
+#include "oi_codec_sbc_private.h"
+
+/** Version string for the BLUEmagic 3.0 protocol stack and profiles */
+PRIVATE OI_CHAR * const codecVersion = "v1.5"
+#ifdef OI_SBC_EVAL
+" (Evaluation version)"
+#endif
+;
+
+/** This function returns the version string for the BLUEmagic 3.0 protocol stack
+ and profiles */
+OI_CHAR *OI_CODEC_Version(void) {
+ return codecVersion;
+}
+
+/**********************************************************************************/
+
+/**
+@}
+*/
diff --git a/embdrv/sbc/decoder/srce/readsamplesjoint.inc b/embdrv/sbc/decoder/srce/readsamplesjoint.inc
new file mode 100644
index 0000000..875a394
--- /dev/null
+++ b/embdrv/sbc/decoder/srce/readsamplesjoint.inc
@@ -0,0 +1,111 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/*******************************************************************************
+ * @file readsamplesjoint.inc
+ *
+ * This is the body of the generic version of OI_SBC_ReadSamplesJoint().
+ * It is designed to be \#included into a function as follows:
+ \code
+ void OI_SBC_ReadSamplesJoint4(OI_CODEC_SBC_COMMON_CONTEXT *common, OI_BITSTREAM *global_bs)
+ {
+ #define NROF_SUBBANDS 4
+ #include "readsamplesjoint.inc"
+ #undef NROF_SUBBANDS
+ }
+
+ void OI_SBC_ReadSamplesJoint8(OI_CODEC_SBC_COMMON_CONTEXT *common, OI_BITSTREAM *global_bs)
+ {
+ #define NROF_SUBBANDS 8
+ #include "readsamplesjoint.inc"
+ #undef NROF_SUBBANDS
+ }
+ \endcode
+ * Or to make a generic version:
+ \code
+ void OI_SBC_ReadSamplesJoint(OI_CODEC_SBC_COMMON_CONTEXT *common, OI_BITSTREAM *global_bs)
+ {
+ OI_UINT nrof_subbands = common->frameInfo.nrof_subbands;
+
+ #define NROF_SUBBANDS nrof_subbands
+ #include "readsamplesjoint.inc"
+ #undef NROF_SUBBANDS
+ }
+ \endcode
+ * @ingroup codec_internal
+ *******************************************************************************/
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+{
+ OI_CODEC_SBC_COMMON_CONTEXT *common = &context->common;
+ OI_UINT bl = common->frameInfo.nrof_blocks;
+ OI_INT32 * RESTRICT s = common->subdata;
+ OI_UINT8 *ptr = global_bs->ptr.w;
+ OI_UINT32 value = global_bs->value;
+ OI_UINT bitPtr = global_bs->bitPtr;
+ OI_UINT8 jmask = common->frameInfo.join << (8 - NROF_SUBBANDS);
+
+ do {
+ OI_INT8 *sf_array = &common->scale_factor[0];
+ OI_UINT8 *bits_array = &common->bits.uint8[0];
+ OI_UINT8 joint = jmask;
+ OI_UINT sb;
+ /*
+ * Left channel
+ */
+ sb = NROF_SUBBANDS;
+ do {
+ OI_UINT32 raw;
+ OI_INT32 dequant;
+ OI_UINT8 bits = *bits_array++;
+ OI_INT sf = *sf_array++;
+
+ OI_BITSTREAM_READUINT(raw, bits, ptr, value, bitPtr);
+ dequant = OI_SBC_Dequant(raw, sf, bits);
+ *s++ = dequant;
+ } while (--sb);
+ /*
+ * Right channel
+ */
+ sb = NROF_SUBBANDS;
+ do {
+ OI_UINT32 raw;
+ OI_INT32 dequant;
+ OI_UINT8 bits = *bits_array++;
+ OI_INT sf = *sf_array++;
+
+ OI_BITSTREAM_READUINT(raw, bits, ptr, value, bitPtr);
+ dequant = OI_SBC_Dequant(raw, sf, bits);
+ /*
+ * Check if we need to do mid/side
+ */
+ if (joint & 0x80) {
+ OI_INT32 mid = *(s - NROF_SUBBANDS);
+ OI_INT32 side = dequant;
+ *(s - NROF_SUBBANDS) = mid + side;
+ dequant = mid - side;
+ }
+ joint <<= 1;
+ *s++ = dequant;
+ } while (--sb);
+ } while (--bl);
+}
diff --git a/embdrv/sbc/decoder/srce/synthesis-8-generated.c b/embdrv/sbc/decoder/srce/synthesis-8-generated.c
new file mode 100644
index 0000000..c33498e
--- /dev/null
+++ b/embdrv/sbc/decoder/srce/synthesis-8-generated.c
@@ -0,0 +1,135 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/**
+ @file
+
+ DO NOT EDIT THIS FILE DIRECTLY
+
+ This file is automatically generated by the "synthesis-gen.pl" script.
+ Any changes to this generated file will be lost when the script is re-run.
+
+ These functions are called by functions in synthesis.c to perform the synthesis
+ filterbank computations for the SBC decoder.
+
+
+ */
+
+#include <oi_codec_sbc_private.h>
+
+#ifndef CLIP_INT16
+#define CLIP_INT16(x) do { if (x > OI_INT16_MAX) { x = OI_INT16_MAX; } else if (x < OI_INT16_MIN) { x = OI_INT16_MIN; } } while (0)
+#endif
+
+#define MUL_16S_16S(_x, _y) ((_x) * (_y))
+
+PRIVATE void SynthWindow80_generated(OI_INT16 *pcm, SBC_BUFFER_T const * RESTRICT buffer, OI_UINT strideShift)
+{
+ OI_INT32 pcm_a, pcm_b;
+ /* 1 - stage 0 */ pcm_b = 0;
+ /* 1 - stage 0 */ pcm_b +=(MUL_16S_16S(8235, buffer[ 12]))>> 3;
+ /* 1 - stage 0 */ pcm_b +=(MUL_16S_16S(-23167, buffer[ 20]))>> 3;
+ /* 1 - stage 0 */ pcm_b +=(MUL_16S_16S(26479, buffer[ 28]))>> 2;
+ /* 1 - stage 0 */ pcm_b +=(MUL_16S_16S(-17397, buffer[ 36]))<< 1;
+ /* 1 - stage 0 */ pcm_b +=(MUL_16S_16S(9399, buffer[ 44]))<< 3;
+ /* 1 - stage 0 */ pcm_b +=(MUL_16S_16S(17397, buffer[ 52]))<< 1;
+ /* 1 - stage 0 */ pcm_b +=(MUL_16S_16S(26479, buffer[ 60]))>> 2;
+ /* 1 - stage 0 */ pcm_b +=(MUL_16S_16S(23167, buffer[ 68]))>> 3;
+ /* 1 - stage 0 */ pcm_b +=(MUL_16S_16S(8235, buffer[ 76]))>> 3;
+ /* 1 - stage 0 */ pcm_b /= 32768; CLIP_INT16(pcm_b); pcm[0<<strideShift] = (OI_INT16)pcm_b;
+ /* 1 - stage 1 */ pcm_a = 0;
+ /* 1 - stage 1 */ pcm_b = 0;
+ /* 1 - stage 1 */ pcm_a +=(MUL_16S_16S(-3263, buffer[ 5]))>> 5;
+ /* 1 - stage 1 */ pcm_b +=(MUL_16S_16S(9293, buffer[ 5]))>> 3;
+ /* 1 - stage 1 */ pcm_a +=(MUL_16S_16S(29293, buffer[ 11]))>> 5;
+ /* 1 - stage 1 */ pcm_b +=(MUL_16S_16S(-6087, buffer[ 11]))>> 2;
+ /* 1 - stage 1 */ pcm_a +=(MUL_16S_16S(-5229, buffer[ 21]));
+ /* 1 - stage 1 */ pcm_b +=(MUL_16S_16S(1247, buffer[ 21]))<< 3;
+ /* 1 - stage 1 */ pcm_a +=(MUL_16S_16S(30835, buffer[ 27]))>> 3;
+ /* 1 - stage 1 */ pcm_b +=(MUL_16S_16S(-2893, buffer[ 27]))<< 3;
+ /* 1 - stage 1 */ pcm_a +=(MUL_16S_16S(-27021, buffer[ 37]))<< 1;
+ /* 1 - stage 1 */ pcm_b +=(MUL_16S_16S(23671, buffer[ 37]))<< 2;
+ /* 1 - stage 1 */ pcm_a +=(MUL_16S_16S(31633, buffer[ 43]))<< 1;
+ /* 1 - stage 1 */ pcm_b +=(MUL_16S_16S(18055, buffer[ 43]))<< 1;
+ /* 1 - stage 1 */ pcm_a +=(MUL_16S_16S(17319, buffer[ 53]))<< 1;
+ /* 1 - stage 1 */ pcm_b +=(MUL_16S_16S(11537, buffer[ 53]))>> 1;
+ /* 1 - stage 1 */ pcm_a +=(MUL_16S_16S(26663, buffer[ 59]))>> 2;
+ /* 1 - stage 1 */ pcm_b +=(MUL_16S_16S(1747, buffer[ 59]))<< 1;
+ /* 1 - stage 1 */ pcm_a +=(MUL_16S_16S(4555, buffer[ 69]))>> 1;
+ /* 1 - stage 1 */ pcm_b +=(MUL_16S_16S(685, buffer[ 69]))<< 1;
+ /* 1 - stage 1 */ pcm_a +=(MUL_16S_16S(12419, buffer[ 75]))>> 4;
+ /* 1 - stage 1 */ pcm_b +=(MUL_16S_16S(8721, buffer[ 75]))>> 7;
+ /* 1 - stage 1 */ pcm_a /= 32768; CLIP_INT16(pcm_a); pcm[1<<strideShift] = (OI_INT16)pcm_a;
+ /* 1 - stage 1 */ pcm_b /= 32768; CLIP_INT16(pcm_b); pcm[7<<strideShift] = (OI_INT16)pcm_b;
+ /* 1 - stage 2 */ pcm_a = 0;
+ /* 1 - stage 2 */ pcm_b = 0;
+ /* 1 - stage 2 */ pcm_a +=(MUL_16S_16S(-10385, buffer[ 6]))>> 6;
+ /* 1 - stage 2 */ pcm_b +=(MUL_16S_16S(11167, buffer[ 6]))>> 4;
+ /* 1 - stage 2 */ pcm_a +=(MUL_16S_16S(24995, buffer[ 10]))>> 5;
+ /* 1 - stage 2 */ pcm_b +=(MUL_16S_16S(-10337, buffer[ 10]))>> 4;
+ /* 1 - stage 2 */ pcm_a +=(MUL_16S_16S(-309, buffer[ 22]))<< 4;
+ /* 1 - stage 2 */ pcm_b +=(MUL_16S_16S(1917, buffer[ 22]))<< 2;
+ /* 1 - stage 2 */ pcm_a +=(MUL_16S_16S(9161, buffer[ 26]))>> 3;
+ /* 1 - stage 2 */ pcm_b +=(MUL_16S_16S(-30605, buffer[ 26]))>> 1;
+ /* 1 - stage 2 */ pcm_a +=(MUL_16S_16S(-23063, buffer[ 38]))<< 1;
+ /* 1 - stage 2 */ pcm_b +=(MUL_16S_16S(8317, buffer[ 38]))<< 3;
+ /* 1 - stage 2 */ pcm_a +=(MUL_16S_16S(27561, buffer[ 42]))<< 1;
+ /* 1 - stage 2 */ pcm_b +=(MUL_16S_16S(9553, buffer[ 42]))<< 2;
+ /* 1 - stage 2 */ pcm_a +=(MUL_16S_16S(2309, buffer[ 54]))<< 3;
+ /* 1 - stage 2 */ pcm_b +=(MUL_16S_16S(22117, buffer[ 54]))>> 4;
+ /* 1 - stage 2 */ pcm_a +=(MUL_16S_16S(12705, buffer[ 58]))>> 1;
+ /* 1 - stage 2 */ pcm_b +=(MUL_16S_16S(16383, buffer[ 58]))>> 2;
+ /* 1 - stage 2 */ pcm_a +=(MUL_16S_16S(6239, buffer[ 70]))>> 3;
+ /* 1 - stage 2 */ pcm_b +=(MUL_16S_16S(7543, buffer[ 70]))>> 3;
+ /* 1 - stage 2 */ pcm_a +=(MUL_16S_16S(9251, buffer[ 74]))>> 4;
+ /* 1 - stage 2 */ pcm_b +=(MUL_16S_16S(8603, buffer[ 74]))>> 6;
+ /* 1 - stage 2 */ pcm_a /= 32768; CLIP_INT16(pcm_a); pcm[2<<strideShift] = (OI_INT16)pcm_a;
+ /* 1 - stage 2 */ pcm_b /= 32768; CLIP_INT16(pcm_b); pcm[6<<strideShift] = (OI_INT16)pcm_b;
+ /* 1 - stage 3 */ pcm_a = 0;
+ /* 1 - stage 3 */ pcm_b = 0;
+ /* 1 - stage 3 */ pcm_a +=(MUL_16S_16S(-16457, buffer[ 7]))>> 6;
+ /* 1 - stage 3 */ pcm_b +=(MUL_16S_16S(16913, buffer[ 7]))>> 5;
+ /* 1 - stage 3 */ pcm_a +=(MUL_16S_16S(19083, buffer[ 9]))>> 5;
+ /* 1 - stage 3 */ pcm_b +=(MUL_16S_16S(-8443, buffer[ 9]))>> 7;
+ /* 1 - stage 3 */ pcm_a +=(MUL_16S_16S(-23641, buffer[ 23]))>> 2;
+ /* 1 - stage 3 */ pcm_b +=(MUL_16S_16S(3687, buffer[ 23]))<< 1;
+ /* 1 - stage 3 */ pcm_a +=(MUL_16S_16S(-29015, buffer[ 25]))>> 4;
+ /* 1 - stage 3 */ pcm_b +=(MUL_16S_16S(-301, buffer[ 25]))<< 5;
+ /* 1 - stage 3 */ pcm_a +=(MUL_16S_16S(-12889, buffer[ 39]))<< 2;
+ /* 1 - stage 3 */ pcm_b +=(MUL_16S_16S(15447, buffer[ 39]))<< 2;
+ /* 1 - stage 3 */ pcm_a +=(MUL_16S_16S(6145, buffer[ 41]))<< 3;
+ /* 1 - stage 3 */ pcm_b +=(MUL_16S_16S(10255, buffer[ 41]))<< 2;
+ /* 1 - stage 3 */ pcm_a +=(MUL_16S_16S(24211, buffer[ 55]))>> 1;
+ /* 1 - stage 3 */ pcm_b +=(MUL_16S_16S(-18233, buffer[ 55]))>> 3;
+ /* 1 - stage 3 */ pcm_a +=(MUL_16S_16S(23469, buffer[ 57]))>> 2;
+ /* 1 - stage 3 */ pcm_b +=(MUL_16S_16S(9405, buffer[ 57]))>> 1;
+ /* 1 - stage 3 */ pcm_a +=(MUL_16S_16S(21223, buffer[ 71]))>> 8;
+ /* 1 - stage 3 */ pcm_b +=(MUL_16S_16S(1499, buffer[ 71]))>> 1;
+ /* 1 - stage 3 */ pcm_a +=(MUL_16S_16S(26913, buffer[ 73]))>> 6;
+ /* 1 - stage 3 */ pcm_b +=(MUL_16S_16S(26189, buffer[ 73]))>> 7;
+ /* 1 - stage 3 */ pcm_a /= 32768; CLIP_INT16(pcm_a); pcm[3<<strideShift] = (OI_INT16)pcm_a;
+ /* 1 - stage 3 */ pcm_b /= 32768; CLIP_INT16(pcm_b); pcm[5<<strideShift] = (OI_INT16)pcm_b;
+ /* 1 - stage 4 */ pcm_a = 0;
+ /* 1 - stage 4 */ pcm_a +=(MUL_16S_16S(10445, buffer[ 8]))>> 4;
+ /* 1 - stage 4 */ pcm_a +=(MUL_16S_16S(-5297, buffer[ 24]))<< 1;
+ /* 1 - stage 4 */ pcm_a +=(MUL_16S_16S(22299, buffer[ 40]))<< 2;
+ /* 1 - stage 4 */ pcm_a +=(MUL_16S_16S(10603, buffer[ 56]));
+ /* 1 - stage 4 */ pcm_a +=(MUL_16S_16S(9539, buffer[ 72]))>> 4;
+ /* 1 - stage 4 */ pcm_a /= 32768; CLIP_INT16(pcm_a); pcm[4<<strideShift] = (OI_INT16)pcm_a;
+}
diff --git a/embdrv/sbc/decoder/srce/synthesis-dct8.c b/embdrv/sbc/decoder/srce/synthesis-dct8.c
new file mode 100644
index 0000000..4280758
--- /dev/null
+++ b/embdrv/sbc/decoder/srce/synthesis-dct8.c
@@ -0,0 +1,305 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+/** @file
+@ingroup codec_internal
+*/
+
+/**@addgroup codec_internal*/
+/**@{*/
+
+/*
+ * Performs an 8-point Type-II scaled DCT using the Arai-Agui-Nakajima
+ * factorization. The scaling factors are folded into the windowing
+ * constants. 29 adds and 5 16x32 multiplies per 8 samples.
+ */
+
+#include "oi_codec_sbc_private.h"
+
+#define AAN_C4_FIX (759250125)/* S1.30 759250125 0.707107*/
+
+#define AAN_C6_FIX (410903207)/* S1.30 410903207 0.382683*/
+
+#define AAN_Q0_FIX (581104888)/* S1.30 581104888 0.541196*/
+
+#define AAN_Q1_FIX (1402911301)/* S1.30 1402911301 1.306563*/
+
+/** Scales x by y bits to the right, adding a rounding factor.
+ */
+#ifndef SCALE
+#define SCALE(x, y) (((x) + (1 <<((y)-1))) >> (y))
+#endif
+
+/**
+ * Default C language implementation of a 32x32->32 multiply. This function may
+ * be replaced by a platform-specific version for speed.
+ *
+ * @param u A signed 32-bit multiplicand
+ * @param v A signed 32-bit multiplier
+
+ * @return A signed 32-bit value corresponding to the 32 most significant bits
+ * of the 64-bit product of u and v.
+ */
+INLINE OI_INT32 default_mul_32s_32s_hi(OI_INT32 u, OI_INT32 v)
+{
+ OI_UINT32 u0, v0;
+ OI_INT32 u1, v1, w1, w2, t;
+
+ u0 = u & 0xFFFF; u1 = u >> 16;
+ v0 = v & 0xFFFF; v1 = v >> 16;
+ t = u0*v0;
+ t = u1*v0 + ((OI_UINT32)t >> 16);
+ w1 = t & 0xFFFF;
+ w2 = t >> 16;
+ w1 = u0*v1 + w1;
+ return u1*v1 + w2 + (w1 >> 16);
+}
+
+#define MUL_32S_32S_HI(_x, _y) default_mul_32s_32s_hi(_x, _y)
+
+
+#ifdef DEBUG_DCT
+PRIVATE void float_dct2_8(float * RESTRICT out, OI_INT32 const *RESTRICT in)
+{
+#define FIX(x,bits) (((int)floor(0.5f+((x)*((float)(1<<bits)))))/((float)(1<<bits)))
+#define FLOAT_BUTTERFLY(x,y) x += y; y = x - (y*2); OI_ASSERT(VALID_INT32(x)); OI_ASSERT(VALID_INT32(y));
+#define FLOAT_MULT_DCT(K, sample) (FIX(K,20) * sample)
+#define FLOAT_SCALE(x, y) (((x) / (double)(1 << (y))))
+
+ double L00,L01,L02,L03,L04,L05,L06,L07;
+ double L25;
+
+ double in0,in1,in2,in3;
+ double in4,in5,in6,in7;
+
+ in0 = FLOAT_SCALE(in[0], DCTII_8_SHIFT_IN); OI_ASSERT(VALID_INT32(in0));
+ in1 = FLOAT_SCALE(in[1], DCTII_8_SHIFT_IN); OI_ASSERT(VALID_INT32(in1));
+ in2 = FLOAT_SCALE(in[2], DCTII_8_SHIFT_IN); OI_ASSERT(VALID_INT32(in2));
+ in3 = FLOAT_SCALE(in[3], DCTII_8_SHIFT_IN); OI_ASSERT(VALID_INT32(in3));
+ in4 = FLOAT_SCALE(in[4], DCTII_8_SHIFT_IN); OI_ASSERT(VALID_INT32(in4));
+ in5 = FLOAT_SCALE(in[5], DCTII_8_SHIFT_IN); OI_ASSERT(VALID_INT32(in5));
+ in6 = FLOAT_SCALE(in[6], DCTII_8_SHIFT_IN); OI_ASSERT(VALID_INT32(in6));
+ in7 = FLOAT_SCALE(in[7], DCTII_8_SHIFT_IN); OI_ASSERT(VALID_INT32(in7));
+
+ L00 = (in0 + in7); OI_ASSERT(VALID_INT32(L00));
+ L01 = (in1 + in6); OI_ASSERT(VALID_INT32(L01));
+ L02 = (in2 + in5); OI_ASSERT(VALID_INT32(L02));
+ L03 = (in3 + in4); OI_ASSERT(VALID_INT32(L03));
+
+ L04 = (in3 - in4); OI_ASSERT(VALID_INT32(L04));
+ L05 = (in2 - in5); OI_ASSERT(VALID_INT32(L05));
+ L06 = (in1 - in6); OI_ASSERT(VALID_INT32(L06));
+ L07 = (in0 - in7); OI_ASSERT(VALID_INT32(L07));
+
+ FLOAT_BUTTERFLY(L00, L03);
+ FLOAT_BUTTERFLY(L01, L02);
+
+ L02 += L03; OI_ASSERT(VALID_INT32(L02));
+
+ L02 = FLOAT_MULT_DCT(AAN_C4_FLOAT, L02); OI_ASSERT(VALID_INT32(L02));
+
+ FLOAT_BUTTERFLY(L00, L01);
+
+ out[0] = (float)FLOAT_SCALE(L00, DCTII_8_SHIFT_0); OI_ASSERT(VALID_INT16(out[0]));
+ out[4] = (float)FLOAT_SCALE(L01, DCTII_8_SHIFT_4); OI_ASSERT(VALID_INT16(out[4]));
+
+ FLOAT_BUTTERFLY(L03, L02);
+ out[6] = (float)FLOAT_SCALE(L02, DCTII_8_SHIFT_6); OI_ASSERT(VALID_INT16(out[6]));
+ out[2] = (float)FLOAT_SCALE(L03, DCTII_8_SHIFT_2); OI_ASSERT(VALID_INT16(out[2]));
+
+ L04 += L05; OI_ASSERT(VALID_INT32(L04));
+ L05 += L06; OI_ASSERT(VALID_INT32(L05));
+ L06 += L07; OI_ASSERT(VALID_INT32(L06));
+
+ L04/=2;
+ L05/=2;
+ L06/=2;
+ L07/=2;
+
+ L05 = FLOAT_MULT_DCT(AAN_C4_FLOAT, L05); OI_ASSERT(VALID_INT32(L05));
+
+ L25 = L06 - L04; OI_ASSERT(VALID_INT32(L25));
+ L25 = FLOAT_MULT_DCT(AAN_C6_FLOAT, L25); OI_ASSERT(VALID_INT32(L25));
+
+ L04 = FLOAT_MULT_DCT(AAN_Q0_FLOAT, L04); OI_ASSERT(VALID_INT32(L04));
+ L04 -= L25; OI_ASSERT(VALID_INT32(L04));
+
+ L06 = FLOAT_MULT_DCT(AAN_Q1_FLOAT, L06); OI_ASSERT(VALID_INT32(L06));
+ L06 -= L25; OI_ASSERT(VALID_INT32(L25));
+
+ FLOAT_BUTTERFLY(L07, L05);
+
+ FLOAT_BUTTERFLY(L05, L04);
+ out[3] = (float)(FLOAT_SCALE(L04, DCTII_8_SHIFT_3-1)); OI_ASSERT(VALID_INT16(out[3]));
+ out[5] = (float)(FLOAT_SCALE(L05, DCTII_8_SHIFT_5-1)); OI_ASSERT(VALID_INT16(out[5]));
+
+ FLOAT_BUTTERFLY(L07, L06);
+ out[7] = (float)(FLOAT_SCALE(L06, DCTII_8_SHIFT_7-1)); OI_ASSERT(VALID_INT16(out[7]));
+ out[1] = (float)(FLOAT_SCALE(L07, DCTII_8_SHIFT_1-1)); OI_ASSERT(VALID_INT16(out[1]));
+}
+#undef BUTTERFLY
+#endif
+
+
+/*
+ * This function calculates the AAN DCT. Its inputs are in S16.15 format, as
+ * returned by OI_SBC_Dequant. In practice, abs(in[x]) < 52429.0 / 1.38
+ * (1244918057 integer). The function it computes is an approximation to the array defined
+ * by:
+ *
+ * diag(aan_s) * AAN= C2
+ *
+ * or
+ *
+ * AAN = diag(1/aan_s) * C2
+ *
+ * where C2 is as it is defined in the comment at the head of this file, and
+ *
+ * aan_s[i] = aan_s = 1/(2*cos(i*pi/16)) with i = 1..7, aan_s[0] = 1;
+ *
+ * aan_s[i] = [ 1.000 0.510 0.541 0.601 0.707 0.900 1.307 2.563 ]
+ *
+ * The output ranges are shown as follows:
+ *
+ * Let Y[0..7] = AAN * X[0..7]
+ *
+ * Without loss of generality, assume the input vector X consists of elements
+ * between -1 and 1. The maximum possible value of a given output element occurs
+ * with some particular combination of input vector elements each of which is -1
+ * or 1. Consider the computation of Y[i]. Y[i] = sum t=0..7 of AAN[t,i]*X[i]. Y is
+ * maximized if the sign of X[i] matches the sign of AAN[t,i], ensuring a
+ * positive contribution to the sum. Equivalently, one may simply sum
+ * abs(AAN)[t,i] over t to get the maximum possible value of Y[i].
+ *
+ * This yields approximately [8.00 10.05 9.66 8.52 8.00 5.70 4.00 2.00]
+ *
+ * Given the maximum magnitude sensible input value of +/-37992, this yields the
+ * following vector of maximum output magnitudes:
+ *
+ * [ 303936 381820 367003 323692 303936 216555 151968 75984 ]
+ *
+ * Ultimately, these values must fit into 16 bit signed integers, so they must
+ * be scaled. A non-uniform scaling helps maximize the kept precision. The
+ * relative number of extra bits of precision maintainable with respect to the
+ * largest value is given here:
+ *
+ * [ 0 0 0 0 0 0 1 2 ]
+ *
+ */
+PRIVATE void dct2_8(SBC_BUFFER_T * RESTRICT out, OI_INT32 const *RESTRICT in)
+{
+#define BUTTERFLY(x,y) x += y; y = x - (y<<1);
+#define FIX_MULT_DCT(K, x) (MUL_32S_32S_HI(K,x)<<2)
+
+ OI_INT32 L00,L01,L02,L03,L04,L05,L06,L07;
+ OI_INT32 L25;
+
+ OI_INT32 in0,in1,in2,in3;
+ OI_INT32 in4,in5,in6,in7;
+
+#if DCTII_8_SHIFT_IN != 0
+ in0 = SCALE(in[0], DCTII_8_SHIFT_IN);
+ in1 = SCALE(in[1], DCTII_8_SHIFT_IN);
+ in2 = SCALE(in[2], DCTII_8_SHIFT_IN);
+ in3 = SCALE(in[3], DCTII_8_SHIFT_IN);
+ in4 = SCALE(in[4], DCTII_8_SHIFT_IN);
+ in5 = SCALE(in[5], DCTII_8_SHIFT_IN);
+ in6 = SCALE(in[6], DCTII_8_SHIFT_IN);
+ in7 = SCALE(in[7], DCTII_8_SHIFT_IN);
+#else
+ in0 = in[0];
+ in1 = in[1];
+ in2 = in[2];
+ in3 = in[3];
+ in4 = in[4];
+ in5 = in[5];
+ in6 = in[6];
+ in7 = in[7];
+#endif
+
+ L00 = in0 + in7;
+ L01 = in1 + in6;
+ L02 = in2 + in5;
+ L03 = in3 + in4;
+
+ L04 = in3 - in4;
+ L05 = in2 - in5;
+ L06 = in1 - in6;
+ L07 = in0 - in7;
+
+ BUTTERFLY(L00, L03);
+ BUTTERFLY(L01, L02);
+
+ L02 += L03;
+
+ L02 = FIX_MULT_DCT(AAN_C4_FIX, L02);
+
+ BUTTERFLY(L00, L01);
+
+ out[0] = (OI_INT16)SCALE(L00, DCTII_8_SHIFT_0);
+ out[4] = (OI_INT16)SCALE(L01, DCTII_8_SHIFT_4);
+
+ BUTTERFLY(L03, L02);
+ out[6] = (OI_INT16)SCALE(L02, DCTII_8_SHIFT_6);
+ out[2] = (OI_INT16)SCALE(L03, DCTII_8_SHIFT_2);
+
+ L04 += L05;
+ L05 += L06;
+ L06 += L07;
+
+ L04/=2;
+ L05/=2;
+ L06/=2;
+ L07/=2;
+
+ L05 = FIX_MULT_DCT(AAN_C4_FIX, L05);
+
+ L25 = L06 - L04;
+ L25 = FIX_MULT_DCT(AAN_C6_FIX, L25);
+
+ L04 = FIX_MULT_DCT(AAN_Q0_FIX, L04);
+ L04 -= L25;
+
+ L06 = FIX_MULT_DCT(AAN_Q1_FIX, L06);
+ L06 -= L25;
+
+ BUTTERFLY(L07, L05);
+
+ BUTTERFLY(L05, L04);
+ out[3] = (OI_INT16)SCALE(L04, DCTII_8_SHIFT_3-1);
+ out[5] = (OI_INT16)SCALE(L05, DCTII_8_SHIFT_5-1);
+
+ BUTTERFLY(L07, L06);
+ out[7] = (OI_INT16)SCALE(L06, DCTII_8_SHIFT_7-1);
+ out[1] = (OI_INT16)SCALE(L07, DCTII_8_SHIFT_1-1);
+#undef BUTTERFLY
+
+#ifdef DEBUG_DCT
+ {
+ float float_out[8];
+ float_dct2_8(float_out, in);
+ }
+#endif
+}
+
+/**@}*/
diff --git a/embdrv/sbc/decoder/srce/synthesis-sbc.c b/embdrv/sbc/decoder/srce/synthesis-sbc.c
new file mode 100644
index 0000000..38c6f17
--- /dev/null
+++ b/embdrv/sbc/decoder/srce/synthesis-sbc.c
@@ -0,0 +1,510 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/**********************************************************************************
+ $Revision: #1 $
+***********************************************************************************/
+
+/** @file
+
+This file, along with synthesis-generated.c, contains the synthesis
+filterbank routines. The operations performed correspond to the
+operations described in A2DP Appendix B, Figure 12.3. Several
+mathematical optimizations are performed, particularly for the
+8-subband case.
+
+One important optimization is to note that the "matrixing" operation
+can be decomposed into the product of a type II discrete cosine kernel
+and another, sparse matrix.
+
+According to Fig 12.3, in the 8-subband case,
+@code
+ N[k][i] = cos((i+0.5)*(k+4)*pi/8), k = 0..15 and i = 0..7
+@endcode
+
+N can be factored as R * C2, where C2 is an 8-point type II discrete
+cosine kernel given by
+@code
+ C2[k][i] = cos((i+0.5)*k*pi/8)), k = 0..7 and i = 0..7
+@endcode
+
+R turns out to be a sparse 16x8 matrix with the following non-zero
+entries:
+@code
+ R[k][k+4] = 1, k = 0..3
+ R[k][abs(12-k)] = -1, k = 5..15
+@endcode
+
+The spec describes computing V[0..15] as N * R.
+@code
+ V[0..15] = N * R = (R * C2) * R = R * (C2 * R)
+@endcode
+
+C2 * R corresponds to computing the discrete cosine transform of R, so
+V[0..15] can be computed by taking the DCT of R followed by assignment
+and selective negation of the DCT result into V.
+
+ Although this was derived empirically using GNU Octave, it is
+ formally demonstrated in, e.g., Liu, Chi-Min and Lee,
+ Wen-Chieh. "A Unified Fast Algorithm for Cosine Modulated
+ Filter Banks in Current Audio Coding Standards." Journal of
+ the AES 47 (December 1999): 1061.
+
+Given the shift operation performed prior to computing V[0..15], it is
+clear that V[0..159] represents a rolling history of the 10 most
+recent groups of blocks input to the synthesis operation. Interpreting
+the matrix N in light of its factorization into C2 and R, R's
+sparseness has implications for interpreting the values in V. In
+particular, there is considerable redundancy in the values stored in
+V. Furthermore, since R[4][0..7] are all zeros, one out of every 16
+values in V will be zero regardless of the input data. Within each
+block of 16 values in V, fully half of them are redundant or
+irrelevant:
+
+@code
+ V[ 0] = DCT[4]
+ V[ 1] = DCT[5]
+ V[ 2] = DCT[6]
+ V[ 3] = DCT[7]
+ V[ 4] = 0
+ V[ 5] = -DCT[7] = -V[3] (redundant)
+ V[ 6] = -DCT[6] = -V[2] (redundant)
+ V[ 7] = -DCT[5] = -V[1] (redundant)
+ V[ 8] = -DCT[4] = -V[0] (redundant)
+ V[ 9] = -DCT[3]
+ V[10] = -DCT[2]
+ V[11] = -DCT[1]
+ V[12] = -DCT[0]
+ V[13] = -DCT[1] = V[11] (redundant)
+ V[14] = -DCT[2] = V[10] (redundant)
+ V[15] = -DCT[3] = V[ 9] (redundant)
+@endcode
+
+Since the elements of V beyond 15 were originally computed the same
+way during a previous run, what holds true for V[x] also holds true
+for V[x+16]. Thus, so long as care is taken to maintain the mapping,
+we need only actually store the unique values, which correspond to the
+output of the DCT, in some cases inverted. In fact, instead of storing
+V[0..159], we could store DCT[0..79] which would contain a history of
+DCT results. More on this in a bit.
+
+Going back to figure 12.3 in the spec, it should be clear that the
+vector U need not actually be explicitly constructed, but that with
+suitable indexing into V during the window operation, the same end can
+be accomplished. In the same spirit of the pseudocode shown in the
+figure, the following is the construction of W without using U:
+
+@code
+ for i=0 to 79 do
+ W[i] = D[i]*VSIGN(i)*V[remap_V(i)] where remap_V(i) = 32*(int(i/16)) + (i % 16) + (i % 16 >= 8 ? 16 : 0)
+ and VSIGN(i) maps i%16 into {1, 1, 1, 1, 0, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1 }
+ These values correspond to the
+ signs of the redundant values as
+ shown in the explanation three
+ paragraphs above.
+@endcode
+
+We saw above how V[4..8,13..15] (and by extension
+V[(4..8,13..15)+16*n]) can be defined in terms of other elements
+within the subblock of V. V[0..3,9..12] correspond to DCT elements.
+
+@code
+ for i=0 to 79 do
+ W[i] = D[i]*DSIGN(i)*DCT[remap_DCT(i)]
+@endcode
+
+The DCT is calculated using the Arai-Agui-Nakajima factorization,
+which saves some computation by producing output that needs to be
+multiplied by scaling factors before being used.
+
+@code
+ for i=0 to 79 do
+ W[i] = D[i]*SCALE[i%8]*AAN_DCT[remap_DCT(i)]
+@endcode
+
+D can be premultiplied with the DCT scaling factors to yield
+
+@code
+ for i=0 to 79 do
+ W[i] = DSCALED[i]*AAN_DCT[remap_DCT(i)] where DSCALED[i] = D[i]*SCALE[i%8]
+@endcode
+
+The output samples X[0..7] are defined as sums of W:
+
+@code
+ X[j] = sum{i=0..9}(W[j+8*i])
+@endcode
+
+@ingroup codec_internal
+*/
+
+/**
+@addtogroup codec_internal
+@{
+*/
+
+#include "oi_codec_sbc_private.h"
+
+const OI_INT32 dec_window_4[21] = {
+ 0, /* +0.00000000E+00 */
+ 97, /* +5.36548976E-04 */
+ 270, /* +1.49188357E-03 */
+ 495, /* +2.73370904E-03 */
+ 694, /* +3.83720193E-03 */
+ 704, /* +3.89205149E-03 */
+ 338, /* +1.86581691E-03 */
+ -554, /* -3.06012286E-03 */
+ 1974, /* +1.09137620E-02 */
+ 3697, /* +2.04385087E-02 */
+ 5224, /* +2.88757392E-02 */
+ 5824, /* +3.21939290E-02 */
+ 4681, /* +2.58767811E-02 */
+ 1109, /* +6.13245186E-03 */
+ -5214, /* -2.88217274E-02 */
+ -14047, /* -7.76463494E-02 */
+ 24529, /* +1.35593274E-01 */
+ 35274, /* +1.94987841E-01 */
+ 44618, /* +2.46636662E-01 */
+ 50984, /* +2.81828203E-01 */
+ 53243, /* +2.94315332E-01 */
+};
+
+#define DCTII_4_K06_FIX ( 11585)/* S1.14 11585 0.707107*/
+
+#define DCTII_4_K08_FIX ( 21407)/* S1.14 21407 1.306563*/
+
+#define DCTII_4_K09_FIX (-15137)/* S1.14 -15137 -0.923880*/
+
+#define DCTII_4_K10_FIX ( -8867)/* S1.14 -8867 -0.541196*/
+
+/** Scales x by y bits to the right, adding a rounding factor.
+ */
+#ifndef SCALE
+#define SCALE(x, y) (((x) + (1 <<((y)-1))) >> (y))
+#endif
+
+#ifndef CLIP_INT16
+#define CLIP_INT16(x) do { if (x > OI_INT16_MAX) { x = OI_INT16_MAX; } else if (x < OI_INT16_MIN) { x = OI_INT16_MIN; } } while (0)
+#endif
+
+/**
+ * Default C language implementation of a 16x32->32 multiply. This function may
+ * be replaced by a platform-specific version for speed.
+ *
+ * @param u A signed 16-bit multiplicand
+ * @param v A signed 32-bit multiplier
+
+ * @return A signed 32-bit value corresponding to the 32 most significant bits
+ * of the 48-bit product of u and v.
+ */
+INLINE OI_INT32 default_mul_16s_32s_hi(OI_INT16 u, OI_INT32 v)
+{
+ OI_UINT16 v0;
+ OI_INT16 v1;
+
+ OI_INT32 w,x;
+
+ v0 = (OI_UINT16)(v & 0xffff);
+ v1 = (OI_INT16) (v >> 16);
+
+ w = v1 * u;
+ x = u * v0;
+
+ return w + (x >> 16);
+}
+
+#define MUL_16S_32S_HI(_x, _y) default_mul_16s_32s_hi(_x, _y)
+
+#define LONG_MULT_DCT(K, sample) (MUL_16S_32S_HI(K, sample)<<2)
+
+PRIVATE void SynthWindow80_generated(OI_INT16 *pcm, SBC_BUFFER_T const * RESTRICT buffer, OI_UINT strideShift);
+PRIVATE void SynthWindow112_generated(OI_INT16 *pcm, SBC_BUFFER_T const * RESTRICT buffer, OI_UINT strideShift);
+PRIVATE void dct2_8(SBC_BUFFER_T * RESTRICT out, OI_INT32 const * RESTRICT x);
+
+typedef void (*SYNTH_FRAME)(OI_CODEC_SBC_DECODER_CONTEXT *context, OI_INT16 *pcm, OI_UINT blkstart, OI_UINT blkcount);
+
+#ifndef COPY_BACKWARD_32BIT_ALIGNED_72_HALFWORDS
+#define COPY_BACKWARD_32BIT_ALIGNED_72_HALFWORDS(dest, src) do { shift_buffer(dest, src, 72); } while (0)
+#endif
+
+#ifndef DCT2_8
+#define DCT2_8(dst, src) dct2_8(dst, src)
+#endif
+
+#ifndef SYNTH80
+#define SYNTH80 SynthWindow80_generated
+#endif
+
+#ifndef SYNTH112
+#define SYNTH112 SynthWindow112_generated
+#endif
+
+PRIVATE void OI_SBC_SynthFrame_80(OI_CODEC_SBC_DECODER_CONTEXT *context, OI_INT16 *pcm, OI_UINT blkstart, OI_UINT blkcount)
+{
+ OI_UINT blk;
+ OI_UINT ch;
+ OI_UINT nrof_channels = context->common.frameInfo.nrof_channels;
+ OI_UINT pcmStrideShift = context->common.pcmStride == 1 ? 0 : 1;
+ OI_UINT offset = context->common.filterBufferOffset;
+ OI_INT32 *s = context->common.subdata + 8 * nrof_channels * blkstart;
+ OI_UINT blkstop = blkstart + blkcount;
+
+ for (blk = blkstart; blk < blkstop; blk++) {
+ if (offset == 0) {
+ COPY_BACKWARD_32BIT_ALIGNED_72_HALFWORDS(context->common.filterBuffer[0] + context->common.filterBufferLen - 72, context->common.filterBuffer[0]);
+ if (nrof_channels == 2) {
+ COPY_BACKWARD_32BIT_ALIGNED_72_HALFWORDS(context->common.filterBuffer[1] + context->common.filterBufferLen - 72, context->common.filterBuffer[1]);
+ }
+ offset = context->common.filterBufferLen - 80;
+ } else {
+ offset -= 1*8;
+ }
+
+ for (ch = 0; ch < nrof_channels; ch++) {
+ DCT2_8(context->common.filterBuffer[ch] + offset, s);
+ SYNTH80(pcm + ch, context->common.filterBuffer[ch] + offset, pcmStrideShift);
+ s += 8;
+ }
+ pcm += (8 << pcmStrideShift);
+ }
+ context->common.filterBufferOffset = offset;
+}
+
+PRIVATE void OI_SBC_SynthFrame_4SB(OI_CODEC_SBC_DECODER_CONTEXT *context, OI_INT16 *pcm, OI_UINT blkstart, OI_UINT blkcount)
+{
+ OI_UINT blk;
+ OI_UINT ch;
+ OI_UINT nrof_channels = context->common.frameInfo.nrof_channels;
+ OI_UINT pcmStrideShift = context->common.pcmStride == 1 ? 0 : 1;
+ OI_UINT offset = context->common.filterBufferOffset;
+ OI_INT32 *s = context->common.subdata + 8 * nrof_channels * blkstart;
+ OI_UINT blkstop = blkstart + blkcount;
+
+ for (blk = blkstart; blk < blkstop; blk++) {
+ if (offset == 0) {
+ COPY_BACKWARD_32BIT_ALIGNED_72_HALFWORDS(context->common.filterBuffer[0] + context->common.filterBufferLen - 72,context->common.filterBuffer[0]);
+ if (nrof_channels == 2) {
+ COPY_BACKWARD_32BIT_ALIGNED_72_HALFWORDS(context->common.filterBuffer[1] + context->common.filterBufferLen - 72,context->common.filterBuffer[1]);
+ }
+ offset =context->common.filterBufferLen - 80;
+ } else {
+ offset -= 8;
+ }
+ for (ch = 0; ch < nrof_channels; ch++) {
+ cosineModulateSynth4(context->common.filterBuffer[ch] + offset, s);
+ SynthWindow40_int32_int32_symmetry_with_sum(pcm + ch,
+ context->common.filterBuffer[ch] + offset,
+ pcmStrideShift);
+ s += 4;
+ }
+ pcm += (4 << pcmStrideShift);
+ }
+ context->common.filterBufferOffset = offset;
+}
+
+#ifdef SBC_ENHANCED
+
+PRIVATE void OI_SBC_SynthFrame_Enhanced(OI_CODEC_SBC_DECODER_CONTEXT *context, OI_INT16 *pcm, OI_UINT blkstart, OI_UINT blkcount)
+{
+ OI_UINT blk;
+ OI_UINT ch;
+ OI_UINT nrof_channels = context->common.frameInfo.nrof_channels;
+ OI_UINT pcmStrideShift = context->common.pcmStride == 1 ? 0 : 1;
+ OI_UINT offset = context->common.filterBufferOffset;
+ OI_INT32 *s = context->common.subdata + 8 * nrof_channels * blkstart;
+ OI_UINT blkstop = blkstart + blkcount;
+
+ for (blk = blkstart; blk < blkstop; blk++) {
+ if (offset == 0) {
+ COPY_BACKWARD_32BIT_ALIGNED_104_HALFWORDS(context->common.filterBuffer[0] +context->common.filterBufferLen - 104, context->common.filterBuffer[0]);
+ if (nrof_channels == 2) {
+ COPY_BACKWARD_32BIT_ALIGNED_104_HALFWORDS(context->common.filterBuffer[1] + context->common.filterBufferLen - 104, context->common.filterBuffer[1]);
+ }
+ offset = context->common.filterBufferLen - 112;
+ } else {
+ offset -= 8;
+ }
+ for (ch = 0; ch < nrof_channels; ++ch) {
+ DCT2_8(context->common.filterBuffer[ch] + offset, s);
+ SYNTH112(pcm + ch, context->common.filterBuffer[ch] + offset, pcmStrideShift);
+ s += 8;
+ }
+ pcm += (8 << pcmStrideShift);
+ }
+ context->common.filterBufferOffset = offset;
+}
+
+static const SYNTH_FRAME SynthFrameEnhanced[] = {
+ NULL, /* invalid */
+ OI_SBC_SynthFrame_Enhanced, /* mono */
+ OI_SBC_SynthFrame_Enhanced /* stereo */
+};
+
+#endif
+
+static const SYNTH_FRAME SynthFrame8SB[] = {
+ NULL, /* invalid */
+ OI_SBC_SynthFrame_80, /* mono */
+ OI_SBC_SynthFrame_80 /* stereo */
+};
+
+
+static const SYNTH_FRAME SynthFrame4SB[] = {
+ NULL, /* invalid */
+ OI_SBC_SynthFrame_4SB, /* mono */
+ OI_SBC_SynthFrame_4SB /* stereo */
+};
+
+PRIVATE void OI_SBC_SynthFrame(OI_CODEC_SBC_DECODER_CONTEXT *context, OI_INT16 *pcm, OI_UINT start_block, OI_UINT nrof_blocks)
+{
+ OI_UINT nrof_subbands = context->common.frameInfo.nrof_subbands;
+ OI_UINT nrof_channels = context->common.frameInfo.nrof_channels;
+
+ OI_ASSERT(nrof_subbands == 4 || nrof_subbands == 8);
+ if (nrof_subbands == 4) {
+ SynthFrame4SB[nrof_channels](context, pcm, start_block, nrof_blocks);
+#ifdef SBC_ENHANCED
+ } else if (context->common.frameInfo.enhanced) {
+ SynthFrameEnhanced[nrof_channels](context, pcm, start_block, nrof_blocks);
+#endif /* SBC_ENHANCED */
+ } else {
+ SynthFrame8SB[nrof_channels](context, pcm, start_block, nrof_blocks);
+ }
+}
+
+
+void SynthWindow40_int32_int32_symmetry_with_sum(OI_INT16 *pcm, SBC_BUFFER_T buffer[80], OI_UINT strideShift)
+{
+ OI_INT32 pa;
+ OI_INT32 pb;
+
+ /* These values should be zero, since out[2] of the 4-band cosine modulation
+ * is always zero. */
+ OI_ASSERT(buffer[ 2] == 0);
+ OI_ASSERT(buffer[10] == 0);
+ OI_ASSERT(buffer[18] == 0);
+ OI_ASSERT(buffer[26] == 0);
+ OI_ASSERT(buffer[34] == 0);
+ OI_ASSERT(buffer[42] == 0);
+ OI_ASSERT(buffer[50] == 0);
+ OI_ASSERT(buffer[58] == 0);
+ OI_ASSERT(buffer[66] == 0);
+ OI_ASSERT(buffer[74] == 0);
+
+
+ pa = dec_window_4[ 4] * (buffer[12] + buffer[76]);
+ pa += dec_window_4[ 8] * (buffer[16] - buffer[64]);
+ pa += dec_window_4[12] * (buffer[28] + buffer[60]);
+ pa += dec_window_4[16] * (buffer[32] - buffer[48]);
+ pa += dec_window_4[20] * buffer[44];
+ pa = SCALE(-pa, 15);
+ CLIP_INT16(pa);
+ pcm[0 << strideShift] = (OI_INT16)pa;
+
+
+ pa = dec_window_4[ 1] * buffer[ 1]; pb = dec_window_4[ 1] * buffer[79];
+ pb += dec_window_4[ 3] * buffer[ 3]; pa += dec_window_4[ 3] * buffer[77];
+ pa += dec_window_4[ 5] * buffer[13]; pb += dec_window_4[ 5] * buffer[67];
+ pb += dec_window_4[ 7] * buffer[15]; pa += dec_window_4[ 7] * buffer[65];
+ pa += dec_window_4[ 9] * buffer[17]; pb += dec_window_4[ 9] * buffer[63];
+ pb += dec_window_4[11] * buffer[19]; pa += dec_window_4[11] * buffer[61];
+ pa += dec_window_4[13] * buffer[29]; pb += dec_window_4[13] * buffer[51];
+ pb += dec_window_4[15] * buffer[31]; pa += dec_window_4[15] * buffer[49];
+ pa += dec_window_4[17] * buffer[33]; pb += dec_window_4[17] * buffer[47];
+ pb += dec_window_4[19] * buffer[35]; pa += dec_window_4[19] * buffer[45];
+ pa = SCALE(-pa, 15);
+ CLIP_INT16(pa);
+ pcm[1 << strideShift] = (OI_INT16)(pa);
+ pb = SCALE(-pb, 15);
+ CLIP_INT16(pb);
+ pcm[3 << strideShift] = (OI_INT16)(pb);
+
+
+ pa = dec_window_4[2] * (/*buffer[ 2] + */ buffer[78]); /* buffer[ 2] is always zero */
+ pa += dec_window_4[6] * (buffer[14] /* + buffer[66]*/); /* buffer[66] is always zero */
+ pa += dec_window_4[10] * (/*buffer[18] + */ buffer[62]); /* buffer[18] is always zero */
+ pa += dec_window_4[14] * (buffer[30] /* + buffer[50]*/); /* buffer[50] is always zero */
+ pa += dec_window_4[18] * (/*buffer[34] + */ buffer[46]); /* buffer[34] is always zero */
+ pa = SCALE(-pa, 15);
+ CLIP_INT16(pa);
+ pcm[2 << strideShift] = (OI_INT16)(pa);
+}
+
+
+/**
+ This routine implements the cosine modulation matrix for 4-subband
+ synthesis. This is called "matrixing" in the SBC specification. This
+ matrix, M4, can be factored into an 8-point Type II Discrete Cosine
+ Transform, DCTII_4 and a matrix S4, given here:
+
+ @code
+ __ __
+ | 0 0 1 0 |
+ | 0 0 0 1 |
+ | 0 0 0 0 |
+ | 0 0 0 -1 |
+ S4 = | 0 0 -1 0 |
+ | 0 -1 0 0 |
+ | -1 0 0 0 |
+ |__ 0 -1 0 0 __|
+
+ M4 * in = S4 * (DCTII_4 * in)
+ @endcode
+
+ (DCTII_4 * in) is computed using a Fast Cosine Transform. The algorithm
+ here is based on an implementation computed by the SPIRAL computer
+ algebra system, manually converted to fixed-point arithmetic. S4 can be
+ implemented using only assignment and negation.
+ */
+PRIVATE void cosineModulateSynth4(SBC_BUFFER_T * RESTRICT out, OI_INT32 const * RESTRICT in)
+{
+ OI_INT32 f0, f1, f2, f3, f4, f7, f8, f9, f10;
+ OI_INT32 y0, y1, y2, y3;
+
+ f0 = (in[0] - in[3]);
+ f1 = (in[0] + in[3]);
+ f2 = (in[1] - in[2]);
+ f3 = (in[1] + in[2]);
+
+ f4 = f1 - f3;
+
+ y0 = -SCALE(f1 + f3, DCT_SHIFT);
+ y2 = -SCALE(LONG_MULT_DCT(DCTII_4_K06_FIX, f4), DCT_SHIFT);
+ f7 = f0 + f2;
+ f8 = LONG_MULT_DCT(DCTII_4_K08_FIX, f0);
+ f9 = LONG_MULT_DCT(DCTII_4_K09_FIX, f7);
+ f10 = LONG_MULT_DCT(DCTII_4_K10_FIX, f2);
+ y3 = -SCALE(f8 + f9, DCT_SHIFT);
+ y1 = -SCALE(f10 - f9, DCT_SHIFT);
+
+ out[0] = (OI_INT16)-y2;
+ out[1] = (OI_INT16)-y3;
+ out[2] = (OI_INT16)0;
+ out[3] = (OI_INT16)y3;
+ out[4] = (OI_INT16)y2;
+ out[5] = (OI_INT16)y1;
+ out[6] = (OI_INT16)y0;
+ out[7] = (OI_INT16)y1;
+}
+
+
+
+/**
+@}
+*/
diff --git a/gki/Android.mk b/gki/Android.mk
index ec4546a..2e8ef56 100644
--- a/gki/Android.mk
+++ b/gki/Android.mk
@@ -1,5 +1,3 @@
-ifneq ($(TARGET_SIMULATOR),true)
-
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
@@ -29,7 +27,6 @@
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := libcutils libc
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
+LOCAL_MULTILIB := 32
include $(BUILD_STATIC_LIBRARY)
-
-endif # TARGET_SIMULATOR != true
diff --git a/gki/common/gki.h b/gki/common/gki.h
index 5180dcd..bff0c6c 100644
--- a/gki/common/gki.h
+++ b/gki/common/gki.h
@@ -461,8 +461,6 @@
*/
GKI_API extern void GKI_enable(void);
GKI_API extern void GKI_disable(void);
-GKI_API extern void GKI_sched_lock(void);
-GKI_API extern void GKI_sched_unlock(void);
/* Allocate (Free) memory from an OS
*/
diff --git a/gki/common/gki_time.c b/gki/common/gki_time.c
index ceda9ad..af98700 100644
--- a/gki/common/gki_time.c
+++ b/gki/common/gki_time.c
@@ -16,7 +16,7 @@
*
******************************************************************************/
-
+#include <utils/Log.h>
#include "gki_int.h"
#ifndef BT_ERROR_TRACE_0
@@ -33,6 +33,11 @@
#define GKI_UNUSED_LIST_ENTRY (0x80000000L) /* Marks an unused timer list entry (initial value) */
#define GKI_MAX_INT32 (0x7fffffffL)
+#define GKI_ERROR(fmt, ...) ALOGE ("ERROR : %s: " fmt, __FUNCTION__, ## __VA_ARGS__)
+
+// Used for controlling alarms from AlarmService.
+extern void alarm_service_reschedule(void);
+
/*******************************************************************************
**
** Function gki_timers_init
@@ -428,6 +433,9 @@
/* No need to update the ticks if no timeout has occurred */
if (gki_cb.com.OSTicksTilExp > 0)
{
+ // When using alarms from AlarmService we should
+ // always have work to be done here.
+ GKI_ERROR("No work to be done when expected work\n");
gki_cb.com.timer_nesting = 0;
return;
}
@@ -561,12 +569,6 @@
#endif
}
-
-#if GKI_TIMER_LIST_NOPREEMPT == TRUE
- /* End the critical section */
- GKI_enable();
-#endif
-
/* Set the next timer experation value if there is one to start */
if (next_expiration < GKI_NO_NEW_TMRS_STARTED)
{
@@ -577,6 +579,16 @@
gki_cb.com.OSTicksTilExp = gki_cb.com.OSNumOrigTicks = 0;
}
+ // Set alarm service for next alarm.
+ alarm_service_reschedule();
+
+#if GKI_TIMER_LIST_NOPREEMPT == TRUE
+ /* End the critical section */
+ GKI_enable();
+#endif
+
+// GKI_ERROR("Timer expired - next expiration ticks:%ld\n", next_expiration);
+
gki_cb.com.timer_nesting = 0;
return;
@@ -1027,6 +1039,7 @@
{
gki_cb.com.OSNumOrigTicks = (gki_cb.com.OSNumOrigTicks - gki_cb.com.OSTicksTilExp) + ticks;
gki_cb.com.OSTicksTilExp = ticks;
+ alarm_service_reschedule();
}
}
diff --git a/gki/ulinux/gki_ulinux.c b/gki/ulinux/gki_ulinux.c
index d03eb05..5e37532 100644
--- a/gki/ulinux/gki_ulinux.c
+++ b/gki/ulinux/gki_ulinux.c
@@ -25,19 +25,16 @@
**
*****************************************************************************/
-#include <stdio.h>
-#include <stdarg.h>
-#include <errno.h>
+#include <assert.h>
#include <sys/times.h>
-#include <pthread.h> /* must be 1st header defined */
-#include <time.h>
#include "gki_int.h"
#include "bt_utils.h"
#define LOG_TAG "GKI_LINUX"
#include <utils/Log.h>
+#include <hardware/bluetooth.h>
/*****************************************************************************
** Constants & Macros
@@ -47,7 +44,9 @@
#define GKI_TICK_TIMER_DEBUG FALSE
#endif
+#define GKI_VERBOSE(fmt, ...) ALOGV ("%s: " fmt, __FUNCTION__, ## __VA_ARGS__)
#define GKI_INFO(fmt, ...) ALOGI ("%s: " fmt, __FUNCTION__, ## __VA_ARGS__)
+#define GKI_ERROR(fmt, ...) ALOGE ("%s: " fmt, __FUNCTION__, ## __VA_ARGS__)
/* always log errors */
#define GKI_ERROR_LOG(fmt, ...) ALOGE ("##### ERROR : %s: " fmt "#####", __FUNCTION__, ## __VA_ARGS__)
@@ -58,7 +57,6 @@
#define GKI_TIMER_TRACE(fmt, ...)
#endif
-
#define SCHED_NORMAL 0
#define SCHED_FIFO 1
#define SCHED_RR 2
@@ -67,38 +65,20 @@
#define NANOSEC_PER_MILLISEC (1000000)
#define NSEC_PER_SEC (1000*NANOSEC_PER_MILLISEC)
-/* works only for 1ms to 1000ms heart beat ranges */
-#define LINUX_SEC (1000/TICKS_PER_SEC)
-
-#define LOCK(m) pthread_mutex_lock(&m)
-#define UNLOCK(m) pthread_mutex_unlock(&m)
-#define INIT(m) pthread_mutex_init(&m, NULL)
-
-#define WAKE_LOCK_ID "brcm_btld"
-#define PARTIAL_WAKE_LOCK 1
+#define WAKE_LOCK_ID "bluedroid_timer"
#if GKI_DYNAMIC_MEMORY == FALSE
tGKI_CB gki_cb;
#endif
-#ifdef NO_GKI_RUN_RETURN
-static pthread_t timer_thread_id = 0;
-static int shutdown_timer = 0;
-#endif
-
#ifndef GKI_SHUTDOWN_EVT
#define GKI_SHUTDOWN_EVT APPL_EVT_7
#endif
-#define __likely(cond) __builtin_expect(!!(cond), 1)
-#define __unlikely(cond) __builtin_expect(!!(cond), 0)
-
/*****************************************************************************
** Local type definitions
******************************************************************************/
-#define pthread_cond_timedwait_monotonic pthread_cond_timedwait
-
typedef struct
{
UINT8 task_id; /* GKI task id */
@@ -106,14 +86,29 @@
UINT32 params; /* Extra params to pass to task entry function */
} gki_pthread_info_t;
+// Alarm service structure used to pass up via JNI to the bluetooth
+// app in order to create a wakeable Alarm.
+typedef struct {
+ int32_t num_ticks;
+ uint32_t alarm_cnt;
+ bool wakelock;
+} alarm_service_t;
/*****************************************************************************
** Static variables
******************************************************************************/
-int g_GkiTimerWakeLockOn = 0;
gki_pthread_info_t gki_pthread_info[GKI_MAX_TASKS];
+// Only a single alarm is used to wake bluedroid.
+// NOTE: Must be manipulated with the GKI_disable() lock held.
+static alarm_service_t alarm_service;
+
+// If the next wakeup time is less than this threshold, we should acquire
+// a wakelock instead of setting a wake alarm so we're not bouncing in
+// and out of suspend frequently.
+static const uint32_t TIMER_INTERVAL_FOR_WAKELOCK_IN_MS = 3000;
+
/*****************************************************************************
** Static functions
******************************************************************************/
@@ -122,13 +117,82 @@
** Externs
******************************************************************************/
-extern int acquire_wake_lock(int lock, const char* id);
-extern int release_wake_lock(const char* id);
+extern bt_os_callouts_t *bt_os_callouts;
/*****************************************************************************
** Functions
******************************************************************************/
+/** Callback from Java thread after alarm from AlarmService fires. */
+static void bt_alarm_cb(void *data) {
+ alarm_service_t *alarm_service = (alarm_service_t *)data;
+ GKI_timer_update(alarm_service->num_ticks);
+}
+
+/** NOTE: This is only called on init and may be called without the GKI_disable()
+ * lock held.
+ */
+static void alarm_service_init() {
+ alarm_service.num_ticks = 0;
+ alarm_service.alarm_cnt = 0;
+ alarm_service.wakelock = false;
+}
+
+/** Requests an alarm from AlarmService to fire when the next
+ * timer in the timer queue is set to expire. Only takes a wakelock
+ * if the timer tick expiration is a short interval in the future
+ * and releases the wakelock if the timer is a longer interval
+ * or if there are no more timers in the queue.
+ *
+ * NOTE: Must be called with GKI_disable() lock held.
+ */
+void alarm_service_reschedule() {
+ int32_t ticks_till_next_exp = GKI_ready_to_sleep();
+
+ assert(ticks_till_next_exp >= 0);
+
+ // No more timers remaining. Release wakelock if we're holding one.
+ if (ticks_till_next_exp == 0) {
+ if (alarm_service.wakelock) {
+ GKI_VERBOSE("%s releasing wake lock.", __func__);
+ alarm_service.wakelock = false;
+ int rc = bt_os_callouts->release_wake_lock(WAKE_LOCK_ID);
+ if (rc != BT_STATUS_SUCCESS) {
+ GKI_ERROR("%s unable to release wake lock with no timers: %d", __func__, rc);
+ }
+ }
+ GKI_VERBOSE("%s no more alarms.", __func__);
+ return;
+ }
+
+ alarm_service.num_ticks = ticks_till_next_exp;
+ alarm_service.alarm_cnt++;
+
+ uint64_t ticks_in_millis = GKI_TICKS_TO_MS(ticks_till_next_exp);
+ if (ticks_in_millis <= TIMER_INTERVAL_FOR_WAKELOCK_IN_MS) {
+ // The next deadline is close, just take a wakelock and set a regular (non-wake) timer.
+ int rc = bt_os_callouts->acquire_wake_lock(WAKE_LOCK_ID);
+ if (rc != BT_STATUS_SUCCESS) {
+ GKI_ERROR("%s unable to acquire wake lock: %d", __func__, rc);
+ return;
+ }
+ alarm_service.wakelock = true;
+ GKI_VERBOSE("%s acquired wake lock, setting short alarm (%lldms).", __func__, ticks_in_millis);
+ if (!bt_os_callouts->set_wake_alarm(ticks_in_millis, false, bt_alarm_cb, &alarm_service)) {
+ GKI_ERROR("%s unable to set short alarm.", __func__);
+ }
+ } else {
+ // The deadline is far away, set a wake alarm and release wakelock if we're holding it.
+ if (!bt_os_callouts->set_wake_alarm(ticks_in_millis, true, bt_alarm_cb, &alarm_service)) {
+ GKI_ERROR("%s unable to set long alarm, releasing wake lock anyway.", __func__);
+ } else {
+ GKI_VERBOSE("%s set long alarm (%lldms), releasing wake lock.", __func__, ticks_in_millis);
+ }
+ alarm_service.wakelock = false;
+ bt_os_callouts->release_wake_lock(WAKE_LOCK_ID);
+ }
+}
+
/*****************************************************************************
**
@@ -180,6 +244,8 @@
gki_buffer_init();
gki_timers_init();
+ alarm_service_init();
+
gki_cb.com.OSTicks = (UINT32) times(0);
pthread_mutexattr_init(&attr);
@@ -266,8 +332,12 @@
gki_cb.com.OSWaitEvt[task_id] = 0;
/* Initialize mutex and condition variable objects for events and timeouts */
+ pthread_condattr_t cond_attr;
+ pthread_condattr_init(&cond_attr);
+ pthread_condattr_setclock(&cond_attr, CLOCK_MONOTONIC);
+
pthread_mutex_init(&gki_cb.os.thread_evt_mutex[task_id], NULL);
- pthread_cond_init (&gki_cb.os.thread_evt_cond[task_id], NULL);
+ pthread_cond_init (&gki_cb.os.thread_evt_cond[task_id], &cond_attr);
pthread_mutex_init(&gki_cb.os.thread_timeout_mutex[task_id], NULL);
pthread_cond_init (&gki_cb.os.thread_timeout_cond[task_id], NULL);
@@ -522,15 +592,6 @@
i = 0;
#endif
-#ifdef NO_GKI_RUN_RETURN
- shutdown_timer = 1;
-#endif
- if (g_GkiTimerWakeLockOn)
- {
- GKI_TRACE("GKI_shutdown : release_wake_lock(brcm_btld)");
- release_wake_lock(WAKE_LOCK_ID);
- g_GkiTimerWakeLockOn = 0;
- }
}
/*******************************************************************************
@@ -547,178 +608,13 @@
void gki_system_tick_start_stop_cback(BOOLEAN start)
{
- tGKI_OS *p_os = &gki_cb.os;
- int *p_run_cond = &p_os->no_timer_suspend;
- static int wake_lock_count;
-
- if ( FALSE == start )
- {
- /* gki_system_tick_start_stop_cback() maybe called even so it was already stopped! */
- if (GKI_TIMER_TICK_RUN_COND == *p_run_cond)
- {
-#ifdef NO_GKI_RUN_RETURN
- /* take free mutex to block timer thread */
- pthread_mutex_lock(&p_os->gki_timer_mutex);
-#endif
- /* this can lead to a race condition. however as we only read this variable in the
- * timer loop we should be fine with this approach. otherwise uncomment below mutexes.
- */
- /* GKI_disable(); */
- *p_run_cond = GKI_TIMER_TICK_STOP_COND;
- /* GKI_enable(); */
-
- GKI_TIMER_TRACE(">>> STOP GKI_timer_update(), wake_lock_count:%d", --wake_lock_count);
-
- release_wake_lock(WAKE_LOCK_ID);
- g_GkiTimerWakeLockOn = 0;
- }
- }
- else
- {
- /* restart GKI_timer_update() loop */
- acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID);
-
- g_GkiTimerWakeLockOn = 1;
- *p_run_cond = GKI_TIMER_TICK_RUN_COND;
-
-#ifdef NO_GKI_RUN_RETURN
- pthread_mutex_unlock( &p_os->gki_timer_mutex );
-#else
- pthread_mutex_lock( &p_os->gki_timer_mutex );
- pthread_cond_signal( &p_os->gki_timer_cond );
- pthread_mutex_unlock( &p_os->gki_timer_mutex );
-#endif
-
- GKI_TIMER_TRACE(">>> START GKI_timer_update(), wake_lock_count:%d", ++wake_lock_count );
+ if (start) {
+ GKI_VERBOSE("Starting system ticks\n");
+ } else {
+ GKI_VERBOSE("Stopping system ticks\n");
}
}
-
-/*******************************************************************************
-**
-** Function GKI_run
-**
-** Description This function runs a task
-****
-** Returns void
-**
-** NOTE This function is only needed for operating systems where
-** starting a task is a 2-step process. Most OS's do it in
-** one step, If your OS does it in one step, this function
-** should be empty.
-*********************************************************************************/
-#ifdef NO_GKI_RUN_RETURN
-void* timer_thread(void *arg)
-{
- int timeout_ns=0;
- struct timespec timeout;
- struct timespec previous = {0,0};
- struct timespec current;
- int err;
- int delta_ns;
- int restart;
- tGKI_OS *p_os = &gki_cb.os;
- int *p_run_cond = &p_os->no_timer_suspend;
- (void)arg;
-
- /* Indicate that tick is just starting */
- restart = 1;
-
- prctl(PR_SET_NAME, (unsigned long)"gki timer", 0, 0, 0);
-
- raise_priority_a2dp(TASK_HIGH_GKI_TIMER);
-
- while(!shutdown_timer)
- {
- /* If the timer has been stopped (no SW timer running) */
- if (*p_run_cond == GKI_TIMER_TICK_STOP_COND)
- {
- /*
- * We will lock/wait on GKI_timer_mutex.
- * This mutex will be unlocked when timer is re-started
- */
- GKI_TRACE("GKI_run lock mutex");
- pthread_mutex_lock(&p_os->gki_timer_mutex);
-
- /* We are here because the mutex has been released by timer cback */
- /* Let's release it for future use */
- GKI_TRACE("GKI_run unlock mutex");
- pthread_mutex_unlock(&p_os->gki_timer_mutex);
-
- /* Indicate that tick is just starting */
- restart = 1;
- }
-
- /* Get time */
- clock_gettime(CLOCK_MONOTONIC, ¤t);
-
- /* Check if tick was just restarted, indicating to the compiler that this is
- * unlikely to happen (to help branch prediction) */
- if (__unlikely(restart))
- {
- /* Clear the restart indication */
- restart = 0;
-
- timeout_ns = (GKI_TICKS_TO_MS(1) * 1000000);
- }
- else
- {
- /* Compute time elapsed since last sleep start */
- delta_ns = current.tv_nsec - previous.tv_nsec;
- delta_ns += (current.tv_sec - previous.tv_sec) * 1000000000;
-
- /* Compute next timeout:
- * timeout = (next theoretical expiration) - current time
- * timeout = (previous time + timeout + delay) - current time
- * timeout = timeout + delay - (current time - previous time)
- * timeout += delay - delta */
- timeout_ns += (GKI_TICKS_TO_MS(1) * 1000000) - delta_ns;
- }
- /* Save the current time for next iteration */
- previous = current;
-
- timeout.tv_sec = 0;
-
- /* Sleep until next theoretical tick time. In case of excessive
- elapsed time since last theoretical tick expiration, it is
- possible that the timeout value is negative. To protect
- against this error, we set minimum sleep time to 10% of the
- tick period. We indicate to compiler that this is unlikely to
- happen (to help branch prediction) */
-
- if (__unlikely(timeout_ns < ((GKI_TICKS_TO_MS(1) * 1000000) * 0.1)))
- {
- timeout.tv_nsec = (GKI_TICKS_TO_MS(1) * 1000000) * 0.1;
-
- /* Print error message if tick really got delayed
- (more than 5 ticks) */
- if (timeout_ns < GKI_TICKS_TO_MS(-5) * 1000000)
- {
- GKI_ERROR_LOG("tick delayed > 5 slots (%d,%d) -- cpu overload ? ",
- timeout_ns, GKI_TICKS_TO_MS(-5) * 1000000);
- }
- }
- else
- {
- timeout.tv_nsec = timeout_ns;
- }
-
- do
- {
- /* [u]sleep can't be used because it uses SIGALRM */
- err = nanosleep(&timeout, &timeout);
- } while (err < 0 && errno == EINTR);
-
- /* Increment the GKI time value by one tick and update internal timers */
- GKI_timer_update(1);
- }
- GKI_TRACE("gki_ulinux: Exiting timer_thread");
- pthread_exit(NULL);
- return NULL;
-}
-#endif
-
-
/*****************************************************************************
**
** Function gki_set_timer_scheduling
@@ -769,10 +665,7 @@
void GKI_freeze()
{
#ifdef NO_GKI_RUN_RETURN
- shutdown_timer = 1;
- pthread_mutex_unlock( &gki_cb.os.gki_timer_mutex );
- /* Ensure that the timer thread exits */
- pthread_join(timer_thread_id, NULL);
+ pthread_mutex_unlock( &gki_cb.os.gki_timer_mutex );
#endif
}
@@ -788,9 +681,6 @@
void GKI_run (void * p_task_id)
{
- struct timespec delay;
- int err;
- volatile int * p_run_cond = &gki_cb.os.no_timer_suspend;
UNUSED(p_task_id);
#ifndef GKI_NO_TICK_STOP
@@ -802,61 +692,6 @@
GKI_timer_queue_register_callback( gki_system_tick_start_stop_cback );
GKI_TRACE( "GKI_run(): Start/Stop GKI_timer_update_registered!" );
#endif
-
-#ifdef NO_GKI_RUN_RETURN
- pthread_attr_t timer_attr;
-
- shutdown_timer = 0;
-
- pthread_attr_init(&timer_attr);
- if (pthread_create( &timer_thread_id,
- &timer_attr,
- timer_thread,
- NULL) != 0 )
- {
- GKI_ERROR_LOG("pthread_create failed to create timer_thread!\n\r");
- return;
- }
-
-#else
- GKI_TRACE("GKI_run ");
- for (;;)
- {
- do
- {
- /* adjust hear bit tick in btld by changning TICKS_PER_SEC!!!!! this formula works only for
- * 1-1000ms heart beat units! */
- delay.tv_sec = LINUX_SEC / 1000;
- delay.tv_nsec = 1000 * 1000 * (LINUX_SEC % 1000);
-
- /* [u]sleep can't be used because it uses SIGALRM */
- do
- {
- err = nanosleep(&delay, &delay);
- } while (err < 0 && errno == EINTR);
-
- /* the unit should be alsways 1 (1 tick). only if you vary for some reason heart beat tick
- * e.g. power saving you may want to provide more ticks
- */
- GKI_timer_update( 1 );
- /* BT_TRACE_2( TRACE_LAYER_HCI, TRACE_TYPE_DEBUG, "update: tv_sec: %d, tv_nsec: %d", delay.tv_sec, delay.tv_nsec ); */
- } while ( GKI_TIMER_TICK_RUN_COND == *p_run_cond );
-
- /* currently on reason to exit above loop is no_timer_suspend == GKI_TIMER_TICK_STOP_COND
- * block timer main thread till re-armed by */
-
- GKI_TIMER_TRACE(">>> SUSPENDED GKI_timer_update()" );
-
- pthread_mutex_lock( &gki_cb.os.gki_timer_mutex );
- pthread_cond_wait( &gki_cb.os.gki_timer_cond, &gki_cb.os.gki_timer_mutex );
- pthread_mutex_unlock( &gki_cb.os.gki_timer_mutex );
-
- /* potentially we need to adjust os gki_cb.com.OSTicks */
- GKI_TIMER_TRACE(">>> RESTARTED GKI_timer_update(): run_cond: %d",
- *p_run_cond );
-
- }
-#endif
return;
}
@@ -944,9 +779,8 @@
}
abstime.tv_sec += sec;
- pthread_cond_timedwait_monotonic(&gki_cb.os.thread_evt_cond[rtask],
+ pthread_cond_timedwait(&gki_cb.os.thread_evt_cond[rtask],
&gki_cb.os.thread_evt_mutex[rtask], &abstime);
-
}
else
{
@@ -1060,7 +894,6 @@
{
GKI_TRACE("GKI_send_event %d %x", task_id, event);
- /* use efficient coding to avoid pipeline stalls */
if (task_id < GKI_MAX_TASKS)
{
/* protect OSWaitEvt[task_id] from manipulation in GKI_wait() */
@@ -1476,45 +1309,3 @@
GKI_INFO("GKI_exit_task %d done", task_id);
return;
}
-
-
-/*******************************************************************************
-**
-** Function GKI_sched_lock
-**
-** Description This function is called by tasks to disable scheduler
-** task context switching.
-**
-** Returns void
-**
-** NOTE This function is NOT called by the Broadcom stack and
-** profiles. If you want to use it in your own implementation,
-** put code here to tell the OS to disable context switching.
-**
-*******************************************************************************/
-void GKI_sched_lock(void)
-{
- GKI_TRACE("GKI_sched_lock");
- return;
-}
-
-
-/*******************************************************************************
-**
-** Function GKI_sched_unlock
-**
-** Description This function is called by tasks to enable scheduler switching.
-**
-** Returns void
-**
-** NOTE This function is NOT called by the Broadcom stack and
-** profiles. If you want to use it in your own implementation,
-** put code here to tell the OS to re-enable context switching.
-**
-*******************************************************************************/
-void GKI_sched_unlock(void)
-{
- GKI_TRACE("GKI_sched_unlock");
-}
-
-
diff --git a/hci/Android.mk b/hci/Android.mk
index 96f0813..4e956c2 100644
--- a/hci/Android.mk
+++ b/hci/Android.mk
@@ -2,16 +2,21 @@
include $(CLEAR_VARS)
+LOCAL_CFLAGS += $(bdroid_CFLAGS)
+
LOCAL_SRC_FILES := \
src/bt_hci_bdroid.c \
src/lpm.c \
src/bt_hw.c \
src/btsnoop.c \
+ src/btsnoop_net.c \
src/utils.c
+LOCAL_CFLAGS := -Wno-unused-parameter
+
ifeq ($(BLUETOOTH_HCI_USE_MCT),true)
-LOCAL_CFLAGS := -DHCI_USE_MCT
+LOCAL_CFLAGS += -DHCI_USE_MCT
LOCAL_SRC_FILES += \
src/hci_mct.c \
@@ -29,7 +34,8 @@
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/include \
- $(LOCAL_PATH)/../utils/include
+ $(LOCAL_PATH)/../utils/include \
+ $(bdroid_C_INCLUDES)
LOCAL_SHARED_LIBRARIES := \
libcutils \
diff --git a/hci/include/bt_hci_bdroid.h b/hci/include/bt_hci_bdroid.h
index 7b23851..ac2f162 100644
--- a/hci/include/bt_hci_bdroid.h
+++ b/hci/include/bt_hci_bdroid.h
@@ -32,6 +32,10 @@
#include "bt_hci_lib.h"
+#ifdef HAS_BDROID_BUILDCFG
+#include "bdroid_buildcfg.h"
+#endif
+
/******************************************************************************
** Constants & Macros
******************************************************************************/
@@ -62,9 +66,8 @@
#endif
#endif // (BTHC_LINUX_BASE_POLICY != SCHED_NORMAL)
-#ifndef BTHC_USERIAL_READ_MEM_SIZE
-#define BTHC_USERIAL_READ_MEM_SIZE (1024)
-#endif
+#define HCI_ACL_MAX_SIZE 1024
+#define HCI_MAX_FRAME_SIZE (HCI_ACL_MAX_SIZE + 4)
#ifndef BTSNOOPDISP_INCLUDED
#define BTSNOOPDISP_INCLUDED TRUE
diff --git a/hci/include/userial.h b/hci/include/userial.h
index d3a5480..86984f6 100644
--- a/hci/include/userial.h
+++ b/hci/include/userial.h
@@ -16,126 +16,63 @@
*
******************************************************************************/
-/******************************************************************************
- *
- * Filename: userial.h
- *
- * Description: Contains definitions used for serial port controls
- *
- ******************************************************************************/
+// This module manages the serial port over which HCI commands
+// and data are sent/received.
-#ifndef USERIAL_H
-#define USERIAL_H
+#pragma once
-/******************************************************************************
-** Constants & Macros
-******************************************************************************/
-
-/**** port IDs ****/
-#define USERIAL_PORT_1 0
-#define USERIAL_PORT_2 1
-#define USERIAL_PORT_3 2
-#define USERIAL_PORT_4 3
-#define USERIAL_PORT_5 4
-#define USERIAL_PORT_6 5
-#define USERIAL_PORT_7 6
-#define USERIAL_PORT_8 7
-#define USERIAL_PORT_9 8
-#define USERIAL_PORT_10 9
-#define USERIAL_PORT_11 10
-#define USERIAL_PORT_12 11
-#define USERIAL_PORT_13 12
-#define USERIAL_PORT_14 13
-#define USERIAL_PORT_15 14
-#define USERIAL_PORT_16 15
-#define USERIAL_PORT_17 16
-#define USERIAL_PORT_18 17
+#include <stdbool.h>
+#include <stdint.h>
typedef enum {
- USERIAL_OP_INIT,
- USERIAL_OP_RXFLOW_ON,
- USERIAL_OP_RXFLOW_OFF,
-} userial_ioctl_op_t;
+ USERIAL_PORT_1,
+ USERIAL_PORT_2,
+ USERIAL_PORT_3,
+ USERIAL_PORT_4,
+ USERIAL_PORT_5,
+ USERIAL_PORT_6,
+ USERIAL_PORT_7,
+ USERIAL_PORT_8,
+ USERIAL_PORT_9,
+ USERIAL_PORT_10,
+ USERIAL_PORT_11,
+ USERIAL_PORT_12,
+ USERIAL_PORT_13,
+ USERIAL_PORT_14,
+ USERIAL_PORT_15,
+ USERIAL_PORT_16,
+ USERIAL_PORT_17,
+ USERIAL_PORT_18,
+} userial_port_t;
-/******************************************************************************
-** Type definitions
-******************************************************************************/
+// Initializes the userial module. This function should only ever be called once.
+// It returns true if the module could be initialized, false if there was an error.
+bool userial_init(void);
-/******************************************************************************
-** Extern variables and functions
-******************************************************************************/
-
-/******************************************************************************
-** Functions
-******************************************************************************/
-
-/*******************************************************************************
-**
-** Function userial_init
-**
-** Description Initializes the userial driver
-**
-** Returns TRUE/FALSE
-**
-*******************************************************************************/
-uint8_t userial_init(void);
-
-/*******************************************************************************
-**
-** Function userial_open
-**
-** Description Open Bluetooth device with the port ID
-**
-** Returns TRUE/FALSE
-**
-*******************************************************************************/
-uint8_t userial_open(uint8_t port);
-
-/*******************************************************************************
-**
-** Function userial_read
-**
-** Description Read data from the userial port
-**
-** Returns Number of bytes actually read from the userial port and
-** copied into p_data. This may be less than len.
-**
-*******************************************************************************/
-uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len);
-
-/*******************************************************************************
-**
-** Function userial_write
-**
-** Description Write data to the userial port
-**
-** Returns Number of bytes actually written to the userial port. This
-** may be less than len.
-**
-*******************************************************************************/
-uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len);
-
-/*******************************************************************************
-**
-** Function userial_close
-**
-** Description Close the userial port
-**
-** Returns None
-**
-*******************************************************************************/
+// Opens the given serial port. Returns true if successful, false otherwise.
+// Once this function is called, the userial module will begin producing
+// buffers from data read off the serial port. If you wish to pause the
+// production of buffers, call |userial_pause_reading|. You can then resume
+// by calling |userial_resume_reading|. This function returns true if the
+// serial port was successfully opened and buffer production has started. It
+// returns false if there was an error.
+bool userial_open(userial_port_t port);
void userial_close(void);
-/*******************************************************************************
-**
-** Function userial_ioctl
-**
-** Description ioctl inteface
-**
-** Returns None
-**
-*******************************************************************************/
-void userial_ioctl(userial_ioctl_op_t op, void *p_data);
+// Reads a maximum of |len| bytes from the serial port into |p_buffer|.
+// This function returns the number of bytes actually read, which may be
+// less than |len|. This function will not block.
+uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len);
-#endif /* USERIAL_H */
+// Writes a maximum of |len| bytes from |p_data| to the serial port.
+// This function returns the number of bytes actually written, which may be
+// less than |len|. This function may block.
+uint16_t userial_write(uint16_t msg_id, const uint8_t *p_data, uint16_t len);
+// Pauses reading data from the serial port. No new buffers will be produced
+// until |userial_resume_reading| is called. This function is idempotent.
+void userial_pause_reading(void);
+
+// Resumes reading data from the serial port if reads were previously paused.
+// This function is idempotent.
+void userial_resume_reading(void);
diff --git a/hci/src/bt_hci_bdroid.c b/hci/src/bt_hci_bdroid.c
index ed98b37..7cd422e 100644
--- a/hci/src/bt_hci_bdroid.c
+++ b/hci/src/bt_hci_bdroid.c
@@ -27,6 +27,7 @@
#define LOG_TAG "bt_hci_bdroid"
+#include <assert.h>
#include <utils/Log.h>
#include <pthread.h>
#include "bt_hci_bdroid.h"
@@ -332,13 +333,23 @@
/** Controls receive flow */
-static int set_rxflow(bt_rx_flow_state_t state)
-{
+static int set_rxflow(bt_rx_flow_state_t state) {
BTHCDBG("set_rxflow %d", state);
- userial_ioctl(\
- ((state == BT_RXFLOW_ON) ? USERIAL_OP_RXFLOW_ON : USERIAL_OP_RXFLOW_OFF), \
- NULL);
+ switch (state) {
+ case BT_RXFLOW_ON:
+ userial_resume_reading();
+ break;
+
+ case BT_RXFLOW_OFF:
+ userial_pause_reading();
+ break;
+
+ default:
+ assert(false);
+ ALOGE("%s unexpected flow state: %d", __func__, state);
+ return BT_HC_STATUS_FAIL;
+ }
return BT_HC_STATUS_SUCCESS;
}
diff --git a/hci/src/btsnoop.c b/hci/src/btsnoop.c
index c6556d6..e4b1376 100644
--- a/hci/src/btsnoop.c
+++ b/hci/src/btsnoop.c
@@ -34,6 +34,7 @@
#include <unistd.h>
#include <ctype.h>
#include <fcntl.h>
+#include <stdbool.h>
#include <arpa/inet.h>
#include <netinet/in.h>
@@ -67,10 +68,16 @@
#define SNOOPDBG(param, ...) {}
#endif
-#define HCIT_TYPE_COMMAND 1
-#define HCIT_TYPE_ACL_DATA 2
-#define HCIT_TYPE_SCO_DATA 3
-#define HCIT_TYPE_EVENT 4
+typedef enum {
+ kCommandPacket = 1,
+ kAclPacket = 2,
+ kScoPacket = 3,
+ kEventPacket = 4
+} packet_type;
+
+void btsnoop_net_init();
+void btsnoop_net_cleanup();
+void btsnoop_net_write(const void *data, size_t length);
/* file descriptor of the BT snoop file (by default, -1 means disabled) */
int hci_btsnoop_fd = -1;
@@ -259,117 +266,78 @@
}
/*******************************************************************************
- ** Function btsnoop_write
**
- ** Description Function used to write the actual data to the log
+ ** Function btsnoop_write
**
- ** Returns none
+ ** Description Writes raw bytes to the BTSNOOP sinks.
+ **
+ ** Returns None
*******************************************************************************/
+static void btsnoop_write(const void *data, size_t length) {
+ if (hci_btsnoop_fd != -1) {
+ write(hci_btsnoop_fd, data, length);
+ }
+ btsnoop_net_write(data, length);
+}
-void btsnoop_write(uint8_t *p, uint32_t flags, const uint8_t *ptype, uint32_t len)
-{
- uint32_t value, value_hi;
+/*******************************************************************************
+ **
+ ** Function btsnoop_write_packet
+ **
+ ** Description Writes a single HCI packet to BTSNOOP sinks.
+ **
+ ** Returns None
+*******************************************************************************/
+static void btsnoop_write_packet(packet_type type,
+ const uint8_t *packet,
+ bool is_received) {
+ int length_he;
+ int length;
+ int flags;
+ int drops = 0;
+ switch (type) {
+ case kCommandPacket:
+ length_he = packet[2] + 4;
+ flags = 2;
+ break;
+ case kAclPacket:
+ length_he = (packet[3] << 8) + packet[2] + 5;
+ flags = is_received;
+ break;
+ case kScoPacket:
+ length_he = packet[2] + 4;
+ flags = is_received;
+ break;
+ case kEventPacket:
+ length_he = packet[1] + 3;
+ flags = 3;
+ break;
+ }
+
+ uint32_t time_hi, time_lo;
struct timeval tv;
- struct iovec io[3];
- uint32_t header[6];
-
- /* store the length in both original and included fields */
- header[0] = l_to_be(len + 1);
- header[1] = header[0];
- /* flags: data can be sent or received */
- header[2] = l_to_be(flags);
- /* drops: none */
- header[3] = 0;
- /* time */
gettimeofday(&tv, NULL);
- tv_to_btsnoop_ts(&header[5], &header[4], &tv);
- header[4] = l_to_be(header[4]);
- header[5] = l_to_be(header[5]);
+ tv_to_btsnoop_ts(&time_lo, &time_hi, &tv);
- io[0].iov_base = header;
- io[0].iov_len = sizeof(header);
+ length = l_to_be(length_he);
+ flags = l_to_be(flags);
+ drops = l_to_be(drops);
+ time_hi = l_to_be(time_hi);
+ time_lo = l_to_be(time_lo);
- io[1].iov_base = (void*)ptype;
- io[1].iov_len = 1;
+ /* since these display functions are called from different contexts */
+ utils_lock();
- io[2].iov_base = p;
- io[2].iov_len = len;
+ btsnoop_write(&length, 4);
+ btsnoop_write(&length, 4);
+ btsnoop_write(&flags, 4);
+ btsnoop_write(&drops, 4);
+ btsnoop_write(&time_hi, 4);
+ btsnoop_write(&time_lo, 4);
+ btsnoop_write(&type, 1);
+ btsnoop_write(packet, length_he - 1);
- (void) writev(hci_btsnoop_fd, io, 3);
-}
-
-/*******************************************************************************
- **
- ** Function btsnoop_hci_cmd
- **
- ** Description Function to add a command in the BTSNOOP file
- **
- ** Returns None
-*******************************************************************************/
-void btsnoop_hci_cmd(uint8_t *p)
-{
- const uint8_t cmd = HCIT_TYPE_COMMAND;
- int plen;
- SNOOPDBG("btsnoop_hci_cmd: fd = %d", hci_btsnoop_fd);
- plen = (int) p[2] + 3;
- btsnoop_write(p, 2, &cmd, plen);
-}
-
-
-/*******************************************************************************
- **
- ** Function btsnoop_hci_evt
- **
- ** Description Function to add a event in the BTSNOOP file
- **
- ** Returns None
-*******************************************************************************/
-void btsnoop_hci_evt(uint8_t *p)
-{
- const uint8_t evt = HCIT_TYPE_EVENT;
- int plen;
- SNOOPDBG("btsnoop_hci_evt: fd = %d", hci_btsnoop_fd);
- plen = (int) p[1] + 2;
-
- btsnoop_write(p, 3, &evt, plen);
-}
-
-/*******************************************************************************
- **
- ** Function btsnoop_sco_data
- **
- ** Description Function to add a SCO data packet in the BTSNOOP file
- **
- ** Returns None
-*******************************************************************************/
-void btsnoop_sco_data(uint8_t *p, uint8_t is_rcvd)
-{
- const uint8_t sco = HCIT_TYPE_SCO_DATA;
- int plen;
- SNOOPDBG("btsnoop_sco_data: fd = %d", hci_btsnoop_fd);
- plen = (int) p[2] + 3;
-
- btsnoop_write(p, is_rcvd, &sco, plen);
-}
-
-/*******************************************************************************
- **
- ** Function btsnoop_acl_data
- **
- ** Description Function to add an ACL data packet in the BTSNOOP file
- **
- ** Returns None
-*******************************************************************************/
-void btsnoop_acl_data(uint8_t *p, uint8_t is_rcvd)
-{
- const uint8_t acl = HCIT_TYPE_ACL_DATA;
- int plen;
-
- SNOOPDBG("btsnoop_acl_data: fd = %d", hci_btsnoop_fd);
-
- plen = (((int) p[3]) << 8) + ((int) p[2]) +4;
-
- btsnoop_write(p, is_rcvd, &acl, plen);
+ utils_unlock();
}
/********************************************************************************
@@ -433,7 +401,7 @@
s = accept(s_listen, (struct sockaddr *) &cliaddr, &clilen);
if (s < 0)
-{
+ {
perror("accept");
return -1;
}
@@ -528,7 +496,9 @@
if (pthread_create(&thread_id, NULL,
(void*)ext_parser_thread,NULL)!=0)
perror("pthread_create");
+
#endif
+ btsnoop_net_init();
}
void btsnoop_open(char *p_path)
@@ -549,6 +519,7 @@
void btsnoop_cleanup (void)
{
+ btsnoop_net_cleanup();
#if defined(BTSNOOP_EXT_PARSER_INCLUDED) && (BTSNOOP_EXT_PARSER_INCLUDED == TRUE)
ALOGD("btsnoop_cleanup");
pthread_kill(thread_id, SIGUSR2);
@@ -605,24 +576,22 @@
{
case MSG_HC_TO_STACK_HCI_EVT:
SNOOPDBG("TYPE : EVT");
- btsnoop_hci_evt(p);
+ btsnoop_write_packet(kEventPacket, p, false);
break;
case MSG_HC_TO_STACK_HCI_ACL:
case MSG_STACK_TO_HC_HCI_ACL:
SNOOPDBG("TYPE : ACL");
- btsnoop_acl_data(p, is_rcvd);
+ btsnoop_write_packet(kAclPacket, p, is_rcvd);
break;
case MSG_HC_TO_STACK_HCI_SCO:
case MSG_STACK_TO_HC_HCI_SCO:
SNOOPDBG("TYPE : SCO");
- btsnoop_sco_data(p, is_rcvd);
+ btsnoop_write_packet(kScoPacket, p, is_rcvd);
break;
case MSG_STACK_TO_HC_HCI_CMD:
SNOOPDBG("TYPE : CMD");
- btsnoop_hci_cmd(p);
+ btsnoop_write_packet(kCommandPacket, p, true);
break;
}
#endif // BTSNOOPDISP_INCLUDED
}
-
-
diff --git a/hci/src/btsnoop_net.c b/hci/src/btsnoop_net.c
new file mode 100644
index 0000000..06cc01a
--- /dev/null
+++ b/hci/src/btsnoop_net.c
@@ -0,0 +1,134 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2013 Google, Inc.
+ *
+ * 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 <assert.h>
+#include <errno.h>
+#include <netinet/in.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <string.h>
+#include <sys/prctl.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+
+#define LOG_TAG "btsnoop_net"
+#include <cutils/log.h>
+
+static void safe_close_(int *fd);
+static void *listen_fn_(void *context);
+
+static const char *LISTEN_THREAD_NAME_ = "btsnoop_net_listen";
+static const int LOCALHOST_ = 0x7F000001;
+static const int LISTEN_PORT_ = 8872;
+
+static pthread_t listen_thread_;
+static bool listen_thread_valid_ = false;
+static pthread_mutex_t client_socket_lock_ = PTHREAD_MUTEX_INITIALIZER;
+static int listen_socket_ = -1;
+static int client_socket_ = -1;
+
+void btsnoop_net_init() {
+ listen_thread_valid_ = (pthread_create(&listen_thread_, NULL, listen_fn_, NULL) == 0);
+ if (!listen_thread_valid_) {
+ ALOGE("%s pthread_create failed: %s", __func__, strerror(errno));
+ } else {
+ ALOGD("initialized");
+ }
+}
+
+void btsnoop_net_cleanup() {
+ if (listen_thread_valid_) {
+ shutdown(listen_socket_, SHUT_RDWR);
+ pthread_join(listen_thread_, NULL);
+ safe_close_(&client_socket_);
+ listen_thread_valid_ = false;
+ }
+}
+
+void btsnoop_net_write(const void *data, size_t length) {
+ pthread_mutex_lock(&client_socket_lock_);
+ if (client_socket_ != -1) {
+ if (send(client_socket_, data, length, 0) == -1 && errno == ECONNRESET) {
+ safe_close_(&client_socket_);
+ }
+ }
+ pthread_mutex_unlock(&client_socket_lock_);
+}
+
+static void *listen_fn_(void *context) {
+ prctl(PR_SET_NAME, (unsigned long)LISTEN_THREAD_NAME_, 0, 0, 0);
+
+ listen_socket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (listen_socket_ == -1) {
+ ALOGE("%s socket creation failed: %s", __func__, strerror(errno));
+ goto cleanup;
+ }
+
+ int enable = 1;
+ if (setsockopt(listen_socket_, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)) == -1) {
+ ALOGE("%s unable to set SO_REUSEADDR: %s", __func__, strerror(errno));
+ goto cleanup;
+ }
+
+ struct sockaddr_in addr;
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = htonl(LOCALHOST_);
+ addr.sin_port = htons(LISTEN_PORT_);
+ if (bind(listen_socket_, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
+ ALOGE("%s unable to bind listen socket: %s", __func__, strerror(errno));
+ goto cleanup;
+ }
+
+ if (listen(listen_socket_, 10) == -1) {
+ ALOGE("%s unable to listen: %s", __func__, strerror(errno));
+ goto cleanup;
+ }
+
+ for (;;) {
+ ALOGD("waiting for client connection");
+ int client_socket = accept(listen_socket_, NULL, NULL);
+ if (client_socket == -1) {
+ if (errno == EINVAL || errno == EBADF) {
+ break;
+ }
+ ALOGW("%s error accepting socket: %s", __func__, strerror(errno));
+ continue;
+ }
+
+ /* When a new client connects, we have to send the btsnoop file header. This allows
+ a decoder to treat the session as a new, valid btsnoop file. */
+ ALOGI("client connected");
+ pthread_mutex_lock(&client_socket_lock_);
+ safe_close_(&client_socket_);
+ client_socket_ = client_socket;
+ send(client_socket_, "btsnoop\0\0\0\0\1\0\0\x3\xea", 16, 0);
+ pthread_mutex_unlock(&client_socket_lock_);
+ }
+
+cleanup:
+ safe_close_(&listen_socket_);
+ return NULL;
+}
+
+static void safe_close_(int *fd) {
+ assert(fd != NULL);
+ if (*fd != -1) {
+ close(*fd);
+ *fd = -1;
+ }
+}
diff --git a/hci/src/lpm.c b/hci/src/lpm.c
index b8cfdce..946b193 100644
--- a/hci/src/lpm.c
+++ b/hci/src/lpm.c
@@ -154,7 +154,7 @@
if (bt_lpm_cb.timer_created == TRUE)
{
ts.it_value.tv_sec = bt_lpm_cb.timeout_ms/1000;
- ts.it_value.tv_nsec = 1000*(bt_lpm_cb.timeout_ms%1000);
+ ts.it_value.tv_nsec = 1000000*(bt_lpm_cb.timeout_ms%1000);
ts.it_interval.tv_sec = 0;
ts.it_interval.tv_nsec = 0;
diff --git a/hci/src/userial.c b/hci/src/userial.c
index 5dc4f84..49e6c2c 100644
--- a/hci/src/userial.c
+++ b/hci/src/userial.c
@@ -26,25 +26,28 @@
#define LOG_TAG "bt_userial"
-#include <utils/Log.h>
-#include <pthread.h>
-#include <fcntl.h>
+#include <assert.h>
#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
#include <stdio.h>
+#include <sys/eventfd.h>
+#include <sys/prctl.h>
#include <sys/socket.h>
+#include <utils/Log.h>
+
#include "bt_hci_bdroid.h"
+#include "bt_utils.h"
+#include "bt_vendor_lib.h"
#include "userial.h"
#include "utils.h"
-#include "bt_vendor_lib.h"
-#include <sys/prctl.h>
-#include "bt_utils.h"
/******************************************************************************
** Constants & Macros
******************************************************************************/
#ifndef USERIAL_DBG
-#define USERIAL_DBG FALSE
+#define USERIAL_DBG TRUE
#endif
#if (USERIAL_DBG == TRUE)
@@ -53,17 +56,15 @@
#define USERIALDBG(param, ...) {}
#endif
-#ifndef ENABLE_USERIAL_TIMING_LOGS
-#define ENABLE_USERIAL_TIMING_LOGS FALSE
-#endif
-
#define MAX_SERIAL_PORT (USERIAL_PORT_3 + 1)
-#define READ_LIMIT (BTHC_USERIAL_READ_MEM_SIZE - BT_HC_HDR_SIZE)
+// The set of events one can send to the userial read thread.
+// Note that the values must be >= 0x8000000000000000 to guarantee delivery
+// of the message (see eventfd(2) for details on blocking behaviour).
enum {
- USERIAL_RX_EXIT,
- USERIAL_RX_FLOW_OFF,
- USERIAL_RX_FLOW_ON
+ USERIAL_RX_EXIT = 0x8000000000000000ULL,
+ USERIAL_RX_FLOW_OFF = 0x8000000000000001ULL,
+ USERIAL_RX_FLOW_ON = 0x8000000000000002ULL,
};
/******************************************************************************
@@ -92,33 +93,6 @@
static tUSERIAL_CB userial_cb;
static volatile uint8_t userial_running = 0;
-/******************************************************************************
-** Static functions
-******************************************************************************/
-
-#if defined(ENABLE_USERIAL_TIMING_LOGS) && (ENABLE_USERIAL_TIMING_LOGS==TRUE)
-
-static void log_userial_tx_timing(int len)
-{
- #define USEC_PER_SEC 1000000L
- static struct timespec prev = {0, 0};
- struct timespec now, diff;
- unsigned int diff_us = 0;
- unsigned int now_us = 0;
-
- clock_gettime(CLOCK_MONOTONIC, &now);
- now_us = now.tv_sec*USEC_PER_SEC + now.tv_nsec/1000;
- diff_us = (now.tv_sec - prev.tv_sec) * USEC_PER_SEC + (now.tv_nsec - prev.tv_nsec)/1000;
-
- ALOGW("[userial] ts %08d diff : %08d len %d", now_us, diff_us,
- len);
-
- prev = now;
-}
-
-#endif
-
-
/*****************************************************************************
** Socket signal functions to wake up userial_read_thread for termination
**
@@ -126,33 +100,39 @@
** - signal_fds[0]: join fd_set in select call of userial_read_thread
** - signal_fds[1]: trigger from userial_close
*****************************************************************************/
-static int signal_fds[2]={0,1};
+static int event_fd = -1;
static uint8_t rx_flow_on = TRUE;
-static inline int create_signal_fds(fd_set* set)
-{
- if(signal_fds[0]==0 && socketpair(AF_UNIX, SOCK_STREAM, 0, signal_fds)<0)
- {
- ALOGE("create_signal_sockets:socketpair failed, errno: %d", errno);
- return -1;
+
+static inline int add_event_fd(fd_set *set) {
+ if (event_fd == -1) {
+ event_fd = eventfd(0, 0);
+ if (event_fd == -1) {
+ ALOGE("%s unable to create event fd: %s", __func__, strerror(errno));
+ return -1;
+ }
}
- FD_SET(signal_fds[0], set);
- return signal_fds[0];
-}
-static inline int send_wakeup_signal(char sig_cmd)
-{
- return send(signal_fds[1], &sig_cmd, sizeof(sig_cmd), 0);
-}
-static inline char reset_signal()
-{
- char sig_recv = -1;
- recv(signal_fds[0], &sig_recv, sizeof(sig_recv), MSG_WAITALL);
- return sig_recv;
-}
-static inline int is_signaled(fd_set* set)
-{
- return FD_ISSET(signal_fds[0], set);
+
+ FD_SET(event_fd, set);
+ return event_fd;
}
+static inline void send_event(uint64_t event_id) {
+ assert(event_fd != -1);
+ eventfd_write(event_fd, event_id);
+}
+
+static inline uint64_t read_event() {
+ assert(event_fd != -1);
+
+ uint64_t value = 0;
+ eventfd_read(event_fd, &value);
+ return value;
+}
+
+static inline bool is_event_available(fd_set *set) {
+ assert(event_fd != -1);
+ return !!FD_ISSET(event_fd, set);
+}
/*******************************************************************************
**
@@ -170,7 +150,6 @@
{
fd_set input;
int n = 0, ret = -1;
- char reason = 0;
while (userial_running)
{
@@ -180,28 +159,26 @@
{
FD_SET(fd, &input);
}
- int fd_max = create_signal_fds(&input);
+ int fd_max = add_event_fd(&input);
fd_max = fd_max > fd ? fd_max : fd;
/* Do the select */
n = select(fd_max+1, &input, NULL, NULL, NULL);
- if(is_signaled(&input))
+ if(is_event_available(&input))
{
- reason = reset_signal();
- if (reason == USERIAL_RX_EXIT)
- {
- USERIALDBG("RX termination");
- return -1;
- }
- else if (reason == USERIAL_RX_FLOW_OFF)
- {
- USERIALDBG("RX flow OFF");
- rx_flow_on = FALSE;
- }
- else if (reason == USERIAL_RX_FLOW_ON)
- {
- USERIALDBG("RX flow ON");
- rx_flow_on = TRUE;
+ uint64_t event = read_event();
+ switch (event) {
+ case USERIAL_RX_FLOW_ON:
+ USERIALDBG("RX flow ON");
+ rx_flow_on = TRUE;
+ break;
+ case USERIAL_RX_FLOW_OFF:
+ USERIALDBG("RX flow OFF");
+ rx_flow_on = FALSE;
+ break;
+ case USERIAL_RX_EXIT:
+ USERIALDBG("RX termination");
+ return -1;
}
}
@@ -227,15 +204,6 @@
return ret;
}
-/*******************************************************************************
-**
-** Function userial_read_thread
-**
-** Description
-**
-** Returns void *
-**
-*******************************************************************************/
static void *userial_read_thread(void *arg)
{
int rx_length = 0;
@@ -255,8 +223,8 @@
{
if (bt_hc_cbacks)
{
- p_buf = (HC_BT_HDR *) bt_hc_cbacks->alloc( \
- BTHC_USERIAL_READ_MEM_SIZE);
+ p_buf = (HC_BT_HDR *) bt_hc_cbacks->alloc(
+ BT_HC_HDR_SIZE + HCI_MAX_FRAME_SIZE + 1); /* H4 HDR = 1 */
}
else
p_buf = NULL;
@@ -267,7 +235,7 @@
p_buf->layer_specific = 0;
p = (uint8_t *) (p_buf + 1);
- rx_length = select_read(userial_cb.fd, p, READ_LIMIT);
+ rx_length = select_read(userial_cb.fd, p, HCI_MAX_FRAME_SIZE + 1);
}
else
{
@@ -307,128 +275,61 @@
** Userial API Functions
*****************************************************************************/
-/*******************************************************************************
-**
-** Function userial_init
-**
-** Description Initializes the userial driver
-**
-** Returns TRUE/FALSE
-**
-*******************************************************************************/
-uint8_t userial_init(void)
+bool userial_init(void)
{
USERIALDBG("userial_init");
memset(&userial_cb, 0, sizeof(tUSERIAL_CB));
userial_cb.fd = -1;
- utils_queue_init(&(userial_cb.rx_q));
- return TRUE;
+ utils_queue_init(&userial_cb.rx_q);
+ return true;
}
+bool userial_open(userial_port_t port) {
+ if (port >= MAX_SERIAL_PORT) {
+ ALOGE("%s serial port %d > %d (max).", __func__, port, MAX_SERIAL_PORT);
+ return false;
+ }
-/*******************************************************************************
-**
-** Function userial_open
-**
-** Description Open Bluetooth device with the port ID
-**
-** Returns TRUE/FALSE
-**
-*******************************************************************************/
-uint8_t userial_open(uint8_t port)
-{
- struct sched_param param;
- int policy, result;
- pthread_attr_t thread_attr;
- int fd_array[CH_MAX];
+ if (!bt_vnd_if) {
+ ALOGE("%s no vendor interface, cannot open serial port.", __func__);
+ return false;
+ }
- USERIALDBG("userial_open(port:%d)", port);
-
- if (userial_running)
- {
- /* Userial is open; close it first */
+ if (userial_running) {
userial_close();
utils_delay(50);
}
- if (port >= MAX_SERIAL_PORT)
- {
- ALOGE("Port > MAX_SERIAL_PORT");
- return FALSE;
+ // Call in to the vendor-specific library to open the serial port.
+ int fd_array[CH_MAX];
+ int num_ports = bt_vnd_if->op(BT_VND_OP_USERIAL_OPEN, &fd_array);
+
+ if (num_ports > 1) {
+ ALOGE("%s opened wrong number of ports: got %d, expected 1.", __func__, num_ports);
+ goto error;
}
- /* Calling vendor-specific part */
- if (bt_vnd_if)
- {
- result = bt_vnd_if->op(BT_VND_OP_USERIAL_OPEN, &fd_array);
-
- if (result != 1)
- {
- ALOGE("userial_open: wrong numbers of open fd in vendor lib [%d]!",
- result);
- ALOGE("userial_open: HCI UART expects only one open fd");
- bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL);
- return FALSE;
- }
-
- userial_cb.fd = fd_array[0];
+ userial_cb.fd = fd_array[0];
+ if (userial_cb.fd == -1) {
+ ALOGE("%s unable to open serial port.", __func__);
+ goto error;
}
- else
- {
- ALOGE("userial_open: missing vendor lib interface !!!");
- ALOGE("userial_open: unable to open UART port");
- return FALSE;
- }
-
- if (userial_cb.fd == -1)
- {
- ALOGE("userial_open: failed to open UART port");
- return FALSE;
- }
-
- USERIALDBG( "fd = %d", userial_cb.fd);
userial_cb.port = port;
- pthread_attr_init(&thread_attr);
-
- if (pthread_create(&(userial_cb.read_thread), &thread_attr, \
- userial_read_thread, NULL) != 0 )
- {
- ALOGE("pthread_create failed!");
- return FALSE;
+ if (pthread_create(&userial_cb.read_thread, NULL, userial_read_thread, NULL)) {
+ ALOGE("%s unable to spawn read thread.", __func__);
+ goto error;
}
- if(pthread_getschedparam(userial_cb.read_thread, &policy, ¶m)==0)
- {
- policy = BTHC_LINUX_BASE_POLICY;
-#if (BTHC_LINUX_BASE_POLICY != SCHED_NORMAL)
- param.sched_priority = BTHC_USERIAL_READ_THREAD_PRIORITY;
-#else
- param.sched_priority = 0;
-#endif
- result = pthread_setschedparam(userial_cb.read_thread, policy, ¶m);
- if (result != 0)
- {
- ALOGW("userial_open: pthread_setschedparam failed (%s)", \
- strerror(result));
- }
- }
+ return true;
- return TRUE;
+error:
+ bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL);
+ return false;
}
-/*******************************************************************************
-**
-** Function userial_read
-**
-** Description Read data from the userial port
-**
-** Returns Number of bytes actually read from the userial port and
-** copied into p_data. This may be less than len.
-**
-*******************************************************************************/
-uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len)
+uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len)
{
uint16_t total_len = 0;
uint16_t copy_len = 0;
@@ -473,99 +374,58 @@
return total_len;
}
-/*******************************************************************************
-**
-** Function userial_write
-**
-** Description Write data to the userial port
-**
-** Returns Number of bytes actually written to the userial port. This
-** may be less than len.
-**
-*******************************************************************************/
-uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len)
-{
- int ret, total = 0;
+uint16_t userial_write(uint16_t msg_id, const uint8_t *p_data, uint16_t len) {
UNUSED(msg_id);
- while(len != 0)
- {
-#if defined(ENABLE_USERIAL_TIMING_LOGS) && (ENABLE_USERIAL_TIMING_LOGS==TRUE)
- log_userial_tx_timing(len);
-#endif
- ret = write(userial_cb.fd, p_data+total, len);
- total += ret;
- len -= ret;
- }
-
- return ((uint16_t)total);
-}
-
-/*******************************************************************************
-**
-** Function userial_close
-**
-** Description Close the userial port
-**
-** Returns None
-**
-*******************************************************************************/
-void userial_close(void)
-{
- int result;
- TRANSAC p_buf;
-
- USERIALDBG("userial_close(fd:%d)", userial_cb.fd);
-
- if (userial_running)
- send_wakeup_signal(USERIAL_RX_EXIT);
-
- if ((result=pthread_join(userial_cb.read_thread, NULL)) < 0)
- ALOGE( "pthread_join() FAILED result:%d", result);
-
- /* Calling vendor-specific part */
- if (bt_vnd_if)
- bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL);
-
- userial_cb.fd = -1;
-
- if (bt_hc_cbacks)
- {
- while ((p_buf = utils_dequeue (&(userial_cb.rx_q))) != NULL)
- {
- bt_hc_cbacks->dealloc(p_buf, (char *) ((HC_BT_HDR *)p_buf+1));
+ uint16_t total = 0;
+ while (len) {
+ ssize_t ret = write(userial_cb.fd, p_data + total, len);
+ switch (ret) {
+ case -1:
+ ALOGE("%s error writing to serial port: %s", __func__, strerror(errno));
+ return total;
+ case 0: // don't loop forever in case write returns 0.
+ return total;
+ default:
+ total += ret;
+ len -= ret;
+ break;
}
}
+
+ return total;
}
-/*******************************************************************************
-**
-** Function userial_ioctl
-**
-** Description ioctl inteface
-**
-** Returns None
-**
-*******************************************************************************/
-void userial_ioctl(userial_ioctl_op_t op, void *p_data)
-{
- UNUSED(p_data);
+void userial_close(void) {
+ assert(bt_vnd_if != NULL);
+ assert(bt_hc_cbacks != NULL);
- switch(op)
- {
- case USERIAL_OP_RXFLOW_ON:
- if (userial_running)
- send_wakeup_signal(USERIAL_RX_FLOW_ON);
- break;
-
- case USERIAL_OP_RXFLOW_OFF:
- if (userial_running)
- send_wakeup_signal(USERIAL_RX_FLOW_OFF);
- break;
-
- case USERIAL_OP_INIT:
- default:
- break;
+ // Join the reader thread if it's still running.
+ if (userial_running) {
+ send_event(USERIAL_RX_EXIT);
+ int result = pthread_join(userial_cb.read_thread, NULL);
+ if (result)
+ ALOGE("%s failed to join reader thread: %d", __func__, result);
}
+
+ // Ask the vendor-specific library to close the serial port.
+ bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL);
+
+ // Free all buffers still waiting in the RX queue.
+ // TODO: use list data structure and clean this up.
+ void *buf;
+ while ((buf = utils_dequeue(&userial_cb.rx_q)) != NULL)
+ bt_hc_cbacks->dealloc(buf, (char *) ((HC_BT_HDR *)buf + 1));
+
+ userial_cb.fd = -1;
}
+void userial_pause_reading(void) {
+ if (userial_running)
+ send_event(USERIAL_RX_FLOW_OFF);
+}
+
+void userial_resume_reading(void) {
+ if (userial_running)
+ send_event(USERIAL_RX_FLOW_ON);
+}
diff --git a/hci/src/userial_mct.c b/hci/src/userial_mct.c
index d7554cc..ecb25e3 100644
--- a/hci/src/userial_mct.c
+++ b/hci/src/userial_mct.c
@@ -226,10 +226,8 @@
**
** Description Initializes the userial driver
**
-** Returns TRUE/FALSE
-**
*******************************************************************************/
-uint8_t userial_init(void)
+bool userial_init(void)
{
int idx;
@@ -238,7 +236,7 @@
for (idx=0; idx < CH_MAX; idx++)
userial_cb.fd[idx] = -1;
utils_queue_init(&(userial_cb.rx_q));
- return TRUE;
+ return true;
}
@@ -248,10 +246,8 @@
**
** Description Open Bluetooth device with the port ID
**
-** Returns TRUE/FALSE
-**
*******************************************************************************/
-uint8_t userial_open(uint8_t port)
+bool userial_open(userial_port_t port)
{
struct sched_param param;
int policy, result;
@@ -269,7 +265,7 @@
if (port >= MAX_SERIAL_PORT)
{
ALOGE("Port > MAX_SERIAL_PORT");
- return FALSE;
+ return false;
}
/* Calling vendor-specific part */
@@ -283,14 +279,14 @@
result);
ALOGE("userial_open: HCI MCT expects 2 or 4 open file descriptors");
bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL);
- return FALSE;
+ return false;
}
}
else
{
ALOGE("userial_open: missing vendor lib interface !!!");
ALOGE("userial_open: unable to open BT transport");
- return FALSE;
+ return false;
}
ALOGI("CMD=%d, EVT=%d, ACL_Out=%d, ACL_In=%d", \
@@ -302,7 +298,7 @@
{
ALOGE("userial_open: failed to open BT transport");
bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL);
- return FALSE;
+ return false;
}
userial_cb.port = port;
@@ -315,7 +311,7 @@
{
ALOGE("pthread_create failed!");
bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL);
- return FALSE;
+ return false;
}
if(pthread_getschedparam(userial_cb.read_thread, &policy, ¶m)==0)
@@ -334,7 +330,7 @@
}
}
- return TRUE;
+ return true;
}
/*******************************************************************************
@@ -347,7 +343,7 @@
** copied into p_data. This may be less than len.
**
*******************************************************************************/
-uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len)
+uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len)
{
int ret = -1;
int ch_idx = (msg_id == MSG_HC_TO_STACK_HCI_EVT) ? CH_EVT : CH_ACL_IN;
@@ -369,7 +365,7 @@
** may be less than len.
**
*******************************************************************************/
-uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len)
+uint16_t userial_write(uint16_t msg_id, const uint8_t *p_data, uint16_t len)
{
int ret, total = 0;
int ch_idx = (msg_id == MSG_STACK_TO_HC_HCI_CMD) ? CH_CMD : CH_ACL_OUT;
@@ -390,8 +386,6 @@
**
** Description Close the userial port
**
-** Returns None
-**
*******************************************************************************/
void userial_close(void)
{
@@ -413,32 +407,12 @@
userial_cb.fd[idx] = -1;
}
-/*******************************************************************************
-**
-** Function userial_ioctl
-**
-** Description ioctl inteface
-**
-** Returns None
-**
-*******************************************************************************/
-void userial_ioctl(userial_ioctl_op_t op, void *p_data)
-{
- switch(op)
- {
- case USERIAL_OP_RXFLOW_ON:
- if (userial_running)
- send_wakeup_signal(USERIAL_RX_FLOW_ON);
- break;
-
- case USERIAL_OP_RXFLOW_OFF:
- if (userial_running)
- send_wakeup_signal(USERIAL_RX_FLOW_OFF);
- break;
-
- case USERIAL_OP_INIT:
- default:
- break;
- }
+void userial_pause_reading(void) {
+ if (userial_running)
+ send_wakeup_signal(USERIAL_RX_FLOW_OFF);
}
+void userial_resume_reading(void) {
+ if (userial_running)
+ send_wakeup_signal(USERIAL_RX_FLOW_ON);
+}
diff --git a/include/bt_target.h b/include/bt_target.h
index e6b3bb5..e91b626 100644
--- a/include/bt_target.h
+++ b/include/bt_target.h
@@ -1,5 +1,6 @@
/******************************************************************************
*
+ * Copyright (c) 2014 The Android Open Source Project
* Copyright (C) 1999-2012 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,6 +34,9 @@
#define BTIF_HFAG_SERVICE_NAME ("Handsfree Gateway")
#endif
+#ifndef BTIF_HF_CLIENT_SERVICE_NAME
+#define BTIF_HF_CLIENT_SERVICE_NAME ("Handsfree")
+#endif
#ifdef BUILDCFG
@@ -163,6 +167,8 @@
#define BTA_GATT_INCLUDED TRUE
#endif
+/* defined BTA_AVK_INCLUDED in Android.mk file based on target selected*/
+
#ifndef BTA_DISABLE_DELAY
#define BTA_DISABLE_DELAY 200 /* in milliseconds */
#endif
@@ -589,6 +595,11 @@
#define GATT_DB_POOL_ID GKI_POOL_ID_8
#endif
+/* GATT Data sending buffer pool ID, use default ACL pool for fix channel data */
+#ifndef GATT_BUF_POOL_ID
+#define GATT_BUF_POOL_ID HCI_ACL_POOL_ID
+#endif
+
/******************************************************************************
**
** Lower Layer Interface
@@ -1291,13 +1302,20 @@
#define BLE_ANDROID_CONTROLLER_SCAN_FILTER TRUE
#endif
-
#ifndef LOCAL_BLE_CONTROLLER_ID
#define LOCAL_BLE_CONTROLLER_ID (1)
#endif
#ifndef BLE_PRIVACY_SPT
-#define BLE_PRIVACY_SPT TRUE
+#define BLE_PRIVACY_SPT FALSE
+#endif
+
+#ifndef BLE_MULTI_ADV_INCLUDED
+#define BLE_MULTI_ADV_INCLUDED TRUE
+#endif
+
+#ifndef BLE_VND_INCLUDED
+#define BLE_VND_INCLUDED TRUE
#endif
/******************************************************************************
@@ -3436,6 +3454,10 @@
#define AVRC_ADV_CTRL_INCLUDED TRUE
#endif
+#ifndef AVRC_CTLR_INCLUDED
+#define AVRC_CTLR_INCLUDED TRUE
+#endif
+
/******************************************************************************
**
** MCAP
diff --git a/include/bt_trace.h b/include/bt_trace.h
index ae1b1ae..6f3687c 100644
--- a/include/bt_trace.h
+++ b/include/bt_trace.h
@@ -197,17 +197,6 @@
/* Prototype for message logging function. */
EXPORT_API extern void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...);
-extern void LogMsg_0 (UINT32 trace_set_mask, const char *p_str);
-extern void LogMsg_1 (UINT32 trace_set_mask, const char *fmt_str, UINT32 p1);
-extern void LogMsg_2 (UINT32 trace_set_mask, const char *fmt_str, UINT32 p1, UINT32 p2);
-extern void LogMsg_3 (UINT32 trace_set_mask, const char *fmt_str, UINT32 p1, UINT32 p2,
- UINT32 p3);
-extern void LogMsg_4 (UINT32 trace_set_mask, const char *fmt_str, UINT32 p1, UINT32 p2,
- UINT32 p3, UINT32 p4);
-extern void LogMsg_5 (UINT32 trace_set_mask, const char *fmt_str, UINT32 p1, UINT32 p2,
- UINT32 p3, UINT32 p4, UINT32 p5);
-extern void LogMsg_6 (UINT32 trace_set_mask, const char *fmt_str, UINT32 p1, UINT32 p2,
- UINT32 p3, UINT32 p4, UINT32 p5, UINT32 p6);
/* Prototype for stack tracing function. */
EXPORT_API extern void BTTRC_StackTrace0(tBTTRC_LAYER_ID layer_id,
@@ -627,1000 +616,923 @@
#if (BT_USE_TRACES == TRUE)
-#define BT_TRACE_0(l,t,m) LogMsg_0((TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t)),(m))
-#define BT_TRACE_1(l,t,m,p1) LogMsg_1(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINT32)(p1))
-#define BT_TRACE_2(l,t,m,p1,p2) LogMsg_2(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINT32)(p1), \
- (UINT32)(p2))
-#define BT_TRACE_3(l,t,m,p1,p2,p3) LogMsg_3(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINT32)(p1), \
- (UINT32)(p2),(UINT32)(p3))
-#define BT_TRACE_4(l,t,m,p1,p2,p3,p4) LogMsg_4(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINT32)(p1), \
- (UINT32)(p2),(UINT32)(p3),(UINT32)(p4))
-#define BT_TRACE_5(l,t,m,p1,p2,p3,p4,p5) LogMsg_5(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINT32)(p1), \
- (UINT32)(p2),(UINT32)(p3),(UINT32)(p4), \
- (UINT32)(p5))
-#define BT_TRACE_6(l,t,m,p1,p2,p3,p4,p5,p6) LogMsg_6(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINT32)(p1), \
- (UINT32)(p2),(UINT32)(p3),(UINT32)(p4), \
- (UINT32)(p5),(UINT32)(p6))
-
-#define BT_ERROR_TRACE_0(l,m) LogMsg_0(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | TRACE_TYPE_ERROR,(m))
-#define BT_ERROR_TRACE_1(l,m,p1) LogMsg_1(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | TRACE_TYPE_ERROR,(m),(UINT32)(p1))
-#define BT_ERROR_TRACE_2(l,m,p1,p2) LogMsg_2(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | TRACE_TYPE_ERROR,(m),(UINT32)(p1),(UINT32)(p2))
-#define BT_ERROR_TRACE_3(l,m,p1,p2,p3) LogMsg_3(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | TRACE_TYPE_ERROR,(m),(UINT32)(p1),(UINT32)(p2),(UINT32)(p3))
+#define BT_TRACE(l,t,...) LogMsg((TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t)), ##__VA_ARGS__)
+#define BT_ERROR_TRACE(l,...) LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | TRACE_TYPE_ERROR, ##__VA_ARGS__)
/* Define tracing for the HCI unit
*/
-#define HCI_TRACE_ERROR0(m) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_HCI, TRACE_TYPE_ERROR, m);}
-#define HCI_TRACE_ERROR1(m,p1) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_HCI, TRACE_TYPE_ERROR, m,p1);}
-#define HCI_TRACE_ERROR2(m,p1,p2) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_HCI, TRACE_TYPE_ERROR, m,p1,p2);}
-#define HCI_TRACE_ERROR3(m,p1,p2,p3) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_HCI, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define HCI_TRACE_ERROR4(m,p1,p2,p3,p4) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_HCI, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define HCI_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_HCI, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define HCI_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_HCI, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define HCI_TRACE_WARNING0(m) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, m);}
-#define HCI_TRACE_WARNING1(m,p1) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, m,p1);}
-#define HCI_TRACE_WARNING2(m,p1,p2) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, m,p1,p2);}
-#define HCI_TRACE_WARNING3(m,p1,p2,p3) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define HCI_TRACE_WARNING4(m,p1,p2,p3,p4) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define HCI_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define HCI_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-
-#define HCI_TRACE_EVENT0(m) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_HCI, TRACE_TYPE_EVENT, m);}
-#define HCI_TRACE_EVENT1(m,p1) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_HCI, TRACE_TYPE_EVENT, m, p1);}
-#define HCI_TRACE_EVENT2(m,p1,p2) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_HCI, TRACE_TYPE_EVENT, m,p1,p2);}
-#define HCI_TRACE_EVENT3(m,p1,p2,p3) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_HCI, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define HCI_TRACE_EVENT4(m,p1,p2,p3,p4) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_HCI, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define HCI_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_HCI, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define HCI_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_HCI, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-
-#define HCI_TRACE_DEBUG0(m) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_HCI, TRACE_TYPE_DEBUG, m);}
-#define HCI_TRACE_DEBUG1(m,p1) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_HCI, TRACE_TYPE_DEBUG, m,p1);}
-#define HCI_TRACE_DEBUG2(m,p1,p2) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_HCI, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define HCI_TRACE_DEBUG3(m,p1,p2,p3) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_HCI, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define HCI_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_HCI, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define HCI_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_HCI, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define HCI_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_HCI, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define HCI_TRACE_ERROR(...) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
+#define HCI_TRACE_WARNING(...) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
+#define HCI_TRACE_EVENT(...) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
+#define HCI_TRACE_DEBUG(...) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
/* Define tracing for BTM
*/
-#define BTM_TRACE_ERROR0(m) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_BTM, TRACE_TYPE_ERROR, m);}
-#define BTM_TRACE_ERROR1(m,p1) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_BTM, TRACE_TYPE_ERROR, m,p1);}
-#define BTM_TRACE_ERROR2(m,p1,p2) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_BTM, TRACE_TYPE_ERROR, m,p1,p2);}
-#define BTM_TRACE_ERROR3(m,p1,p2,p3) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_BTM, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define BTM_TRACE_ERROR4(m,p1,p2,p3,p4) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_BTM, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define BTM_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_BTM, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define BTM_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_BTM, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-
-#define BTM_TRACE_WARNING0(m) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_BTM, TRACE_TYPE_WARNING, m);}
-#define BTM_TRACE_WARNING1(m,p1) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_BTM, TRACE_TYPE_WARNING, m,p1);}
-#define BTM_TRACE_WARNING2(m,p1,p2) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_BTM, TRACE_TYPE_WARNING, m,p1,p2);}
-#define BTM_TRACE_WARNING3(m,p1,p2,p3) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_BTM, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define BTM_TRACE_WARNING4(m,p1,p2,p3,p4) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_BTM, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define BTM_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_BTM, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define BTM_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_BTM, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-
-#define BTM_TRACE_API0(m) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_BTM, TRACE_TYPE_API, m);}
-#define BTM_TRACE_API1(m,p1) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_BTM, TRACE_TYPE_API, m, p1);}
-#define BTM_TRACE_API2(m,p1,p2) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_BTM, TRACE_TYPE_API, m,p1,p2);}
-#define BTM_TRACE_API3(m,p1,p2,p3) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_BTM, TRACE_TYPE_API, m,p1,p2,p3);}
-#define BTM_TRACE_API4(m,p1,p2,p3,p4) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_BTM, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define BTM_TRACE_API5(m,p1,p2,p3,p4,p5) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_BTM, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define BTM_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_BTM, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-
-#define BTM_TRACE_EVENT0(m) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_BTM, TRACE_TYPE_EVENT, m);}
-#define BTM_TRACE_EVENT1(m,p1) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_BTM, TRACE_TYPE_EVENT, m, p1);}
-#define BTM_TRACE_EVENT2(m,p1,p2) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_BTM, TRACE_TYPE_EVENT, m,p1,p2);}
-#define BTM_TRACE_EVENT3(m,p1,p2,p3) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_BTM, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define BTM_TRACE_EVENT4(m,p1,p2,p3,p4) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_BTM, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define BTM_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_BTM, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define BTM_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_BTM, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-
-#define BTM_TRACE_DEBUG0(m) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, m);}
-#define BTM_TRACE_DEBUG1(m,p1) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, m,p1);}
-#define BTM_TRACE_DEBUG2(m,p1,p2) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define BTM_TRACE_DEBUG3(m,p1,p2,p3) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define BTM_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define BTM_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define BTM_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define BTM_TRACE_ERROR(...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
+#define BTM_TRACE_WARNING(...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
+#define BTM_TRACE_API(...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_API, ##__VA_ARGS__);}
+#define BTM_TRACE_EVENT(...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
+#define BTM_TRACE_DEBUG(...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
/* Define tracing for the L2CAP unit
*/
-#define L2CAP_TRACE_ERROR0(m) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, m);}
-#define L2CAP_TRACE_ERROR1(m,p1) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, m,p1);}
-#define L2CAP_TRACE_ERROR2(m,p1,p2) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define L2CAP_TRACE_ERROR3(m,p1,p2,p3) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define L2CAP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define L2CAP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define L2CAP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define L2CAP_TRACE_ERROR0(m) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, m);}
+#define L2CAP_TRACE_ERROR1(m,p1) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, m,p1);}
+#define L2CAP_TRACE_ERROR2(m,p1,p2) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define L2CAP_TRACE_ERROR3(m,p1,p2,p3) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define L2CAP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define L2CAP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define L2CAP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define L2CAP_TRACE_WARNING0(m) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, m);}
-#define L2CAP_TRACE_WARNING1(m,p1) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, m,p1);}
-#define L2CAP_TRACE_WARNING2(m,p1,p2) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define L2CAP_TRACE_WARNING3(m,p1,p2,p3) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define L2CAP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define L2CAP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define L2CAP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define L2CAP_TRACE_WARNING0(m) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, m);}
+#define L2CAP_TRACE_WARNING1(m,p1) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, m,p1);}
+#define L2CAP_TRACE_WARNING2(m,p1,p2) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define L2CAP_TRACE_WARNING3(m,p1,p2,p3) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define L2CAP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define L2CAP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define L2CAP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define L2CAP_TRACE_API0(m) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_L2CAP, TRACE_TYPE_API, m);}
-#define L2CAP_TRACE_API1(m,p1) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_L2CAP, TRACE_TYPE_API, m,p1);}
-#define L2CAP_TRACE_API2(m,p1,p2) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_L2CAP, TRACE_TYPE_API, m,p1,p2);}
-#define L2CAP_TRACE_API3(m,p1,p2,p3) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_L2CAP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define L2CAP_TRACE_API4(m,p1,p2,p3,p4) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_L2CAP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define L2CAP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_L2CAP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define L2CAP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_L2CAP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define L2CAP_TRACE_API0(m) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_API, m);}
+#define L2CAP_TRACE_API1(m,p1) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_API, m,p1);}
+#define L2CAP_TRACE_API2(m,p1,p2) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_API, m,p1,p2);}
+#define L2CAP_TRACE_API3(m,p1,p2,p3) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define L2CAP_TRACE_API4(m,p1,p2,p3,p4) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define L2CAP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define L2CAP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define L2CAP_TRACE_EVENT0(m) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, m);}
-#define L2CAP_TRACE_EVENT1(m,p1) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, m, p1);}
-#define L2CAP_TRACE_EVENT2(m,p1,p2) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define L2CAP_TRACE_EVENT3(m,p1,p2,p3) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define L2CAP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define L2CAP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define L2CAP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define L2CAP_TRACE_EVENT0(m) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, m);}
+#define L2CAP_TRACE_EVENT1(m,p1) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, m, p1);}
+#define L2CAP_TRACE_EVENT2(m,p1,p2) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define L2CAP_TRACE_EVENT3(m,p1,p2,p3) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define L2CAP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define L2CAP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define L2CAP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define L2CAP_TRACE_DEBUG0(m) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, m);}
-#define L2CAP_TRACE_DEBUG1(m,p1) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, m,p1);}
-#define L2CAP_TRACE_DEBUG2(m,p1,p2) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define L2CAP_TRACE_DEBUG3(m,p1,p2,p3) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define L2CAP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define L2CAP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define L2CAP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define L2CAP_TRACE_DEBUG0(m) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, m);}
+#define L2CAP_TRACE_DEBUG1(m,p1) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, m,p1);}
+#define L2CAP_TRACE_DEBUG2(m,p1,p2) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define L2CAP_TRACE_DEBUG3(m,p1,p2,p3) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define L2CAP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define L2CAP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define L2CAP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the LLCP unit
*/
-#define LLCP_TRACE_ERROR0(m) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m);}
-#define LLCP_TRACE_ERROR1(m,p1) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m,p1);}
-#define LLCP_TRACE_ERROR2(m,p1,p2) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define LLCP_TRACE_ERROR3(m,p1,p2,p3) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define LLCP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define LLCP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define LLCP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define LLCP_TRACE_ERROR0(m) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m);}
+#define LLCP_TRACE_ERROR1(m,p1) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m,p1);}
+#define LLCP_TRACE_ERROR2(m,p1,p2) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define LLCP_TRACE_ERROR3(m,p1,p2,p3) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define LLCP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define LLCP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define LLCP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define LLCP_TRACE_WARNING0(m) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m);}
-#define LLCP_TRACE_WARNING1(m,p1) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m,p1);}
-#define LLCP_TRACE_WARNING2(m,p1,p2) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define LLCP_TRACE_WARNING3(m,p1,p2,p3) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define LLCP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define LLCP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define LLCP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define LLCP_TRACE_WARNING0(m) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m);}
+#define LLCP_TRACE_WARNING1(m,p1) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m,p1);}
+#define LLCP_TRACE_WARNING2(m,p1,p2) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define LLCP_TRACE_WARNING3(m,p1,p2,p3) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define LLCP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define LLCP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define LLCP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define LLCP_TRACE_API0(m) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_LLCP, TRACE_TYPE_API, m);}
-#define LLCP_TRACE_API1(m,p1) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_LLCP, TRACE_TYPE_API, m,p1);}
-#define LLCP_TRACE_API2(m,p1,p2) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_LLCP, TRACE_TYPE_API, m,p1,p2);}
-#define LLCP_TRACE_API3(m,p1,p2,p3) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_LLCP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define LLCP_TRACE_API4(m,p1,p2,p3,p4) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_LLCP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define LLCP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_LLCP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define LLCP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_LLCP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define LLCP_TRACE_API0(m) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_API, m);}
+#define LLCP_TRACE_API1(m,p1) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_API, m,p1);}
+#define LLCP_TRACE_API2(m,p1,p2) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_API, m,p1,p2);}
+#define LLCP_TRACE_API3(m,p1,p2,p3) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define LLCP_TRACE_API4(m,p1,p2,p3,p4) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define LLCP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define LLCP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define LLCP_TRACE_EVENT0(m) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m);}
-#define LLCP_TRACE_EVENT1(m,p1) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m, p1);}
-#define LLCP_TRACE_EVENT2(m,p1,p2) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define LLCP_TRACE_EVENT3(m,p1,p2,p3) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define LLCP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define LLCP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define LLCP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define LLCP_TRACE_EVENT0(m) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m);}
+#define LLCP_TRACE_EVENT1(m,p1) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m, p1);}
+#define LLCP_TRACE_EVENT2(m,p1,p2) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define LLCP_TRACE_EVENT3(m,p1,p2,p3) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define LLCP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define LLCP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define LLCP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define LLCP_TRACE_DEBUG0(m) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m);}
-#define LLCP_TRACE_DEBUG1(m,p1) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m,p1);}
-#define LLCP_TRACE_DEBUG2(m,p1,p2) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define LLCP_TRACE_DEBUG3(m,p1,p2,p3) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define LLCP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define LLCP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define LLCP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define LLCP_TRACE_DEBUG0(m) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m);}
+#define LLCP_TRACE_DEBUG1(m,p1) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m,p1);}
+#define LLCP_TRACE_DEBUG2(m,p1,p2) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define LLCP_TRACE_DEBUG3(m,p1,p2,p3) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define LLCP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define LLCP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define LLCP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the SDP unit
*/
-#define SDP_TRACE_ERROR0(m) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, m);}
-#define SDP_TRACE_ERROR1(m,p1) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, m,p1);}
-#define SDP_TRACE_ERROR2(m,p1,p2) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define SDP_TRACE_ERROR3(m,p1,p2,p3) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define SDP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define SDP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define SDP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define SDP_TRACE_ERROR0(m) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, m);}
+#define SDP_TRACE_ERROR1(m,p1) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, m,p1);}
+#define SDP_TRACE_ERROR2(m,p1,p2) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define SDP_TRACE_ERROR3(m,p1,p2,p3) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define SDP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define SDP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define SDP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define SDP_TRACE_WARNING0(m) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, m);}
-#define SDP_TRACE_WARNING1(m,p1) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, m,p1);}
-#define SDP_TRACE_WARNING2(m,p1,p2) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define SDP_TRACE_WARNING3(m,p1,p2,p3) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define SDP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define SDP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define SDP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define SDP_TRACE_WARNING0(m) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, m);}
+#define SDP_TRACE_WARNING1(m,p1) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, m,p1);}
+#define SDP_TRACE_WARNING2(m,p1,p2) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define SDP_TRACE_WARNING3(m,p1,p2,p3) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define SDP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define SDP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define SDP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define SDP_TRACE_API0(m) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_SDP, TRACE_TYPE_API, m);}
-#define SDP_TRACE_API1(m,p1) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_SDP, TRACE_TYPE_API, m,p1);}
-#define SDP_TRACE_API2(m,p1,p2) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_SDP, TRACE_TYPE_API, m,p1,p2);}
-#define SDP_TRACE_API3(m,p1,p2,p3) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_SDP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define SDP_TRACE_API4(m,p1,p2,p3,p4) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_SDP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define SDP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_SDP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define SDP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_SDP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define SDP_TRACE_API0(m) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_API, m);}
+#define SDP_TRACE_API1(m,p1) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_API, m,p1);}
+#define SDP_TRACE_API2(m,p1,p2) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_API, m,p1,p2);}
+#define SDP_TRACE_API3(m,p1,p2,p3) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define SDP_TRACE_API4(m,p1,p2,p3,p4) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define SDP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define SDP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define SDP_TRACE_EVENT0(m) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, m);}
-#define SDP_TRACE_EVENT1(m,p1) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, m, p1);}
-#define SDP_TRACE_EVENT2(m,p1,p2) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define SDP_TRACE_EVENT3(m,p1,p2,p3) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define SDP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define SDP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define SDP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define SDP_TRACE_EVENT0(m) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, m);}
+#define SDP_TRACE_EVENT1(m,p1) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, m, p1);}
+#define SDP_TRACE_EVENT2(m,p1,p2) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define SDP_TRACE_EVENT3(m,p1,p2,p3) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define SDP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define SDP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define SDP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define SDP_TRACE_DEBUG0(m) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, m);}
-#define SDP_TRACE_DEBUG1(m,p1) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, m,p1);}
-#define SDP_TRACE_DEBUG2(m,p1,p2) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define SDP_TRACE_DEBUG3(m,p1,p2,p3) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define SDP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define SDP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define SDP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define SDP_TRACE_DEBUG0(m) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, m);}
+#define SDP_TRACE_DEBUG1(m,p1) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, m,p1);}
+#define SDP_TRACE_DEBUG2(m,p1,p2) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define SDP_TRACE_DEBUG3(m,p1,p2,p3) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define SDP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define SDP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define SDP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the RFCOMM unit
*/
-#define RFCOMM_TRACE_ERROR0(m) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, m);}
-#define RFCOMM_TRACE_ERROR1(m,p1) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, m,p1);}
-#define RFCOMM_TRACE_ERROR2(m,p1,p2) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, m,p1,p2);}
-#define RFCOMM_TRACE_ERROR3(m,p1,p2,p3) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define RFCOMM_TRACE_ERROR4(m,p1,p2,p3,p4) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define RFCOMM_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define RFCOMM_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define RFCOMM_TRACE_ERROR0(m) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, m);}
+#define RFCOMM_TRACE_ERROR1(m,p1) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, m,p1);}
+#define RFCOMM_TRACE_ERROR2(m,p1,p2) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, m,p1,p2);}
+#define RFCOMM_TRACE_ERROR3(m,p1,p2,p3) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define RFCOMM_TRACE_ERROR4(m,p1,p2,p3,p4) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define RFCOMM_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define RFCOMM_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define RFCOMM_TRACE_WARNING0(m) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, m);}
-#define RFCOMM_TRACE_WARNING1(m,p1) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, m,p1);}
-#define RFCOMM_TRACE_WARNING2(m,p1,p2) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, m,p1,p2);}
-#define RFCOMM_TRACE_WARNING3(m,p1,p2,p3) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define RFCOMM_TRACE_WARNING4(m,p1,p2,p3,p4) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define RFCOMM_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define RFCOMM_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define RFCOMM_TRACE_WARNING0(m) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, m);}
+#define RFCOMM_TRACE_WARNING1(m,p1) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, m,p1);}
+#define RFCOMM_TRACE_WARNING2(m,p1,p2) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, m,p1,p2);}
+#define RFCOMM_TRACE_WARNING3(m,p1,p2,p3) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define RFCOMM_TRACE_WARNING4(m,p1,p2,p3,p4) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define RFCOMM_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define RFCOMM_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define RFCOMM_TRACE_API0(m) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, m);}
-#define RFCOMM_TRACE_API1(m,p1) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, m,p1);}
-#define RFCOMM_TRACE_API2(m,p1,p2) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, m,p1,p2);}
-#define RFCOMM_TRACE_API3(m,p1,p2,p3) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, m,p1,p2,p3);}
-#define RFCOMM_TRACE_API4(m,p1,p2,p3,p4) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define RFCOMM_TRACE_API5(m,p1,p2,p3,p4,p5) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define RFCOMM_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define RFCOMM_TRACE_API0(m) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, m);}
+#define RFCOMM_TRACE_API1(m,p1) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, m,p1);}
+#define RFCOMM_TRACE_API2(m,p1,p2) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, m,p1,p2);}
+#define RFCOMM_TRACE_API3(m,p1,p2,p3) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, m,p1,p2,p3);}
+#define RFCOMM_TRACE_API4(m,p1,p2,p3,p4) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define RFCOMM_TRACE_API5(m,p1,p2,p3,p4,p5) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define RFCOMM_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define RFCOMM_TRACE_EVENT0(m) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, m);}
-#define RFCOMM_TRACE_EVENT1(m,p1) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, m, p1);}
-#define RFCOMM_TRACE_EVENT2(m,p1,p2) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, m,p1,p2);}
-#define RFCOMM_TRACE_EVENT3(m,p1,p2,p3) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define RFCOMM_TRACE_EVENT4(m,p1,p2,p3,p4) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define RFCOMM_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define RFCOMM_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define RFCOMM_TRACE_EVENT0(m) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, m);}
+#define RFCOMM_TRACE_EVENT1(m,p1) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, m, p1);}
+#define RFCOMM_TRACE_EVENT2(m,p1,p2) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, m,p1,p2);}
+#define RFCOMM_TRACE_EVENT3(m,p1,p2,p3) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define RFCOMM_TRACE_EVENT4(m,p1,p2,p3,p4) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define RFCOMM_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define RFCOMM_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define RFCOMM_TRACE_DEBUG0(m) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, m);}
-#define RFCOMM_TRACE_DEBUG1(m,p1) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, m,p1);}
-#define RFCOMM_TRACE_DEBUG2(m,p1,p2) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define RFCOMM_TRACE_DEBUG3(m,p1,p2,p3) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define RFCOMM_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define RFCOMM_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define RFCOMM_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define RFCOMM_TRACE_DEBUG0(m) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, m);}
+#define RFCOMM_TRACE_DEBUG1(m,p1) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, m,p1);}
+#define RFCOMM_TRACE_DEBUG2(m,p1,p2) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define RFCOMM_TRACE_DEBUG3(m,p1,p2,p3) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define RFCOMM_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define RFCOMM_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define RFCOMM_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for Serial Port Profile
*/
-#define SPP_TRACE_ERROR0(m) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_SPP, TRACE_TYPE_ERROR, m);}
-#define SPP_TRACE_ERROR1(m,p1) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_SPP, TRACE_TYPE_ERROR, m,p1);}
-#define SPP_TRACE_ERROR2(m,p1,p2) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_SPP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define SPP_TRACE_ERROR3(m,p1,p2,p3) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_SPP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define SPP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_SPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define SPP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_SPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define SPP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_SPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define SPP_TRACE_ERROR0(m) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_ERROR, m);}
+#define SPP_TRACE_ERROR1(m,p1) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_ERROR, m,p1);}
+#define SPP_TRACE_ERROR2(m,p1,p2) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define SPP_TRACE_ERROR3(m,p1,p2,p3) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define SPP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define SPP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define SPP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define SPP_TRACE_WARNING0(m) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_SPP, TRACE_TYPE_WARNING, m);}
-#define SPP_TRACE_WARNING1(m,p1) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_SPP, TRACE_TYPE_WARNING, m,p1);}
-#define SPP_TRACE_WARNING2(m,p1,p2) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_SPP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define SPP_TRACE_WARNING3(m,p1,p2,p3) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_SPP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define SPP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_SPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define SPP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_SPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define SPP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_SPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define SPP_TRACE_WARNING0(m) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_WARNING, m);}
+#define SPP_TRACE_WARNING1(m,p1) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_WARNING, m,p1);}
+#define SPP_TRACE_WARNING2(m,p1,p2) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define SPP_TRACE_WARNING3(m,p1,p2,p3) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define SPP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define SPP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define SPP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define SPP_TRACE_EVENT0(m) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_SPP, TRACE_TYPE_EVENT, m);}
-#define SPP_TRACE_EVENT1(m,p1) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_SPP, TRACE_TYPE_EVENT, m, p1);}
-#define SPP_TRACE_EVENT2(m,p1,p2) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_SPP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define SPP_TRACE_EVENT3(m,p1,p2,p3) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_SPP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define SPP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_SPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define SPP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_SPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define SPP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_SPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define SPP_TRACE_EVENT0(m) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_EVENT, m);}
+#define SPP_TRACE_EVENT1(m,p1) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_EVENT, m, p1);}
+#define SPP_TRACE_EVENT2(m,p1,p2) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define SPP_TRACE_EVENT3(m,p1,p2,p3) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define SPP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define SPP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define SPP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define SPP_TRACE_API0(m) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_SPP, TRACE_TYPE_API, m);}
-#define SPP_TRACE_API1(m,p1) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_SPP, TRACE_TYPE_API, m, p1);}
-#define SPP_TRACE_API2(m,p1,p2) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_SPP, TRACE_TYPE_API, m,p1,p2);}
-#define SPP_TRACE_API3(m,p1,p2,p3) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_SPP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define SPP_TRACE_API4(m,p1,p2,p3,p4) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_SPP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define SPP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_SPP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define SPP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_SPP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define SPP_TRACE_API0(m) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_API, m);}
+#define SPP_TRACE_API1(m,p1) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_API, m, p1);}
+#define SPP_TRACE_API2(m,p1,p2) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_API, m,p1,p2);}
+#define SPP_TRACE_API3(m,p1,p2,p3) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define SPP_TRACE_API4(m,p1,p2,p3,p4) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define SPP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define SPP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define SPP_TRACE_DEBUG0(m) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_SPP, TRACE_TYPE_DEBUG, m);}
-#define SPP_TRACE_DEBUG1(m,p1) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_SPP, TRACE_TYPE_DEBUG, m,p1);}
-#define SPP_TRACE_DEBUG2(m,p1,p2) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_SPP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define SPP_TRACE_DEBUG3(m,p1,p2,p3) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_SPP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define SPP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_SPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define SPP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_SPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define SPP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_SPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define SPP_TRACE_DEBUG0(m) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_DEBUG, m);}
+#define SPP_TRACE_DEBUG1(m,p1) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_DEBUG, m,p1);}
+#define SPP_TRACE_DEBUG2(m,p1,p2) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define SPP_TRACE_DEBUG3(m,p1,p2,p3) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define SPP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define SPP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define SPP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (spp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* Generic Access Profile traces */
-#define GAP_TRACE_ERROR0(m) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, m);}
-#define GAP_TRACE_ERROR1(m,p1) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, m, p1);}
-#define GAP_TRACE_ERROR2(m,p1,p2) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define GAP_TRACE_ERROR3(m,p1,p2,p3) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define GAP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define GAP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define GAP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define GAP_TRACE_ERROR0(m) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, m);}
+#define GAP_TRACE_ERROR1(m,p1) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, m, p1);}
+#define GAP_TRACE_ERROR2(m,p1,p2) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define GAP_TRACE_ERROR3(m,p1,p2,p3) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define GAP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define GAP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define GAP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define GAP_TRACE_EVENT0(m) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, m);}
-#define GAP_TRACE_EVENT1(m,p1) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, m, p1);}
-#define GAP_TRACE_EVENT2(m,p1,p2) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define GAP_TRACE_EVENT3(m,p1,p2,p3) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define GAP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define GAP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define GAP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define GAP_TRACE_EVENT0(m) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, m);}
+#define GAP_TRACE_EVENT1(m,p1) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, m, p1);}
+#define GAP_TRACE_EVENT2(m,p1,p2) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define GAP_TRACE_EVENT3(m,p1,p2,p3) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define GAP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define GAP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define GAP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define GAP_TRACE_API0(m) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_GAP, TRACE_TYPE_API, m);}
-#define GAP_TRACE_API1(m,p1) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_GAP, TRACE_TYPE_API, m, p1);}
-#define GAP_TRACE_API2(m,p1,p2) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_GAP, TRACE_TYPE_API, m,p1,p2);}
-#define GAP_TRACE_API3(m,p1,p2,p3) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_GAP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define GAP_TRACE_API4(m,p1,p2,p3,p4) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_GAP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define GAP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_GAP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define GAP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_GAP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define GAP_TRACE_API0(m) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_API, m);}
+#define GAP_TRACE_API1(m,p1) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_API, m, p1);}
+#define GAP_TRACE_API2(m,p1,p2) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_API, m,p1,p2);}
+#define GAP_TRACE_API3(m,p1,p2,p3) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define GAP_TRACE_API4(m,p1,p2,p3,p4) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define GAP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define GAP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define GAP_TRACE_WARNING0(m) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, m);}
-#define GAP_TRACE_WARNING1(m,p1) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, m, p1);}
-#define GAP_TRACE_WARNING2(m,p1,p2) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define GAP_TRACE_WARNING3(m,p1,p2,p3) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define GAP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define GAP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define GAP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define GAP_TRACE_WARNING0(m) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, m);}
+#define GAP_TRACE_WARNING1(m,p1) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, m, p1);}
+#define GAP_TRACE_WARNING2(m,p1,p2) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define GAP_TRACE_WARNING3(m,p1,p2,p3) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define GAP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define GAP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define GAP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for OBX
*/
-#define OBX_TRACE_ERROR0(m) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_OBEX, TRACE_TYPE_ERROR, m);}
-#define OBX_TRACE_ERROR1(m,p1) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_OBEX, TRACE_TYPE_ERROR, m,p1);}
-#define OBX_TRACE_ERROR2(m,p1,p2) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_OBEX, TRACE_TYPE_ERROR, m,p1,p2);}
-#define OBX_TRACE_ERROR3(m,p1,p2,p3) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_OBEX, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define OBX_TRACE_ERROR4(m,p1,p2,p3,p4) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_OBEX, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define OBX_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_OBEX, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define OBX_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_OBEX, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define OBX_TRACE_ERROR0(m) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_ERROR, m);}
+#define OBX_TRACE_ERROR1(m,p1) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_ERROR, m,p1);}
+#define OBX_TRACE_ERROR2(m,p1,p2) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_ERROR, m,p1,p2);}
+#define OBX_TRACE_ERROR3(m,p1,p2,p3) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define OBX_TRACE_ERROR4(m,p1,p2,p3,p4) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define OBX_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define OBX_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define OBX_TRACE_WARNING0(m) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_OBEX, TRACE_TYPE_WARNING, m);}
-#define OBX_TRACE_WARNING1(m,p1) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_OBEX, TRACE_TYPE_WARNING, m,p1);}
-#define OBX_TRACE_WARNING2(m,p1,p2) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_OBEX, TRACE_TYPE_WARNING, m,p1,p2);}
-#define OBX_TRACE_WARNING3(m,p1,p2,p3) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_OBEX, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define OBX_TRACE_WARNING4(m,p1,p2,p3,p4) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_OBEX, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define OBX_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_OBEX, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define OBX_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_OBEX, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define OBX_TRACE_WARNING0(m) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_WARNING, m);}
+#define OBX_TRACE_WARNING1(m,p1) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_WARNING, m,p1);}
+#define OBX_TRACE_WARNING2(m,p1,p2) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_WARNING, m,p1,p2);}
+#define OBX_TRACE_WARNING3(m,p1,p2,p3) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define OBX_TRACE_WARNING4(m,p1,p2,p3,p4) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define OBX_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define OBX_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define OBX_TRACE_EVENT0(m) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_OBEX, TRACE_TYPE_EVENT, m);}
-#define OBX_TRACE_EVENT1(m,p1) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_OBEX, TRACE_TYPE_EVENT, m, p1);}
-#define OBX_TRACE_EVENT2(m,p1,p2) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_OBEX, TRACE_TYPE_EVENT, m,p1,p2);}
-#define OBX_TRACE_EVENT3(m,p1,p2,p3) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_OBEX, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define OBX_TRACE_EVENT4(m,p1,p2,p3,p4) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_OBEX, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define OBX_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_OBEX, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define OBX_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_OBEX, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define OBX_TRACE_EVENT0(m) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_EVENT, m);}
+#define OBX_TRACE_EVENT1(m,p1) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_EVENT, m, p1);}
+#define OBX_TRACE_EVENT2(m,p1,p2) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_EVENT, m,p1,p2);}
+#define OBX_TRACE_EVENT3(m,p1,p2,p3) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define OBX_TRACE_EVENT4(m,p1,p2,p3,p4) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define OBX_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define OBX_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define OBX_TRACE_DEBUG0(m) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_OBEX, TRACE_TYPE_DEBUG, m);}
-#define OBX_TRACE_DEBUG1(m,p1) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_OBEX, TRACE_TYPE_DEBUG, m,p1);}
-#define OBX_TRACE_DEBUG2(m,p1,p2) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_OBEX, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define OBX_TRACE_DEBUG3(m,p1,p2,p3) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_OBEX, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define OBX_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_OBEX, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define OBX_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_OBEX, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define OBX_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_OBEX, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define OBX_TRACE_DEBUG0(m) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_DEBUG, m);}
+#define OBX_TRACE_DEBUG1(m,p1) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_DEBUG, m,p1);}
+#define OBX_TRACE_DEBUG2(m,p1,p2) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define OBX_TRACE_DEBUG3(m,p1,p2,p3) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define OBX_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define OBX_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define OBX_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#define OBX_TRACE_API0(m) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_OBEX, TRACE_TYPE_API, m);}
-#define OBX_TRACE_API1(m,p1) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_OBEX, TRACE_TYPE_API, m, p1);}
-#define OBX_TRACE_API2(m,p1,p2) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_OBEX, TRACE_TYPE_API, m,p1,p2);}
-#define OBX_TRACE_API3(m,p1,p2,p3) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_OBEX, TRACE_TYPE_API, m,p1,p2,p3);}
-#define OBX_TRACE_API4(m,p1,p2,p3,p4) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_OBEX, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define OBX_TRACE_API5(m,p1,p2,p3,p4,p5) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_OBEX, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define OBX_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_OBEX, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define OBX_TRACE_API0(m) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_API, m);}
+#define OBX_TRACE_API1(m,p1) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_API, m, p1);}
+#define OBX_TRACE_API2(m,p1,p2) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_API, m,p1,p2);}
+#define OBX_TRACE_API3(m,p1,p2,p3) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_API, m,p1,p2,p3);}
+#define OBX_TRACE_API4(m,p1,p2,p3,p4) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define OBX_TRACE_API5(m,p1,p2,p3,p4,p5) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define OBX_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (obx_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_OBEX, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for OBEX application profiles
*/
-#define GOEP_TRACE_ERROR0(m) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_GOEP, TRACE_TYPE_ERROR, m);}
-#define GOEP_TRACE_ERROR1(m,p1) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_GOEP, TRACE_TYPE_ERROR, m,p1);}
-#define GOEP_TRACE_ERROR2(m,p1,p2) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_GOEP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define GOEP_TRACE_ERROR3(m,p1,p2,p3) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_GOEP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define GOEP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_GOEP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define GOEP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_GOEP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define GOEP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_GOEP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define GOEP_TRACE_ERROR0(m) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_ERROR, m);}
+#define GOEP_TRACE_ERROR1(m,p1) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_ERROR, m,p1);}
+#define GOEP_TRACE_ERROR2(m,p1,p2) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define GOEP_TRACE_ERROR3(m,p1,p2,p3) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define GOEP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define GOEP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define GOEP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define GOEP_TRACE_WARNING0(m) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_GOEP, TRACE_TYPE_WARNING, m);}
-#define GOEP_TRACE_WARNING1(m,p1) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_GOEP, TRACE_TYPE_WARNING, m,p1);}
-#define GOEP_TRACE_WARNING2(m,p1,p2) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_GOEP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define GOEP_TRACE_WARNING3(m,p1,p2,p3) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_GOEP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define GOEP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_GOEP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define GOEP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_GOEP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define GOEP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_GOEP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define GOEP_TRACE_WARNING0(m) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_WARNING, m);}
+#define GOEP_TRACE_WARNING1(m,p1) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_WARNING, m,p1);}
+#define GOEP_TRACE_WARNING2(m,p1,p2) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define GOEP_TRACE_WARNING3(m,p1,p2,p3) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define GOEP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define GOEP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define GOEP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define GOEP_TRACE_EVENT0(m) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_GOEP, TRACE_TYPE_EVENT, m);}
-#define GOEP_TRACE_EVENT1(m,p1) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_GOEP, TRACE_TYPE_EVENT, m, p1);}
-#define GOEP_TRACE_EVENT2(m,p1,p2) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_GOEP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define GOEP_TRACE_EVENT3(m,p1,p2,p3) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_GOEP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define GOEP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_GOEP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define GOEP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_GOEP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define GOEP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_GOEP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define GOEP_TRACE_EVENT0(m) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_EVENT, m);}
+#define GOEP_TRACE_EVENT1(m,p1) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_EVENT, m, p1);}
+#define GOEP_TRACE_EVENT2(m,p1,p2) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define GOEP_TRACE_EVENT3(m,p1,p2,p3) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define GOEP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define GOEP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define GOEP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define GOEP_TRACE_DEBUG0(m) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m);}
-#define GOEP_TRACE_DEBUG1(m,p1) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1);}
-#define GOEP_TRACE_DEBUG2(m,p1,p2) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define GOEP_TRACE_DEBUG3(m,p1,p2,p3) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define GOEP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define GOEP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define GOEP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define GOEP_TRACE_DEBUG0(m) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m);}
+#define GOEP_TRACE_DEBUG1(m,p1) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1);}
+#define GOEP_TRACE_DEBUG2(m,p1,p2) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define GOEP_TRACE_DEBUG3(m,p1,p2,p3) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define GOEP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define GOEP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define GOEP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#define GOEP_TRACE_API0(m) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_GOEP, TRACE_TYPE_API, m);}
-#define GOEP_TRACE_API1(m,p1) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_GOEP, TRACE_TYPE_API, m, p1);}
-#define GOEP_TRACE_API2(m,p1,p2) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_GOEP, TRACE_TYPE_API, m,p1,p2);}
-#define GOEP_TRACE_API3(m,p1,p2,p3) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_GOEP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define GOEP_TRACE_API4(m,p1,p2,p3,p4) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_GOEP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define GOEP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_GOEP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define GOEP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_GOEP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define GOEP_TRACE_API0(m) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_API, m);}
+#define GOEP_TRACE_API1(m,p1) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_API, m, p1);}
+#define GOEP_TRACE_API2(m,p1,p2) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_API, m,p1,p2);}
+#define GOEP_TRACE_API3(m,p1,p2,p3) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define GOEP_TRACE_API4(m,p1,p2,p3,p4) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define GOEP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define GOEP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (goep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GOEP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the BPP profile
*/
-#define BPP_TRACE_ERROR0(m) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_BPP, TRACE_TYPE_ERROR, m);}
-#define BPP_TRACE_ERROR1(m,p1) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_BPP, TRACE_TYPE_ERROR, m,p1);}
-#define BPP_TRACE_ERROR2(m,p1,p2) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_BPP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define BPP_TRACE_ERROR3(m,p1,p2,p3) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_BPP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define BPP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_BPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define BPP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_BPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define BPP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_BPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define BPP_TRACE_ERROR0(m) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_ERROR, m);}
+#define BPP_TRACE_ERROR1(m,p1) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_ERROR, m,p1);}
+#define BPP_TRACE_ERROR2(m,p1,p2) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define BPP_TRACE_ERROR3(m,p1,p2,p3) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define BPP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define BPP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define BPP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define BPP_TRACE_WARNING0(m) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_BPP, TRACE_TYPE_WARNING, m);}
-#define BPP_TRACE_WARNING1(m,p1) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_BPP, TRACE_TYPE_WARNING, m,p1);}
-#define BPP_TRACE_WARNING2(m,p1,p2) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_BPP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define BPP_TRACE_WARNING3(m,p1,p2,p3) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_BPP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define BPP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_BPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define BPP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_BPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define BPP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_BPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define BPP_TRACE_WARNING0(m) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_WARNING, m);}
+#define BPP_TRACE_WARNING1(m,p1) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_WARNING, m,p1);}
+#define BPP_TRACE_WARNING2(m,p1,p2) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define BPP_TRACE_WARNING3(m,p1,p2,p3) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define BPP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define BPP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define BPP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define BPP_TRACE_EVENT0(m) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_BPP, TRACE_TYPE_EVENT, m);}
-#define BPP_TRACE_EVENT1(m,p1) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_BPP, TRACE_TYPE_EVENT, m, p1);}
-#define BPP_TRACE_EVENT2(m,p1,p2) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_BPP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define BPP_TRACE_EVENT3(m,p1,p2,p3) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_BPP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define BPP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_BPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define BPP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_BPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define BPP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_BPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define BPP_TRACE_EVENT0(m) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_EVENT, m);}
+#define BPP_TRACE_EVENT1(m,p1) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_EVENT, m, p1);}
+#define BPP_TRACE_EVENT2(m,p1,p2) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define BPP_TRACE_EVENT3(m,p1,p2,p3) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define BPP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define BPP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define BPP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define BPP_TRACE_DEBUG0(m) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_BPP, TRACE_TYPE_DEBUG, m);}
-#define BPP_TRACE_DEBUG1(m,p1) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_BPP, TRACE_TYPE_DEBUG, m,p1);}
-#define BPP_TRACE_DEBUG2(m,p1,p2) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_BPP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define BPP_TRACE_DEBUG3(m,p1,p2,p3) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_BPP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define BPP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_BPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define BPP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_BPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define BPP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_BPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define BPP_TRACE_DEBUG0(m) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_DEBUG, m);}
+#define BPP_TRACE_DEBUG1(m,p1) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_DEBUG, m,p1);}
+#define BPP_TRACE_DEBUG2(m,p1,p2) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define BPP_TRACE_DEBUG3(m,p1,p2,p3) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define BPP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define BPP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define BPP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#define BPP_TRACE_API0(m) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_BPP, TRACE_TYPE_API, m);}
-#define BPP_TRACE_API1(m,p1) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_BPP, TRACE_TYPE_API, m, p1);}
-#define BPP_TRACE_API2(m,p1,p2) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_BPP, TRACE_TYPE_API, m,p1,p2);}
-#define BPP_TRACE_API3(m,p1,p2,p3) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_BPP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define BPP_TRACE_API4(m,p1,p2,p3,p4) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_BPP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define BPP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_BPP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define BPP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_BPP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define BPP_TRACE_API0(m) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_API, m);}
+#define BPP_TRACE_API1(m,p1) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_API, m, p1);}
+#define BPP_TRACE_API2(m,p1,p2) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_API, m,p1,p2);}
+#define BPP_TRACE_API3(m,p1,p2,p3) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define BPP_TRACE_API4(m,p1,p2,p3,p4) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define BPP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define BPP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (bpp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BPP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the BIP profile
*/
-#define BIP_TRACE_ERROR0(m) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_BIP, TRACE_TYPE_ERROR, m);}
-#define BIP_TRACE_ERROR1(m,p1) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_BIP, TRACE_TYPE_ERROR, m,p1);}
-#define BIP_TRACE_ERROR2(m,p1,p2) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_BIP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define BIP_TRACE_ERROR3(m,p1,p2,p3) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_BIP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define BIP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_BIP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define BIP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_BIP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define BIP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_BIP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define BIP_TRACE_ERROR0(m) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_ERROR, m);}
+#define BIP_TRACE_ERROR1(m,p1) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_ERROR, m,p1);}
+#define BIP_TRACE_ERROR2(m,p1,p2) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define BIP_TRACE_ERROR3(m,p1,p2,p3) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define BIP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define BIP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define BIP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define BIP_TRACE_WARNING0(m) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_BIP, TRACE_TYPE_WARNING, m);}
-#define BIP_TRACE_WARNING1(m,p1) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_BIP, TRACE_TYPE_WARNING, m,p1);}
-#define BIP_TRACE_WARNING2(m,p1,p2) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_BIP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define BIP_TRACE_WARNING3(m,p1,p2,p3) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_BIP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define BIP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_BIP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define BIP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_BIP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define BIP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_BIP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define BIP_TRACE_WARNING0(m) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_WARNING, m);}
+#define BIP_TRACE_WARNING1(m,p1) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_WARNING, m,p1);}
+#define BIP_TRACE_WARNING2(m,p1,p2) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define BIP_TRACE_WARNING3(m,p1,p2,p3) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define BIP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define BIP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define BIP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define BIP_TRACE_EVENT0(m) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_BIP, TRACE_TYPE_EVENT, m);}
-#define BIP_TRACE_EVENT1(m,p1) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_BIP, TRACE_TYPE_EVENT, m, p1);}
-#define BIP_TRACE_EVENT2(m,p1,p2) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_BIP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define BIP_TRACE_EVENT3(m,p1,p2,p3) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_BIP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define BIP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_BIP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define BIP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_BIP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define BIP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_BIP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define BIP_TRACE_EVENT0(m) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_EVENT, m);}
+#define BIP_TRACE_EVENT1(m,p1) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_EVENT, m, p1);}
+#define BIP_TRACE_EVENT2(m,p1,p2) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define BIP_TRACE_EVENT3(m,p1,p2,p3) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define BIP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define BIP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define BIP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define BIP_TRACE_DEBUG0(m) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_BIP, TRACE_TYPE_DEBUG, m);}
-#define BIP_TRACE_DEBUG1(m,p1) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_BIP, TRACE_TYPE_DEBUG, m,p1);}
-#define BIP_TRACE_DEBUG2(m,p1,p2) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_BIP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define BIP_TRACE_DEBUG3(m,p1,p2,p3) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_BIP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define BIP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_BIP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define BIP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_BIP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define BIP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_BIP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define BIP_TRACE_DEBUG0(m) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_DEBUG, m);}
+#define BIP_TRACE_DEBUG1(m,p1) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_DEBUG, m,p1);}
+#define BIP_TRACE_DEBUG2(m,p1,p2) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define BIP_TRACE_DEBUG3(m,p1,p2,p3) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define BIP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define BIP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define BIP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#define BIP_TRACE_API0(m) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_BIP, TRACE_TYPE_API, m);}
-#define BIP_TRACE_API1(m,p1) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_BIP, TRACE_TYPE_API, m, p1);}
-#define BIP_TRACE_API2(m,p1,p2) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_BIP, TRACE_TYPE_API, m,p1,p2);}
-#define BIP_TRACE_API3(m,p1,p2,p3) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_BIP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define BIP_TRACE_API4(m,p1,p2,p3,p4) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_BIP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define BIP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_BIP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define BIP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_BIP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define BIP_TRACE_API0(m) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_API, m);}
+#define BIP_TRACE_API1(m,p1) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_API, m, p1);}
+#define BIP_TRACE_API2(m,p1,p2) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_API, m,p1,p2);}
+#define BIP_TRACE_API3(m,p1,p2,p3) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define BIP_TRACE_API4(m,p1,p2,p3,p4) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define BIP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define BIP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (bip_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BIP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for TCS
*/
-#define TCS_TRACE_ERROR0(m) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_TCS, TRACE_TYPE_ERROR, m);}
-#define TCS_TRACE_ERROR1(m,p1) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_TCS, TRACE_TYPE_ERROR, m,p1);}
-#define TCS_TRACE_ERROR2(m,p1,p2) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_TCS, TRACE_TYPE_ERROR, m,p1,p2);}
-#define TCS_TRACE_ERROR3(m,p1,p2,p3) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_TCS, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define TCS_TRACE_ERROR4(m,p1,p2,p3,p4) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_TCS, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define TCS_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_TCS, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define TCS_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_TCS, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define TCS_TRACE_ERROR0(m) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_ERROR, m);}
+#define TCS_TRACE_ERROR1(m,p1) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_ERROR, m,p1);}
+#define TCS_TRACE_ERROR2(m,p1,p2) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_ERROR, m,p1,p2);}
+#define TCS_TRACE_ERROR3(m,p1,p2,p3) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define TCS_TRACE_ERROR4(m,p1,p2,p3,p4) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define TCS_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define TCS_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define TCS_TRACE_WARNING0(m) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_TCS, TRACE_TYPE_WARNING, m);}
-#define TCS_TRACE_WARNING1(m,p1) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_TCS, TRACE_TYPE_WARNING, m,p1);}
-#define TCS_TRACE_WARNING2(m,p1,p2) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_TCS, TRACE_TYPE_WARNING, m,p1,p2);}
-#define TCS_TRACE_WARNING3(m,p1,p2,p3) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_TCS, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define TCS_TRACE_WARNING4(m,p1,p2,p3,p4) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_TCS, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define TCS_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_TCS, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define TCS_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_TCS, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define TCS_TRACE_WARNING0(m) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_WARNING, m);}
+#define TCS_TRACE_WARNING1(m,p1) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_WARNING, m,p1);}
+#define TCS_TRACE_WARNING2(m,p1,p2) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_WARNING, m,p1,p2);}
+#define TCS_TRACE_WARNING3(m,p1,p2,p3) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define TCS_TRACE_WARNING4(m,p1,p2,p3,p4) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define TCS_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define TCS_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define TCS_TRACE_EVENT0(m) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_TCS, TRACE_TYPE_EVENT, m);}
-#define TCS_TRACE_EVENT1(m,p1) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_TCS, TRACE_TYPE_EVENT, m, p1);}
-#define TCS_TRACE_EVENT2(m,p1,p2) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_TCS, TRACE_TYPE_EVENT, m,p1,p2);}
-#define TCS_TRACE_EVENT3(m,p1,p2,p3) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_TCS, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define TCS_TRACE_EVENT4(m,p1,p2,p3,p4) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_TCS, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define TCS_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_TCS, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define TCS_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_TCS, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define TCS_TRACE_EVENT0(m) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_EVENT, m);}
+#define TCS_TRACE_EVENT1(m,p1) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_EVENT, m, p1);}
+#define TCS_TRACE_EVENT2(m,p1,p2) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_EVENT, m,p1,p2);}
+#define TCS_TRACE_EVENT3(m,p1,p2,p3) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define TCS_TRACE_EVENT4(m,p1,p2,p3,p4) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define TCS_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define TCS_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define TCS_TRACE_DEBUG0(m) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_TCS, TRACE_TYPE_DEBUG, m);}
-#define TCS_TRACE_DEBUG1(m,p1) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_TCS, TRACE_TYPE_DEBUG, m,p1);}
-#define TCS_TRACE_DEBUG2(m,p1,p2) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_TCS, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define TCS_TRACE_DEBUG3(m,p1,p2,p3) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_TCS, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define TCS_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_TCS, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define TCS_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_TCS, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define TCS_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_TCS, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define TCS_TRACE_DEBUG0(m) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_DEBUG, m);}
+#define TCS_TRACE_DEBUG1(m,p1) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_DEBUG, m,p1);}
+#define TCS_TRACE_DEBUG2(m,p1,p2) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define TCS_TRACE_DEBUG3(m,p1,p2,p3) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define TCS_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define TCS_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define TCS_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#define TCS_TRACE_API0(m) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_TCS, TRACE_TYPE_API, m);}
-#define TCS_TRACE_API1(m,p1) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_TCS, TRACE_TYPE_API, m, p1);}
-#define TCS_TRACE_API2(m,p1,p2) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_TCS, TRACE_TYPE_API, m,p1,p2);}
-#define TCS_TRACE_API3(m,p1,p2,p3) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_TCS, TRACE_TYPE_API, m,p1,p2,p3);}
-#define TCS_TRACE_API4(m,p1,p2,p3,p4) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_TCS, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define TCS_TRACE_API5(m,p1,p2,p3,p4,p5) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_TCS, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define TCS_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_TCS, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define TCS_TRACE_API0(m) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_API, m);}
+#define TCS_TRACE_API1(m,p1) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_API, m, p1);}
+#define TCS_TRACE_API2(m,p1,p2) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_API, m,p1,p2);}
+#define TCS_TRACE_API3(m,p1,p2,p3) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_API, m,p1,p2,p3);}
+#define TCS_TRACE_API4(m,p1,p2,p3,p4) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define TCS_TRACE_API5(m,p1,p2,p3,p4,p5) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define TCS_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (tcs_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_TCS, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for ICP
*/
-#define ICP_TRACE_ERROR0(m) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_ICP, TRACE_TYPE_ERROR, m);}
-#define ICP_TRACE_ERROR1(m,p1) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_ICP, TRACE_TYPE_ERROR, m,p1);}
-#define ICP_TRACE_ERROR2(m,p1,p2) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_ICP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define ICP_TRACE_ERROR3(m,p1,p2,p3) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_ICP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define ICP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_ICP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define ICP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_ICP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define ICP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_ICP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define ICP_TRACE_ERROR0(m) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_ERROR, m);}
+#define ICP_TRACE_ERROR1(m,p1) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_ERROR, m,p1);}
+#define ICP_TRACE_ERROR2(m,p1,p2) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define ICP_TRACE_ERROR3(m,p1,p2,p3) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define ICP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define ICP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define ICP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define ICP_TRACE_WARNING0(m) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_ICP, TRACE_TYPE_WARNING, m);}
-#define ICP_TRACE_WARNING1(m,p1) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_ICP, TRACE_TYPE_WARNING, m,p1);}
-#define ICP_TRACE_WARNING2(m,p1,p2) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_ICP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define ICP_TRACE_WARNING3(m,p1,p2,p3) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_ICP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define ICP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_ICP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define ICP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_ICP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define ICP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_ICP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define ICP_TRACE_WARNING0(m) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_WARNING, m);}
+#define ICP_TRACE_WARNING1(m,p1) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_WARNING, m,p1);}
+#define ICP_TRACE_WARNING2(m,p1,p2) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define ICP_TRACE_WARNING3(m,p1,p2,p3) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define ICP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define ICP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define ICP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define ICP_TRACE_EVENT0(m) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_ICP, TRACE_TYPE_EVENT, m);}
-#define ICP_TRACE_EVENT1(m,p1) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_ICP, TRACE_TYPE_EVENT, m, p1);}
-#define ICP_TRACE_EVENT2(m,p1,p2) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_ICP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define ICP_TRACE_EVENT3(m,p1,p2,p3) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_ICP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define ICP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_ICP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define ICP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_ICP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define ICP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_ICP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define ICP_TRACE_EVENT0(m) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_EVENT, m);}
+#define ICP_TRACE_EVENT1(m,p1) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_EVENT, m, p1);}
+#define ICP_TRACE_EVENT2(m,p1,p2) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define ICP_TRACE_EVENT3(m,p1,p2,p3) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define ICP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define ICP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define ICP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define ICP_TRACE_DEBUG0(m) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_ICP, TRACE_TYPE_DEBUG, m);}
-#define ICP_TRACE_DEBUG1(m,p1) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_ICP, TRACE_TYPE_DEBUG, m,p1);}
-#define ICP_TRACE_DEBUG2(m,p1,p2) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_ICP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define ICP_TRACE_DEBUG3(m,p1,p2,p3) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_ICP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define ICP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_ICP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define ICP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_ICP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define ICP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_ICP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define ICP_TRACE_DEBUG0(m) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_DEBUG, m);}
+#define ICP_TRACE_DEBUG1(m,p1) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_DEBUG, m,p1);}
+#define ICP_TRACE_DEBUG2(m,p1,p2) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define ICP_TRACE_DEBUG3(m,p1,p2,p3) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define ICP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define ICP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define ICP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#define ICP_TRACE_API0(m) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_ICP, TRACE_TYPE_API, m);}
-#define ICP_TRACE_API1(m,p1) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_ICP, TRACE_TYPE_API, m, p1);}
-#define ICP_TRACE_API2(m,p1,p2) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_ICP, TRACE_TYPE_API, m,p1,p2);}
-#define ICP_TRACE_API3(m,p1,p2,p3) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_ICP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define ICP_TRACE_API4(m,p1,p2,p3,p4) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_ICP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define ICP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_ICP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define ICP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_ICP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define ICP_TRACE_API0(m) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_API, m);}
+#define ICP_TRACE_API1(m,p1) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_API, m, p1);}
+#define ICP_TRACE_API2(m,p1,p2) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_API, m,p1,p2);}
+#define ICP_TRACE_API3(m,p1,p2,p3) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define ICP_TRACE_API4(m,p1,p2,p3,p4) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define ICP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define ICP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (icp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ICP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
/* CTP */
-#define CTP_TRACE_ERROR0(m) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_CTP, TRACE_TYPE_ERROR, m);}
-#define CTP_TRACE_ERROR1(m,p1) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_CTP, TRACE_TYPE_ERROR, m,p1);}
-#define CTP_TRACE_ERROR2(m,p1,p2) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_CTP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define CTP_TRACE_ERROR3(m,p1,p2,p3) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_CTP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define CTP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_CTP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define CTP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_CTP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define CTP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_CTP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define CTP_TRACE_ERROR0(m) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_ERROR, m);}
+#define CTP_TRACE_ERROR1(m,p1) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_ERROR, m,p1);}
+#define CTP_TRACE_ERROR2(m,p1,p2) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define CTP_TRACE_ERROR3(m,p1,p2,p3) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define CTP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define CTP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define CTP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define CTP_TRACE_WARNING0(m) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_CTP, TRACE_TYPE_WARNING, m);}
-#define CTP_TRACE_WARNING1(m,p1) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_CTP, TRACE_TYPE_WARNING, m,p1);}
-#define CTP_TRACE_WARNING2(m,p1,p2) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_CTP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define CTP_TRACE_WARNING3(m,p1,p2,p3) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_CTP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define CTP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_CTP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define CTP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_CTP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define CTP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_CTP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define CTP_TRACE_WARNING0(m) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_WARNING, m);}
+#define CTP_TRACE_WARNING1(m,p1) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_WARNING, m,p1);}
+#define CTP_TRACE_WARNING2(m,p1,p2) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define CTP_TRACE_WARNING3(m,p1,p2,p3) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define CTP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define CTP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define CTP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define CTP_TRACE_EVENT0(m) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_CTP, TRACE_TYPE_EVENT, m);}
-#define CTP_TRACE_EVENT1(m,p1) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_CTP, TRACE_TYPE_EVENT, m, p1);}
-#define CTP_TRACE_EVENT2(m,p1,p2) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_CTP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define CTP_TRACE_EVENT3(m,p1,p2,p3) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_CTP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define CTP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_CTP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define CTP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_CTP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define CTP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_CTP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define CTP_TRACE_EVENT0(m) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_EVENT, m);}
+#define CTP_TRACE_EVENT1(m,p1) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_EVENT, m, p1);}
+#define CTP_TRACE_EVENT2(m,p1,p2) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define CTP_TRACE_EVENT3(m,p1,p2,p3) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define CTP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define CTP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define CTP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define CTP_TRACE_DEBUG0(m) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_CTP, TRACE_TYPE_DEBUG, m);}
-#define CTP_TRACE_DEBUG1(m,p1) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_CTP, TRACE_TYPE_DEBUG, m,p1);}
-#define CTP_TRACE_DEBUG2(m,p1,p2) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_CTP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define CTP_TRACE_DEBUG3(m,p1,p2,p3) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_CTP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define CTP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_CTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define CTP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_CTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define CTP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_CTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define CTP_TRACE_DEBUG0(m) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_DEBUG, m);}
+#define CTP_TRACE_DEBUG1(m,p1) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_DEBUG, m,p1);}
+#define CTP_TRACE_DEBUG2(m,p1,p2) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define CTP_TRACE_DEBUG3(m,p1,p2,p3) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define CTP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define CTP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define CTP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (ctp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_CTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* define traces for HID Host */
-#define HIDH_TRACE_ERROR0(m) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m);}
-#define HIDH_TRACE_ERROR1(m,p1) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m, p1);}
-#define HIDH_TRACE_ERROR2(m,p1,p2) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2);}
-#define HIDH_TRACE_ERROR3(m,p1,p2,p3) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define HIDH_TRACE_ERROR4(m,p1,p2,p3,p4) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define HIDH_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define HIDH_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define HIDH_TRACE_ERROR0(m) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m);}
+#define HIDH_TRACE_ERROR1(m,p1) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m, p1);}
+#define HIDH_TRACE_ERROR2(m,p1,p2) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2);}
+#define HIDH_TRACE_ERROR3(m,p1,p2,p3) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define HIDH_TRACE_ERROR4(m,p1,p2,p3,p4) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define HIDH_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define HIDH_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define HIDH_TRACE_WARNING0(m) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m);}
-#define HIDH_TRACE_WARNING1(m,p1) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1);}
-#define HIDH_TRACE_WARNING2(m,p1,p2) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2);}
-#define HIDH_TRACE_WARNING3(m,p1,p2,p3) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define HIDH_TRACE_WARNING4(m,p1,p2,p3,p4) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define HIDH_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define HIDH_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define HIDH_TRACE_WARNING0(m) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m);}
+#define HIDH_TRACE_WARNING1(m,p1) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1);}
+#define HIDH_TRACE_WARNING2(m,p1,p2) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2);}
+#define HIDH_TRACE_WARNING3(m,p1,p2,p3) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define HIDH_TRACE_WARNING4(m,p1,p2,p3,p4) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define HIDH_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define HIDH_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define HIDH_TRACE_API0(m) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_HID, TRACE_TYPE_API, m);}
-#define HIDH_TRACE_API1(m,p1) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_HID, TRACE_TYPE_API, m, p1);}
-#define HIDH_TRACE_API2(m,p1,p2) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2);}
-#define HIDH_TRACE_API3(m,p1,p2,p3) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2,p3);}
-#define HIDH_TRACE_API4(m,p1,p2,p3,p4) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define HIDH_TRACE_API5(m,p1,p2,p3,p4,p5) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define HIDH_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define HIDH_TRACE_API0(m) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, m);}
+#define HIDH_TRACE_API1(m,p1) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, m, p1);}
+#define HIDH_TRACE_API2(m,p1,p2) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2);}
+#define HIDH_TRACE_API3(m,p1,p2,p3) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2,p3);}
+#define HIDH_TRACE_API4(m,p1,p2,p3,p4) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define HIDH_TRACE_API5(m,p1,p2,p3,p4,p5) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define HIDH_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define HIDH_TRACE_EVENT0(m) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m);}
-#define HIDH_TRACE_EVENT1(m,p1) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m, p1);}
-#define HIDH_TRACE_EVENT2(m,p1,p2) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2);}
-#define HIDH_TRACE_EVENT3(m,p1,p2,p3) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define HIDH_TRACE_EVENT4(m,p1,p2,p3,p4) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define HIDH_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define HIDH_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define HIDH_TRACE_EVENT0(m) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m);}
+#define HIDH_TRACE_EVENT1(m,p1) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m, p1);}
+#define HIDH_TRACE_EVENT2(m,p1,p2) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2);}
+#define HIDH_TRACE_EVENT3(m,p1,p2,p3) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define HIDH_TRACE_EVENT4(m,p1,p2,p3,p4) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define HIDH_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define HIDH_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define HIDH_TRACE_DEBUG0(m) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m);}
-#define HIDH_TRACE_DEBUG1(m,p1) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1);}
-#define HIDH_TRACE_DEBUG2(m,p1,p2) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define HIDH_TRACE_DEBUG3(m,p1,p2,p3) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define HIDH_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define HIDH_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define HIDH_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define HIDH_TRACE_DEBUG0(m) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m);}
+#define HIDH_TRACE_DEBUG1(m,p1) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1);}
+#define HIDH_TRACE_DEBUG2(m,p1,p2) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define HIDH_TRACE_DEBUG3(m,p1,p2,p3) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define HIDH_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define HIDH_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define HIDH_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* define traces for HID Device */
-#define HIDD_TRACE_ERROR0(m) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m);}
-#define HIDD_TRACE_ERROR1(m,p1) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m, p1);}
-#define HIDD_TRACE_ERROR2(m,p1,p2) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2);}
-#define HIDD_TRACE_ERROR3(m,p1,p2,p3) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define HIDD_TRACE_ERROR4(m,p1,p2,p3,p4) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define HIDD_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define HIDD_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define HIDD_TRACE_ERROR0(m) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m);}
+#define HIDD_TRACE_ERROR1(m,p1) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m, p1);}
+#define HIDD_TRACE_ERROR2(m,p1,p2) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2);}
+#define HIDD_TRACE_ERROR3(m,p1,p2,p3) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define HIDD_TRACE_ERROR4(m,p1,p2,p3,p4) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define HIDD_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define HIDD_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define HIDD_TRACE_WARNING0(m) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m);}
-#define HIDD_TRACE_WARNING1(m,p1) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1);}
-#define HIDD_TRACE_WARNING2(m,p1,p2) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2);}
-#define HIDD_TRACE_WARNING3(m,p1,p2,p3) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define HIDD_TRACE_WARNING4(m,p1,p2,p3,p4) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define HIDD_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define HIDD_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define HIDD_TRACE_WARNING0(m) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m);}
+#define HIDD_TRACE_WARNING1(m,p1) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1);}
+#define HIDD_TRACE_WARNING2(m,p1,p2) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2);}
+#define HIDD_TRACE_WARNING3(m,p1,p2,p3) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define HIDD_TRACE_WARNING4(m,p1,p2,p3,p4) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define HIDD_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define HIDD_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define HIDD_TRACE_API0(m) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_HID, TRACE_TYPE_API, m);}
-#define HIDD_TRACE_API1(m,p1) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_HID, TRACE_TYPE_API, m, p1);}
-#define HIDD_TRACE_API2(m,p1,p2) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2);}
-#define HIDD_TRACE_API3(m,p1,p2,p3) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2,p3);}
-#define HIDD_TRACE_API4(m,p1,p2,p3,p4) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define HIDD_TRACE_API5(m,p1,p2,p3,p4,p5) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define HIDD_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define HIDD_TRACE_API0(m) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, m);}
+#define HIDD_TRACE_API1(m,p1) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, m, p1);}
+#define HIDD_TRACE_API2(m,p1,p2) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2);}
+#define HIDD_TRACE_API3(m,p1,p2,p3) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2,p3);}
+#define HIDD_TRACE_API4(m,p1,p2,p3,p4) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define HIDD_TRACE_API5(m,p1,p2,p3,p4,p5) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define HIDD_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define HIDD_TRACE_EVENT0(m) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m);}
-#define HIDD_TRACE_EVENT1(m,p1) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m, p1);}
-#define HIDD_TRACE_EVENT2(m,p1,p2) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2);}
-#define HIDD_TRACE_EVENT3(m,p1,p2,p3) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define HIDD_TRACE_EVENT4(m,p1,p2,p3,p4) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define HIDD_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define HIDD_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define HIDD_TRACE_EVENT0(m) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m);}
+#define HIDD_TRACE_EVENT1(m,p1) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m, p1);}
+#define HIDD_TRACE_EVENT2(m,p1,p2) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2);}
+#define HIDD_TRACE_EVENT3(m,p1,p2,p3) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define HIDD_TRACE_EVENT4(m,p1,p2,p3,p4) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define HIDD_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define HIDD_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define HIDD_TRACE_DEBUG0(m) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m);}
-#define HIDD_TRACE_DEBUG1(m,p1) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1);}
-#define HIDD_TRACE_DEBUG2(m,p1,p2) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define HIDD_TRACE_DEBUG3(m,p1,p2,p3) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define HIDD_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define HIDD_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define HIDD_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define HIDD_TRACE_DEBUG0(m) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m);}
+#define HIDD_TRACE_DEBUG1(m,p1) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1);}
+#define HIDD_TRACE_DEBUG2(m,p1,p2) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define HIDD_TRACE_DEBUG3(m,p1,p2,p3) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define HIDD_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define HIDD_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define HIDD_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (hd_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* define traces for headset profile */
-#define HSP2_TRACE_ERROR0(pcb,m) {if (pcb->trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_HSP2, TRACE_TYPE_ERROR, m);}
-#define HSP2_TRACE_ERROR1(pcb,m,p1) {if (pcb->trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_HSP2, TRACE_TYPE_ERROR, m, p1);}
-#define HSP2_TRACE_ERROR2(pcb,m,p1,p2) {if (pcb->trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_HSP2, TRACE_TYPE_ERROR, m,p1,p2);}
-#define HSP2_TRACE_ERROR3(pcb,m,p1,p2,p3) {if (pcb->trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_HSP2, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define HSP2_TRACE_ERROR4(pcb,m,p1,p2,p3,p4) {if (pcb->trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_HSP2, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define HSP2_TRACE_ERROR5(pcb,m,p1,p2,p3,p4,p5) {if (pcb->trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_HSP2, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define HSP2_TRACE_ERROR6(pcb,m,p1,p2,p3,p4,p5,p6) {if (pcb->trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_HSP2, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define HSP2_TRACE_ERROR0(pcb,m) {if (pcb->trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_ERROR, m);}
+#define HSP2_TRACE_ERROR1(pcb,m,p1) {if (pcb->trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_ERROR, m, p1);}
+#define HSP2_TRACE_ERROR2(pcb,m,p1,p2) {if (pcb->trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_ERROR, m,p1,p2);}
+#define HSP2_TRACE_ERROR3(pcb,m,p1,p2,p3) {if (pcb->trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define HSP2_TRACE_ERROR4(pcb,m,p1,p2,p3,p4) {if (pcb->trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define HSP2_TRACE_ERROR5(pcb,m,p1,p2,p3,p4,p5) {if (pcb->trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define HSP2_TRACE_ERROR6(pcb,m,p1,p2,p3,p4,p5,p6) {if (pcb->trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define HSP2_TRACE_WARNING0(pcb,m) {if (pcb->trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_HSP2, TRACE_TYPE_WARNING, m);}
-#define HSP2_TRACE_WARNING1(pcb,m,p1) {if (pcb->trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_HSP2, TRACE_TYPE_WARNING, m,p1);}
-#define HSP2_TRACE_WARNING2(pcb,m,p1,p2) {if (pcb->trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_HSP2, TRACE_TYPE_WARNING, m,p1,p2);}
-#define HSP2_TRACE_WARNING3(pcb,m,p1,p2,p3) {if (pcb->trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_HSP2, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define HSP2_TRACE_WARNING4(pcb,m,p1,p2,p3,p4) {if (pcb->trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_HSP2, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define HSP2_TRACE_WARNING5(pcb,m,p1,p2,p3,p4,p5) {if (pcb->trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_HSP2, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define HSP2_TRACE_WARNING6(pcb,m,p1,p2,p3,p4,p5,p6) {if (pcb->trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_HSP2, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define HSP2_TRACE_WARNING0(pcb,m) {if (pcb->trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_WARNING, m);}
+#define HSP2_TRACE_WARNING1(pcb,m,p1) {if (pcb->trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_WARNING, m,p1);}
+#define HSP2_TRACE_WARNING2(pcb,m,p1,p2) {if (pcb->trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_WARNING, m,p1,p2);}
+#define HSP2_TRACE_WARNING3(pcb,m,p1,p2,p3) {if (pcb->trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define HSP2_TRACE_WARNING4(pcb,m,p1,p2,p3,p4) {if (pcb->trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define HSP2_TRACE_WARNING5(pcb,m,p1,p2,p3,p4,p5) {if (pcb->trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define HSP2_TRACE_WARNING6(pcb,m,p1,p2,p3,p4,p5,p6) {if (pcb->trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define HSP2_TRACE_API0(pcb,m) {if (pcb->trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_HSP2, TRACE_TYPE_API, m);}
-#define HSP2_TRACE_API1(pcb,m,p1) {if (pcb->trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_HSP2, TRACE_TYPE_API, m, p1);}
-#define HSP2_TRACE_API2(pcb,m,p1,p2) {if (pcb->trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_HSP2, TRACE_TYPE_API, m,p1,p2);}
-#define HSP2_TRACE_API3(pcb,m,p1,p2,p3) {if (pcb->trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_HSP2, TRACE_TYPE_API, m,p1,p2,p3);}
-#define HSP2_TRACE_API4(pcb,m,p1,p2,p3,p4) {if (pcb->trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_HSP2, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define HSP2_TRACE_API5(pcb,m,p1,p2,p3,p4,p5) {if (pcb->trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_HSP2, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define HSP2_TRACE_API6(pcb,m,p1,p2,p3,p4,p5,p6) {if (pcb->trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_HSP2, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define HSP2_TRACE_API0(pcb,m) {if (pcb->trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_API, m);}
+#define HSP2_TRACE_API1(pcb,m,p1) {if (pcb->trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_API, m, p1);}
+#define HSP2_TRACE_API2(pcb,m,p1,p2) {if (pcb->trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_API, m,p1,p2);}
+#define HSP2_TRACE_API3(pcb,m,p1,p2,p3) {if (pcb->trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_API, m,p1,p2,p3);}
+#define HSP2_TRACE_API4(pcb,m,p1,p2,p3,p4) {if (pcb->trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define HSP2_TRACE_API5(pcb,m,p1,p2,p3,p4,p5) {if (pcb->trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define HSP2_TRACE_API6(pcb,m,p1,p2,p3,p4,p5,p6) {if (pcb->trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define HSP2_TRACE_EVENT0(pcb,m) {if (pcb->trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_HSP2, TRACE_TYPE_EVENT, m);}
-#define HSP2_TRACE_EVENT1(pcb,m,p1) {if (pcb->trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_HSP2, TRACE_TYPE_EVENT, m, p1);}
-#define HSP2_TRACE_EVENT2(pcb,m,p1,p2) {if (pcb->trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_HSP2, TRACE_TYPE_EVENT, m,p1,p2);}
-#define HSP2_TRACE_EVENT3(pcb,m,p1,p2,p3) {if (pcb->trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_HSP2, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define HSP2_TRACE_EVENT4(pcb,m,p1,p2,p3,p4) {if (pcb->trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_HSP2, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define HSP2_TRACE_EVENT5(pcb,m,p1,p2,p3,p4,p5) {if (pcb->trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_HSP2, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define HSP2_TRACE_EVENT6(pcb,m,p1,p2,p3,p4,p5,p6) {if (pcb->trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_HSP2, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define HSP2_TRACE_EVENT0(pcb,m) {if (pcb->trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_EVENT, m);}
+#define HSP2_TRACE_EVENT1(pcb,m,p1) {if (pcb->trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_EVENT, m, p1);}
+#define HSP2_TRACE_EVENT2(pcb,m,p1,p2) {if (pcb->trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_EVENT, m,p1,p2);}
+#define HSP2_TRACE_EVENT3(pcb,m,p1,p2,p3) {if (pcb->trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define HSP2_TRACE_EVENT4(pcb,m,p1,p2,p3,p4) {if (pcb->trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define HSP2_TRACE_EVENT5(pcb,m,p1,p2,p3,p4,p5) {if (pcb->trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define HSP2_TRACE_EVENT6(pcb,m,p1,p2,p3,p4,p5,p6) {if (pcb->trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define HSP2_TRACE_DEBUG0(pcb,m) {if (pcb->trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_HSP2, TRACE_TYPE_DEBUG, m);}
-#define HSP2_TRACE_DEBUG1(pcb,m,p1) {if (pcb->trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_HSP2, TRACE_TYPE_DEBUG, m,p1);}
-#define HSP2_TRACE_DEBUG2(pcb,m,p1,p2) {if (pcb->trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_HSP2, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define HSP2_TRACE_DEBUG3(pcb,m,p1,p2,p3) {if (pcb->trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_HSP2, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define HSP2_TRACE_DEBUG4(pcb,m,p1,p2,p3,p4) {if (pcb->trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_HSP2, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define HSP2_TRACE_DEBUG5(pcb,m,p1,p2,p3,p4,p5) {if (pcb->trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_HSP2, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define HSP2_TRACE_DEBUG6(pcb,m,p1,p2,p3,p4,p5,p6) {if (pcb->trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_HSP2, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define HSP2_TRACE_DEBUG0(pcb,m) {if (pcb->trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_DEBUG, m);}
+#define HSP2_TRACE_DEBUG1(pcb,m,p1) {if (pcb->trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_DEBUG, m,p1);}
+#define HSP2_TRACE_DEBUG2(pcb,m,p1,p2) {if (pcb->trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define HSP2_TRACE_DEBUG3(pcb,m,p1,p2,p3) {if (pcb->trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define HSP2_TRACE_DEBUG4(pcb,m,p1,p2,p3,p4) {if (pcb->trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define HSP2_TRACE_DEBUG5(pcb,m,p1,p2,p3,p4,p5) {if (pcb->trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define HSP2_TRACE_DEBUG6(pcb,m,p1,p2,p3,p4,p5,p6) {if (pcb->trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HSP2, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the NFC unit
*/
-#define NFC_TRACE_ERROR0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m);}
-#define NFC_TRACE_ERROR1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m,p1);}
-#define NFC_TRACE_ERROR2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m,p1,p2);}
-#define NFC_TRACE_ERROR3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define NFC_TRACE_ERROR4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define NFC_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define NFC_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define NFC_TRACE_ERROR0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m);}
+#define NFC_TRACE_ERROR1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m,p1);}
+#define NFC_TRACE_ERROR2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m,p1,p2);}
+#define NFC_TRACE_ERROR3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define NFC_TRACE_ERROR4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define NFC_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define NFC_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define NFC_TRACE_WARNING0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m);}
-#define NFC_TRACE_WARNING1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m,p1);}
-#define NFC_TRACE_WARNING2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m,p1,p2);}
-#define NFC_TRACE_WARNING3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define NFC_TRACE_WARNING4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define NFC_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define NFC_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define NFC_TRACE_WARNING0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m);}
+#define NFC_TRACE_WARNING1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m,p1);}
+#define NFC_TRACE_WARNING2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m,p1,p2);}
+#define NFC_TRACE_WARNING3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define NFC_TRACE_WARNING4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define NFC_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define NFC_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define NFC_TRACE_API0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_NFC, TRACE_TYPE_API, m);}
-#define NFC_TRACE_API1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_NFC, TRACE_TYPE_API, m,p1);}
-#define NFC_TRACE_API2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_NFC, TRACE_TYPE_API, m,p1,p2);}
-#define NFC_TRACE_API3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_NFC, TRACE_TYPE_API, m,p1,p2,p3);}
-#define NFC_TRACE_API4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_NFC, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define NFC_TRACE_API5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_NFC, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define NFC_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_NFC, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define NFC_TRACE_API0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_API, m);}
+#define NFC_TRACE_API1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_API, m,p1);}
+#define NFC_TRACE_API2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_API, m,p1,p2);}
+#define NFC_TRACE_API3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_API, m,p1,p2,p3);}
+#define NFC_TRACE_API4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define NFC_TRACE_API5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define NFC_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define NFC_TRACE_EVENT0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m);}
-#define NFC_TRACE_EVENT1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m, p1);}
-#define NFC_TRACE_EVENT2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m,p1,p2);}
-#define NFC_TRACE_EVENT3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define NFC_TRACE_EVENT4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define NFC_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define NFC_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define NFC_TRACE_EVENT0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m);}
+#define NFC_TRACE_EVENT1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m, p1);}
+#define NFC_TRACE_EVENT2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m,p1,p2);}
+#define NFC_TRACE_EVENT3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define NFC_TRACE_EVENT4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define NFC_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define NFC_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define NFC_TRACE_DEBUG0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m);}
-#define NFC_TRACE_DEBUG1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m,p1);}
-#define NFC_TRACE_DEBUG2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define NFC_TRACE_DEBUG3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define NFC_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define NFC_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define NFC_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define NFC_TRACE_DEBUG0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m);}
+#define NFC_TRACE_DEBUG1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m,p1);}
+#define NFC_TRACE_DEBUG2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define NFC_TRACE_DEBUG3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define NFC_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define NFC_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define NFC_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#define NCI_TRACE_ERROR0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m);}
-#define NCI_TRACE_ERROR1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1);}
-#define NCI_TRACE_ERROR2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1,p2);}
-#define NCI_TRACE_ERROR3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define NCI_TRACE_ERROR4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define NCI_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define NCI_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define NCI_TRACE_ERROR0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m);}
+#define NCI_TRACE_ERROR1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1);}
+#define NCI_TRACE_ERROR2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1,p2);}
+#define NCI_TRACE_ERROR3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define NCI_TRACE_ERROR4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define NCI_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define NCI_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define NCI_TRACE_WARNING0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m);}
-#define NCI_TRACE_WARNING1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1);}
-#define NCI_TRACE_WARNING2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1,p2);}
-#define NCI_TRACE_WARNING3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define NCI_TRACE_WARNING4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define NCI_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define NCI_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define NCI_TRACE_WARNING0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m);}
+#define NCI_TRACE_WARNING1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1);}
+#define NCI_TRACE_WARNING2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1,p2);}
+#define NCI_TRACE_WARNING3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define NCI_TRACE_WARNING4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define NCI_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define NCI_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define NCI_TRACE_API0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_NCI, TRACE_TYPE_API, m);}
-#define NCI_TRACE_API1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1);}
-#define NCI_TRACE_API2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1,p2);}
-#define NCI_TRACE_API3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1,p2,p3);}
-#define NCI_TRACE_API4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define NCI_TRACE_API5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define NCI_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define NCI_TRACE_API0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_API, m);}
+#define NCI_TRACE_API1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1);}
+#define NCI_TRACE_API2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1,p2);}
+#define NCI_TRACE_API3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1,p2,p3);}
+#define NCI_TRACE_API4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define NCI_TRACE_API5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define NCI_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define NCI_TRACE_EVENT0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m);}
-#define NCI_TRACE_EVENT1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m, p1);}
-#define NCI_TRACE_EVENT2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m,p1,p2);}
-#define NCI_TRACE_EVENT3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define NCI_TRACE_EVENT4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define NCI_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define NCI_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define NCI_TRACE_EVENT0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m);}
+#define NCI_TRACE_EVENT1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m, p1);}
+#define NCI_TRACE_EVENT2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m,p1,p2);}
+#define NCI_TRACE_EVENT3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define NCI_TRACE_EVENT4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define NCI_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define NCI_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define NCI_TRACE_DEBUG0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m);}
-#define NCI_TRACE_DEBUG1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1);}
-#define NCI_TRACE_DEBUG2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define NCI_TRACE_DEBUG3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define NCI_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define NCI_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define NCI_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define NCI_TRACE_DEBUG0(m) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m);}
+#define NCI_TRACE_DEBUG1(m,p1) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1);}
+#define NCI_TRACE_DEBUG2(m,p1,p2) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define NCI_TRACE_DEBUG3(m,p1,p2,p3) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define NCI_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define NCI_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define NCI_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#define RW_TRACE_ERROR0(m) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m);}
-#define RW_TRACE_ERROR1(m,p1) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m,p1);}
-#define RW_TRACE_ERROR2(m,p1,p2) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m,p1,p2);}
-#define RW_TRACE_ERROR3(m,p1,p2,p3) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define RW_TRACE_ERROR4(m,p1,p2,p3,p4) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define RW_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define RW_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define RW_TRACE_ERROR0(m) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m);}
+#define RW_TRACE_ERROR1(m,p1) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m,p1);}
+#define RW_TRACE_ERROR2(m,p1,p2) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m,p1,p2);}
+#define RW_TRACE_ERROR3(m,p1,p2,p3) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define RW_TRACE_ERROR4(m,p1,p2,p3,p4) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define RW_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define RW_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define RW_TRACE_WARNING0(m) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m);}
-#define RW_TRACE_WARNING1(m,p1) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m,p1);}
-#define RW_TRACE_WARNING2(m,p1,p2) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m,p1,p2);}
-#define RW_TRACE_WARNING3(m,p1,p2,p3) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define RW_TRACE_WARNING4(m,p1,p2,p3,p4) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define RW_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define RW_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define RW_TRACE_WARNING0(m) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m);}
+#define RW_TRACE_WARNING1(m,p1) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m,p1);}
+#define RW_TRACE_WARNING2(m,p1,p2) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m,p1,p2);}
+#define RW_TRACE_WARNING3(m,p1,p2,p3) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define RW_TRACE_WARNING4(m,p1,p2,p3,p4) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define RW_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define RW_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define RW_TRACE_API0(m) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_RW, TRACE_TYPE_API, m);}
-#define RW_TRACE_API1(m,p1) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_RW, TRACE_TYPE_API, m,p1);}
-#define RW_TRACE_API2(m,p1,p2) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_RW, TRACE_TYPE_API, m,p1,p2);}
-#define RW_TRACE_API3(m,p1,p2,p3) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_RW, TRACE_TYPE_API, m,p1,p2,p3);}
-#define RW_TRACE_API4(m,p1,p2,p3,p4) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_RW, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define RW_TRACE_API5(m,p1,p2,p3,p4,p5) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_RW, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define RW_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_RW, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define RW_TRACE_API0(m) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_API, m);}
+#define RW_TRACE_API1(m,p1) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_API, m,p1);}
+#define RW_TRACE_API2(m,p1,p2) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_API, m,p1,p2);}
+#define RW_TRACE_API3(m,p1,p2,p3) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_API, m,p1,p2,p3);}
+#define RW_TRACE_API4(m,p1,p2,p3,p4) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define RW_TRACE_API5(m,p1,p2,p3,p4,p5) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define RW_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define RW_TRACE_EVENT0(m) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m);}
-#define RW_TRACE_EVENT1(m,p1) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m, p1);}
-#define RW_TRACE_EVENT2(m,p1,p2) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m,p1,p2);}
-#define RW_TRACE_EVENT3(m,p1,p2,p3) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define RW_TRACE_EVENT4(m,p1,p2,p3,p4) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define RW_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define RW_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define RW_TRACE_EVENT0(m) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m);}
+#define RW_TRACE_EVENT1(m,p1) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m, p1);}
+#define RW_TRACE_EVENT2(m,p1,p2) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m,p1,p2);}
+#define RW_TRACE_EVENT3(m,p1,p2,p3) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define RW_TRACE_EVENT4(m,p1,p2,p3,p4) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define RW_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define RW_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define RW_TRACE_DEBUG0(m) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m);}
-#define RW_TRACE_DEBUG1(m,p1) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m,p1);}
-#define RW_TRACE_DEBUG2(m,p1,p2) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define RW_TRACE_DEBUG3(m,p1,p2,p3) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define RW_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define RW_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define RW_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define RW_TRACE_DEBUG0(m) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m);}
+#define RW_TRACE_DEBUG1(m,p1) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m,p1);}
+#define RW_TRACE_DEBUG2(m,p1,p2) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define RW_TRACE_DEBUG3(m,p1,p2,p3) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define RW_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define RW_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define RW_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#define CE_TRACE_ERROR0(m) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m);}
-#define CE_TRACE_ERROR1(m,p1) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m,p1);}
-#define CE_TRACE_ERROR2(m,p1,p2) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m,p1,p2);}
-#define CE_TRACE_ERROR3(m,p1,p2,p3) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define CE_TRACE_ERROR4(m,p1,p2,p3,p4) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define CE_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define CE_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define CE_TRACE_ERROR0(m) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m);}
+#define CE_TRACE_ERROR1(m,p1) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m,p1);}
+#define CE_TRACE_ERROR2(m,p1,p2) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m,p1,p2);}
+#define CE_TRACE_ERROR3(m,p1,p2,p3) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define CE_TRACE_ERROR4(m,p1,p2,p3,p4) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define CE_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define CE_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define CE_TRACE_WARNING0(m) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m);}
-#define CE_TRACE_WARNING1(m,p1) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m,p1);}
-#define CE_TRACE_WARNING2(m,p1,p2) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m,p1,p2);}
-#define CE_TRACE_WARNING3(m,p1,p2,p3) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define CE_TRACE_WARNING4(m,p1,p2,p3,p4) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define CE_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define CE_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define CE_TRACE_WARNING0(m) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m);}
+#define CE_TRACE_WARNING1(m,p1) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m,p1);}
+#define CE_TRACE_WARNING2(m,p1,p2) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m,p1,p2);}
+#define CE_TRACE_WARNING3(m,p1,p2,p3) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define CE_TRACE_WARNING4(m,p1,p2,p3,p4) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define CE_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define CE_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define CE_TRACE_API0(m) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_CE, TRACE_TYPE_API, m);}
-#define CE_TRACE_API1(m,p1) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_CE, TRACE_TYPE_API, m,p1);}
-#define CE_TRACE_API2(m,p1,p2) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_CE, TRACE_TYPE_API, m,p1,p2);}
-#define CE_TRACE_API3(m,p1,p2,p3) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_CE, TRACE_TYPE_API, m,p1,p2,p3);}
-#define CE_TRACE_API4(m,p1,p2,p3,p4) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_CE, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define CE_TRACE_API5(m,p1,p2,p3,p4,p5) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_CE, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define CE_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_CE, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define CE_TRACE_API0(m) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_API, m);}
+#define CE_TRACE_API1(m,p1) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_API, m,p1);}
+#define CE_TRACE_API2(m,p1,p2) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_API, m,p1,p2);}
+#define CE_TRACE_API3(m,p1,p2,p3) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_API, m,p1,p2,p3);}
+#define CE_TRACE_API4(m,p1,p2,p3,p4) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define CE_TRACE_API5(m,p1,p2,p3,p4,p5) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define CE_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define CE_TRACE_EVENT0(m) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m);}
-#define CE_TRACE_EVENT1(m,p1) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m, p1);}
-#define CE_TRACE_EVENT2(m,p1,p2) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m,p1,p2);}
-#define CE_TRACE_EVENT3(m,p1,p2,p3) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define CE_TRACE_EVENT4(m,p1,p2,p3,p4) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define CE_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define CE_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define CE_TRACE_EVENT0(m) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m);}
+#define CE_TRACE_EVENT1(m,p1) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m, p1);}
+#define CE_TRACE_EVENT2(m,p1,p2) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m,p1,p2);}
+#define CE_TRACE_EVENT3(m,p1,p2,p3) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define CE_TRACE_EVENT4(m,p1,p2,p3,p4) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define CE_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define CE_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define CE_TRACE_DEBUG0(m) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m);}
-#define CE_TRACE_DEBUG1(m,p1) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m,p1);}
-#define CE_TRACE_DEBUG2(m,p1,p2) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define CE_TRACE_DEBUG3(m,p1,p2,p3) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define CE_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define CE_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define CE_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define CE_TRACE_DEBUG0(m) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m);}
+#define CE_TRACE_DEBUG1(m,p1) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m,p1);}
+#define CE_TRACE_DEBUG2(m,p1,p2) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define CE_TRACE_DEBUG3(m,p1,p2,p3) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define CE_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define CE_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define CE_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#define NDEF_TRACE_ERROR0(m) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m);}
-#define NDEF_TRACE_ERROR1(m,p1) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m,p1);}
-#define NDEF_TRACE_ERROR2(m,p1,p2) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m,p1,p2);}
-#define NDEF_TRACE_ERROR3(m,p1,p2,p3) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define NDEF_TRACE_ERROR4(m,p1,p2,p3,p4) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define NDEF_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define NDEF_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define NDEF_TRACE_ERROR0(m) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m);}
+#define NDEF_TRACE_ERROR1(m,p1) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m,p1);}
+#define NDEF_TRACE_ERROR2(m,p1,p2) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m,p1,p2);}
+#define NDEF_TRACE_ERROR3(m,p1,p2,p3) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define NDEF_TRACE_ERROR4(m,p1,p2,p3,p4) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define NDEF_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define NDEF_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define NDEF_TRACE_WARNING0(m) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m);}
-#define NDEF_TRACE_WARNING1(m,p1) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m,p1);}
-#define NDEF_TRACE_WARNING2(m,p1,p2) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m,p1,p2);}
-#define NDEF_TRACE_WARNING3(m,p1,p2,p3) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define NDEF_TRACE_WARNING4(m,p1,p2,p3,p4) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define NDEF_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define NDEF_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define NDEF_TRACE_WARNING0(m) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m);}
+#define NDEF_TRACE_WARNING1(m,p1) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m,p1);}
+#define NDEF_TRACE_WARNING2(m,p1,p2) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m,p1,p2);}
+#define NDEF_TRACE_WARNING3(m,p1,p2,p3) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define NDEF_TRACE_WARNING4(m,p1,p2,p3,p4) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define NDEF_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define NDEF_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define NDEF_TRACE_API0(m) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_NDEF, TRACE_TYPE_API, m);}
-#define NDEF_TRACE_API1(m,p1) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_NDEF, TRACE_TYPE_API, m,p1);}
-#define NDEF_TRACE_API2(m,p1,p2) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_NDEF, TRACE_TYPE_API, m,p1,p2);}
-#define NDEF_TRACE_API3(m,p1,p2,p3) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_NDEF, TRACE_TYPE_API, m,p1,p2,p3);}
-#define NDEF_TRACE_API4(m,p1,p2,p3,p4) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_NDEF, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define NDEF_TRACE_API5(m,p1,p2,p3,p4,p5) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_NDEF, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define NDEF_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_NDEF, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define NDEF_TRACE_API0(m) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_API, m);}
+#define NDEF_TRACE_API1(m,p1) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_API, m,p1);}
+#define NDEF_TRACE_API2(m,p1,p2) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_API, m,p1,p2);}
+#define NDEF_TRACE_API3(m,p1,p2,p3) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_API, m,p1,p2,p3);}
+#define NDEF_TRACE_API4(m,p1,p2,p3,p4) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define NDEF_TRACE_API5(m,p1,p2,p3,p4,p5) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define NDEF_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define NDEF_TRACE_EVENT0(m) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m);}
-#define NDEF_TRACE_EVENT1(m,p1) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m, p1);}
-#define NDEF_TRACE_EVENT2(m,p1,p2) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m,p1,p2);}
-#define NDEF_TRACE_EVENT3(m,p1,p2,p3) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define NDEF_TRACE_EVENT4(m,p1,p2,p3,p4) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define NDEF_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define NDEF_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define NDEF_TRACE_EVENT0(m) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m);}
+#define NDEF_TRACE_EVENT1(m,p1) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m, p1);}
+#define NDEF_TRACE_EVENT2(m,p1,p2) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m,p1,p2);}
+#define NDEF_TRACE_EVENT3(m,p1,p2,p3) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define NDEF_TRACE_EVENT4(m,p1,p2,p3,p4) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define NDEF_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define NDEF_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define NDEF_TRACE_DEBUG0(m) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m);}
-#define NDEF_TRACE_DEBUG1(m,p1) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m,p1);}
-#define NDEF_TRACE_DEBUG2(m,p1,p2) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define NDEF_TRACE_DEBUG3(m,p1,p2,p3) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define NDEF_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define NDEF_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define NDEF_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define NDEF_TRACE_DEBUG0(m) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m);}
+#define NDEF_TRACE_DEBUG1(m,p1) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m,p1);}
+#define NDEF_TRACE_DEBUG2(m,p1,p2) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define NDEF_TRACE_DEBUG3(m,p1,p2,p3) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define NDEF_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define NDEF_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define NDEF_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the NFA unit
*/
-#define NFA_TRACE_ERROR0(m) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m);}
-#define NFA_TRACE_ERROR1(m,p1) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m,p1);}
-#define NFA_TRACE_ERROR2(m,p1,p2) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m,p1,p2);}
-#define NFA_TRACE_ERROR3(m,p1,p2,p3) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define NFA_TRACE_ERROR4(m,p1,p2,p3,p4) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define NFA_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define NFA_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define NFA_TRACE_ERROR0(m) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m);}
+#define NFA_TRACE_ERROR1(m,p1) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m,p1);}
+#define NFA_TRACE_ERROR2(m,p1,p2) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m,p1,p2);}
+#define NFA_TRACE_ERROR3(m,p1,p2,p3) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define NFA_TRACE_ERROR4(m,p1,p2,p3,p4) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define NFA_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define NFA_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define NFA_TRACE_WARNING0(m) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m);}
-#define NFA_TRACE_WARNING1(m,p1) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m,p1);}
-#define NFA_TRACE_WARNING2(m,p1,p2) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m,p1,p2);}
-#define NFA_TRACE_WARNING3(m,p1,p2,p3) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define NFA_TRACE_WARNING4(m,p1,p2,p3,p4) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define NFA_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define NFA_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define NFA_TRACE_WARNING0(m) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m);}
+#define NFA_TRACE_WARNING1(m,p1) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m,p1);}
+#define NFA_TRACE_WARNING2(m,p1,p2) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m,p1,p2);}
+#define NFA_TRACE_WARNING3(m,p1,p2,p3) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define NFA_TRACE_WARNING4(m,p1,p2,p3,p4) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define NFA_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define NFA_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define NFA_TRACE_API0(m) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_NFA, TRACE_TYPE_API, m);}
-#define NFA_TRACE_API1(m,p1) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_NFA, TRACE_TYPE_API, m,p1);}
-#define NFA_TRACE_API2(m,p1,p2) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_NFA, TRACE_TYPE_API, m,p1,p2);}
-#define NFA_TRACE_API3(m,p1,p2,p3) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_NFA, TRACE_TYPE_API, m,p1,p2,p3);}
-#define NFA_TRACE_API4(m,p1,p2,p3,p4) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_NFA, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define NFA_TRACE_API5(m,p1,p2,p3,p4,p5) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_NFA, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define NFA_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_NFA, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define NFA_TRACE_API0(m) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_API, m);}
+#define NFA_TRACE_API1(m,p1) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_API, m,p1);}
+#define NFA_TRACE_API2(m,p1,p2) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_API, m,p1,p2);}
+#define NFA_TRACE_API3(m,p1,p2,p3) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_API, m,p1,p2,p3);}
+#define NFA_TRACE_API4(m,p1,p2,p3,p4) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define NFA_TRACE_API5(m,p1,p2,p3,p4,p5) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define NFA_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define NFA_TRACE_EVENT0(m) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m);}
-#define NFA_TRACE_EVENT1(m,p1) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m, p1);}
-#define NFA_TRACE_EVENT2(m,p1,p2) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m,p1,p2);}
-#define NFA_TRACE_EVENT3(m,p1,p2,p3) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define NFA_TRACE_EVENT4(m,p1,p2,p3,p4) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define NFA_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define NFA_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define NFA_TRACE_EVENT0(m) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m);}
+#define NFA_TRACE_EVENT1(m,p1) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m, p1);}
+#define NFA_TRACE_EVENT2(m,p1,p2) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m,p1,p2);}
+#define NFA_TRACE_EVENT3(m,p1,p2,p3) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define NFA_TRACE_EVENT4(m,p1,p2,p3,p4) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define NFA_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define NFA_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define NFA_TRACE_DEBUG0(m) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m);}
-#define NFA_TRACE_DEBUG1(m,p1) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m,p1);}
-#define NFA_TRACE_DEBUG2(m,p1,p2) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define NFA_TRACE_DEBUG3(m,p1,p2,p3) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define NFA_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define NFA_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define NFA_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define NFA_TRACE_DEBUG0(m) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m);}
+#define NFA_TRACE_DEBUG1(m,p1) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m,p1);}
+#define NFA_TRACE_DEBUG2(m,p1,p2) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define NFA_TRACE_DEBUG3(m,p1,p2,p3) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define NFA_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define NFA_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define NFA_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
#define MMI_TRACE_0(m)
#define MMI_TRACE_1(m,p1)
@@ -1630,29 +1542,29 @@
#define MMI_TRACE_5(m,p1,p2,p3,p4,p5)
#define MMI_TRACE_6(m,p1,p2,p3,p4,p5,p6)
-#define MMI_DEBUG_0(m) BT_TRACE_0(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m)
-#define MMI_DEBUG_1(m,p1) BT_TRACE_1(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1)
-#define MMI_DEBUG_2(m,p1,p2) BT_TRACE_2(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2)
-#define MMI_DEBUG_3(m,p1,p2,p3) BT_TRACE_3(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3)
-#define MMI_DEBUG_4(m,p1,p2,p3,p4) BT_TRACE_4(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4)
-#define MMI_DEBUG_5(m,p1,p2,p3,p4,p5) BT_TRACE_5(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5)
-#define MMI_DEBUG_6(m,p1,p2,p3,p4,p5,p6) BT_TRACE_6(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6)
+#define MMI_DEBUG_0(m) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m)
+#define MMI_DEBUG_1(m,p1) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1)
+#define MMI_DEBUG_2(m,p1,p2) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2)
+#define MMI_DEBUG_3(m,p1,p2,p3) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3)
+#define MMI_DEBUG_4(m,p1,p2,p3,p4) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4)
+#define MMI_DEBUG_5(m,p1,p2,p3,p4,p5) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5)
+#define MMI_DEBUG_6(m,p1,p2,p3,p4,p5,p6) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6)
-#define MMI_WARNING_0(m) BT_TRACE_0(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m)
-#define MMI_WARNING_1(m,p1) BT_TRACE_1(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1)
-#define MMI_WARNING_2(m,p1,p2) BT_TRACE_2(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2)
-#define MMI_WARNING_3(m,p1,p2,p3) BT_TRACE_3(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3)
-#define MMI_WARNING_4(m,p1,p2,p3,p4) BT_TRACE_4(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4)
-#define MMI_WARNING_5(m,p1,p2,p3,p4,p5) BT_TRACE_5(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5)
-#define MMI_WARNING_6(m,p1,p2,p3,p4,p5,p6) BT_TRACE_6(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6)
+#define MMI_WARNING_0(m) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m)
+#define MMI_WARNING_1(m,p1) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1)
+#define MMI_WARNING_2(m,p1,p2) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2)
+#define MMI_WARNING_3(m,p1,p2,p3) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3)
+#define MMI_WARNING_4(m,p1,p2,p3,p4) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4)
+#define MMI_WARNING_5(m,p1,p2,p3,p4,p5) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5)
+#define MMI_WARNING_6(m,p1,p2,p3,p4,p5,p6) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6)
-#define MMI_ERROR_0(m) BT_TRACE_0(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m)
-#define MMI_ERROR_1(m,p1) BT_TRACE_1(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1)
-#define MMI_ERROR_2(m,p1,p2) BT_TRACE_2(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2)
-#define MMI_ERROR_3(m,p1,p2,p3) BT_TRACE_3(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3)
-#define MMI_ERROR_4(m,p1,p2,p3,p4) BT_TRACE_4(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4)
-#define MMI_ERROR_5(m,p1,p2,p3,p4,p5) BT_TRACE_5(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5)
-#define MMI_ERROR_6(m,p1,p2,p3,p4,p5,p6) BT_TRACE_6(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6)
+#define MMI_ERROR_0(m) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m)
+#define MMI_ERROR_1(m,p1) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1)
+#define MMI_ERROR_2(m,p1,p2) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2)
+#define MMI_ERROR_3(m,p1,p2,p3) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3)
+#define MMI_ERROR_4(m,p1,p2,p3,p4) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4)
+#define MMI_ERROR_5(m,p1,p2,p3,p4,p5) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5)
+#define MMI_ERROR_6(m,p1,p2,p3,p4,p5,p6) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6)
#define TAK_TRACE_0(m) MMI_Echo(m)
@@ -1684,969 +1596,898 @@
/* define traces for DUN */
-#define DUN_TRACE_ERROR0(m) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_DUN, TRACE_TYPE_ERROR, m);}
-#define DUN_TRACE_ERROR1(m,p1) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_DUN, TRACE_TYPE_ERROR, m, p1);}
-#define DUN_TRACE_ERROR2(m,p1,p2) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_DUN, TRACE_TYPE_ERROR, m,p1,p2);}
-#define DUN_TRACE_ERROR3(m,p1,p2,p3) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_DUN, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define DUN_TRACE_ERROR4(m,p1,p2,p3,p4) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_DUN, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define DUN_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_DUN, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define DUN_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_DUN, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define DUN_TRACE_ERROR0(m) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_ERROR, m);}
+#define DUN_TRACE_ERROR1(m,p1) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_ERROR, m, p1);}
+#define DUN_TRACE_ERROR2(m,p1,p2) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_ERROR, m,p1,p2);}
+#define DUN_TRACE_ERROR3(m,p1,p2,p3) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define DUN_TRACE_ERROR4(m,p1,p2,p3,p4) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define DUN_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define DUN_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define DUN_TRACE_WARNING0(m) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_DUN, TRACE_TYPE_WARNING, m);}
-#define DUN_TRACE_WARNING1(m,p1) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_DUN, TRACE_TYPE_WARNING, m,p1);}
-#define DUN_TRACE_WARNING2(m,p1,p2) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_DUN, TRACE_TYPE_WARNING, m,p1,p2);}
-#define DUN_TRACE_WARNING3(m,p1,p2,p3) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_DUN, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define DUN_TRACE_WARNING4(m,p1,p2,p3,p4) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_DUN, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define DUN_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_DUN, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define DUN_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_DUN, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define DUN_TRACE_WARNING0(m) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_WARNING, m);}
+#define DUN_TRACE_WARNING1(m,p1) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_WARNING, m,p1);}
+#define DUN_TRACE_WARNING2(m,p1,p2) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_WARNING, m,p1,p2);}
+#define DUN_TRACE_WARNING3(m,p1,p2,p3) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define DUN_TRACE_WARNING4(m,p1,p2,p3,p4) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define DUN_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define DUN_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define DUN_TRACE_API0(m) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_DUN, TRACE_TYPE_API, m);}
-#define DUN_TRACE_API1(m,p1) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_DUN, TRACE_TYPE_API, m, p1);}
-#define DUN_TRACE_API2(m,p1,p2) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_DUN, TRACE_TYPE_API, m,p1,p2);}
-#define DUN_TRACE_API3(m,p1,p2,p3) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_DUN, TRACE_TYPE_API, m,p1,p2,p3);}
-#define DUN_TRACE_API4(m,p1,p2,p3,p4) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_DUN, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define DUN_TRACE_API5(m,p1,p2,p3,p4,p5) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_DUN, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define DUN_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_DUN, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define DUN_TRACE_API0(m) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_API, m);}
+#define DUN_TRACE_API1(m,p1) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_API, m, p1);}
+#define DUN_TRACE_API2(m,p1,p2) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_API, m,p1,p2);}
+#define DUN_TRACE_API3(m,p1,p2,p3) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_API, m,p1,p2,p3);}
+#define DUN_TRACE_API4(m,p1,p2,p3,p4) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define DUN_TRACE_API5(m,p1,p2,p3,p4,p5) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define DUN_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define DUN_TRACE_EVENT0(m) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_DUN, TRACE_TYPE_EVENT, m);}
-#define DUN_TRACE_EVENT1(m,p1) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_DUN, TRACE_TYPE_EVENT, m, p1);}
-#define DUN_TRACE_EVENT2(m,p1,p2) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_DUN, TRACE_TYPE_EVENT, m,p1,p2);}
-#define DUN_TRACE_EVENT3(m,p1,p2,p3) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_DUN, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define DUN_TRACE_EVENT4(m,p1,p2,p3,p4) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_DUN, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define DUN_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_DUN, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define DUN_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_DUN, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define DUN_TRACE_EVENT0(m) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_EVENT, m);}
+#define DUN_TRACE_EVENT1(m,p1) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_EVENT, m, p1);}
+#define DUN_TRACE_EVENT2(m,p1,p2) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_EVENT, m,p1,p2);}
+#define DUN_TRACE_EVENT3(m,p1,p2,p3) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define DUN_TRACE_EVENT4(m,p1,p2,p3,p4) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define DUN_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define DUN_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define DUN_TRACE_DEBUG0(m) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_DUN, TRACE_TYPE_DEBUG, m);}
-#define DUN_TRACE_DEBUG1(m,p1) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_DUN, TRACE_TYPE_DEBUG, m,p1);}
-#define DUN_TRACE_DEBUG2(m,p1,p2) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_DUN, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define DUN_TRACE_DEBUG3(m,p1,p2,p3) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_DUN, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define DUN_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_DUN, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define DUN_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_DUN, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define DUN_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_DUN, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define DUN_TRACE_DEBUG0(m) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_DEBUG, m);}
+#define DUN_TRACE_DEBUG1(m,p1) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_DEBUG, m,p1);}
+#define DUN_TRACE_DEBUG2(m,p1,p2) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define DUN_TRACE_DEBUG3(m,p1,p2,p3) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define DUN_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define DUN_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define DUN_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (dun_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_DUN, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* define traces for hardcopy cable replacement profile */
-#define HCRP_TRACE_ERROR0(m) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m);}
-#define HCRP_TRACE_ERROR1(m,p1) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m, p1);}
-#define HCRP_TRACE_ERROR2(m,p1,p2) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define HCRP_TRACE_ERROR3(m,p1,p2,p3) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define HCRP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define HCRP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define HCRP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define HCRP_TRACE_ERROR0(m) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m);}
+#define HCRP_TRACE_ERROR1(m,p1) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m, p1);}
+#define HCRP_TRACE_ERROR2(m,p1,p2) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define HCRP_TRACE_ERROR3(m,p1,p2,p3) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define HCRP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define HCRP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define HCRP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define HCRP_TRACE_WARNING0(m) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m);}
-#define HCRP_TRACE_WARNING1(m,p1) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1);}
-#define HCRP_TRACE_WARNING2(m,p1,p2) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define HCRP_TRACE_WARNING3(m,p1,p2,p3) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define HCRP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define HCRP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define HCRP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define HCRP_TRACE_WARNING0(m) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m);}
+#define HCRP_TRACE_WARNING1(m,p1) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1);}
+#define HCRP_TRACE_WARNING2(m,p1,p2) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define HCRP_TRACE_WARNING3(m,p1,p2,p3) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define HCRP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define HCRP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define HCRP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define HCRP_TRACE_API0(m) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_HCRP, TRACE_TYPE_API, m);}
-#define HCRP_TRACE_API1(m,p1) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_HCRP, TRACE_TYPE_API, m, p1);}
-#define HCRP_TRACE_API2(m,p1,p2) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2);}
-#define HCRP_TRACE_API3(m,p1,p2,p3) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define HCRP_TRACE_API4(m,p1,p2,p3,p4) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define HCRP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define HCRP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define HCRP_TRACE_API0(m) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_API, m);}
+#define HCRP_TRACE_API1(m,p1) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_API, m, p1);}
+#define HCRP_TRACE_API2(m,p1,p2) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2);}
+#define HCRP_TRACE_API3(m,p1,p2,p3) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define HCRP_TRACE_API4(m,p1,p2,p3,p4) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define HCRP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define HCRP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define HCRP_TRACE_EVENT0(m) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m);}
-#define HCRP_TRACE_EVENT1(m,p1) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m, p1);}
-#define HCRP_TRACE_EVENT2(m,p1,p2) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define HCRP_TRACE_EVENT3(m,p1,p2,p3) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define HCRP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define HCRP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define HCRP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define HCRP_TRACE_EVENT0(m) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m);}
+#define HCRP_TRACE_EVENT1(m,p1) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m, p1);}
+#define HCRP_TRACE_EVENT2(m,p1,p2) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define HCRP_TRACE_EVENT3(m,p1,p2,p3) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define HCRP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define HCRP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define HCRP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define HCRP_TRACE_DEBUG0(m) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m);}
-#define HCRP_TRACE_DEBUG1(m,p1) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1);}
-#define HCRP_TRACE_DEBUG2(m,p1,p2) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define HCRP_TRACE_DEBUG3(m,p1,p2,p3) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define HCRP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define HCRP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define HCRP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define HCRP_TRACE_DEBUG0(m) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m);}
+#define HCRP_TRACE_DEBUG1(m,p1) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1);}
+#define HCRP_TRACE_DEBUG2(m,p1,p2) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define HCRP_TRACE_DEBUG3(m,p1,p2,p3) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define HCRP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define HCRP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define HCRP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (hcrp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* define traces for multi-client server hardcopy cable replacement profile */
-#define HCRPM_TRACE_ERROR0(m) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m);}
-#define HCRPM_TRACE_ERROR1(m,p1) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m, p1);}
-#define HCRPM_TRACE_ERROR2(m,p1,p2) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define HCRPM_TRACE_ERROR3(m,p1,p2,p3) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define HCRPM_TRACE_ERROR4(m,p1,p2,p3,p4) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define HCRPM_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define HCRPM_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define HCRPM_TRACE_ERROR0(m) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m);}
+#define HCRPM_TRACE_ERROR1(m,p1) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m, p1);}
+#define HCRPM_TRACE_ERROR2(m,p1,p2) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define HCRPM_TRACE_ERROR3(m,p1,p2,p3) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define HCRPM_TRACE_ERROR4(m,p1,p2,p3,p4) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define HCRPM_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define HCRPM_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define HCRPM_TRACE_WARNING0(m) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m);}
-#define HCRPM_TRACE_WARNING1(m,p1) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1);}
-#define HCRPM_TRACE_WARNING2(m,p1,p2) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define HCRPM_TRACE_WARNING3(m,p1,p2,p3) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define HCRPM_TRACE_WARNING4(m,p1,p2,p3,p4) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define HCRPM_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define HCRPM_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define HCRPM_TRACE_WARNING0(m) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m);}
+#define HCRPM_TRACE_WARNING1(m,p1) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1);}
+#define HCRPM_TRACE_WARNING2(m,p1,p2) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define HCRPM_TRACE_WARNING3(m,p1,p2,p3) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define HCRPM_TRACE_WARNING4(m,p1,p2,p3,p4) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define HCRPM_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define HCRPM_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define HCRPM_TRACE_API0(m) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_HCRP, TRACE_TYPE_API, m);}
-#define HCRPM_TRACE_API1(m,p1) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_HCRP, TRACE_TYPE_API, m, p1);}
-#define HCRPM_TRACE_API2(m,p1,p2) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2);}
-#define HCRPM_TRACE_API3(m,p1,p2,p3) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define HCRPM_TRACE_API4(m,p1,p2,p3,p4) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define HCRPM_TRACE_API5(m,p1,p2,p3,p4,p5) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define HCRPM_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define HCRPM_TRACE_API0(m) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_API, m);}
+#define HCRPM_TRACE_API1(m,p1) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_API, m, p1);}
+#define HCRPM_TRACE_API2(m,p1,p2) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2);}
+#define HCRPM_TRACE_API3(m,p1,p2,p3) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define HCRPM_TRACE_API4(m,p1,p2,p3,p4) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define HCRPM_TRACE_API5(m,p1,p2,p3,p4,p5) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define HCRPM_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define HCRPM_TRACE_EVENT0(m) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m);}
-#define HCRPM_TRACE_EVENT1(m,p1) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m, p1);}
-#define HCRPM_TRACE_EVENT2(m,p1,p2) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define HCRPM_TRACE_EVENT3(m,p1,p2,p3) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define HCRPM_TRACE_EVENT4(m,p1,p2,p3,p4) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define HCRPM_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define HCRPM_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define HCRPM_TRACE_EVENT0(m) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m);}
+#define HCRPM_TRACE_EVENT1(m,p1) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m, p1);}
+#define HCRPM_TRACE_EVENT2(m,p1,p2) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define HCRPM_TRACE_EVENT3(m,p1,p2,p3) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define HCRPM_TRACE_EVENT4(m,p1,p2,p3,p4) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define HCRPM_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define HCRPM_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define HCRPM_TRACE_DEBUG0(m) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m);}
-#define HCRPM_TRACE_DEBUG1(m,p1) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1);}
-#define HCRPM_TRACE_DEBUG2(m,p1,p2) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define HCRPM_TRACE_DEBUG3(m,p1,p2,p3) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define HCRPM_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define HCRPM_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define HCRPM_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define HCRPM_TRACE_DEBUG0(m) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m);}
+#define HCRPM_TRACE_DEBUG1(m,p1) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1);}
+#define HCRPM_TRACE_DEBUG2(m,p1,p2) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define HCRPM_TRACE_DEBUG3(m,p1,p2,p3) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define HCRPM_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define HCRPM_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define HCRPM_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (hcrpm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCRP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* define traces for RPC */
-#define RPC_TRACE_ERROR0(m) {if (rpc_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_ERROR, (m));}
-#define RPC_TRACE_ERROR1(m,p1) {if (rpc_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_ERROR, \
+#define RPC_TRACE_ERROR0(m) {if (rpc_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_ERROR, (m));}
+#define RPC_TRACE_ERROR1(m,p1) {if (rpc_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1));}
-#define RPC_TRACE_ERROR2(m,p1,p2) {if (rpc_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_ERROR, \
+#define RPC_TRACE_ERROR2(m,p1,p2) {if (rpc_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1), (UINT32)(p2));}
-#define RPC_TRACE_ERROR3(m,p1,p2,p3) {if (rpc_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_ERROR, \
+#define RPC_TRACE_ERROR3(m,p1,p2,p3) {if (rpc_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
-#define RPC_TRACE_ERROR4(m,p1,p2,p3,p4) {if (rpc_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_ERROR, \
+#define RPC_TRACE_ERROR4(m,p1,p2,p3,p4) {if (rpc_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
-#define RPC_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (rpc_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_ERROR, \
+#define RPC_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (rpc_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
-#define RPC_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (rpc_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_ERROR, \
+#define RPC_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (rpc_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
-#define RPC_TRACE_WARNING0(m) {if (rpc_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_WARNING, (m));}
-#define RPC_TRACE_WARNING1(m,p1) {if (rpc_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_WARNING, \
+#define RPC_TRACE_WARNING0(m) {if (rpc_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_WARNING, (m));}
+#define RPC_TRACE_WARNING1(m,p1) {if (rpc_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1));}
-#define RPC_TRACE_WARNING2(m,p1,p2) {if (rpc_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_WARNING, \
+#define RPC_TRACE_WARNING2(m,p1,p2) {if (rpc_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1), (UINT32)(p2));}
-#define RPC_TRACE_WARNING3(m,p1,p2,p3) {if (rpc_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_WARNING, \
+#define RPC_TRACE_WARNING3(m,p1,p2,p3) {if (rpc_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
-#define RPC_TRACE_WARNING4(m,p1,p2,p3,p4) {if (rpc_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_WARNING, \
+#define RPC_TRACE_WARNING4(m,p1,p2,p3,p4) {if (rpc_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
-#define RPC_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (rpc_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_WARNING, \
+#define RPC_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (rpc_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
-#define RPC_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (rpc_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_WARNING, \
+#define RPC_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (rpc_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
-#define RPC_TRACE_API0(m) {if (rpc_trace_level >= BT_TRACE_LEVEL_API) LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_API, (m));}
-#define RPC_TRACE_API1(m,p1) {if (rpc_trace_level >= BT_TRACE_LEVEL_API) LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_API, \
+#define RPC_TRACE_API0(m) {if (rpc_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_API, (m));}
+#define RPC_TRACE_API1(m,p1) {if (rpc_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_API, \
(m), (UINT32)(p1));}
-#define RPC_TRACE_API2(m,p1,p2) {if (rpc_trace_level >= BT_TRACE_LEVEL_API) LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_API, \
+#define RPC_TRACE_API2(m,p1,p2) {if (rpc_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_API, \
(m), (UINT32)(p1), (UINT32)(p2));}
-#define RPC_TRACE_API3(m,p1,p2,p3) {if (rpc_trace_level >= BT_TRACE_LEVEL_API) LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_API, \
+#define RPC_TRACE_API3(m,p1,p2,p3) {if (rpc_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_API, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
-#define RPC_TRACE_API4(m,p1,p2,p3,p4) {if (rpc_trace_level >= BT_TRACE_LEVEL_API) LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_API, \
+#define RPC_TRACE_API4(m,p1,p2,p3,p4) {if (rpc_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_API, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
-#define RPC_TRACE_API5(m,p1,p2,p3,p4,p5) {if (rpc_trace_level >= BT_TRACE_LEVEL_API) LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_API, \
+#define RPC_TRACE_API5(m,p1,p2,p3,p4,p5) {if (rpc_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_API, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
-#define RPC_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (rpc_trace_level >= BT_TRACE_LEVEL_API) LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_API, \
+#define RPC_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (rpc_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_API, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
-#define RPC_TRACE_EVENT0(m) {if (rpc_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_EVENT, (m));}
-#define RPC_TRACE_EVENT1(m,p1) {if (rpc_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_EVENT, \
+#define RPC_TRACE_EVENT0(m) {if (rpc_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_EVENT, (m));}
+#define RPC_TRACE_EVENT1(m,p1) {if (rpc_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1));}
-#define RPC_TRACE_EVENT2(m,p1,p2) {if (rpc_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_EVENT, \
+#define RPC_TRACE_EVENT2(m,p1,p2) {if (rpc_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1), (UINT32)(p2));}
-#define RPC_TRACE_EVENT3(m,p1,p2,p3) {if (rpc_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_EVENT, \
+#define RPC_TRACE_EVENT3(m,p1,p2,p3) {if (rpc_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
-#define RPC_TRACE_EVENT4(m,p1,p2,p3,p4) {if (rpc_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_EVENT, \
+#define RPC_TRACE_EVENT4(m,p1,p2,p3,p4) {if (rpc_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
-#define RPC_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (rpc_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_EVENT, \
+#define RPC_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (rpc_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
-#define RPC_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (rpc_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_EVENT, \
+#define RPC_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (rpc_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
-#define RPC_TRACE_DEBUG0(m) {if (rpc_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_DEBUG, (m));}
-#define RPC_TRACE_DEBUG1(m,p1) {if (rpc_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_DEBUG, \
+#define RPC_TRACE_DEBUG0(m) {if (rpc_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_DEBUG, (m));}
+#define RPC_TRACE_DEBUG1(m,p1) {if (rpc_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1));}
-#define RPC_TRACE_DEBUG2(m,p1,p2) {if (rpc_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_DEBUG, \
+#define RPC_TRACE_DEBUG2(m,p1,p2) {if (rpc_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2));}
-#define RPC_TRACE_DEBUG3(m,p1,p2,p3) {if (rpc_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_DEBUG, \
+#define RPC_TRACE_DEBUG3(m,p1,p2,p3) {if (rpc_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
-#define RPC_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (rpc_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_DEBUG, \
+#define RPC_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (rpc_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
-#define RPC_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (rpc_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_DEBUG, \
+#define RPC_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (rpc_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
-#define RPC_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (rpc_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_DEBUG, \
+#define RPC_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (rpc_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_RPC | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
/* define traces for BNEP */
-#define BNEP_TRACE_ERROR0(m) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, m);}
-#define BNEP_TRACE_ERROR1(m,p1) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, m, p1);}
-#define BNEP_TRACE_ERROR2(m,p1,p2) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define BNEP_TRACE_ERROR3(m,p1,p2,p3) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define BNEP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define BNEP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define BNEP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define BNEP_TRACE_ERROR0(m) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, m);}
+#define BNEP_TRACE_ERROR1(m,p1) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, m, p1);}
+#define BNEP_TRACE_ERROR2(m,p1,p2) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define BNEP_TRACE_ERROR3(m,p1,p2,p3) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define BNEP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define BNEP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define BNEP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define BNEP_TRACE_WARNING0(m) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, m);}
-#define BNEP_TRACE_WARNING1(m,p1) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, m,p1);}
-#define BNEP_TRACE_WARNING2(m,p1,p2) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define BNEP_TRACE_WARNING3(m,p1,p2,p3) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define BNEP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define BNEP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define BNEP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define BNEP_TRACE_WARNING0(m) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, m);}
+#define BNEP_TRACE_WARNING1(m,p1) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, m,p1);}
+#define BNEP_TRACE_WARNING2(m,p1,p2) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define BNEP_TRACE_WARNING3(m,p1,p2,p3) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define BNEP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define BNEP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define BNEP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define BNEP_TRACE_API0(m) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_BNEP, TRACE_TYPE_API, m);}
-#define BNEP_TRACE_API1(m,p1) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_BNEP, TRACE_TYPE_API, m, p1);}
-#define BNEP_TRACE_API2(m,p1,p2) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_BNEP, TRACE_TYPE_API, m,p1,p2);}
-#define BNEP_TRACE_API3(m,p1,p2,p3) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_BNEP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define BNEP_TRACE_API4(m,p1,p2,p3,p4) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_BNEP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define BNEP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_BNEP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define BNEP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_BNEP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define BNEP_TRACE_API0(m) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_API, m);}
+#define BNEP_TRACE_API1(m,p1) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_API, m, p1);}
+#define BNEP_TRACE_API2(m,p1,p2) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_API, m,p1,p2);}
+#define BNEP_TRACE_API3(m,p1,p2,p3) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define BNEP_TRACE_API4(m,p1,p2,p3,p4) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define BNEP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define BNEP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define BNEP_TRACE_EVENT0(m) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, m);}
-#define BNEP_TRACE_EVENT1(m,p1) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, m, p1);}
-#define BNEP_TRACE_EVENT2(m,p1,p2) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define BNEP_TRACE_EVENT3(m,p1,p2,p3) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define BNEP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define BNEP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define BNEP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define BNEP_TRACE_EVENT0(m) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, m);}
+#define BNEP_TRACE_EVENT1(m,p1) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, m, p1);}
+#define BNEP_TRACE_EVENT2(m,p1,p2) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define BNEP_TRACE_EVENT3(m,p1,p2,p3) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define BNEP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define BNEP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define BNEP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define BNEP_TRACE_DEBUG0(m) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, m);}
-#define BNEP_TRACE_DEBUG1(m,p1) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, m,p1);}
-#define BNEP_TRACE_DEBUG2(m,p1,p2) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define BNEP_TRACE_DEBUG3(m,p1,p2,p3) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define BNEP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define BNEP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define BNEP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define BNEP_TRACE_DEBUG0(m) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, m);}
+#define BNEP_TRACE_DEBUG1(m,p1) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, m,p1);}
+#define BNEP_TRACE_DEBUG2(m,p1,p2) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define BNEP_TRACE_DEBUG3(m,p1,p2,p3) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define BNEP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define BNEP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define BNEP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* define traces for PAN */
-#define PAN_TRACE_ERROR0(m) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, m);}
-#define PAN_TRACE_ERROR1(m,p1) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, m, p1);}
-#define PAN_TRACE_ERROR2(m,p1,p2) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, m,p1,p2);}
-#define PAN_TRACE_ERROR3(m,p1,p2,p3) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define PAN_TRACE_ERROR4(m,p1,p2,p3,p4) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define PAN_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define PAN_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define PAN_TRACE_ERROR0(m) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, m);}
+#define PAN_TRACE_ERROR1(m,p1) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, m, p1);}
+#define PAN_TRACE_ERROR2(m,p1,p2) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, m,p1,p2);}
+#define PAN_TRACE_ERROR3(m,p1,p2,p3) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define PAN_TRACE_ERROR4(m,p1,p2,p3,p4) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define PAN_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define PAN_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define PAN_TRACE_WARNING0(m) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, m);}
-#define PAN_TRACE_WARNING1(m,p1) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, m,p1);}
-#define PAN_TRACE_WARNING2(m,p1,p2) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, m,p1,p2);}
-#define PAN_TRACE_WARNING3(m,p1,p2,p3) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define PAN_TRACE_WARNING4(m,p1,p2,p3,p4) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define PAN_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define PAN_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define PAN_TRACE_WARNING0(m) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, m);}
+#define PAN_TRACE_WARNING1(m,p1) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, m,p1);}
+#define PAN_TRACE_WARNING2(m,p1,p2) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, m,p1,p2);}
+#define PAN_TRACE_WARNING3(m,p1,p2,p3) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define PAN_TRACE_WARNING4(m,p1,p2,p3,p4) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define PAN_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define PAN_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define PAN_TRACE_API0(m) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_PAN, TRACE_TYPE_API, m);}
-#define PAN_TRACE_API1(m,p1) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_PAN, TRACE_TYPE_API, m, p1);}
-#define PAN_TRACE_API2(m,p1,p2) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_PAN, TRACE_TYPE_API, m,p1,p2);}
-#define PAN_TRACE_API3(m,p1,p2,p3) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_PAN, TRACE_TYPE_API, m,p1,p2,p3);}
-#define PAN_TRACE_API4(m,p1,p2,p3,p4) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_PAN, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define PAN_TRACE_API5(m,p1,p2,p3,p4,p5) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_PAN, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define PAN_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_PAN, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define PAN_TRACE_API0(m) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_API, m);}
+#define PAN_TRACE_API1(m,p1) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_API, m, p1);}
+#define PAN_TRACE_API2(m,p1,p2) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_API, m,p1,p2);}
+#define PAN_TRACE_API3(m,p1,p2,p3) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_API, m,p1,p2,p3);}
+#define PAN_TRACE_API4(m,p1,p2,p3,p4) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define PAN_TRACE_API5(m,p1,p2,p3,p4,p5) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define PAN_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define PAN_TRACE_EVENT0(m) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, m);}
-#define PAN_TRACE_EVENT1(m,p1) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, m, p1);}
-#define PAN_TRACE_EVENT2(m,p1,p2) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, m,p1,p2);}
-#define PAN_TRACE_EVENT3(m,p1,p2,p3) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define PAN_TRACE_EVENT4(m,p1,p2,p3,p4) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define PAN_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define PAN_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define PAN_TRACE_EVENT0(m) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, m);}
+#define PAN_TRACE_EVENT1(m,p1) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, m, p1);}
+#define PAN_TRACE_EVENT2(m,p1,p2) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, m,p1,p2);}
+#define PAN_TRACE_EVENT3(m,p1,p2,p3) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define PAN_TRACE_EVENT4(m,p1,p2,p3,p4) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define PAN_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define PAN_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define PAN_TRACE_DEBUG0(m) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, m);}
-#define PAN_TRACE_DEBUG1(m,p1) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, m,p1);}
-#define PAN_TRACE_DEBUG2(m,p1,p2) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define PAN_TRACE_DEBUG3(m,p1,p2,p3) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define PAN_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define PAN_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define PAN_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define PAN_TRACE_DEBUG0(m) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, m);}
+#define PAN_TRACE_DEBUG1(m,p1) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, m,p1);}
+#define PAN_TRACE_DEBUG2(m,p1,p2) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define PAN_TRACE_DEBUG3(m,p1,p2,p3) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define PAN_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define PAN_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define PAN_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* define traces for SIM */
-#define SAP_TRACE_ERROR0(m) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_SAP, TRACE_TYPE_ERROR, m);}
-#define SAP_TRACE_ERROR1(m,p1) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_SAP, TRACE_TYPE_ERROR, m, p1);}
-#define SAP_TRACE_ERROR2(m,p1,p2) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_SAP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define SAP_TRACE_ERROR3(m,p1,p2,p3) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_SAP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define SAP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_SAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define SAP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_SAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define SAP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_SAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define SAP_TRACE_ERROR0(m) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_ERROR, m);}
+#define SAP_TRACE_ERROR1(m,p1) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_ERROR, m, p1);}
+#define SAP_TRACE_ERROR2(m,p1,p2) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define SAP_TRACE_ERROR3(m,p1,p2,p3) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define SAP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define SAP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define SAP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define SAP_TRACE_WARNING0(m) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_SAP, TRACE_TYPE_WARNING, m);}
-#define SAP_TRACE_WARNING1(m,p1) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_SAP, TRACE_TYPE_WARNING, m,p1);}
-#define SAP_TRACE_WARNING2(m,p1,p2) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_SAP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define SAP_TRACE_WARNING3(m,p1,p2,p3) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_SAP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define SAP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_SAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define SAP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_SAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define SAP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_SAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define SAP_TRACE_WARNING0(m) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_WARNING, m);}
+#define SAP_TRACE_WARNING1(m,p1) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_WARNING, m,p1);}
+#define SAP_TRACE_WARNING2(m,p1,p2) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define SAP_TRACE_WARNING3(m,p1,p2,p3) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define SAP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define SAP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define SAP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define SAP_TRACE_API0(m) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_SAP, TRACE_TYPE_API, m);}
-#define SAP_TRACE_API1(m,p1) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_SAP, TRACE_TYPE_API, m, p1);}
-#define SAP_TRACE_API2(m,p1,p2) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_SAP, TRACE_TYPE_API, m,p1,p2);}
-#define SAP_TRACE_API3(m,p1,p2,p3) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_SAP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define SAP_TRACE_API4(m,p1,p2,p3,p4) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_SAP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define SAP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_SAP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define SAP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_SAP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define SAP_TRACE_API0(m) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_API, m);}
+#define SAP_TRACE_API1(m,p1) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_API, m, p1);}
+#define SAP_TRACE_API2(m,p1,p2) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_API, m,p1,p2);}
+#define SAP_TRACE_API3(m,p1,p2,p3) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define SAP_TRACE_API4(m,p1,p2,p3,p4) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define SAP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define SAP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define SAP_TRACE_EVENT0(m) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_SAP, TRACE_TYPE_EVENT, m);}
-#define SAP_TRACE_EVENT1(m,p1) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_SAP, TRACE_TYPE_EVENT, m, p1);}
-#define SAP_TRACE_EVENT2(m,p1,p2) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_SAP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define SAP_TRACE_EVENT3(m,p1,p2,p3) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_SAP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define SAP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_SAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define SAP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_SAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define SAP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_SAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define SAP_TRACE_EVENT0(m) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_EVENT, m);}
+#define SAP_TRACE_EVENT1(m,p1) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_EVENT, m, p1);}
+#define SAP_TRACE_EVENT2(m,p1,p2) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define SAP_TRACE_EVENT3(m,p1,p2,p3) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define SAP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define SAP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define SAP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define SAP_TRACE_DEBUG0(m) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_SAP, TRACE_TYPE_DEBUG, m);}
-#define SAP_TRACE_DEBUG1(m,p1) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_SAP, TRACE_TYPE_DEBUG, m,p1);}
-#define SAP_TRACE_DEBUG2(m,p1,p2) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_SAP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define SAP_TRACE_DEBUG3(m,p1,p2,p3) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_SAP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define SAP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_SAP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define SAP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_SAP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define SAP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_SAP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define SAP_TRACE_DEBUG0(m) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_DEBUG, m);}
+#define SAP_TRACE_DEBUG1(m,p1) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_DEBUG, m,p1);}
+#define SAP_TRACE_DEBUG2(m,p1,p2) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define SAP_TRACE_DEBUG3(m,p1,p2,p3) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define SAP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define SAP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define SAP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (sap_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SAP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for OPP profile
*/
-#define OPP_TRACE_ERROR0(m) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_OPP, TRACE_TYPE_ERROR, m);}
-#define OPP_TRACE_ERROR1(m,p1) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_OPP, TRACE_TYPE_ERROR, m,p1);}
-#define OPP_TRACE_ERROR2(m,p1,p2) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_OPP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define OPP_TRACE_ERROR3(m,p1,p2,p3) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_OPP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define OPP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_OPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define OPP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_OPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define OPP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_OPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define OPP_TRACE_ERROR0(m) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_ERROR, m);}
+#define OPP_TRACE_ERROR1(m,p1) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_ERROR, m,p1);}
+#define OPP_TRACE_ERROR2(m,p1,p2) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define OPP_TRACE_ERROR3(m,p1,p2,p3) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define OPP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define OPP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define OPP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define OPP_TRACE_WARNING0(m) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_OPP, TRACE_TYPE_WARNING, m);}
-#define OPP_TRACE_WARNING1(m,p1) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_OPP, TRACE_TYPE_WARNING, m,p1);}
-#define OPP_TRACE_WARNING2(m,p1,p2) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_OPP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define OPP_TRACE_WARNING3(m,p1,p2,p3) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_OPP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define OPP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_OPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define OPP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_OPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define OPP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_OPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define OPP_TRACE_WARNING0(m) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_WARNING, m);}
+#define OPP_TRACE_WARNING1(m,p1) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_WARNING, m,p1);}
+#define OPP_TRACE_WARNING2(m,p1,p2) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define OPP_TRACE_WARNING3(m,p1,p2,p3) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define OPP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define OPP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define OPP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define OPP_TRACE_EVENT0(m) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_OPP, TRACE_TYPE_EVENT, m);}
-#define OPP_TRACE_EVENT1(m,p1) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_OPP, TRACE_TYPE_EVENT, m, p1);}
-#define OPP_TRACE_EVENT2(m,p1,p2) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_OPP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define OPP_TRACE_EVENT3(m,p1,p2,p3) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_OPP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define OPP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_OPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define OPP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_OPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define OPP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_OPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define OPP_TRACE_EVENT0(m) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_EVENT, m);}
+#define OPP_TRACE_EVENT1(m,p1) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_EVENT, m, p1);}
+#define OPP_TRACE_EVENT2(m,p1,p2) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define OPP_TRACE_EVENT3(m,p1,p2,p3) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define OPP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define OPP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define OPP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define OPP_TRACE_DEBUG0(m) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_OPP, TRACE_TYPE_DEBUG, m);}
-#define OPP_TRACE_DEBUG1(m,p1) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_OPP, TRACE_TYPE_DEBUG, m,p1);}
-#define OPP_TRACE_DEBUG2(m,p1,p2) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_OPP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define OPP_TRACE_DEBUG3(m,p1,p2,p3) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_OPP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define OPP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_OPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define OPP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_OPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define OPP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_OPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define OPP_TRACE_DEBUG0(m) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_DEBUG, m);}
+#define OPP_TRACE_DEBUG1(m,p1) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_DEBUG, m,p1);}
+#define OPP_TRACE_DEBUG2(m,p1,p2) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define OPP_TRACE_DEBUG3(m,p1,p2,p3) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define OPP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define OPP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define OPP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (opp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_OPP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for FTP profile
*/
-#define FTP_TRACE_ERROR0(m) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_FTP, TRACE_TYPE_ERROR, m);}
-#define FTP_TRACE_ERROR1(m,p1) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_FTP, TRACE_TYPE_ERROR, m,p1);}
-#define FTP_TRACE_ERROR2(m,p1,p2) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_FTP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define FTP_TRACE_ERROR3(m,p1,p2,p3) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_FTP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define FTP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_FTP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define FTP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_FTP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define FTP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_FTP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define FTP_TRACE_ERROR0(m) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_ERROR, m);}
+#define FTP_TRACE_ERROR1(m,p1) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_ERROR, m,p1);}
+#define FTP_TRACE_ERROR2(m,p1,p2) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define FTP_TRACE_ERROR3(m,p1,p2,p3) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define FTP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define FTP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define FTP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define FTP_TRACE_WARNING0(m) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_FTP, TRACE_TYPE_WARNING, m);}
-#define FTP_TRACE_WARNING1(m,p1) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_FTP, TRACE_TYPE_WARNING, m,p1);}
-#define FTP_TRACE_WARNING2(m,p1,p2) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_FTP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define FTP_TRACE_WARNING3(m,p1,p2,p3) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_FTP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define FTP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_FTP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define FTP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_FTP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define FTP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_FTP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define FTP_TRACE_WARNING0(m) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_WARNING, m);}
+#define FTP_TRACE_WARNING1(m,p1) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_WARNING, m,p1);}
+#define FTP_TRACE_WARNING2(m,p1,p2) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define FTP_TRACE_WARNING3(m,p1,p2,p3) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define FTP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define FTP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define FTP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define FTP_TRACE_EVENT0(m) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_FTP, TRACE_TYPE_EVENT, m);}
-#define FTP_TRACE_EVENT1(m,p1) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_FTP, TRACE_TYPE_EVENT, m, p1);}
-#define FTP_TRACE_EVENT2(m,p1,p2) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_FTP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define FTP_TRACE_EVENT3(m,p1,p2,p3) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_FTP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define FTP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_FTP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define FTP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_FTP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define FTP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_FTP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define FTP_TRACE_EVENT0(m) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_EVENT, m);}
+#define FTP_TRACE_EVENT1(m,p1) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_EVENT, m, p1);}
+#define FTP_TRACE_EVENT2(m,p1,p2) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define FTP_TRACE_EVENT3(m,p1,p2,p3) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define FTP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define FTP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define FTP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define FTP_TRACE_DEBUG0(m) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m);}
-#define FTP_TRACE_DEBUG1(m,p1) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1);}
-#define FTP_TRACE_DEBUG2(m,p1,p2) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define FTP_TRACE_DEBUG3(m,p1,p2,p3) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define FTP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define FTP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define FTP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define FTP_TRACE_DEBUG0(m) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m);}
+#define FTP_TRACE_DEBUG1(m,p1) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1);}
+#define FTP_TRACE_DEBUG2(m,p1,p2) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define FTP_TRACE_DEBUG3(m,p1,p2,p3) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define FTP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define FTP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define FTP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (ftp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the A2DP profile
*/
-#define A2D_TRACE_ERROR0(m) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,m);}
-#define A2D_TRACE_ERROR1(m,p1) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,m,p1);}
-#define A2D_TRACE_ERROR2(m,p1,p2) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,m,p1,p2);}
-#define A2D_TRACE_ERROR3(m,p1,p2,p3) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,m,p1,p2,p3);}
-#define A2D_TRACE_ERROR4(m,p1,p2,p3,p4) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,m,p1,p2,p3,p4);}
-#define A2D_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,m,p1,p2,p3,p4,p5);}
-#define A2D_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,m,p1,p2,p3,p4,p5,p6);}
+#define A2D_TRACE_ERROR0(m) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,m);}
+#define A2D_TRACE_ERROR1(m,p1) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,m,p1);}
+#define A2D_TRACE_ERROR2(m,p1,p2) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,m,p1,p2);}
+#define A2D_TRACE_ERROR3(m,p1,p2,p3) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,m,p1,p2,p3);}
+#define A2D_TRACE_ERROR4(m,p1,p2,p3,p4) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,m,p1,p2,p3,p4);}
+#define A2D_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,m,p1,p2,p3,p4,p5);}
+#define A2D_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,m,p1,p2,p3,p4,p5,p6);}
-#define A2D_TRACE_WARNING0(m) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,m);}
-#define A2D_TRACE_WARNING1(m,p1) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,m,p1);}
-#define A2D_TRACE_WARNING2(m,p1,p2) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,m,p1,p2);}
-#define A2D_TRACE_WARNING3(m,p1,p2,p3) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,m,p1,p2,p3);}
-#define A2D_TRACE_WARNING4(m,p1,p2,p3,p4) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,m,p1,p2,p3,p4);}
-#define A2D_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,m,p1,p2,p3,p4,p5);}
-#define A2D_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,m,p1,p2,p3,p4,p5,p6);}
+#define A2D_TRACE_WARNING0(m) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,m);}
+#define A2D_TRACE_WARNING1(m,p1) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,m,p1);}
+#define A2D_TRACE_WARNING2(m,p1,p2) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,m,p1,p2);}
+#define A2D_TRACE_WARNING3(m,p1,p2,p3) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,m,p1,p2,p3);}
+#define A2D_TRACE_WARNING4(m,p1,p2,p3,p4) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,m,p1,p2,p3,p4);}
+#define A2D_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,m,p1,p2,p3,p4,p5);}
+#define A2D_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,m,p1,p2,p3,p4,p5,p6);}
-#define A2D_TRACE_EVENT0(m) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,m);}
-#define A2D_TRACE_EVENT1(m,p1) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,m, p1);}
-#define A2D_TRACE_EVENT2(m,p1,p2) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,m,p1,p2);}
-#define A2D_TRACE_EVENT3(m,p1,p2,p3) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,m,p1,p2,p3);}
-#define A2D_TRACE_EVENT4(m,p1,p2,p3,p4) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,m,p1,p2,p3,p4);}
-#define A2D_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,m,p1,p2,p3,p4,p5);}
-#define A2D_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,m,p1,p2,p3,p4,p5,p6);}
+#define A2D_TRACE_EVENT0(m) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,m);}
+#define A2D_TRACE_EVENT1(m,p1) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,m, p1);}
+#define A2D_TRACE_EVENT2(m,p1,p2) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,m,p1,p2);}
+#define A2D_TRACE_EVENT3(m,p1,p2,p3) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,m,p1,p2,p3);}
+#define A2D_TRACE_EVENT4(m,p1,p2,p3,p4) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,m,p1,p2,p3,p4);}
+#define A2D_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,m,p1,p2,p3,p4,p5);}
+#define A2D_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,m,p1,p2,p3,p4,p5,p6);}
-#define A2D_TRACE_DEBUG0(m) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,m);}
-#define A2D_TRACE_DEBUG1(m,p1) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,m,p1);}
-#define A2D_TRACE_DEBUG2(m,p1,p2) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,m,p1,p2);}
-#define A2D_TRACE_DEBUG3(m,p1,p2,p3) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,m,p1,p2,p3);}
-#define A2D_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4);}
-#define A2D_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4,p5);}
-#define A2D_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4,p5,p6);}
+#define A2D_TRACE_DEBUG0(m) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,m);}
+#define A2D_TRACE_DEBUG1(m,p1) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,m,p1);}
+#define A2D_TRACE_DEBUG2(m,p1,p2) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,m,p1,p2);}
+#define A2D_TRACE_DEBUG3(m,p1,p2,p3) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,m,p1,p2,p3);}
+#define A2D_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4);}
+#define A2D_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4,p5);}
+#define A2D_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4,p5,p6);}
-#define A2D_TRACE_API0(m) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_A2D, TRACE_TYPE_API,m);}
-#define A2D_TRACE_API1(m,p1) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_A2D, TRACE_TYPE_API,m, p1);}
-#define A2D_TRACE_API2(m,p1,p2) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_A2D, TRACE_TYPE_API,m,p1,p2);}
-#define A2D_TRACE_API3(m,p1,p2,p3) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_A2D, TRACE_TYPE_API,m,p1,p2,p3);}
-#define A2D_TRACE_API4(m,p1,p2,p3,p4) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_A2D, TRACE_TYPE_API,m,p1,p2,p3,p4);}
-#define A2D_TRACE_API5(m,p1,p2,p3,p4,p5) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_A2D, TRACE_TYPE_API,m,p1,p2,p3,p4,p5);}
-#define A2D_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_A2D, TRACE_TYPE_API,m,p1,p2,p3,p4,p5,p6);}
+#define A2D_TRACE_API0(m) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_API,m);}
+#define A2D_TRACE_API1(m,p1) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_API,m, p1);}
+#define A2D_TRACE_API2(m,p1,p2) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_API,m,p1,p2);}
+#define A2D_TRACE_API3(m,p1,p2,p3) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_API,m,p1,p2,p3);}
+#define A2D_TRACE_API4(m,p1,p2,p3,p4) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_API,m,p1,p2,p3,p4);}
+#define A2D_TRACE_API5(m,p1,p2,p3,p4,p5) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_API,m,p1,p2,p3,p4,p5);}
+#define A2D_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_API,m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the VDP profile
*/
-#define VDP_TRACE_ERROR0(m) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m);}
-#define VDP_TRACE_ERROR1(m,p1) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1);}
-#define VDP_TRACE_ERROR2(m,p1,p2) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2);}
-#define VDP_TRACE_ERROR3(m,p1,p2,p3) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2,p3);}
-#define VDP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2,p3,p4);}
-#define VDP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2,p3,p4,p5);}
-#define VDP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2,p3,p4,p5,p6);}
+#define VDP_TRACE_ERROR0(m) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m);}
+#define VDP_TRACE_ERROR1(m,p1) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1);}
+#define VDP_TRACE_ERROR2(m,p1,p2) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2);}
+#define VDP_TRACE_ERROR3(m,p1,p2,p3) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2,p3);}
+#define VDP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2,p3,p4);}
+#define VDP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2,p3,p4,p5);}
+#define VDP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2,p3,p4,p5,p6);}
-#define VDP_TRACE_WARNING0(m) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m);}
-#define VDP_TRACE_WARNING1(m,p1) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1);}
-#define VDP_TRACE_WARNING2(m,p1,p2) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2);}
-#define VDP_TRACE_WARNING3(m,p1,p2,p3) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2,p3);}
-#define VDP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2,p3,p4);}
-#define VDP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2,p3,p4,p5);}
-#define VDP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2,p3,p4,p5,p6);}
+#define VDP_TRACE_WARNING0(m) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m);}
+#define VDP_TRACE_WARNING1(m,p1) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1);}
+#define VDP_TRACE_WARNING2(m,p1,p2) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2);}
+#define VDP_TRACE_WARNING3(m,p1,p2,p3) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2,p3);}
+#define VDP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2,p3,p4);}
+#define VDP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2,p3,p4,p5);}
+#define VDP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2,p3,p4,p5,p6);}
-#define VDP_TRACE_EVENT0(m) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m);}
-#define VDP_TRACE_EVENT1(m,p1) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m, p1);}
-#define VDP_TRACE_EVENT2(m,p1,p2) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2);}
-#define VDP_TRACE_EVENT3(m,p1,p2,p3) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2,p3);}
-#define VDP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2,p3,p4);}
-#define VDP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2,p3,p4,p5);}
-#define VDP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2,p3,p4,p5,p6);}
+#define VDP_TRACE_EVENT0(m) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m);}
+#define VDP_TRACE_EVENT1(m,p1) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m, p1);}
+#define VDP_TRACE_EVENT2(m,p1,p2) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2);}
+#define VDP_TRACE_EVENT3(m,p1,p2,p3) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2,p3);}
+#define VDP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2,p3,p4);}
+#define VDP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2,p3,p4,p5);}
+#define VDP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2,p3,p4,p5,p6);}
-#define VDP_TRACE_DEBUG0(m) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m);}
-#define VDP_TRACE_DEBUG1(m,p1) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1);}
-#define VDP_TRACE_DEBUG2(m,p1,p2) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2);}
-#define VDP_TRACE_DEBUG3(m,p1,p2,p3) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2,p3);}
-#define VDP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4);}
-#define VDP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4,p5);}
-#define VDP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4,p5,p6);}
+#define VDP_TRACE_DEBUG0(m) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m);}
+#define VDP_TRACE_DEBUG1(m,p1) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1);}
+#define VDP_TRACE_DEBUG2(m,p1,p2) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2);}
+#define VDP_TRACE_DEBUG3(m,p1,p2,p3) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2,p3);}
+#define VDP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4);}
+#define VDP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4,p5);}
+#define VDP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4,p5,p6);}
-#define VDP_TRACE_API0(m) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_API,m);}
-#define VDP_TRACE_API1(m,p1) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_API,m, p1);}
-#define VDP_TRACE_API2(m,p1,p2) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2);}
-#define VDP_TRACE_API3(m,p1,p2,p3) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2,p3);}
-#define VDP_TRACE_API4(m,p1,p2,p3,p4) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2,p3,p4);}
-#define VDP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2,p3,p4,p5);}
-#define VDP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2,p3,p4,p5,p6);}
+#define VDP_TRACE_API0(m) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API,m);}
+#define VDP_TRACE_API1(m,p1) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API,m, p1);}
+#define VDP_TRACE_API2(m,p1,p2) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2);}
+#define VDP_TRACE_API3(m,p1,p2,p3) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2,p3);}
+#define VDP_TRACE_API4(m,p1,p2,p3,p4) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2,p3,p4);}
+#define VDP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2,p3,p4,p5);}
+#define VDP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (vdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the LM unit
*/
-#define LMP_TRACE_ERROR0(m) {if (lmp_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_LM, TRACE_TYPE_ERROR, m);}
-#define LMP_TRACE_ERROR1(m,p1) {if (lmp_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_LM, TRACE_TYPE_ERROR, m,p1);}
-#define LMP_TRACE_ERROR2(m,p1,p2) {if (lmp_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_LM, TRACE_TYPE_ERROR, m,p1,p2);}
-#define LMP_TRACE_ERROR3(m,p1,p2,p3) {if (lmp_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_LM, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define LMP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (lmp_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_LM, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define LMP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (lmp_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_LM, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define LMP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (lmp_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_LM, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define LMP_TRACE_ERROR0(m) {if (lmp_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_ERROR, m);}
+#define LMP_TRACE_ERROR1(m,p1) {if (lmp_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_ERROR, m,p1);}
+#define LMP_TRACE_ERROR2(m,p1,p2) {if (lmp_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_ERROR, m,p1,p2);}
+#define LMP_TRACE_ERROR3(m,p1,p2,p3) {if (lmp_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define LMP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (lmp_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define LMP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (lmp_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define LMP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (lmp_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define LMP_TRACE_WARNING0(m) {if (lmp_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_LM, TRACE_TYPE_WARNING, m);}
-#define LMP_TRACE_WARNING1(m,p1) {if (lmp_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_LM, TRACE_TYPE_WARNING, m,p1);}
-#define LMP_TRACE_WARNING2(m,p1,p2) {if (lmp_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_LM, TRACE_TYPE_WARNING, m,p1,p2);}
-#define LMP_TRACE_WARNING3(m,p1,p2,p3) {if (lmp_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_LM, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define LMP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (lmp_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_LM, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define LMP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (lmp_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_LM, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define LMP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (lmp_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_LM, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define LMP_TRACE_WARNING0(m) {if (lmp_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_WARNING, m);}
+#define LMP_TRACE_WARNING1(m,p1) {if (lmp_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_WARNING, m,p1);}
+#define LMP_TRACE_WARNING2(m,p1,p2) {if (lmp_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_WARNING, m,p1,p2);}
+#define LMP_TRACE_WARNING3(m,p1,p2,p3) {if (lmp_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define LMP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (lmp_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define LMP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (lmp_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define LMP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (lmp_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define LMP_TRACE_EVENT0(m) {if (lmp_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_LM, TRACE_TYPE_EVENT, m);}
-#define LMP_TRACE_EVENT1(m,p1) {if (lmp_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_LM, TRACE_TYPE_EVENT, m, p1);}
-#define LMP_TRACE_EVENT2(m,p1,p2) {if (lmp_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_LM, TRACE_TYPE_EVENT, m,p1,p2);}
-#define LMP_TRACE_EVENT3(m,p1,p2,p3) {if (lmp_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_LM, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define LMP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (lmp_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_LM, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define LMP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (lmp_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_LM, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define LMP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (lmp_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_LM, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define LMP_TRACE_EVENT0(m) {if (lmp_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_EVENT, m);}
+#define LMP_TRACE_EVENT1(m,p1) {if (lmp_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_EVENT, m, p1);}
+#define LMP_TRACE_EVENT2(m,p1,p2) {if (lmp_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_EVENT, m,p1,p2);}
+#define LMP_TRACE_EVENT3(m,p1,p2,p3) {if (lmp_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define LMP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (lmp_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define LMP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (lmp_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define LMP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (lmp_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define LMP_TRACE_DEBUG0(m) {if (lmp_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_LM, TRACE_TYPE_DEBUG, m);}
-#define LMP_TRACE_DEBUG1(m,p1) {if (lmp_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_LM, TRACE_TYPE_DEBUG, m,p1);}
-#define LMP_TRACE_DEBUG2(m,p1,p2) {if (lmp_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_LM, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define LMP_TRACE_DEBUG3(m,p1,p2,p3) {if (lmp_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_LM, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define LMP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (lmp_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_LM, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define LMP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (lmp_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_LM, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define LMP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (lmp_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_LM, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define LMP_TRACE_DEBUG0(m) {if (lmp_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_DEBUG, m);}
+#define LMP_TRACE_DEBUG1(m,p1) {if (lmp_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_DEBUG, m,p1);}
+#define LMP_TRACE_DEBUG2(m,p1,p2) {if (lmp_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define LMP_TRACE_DEBUG3(m,p1,p2,p3) {if (lmp_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define LMP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (lmp_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define LMP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (lmp_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define LMP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (lmp_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_LM, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the LC unit
*/
-#define LC_TRACE_ERROR0(m) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_ERROR]) BT_TRACE_0(TRACE_LAYER_LC, TRACE_TYPE_ERROR, m);}
-#define LC_TRACE_ERROR1(m,p1) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_ERROR]) BT_TRACE_1(TRACE_LAYER_LC, TRACE_TYPE_ERROR, m,p1);}
-#define LC_TRACE_ERROR2(m,p1,p2) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_ERROR]) BT_TRACE_2(TRACE_LAYER_LC, TRACE_TYPE_ERROR, m,p1,p2);}
-#define LC_TRACE_ERROR3(m,p1,p2,p3) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_ERROR]) BT_TRACE_3(TRACE_LAYER_LC, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define LC_TRACE_ERROR4(m,p1,p2,p3,p4) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_ERROR]) BT_TRACE_4(TRACE_LAYER_LC, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define LC_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_ERROR]) BT_TRACE_5(TRACE_LAYER_LC, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define LC_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_ERROR]) BT_TRACE_6(TRACE_LAYER_LC, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define LC_TRACE_ERROR0(m) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_ERROR]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_ERROR, m);}
+#define LC_TRACE_ERROR1(m,p1) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_ERROR]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_ERROR, m,p1);}
+#define LC_TRACE_ERROR2(m,p1,p2) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_ERROR]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_ERROR, m,p1,p2);}
+#define LC_TRACE_ERROR3(m,p1,p2,p3) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_ERROR]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define LC_TRACE_ERROR4(m,p1,p2,p3,p4) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_ERROR]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define LC_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_ERROR]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define LC_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_ERROR]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define LC_TRACE_WARNING0(m) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_WARNING]) BT_TRACE_0(TRACE_LAYER_LC, TRACE_TYPE_WARNING, m);}
-#define LC_TRACE_WARNING1(m,p1) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_WARNING]) BT_TRACE_1(TRACE_LAYER_LC, TRACE_TYPE_WARNING, m,p1);}
-#define LC_TRACE_WARNING2(m,p1,p2) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_WARNING]) BT_TRACE_2(TRACE_LAYER_LC, TRACE_TYPE_WARNING, m,p1,p2);}
-#define LC_TRACE_WARNING3(m,p1,p2,p3) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_WARNING]) BT_TRACE_3(TRACE_LAYER_LC, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define LC_TRACE_WARNING4(m,p1,p2,p3,p4) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_WARNING]) BT_TRACE_4(TRACE_LAYER_LC, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define LC_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_WARNING]) BT_TRACE_5(TRACE_LAYER_LC, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define LC_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_WARNING]) BT_TRACE_6(TRACE_LAYER_LC, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define LC_TRACE_WARNING0(m) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_WARNING]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_WARNING, m);}
+#define LC_TRACE_WARNING1(m,p1) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_WARNING]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_WARNING, m,p1);}
+#define LC_TRACE_WARNING2(m,p1,p2) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_WARNING]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_WARNING, m,p1,p2);}
+#define LC_TRACE_WARNING3(m,p1,p2,p3) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_WARNING]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define LC_TRACE_WARNING4(m,p1,p2,p3,p4) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_WARNING]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define LC_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_WARNING]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define LC_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_WARNING]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define LC_TRACE_EVENT0(m) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_EVENT]) BT_TRACE_0(TRACE_LAYER_LC, TRACE_TYPE_EVENT, m);}
-#define LC_TRACE_EVENT1(m,p1) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_EVENT]) BT_TRACE_1(TRACE_LAYER_LC, TRACE_TYPE_EVENT, m, p1);}
-#define LC_TRACE_EVENT2(m,p1,p2) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_EVENT]) BT_TRACE_2(TRACE_LAYER_LC, TRACE_TYPE_EVENT, m,p1,p2);}
-#define LC_TRACE_EVENT3(m,p1,p2,p3) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_EVENT]) BT_TRACE_3(TRACE_LAYER_LC, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define LC_TRACE_EVENT4(m,p1,p2,p3,p4) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_EVENT]) BT_TRACE_4(TRACE_LAYER_LC, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define LC_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_EVENT]) BT_TRACE_5(TRACE_LAYER_LC, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define LC_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_EVENT]) BT_TRACE_6(TRACE_LAYER_LC, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define LC_TRACE_EVENT0(m) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_EVENT]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_EVENT, m);}
+#define LC_TRACE_EVENT1(m,p1) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_EVENT]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_EVENT, m, p1);}
+#define LC_TRACE_EVENT2(m,p1,p2) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_EVENT]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_EVENT, m,p1,p2);}
+#define LC_TRACE_EVENT3(m,p1,p2,p3) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_EVENT]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define LC_TRACE_EVENT4(m,p1,p2,p3,p4) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_EVENT]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define LC_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_EVENT]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define LC_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_EVENT]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define LC_TRACE_DEBUG0(m) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_DEBUG]) BT_TRACE_0(TRACE_LAYER_LC, TRACE_TYPE_DEBUG, m);}
-#define LC_TRACE_DEBUG1(m,p1) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_DEBUG]) BT_TRACE_1(TRACE_LAYER_LC, TRACE_TYPE_DEBUG, m,p1);}
-#define LC_TRACE_DEBUG2(m,p1,p2) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_DEBUG]) BT_TRACE_2(TRACE_LAYER_LC, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define LC_TRACE_DEBUG3(m,p1,p2,p3) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_DEBUG]) BT_TRACE_3(TRACE_LAYER_LC, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define LC_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_DEBUG]) BT_TRACE_5(TRACE_LAYER_LC, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define LC_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_DEBUG]) BT_TRACE_6(TRACE_LAYER_LC, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define LC_TRACE_DEBUG0(m) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_DEBUG]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_DEBUG, m);}
+#define LC_TRACE_DEBUG1(m,p1) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_DEBUG]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_DEBUG, m,p1);}
+#define LC_TRACE_DEBUG2(m,p1,p2) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_DEBUG]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define LC_TRACE_DEBUG3(m,p1,p2,p3) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_DEBUG]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define LC_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_DEBUG]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define LC_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (lc_trace_level & trace_map[BT_TRACE_LEVEL_DEBUG]) BT_TRACE(TRACE_LAYER_LC, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the Serial Dongle Application SDA
*/
-#define SDA_TRACE_ERROR0(m) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(m);}
-#define SDA_TRACE_ERROR1(m,p1) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(m,p1);}
-#define SDA_TRACE_ERROR2(m,p1,p2) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(m,p1,p2);}
-#define SDA_TRACE_ERROR3(m,p1,p2,p3) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(m,p1,p2,p3);}
-#define SDA_TRACE_ERROR4(m,p1,p2,p3,p4) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(m,p1,p2,p3,p4);}
-#define SDA_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(m,p1,p2,p3,p4,p5);}
-#define SDA_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(m,p1,p2,p3,p4,p5,p6);}
+#define SDA_TRACE_ERROR0(m) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(m);}
+#define SDA_TRACE_ERROR1(m,p1) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(m,p1);}
+#define SDA_TRACE_ERROR2(m,p1,p2) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(m,p1,p2);}
+#define SDA_TRACE_ERROR3(m,p1,p2,p3) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(m,p1,p2,p3);}
+#define SDA_TRACE_ERROR4(m,p1,p2,p3,p4) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(m,p1,p2,p3,p4);}
+#define SDA_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(m,p1,p2,p3,p4,p5);}
+#define SDA_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(m,p1,p2,p3,p4,p5,p6);}
-#define SDA_TRACE_WARNING0(m) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(m);}
-#define SDA_TRACE_WARNING1(m,p1) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(m,p1);}
-#define SDA_TRACE_WARNING2(m,p1,p2) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(m,p1,p2);}
-#define SDA_TRACE_WARNING3(m,p1,p2,p3) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(m,p1,p2,p3);}
-#define SDA_TRACE_WARNING4(m,p1,p2,p3,p4) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(m,p1,p2,p3,p4);}
-#define SDA_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(m,p1,p2,p3,p4,p5);}
-#define SDA_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(m,p1,p2,p3,p4,p5,p6);}
+#define SDA_TRACE_WARNING0(m) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(m);}
+#define SDA_TRACE_WARNING1(m,p1) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(m,p1);}
+#define SDA_TRACE_WARNING2(m,p1,p2) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(m,p1,p2);}
+#define SDA_TRACE_WARNING3(m,p1,p2,p3) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(m,p1,p2,p3);}
+#define SDA_TRACE_WARNING4(m,p1,p2,p3,p4) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(m,p1,p2,p3,p4);}
+#define SDA_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(m,p1,p2,p3,p4,p5);}
+#define SDA_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(m,p1,p2,p3,p4,p5,p6);}
-#define SDA_TRACE_EVENT0(m) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(m);}
-#define SDA_TRACE_EVENT1(m,p1) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(m, p1);}
-#define SDA_TRACE_EVENT2(m,p1,p2) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(m,p1,p2);}
-#define SDA_TRACE_EVENT3(m,p1,p2,p3) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(m,p1,p2,p3);}
-#define SDA_TRACE_EVENT4(m,p1,p2,p3,p4) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(m,p1,p2,p3,p4);}
-#define SDA_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(m,p1,p2,p3,p4,p5);}
-#define SDA_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(m,p1,p2,p3,p4,p5,p6);}
+#define SDA_TRACE_EVENT0(m) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(m);}
+#define SDA_TRACE_EVENT1(m,p1) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(m, p1);}
+#define SDA_TRACE_EVENT2(m,p1,p2) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(m,p1,p2);}
+#define SDA_TRACE_EVENT3(m,p1,p2,p3) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(m,p1,p2,p3);}
+#define SDA_TRACE_EVENT4(m,p1,p2,p3,p4) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(m,p1,p2,p3,p4);}
+#define SDA_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(m,p1,p2,p3,p4,p5);}
+#define SDA_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(m,p1,p2,p3,p4,p5,p6);}
-#define SDA_TRACE_DEBUG0(m) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(m);}
-#define SDA_TRACE_DEBUG1(m,p1) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(m,p1);}
-#define SDA_TRACE_DEBUG2(m,p1,p2) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(m,p1,p2);}
-#define SDA_TRACE_DEBUG3(m,p1,p2,p3) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(m,p1,p2,p3);}
-#define SDA_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(m,p1,p2,p3,p4);}
-#define SDA_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(m,p1,p2,p3,p4,p5);}
-#define SDA_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(m,p1,p2,p3,p4,p5,p6);}
+#define SDA_TRACE_DEBUG0(m) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(m);}
+#define SDA_TRACE_DEBUG1(m,p1) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(m,p1);}
+#define SDA_TRACE_DEBUG2(m,p1,p2) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(m,p1,p2);}
+#define SDA_TRACE_DEBUG3(m,p1,p2,p3) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(m,p1,p2,p3);}
+#define SDA_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(m,p1,p2,p3,p4);}
+#define SDA_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(m,p1,p2,p3,p4,p5);}
+#define SDA_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (sda_config_cb.sda_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(m,p1,p2,p3,p4,p5,p6);}
/* AVDTP
*/
-#define AVDT_TRACE_ERROR0(m) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m);}
-#define AVDT_TRACE_ERROR1(m,p1) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1);}
-#define AVDT_TRACE_ERROR2(m,p1,p2) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define AVDT_TRACE_ERROR3(m,p1,p2,p3) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define AVDT_TRACE_ERROR4(m,p1,p2,p3,p4) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define AVDT_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define AVDT_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define AVDT_TRACE_ERROR0(m) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m);}
+#define AVDT_TRACE_ERROR1(m,p1) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1);}
+#define AVDT_TRACE_ERROR2(m,p1,p2) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define AVDT_TRACE_ERROR3(m,p1,p2,p3) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define AVDT_TRACE_ERROR4(m,p1,p2,p3,p4) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define AVDT_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define AVDT_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define AVDT_TRACE_WARNING0(m) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m);}
-#define AVDT_TRACE_WARNING1(m,p1) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1);}
-#define AVDT_TRACE_WARNING2(m,p1,p2) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define AVDT_TRACE_WARNING3(m,p1,p2,p3) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define AVDT_TRACE_WARNING4(m,p1,p2,p3,p4) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define AVDT_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define AVDT_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define AVDT_TRACE_WARNING0(m) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m);}
+#define AVDT_TRACE_WARNING1(m,p1) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1);}
+#define AVDT_TRACE_WARNING2(m,p1,p2) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define AVDT_TRACE_WARNING3(m,p1,p2,p3) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define AVDT_TRACE_WARNING4(m,p1,p2,p3,p4) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define AVDT_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define AVDT_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define AVDT_TRACE_EVENT0(m) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m);}
-#define AVDT_TRACE_EVENT1(m,p1) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m, p1);}
-#define AVDT_TRACE_EVENT2(m,p1,p2) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define AVDT_TRACE_EVENT3(m,p1,p2,p3) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define AVDT_TRACE_EVENT4(m,p1,p2,p3,p4) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define AVDT_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define AVDT_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define AVDT_TRACE_EVENT0(m) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m);}
+#define AVDT_TRACE_EVENT1(m,p1) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m, p1);}
+#define AVDT_TRACE_EVENT2(m,p1,p2) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define AVDT_TRACE_EVENT3(m,p1,p2,p3) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define AVDT_TRACE_EVENT4(m,p1,p2,p3,p4) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define AVDT_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define AVDT_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define AVDT_TRACE_DEBUG0(m) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m);}
-#define AVDT_TRACE_DEBUG1(m,p1) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1);}
-#define AVDT_TRACE_DEBUG2(m,p1,p2) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define AVDT_TRACE_DEBUG3(m,p1,p2,p3) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define AVDT_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define AVDT_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define AVDT_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define AVDT_TRACE_DEBUG0(m) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m);}
+#define AVDT_TRACE_DEBUG1(m,p1) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1);}
+#define AVDT_TRACE_DEBUG2(m,p1,p2) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define AVDT_TRACE_DEBUG3(m,p1,p2,p3) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define AVDT_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define AVDT_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define AVDT_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#define AVDT_TRACE_API0(m) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_API, m);}
-#define AVDT_TRACE_API1(m,p1) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1);}
-#define AVDT_TRACE_API2(m,p1,p2) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2);}
-#define AVDT_TRACE_API3(m,p1,p2,p3) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define AVDT_TRACE_API4(m,p1,p2,p3,p4) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define AVDT_TRACE_API5(m,p1,p2,p3,p4,p5) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define AVDT_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define AVDT_TRACE_API0(m) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, m);}
+#define AVDT_TRACE_API1(m,p1) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1);}
+#define AVDT_TRACE_API2(m,p1,p2) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2);}
+#define AVDT_TRACE_API3(m,p1,p2,p3) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define AVDT_TRACE_API4(m,p1,p2,p3,p4) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define AVDT_TRACE_API5(m,p1,p2,p3,p4,p5) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define AVDT_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the AVCTP protocol
*/
-#define AVCT_TRACE_ERROR0(m) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m);}
-#define AVCT_TRACE_ERROR1(m,p1) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1);}
-#define AVCT_TRACE_ERROR2(m,p1,p2) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define AVCT_TRACE_ERROR3(m,p1,p2,p3) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define AVCT_TRACE_ERROR4(m,p1,p2,p3,p4) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define AVCT_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define AVCT_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define AVCT_TRACE_ERROR0(m) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m);}
+#define AVCT_TRACE_ERROR1(m,p1) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1);}
+#define AVCT_TRACE_ERROR2(m,p1,p2) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define AVCT_TRACE_ERROR3(m,p1,p2,p3) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define AVCT_TRACE_ERROR4(m,p1,p2,p3,p4) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define AVCT_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define AVCT_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define AVCT_TRACE_WARNING0(m) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m);}
-#define AVCT_TRACE_WARNING1(m,p1) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1);}
-#define AVCT_TRACE_WARNING2(m,p1,p2) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define AVCT_TRACE_WARNING3(m,p1,p2,p3) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define AVCT_TRACE_WARNING4(m,p1,p2,p3,p4) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define AVCT_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define AVCT_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define AVCT_TRACE_WARNING0(m) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m);}
+#define AVCT_TRACE_WARNING1(m,p1) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1);}
+#define AVCT_TRACE_WARNING2(m,p1,p2) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define AVCT_TRACE_WARNING3(m,p1,p2,p3) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define AVCT_TRACE_WARNING4(m,p1,p2,p3,p4) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define AVCT_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define AVCT_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define AVCT_TRACE_EVENT0(m) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m);}
-#define AVCT_TRACE_EVENT1(m,p1) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m, p1);}
-#define AVCT_TRACE_EVENT2(m,p1,p2) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define AVCT_TRACE_EVENT3(m,p1,p2,p3) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define AVCT_TRACE_EVENT4(m,p1,p2,p3,p4) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define AVCT_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define AVCT_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define AVCT_TRACE_EVENT0(m) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m);}
+#define AVCT_TRACE_EVENT1(m,p1) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m, p1);}
+#define AVCT_TRACE_EVENT2(m,p1,p2) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define AVCT_TRACE_EVENT3(m,p1,p2,p3) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define AVCT_TRACE_EVENT4(m,p1,p2,p3,p4) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define AVCT_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define AVCT_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define AVCT_TRACE_DEBUG0(m) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m);}
-#define AVCT_TRACE_DEBUG1(m,p1) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1);}
-#define AVCT_TRACE_DEBUG2(m,p1,p2) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define AVCT_TRACE_DEBUG3(m,p1,p2,p3) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define AVCT_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define AVCT_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define AVCT_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define AVCT_TRACE_DEBUG0(m) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m);}
+#define AVCT_TRACE_DEBUG1(m,p1) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1);}
+#define AVCT_TRACE_DEBUG2(m,p1,p2) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define AVCT_TRACE_DEBUG3(m,p1,p2,p3) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define AVCT_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define AVCT_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define AVCT_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#define AVCT_TRACE_API0(m) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_API, m);}
-#define AVCT_TRACE_API1(m,p1) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1);}
-#define AVCT_TRACE_API2(m,p1,p2) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2);}
-#define AVCT_TRACE_API3(m,p1,p2,p3) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define AVCT_TRACE_API4(m,p1,p2,p3,p4) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define AVCT_TRACE_API5(m,p1,p2,p3,p4,p5) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define AVCT_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define AVCT_TRACE_API0(m) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, m);}
+#define AVCT_TRACE_API1(m,p1) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1);}
+#define AVCT_TRACE_API2(m,p1,p2) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2);}
+#define AVCT_TRACE_API3(m,p1,p2,p3) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define AVCT_TRACE_API4(m,p1,p2,p3,p4) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define AVCT_TRACE_API5(m,p1,p2,p3,p4,p5) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define AVCT_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the AVRCP profile
*/
-#define AVRC_TRACE_ERROR0(m) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m);}
-#define AVRC_TRACE_ERROR1(m,p1) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1);}
-#define AVRC_TRACE_ERROR2(m,p1,p2) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2);}
-#define AVRC_TRACE_ERROR3(m,p1,p2,p3) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2,p3);}
-#define AVRC_TRACE_ERROR4(m,p1,p2,p3,p4) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2,p3,p4);}
-#define AVRC_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2,p3,p4,p5);}
-#define AVRC_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2,p3,p4,p5,p6);}
+#define AVRC_TRACE_ERROR0(m) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m);}
+#define AVRC_TRACE_ERROR1(m,p1) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1);}
+#define AVRC_TRACE_ERROR2(m,p1,p2) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2);}
+#define AVRC_TRACE_ERROR3(m,p1,p2,p3) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2,p3);}
+#define AVRC_TRACE_ERROR4(m,p1,p2,p3,p4) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2,p3,p4);}
+#define AVRC_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2,p3,p4,p5);}
+#define AVRC_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR,m,p1,p2,p3,p4,p5,p6);}
-#define AVRC_TRACE_WARNING0(m) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m);}
-#define AVRC_TRACE_WARNING1(m,p1) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1);}
-#define AVRC_TRACE_WARNING2(m,p1,p2) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2);}
-#define AVRC_TRACE_WARNING3(m,p1,p2,p3) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2,p3);}
-#define AVRC_TRACE_WARNING4(m,p1,p2,p3,p4) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2,p3,p4);}
-#define AVRC_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2,p3,p4,p5);}
-#define AVRC_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2,p3,p4,p5,p6);}
+#define AVRC_TRACE_WARNING0(m) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m);}
+#define AVRC_TRACE_WARNING1(m,p1) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1);}
+#define AVRC_TRACE_WARNING2(m,p1,p2) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2);}
+#define AVRC_TRACE_WARNING3(m,p1,p2,p3) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2,p3);}
+#define AVRC_TRACE_WARNING4(m,p1,p2,p3,p4) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2,p3,p4);}
+#define AVRC_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2,p3,p4,p5);}
+#define AVRC_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING,m,p1,p2,p3,p4,p5,p6);}
-#define AVRC_TRACE_EVENT0(m) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m);}
-#define AVRC_TRACE_EVENT1(m,p1) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m, p1);}
-#define AVRC_TRACE_EVENT2(m,p1,p2) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2);}
-#define AVRC_TRACE_EVENT3(m,p1,p2,p3) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2,p3);}
-#define AVRC_TRACE_EVENT4(m,p1,p2,p3,p4) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2,p3,p4);}
-#define AVRC_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2,p3,p4,p5);}
-#define AVRC_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2,p3,p4,p5,p6);}
+#define AVRC_TRACE_EVENT0(m) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m);}
+#define AVRC_TRACE_EVENT1(m,p1) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m, p1);}
+#define AVRC_TRACE_EVENT2(m,p1,p2) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2);}
+#define AVRC_TRACE_EVENT3(m,p1,p2,p3) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2,p3);}
+#define AVRC_TRACE_EVENT4(m,p1,p2,p3,p4) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2,p3,p4);}
+#define AVRC_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2,p3,p4,p5);}
+#define AVRC_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT,m,p1,p2,p3,p4,p5,p6);}
-#define AVRC_TRACE_DEBUG0(m) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m);}
-#define AVRC_TRACE_DEBUG1(m,p1) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1);}
-#define AVRC_TRACE_DEBUG2(m,p1,p2) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2);}
-#define AVRC_TRACE_DEBUG3(m,p1,p2,p3) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2,p3);}
-#define AVRC_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4);}
-#define AVRC_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4,p5);}
-#define AVRC_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4,p5,p6);}
+#define AVRC_TRACE_DEBUG0(m) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m);}
+#define AVRC_TRACE_DEBUG1(m,p1) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1);}
+#define AVRC_TRACE_DEBUG2(m,p1,p2) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2);}
+#define AVRC_TRACE_DEBUG3(m,p1,p2,p3) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2,p3);}
+#define AVRC_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4);}
+#define AVRC_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4,p5);}
+#define AVRC_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG,m,p1,p2,p3,p4,p5,p6);}
-#define AVRC_TRACE_API0(m) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_AVP, TRACE_TYPE_API,m);}
-#define AVRC_TRACE_API1(m,p1) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_AVP, TRACE_TYPE_API,m, p1);}
-#define AVRC_TRACE_API2(m,p1,p2) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2);}
-#define AVRC_TRACE_API3(m,p1,p2,p3) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2,p3);}
-#define AVRC_TRACE_API4(m,p1,p2,p3,p4) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2,p3,p4);}
-#define AVRC_TRACE_API5(m,p1,p2,p3,p4,p5) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2,p3,p4,p5);}
-#define AVRC_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2,p3,p4,p5,p6);}
+#define AVRC_TRACE_API0(m) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API,m);}
+#define AVRC_TRACE_API1(m,p1) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API,m, p1);}
+#define AVRC_TRACE_API2(m,p1,p2) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2);}
+#define AVRC_TRACE_API3(m,p1,p2,p3) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2,p3);}
+#define AVRC_TRACE_API4(m,p1,p2,p3,p4) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2,p3,p4);}
+#define AVRC_TRACE_API5(m,p1,p2,p3,p4,p5) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2,p3,p4,p5);}
+#define AVRC_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API,m,p1,p2,p3,p4,p5,p6);}
/* MCAP
*/
-#define MCA_TRACE_ERROR0(m) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, m);}
-#define MCA_TRACE_ERROR1(m,p1) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, m,p1);}
-#define MCA_TRACE_ERROR2(m,p1,p2) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, m,p1,p2);}
-#define MCA_TRACE_ERROR3(m,p1,p2,p3) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define MCA_TRACE_ERROR4(m,p1,p2,p3,p4) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define MCA_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define MCA_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define MCA_TRACE_ERROR0(m) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, m);}
+#define MCA_TRACE_ERROR1(m,p1) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, m,p1);}
+#define MCA_TRACE_ERROR2(m,p1,p2) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, m,p1,p2);}
+#define MCA_TRACE_ERROR3(m,p1,p2,p3) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define MCA_TRACE_ERROR4(m,p1,p2,p3,p4) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define MCA_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define MCA_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define MCA_TRACE_WARNING0(m) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, m);}
-#define MCA_TRACE_WARNING1(m,p1) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, m,p1);}
-#define MCA_TRACE_WARNING2(m,p1,p2) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, m,p1,p2);}
-#define MCA_TRACE_WARNING3(m,p1,p2,p3) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define MCA_TRACE_WARNING4(m,p1,p2,p3,p4) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define MCA_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define MCA_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define MCA_TRACE_WARNING0(m) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, m);}
+#define MCA_TRACE_WARNING1(m,p1) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, m,p1);}
+#define MCA_TRACE_WARNING2(m,p1,p2) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, m,p1,p2);}
+#define MCA_TRACE_WARNING3(m,p1,p2,p3) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define MCA_TRACE_WARNING4(m,p1,p2,p3,p4) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define MCA_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define MCA_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define MCA_TRACE_EVENT0(m) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, m);}
-#define MCA_TRACE_EVENT1(m,p1) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, m, p1);}
-#define MCA_TRACE_EVENT2(m,p1,p2) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, m,p1,p2);}
-#define MCA_TRACE_EVENT3(m,p1,p2,p3) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define MCA_TRACE_EVENT4(m,p1,p2,p3,p4) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define MCA_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define MCA_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define MCA_TRACE_EVENT0(m) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, m);}
+#define MCA_TRACE_EVENT1(m,p1) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, m, p1);}
+#define MCA_TRACE_EVENT2(m,p1,p2) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, m,p1,p2);}
+#define MCA_TRACE_EVENT3(m,p1,p2,p3) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define MCA_TRACE_EVENT4(m,p1,p2,p3,p4) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define MCA_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define MCA_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define MCA_TRACE_DEBUG0(m) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, m);}
-#define MCA_TRACE_DEBUG1(m,p1) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, m,p1);}
-#define MCA_TRACE_DEBUG2(m,p1,p2) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define MCA_TRACE_DEBUG3(m,p1,p2,p3) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define MCA_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define MCA_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define MCA_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define MCA_TRACE_DEBUG0(m) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, m);}
+#define MCA_TRACE_DEBUG1(m,p1) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, m,p1);}
+#define MCA_TRACE_DEBUG2(m,p1,p2) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define MCA_TRACE_DEBUG3(m,p1,p2,p3) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define MCA_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define MCA_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define MCA_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#define MCA_TRACE_API0(m) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_MCA, TRACE_TYPE_API, m);}
-#define MCA_TRACE_API1(m,p1) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_MCA, TRACE_TYPE_API, m,p1);}
-#define MCA_TRACE_API2(m,p1,p2) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_MCA, TRACE_TYPE_API, m,p1,p2);}
-#define MCA_TRACE_API3(m,p1,p2,p3) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_MCA, TRACE_TYPE_API, m,p1,p2,p3);}
-#define MCA_TRACE_API4(m,p1,p2,p3,p4) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_MCA, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define MCA_TRACE_API5(m,p1,p2,p3,p4,p5) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_MCA, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define MCA_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_MCA, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define MCA_TRACE_API0(m) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_API, m);}
+#define MCA_TRACE_API1(m,p1) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_API, m,p1);}
+#define MCA_TRACE_API2(m,p1,p2) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_API, m,p1,p2);}
+#define MCA_TRACE_API3(m,p1,p2,p3) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_API, m,p1,p2,p3);}
+#define MCA_TRACE_API4(m,p1,p2,p3,p4) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define MCA_TRACE_API5(m,p1,p2,p3,p4,p5) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define MCA_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the AMP unit
*/
-#define AMP_TRACE_ERROR0(m) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_AMP, TRACE_TYPE_ERROR, m);}
-#define AMP_TRACE_ERROR1(m,p1) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_AMP, TRACE_TYPE_ERROR, m,p1);}
-#define AMP_TRACE_ERROR2(m,p1,p2) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_AMP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define AMP_TRACE_ERROR3(m,p1,p2,p3) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_AMP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define AMP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_AMP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define AMP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_AMP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define AMP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_AMP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define AMP_TRACE_ERROR0(m) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_ERROR, m);}
+#define AMP_TRACE_ERROR1(m,p1) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_ERROR, m,p1);}
+#define AMP_TRACE_ERROR2(m,p1,p2) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define AMP_TRACE_ERROR3(m,p1,p2,p3) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define AMP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define AMP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define AMP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define AMP_TRACE_WARNING0(m) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_AMP, TRACE_TYPE_WARNING, m);}
-#define AMP_TRACE_WARNING1(m,p1) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_AMP, TRACE_TYPE_WARNING, m,p1);}
-#define AMP_TRACE_WARNING2(m,p1,p2) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_AMP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define AMP_TRACE_WARNING3(m,p1,p2,p3) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_AMP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define AMP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_AMP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define AMP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_AMP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define AMP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_AMP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define AMP_TRACE_WARNING0(m) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_WARNING, m);}
+#define AMP_TRACE_WARNING1(m,p1) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_WARNING, m,p1);}
+#define AMP_TRACE_WARNING2(m,p1,p2) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define AMP_TRACE_WARNING3(m,p1,p2,p3) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define AMP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define AMP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define AMP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define AMP_TRACE_API0(m) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_AMP, TRACE_TYPE_API, m);}
-#define AMP_TRACE_API1(m,p1) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_AMP, TRACE_TYPE_API, m,p1);}
-#define AMP_TRACE_API2(m,p1,p2) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_AMP, TRACE_TYPE_API, m,p1,p2);}
-#define AMP_TRACE_API3(m,p1,p2,p3) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_AMP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define AMP_TRACE_API4(m,p1,p2,p3,p4) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_AMP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define AMP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_AMP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define AMP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_AMP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define AMP_TRACE_API0(m) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_API, m);}
+#define AMP_TRACE_API1(m,p1) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_API, m,p1);}
+#define AMP_TRACE_API2(m,p1,p2) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_API, m,p1,p2);}
+#define AMP_TRACE_API3(m,p1,p2,p3) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define AMP_TRACE_API4(m,p1,p2,p3,p4) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define AMP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define AMP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define AMP_TRACE_EVENT0(m) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_AMP, TRACE_TYPE_EVENT, m);}
-#define AMP_TRACE_EVENT1(m,p1) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_AMP, TRACE_TYPE_EVENT, m, p1);}
-#define AMP_TRACE_EVENT2(m,p1,p2) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_AMP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define AMP_TRACE_EVENT3(m,p1,p2,p3) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_AMP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define AMP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_AMP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define AMP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_AMP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define AMP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_AMP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define AMP_TRACE_EVENT0(m) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_EVENT, m);}
+#define AMP_TRACE_EVENT1(m,p1) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_EVENT, m, p1);}
+#define AMP_TRACE_EVENT2(m,p1,p2) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define AMP_TRACE_EVENT3(m,p1,p2,p3) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define AMP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define AMP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define AMP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define AMP_TRACE_DEBUG0(m) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_AMP, TRACE_TYPE_DEBUG, m);}
-#define AMP_TRACE_DEBUG1(m,p1) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_AMP, TRACE_TYPE_DEBUG, m,p1);}
-#define AMP_TRACE_DEBUG2(m,p1,p2) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_AMP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define AMP_TRACE_DEBUG3(m,p1,p2,p3) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_AMP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define AMP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_AMP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define AMP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_AMP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define AMP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_AMP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define AMP_TRACE_DEBUG0(m) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_DEBUG, m);}
+#define AMP_TRACE_DEBUG1(m,p1) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_DEBUG, m,p1);}
+#define AMP_TRACE_DEBUG2(m,p1,p2) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define AMP_TRACE_DEBUG3(m,p1,p2,p3) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define AMP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define AMP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define AMP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (amp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AMP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the ATT/GATT unit
*/
-#define GATT_TRACE_ERROR0(m) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, m);}
-#define GATT_TRACE_ERROR1(m,p1) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, m,p1);}
-#define GATT_TRACE_ERROR2(m,p1,p2) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, m,p1,p2);}
-#define GATT_TRACE_ERROR3(m,p1,p2,p3) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define GATT_TRACE_ERROR4(m,p1,p2,p3,p4) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define GATT_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define GATT_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define GATT_TRACE_ERROR0(m) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, m);}
+#define GATT_TRACE_ERROR1(m,p1) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, m,p1);}
+#define GATT_TRACE_ERROR2(m,p1,p2) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, m,p1,p2);}
+#define GATT_TRACE_ERROR3(m,p1,p2,p3) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define GATT_TRACE_ERROR4(m,p1,p2,p3,p4) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define GATT_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define GATT_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define GATT_TRACE_WARNING0(m) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, m);}
-#define GATT_TRACE_WARNING1(m,p1) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, m,p1);}
-#define GATT_TRACE_WARNING2(m,p1,p2) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, m,p1,p2);}
-#define GATT_TRACE_WARNING3(m,p1,p2,p3) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define GATT_TRACE_WARNING4(m,p1,p2,p3,p4) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define GATT_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define GATT_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define GATT_TRACE_WARNING0(m) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, m);}
+#define GATT_TRACE_WARNING1(m,p1) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, m,p1);}
+#define GATT_TRACE_WARNING2(m,p1,p2) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, m,p1,p2);}
+#define GATT_TRACE_WARNING3(m,p1,p2,p3) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define GATT_TRACE_WARNING4(m,p1,p2,p3,p4) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define GATT_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define GATT_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define GATT_TRACE_API0(m) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_ATT, TRACE_TYPE_API, m);}
-#define GATT_TRACE_API1(m,p1) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_ATT, TRACE_TYPE_API, m,p1);}
-#define GATT_TRACE_API2(m,p1,p2) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_ATT, TRACE_TYPE_API, m,p1,p2);}
-#define GATT_TRACE_API3(m,p1,p2,p3) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_ATT, TRACE_TYPE_API, m,p1,p2,p3);}
-#define GATT_TRACE_API4(m,p1,p2,p3,p4) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_ATT, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define GATT_TRACE_API5(m,p1,p2,p3,p4,p5) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_ATT, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define GATT_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_ATT, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define GATT_TRACE_API0(m) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_API, m);}
+#define GATT_TRACE_API1(m,p1) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_API, m,p1);}
+#define GATT_TRACE_API2(m,p1,p2) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_API, m,p1,p2);}
+#define GATT_TRACE_API3(m,p1,p2,p3) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_API, m,p1,p2,p3);}
+#define GATT_TRACE_API4(m,p1,p2,p3,p4) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define GATT_TRACE_API5(m,p1,p2,p3,p4,p5) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define GATT_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define GATT_TRACE_EVENT0(m) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, m);}
-#define GATT_TRACE_EVENT1(m,p1) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, m, p1);}
-#define GATT_TRACE_EVENT2(m,p1,p2) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, m,p1,p2);}
-#define GATT_TRACE_EVENT3(m,p1,p2,p3) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define GATT_TRACE_EVENT4(m,p1,p2,p3,p4) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define GATT_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define GATT_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define GATT_TRACE_EVENT0(m) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, m);}
+#define GATT_TRACE_EVENT1(m,p1) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, m, p1);}
+#define GATT_TRACE_EVENT2(m,p1,p2) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, m,p1,p2);}
+#define GATT_TRACE_EVENT3(m,p1,p2,p3) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define GATT_TRACE_EVENT4(m,p1,p2,p3,p4) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define GATT_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define GATT_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define GATT_TRACE_DEBUG0(m) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, m);}
-#define GATT_TRACE_DEBUG1(m,p1) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, m,p1);}
-#define GATT_TRACE_DEBUG2(m,p1,p2) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define GATT_TRACE_DEBUG3(m,p1,p2,p3) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define GATT_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define GATT_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define GATT_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define GATT_TRACE_DEBUG0(m) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, m);}
+#define GATT_TRACE_DEBUG1(m,p1) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, m,p1);}
+#define GATT_TRACE_DEBUG2(m,p1,p2) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define GATT_TRACE_DEBUG3(m,p1,p2,p3) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define GATT_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define GATT_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define GATT_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* Define tracing for the SMP unit
*/
-#define SMP_TRACE_ERROR0(m) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, m);}
-#define SMP_TRACE_ERROR1(m,p1) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, m,p1);}
-#define SMP_TRACE_ERROR2(m,p1,p2) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, m,p1,p2);}
-#define SMP_TRACE_ERROR3(m,p1,p2,p3) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
-#define SMP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
-#define SMP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
-#define SMP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
+#define SMP_TRACE_ERROR0(m) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, m);}
+#define SMP_TRACE_ERROR1(m,p1) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, m,p1);}
+#define SMP_TRACE_ERROR2(m,p1,p2) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, m,p1,p2);}
+#define SMP_TRACE_ERROR3(m,p1,p2,p3) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, m,p1,p2,p3);}
+#define SMP_TRACE_ERROR4(m,p1,p2,p3,p4) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);}
+#define SMP_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);}
+#define SMP_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);}
-#define SMP_TRACE_WARNING0(m) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, m);}
-#define SMP_TRACE_WARNING1(m,p1) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, m,p1);}
-#define SMP_TRACE_WARNING2(m,p1,p2) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, m,p1,p2);}
-#define SMP_TRACE_WARNING3(m,p1,p2,p3) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
-#define SMP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
-#define SMP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
-#define SMP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
+#define SMP_TRACE_WARNING0(m) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, m);}
+#define SMP_TRACE_WARNING1(m,p1) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, m,p1);}
+#define SMP_TRACE_WARNING2(m,p1,p2) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, m,p1,p2);}
+#define SMP_TRACE_WARNING3(m,p1,p2,p3) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, m,p1,p2,p3);}
+#define SMP_TRACE_WARNING4(m,p1,p2,p3,p4) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);}
+#define SMP_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);}
+#define SMP_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);}
-#define SMP_TRACE_API0(m) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_SMP, TRACE_TYPE_API, m);}
-#define SMP_TRACE_API1(m,p1) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_SMP, TRACE_TYPE_API, m,p1);}
-#define SMP_TRACE_API2(m,p1,p2) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_SMP, TRACE_TYPE_API, m,p1,p2);}
-#define SMP_TRACE_API3(m,p1,p2,p3) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_SMP, TRACE_TYPE_API, m,p1,p2,p3);}
-#define SMP_TRACE_API4(m,p1,p2,p3,p4) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_SMP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
-#define SMP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_SMP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
-#define SMP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_SMP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
+#define SMP_TRACE_API0(m) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_API, m);}
+#define SMP_TRACE_API1(m,p1) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_API, m,p1);}
+#define SMP_TRACE_API2(m,p1,p2) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_API, m,p1,p2);}
+#define SMP_TRACE_API3(m,p1,p2,p3) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_API, m,p1,p2,p3);}
+#define SMP_TRACE_API4(m,p1,p2,p3,p4) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_API, m,p1,p2,p3,p4);}
+#define SMP_TRACE_API5(m,p1,p2,p3,p4,p5) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);}
+#define SMP_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);}
-#define SMP_TRACE_EVENT0(m) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, m);}
-#define SMP_TRACE_EVENT1(m,p1) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, m, p1);}
-#define SMP_TRACE_EVENT2(m,p1,p2) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, m,p1,p2);}
-#define SMP_TRACE_EVENT3(m,p1,p2,p3) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
-#define SMP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
-#define SMP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
-#define SMP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
+#define SMP_TRACE_EVENT0(m) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, m);}
+#define SMP_TRACE_EVENT1(m,p1) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, m, p1);}
+#define SMP_TRACE_EVENT2(m,p1,p2) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, m,p1,p2);}
+#define SMP_TRACE_EVENT3(m,p1,p2,p3) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, m,p1,p2,p3);}
+#define SMP_TRACE_EVENT4(m,p1,p2,p3,p4) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);}
+#define SMP_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);}
+#define SMP_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);}
-#define SMP_TRACE_DEBUG0(m) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, m);}
-#define SMP_TRACE_DEBUG1(m,p1) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, m,p1);}
-#define SMP_TRACE_DEBUG2(m,p1,p2) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define SMP_TRACE_DEBUG3(m,p1,p2,p3) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define SMP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define SMP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define SMP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
+#define SMP_TRACE_DEBUG0(m) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, m);}
+#define SMP_TRACE_DEBUG1(m,p1) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, m,p1);}
+#define SMP_TRACE_DEBUG2(m,p1,p2) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, m,p1,p2);}
+#define SMP_TRACE_DEBUG3(m,p1,p2,p3) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
+#define SMP_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
+#define SMP_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
+#define SMP_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
/* END OF USE TRACES */
#else
-#define BT_TRACE_0(l,t,m)
-#define BT_TRACE_1(l,t,m,p1)
-#define BT_TRACE_2(l,t,m,p1,p2)
-#define BT_TRACE_3(l,t,m,p1,p2,p3)
-#define BT_TRACE_4(l,t,m,p1,p2,p3,p4)
-#define BT_TRACE_5(l,t,m,p1,p2,p3,p4,p5)
-#define BT_TRACE_6(l,t,m,p1,p2,p3,p4,p5,p6)
-
-#define BT_ERROR_TRACE_0(l,m)
-#define BT_ERROR_TRACE_1(l,m,p1)
-#define BT_ERROR_TRACE_2(l,m,p1,p2)
-#define BT_ERROR_TRACE_3(l,m,p1,p2,p3)
+#define BT_TRACE(l,t,...)
+#define BT_BT_ERROR_TRACE(l,...)
/* Define tracing for the HCI unit
*/
-#define HCI_TRACE_ERROR0(m)
-#define HCI_TRACE_ERROR1(m,p1)
-#define HCI_TRACE_ERROR2(m,p1,p2)
-#define HCI_TRACE_ERROR3(m,p1,p2,p3)
-#define HCI_TRACE_ERROR4(m,p1,p2,p3,p4)
-#define HCI_TRACE_ERROR5(m,p1,p2,p3,p4,p5)
-#define HCI_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6)
-
-#define HCI_TRACE_WARNING0(m)
-#define HCI_TRACE_WARNING1(m,p1)
-#define HCI_TRACE_WARNING2(m,p1,p2)
-#define HCI_TRACE_WARNING3(m,p1,p2,p3)
-#define HCI_TRACE_WARNING4(m,p1,p2,p3,p4)
-#define HCI_TRACE_WARNING5(m,p1,p2,p3,p4,p5)
-#define HCI_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6)
-
-#define HCI_TRACE_EVENT0(m)
-#define HCI_TRACE_EVENT1(m,p1)
-#define HCI_TRACE_EVENT2(m,p1,p2)
-#define HCI_TRACE_EVENT3(m,p1,p2,p3)
-#define HCI_TRACE_EVENT4(m,p1,p2,p3,p4)
-#define HCI_TRACE_EVENT5(m,p1,p2,p3,p4,p5)
-#define HCI_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6)
-
-#define HCI_TRACE_DEBUG0(m)
-#define HCI_TRACE_DEBUG1(m,p1)
-#define HCI_TRACE_DEBUG2(m,p1,p2)
-#define HCI_TRACE_DEBUG3(m,p1,p2,p3)
-#define HCI_TRACE_DEBUG4(m,p1,p2,p3,p4)
-#define HCI_TRACE_DEBUG5(m,p1,p2,p3,p4,p5)
-#define HCI_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6)
+#define HCI_TRACE_ERROR(...)
+#define HCI_TRACE_WARNING(...)
+#define HCI_TRACE_EVENT(...)
+#define HCI_TRACE_DEBUG(...)
/* Define tracing for BTM
*/
-#define BTM_TRACE_ERROR0(m)
-#define BTM_TRACE_ERROR1(m,p1)
-#define BTM_TRACE_ERROR2(m,p1,p2)
-#define BTM_TRACE_ERROR3(m,p1,p2,p3)
-#define BTM_TRACE_ERROR4(m,p1,p2,p3,p4)
-#define BTM_TRACE_ERROR5(m,p1,p2,p3,p4,p5)
-#define BTM_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6)
-
-#define BTM_TRACE_WARNING0(m)
-#define BTM_TRACE_WARNING1(m,p1)
-#define BTM_TRACE_WARNING2(m,p1,p2)
-#define BTM_TRACE_WARNING3(m,p1,p2,p3)
-#define BTM_TRACE_WARNING4(m,p1,p2,p3,p4)
-#define BTM_TRACE_WARNING5(m,p1,p2,p3,p4,p5)
-#define BTM_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6)
-
-#define BTM_TRACE_API0(m)
-#define BTM_TRACE_API1(m,p1)
-#define BTM_TRACE_API2(m,p1,p2)
-#define BTM_TRACE_API3(m,p1,p2,p3)
-#define BTM_TRACE_API4(m,p1,p2,p3,p4)
-#define BTM_TRACE_API5(m,p1,p2,p3,p4,p5)
-#define BTM_TRACE_API6(m,p1,p2,p3,p4,p5,p6)
-
-#define BTM_TRACE_EVENT0(m)
-#define BTM_TRACE_EVENT1(m,p1)
-#define BTM_TRACE_EVENT2(m,p1,p2)
-#define BTM_TRACE_EVENT3(m,p1,p2,p3)
-#define BTM_TRACE_EVENT4(m,p1,p2,p3,p4)
-#define BTM_TRACE_EVENT5(m,p1,p2,p3,p4,p5)
-#define BTM_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6)
-
-#define BTM_TRACE_DEBUG0(m)
-#define BTM_TRACE_DEBUG1(m,p1)
-#define BTM_TRACE_DEBUG2(m,p1,p2)
-#define BTM_TRACE_DEBUG3(m,p1,p2,p3)
-#define BTM_TRACE_DEBUG4(m,p1,p2,p3,p4)
-#define BTM_TRACE_DEBUG5(m,p1,p2,p3,p4,p5)
-#define BTM_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6)
+#define BTM_TRACE_ERROR(...)
+#define BTM_TRACE_WARNING(...)
+#define BTM_TRACE_API(...)
+#define BTM_TRACE_EVENT(...)
+#define BTM_TRACE_DEBUG(...)
/* Define tracing for the L2CAP unit
@@ -4449,88 +4290,88 @@
extern UINT8 btif_trace_level;
/* define traces for application */
-#define BTIF_TRACE_ERROR0(m) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, (m));}
-#define BTIF_TRACE_ERROR1(m,p1) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
+#define BTIF_TRACE_ERROR0(m) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, (m));}
+#define BTIF_TRACE_ERROR1(m,p1) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1));}
-#define BTIF_TRACE_ERROR2(m,p1,p2) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
+#define BTIF_TRACE_ERROR2(m,p1,p2) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1), (UINT32)(p2));}
-#define BTIF_TRACE_ERROR3(m,p1,p2,p3) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
+#define BTIF_TRACE_ERROR3(m,p1,p2,p3) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
-#define BTIF_TRACE_ERROR4(m,p1,p2,p3,p4) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
+#define BTIF_TRACE_ERROR4(m,p1,p2,p3,p4) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
-#define BTIF_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
+#define BTIF_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
-#define BTIF_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
+#define BTIF_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
-#define BTIF_TRACE_WARNING0(m) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, (m));}
-#define BTIF_TRACE_WARNING1(m,p1) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
+#define BTIF_TRACE_WARNING0(m) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, (m));}
+#define BTIF_TRACE_WARNING1(m,p1) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1));}
-#define BTIF_TRACE_WARNING2(m,p1,p2) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
+#define BTIF_TRACE_WARNING2(m,p1,p2) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1), (UINT32)(p2));}
-#define BTIF_TRACE_WARNING3(m,p1,p2,p3) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
+#define BTIF_TRACE_WARNING3(m,p1,p2,p3) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
-#define BTIF_TRACE_WARNING4(m,p1,p2,p3,p4) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
+#define BTIF_TRACE_WARNING4(m,p1,p2,p3,p4) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
-#define BTIF_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
+#define BTIF_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
-#define BTIF_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
+#define BTIF_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
-#define BTIF_TRACE_API0(m) {if (btif_trace_level >= BT_TRACE_LEVEL_API) LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, (m));}
-#define BTIF_TRACE_API1(m,p1) {if (btif_trace_level >= BT_TRACE_LEVEL_API) LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
+#define BTIF_TRACE_API0(m) {if (btif_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, (m));}
+#define BTIF_TRACE_API1(m,p1) {if (btif_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
(m), (UINT32)(p1));}
-#define BTIF_TRACE_API2(m,p1,p2) {if (btif_trace_level >= BT_TRACE_LEVEL_API) LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
+#define BTIF_TRACE_API2(m,p1,p2) {if (btif_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
(m), (UINT32)(p1), (UINT32)(p2));}
-#define BTIF_TRACE_API3(m,p1,p2,p3) {if (btif_trace_level >= BT_TRACE_LEVEL_API) LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
+#define BTIF_TRACE_API3(m,p1,p2,p3) {if (btif_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
-#define BTIF_TRACE_API4(m,p1,p2,p3,p4) {if (btif_trace_level >= BT_TRACE_LEVEL_API) LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
+#define BTIF_TRACE_API4(m,p1,p2,p3,p4) {if (btif_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
-#define BTIF_TRACE_API5(m,p1,p2,p3,p4,p5) {if (btif_trace_level >= BT_TRACE_LEVEL_API) LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
+#define BTIF_TRACE_API5(m,p1,p2,p3,p4,p5) {if (btif_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
-#define BTIF_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (btif_trace_level >= BT_TRACE_LEVEL_API) LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
+#define BTIF_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (btif_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
-#define BTIF_TRACE_EVENT0(m) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, (m));}
-#define BTIF_TRACE_EVENT1(m,p1) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
+#define BTIF_TRACE_EVENT0(m) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, (m));}
+#define BTIF_TRACE_EVENT1(m,p1) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1));}
-#define BTIF_TRACE_EVENT2(m,p1,p2) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
+#define BTIF_TRACE_EVENT2(m,p1,p2) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1), (UINT32)(p2));}
-#define BTIF_TRACE_EVENT3(m,p1,p2,p3) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
+#define BTIF_TRACE_EVENT3(m,p1,p2,p3) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
-#define BTIF_TRACE_EVENT4(m,p1,p2,p3,p4) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
+#define BTIF_TRACE_EVENT4(m,p1,p2,p3,p4) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
-#define BTIF_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
+#define BTIF_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
-#define BTIF_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
+#define BTIF_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
-#define BTIF_TRACE_DEBUG0(m) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m));}
-#define BTIF_TRACE_DEBUG1(m,p1) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define BTIF_TRACE_DEBUG0(m) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m));}
+#define BTIF_TRACE_DEBUG1(m,p1) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1));}
-#define BTIF_TRACE_DEBUG2(m,p1,p2) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define BTIF_TRACE_DEBUG2(m,p1,p2) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2));}
-#define BTIF_TRACE_DEBUG3(m,p1,p2,p3) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define BTIF_TRACE_DEBUG3(m,p1,p2,p3) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
-#define BTIF_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define BTIF_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
-#define BTIF_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define BTIF_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
-#define BTIF_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define BTIF_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
-#define BTIF_TRACE_VERBOSE0(m) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE) LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m));}
-#define BTIF_TRACE_VERBOSE1(m,p1) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE) LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define BTIF_TRACE_VERBOSE0(m) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m));}
+#define BTIF_TRACE_VERBOSE1(m,p1) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1));}
-#define BTIF_TRACE_VERBOSE2(m,p1,p2) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE) LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define BTIF_TRACE_VERBOSE2(m,p1,p2) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2));}
-#define BTIF_TRACE_VERBOSE3(m,p1,p2,p3) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE) LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define BTIF_TRACE_VERBOSE3(m,p1,p2,p3) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
-#define BTIF_TRACE_VERBOSE4(m,p1,p2,p3,p4) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE) LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define BTIF_TRACE_VERBOSE4(m,p1,p2,p3,p4) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
-#define BTIF_TRACE_VERBOSE5(m,p1,p2,p3,p4,p5) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE) LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define BTIF_TRACE_VERBOSE5(m,p1,p2,p3,p4,p5) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
-#define BTIF_TRACE_VERBOSE6(m,p1,p2,p3,p4,p5,p6) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE) LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define BTIF_TRACE_VERBOSE6(m,p1,p2,p3,p4,p5,p6) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
#else
@@ -4599,95 +4440,95 @@
#if (BT_USE_TRACES == TRUE || BT_TRACE_APPL == TRUE)
/* define traces for application */
-#define APPL_TRACE_ERROR0(m) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, (m));}
-#define APPL_TRACE_ERROR1(m,p1) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
+#define APPL_TRACE_ERROR0(m) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, (m));}
+#define APPL_TRACE_ERROR1(m,p1) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1));}
-#define APPL_TRACE_ERROR2(m,p1,p2) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
+#define APPL_TRACE_ERROR2(m,p1,p2) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1), (UINT32)(p2));}
-#define APPL_TRACE_ERROR3(m,p1,p2,p3) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
+#define APPL_TRACE_ERROR3(m,p1,p2,p3) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
-#define APPL_TRACE_ERROR4(m,p1,p2,p3,p4) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
+#define APPL_TRACE_ERROR4(m,p1,p2,p3,p4) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
-#define APPL_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
+#define APPL_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
-#define APPL_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
+#define APPL_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
-#define APPL_TRACE_WARNING0(m) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, (m));}
-#define APPL_TRACE_WARNING1(m,p1) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
+#define APPL_TRACE_WARNING0(m) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, (m));}
+#define APPL_TRACE_WARNING1(m,p1) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1));}
-#define APPL_TRACE_WARNING2(m,p1,p2) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
+#define APPL_TRACE_WARNING2(m,p1,p2) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1), (UINT32)(p2));}
-#define APPL_TRACE_WARNING3(m,p1,p2,p3) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
+#define APPL_TRACE_WARNING3(m,p1,p2,p3) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
-#define APPL_TRACE_WARNING4(m,p1,p2,p3,p4) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
+#define APPL_TRACE_WARNING4(m,p1,p2,p3,p4) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
-#define APPL_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
+#define APPL_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
-#define APPL_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
+#define APPL_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
-#define APPL_TRACE_API0(m) {if (appl_trace_level >= BT_TRACE_LEVEL_API) LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, (m));}
-#define APPL_TRACE_API1(m,p1) {if (appl_trace_level >= BT_TRACE_LEVEL_API) LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
+#define APPL_TRACE_API0(m) {if (appl_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, (m));}
+#define APPL_TRACE_API1(m,p1) {if (appl_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
(m), (UINT32)(p1));}
-#define APPL_TRACE_API2(m,p1,p2) {if (appl_trace_level >= BT_TRACE_LEVEL_API) LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
+#define APPL_TRACE_API2(m,p1,p2) {if (appl_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
(m), (UINT32)(p1), (UINT32)(p2));}
-#define APPL_TRACE_API3(m,p1,p2,p3) {if (appl_trace_level >= BT_TRACE_LEVEL_API) LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
+#define APPL_TRACE_API3(m,p1,p2,p3) {if (appl_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
-#define APPL_TRACE_API4(m,p1,p2,p3,p4) {if (appl_trace_level >= BT_TRACE_LEVEL_API) LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
+#define APPL_TRACE_API4(m,p1,p2,p3,p4) {if (appl_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
-#define APPL_TRACE_API5(m,p1,p2,p3,p4,p5) {if (appl_trace_level >= BT_TRACE_LEVEL_API) LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
+#define APPL_TRACE_API5(m,p1,p2,p3,p4,p5) {if (appl_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
-#define APPL_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (appl_trace_level >= BT_TRACE_LEVEL_API) LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
+#define APPL_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (appl_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
-#define APPL_TRACE_EVENT0(m) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, (m));}
-#define APPL_TRACE_EVENT1(m,p1) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
+#define APPL_TRACE_EVENT0(m) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, (m));}
+#define APPL_TRACE_EVENT1(m,p1) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1));}
-#define APPL_TRACE_EVENT2(m,p1,p2) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
+#define APPL_TRACE_EVENT2(m,p1,p2) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1), (UINT32)(p2));}
-#define APPL_TRACE_EVENT3(m,p1,p2,p3) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
+#define APPL_TRACE_EVENT3(m,p1,p2,p3) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
-#define APPL_TRACE_EVENT4(m,p1,p2,p3,p4) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
+#define APPL_TRACE_EVENT4(m,p1,p2,p3,p4) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
-#define APPL_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
+#define APPL_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
-#define APPL_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
+#define APPL_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
-#define APPL_TRACE_DEBUG0(m) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m));}
-#define APPL_TRACE_DEBUG1(m,p1) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define APPL_TRACE_DEBUG0(m) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m));}
+#define APPL_TRACE_DEBUG1(m,p1) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1));}
-#define APPL_TRACE_DEBUG2(m,p1,p2) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define APPL_TRACE_DEBUG2(m,p1,p2) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2));}
-#define APPL_TRACE_DEBUG3(m,p1,p2,p3) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define APPL_TRACE_DEBUG3(m,p1,p2,p3) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
-#define APPL_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define APPL_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
-#define APPL_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define APPL_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
-#define APPL_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
+#define APPL_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, \
(m), (UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
#define APPL_TRACE_VERBOSE0(m) {if (appl_trace_level >= BT_TRACE_LEVEL_VERBOSE)\
- LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m));}
+ LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m));}
#define APPL_TRACE_VERBOSE1(m,p1) {if (appl_trace_level >= BT_TRACE_LEVEL_VERBOSE)\
- LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m), \
+ LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m), \
(UINT32)(p1));}
#define APPL_TRACE_VERBOSE2(m,p1,p2) {if (appl_trace_level >= BT_TRACE_LEVEL_VERBOSE)\
- LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m), \
+ LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m), \
(UINT32)(p1), (UINT32)(p2));}
#define APPL_TRACE_VERBOSE3(m,p1,p2,p3) {if (appl_trace_level >= BT_TRACE_LEVEL_VERBOSE)\
- LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m), \
+ LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m), \
(UINT32)(p1), (UINT32)(p2), (UINT32)(p3));}
#define APPL_TRACE_VERBOSE4(m,p1,p2,p3,p4) {if (appl_trace_level >= BT_TRACE_LEVEL_VERBOSE)\
- LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m), \
+ LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m), \
(UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4));}
#define APPL_TRACE_VERBOSE5(m,p1,p2,p3,p4,p5) {if (appl_trace_level >= BT_TRACE_LEVEL_VERBOSE)\
- LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m), \
+ LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m), \
(UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5));}
#define APPL_TRACE_VERBOSE6(m,p1,p2,p3,p4,p5,p6) {if (appl_trace_level >= BT_TRACE_LEVEL_VERBOSE)\
- LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m), \
+ LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, (m), \
(UINT32)(p1), (UINT32)(p2), (UINT32)(p3), (UINT32)(p4), (UINT32)(p5), (UINT32)(p6));}
#else
diff --git a/include/gki_target.h b/include/gki_target.h
index cdd7726..451b3aa 100644
--- a/include/gki_target.h
+++ b/include/gki_target.h
@@ -132,12 +132,12 @@
/* delay in ticks before stopping system tick. */
#ifndef GKI_DELAY_STOP_SYS_TICK
-#define GKI_DELAY_STOP_SYS_TICK 10
+#define GKI_DELAY_STOP_SYS_TICK 0
#endif
/* Option to guarantee no preemption during timer expiration (most system don't need this) */
#ifndef GKI_TIMER_LIST_NOPREEMPT
-#define GKI_TIMER_LIST_NOPREEMPT FALSE
+#define GKI_TIMER_LIST_NOPREEMPT TRUE
#endif
/******************************************************************************
diff --git a/main/Android.mk b/main/Android.mk
index 99c8809..2eec581 100644
--- a/main/Android.mk
+++ b/main/Android.mk
@@ -26,6 +26,7 @@
../btif/src/btif_util.c \
../btif/src/btif_sm.c \
../btif/src/btif_hf.c \
+ ../btif/src/btif_hf_client.c \
../btif/src/btif_av.c \
../btif/src/btif_rc.c \
../btif/src/btif_media_task.c \
@@ -38,6 +39,7 @@
../btif/src/btif_sock_util.c \
../btif/src/btif_pan.c \
../btif/src/btif_gatt.c \
+ ../btif/src/btif_gatt_multi_adv_util.c \
../btif/src/btif_gatt_client.c \
../btif/src/btif_gatt_server.c \
../btif/src/btif_gatt_util.c \
@@ -95,6 +97,7 @@
$(LOCAL_PATH)/../hci/include\
$(LOCAL_PATH)/../vnd/include \
$(LOCAL_PATH)/../embdrv/sbc/encoder/include \
+ $(LOCAL_PATH)/../embdrv/sbc/decoder/include \
$(LOCAL_PATH)/../audio_a2dp_hw \
$(LOCAL_PATH)/../utils/include \
$(bdroid_C_INCLUDES) \
@@ -128,12 +131,13 @@
libbt-utils
#LOCAL_WHOLE_STATIC_LIBRARIES := libbt-brcm_gki libbt-brcm_stack libbt-brcm_bta
-LOCAL_STATIC_LIBRARIES := libosi libbt-brcm_gki libbt-brcm_bta libbt-brcm_stack libtinyxml2
+LOCAL_STATIC_LIBRARIES := libosi libbt-brcm_gki libbt-brcm_bta libbt-brcm_stack libtinyxml2 libbt-qcom_sbc_decoder
LOCAL_MODULE := bluetooth.default
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_REQUIRED_MODULES := libbt-hci libbt-vendor bt_stack.conf bt_did.conf auto_pair_devlist.conf
+LOCAL_MULTILIB := 32
include $(BUILD_SHARED_LIBRARY)
diff --git a/main/bte_conf.c b/main/bte_conf.c
index ddad0c7..0de28b1 100644
--- a/main/bte_conf.c
+++ b/main/bte_conf.c
@@ -27,6 +27,7 @@
#define LOG_TAG "bte_conf"
+#include <assert.h>
#include <utils/Log.h>
#include <stdio.h>
#include <string.h>
@@ -36,6 +37,7 @@
#include "bt_target.h"
#include "bta_api.h"
#include "bt_utils.h"
+#include "config.h"
/******************************************************************************
** Externs
@@ -43,12 +45,13 @@
extern BOOLEAN hci_logging_enabled;
extern char hci_logfile[256];
extern BOOLEAN trace_conf_enabled;
-void bte_trace_conf(char *p_name, char *p_conf_value);
-int device_name_cfg(char *p_conf_name, char *p_conf_value);
-int device_class_cfg(char *p_conf_name, char *p_conf_value);
-int logging_cfg_onoff(char *p_conf_name, char *p_conf_value);
-int logging_set_filepath(char *p_conf_name, char *p_conf_value);
-int trace_cfg_onoff(char *p_conf_name, char *p_conf_value);
+void bte_trace_conf(const char *p_name, const char *p_conf_value);
+void bte_trace_conf_config(const config_t *config);
+int device_name_cfg(const char *p_conf_name, const char *p_conf_value);
+int device_class_cfg(const char *p_conf_name, const char *p_conf_value);
+int logging_cfg_onoff(const char *p_conf_name, const char *p_conf_value);
+int logging_set_filepath(const char *p_conf_name, const char *p_conf_value);
+int trace_cfg_onoff(const char *p_conf_name, const char *p_conf_value);
BD_NAME local_device_default_name = BTM_DEF_LOCAL_NAME;
DEV_CLASS local_device_default_class = {0x40, 0x02, 0x0C};
@@ -70,10 +73,10 @@
#define CONF_COD_DELIMITERS " {,}\t"
#define CONF_MAX_LINE_LEN 255
-typedef int (conf_action_t)(char *p_conf_name, char *p_conf_value);
+typedef int (conf_action_t)(const char *p_conf_name, const char *p_conf_value);
typedef struct {
- const char *conf_entry;
+ const char *key_name;
conf_action_t *p_action;
} conf_entry_t;
@@ -129,20 +132,23 @@
** FUNCTIONS
*****************************************************************************/
-int device_name_cfg(char *p_conf_name, char *p_conf_value)
+int device_name_cfg(const char *p_conf_name, const char *p_conf_value)
{
UNUSED(p_conf_name);
strcpy((char *)local_device_default_name, p_conf_value);
return 0;
}
-int device_class_cfg(char *p_conf_name, char *p_conf_value)
+int device_class_cfg(const char *p_conf_name, const char *p_conf_value)
{
char *p_token;
unsigned int x;
+ char tmp[1024] = { 0 };
+ strncpy(tmp, p_conf_value, sizeof(tmp) - 1);
+
UNUSED(p_conf_name);
- p_token = strtok(p_conf_value, CONF_COD_DELIMITERS);
+ p_token = strtok(tmp, CONF_COD_DELIMITERS);
sscanf(p_token, "%x", &x);
local_device_default_class[0] = (UINT8) x;
p_token = strtok(NULL, CONF_COD_DELIMITERS);
@@ -155,7 +161,7 @@
return 0;
}
-int logging_cfg_onoff(char *p_conf_name, char *p_conf_value)
+int logging_cfg_onoff(const char *p_conf_name, const char *p_conf_value)
{
UNUSED(p_conf_name);
if (strcmp(p_conf_value, "true") == 0)
@@ -165,14 +171,14 @@
return 0;
}
-int logging_set_filepath(char *p_conf_name, char *p_conf_value)
+int logging_set_filepath(const char *p_conf_name, const char *p_conf_value)
{
UNUSED(p_conf_name);
strcpy(hci_logfile, p_conf_value);
return 0;
}
-int trace_cfg_onoff(char *p_conf_name, char *p_conf_value)
+int trace_cfg_onoff(const char *p_conf_name, const char *p_conf_value)
{
UNUSED(p_conf_name);
trace_conf_enabled = (strcmp(p_conf_value, "true") == 0) ? TRUE : FALSE;
@@ -187,75 +193,31 @@
**
** Function bte_load_conf
**
-** Description Read conf entry from p_path file one by one and call
+** Description Read conf entry from path file one by one and call
** the corresponding config function
**
** Returns None
**
*******************************************************************************/
-void bte_load_conf(const char *p_path)
-{
- FILE *p_file;
- char *p_name;
- char *p_value;
- conf_entry_t *p_entry;
- char line[CONF_MAX_LINE_LEN+1]; /* add 1 for \0 char */
- BOOLEAN name_matched;
+void bte_load_conf(const char *path) {
+ assert(path != NULL);
- ALOGI("Attempt to load stack conf from %s", p_path);
+ ALOGI("%s attempt to load stack conf from %s", __func__, path);
- if ((p_file = fopen(p_path, "r")) != NULL)
- {
- /* read line by line */
- while (fgets(line, CONF_MAX_LINE_LEN+1, p_file) != NULL)
- {
- if (line[0] == CONF_COMMENT)
- continue;
+ config_t *config = config_new(path);
+ if (!config) {
+ ALOGI("%s file >%s< not found", __func__, path);
+ return;
+ }
- p_name = strtok(line, CONF_DELIMITERS);
+ for (const conf_entry_t *entry = &conf_table[0]; entry->key_name; ++entry) {
+ const char *value = config_get_string(config, CONFIG_DEFAULT_SECTION, entry->key_name, NULL);
+ if (value)
+ entry->p_action(entry->key_name, value);
+ }
- if (NULL == p_name)
- {
- continue;
- }
-
- p_value = strtok(NULL, CONF_VALUES_DELIMITERS);
-
- if (NULL == p_value)
- {
- ALOGW("bte_load_conf: missing value for name: %s", p_name);
- continue;
- }
-
- name_matched = FALSE;
- p_entry = (conf_entry_t *)conf_table;
-
- while (p_entry->conf_entry != NULL)
- {
- if (strcmp(p_entry->conf_entry, (const char *)p_name) == 0)
- {
- name_matched = TRUE;
- if (p_entry->p_action != NULL)
- p_entry->p_action(p_name, p_value);
- break;
- }
-
- p_entry++;
- }
-
- if ((name_matched == FALSE) && (trace_conf_enabled == TRUE))
- {
- /* Check if this is a TRC config item */
- bte_trace_conf(p_name, p_value);
- }
- }
-
- fclose(p_file);
- }
- else
- {
- ALOGI( "bte_load_conf file >%s< not found", p_path);
- }
+ bte_trace_conf_config(config);
+ config_free(config);
}
/*******************************************************************************
@@ -452,4 +414,3 @@
}
}
}
-
diff --git a/main/bte_logmsg.c b/main/bte_logmsg.c
index 6c9a5eb..c9fc17e 100644
--- a/main/bte_logmsg.c
+++ b/main/bte_logmsg.c
@@ -23,11 +23,13 @@
*
******************************************************************************/
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
+#include "config.h"
#include "gki.h"
#include "bte.h"
@@ -206,13 +208,13 @@
//#define DBG_TRACE
#if defined( DBG_TRACE )
-#define DBG_TRACE_API0( m ) BT_TRACE_0( TRACE_LAYER_HCI, TRACE_TYPE_API, m )
-#define DBG_TRACE_WARNING2( m, p0, p1 ) BT_TRACE_2( TRACE_LAYER_BTM, (TRACE_ORG_APPL|TRACE_TYPE_WARNING), m, p0, p1 )
+#define DBG_TRACE_API0( m ) BT_TRACE( TRACE_LAYER_HCI, TRACE_TYPE_API, m )
+#define DBG_TRACE_WARNING2( m, p0, p1 ) BT_TRACE( TRACE_LAYER_BTM, (TRACE_ORG_APPL|TRACE_TYPE_WARNING), m, p0, p1 )
#else
#define DBG_TRACE_API0( m )
#define DBG_TRACE_WARNING2( m, p0, p1 )
#endif
-#define DBG_TRACE_DEBUG2( m, p0, p1 ) BT_TRACE_2( TRACE_LAYER_BTM, (TRACE_ORG_APPL|TRACE_TYPE_DEBUG), m, p0, p1 )
+#define DBG_TRACE_DEBUG2( m, p0, p1 ) BT_TRACE( TRACE_LAYER_BTM, (TRACE_ORG_APPL|TRACE_TYPE_DEBUG), m, p0, p1 )
void
LogMsg(UINT32 trace_set_mask, const char *fmt_str, ...)
@@ -329,7 +331,7 @@
BOOLEAN trace_conf_enabled = FALSE;
-void bte_trace_conf(char *p_conf_name, char *p_conf_value)
+void bte_trace_conf(const char *p_conf_name, const char *p_conf_value)
{
tBTTRC_FUNC_MAP *p_f_map = (tBTTRC_FUNC_MAP *) &bttrc_set_level_map[0];
@@ -344,6 +346,16 @@
}
}
+void bte_trace_conf_config(const config_t *config) {
+ assert(config != NULL);
+
+ for (tBTTRC_FUNC_MAP *functions = &bttrc_set_level_map[0]; functions->trc_name; ++functions) {
+ int value = config_get_int(config, CONFIG_DEFAULT_SECTION, functions->trc_name, -1);
+ if (value != -1)
+ functions->trace_level = value;
+ }
+}
+
/********************************************************************************
**
** Function Name: BTA_SysSetTraceLevel
@@ -526,121 +538,3 @@
}
#endif
}
-
-
-/********************************************************************************
- **
- ** Function Name: LogMsg_0
- **
- ** Purpose: Encodes a trace message that has no parameter arguments
- **
- ** Input Parameters: trace_set_mask: tester trace type.
- ** fmt_str: displayable string.
- ** Returns:
- ** Nothing.
- **
- *********************************************************************************/
-void LogMsg_0(UINT32 trace_set_mask, const char *fmt_str) {
- LogMsg(trace_set_mask, fmt_str);
-}
-
-/********************************************************************************
- **
- ** Function Name: LogMsg_1
- **
- ** Purpose: Encodes a trace message that has one parameter argument
- **
- ** Input Parameters: trace_set_mask: tester trace type.
- ** fmt_str: displayable string.
- ** Returns:
- ** Nothing.
- **
- *********************************************************************************/
-void LogMsg_1(UINT32 trace_set_mask, const char *fmt_str, UINT32 p1) {
-
- LogMsg(trace_set_mask, fmt_str, p1);
-}
-
-/********************************************************************************
- **
- ** Function Name: LogMsg_2
- **
- ** Purpose: Encodes a trace message that has two parameter arguments
- **
- ** Input Parameters: trace_set_mask: tester trace type.
- ** fmt_str: displayable string.
- ** Returns:
- ** Nothing.
- **
- *********************************************************************************/
-void LogMsg_2(UINT32 trace_set_mask, const char *fmt_str, UINT32 p1, UINT32 p2) {
- LogMsg(trace_set_mask, fmt_str, p1, p2);
-}
-
-/********************************************************************************
- **
- ** Function Name: LogMsg_3
- **
- ** Purpose: Encodes a trace message that has three parameter arguments
- **
- ** Input Parameters: trace_set_mask: tester trace type.
- ** fmt_str: displayable string.
- ** Returns:
- ** Nothing.
- **
- *********************************************************************************/
-void LogMsg_3(UINT32 trace_set_mask, const char *fmt_str, UINT32 p1, UINT32 p2,
- UINT32 p3) {
- LogMsg(trace_set_mask, fmt_str, p1, p2, p3);
-}
-
-/********************************************************************************
- **
- ** Function Name: LogMsg_4
- **
- ** Purpose: Encodes a trace message that has four parameter arguments
- **
- ** Input Parameters: trace_set_mask: tester trace type.
- ** fmt_str: displayable string.
- ** Returns:
- ** Nothing.
- **
- *********************************************************************************/
-void LogMsg_4(UINT32 trace_set_mask, const char *fmt_str, UINT32 p1, UINT32 p2,
- UINT32 p3, UINT32 p4) {
- LogMsg(trace_set_mask, fmt_str, p1, p2, p3, p4);
-}
-
-/********************************************************************************
- **
- ** Function Name: LogMsg_5
- **
- ** Purpose: Encodes a trace message that has five parameter arguments
- **
- ** Input Parameters: trace_set_mask: tester trace type.
- ** fmt_str: displayable string.
- ** Returns:
- ** Nothing.
- **
- *********************************************************************************/
-void LogMsg_5(UINT32 trace_set_mask, const char *fmt_str, UINT32 p1, UINT32 p2,
- UINT32 p3, UINT32 p4, UINT32 p5) {
- LogMsg(trace_set_mask, fmt_str, p1, p2, p3, p4, p5);
-}
-
-/********************************************************************************
- **
- ** Function Name: LogMsg_6
- **
- ** Purpose: Encodes a trace message that has six parameter arguments
- **
- ** Input Parameters: trace_set_mask: tester trace type.
- ** fmt_str: displayable string.
- ** Returns:
- ** Nothing.
- **
- *********************************************************************************/
-void LogMsg_6(UINT32 trace_set_mask, const char *fmt_str, UINT32 p1, UINT32 p2,
- UINT32 p3, UINT32 p4, UINT32 p5, UINT32 p6) {
- LogMsg(trace_set_mask, fmt_str, p1, p2, p3, p4, p5, p6);
-}
diff --git a/osi/Android.mk b/osi/Android.mk
index e221ed1..23c43f7 100644
--- a/osi/Android.mk
+++ b/osi/Android.mk
@@ -6,12 +6,15 @@
$(LOCAL_PATH)/include
LOCAL_SRC_FILES := \
- ./src/list.c
+ ./src/config.c \
+ ./src/fixed_queue.c \
+ ./src/list.c \
+ ./src/semaphore.c
LOCAL_CFLAGS := -std=c99 -Wall -Werror
LOCAL_MODULE := libosi
LOCAL_MODULE_TAGS := optional
-LOCAL_SHARED_LIBRARIES := libc
+LOCAL_SHARED_LIBRARIES := libc liblog
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
include $(BUILD_STATIC_LIBRARY)
@@ -24,11 +27,13 @@
$(LOCAL_PATH)/include
LOCAL_SRC_FILES := \
+ ./test/config_test.cpp \
./test/list_test.cpp
LOCAL_CFLAGS := -Wall -Werror
LOCAL_MODULE := ositests
LOCAL_MODULE_TAGS := tests
+LOCAL_SHARED_LIBRARIES := liblog
LOCAL_STATIC_LIBRARIES := libosi
include $(BUILD_NATIVE_TEST)
diff --git a/osi/include/config.h b/osi/include/config.h
new file mode 100644
index 0000000..5e45003
--- /dev/null
+++ b/osi/include/config.h
@@ -0,0 +1,78 @@
+#pragma once
+
+// This module implements a configuration parser. Clients can query the
+// contents of a configuration file through the interface provided here.
+// The current implementation is read-only; mutations are only kept in
+// memory. This parser supports the INI file format.
+
+// Implementation notes:
+// - Key/value pairs that are not within a section are assumed to be under
+// the |CONFIG_DEFAULT_SECTION| section.
+// - Multiple sections with the same name will be merged as if they were in
+// a single section.
+// - Empty sections with no key/value pairs will be treated as if they do
+// not exist. In other words, |config_has_section| will return false for
+// empty sections.
+// - Duplicate keys in a section will overwrite previous values.
+
+#include <stdbool.h>
+
+// The default section name to use if a key/value pair is not defined within
+// a section.
+#define CONFIG_DEFAULT_SECTION "Global"
+
+struct config_t;
+typedef struct config_t config_t;
+
+// Loads the specified file and returns a handle to the config file. If there
+// was a problem loading the file or allocating memory, this function returns
+// NULL. Clients must call |config_free| on the returned handle when it is no
+// longer required. |filename| must not be NULL and must point to a readable
+// file on the filesystem.
+config_t *config_new(const char *filename);
+
+// Frees resources associated with the config file. No further operations may
+// be performed on the |config| object after calling this function. |config|
+// may be NULL.
+void config_free(config_t *config);
+
+// Returns true if the config file contains a section named |section|. If
+// the section has no key/value pairs in it, this function will return false.
+// |config| and |section| must not be NULL.
+bool config_has_section(const config_t *config, const char *section);
+
+// Returns true if the config file has a key named |key| under |section|.
+// Returns false otherwise. |config|, |section|, and |key| must not be NULL.
+bool config_has_key(const config_t *config, const char *section, const char *key);
+
+// Returns the integral value for a given |key| in |section|. If |section|
+// or |key| do not exist, or the value cannot be fully converted to an integer,
+// this function returns |def_value|. |config|, |section|, and |key| must not
+// be NULL.
+int config_get_int(const config_t *config, const char *section, const char *key, int def_value);
+
+// Returns the boolean value for a given |key| in |section|. If |section|
+// or |key| do not exist, or the value cannot be converted to a boolean, this
+// function returns |def_value|. |config|, |section|, and |key| must not be NULL.
+bool config_get_bool(const config_t *config, const char *section, const char *key, bool def_value);
+
+// Returns the string value for a given |key| in |section|. If |section| or
+// |key| do not exist, this function returns |def_value|. The returned string
+// is owned by the config module and must not be freed. |config|, |section|,
+// and |key| must not be NULL. |def_value| may be NULL.
+const char *config_get_string(const config_t *config, const char *section, const char *key, const char *def_value);
+
+// Sets an integral value for the |key| in |section|. If |key| or |section| do
+// not already exist, this function creates them. |config|, |section|, and |key|
+// must not be NULL.
+void config_set_int(config_t *config, const char *section, const char *key, int value);
+
+// Sets a boolean value for the |key| in |section|. If |key| or |section| do
+// not already exist, this function creates them. |config|, |section|, and |key|
+// must not be NULL.
+void config_set_bool(config_t *config, const char *section, const char *key, bool value);
+
+// Sets a string value for the |key| in |section|. If |key| or |section| do
+// not already exist, this function creates them. |config|, |section|, |key|, and
+// |value| must not be NULL.
+void config_set_string(config_t *config, const char *section, const char *key, const char *value);
diff --git a/osi/include/fixed_queue.h b/osi/include/fixed_queue.h
new file mode 100644
index 0000000..5c4f9c4
--- /dev/null
+++ b/osi/include/fixed_queue.h
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "list.h"
+
+struct fixed_queue_t;
+typedef struct fixed_queue_t fixed_queue_t;
+
+typedef void (*fixed_queue_free_cb)(void *data);
+
+fixed_queue_t *fixed_queue_new(size_t capacity);
+
+// Freeing a queue that is currently in use (i.e. has waiters
+// blocked on it) resuls in undefined behaviour.
+void fixed_queue_free(fixed_queue_t *queue, fixed_queue_free_cb free_cb);
+
+void fixed_queue_enqueue(fixed_queue_t *queue, void *data);
+void *fixed_queue_dequeue(fixed_queue_t *queue);
diff --git a/osi/include/osi.h b/osi/include/osi.h
index 3ca81a6..2b79527 100644
--- a/osi/include/osi.h
+++ b/osi/include/osi.h
@@ -3,5 +3,5 @@
#include <stdbool.h>
#include <stdint.h>
-#define UNUSED __attribute__((unused))
+#define UNUSED_ATTR __attribute__((unused))
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
diff --git a/osi/include/semaphore.h b/osi/include/semaphore.h
new file mode 100644
index 0000000..3c8b13a
--- /dev/null
+++ b/osi/include/semaphore.h
@@ -0,0 +1,10 @@
+#pragma once
+
+struct semaphore_t;
+typedef struct semaphore_t semaphore_t;
+
+semaphore_t *semaphore_new(unsigned int value);
+void semaphore_free(semaphore_t *semaphore);
+
+void semaphore_wait(semaphore_t *semaphore);
+void semaphore_post(semaphore_t *semaphore);
diff --git a/osi/src/config.c b/osi/src/config.c
new file mode 100644
index 0000000..f38c7f0
--- /dev/null
+++ b/osi/src/config.c
@@ -0,0 +1,278 @@
+#define LOG_TAG "bt_osi_config"
+
+#include <assert.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <utils/Log.h>
+
+#include "config.h"
+#include "list.h"
+
+typedef struct {
+ char *key;
+ char *value;
+} entry_t;
+
+typedef struct {
+ char *name;
+ list_t *entries;
+} section_t;
+
+struct config_t {
+ list_t *sections;
+};
+
+static void config_parse(FILE *fp, config_t *config);
+
+static section_t *section_new(const char *name);
+static void section_free(void *ptr);
+static section_t *section_find(const config_t *config, const char *section);
+
+static entry_t *entry_new(const char *key, const char *value);
+static void entry_free(void *ptr);
+static entry_t *entry_find(const config_t *config, const char *section, const char *key);
+
+config_t *config_new(const char *filename) {
+ assert(filename != NULL);
+
+ FILE *fp = fopen(filename, "rt");
+ if (!fp) {
+ ALOGE("%s unable to open file '%s': %s", __func__, filename, strerror(errno));
+ return NULL;
+ }
+
+ config_t *config = calloc(1, sizeof(config_t));
+ if (!config) {
+ ALOGE("%s unable to allocate memory for config_t.", __func__);
+ fclose(fp);
+ return NULL;
+ }
+
+ config->sections = list_new(section_free);
+ config_parse(fp, config);
+
+ fclose(fp);
+
+ return config;
+}
+
+void config_free(config_t *config) {
+ if (!config)
+ return;
+
+ list_free(config->sections);
+ free(config);
+}
+
+bool config_has_section(const config_t *config, const char *section) {
+ assert(config != NULL);
+ assert(section != NULL);
+
+ return (section_find(config, section) != NULL);
+}
+
+bool config_has_key(const config_t *config, const char *section, const char *key) {
+ assert(config != NULL);
+ assert(section != NULL);
+ assert(key != NULL);
+
+ return (entry_find(config, section, key) != NULL);
+}
+
+int config_get_int(const config_t *config, const char *section, const char *key, int def_value) {
+ assert(config != NULL);
+ assert(section != NULL);
+ assert(key != NULL);
+
+ entry_t *entry = entry_find(config, section, key);
+ if (!entry)
+ return def_value;
+
+ char *endptr;
+ int ret = strtol(entry->value, &endptr, 0);
+ return (*endptr == '\0') ? ret : def_value;
+}
+
+bool config_get_bool(const config_t *config, const char *section, const char *key, bool def_value) {
+ assert(config != NULL);
+ assert(section != NULL);
+ assert(key != NULL);
+
+ entry_t *entry = entry_find(config, section, key);
+ if (!entry)
+ return def_value;
+
+ if (!strcmp(entry->value, "true"))
+ return true;
+ if (!strcmp(entry->value, "false"))
+ return false;
+
+ return def_value;
+}
+
+const char *config_get_string(const config_t *config, const char *section, const char *key, const char *def_value) {
+ assert(config != NULL);
+ assert(section != NULL);
+ assert(key != NULL);
+
+ entry_t *entry = entry_find(config, section, key);
+ if (!entry)
+ return def_value;
+
+ return entry->value;
+}
+
+void config_set_int(config_t *config, const char *section, const char *key, int value) {
+ assert(config != NULL);
+ assert(section != NULL);
+ assert(key != NULL);
+
+ char value_str[32] = { 0 };
+ sprintf(value_str, "%d", value);
+ config_set_string(config, section, key, value_str);
+}
+
+void config_set_bool(config_t *config, const char *section, const char *key, bool value) {
+ assert(config != NULL);
+ assert(section != NULL);
+ assert(key != NULL);
+
+ config_set_string(config, section, key, value ? "true" : "false");
+}
+
+void config_set_string(config_t *config, const char *section, const char *key, const char *value) {
+ section_t *sec = section_find(config, section);
+ if (!sec) {
+ sec = section_new(section);
+ list_append(config->sections, sec);
+ }
+
+ for (const list_node_t *node = list_begin(sec->entries); node != list_end(sec->entries); node = list_next(node)) {
+ entry_t *entry = list_node(node);
+ if (!strcmp(entry->key, key)) {
+ free(entry->value);
+ entry->value = strdup(value);
+ return;
+ }
+ }
+
+ entry_t *entry = entry_new(key, value);
+ list_append(sec->entries, entry);
+}
+
+static char *trim(char *str) {
+ while (isspace(*str))
+ ++str;
+
+ if (!*str)
+ return str;
+
+ char *end_str = str + strlen(str) - 1;
+ while (end_str > str && isspace(*end_str))
+ --end_str;
+
+ end_str[1] = '\0';
+ return str;
+}
+
+static void config_parse(FILE *fp, config_t *config) {
+ assert(fp != NULL);
+ assert(config != NULL);
+
+ int line_num = 0;
+ char line[1024];
+ char section[1024];
+ strcpy(section, CONFIG_DEFAULT_SECTION);
+
+ while (fgets(line, sizeof(line), fp)) {
+ char *line_ptr = trim(line);
+ ++line_num;
+
+ // Skip blank and comment lines.
+ if (*line_ptr == '\0' || *line_ptr == '#')
+ continue;
+
+ if (*line_ptr == '[') {
+ size_t len = strlen(line_ptr);
+ if (line_ptr[len - 1] != ']') {
+ ALOGD("%s unterminated section name on line %d.", __func__, line_num);
+ continue;
+ }
+ strncpy(section, line_ptr + 1, len - 2);
+ section[len - 2] = '\0';
+ } else {
+ char *split = strchr(line_ptr, '=');
+ if (!split) {
+ ALOGD("%s no key/value separator found on line %d.", __func__, line_num);
+ continue;
+ }
+
+ *split = '\0';
+ config_set_string(config, section, trim(line_ptr), trim(split + 1));
+ }
+ }
+}
+
+static section_t *section_new(const char *name) {
+ section_t *section = calloc(1, sizeof(section_t));
+ if (!section)
+ return NULL;
+
+ section->name = strdup(name);
+ section->entries = list_new(entry_free);
+ return section;
+}
+
+static void section_free(void *ptr) {
+ if (!ptr)
+ return;
+
+ section_t *section = ptr;
+ free(section->name);
+ list_free(section->entries);
+}
+
+static section_t *section_find(const config_t *config, const char *section) {
+ for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); node = list_next(node)) {
+ section_t *sec = list_node(node);
+ if (!strcmp(sec->name, section))
+ return sec;
+ }
+
+ return NULL;
+}
+
+static entry_t *entry_new(const char *key, const char *value) {
+ entry_t *entry = calloc(1, sizeof(entry_t));
+ if (!entry)
+ return NULL;
+
+ entry->key = strdup(key);
+ entry->value = strdup(value);
+ return entry;
+}
+
+static void entry_free(void *ptr) {
+ if (!ptr)
+ return;
+
+ entry_t *entry = ptr;
+ free(entry->key);
+ free(entry->value);
+}
+
+static entry_t *entry_find(const config_t *config, const char *section, const char *key) {
+ section_t *sec = section_find(config, section);
+ if (!sec)
+ return NULL;
+
+ for (const list_node_t *node = list_begin(sec->entries); node != list_end(sec->entries); node = list_next(node)) {
+ entry_t *entry = list_node(node);
+ if (!strcmp(entry->key, key))
+ return entry;
+ }
+
+ return NULL;
+}
diff --git a/osi/src/fixed_queue.c b/osi/src/fixed_queue.c
new file mode 100644
index 0000000..76cf603
--- /dev/null
+++ b/osi/src/fixed_queue.c
@@ -0,0 +1,94 @@
+#include <assert.h>
+#include <pthread.h>
+#include <stdlib.h>
+
+#include "fixed_queue.h"
+#include "list.h"
+#include "osi.h"
+#include "semaphore.h"
+
+typedef struct fixed_queue_t {
+ list_t *list;
+ semaphore_t *enqueue_sem;
+ semaphore_t *dequeue_sem;
+ pthread_mutex_t lock;
+ size_t capacity;
+} fixed_queue_t;
+
+fixed_queue_t *fixed_queue_new(size_t capacity) {
+ fixed_queue_t *ret = calloc(1, sizeof(fixed_queue_t));
+ if (!ret)
+ goto error;
+
+ ret->list = list_new(NULL);
+ if (!ret->list)
+ goto error;
+
+ ret->enqueue_sem = semaphore_new(capacity);
+ if (!ret->enqueue_sem)
+ goto error;
+
+ ret->dequeue_sem = semaphore_new(0);
+ if (!ret->dequeue_sem)
+ goto error;
+
+ pthread_mutex_init(&ret->lock, NULL);
+ ret->capacity = capacity;
+
+ return ret;
+
+error:;
+ if (ret) {
+ list_free(ret->list);
+ semaphore_free(ret->enqueue_sem);
+ semaphore_free(ret->dequeue_sem);
+ }
+
+ free(ret);
+ return NULL;
+}
+
+void fixed_queue_free(fixed_queue_t *queue, fixed_queue_free_cb free_cb) {
+ if (!queue)
+ return;
+
+ if (free_cb)
+ for (const list_node_t *node = list_begin(queue->list); node != list_end(queue->list); node = list_next(node))
+ free_cb(list_node(node));
+
+ list_free(queue->list);
+ semaphore_free(queue->enqueue_sem);
+ semaphore_free(queue->dequeue_sem);
+ pthread_mutex_destroy(&queue->lock);
+ free(queue);
+}
+
+void fixed_queue_enqueue(fixed_queue_t *queue, void *data) {
+ assert(queue != NULL);
+ assert(data != NULL);
+
+ semaphore_wait(queue->enqueue_sem);
+
+ pthread_mutex_lock(&queue->lock);
+ list_append(queue->list, data);
+ pthread_mutex_unlock(&queue->lock);
+
+ semaphore_post(queue->dequeue_sem);
+}
+
+void *fixed_queue_dequeue(fixed_queue_t *queue) {
+ assert(queue != NULL);
+
+ void *ret;
+
+ semaphore_wait(queue->dequeue_sem);
+
+ pthread_mutex_lock(&queue->lock);
+ ret = list_front(queue->list);
+ list_remove(queue->list, ret);
+ pthread_mutex_unlock(&queue->lock);
+
+ semaphore_post(queue->enqueue_sem);
+
+ return ret;
+}
diff --git a/osi/src/list.c b/osi/src/list.c
index 5d84ef6..caffa8c 100644
--- a/osi/src/list.c
+++ b/osi/src/list.c
@@ -185,7 +185,7 @@
// this function returns the value of an invalid iterator for the given list.
// When an iterator has the same value as what's returned by this function, you
// may no longer call |list_next| with the iterator. |list| may not be NULL.
-const list_node_t *list_end(UNUSED const list_t *list) {
+const list_node_t *list_end(UNUSED_ATTR const list_t *list) {
assert(list != NULL);
return NULL;
}
diff --git a/osi/src/semaphore.c b/osi/src/semaphore.c
new file mode 100644
index 0000000..a46c435
--- /dev/null
+++ b/osi/src/semaphore.c
@@ -0,0 +1,53 @@
+#define LOG_TAG "osi_semaphore"
+
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/eventfd.h>
+#include <utils/Log.h>
+
+#include "semaphore.h"
+
+#if !defined(EFD_SEMAPHORE)
+# define EFD_SEMAPHORE (1 << 0)
+#endif
+
+struct semaphore_t {
+ int fd;
+};
+
+semaphore_t *semaphore_new(unsigned int value) {
+ semaphore_t *ret = malloc(sizeof(semaphore_t));
+ if (ret) {
+ ret->fd = eventfd(value, EFD_SEMAPHORE);
+ if (ret->fd == -1) {
+ ALOGE("%s unable to allocate semaphore: %s", __func__, strerror(errno));
+ free(ret);
+ ret = NULL;
+ }
+ }
+ return ret;
+}
+
+void semaphore_free(semaphore_t *semaphore) {
+ if (semaphore->fd != -1)
+ close(semaphore->fd);
+ free(semaphore);
+}
+
+void semaphore_wait(semaphore_t *semaphore) {
+ assert(semaphore != NULL);
+ assert(semaphore->fd != -1);
+
+ uint64_t value;
+ if (eventfd_read(semaphore->fd, &value) == -1)
+ ALOGE("%s unable to wait on semaphore: %s", __func__, strerror(errno));
+}
+
+void semaphore_post(semaphore_t *semaphore) {
+ assert(semaphore != NULL);
+ assert(semaphore->fd != -1);
+
+ if (eventfd_write(semaphore->fd, 1ULL) == -1)
+ ALOGE("%s unable to post to semaphore: %s", __func__, strerror(errno));
+}
diff --git a/osi/test/config_test.cpp b/osi/test/config_test.cpp
new file mode 100644
index 0000000..1ce199d
--- /dev/null
+++ b/osi/test/config_test.cpp
@@ -0,0 +1,113 @@
+#include <gtest/gtest.h>
+
+extern "C" {
+#include "config.h"
+}
+
+static const char CONFIG_FILE[] = "/data/local/tmp/config_test.conf";
+static const char CONFIG_FILE_CONTENT[] =
+" \n\
+first_key=value \n\
+ \n\
+# Device ID (DID) configuration \n\
+[DID] \n\
+ \n\
+# Record Number: 1, 2 or 3 - maximum of 3 records \n\
+recordNumber = 1 \n\
+ \n\
+# Primary Record - true or false (default) \n\
+# There can be only one primary record \n\
+primaryRecord = true \n\
+ \n\
+# Vendor ID '0xFFFF' indicates no Device ID Service Record is present in the device \n\
+# 0x000F = Broadcom Corporation (default) \n\
+#vendorId = 0x000F \n\
+ \n\
+# Vendor ID Source \n\
+# 0x0001 = Bluetooth SIG assigned Device ID Vendor ID value (default) \n\
+# 0x0002 = USB Implementer's Forum assigned Device ID Vendor ID value \n\
+#vendorIdSource = 0x0001 \n\
+ \n\
+# Product ID & Product Version \n\
+# Per spec DID v1.3 0xJJMN for version is interpreted as JJ.M.N \n\
+# JJ: major version number, M: minor version number, N: sub-minor version number \n\
+# For example: 1200, v14.3.6 \n\
+productId = 0x1200 \n\
+version = 0x1111 \n\
+ \n\
+# Optional attributes \n\
+#clientExecutableURL = \n\
+#serviceDescription = \n\
+#documentationURL = \n\
+ \n\
+# Additional optional DID records. Bluedroid supports up to 3 records. \n\
+[DID] \n\
+[DID] \n\
+version = 0x1436 \n\
+";
+
+class ConfigTest : public ::testing::Test {
+ protected:
+ virtual void SetUp() {
+ FILE *fp = fopen(CONFIG_FILE, "wt");
+ fwrite(CONFIG_FILE_CONTENT, 1, sizeof(CONFIG_FILE_CONTENT), fp);
+ fclose(fp);
+ }
+};
+
+TEST_F(ConfigTest, config_new_no_file) {
+ config_t *config = config_new("/meow");
+ EXPECT_TRUE(config == NULL);
+}
+
+TEST_F(ConfigTest, config_new) {
+ config_t *config = config_new(CONFIG_FILE);
+ EXPECT_TRUE(config != NULL);
+ config_free(config);
+}
+
+TEST_F(ConfigTest, config_free_null) {
+ config_free(NULL);
+}
+
+TEST_F(ConfigTest, config_has_section) {
+ config_t *config = config_new(CONFIG_FILE);
+ EXPECT_TRUE(config_has_section(config, "DID"));
+ config_free(config);
+}
+
+TEST_F(ConfigTest, config_has_key_in_default_section) {
+ config_t *config = config_new(CONFIG_FILE);
+ EXPECT_TRUE(config_has_key(config, CONFIG_DEFAULT_SECTION, "first_key"));
+ EXPECT_STREQ(config_get_string(config, CONFIG_DEFAULT_SECTION, "first_key", "meow"), "value");
+ config_free(config);
+}
+
+TEST_F(ConfigTest, config_has_keys) {
+ config_t *config = config_new(CONFIG_FILE);
+ EXPECT_TRUE(config_has_key(config, "DID", "recordNumber"));
+ EXPECT_TRUE(config_has_key(config, "DID", "primaryRecord"));
+ EXPECT_TRUE(config_has_key(config, "DID", "productId"));
+ EXPECT_TRUE(config_has_key(config, "DID", "version"));
+ config_free(config);
+}
+
+TEST_F(ConfigTest, config_no_bad_keys) {
+ config_t *config = config_new(CONFIG_FILE);
+ EXPECT_FALSE(config_has_key(config, "DID_BAD", "primaryRecord"));
+ EXPECT_FALSE(config_has_key(config, "DID", "primaryRecord_BAD"));
+ EXPECT_FALSE(config_has_key(config, CONFIG_DEFAULT_SECTION, "primaryRecord"));
+ config_free(config);
+}
+
+TEST_F(ConfigTest, config_get_int_version) {
+ config_t *config = config_new(CONFIG_FILE);
+ EXPECT_EQ(config_get_int(config, "DID", "version", 0), 0x1436);
+ config_free(config);
+}
+
+TEST_F(ConfigTest, config_get_int_default) {
+ config_t *config = config_new(CONFIG_FILE);
+ EXPECT_EQ(config_get_int(config, "DID", "primaryRecord", 123), 123);
+ config_free(config);
+}
diff --git a/osi/test/list_test.cpp b/osi/test/list_test.cpp
index 06e8be7..d874b4b 100644
--- a/osi/test/list_test.cpp
+++ b/osi/test/list_test.cpp
@@ -133,3 +133,17 @@
list_free(list);
}
+
+TEST(ListTest, test_list_begin_empty_list) {
+ list_t *list = list_new(NULL);
+ EXPECT_EQ(list_begin(list), list_end(list));
+ list_free(list);
+}
+
+TEST(ListTest, test_list_next) {
+ list_t *list = list_new(NULL);
+ list_append(list, &list);
+ EXPECT_NE(list_begin(list), list_end(list));
+ EXPECT_EQ(list_next(list_begin(list)), list_end(list));
+ list_free(list);
+}
diff --git a/stack/Android.mk b/stack/Android.mk
index ecc42ef..fd76ed8 100644
--- a/stack/Android.mk
+++ b/stack/Android.mk
@@ -1,5 +1,3 @@
-ifneq ($(TARGET_SIMULATOR),true)
-
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
@@ -67,6 +65,7 @@
./btm/btm_main.c \
./btm/btm_dev.c \
./btm/btm_ble_gap.c \
+ ./btm/btm_ble_multi_adv.c \
./btm/btm_acl.c \
./btm/btm_sco.c \
./btm/btm_pm.c \
@@ -153,7 +152,6 @@
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_SHARED_LIBRARIES := libcutils libc
+LOCAL_MULTILIB := 32
include $(BUILD_STATIC_LIBRARY)
-
-endif # TARGET_SIMULATOR != true
diff --git a/stack/a2dp/a2d_sbc.c b/stack/a2dp/a2d_sbc.c
index a4e5255..3858b4a 100644
--- a/stack/a2dp/a2d_sbc.c
+++ b/stack/a2dp/a2d_sbc.c
@@ -24,12 +24,13 @@
******************************************************************************/
#include "bt_target.h"
-
-#if (A2D_SBC_INCLUDED == TRUE)
#include <string.h>
#include "a2d_api.h"
#include "a2d_int.h"
#include "a2d_sbc.h"
+#include "bt_utils.h"
+
+#if (A2D_SBC_INCLUDED == TRUE)
/*************************************************************************************************
* SBC descramble code
@@ -398,4 +399,57 @@
}
}
+#else /* A2D_SBC_INCLUDED == TRUE */
+
+void A2D_SbcChkFrInit(UINT8 *p_pkt)
+{
+ UNUSED(p_pkt);
+}
+
+void A2D_SbcDescramble(UINT8 *p_pkt, UINT16 len)
+{
+ UNUSED(p_pkt);
+ UNUSED(len);
+}
+
+tA2D_STATUS A2D_BldSbcInfo(UINT8 media_type, tA2D_SBC_CIE *p_ie,
+ UINT8 *p_result)
+{
+ UNUSED(media_type);
+ UNUSED(p_ie);
+ UNUSED(p_result);
+ return A2D_FAIL;
+}
+
+tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info,
+ BOOLEAN for_caps)
+{
+ UNUSED(p_ie);
+ UNUSED(p_info);
+ UNUSED(for_caps);
+ return A2D_FAIL;
+}
+
+void A2D_BldSbcMplHdr(UINT8 *p_dst, BOOLEAN frag, BOOLEAN start,
+ BOOLEAN last, UINT8 num)
+{
+ UNUSED(p_dst);
+ UNUSED(frag);
+ UNUSED(start);
+ UNUSED(last);
+ UNUSED(num);
+}
+
+void A2D_ParsSbcMplHdr(UINT8 *p_src, BOOLEAN *p_frag,
+ BOOLEAN *p_start, BOOLEAN *p_last,
+ UINT8 *p_num)
+{
+ UNUSED(p_src);
+ UNUSED(p_frag);
+ UNUSED(p_start);
+ UNUSED(p_last);
+ UNUSED(p_num);
+}
+
+
#endif /* A2D_SBC_INCLUDED == TRUE */
diff --git a/stack/avdt/avdt_ad.c b/stack/avdt/avdt_ad.c
index 7fe665c..5f9e60a 100644
--- a/stack/avdt/avdt_ad.c
+++ b/stack/avdt/avdt_ad.c
@@ -482,7 +482,10 @@
avdt_scb_event(p_scb, AVDT_SCB_TC_DATA_EVT, (tAVDT_SCB_EVT *) &p_buf);
}
else
+ {
GKI_freebuf(p_buf);
+ AVDT_TRACE_ERROR0(" avdt_ad_tc_data_ind buffer freed");
+ }
}
}
diff --git a/stack/avdt/avdt_api.c b/stack/avdt/avdt_api.c
index 855f17e..5e5ea2b 100644
--- a/stack/avdt/avdt_api.c
+++ b/stack/avdt/avdt_api.c
@@ -176,6 +176,68 @@
/*******************************************************************************
**
+** Function AVDT_SINK_Activate
+**
+** Description Activate SEP of A2DP Sink. In Use parameter is adjusted.
+** In Use will be made false in case of activation. A2DP SRC
+** will receive in_use as false and can open A2DP Sink
+** connection
+**
+** Returns void.
+**
+*******************************************************************************/
+void AVDT_SINK_Activate()
+{
+ tAVDT_SCB *p_scb = &avdt_cb.scb[0];
+ int i;
+ AVDT_TRACE_DEBUG0("AVDT_SINK_Activate");
+ /* for all allocated scbs */
+ for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++)
+ {
+ if ((p_scb->allocated) && (p_scb->cs.tsep == AVDT_TSEP_SNK))
+ {
+ AVDT_TRACE_DEBUG0("AVDT_SINK_Activate found scb");
+ p_scb->sink_activated = TRUE;
+ /* update in_use */
+ p_scb->in_use = FALSE;
+ break;
+ }
+ }
+}
+
+/*******************************************************************************
+**
+** Function AVDT_SINK_Deactivate
+**
+** Description Deactivate SEP of A2DP Sink. In Use parameter is adjusted.
+** In Use will be made TRUE in case of activation. A2DP SRC
+** will receive in_use as true and will not open A2DP Sink
+** connection
+**
+** Returns void.
+**
+*******************************************************************************/
+void AVDT_SINK_Deactivate()
+{
+ tAVDT_SCB *p_scb = &avdt_cb.scb[0];
+ int i;
+ AVDT_TRACE_DEBUG0("AVDT_SINK_Deactivate");
+ /* for all allocated scbs */
+ for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++)
+ {
+ if ((p_scb->allocated) && (p_scb->cs.tsep == AVDT_TSEP_SNK))
+ {
+ AVDT_TRACE_DEBUG0("AVDT_SINK_Deactivate, found scb");
+ p_scb->sink_activated = FALSE;
+ /* update in_use */
+ p_scb->in_use = TRUE;
+ break;
+ }
+ }
+}
+
+/*******************************************************************************
+**
** Function AVDT_CreateStream
**
** Description Create a stream endpoint. After a stream endpoint is
diff --git a/stack/avdt/avdt_int.h b/stack/avdt/avdt_int.h
index 04968a6..e9752c2 100644
--- a/stack/avdt/avdt_int.h
+++ b/stack/avdt/avdt_int.h
@@ -491,6 +491,7 @@
UINT16 media_seq; /* media packet sequence number */
BOOLEAN allocated; /* whether scb is allocated or unused */
BOOLEAN in_use; /* whether stream being used by peer */
+ BOOLEAN sink_activated; /* A2DP Sink activated/de-activated from Application */
UINT8 role; /* initiator/acceptor role in current procedure */
BOOLEAN remove; /* whether CB is marked for removal */
UINT8 state; /* state machine state */
diff --git a/stack/avdt/avdt_scb.c b/stack/avdt/avdt_scb.c
index d0c9e0f..f509240 100644
--- a/stack/avdt/avdt_scb.c
+++ b/stack/avdt/avdt_scb.c
@@ -601,6 +601,13 @@
memset(p_scb,0,sizeof(tAVDT_SCB));
p_scb->allocated = TRUE;
p_scb->p_ccb = NULL;
+
+ /* initialize sink as activated */
+ if (p_cs->tsep == AVDT_TSEP_SNK)
+ {
+ p_scb->sink_activated = TRUE;
+ }
+
memcpy(&p_scb->cs, p_cs, sizeof(tAVDT_CS));
#if AVDT_MULTIPLEXING == TRUE
/* initialize fragments gueue */
diff --git a/stack/avdt/avdt_scb_act.c b/stack/avdt/avdt_scb_act.c
index 8175b96..87cc61f 100644
--- a/stack/avdt/avdt_scb_act.c
+++ b/stack/avdt/avdt_scb_act.c
@@ -678,7 +678,7 @@
UNUSED(p_scb);
GKI_freebuf(p_data->p_pkt);
- AVDT_TRACE_WARNING0("Dropped incoming media packet");
+ AVDT_TRACE_ERROR0(" avdt_scb_drop_pkt Dropped incoming media packet");
}
/*******************************************************************************
@@ -826,7 +826,7 @@
p_scb->peer_seid = p_data->msg.config_cmd.int_seid;
memcpy(&p_scb->req_cfg, p_cfg, sizeof(tAVDT_CFG));
/* call app callback */
- (*p_scb->cs.p_ctrl_cback)(avdt_scb_to_hdl(p_scb),
+ (*p_scb->cs.p_ctrl_cback)(avdt_scb_to_hdl(p_scb), /* handle of scb- which is same as sep handle of bta_av_cb.p_scb*/
p_scb->p_ccb ? p_scb->p_ccb->peer_addr : NULL,
AVDT_CONFIG_IND_EVT,
(tAVDT_CTRL *) &p_data->msg.config_cmd);
@@ -2054,7 +2054,14 @@
{
UNUSED(p_data);
- p_scb->in_use = FALSE;
+ if ((p_scb->cs.tsep == AVDT_TSEP_SNK) && (!p_scb->sink_activated))
+ {
+ p_scb->in_use = TRUE;
+ }
+ else
+ {
+ p_scb->in_use = FALSE;
+ }
p_scb->p_ccb = NULL;
p_scb->peer_seid = 0;
}
diff --git a/stack/btm/btm_acl.c b/stack/btm/btm_acl.c
index ee30887..07ad501 100644
--- a/stack/btm/btm_acl.c
+++ b/stack/btm/btm_acl.c
@@ -38,6 +38,7 @@
#include "l2c_int.h"
#include "hcidefs.h"
#include "bd.h"
+#include "bt_utils.h"
static void btm_establish_continue (tACL_CONN *p_acl_cb);
static void btm_read_remote_features (UINT16 handle);
@@ -105,7 +106,7 @@
*******************************************************************************/
void btm_acl_init (void)
{
- BTM_TRACE_DEBUG0 ("btm_acl_init");
+ BTM_TRACE_DEBUG ("btm_acl_init");
#if 0 /* cleared in btm_init; put back in if called from anywhere else! */
memset (&btm_cb.acl_db, 0, sizeof (btm_cb.acl_db));
#if RFCOMM_INCLUDED == TRUE
@@ -151,7 +152,7 @@
#endif
)
{
- BTM_TRACE_DEBUG0 ("btm_bda_to_acl found");
+ BTM_TRACE_DEBUG ("btm_bda_to_acl found");
return(p);
}
}
@@ -174,7 +175,7 @@
{
tACL_CONN *p = &btm_cb.acl_db[0];
UINT8 xx;
- BTM_TRACE_DEBUG0 ("btm_handle_to_acl_index");
+ BTM_TRACE_DEBUG ("btm_handle_to_acl_index");
for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p++)
{
if ((p->in_use) && (p->hci_handle == hci_handle))
@@ -206,7 +207,7 @@
if (p_dev_rec == NULL)
{
- BTM_TRACE_ERROR0("btm_ble_get_acl_remote_addr can not find device with matching address");
+ BTM_TRACE_ERROR("btm_ble_get_acl_remote_addr can not find device with matching address");
return FALSE;
}
@@ -228,13 +229,16 @@
break;
default:
- BTM_TRACE_ERROR1("Unknown active address: %d", p_dev_rec->ble.active_addr_type);
+ BTM_TRACE_ERROR("Unknown active address: %d", p_dev_rec->ble.active_addr_type);
st = FALSE;
break;
}
return st;
#else
+ UNUSED(p_dev_rec);
+ UNUSED(conn_addr);
+ UNUSED(p_addr_type);
return FALSE;
#endif
}
@@ -257,7 +261,7 @@
tACL_CONN *p;
UINT8 xx;
- BTM_TRACE_DEBUG3 ("btm_acl_created hci_handle=%d link_role=%d transport=%d",
+ BTM_TRACE_DEBUG ("btm_acl_created hci_handle=%d link_role=%d transport=%d",
hci_handle,link_role, transport);
/* Ensure we don't have duplicates */
p = btm_bda_to_acl(bda, transport);
@@ -269,7 +273,7 @@
#if BLE_INCLUDED == TRUE
p->transport = transport;
#endif
- BTM_TRACE_DEBUG6 ("Duplicate btm_acl_created: RemBdAddr: %02x%02x%02x%02x%02x%02x",
+ BTM_TRACE_DEBUG ("Duplicate btm_acl_created: RemBdAddr: %02x%02x%02x%02x%02x%02x",
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
BTM_SetLinkPolicy(p->remote_addr, &btm_cb.btm_def_link_policy);
return;
@@ -333,7 +337,7 @@
#if (BLE_INCLUDED == TRUE)
if (p_dev_rec )
{
- BTM_TRACE_DEBUG1 ("device_type=0x%x", p_dev_rec->device_type);
+ BTM_TRACE_DEBUG ("device_type=0x%x", p_dev_rec->device_type);
}
#endif
@@ -406,7 +410,7 @@
void btm_acl_report_role_change (UINT8 hci_status, BD_ADDR bda)
{
tBTM_ROLE_SWITCH_CMPL ref_data;
- BTM_TRACE_DEBUG0 ("btm_acl_report_role_change");
+ BTM_TRACE_DEBUG ("btm_acl_report_role_change");
if (btm_cb.devcb.p_switch_role_cb
&& (bda && (0 == memcmp(btm_cb.devcb.switch_role_ref_data.remote_bd_addr, bda, BD_ADDR_LEN))))
{
@@ -439,7 +443,7 @@
tBTM_SEC_DEV_REC *p_dev_rec=NULL;
#endif
- BTM_TRACE_DEBUG0 ("btm_acl_removed");
+ BTM_TRACE_DEBUG ("btm_acl_removed");
p = btm_bda_to_acl(bda, transport);
if (p != (tACL_CONN *)NULL)
{
@@ -479,7 +483,7 @@
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
- BTM_TRACE_DEBUG4 ("acl hci_handle=%d transport=%d connectable_mode=0x%0x link_role=%d",
+ BTM_TRACE_DEBUG ("acl hci_handle=%d transport=%d connectable_mode=0x%0x link_role=%d",
p->hci_handle,
p->transport,
btm_cb.ble_ctr_cb.inq_var.connectable_mode,
@@ -488,32 +492,32 @@
p_dev_rec = btm_find_dev(bda);
if ( p_dev_rec)
{
- BTM_TRACE_DEBUG1("before update p_dev_rec->sec_flags=0x%x", p_dev_rec->sec_flags);
+ BTM_TRACE_DEBUG("before update p_dev_rec->sec_flags=0x%x", p_dev_rec->sec_flags);
if (p->transport == BT_TRANSPORT_LE)
{
- BTM_TRACE_DEBUG0("LE link down");
+ BTM_TRACE_DEBUG("LE link down");
p_dev_rec->sec_flags &= ~(BTM_SEC_LE_ENCRYPTED | BTM_SEC_ROLE_SWITCHED);
if ( (p_dev_rec->sec_flags & BTM_SEC_LE_LINK_KEY_KNOWN) == 0)
{
- BTM_TRACE_DEBUG0("Not Bonded");
+ BTM_TRACE_DEBUG("Not Bonded");
p_dev_rec->sec_flags &= ~(BTM_SEC_LE_LINK_KEY_AUTHED | BTM_SEC_LE_AUTHENTICATED);
}
else
{
- BTM_TRACE_DEBUG0("Bonded");
+ BTM_TRACE_DEBUG("Bonded");
}
}
else
{
- BTM_TRACE_DEBUG0("Bletooth link down");
+ BTM_TRACE_DEBUG("Bletooth link down");
p_dev_rec->sec_flags &= ~(BTM_SEC_AUTHORIZED | BTM_SEC_AUTHENTICATED
| BTM_SEC_ENCRYPTED | BTM_SEC_ROLE_SWITCHED);
}
- BTM_TRACE_DEBUG1("after update p_dev_rec->sec_flags=0x%x", p_dev_rec->sec_flags);
+ BTM_TRACE_DEBUG("after update p_dev_rec->sec_flags=0x%x", p_dev_rec->sec_flags);
}
else
{
- BTM_TRACE_ERROR0("Device not found");
+ BTM_TRACE_ERROR("Device not found");
}
#endif
@@ -537,12 +541,12 @@
{
tACL_CONN *p = &btm_cb.acl_db[0];
UINT16 xx;
- BTM_TRACE_DEBUG0 ("btm_acl_device_down");
+ BTM_TRACE_DEBUG ("btm_acl_device_down");
for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p++)
{
if (p->in_use)
{
- BTM_TRACE_DEBUG1 ("hci_handle=%d HCI_ERR_HW_FAILURE ",p->hci_handle );
+ BTM_TRACE_DEBUG ("hci_handle=%d HCI_ERR_HW_FAILURE ",p->hci_handle );
l2c_link_hci_disc_comp (p->hci_handle, HCI_ERR_HW_FAILURE);
}
}
@@ -563,47 +567,47 @@
{
tBTM_BL_UPDATE_DATA evt;
UINT8 busy_level;
- BTM_TRACE_DEBUG0 ("btm_acl_update_busy_level");
+ BTM_TRACE_DEBUG ("btm_acl_update_busy_level");
BOOLEAN old_inquiry_state = btm_cb.is_inquiry;
switch (event)
{
case BTM_BLI_ACL_UP_EVT:
- BTM_TRACE_DEBUG0 ("BTM_BLI_ACL_UP_EVT");
+ BTM_TRACE_DEBUG ("BTM_BLI_ACL_UP_EVT");
btm_cb.num_acl++;
break;
case BTM_BLI_ACL_DOWN_EVT:
if (btm_cb.num_acl)
{
btm_cb.num_acl--;
- BTM_TRACE_DEBUG1 ("BTM_BLI_ACL_DOWN_EVT", btm_cb.num_acl);
+ BTM_TRACE_DEBUG ("BTM_BLI_ACL_DOWN_EVT", btm_cb.num_acl);
}
else
{
- BTM_TRACE_ERROR0 ("BTM_BLI_ACL_DOWN_EVT issued, but num_acl already zero !!!");
+ BTM_TRACE_ERROR ("BTM_BLI_ACL_DOWN_EVT issued, but num_acl already zero !!!");
}
break;
case BTM_BLI_PAGE_EVT:
- BTM_TRACE_DEBUG0 ("BTM_BLI_PAGE_EVT");
+ BTM_TRACE_DEBUG ("BTM_BLI_PAGE_EVT");
btm_cb.is_paging = TRUE;
evt.busy_level_flags= BTM_BL_PAGING_STARTED;
break;
case BTM_BLI_PAGE_DONE_EVT:
- BTM_TRACE_DEBUG0 ("BTM_BLI_PAGE_DONE_EVT");
+ BTM_TRACE_DEBUG ("BTM_BLI_PAGE_DONE_EVT");
btm_cb.is_paging = FALSE;
evt.busy_level_flags = BTM_BL_PAGING_COMPLETE;
break;
case BTM_BLI_INQ_EVT:
- BTM_TRACE_DEBUG0 ("BTM_BLI_INQ_EVT");
+ BTM_TRACE_DEBUG ("BTM_BLI_INQ_EVT");
btm_cb.is_inquiry = TRUE;
evt.busy_level_flags = BTM_BL_INQUIRY_STARTED;
break;
case BTM_BLI_INQ_CANCEL_EVT:
- BTM_TRACE_DEBUG0 ("BTM_BLI_INQ_CANCEL_EVT");
+ BTM_TRACE_DEBUG ("BTM_BLI_INQ_CANCEL_EVT");
btm_cb.is_inquiry = FALSE;
evt.busy_level_flags = BTM_BL_INQUIRY_CANCELLED;
break;
case BTM_BLI_INQ_DONE_EVT:
- BTM_TRACE_DEBUG0 ("BTM_BLI_INQ_DONE_EVT");
+ BTM_TRACE_DEBUG ("BTM_BLI_INQ_DONE_EVT");
btm_cb.is_inquiry = FALSE;
evt.busy_level_flags = BTM_BL_INQUIRY_COMPLETE;
break;
@@ -642,7 +646,7 @@
tBTM_STATUS BTM_GetRole (BD_ADDR remote_bd_addr, UINT8 *p_role)
{
tACL_CONN *p;
- BTM_TRACE_DEBUG0 ("BTM_GetRole");
+ BTM_TRACE_DEBUG ("BTM_GetRole");
if ((p = btm_bda_to_acl(remote_bd_addr, BT_TRANSPORT_BR_EDR)) == NULL)
{
*p_role = BTM_ROLE_UNDEFINED;
@@ -687,7 +691,7 @@
#if (BT_USE_TRACES == TRUE)
BD_ADDR_PTR p_bda;
#endif
- BTM_TRACE_API6 ("BTM_SwitchRole BDA: %02x-%02x-%02x-%02x-%02x-%02x",
+ BTM_TRACE_API ("BTM_SwitchRole BDA: %02x-%02x-%02x-%02x-%02x-%02x",
remote_bd_addr[0], remote_bd_addr[1], remote_bd_addr[2],
remote_bd_addr[3], remote_bd_addr[4], remote_bd_addr[5]);
@@ -699,7 +703,7 @@
{
#if (BT_USE_TRACES == TRUE)
p_bda = btm_cb.devcb.switch_role_ref_data.remote_bd_addr;
- BTM_TRACE_DEBUG6 ("Role switch on other device is in progress 0x%02x%02x%02x%02x%02x%02x",
+ BTM_TRACE_DEBUG ("Role switch on other device is in progress 0x%02x%02x%02x%02x%02x%02x",
p_bda[0], p_bda[1], p_bda[2],
p_bda[3], p_bda[4], p_bda[5]);
#endif
@@ -724,7 +728,7 @@
/* Ignore role switch request if the previous request was not completed */
if (p->switch_role_state != BTM_ACL_SWKEY_STATE_IDLE)
{
- BTM_TRACE_DEBUG1 ("BTM_SwitchRole busy: %d",
+ BTM_TRACE_DEBUG ("BTM_SwitchRole busy: %d",
p->switch_role_state);
return(BTM_BUSY);
}
@@ -830,14 +834,14 @@
tBTM_PM_MODE pwr_mode;
tBTM_PM_PWR_MD settings;
#endif
- BTM_TRACE_DEBUG0 ("BTM_ChangeLinkKey");
+ BTM_TRACE_DEBUG ("BTM_ChangeLinkKey");
if ((p = btm_bda_to_acl(remote_bd_addr, BT_TRANSPORT_BR_EDR)) == NULL)
return(BTM_UNKNOWN_ADDR);
/* Ignore change link key request if the previsous request has not completed */
if (p->change_key_state != BTM_ACL_SWKEY_STATE_IDLE)
{
- BTM_TRACE_DEBUG0 ("Link key change request declined since the previous request"
+ BTM_TRACE_DEBUG ("Link key change request declined since the previous request"
" for this device has not completed ");
return(BTM_BUSY);
}
@@ -914,7 +918,7 @@
tBTM_CHANGE_KEY_CMPL *p_data;
tACL_CONN *p;
UINT8 xx;
- BTM_TRACE_DEBUG0 ("btm_acl_link_key_change");
+ BTM_TRACE_DEBUG ("btm_acl_link_key_change");
/* Look up the connection by handle and set the current mode */
xx = btm_handle_to_acl_index(handle);
@@ -961,7 +965,7 @@
btm_cb.devcb.p_chg_link_key_cb = NULL;
}
- BTM_TRACE_ERROR2("Change Link Key Complete Event: Handle 0x%02x, HCI Status 0x%02x",
+ BTM_TRACE_ERROR("Change Link Key Complete Event: Handle 0x%02x, HCI Status 0x%02x",
handle, p_data->hci_status);
}
@@ -986,7 +990,7 @@
tBTM_BL_ROLE_CHG_DATA evt;
#endif
- BTM_TRACE_DEBUG3 ("btm_acl_encrypt_change handle=%d status=%d encr_enabl=%d",
+ BTM_TRACE_DEBUG ("btm_acl_encrypt_change handle=%d status=%d encr_enabl=%d",
handle, status, encr_enable);
xx = btm_handle_to_acl_index(handle);
/* don't assume that we can never get a bad hci_handle */
@@ -1042,7 +1046,7 @@
evt.hci_status = btm_cb.devcb.switch_role_ref_data.hci_status;
(*btm_cb.p_bl_changed_cb)((tBTM_BL_EVENT_DATA *)&evt);
- BTM_TRACE_DEBUG3("Role Switch Event: new_role 0x%02x, HCI Status 0x%02x, rs_st:%d",
+ BTM_TRACE_DEBUG("Role Switch Event: new_role 0x%02x, HCI Status 0x%02x, rs_st:%d",
evt.new_role, evt.hci_status, p->switch_role_state);
}
#endif
@@ -1053,10 +1057,10 @@
{
if (p_dev_rec->rs_disc_pending == BTM_SEC_DISC_PENDING)
{
- BTM_TRACE_WARNING0("btm_acl_encrypt_change -> Issuing delayed HCI_Disconnect!!!");
+ BTM_TRACE_WARNING("btm_acl_encrypt_change -> Issuing delayed HCI_Disconnect!!!");
btsnd_hcic_disconnect(p_dev_rec->hci_handle, HCI_ERR_PEER_USER);
}
- BTM_TRACE_ERROR2("btm_acl_encrypt_change: tBTM_SEC_DEV:0x%x rs_disc_pending=%d",
+ BTM_TRACE_ERROR("btm_acl_encrypt_change: tBTM_SEC_DEV:0x%x rs_disc_pending=%d",
(UINT32)p_dev_rec, p_dev_rec->rs_disc_pending);
p_dev_rec->rs_disc_pending = BTM_SEC_RS_NOT_PENDING; /* reset flag */
}
@@ -1115,8 +1119,8 @@
{
tACL_CONN *p;
UINT8 *localFeatures = BTM_ReadLocalFeatures();
- BTM_TRACE_DEBUG0 ("BTM_SetLinkPolicy");
-/* BTM_TRACE_API1 ("BTM_SetLinkPolicy: requested settings: 0x%04x", *settings ); */
+ BTM_TRACE_DEBUG ("BTM_SetLinkPolicy");
+/* BTM_TRACE_API ("BTM_SetLinkPolicy: requested settings: 0x%04x", *settings ); */
/* First, check if hold mode is supported */
if (*settings != HCI_DISABLE_ALL_LM_MODES)
@@ -1124,22 +1128,22 @@
if ( (*settings & HCI_ENABLE_MASTER_SLAVE_SWITCH) && (!HCI_SWITCH_SUPPORTED(localFeatures)) )
{
*settings &= (~HCI_ENABLE_MASTER_SLAVE_SWITCH);
- BTM_TRACE_API1 ("BTM_SetLinkPolicy switch not supported (settings: 0x%04x)", *settings );
+ BTM_TRACE_API ("BTM_SetLinkPolicy switch not supported (settings: 0x%04x)", *settings );
}
if ( (*settings & HCI_ENABLE_HOLD_MODE) && (!HCI_HOLD_MODE_SUPPORTED(localFeatures)) )
{
*settings &= (~HCI_ENABLE_HOLD_MODE);
- BTM_TRACE_API1 ("BTM_SetLinkPolicy hold not supported (settings: 0x%04x)", *settings );
+ BTM_TRACE_API ("BTM_SetLinkPolicy hold not supported (settings: 0x%04x)", *settings );
}
if ( (*settings & HCI_ENABLE_SNIFF_MODE) && (!HCI_SNIFF_MODE_SUPPORTED(localFeatures)) )
{
*settings &= (~HCI_ENABLE_SNIFF_MODE);
- BTM_TRACE_API1 ("BTM_SetLinkPolicy sniff not supported (settings: 0x%04x)", *settings );
+ BTM_TRACE_API ("BTM_SetLinkPolicy sniff not supported (settings: 0x%04x)", *settings );
}
if ( (*settings & HCI_ENABLE_PARK_MODE) && (!HCI_PARK_MODE_SUPPORTED(localFeatures)) )
{
*settings &= (~HCI_ENABLE_PARK_MODE);
- BTM_TRACE_API1 ("BTM_SetLinkPolicy park not supported (settings: 0x%04x)", *settings );
+ BTM_TRACE_API ("BTM_SetLinkPolicy park not supported (settings: 0x%04x)", *settings );
}
}
@@ -1164,29 +1168,29 @@
{
UINT8 *localFeatures = BTM_ReadLocalFeatures();
- BTM_TRACE_DEBUG1("BTM_SetDefaultLinkPolicy setting:0x%04x", settings);
+ BTM_TRACE_DEBUG("BTM_SetDefaultLinkPolicy setting:0x%04x", settings);
if((settings & HCI_ENABLE_MASTER_SLAVE_SWITCH) && (!HCI_SWITCH_SUPPORTED(localFeatures)))
{
settings &= ~HCI_ENABLE_MASTER_SLAVE_SWITCH;
- BTM_TRACE_DEBUG1("BTM_SetDefaultLinkPolicy switch not supported (settings: 0x%04x)", settings);
+ BTM_TRACE_DEBUG("BTM_SetDefaultLinkPolicy switch not supported (settings: 0x%04x)", settings);
}
if ((settings & HCI_ENABLE_HOLD_MODE) && (!HCI_HOLD_MODE_SUPPORTED(localFeatures)))
{
settings &= ~HCI_ENABLE_HOLD_MODE;
- BTM_TRACE_DEBUG1("BTM_SetDefaultLinkPolicy hold not supported (settings: 0x%04x)", settings);
+ BTM_TRACE_DEBUG("BTM_SetDefaultLinkPolicy hold not supported (settings: 0x%04x)", settings);
}
if ((settings & HCI_ENABLE_SNIFF_MODE) && (!HCI_SNIFF_MODE_SUPPORTED(localFeatures)))
{
settings &= ~HCI_ENABLE_SNIFF_MODE;
- BTM_TRACE_DEBUG1("BTM_SetDefaultLinkPolicy sniff not supported (settings: 0x%04x)", settings);
+ BTM_TRACE_DEBUG("BTM_SetDefaultLinkPolicy sniff not supported (settings: 0x%04x)", settings);
}
if ((settings & HCI_ENABLE_PARK_MODE) && (!HCI_PARK_MODE_SUPPORTED(localFeatures)))
{
settings &= ~HCI_ENABLE_PARK_MODE;
- BTM_TRACE_DEBUG1("BTM_SetDefaultLinkPolicy park not supported (settings: 0x%04x)", settings);
+ BTM_TRACE_DEBUG("BTM_SetDefaultLinkPolicy park not supported (settings: 0x%04x)", settings);
}
- BTM_TRACE_DEBUG1("Set DefaultLinkPolicy:0x%04x", settings);
+ BTM_TRACE_DEBUG("Set DefaultLinkPolicy:0x%04x", settings);
btm_cb.btm_def_link_policy = settings;
@@ -1210,7 +1214,7 @@
{
tACL_CONN *p;
- BTM_TRACE_API6 ("BTM_ReadLinkPolicy: RemBdAddr: %02x%02x%02x%02x%02x%02x",
+ BTM_TRACE_API ("BTM_ReadLinkPolicy: RemBdAddr: %02x%02x%02x%02x%02x%02x",
remote_bda[0], remote_bda[1], remote_bda[2],
remote_bda[3], remote_bda[4], remote_bda[5]);
@@ -1256,7 +1260,7 @@
UINT16 handle;
tACL_CONN *p_acl_cb = &btm_cb.acl_db[0];
UINT16 index;
- BTM_TRACE_DEBUG0 ("btm_read_link_policy_complete");
+ BTM_TRACE_DEBUG ("btm_read_link_policy_complete");
btu_stop_timer (&btm_cb.devcb.rlinkp_timer);
/* If there was a callback address for read local version, call it */
@@ -1308,7 +1312,7 @@
UINT8 status;
UINT16 handle;
int xx;
- BTM_TRACE_DEBUG0 ("btm_read_remote_version_complete");
+ BTM_TRACE_DEBUG ("btm_read_remote_version_complete");
STREAM_TO_UINT8 (status, p);
if (status == HCI_SUCCESS)
{
@@ -1345,7 +1349,7 @@
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle);
UINT8 page_idx;
- BTM_TRACE_DEBUG0 ("btm_process_remote_ext_features");
+ BTM_TRACE_DEBUG ("btm_process_remote_ext_features");
/* Make sure we have the record to save remote features information */
if (p_dev_rec == NULL)
@@ -1419,7 +1423,7 @@
p_dev_rec->sm4 = BTM_SM4_KNOWN;
}
- BTM_TRACE_API4 ("ext_features_complt page_num:%d f[0]:x%02x, sm4:%x, pend:%d",
+ BTM_TRACE_API ("ext_features_complt page_num:%d f[0]:x%02x, sm4:%x, pend:%d",
HCI_EXT_FEATURES_PAGE_1, *(p_dev_rec->features[HCI_EXT_FEATURES_PAGE_1]),
p_dev_rec->sm4, req_pend);
@@ -1434,7 +1438,7 @@
break;
default:
- BTM_TRACE_ERROR1("btm_process_remote_ext_features_page page=%d unexpected", page_idx);
+ BTM_TRACE_ERROR("btm_process_remote_ext_features_page page=%d unexpected", page_idx);
break;
}
}
@@ -1455,11 +1459,11 @@
UINT8 acl_idx;
tACL_CONN *p_acl_cb;
- BTM_TRACE_DEBUG1("btm_read_remote_features() handle: %d", handle);
+ BTM_TRACE_DEBUG("btm_read_remote_features() handle: %d", handle);
if ((acl_idx = btm_handle_to_acl_index(handle)) >= MAX_L2CAP_LINKS)
{
- BTM_TRACE_ERROR1("btm_read_remote_features handle=%d invalid", handle);
+ BTM_TRACE_ERROR("btm_read_remote_features handle=%d invalid", handle);
return;
}
@@ -1484,7 +1488,7 @@
*******************************************************************************/
void btm_read_remote_ext_features (UINT16 handle, UINT8 page_number)
{
- BTM_TRACE_DEBUG2("btm_read_remote_ext_features() handle: %d page: %d", handle, page_number);
+ BTM_TRACE_DEBUG("btm_read_remote_ext_features() handle: %d page: %d", handle, page_number);
btsnd_hcic_rmt_ext_features(handle, page_number);
}
@@ -1507,12 +1511,12 @@
UINT16 handle;
UINT8 acl_idx;
- BTM_TRACE_DEBUG0 ("btm_read_remote_features_complete");
+ BTM_TRACE_DEBUG ("btm_read_remote_features_complete");
STREAM_TO_UINT8 (status, p);
if (status != HCI_SUCCESS)
{
- BTM_TRACE_ERROR1 ("btm_read_remote_features_complete failed (status 0x%02x)", status);
+ BTM_TRACE_ERROR ("btm_read_remote_features_complete failed (status 0x%02x)", status);
return;
}
@@ -1520,7 +1524,7 @@
if ((acl_idx = btm_handle_to_acl_index(handle)) >= MAX_L2CAP_LINKS)
{
- BTM_TRACE_ERROR1("btm_read_remote_features_complete handle=%d invalid", handle);
+ BTM_TRACE_ERROR("btm_read_remote_features_complete handle=%d invalid", handle);
return;
}
@@ -1536,7 +1540,7 @@
/* if the remote controller has extended features and local controller supports
** HCI_Read_Remote_Extended_Features command then start reading these feature starting
** with extended features page 1 */
- BTM_TRACE_DEBUG0 ("Start reading remote extended features");
+ BTM_TRACE_DEBUG ("Start reading remote extended features");
btm_read_remote_ext_features(handle, HCI_EXT_FEATURES_PAGE_1);
return;
}
@@ -1566,7 +1570,7 @@
UINT16 handle;
UINT8 acl_idx;
- BTM_TRACE_DEBUG0 ("btm_read_remote_ext_features_complete");
+ BTM_TRACE_DEBUG ("btm_read_remote_ext_features_complete");
STREAM_TO_UINT8 (status, p);
STREAM_TO_UINT16 (handle, p);
@@ -1576,13 +1580,13 @@
/* Validate parameters */
if ((acl_idx = btm_handle_to_acl_index(handle)) >= MAX_L2CAP_LINKS)
{
- BTM_TRACE_ERROR1("btm_read_remote_ext_features_complete handle=%d invalid", handle);
+ BTM_TRACE_ERROR("btm_read_remote_ext_features_complete handle=%d invalid", handle);
return;
}
if (max_page > HCI_EXT_FEATURES_PAGE_MAX)
{
- BTM_TRACE_ERROR1("btm_read_remote_ext_features_complete page=%d unknown", max_page);
+ BTM_TRACE_ERROR("btm_read_remote_ext_features_complete page=%d unknown", max_page);
return;
}
@@ -1596,13 +1600,13 @@
if ((page_num < max_page) && (page_num < HCI_EXT_FEATURES_PAGE_MAX))
{
page_num++;
- BTM_TRACE_DEBUG1("BTM reads next remote extended features page (%d)", page_num);
+ BTM_TRACE_DEBUG("BTM reads next remote extended features page (%d)", page_num);
btm_read_remote_ext_features (handle, page_num);
return;
}
/* Reading of remote feature pages is complete */
- BTM_TRACE_DEBUG1("BTM reached last remote extended features page (%d)", page_num);
+ BTM_TRACE_DEBUG("BTM reached last remote extended features page (%d)", page_num);
/* Process the pages */
btm_process_remote_ext_features (p_acl_cb, (UINT8) (page_num + 1));
@@ -1626,12 +1630,12 @@
tACL_CONN *p_acl_cb;
UINT8 acl_idx;
- BTM_TRACE_WARNING2 ("btm_read_remote_ext_features_failed (status 0x%02x) for handle %d",
+ BTM_TRACE_WARNING ("btm_read_remote_ext_features_failed (status 0x%02x) for handle %d",
status, handle);
if ((acl_idx = btm_handle_to_acl_index(handle)) >= MAX_L2CAP_LINKS)
{
- BTM_TRACE_ERROR1("btm_read_remote_ext_features_failed handle=%d invalid", handle);
+ BTM_TRACE_ERROR("btm_read_remote_ext_features_failed handle=%d invalid", handle);
return;
}
@@ -1659,7 +1663,7 @@
#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
tBTM_BL_EVENT_DATA evt_data;
#endif
- BTM_TRACE_DEBUG0 ("btm_establish_continue");
+ BTM_TRACE_DEBUG ("btm_establish_continue");
#if (!defined(BTM_BYPASS_EXTRA_ACL_SETUP) || BTM_BYPASS_EXTRA_ACL_SETUP == FALSE)
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
if (p_acl_cb->transport == BT_TRANSPORT_BR_EDR)
@@ -1728,7 +1732,7 @@
*******************************************************************************/
void BTM_SetDefaultLinkSuperTout (UINT16 timeout)
{
- BTM_TRACE_DEBUG0 ("BTM_SetDefaultLinkSuperTout");
+ BTM_TRACE_DEBUG ("BTM_SetDefaultLinkSuperTout");
btm_cb.btm_def_link_super_tout = timeout;
}
@@ -1745,7 +1749,7 @@
{
tACL_CONN *p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
- BTM_TRACE_DEBUG0 ("BTM_GetLinkSuperTout");
+ BTM_TRACE_DEBUG ("BTM_GetLinkSuperTout");
if (p != (tACL_CONN *)NULL)
{
*p_timeout = p->link_super_tout;
@@ -1769,7 +1773,7 @@
{
tACL_CONN *p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
- BTM_TRACE_DEBUG0 ("BTM_SetLinkSuperTout");
+ BTM_TRACE_DEBUG ("BTM_SetLinkSuperTout");
if (p != (tACL_CONN *)NULL)
{
p->link_super_tout = timeout;
@@ -1802,7 +1806,7 @@
*******************************************************************************/
void BTM_RegForLstoEvt (tBTM_LSTO_CBACK *p_cback)
{
- BTM_TRACE_DEBUG0 ("BTM_RegForLstoEvt");
+ BTM_TRACE_DEBUG ("BTM_RegForLstoEvt");
btm_cb.p_lsto_cback = p_cback;
}
@@ -1819,7 +1823,7 @@
{
UINT8 xx;
- BTM_TRACE_DEBUG0 ("btm_proc_lsto_evt");
+ BTM_TRACE_DEBUG ("btm_proc_lsto_evt");
if (btm_cb.p_lsto_cback)
{
/* Look up the connection by handle and set the current mode */
@@ -1849,7 +1853,7 @@
{
tACL_CONN *p;
- BTM_TRACE_DEBUG0 ("BTM_SetHoldMode");
+ BTM_TRACE_DEBUG ("BTM_SetHoldMode");
/* First, check if hold mode is supported */
if (!HCI_HOLD_MODE_SUPPORTED(BTM_ReadLocalFeatures()))
return(BTM_MODE_UNSUPPORTED);
@@ -1887,7 +1891,7 @@
UINT16 attempt, UINT16 timeout)
{
tACL_CONN *p;
- BTM_TRACE_DEBUG0 ("BTM_SetSniffMode");
+ BTM_TRACE_DEBUG ("BTM_SetSniffMode");
/* First, check if sniff mode is supported */
if (!HCI_SNIFF_MODE_SUPPORTED(BTM_ReadLocalFeatures()))
return(BTM_MODE_UNSUPPORTED);
@@ -1927,7 +1931,7 @@
tBTM_STATUS BTM_CancelSniffMode (BD_ADDR remote_bda)
{
tACL_CONN *p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
- BTM_TRACE_DEBUG0 ("BTM_CancelSniffMode ");
+ BTM_TRACE_DEBUG ("BTM_CancelSniffMode ");
if (p == (tACL_CONN *)NULL)
return(BTM_UNKNOWN_ADDR);
@@ -1957,7 +1961,7 @@
{
tACL_CONN *p;
- BTM_TRACE_DEBUG0 ("BTM_SetParkMode");
+ BTM_TRACE_DEBUG ("BTM_SetParkMode");
/* First, check if park mode is supported */
if (!HCI_PARK_MODE_SUPPORTED(BTM_ReadLocalFeatures()))
return(BTM_MODE_UNSUPPORTED);
@@ -1999,7 +2003,7 @@
{
tACL_CONN *p;
- BTM_TRACE_DEBUG0 ("BTM_CancelParkMode");
+ BTM_TRACE_DEBUG ("BTM_CancelParkMode");
p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
if (p != (tACL_CONN *)NULL)
{
@@ -2032,7 +2036,7 @@
tBTM_STATUS BTM_SetPacketTypes (BD_ADDR remote_bda, UINT16 pkt_types)
{
tACL_CONN *p;
- BTM_TRACE_DEBUG0 ("BTM_SetPacketTypes");
+ BTM_TRACE_DEBUG ("BTM_SetPacketTypes");
if ((p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR)) != NULL)
return(btm_set_packet_types (p, pkt_types));
@@ -2056,7 +2060,7 @@
{
tACL_CONN *p;
- BTM_TRACE_DEBUG0 ("BTM_ReadPacketTypes");
+ BTM_TRACE_DEBUG ("BTM_ReadPacketTypes");
p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
if (p != (tACL_CONN *)NULL)
{
@@ -2093,7 +2097,7 @@
{
tACL_CONN *p;
- BTM_TRACE_API6 ("BTM_ReadAclMode: RemBdAddr: %02x%02x%02x%02x%02x%02x",
+ BTM_TRACE_API ("BTM_ReadAclMode: RemBdAddr: %02x%02x%02x%02x%02x%02x",
remote_bda[0], remote_bda[1], remote_bda[2],
remote_bda[3], remote_bda[4], remote_bda[5]);
@@ -2125,7 +2129,7 @@
{
tACL_CONN *p;
- BTM_TRACE_API6 ("BTM_ReadClockOffset: RemBdAddr: %02x%02x%02x%02x%02x%02x",
+ BTM_TRACE_API ("BTM_ReadClockOffset: RemBdAddr: %02x%02x%02x%02x%02x%02x",
remote_bda[0], remote_bda[1], remote_bda[2],
remote_bda[3], remote_bda[4], remote_bda[5]);
@@ -2150,7 +2154,7 @@
{
tACL_CONN *p;
- BTM_TRACE_API6 ("BTM_IsAclConnectionUp: RemBdAddr: %02x%02x%02x%02x%02x%02x",
+ BTM_TRACE_API ("BTM_IsAclConnectionUp: RemBdAddr: %02x%02x%02x%02x%02x%02x",
remote_bda[0], remote_bda[1], remote_bda[2],
remote_bda[3], remote_bda[4], remote_bda[5]);
@@ -2181,7 +2185,7 @@
#else
tACL_CONN *p = &btm_cb.acl_db[0];
UINT16 xx, yy;
- BTM_TRACE_DEBUG0 ("BTM_GetNumAclLinks");
+ BTM_TRACE_DEBUG ("BTM_GetNumAclLinks");
for (xx = yy = 0; xx < MAX_L2CAP_LINKS; xx++, p++)
{
if (p->in_use)
@@ -2209,7 +2213,7 @@
#if BLE_INCLUDED == TRUE
tACL_CONN *p = &btm_cb.acl_db[0];
UINT16 xx;
- BTM_TRACE_DEBUG0 ("BTM_GetNumLeLinks");
+ BTM_TRACE_DEBUG ("BTM_GetNumLeLinks");
for (xx = yy = 0; xx < MAX_L2CAP_LINKS; xx++, p++)
{
if ((p->in_use) &&(p->transport == BT_TRANSPORT_LE))
@@ -2233,7 +2237,7 @@
UINT16 btm_get_acl_disc_reason_code (void)
{
UINT8 res = btm_cb.acl_disc_reason;
- BTM_TRACE_DEBUG0 ("btm_get_acl_disc_reason_code");
+ BTM_TRACE_DEBUG ("btm_get_acl_disc_reason_code");
return(res);
}
@@ -2251,7 +2255,7 @@
UINT16 BTM_GetHCIConnHandle (BD_ADDR remote_bda, tBT_TRANSPORT transport)
{
tACL_CONN *p;
- BTM_TRACE_DEBUG0 ("BTM_GetHCIConnHandle");
+ BTM_TRACE_DEBUG ("BTM_GetHCIConnHandle");
p = btm_bda_to_acl(remote_bda, transport);
if (p != (tACL_CONN *)NULL)
{
@@ -2281,10 +2285,10 @@
{
tACL_CONN *p;
UINT8 xx;
- BTM_TRACE_DEBUG0 ("btm_process_mode_change");
+ BTM_TRACE_DEBUG ("btm_process_mode_change");
if (hci_status != HCI_SUCCESS)
{
- BTM_TRACE_WARNING1 ("BTM: HCI Mode Change Error Status: 0x%02x", hci_status);
+ BTM_TRACE_WARNING ("BTM: HCI Mode Change Error Status: 0x%02x", hci_status);
}
/* Look up the connection by handle and set the current mode */
@@ -2320,7 +2324,7 @@
void btm_process_clk_off_comp_evt (UINT16 hci_handle, UINT16 clock_offset)
{
UINT8 xx;
- BTM_TRACE_DEBUG0 ("btm_process_clk_off_comp_evt");
+ BTM_TRACE_DEBUG ("btm_process_clk_off_comp_evt");
/* Look up the connection by handle and set the current mode */
if ((xx = btm_handle_to_acl_index(hci_handle)) < MAX_L2CAP_LINKS)
btm_cb.acl_db[xx].clock_offset = clock_offset;
@@ -2349,7 +2353,7 @@
tBTM_BL_ROLE_CHG_DATA evt;
#endif
- BTM_TRACE_DEBUG0 ("btm_acl_role_changed");
+ BTM_TRACE_DEBUG ("btm_acl_role_changed");
/* Ignore any stray events */
if (p == NULL)
{
@@ -2427,7 +2431,7 @@
(*btm_cb.p_bl_changed_cb)((tBTM_BL_EVENT_DATA *)&evt);
}
- BTM_TRACE_DEBUG3("Role Switch Event: new_role 0x%02x, HCI Status 0x%02x, rs_st:%d",
+ BTM_TRACE_DEBUG("Role Switch Event: new_role 0x%02x, HCI Status 0x%02x, rs_st:%d",
p_data->role, p_data->hci_status, p->switch_role_state);
#endif
@@ -2437,10 +2441,10 @@
{
if (p_dev_rec->rs_disc_pending == BTM_SEC_DISC_PENDING)
{
- BTM_TRACE_WARNING0("btm_acl_role_changed -> Issuing delayed HCI_Disconnect!!!");
+ BTM_TRACE_WARNING("btm_acl_role_changed -> Issuing delayed HCI_Disconnect!!!");
btsnd_hcic_disconnect(p_dev_rec->hci_handle, HCI_ERR_PEER_USER);
}
- BTM_TRACE_ERROR2("tBTM_SEC_DEV:0x%x rs_disc_pending=%d",
+ BTM_TRACE_ERROR("tBTM_SEC_DEV:0x%x rs_disc_pending=%d",
(UINT32)p_dev_rec, p_dev_rec->rs_disc_pending);
p_dev_rec->rs_disc_pending = BTM_SEC_RS_NOT_PENDING; /* reset flag */
}
@@ -2463,7 +2467,7 @@
UINT8 BTM_AllocateSCN(void)
{
UINT8 x;
- BTM_TRACE_DEBUG0 ("BTM_AllocateSCN");
+ BTM_TRACE_DEBUG ("BTM_AllocateSCN");
// stack reserves scn 1 for HFP, HSP we still do the correct way
for (x = 1; x < BTM_MAX_SCN; x++)
@@ -2519,7 +2523,7 @@
*******************************************************************************/
BOOLEAN BTM_FreeSCN(UINT8 scn)
{
- BTM_TRACE_DEBUG0 ("BTM_FreeSCN ");
+ BTM_TRACE_DEBUG ("BTM_FreeSCN ");
if (scn <= BTM_MAX_SCN)
{
btm_cb.btm_scn[scn-1] = FALSE;
@@ -2558,7 +2562,7 @@
{
UINT32 timer_type = p_tle->param;
- BTM_TRACE_DEBUG0 ("btm_acl_timeout");
+ BTM_TRACE_DEBUG ("btm_acl_timeout");
if (timer_type == TT_DEV_RLNKP)
{
tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_rlinkp_cmpl_cb;
@@ -2588,7 +2592,7 @@
tBTM_STATUS btm_set_packet_types (tACL_CONN *p, UINT16 pkt_types)
{
UINT16 temp_pkt_types;
- BTM_TRACE_DEBUG0 ("btm_set_packet_types");
+ BTM_TRACE_DEBUG ("btm_set_packet_types");
/* Save in the ACL control blocks, types that we support */
temp_pkt_types = (pkt_types & BTM_ACL_SUPPORTED_PKTS_MASK &
btm_cb.btm_acl_pkt_types_supported);
@@ -2607,7 +2611,7 @@
/* Exclude packet types not supported by the peer */
btm_acl_chk_peer_pkt_type_support (p, &temp_pkt_types);
- BTM_TRACE_DEBUG1 ("SetPacketType Mask -> 0x%04x", temp_pkt_types);
+ BTM_TRACE_DEBUG ("SetPacketType Mask -> 0x%04x", temp_pkt_types);
if (!btsnd_hcic_change_conn_type (p->hci_handle, temp_pkt_types))
{
@@ -2632,7 +2636,7 @@
tACL_CONN *p = btm_bda_to_acl(addr, BT_TRANSPORT_BR_EDR);
UINT16 pkt_types = 0;
UINT16 pkt_size = 0;
- BTM_TRACE_DEBUG0 ("btm_get_max_packet_size");
+ BTM_TRACE_DEBUG ("btm_get_max_packet_size");
if (p != NULL)
{
pkt_types = p->pkt_types_mask;
@@ -2688,7 +2692,7 @@
UINT16 *manufacturer, UINT16 *lmp_sub_version)
{
tACL_CONN *p = btm_bda_to_acl(addr, BT_TRANSPORT_BR_EDR);
- BTM_TRACE_DEBUG0 ("BTM_ReadRemoteVersion");
+ BTM_TRACE_DEBUG ("BTM_ReadRemoteVersion");
if (p == NULL)
return(BTM_UNKNOWN_ADDR);
@@ -2714,7 +2718,7 @@
UINT8 *BTM_ReadRemoteFeatures (BD_ADDR addr)
{
tACL_CONN *p = btm_bda_to_acl(addr, BT_TRANSPORT_BR_EDR);
- BTM_TRACE_DEBUG0 ("BTM_ReadRemoteFeatures");
+ BTM_TRACE_DEBUG ("BTM_ReadRemoteFeatures");
if (p == NULL)
{
return(NULL);
@@ -2734,7 +2738,7 @@
UINT8 *BTM_ReadRemoteExtendedFeatures (BD_ADDR addr, UINT8 page_number)
{
tACL_CONN *p = btm_bda_to_acl(addr, BT_TRANSPORT_BR_EDR);
- BTM_TRACE_DEBUG0 ("BTM_ReadRemoteExtendedFeatures");
+ BTM_TRACE_DEBUG ("BTM_ReadRemoteExtendedFeatures");
if (p == NULL)
{
return(NULL);
@@ -2742,7 +2746,7 @@
if (page_number > HCI_EXT_FEATURES_PAGE_MAX)
{
- BTM_TRACE_ERROR1("Warning: BTM_ReadRemoteExtendedFeatures page %d unknown", page_number);
+ BTM_TRACE_ERROR("Warning: BTM_ReadRemoteExtendedFeatures page %d unknown", page_number);
return NULL;
}
@@ -2759,7 +2763,7 @@
UINT8 BTM_ReadNumberRemoteFeaturesPages (BD_ADDR addr)
{
tACL_CONN *p = btm_bda_to_acl(addr, BT_TRANSPORT_BR_EDR);
- BTM_TRACE_DEBUG0 ("BTM_ReadNumberRemoteFeaturesPages");
+ BTM_TRACE_DEBUG ("BTM_ReadNumberRemoteFeaturesPages");
if (p == NULL)
{
return(0);
@@ -2778,7 +2782,7 @@
UINT8 *BTM_ReadAllRemoteFeatures (BD_ADDR addr)
{
tACL_CONN *p = btm_bda_to_acl(addr, BT_TRANSPORT_BR_EDR);
- BTM_TRACE_DEBUG0 ("BTM_ReadAllRemoteFeatures");
+ BTM_TRACE_DEBUG ("BTM_ReadAllRemoteFeatures");
if (p == NULL)
{
return(NULL);
@@ -2801,7 +2805,7 @@
tBTM_STATUS BTM_RegBusyLevelNotif (tBTM_BL_CHANGE_CB *p_cb, UINT8 *p_level,
tBTM_BL_EVENT_MASK evt_mask)
{
- BTM_TRACE_DEBUG0 ("BTM_RegBusyLevelNotif");
+ BTM_TRACE_DEBUG ("BTM_RegBusyLevelNotif");
if (p_level)
*p_level = btm_cb.busy_level;
@@ -2827,7 +2831,7 @@
*******************************************************************************/
tBTM_STATUS BTM_AclRegisterForChanges (tBTM_ACL_DB_CHANGE_CB *p_cb)
{
- BTM_TRACE_DEBUG0 ("BTM_AclRegisterForChanges");
+ BTM_TRACE_DEBUG ("BTM_AclRegisterForChanges");
if (!p_cb)
btm_cb.p_acl_changed_cb = NULL;
else if (btm_cb.p_acl_changed_cb)
@@ -2852,7 +2856,7 @@
{
tACL_CONN *p = &btm_cb.acl_db[0];
- BTM_TRACE_API6 ("BTM_SetQoS: BdAddr: %02x%02x%02x%02x%02x%02x",
+ BTM_TRACE_API ("BTM_SetQoS: BdAddr: %02x%02x%02x%02x%02x%02x",
bd[0], bd[1], bd[2],
bd[3], bd[4], bd[5]);
@@ -2895,7 +2899,7 @@
{
tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_qossu_cmpl_cb;
tBTM_QOS_SETUP_CMPL qossu;
- BTM_TRACE_DEBUG0 ("btm_qos_setup_complete");
+ BTM_TRACE_DEBUG ("btm_qos_setup_complete");
btu_stop_timer (&btm_cb.devcb.qossu_timer);
btm_cb.devcb.p_qossu_cmpl_cb = NULL;
@@ -2914,7 +2918,7 @@
qossu.flow.latency = p_flow->latency;
qossu.flow.delay_variation = p_flow->delay_variation;
}
- BTM_TRACE_DEBUG1 ("BTM: p_flow->delay_variation: 0x%02x",
+ BTM_TRACE_DEBUG ("BTM: p_flow->delay_variation: 0x%02x",
qossu.flow.delay_variation);
(*p_cb)(&qossu);
}
@@ -2936,7 +2940,7 @@
{
tACL_CONN *p;
- BTM_TRACE_API6 ("BTM_ReadRSSI: RemBdAddr: %02x%02x%02x%02x%02x%02x",
+ BTM_TRACE_API ("BTM_ReadRSSI: RemBdAddr: %02x%02x%02x%02x%02x%02x",
remote_bda[0], remote_bda[1], remote_bda[2],
remote_bda[3], remote_bda[4], remote_bda[5]);
@@ -2981,7 +2985,7 @@
{
tACL_CONN *p;
- BTM_TRACE_API6 ("BTM_ReadLinkQuality: RemBdAddr: %02x%02x%02x%02x%02x%02x",
+ BTM_TRACE_API ("BTM_ReadLinkQuality: RemBdAddr: %02x%02x%02x%02x%02x%02x",
remote_bda[0], remote_bda[1], remote_bda[2],
remote_bda[3], remote_bda[4], remote_bda[5]);
@@ -3029,7 +3033,7 @@
#define BTM_READ_RSSI_TYPE_CUR 0x00
#define BTM_READ_RSSI_TYPE_MAX 0X01
- BTM_TRACE_API6 ("BTM_ReadTxPower: RemBdAddr: %02x%02x%02x%02x%02x%02x",
+ BTM_TRACE_API ("BTM_ReadTxPower: RemBdAddr: %02x%02x%02x%02x%02x%02x",
remote_bda[0], remote_bda[1], remote_bda[2],
remote_bda[3], remote_bda[4], remote_bda[5]);
@@ -3086,7 +3090,7 @@
UINT16 handle;
tACL_CONN *p_acl_cb = &btm_cb.acl_db[0];
UINT16 index;
- BTM_TRACE_DEBUG0 ("btm_read_tx_power_complete");
+ BTM_TRACE_DEBUG ("btm_read_tx_power_complete");
btu_stop_timer (&btm_cb.devcb.tx_power_timer);
/* If there was a callback registered for read rssi, call it */
@@ -3122,7 +3126,7 @@
memcpy(results.rem_bda, btm_cb.devcb.read_tx_pwr_addr, BD_ADDR_LEN);
}
#endif
- BTM_TRACE_DEBUG2 ("BTM TX power Complete: tx_power %d, hci status 0x%02x",
+ BTM_TRACE_DEBUG ("BTM TX power Complete: tx_power %d, hci status 0x%02x",
results.tx_power, results.hci_status);
}
else
@@ -3149,7 +3153,7 @@
UINT16 handle;
tACL_CONN *p_acl_cb = &btm_cb.acl_db[0];
UINT16 index;
- BTM_TRACE_DEBUG0 ("btm_read_rssi_complete");
+ BTM_TRACE_DEBUG ("btm_read_rssi_complete");
btu_stop_timer (&btm_cb.devcb.rssi_timer);
/* If there was a callback registered for read rssi, call it */
@@ -3166,7 +3170,7 @@
STREAM_TO_UINT16 (handle, p);
STREAM_TO_UINT8 (results.rssi, p);
- BTM_TRACE_DEBUG2 ("BTM RSSI Complete: rssi %d, hci status 0x%02x",
+ BTM_TRACE_DEBUG ("BTM RSSI Complete: rssi %d, hci status 0x%02x",
results.rssi, results.hci_status);
/* Search through the list of active channels for the correct BD Addr */
@@ -3203,7 +3207,7 @@
UINT16 handle;
tACL_CONN *p_acl_cb = &btm_cb.acl_db[0];
UINT16 index;
- BTM_TRACE_DEBUG0 ("btm_read_link_quality_complete");
+ BTM_TRACE_DEBUG ("btm_read_link_quality_complete");
btu_stop_timer (&btm_cb.devcb.lnk_quality_timer);
/* If there was a callback registered for read rssi, call it */
@@ -3220,7 +3224,7 @@
STREAM_TO_UINT16 (handle, p);
STREAM_TO_UINT8 (results.link_quality, p);
- BTM_TRACE_DEBUG2 ("BTM Link Quality Complete: Link Quality %d, hci status 0x%02x",
+ BTM_TRACE_DEBUG ("BTM Link Quality Complete: Link Quality %d, hci status 0x%02x",
results.link_quality, results.hci_status);
/* Search through the list of active channels for the correct BD Addr */
@@ -3254,7 +3258,7 @@
UINT16 hci_handle = BTM_GetHCIConnHandle(bd_addr, transport);
tBTM_STATUS status = BTM_SUCCESS;
- BTM_TRACE_DEBUG0 ("btm_remove_acl");
+ BTM_TRACE_DEBUG ("btm_remove_acl");
#if BTM_DISC_DURING_RS == TRUE
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr);
@@ -3291,7 +3295,7 @@
*******************************************************************************/
UINT8 BTM_SetTraceLevel (UINT8 new_level)
{
- BTM_TRACE_DEBUG0 ("BTM_SetTraceLevel");
+ BTM_TRACE_DEBUG ("BTM_SetTraceLevel");
if (new_level != 0xFF)
btm_cb.trace_level = new_level;
@@ -3314,7 +3318,7 @@
{
BOOLEAN sw_ok = TRUE;
BOOLEAN chlk_ok = TRUE;
- BTM_TRACE_DEBUG0 ("btm_cont_rswitch_or_chglinkkey ");
+ BTM_TRACE_DEBUG ("btm_cont_rswitch_or_chglinkkey ");
/* Check to see if encryption needs to be turned off if pending
change of link key or role switch */
if (p->switch_role_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE ||
@@ -3396,7 +3400,7 @@
BT_HDR *p_buf;
UINT8 *pp;
BD_ADDR bda;
- BTM_TRACE_DEBUG0 ("btm_acl_resubmit_page");
+ BTM_TRACE_DEBUG ("btm_acl_resubmit_page");
/* If there were other page request schedule can start the next one */
if ((p_buf = (BT_HDR *)GKI_dequeue (&btm_cb.page_queue)) != NULL)
{
@@ -3427,7 +3431,7 @@
void btm_acl_reset_paging (void)
{
BT_HDR *p;
- BTM_TRACE_DEBUG0 ("btm_acl_reset_paging");
+ BTM_TRACE_DEBUG ("btm_acl_reset_paging");
/* If we sent reset we are definitely not paging any more */
while ((p = (BT_HDR *)GKI_dequeue(&btm_cb.page_queue)) != NULL)
GKI_freebuf (p);
@@ -3444,7 +3448,7 @@
*******************************************************************************/
void btm_acl_set_discing (BOOLEAN discing)
{
- BTM_TRACE_DEBUG0 ("btm_acl_set_discing");
+ BTM_TRACE_DEBUG ("btm_acl_set_discing");
btm_cb.discing = discing;
}
@@ -3459,7 +3463,7 @@
{
tBTM_SEC_DEV_REC *p_dev_rec;
- BTM_TRACE_DEBUG4 ("btm_acl_paging discing:%d, paging:%d BDA: %06x%06x",
+ BTM_TRACE_DEBUG ("btm_acl_paging discing:%d, paging:%d BDA: %06x%06x",
btm_cb.discing, btm_cb.paging,
(bda[0]<<16) + (bda[1]<<8) + bda[2], (bda[3]<<16) + (bda[4] << 8) + bda[5]);
if (btm_cb.discing)
@@ -3471,7 +3475,7 @@
{
if (!BTM_ACL_IS_CONNECTED (bda))
{
- BTM_TRACE_DEBUG2 ("connecting_bda: %06x%06x",
+ BTM_TRACE_DEBUG ("connecting_bda: %06x%06x",
(btm_cb.connecting_bda[0]<<16) + (btm_cb.connecting_bda[1]<<8) +
btm_cb.connecting_bda[2],
(btm_cb.connecting_bda[3]<<16) + (btm_cb.connecting_bda[4] << 8) +
@@ -3520,7 +3524,7 @@
/* Report possible collision to the upper layer. */
if (btm_cb.p_bl_changed_cb)
{
- BTM_TRACE_DEBUG6 ("btm_acl_notif_conn_collision: RemBdAddr: %02x%02x%02x%02x%02x%02x",
+ BTM_TRACE_DEBUG ("btm_acl_notif_conn_collision: RemBdAddr: %02x%02x%02x%02x%02x%02x",
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
evt_data.event = BTM_BL_COLLISION_EVT;
diff --git a/stack/btm/btm_ble.c b/stack/btm/btm_ble.c
index 9bd771a..86d1260 100644
--- a/stack/btm/btm_ble.c
+++ b/stack/btm/btm_ble.c
@@ -38,6 +38,10 @@
#include "gap_api.h"
#include "bt_utils.h"
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
+#include "vendor_ble.h"
+#endif
+
#if SMP_INCLUDED == TRUE
extern BOOLEAN AES_CMAC ( BT_OCTET16 key, UINT8 *input, UINT16 length, UINT16 tlen, UINT8 *p_signature);
extern void smp_link_encrypted(BD_ADDR bda, UINT8 encr_enable);
@@ -71,12 +75,12 @@
UINT8 i = 0;
tBTM_INQ_INFO *p_info=NULL;
- BTM_TRACE_DEBUG1 ("BTM_SecAddBleDevice dev_type=0x%x", dev_type);
+ BTM_TRACE_DEBUG ("BTM_SecAddBleDevice dev_type=0x%x", dev_type);
p_dev_rec = btm_find_dev (bd_addr);
if (!p_dev_rec)
{
- BTM_TRACE_DEBUG0("Add a new device");
+ BTM_TRACE_DEBUG("Add a new device");
/* There is no device record, allocate one.
* If we can not find an empty spot for this one, let it fail. */
@@ -84,7 +88,7 @@
{
if (!(btm_cb.sec_dev_rec[i].sec_flags & BTM_SEC_IN_USE))
{
- BTM_TRACE_DEBUG1 ("allocate a new dev rec idx=0x%x ", i );
+ BTM_TRACE_DEBUG ("allocate a new dev rec idx=0x%x ", i );
p_dev_rec = &btm_cb.sec_dev_rec[i];
/* Mark this record as in use and initialize */
@@ -100,7 +104,7 @@
p_dev_rec->conn_params.supervision_tout =
p_dev_rec->conn_params.slave_latency = BTM_BLE_CONN_PARAM_UNDEF;
- BTM_TRACE_DEBUG1 ("hci_handl=0x%x ", p_dev_rec->ble_hci_handle );
+ BTM_TRACE_DEBUG ("hci_handl=0x%x ", p_dev_rec->ble_hci_handle );
break;
}
}
@@ -110,7 +114,7 @@
}
else
{
- BTM_TRACE_DEBUG0("Device already exist");
+ BTM_TRACE_DEBUG("Device already exist");
}
memset(p_dev_rec->sec_bd_name, 0, sizeof(tBTM_BD_NAME));
@@ -123,7 +127,7 @@
}
p_dev_rec->device_type = dev_type;
p_dev_rec->ble.ble_addr_type = addr_type;
- BTM_TRACE_DEBUG3 ("p_dev_rec->device_type =0x%x addr_type=0x%x sec_flags=0x%x",
+ BTM_TRACE_DEBUG ("p_dev_rec->device_type =0x%x addr_type=0x%x sec_flags=0x%x",
dev_type, addr_type, p_dev_rec->sec_flags);
/* sync up with the Inq Data base*/
@@ -132,7 +136,7 @@
{
p_info->results.ble_addr_type = p_dev_rec->ble.ble_addr_type ;
p_info->results.device_type = p_dev_rec->device_type;
- BTM_TRACE_DEBUG2 ("InqDb device_type =0x%x addr_type=0x%x",
+ BTM_TRACE_DEBUG ("InqDb device_type =0x%x addr_type=0x%x",
p_info->results.device_type, p_info->results.ble_addr_type);
}
@@ -158,21 +162,21 @@
{
#if SMP_INCLUDED == TRUE
tBTM_SEC_DEV_REC *p_dev_rec;
- BTM_TRACE_DEBUG0 ("BTM_SecAddBleKey");
+ BTM_TRACE_DEBUG ("BTM_SecAddBleKey");
p_dev_rec = btm_find_dev (bd_addr);
if (!p_dev_rec || !p_le_key ||
(key_type != BTM_LE_KEY_PENC && key_type != BTM_LE_KEY_PID &&
key_type != BTM_LE_KEY_PCSRK && key_type != BTM_LE_KEY_LENC &&
key_type != BTM_LE_KEY_LCSRK))
{
- BTM_TRACE_WARNING3 ("BTM_SecAddBleKey() Wrong Type, or No Device record \
+ BTM_TRACE_WARNING ("BTM_SecAddBleKey() Wrong Type, or No Device record \
for bdaddr: %08x%04x, Type: %d",
(bd_addr[0]<<24)+(bd_addr[1]<<16)+(bd_addr[2]<<8)+bd_addr[3],
(bd_addr[4]<<8)+bd_addr[5], key_type);
return(FALSE);
}
- BTM_TRACE_DEBUG3 ("BTM_SecAddLeKey() BDA: %08x%04x, Type: 0x%02x",
+ BTM_TRACE_DEBUG ("BTM_SecAddLeKey() BDA: %08x%04x, Type: 0x%02x",
(bd_addr[0]<<24)+(bd_addr[1]<<16)+(bd_addr[2]<<8)+bd_addr[3],
(bd_addr[4]<<8)+bd_addr[5], key_type);
@@ -204,7 +208,7 @@
void BTM_BleLoadLocalKeys(UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key)
{
tBTM_DEVCB *p_devcb = &btm_cb.devcb;
- BTM_TRACE_DEBUG0 ("BTM_BleLoadLocalKeys");
+ BTM_TRACE_DEBUG ("BTM_BleLoadLocalKeys");
if (p_key != NULL)
{
switch (key_type)
@@ -218,7 +222,7 @@
break;
default:
- BTM_TRACE_ERROR1("unknow local key type: %d", key_type);
+ BTM_TRACE_ERROR("unknow local key type: %d", key_type);
break;
}
}
@@ -237,7 +241,7 @@
*******************************************************************************/
void BTM_GetDeviceEncRoot (BT_OCTET16 er)
{
- BTM_TRACE_DEBUG0 ("BTM_GetDeviceEncRoot");
+ BTM_TRACE_DEBUG ("BTM_GetDeviceEncRoot");
memcpy (er, btm_cb.devcb.er, BT_OCTET16_LEN);
}
@@ -255,7 +259,7 @@
*******************************************************************************/
void BTM_GetDeviceIDRoot (BT_OCTET16 irk)
{
- BTM_TRACE_DEBUG0 ("BTM_GetDeviceIDRoot ");
+ BTM_TRACE_DEBUG ("BTM_GetDeviceIDRoot ");
memcpy (irk, btm_cb.devcb.id_keys.irk, BT_OCTET16_LEN);
}
@@ -272,7 +276,7 @@
*******************************************************************************/
void BTM_GetDeviceDHK (BT_OCTET16 dhk)
{
- BTM_TRACE_DEBUG0 ("BTM_GetDeviceDHK");
+ BTM_TRACE_DEBUG ("BTM_GetDeviceDHK");
memcpy (dhk, btm_cb.devcb.id_keys.dhk, BT_OCTET16_LEN);
}
@@ -292,13 +296,13 @@
if (p_acl == NULL)
{
- BTM_TRACE_ERROR0("No connection exist!");
+ BTM_TRACE_ERROR("No connection exist!");
return;
}
memcpy(local_conn_addr, p_acl->conn_addr, BD_ADDR_LEN);
* p_addr_type = p_acl->conn_addr_type;
- BTM_TRACE_DEBUG2 ("BTM_ReadConnectionAddr address type: %d addr: 0x%02x",
+ BTM_TRACE_DEBUG ("BTM_ReadConnectionAddr address type: %d addr: 0x%02x",
p_acl->conn_addr_type, p_acl->conn_addr[0]);
}
@@ -318,7 +322,7 @@
UINT8 xx;
tACL_CONN *p;
- BTM_TRACE_API1 ("BTM_IsBleConnection: conn_handle: %d", conn_handle);
+ BTM_TRACE_API ("BTM_IsBleConnection: conn_handle: %d", conn_handle);
xx = btm_handle_to_acl_index (conn_handle);
if (xx >= MAX_L2CAP_LINKS)
@@ -354,7 +358,7 @@
if (p == NULL)
{
- BTM_TRACE_ERROR0("BTM_ReadRemoteConnectionAddr can not find connection"
+ BTM_TRACE_ERROR("BTM_ReadRemoteConnectionAddr can not find connection"
" with matching address");
return FALSE;
}
@@ -390,7 +394,7 @@
{
#if SMP_INCLUDED == TRUE
tSMP_STATUS res_smp = (res == BTM_SUCCESS) ? SMP_SUCCESS : SMP_REPEATED_ATTEMPTS;
- BTM_TRACE_DEBUG0 ("BTM_SecurityGrant");
+ BTM_TRACE_DEBUG ("BTM_SecurityGrant");
SMP_SecurityGrant(bd_addr, res_smp);
#endif
}
@@ -417,12 +421,12 @@
if (p_dev_rec == NULL)
{
- BTM_TRACE_ERROR0("Passkey reply to Unknown device");
+ BTM_TRACE_ERROR("Passkey reply to Unknown device");
return;
}
p_dev_rec->sec_flags |= BTM_SEC_LE_LINK_KEY_AUTHED;
- BTM_TRACE_DEBUG0 ("BTM_BlePasskeyReply");
+ BTM_TRACE_DEBUG ("BTM_BlePasskeyReply");
SMP_PasskeyReply(bd_addr, res_smp, passkey);
#endif
}
@@ -445,11 +449,11 @@
tSMP_STATUS res_smp = (res == BTM_SUCCESS) ? SMP_SUCCESS : SMP_OOB_FAIL;
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr);
- BTM_TRACE_DEBUG0 ("BTM_BleOobDataReply");
+ BTM_TRACE_DEBUG ("BTM_BleOobDataReply");
if (p_dev_rec == NULL)
{
- BTM_TRACE_ERROR0("BTM_BleOobDataReply() to Unknown device");
+ BTM_TRACE_ERROR("BTM_BleOobDataReply() to Unknown device");
return;
}
@@ -500,7 +504,7 @@
}
else
{
- BTM_TRACE_ERROR0("Illegal Connection Scan Parameters");
+ BTM_TRACE_ERROR("Illegal Connection Scan Parameters");
}
#endif
}
@@ -528,7 +532,7 @@
{
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr);
- BTM_TRACE_API4 ("BTM_BleSetPrefConnParams min: %u max: %u latency: %u \
+ BTM_TRACE_API ("BTM_BleSetPrefConnParams min: %u max: %u latency: %u \
tout: %u",
min_conn_int, max_conn_int, slave_latency, supervision_tout);
@@ -560,19 +564,19 @@
if (supervision_tout != BTM_BLE_CONN_PARAM_UNDEF)
p_dev_rec->conn_params.supervision_tout = supervision_tout;
else
- p_dev_rec->conn_params.slave_latency = BTM_BLE_CONN_TIMEOUT_DEF;
+ p_dev_rec->conn_params.supervision_tout = BTM_BLE_CONN_TIMEOUT_DEF;
}
}
else
{
- BTM_TRACE_ERROR0("Unknown Device, setting rejected");
+ BTM_TRACE_ERROR("Unknown Device, setting rejected");
}
}
else
{
- BTM_TRACE_ERROR0("Illegal Connection Parameters");
+ BTM_TRACE_ERROR("Illegal Connection Parameters");
}
}
@@ -605,7 +609,7 @@
*p_addr_type = p_inq_info->results.ble_addr_type;
} else {
/* unknown device, assume BR/EDR */
- BTM_TRACE_DEBUG0 ("btm_find_dev_type - unknown device, BR/EDR assumed");
+ BTM_TRACE_DEBUG ("btm_find_dev_type - unknown device, BR/EDR assumed");
}
}
else /* there is a security device record exisitng */
@@ -621,7 +625,7 @@
}
- BTM_TRACE_DEBUG2 ("btm_find_dev_type - device_type = %d addr_type = %d", *p_dev_type , *p_addr_type);
+ BTM_TRACE_DEBUG ("btm_find_dev_type - device_type = %d addr_type = %d", *p_dev_type , *p_addr_type);
}
/*******************************************************************************
@@ -640,7 +644,7 @@
if (btsnd_hcic_ble_receiver_test(rx_freq) == FALSE)
{
- BTM_TRACE_ERROR1("%s: Unable to Trigger LE receiver test", __FUNCTION__);
+ BTM_TRACE_ERROR("%s: Unable to Trigger LE receiver test", __FUNCTION__);
}
}
@@ -662,7 +666,7 @@
btm_cb.devcb.p_le_test_cmd_cmpl_cb = p_cmd_cmpl_cback;
if (btsnd_hcic_ble_transmitter_test(tx_freq, test_data_len, packet_payload) == FALSE)
{
- BTM_TRACE_ERROR1("%s: Unable to Trigger LE transmitter test", __FUNCTION__);
+ BTM_TRACE_ERROR("%s: Unable to Trigger LE transmitter test", __FUNCTION__);
}
}
@@ -681,7 +685,7 @@
if (btsnd_hcic_ble_test_end() == FALSE)
{
- BTM_TRACE_ERROR1("%s: Unable to End the LE TX/RX test", __FUNCTION__);
+ BTM_TRACE_ERROR("%s: Unable to End the LE TX/RX test", __FUNCTION__);
}
}
@@ -748,7 +752,7 @@
tBTM_RAND_ENC params;
UINT8 *p_dest = params.param_buf;
- BTM_TRACE_DEBUG0 ("btm_ble_rand_enc_complete");
+ BTM_TRACE_DEBUG ("btm_ble_rand_enc_complete");
memset(¶ms, 0, sizeof(tBTM_RAND_ENC));
@@ -789,7 +793,7 @@
{
tBTM_SEC_DEV_REC *p_dev_rec;
- BTM_TRACE_DEBUG1 ("btm_ble_increment_sign_ctr is_local=%d", is_local);
+ BTM_TRACE_DEBUG ("btm_ble_increment_sign_ctr is_local=%d", is_local);
if ((p_dev_rec = btm_find_dev (bd_addr)) != NULL)
{
@@ -797,7 +801,7 @@
p_dev_rec->ble.keys.local_counter++;
else
p_dev_rec->ble.keys.counter++;
- BTM_TRACE_DEBUG3 ("is_local=%d local sign counter=%d peer sign counter=%d",
+ BTM_TRACE_DEBUG ("is_local=%d local sign counter=%d peer sign counter=%d",
is_local,
p_dev_rec->ble.keys.local_counter,
p_dev_rec->ble.keys.counter);
@@ -818,7 +822,7 @@
{
tBTM_SEC_DEV_REC *p_dev_rec;
- BTM_TRACE_DEBUG0 ("btm_ble_get_enc_key_type");
+ BTM_TRACE_DEBUG ("btm_ble_get_enc_key_type");
if ((p_dev_rec = btm_find_dev (bd_addr)) != NULL)
{
@@ -840,13 +844,14 @@
{
tBTM_SEC_DEV_REC *p_dev_rec;
BOOLEAN status = FALSE;
- BTM_TRACE_DEBUG0 ("btm_get_local_div");
+ BTM_TRACE_DEBUG ("btm_get_local_div");
- BTM_TRACE_DEBUG6("bd_addr:%02x-%02x-%02x-%02x-%02x-%02x",
+ BTM_TRACE_DEBUG("bd_addr:%02x-%02x-%02x-%02x-%02x-%02x",
bd_addr[0],bd_addr[1],
bd_addr[2],bd_addr[3],
bd_addr[4],bd_addr[5]);
+ *p_div = 0;
p_dev_rec = btm_find_dev (bd_addr);
if (p_dev_rec && p_dev_rec->ble.keys.div)
@@ -854,7 +859,7 @@
status = TRUE;
*p_div = p_dev_rec->ble.keys.div;
}
- BTM_TRACE_DEBUG2 ("btm_get_local_div status=%d (1-OK) DIV=0x%x", status, *p_div);
+ BTM_TRACE_DEBUG ("btm_get_local_div status=%d (1-OK) DIV=0x%x", status, *p_div);
return status;
}
@@ -878,10 +883,10 @@
tBTM_LE_EVT_DATA cb_data;
UINT8 i;
- BTM_TRACE_DEBUG2 ("btm_sec_save_le_key key_type=0x%x pass_to_application=%d",key_type, pass_to_application);
+ BTM_TRACE_DEBUG ("btm_sec_save_le_key key_type=0x%x pass_to_application=%d",key_type, pass_to_application);
/* Store the updated key in the device database */
- BTM_TRACE_DEBUG6("bd_addr:%02x-%02x-%02x-%02x-%02x-%02x",
+ BTM_TRACE_DEBUG("bd_addr:%02x-%02x-%02x-%02x-%02x-%02x",
bd_addr[0],bd_addr[1],
bd_addr[2],bd_addr[3],
bd_addr[4],bd_addr[5]);
@@ -902,7 +907,7 @@
p_rec->sec_flags |= BTM_SEC_LE_LINK_KEY_AUTHED;
else
p_rec->sec_flags &= ~BTM_SEC_LE_LINK_KEY_AUTHED;
- BTM_TRACE_DEBUG3("BTM_LE_KEY_PENC key_type=0x%x sec_flags=0x%x sec_leve=0x%x",
+ BTM_TRACE_DEBUG("BTM_LE_KEY_PENC key_type=0x%x sec_flags=0x%x sec_leve=0x%x",
p_rec->ble.key_type,
p_rec->sec_flags,
p_rec->ble.keys.sec_level);
@@ -918,7 +923,7 @@
memcpy(p_rec->ble.static_addr, p_keys->pid_key.static_addr, BD_ADDR_LEN);
p_rec->ble.static_addr_type = p_keys->pid_key.addr_type;
p_rec->ble.key_type |= BTM_LE_KEY_PID;
- BTM_TRACE_DEBUG1("BTM_LE_KEY_PID key_type=0x%x save peer IRK", p_rec->ble.key_type);
+ BTM_TRACE_DEBUG("BTM_LE_KEY_PID key_type=0x%x save peer IRK", p_rec->ble.key_type);
break;
case BTM_LE_KEY_PCSRK:
@@ -932,7 +937,7 @@
else
p_rec->sec_flags &= ~BTM_SEC_LE_LINK_KEY_AUTHED;
- BTM_TRACE_DEBUG4("BTM_LE_KEY_PCSRK key_type=0x%x sec_flags=0x%x sec_level=0x%x peer_counter=%d",
+ BTM_TRACE_DEBUG("BTM_LE_KEY_PCSRK key_type=0x%x sec_flags=0x%x sec_level=0x%x peer_counter=%d",
p_rec->ble.key_type,
p_rec->sec_flags,
p_rec->ble.keys.srk_sec_level,
@@ -945,7 +950,7 @@
p_rec->ble.keys.key_size = p_keys->lenc_key.key_size;
p_rec->ble.key_type |= BTM_LE_KEY_LENC;
- BTM_TRACE_DEBUG4("BTM_LE_KEY_LENC key_type=0x%x DIV=0x%x key_size=0x%x sec_level=0x%x",
+ BTM_TRACE_DEBUG("BTM_LE_KEY_LENC key_type=0x%x DIV=0x%x key_size=0x%x sec_level=0x%x",
p_rec->ble.key_type,
p_rec->ble.keys.div,
p_rec->ble.keys.key_size,
@@ -957,7 +962,7 @@
p_rec->ble.keys.local_csrk_sec_level = p_keys->lcsrk_key.sec_level;
p_rec->ble.keys.local_counter = p_keys->lcsrk_key.counter;
p_rec->ble.key_type |= BTM_LE_KEY_LCSRK;
- BTM_TRACE_DEBUG4("BTM_LE_KEY_LCSRK key_type=0x%x DIV=0x%x scrk_sec_level=0x%x local_counter=%d",
+ BTM_TRACE_DEBUG("BTM_LE_KEY_LCSRK key_type=0x%x DIV=0x%x scrk_sec_level=0x%x local_counter=%d",
p_rec->ble.key_type,
p_rec->ble.keys.div,
p_rec->ble.keys.local_csrk_sec_level,
@@ -965,11 +970,11 @@
break;
default:
- BTM_TRACE_WARNING1("btm_sec_save_le_key (Bad key_type 0x%02x)", key_type);
+ BTM_TRACE_WARNING("btm_sec_save_le_key (Bad key_type 0x%02x)", key_type);
return;
}
- BTM_TRACE_DEBUG3 ("BLE key type 0x%02x updated for BDA: %08x%04x (btm_sec_save_le_key)", key_type,
+ BTM_TRACE_DEBUG ("BLE key type 0x%02x updated for BDA: %08x%04x (btm_sec_save_le_key)", key_type,
(bd_addr[0]<<24)+(bd_addr[1]<<16)+(bd_addr[2]<<8)+bd_addr[3],
(bd_addr[4]<<8)+bd_addr[5]);
@@ -984,13 +989,13 @@
return;
}
- BTM_TRACE_WARNING3 ("BLE key type 0x%02x called for Unknown BDA or type: %08x%04x !! (btm_sec_save_le_key)", key_type,
+ BTM_TRACE_WARNING ("BLE key type 0x%02x called for Unknown BDA or type: %08x%04x !! (btm_sec_save_le_key)", key_type,
(bd_addr[0]<<24)+(bd_addr[1]<<16)+(bd_addr[2]<<8)+bd_addr[3],
(bd_addr[4]<<8)+bd_addr[5]);
if (p_rec)
{
- BTM_TRACE_DEBUG1 ("sec_flags=0x%x", p_rec->sec_flags);
+ BTM_TRACE_DEBUG ("sec_flags=0x%x", p_rec->sec_flags);
}
}
@@ -1007,7 +1012,7 @@
{
tBTM_SEC_DEV_REC *p_rec;
- BTM_TRACE_DEBUG1("btm_ble_update_sec_key_size enc_key_size = %d", enc_key_size);
+ BTM_TRACE_DEBUG("btm_ble_update_sec_key_size enc_key_size = %d", enc_key_size);
if ((p_rec = btm_find_dev (bd_addr)) != NULL )
{
@@ -1050,11 +1055,11 @@
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr);
UINT8 req_sec_level = BTM_LE_SEC_NONE, cur_sec_level = BTM_LE_SEC_NONE;
- BTM_TRACE_DEBUG1 ("btm_ble_link_sec_check auth_req =0x%x", auth_req);
+ BTM_TRACE_DEBUG ("btm_ble_link_sec_check auth_req =0x%x", auth_req);
if (p_dev_rec == NULL)
{
- BTM_TRACE_ERROR0 ("btm_ble_link_sec_check received for unknown device");
+ BTM_TRACE_ERROR ("btm_ble_link_sec_check received for unknown device");
return;
}
@@ -1073,7 +1078,7 @@
req_sec_level = BTM_LE_SEC_AUTHENTICATED;
}
- BTM_TRACE_DEBUG1 ("dev_rec sec_flags=0x%x", p_dev_rec->sec_flags);
+ BTM_TRACE_DEBUG ("dev_rec sec_flags=0x%x", p_dev_rec->sec_flags);
/* currently encrpted */
if (p_dev_rec->sec_flags & BTM_SEC_LE_ENCRYPTED)
@@ -1115,7 +1120,7 @@
}
}
- BTM_TRACE_DEBUG3("cur_sec_level=%d req_sec_level=%d sec_req_act=%d",
+ BTM_TRACE_DEBUG("cur_sec_level=%d req_sec_level=%d sec_req_act=%d",
cur_sec_level,
req_sec_level,
*p_sec_req_act);
@@ -1143,11 +1148,11 @@
if (p_rec == NULL)
{
- BTM_TRACE_WARNING1 ("btm_ble_set_encryption (NULL device record!! sec_act=0x%x", sec_act);
+ BTM_TRACE_WARNING ("btm_ble_set_encryption (NULL device record!! sec_act=0x%x", sec_act);
return(BTM_WRONG_MODE);
}
- BTM_TRACE_DEBUG2 ("btm_ble_set_encryption sec_act=0x%x role_master=%d", sec_act, p_rec->role_master);
+ BTM_TRACE_DEBUG ("btm_ble_set_encryption sec_act=0x%x role_master=%d", sec_act, p_rec->role_master);
if (sec_act == BTM_BLE_SEC_ENCRYPT_MITM)
{
@@ -1160,7 +1165,7 @@
if (link_role == BTM_ROLE_MASTER)
{
if(p_rec->sec_state == BTM_SEC_STATE_ENCRYPTING) {
- BTM_TRACE_DEBUG0 ("State is already encrypting::");
+ BTM_TRACE_DEBUG ("State is already encrypting::");
cmd = BTM_CMD_STARTED;
}
else {
@@ -1209,7 +1214,7 @@
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle);
BT_OCTET8 dummy_stk = {0};
- BTM_TRACE_DEBUG0 ("btm_ble_ltk_request");
+ BTM_TRACE_DEBUG ("btm_ble_ltk_request");
p_cb->ediv = ediv;
@@ -1240,17 +1245,17 @@
BT_OCTET8 dummy_rand = {0};
tBTM_STATUS rt = BTM_NO_RESOURCES;
- BTM_TRACE_DEBUG0 ("btm_ble_start_encrypt");
+ BTM_TRACE_DEBUG ("btm_ble_start_encrypt");
if (!p_rec )
{
- BTM_TRACE_ERROR0("Link is not active, can not encrypt!");
+ BTM_TRACE_ERROR("Link is not active, can not encrypt!");
return BTM_WRONG_MODE;
}
if (p_rec->sec_state == BTM_SEC_STATE_ENCRYPTING)
{
- BTM_TRACE_WARNING0("Link Encryption is active, Busy!");
+ BTM_TRACE_WARNING("Link Encryption is active, Busy!");
return BTM_BUSY;
}
@@ -1269,7 +1274,7 @@
}
else
{
- BTM_TRACE_ERROR0("No key available to encrypt the link");
+ BTM_TRACE_ERROR("No key available to encrypt the link");
}
if (rt == BTM_CMD_STARTED)
{
@@ -1296,17 +1301,17 @@
if (!p_dev_rec)
{
- BTM_TRACE_WARNING1 ("btm_ble_link_encrypted (No Device Found!) encr_enable=%d", encr_enable);
+ BTM_TRACE_WARNING ("btm_ble_link_encrypted (No Device Found!) encr_enable=%d", encr_enable);
return;
}
- BTM_TRACE_DEBUG1 ("btm_ble_link_encrypted encr_enable=%d", encr_enable);
+ BTM_TRACE_DEBUG ("btm_ble_link_encrypted encr_enable=%d", encr_enable);
enc_cback = (p_dev_rec->sec_state == BTM_SEC_STATE_ENCRYPTING);
smp_link_encrypted(bd_addr, encr_enable);
- BTM_TRACE_DEBUG1(" p_dev_rec->sec_flags=0x%x", p_dev_rec->sec_flags);
+ BTM_TRACE_DEBUG(" p_dev_rec->sec_flags=0x%x", p_dev_rec->sec_flags);
if (encr_enable && p_dev_rec->enc_key_size == 0)
p_dev_rec->enc_key_size = p_dev_rec->ble.keys.key_size;
@@ -1331,7 +1336,7 @@
static void btm_enc_proc_ltk(tSMP_ENC *p)
{
UINT8 i;
- BTM_TRACE_DEBUG0 ("btm_enc_proc_ltk");
+ BTM_TRACE_DEBUG ("btm_enc_proc_ltk");
if (p && p->param_len == BT_OCTET16_LEN)
{
for (i = 0; i < (BT_OCTET16_LEN - btm_cb.key_size); i ++)
@@ -1352,7 +1357,7 @@
tSMP_ENC output;
tBTM_SEC_DEV_REC *p_dev_rec;
- BTM_TRACE_DEBUG0 ("btm_enc_proc_slave_y");
+ BTM_TRACE_DEBUG ("btm_enc_proc_slave_y");
if (p != NULL)
{
STREAM_TO_UINT16(y, pp);
@@ -1363,14 +1368,14 @@
if ( p_dev_rec &&
p_dev_rec->ble.keys.div == div )
{
- BTM_TRACE_DEBUG0 ("LTK request OK");
+ BTM_TRACE_DEBUG ("LTK request OK");
/* calculating LTK , LTK = E er(div) */
SMP_Encrypt(p_cb->devcb.er, BT_OCTET16_LEN, (UINT8 *)&div, 2, &output);
btm_enc_proc_ltk(&output);
}
else
{
- BTM_TRACE_DEBUG0 ("LTK request failed - send negative reply");
+ BTM_TRACE_DEBUG ("LTK request failed - send negative reply");
btsnd_hcic_ble_ltk_req_neg_reply(p_cb->enc_handle);
if (p_dev_rec)
btm_ble_link_encrypted(p_dev_rec->bd_addr, 0);
@@ -1397,15 +1402,15 @@
if (p_rec == NULL)
{
- BTM_TRACE_ERROR0("btm_ble_ltk_request_reply received for unknown device");
+ BTM_TRACE_ERROR("btm_ble_ltk_request_reply received for unknown device");
return;
}
- BTM_TRACE_DEBUG0 ("btm_ble_ltk_request_reply");
+ BTM_TRACE_DEBUG ("btm_ble_ltk_request_reply");
p_cb->enc_handle = p_rec->ble_hci_handle;
p_cb->key_size = p_rec->ble.keys.key_size;
- BTM_TRACE_ERROR1("key size = %d", p_rec->ble.keys.key_size);
+ BTM_TRACE_ERROR("key size = %d", p_rec->ble.keys.key_size);
if (use_stk)
{
btsnd_hcic_ble_ltk_req_reply(btm_cb.enc_handle, stk);
@@ -1431,7 +1436,7 @@
UINT8 btm_ble_io_capabilities_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p_data)
{
UINT8 callback_rc = BTM_SUCCESS;
- BTM_TRACE_DEBUG0 ("btm_ble_io_capabilities_req");
+ BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req");
if (btm_cb.api.p_le_callback)
{
/* the callback function implementation may change the IO capability... */
@@ -1443,11 +1448,25 @@
if (callback_rc == BTM_SUCCESS)
#endif
{
+#if BTM_BLE_CONFORMANCE_TESTING == TRUE
+ if (btm_cb.devcb.keep_rfu_in_auth_req)
+ {
+ BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req keep_rfu_in_auth_req = %u",
+ btm_cb.devcb.keep_rfu_in_auth_req);
+ p_data->auth_req &= BTM_LE_AUTH_REQ_MASK_KEEP_RFU;
+ btm_cb.devcb.keep_rfu_in_auth_req = FALSE;
+ }
+ else
+ { /* default */
+ p_data->auth_req &= BTM_LE_AUTH_REQ_MASK;
+ }
+#else
p_data->auth_req &= BTM_LE_AUTH_REQ_MASK;
+#endif
- BTM_TRACE_DEBUG2 ("btm_ble_io_capabilities_req 1: p_dev_rec->security_required = %d auth_req:%d",
+ BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 1: p_dev_rec->security_required = %d auth_req:%d",
p_dev_rec->security_required, p_data->auth_req);
- BTM_TRACE_DEBUG2 ("btm_ble_io_capabilities_req 2: i_keys=0x%x r_keys=0x%x (bit 0-LTK 1-IRK 2-CSRK)",
+ BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 2: i_keys=0x%x r_keys=0x%x (bit 0-LTK 1-IRK 2-CSRK)",
p_data->init_keys,
p_data->resp_keys);
@@ -1457,24 +1476,24 @@
if (!(p_data->auth_req & SMP_AUTH_BOND))
{
- BTM_TRACE_DEBUG0("Non bonding: No keys should be exchanged");
+ BTM_TRACE_DEBUG("Non bonding: No keys should be exchanged");
p_data->init_keys = 0;
p_data->resp_keys = 0;
}
- BTM_TRACE_DEBUG1 ("btm_ble_io_capabilities_req 3: auth_req:%d", p_data->auth_req);
- BTM_TRACE_DEBUG2 ("btm_ble_io_capabilities_req 4: i_keys=0x%x r_keys=0x%x",
+ BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 3: auth_req:%d", p_data->auth_req);
+ BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 4: i_keys=0x%x r_keys=0x%x",
p_data->init_keys,
p_data->resp_keys);
- BTM_TRACE_DEBUG2 ("btm_ble_io_capabilities_req 5: p_data->io_cap = %d auth_req:%d",
+ BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 5: p_data->io_cap = %d auth_req:%d",
p_data->io_cap, p_data->auth_req);
/* remove MITM protection requirement if IO cap does not allow it */
if ((p_data->io_cap == BTM_IO_CAP_NONE) && p_data->oob_data == SMP_OOB_NONE)
p_data->auth_req &= ~BTM_LE_AUTH_REQ_MITM;
- BTM_TRACE_DEBUG3 ("btm_ble_io_capabilities_req 6: IO_CAP:%d oob_data:%d auth_req:%d",
+ BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 6: IO_CAP:%d oob_data:%d auth_req:%d",
p_data->io_cap, p_data->oob_data, p_data->auth_req);
}
return callback_rc;
@@ -1511,11 +1530,11 @@
handle = HCID_GET_HANDLE (handle);
- BTM_TRACE_EVENT0 ("btm_ble_resolve_random_addr_master_cmpl");
+ BTM_TRACE_EVENT ("btm_ble_resolve_random_addr_master_cmpl");
if (match_rec)
{
- BTM_TRACE_ERROR0("Random match");
+ BTM_TRACE_ERROR("Random match");
match = TRUE;
match_rec->ble.active_addr_type = BTM_BLE_ADDR_RRA;
memcpy(match_rec->ble.cur_rand_addr, bda, BD_ADDR_LEN);
@@ -1523,7 +1542,7 @@
}
else
{
- BTM_TRACE_ERROR0("Random unmatch");
+ BTM_TRACE_ERROR("Random unmatch");
}
btm_ble_connected(bda, handle, HCI_ENCRYPT_MODE_DISABLED, role, bda_type, match);
@@ -1552,23 +1571,23 @@
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
UNUSED(addr_matched);
- BTM_TRACE_EVENT0 ("btm_ble_connected");
+ BTM_TRACE_EVENT ("btm_ble_connected");
/* Commenting out trace due to obf/compilation problems.
*/
#if (BT_USE_TRACES == TRUE)
if (p_dev_rec)
{
- BTM_TRACE_EVENT4 ("Security Manager: btm_ble_connected : handle:%d enc_mode:%d bda:%x RName:%s",
+ BTM_TRACE_EVENT ("Security Manager: btm_ble_connected : handle:%d enc_mode:%d bda:%x RName:%s",
handle, enc_mode,
(bda[2]<<24)+(bda[3]<<16)+(bda[4]<<8)+bda[5],
p_dev_rec->sec_bd_name);
- BTM_TRACE_DEBUG1 ("btm_ble_connected sec_flags=0x%x",p_dev_rec->sec_flags);
+ BTM_TRACE_DEBUG ("btm_ble_connected sec_flags=0x%x",p_dev_rec->sec_flags);
}
else
{
- BTM_TRACE_EVENT3 ("Security Manager: btm_ble_connected: handle:%d enc_mode:%d bda:%x ",
+ BTM_TRACE_EVENT ("Security Manager: btm_ble_connected: handle:%d enc_mode:%d bda:%x ",
handle, enc_mode,
(bda[2]<<24)+(bda[3]<<16)+(bda[4]<<8)+bda[5]);
}
@@ -1599,6 +1618,10 @@
if (p_dev_rec->ble.ble_addr_type == BLE_ADDR_RANDOM && !addr_matched)
memcpy(p_dev_rec->ble.cur_rand_addr, bda, BD_ADDR_LEN);
+
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
+ btm_ble_vendor_disable_irk_list();
+#endif
#endif
if (role == HCI_ROLE_SLAVE)
@@ -1635,6 +1658,9 @@
if (status == 0)
{
#if (BLE_PRIVACY_SPT == TRUE )
+#if (BLE_VND_INCLUDED == TRUE)
+ match = btm_public_addr_to_random_pseudo (bda, &bda_type);
+#endif
/* possiblly receive connection complete with resolvable random on
slave role while the device has been paired */
if (!match && role == HCI_ROLE_SLAVE && BTM_BLE_IS_RESOLVE_BDA(bda))
@@ -1658,9 +1684,9 @@
{
role = HCI_ROLE_UNKNOWN;
- if (status == HCI_ERR_DIRECTED_ADVERTISING_TIMEOUT)
+ if (status != HCI_ERR_DIRECTED_ADVERTISING_TIMEOUT)
{
- btm_ble_dir_adv_tout();
+ btm_ble_set_conn_st(BLE_CONN_IDLE);
}
/* this is to work around broadcom firmware problem to handle
* unsolicited command complete event for HCI_LE_Create_Connection_Cancel
@@ -1697,7 +1723,7 @@
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr);
UINT8 res = 0;
- BTM_TRACE_DEBUG1 ("btm_proc_smp_cback event = %d", event);
+ BTM_TRACE_DEBUG ("btm_proc_smp_cback event = %d", event);
if (p_dev_rec != NULL)
{
@@ -1721,24 +1747,24 @@
if (btm_cb.api.p_le_callback)
{
/* the callback function implementation may change the IO capability... */
- BTM_TRACE_DEBUG1 ("btm_cb.api.p_le_callback=0x%x", btm_cb.api.p_le_callback );
+ BTM_TRACE_DEBUG ("btm_cb.api.p_le_callback=0x%x", btm_cb.api.p_le_callback );
(*btm_cb.api.p_le_callback) (event, bd_addr, (tBTM_LE_EVT_DATA *)p_data);
}
if (event == SMP_COMPLT_EVT)
{
- BTM_TRACE_DEBUG2 ("evt=SMP_COMPLT_EVT before update sec_level=0x%x sec_flags=0x%x", p_data->cmplt.sec_level , p_dev_rec->sec_flags );
+ BTM_TRACE_DEBUG ("evt=SMP_COMPLT_EVT before update sec_level=0x%x sec_flags=0x%x", p_data->cmplt.sec_level , p_dev_rec->sec_flags );
res = (p_data->cmplt.reason == SMP_SUCCESS) ? BTM_SUCCESS : BTM_ERR_PROCESSING;
- BTM_TRACE_DEBUG3 ("after update result=%d sec_level=0x%x sec_flags=0x%x",
+ BTM_TRACE_DEBUG ("after update result=%d sec_level=0x%x sec_flags=0x%x",
res, p_data->cmplt.sec_level , p_dev_rec->sec_flags );
btm_sec_dev_rec_cback_event(p_dev_rec, res, TRUE);
if (p_data->cmplt.is_pair_cancel && btm_cb.api.p_bond_cancel_cmpl_callback )
{
- BTM_TRACE_DEBUG0 ("Pairing Cancel completed");
+ BTM_TRACE_DEBUG ("Pairing Cancel completed");
(*btm_cb.api.p_bond_cancel_cmpl_callback)(BTM_SUCCESS);
}
#if BTM_BLE_CONFORMANCE_TESTING == TRUE
@@ -1746,12 +1772,12 @@
{
if (!btm_cb.devcb.no_disc_if_pair_fail && p_data->cmplt.reason != SMP_CONN_TOUT)
{
- BTM_TRACE_DEBUG0 ("Pairing failed - Remove ACL");
+ BTM_TRACE_DEBUG ("Pairing failed - Remove ACL");
btm_remove_acl(bd_addr, BT_TRANSPORT_LE);
}
else
{
- BTM_TRACE_DEBUG0 ("Pairing failed - Not Removing ACL");
+ BTM_TRACE_DEBUG ("Pairing failed - Not Removing ACL");
p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
}
}
@@ -1760,11 +1786,11 @@
btm_remove_acl(bd_addr, BT_TRANSPORT_LE);
#endif
- BTM_TRACE_DEBUG3 ("btm_cb pairing_state=%x pairing_flags=%x pin_code_len=%x",
+ BTM_TRACE_DEBUG ("btm_cb pairing_state=%x pairing_flags=%x pin_code_len=%x",
btm_cb.pairing_state,
btm_cb.pairing_flags,
btm_cb.pin_code_len );
- BTM_TRACE_DEBUG6 ("btm_cb.pairing_bda %02x:%02x:%02x:%02x:%02x:%02x",
+ BTM_TRACE_DEBUG ("btm_cb.pairing_bda %02x:%02x:%02x:%02x:%02x:%02x",
btm_cb.pairing_bda[0], btm_cb.pairing_bda[1], btm_cb.pairing_bda[2],
btm_cb.pairing_bda[3], btm_cb.pairing_bda[4], btm_cb.pairing_bda[5]);
@@ -1775,7 +1801,7 @@
break;
default:
- BTM_TRACE_DEBUG1 ("unknown event = %d", event);
+ BTM_TRACE_DEBUG ("unknown event = %d", event);
break;
@@ -1783,7 +1809,7 @@
}
else
{
- BTM_TRACE_ERROR0("btm_proc_smp_cback received for unknown device");
+ BTM_TRACE_ERROR("btm_proc_smp_cback received for unknown device");
}
return 0;
@@ -1823,16 +1849,16 @@
tSMP_ENC output;
BT_OCTET16 local_csrk;
- BTM_TRACE_DEBUG0 ("BTM_BleDataSignature");
+ BTM_TRACE_DEBUG ("BTM_BleDataSignature");
if (p_rec == NULL)
{
- BTM_TRACE_ERROR0("data signing can not be done from unknow device");
+ BTM_TRACE_ERROR("data signing can not be done from unknow device");
}
else
{
if ((p_buf = (UINT8 *)GKI_getbuf((UINT16)(len + 4))) != NULL)
{
- BTM_TRACE_DEBUG0("Start to generate Local CSRK");
+ BTM_TRACE_DEBUG("Start to generate Local CSRK");
pp = p_buf;
/* prepare plain text */
if (p_text)
@@ -1844,7 +1870,7 @@
#if BTM_BLE_CONFORMANCE_TESTING == TRUE
if ( btm_cb.devcb.enable_test_local_sign_cntr)
{
- BTM_TRACE_DEBUG1 ("Use Test local counter value from script counter_val=%d", btm_cb.devcb.test_local_sign_cntr);
+ BTM_TRACE_DEBUG ("Use Test local counter value from script counter_val=%d", btm_cb.devcb.test_local_sign_cntr);
UINT32_TO_STREAM(pp, btm_cb.devcb.test_local_sign_cntr);
}
else
@@ -1857,7 +1883,7 @@
/* compute local csrk */
if (btm_get_local_div(bd_addr, &div))
{
- BTM_TRACE_DEBUG1 ("compute_csrk div=%x", div);
+ BTM_TRACE_DEBUG ("compute_csrk div=%x", div);
BTM_GetDeviceEncRoot(er);
/* CSRK = d1(ER, DIV, 1) */
@@ -1866,11 +1892,11 @@
if (!SMP_Encrypt(er, BT_OCTET16_LEN, temp, 4, &output))
{
- BTM_TRACE_ERROR0("Local CSRK generation failed ");
+ BTM_TRACE_ERROR("Local CSRK generation failed ");
}
else
{
- BTM_TRACE_DEBUG0("local CSRK generation success");
+ BTM_TRACE_DEBUG("local CSRK generation success");
memcpy((void *)local_csrk, output.param_buf, BT_OCTET16_LEN);
@@ -1894,15 +1920,15 @@
#if BTM_BLE_CONFORMANCE_TESTING == TRUE
if ( btm_cb.devcb.enable_test_mac_val)
{
- BTM_TRACE_DEBUG0 ("Use MAC value from script");
+ BTM_TRACE_DEBUG ("Use MAC value from script");
memcpy(p_mac, btm_cb.devcb.test_mac, BTM_CMAC_TLEN_SIZE);
}
#endif
}
- BTM_TRACE_DEBUG1("BTM_BleDataSignature p_mac = %d", p_mac);
- BTM_TRACE_DEBUG4("p_mac[0] = 0x%02x p_mac[1] = 0x%02x p_mac[2] = 0x%02x p_mac[3] = 0x%02x",
+ BTM_TRACE_DEBUG("BTM_BleDataSignature p_mac = %d", p_mac);
+ BTM_TRACE_DEBUG("p_mac[0] = 0x%02x p_mac[1] = 0x%02x p_mac[2] = 0x%02x p_mac[3] = 0x%02x",
*p_mac, *(p_mac + 1), *(p_mac + 2), *(p_mac + 3));
- BTM_TRACE_DEBUG4("p_mac[4] = 0x%02x p_mac[5] = 0x%02x p_mac[6] = 0x%02x p_mac[7] = 0x%02x",
+ BTM_TRACE_DEBUG("p_mac[4] = 0x%02x p_mac[5] = 0x%02x p_mac[6] = 0x%02x p_mac[7] = 0x%02x",
*(p_mac + 4), *(p_mac + 5), *(p_mac + 6), *(p_mac + 7));
GKI_freebuf(p_buf);
@@ -1939,19 +1965,19 @@
if (p_rec == NULL || (p_rec && !(p_rec->ble.key_type & BTM_LE_KEY_PCSRK)))
{
- BTM_TRACE_ERROR0("can not verify signature for unknown device");
+ BTM_TRACE_ERROR("can not verify signature for unknown device");
}
else if (counter < p_rec->ble.keys.counter)
{
- BTM_TRACE_ERROR0("signature received with out dated sign counter");
+ BTM_TRACE_ERROR("signature received with out dated sign counter");
}
else if (p_orig == NULL)
{
- BTM_TRACE_ERROR0("No signature to verify");
+ BTM_TRACE_ERROR("No signature to verify");
}
else
{
- BTM_TRACE_DEBUG2 ("BTM_BleVerifySignature rcv_cnt=%d >= expected_cnt=%d", counter, p_rec->ble.keys.counter);
+ BTM_TRACE_DEBUG ("BTM_BleVerifySignature rcv_cnt=%d >= expected_cnt=%d", counter, p_rec->ble.keys.counter);
if (AES_CMAC(p_rec->ble.keys.csrk, p_orig, len, BTM_CMAC_TLEN_SIZE, p_mac))
{
@@ -1983,24 +2009,24 @@
{
tBTM_BLE_LOCAL_KEYS *p_locak_keys = NULL;
- BTM_TRACE_DEBUG1 ("btm_notify_new_key key_type=%d", key_type);
+ BTM_TRACE_DEBUG ("btm_notify_new_key key_type=%d", key_type);
if (btm_cb.api.p_le_key_callback)
{
switch (key_type)
{
case BTM_BLE_KEY_TYPE_ID:
- BTM_TRACE_DEBUG0 ("BTM_BLE_KEY_TYPE_ID");
+ BTM_TRACE_DEBUG ("BTM_BLE_KEY_TYPE_ID");
p_locak_keys = (tBTM_BLE_LOCAL_KEYS *)&btm_cb.devcb.id_keys;
break;
case BTM_BLE_KEY_TYPE_ER:
- BTM_TRACE_DEBUG0 ("BTM_BLE_KEY_TYPE_ER");
+ BTM_TRACE_DEBUG ("BTM_BLE_KEY_TYPE_ER");
p_locak_keys = (tBTM_BLE_LOCAL_KEYS *)&btm_cb.devcb.er;
break;
default:
- BTM_TRACE_ERROR1("unknown key type: %d", key_type);
+ BTM_TRACE_ERROR("unknown key type: %d", key_type);
break;
}
if (p_locak_keys != NULL)
@@ -2020,7 +2046,7 @@
*******************************************************************************/
static void btm_ble_process_er2(tBTM_RAND_ENC *p)
{
- BTM_TRACE_DEBUG0 ("btm_ble_process_er2");
+ BTM_TRACE_DEBUG ("btm_ble_process_er2");
if (p &&p->opcode == HCI_BLE_RAND)
{
@@ -2029,7 +2055,7 @@
}
else
{
- BTM_TRACE_ERROR0("Generating ER2 exception.");
+ BTM_TRACE_ERROR("Generating ER2 exception.");
memset(&btm_cb.devcb.er, 0, sizeof(BT_OCTET16));
}
}
@@ -2046,7 +2072,7 @@
*******************************************************************************/
static void btm_ble_process_er(tBTM_RAND_ENC *p)
{
- BTM_TRACE_DEBUG0 ("btm_ble_process_er");
+ BTM_TRACE_DEBUG ("btm_ble_process_er");
if (p &&p->opcode == HCI_BLE_RAND)
{
@@ -2055,12 +2081,12 @@
if (!btsnd_hcic_ble_rand((void *)btm_ble_process_er2))
{
memset(&btm_cb.devcb.er, 0, sizeof(BT_OCTET16));
- BTM_TRACE_ERROR0("Generating ER2 failed.");
+ BTM_TRACE_ERROR("Generating ER2 failed.");
}
}
else
{
- BTM_TRACE_ERROR0("Generating ER1 exception.");
+ BTM_TRACE_ERROR("Generating ER1 exception.");
}
}
@@ -2076,7 +2102,7 @@
*******************************************************************************/
static void btm_ble_process_irk(tSMP_ENC *p)
{
- BTM_TRACE_DEBUG0 ("btm_ble_process_irk");
+ BTM_TRACE_DEBUG ("btm_ble_process_irk");
if (p &&p->opcode == HCI_BLE_ENCRYPT)
{
memcpy(btm_cb.devcb.id_keys.irk, p->param_buf, BT_OCTET16_LEN);
@@ -2084,13 +2110,13 @@
}
else
{
- BTM_TRACE_ERROR0("Generating IRK exception.");
+ BTM_TRACE_ERROR("Generating IRK exception.");
}
/* proceed generate ER */
if (!btsnd_hcic_ble_rand((void *)btm_ble_process_er))
{
- BTM_TRACE_ERROR0("Generating ER failed.");
+ BTM_TRACE_ERROR("Generating ER failed.");
}
}
@@ -2111,12 +2137,12 @@
UINT8 btm_ble_irk_pt = 0x01;
tSMP_ENC output;
- BTM_TRACE_DEBUG0 ("btm_ble_process_dhk");
+ BTM_TRACE_DEBUG ("btm_ble_process_dhk");
if (p && p->opcode == HCI_BLE_ENCRYPT)
{
memcpy(btm_cb.devcb.id_keys.dhk, p->param_buf, BT_OCTET16_LEN);
- BTM_TRACE_DEBUG0("BLE DHK generated.");
+ BTM_TRACE_DEBUG("BLE DHK generated.");
/* IRK = D1(IR, 1) */
if (!SMP_Encrypt(btm_cb.devcb.id_keys.ir, BT_OCTET16_LEN, &btm_ble_irk_pt,
@@ -2155,7 +2181,7 @@
UINT8 btm_ble_dhk_pt = 0x03;
tSMP_ENC output;
- BTM_TRACE_DEBUG0 ("btm_ble_process_ir2");
+ BTM_TRACE_DEBUG ("btm_ble_process_ir2");
if (p && p->opcode == HCI_BLE_RAND)
{
@@ -2168,7 +2194,7 @@
1, &output);
btm_ble_process_dhk(&output);
- BTM_TRACE_DEBUG0("BLE IR generated.");
+ BTM_TRACE_DEBUG("BLE IR generated.");
}
else
{
@@ -2190,7 +2216,7 @@
*******************************************************************************/
static void btm_ble_process_ir(tBTM_RAND_ENC *p)
{
- BTM_TRACE_DEBUG0 ("btm_ble_process_ir");
+ BTM_TRACE_DEBUG ("btm_ble_process_ir");
if (p && p->opcode == HCI_BLE_RAND)
{
@@ -2199,7 +2225,7 @@
if (!btsnd_hcic_ble_rand((void *)btm_ble_process_ir2))
{
- BTM_TRACE_ERROR0("Generating IR2 failed.");
+ BTM_TRACE_ERROR("Generating IR2 failed.");
memset(&btm_cb.devcb.id_keys, 0, sizeof(tBTM_BLE_LOCAL_ID_KEYS));
}
}
@@ -2216,12 +2242,12 @@
*******************************************************************************/
void btm_ble_reset_id( void )
{
- BTM_TRACE_DEBUG0 ("btm_ble_reset_id");
+ BTM_TRACE_DEBUG ("btm_ble_reset_id");
/* regenrate Identity Root*/
if (!btsnd_hcic_ble_rand((void *)btm_ble_process_ir))
{
- BTM_TRACE_DEBUG0("Generating IR failed.");
+ BTM_TRACE_DEBUG("Generating IR failed.");
}
}
@@ -2238,7 +2264,7 @@
*******************************************************************************/
void btm_ble_set_no_disc_if_pair_fail(BOOLEAN disable_disc )
{
- BTM_TRACE_DEBUG1 ("btm_ble_set_disc_enable_if_pair_fail disable_disc=%d", disable_disc);
+ BTM_TRACE_DEBUG ("btm_ble_set_disc_enable_if_pair_fail disable_disc=%d", disable_disc);
btm_cb.devcb.no_disc_if_pair_fail = disable_disc;
}
@@ -2253,7 +2279,7 @@
*******************************************************************************/
void btm_ble_set_test_mac_value(BOOLEAN enable, UINT8 *p_test_mac_val )
{
- BTM_TRACE_DEBUG1 ("btm_ble_set_test_mac_value enable=%d", enable);
+ BTM_TRACE_DEBUG ("btm_ble_set_test_mac_value enable=%d", enable);
btm_cb.devcb.enable_test_mac_val = enable;
memcpy(btm_cb.devcb.test_mac, p_test_mac_val, BT_OCTET8_LEN);
}
@@ -2269,7 +2295,7 @@
*******************************************************************************/
void btm_ble_set_test_local_sign_cntr_value(BOOLEAN enable, UINT32 test_local_sign_cntr )
{
- BTM_TRACE_DEBUG2 ("btm_ble_set_test_local_sign_cntr_value enable=%d local_sign_cntr=%d",
+ BTM_TRACE_DEBUG ("btm_ble_set_test_local_sign_cntr_value enable=%d local_sign_cntr=%d",
enable, test_local_sign_cntr);
btm_cb.devcb.enable_test_local_sign_cntr = enable;
btm_cb.devcb.test_local_sign_cntr = test_local_sign_cntr;
@@ -2289,7 +2315,7 @@
tBTM_LE_RANDOM_CB *p_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
BOOLEAN adv_mode = btm_cb.ble_ctr_cb.inq_var.adv_mode ;
- BTM_TRACE_DEBUG0 ("btm_set_random_address");
+ BTM_TRACE_DEBUG ("btm_set_random_address");
if (adv_mode == BTM_BLE_ADV_ENABLE)
btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_DISABLE);
@@ -2302,6 +2328,23 @@
}
+
+/*******************************************************************************
+**
+** Function btm_ble_set_keep_rfu_in_auth_req
+**
+** Description This function indicates if RFU bits have to be kept as is
+** (by default they have to be set to 0 by the sender).
+**
+** Returns void
+**
+*******************************************************************************/
+void btm_ble_set_keep_rfu_in_auth_req(BOOLEAN keep_rfu)
+{
+ BTM_TRACE_DEBUG ("btm_ble_set_keep_rfu_in_auth_req keep_rfus=%d", keep_rfu);
+ btm_cb.devcb.keep_rfu_in_auth_req = keep_rfu;
+}
+
#endif /* BTM_BLE_CONFORMANCE_TESTING */
#endif /* BLE_INCLUDED */
diff --git a/stack/btm/btm_ble_addr.c b/stack/btm/btm_ble_addr.c
index 3c646e9..de22a89 100644
--- a/stack/btm/btm_ble_addr.c
+++ b/stack/btm/btm_ble_addr.c
@@ -33,8 +33,10 @@
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
#include "btm_ble_int.h"
#include "smp_api.h"
-#define BTM_BLE_PRIVATE_ADDR_INT 900 /* 15 minutes minimum for
- random address refreshing */
+
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
+#include "vendor_ble.h"
+#endif
/*******************************************************************************
**
@@ -49,7 +51,7 @@
static void btm_gen_resolve_paddr_cmpl(tSMP_ENC *p)
{
tBTM_LE_RANDOM_CB *p_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
- BTM_TRACE_EVENT0 ("btm_gen_resolve_paddr_cmpl");
+ BTM_TRACE_EVENT ("btm_gen_resolve_paddr_cmpl");
if (p)
{
@@ -64,14 +66,18 @@
/* start a periodical timer to refresh random addr */
btu_stop_timer(&p_cb->raddr_timer_ent);
+#if (BTM_BLE_CONFORMANCE_TESTING == TRUE)
+ btu_start_timer (&p_cb->raddr_timer_ent, BTU_TTYPE_BLE_RANDOM_ADDR,
+ btm_cb.ble_ctr_cb.rpa_tout);
+#else
btu_start_timer (&p_cb->raddr_timer_ent, BTU_TTYPE_BLE_RANDOM_ADDR,
BTM_BLE_PRIVATE_ADDR_INT);
-
+#endif
}
else
{
/* random address set failure */
- BTM_TRACE_DEBUG0("set random address failed");
+ BTM_TRACE_DEBUG("set random address failed");
}
}
/*******************************************************************************
@@ -84,13 +90,13 @@
** Returns void
**
*******************************************************************************/
-static void btm_gen_resolve_paddr_low(tBTM_RAND_ENC *p)
+void btm_gen_resolve_paddr_low(tBTM_RAND_ENC *p)
{
#if (BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
tBTM_LE_RANDOM_CB *p_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
tSMP_ENC output;
- BTM_TRACE_EVENT0 ("btm_gen_resolve_paddr_low");
+ BTM_TRACE_EVENT ("btm_gen_resolve_paddr_low");
if (p)
{
p->param_buf[2] &= (~BLE_RESOLVE_ADDR_MASK);
@@ -121,11 +127,11 @@
** Returns void
**
*******************************************************************************/
-void btm_gen_resolvable_private_addr (void)
+void btm_gen_resolvable_private_addr (void *p_cmd_cplt_cback)
{
- BTM_TRACE_EVENT0 ("btm_gen_resolvable_private_addr");
+ BTM_TRACE_EVENT ("btm_gen_resolvable_private_addr");
/* generate 3B rand as BD LSB, SRK with it, get BD MSB */
- if (!btsnd_hcic_ble_rand((void *)btm_gen_resolve_paddr_low))
+ if (!btsnd_hcic_ble_rand((void *)p_cmd_cplt_cback))
btm_gen_resolve_paddr_cmpl(NULL);
}
/*******************************************************************************
@@ -146,7 +152,7 @@
UINT8 *pp;
BD_ADDR static_random;
- BTM_TRACE_EVENT0 ("btm_gen_non_resolve_paddr_cmpl");
+ BTM_TRACE_EVENT ("btm_gen_non_resolve_paddr_cmpl");
p_cb->p_generate_cback = NULL;
if (p)
@@ -163,7 +169,7 @@
}
else
{
- BTM_TRACE_DEBUG0("btm_gen_non_resolvable_private_addr failed");
+ BTM_TRACE_DEBUG("btm_gen_non_resolvable_private_addr failed");
if (p_cback)
(* p_cback)(NULL, p_data);
}
@@ -182,7 +188,7 @@
{
tBTM_LE_RANDOM_CB *p_mgnt_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
- BTM_TRACE_EVENT0 ("btm_gen_non_resolvable_private_addr");
+ BTM_TRACE_EVENT ("btm_gen_non_resolvable_private_addr");
if (p_mgnt_cb->p_generate_cback != NULL)
return;
@@ -214,7 +220,7 @@
tBTM_LE_RANDOM_CB *p_mgnt_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
tBTM_SEC_DEV_REC *p_dev_rec = NULL;
- BTM_TRACE_EVENT1 ("btm_ble_resolve_address_cmpl p_mgnt_cb->index = %d", p_mgnt_cb->index);
+ BTM_TRACE_EVENT ("btm_ble_resolve_address_cmpl p_mgnt_cb->index = %d", p_mgnt_cb->index);
if (p_mgnt_cb->index < BTM_SEC_MAX_DEVICE_RECORDS)
{
@@ -239,7 +245,7 @@
{
tBTM_LE_RANDOM_CB *p_mgnt_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
UINT8 comp[3];
- BTM_TRACE_EVENT0 ("btm_ble_proc_resolve_x");
+ BTM_TRACE_EVENT ("btm_ble_proc_resolve_x");
/* compare the hash with 3 LSB of bd address */
comp[0] = p_mgnt_cb->random_bda[5];
comp[1] = p_mgnt_cb->random_bda[4];
@@ -250,7 +256,7 @@
if (!memcmp(p->param_buf, &comp[0], 3))
{
/* match is found */
- BTM_TRACE_EVENT0 ("match is found");
+ BTM_TRACE_EVENT ("match is found");
btm_ble_resolve_address_cmpl();
return TRUE;
}
@@ -281,13 +287,13 @@
rand[1] = p_mgnt_cb->random_bda[1];
rand[2] = p_mgnt_cb->random_bda[0];
- BTM_TRACE_EVENT1("btm_ble_match_random_bda rec_index = %d", rec_index);
+ BTM_TRACE_EVENT("btm_ble_match_random_bda rec_index = %d", rec_index);
if (rec_index < BTM_SEC_MAX_DEVICE_RECORDS)
{
p_dev_rec = &btm_cb.sec_dev_rec[rec_index];
- BTM_TRACE_DEBUG2("sec_flags = %02x device_type = %d", p_dev_rec->sec_flags, p_dev_rec->device_type);
+ BTM_TRACE_DEBUG("sec_flags = %02x device_type = %d", p_dev_rec->sec_flags, p_dev_rec->device_type);
if ((p_dev_rec->device_type == BT_DEVICE_TYPE_BLE) &&
(p_dev_rec->ble.key_type & BTM_LE_KEY_PID))
@@ -325,7 +331,7 @@
{
tBTM_LE_RANDOM_CB *p_mgnt_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
- BTM_TRACE_EVENT0 ("btm_ble_resolve_random_addr");
+ BTM_TRACE_EVENT ("btm_ble_resolve_random_addr");
if ( !p_mgnt_cb->busy)
{
p_mgnt_cb->p = p;
@@ -362,7 +368,7 @@
tBLE_ADDR_TYPE btm_ble_map_bda_to_conn_bda(BD_ADDR bd_addr)
{
tBTM_SEC_DEV_REC *p_dev_rec = NULL;
- BTM_TRACE_EVENT0 ("btm_ble_map_bda_to_conn_bda");
+ BTM_TRACE_EVENT ("btm_ble_map_bda_to_conn_bda");
if ((p_dev_rec = btm_find_dev (bd_addr)) != NULL &&
p_dev_rec->device_type == BT_DEVICE_TYPE_BLE)
{
@@ -376,6 +382,148 @@
return BLE_ADDR_PUBLIC;
}
+#if BLE_PRIVACY_SPT == TRUE
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
+/*******************************************************************************
+**
+** Function btm_find_dev_by_public_static_addr
+**
+** Description find the security record whose LE static address is matching
+**
+*******************************************************************************/
+tBTM_SEC_DEV_REC* btm_find_dev_by_public_static_addr(BD_ADDR bd_addr)
+{
+ UINT8 i;
+ tBTM_SEC_DEV_REC *p_dev_rec = &btm_cb.sec_dev_rec[0];
+
+ for (i = 0; i < BTM_SEC_MAX_DEVICE_RECORDS; i ++, p_dev_rec ++)
+ {
+ if (p_dev_rec->ble.ble_addr_type == BLE_ADDR_RANDOM &&
+ BTM_BLE_IS_RESOLVE_BDA(p_dev_rec->bd_addr))
+ {
+ if ( memcmp(p_dev_rec->ble.static_addr, bd_addr, BD_ADDR_LEN) == 0)
+ {
+ p_dev_rec->ble.active_addr_type = BTM_BLE_ADDR_RRA;
+ /* found the match */
+ return p_dev_rec;
+ }
+ }
+ }
+ return NULL;
+}
+
+/*******************************************************************************
+**
+** Function btm_public_addr_to_random_pseudo
+**
+** Description This function map a static BD address to a pseudo random address
+** in security database.
+**
+*******************************************************************************/
+BOOLEAN btm_public_addr_to_random_pseudo(BD_ADDR bd_addr, UINT8 *p_addr_type)
+{
+ tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_public_static_addr(bd_addr);
+
+ BTM_TRACE_EVENT ("btm_public_addr_to_random_pseudo");
+
+ /* evt reported on static address, map static address to random pseudo */
+ if (p_dev_rec != NULL &&
+ /* static address is not static address */
+ memcmp(p_dev_rec->bd_addr, bd_addr, BD_ADDR_LEN) != 0)
+ /* update current random */
+ btm_ble_read_irk_entry(p_dev_rec->ble.static_addr);
+ if (p_dev_rec != NULL)
+ {
+ /* assign the orginal random to be the current report address */
+ memcpy(bd_addr, p_dev_rec->bd_addr, BD_ADDR_LEN);
+ /* always be a resolvable random if a match is found */
+ *p_addr_type = BLE_ADDR_RANDOM;
+
+ BTM_TRACE_ERROR("matched a public/reconnect address and map to random pseudo");
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*******************************************************************************
+**
+** Function btm_random_pseudo_to_public
+**
+** Description This function map a random pseudo address to a public address
+** random_pseudo is input and output parameter
+**
+*******************************************************************************/
+BOOLEAN btm_random_pseudo_to_public(BD_ADDR random_pseudo, UINT8 *p_static_addr_type)
+{
+ tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (random_pseudo);
+
+ if (p_dev_rec != NULL)
+ {
+ if (p_dev_rec->ble.ble_addr_type == BLE_ADDR_RANDOM &&
+ BTM_BLE_IS_RESOLVE_BDA(p_dev_rec->bd_addr) &&
+ (p_dev_rec->ble.key_type & BTM_LE_KEY_PID) != 0)
+ {
+ BTM_TRACE_EVENT ("btm_random_pseudo_to_public found the puclic static address!");
+ * p_static_addr_type = p_dev_rec->ble.static_addr_type;
+ memcpy(random_pseudo, p_dev_rec->ble.static_addr, BD_ADDR_LEN);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+/*******************************************************************************
+**
+** Function btm_ble_refresh_rra
+**
+** Description This function refresh the currently used RRA into security
+** database and set active connection address.
+**
+*******************************************************************************/
+void btm_ble_refresh_rra(BD_ADDR static_bda, BD_ADDR rra)
+{
+ tBTM_SEC_DEV_REC *p_sec_rec = btm_find_dev_by_public_static_addr(static_bda);
+ tACL_CONN *p_acl = btm_bda_to_acl (p_sec_rec->bd_addr, BT_TRANSPORT_LE);
+ UINT8 rra_dummy = FALSE;
+ BD_ADDR dummy_bda = {0};
+
+ BTM_TRACE_ERROR("btm_ble_refresh_rra");
+
+ if (memcmp(dummy_bda, rra, BD_ADDR_LEN) == 0)
+ rra_dummy = TRUE;
+
+ /* connection refresh RRA */
+ if (p_acl != NULL /* && memcmp(p_acl->active_remote_addr, dummy_bda, BD_ADDR_LEN) == 0 */)
+ {
+ /* use static address, rra is empty */
+ if (rra_dummy)
+ {
+ p_acl->active_remote_addr_type = p_sec_rec->ble.static_addr_type;
+ memcpy(p_acl->active_remote_addr, p_sec_rec->ble.static_addr, BD_ADDR_LEN);
+ }
+ else
+ {
+ p_acl->active_remote_addr_type = BLE_ADDR_RANDOM;
+ memcpy(p_acl->active_remote_addr, rra, BD_ADDR_LEN);
+ }
+ }
+ /* update security record here, in adv event or connection complete process */
+ if (p_sec_rec != NULL)
+ {
+ memcpy(p_sec_rec->ble.cur_rand_addr, rra, BD_ADDR_LEN);
+ p_sec_rec->ble.active_addr_type = rra_dummy ? BTM_BLE_ADDR_STATIC: BTM_BLE_ADDR_RRA;
+ }
+ else
+ {
+ BTM_TRACE_ERROR("No matching known device in record");
+ }
+
+}
+#endif /* CS support */
+#endif /* privacy support */
#endif
diff --git a/stack/btm/btm_ble_bgconn.c b/stack/btm/btm_ble_bgconn.c
index 7341cd2..4f1c145 100644
--- a/stack/btm/btm_ble_bgconn.c
+++ b/stack/btm/btm_ble_bgconn.c
@@ -30,6 +30,9 @@
#include "l2c_int.h"
#include "hcimsgs.h"
#include "bt_utils.h"
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
+#include "vendor_ble.h"
+#endif
#ifndef BTM_BLE_SCAN_PARAM_TOUT
#define BTM_BLE_SCAN_PARAM_TOUT 50 /* 50 seconds */
@@ -49,7 +52,7 @@
void btm_update_scanner_filter_policy(tBTM_BLE_SFP scan_policy)
{
tBTM_BLE_INQ_CB *p_inq = &btm_cb.ble_ctr_cb.inq_var;
- BTM_TRACE_EVENT0 ("btm_update_scanner_filter_policy");
+ BTM_TRACE_EVENT ("btm_update_scanner_filter_policy");
p_inq->sfp = scan_policy;
p_inq->scan_type = (p_inq->scan_type == BTM_BLE_SCAN_MODE_NONE) ? BTM_BLE_SCAN_MODE_ACTI: p_inq->scan_type;
@@ -83,6 +86,12 @@
{
if (p_dev_rec->ble.ble_addr_type == BLE_ADDR_PUBLIC || !BTM_BLE_IS_RESOLVE_BDA(bd_addr))
{
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
+#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
+ /* add device into IRK list */
+ btm_ble_vendor_irk_list_load_dev(p_dev_rec);
+#endif
+#endif
started = btsnd_hcic_ble_add_white_list (p_dev_rec->ble.ble_addr_type, bd_addr);
}
if (memcmp(p_dev_rec->ble.static_addr, bd_addr, BD_ADDR_LEN) != 0 &&
@@ -173,7 +182,7 @@
}
else
{
- BTM_TRACE_ERROR0("max pending WL operation reached, discard");
+ BTM_TRACE_ERROR("max pending WL operation reached, discard");
}
return;
}
@@ -193,7 +202,7 @@
if ((to_add && p_cb->num_empty_filter == 0) ||
(!to_add && p_cb->num_empty_filter == p_cb->max_filter_entries))
{
- BTM_TRACE_ERROR1("WL full or empty, unable to update to WL. num_entry available: %d",
+ BTM_TRACE_ERROR("WL full or empty, unable to update to WL. num_entry available: %d",
p_cb->num_empty_filter);
return started;
}
@@ -215,7 +224,7 @@
*******************************************************************************/
void btm_ble_clear_white_list (void)
{
- BTM_TRACE_EVENT0 ("btm_ble_clear_white_list");
+ BTM_TRACE_EVENT ("btm_ble_clear_white_list");
btsnd_hcic_ble_clear_white_list();
}
@@ -231,7 +240,7 @@
UINT8 status;
UNUSED(evt_len);
- BTM_TRACE_EVENT0 ("btm_ble_clear_white_list_complete");
+ BTM_TRACE_EVENT ("btm_ble_clear_white_list_complete");
STREAM_TO_UINT8 (status, p_data);
if (status == HCI_SUCCESS)
@@ -247,7 +256,7 @@
void btm_ble_add_2_white_list_complete(UINT8 status)
{
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
- BTM_TRACE_EVENT0 ("btm_ble_add_2_white_list_complete");
+ BTM_TRACE_EVENT ("btm_ble_add_2_white_list_complete");
if (status == HCI_SUCCESS)
{
@@ -265,7 +274,7 @@
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
UNUSED(evt_len);
- BTM_TRACE_EVENT0 ("btm_ble_remove_from_white_list_complete");
+ BTM_TRACE_EVENT ("btm_ble_remove_from_white_list_complete");
if (*p == HCI_SUCCESS)
{
p_cb->num_empty_filter ++;
@@ -307,11 +316,11 @@
BOOLEAN ret = FALSE;
UNUSED(p_attr_tag);
- BTM_TRACE_EVENT0 ("btm_update_bg_conn_list");
+ BTM_TRACE_EVENT ("btm_update_bg_conn_list");
if ((to_add && (p_cb->bg_dev_num == BTM_BLE_MAX_BG_CONN_DEV_NUM || p_cb->num_empty_filter == 0)))
{
- BTM_TRACE_DEBUG1("num_empty_filter = %d", p_cb->num_empty_filter);
+ BTM_TRACE_DEBUG("num_empty_filter = %d", p_cb->num_empty_filter);
return ret;
}
@@ -333,7 +342,7 @@
}
else if (!p_bg_dev->in_use && to_add)
{
- BTM_TRACE_DEBUG0("add new WL entry in bg_dev_list");
+ BTM_TRACE_DEBUG("add new WL entry in bg_dev_list");
memcpy(p_bg_dev->bd_addr, bd_addr, BD_ADDR_LEN);
p_bg_dev->in_use = TRUE;
@@ -412,11 +421,16 @@
btsnd_hcic_ble_create_conn_cancel();
btm_ble_set_conn_st (BLE_CONN_CANCEL);
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
+#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
+ btm_ble_vendor_disable_irk_list();
+#endif
+#endif
}
else
{
#if 0
- BTM_TRACE_ERROR1("conn_st = %d, not in auto conn state, can not stop.", p_cb->conn_state);
+ BTM_TRACE_ERROR("conn_st = %d, not in auto conn state, can not stop.", p_cb->conn_state);
exec = FALSE;
#endif
}
@@ -442,7 +456,7 @@
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
UINT16 scan_int, scan_win;
- BTM_TRACE_EVENT0 ("btm_ble_start_select_conn");
+ BTM_TRACE_EVENT ("btm_ble_start_select_conn");
scan_int = (p_cb->scan_int == BTM_BLE_CONN_PARAM_UNDEF) ? BTM_BLE_SCAN_FAST_INT : p_cb->scan_int;
scan_win = (p_cb->scan_win == BTM_BLE_CONN_PARAM_UNDEF) ? BTM_BLE_SCAN_FAST_WIN : p_cb->scan_win;
@@ -469,7 +483,7 @@
if (!btm_ble_topology_check(BTM_BLE_STATE_PASSIVE_SCAN))
{
- BTM_TRACE_ERROR0("peripheral device cannot initiate passive scan for a selective connection");
+ BTM_TRACE_ERROR("peripheral device cannot initiate passive scan for a selective connection");
return FALSE;
}
else if (p_cb->bg_dev_num > 0 && btm_ble_count_unconn_dev_in_whitelist() > 0 )
@@ -484,7 +498,7 @@
}
else
{
- BTM_TRACE_ERROR0("scan active, can not start selective connection procedure");
+ BTM_TRACE_ERROR("scan active, can not start selective connection procedure");
return FALSE;
}
}
@@ -493,6 +507,11 @@
p_cb->scan_activity &= ~BTM_LE_SELECT_CONN_ACTIVE;
p_cb->p_select_cback = NULL;
+#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
+ btm_ble_vendor_disable_irk_list();
+#endif
+#endif
/* stop scanning */
if (!BTM_BLE_IS_SCAN_ACTIVE(p_cb->scan_activity))
@@ -516,12 +535,12 @@
*******************************************************************************/
void btm_ble_initiate_select_conn(BD_ADDR bda)
{
- BTM_TRACE_EVENT0 ("btm_ble_initiate_select_conn");
+ BTM_TRACE_EVENT ("btm_ble_initiate_select_conn");
/* use direct connection procedure to initiate connection */
if (!L2CA_ConnectFixedChnl(L2CAP_ATT_CID, bda))
{
- BTM_TRACE_ERROR0("btm_ble_initiate_select_conn failed");
+ BTM_TRACE_ERROR("btm_ble_initiate_select_conn failed");
}
}
/*******************************************************************************
@@ -539,7 +558,7 @@
void btm_ble_suspend_bg_conn(void)
{
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
- BTM_TRACE_EVENT0 ("btm_ble_suspend_bg_conn");
+ BTM_TRACE_EVENT ("btm_ble_suspend_bg_conn");
if (p_cb->bg_conn_type == BTM_BLE_CONN_AUTO)
{
diff --git a/stack/btm/btm_ble_gap.c b/stack/btm/btm_ble_gap.c
index f9bd1aa..0e9133f 100644
--- a/stack/btm/btm_ble_gap.c
+++ b/stack/btm/btm_ble_gap.c
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright (C) 2008-2012 Broadcom Corporation
+ * Copyright (C) 2008-2014 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +35,9 @@
#include "gap_api.h"
#endif
#if (BLE_INCLUDED == TRUE)
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
+#include "vendor_ble.h"
+#endif
#include "gattdefs.h"
#include "btm_ble_int.h"
@@ -46,13 +49,19 @@
#define BTM_BLE_POLICY_UNKNOWN 0xff
#define BTM_EXT_BLE_RMT_NAME_TIMEOUT 30
+#define MIN_ADV_LENGTH 2
+
+extern tBTM_BLE_MULTI_ADV_CB btm_multi_adv_cb;
+static tBTM_BLE_CTRL_FEATURES_CBACK *p_ctrl_le_feature_rd_cmpl_cback = NULL;
+
/*******************************************************************************
** Local functions
*******************************************************************************/
static void btm_ble_update_adv_flag(UINT8 flag);
static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt_type, UINT8 *p);
-static UINT8 *btm_ble_build_adv_data(tBTM_BLE_AD_MASK *p_data_mask, UINT8 **p_dst, tBTM_BLE_ADV_DATA *p_data);
+UINT8 *btm_ble_build_adv_data(tBTM_BLE_AD_MASK *p_data_mask, UINT8 **p_dst,
+ tBTM_BLE_ADV_DATA *p_data);
static UINT8 btm_set_conn_mode_adv_init_addr(tBTM_BLE_INQ_CB *p_cb,
BD_ADDR_PTR p_addr_ptr,
tBLE_ADDR_TYPE *p_init_addr_type,
@@ -241,7 +250,7 @@
BD_ADDR p_addr_ptr= {0};
UINT8 adv_mode = p_cb->adv_mode;
- BTM_TRACE_EVENT0 ("BTM_BleUpdateAdvFilterPolicy");
+ BTM_TRACE_EVENT ("BTM_BleUpdateAdvFilterPolicy");
if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
return;
@@ -292,7 +301,7 @@
tBTM_BLE_INQ_CB *p_inq = &btm_cb.ble_ctr_cb.inq_var;
tBTM_STATUS status = BTM_WRONG_MODE;
- BTM_TRACE_EVENT1 ("BTM_BleObserve : scan_type:%d",btm_cb.btm_inq_vars.scan_type);
+ BTM_TRACE_EVENT ("BTM_BleObserve : scan_type:%d",btm_cb.btm_inq_vars.scan_type);
if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
return BTM_ILLEGAL_VALUE;
@@ -302,7 +311,7 @@
/* shared inquiry database, do not allow observe if any inquiry is active */
if (BTM_BLE_IS_OBS_ACTIVE(btm_cb.ble_ctr_cb.scan_activity))
{
- BTM_TRACE_ERROR0("Observe Already Active");
+ BTM_TRACE_ERROR("Observe Already Active");
return status;
}
@@ -321,6 +330,12 @@
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type,
BTM_BLE_DEFAULT_SFP); /* assume observe always not using white list */
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
+#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
+ /* enable IRK list */
+ btm_ble_vendor_irk_list_known_dev (TRUE);
+#endif
+#endif
status = btm_ble_start_scan(BTM_BLE_DUPLICATE_DISABLE);
}
if (status == BTM_CMD_STARTED)
@@ -339,7 +354,7 @@
}
else
{
- BTM_TRACE_ERROR0("Observe not active");
+ BTM_TRACE_ERROR("Observe not active");
}
return status;
@@ -401,7 +416,7 @@
else
{
status = BTM_WRONG_MODE;
- BTM_TRACE_ERROR2("Can not %s Broadcast, device %s in Broadcast mode",
+ BTM_TRACE_ERROR("Can not %s Broadcast, device %s in Broadcast mode",
(start ? "Start" : "Stop"), (start ? "already" :"not"));
}
return status;
@@ -409,6 +424,101 @@
/*******************************************************************************
**
+** Function btm_vsc_brcm_features_complete
+**
+** Description Command Complete callback for HCI_BLE_VENDOR_CAP_OCF
+**
+** Returns void
+**
+*******************************************************************************/
+static void btm_ble_vendor_capability_vsc_cmpl_cback (tBTM_VSC_CMPL *p_vcs_cplt_params)
+{
+ UINT8 status = 0xFF, *p;
+ UINT8 rpa_offloading, max_irk_list_sz, filtering_support, max_filter;
+ UINT16 scan_result_storage;
+ tBTM_BLE_VENDOR_CB *p_vcb = &btm_ble_vendor_cb;
+ max_irk_list_sz = 0;
+
+ BTM_TRACE_DEBUG("btm_ble_vendor_capability_vsc_cmpl_cback");
+
+ /* Check status of command complete event */
+ if((p_vcs_cplt_params->opcode == HCI_BLE_VENDOR_CAP_OCF)
+ &&(p_vcs_cplt_params->param_len > 0 ))
+ {
+ p = p_vcs_cplt_params->p_param_buf;
+ STREAM_TO_UINT8 (status, p);
+ }
+
+ if(status == HCI_SUCCESS)
+ {
+ STREAM_TO_UINT8 (btm_cb.cmn_ble_vsc_cb.adv_inst_max, p);
+ STREAM_TO_UINT8 (btm_cb.cmn_ble_vsc_cb.rpa_offloading, p);
+ STREAM_TO_UINT16 (btm_cb.cmn_ble_vsc_cb.tot_scan_results_strg, p);
+ STREAM_TO_UINT8 (btm_cb.cmn_ble_vsc_cb.max_irk_list_sz, p);
+ STREAM_TO_UINT8 (btm_cb.cmn_ble_vsc_cb.filter_support, p);
+ STREAM_TO_UINT8 (btm_cb.cmn_ble_vsc_cb.max_filter, p);
+ }
+ p_vcb->irk_avail_size = max_irk_list_sz;
+
+ if (p_ctrl_le_feature_rd_cmpl_cback != NULL)
+ p_ctrl_le_feature_rd_cmpl_cback(status);
+ btm_multi_adv_cb.adv_inst_max = btm_cb.cmn_ble_vsc_cb.adv_inst_max;
+ BTM_TRACE_DEBUG("btm_ble_vendor_capability_vsc_cmpl_cback:%d, status=%d, max_irk_size=%d",
+ btm_multi_adv_cb.adv_inst_max, status,btm_ble_vendor_cb.irk_avail_size);
+}
+
+/*******************************************************************************
+**
+** Function BTM_BleGetVendorCapabilities
+**
+** Description This function reads local LE features
+**
+** Parameters p_cmn_vsc_cb : Locala LE capability structure
+**
+** Returns void
+**
+*******************************************************************************/
+BTM_API extern void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb)
+{
+ BTM_TRACE_DEBUG("btm_ble_vendor_capability_init");
+
+ if(NULL != p_cmn_vsc_cb)
+ {
+ *p_cmn_vsc_cb = btm_cb.cmn_ble_vsc_cb;
+ }
+}
+
+/******************************************************************************
+**
+** Function BTM_BleReadControllerFeatures
+**
+** Description Reads BLE specific controller features
+**
+** Parameters: tBTM_BLE_CTRL_FEATURES_CBACK : Callback to notify when features are read
+**
+** Returns void
+**
+*******************************************************************************/
+BTM_API extern void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback)
+{
+ BTM_TRACE_DEBUG("BTM_BleReadControllerFeatures");
+
+ memset(&btm_ble_vendor_cb, 0, sizeof(tBTM_BLE_VENDOR_CB));
+
+ p_ctrl_le_feature_rd_cmpl_cback = p_vsc_cback;
+ if ( BTM_VendorSpecificCommand (HCI_BLE_VENDOR_CAP_OCF,
+ 0,
+ NULL,
+ btm_ble_vendor_capability_vsc_cmpl_cback)
+ != BTM_CMD_STARTED)
+ {
+ BTM_TRACE_ERROR("LE Get_Vendor Capabilities Command Failed.");
+ }
+ return ;
+}
+
+/*******************************************************************************
+**
** Function BTM_RegisterScanReqEvt
**
** Description This function is called to register a scan request callback
@@ -450,7 +560,7 @@
{
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
- BTM_TRACE_EVENT0 (" BTM_BleConfigPrivacy");
+ BTM_TRACE_EVENT (" BTM_BleConfigPrivacy");
if (p_cb->privacy != enable)
{
@@ -459,16 +569,16 @@
if (p_cb->privacy)
{
/* generate resolvable private address */
- btm_gen_resolvable_private_addr();
+ btm_gen_resolvable_private_addr(NULL);
}
else /* if privacy disabled, always use public address */
{
p_cb->addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
}
+ btm_ble_multi_adv_enb_privacy(p_cb->privacy);
}
}
-
/*******************************************************************************
**
** Function btm_ble_resolve_random_addr_on_adv
@@ -486,7 +596,7 @@
UINT8 *pp = (UINT8 *)p + 1;
UINT8 evt_type;
- BTM_TRACE_EVENT0 ("btm_ble_resolve_random_addr_on_adv ");
+ BTM_TRACE_EVENT ("btm_ble_resolve_random_addr_on_adv ");
STREAM_TO_UINT8 (evt_type, pp);
STREAM_TO_UINT8 (addr_type, pp);
@@ -494,7 +604,7 @@
if (match_rec)
{
- BTM_TRACE_ERROR0("Random match");
+ BTM_TRACE_ERROR("Random match");
match_rec->ble.active_addr_type = BTM_BLE_ADDR_RRA;
memcpy(match_rec->ble.cur_rand_addr, bda, BD_ADDR_LEN);
memcpy(bda, match_rec->bd_addr, BD_ADDR_LEN);
@@ -502,7 +612,7 @@
}
else
{
- BTM_TRACE_ERROR0("Random unmatch");
+ BTM_TRACE_ERROR("Random unmatch");
}
btm_ble_process_adv_pkt_cont(bda, addr_type, evt_type, pp);
@@ -513,6 +623,24 @@
/*******************************************************************************
**
+** Function BTM_BleLocalPrivacyEnabled
+**
+** Description Checks if local device supports private address
+**
+** Returns Return TRUE if local privacy is enabled else FALSE
+**
+*******************************************************************************/
+BOOLEAN BTM_BleLocalPrivacyEnabled()
+{
+#if BLE_PRIVACY_SPT == TRUE
+ return btm_cb.ble_ctr_cb.privacy;
+#else
+ return false;
+#endif
+}
+
+/*******************************************************************************
+**
** Function BTM_BleSetBgConnType
**
** Description This function is called to set BLE connectable mode for a
@@ -530,7 +658,7 @@
{
BOOLEAN started = TRUE;
- BTM_TRACE_EVENT0 ("BTM_BleSetBgConnType ");
+ BTM_TRACE_EVENT ("BTM_BleSetBgConnType ");
if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
return FALSE;
@@ -563,7 +691,7 @@
break;
default:
- BTM_TRACE_ERROR1("invalid bg connection type : %d ", bg_conn_type);
+ BTM_TRACE_ERROR("invalid bg connection type : %d ", bg_conn_type);
started = FALSE;
break;
}
@@ -593,7 +721,7 @@
{
BOOLEAN ret = TRUE;
UINT8 dev_wl_type = 0;
- BTM_TRACE_EVENT0 (" BTM_BleUpdateBgConnDev");
+ BTM_TRACE_EVENT (" BTM_BleUpdateBgConnDev");
/* update white list */
ret = btm_update_bg_conn_list(add_remove, remote_bda, &dev_wl_type);
@@ -620,7 +748,7 @@
{
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
- BTM_TRACE_EVENT1 ("BTM_BleSetConnMode is_directed = %d ", is_directed);
+ BTM_TRACE_EVENT ("BTM_BleSetConnMode is_directed = %d ", is_directed);
if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
return BTM_ILLEGAL_VALUE;
@@ -666,7 +794,7 @@
!BTM_BLE_IS_RESOLVE_BDA(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr))
{
/* need to generate RRA and update random addresss in controller */
- btm_gen_resolvable_private_addr();
+ btm_gen_resolvable_private_addr((void *)btm_gen_resolve_paddr_low);
}
#endif
}
@@ -701,7 +829,7 @@
tBLE_ADDR_TYPE own_addr_type = p_addr_cb->own_addr_type;
UINT8 adv_mode = p_cb->adv_mode;
- BTM_TRACE_EVENT0 ("BTM_BleSetAdvParams");
+ BTM_TRACE_EVENT ("BTM_BleSetAdvParams");
if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
return BTM_ILLEGAL_VALUE;
@@ -721,7 +849,7 @@
memcpy(&p_cb->direct_bda, p_dir_bda, sizeof(tBLE_BD_ADDR));
}
- BTM_TRACE_EVENT0 ("update params for an active adv");
+ BTM_TRACE_EVENT ("update params for an active adv");
btm_ble_stop_adv();
@@ -763,7 +891,7 @@
{
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
- BTM_TRACE_EVENT0 ("BTM_BleReadAdvParams ");
+ BTM_TRACE_EVENT ("BTM_BleReadAdvParams ");
if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
return ;
@@ -796,7 +924,7 @@
{
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
- BTM_TRACE_EVENT0 (" BTM_BleSetScanParams");
+ BTM_TRACE_EVENT (" BTM_BleSetScanParams");
if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
return ;
@@ -814,7 +942,7 @@
}
else
{
- BTM_TRACE_ERROR2("Illegal params: scan_interval = %d scan_window = %d",
+ BTM_TRACE_ERROR("Illegal params: scan_interval = %d scan_window = %d",
scan_interval, scan_window);
}
@@ -837,7 +965,7 @@
UINT8 rsp_data[BTM_BLE_AD_DATA_LEN],
*p = rsp_data;
- BTM_TRACE_EVENT0 (" BTM_BleWriteScanRsp");
+ BTM_TRACE_EVENT (" BTM_BleWriteScanRsp");
if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
return BTM_ILLEGAL_VALUE;
@@ -877,7 +1005,7 @@
UINT8 *p;
tBTM_BLE_AD_MASK mask = data_mask;
- BTM_TRACE_EVENT0 ("BTM_BleWriteAdvData ");
+ BTM_TRACE_EVENT ("BTM_BleWriteAdvData ");
if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
return BTM_ILLEGAL_VALUE;
@@ -890,9 +1018,9 @@
p_cb_data->p_pad = p;
- if (data_mask != 0)
+ if (mask != 0)
{
- BTM_TRACE_ERROR0("Partial data write into ADV");
+ BTM_TRACE_ERROR("Partial data write into ADV");
}
p_cb_data->data_mask &= ~mask;
@@ -923,7 +1051,7 @@
UINT8 *p = p_adv;
UINT8 length;
UINT8 adv_type;
- BTM_TRACE_API1("BTM_CheckAdvData type=0x%02X", type);
+ BTM_TRACE_API("BTM_CheckAdvData type=0x%02X", type);
STREAM_TO_UINT8(length, p);
@@ -951,16 +1079,17 @@
**
** Description This function is called build the adv data and rsp data.
*******************************************************************************/
-static UINT8 *btm_ble_build_adv_data(tBTM_BLE_AD_MASK *p_data_mask, UINT8 **p_dst, tBTM_BLE_ADV_DATA *p_data)
+UINT8 *btm_ble_build_adv_data(tBTM_BLE_AD_MASK *p_data_mask, UINT8 **p_dst,
+ tBTM_BLE_ADV_DATA *p_data)
{
- UINT16 data_mask = *p_data_mask;
+ UINT32 data_mask = *p_data_mask;
UINT8 *p = *p_dst,
*p_flag = NULL;
UINT16 len = BTM_BLE_AD_DATA_LEN, cp_len = 0;
UINT8 i = 0;
tBTM_BLE_PROP_ELEM *p_elem;
- BTM_TRACE_EVENT0 (" btm_ble_build_adv_data");
+ BTM_TRACE_EVENT (" btm_ble_build_adv_data");
/* build the adv data structure and build the data string */
if (data_mask)
@@ -968,7 +1097,7 @@
/* flags */
if (data_mask & BTM_BLE_AD_BIT_FLAGS)
{
- *p++ = 2;
+ *p++ = MIN_ADV_LENGTH;
*p++ = BTM_BLE_AD_TYPE_FLAG;
p_flag = p;
if (p_data)
@@ -992,13 +1121,13 @@
}
/* device name */
#if BTM_MAX_LOC_BD_NAME_LEN > 0
- if (len > 2 && data_mask & BTM_BLE_AD_BIT_DEV_NAME)
+ if (len > MIN_ADV_LENGTH && data_mask & BTM_BLE_AD_BIT_DEV_NAME)
{
- if (strlen(btm_cb.cfg.bd_name) > (UINT16)(len - 2))
+ if (strlen(btm_cb.cfg.bd_name) > (UINT16)(len - MIN_ADV_LENGTH))
{
- *p++ = len - 2 + 1;
+ *p++ = len - MIN_ADV_LENGTH + 1;
*p++ = BTM_BLE_AD_TYPE_NAME_SHORT;
- ARRAY_TO_STREAM(p, btm_cb.cfg.bd_name, len - 2);
+ ARRAY_TO_STREAM(p, btm_cb.cfg.bd_name, len - MIN_ADV_LENGTH);
}
else
{
@@ -1007,61 +1136,180 @@
*p++ = BTM_BLE_AD_TYPE_NAME_CMPL;
ARRAY_TO_STREAM(p, btm_cb.cfg.bd_name, cp_len);
}
- len -= (cp_len + 2);
+ len -= (cp_len + MIN_ADV_LENGTH);
data_mask &= ~BTM_BLE_AD_BIT_DEV_NAME;
}
#endif
/* manufacturer data */
- if (len > 2 && data_mask & BTM_BLE_AD_BIT_MANU &&
- p_data && p_data->manu.len != 0 && p_data->manu.p_val)
+ if (len > MIN_ADV_LENGTH && data_mask & BTM_BLE_AD_BIT_MANU &&
+ p_data && p_data->p_manu &&
+ p_data->p_manu->len != 0 && p_data->p_manu->p_val)
{
- if (p_data->manu.len > (len - 2))
- cp_len = len - 2;
+ if (p_data->p_manu->len > (len - MIN_ADV_LENGTH))
+ cp_len = len - MIN_ADV_LENGTH;
else
- cp_len = p_data->manu.len;
+ cp_len = p_data->p_manu->len;
*p++ = cp_len + 1;
*p++ = BTM_BLE_AD_TYPE_MANU;
- ARRAY_TO_STREAM(p, p_data->manu.p_val, cp_len);
+ ARRAY_TO_STREAM(p, p_data->p_manu->p_val, cp_len);
- len -= (cp_len + 2);
+ len -= (cp_len + MIN_ADV_LENGTH);
data_mask &= ~BTM_BLE_AD_BIT_MANU;
}
/* TX power */
- if (len > 2 && data_mask & BTM_BLE_AD_BIT_TX_PWR)
+ if (len > MIN_ADV_LENGTH && data_mask & BTM_BLE_AD_BIT_TX_PWR)
{
- *p++ = 2;
+ *p++ = MIN_ADV_LENGTH;
*p++ = BTM_BLE_AD_TYPE_TX_PWR;
- *p++ = btm_cb.ble_ctr_cb.inq_var.tx_power;
+ *p++ = p_data->tx_power;
len -= 3;
data_mask &= ~BTM_BLE_AD_BIT_TX_PWR;
}
- /* services */
- if (len > 2 && data_mask & BTM_BLE_AD_BIT_SERVICE &&
- p_data && p_data->services.num_service != 0 &&
- p_data->services.p_uuid)
+ /* 16 bits services */
+ if (len > MIN_ADV_LENGTH && data_mask & BTM_BLE_AD_BIT_SERVICE &&
+ p_data && p_data->p_services &&
+ p_data->p_services->num_service != 0 &&
+ p_data->p_services->p_uuid)
{
- if (p_data->services.num_service * 2 > (len - 2))
+ if (p_data->p_services->num_service * LEN_UUID_16 > (len - MIN_ADV_LENGTH))
{
- cp_len = (len - 2)/2;
- *p ++ = 1 + cp_len * 2;
+ cp_len = (len - MIN_ADV_LENGTH)/LEN_UUID_16;
+ *p ++ = 1 + cp_len * LEN_UUID_16;
*p++ = BTM_BLE_AD_TYPE_16SRV_PART;
}
else
{
- cp_len = p_data->services.num_service;
- *p++ = 1 + cp_len * 2;
+ cp_len = p_data->p_services->num_service;
+ *p++ = 1 + cp_len * LEN_UUID_16;
*p++ = BTM_BLE_AD_TYPE_16SRV_CMPL;
}
for (i = 0; i < cp_len; i ++)
{
- UINT16_TO_STREAM(p, *(p_data->services.p_uuid + i));
+ UINT16_TO_STREAM(p, *(p_data->p_services->p_uuid + i));
}
- len -= (cp_len * 2 + 2);
+ len -= (cp_len * MIN_ADV_LENGTH + MIN_ADV_LENGTH);
data_mask &= ~BTM_BLE_AD_BIT_SERVICE;
}
+ /* 32 bits service uuid */
+ if (len > MIN_ADV_LENGTH && data_mask & BTM_BLE_AD_BIT_SERVICE_32 &&
+ p_data && p_data->p_service_32b &&
+ p_data->p_service_32b->num_service != 0 &&
+ p_data->p_service_32b->p_uuid)
+ {
+ if ((p_data->p_service_32b->num_service * LEN_UUID_32) > (len - MIN_ADV_LENGTH))
+ {
+ cp_len = (len - MIN_ADV_LENGTH)/LEN_UUID_32;
+ *p ++ = 1 + cp_len * LEN_UUID_32;
+ *p++ = BTM_BLE_AD_TYPE_32SRV_PART;
+ }
+ else
+ {
+ cp_len = p_data->p_service_32b->num_service;
+ *p++ = 1 + cp_len * LEN_UUID_32;
+ *p++ = BTM_BLE_AD_TYPE_32SRV_CMPL;
+ }
+ for (i = 0; i < cp_len; i ++)
+ {
+ UINT32_TO_STREAM(p, *(p_data->p_service_32b->p_uuid + i));
+ }
+
+ len -= (cp_len * LEN_UUID_32 + MIN_ADV_LENGTH);
+ data_mask &= ~BTM_BLE_AD_BIT_SERVICE_32;
+ }
+ /* 128 bits services */
+ if (len >= (MAX_UUID_SIZE + 2) && data_mask & BTM_BLE_AD_BIT_SERVICE_128 &&
+ p_data && p_data->p_services_128b)
+ {
+ *p ++ = 1 + MAX_UUID_SIZE;
+ if (!p_data->p_services_128b->list_cmpl)
+ *p++ = BTM_BLE_AD_TYPE_128SRV_PART;
+ else
+ *p++ = BTM_BLE_AD_TYPE_128SRV_CMPL;
+
+ ARRAY_TO_STREAM(p, p_data->p_services_128b->uuid128, MAX_UUID_SIZE);
+
+ len -= (MAX_UUID_SIZE + MIN_ADV_LENGTH);
+ data_mask &= ~BTM_BLE_AD_BIT_SERVICE_128;
+ }
+ /* 32 bits Service Solicitation UUIDs */
+ if (len > MIN_ADV_LENGTH && data_mask & BTM_BLE_AD_BIT_SERVICE_32SOL &&
+ p_data && p_data->p_sol_service_32b &&
+ p_data->p_sol_service_32b->num_service != 0 &&
+ p_data->p_sol_service_32b->p_uuid)
+ {
+ if ((p_data->p_sol_service_32b->num_service * LEN_UUID_32) > (len - MIN_ADV_LENGTH))
+ {
+ cp_len = (len - MIN_ADV_LENGTH)/LEN_UUID_32;
+ *p ++ = 1 + cp_len * LEN_UUID_32;
+ }
+ else
+ {
+ cp_len = p_data->p_sol_service_32b->num_service;
+ *p++ = 1 + cp_len * LEN_UUID_32;
+ }
+
+ *p++ = BTM_BLE_AD_TYPE_32SOL_SRV_UUID;
+ for (i = 0; i < cp_len; i ++)
+ {
+ UINT32_TO_STREAM(p, *(p_data->p_sol_service_32b->p_uuid + i));
+ }
+
+ len -= (cp_len * LEN_UUID_32 + MIN_ADV_LENGTH);
+ data_mask &= ~BTM_BLE_AD_BIT_SERVICE_32SOL;
+ }
+ /* 128 bits Solicitation services UUID */
+ if (len >= (MAX_UUID_SIZE + MIN_ADV_LENGTH) && data_mask & BTM_BLE_AD_BIT_SERVICE_128SOL &&
+ p_data && p_data->p_sol_service_128b)
+ {
+ *p ++ = 1 + MAX_UUID_SIZE;
+ *p++ = BTM_BLE_AD_TYPE_128SOL_SRV_UUID;
+ ARRAY_TO_STREAM(p, p_data->p_sol_service_128b->uuid128, MAX_UUID_SIZE);
+ len -= (MAX_UUID_SIZE + MIN_ADV_LENGTH);
+ data_mask &= ~BTM_BLE_AD_BIT_SERVICE_128SOL;
+ }
+ /* 16bits/32bits/128bits Service Data */
+ if (len > MIN_ADV_LENGTH && data_mask & BTM_BLE_AD_BIT_SERVICE_DATA &&
+ p_data && p_data->p_service_data->len != 0 && p_data->p_service_data->p_val)
+ {
+ if (len > (p_data->p_service_data->service_uuid.len + MIN_ADV_LENGTH))
+ {
+ if (p_data->p_service_data->len > (len - MIN_ADV_LENGTH))
+ cp_len = len - MIN_ADV_LENGTH- p_data->p_service_data->service_uuid.len;
+ else
+ cp_len = p_data->p_service_data->len;
+
+ *p++ = cp_len + 1 + p_data->p_service_data->service_uuid.len;
+ if (p_data->p_service_data->service_uuid.len == LEN_UUID_16)
+ {
+ *p++ = BTM_BLE_AD_TYPE_SERVICE_DATA;
+ UINT16_TO_STREAM(p, p_data->p_service_data->service_uuid.uu.uuid16);
+ }
+ else if (p_data->p_service_data->service_uuid.len == LEN_UUID_32)
+ {
+ *p++ = BTM_BLE_AD_TYPE_32SERVICE_DATA;
+ UINT32_TO_STREAM(p, p_data->p_service_data->service_uuid.uu.uuid32);
+ }
+ else
+ {
+ *p++ = BTM_BLE_AD_TYPE_128SERVICE_DATA;
+ ARRAY_TO_STREAM(p, p_data->p_service_data->service_uuid.uu.uuid128,
+ LEN_UUID_128);
+ }
+
+ ARRAY_TO_STREAM(p, p_data->p_service_data->p_val, cp_len);
+
+ len -= (cp_len + MIN_ADV_LENGTH + p_data->p_service_data->service_uuid.len);
+ data_mask &= ~BTM_BLE_AD_BIT_SERVICE_DATA;
+ }
+ else
+ {
+ BTM_TRACE_WARNING("service data does not fit");
+ }
+ }
+
if (len >= 6 && data_mask & BTM_BLE_AD_BIT_INT_RANGE &&
p_data)
{
@@ -1078,17 +1326,18 @@
{
p_elem = p_data->p_proprietary->p_elem + i;
- if (len >= (2 + p_elem->len))/* len byte(1) + ATTR type(1) + Uuid len(2) + value length */
+ if (len >= (MIN_ADV_LENGTH + p_elem->len))/* len byte(1) + ATTR type(1) + Uuid len(2)
+ + value length */
{
*p ++ = p_elem->len + 1; /* Uuid len + value length */
*p ++ = p_elem->adv_type;
ARRAY_TO_STREAM(p, p_elem->p_val, p_elem->len);
- len -= (2 + p_elem->len);
+ len -= (MIN_ADV_LENGTH + p_elem->len);
}
else
{
- BTM_TRACE_WARNING0("data exceed max adv packet length");
+ BTM_TRACE_WARNING("data exceed max adv packet length");
break;
}
}
@@ -1172,7 +1421,7 @@
else
flag &= ~(BTM_BLE_DMT_CONTROLLER_SPT|BTM_BLE_DMT_HOST_SPT);
- BTM_TRACE_ERROR1("disc_mode %04x", disc_mode);
+ BTM_TRACE_ERROR("disc_mode %04x", disc_mode);
/* update discoverable flag */
if (disc_mode & BTM_BLE_LIMITED_DISCOVERABLE)
{
@@ -1200,9 +1449,9 @@
**
** Description This function is called to set BLE discoverable mode.
**
-** Parameters: mode: discoverability mode.
+** Parameters: combined_mode: discoverability mode.
**
-** Returns void
+** Returns BTM_SUCCESS is status set successfully; otherwise failure.
**
*******************************************************************************/
tBTM_STATUS btm_ble_set_discoverability(UINT16 combined_mode)
@@ -1220,7 +1469,7 @@
own_addr_type = p_addr_cb->own_addr_type;
UINT16 adv_int_min, adv_int_max;
- BTM_TRACE_EVENT2 ("btm_ble_set_discoverability mode=0x%0x combined_mode=0x%x", mode, combined_mode);
+ BTM_TRACE_EVENT ("btm_ble_set_discoverability mode=0x%0x combined_mode=0x%x", mode, combined_mode);
/*** Check mode parameter ***/
if (mode > BTM_BLE_MAX_DISCOVERABLE)
@@ -1238,7 +1487,7 @@
btu_stop_timer(&p_cb->fast_adv_timer);
/* update adv params if start advertising */
- BTM_TRACE_EVENT2 ("evt_type=0x%x p-cb->evt_type=0x%x ", evt_type, p_cb->evt_type);
+ BTM_TRACE_EVENT ("evt_type=0x%x p-cb->evt_type=0x%x ", evt_type, p_cb->evt_type);
if (new_mode == BTM_BLE_ADV_ENABLE &&
(evt_type != p_cb->evt_type ||p_cb->adv_addr_type != own_addr_type || !p_cb->fast_adv_on))
@@ -1282,7 +1531,7 @@
/* set up stop advertising timer */
if (status == BTM_SUCCESS && mode == BTM_BLE_LIMITED_DISCOVERABLE)
{
- BTM_TRACE_EVENT1 ("start timer for limited disc mode duration=%d (180 secs)", BTM_BLE_GAP_LIM_TOUT);
+ BTM_TRACE_EVENT ("start timer for limited disc mode duration=%d (180 secs)", BTM_BLE_GAP_LIM_TOUT);
/* start Tgap(lim_timeout) */
btu_start_timer (&p_cb->inq_timer_ent, BTU_TTYPE_BLE_GAP_LIM_DISC,
BTM_BLE_GAP_LIM_TOUT);
@@ -1296,9 +1545,9 @@
**
** Description This function is called to set BLE connectability mode.
**
-** Parameters: mode: connectability mode.
+** Parameters: combined_mode: connectability mode.
**
-** Returns void
+** Returns BTM_SUCCESS is status set successfully; otherwise failure.
**
*******************************************************************************/
tBTM_STATUS btm_ble_set_connectability(UINT16 combined_mode)
@@ -1314,7 +1563,7 @@
own_addr_type = p_addr_cb->own_addr_type;
UINT16 adv_int_min, adv_int_max;
- BTM_TRACE_EVENT2 ("btm_ble_set_connectability mode=0x%0x combined_mode=0x%x", mode, combined_mode);
+ BTM_TRACE_EVENT ("btm_ble_set_connectability mode=0x%0x combined_mode=0x%x", mode, combined_mode);
/*** Check mode parameter ***/
if (mode > BTM_BLE_MAX_CONNECTABLE)
@@ -1397,19 +1646,26 @@
tBTM_BLE_CB *p_ble_cb = &btm_cb.ble_ctr_cb;
tBTM_INQUIRY_VAR_ST *p_inq = &btm_cb.btm_inq_vars;
- BTM_TRACE_DEBUG2("btm_ble_start_inquiry: mode = %02x inq_active = 0x%02x", mode, btm_cb.btm_inq_vars.inq_active);
+ BTM_TRACE_DEBUG("btm_ble_start_inquiry: mode = %02x inq_active = 0x%02x", mode, btm_cb.btm_inq_vars.inq_active);
/* if selective connection is active, or inquiry is already active, reject it */
if (BTM_BLE_IS_INQ_ACTIVE(p_ble_cb->scan_activity) ||
BTM_BLE_IS_SEL_CONN_ACTIVE (p_ble_cb->scan_activity))
{
- BTM_TRACE_ERROR0("LE Inquiry is active, can not start inquiry");
+ BTM_TRACE_ERROR("LE Inquiry is active, can not start inquiry");
return(BTM_BUSY);
}
if (!BTM_BLE_IS_SCAN_ACTIVE(p_ble_cb->scan_activity))
{
btm_update_scanner_filter_policy(SP_ADV_ALL);
+
+#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
+ /* enable IRK list */
+ btm_ble_vendor_irk_list_known_dev (TRUE);
+#endif
+#endif
status = btm_ble_start_scan(BTM_BLE_DUPLICATE_DISABLE);
}
@@ -1418,7 +1674,7 @@
p_inq->inq_active |= mode;
p_ble_cb->scan_activity |= mode;
- BTM_TRACE_DEBUG1("btm_ble_start_inquiry inq_active = 0x%02x", p_inq->inq_active);
+ BTM_TRACE_DEBUG("btm_ble_start_inquiry inq_active = 0x%02x", p_inq->inq_active);
if (duration != 0)
{
@@ -1484,7 +1740,7 @@
p_cur->results.ble_evt_type != BTM_BLE_EVT_CONN_ADV &&
p_cur->results.ble_evt_type != BTM_BLE_EVT_CONN_DIR_ADV)
{
- BTM_TRACE_DEBUG0("name request to non-connectable device failed.");
+ BTM_TRACE_DEBUG("name request to non-connectable device failed.");
return BTM_ERR_PROCESSING;
}
@@ -1549,11 +1805,11 @@
tBTM_BLE_LOCAL_ADV_DATA *p_adv_data = &btm_cb.ble_ctr_cb.inq_var.adv_data;
UINT8 *p;
- BTM_TRACE_DEBUG1 ("btm_ble_update_adv_flag new=0x%x", flag);
+ BTM_TRACE_DEBUG ("btm_ble_update_adv_flag new=0x%x", flag);
if (p_adv_data->p_flags != NULL)
{
- BTM_TRACE_DEBUG1 ("btm_ble_update_adv_flag old=0x%x", *p_adv_data->p_flags);
+ BTM_TRACE_DEBUG ("btm_ble_update_adv_flag old=0x%x", *p_adv_data->p_flags);
*p_adv_data->p_flags = flag;
}
else /* no FLAGS in ADV data*/
@@ -1596,17 +1852,17 @@
UINT8 *p_cur = p_data;
UINT8 ad_len, ad_type, ad_flag;
- BTM_TRACE_EVENT0 (" btm_ble_parse_adv_data");
+ BTM_TRACE_EVENT (" btm_ble_parse_adv_data");
while (len > 0)
{
- BTM_TRACE_DEBUG1("btm_ble_parse_adv_data: len = %d", len);
+ BTM_TRACE_DEBUG("btm_ble_parse_adv_data: len = %d", len);
if ((ad_len = *p_cur ++) == 0)
break;
ad_type = *p_cur ++;
- BTM_TRACE_DEBUG2(" ad_type = %02x ad_len = %d", ad_type, ad_len);
+ BTM_TRACE_DEBUG(" ad_type = %02x ad_len = %d", ad_type, ad_len);
switch (ad_type)
{
@@ -1622,7 +1878,7 @@
p_info->remote_name[ad_len] = 0;
p_adv_data->p_remote_name = p_info->remote_name;
p_info->remote_name_len = p_adv_data->remote_name_len = ad_len - 1;
- BTM_TRACE_DEBUG1("BTM_BLE_AD_TYPE_NAME name = %s",p_adv_data->p_remote_name);
+ BTM_TRACE_DEBUG("BTM_BLE_AD_TYPE_NAME name = %s",p_adv_data->p_remote_name);
}
p_cur += (ad_len -1);
@@ -1632,7 +1888,7 @@
p_adv_data->ad_mask |= BTM_BLE_AD_BIT_FLAGS;
ad_flag = *p_cur ++;
p_adv_data->flag = (UINT8)(ad_flag & BTM_BLE_ADV_FLAG_MASK) ;
- BTM_TRACE_DEBUG3("BTM_BLE_AD_TYPE_FLAG flag = %s | %s | %s",
+ BTM_TRACE_DEBUG("BTM_BLE_AD_TYPE_FLAG flag = %s | %s | %s",
(p_adv_data->flag & BTM_BLE_LIMIT_DISC_FLAG)? "LE_LIMIT_DISC" : "",
(p_adv_data->flag & BTM_BLE_GEN_DISC_FLAG)? "LE_GENERAL_DISC" : "",
(p_adv_data->flag & BTM_BLE_BREDR_NOT_SPT)? "LE Only device" : "");
@@ -1641,7 +1897,7 @@
case BTM_BLE_AD_TYPE_TX_PWR:
p_adv_data->ad_mask |= BTM_BLE_AD_BIT_TX_PWR;
p_adv_data->tx_power_level = (INT8)*p_cur ++;
- BTM_TRACE_DEBUG1("BTM_BLE_AD_TYPE_TX_PWR tx_level = %d", p_adv_data->tx_power_level);
+ BTM_TRACE_DEBUG("BTM_BLE_AD_TYPE_TX_PWR tx_level = %d", p_adv_data->tx_power_level);
break;
case BTM_BLE_AD_TYPE_MANU:
@@ -1651,7 +1907,7 @@
p_adv_data->ad_mask |= BTM_BLE_AD_BIT_SERVICE;
/* need allocate memory to store UUID list */
p_adv_data->service.num_service = (ad_len - 1)/2;
- BTM_TRACE_DEBUG1("service UUID list, num = %d", p_adv_data->service.num_service);
+ BTM_TRACE_DEBUG("service UUID list, num = %d", p_adv_data->service.num_service);
p_cur += (ad_len - 1);
break;
@@ -1659,7 +1915,7 @@
p_adv_data->ad_mask |= BTM_BLE_AD_BIT_SERVICE_SOL;
/* need allocate memory to store UUID list */
p_adv_data->service.num_service = (ad_len - 1)/2;
- BTM_TRACE_DEBUG1("service UUID list, num = %d", p_adv_data->service.num_service);
+ BTM_TRACE_DEBUG("service UUID list, num = %d", p_adv_data->service.num_service);
p_cur += (ad_len - 1);
break;
@@ -1667,7 +1923,7 @@
p_adv_data->ad_mask |= BTM_BLE_AD_BIT_SERVICE_128SOL;
/* need allocate memory to store UUID list */
p_adv_data->service.num_service = (ad_len - 1)/16;
- BTM_TRACE_DEBUG1("service UUID list, num = %d", p_adv_data->service.num_service);
+ BTM_TRACE_DEBUG("service UUID list, num = %d", p_adv_data->service.num_service);
p_cur += (ad_len - 1);
break;
@@ -1760,7 +2016,7 @@
if (p_cond->filter_cond_type == BTM_FILTER_COND_BD_ADDR &&
memcmp(bda, p_cond->filter_cond.bdaddr_cond, BD_ADDR_LEN) != 0)
{
- BTM_TRACE_DEBUG0("BD ADDR does not meet filter condition");
+ BTM_TRACE_DEBUG("BD ADDR does not meet filter condition");
return rt;
}
@@ -1774,14 +2030,14 @@
if ((btm_cb.btm_inq_vars.inq_active & BTM_BLE_GENERAL_INQUIRY) &&
(flag & (BTM_BLE_LIMIT_DISC_FLAG|BTM_BLE_GEN_DISC_FLAG)) != 0)
{
- BTM_TRACE_DEBUG0("Find Generable Discoverable device");
+ BTM_TRACE_DEBUG("Find Generable Discoverable device");
rt |= BTM_BLE_INQ_RESULT;
}
else if (btm_cb.btm_inq_vars.inq_active & BTM_BLE_LIMITED_INQUIRY &&
(flag & BTM_BLE_LIMIT_DISC_FLAG) != 0)
{
- BTM_TRACE_DEBUG0("Find limited discoverable device");
+ BTM_TRACE_DEBUG("Find limited discoverable device");
rt |= BTM_BLE_INQ_RESULT;
}
}
@@ -1789,6 +2045,133 @@
return rt;
}
+static void btm_ble_appearance_to_cod(UINT16 appearance, UINT8 *dev_class)
+{
+ dev_class[0] = 0;
+
+ switch (appearance)
+ {
+ case BTM_BLE_APPEARANCE_GENERIC_PHONE:
+ dev_class[1] = BTM_COD_MAJOR_PHONE;
+ dev_class[2] = BTM_COD_MINOR_UNCLASSIFIED;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_COMPUTER:
+ dev_class[1] = BTM_COD_MAJOR_COMPUTER;
+ dev_class[2] = BTM_COD_MINOR_UNCLASSIFIED;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_REMOTE:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_REMOTE_CONTROL;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_THERMOMETER:
+ case BTM_BLE_APPEARANCE_THERMOMETER_EAR:
+ dev_class[1] = BTM_COD_MAJOR_HEALTH;
+ dev_class[2] = BTM_COD_MINOR_THERMOMETER;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_HEART_RATE:
+ case BTM_BLE_APPEARANCE_HEART_RATE_BELT:
+ dev_class[1] = BTM_COD_MAJOR_HEALTH;
+ dev_class[2] = BTM_COD_MINOR_HEART_PULSE_MONITOR;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE:
+ case BTM_BLE_APPEARANCE_BLOOD_PRESSURE_ARM:
+ case BTM_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST:
+ dev_class[1] = BTM_COD_MAJOR_HEALTH;
+ dev_class[2] = BTM_COD_MINOR_BLOOD_MONITOR;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER:
+ case BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP:
+ case BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST:
+ dev_class[1] = BTM_COD_MAJOR_HEALTH;
+ dev_class[2] = BTM_COD_MINOR_PULSE_OXIMETER;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_GLUCOSE:
+ dev_class[1] = BTM_COD_MAJOR_HEALTH;
+ dev_class[2] = BTM_COD_MINOR_GLUCOSE_METER;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_WEIGHT:
+ dev_class[1] = BTM_COD_MAJOR_HEALTH;
+ dev_class[2] = BTM_COD_MINOR_WEIGHING_SCALE;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_WALKING:
+ case BTM_BLE_APPEARANCE_WALKING_IN_SHOE:
+ case BTM_BLE_APPEARANCE_WALKING_ON_SHOE:
+ case BTM_BLE_APPEARANCE_WALKING_ON_HIP:
+ dev_class[1] = BTM_COD_MAJOR_HEALTH;
+ dev_class[2] = BTM_COD_MINOR_STEP_COUNTER;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_WATCH:
+ case BTM_BLE_APPEARANCE_SPORTS_WATCH:
+ dev_class[1] = BTM_COD_MAJOR_WEARABLE;
+ dev_class[2] = BTM_COD_MINOR_WRIST_WATCH;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_EYEGLASSES:
+ dev_class[1] = BTM_COD_MAJOR_WEARABLE;
+ dev_class[2] = BTM_COD_MINOR_GLASSES;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_DISPLAY:
+ dev_class[1] = BTM_COD_MAJOR_IMAGING;
+ dev_class[2] = BTM_COD_MINOR_DISPLAY;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER:
+ dev_class[1] = BTM_COD_MAJOR_AUDIO;
+ dev_class[2] = BTM_COD_MINOR_UNCLASSIFIED;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER:
+ case BTM_BLE_APPEARANCE_HID_BARCODE_SCANNER:
+ case BTM_BLE_APPEARANCE_GENERIC_HID:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_UNCLASSIFIED;
+ break;
+ case BTM_BLE_APPEARANCE_HID_KEYBOARD:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_KEYBOARD;
+ break;
+ case BTM_BLE_APPEARANCE_HID_MOUSE:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_POINTING;
+ break;
+ case BTM_BLE_APPEARANCE_HID_JOYSTICK:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_JOYSTICK;
+ break;
+ case BTM_BLE_APPEARANCE_HID_GAMEPAD:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_GAMEPAD;
+ break;
+ case BTM_BLE_APPEARANCE_HID_DIGITIZER_TABLET:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_DIGITIZING_TABLET;
+ break;
+ case BTM_BLE_APPEARANCE_HID_CARD_READER:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_CARD_READER;
+ break;
+ case BTM_BLE_APPEARANCE_HID_DIGITAL_PEN:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_DIGITAL_PAN;
+ break;
+ case BTM_BLE_APPEARANCE_UKNOWN:
+ case BTM_BLE_APPEARANCE_GENERIC_CLOCK:
+ case BTM_BLE_APPEARANCE_GENERIC_TAG:
+ case BTM_BLE_APPEARANCE_GENERIC_KEYRING:
+ case BTM_BLE_APPEARANCE_GENERIC_CYCLING:
+ case BTM_BLE_APPEARANCE_CYCLING_COMPUTER:
+ case BTM_BLE_APPEARANCE_CYCLING_SPEED:
+ case BTM_BLE_APPEARANCE_CYCLING_CADENCE:
+ case BTM_BLE_APPEARANCE_CYCLING_POWER:
+ case BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE:
+ case BTM_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS:
+ case BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION:
+ case BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV:
+ case BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD:
+ case BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV:
+ default:
+ dev_class[1] = BTM_COD_MAJOR_UNCLASSIFIED;
+ dev_class[2] = BTM_COD_MINOR_UNCLASSIFIED;
+ };
+}
+
/*******************************************************************************
**
** Function btm_ble_update_inq_result
@@ -1816,7 +2199,7 @@
if (data_len > BTM_BLE_ADV_DATA_LEN_MAX)
{
- BTM_TRACE_WARNING1("EIR data too long %d. discard", data_len);
+ BTM_TRACE_WARNING("EIR data too long %d. discard", data_len);
return FALSE;
}
btm_ble_cache_adv_data(p_cur, data_len, p, evt_type);
@@ -1833,7 +2216,7 @@
if ((btm_cb.ble_ctr_cb.inq_var.scan_type == BTM_BLE_SCAN_MODE_ACTI &&
(evt_type == BTM_BLE_CONNECT_EVT || evt_type == BTM_BLE_DISCOVER_EVT)))
{
- BTM_TRACE_DEBUG1("btm_ble_update_inq_result scan_rsp=false, to_report=false,\
+ BTM_TRACE_DEBUG("btm_ble_update_inq_result scan_rsp=false, to_report=false,\
scan_type_active=%d", btm_cb.ble_ctr_cb.inq_var.scan_type);
p_i->scan_rsp = FALSE;
to_report = FALSE;
@@ -1859,19 +2242,31 @@
if (p_le_inq_cb->adv_len != 0)
{
- if ((p_uuid16 = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache,
- BTM_BLE_AD_TYPE_16SRV_CMPL, &len)) != NULL)
+ /* Check to see the BLE device has the Appearance UUID in the advertising data. If it does
+ * then try to convert the appearance value to a class of device value Bluedroid can use.
+ * Otherwise fall back to trying to infer if it is a HID device based on the service class.
+ */
+ p_uuid16 = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache, BTM_BLE_AD_TYPE_APPEARANCE, &len);
+ if (p_uuid16 && len == 2)
{
- UINT8 i;
- for (i = 0; i + 2 <= len; i = i + 2)
+ btm_ble_appearance_to_cod((UINT16)p_uuid16[0] | (p_uuid16[1] << 8), p_cur->dev_class);
+ }
+ else
+ {
+ if ((p_uuid16 = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache,
+ BTM_BLE_AD_TYPE_16SRV_CMPL, &len)) != NULL)
{
- /* if this BLE device support HID over LE, set HID Major in class of device */
- if ((p_uuid16[i] | (p_uuid16[i+1] << 8)) == UUID_SERVCLASS_LE_HID)
+ UINT8 i;
+ for (i = 0; i + 2 <= len; i = i + 2)
{
- p_cur->dev_class[0] = 0;
- p_cur->dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
- p_cur->dev_class[2] = 0;
- break;
+ /* if this BLE device support HID over LE, set HID Major in class of device */
+ if ((p_uuid16[i] | (p_uuid16[i+1] << 8)) == UUID_SERVCLASS_LE_HID)
+ {
+ p_cur->dev_class[0] = 0;
+ p_cur->dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ p_cur->dev_class[2] = 0;
+ break;
+ }
}
}
}
@@ -1883,15 +2278,15 @@
{
if (p_cur->ble_addr_type != BLE_ADDR_RANDOM)
{
- BTM_TRACE_DEBUG0("BR/EDR NOT support bit not set, treat as DUMO");
+ BTM_TRACE_DEBUG("BR/EDR NOT support bit not set, treat as DUMO");
p_cur->device_type |= BT_DEVICE_TYPE_DUMO;
} else {
- BTM_TRACE_DEBUG0("Random address, treating device as LE only");
+ BTM_TRACE_DEBUG("Random address, treating device as LE only");
}
}
else
{
- BTM_TRACE_DEBUG0("BR/EDR NOT SUPPORT bit set, LE only device");
+ BTM_TRACE_DEBUG("BR/EDR NOT SUPPORT bit set, LE only device");
}
return to_report;
@@ -1959,46 +2354,63 @@
BD_ADDR bda;
UINT8 evt_type = 0, *p = p_data;
UINT8 addr_type = 0;
+ UINT8 num_reports;
+ UINT8 data_len;
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
BOOLEAN match = FALSE;
#endif
- /* always get one device at a time */
- p ++;
+ /* Extract the number of reports in this event. */
+ STREAM_TO_UINT8(num_reports, p);
- /* Extract inquiry results */
- STREAM_TO_UINT8 (evt_type, p);
- STREAM_TO_UINT8 (addr_type, p);
- STREAM_TO_BDADDR (bda, p);
+ while (num_reports--)
+ {
+ /* Extract inquiry results */
+ STREAM_TO_UINT8 (evt_type, p);
+ STREAM_TO_UINT8 (addr_type, p);
+ STREAM_TO_BDADDR (bda, p);
#ifdef BTM_BLE_PC_ADV_TEST_MODE /* For general stack code (e.g. BTInsight testing), we simply do not define it to exclude or set it to TRUE to include */
- if (BTM_BLE_PC_ADV_TEST_MODE) /* For stack component, it is always defined and maps to a global variable g_bDraculaAdvertisingMode */
- {
- if (btm_cb.ble_ctr_cb.p_scan_req_cback)
- (*btm_cb.ble_ctr_cb.p_scan_req_cback)(bda, addr_type, evt_type);
- }
+ if (BTM_BLE_PC_ADV_TEST_MODE) /* For stack component, it is always defined and maps to a global variable g_bDraculaAdvertisingMode */
+ {
+ if (btm_cb.ble_ctr_cb.p_scan_req_cback)
+ (*btm_cb.ble_ctr_cb.p_scan_req_cback)(bda, addr_type, evt_type);
+ }
#endif
+#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
+ /* map address to security record */
+ btm_public_addr_to_random_pseudo(bda, &addr_type);
+ BTM_TRACE_ERROR("new address: %02x:%02x:%02x:%02x:%02x:%02x",
+ bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
+#endif
+#endif
+ /* Only process the results if the inquiry is still active */
+ if (!BTM_BLE_IS_SCAN_ACTIVE(btm_cb.ble_ctr_cb.scan_activity))
+ return;
- /* Only process the results if the inquiry is still active */
- if (!BTM_BLE_IS_SCAN_ACTIVE(btm_cb.ble_ctr_cb.scan_activity))
- return;
-
- BTM_TRACE_DEBUG6("btm_ble_process_adv_pkt:bda= %0x:%0x:%0x:%0x:%0x:%0x",
+ BTM_TRACE_DEBUG("btm_ble_process_adv_pkt:bda= %0x:%0x:%0x:%0x:%0x:%0x",
bda[0],bda[1],bda[2],bda[3],bda[4],bda[5]);
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
#if SMP_INCLUDED == TRUE
- /* always do RRA resolution on host */
- if (!match && BTM_BLE_IS_RESOLVE_BDA(bda))
- {
- btm_ble_resolve_random_addr(bda, btm_ble_resolve_random_addr_on_adv, p_data);
- }
- else
+ /* always do RRA resolution on host */
+ if (!match && BTM_BLE_IS_RESOLVE_BDA(bda))
+ {
+ btm_ble_resolve_random_addr(bda, btm_ble_resolve_random_addr_on_adv, p_data);
+ }
+ else
#endif
#endif
- {
- btm_ble_process_adv_pkt_cont(bda, addr_type, evt_type, p);
+ {
+ btm_ble_process_adv_pkt_cont(bda, addr_type, evt_type, p);
+ }
+
+ STREAM_TO_UINT8(data_len, p);
+
+ /* Advance to the next event data_len + rssi byte */
+ p += data_len + 1;
}
}
@@ -2067,7 +2479,7 @@
if ((result = btm_ble_is_discoverable(bda, evt_type, p)) == 0)
{
- BTM_TRACE_ERROR0("discard adv pkt");
+ BTM_TRACE_ERROR("discard adv pkt");
return;
}
if (!update)
@@ -2082,7 +2494,7 @@
(/* assume a DUMO device, BR/EDR inquiry is always active */
p_i && p_i->inq_info.results.device_type == BT_DEVICE_TYPE_BLE && p_i->scan_rsp))
{
- BTM_TRACE_WARNING0("INQ RES: Extra Response Received...cancelling inquiry..");
+ BTM_TRACE_WARNING("INQ RES: Extra Response Received...cancelling inquiry..");
/* if is non-periodic inquiry active, cancel now */
if ((p_inq->inq_active & BTM_BR_INQ_ACTIVE_MASK) != 0 &&
@@ -2104,7 +2516,7 @@
btm_send_sel_conn_callback(bda, evt_type, p, addr_type);
else
{
- BTM_TRACE_DEBUG0("None LE device, can not initiate selective connection");
+ BTM_TRACE_DEBUG("None LE device, can not initiate selective connection");
}
}
else
@@ -2158,7 +2570,7 @@
*******************************************************************************/
void btm_ble_stop_scan(void)
{
- BTM_TRACE_EVENT0 ("btm_ble_stop_scan ");
+ BTM_TRACE_EVENT ("btm_ble_stop_scan ");
/* Clear the inquiry callback if set */
btm_cb.ble_ctr_cb.inq_var.scan_type = BTM_BLE_SCAN_MODE_NONE;
@@ -2191,7 +2603,7 @@
btm_ble_stop_scan();
/* If we have a callback registered for inquiry complete, call it */
- BTM_TRACE_DEBUG2 ("BTM Inq Compl Callback: status 0x%02x, num results %d",
+ BTM_TRACE_DEBUG ("BTM Inq Compl Callback: status 0x%02x, num results %d",
p_inq->inq_cmpl_info.status, p_inq->inq_cmpl_info.num_resp);
btm_process_inq_complete(HCI_SUCCESS, (UINT8)(p_inq->inqparms.mode & BTM_BLE_INQUIRY_MASK));
@@ -2256,7 +2668,7 @@
break;
default:
- BTM_TRACE_ERROR1("unknown adv event : %d", adv_evt);
+ BTM_TRACE_ERROR("unknown adv event : %d", adv_evt);
break;
}
@@ -2411,7 +2823,8 @@
}
}
- if (btm_cb.ble_ctr_cb.inq_var.connectable_mode == BTM_BLE_CONNECTABLE)
+ if (btm_multi_adv_cb.adv_inst_max == 0 &&
+ btm_cb.ble_ctr_cb.inq_var.connectable_mode == BTM_BLE_CONNECTABLE)
{
btm_ble_set_connectability ( btm_cb.ble_ctr_cb.inq_var.connectable_mode );
}
@@ -2467,7 +2880,7 @@
*******************************************************************************/
void btm_ble_timeout(TIMER_LIST_ENT *p_tle)
{
- BTM_TRACE_EVENT0 ("btm_ble_timeout");
+ BTM_TRACE_EVENT ("btm_ble_timeout");
switch (p_tle->event)
{
@@ -2482,15 +2895,21 @@
case BTU_TTYPE_BLE_GAP_LIM_DISC:
/* lim_timeout expiried, limited discovery should exit now */
btm_cb.btm_inq_vars.discoverable_mode &= ~BTM_BLE_LIMITED_DISCOVERABLE;
-
btm_ble_set_adv_flag(btm_cb.btm_inq_vars.connectable_mode, btm_cb.btm_inq_vars.discoverable_mode);
break;
case BTU_TTYPE_BLE_RANDOM_ADDR:
if (btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM)
{
+ if ((void *)(p_tle->param) == NULL)
/* refresh the random addr */
- btm_gen_resolvable_private_addr();
+ btm_gen_resolvable_private_addr((void *)btm_gen_resolve_paddr_low);
+ else
+ {
+#if BLE_MULTI_ADV_INCLUDED == TRUE
+ btm_ble_multi_adv_configure_rpa((tBTM_BLE_MULTI_ADV_INST*)p_tle->param);
+#endif
+ }
}
break;
@@ -2523,7 +2942,7 @@
UINT16 handle;
int xx;
- BTM_TRACE_EVENT0 ("btm_ble_read_remote_features_complete ");
+ BTM_TRACE_EVENT ("btm_ble_read_remote_features_complete ");
/* Skip status */
p++;
@@ -2561,7 +2980,10 @@
p_cb->adv_mode = !p_cb->adv_mode;
}
-
+#if (BLE_VND_INCLUDED == TRUE && BLE_PRIVACY_SPT == TRUE)
+ if (p_cb->adv_mode == BTM_BLE_ADV_DISABLE)
+ btm_ble_vendor_disable_irk_list();
+#endif
}
/*******************************************************************************
@@ -2594,7 +3016,7 @@
{
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
- BTM_TRACE_EVENT0 ("btm_ble_init ");
+ BTM_TRACE_EVENT ("btm_ble_init ");
memset(p_cb, 0, sizeof(tBTM_BLE_CB));
p_cb->cur_states = 0;
@@ -2611,6 +3033,9 @@
p_cb->scan_int = p_cb->scan_win = BTM_BLE_CONN_PARAM_UNDEF;
p_cb->inq_var.evt_type = BTM_BLE_NON_CONNECT_EVT;
+#if BLE_MULTI_ADV_INCLUDED == TRUE
+ btm_ble_multi_adv_init();
+#endif
}
/*******************************************************************************
@@ -2639,7 +3064,7 @@
request_state_mask > BTM_BLE_STATE_SCAN_ADV_BIT ||
(request_state_mask & (request_state_mask -1 )) != 0)
{
- BTM_TRACE_ERROR1("illegal state requested: %d", request_state_mask);
+ BTM_TRACE_ERROR("illegal state requested: %d", request_state_mask);
return rt;
}
@@ -2655,7 +3080,7 @@
if (!BTM_LE_STATES_SUPPORTED(btm_cb.devcb.le_supported_states, mask, offset))
{
- BTM_TRACE_ERROR1("state requested not supported: %d", request_state);
+ BTM_TRACE_ERROR("state requested not supported: %d", request_state);
return rt;
}
diff --git a/stack/btm/btm_ble_int.h b/stack/btm/btm_ble_int.h
index f3cb771..52be674 100644
--- a/stack/btm/btm_ble_int.h
+++ b/stack/btm/btm_ble_int.h
@@ -116,6 +116,9 @@
#define BTM_BLE_VALID_PRAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == BTM_BLE_CONN_PARAM_UNDEF))
+#define BTM_BLE_PRIVATE_ADDR_INT 900 /* 15 minutes minimum for
+ random address refreshing */
+
typedef struct
{
@@ -328,6 +331,8 @@
extern void btm_read_ble_local_supported_states_complete(UINT8 *p, UINT16 evt_len);
extern tBTM_BLE_CONN_ST btm_ble_get_conn_st(void);
extern void btm_ble_set_conn_st(tBTM_BLE_CONN_ST new_st);
+extern UINT8 *btm_ble_build_adv_data(tBTM_BLE_AD_MASK *p_data_mask, UINT8 **p_dst,
+ tBTM_BLE_ADV_DATA *p_data);
extern tBTM_STATUS btm_ble_start_adv(void);
extern tBTM_STATUS btm_ble_stop_adv(void);
extern tBTM_STATUS btm_ble_start_scan (UINT8 filter_enb);
@@ -383,19 +388,33 @@
extern void btm_ble_enqueue_direct_conn_req(void *p_param);
/* BLE address management */
-extern void btm_gen_resolvable_private_addr (void);
+extern void btm_gen_resolvable_private_addr (void *p_cmd_cplt_cback);
extern void btm_gen_non_resolvable_private_addr (tBTM_BLE_ADDR_CBACK *p_cback, void *p);
extern void btm_ble_resolve_random_addr(BD_ADDR random_bda, tBTM_BLE_RESOLVE_CBACK * p_cback, void *p);
extern void btm_ble_update_reconnect_address(BD_ADDR bd_addr);
+extern void btm_gen_resolve_paddr_low(tBTM_RAND_ENC *p);
+
+extern void btm_ble_multi_adv_configure_rpa (tBTM_BLE_MULTI_ADV_INST *p_inst);
+extern void btm_ble_multi_adv_init(void);
+extern void btm_ble_multi_adv_reenable(UINT8 inst_id);
+extern void btm_ble_multi_adv_enb_privacy(BOOLEAN enable);
extern BOOLEAN btm_ble_topology_check(tBTM_BLE_STATE_MASK request);
extern BOOLEAN btm_ble_clear_topology_mask(tBTM_BLE_STATE_MASK request_state);
extern BOOLEAN btm_ble_set_topology_mask(tBTM_BLE_STATE_MASK request_state);
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
+/* BLE address mapping with CS feature */
+extern BOOLEAN btm_public_addr_to_random_pseudo(BD_ADDR bd_addr, UINT8 *p_addr_type);
+extern BOOLEAN btm_random_pseudo_to_public(BD_ADDR random_pseudo, UINT8 *p_static_addr_type);
+extern void btm_ble_refresh_rra(BD_ADDR pseudo_bda, BD_ADDR rra);
+#endif
+
#if BTM_BLE_CONFORMANCE_TESTING == TRUE
BT_API extern void btm_ble_set_no_disc_if_pair_fail (BOOLEAN disble_disc);
BT_API extern void btm_ble_set_test_mac_value (BOOLEAN enable, UINT8 *p_test_mac_val);
BT_API extern void btm_ble_set_test_local_sign_cntr_value(BOOLEAN enable, UINT32 test_local_sign_cntr);
BT_API extern void btm_set_random_address(BD_ADDR random_bda);
+BT_API extern void btm_ble_set_keep_rfu_in_auth_req(BOOLEAN keep_rfu);
#endif
diff --git a/stack/btm/btm_ble_multi_adv.c b/stack/btm/btm_ble_multi_adv.c
new file mode 100644
index 0000000..0e909ed
--- /dev/null
+++ b/stack/btm/btm_ble_multi_adv.c
@@ -0,0 +1,790 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 Broadcom 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 <string.h>
+#include "bt_target.h"
+
+#if (BLE_INCLUDED == TRUE)
+#if BLE_MULTI_ADV_INCLUDED == TRUE
+#include "bt_types.h"
+#include "hcimsgs.h"
+#include "btu.h"
+#include "btm_int.h"
+#include "bt_utils.h"
+#include "hcidefs.h"
+#include "btm_ble_api.h"
+
+/* length of each multi adv sub command */
+#define BTM_BLE_MULTI_ADV_ENB_LEN 3
+#define BTM_BLE_MULTI_ADV_SET_PARAM_LEN 24
+#define BTM_BLE_MULTI_ADV_WRITE_DATA_LEN (BTM_BLE_AD_DATA_LEN + 3)
+#define BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR_LEN 8
+
+#ifndef BTM_BLE_MULTI_ADV_INST_MAX
+#define BTM_BLE_MULTI_ADV_INST_MAX 5
+#endif
+
+tBTM_BLE_MULTI_ADV_CB btm_multi_adv_cb;
+
+static void btm_ble_multi_adv_gen_rpa_cmpl_1(tBTM_RAND_ENC *p);
+static void btm_ble_multi_adv_gen_rpa_cmpl_2(tBTM_RAND_ENC *p);
+static void btm_ble_multi_adv_gen_rpa_cmpl_3(tBTM_RAND_ENC *p);
+static void btm_ble_multi_adv_gen_rpa_cmpl_4(tBTM_RAND_ENC *p);
+
+typedef void (*tBTM_MULTI_ADV_RPA_CMPL)(tBTM_RAND_ENC *p);
+const tBTM_MULTI_ADV_RPA_CMPL btm_ble_multi_adv_rpa_cmpl [] =
+{
+ btm_ble_multi_adv_gen_rpa_cmpl_1,
+ btm_ble_multi_adv_gen_rpa_cmpl_2,
+ btm_ble_multi_adv_gen_rpa_cmpl_3,
+ btm_ble_multi_adv_gen_rpa_cmpl_4
+};
+
+#define BTM_BLE_MULTI_ADV_CB_EVT_MASK 0xF0
+#define BTM_BLE_MULTI_ADV_SUBCODE_MASK 0x0F
+
+/*******************************************************************************
+**
+** Function btm_ble_multi_adv_enq_op_q
+**
+** Description enqueue a multi adv operation in q to check command complete
+** status.
+**
+** Returns void
+**
+*******************************************************************************/
+void btm_ble_multi_adv_enq_op_q(UINT8 opcode, UINT8 inst_id, UINT8 cb_evt)
+{
+ tBTM_BLE_MULTI_ADV_OPQ *p_op_q = &btm_multi_adv_cb.op_q;
+
+ p_op_q->inst_id[p_op_q->next_idx] = inst_id;
+
+ p_op_q->sub_code[p_op_q->next_idx] = (opcode |(cb_evt << 4));
+
+ p_op_q->next_idx = (p_op_q->next_idx + 1) % BTM_BLE_MULTI_ADV_MAX;
+}
+
+/*******************************************************************************
+**
+** Function btm_ble_multi_adv_deq_op_q
+**
+** Description dequeue a multi adv operation from q when command complete
+** is received.
+**
+** Returns void
+**
+*******************************************************************************/
+void btm_ble_multi_adv_deq_op_q(UINT8 *p_opcode, UINT8 *p_inst_id, UINT8 *p_cb_evt)
+{
+ tBTM_BLE_MULTI_ADV_OPQ *p_op_q = &btm_multi_adv_cb.op_q;
+
+ *p_inst_id = p_op_q->inst_id[p_op_q->pending_idx] & 0x7F;
+ *p_cb_evt = (p_op_q->sub_code[p_op_q->pending_idx] >> 4);
+ *p_opcode = (p_op_q->sub_code[p_op_q->pending_idx] & BTM_BLE_MULTI_ADV_SUBCODE_MASK);
+
+ p_op_q->pending_idx = (p_op_q->pending_idx + 1) % BTM_BLE_MULTI_ADV_MAX;
+}
+
+/*******************************************************************************
+**
+** Function btm_ble_multi_adv_vsc_cmpl_cback
+**
+** Description Multi adv VSC complete callback
+**
+** Parameters
+**
+** Returns void
+**
+*******************************************************************************/
+void btm_ble_multi_adv_vsc_cmpl_cback (tBTM_VSC_CMPL *p_params)
+{
+ UINT8 status, subcode;
+ UINT8 *p = p_params->p_param_buf, inst_id;
+ UINT16 len = p_params->param_len;
+ tBTM_BLE_MULTI_ADV_INST *p_inst ;
+ UINT8 cb_evt = 0, opcode;
+
+ if (len < 2)
+ {
+ BTM_TRACE_ERROR("wrong length for btm_ble_multi_adv_vsc_cmpl_cback");
+ return;
+ }
+
+ STREAM_TO_UINT8(status, p);
+ STREAM_TO_UINT8(subcode, p);
+
+ btm_ble_multi_adv_deq_op_q(&opcode, &inst_id, &cb_evt);
+
+ BTM_TRACE_DEBUG("op_code = %02x inst_id = %d cb_evt = %02x", opcode, inst_id, cb_evt);
+
+ if (opcode != subcode || inst_id == 0)
+ {
+ BTM_TRACE_ERROR("get unexpected VSC cmpl, expect: %d get: %d",subcode,opcode);
+ return;
+ }
+
+ p_inst = &btm_multi_adv_cb.adv_inst[inst_id - 1];
+
+ switch (subcode)
+ {
+ case BTM_BLE_MULTI_ADV_ENB:
+ BTM_TRACE_DEBUG("BTM_BLE_MULTI_ADV_ENB status = %d", status);
+ if (status != HCI_SUCCESS)
+ {
+ btm_multi_adv_cb.adv_inst[inst_id-1].inst_id = 0;
+ }
+ break;
+
+ case BTM_BLE_MULTI_ADV_SET_PARAM:
+ {
+ BTM_TRACE_DEBUG("BTM_BLE_MULTI_ADV_SET_PARAM status = %d", status);
+ break;
+ }
+
+ case BTM_BLE_MULTI_ADV_WRITE_ADV_DATA:
+ {
+ BTM_TRACE_DEBUG("BTM_BLE_MULTI_ADV_WRITE_ADV_DATA status = %d", status);
+ break;
+ }
+
+ case BTM_BLE_MULTI_ADV_WRITE_SCAN_RSP_DATA:
+ {
+ BTM_TRACE_DEBUG("BTM_BLE_MULTI_ADV_WRITE_SCAN_RSP_DATA status = %d", status);
+ break;
+ }
+
+ case BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR:
+ {
+ BTM_TRACE_DEBUG("BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR status = %d", status);
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ if (cb_evt != 0 && p_inst->p_cback != NULL)
+ {
+ (p_inst->p_cback)(cb_evt, inst_id, p_inst->p_ref, status);
+ }
+ return;
+}
+
+/*******************************************************************************
+**
+** Function btm_ble_enable_multi_adv
+**
+** Description This function enable the customer specific feature in controller
+**
+** Parameters enable: enable or disable
+** inst_id: adv instance ID, can not be 0
+**
+** Returns status
+**
+*******************************************************************************/
+tBTM_STATUS btm_ble_enable_multi_adv (BOOLEAN enable, UINT8 inst_id, UINT8 cb_evt)
+{
+ UINT8 param[BTM_BLE_MULTI_ADV_ENB_LEN], *pp;
+ UINT8 enb = enable ? 1: 0;
+ tBTM_STATUS rt;
+
+ pp = param;
+ memset(param, 0, BTM_BLE_MULTI_ADV_ENB_LEN);
+
+ UINT8_TO_STREAM (pp, BTM_BLE_MULTI_ADV_ENB);
+ UINT8_TO_STREAM (pp, enb);
+ UINT8_TO_STREAM (pp, inst_id);
+
+ BTM_TRACE_EVENT (" btm_ble_enable_multi_adv: enb %d, Inst ID %d",enb,inst_id);
+
+ if ((rt = BTM_VendorSpecificCommand (HCI_BLE_MULTI_ADV_OCF,
+ BTM_BLE_MULTI_ADV_ENB_LEN,
+ param,
+ btm_ble_multi_adv_vsc_cmpl_cback))
+ == BTM_CMD_STARTED)
+ {
+ btm_ble_multi_adv_enq_op_q(BTM_BLE_MULTI_ADV_ENB, inst_id, cb_evt);
+ }
+ return rt;
+}
+
+/*******************************************************************************
+**
+** Function btm_ble_multi_adv_set_params
+**
+** Description This function enable the customer specific feature in controller
+**
+** Parameters advertise parameters used for this instance.
+**
+** Returns status
+**
+*******************************************************************************/
+tBTM_STATUS btm_ble_multi_adv_set_params (tBTM_BLE_MULTI_ADV_INST *p_inst,
+ tBTM_BLE_ADV_PARAMS *p_params,
+ UINT8 cb_evt)
+{
+ UINT8 param[BTM_BLE_MULTI_ADV_SET_PARAM_LEN], *pp;
+ tBTM_STATUS rt;
+ BD_ADDR dummy ={0,0,0,0,0,0};
+
+ pp = param;
+ memset(param, 0, BTM_BLE_MULTI_ADV_SET_PARAM_LEN);
+
+ UINT8_TO_STREAM(pp, BTM_BLE_MULTI_ADV_SET_PARAM);
+
+ UINT16_TO_STREAM (pp, p_params->adv_int_min);
+ UINT16_TO_STREAM (pp, p_params->adv_int_max);
+ UINT8_TO_STREAM (pp, p_params->adv_type);
+
+#if BLE_PRIVACY_SPT
+ if (btm_cb.ble_ctr_cb.privacy)
+ {
+ UINT8_TO_STREAM (pp, BLE_ADDR_RANDOM);
+ BDADDR_TO_STREAM (pp, p_inst->rpa);
+ }
+ else
+#endif
+ {
+ UINT8_TO_STREAM (pp, BLE_ADDR_PUBLIC);
+ BDADDR_TO_STREAM (pp, btm_cb.devcb.local_addr);
+ }
+
+ BTM_TRACE_EVENT (" btm_ble_multi_adv_set_params,Min %d, Max %d,adv_type %d",
+ p_params->adv_int_min,p_params->adv_int_max,p_params->adv_type);
+
+ UINT8_TO_STREAM (pp, 0);
+ BDADDR_TO_STREAM (pp, dummy);
+
+ if (p_params->channel_map == 0 || p_params->channel_map > BTM_BLE_DEFAULT_ADV_CHNL_MAP)
+ p_params->channel_map = BTM_BLE_DEFAULT_ADV_CHNL_MAP;
+ UINT8_TO_STREAM (pp, p_params->channel_map);
+
+ if (p_params->adv_filter_policy >= AP_SCAN_CONN_POLICY_MAX)
+ p_params->adv_filter_policy = AP_SCAN_CONN_ALL;
+ UINT8_TO_STREAM (pp, p_params->adv_filter_policy);
+
+ UINT8_TO_STREAM (pp, p_inst->inst_id);
+
+ if (p_params->tx_power > BTM_BLE_ADV_TX_POWER_MAX)
+ p_params->tx_power = BTM_BLE_ADV_TX_POWER_MAX;
+ UINT8_TO_STREAM (pp, p_params->tx_power);
+
+ BTM_TRACE_EVENT("set_params:Chnl Map %d,adv_fltr policy %d,ID:%d, TX Power%d",
+ p_params->channel_map,p_params->adv_filter_policy,p_inst->inst_id,p_params->tx_power);
+
+ if ((rt = BTM_VendorSpecificCommand (HCI_BLE_MULTI_ADV_OCF,
+ BTM_BLE_MULTI_ADV_SET_PARAM_LEN,
+ param,
+ btm_ble_multi_adv_vsc_cmpl_cback))
+ == BTM_CMD_STARTED)
+ {
+ p_inst->adv_evt = p_params->adv_type;
+
+#if BLE_PRIVACY_SPT
+ if (btm_cb.ble_ctr_cb.privacy)
+ {
+ /* start timer */
+ p_inst->raddr_timer_ent.param = (TIMER_PARAM_TYPE) p_inst;
+ btu_start_timer (&p_inst->raddr_timer_ent, BTU_TTYPE_BLE_RANDOM_ADDR,
+ BTM_BLE_PRIVATE_ADDR_INT);
+ }
+#endif
+ btm_ble_multi_adv_enq_op_q(BTM_BLE_MULTI_ADV_SET_PARAM, p_inst->inst_id, cb_evt);
+ }
+ return rt;
+}
+
+/*******************************************************************************
+**
+** Function btm_ble_multi_adv_write_rpa
+**
+** Description This function write the random address for the adv instance into
+** controller
+**
+** Parameters
+**
+** Returns status
+**
+*******************************************************************************/
+tBTM_STATUS btm_ble_multi_adv_write_rpa (tBTM_BLE_MULTI_ADV_INST *p_inst, BD_ADDR random_addr)
+{
+ UINT8 param[BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR_LEN], *pp = param;
+ tBTM_STATUS rt;
+
+ BTM_TRACE_EVENT (" btm_ble_multi_adv_set_random_addr");
+
+ memset(param, 0, BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR_LEN);
+
+ UINT8_TO_STREAM (pp, BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR);
+ BDADDR_TO_STREAM(pp, random_addr);
+ UINT8_TO_STREAM(pp, p_inst->inst_id);
+
+ if ((rt = BTM_VendorSpecificCommand (HCI_BLE_MULTI_ADV_OCF,
+ BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR_LEN,
+ param,
+ btm_ble_multi_adv_vsc_cmpl_cback)) == BTM_CMD_STARTED)
+ {
+ /* start a periodical timer to refresh random addr */
+ btu_stop_timer(&p_inst->raddr_timer_ent);
+ p_inst->raddr_timer_ent.param = (TIMER_PARAM_TYPE) p_inst;
+ btu_start_timer (&p_inst->raddr_timer_ent, BTU_TTYPE_BLE_RANDOM_ADDR,
+ BTM_BLE_PRIVATE_ADDR_INT);
+
+ btm_ble_multi_adv_enq_op_q(BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR, p_inst->inst_id, 0);
+ }
+ return rt;
+}
+
+/*******************************************************************************
+**
+** Function btm_ble_multi_adv_gen_rpa_cmpl
+**
+** Description RPA generation completion callback for each adv instance. Will
+** continue write the new RPA into controller.
+**
+** Returns none.
+**
+*******************************************************************************/
+void btm_ble_multi_adv_gen_rpa_cmpl(tBTM_RAND_ENC *p, tBTM_BLE_MULTI_ADV_INST *p_inst )
+{
+#if (SMP_INCLUDED == TRUE)
+ tBTM_LE_RANDOM_CB *p_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
+ tSMP_ENC output;
+
+ BTM_TRACE_EVENT ("btm_ble_multi_adv_gen_rpa_cmpl inst_id = %d", p_inst->inst_id);
+ if (p)
+ {
+ p->param_buf[2] &= (~BLE_RESOLVE_ADDR_MASK);
+ p->param_buf[2] |= BLE_RESOLVE_ADDR_MSB;
+
+ p_inst->rpa[2] = p->param_buf[0];
+ p_inst->rpa[1] = p->param_buf[1];
+ p_inst->rpa[0] = p->param_buf[2];
+
+ if (!SMP_Encrypt(btm_cb.devcb.id_keys.irk, BT_OCTET16_LEN, p->param_buf, 3, &output))
+ {
+ BTM_TRACE_DEBUG("generate random address failed");
+ }
+ else
+ {
+ /* set hash to be LSB of rpAddress */
+ p_inst->rpa[5] = output.param_buf[0];
+ p_inst->rpa[4] = output.param_buf[1];
+ p_inst->rpa[3] = output.param_buf[2];
+
+ if (p_inst->inst_id != 0)
+ {
+ /* set it to controller */
+ btm_ble_multi_adv_write_rpa(p_inst, p_inst->rpa);
+ }
+ }
+ }
+#endif
+}
+
+/*******************************************************************************
+**
+** Function btm_ble_multi_adv_gen_rpa_cmpl1
+**
+** Description RPA generation completion callback for each adv instance. Will
+** continue write the new RPA into controller.
+**
+** Returns none.
+**
+*******************************************************************************/
+static void btm_ble_multi_adv_gen_rpa_cmpl_1(tBTM_RAND_ENC *p)
+{
+ btm_ble_multi_adv_gen_rpa_cmpl(p, &btm_multi_adv_cb.adv_inst[0]);
+}
+
+/*******************************************************************************
+**
+** Function btm_ble_multi_adv_gen_rpa_cmpl2
+**
+** Description RPA generation completion callback for each adv instance. Will
+** continue write the new RPA into controller.
+**
+** Returns none.
+**
+*******************************************************************************/
+static void btm_ble_multi_adv_gen_rpa_cmpl_2(tBTM_RAND_ENC *p)
+{
+ btm_ble_multi_adv_gen_rpa_cmpl(p, &btm_multi_adv_cb.adv_inst[1]);
+}
+
+/*******************************************************************************
+**
+** Function btm_ble_multi_adv_gen_rpa_cmpl3
+**
+** Description RPA generation completion callback for each adv instance. Will
+** continue write the new RPA into controller.
+**
+** Returns none.
+**
+*******************************************************************************/
+static void btm_ble_multi_adv_gen_rpa_cmpl_3(tBTM_RAND_ENC *p)
+{
+ btm_ble_multi_adv_gen_rpa_cmpl(p, &btm_multi_adv_cb.adv_inst[2]);
+}
+
+/*******************************************************************************
+**
+** Function btm_ble_multi_adv_gen_rpa_cmpl4
+**
+** Description RPA generation completion callback for each adv instance. Will
+** continue write the new RPA into controller.
+**
+** Returns none.
+**
+*******************************************************************************/
+static void btm_ble_multi_adv_gen_rpa_cmpl_4(tBTM_RAND_ENC *p)
+{
+ btm_ble_multi_adv_gen_rpa_cmpl(p, &btm_multi_adv_cb.adv_inst[3]);
+}
+/*******************************************************************************
+**
+** Function btm_ble_multi_adv_configure_rpa
+**
+** Description This function set the random address for the adv instance
+**
+** Parameters advertise parameters used for this instance.
+**
+** Returns none
+**
+*******************************************************************************/
+void btm_ble_multi_adv_configure_rpa (tBTM_BLE_MULTI_ADV_INST *p_inst)
+{
+ btm_gen_resolvable_private_addr((void *)p_inst->p_rpa_cback);
+}
+
+/*******************************************************************************
+**
+** Function btm_ble_multi_adv_reenable
+**
+** Description This function re-enable adv instance upon a connection establishment.
+**
+** Parameters advertise parameters used for this instance.
+**
+** Returns none.
+**
+*******************************************************************************/
+void btm_ble_multi_adv_reenable(UINT8 inst_id)
+{
+ tBTM_BLE_MULTI_ADV_INST *p_inst = &btm_multi_adv_cb.adv_inst[inst_id - 1];
+
+ if (p_inst->inst_id != 0)
+ {
+ if (p_inst->adv_evt != BTM_BLE_CONNECT_DIR_EVT)
+ btm_ble_enable_multi_adv (TRUE, p_inst->inst_id, 0);
+ else
+ /* mark directed adv as disabled if adv has been stopped */
+ {
+ (p_inst->p_cback)(BTM_BLE_MULTI_ADV_DISABLE_EVT,p_inst->inst_id,p_inst->p_ref,0);
+ p_inst->inst_id = 0;
+ }
+ }
+}
+
+/*******************************************************************************
+**
+** Function btm_ble_multi_adv_enb_privacy
+**
+** Description This function enable/disable privacy setting in multi adv
+**
+** Parameters enable: enable or disable the adv instance.
+**
+** Returns none.
+**
+*******************************************************************************/
+void btm_ble_multi_adv_enb_privacy(BOOLEAN enable)
+{
+ UINT8 i;
+ tBTM_BLE_MULTI_ADV_INST *p_inst = &btm_multi_adv_cb.adv_inst[0];
+
+ for (i = 0; i < BTM_BLE_MULTI_ADV_MAX; i ++, p_inst++)
+ {
+ if (enable)
+ btm_ble_multi_adv_configure_rpa (p_inst);
+ else
+ btu_stop_timer(&p_inst->raddr_timer_ent);
+ }
+}
+
+/*******************************************************************************
+**
+** Function BTM_BleEnableAdvInstance
+**
+** Description This function enable a Multi-ADV instance with the specified
+** adv parameters
+**
+** Parameters p_params: pointer to the adv parameter structure, set as default
+** adv parameter when the instance is enabled.
+** p_cback: callback function for the adv instance.
+** p_ref: reference data attach to the adv instance to be enabled.
+**
+** Returns status
+**
+*******************************************************************************/
+tBTM_STATUS BTM_BleEnableAdvInstance (tBTM_BLE_ADV_PARAMS *p_params,
+ tBTM_BLE_MULTI_ADV_CBACK *p_cback,void *p_ref)
+{
+ UINT8 i;
+ tBTM_STATUS rt = BTM_NO_RESOURCES;
+ tBTM_BLE_MULTI_ADV_INST *p_inst = &btm_multi_adv_cb.adv_inst[0];
+
+ BTM_TRACE_EVENT("BTM_BleEnableAdvInstance called");
+
+ if (btm_multi_adv_cb.adv_inst_max == 0)
+ {
+ BTM_TRACE_ERROR("Controller does not support Multi ADV");
+ return BTM_ERR_PROCESSING;
+ }
+
+ for (i = 0; i < BTM_BLE_MULTI_ADV_MAX; i ++, p_inst++)
+ {
+ if (p_inst->inst_id == 0)
+ {
+ p_inst->inst_id = i + 1;
+
+ /* configure adv parameter */
+ if (p_params)
+ btm_ble_multi_adv_set_params(p_inst, p_params, 0);
+
+ /* enable adv */
+ BTM_TRACE_EVENT("btm_ble_enable_multi_adv being called with inst_id:%d",
+ p_inst->inst_id);
+ if ((rt = btm_ble_enable_multi_adv (TRUE, p_inst->inst_id, BTM_BLE_MULTI_ADV_ENB_EVT))
+ == BTM_CMD_STARTED)
+ {
+ p_inst->p_cback = p_cback;
+ p_inst->p_ref = p_ref;
+ }
+ else
+ {
+ p_inst->inst_id = 0;
+ BTM_TRACE_ERROR("BTM_BleEnableAdvInstance failed, no resources");
+ }
+ break;
+ }
+ }
+ return rt;
+}
+
+/*******************************************************************************
+**
+** Function BTM_BleUpdateAdvInstParam
+**
+** Description This function update a Multi-ADV instance with the specified
+** adv parameters.
+**
+** Parameters inst_id: adv instance ID
+** p_params: pointer to the adv parameter structure.
+**
+** Returns status
+**
+*******************************************************************************/
+tBTM_STATUS BTM_BleUpdateAdvInstParam (UINT8 inst_id, tBTM_BLE_ADV_PARAMS *p_params)
+{
+ tBTM_STATUS rt = BTM_ILLEGAL_VALUE;
+ tBTM_BLE_MULTI_ADV_INST *p_inst = &btm_multi_adv_cb.adv_inst[inst_id - 1];
+
+ BTM_TRACE_EVENT("BTM_BleUpdateAdvInstParam called with inst_id:%d", inst_id);
+
+ if (btm_multi_adv_cb.adv_inst_max == 0)
+ {
+ BTM_TRACE_ERROR("Controller does not support Multi ADV");
+ return BTM_ERR_PROCESSING;
+ }
+
+ if (inst_id <= BTM_BLE_MULTI_ADV_MAX &&
+ inst_id != BTM_BLE_MULTI_ADV_DEFAULT_STD &&
+ p_params != NULL)
+ {
+ if (p_inst->inst_id == 0)
+ {
+ BTM_TRACE_DEBUG("adv instance %d is not active", inst_id);
+ return BTM_WRONG_MODE;
+ }
+ else
+ btm_ble_enable_multi_adv(FALSE, inst_id, 0);
+
+ btm_ble_multi_adv_set_params(p_inst, p_params, 0);
+
+ rt = btm_ble_enable_multi_adv(TRUE, inst_id, BTM_BLE_MULTI_ADV_PARAM_EVT);
+ }
+ return rt;
+}
+
+/*******************************************************************************
+**
+** Function BTM_BleCfgAdvInstData
+**
+** Description This function configure a Multi-ADV instance with the specified
+** adv data or scan response data.
+**
+** Parameters inst_id: adv instance ID
+** is_scan_rsp: is this scacn response, if no set as adv data.
+** data_mask: adv data mask.
+** p_data: pointer to the adv data structure.
+**
+** Returns status
+**
+*******************************************************************************/
+tBTM_STATUS BTM_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
+ tBTM_BLE_AD_MASK data_mask,
+ tBTM_BLE_ADV_DATA *p_data)
+{
+ UINT8 param[BTM_BLE_MULTI_ADV_WRITE_DATA_LEN], *pp = param;
+ UINT8 sub_code = (is_scan_rsp) ?
+ BTM_BLE_MULTI_ADV_WRITE_SCAN_RSP_DATA : BTM_BLE_MULTI_ADV_WRITE_ADV_DATA;
+ UINT8 *p_len;
+ tBTM_STATUS rt;
+ UINT8 *pp_temp = (UINT8*)(param + BTM_BLE_MULTI_ADV_WRITE_DATA_LEN -1);
+
+ if (btm_multi_adv_cb.adv_inst_max == 0)
+ {
+ BTM_TRACE_ERROR("Controller does not support Multi ADV");
+ return BTM_ERR_PROCESSING;
+ }
+
+ BTM_TRACE_EVENT("BTM_BleCfgAdvInstData called with inst_id:%d", inst_id);
+ if (inst_id > BTM_BLE_MULTI_ADV_MAX || inst_id == BTM_BLE_MULTI_ADV_DEFAULT_STD)
+ return BTM_ILLEGAL_VALUE;
+
+ memset(param, 0, BTM_BLE_MULTI_ADV_WRITE_DATA_LEN);
+
+ UINT8_TO_STREAM(pp, sub_code);
+ p_len = pp ++;
+ btm_ble_build_adv_data(&data_mask, &pp, p_data);
+ *p_len = (UINT8)(pp - param - 2);
+ UINT8_TO_STREAM(pp_temp, inst_id);
+
+ if ((rt = BTM_VendorSpecificCommand (HCI_BLE_MULTI_ADV_OCF,
+ (UINT8)BTM_BLE_MULTI_ADV_WRITE_DATA_LEN,
+ param,
+ btm_ble_multi_adv_vsc_cmpl_cback))
+ == BTM_CMD_STARTED)
+ {
+ btm_ble_multi_adv_enq_op_q(sub_code, inst_id, BTM_BLE_MULTI_ADV_DATA_EVT);
+ }
+ return rt;
+}
+
+/*******************************************************************************
+**
+** Function BTM_BleDisableAdvInstance
+**
+** Description This function disables a Multi-ADV instance.
+**
+** Parameters inst_id: adv instance ID
+**
+** Returns status
+**
+*******************************************************************************/
+tBTM_STATUS BTM_BleDisableAdvInstance (UINT8 inst_id)
+{
+ tBTM_STATUS rt = BTM_ILLEGAL_VALUE;
+
+ BTM_TRACE_EVENT("BTM_BleDisableAdvInstance with inst_id:%d", inst_id);
+
+ if (btm_multi_adv_cb.adv_inst_max == 0)
+ {
+ BTM_TRACE_ERROR("Controller does not support Multi ADV");
+ return BTM_ERR_PROCESSING;
+ }
+
+ if (inst_id <= BTM_BLE_MULTI_ADV_MAX && inst_id != BTM_BLE_MULTI_ADV_DEFAULT_STD)
+ {
+ if ((rt = btm_ble_enable_multi_adv(FALSE, inst_id, BTM_BLE_MULTI_ADV_DISABLE_EVT))
+ == BTM_CMD_STARTED)
+ {
+ btu_stop_timer(&btm_multi_adv_cb.adv_inst[inst_id-1].raddr_timer_ent);
+ btm_ble_multi_adv_configure_rpa(&btm_multi_adv_cb.adv_inst[inst_id-1]);
+ btm_multi_adv_cb.adv_inst[inst_id-1].inst_id = 0;
+ }
+ }
+ return rt;
+}
+/*******************************************************************************
+**
+** Function btm_ble_multi_adv_vse_cback
+**
+** Description VSE callback for multi adv events.
+**
+** Returns
+**
+*******************************************************************************/
+void btm_ble_multi_adv_vse_cback(UINT8 len, UINT8 *p)
+{
+ UINT8 sub_event;
+ UINT8 adv_inst, reason, conn_handle;
+
+ /* Check if this is a BLE RSSI vendor specific event */
+ STREAM_TO_UINT8(sub_event, p);
+ len--;
+
+ BTM_TRACE_EVENT("btm_ble_multi_adv_vse_cback called with event:%d", sub_event);
+ if ((sub_event == HCI_VSE_SUBCODE_BLE_MULTI_ADV_ST_CHG) && (len>=4))
+ {
+ STREAM_TO_UINT8(adv_inst, p);
+ STREAM_TO_UINT8(reason, p);
+ STREAM_TO_UINT16(conn_handle, p);
+
+ if (adv_inst <= BTM_BLE_MULTI_ADV_MAX && adv_inst != BTM_BLE_MULTI_ADV_DEFAULT_STD)
+ {
+ BTM_TRACE_EVENT("btm_ble_multi_adv_reenable called");
+ btm_ble_multi_adv_reenable(adv_inst);
+ }
+ /* re-enable connectibility */
+ else if (adv_inst == BTM_BLE_MULTI_ADV_DEFAULT_STD)
+ {
+ if (btm_cb.ble_ctr_cb.inq_var.connectable_mode == BTM_BLE_CONNECTABLE)
+ {
+ btm_ble_set_connectability ( btm_cb.ble_ctr_cb.inq_var.connectable_mode );
+
+ }
+ }
+
+ }
+
+}
+/*******************************************************************************
+**
+** Function btm_ble_multi_adv_init
+**
+** Description This function initialize the multi adv control block.
+**
+** Parameters
+**
+** Returns status
+**
+*******************************************************************************/
+void btm_ble_multi_adv_init(void)
+{
+ UINT8 i;
+
+ memset(&btm_multi_adv_cb, 0, sizeof(tBTM_BLE_MULTI_ADV_CB));
+
+ for (i = 0; i < BTM_BLE_MULTI_ADV_MAX; i ++)
+ btm_multi_adv_cb.adv_inst[i].p_rpa_cback = btm_ble_multi_adv_rpa_cmpl[i];
+
+ BTM_RegisterForVSEvents(btm_ble_multi_adv_vse_cback, TRUE);
+}
+#endif
+#endif
+
diff --git a/stack/btm/btm_dev.c b/stack/btm/btm_dev.c
index fbf4df1..bdc5906 100644
--- a/stack/btm/btm_dev.c
+++ b/stack/btm/btm_dev.c
@@ -64,7 +64,7 @@
int i, j;
BOOLEAN found = FALSE;
- BTM_TRACE_API2("%s, link key type:%x", __FUNCTION__,key_type);
+ BTM_TRACE_API("%s, link key type:%x", __FUNCTION__,key_type);
p_dev_rec = btm_find_dev (bd_addr);
if (!p_dev_rec)
{
@@ -137,7 +137,7 @@
if (link_key)
{
- BTM_TRACE_EVENT6 ("BTM_SecAddDevice() BDA: %02x:%02x:%02x:%02x:%02x:%02x",
+ BTM_TRACE_EVENT ("BTM_SecAddDevice() BDA: %02x:%02x:%02x:%02x:%02x:%02x",
bd_addr[0], bd_addr[1], bd_addr[2],
bd_addr[3], bd_addr[4], bd_addr[5]);
p_dev_rec->sec_flags |= BTM_SEC_LINK_KEY_KNOWN;
@@ -175,7 +175,7 @@
if (BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_LE) || BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_BR_EDR))
{
- BTM_TRACE_WARNING0("BTM_SecDeleteDevice FAILED: Cannot Delete when connection is active");
+ BTM_TRACE_WARNING("BTM_SecDeleteDevice FAILED: Cannot Delete when connection is active");
return(FALSE);
}
@@ -226,7 +226,7 @@
tBTM_SEC_DEV_REC *p_dev_rec = NULL;
tBTM_INQ_INFO *p_inq_info;
int i;
- BTM_TRACE_EVENT0 ("btm_sec_alloc_dev");
+ BTM_TRACE_EVENT ("btm_sec_alloc_dev");
for (i = 0; i < BTM_SEC_MAX_DEVICE_RECORDS; i++)
{
if (!(btm_cb.sec_dev_rec[i].sec_flags & BTM_SEC_IN_USE))
@@ -336,7 +336,7 @@
{
if (HCI_SWITCH_SUPPORTED(p_dev_rec->features[HCI_EXT_FEATURES_PAGE_0]))
{
- BTM_TRACE_DEBUG0("btm_dev_support_switch return TRUE (feature found)");
+ BTM_TRACE_DEBUG("btm_dev_support_switch return TRUE (feature found)");
return (TRUE);
}
@@ -353,12 +353,12 @@
/* If we don't know peer's capabilities, assume it supports Role-switch */
if (feature_empty)
{
- BTM_TRACE_DEBUG0("btm_dev_support_switch return TRUE (feature empty)");
+ BTM_TRACE_DEBUG("btm_dev_support_switch return TRUE (feature empty)");
return (TRUE);
}
}
- BTM_TRACE_DEBUG0("btm_dev_support_switch return FALSE");
+ BTM_TRACE_DEBUG("btm_dev_support_switch return FALSE");
return(FALSE);
}
@@ -430,7 +430,7 @@
tBTM_SEC_DEV_REC *btm_find_or_alloc_dev (BD_ADDR bd_addr)
{
tBTM_SEC_DEV_REC *p_dev_rec;
- BTM_TRACE_EVENT0 ("btm_find_or_alloc_dev");
+ BTM_TRACE_EVENT ("btm_find_or_alloc_dev");
if ((p_dev_rec = btm_find_dev (bd_addr)) == NULL)
{
diff --git a/stack/btm/btm_devctl.c b/stack/btm/btm_devctl.c
index 8117c45..c837c16 100644
--- a/stack/btm/btm_devctl.c
+++ b/stack/btm/btm_devctl.c
@@ -175,7 +175,7 @@
#endif
#else
- BTM_TRACE_EVENT0 ("BTM_AUTOMATIC_HCI_RESET is FALSE, so skip btm reset for now");
+ BTM_TRACE_EVENT ("BTM_AUTOMATIC_HCI_RESET is FALSE, so skip btm reset for now");
#endif
}
@@ -319,7 +319,7 @@
*******************************************************************************/
tBTM_STATUS BTM_SetAfhChannels (UINT8 first, UINT8 last)
{
- BTM_TRACE_API4 ("BTM_SetAfhChannels first: %d (%d) last: %d (%d)",
+ BTM_TRACE_API ("BTM_SetAfhChannels first: %d (%d) last: %d (%d)",
first, btm_cb.first_disabled_channel, last,
btm_cb.last_disabled_channel);
@@ -441,7 +441,7 @@
*******************************************************************************/
void btm_read_ble_wl_size(void)
{
- BTM_TRACE_DEBUG0("btm_read_ble_wl_size ");
+ BTM_TRACE_DEBUG("btm_read_ble_wl_size ");
btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
/* Send a Read Buffer Size message to the Host Controller. */
@@ -458,7 +458,7 @@
*******************************************************************************/
void btm_get_ble_buffer_size(void)
{
- BTM_TRACE_DEBUG0("btm_get_ble_buffer_size ");
+ BTM_TRACE_DEBUG("btm_get_ble_buffer_size ");
btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
/* Send a Read Buffer Size message to the Host Controller. */
@@ -477,7 +477,7 @@
*******************************************************************************/
static void btm_read_ble_local_supported_features(void)
{
- BTM_TRACE_DEBUG0("btm_read_ble_local_supported_features ");
+ BTM_TRACE_DEBUG("btm_read_ble_local_supported_features ");
btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
/* Send a Read Local Supported Features message to the Host Controller. */
@@ -496,7 +496,7 @@
*******************************************************************************/
static void btm_read_ble_local_supported_states(void)
{
- BTM_TRACE_DEBUG0("btm_read_ble_local_supported_states ");
+ BTM_TRACE_DEBUG("btm_read_ble_local_supported_states ");
btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
/* Send a Read Local Supported states message to the Host Controller. */
@@ -538,7 +538,7 @@
*******************************************************************************/
static void btm_read_local_supported_cmds (UINT8 local_controller_id)
{
- BTM_TRACE_DEBUG0("Start reading local supported commands");
+ BTM_TRACE_DEBUG("Start reading local supported commands");
btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
@@ -632,7 +632,7 @@
{
int devinx;
- BTM_TRACE_EVENT0 ("btm_reset_complete");
+ BTM_TRACE_EVENT ("btm_reset_complete");
/* Handle if btm initiated the reset */
if (btm_cb.devcb.state == BTM_DEV_STATE_WAIT_RESET_CMPLT)
@@ -671,6 +671,7 @@
btm_cb.ble_ctr_cb.p_select_cback = NULL;
memset(&btm_cb.ble_ctr_cb.bg_dev_list, 0, (sizeof(tBTM_LE_BG_CONN_DEV)*BTM_BLE_MAX_BG_CONN_DEV_NUM));
gatt_reset_bgdev_list();
+ btm_ble_multi_adv_init();
#endif
}
}
@@ -813,7 +814,7 @@
UINT16 lm_num_le_bufs;
UNUSED(evt_len);
- BTM_TRACE_DEBUG0("btm_read_ble_buf_size_complete ");
+ BTM_TRACE_DEBUG("btm_read_ble_buf_size_complete ");
STREAM_TO_UINT8 (status, p);
if (status == HCI_SUCCESS)
{
@@ -844,7 +845,7 @@
UINT8 status;
UNUSED(evt_len);
- BTM_TRACE_DEBUG0("btm_read_ble_local_supported_states_complete ");
+ BTM_TRACE_DEBUG("btm_read_ble_local_supported_states_complete ");
btu_stop_timer (&btm_cb.devcb.reset_timer);
@@ -855,7 +856,7 @@
}
else
{
- BTM_TRACE_WARNING1 ("btm_read_ble_local_supported_features_complete status = %d", status);
+ BTM_TRACE_WARNING ("btm_read_ble_local_supported_features_complete status = %d", status);
}
btm_read_ble_local_supported_features();
@@ -877,7 +878,7 @@
UINT8 status;
UNUSED(evt_len);
- BTM_TRACE_DEBUG0("btm_read_ble_local_supported_features_complete ");
+ BTM_TRACE_DEBUG("btm_read_ble_local_supported_features_complete ");
btu_stop_timer (&btm_cb.devcb.reset_timer);
@@ -888,7 +889,7 @@
}
else
{
- BTM_TRACE_WARNING1 ("btm_read_ble_local_supported_features_complete status = %d", status);
+ BTM_TRACE_WARNING ("btm_read_ble_local_supported_features_complete status = %d", status);
}
btsnd_hcic_ble_set_evt_mask((UINT8 *)HCI_BLE_EVENT_MASK_DEF);
@@ -917,7 +918,7 @@
UINT8 status;
UNUSED(evt_len);
- BTM_TRACE_DEBUG0("btm_read_white_list_size_complete ");
+ BTM_TRACE_DEBUG("btm_read_white_list_size_complete ");
STREAM_TO_UINT8 (status, p);
if (status == HCI_SUCCESS)
@@ -988,7 +989,7 @@
UINT8 last;
UINT8 first;
- BTM_TRACE_DEBUG1 ("btm_decode_ext_features_page page: %d", page_number);
+ BTM_TRACE_DEBUG ("btm_decode_ext_features_page page: %d", page_number);
switch (page_number)
{
/* Extended (Legacy) Page 0 */
@@ -1039,7 +1040,7 @@
}
}
- BTM_TRACE_DEBUG1("Local supported ACL packet types: 0x%04x",
+ BTM_TRACE_DEBUG("Local supported ACL packet types: 0x%04x",
btm_cb.btm_acl_pkt_types_supported);
/* Create (e)SCO supported packet types mask */
@@ -1096,7 +1097,7 @@
}
#endif
- BTM_TRACE_DEBUG1("Local supported SCO packet types: 0x%04x",
+ BTM_TRACE_DEBUG("Local supported SCO packet types: 0x%04x",
btm_cb.btm_sco_pkt_types_supported);
/* Create Default Policy Settings */
@@ -1155,7 +1156,7 @@
break;
default:
- BTM_TRACE_ERROR1("btm_decode_ext_features_page page=%d unknown", page_number);
+ BTM_TRACE_ERROR("btm_decode_ext_features_page page=%d unknown", page_number);
break;
}
}
@@ -1196,11 +1197,11 @@
}
if (!found)
- BTM_TRACE_WARNING0 ("btm_reset_ctrlr_complete: NONE of local controller features is set");
+ BTM_TRACE_WARNING ("btm_reset_ctrlr_complete: NONE of local controller features is set");
max_page_number = i;
- BTM_TRACE_DEBUG1 ("btm_reset_ctrlr_complete: max_page_number: %d", max_page_number);
+ BTM_TRACE_DEBUG ("btm_reset_ctrlr_complete: max_page_number: %d", max_page_number);
/*
* Set State to Ready (needs to be done before btm_decode_ext_features_page
@@ -1244,7 +1245,7 @@
*******************************************************************************/
static void btm_issue_host_support_for_lmp_features (void)
{
- BTM_TRACE_DEBUG1("btm_issue_host_support_for_lmp_features lmp_features_host_may_support: 0x%02x", btm_cb.devcb.lmp_features_host_may_support);
+ BTM_TRACE_DEBUG("btm_issue_host_support_for_lmp_features lmp_features_host_may_support: 0x%02x", btm_cb.devcb.lmp_features_host_may_support);
if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_SSP)
{
@@ -1294,7 +1295,7 @@
return;
}
- BTM_TRACE_ERROR2("%s lmp_features_host_may_support: 0x%02x. This is unexpected.",__FUNCTION__,
+ BTM_TRACE_ERROR("%s lmp_features_host_may_support: 0x%02x. This is unexpected.",__FUNCTION__,
btm_cb.devcb.lmp_features_host_may_support);
}
@@ -1402,7 +1403,7 @@
/* if local controller has extended features and supports
**HCI_Read_Local_Extended_Features command,
** then start reading these feature starting with extended features page 1 */
- BTM_TRACE_DEBUG0 ("Start reading local extended features");
+ BTM_TRACE_DEBUG ("Start reading local extended features");
btm_get_local_ext_features(HCI_EXT_FEATURES_PAGE_1);
}
else
@@ -1437,7 +1438,7 @@
if (status != HCI_SUCCESS)
{
- BTM_TRACE_WARNING1("btm_read_local_ext_features_complete status = 0x%02X", status);
+ BTM_TRACE_WARNING("btm_read_local_ext_features_complete status = 0x%02X", status);
btm_read_all_lmp_features_complete (HCI_EXT_FEATURES_PAGE_0);
return;
}
@@ -1450,7 +1451,7 @@
if (page_number > HCI_EXT_FEATURES_PAGE_MAX)
{
- BTM_TRACE_ERROR1("btm_read_local_ext_features_complete page=%d unknown",
+ BTM_TRACE_ERROR("btm_read_local_ext_features_complete page=%d unknown",
page_number);
return;
}
@@ -1473,7 +1474,7 @@
if ((page_number == page_number_max) ||
(page_number == HCI_EXT_FEATURES_PAGE_MAX))
{
- BTM_TRACE_DEBUG1("BTM reached last extended features page (%d)", page_number);
+ BTM_TRACE_DEBUG("BTM reached last extended features page (%d)", page_number);
btm_read_all_lmp_features_complete(page_number);
}
/* Else (another page must be read) */
@@ -1481,7 +1482,7 @@
{
/* Read the next features page */
page_number++;
- BTM_TRACE_DEBUG1("BTM reads next extended features page (%d)", page_number);
+ BTM_TRACE_DEBUG("BTM reads next extended features page (%d)", page_number);
btm_get_local_ext_features(page_number);
}
}
@@ -1504,7 +1505,7 @@
btu_stop_timer (&(p_devcb->reset_timer));
STREAM_TO_UINT8 (status, p);
- BTM_TRACE_DEBUG1("btm_read_local_supported_cmds_complete status (0x%02x)", status);
+ BTM_TRACE_DEBUG("btm_read_local_supported_cmds_complete status (0x%02x)", status);
if (status == HCI_SUCCESS)
{
@@ -1534,7 +1535,7 @@
if (status != HCI_SUCCESS)
{
- BTM_TRACE_WARNING1("btm_write_simple_paring_mode_complete status: 0x%02x", status);
+ BTM_TRACE_WARNING("btm_write_simple_paring_mode_complete status: 0x%02x", status);
}
if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_SSP)
@@ -1563,7 +1564,7 @@
if (status != HCI_SUCCESS)
{
- BTM_TRACE_WARNING1("btm_write_le_host_supported_complete status: 0x%02x", status);
+ BTM_TRACE_WARNING("btm_write_le_host_supported_complete status: 0x%02x", status);
}
if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_LE)
@@ -1875,7 +1876,7 @@
if (page_number <= HCI_EXT_FEATURES_PAGE_MAX)
return (btm_cb.devcb.local_lmp_features[page_number]);
- BTM_TRACE_ERROR1("Warning: BTM_ReadLocalExtendedFeatures page %d unknown",
+ BTM_TRACE_ERROR("Warning: BTM_ReadLocalExtendedFeatures page %d unknown",
page_number);
return NULL;
}
@@ -1936,7 +1937,7 @@
{
void *p_buf;
- BTM_TRACE_EVENT2 ("BTM: BTM_VendorSpecificCommand: Opcode: 0x%04X, ParamLen: %i.",
+ BTM_TRACE_EVENT ("BTM: BTM_VendorSpecificCommand: Opcode: 0x%04X, ParamLen: %i.",
opcode, param_len);
/* Allocate a buffer to hold HCI command plus the callback function */
@@ -2018,7 +2019,7 @@
if (is_register == FALSE)
{
btm_cb.devcb.p_vend_spec_cb[i] = NULL;
- BTM_TRACE_EVENT0("BTM Deregister For VSEvents is successfully");
+ BTM_TRACE_EVENT("BTM Deregister For VSEvents is successfully");
}
return (BTM_SUCCESS);
}
@@ -2030,12 +2031,12 @@
if (free_idx < BTM_MAX_VSE_CALLBACKS)
{
btm_cb.devcb.p_vend_spec_cb[free_idx] = p_cb;
- BTM_TRACE_EVENT0("BTM Register For VSEvents is successfully");
+ BTM_TRACE_EVENT("BTM Register For VSEvents is successfully");
}
else
{
/* No free entries available */
- BTM_TRACE_ERROR0 ("BTM_RegisterForVSEvents: too many callbacks registered");
+ BTM_TRACE_ERROR ("BTM_RegisterForVSEvents: too many callbacks registered");
retval = BTM_NO_RESOURCES;
}
@@ -2060,7 +2061,7 @@
{
UINT8 i;
- BTM_TRACE_DEBUG0 ("BTM Event: Vendor Specific event from controller");
+ BTM_TRACE_DEBUG ("BTM Event: Vendor Specific event from controller");
for (i=0; i<BTM_MAX_VSE_CALLBACKS; i++)
{
@@ -2084,7 +2085,7 @@
*******************************************************************************/
tBTM_STATUS BTM_WritePageTimeout(UINT16 timeout)
{
- BTM_TRACE_EVENT1 ("BTM: BTM_WritePageTimeout: Timeout: %d.", timeout);
+ BTM_TRACE_EVENT ("BTM: BTM_WritePageTimeout: Timeout: %d.", timeout);
/* Send the HCI command */
if (btsnd_hcic_write_page_tout (timeout))
@@ -2108,7 +2109,7 @@
*******************************************************************************/
tBTM_STATUS BTM_WriteVoiceSettings(UINT16 settings)
{
- BTM_TRACE_EVENT1 ("BTM: BTM_WriteVoiceSettings: Settings: 0x%04x.", settings);
+ BTM_TRACE_EVENT ("BTM: BTM_WriteVoiceSettings: Settings: 0x%04x.", settings);
/* Send the HCI command */
if (btsnd_hcic_write_voice_settings ((UINT16)(settings & 0x03ff)))
@@ -2136,7 +2137,7 @@
{
UINT8 cond;
- BTM_TRACE_EVENT0 ("BTM: BTM_EnableTestMode");
+ BTM_TRACE_EVENT ("BTM: BTM_EnableTestMode");
/* set auto accept connection as this is needed during test mode */
/* Allocate a buffer to hold HCI command */
@@ -2223,7 +2224,7 @@
bd_addr = local_bd_addr;
}
- BTM_TRACE_EVENT1 ("BTM: BTM_ReadStoredLinkKey: Read_All: %s",
+ BTM_TRACE_EVENT ("BTM: BTM_ReadStoredLinkKey: Read_All: %s",
read_all_flag ? "TRUE" : "FALSE");
/* Send the HCI command */
@@ -2260,7 +2261,7 @@
if (btm_cb.devcb.p_stored_link_key_cmpl_cb)
return (BTM_BUSY);
- BTM_TRACE_EVENT1 ("BTM: BTM_WriteStoredLinkKey: num_keys: %d", num_keys);
+ BTM_TRACE_EVENT ("BTM: BTM_WriteStoredLinkKey: num_keys: %d", num_keys);
/* Check the maximum number of link keys */
if(num_keys > HCI_MAX_NUM_OF_LINK_KEYS_PER_CMMD)
@@ -2307,7 +2308,7 @@
bd_addr = local_bd_addr;
}
- BTM_TRACE_EVENT1 ("BTM: BTM_DeleteStoredLinkKey: delete_all_flag: %s",
+ BTM_TRACE_EVENT ("BTM: BTM_DeleteStoredLinkKey: delete_all_flag: %s",
delete_all_flag ? "TRUE" : "FALSE");
/* Send the HCI command */
@@ -2353,7 +2354,7 @@
}
else
{
- BTM_TRACE_WARNING1("Read stored link key status %d", result.status);
+ BTM_TRACE_WARNING("Read stored link key status %d", result.status);
result.max_keys = 0;
result.read_keys = 0;
}
diff --git a/stack/btm/btm_inq.c b/stack/btm/btm_inq.c
index 01cbd56..e5d2cdf 100644
--- a/stack/btm/btm_inq.c
+++ b/stack/btm/btm_inq.c
@@ -183,7 +183,7 @@
BOOLEAN is_limited;
BOOLEAN cod_limited;
- BTM_TRACE_API0 ("BTM_SetDiscoverability");
+ BTM_TRACE_API ("BTM_SetDiscoverability");
#if (BLE_INCLUDED == TRUE && BLE_INCLUDED == TRUE)
if (HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
{
@@ -212,7 +212,7 @@
if (!interval)
interval = BTM_DEFAULT_DISC_INTERVAL;
- BTM_TRACE_API3 ("BTM_SetDiscoverability: mode %d [NonDisc-0, Lim-1, Gen-2], window 0x%04x, interval 0x%04x",
+ BTM_TRACE_API ("BTM_SetDiscoverability: mode %d [NonDisc-0, Lim-1, Gen-2], window 0x%04x, interval 0x%04x",
inq_mode, window, interval);
/*** Check for valid window and interval parameters ***/
@@ -311,7 +311,7 @@
tBTM_STATUS BTM_SetInquiryScanType (UINT16 scan_type)
{
- BTM_TRACE_API0 ("BTM_SetInquiryScanType");
+ BTM_TRACE_API ("BTM_SetInquiryScanType");
if (scan_type != BTM_SCAN_TYPE_STANDARD && scan_type != BTM_SCAN_TYPE_INTERLACED)
return (BTM_ILLEGAL_VALUE);
@@ -348,7 +348,7 @@
*******************************************************************************/
tBTM_STATUS BTM_SetPageScanType (UINT16 scan_type)
{
- BTM_TRACE_API0 ("BTM_SetPageScanType");
+ BTM_TRACE_API ("BTM_SetPageScanType");
if (scan_type != BTM_SCAN_TYPE_STANDARD && scan_type != BTM_SCAN_TYPE_INTERLACED)
return (BTM_ILLEGAL_VALUE);
@@ -389,7 +389,7 @@
*******************************************************************************/
tBTM_STATUS BTM_SetInquiryMode (UINT8 mode)
{
- BTM_TRACE_API0 ("BTM_SetInquiryMode");
+ BTM_TRACE_API ("BTM_SetInquiryMode");
if (mode == BTM_INQ_RESULT_STANDARD)
{
/* mandatory mode */
@@ -434,7 +434,7 @@
*******************************************************************************/
UINT16 BTM_ReadDiscoverability (UINT16 *p_window, UINT16 *p_interval)
{
- BTM_TRACE_API0 ("BTM_ReadDiscoverability");
+ BTM_TRACE_API ("BTM_ReadDiscoverability");
if (p_window)
*p_window = btm_cb.btm_inq_vars.inq_scan_window;
@@ -480,7 +480,7 @@
tBTM_STATUS status;
tBTM_INQUIRY_VAR_ST *p_inq = &btm_cb.btm_inq_vars;
- BTM_TRACE_API6 ("BTM_SetPeriodicInquiryMode: mode: %d, dur: %d, rsps: %d, flt: %d, min: %d, max: %d",
+ BTM_TRACE_API ("BTM_SetPeriodicInquiryMode: mode: %d, dur: %d, rsps: %d, flt: %d, min: %d, max: %d",
p_inqparms->mode, p_inqparms->duration, p_inqparms->max_resps,
p_inqparms->filter_cond_type, min_delay, max_delay);
@@ -524,7 +524,7 @@
(BTM_GENERAL_INQUIRY_ACTIVE | BTM_PERIODIC_INQUIRY_ACTIVE));
#if (defined(BTM_BYPASS_EVENT_FILTERING) && BTM_BYPASS_EVENT_FILTERING == TRUE)
- BTM_TRACE_WARNING0("BTM: Bypassing event filtering...");
+ BTM_TRACE_WARNING("BTM: Bypassing event filtering...");
p_inq->state = BTM_INQ_ACTIVE_STATE;
p_inq->inqfilt_active = FALSE;
@@ -573,7 +573,7 @@
{
tBTM_INQUIRY_VAR_ST *p_inq = &btm_cb.btm_inq_vars;
tBTM_STATUS status = BTM_SUCCESS;
- BTM_TRACE_API0 ("BTM_CancelPeriodicInquiry called");
+ BTM_TRACE_API ("BTM_CancelPeriodicInquiry called");
/*** Make sure the device is ready ***/
if (!BTM_IsDeviceUp())
@@ -619,7 +619,7 @@
UINT8 scan_mode = 0;
tBTM_INQUIRY_VAR_ST *p_inq = &btm_cb.btm_inq_vars;
- BTM_TRACE_API0 ("BTM_SetConnectability");
+ BTM_TRACE_API ("BTM_SetConnectability");
#if (BLE_INCLUDED == TRUE && BLE_INCLUDED == TRUE)
if (HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
@@ -649,7 +649,7 @@
if (!interval)
interval = BTM_DEFAULT_CONN_INTERVAL;
- BTM_TRACE_API3 ("BTM_SetConnectability: mode %d [NonConn-0, Conn-1], window 0x%04x, interval 0x%04x",
+ BTM_TRACE_API ("BTM_SetConnectability: mode %d [NonConn-0, Conn-1], window 0x%04x, interval 0x%04x",
page_mode, window, interval);
/*** Check for valid window and interval parameters ***/
@@ -708,7 +708,7 @@
*******************************************************************************/
UINT16 BTM_ReadConnectability (UINT16 *p_window, UINT16 *p_interval)
{
- BTM_TRACE_API0 ("BTM_ReadConnectability");
+ BTM_TRACE_API ("BTM_ReadConnectability");
if (p_window)
*p_window = btm_cb.btm_inq_vars.page_scan_window;
@@ -734,7 +734,7 @@
*******************************************************************************/
UINT16 BTM_IsInquiryActive (void)
{
- BTM_TRACE_API0 ("BTM_IsInquiryActive");
+ BTM_TRACE_API ("BTM_IsInquiryActive");
return(btm_cb.btm_inq_vars.inq_active);
}
@@ -759,7 +759,7 @@
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
UINT8 active_mode=p_inq->inq_active;
#endif
- BTM_TRACE_API0 ("BTM_CancelInquiry called");
+ BTM_TRACE_API ("BTM_CancelInquiry called");
/*** Make sure the device is ready ***/
if (!BTM_IsDeviceUp())
@@ -853,7 +853,7 @@
tBTM_STATUS status = BTM_CMD_STARTED;
tBTM_INQUIRY_VAR_ST *p_inq = &btm_cb.btm_inq_vars;
- BTM_TRACE_API4 ("BTM_StartInquiry: mode: %d, dur: %d, rsps: %d, flt: %d",
+ BTM_TRACE_API ("BTM_StartInquiry: mode: %d, dur: %d, rsps: %d, flt: %d",
p_inqparms->mode, p_inqparms->duration, p_inqparms->max_resps,
p_inqparms->filter_cond_type);
@@ -865,7 +865,7 @@
/*check if LE observe is already running*/
if(p_inq->scan_type==INQ_LE_OBSERVE && p_inq->p_inq_ble_results_cb!=NULL)
{
- BTM_TRACE_API0("BTM_StartInquiry: LE observe in progress");
+ BTM_TRACE_API("BTM_StartInquiry: LE observe in progress");
p_inq->scan_type = INQ_GENERAL;
p_inq->inq_active = BTM_INQUIRY_INACTIVE;
btm_cb.ble_ctr_cb.inq_var.scan_type = BTM_BLE_SCAN_MODE_NONE;
@@ -875,7 +875,7 @@
#endif
{
return (BTM_BUSY);
- BTM_TRACE_API0("BTM_StartInquiry: return BUSY");
+ BTM_TRACE_API("BTM_StartInquiry: return BUSY");
}
}
else
@@ -910,7 +910,7 @@
p_inq->inq_cmpl_info.num_resp = 0; /* Clear the results counter */
p_inq->inq_active = p_inqparms->mode;
- BTM_TRACE_DEBUG1("BTM_StartInquiry: p_inq->inq_active = 0x%02x", p_inq->inq_active);
+ BTM_TRACE_DEBUG("BTM_StartInquiry: p_inq->inq_active = 0x%02x", p_inq->inq_active);
/* interleave scan minimal conditions */
#if (BLE_INCLUDED==TRUE && (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE))
@@ -918,13 +918,13 @@
/* check if both modes are present */
if((p_inqparms->mode & BTM_BLE_INQUIRY_MASK) && (p_inqparms->mode & BTM_BR_INQUIRY_MASK))
{
- BTM_TRACE_API0("BTM:Interleave Inquiry Mode Set");
+ BTM_TRACE_API("BTM:Interleave Inquiry Mode Set");
p_inqparms->duration=p_inqparms->intl_duration[p_inq->next_state];
p_inq->inqparms.duration=p_inqparms->duration;
}
else
{
- BTM_TRACE_API1("BTM:Single Mode: No interleaving, Mode:0x%02x", p_inqparms->mode);
+ BTM_TRACE_API("BTM:Single Mode: No interleaving, Mode:0x%02x", p_inqparms->mode);
p_inq->next_state=BTM_NO_INTERLEAVING;
}
#endif
@@ -943,7 +943,7 @@
{
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
p_inq->inq_active = (p_inqparms->mode & BTM_BLE_INQUIRY_MASK);
- BTM_TRACE_API2("BTM:Starting LE Scan with duration %d and activeMode:0x%02x",
+ BTM_TRACE_API("BTM:Starting LE Scan with duration %d and activeMode:0x%02x",
p_inqparms->duration, (p_inqparms->mode & BTM_BLE_INQUIRY_MASK));
#endif
if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
@@ -955,7 +955,7 @@
else if ((status = btm_ble_start_inquiry((UINT8)(p_inqparms->mode & BTM_BLE_INQUIRY_MASK),
p_inqparms->duration)) != BTM_CMD_STARTED)
{
- BTM_TRACE_ERROR0("Err Starting LE Inquiry.");
+ BTM_TRACE_ERROR("Err Starting LE Inquiry.");
p_inq->inqparms.mode &= ~ BTM_BLE_INQUIRY_MASK;
}
#if (!defined(BTA_HOST_INTERLEAVE_SEARCH) || BTA_HOST_INTERLEAVE_SEARCH == FALSE)
@@ -969,7 +969,7 @@
}
else
{
- BTM_TRACE_API1("BTM:Interleaving: started LE scan, Advancing to next state: %d",
+ BTM_TRACE_API("BTM:Interleaving: started LE scan, Advancing to next state: %d",
p_inq->next_state+1);
p_inq->next_state+=1;
}
@@ -982,7 +982,7 @@
#endif
- BTM_TRACE_DEBUG1("BTM_StartInquiry: mode = %02x", p_inqparms->mode);
+ BTM_TRACE_DEBUG("BTM_StartInquiry: mode = %02x", p_inqparms->mode);
}
#endif /* end of BLE_INCLUDED */
@@ -998,7 +998,7 @@
p_inq->inq_active = (p_inqparms->mode & BTM_BR_INQUIRY_MASK);
#endif
#if (defined(BTM_BYPASS_EVENT_FILTERING) && BTM_BYPASS_EVENT_FILTERING == TRUE)
- BTM_TRACE_WARNING0("BTM: Bypassing event filtering...");
+ BTM_TRACE_WARNING("BTM: Bypassing event filtering...");
p_inq->inqfilt_active = FALSE;
btm_initiate_inquiry (p_inq);
status = BTM_CMD_STARTED;
@@ -1037,7 +1037,7 @@
p_inq->next_state=BTM_FINISH;
else
{
- BTM_TRACE_API1("BTM:Interleaving: Started BTM inq, Advancing to next state: %d",
+ BTM_TRACE_API("BTM:Interleaving: Started BTM inq, Advancing to next state: %d",
p_inq->next_state+1);
p_inq->next_state+=1;
}
@@ -1047,7 +1047,7 @@
/* Some error beginning the scan process.
Reset the next_state parameter.. Do we need to reset the inq_active also?
*/
- BTM_TRACE_API1("BTM:Interleaving: Error in Starting inquiry, status: 0x%02x", status);
+ BTM_TRACE_API("BTM:Interleaving: Error in Starting inquiry, status: 0x%02x", status);
p_inq->next_state=BTM_BR_ONE;
}
#endif
@@ -1085,7 +1085,7 @@
tBTM_INQ_INFO *p_cur = NULL;
tINQ_DB_ENT *p_i;
- BTM_TRACE_API6 ("BTM_ReadRemoteDeviceName: bd addr [%02x%02x%02x%02x%02x%02x]",
+ BTM_TRACE_API ("BTM_ReadRemoteDeviceName: bd addr [%02x%02x%02x%02x%02x%02x]",
remote_bda[0], remote_bda[1], remote_bda[2],
remote_bda[3], remote_bda[4], remote_bda[5]);
@@ -1098,7 +1098,7 @@
p_cur->remote_name_state = BTM_INQ_RMT_NAME_EMPTY;
#endif
}
- BTM_TRACE_API0 ("no device found in inquiry db");
+ BTM_TRACE_API ("no device found in inquiry db");
#if (BLE_INCLUDED == TRUE)
if (transport == BT_TRANSPORT_LE)
@@ -1132,7 +1132,7 @@
{
tBTM_INQUIRY_VAR_ST *p_inq = &btm_cb.btm_inq_vars;
- BTM_TRACE_API0 ("BTM_CancelRemoteDeviceName()");
+ BTM_TRACE_API ("BTM_CancelRemoteDeviceName()");
/* Make sure there is not already one in progress */
if (p_inq->remname_active)
@@ -1237,7 +1237,7 @@
UINT16 xx;
tINQ_DB_ENT *p_ent = btm_cb.btm_inq_vars.inq_db;
- BTM_TRACE_API6 ("BTM_InqDbRead: bd addr [%02x%02x%02x%02x%02x%02x]",
+ BTM_TRACE_API ("BTM_InqDbRead: bd addr [%02x%02x%02x%02x%02x%02x]",
p_bda[0], p_bda[1], p_bda[2], p_bda[3], p_bda[4], p_bda[5]);
for (xx = 0; xx < BTM_INQ_DB_SIZE; xx++, p_ent++)
@@ -1583,7 +1583,7 @@
UINT8 normal_active = (BTM_GENERAL_INQUIRY_ACTIVE|BTM_LIMITED_INQUIRY_ACTIVE);
#if (BTM_INQ_DEBUG == TRUE)
- BTM_TRACE_DEBUG4 ("btm_inq_stop_on_ssp: no_inc_ssp=%d inq_active:0x%x state:%d inqfilt_active:%d",
+ BTM_TRACE_DEBUG ("btm_inq_stop_on_ssp: no_inc_ssp=%d inq_active:0x%x state:%d inqfilt_active:%d",
btm_cb.btm_inq_vars.no_inc_ssp, btm_cb.btm_inq_vars.inq_active, btm_cb.btm_inq_vars.state, btm_cb.btm_inq_vars.inqfilt_active);
#endif
if (btm_cb.btm_inq_vars.no_inc_ssp)
@@ -1639,7 +1639,7 @@
UINT16 xx;
#if (BTM_INQ_DEBUG == TRUE)
- BTM_TRACE_DEBUG2 ("btm_clr_inq_db: inq_active:0x%x state:%d",
+ BTM_TRACE_DEBUG ("btm_clr_inq_db: inq_active:0x%x state:%d",
btm_cb.btm_inq_vars.inq_active, btm_cb.btm_inq_vars.state);
#endif
for (xx = 0; xx < BTM_INQ_DB_SIZE; xx++, p_ent++)
@@ -1661,7 +1661,7 @@
}
}
#if (BTM_INQ_DEBUG == TRUE)
- BTM_TRACE_DEBUG2 ("inq_active:0x%x state:%d",
+ BTM_TRACE_DEBUG ("inq_active:0x%x state:%d",
btm_cb.btm_inq_vars.inq_active, btm_cb.btm_inq_vars.state);
#endif
}
@@ -1847,9 +1847,9 @@
UINT8 *p_cond = condition_buf; /* points to the condition to pass to HCI */
#if (BTM_INQ_DEBUG == TRUE)
- BTM_TRACE_DEBUG1 ("btm_set_inq_event_filter: filter type %d [Clear-0, COD-1, BDADDR-2]",
+ BTM_TRACE_DEBUG ("btm_set_inq_event_filter: filter type %d [Clear-0, COD-1, BDADDR-2]",
filter_cond_type);
- BTM_TRACE_DEBUG6 (" condition [%02x%02x%02x %02x%02x%02x]",
+ BTM_TRACE_DEBUG (" condition [%02x%02x%02x %02x%02x%02x]",
p_filt_cond->bdaddr_cond[0], p_filt_cond->bdaddr_cond[1], p_filt_cond->bdaddr_cond[2],
p_filt_cond->bdaddr_cond[3], p_filt_cond->bdaddr_cond[4], p_filt_cond->bdaddr_cond[5]);
#endif
@@ -1911,7 +1911,7 @@
tBTM_CMPL_CB *p_cb = p_inq->p_inqfilter_cmpl_cb;
#if (BTM_INQ_DEBUG == TRUE)
- BTM_TRACE_DEBUG3 ("btm_event_filter_complete: inq_active:0x%x state:%d inqfilt_active:%d",
+ BTM_TRACE_DEBUG ("btm_event_filter_complete: inq_active:0x%x state:%d inqfilt_active:%d",
btm_cb.btm_inq_vars.inq_active, btm_cb.btm_inq_vars.state, btm_cb.btm_inq_vars.inqfilt_active);
#endif
/* If the filter complete event is from an old or cancelled request, ignore it */
@@ -1930,7 +1930,7 @@
if (hci_status != HCI_SUCCESS)
{
/* If standalone operation, return the error status; if embedded in the inquiry, continue the inquiry */
- BTM_TRACE_WARNING1 ("BTM Warning: Set Event Filter Failed (HCI returned 0x%x)", hci_status);
+ BTM_TRACE_WARNING ("BTM Warning: Set Event Filter Failed (HCI returned 0x%x)", hci_status);
status = BTM_ERR_PROCESSING;
}
else
@@ -2010,7 +2010,7 @@
tBTM_INQ_PARMS *p_inqparms = &p_inq->inqparms;
#if (BTM_INQ_DEBUG == TRUE)
- BTM_TRACE_DEBUG3 ("btm_initiate_inquiry: inq_active:0x%x state:%d inqfilt_active:%d",
+ BTM_TRACE_DEBUG ("btm_initiate_inquiry: inq_active:0x%x state:%d inqfilt_active:%d",
btm_cb.btm_inq_vars.inq_active, btm_cb.btm_inq_vars.state, btm_cb.btm_inq_vars.inqfilt_active);
#endif
#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
@@ -2046,7 +2046,7 @@
{
p_inq->max_bd_entries = (UINT16)(GKI_MAX_BUF_SIZE / sizeof(tINQ_BDADDR));
memset(p_inq->p_bd_db, 0, GKI_MAX_BUF_SIZE);
-/* BTM_TRACE_DEBUG1("btm_initiate_inquiry: memory allocated for %d bdaddrs",
+/* BTM_TRACE_DEBUG("btm_initiate_inquiry: memory allocated for %d bdaddrs",
p_inq->max_bd_entries); */
}
@@ -2098,7 +2098,7 @@
#endif
#if (BTM_INQ_DEBUG == TRUE)
- BTM_TRACE_DEBUG3 ("btm_process_inq_results inq_active:0x%x state:%d inqfilt_active:%d",
+ BTM_TRACE_DEBUG ("btm_process_inq_results inq_active:0x%x state:%d inqfilt_active:%d",
btm_cb.btm_inq_vars.inq_active, btm_cb.btm_inq_vars.state, btm_cb.btm_inq_vars.inqfilt_active);
#endif
/* Only process the results if the BR inquiry is still active */
@@ -2147,7 +2147,7 @@
)
{
-/* BTM_TRACE_WARNING0("INQ RES: Extra Response Received...ignoring"); */
+/* BTM_TRACE_WARNING("INQ RES: Extra Response Received...ignoring"); */
return;
}
#endif
@@ -2155,7 +2155,7 @@
/* Check if this address has already been processed for this inquiry */
if (btm_inq_find_bdaddr(bda))
{
-/* BTM_TRACE_DEBUG6("BDA seen before [%02x%02x %02x%02x %02x%02x]",
+/* BTM_TRACE_DEBUG("BDA seen before [%02x%02x %02x%02x %02x%02x]",
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);*/
/* By default suppose no update needed */
i_rssi = (INT8)rssi;
@@ -2170,7 +2170,7 @@
))
{
p_cur = &p_i->inq_info.results;
- BTM_TRACE_DEBUG2("update RSSI new:%d, old:%d", i_rssi, p_cur->rssi);
+ BTM_TRACE_DEBUG("update RSSI new:%d, old:%d", i_rssi, p_cur->rssi);
p_cur->rssi = i_rssi;
update = TRUE;
}
@@ -2261,7 +2261,7 @@
#endif
)
{
-/* BTM_TRACE_DEBUG0("BTMINQ: Found devices, cancelling inquiry..."); */
+/* BTM_TRACE_DEBUG("BTMINQ: Found devices, cancelling inquiry..."); */
btsnd_hcic_inq_cancel();
#if BLE_INCLUDED == TRUE
@@ -2432,7 +2432,7 @@
#if (BTM_INQ_DEBUG == TRUE)
- BTM_TRACE_DEBUG3 ("btm_process_inq_complete inq_active:0x%x state:%d inqfilt_active:%d",
+ BTM_TRACE_DEBUG ("btm_process_inq_complete inq_active:0x%x state:%d inqfilt_active:%d",
btm_cb.btm_inq_vars.inq_active, btm_cb.btm_inq_vars.state, btm_cb.btm_inq_vars.inqfilt_active);
#endif
#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
@@ -2486,7 +2486,7 @@
p_inq->p_inq_cmpl_cb = (tBTM_CMPL_CB *) NULL;
/* If we have a callback registered for inquiry complete, call it */
- BTM_TRACE_DEBUG2 ("BTM Inq Compl Callback: status 0x%02x, num results %d",
+ BTM_TRACE_DEBUG ("BTM Inq Compl Callback: status 0x%02x, num results %d",
p_inq->inq_cmpl_info.status, p_inq->inq_cmpl_info.num_resp);
if (p_inq_cb)
@@ -2509,13 +2509,13 @@
/* check if the LE observe is pending */
if(p_inq->p_inq_ble_results_cb != NULL)
{
- BTM_TRACE_DEBUG0("BTM Inq Compl: resuming a pending LE scan");
+ BTM_TRACE_DEBUG("BTM Inq Compl: resuming a pending LE scan");
BTM_BleObserve(1,0, p_inq->p_inq_ble_results_cb, p_inq->p_inq_ble_cmpl_cb);
}
#endif
}
#if (BTM_INQ_DEBUG == TRUE)
- BTM_TRACE_DEBUG3 ("inq_active:0x%x state:%d inqfilt_active:%d",
+ BTM_TRACE_DEBUG ("inq_active:0x%x state:%d inqfilt_active:%d",
btm_cb.btm_inq_vars.inq_active, btm_cb.btm_inq_vars.state, btm_cb.btm_inq_vars.inqfilt_active);
#endif
}
@@ -2685,12 +2685,12 @@
if (bda != NULL)
{
- BTM_TRACE_EVENT6("BDA %02x:%02x:%02x:%02x:%02x:%02x",bda[0], bda[1],
+ BTM_TRACE_EVENT("BDA %02x:%02x:%02x:%02x:%02x:%02x",bda[0], bda[1],
bda[2], bda[3],
bda[4], bda[5]);
}
- BTM_TRACE_EVENT6("Inquire BDA %02x:%02x:%02x:%02x:%02x:%02x",p_inq->remname_bda[0], p_inq->remname_bda[1],
+ BTM_TRACE_EVENT("Inquire BDA %02x:%02x:%02x:%02x:%02x:%02x",p_inq->remname_bda[0], p_inq->remname_bda[1],
p_inq->remname_bda[2], p_inq->remname_bda[3],
p_inq->remname_bda[4], p_inq->remname_bda[5]);
@@ -2856,7 +2856,7 @@
*******************************************************************************/
void btm_inq_rmt_name_failed (void)
{
- BTM_TRACE_ERROR1 ("btm_inq_rmt_name_failed() remname_active=%d", btm_cb.btm_inq_vars.remname_active);
+ BTM_TRACE_ERROR ("btm_inq_rmt_name_failed() remname_active=%d", btm_cb.btm_inq_vars.remname_active);
if (btm_cb.btm_inq_vars.remname_active)
btm_process_remote_name (btm_cb.btm_inq_vars.remname_bda, NULL, 0, HCI_ERR_UNSPECIFIED);
@@ -2892,7 +2892,7 @@
results.status = BTM_SUCCESS;
STREAM_TO_UINT8 (results.tx_power, p);
- BTM_TRACE_EVENT2 ("BTM INQ TX POWER Complete: tx_power %d, hci status 0x%02x",
+ BTM_TRACE_EVENT ("BTM INQ TX POWER Complete: tx_power %d, hci status 0x%02x",
results.tx_power, results.hci_status);
}
else
@@ -2920,7 +2920,7 @@
#if (BTM_EIR_SERVER_INCLUDED == TRUE)
if (HCI_EXT_INQ_RSP_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
{
- BTM_TRACE_API0("Write Extended Inquiry Response to controller");
+ BTM_TRACE_API("Write Extended Inquiry Response to controller");
btsnd_hcic_write_ext_inquiry_response (p_buff, BTM_EIR_DEFAULT_FEC_REQUIRED);
return BTM_SUCCESS;
}
@@ -2954,7 +2954,7 @@
UINT8 *p = p_eir;
UINT8 length;
UINT8 eir_type;
- BTM_TRACE_API1("BTM_CheckEirData type=0x%02X", type);
+ BTM_TRACE_API("BTM_CheckEirData type=0x%02X", type);
STREAM_TO_UINT8(length, p);
while( length && (p - p_eir <= HCI_EXT_INQ_RESPONSE_LEN))
@@ -3196,19 +3196,19 @@
if( *p_num_uuid > max_num_uuid )
{
- BTM_TRACE_WARNING2("BTM_GetEirUuidList number of uuid in EIR = %d, size of uuid list = %d",
+ BTM_TRACE_WARNING("BTM_GetEirUuidList number of uuid in EIR = %d, size of uuid list = %d",
*p_num_uuid, max_num_uuid );
*p_num_uuid = max_num_uuid;
}
- BTM_TRACE_DEBUG2("BTM_GetEirUuidList type = %02X, number of uuid = %d", type, *p_num_uuid );
+ BTM_TRACE_DEBUG("BTM_GetEirUuidList type = %02X, number of uuid = %d", type, *p_num_uuid );
if( uuid_size == LEN_UUID_16 )
{
for( yy = 0; yy < *p_num_uuid; yy++ )
{
STREAM_TO_UINT16(*(p_uuid16 + yy), p_uuid_data);
- BTM_TRACE_DEBUG1(" 0x%04X", *(p_uuid16 + yy));
+ BTM_TRACE_DEBUG(" 0x%04X", *(p_uuid16 + yy));
}
}
else if( uuid_size == LEN_UUID_32 )
@@ -3216,7 +3216,7 @@
for( yy = 0; yy < *p_num_uuid; yy++ )
{
STREAM_TO_UINT32(*(p_uuid32 + yy), p_uuid_data);
- BTM_TRACE_DEBUG1(" 0x%08X", *(p_uuid32 + yy));
+ BTM_TRACE_DEBUG(" 0x%08X", *(p_uuid32 + yy));
}
}
else if( uuid_size == LEN_UUID_128 )
@@ -3226,7 +3226,7 @@
STREAM_TO_ARRAY16(p_uuid_list + yy * LEN_UUID_128, p_uuid_data);
for( xx = 0; xx < LEN_UUID_128; xx++ )
sprintf(buff + xx*2, "%02X", *(p_uuid_list + yy * LEN_UUID_128 + xx));
- BTM_TRACE_DEBUG1(" 0x%s", buff);
+ BTM_TRACE_DEBUG(" 0x%s", buff);
}
}
@@ -3349,7 +3349,7 @@
}
break;
default:
- BTM_TRACE_WARNING0("btm_convert_uuid_to_uuid16 invalid uuid size");
+ BTM_TRACE_WARNING("btm_convert_uuid_to_uuid16 invalid uuid size");
break;
}
@@ -3387,7 +3387,7 @@
p_results->eir_complete_list = FALSE;
}
- BTM_TRACE_API1("btm_set_eir_uuid eir_complete_list=0x%02X", p_results->eir_complete_list);
+ BTM_TRACE_API("btm_set_eir_uuid eir_complete_list=0x%02X", p_results->eir_complete_list);
if( p_uuid_data )
{
diff --git a/stack/btm/btm_int.h b/stack/btm/btm_int.h
index 913e253..d115c3d 100644
--- a/stack/btm/btm_int.h
+++ b/stack/btm/btm_int.h
@@ -222,7 +222,7 @@
UINT8 state;
tBTM_IO_CAP loc_io_caps; /* IO capability of the local device */
- BOOLEAN loc_auth_req; /* the auth_req flag */
+ tBTM_AUTH_REQ loc_auth_req; /* the auth_req flag */
BD_FEATURES brcm_features; /* Broadcom specific features bit mask */
#define BTM_RELOAD_LE_HOST_FEATURE 0x10
@@ -516,9 +516,11 @@
#define BTM_BLE_ADDR_PSEUDO 0 /* address index device record */
#define BTM_BLE_ADDR_RRA 1 /* cur_rand_addr */
-#define BTM_BLE_ADDR_STATIC 2 /* static_addr */
-
+#define BTM_BLE_ADDR_RECONN 2 /* reconnection address */
+#define BTM_BLE_ADDR_STATIC 3 /* static_addr */
UINT8 active_addr_type;
+
+ BOOLEAN privacy_enabled; /* remote device privacy enabled or not */
#endif
#if SMP_INCLUDED == TRUE
@@ -601,7 +603,7 @@
#define BTM_SM4_CONN_PEND 0x40 /* set this bit to indicate accepting acl conn; to be cleared on btm_acl_created */
UINT8 sm4; /* BTM_SM4_TRUE, if the peer supports SM4 */
tBTM_IO_CAP rmt_io_caps; /* IO capability of the peer device */
- BOOLEAN rmt_auth_req; /* the auth_req flag as in the IO caps rsp evt */
+ tBTM_AUTH_REQ rmt_auth_req; /* the auth_req flag as in the IO caps rsp evt */
#if (BLE_INCLUDED == TRUE)
UINT16 ble_hci_handle; /* use in DUMO connection */
@@ -846,6 +848,7 @@
BT_OCTET8 enc_rand; /* received rand value from LTK request*/
UINT16 ediv; /* received ediv value from LTK request */
UINT8 key_size;
+ tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
#endif
/* Packet types supported by the local device */
diff --git a/stack/btm/btm_pm.c b/stack/btm/btm_pm.c
index 711a69b..93e55ee 100644
--- a/stack/btm/btm_pm.c
+++ b/stack/btm/btm_pm.c
@@ -197,7 +197,7 @@
if(p_mode == NULL)
return BTM_ILLEGAL_VALUE;
- BTM_TRACE_API3( "BTM_SetPowerMode: pm_id %d BDA: %08x mode:0x%x", pm_id,
+ BTM_TRACE_API( "BTM_SetPowerMode: pm_id %d BDA: %08x mode:0x%x", pm_id,
(remote_bda[2]<<24)+(remote_bda[3]<<16)+(remote_bda[4]<<8)+remote_bda[5], p_mode->mode);
/* take out the force bit */
@@ -225,7 +225,7 @@
((p_mode->mode & BTM_PM_MD_FORCE) && (p_mode->max >= p_cb->interval) && (p_mode->min <= p_cb->interval)) ||
((p_mode->mode & BTM_PM_MD_FORCE)==0 && (p_mode->max >= p_cb->interval)) )
{
- BTM_TRACE_DEBUG4( "BTM_SetPowerMode: mode:0x%x interval %d max:%d, min:%d", p_mode->mode, p_cb->interval, p_mode->max, p_mode->min);
+ BTM_TRACE_DEBUG( "BTM_SetPowerMode: mode:0x%x interval %d max:%d, min:%d", p_mode->mode, p_cb->interval, p_mode->max, p_mode->min);
return BTM_SUCCESS;
}
}
@@ -240,7 +240,7 @@
|| ((pm_id == BTM_PM_SET_ONLY_ID) && (btm_cb.pm_pend_link != MAX_L2CAP_LINKS)) )
{
#if BTM_PM_DEBUG == TRUE
- BTM_TRACE_DEBUG2( "BTM_SetPowerMode: Saving cmd acl_ind %d temp_pm_id %d", acl_ind,temp_pm_id);
+ BTM_TRACE_DEBUG( "BTM_SetPowerMode: Saving cmd acl_ind %d temp_pm_id %d", acl_ind,temp_pm_id);
#endif
/* Make sure mask is set to BTM_PM_REG_SET */
btm_cb.pm_reg_db[temp_pm_id].mask |= BTM_PM_REG_SET;
@@ -249,7 +249,7 @@
}
#if BTM_PM_DEBUG == TRUE
- BTM_TRACE_DEBUG2( "btm_pm state:0x%x, pm_pend_link: %d", p_cb->state, btm_cb.pm_pend_link);
+ BTM_TRACE_DEBUG( "btm_pm state:0x%x, pm_pend_link: %d", p_cb->state, btm_cb.pm_pend_link);
#endif
/* if mode == hold or pending, return */
if( (p_cb->state == BTM_PM_STS_HOLD) ||
@@ -260,7 +260,7 @@
{
/* set the stored mask */
p_cb->state |= BTM_PM_STORED_MASK;
- BTM_TRACE_DEBUG1( "btm_pm state stored:%d",acl_ind);
+ BTM_TRACE_DEBUG( "btm_pm state stored:%d",acl_ind);
}
return BTM_CMD_STORED;
}
@@ -399,7 +399,7 @@
memset (p_db, 0, sizeof(tBTM_PM_MCB));
p_db->state = BTM_PM_ST_ACTIVE;
#if BTM_PM_DEBUG == TRUE
- BTM_TRACE_DEBUG2( "btm_pm_sm_alloc ind:%d st:%d", ind, p_db->state);
+ BTM_TRACE_DEBUG( "btm_pm_sm_alloc ind:%d st:%d", ind, p_db->state);
#endif
}
@@ -427,7 +427,7 @@
)
{
#if BTM_PM_DEBUG == TRUE
- BTM_TRACE_DEBUG2( "btm_pm_find_acl_ind ind:%d, st:%d", xx, btm_cb.pm_mode_db[xx].state);
+ BTM_TRACE_DEBUG( "btm_pm_find_acl_ind ind:%d, st:%d", xx, btm_cb.pm_mode_db[xx].state);
#endif
break;
}
@@ -591,7 +591,7 @@
md_res.mode = mode;
#if BTM_PM_DEBUG == TRUE
- BTM_TRACE_DEBUG2( "btm_pm_snd_md_req link_ind:%d, mode: %d",
+ BTM_TRACE_DEBUG( "btm_pm_snd_md_req link_ind:%d, mode: %d",
link_ind, mode);
#endif
@@ -627,7 +627,7 @@
btm_cb.pm_pend_id = pm_id;
#if BTM_PM_DEBUG == TRUE
- BTM_TRACE_DEBUG2("btm_pm_snd_md_req state:0x%x, link_ind: %d", p_cb->state, link_ind);
+ BTM_TRACE_DEBUG("btm_pm_snd_md_req state:0x%x, link_ind: %d", p_cb->state, link_ind);
#endif
switch(md_res.mode)
{
@@ -685,7 +685,7 @@
{
/* the command was not sent */
#if BTM_PM_DEBUG == TRUE
- BTM_TRACE_DEBUG1( "pm_pend_link: %d",btm_cb.pm_pend_link);
+ BTM_TRACE_DEBUG( "pm_pend_link: %d",btm_cb.pm_pend_link);
#endif
return (BTM_NO_RESOURCES);
}
@@ -712,7 +712,7 @@
if(btm_cb.pm_mode_db[xx].state & BTM_PM_STORED_MASK)
{
btm_cb.pm_mode_db[xx].state &= ~BTM_PM_STORED_MASK;
- BTM_TRACE_DEBUG1( "btm_pm_check_stored :%d", xx);
+ BTM_TRACE_DEBUG( "btm_pm_check_stored :%d", xx);
btm_pm_snd_md_req(BTM_PM_SET_ONLY_ID, xx, NULL);
break;
}
@@ -747,7 +747,7 @@
p_cb->state = BTM_PM_ST_PENDING;
pm_status = BTM_PM_STS_PENDING;
#if BTM_PM_DEBUG == TRUE
- BTM_TRACE_DEBUG1( "btm_pm_proc_cmd_status new state:0x%x", p_cb->state);
+ BTM_TRACE_DEBUG( "btm_pm_proc_cmd_status new state:0x%x", p_cb->state);
#endif
}
else /* the command was not successfull. Stay in the same state */
@@ -764,7 +764,7 @@
/* no pending cmd now */
#if BTM_PM_DEBUG == TRUE
- BTM_TRACE_DEBUG3( "btm_pm_proc_cmd_status state:0x%x, pm_pend_link: %d(new: %d)",
+ BTM_TRACE_DEBUG( "btm_pm_proc_cmd_status state:0x%x, pm_pend_link: %d(new: %d)",
p_cb->state, btm_cb.pm_pend_link, MAX_L2CAP_LINKS);
#endif
btm_cb.pm_pend_link = MAX_L2CAP_LINKS;
@@ -807,7 +807,7 @@
{
if(p->restore_pkt_types)
{
- BTM_TRACE_DEBUG3("btm mode change AFTER unsniffing; hci hdl 0x%x, types 0x%02x/0x%02x",
+ BTM_TRACE_DEBUG("btm mode change AFTER unsniffing; hci hdl 0x%x, types 0x%02x/0x%02x",
hci_handle, p->pkt_types_mask, p->restore_pkt_types);
p->pkt_types_mask = p->restore_pkt_types;
p->restore_pkt_types = 0; /* Only exists while SCO is active */
@@ -816,7 +816,7 @@
#if (BTM_PM_SNIFF_SLOT_WORK_AROUND == TRUE)
else
{
- BTM_TRACE_DEBUG2("btm mode change AFTER unsniffing; hci hdl 0x%x, types 0x%02x",
+ BTM_TRACE_DEBUG("btm mode change AFTER unsniffing; hci hdl 0x%x, types 0x%02x",
hci_handle, btm_cb.btm_acl_pkt_types_supported);
btm_set_packet_types (p, btm_cb.btm_acl_pkt_types_supported);
}
@@ -837,7 +837,7 @@
#if (BTM_PM_SNIFF_SLOT_WORK_AROUND == TRUE)
else if (mode == HCI_MODE_SNIFF)
{
- BTM_TRACE_DEBUG1("btm mode change to sniff; hci hdl 0x%x use single slot",
+ BTM_TRACE_DEBUG("btm mode change to sniff; hci hdl 0x%x use single slot",
hci_handle);
btm_set_packet_types (p, (HCI_PKT_TYPES_MASK_DM1 | HCI_PKT_TYPES_MASK_DH1));
}
@@ -849,7 +849,7 @@
p_cb->state = mode;
p_cb->interval = interval;
#if BTM_PM_DEBUG == TRUE
- BTM_TRACE_DEBUG2( "btm_pm_proc_mode_change new state:0x%x (old:0x%x)", p_cb->state, old_state);
+ BTM_TRACE_DEBUG( "btm_pm_proc_mode_change new state:0x%x (old:0x%x)", p_cb->state, old_state);
#endif
if ((p_lcb = l2cu_find_lcb_by_bd_addr(p->remote_addr, BT_TRANSPORT_BR_EDR)) != NULL)
@@ -858,7 +858,7 @@
{
/* There might be any pending packets due to SNIFF or PENDING state */
/* Trigger L2C to start transmission of the pending packets. */
- BTM_TRACE_DEBUG0("btm mode change to active; check l2c_link for outgoing packets");
+ BTM_TRACE_DEBUG("btm mode change to active; check l2c_link for outgoing packets");
l2c_link_check_send_pkts(p_lcb, NULL, NULL);
//btu_stop_timer (&p_lcb->timer_entry);
@@ -877,7 +877,7 @@
if(old_state & BTM_PM_STORED_MASK)
{
#if BTM_PM_DEBUG == TRUE
- BTM_TRACE_DEBUG1( "btm_pm_proc_mode_change: Sending stored req:%d", xx);
+ BTM_TRACE_DEBUG( "btm_pm_proc_mode_change: Sending stored req:%d", xx);
#endif
btm_pm_snd_md_req(BTM_PM_SET_ONLY_ID, xx, NULL);
}
@@ -888,7 +888,7 @@
if(btm_cb.pm_mode_db[zz].chg_ind == TRUE)
{
#if BTM_PM_DEBUG == TRUE
- BTM_TRACE_DEBUG1( "btm_pm_proc_mode_change: Sending PM req :%d", zz);
+ BTM_TRACE_DEBUG( "btm_pm_proc_mode_change: Sending PM req :%d", zz);
#endif
btm_pm_snd_md_req(BTM_PM_SET_ONLY_ID, zz, NULL);
break;
diff --git a/stack/btm/btm_sco.c b/stack/btm/btm_sco.c
index 1ef3827..d9d0fbc 100644
--- a/stack/btm/btm_sco.c
+++ b/stack/btm/btm_sco.c
@@ -162,14 +162,14 @@
{
if (!btsnd_hcic_reject_conn (bda, hci_status))
{
- BTM_TRACE_ERROR0("Could not reject (e)SCO conn: No Buffer!!!");
+ BTM_TRACE_ERROR("Could not reject (e)SCO conn: No Buffer!!!");
}
}
else
{
if (!btsnd_hcic_reject_esco_conn (bda, hci_status))
{
- BTM_TRACE_ERROR0("Could not reject (e)SCO conn: No Buffer!!!");
+ BTM_TRACE_ERROR("Could not reject (e)SCO conn: No Buffer!!!");
}
}
}
@@ -225,7 +225,7 @@
}
else
{
- BTM_TRACE_ERROR0("Could not accept SCO conn: No Buffer!!!");
+ BTM_TRACE_ERROR("Could not accept SCO conn: No Buffer!!!");
}
}
else /* Controller is version 1.1 or earlier */
@@ -260,7 +260,7 @@
p_buf = NULL;
#if BTM_SCO_HCI_DEBUG
- BTM_TRACE_DEBUG1 ("btm: [%d] buf in xmit_data_q", p_ccb->xmit_data_q.count );
+ BTM_TRACE_DEBUG ("btm: [%d] buf in xmit_data_q", p_ccb->xmit_data_q.count );
#endif
p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->xmit_data_q);
@@ -347,7 +347,7 @@
/* Ensure we have enough space in the buffer for the SCO and HCI headers */
if (p_buf->offset < HCI_SCO_PREAMBLE_SIZE)
{
- BTM_TRACE_ERROR1 ("BTM SCO - cannot send buffer, offset: %d", p_buf->offset);
+ BTM_TRACE_ERROR ("BTM SCO - cannot send buffer, offset: %d", p_buf->offset);
GKI_freebuf (p_buf);
status = BTM_ILLEGAL_VALUE;
}
@@ -379,7 +379,7 @@
{
GKI_freebuf(p_buf);
- BTM_TRACE_WARNING2 ("BTM_WriteScoData, invalid sco index: %d at state [%d]",
+ BTM_TRACE_WARNING ("BTM_WriteScoData, invalid sco index: %d at state [%d]",
sco_inx, btm_cb.sco_cb.sco_db[sco_inx].state);
status = BTM_UNKNOWN_ADDR;
}
@@ -437,21 +437,21 @@
if (!HCI_EDR_ESCO_2MPS_SUPPORTED(p_acl->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
{
- BTM_TRACE_WARNING0("BTM Remote does not support 2-EDR eSCO");
+ BTM_TRACE_WARNING("BTM Remote does not support 2-EDR eSCO");
temp_pkt_types |= (HCI_ESCO_PKT_TYPES_MASK_NO_2_EV3 |
HCI_ESCO_PKT_TYPES_MASK_NO_2_EV5);
}
if (!HCI_EDR_ESCO_3MPS_SUPPORTED(p_acl->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
{
- BTM_TRACE_WARNING0("BTM Remote does not support 3-EDR eSCO");
+ BTM_TRACE_WARNING("BTM Remote does not support 3-EDR eSCO");
temp_pkt_types |= (HCI_ESCO_PKT_TYPES_MASK_NO_3_EV3 |
HCI_ESCO_PKT_TYPES_MASK_NO_3_EV5);
}
}
- BTM_TRACE_API6(" txbw 0x%x, rxbw 0x%x, lat 0x%x, voice 0x%x, retrans 0x%02x, pkt 0x%04x",
+ BTM_TRACE_API(" txbw 0x%x, rxbw 0x%x, lat 0x%x, voice 0x%x, retrans 0x%02x, pkt 0x%04x",
p_setup->tx_bw, p_setup->rx_bw,
p_setup->max_latency, p_setup->voice_contfmt,
p_setup->retrans_effort, temp_pkt_types);
@@ -505,7 +505,7 @@
if (sco_inx >= BTM_MAX_SCO_LINKS)
{
- BTM_TRACE_ERROR1("btm_accept_sco_link: Invalid sco_inx(%d)", sco_inx);
+ BTM_TRACE_ERROR("btm_accept_sco_link: Invalid sco_inx(%d)", sco_inx);
return;
}
@@ -515,7 +515,7 @@
p_sco->p_disc_cb = p_disc_cb;
p_sco->esco.data.link_type = BTM_LINK_TYPE_ESCO; /* Accept with all supported types */
- BTM_TRACE_DEBUG1("TCS accept SCO: Packet Types 0x%04x", p_setup->packet_types);
+ BTM_TRACE_DEBUG("TCS accept SCO: Packet Types 0x%04x", p_setup->packet_types);
btm_esco_conn_rsp(sco_inx, HCI_SUCCESS, p_sco->esco.data.bd_addr, p_setup);
#else
@@ -685,7 +685,7 @@
p_acl = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
if (p_acl && p_acl->switch_role_state != BTM_ACL_SWKEY_STATE_IDLE)
{
- BTM_TRACE_API1("Role Change is in progress for ACL handle 0x%04x",acl_handle);
+ BTM_TRACE_API("Role Change is in progress for ACL handle 0x%04x",acl_handle);
p->state = SCO_ST_PEND_ROLECHANGE;
}
@@ -696,7 +696,7 @@
{
if (is_orig)
{
- BTM_TRACE_API2("BTM_CreateSco -> (e)SCO Link for ACL handle 0x%04x, Desired Type %d",
+ BTM_TRACE_API("BTM_CreateSco -> (e)SCO Link for ACL handle 0x%04x, Desired Type %d",
acl_handle, btm_cb.sco_cb.desired_sco_mode);
if ((btm_send_connect_request(acl_handle, p_setup)) != BTM_CMD_STARTED)
@@ -743,7 +743,7 @@
((acl_handle = BTM_GetHCIConnHandle (p->esco.data.bd_addr, BT_TRANSPORT_BR_EDR)) == hci_handle))
{
- BTM_TRACE_API3("btm_sco_chk_pend_unpark -> (e)SCO Link for ACL handle 0x%04x, Desired Type %d, hci_status 0x%02x",
+ BTM_TRACE_API("btm_sco_chk_pend_unpark -> (e)SCO Link for ACL handle 0x%04x, Desired Type %d, hci_status 0x%02x",
acl_handle, btm_cb.sco_cb.desired_sco_mode, hci_status);
if ((btm_send_connect_request(acl_handle, &p->esco.setup)) == BTM_CMD_STARTED)
@@ -777,7 +777,7 @@
((acl_handle = BTM_GetHCIConnHandle (p->esco.data.bd_addr, BT_TRANSPORT_BR_EDR)) == hci_handle))
{
- BTM_TRACE_API1("btm_sco_chk_pend_rolechange -> (e)SCO Link for ACL handle 0x%04x", acl_handle);
+ BTM_TRACE_API("btm_sco_chk_pend_rolechange -> (e)SCO Link for ACL handle 0x%04x", acl_handle);
if ((btm_send_connect_request(acl_handle, &p->esco.setup)) == BTM_CMD_STARTED)
p->state = SCO_ST_CONNECTING;
@@ -878,7 +878,7 @@
#endif
/* If here, no one wants the SCO connection. Reject it */
- BTM_TRACE_WARNING0("btm_sco_conn_req: No one wants this SCO connection; rejecting it");
+ BTM_TRACE_WARNING("btm_sco_conn_req: No one wants this SCO connection; rejecting it");
btm_esco_conn_rsp(BTM_MAX_SCO_LINKS, HCI_ERR_HOST_REJECT_RESOURCES, bda, NULL);
}
@@ -921,7 +921,7 @@
/* If role switch is pending, we need try again after role switch is complete */
if(hci_status == HCI_ERR_ROLE_SWITCH_PENDING)
{
- BTM_TRACE_API1("Role Change pending for HCI handle 0x%04x",hci_handle);
+ BTM_TRACE_API("Role Change pending for HCI handle 0x%04x",hci_handle);
p->state = SCO_ST_PEND_ROLECHANGE;
}
/* avoid calling disconnect callback because of sco creation race */
@@ -1374,17 +1374,17 @@
}
}
p_esco->desired_sco_mode = sco_mode;
- BTM_TRACE_API1("BTM_SetEScoMode -> mode %d", sco_mode);
+ BTM_TRACE_API("BTM_SetEScoMode -> mode %d", sco_mode);
}
else
{
p_esco->desired_sco_mode = BTM_LINK_TYPE_SCO;
p_def->packet_types &= BTM_SCO_LINK_ONLY_MASK;
p_def->retrans_effort = 0;
- BTM_TRACE_API0("BTM_SetEScoMode -> mode SCO (eSCO not supported)");
+ BTM_TRACE_API("BTM_SetEScoMode -> mode SCO (eSCO not supported)");
}
- BTM_TRACE_DEBUG6(" txbw 0x%08x, rxbw 0x%08x, max_lat 0x%04x, voice 0x%04x, pkt 0x%04x, rtx effort 0x%02x",
+ BTM_TRACE_DEBUG(" txbw 0x%08x, rxbw 0x%08x, max_lat 0x%04x, voice 0x%04x, pkt 0x%04x, rtx effort 0x%02x",
p_def->tx_bw, p_def->rx_bw, p_def->max_latency,
p_def->voice_contfmt, p_def->packet_types,
p_def->retrans_effort);
@@ -1451,7 +1451,7 @@
#if (BTM_MAX_SCO_LINKS>0)
UINT8 index;
- BTM_TRACE_API1("BTM_ReadEScoLinkParms -> sco_inx 0x%04x", sco_inx);
+ BTM_TRACE_API("BTM_ReadEScoLinkParms -> sco_inx 0x%04x", sco_inx);
if (sco_inx < BTM_MAX_SCO_LINKS &&
btm_cb.sco_cb.sco_db[sco_inx].state >= SCO_ST_CONNECTED)
@@ -1466,7 +1466,7 @@
{
if (btm_cb.sco_cb.sco_db[index].state >= SCO_ST_CONNECTED)
{
- BTM_TRACE_API1("BTM_ReadEScoLinkParms the first active SCO index is %d",index);
+ BTM_TRACE_API("BTM_ReadEScoLinkParms the first active SCO index is %d",index);
*p_parms = btm_cb.sco_cb.sco_db[index].esco.data;
return (BTM_SUCCESS);
}
@@ -1475,7 +1475,7 @@
#endif
- BTM_TRACE_API0("BTM_ReadEScoLinkParms cannot find the SCO index!");
+ BTM_TRACE_API("BTM_ReadEScoLinkParms cannot find the SCO index!");
memset(p_parms, 0, sizeof(tBTM_ESCO_DATA));
return (BTM_WRONG_MODE);
}
@@ -1522,7 +1522,7 @@
(btm_cb.btm_sco_pkt_types_supported & BTM_SCO_LINK_ONLY_MASK);
- BTM_TRACE_API2("BTM_ChangeEScoLinkParms -> SCO Link for handle 0x%04x, pkt 0x%04x",
+ BTM_TRACE_API("BTM_ChangeEScoLinkParms -> SCO Link for handle 0x%04x, pkt 0x%04x",
p_sco->hci_handle, p_setup->packet_types);
if (!btsnd_hcic_change_conn_type (p_sco->hci_handle,
@@ -1541,8 +1541,8 @@
(btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK));
}
- BTM_TRACE_API1("BTM_ChangeEScoLinkParms -> eSCO Link for handle 0x%04x", p_sco->hci_handle);
- BTM_TRACE_API6(" txbw 0x%x, rxbw 0x%x, lat 0x%x, voice 0x%x, retrans 0x%02x, pkt 0x%04x",
+ BTM_TRACE_API("BTM_ChangeEScoLinkParms -> eSCO Link for handle 0x%04x", p_sco->hci_handle);
+ BTM_TRACE_API(" txbw 0x%x, rxbw 0x%x, lat 0x%x, voice 0x%x, retrans 0x%02x, pkt 0x%04x",
p_setup->tx_bw, p_setup->rx_bw, p_parms->max_latency,
p_setup->voice_contfmt, p_parms->retrans_effort, temp_pkt_types);
@@ -1633,7 +1633,7 @@
tBTM_CHG_ESCO_EVT_DATA data;
UINT16 xx;
- BTM_TRACE_EVENT2("btm_esco_proc_conn_chg -> handle 0x%04x, status 0x%02x",
+ BTM_TRACE_EVENT("btm_esco_proc_conn_chg -> handle 0x%04x, status 0x%02x",
handle, status);
for (xx = 0; xx < BTM_MAX_SCO_LINKS; xx++, p++)
diff --git a/stack/btm/btm_sec.c b/stack/btm/btm_sec.c
index 4f62b40..8623f35 100644
--- a/stack/btm/btm_sec.c
+++ b/stack/btm/btm_sec.c
@@ -196,17 +196,17 @@
BT_OCTET16 temp_value = {0};
#endif
- BTM_TRACE_EVENT0 ("BTM_Sec: application registered");
+ BTM_TRACE_EVENT ("BTM_Sec: application registered");
#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
if (p_cb_info->p_le_callback)
{
- BTM_TRACE_ERROR1 ("BTM_SecRegister:p_cb_info->p_le_callback == 0x%x ", p_cb_info->p_le_callback);
+ BTM_TRACE_ERROR ("BTM_SecRegister:p_cb_info->p_le_callback == 0x%x ", p_cb_info->p_le_callback);
if (p_cb_info->p_le_callback)
{
#if SMP_INCLUDED == TRUE
- BTM_TRACE_EVENT0 ("BTM_Sec: SMP_Register( btm_proc_smp_cback )");
+ BTM_TRACE_EVENT ("BTM_Sec: SMP_Register( btm_proc_smp_cback )");
SMP_Register(btm_proc_smp_cback);
#endif
/* if no IR is loaded, need to regenerate all the keys */
@@ -217,16 +217,16 @@
}
else
{
- BTM_TRACE_ERROR0 ("BTM_SecRegister:p_cb_info->p_le_callback == NULL ");
+ BTM_TRACE_ERROR ("BTM_SecRegister:p_cb_info->p_le_callback == NULL ");
}
}
#endif
btm_cb.api = *p_cb_info;
#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
- BTM_TRACE_ERROR1 ("BTM_SecRegister: btm_cb.api.p_le_callback = 0x%x ", btm_cb.api.p_le_callback);
+ BTM_TRACE_ERROR ("BTM_SecRegister: btm_cb.api.p_le_callback = 0x%x ", btm_cb.api.p_le_callback);
#endif
- BTM_TRACE_EVENT0 ("BTM_Sec: application registered");
+ BTM_TRACE_EVENT ("BTM_Sec: application registered");
return(TRUE);
}
@@ -352,7 +352,7 @@
*p_sec_flags = (UINT8) p_dev_rec->sec_flags;
return(TRUE);
}
- BTM_TRACE_ERROR0 ("BTM_GetSecurityFlags false");
+ BTM_TRACE_ERROR ("BTM_GetSecurityFlags false");
return(FALSE);
}
@@ -379,7 +379,7 @@
return(TRUE);
}
- BTM_TRACE_ERROR0 ("BTM_GetSecurityFlags false");
+ BTM_TRACE_ERROR ("BTM_GetSecurityFlags false");
return(FALSE);
}
@@ -415,7 +415,7 @@
/* the default is enabled */
break;
default:
- BTM_TRACE_ERROR1 ("BTM_SetSecurityMode: unknown mode:%d", security_mode);
+ BTM_TRACE_ERROR ("BTM_SetSecurityMode: unknown mode:%d", security_mode);
return;
}
btm_cb.security_mode = security_mode;
@@ -424,7 +424,7 @@
{
/* Lisbon devices and only use BTM_SEC_MODE_SP */
btm_cb.security_mode = BTM_SEC_MODE_SP;
- BTM_TRACE_DEBUG2("BTM_SetSecurityMode: SP:%d, debug:%d", sp_mode, sp_debug_mode);
+ BTM_TRACE_DEBUG("BTM_SetSecurityMode: SP:%d, debug:%d", sp_mode, sp_debug_mode);
btsnd_hcic_write_simple_pairing_mode(sp_mode);
btsnd_hcic_write_simp_pair_debug_mode(sp_debug_mode);
return;
@@ -437,7 +437,7 @@
if ((old_mode == BTM_SEC_MODE_LINK)
&& ( security_mode != BTM_SEC_MODE_LINK))
{
- BTM_TRACE_DEBUG0("BTM_SetSecurityMode: Authen Enable -> FALSE");
+ BTM_TRACE_DEBUG("BTM_SetSecurityMode: Authen Enable -> FALSE");
btsnd_hcic_write_auth_enable (FALSE);
btsnd_hcic_write_encr_mode (HCI_ENCRYPT_MODE_DISABLED);
}
@@ -447,7 +447,7 @@
if ((old_mode != BTM_SEC_MODE_LINK)
&& ( security_mode == BTM_SEC_MODE_LINK))
{
- BTM_TRACE_DEBUG0("BTM_SetSecurityMode: Authen Enable -> TRUE");
+ BTM_TRACE_DEBUG("BTM_SetSecurityMode: Authen Enable -> TRUE");
btsnd_hcic_write_auth_enable (TRUE);
btsnd_hcic_write_encr_mode (HCI_ENCRYPT_MODE_POINT_TO_POINT);
}
@@ -465,7 +465,7 @@
*******************************************************************************/
void BTM_SetPinType (UINT8 pin_type, PIN_CODE pin_code, UINT8 pin_code_len)
{
- BTM_TRACE_API3 ("BTM_SetPinType: pin type %d [variable-0, fixed-1], code %s, length %d",
+ BTM_TRACE_API ("BTM_SetPinType: pin type %d [variable-0, fixed-1], code %s, length %d",
pin_type, (char *) pin_code, pin_code_len);
/* If device is not up security mode will be set as a part of startup */
@@ -496,7 +496,7 @@
*******************************************************************************/
void BTM_SetPairableMode (BOOLEAN allow_pairing, BOOLEAN connect_only_paired)
{
- BTM_TRACE_API2 ("BTM_SetPairableMode() allow_pairing: %u connect_only_paired: %u", allow_pairing, connect_only_paired);
+ BTM_TRACE_API ("BTM_SetPairableMode() allow_pairing: %u connect_only_paired: %u", allow_pairing, connect_only_paired);
btm_cb.pairing_disabled = !allow_pairing;
btm_cb.connect_only_paired = connect_only_paired;
@@ -677,7 +677,7 @@
if (!record_allocated)
{
- BTM_TRACE_WARNING1("BTM_SEC_REG: Out of Service Records (%d)", BTM_SEC_MAX_SERVICE_RECORDS);
+ BTM_TRACE_WARNING("BTM_SEC_REG: Out of Service Records (%d)", BTM_SEC_MAX_SERVICE_RECORDS);
return(record_allocated);
}
@@ -785,24 +785,24 @@
p_srec->security_flags |= (UINT16)(sec_level | BTM_SEC_IN_USE);
}
- BTM_TRACE_API6("BTM_SEC_REG[%d]: id %d, conn_type 0x%x, psm 0x%04x, proto_id %d, chan_id %d",
+ BTM_TRACE_API("BTM_SEC_REG[%d]: id %d, conn_type 0x%x, psm 0x%04x, proto_id %d, chan_id %d",
index, service_id, conn_type, psm, mx_proto_id, mx_chan_id);
- BTM_TRACE_API2(" : security_flags: 0x%04x, ucd_security_flags: 0x%04x",
+ BTM_TRACE_API(" : security_flags: 0x%04x, ucd_security_flags: 0x%04x",
p_srec->security_flags, p_srec->ucd_security_flags);
#if BTM_SEC_SERVICE_NAME_LEN > 0
- BTM_TRACE_API2(" : service name [%s] (up to %d chars saved)",
+ BTM_TRACE_API(" : service name [%s] (up to %d chars saved)",
p_name, BTM_SEC_SERVICE_NAME_LEN);
#endif
#else
p_srec->security_flags |= (UINT16)(sec_level | BTM_SEC_IN_USE);
- BTM_TRACE_API6("BTM_SEC_REG[%d]: id %d, is_orig %d, psm 0x%04x, proto_id %d, chan_id %d",
+ BTM_TRACE_API("BTM_SEC_REG[%d]: id %d, is_orig %d, psm 0x%04x, proto_id %d, chan_id %d",
index, service_id, is_originator, psm, mx_proto_id, mx_chan_id);
#if BTM_SEC_SERVICE_NAME_LEN > 0
- BTM_TRACE_API3(" : sec: 0x%x, service name [%s] (up to %d chars saved)",
+ BTM_TRACE_API(" : sec: 0x%x, service name [%s] (up to %d chars saved)",
p_srec->security_flags, p_name, BTM_SEC_SERVICE_NAME_LEN);
#endif
#endif
@@ -841,7 +841,7 @@
if ((p_srec->security_flags & BTM_SEC_IN_USE) && (p_srec->psm != BT_PSM_SDP) &&
(!service_id || (service_id == p_srec->service_id)))
{
- BTM_TRACE_API2("BTM_SEC_CLR[%d]: id %d", i, service_id);
+ BTM_TRACE_API("BTM_SEC_CLR[%d]: id %d", i, service_id);
p_srec->security_flags = 0;
#if (L2CAP_UCD_INCLUDED == TRUE)
p_srec->ucd_security_flags = 0;
@@ -880,12 +880,12 @@
/* Delete services with specified name (if in use and not SDP) */
if ((p_srec->security_flags & BTM_SEC_IN_USE) && (p_srec->psm == psm) )
{
- BTM_TRACE_API2("BTM_SEC_CLR[%d]: id %d ", i, p_srec->service_id);
+ BTM_TRACE_API("BTM_SEC_CLR[%d]: id %d ", i, p_srec->service_id);
p_srec->security_flags = 0;
num_freed++;
}
}
- BTM_TRACE_API2("btm_sec_clr_service_by_psm psm:0x%x num_freed:%d", psm, num_freed);
+ BTM_TRACE_API("btm_sec_clr_service_by_psm psm:0x%x num_freed:%d", psm, num_freed);
return(num_freed);
}
@@ -908,14 +908,14 @@
if ((p_dev_rec = btm_find_dev (bda)) == NULL)
{
- BTM_TRACE_WARNING0 ("btm_sec_clr_temp_auth_service() - no dev CB");
+ BTM_TRACE_WARNING ("btm_sec_clr_temp_auth_service() - no dev CB");
return;
}
/* Reset the temporary authorized flag so that next time (untrusted) service is accessed autorization will take place */
if (p_dev_rec->last_author_service_id != BTM_SEC_NO_LAST_SERVICE_ID && p_dev_rec->p_cur_service)
{
- BTM_TRACE_DEBUG6 ("btm_sec_clr_auth_service_by_psm [clearing device: %02x:%02x:%02x:%02x:%02x:%02x]",
+ BTM_TRACE_DEBUG ("btm_sec_clr_auth_service_by_psm [clearing device: %02x:%02x:%02x:%02x:%02x:%02x]",
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
p_dev_rec->last_author_service_id = BTM_SEC_NO_LAST_SERVICE_ID;
@@ -948,7 +948,7 @@
if ((p_srec->security_flags & BTM_SEC_IN_USE) &&
(!service_id || (service_id == (UINT32)p_srec->service_id)))
{
- BTM_TRACE_API2("BTM_UCD_SEC_CLR[%d]: id %d", i, service_id);
+ BTM_TRACE_API("BTM_UCD_SEC_CLR[%d]: id %d", i, service_id);
p_srec->ucd_security_flags = 0;
num_cleared++;
}
@@ -979,25 +979,25 @@
{
tBTM_SEC_DEV_REC *p_dev_rec;
- BTM_TRACE_API4 ("BTM_PINCodeReply(): PairState: %s PairFlags: 0x%02x PinLen:%d Result:%d",
+ BTM_TRACE_API ("BTM_PINCodeReply(): PairState: %s PairFlags: 0x%02x PinLen:%d Result:%d",
btm_pair_state_descr(btm_cb.pairing_state), btm_cb.pairing_flags, pin_len, res);
/* If timeout already expired or has been canceled, ignore the reply */
if (btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_LOCAL_PIN)
{
- BTM_TRACE_WARNING1 ("BTM_PINCodeReply() - Wrong State: %d", btm_cb.pairing_state);
+ BTM_TRACE_WARNING ("BTM_PINCodeReply() - Wrong State: %d", btm_cb.pairing_state);
return;
}
if (memcmp (bd_addr, btm_cb.pairing_bda, BD_ADDR_LEN) != 0)
{
- BTM_TRACE_ERROR0 ("BTM_PINCodeReply() - Wrong BD Addr");
+ BTM_TRACE_ERROR ("BTM_PINCodeReply() - Wrong BD Addr");
return;
}
if ((p_dev_rec = btm_find_dev (bd_addr)) == NULL)
{
- BTM_TRACE_ERROR0 ("BTM_PINCodeReply() - no dev CB");
+ BTM_TRACE_ERROR ("BTM_PINCodeReply() - no dev CB");
return;
}
@@ -1048,7 +1048,7 @@
/* before originating */
if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT)
{
- BTM_TRACE_WARNING0 ("BTM_PINCodeReply(): waiting HCI_Connection_Complete after rejected incoming connection");
+ BTM_TRACE_WARNING ("BTM_PINCodeReply(): waiting HCI_Connection_Complete after rejected incoming connection");
/* we change state little bit early so btm_sec_connected() will originate connection */
/* when existing ACL link is down completely */
btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_PIN_REQ);
@@ -1056,7 +1056,7 @@
/* if we already accepted incoming connection from pairing device */
else if (p_dev_rec->sm4 & BTM_SM4_CONN_PEND)
{
- BTM_TRACE_WARNING0 ("BTM_PINCodeReply(): link is connecting so wait pin code request from peer");
+ BTM_TRACE_WARNING ("BTM_PINCodeReply(): link is connecting so wait pin code request from peer");
btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_PIN_REQ);
}
else if (btm_sec_dd_create_conn(p_dev_rec) != BTM_CMD_STARTED)
@@ -1075,7 +1075,7 @@
btm_cb.acl_disc_reason = HCI_SUCCESS;
#ifdef PORCHE_PAIRING_CONFLICT
- BTM_TRACE_EVENT2("BTM_PINCodeReply(): Saving pin_len: %d btm_cb.pin_code_len: %d", pin_len, btm_cb.pin_code_len);
+ BTM_TRACE_EVENT("BTM_PINCodeReply(): Saving pin_len: %d btm_cb.pin_code_len: %d", pin_len, btm_cb.pin_code_len);
/* if this was not pre-fetched, save the PIN */
if (btm_cb.pin_code_len == 0)
memcpy (btm_cb.pin_code, p_pin, pin_len);
@@ -1102,12 +1102,12 @@
if ((p_dev_rec = btm_find_dev (bd_addr)) == NULL)
{
- BTM_TRACE_WARNING6 ("Security Manager: Attempting Authorization of Unknown Device Address [%02x%02x%02x%02x%02x%02x]",
+ BTM_TRACE_WARNING ("Security Manager: Attempting Authorization of Unknown Device Address [%02x%02x%02x%02x%02x%02x]",
bd_addr[0], bd_addr[1], bd_addr[2], bd_addr[3], bd_addr[4], bd_addr[5]);
return;
}
- BTM_TRACE_EVENT4 ("Security Manager: authorized status:%d State:%d Trusted:%08x %08x",
+ BTM_TRACE_EVENT ("Security Manager: authorized status:%d State:%d Trusted:%08x %08x",
res, (p_dev_rec) ? p_dev_rec->sec_state : 0, trusted_mask[0], trusted_mask[1]);
if (res == BTM_SUCCESS)
@@ -1122,7 +1122,7 @@
by another multiplexer layer */
if (!p_dev_rec->is_originator)
{
- BTM_TRACE_DEBUG1("BTM_DeviceAuthorized: Setting last_author_service_id to %d",
+ BTM_TRACE_DEBUG("BTM_DeviceAuthorized: Setting last_author_service_id to %d",
p_dev_rec->p_cur_service->service_id);
p_dev_rec->last_author_service_id = p_dev_rec->p_cur_service->service_id;
}
@@ -1166,16 +1166,16 @@
UINT8 *p_features;
UINT8 ii;
tACL_CONN *p= btm_bda_to_acl(bd_addr, transport);
- BTM_TRACE_API6 ("btm_sec_bond_by_transport BDA: %02x:%02x:%02x:%02x:%02x:%02x",
+ BTM_TRACE_API ("btm_sec_bond_by_transport BDA: %02x:%02x:%02x:%02x:%02x:%02x",
bd_addr[0], bd_addr[1], bd_addr[2], bd_addr[3], bd_addr[4], bd_addr[5]);
- BTM_TRACE_DEBUG1("btm_sec_bond_by_transport: Transport used %d" , transport);
+ BTM_TRACE_DEBUG("btm_sec_bond_by_transport: Transport used %d" , transport);
/* Other security process is in progress */
if (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE)
{
- BTM_TRACE_ERROR1 ("BTM_SecBond: already busy in state: %s", btm_pair_state_descr(btm_cb.pairing_state));
+ BTM_TRACE_ERROR ("BTM_SecBond: already busy in state: %s", btm_pair_state_descr(btm_cb.pairing_state));
return(BTM_WRONG_MODE);
}
@@ -1184,7 +1184,7 @@
return(BTM_NO_RESOURCES);
}
- BTM_TRACE_DEBUG1 ("before update sec_flags=0x%x", p_dev_rec->sec_flags);
+ BTM_TRACE_DEBUG ("before update sec_flags=0x%x", p_dev_rec->sec_flags);
/* Finished if connection is active and already paired */
if ( ((p_dev_rec->hci_handle != BTM_SEC_INVALID_HANDLE) && transport == BT_TRANSPORT_BR_EDR
@@ -1196,7 +1196,7 @@
)
{
- BTM_TRACE_WARNING0("BTM_SecBond -> Already Paired");
+ BTM_TRACE_WARNING("BTM_SecBond -> Already Paired");
return(BTM_SUCCESS);
}
@@ -1242,7 +1242,7 @@
| BTM_SEC_ROLE_SWITCHED | BTM_SEC_LINK_KEY_AUTHED);
- BTM_TRACE_DEBUG1 ("after update sec_flags=0x%x", p_dev_rec->sec_flags);
+ BTM_TRACE_DEBUG ("after update sec_flags=0x%x", p_dev_rec->sec_flags);
if (!HCI_SIMPLE_PAIRING_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
{
/* The special case when we authenticate keyboard. Set pin type to fixed */
@@ -1260,13 +1260,13 @@
for (ii = 0; ii <= HCI_EXT_FEATURES_PAGE_MAX; ii++)
{
p_features = p_dev_rec->features[ii];
- BTM_TRACE_EVENT5(" remote_features page[%1d] = %02x-%02x-%02x-%02x",
+ BTM_TRACE_EVENT(" remote_features page[%1d] = %02x-%02x-%02x-%02x",
ii, p_features[0], p_features[1], p_features[2], p_features[3]);
- BTM_TRACE_EVENT4(" %02x-%02x-%02x-%02x",
+ BTM_TRACE_EVENT(" %02x-%02x-%02x-%02x",
p_features[4], p_features[5], p_features[6], p_features[7]);
}
- BTM_TRACE_EVENT2 ("BTM_SecBond: Remote sm4: 0x%x HCI Handle: 0x%04x", p_dev_rec->sm4, p_dev_rec->hci_handle);
+ BTM_TRACE_EVENT ("BTM_SecBond: Remote sm4: 0x%x HCI Handle: 0x%04x", p_dev_rec->sm4, p_dev_rec->hci_handle);
#if BTM_SEC_FORCE_RNR_FOR_DBOND == TRUE
p_dev_rec->sec_flags &= ~BTM_SEC_NAME_KNOWN;
@@ -1285,7 +1285,7 @@
return(BTM_CMD_STARTED);
}
- BTM_TRACE_DEBUG2 ("sec mode: %d sm4:x%x", btm_cb.security_mode, p_dev_rec->sm4);
+ BTM_TRACE_DEBUG ("sec mode: %d sm4:x%x", btm_cb.security_mode, p_dev_rec->sm4);
if (!HCI_SIMPLE_PAIRING_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])
|| (p_dev_rec->sm4 == BTM_SM4_KNOWN))
{
@@ -1308,7 +1308,7 @@
/* We are accepting connection request from peer */
btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_PIN_REQ);
}
- BTM_TRACE_DEBUG3 ("State:%s sm4: 0x%x sec_state:%d",
+ BTM_TRACE_DEBUG ("State:%s sm4: 0x%x sec_state:%d",
btm_pair_state_descr (btm_cb.pairing_state), p_dev_rec->sm4, p_dev_rec->sec_state);
return BTM_CMD_STARTED;
}
@@ -1397,7 +1397,7 @@
{
tBTM_SEC_DEV_REC *p_dev_rec;
- BTM_TRACE_API2 ("BTM_SecBondCancel() State: %s flags:0x%x",
+ BTM_TRACE_API ("BTM_SecBondCancel() State: %s flags:0x%x",
btm_pair_state_descr (btm_cb.pairing_state), btm_cb.pairing_flags);
if (((p_dev_rec = btm_find_dev (bd_addr)) == NULL)
@@ -1409,7 +1409,7 @@
{
if (p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING)
{
- BTM_TRACE_DEBUG0 ("Cancel LE pairing");
+ BTM_TRACE_DEBUG ("Cancel LE pairing");
if (SMP_PairCancel(bd_addr))
{
return BTM_CMD_STARTED;
@@ -1419,7 +1419,7 @@
}
#endif
- BTM_TRACE_DEBUG2 ("hci_handle:0x%x sec_state:%d", p_dev_rec->hci_handle, p_dev_rec->sec_state );
+ BTM_TRACE_DEBUG ("hci_handle:0x%x sec_state:%d", p_dev_rec->hci_handle, p_dev_rec->sec_state );
if (BTM_PAIR_STATE_WAIT_LOCAL_PIN == btm_cb.pairing_state &&
BTM_PAIR_FLAGS_WE_STARTED_DD & btm_cb.pairing_flags)
{
@@ -1574,7 +1574,7 @@
)
{
/* Connection should be up and runnning */
- BTM_TRACE_WARNING0 ("Security Manager: BTM_SetEncryption not connected");
+ BTM_TRACE_WARNING ("Security Manager: BTM_SetEncryption not connected");
if (p_callback)
(*p_callback) (bd_addr, transport, p_ref_data, BTM_WRONG_MODE);
@@ -1590,7 +1590,7 @@
#endif
)
{
- BTM_TRACE_EVENT0 ("Security Manager: BTM_SetEncryption already encrypted");
+ BTM_TRACE_EVENT ("Security Manager: BTM_SetEncryption already encrypted");
if (p_callback)
(*p_callback) (bd_addr, transport, p_ref_data, BTM_SUCCESS);
@@ -1601,7 +1601,7 @@
if (p_dev_rec->p_callback)
{
/* Connection should be up and runnning */
- BTM_TRACE_WARNING0 ("Security Manager: BTM_SetEncryption busy");
+ BTM_TRACE_WARNING ("Security Manager: BTM_SetEncryption busy");
if (p_callback)
(*p_callback) (bd_addr, transport, p_ref_data, BTM_BUSY);
@@ -1614,7 +1614,7 @@
p_dev_rec->security_required |= (BTM_SEC_IN_AUTHENTICATE | BTM_SEC_IN_ENCRYPT);
p_dev_rec->is_originator = FALSE;
- BTM_TRACE_API4 ("Security Manager: BTM_SetEncryption Handle:%d State:%d Flags:0x%x Required:0x%x",
+ BTM_TRACE_API ("Security Manager: BTM_SetEncryption Handle:%d State:%d Flags:0x%x Required:0x%x",
p_dev_rec->hci_handle, p_dev_rec->sec_state, p_dev_rec->sec_flags,
p_dev_rec->security_required);
@@ -1647,7 +1647,7 @@
UINT8 old_state = p_dev_rec->sec_state;
tBTM_STATUS status = BTM_CMD_STARTED;
- BTM_TRACE_EVENT2 ("btm_sec_send_hci_disconnect: handle:0x%x, reason=0x%x",
+ BTM_TRACE_EVENT ("btm_sec_send_hci_disconnect: handle:0x%x, reason=0x%x",
conn_handle, reason);
/* if some other thread disconnecting, we do not send second command */
@@ -1661,7 +1661,7 @@
p_dev_rec->hci_handle == conn_handle)
{
- BTM_TRACE_DEBUG0("RS in progress - Set DISC Pending flag in btm_sec_send_hci_disconnect to delay disconnect");
+ BTM_TRACE_DEBUG("RS in progress - Set DISC Pending flag in btm_sec_send_hci_disconnect to delay disconnect");
p_dev_rec->rs_disc_pending = BTM_SEC_DISC_PENDING;
status = BTM_SUCCESS;
}
@@ -1693,7 +1693,7 @@
{
tBTM_SEC_DEV_REC *p_dev_rec;
- BTM_TRACE_EVENT2 ("BTM_ConfirmReqReply() State: %s Res: %u",
+ BTM_TRACE_EVENT ("BTM_ConfirmReqReply() State: %s Res: %u",
btm_pair_state_descr(btm_cb.pairing_state), res);
/* If timeout already expired or has been canceled, ignore the reply */
@@ -1741,7 +1741,7 @@
{
tBTM_SEC_DEV_REC *p_dev_rec;
- BTM_TRACE_API2 ("BTM_PasskeyReqReply: State: %s res:%d",
+ BTM_TRACE_API ("BTM_PasskeyReqReply: State: %s res:%d",
btm_pair_state_descr(btm_cb.pairing_state), res);
if ( (btm_cb.pairing_state == BTM_PAIR_STATE_IDLE)
@@ -1831,7 +1831,7 @@
*******************************************************************************/
void BTM_IoCapRsp(BD_ADDR bd_addr, tBTM_IO_CAP io_cap, tBTM_OOB_DATA oob, tBTM_AUTH_REQ auth_req)
{
- BTM_TRACE_EVENT3 ("BTM_IoCapRsp: state: %s oob: %d io_cap: %d",
+ BTM_TRACE_EVENT ("BTM_IoCapRsp: state: %s oob: %d io_cap: %d",
btm_pair_state_descr(btm_cb.pairing_state), oob, io_cap);
if ( (btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_LOCAL_IOCAPS)
@@ -1882,7 +1882,7 @@
*******************************************************************************/
void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr, BT_OCTET16 c, BT_OCTET16 r)
{
- BTM_TRACE_EVENT2 ("BTM_RemoteOobDataReply(): State: %s res:%d",
+ BTM_TRACE_EVENT ("BTM_RemoteOobDataReply(): State: %s res:%d",
btm_pair_state_descr(btm_cb.pairing_state), res);
/* If timeout already expired or has been canceled, ignore the reply */
@@ -2099,7 +2099,7 @@
&& (p_serv_rec->service_id == service_id)
&& (p_serv_rec->orig_mx_chan_id == mx_chan_id))
{
- BTM_TRACE_API4("BTM_SetOutService p_out_serv id %d, psm 0x%04x, proto_id %d, chan_id %d",
+ BTM_TRACE_API("BTM_SetOutService p_out_serv id %d, psm 0x%04x, proto_id %d, chan_id %d",
p_serv_rec->service_id, p_serv_rec->psm, p_serv_rec->mx_proto_id, p_serv_rec->orig_mx_chan_id);
btm_cb.p_out_serv = p_serv_rec;
if (p_dev_rec)
@@ -2132,13 +2132,13 @@
is_possible = FALSE;
if(p_dev_rec->p_cur_service)
{
- BTM_TRACE_DEBUG5 ("btm_sec_is_upgrade_possible id:%d, link_key_typet:%d, rmt_io_caps:%d, chk flags:x%x, flags:x%x",
+ BTM_TRACE_DEBUG ("btm_sec_is_upgrade_possible id:%d, link_key_typet:%d, rmt_io_caps:%d, chk flags:x%x, flags:x%x",
p_dev_rec->p_cur_service->service_id, p_dev_rec->link_key_type, p_dev_rec->rmt_io_caps,
mtm_check, p_dev_rec->p_cur_service->security_flags);
}
else
{
- BTM_TRACE_DEBUG3 ("btm_sec_is_upgrade_possible link_key_typet:%d, rmt_io_caps:%d, chk flags:x%x, ",
+ BTM_TRACE_DEBUG ("btm_sec_is_upgrade_possible link_key_typet:%d, rmt_io_caps:%d, chk flags:x%x, ",
p_dev_rec->link_key_type, p_dev_rec->rmt_io_caps, mtm_check);
}
/* Already have a link key to the connected peer. Is the link key secure enough?
@@ -2155,7 +2155,7 @@
is_possible = TRUE;
}
}
- BTM_TRACE_DEBUG2 ("btm_sec_is_upgrade_possible is_possible:%d sec_flags:0x%x", is_possible, p_dev_rec->sec_flags);
+ BTM_TRACE_DEBUG ("btm_sec_is_upgrade_possible is_possible:%d sec_flags:0x%x", is_possible, p_dev_rec->sec_flags);
return is_possible;
}
@@ -2173,14 +2173,14 @@
{
tBTM_SP_UPGRADE evt_data;
- BTM_TRACE_DEBUG0 ("btm_sec_check_upgrade...");
+ BTM_TRACE_DEBUG ("btm_sec_check_upgrade...");
/* Only check if link key already exists */
if (!(p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_KNOWN))
return;
if (btm_sec_is_upgrade_possible (p_dev_rec, is_originator) == TRUE)
{
- BTM_TRACE_DEBUG1 ("need upgrade!! sec_flags:0x%x", p_dev_rec->sec_flags);
+ BTM_TRACE_DEBUG ("need upgrade!! sec_flags:0x%x", p_dev_rec->sec_flags);
/* upgrade is possible: check if the application wants the upgrade.
* If the application is configured to use a global MITM flag,
* it probably would not want to upgrade the link key based on the security level database */
@@ -2189,7 +2189,7 @@
if (btm_cb.api.p_sp_callback)
(*btm_cb.api.p_sp_callback) (BTM_SP_UPGRADE_EVT, (tBTM_SP_EVT_DATA *)&evt_data);
- BTM_TRACE_DEBUG1 ("evt_data.upgrade:0x%x", evt_data.upgrade);
+ BTM_TRACE_DEBUG ("evt_data.upgrade:0x%x", evt_data.upgrade);
if (evt_data.upgrade)
{
/* if the application confirms the upgrade, set the upgrade bit */
@@ -2198,7 +2198,7 @@
/* Clear the link key known to go through authentication/pairing again */
p_dev_rec->sec_flags &= ~(BTM_SEC_LINK_KEY_KNOWN | BTM_SEC_LINK_KEY_AUTHED);
p_dev_rec->sec_flags &= ~BTM_SEC_AUTHENTICATED;
- BTM_TRACE_DEBUG1 ("sec_flags:0x%x", p_dev_rec->sec_flags);
+ BTM_TRACE_DEBUG ("sec_flags:0x%x", p_dev_rec->sec_flags);
}
}
}
@@ -2245,11 +2245,11 @@
else
is_originator = FALSE;
- BTM_TRACE_DEBUG2 ("btm_sec_l2cap_access_req conn_type:0x%x, 0x%x", conn_type, p_ref_data);
+ BTM_TRACE_DEBUG ("btm_sec_l2cap_access_req conn_type:0x%x, 0x%x", conn_type, p_ref_data);
#else
is_originator = conn_type;
- BTM_TRACE_DEBUG2 ("btm_sec_l2cap_access_req is_originator:%d, 0x%x", is_originator, p_ref_data);
+ BTM_TRACE_DEBUG ("btm_sec_l2cap_access_req is_originator:%d, 0x%x", is_originator, p_ref_data);
#endif
/* Find or get oldest record */
@@ -2263,7 +2263,7 @@
/* If there is no application registered with this PSM do not allow connection */
if (!p_serv_rec)
{
- BTM_TRACE_WARNING1 ("btm_sec_l2cap_access_req() PSM:%d no application registerd", psm);
+ BTM_TRACE_WARNING ("btm_sec_l2cap_access_req() PSM:%d no application registerd", psm);
(*p_callback) (bd_addr, transport, p_ref_data, BTM_MODE_UNSUPPORTED);
@@ -2322,9 +2322,9 @@
/* we will process one after another */
if ( (p_dev_rec->p_callback) || (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) )
{
- BTM_TRACE_EVENT4 ("btm_sec_l2cap_access_req() - busy - PSM:%d delayed state: %s mode:%d, sm4:0x%x",
+ BTM_TRACE_EVENT ("btm_sec_l2cap_access_req() - busy - PSM:%d delayed state: %s mode:%d, sm4:0x%x",
psm, btm_pair_state_descr(btm_cb.pairing_state), btm_cb.security_mode, p_dev_rec->sm4);
- BTM_TRACE_EVENT2 ("security_flags:x%x, sec_flags:x%x", security_required, p_dev_rec->sec_flags);
+ BTM_TRACE_EVENT ("security_flags:x%x, sec_flags:x%x", security_required, p_dev_rec->sec_flags);
rc = BTM_CMD_STARTED;
if ((BTM_SEC_MODE_SP != btm_cb.security_mode)
|| ((BTM_SEC_MODE_SP == btm_cb.security_mode) && (BTM_SM4_KNOWN == p_dev_rec->sm4))
@@ -2388,7 +2388,7 @@
{
if ( !(BTM_SM4_KNOWN & p_dev_rec->sm4))
{
- BTM_TRACE_DEBUG1 ("remote features unknown!!sec_flags:0x%x", p_dev_rec->sec_flags);
+ BTM_TRACE_DEBUG ("remote features unknown!!sec_flags:0x%x", p_dev_rec->sec_flags);
/* the remote features are not known yet */
p_dev_rec->sm4 |= BTM_SM4_REQ_PEND;
@@ -2410,7 +2410,7 @@
{
if ( !(BTM_SM4_KNOWN & p_dev_rec->sm4))
{
- BTM_TRACE_DEBUG1 ("(rsp) remote features unknown!!sec_flags:0x%x", p_dev_rec->sec_flags);
+ BTM_TRACE_DEBUG ("(rsp) remote features unknown!!sec_flags:0x%x", p_dev_rec->sec_flags);
/* the remote features are not known yet */
p_dev_rec->sm4 |= BTM_SM4_REQ_PEND;
@@ -2420,7 +2420,7 @@
}
}
- BTM_TRACE_DEBUG4 ("btm_sec_l2cap_access_req() sm4:0x%x, sec_flags:0x%x, security_required:0x%x chk:%d",
+ BTM_TRACE_DEBUG ("btm_sec_l2cap_access_req() sm4:0x%x, sec_flags:0x%x, security_required:0x%x chk:%d",
p_dev_rec->sm4, p_dev_rec->sec_flags, security_required, chk_acp_auth_done);
old_security_required = p_dev_rec->security_required;
@@ -2445,10 +2445,10 @@
if ((btm_sec_find_next_serv (p_serv_rec)) != NULL)
#endif
{
- BTM_TRACE_DEBUG2 ("no next_serv sm4:0x%x, chk:%d", p_dev_rec->sm4, chk_acp_auth_done);
+ BTM_TRACE_DEBUG ("no next_serv sm4:0x%x, chk:%d", p_dev_rec->sm4, chk_acp_auth_done);
if (!BTM_SEC_IS_SM4(p_dev_rec->sm4))
{
- BTM_TRACE_EVENT1 ("Security Manager: l2cap_access_req PSM:%d postponed for multiplexer", psm);
+ BTM_TRACE_EVENT ("Security Manager: l2cap_access_req PSM:%d postponed for multiplexer", psm);
/* pre-Lisbon: restore the old settings */
p_dev_rec->security_required = old_security_required;
p_dev_rec->is_originator = old_is_originator;
@@ -2463,7 +2463,7 @@
* The layer above L2CAP needs to carry out the security requirement after L2CAP connect response is received*/
if (is_originator && (btm_cb.security_mode != BTM_SEC_MODE_SP || !BTM_SEC_IS_SM4(p_dev_rec->sm4)) && (psm >= 0x1001))
{
- BTM_TRACE_EVENT1 ("dynamic PSM:0x%x in legacy mode - postponed for upper layer", psm);
+ BTM_TRACE_EVENT ("dynamic PSM:0x%x in legacy mode - postponed for upper layer", psm);
/* restore the old settings */
p_dev_rec->security_required = old_security_required;
p_dev_rec->is_originator = old_is_originator;
@@ -2475,7 +2475,7 @@
if (chk_acp_auth_done)
{
- BTM_TRACE_DEBUG2 ("(SM4 to SM4) btm_sec_l2cap_access_req rspd. authenticated: x%x, enc: x%x",
+ BTM_TRACE_DEBUG ("(SM4 to SM4) btm_sec_l2cap_access_req rspd. authenticated: x%x, enc: x%x",
(p_dev_rec->sec_flags & BTM_SEC_AUTHENTICATED), (p_dev_rec->sec_flags & BTM_SEC_ENCRYPTED));
/* SM4, but we do not know for sure which level of security we need.
* as long as we have a link key, it's OK */
@@ -2487,7 +2487,7 @@
2046 may report HCI_Encryption_Change and L2C Connection Request out of sequence
because of data path issues. Delay this disconnect a little bit
*/
- BTM_TRACE_ERROR0 ("peer should have initiated security process by now (SM4 to SM4)");
+ BTM_TRACE_ERROR ("peer should have initiated security process by now (SM4 to SM4)");
p_dev_rec->p_callback = p_callback;
p_dev_rec->sec_state = BTM_SEC_STATE_DELAY_FOR_ENC;
(*p_callback) (bd_addr, transport, p_ref_data, rc);
@@ -2515,7 +2515,7 @@
btm_sec_check_upgrade(p_dev_rec, is_originator);
}
- BTM_TRACE_EVENT6 ("Security Manager: l2cap_access_req PSM:%d Handle:%d State:%d Flags:0x%x Required:0x%x Service ID:%d",
+ BTM_TRACE_EVENT ("Security Manager: l2cap_access_req PSM:%d Handle:%d State:%d Flags:0x%x Required:0x%x Service ID:%d",
psm, handle, p_dev_rec->sec_state, p_dev_rec->sec_flags, p_dev_rec->security_required, p_dev_rec->p_cur_service->service_id);
if ((rc = btm_sec_execute_procedure (p_dev_rec)) != BTM_CMD_STARTED)
@@ -2561,7 +2561,7 @@
UINT16 security_required;
BOOLEAN transport = FALSE;/* should check PSM range in LE connection oriented L2CAP connection */
- BTM_TRACE_DEBUG1 ("btm_sec_mx_access_request is_originator:%d", is_originator);
+ BTM_TRACE_DEBUG ("btm_sec_mx_access_request is_originator:%d", is_originator);
/* Find or get oldest record */
p_dev_rec = btm_find_or_alloc_dev (bd_addr);
@@ -2574,7 +2574,7 @@
if (p_callback)
(*p_callback) (bd_addr, transport, p_ref_data, BTM_MODE_UNSUPPORTED);
- BTM_TRACE_ERROR3 ("Security Manager: MX service not found PSM:%d Proto:%d SCN:%d",
+ BTM_TRACE_ERROR ("Security Manager: MX service not found PSM:%d Proto:%d SCN:%d",
psm, mx_proto_id, mx_chan_id);
return BTM_NO_RESOURCES;
}
@@ -2583,7 +2583,7 @@
/* we will process one after another */
if ( (p_dev_rec->p_callback) || (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) )
{
- BTM_TRACE_EVENT4 ("btm_sec_mx_access_request service PSM:%d Proto:%d SCN:%d delayed state: %s",
+ BTM_TRACE_EVENT ("btm_sec_mx_access_request service PSM:%d Proto:%d SCN:%d delayed state: %s",
psm, mx_proto_id, mx_chan_id, btm_pair_state_descr(btm_cb.pairing_state));
rc = BTM_CMD_STARTED;
@@ -2648,7 +2648,7 @@
/* scn, we need to request user's permission again. */
p_dev_rec->sec_flags &= ~(BTM_SEC_AUTHORIZED);
- BTM_TRACE_EVENT6 ("Security Manager: mx_access_req proto_id:%d chan_id:%d State:%d Flags:0x%x Required:0x%x Service ID:%d",
+ BTM_TRACE_EVENT ("Security Manager: mx_access_req proto_id:%d chan_id:%d State:%d Flags:0x%x Required:0x%x Service ID:%d",
mx_proto_id, mx_chan_id, p_dev_rec->sec_state, p_dev_rec->sec_flags, p_dev_rec->security_required, p_dev_rec->p_cur_service->service_id);
if ((rc = btm_sec_execute_procedure (p_dev_rec)) != BTM_CMD_STARTED)
@@ -2681,7 +2681,7 @@
/* Some device may request a connection before we are done with the HCI_Reset sequence */
if (btm_cb.devcb.state != BTM_DEV_STATE_READY)
{
- BTM_TRACE_EVENT0 ("Security Manager: connect request when device not ready");
+ BTM_TRACE_EVENT ("Security Manager: connect request when device not ready");
btsnd_hcic_reject_conn (bda, HCI_ERR_HOST_REJECT_DEVICE);
return;
}
@@ -2693,7 +2693,7 @@
{
if (!p_dev_rec || !(p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_AUTHED))
{
- BTM_TRACE_EVENT0 ("Security Manager: connect request from non-paired device");
+ BTM_TRACE_EVENT ("Security Manager: connect request from non-paired device");
btsnd_hcic_reject_conn (bda, HCI_ERR_HOST_REJECT_DEVICE);
return;
}
@@ -2705,7 +2705,7 @@
{
if (!p_dev_rec)
{
- BTM_TRACE_EVENT0 ("Security Manager: connect request from not paired device");
+ BTM_TRACE_EVENT ("Security Manager: connect request from not paired device");
btsnd_hcic_reject_conn (bda, HCI_ERR_HOST_REJECT_DEVICE);
return;
}
@@ -2717,7 +2717,7 @@
{
if (!(* btm_cb.p_conn_filter_cb) (bda, dc))
{
- BTM_TRACE_EVENT0 ("Security Manager: connect request did not pass filter");
+ BTM_TRACE_EVENT ("Security Manager: connect request did not pass filter");
/* incomming call did not pass connection filters. Reject */
btsnd_hcic_reject_conn (bda, HCI_ERR_HOST_REJECT_DEVICE);
@@ -2729,7 +2729,7 @@
&&(btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD)
&&(!memcmp (btm_cb.pairing_bda, bda, BD_ADDR_LEN)))
{
- BTM_TRACE_EVENT0 ("Security Manager: reject connect request from bonding device");
+ BTM_TRACE_EVENT ("Security Manager: reject connect request from bonding device");
/* incoming connection from bonding device is rejected */
btm_cb.pairing_flags |= BTM_PAIR_FLAGS_REJECTED_CONNECT;
@@ -2808,7 +2808,7 @@
UINT8 status;
STREAM_TO_UINT8 (status, p);
- BTM_TRACE_EVENT2 ("btm_create_conn_cancel_complete(): in State: %s status:%d",
+ BTM_TRACE_EVENT ("btm_create_conn_cancel_complete(): in State: %s status:%d",
btm_pair_state_descr(btm_cb.pairing_state), status);
/* if the create conn cancel cmd was issued by the bond cancel,
@@ -2863,7 +2863,7 @@
/* Check that the ACL is still up before starting security procedures */
if (btm_bda_to_acl(p_e->bd_addr, BT_TRANSPORT_BR_EDR) != NULL)
{
- BTM_TRACE_EVENT4 ("btm_sec_check_pending_reqs() submitting PSM: 0x%04x Is_Orig: %u mx_proto_id: %u mx_chan_id: %u",
+ BTM_TRACE_EVENT ("btm_sec_check_pending_reqs() submitting PSM: 0x%04x Is_Orig: %u mx_proto_id: %u mx_chan_id: %u",
p_e->psm, p_e->is_orig, p_e->mx_proto_id, p_e->mx_chan_id);
btm_sec_mx_access_request (p_e->bd_addr, p_e->psm, p_e->is_orig,
@@ -2912,7 +2912,7 @@
*******************************************************************************/
void btm_sec_device_down (void)
{
- BTM_TRACE_EVENT1 ("btm_sec_device_down() State: %s", btm_pair_state_descr(btm_cb.pairing_state));
+ BTM_TRACE_EVENT ("btm_sec_device_down() State: %s", btm_pair_state_descr(btm_cb.pairing_state));
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
}
@@ -2966,7 +2966,7 @@
btm_cb.security_mode = BTM_SEC_MODE_SERVICE;
}
- BTM_TRACE_DEBUG1 ("btm_sec_dev_reset sec mode: %d", btm_cb.security_mode);
+ BTM_TRACE_DEBUG ("btm_sec_dev_reset sec mode: %d", btm_cb.security_mode);
}
/*******************************************************************************
@@ -3016,7 +3016,7 @@
/* Make sure an L2cap link control block is available */
if ((p_lcb = l2cu_allocate_lcb (p_dev_rec->bd_addr, TRUE, BT_TRANSPORT_BR_EDR)) == NULL)
{
- BTM_TRACE_WARNING6 ("Security Manager: failed allocate LCB [%02x%02x%02x%02x%02x%02x]",
+ BTM_TRACE_WARNING ("Security Manager: failed allocate LCB [%02x%02x%02x%02x%02x%02x]",
p_dev_rec->bd_addr[0], p_dev_rec->bd_addr[1], p_dev_rec->bd_addr[2],
p_dev_rec->bd_addr[3], p_dev_rec->bd_addr[4], p_dev_rec->bd_addr[5]);
@@ -3028,7 +3028,7 @@
if (l2cu_create_conn(p_lcb, BT_TRANSPORT_BR_EDR) == FALSE)
{
- BTM_TRACE_WARNING6 ("Security Manager: failed create [%02x%02x%02x%02x%02x%02x]",
+ BTM_TRACE_WARNING ("Security Manager: failed create [%02x%02x%02x%02x%02x%02x]",
p_dev_rec->bd_addr[0], p_dev_rec->bd_addr[1], p_dev_rec->bd_addr[2],
p_dev_rec->bd_addr[3], p_dev_rec->bd_addr[4], p_dev_rec->bd_addr[5]);
@@ -3040,7 +3040,7 @@
btm_acl_update_busy_level (BTM_BLI_PAGE_EVT);
#endif
- BTM_TRACE_DEBUG6 ("Security Manager: btm_sec_dd_create_conn [%02x%02x%02x%02x%02x%02x]",
+ BTM_TRACE_DEBUG ("Security Manager: btm_sec_dd_create_conn [%02x%02x%02x%02x%02x%02x]",
p_dev_rec->bd_addr[0], p_dev_rec->bd_addr[1], p_dev_rec->bd_addr[2],
p_dev_rec->bd_addr[3], p_dev_rec->bd_addr[4], p_dev_rec->bd_addr[5]);
@@ -3066,7 +3066,7 @@
DEV_CLASS dev_class;
UINT8 old_sec_state;
- BTM_TRACE_EVENT0 ("btm_sec_rmt_name_request_complete");
+ BTM_TRACE_EVENT ("btm_sec_rmt_name_request_complete");
if (((p_bd_addr == NULL) && !BTM_ACL_IS_CONNECTED(btm_cb.connecting_bda))
|| ((p_bd_addr != NULL) && !BTM_ACL_IS_CONNECTED(p_bd_addr)))
{
@@ -3104,13 +3104,13 @@
if (p_dev_rec)
{
- BTM_TRACE_EVENT5 ("Security Manager: rmt_name_complete PairState: %s RemName: %s status: %d State:%d p_dev_rec: 0x%08x ",
+ BTM_TRACE_EVENT ("Security Manager: rmt_name_complete PairState: %s RemName: %s status: %d State:%d p_dev_rec: 0x%08x ",
btm_pair_state_descr (btm_cb.pairing_state), p_bd_name,
status, p_dev_rec->sec_state, p_dev_rec);
}
else
{
- BTM_TRACE_EVENT3 ("Security Manager: rmt_name_complete PairState: %s RemName: %s status: %d",
+ BTM_TRACE_EVENT ("Security Manager: rmt_name_complete PairState: %s RemName: %s status: %d",
btm_pair_state_descr (btm_cb.pairing_state), p_bd_name,
status);
}
@@ -3123,7 +3123,7 @@
{
BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name, sizeof (p_dev_rec->sec_bd_name), (char *)p_bd_name, BTM_MAX_REM_BD_NAME_LEN);
p_dev_rec->sec_flags |= BTM_SEC_NAME_KNOWN;
- BTM_TRACE_EVENT1 ("setting BTM_SEC_NAME_KNOWN sec_flags:0x%x", p_dev_rec->sec_flags);
+ BTM_TRACE_EVENT ("setting BTM_SEC_NAME_KNOWN sec_flags:0x%x", p_dev_rec->sec_flags);
}
else
{
@@ -3162,13 +3162,13 @@
if ( (btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_LOCAL_PIN) && p_bd_addr
&& (memcmp (btm_cb.pairing_bda, p_bd_addr, BD_ADDR_LEN) == 0) )
{
- BTM_TRACE_EVENT2 ("btm_sec_rmt_name_request_complete() delayed pin now being requested flags:0x%x, (p_pin_callback=0x%p)", btm_cb.pairing_flags, btm_cb.api.p_pin_callback);
+ BTM_TRACE_EVENT ("btm_sec_rmt_name_request_complete() delayed pin now being requested flags:0x%x, (p_pin_callback=0x%p)", btm_cb.pairing_flags, btm_cb.api.p_pin_callback);
if (((btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) == 0) &&
((btm_cb.pairing_flags & BTM_PAIR_FLAGS_PIN_REQD) == 0) &&
btm_cb.api.p_pin_callback)
{
- BTM_TRACE_EVENT0 ("btm_sec_rmt_name_request_complete() calling pin_callback");
+ BTM_TRACE_EVENT ("btm_sec_rmt_name_request_complete() calling pin_callback");
btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD;
(*btm_cb.api.p_pin_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class, p_bd_name);
}
@@ -3183,7 +3183,7 @@
{
if (p_bd_addr && memcmp (btm_cb.pairing_bda, p_bd_addr, BD_ADDR_LEN) == 0)
{
- BTM_TRACE_EVENT2 ("btm_sec_rmt_name_request_complete() continue bonding sm4: 0x%04x, status:0x%x", p_dev_rec->sm4, status);
+ BTM_TRACE_EVENT ("btm_sec_rmt_name_request_complete() continue bonding sm4: 0x%04x, status:0x%x", p_dev_rec->sm4, status);
if(btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_CANCEL_DD)
{
btm_sec_bond_cancel_complete();
@@ -3205,7 +3205,7 @@
{
/* set the KNOWN flag only if BTM_PAIR_FLAGS_REJECTED_CONNECT is not set.*/
/* If it is set, there may be a race condition */
- BTM_TRACE_DEBUG1 ("btm_sec_rmt_name_request_complete IS_SM4_UNKNOWN Flags:0x%04x",
+ BTM_TRACE_DEBUG ("btm_sec_rmt_name_request_complete IS_SM4_UNKNOWN Flags:0x%04x",
btm_cb.pairing_flags);
if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT) == 0)
{
@@ -3213,7 +3213,7 @@
}
}
- BTM_TRACE_DEBUG5("%s, SM4 Value: %x, Legacy:%d,IS SM4:%d, Unknown:%d",__FUNCTION__,
+ BTM_TRACE_DEBUG("%s, SM4 Value: %x, Legacy:%d,IS SM4:%d, Unknown:%d",__FUNCTION__,
p_dev_rec->sm4, BTM_SEC_IS_SM4_LEGACY(p_dev_rec->sm4),
BTM_SEC_IS_SM4(p_dev_rec->sm4),BTM_SEC_IS_SM4_UNKNOWN(p_dev_rec->sm4));
@@ -3226,12 +3226,12 @@
/* before originating */
if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT)
{
- BTM_TRACE_WARNING0 ("btm_sec_rmt_name_request_complete: waiting HCI_Connection_Complete after rejecting connection");
+ BTM_TRACE_WARNING ("btm_sec_rmt_name_request_complete: waiting HCI_Connection_Complete after rejecting connection");
}
/* Both we and the peer are 2.1 - continue to create connection */
else if (btm_sec_dd_create_conn(p_dev_rec) != BTM_CMD_STARTED)
{
- BTM_TRACE_WARNING0 ("btm_sec_rmt_name_request_complete: failed to start connection");
+ BTM_TRACE_WARNING ("btm_sec_rmt_name_request_complete: failed to start connection");
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
@@ -3244,7 +3244,7 @@
}
else
{
- BTM_TRACE_WARNING0 ("btm_sec_rmt_name_request_complete: wrong BDA, retry with pairing BDA");
+ BTM_TRACE_WARNING ("btm_sec_rmt_name_request_complete: wrong BDA, retry with pairing BDA");
BTM_ReadRemoteDeviceName (btm_cb.pairing_bda, NULL, BT_TRANSPORT_BR_EDR);
return;
@@ -3278,7 +3278,7 @@
if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD)
&& (p_dev_rec->sec_flags & BTM_SEC_AUTHENTICATED))
{
- BTM_TRACE_WARNING0 ("btm_sec_rmt_name_request_complete (none/ce)");
+ BTM_TRACE_WARNING ("btm_sec_rmt_name_request_complete (none/ce)");
p_dev_rec->security_required &= ~(BTM_SEC_OUT_AUTHENTICATE);
l2cu_start_post_bond_timer(p_dev_rec->hci_handle);
return;
@@ -3296,7 +3296,7 @@
if (p_dev_rec->sm4 & BTM_SM4_REQ_PEND)
{
- BTM_TRACE_EVENT0 ("waiting for remote features!!");
+ BTM_TRACE_EVENT ("waiting for remote features!!");
return;
}
@@ -3330,7 +3330,7 @@
STREAM_TO_BDADDR (bd_addr, p);
p_dev_rec = btm_find_or_alloc_dev (bd_addr);
- BTM_TRACE_EVENT2 ("btm_sec_rmt_host_support_feat_evt sm4: 0x%x p[0]: 0x%x", p_dev_rec->sm4, p[0]);
+ BTM_TRACE_EVENT ("btm_sec_rmt_host_support_feat_evt sm4: 0x%x p[0]: 0x%x", p_dev_rec->sm4, p[0]);
if (BTM_SEC_IS_SM4_UNKNOWN(p_dev_rec->sm4))
{
@@ -3340,7 +3340,7 @@
{
p_dev_rec->sm4 = BTM_SM4_TRUE;
}
- BTM_TRACE_EVENT2 ("btm_sec_rmt_host_support_feat_evt sm4: 0x%x features[0]: 0x%x", p_dev_rec->sm4, features[0]);
+ BTM_TRACE_EVENT ("btm_sec_rmt_host_support_feat_evt sm4: 0x%x features[0]: 0x%x", p_dev_rec->sm4, features[0]);
}
}
@@ -3372,12 +3372,12 @@
evt_data.oob_data = BTM_OOB_NONE;
evt_data.auth_req = BTM_DEFAULT_AUTH_REQ;
- BTM_TRACE_EVENT1 ("btm_io_capabilities_req() State: %s", btm_pair_state_descr(btm_cb.pairing_state));
+ BTM_TRACE_EVENT ("btm_io_capabilities_req() State: %s", btm_pair_state_descr(btm_cb.pairing_state));
p_dev_rec = btm_find_or_alloc_dev (evt_data.bd_addr);
p_dev_rec->sm4 |= BTM_SM4_TRUE;
- BTM_TRACE_EVENT3 ("btm_io_capabilities_req() State: %s Flags: 0x%04x p_cur_service: 0x%08x",
+ BTM_TRACE_EVENT ("btm_io_capabilities_req() State: %s Flags: 0x%04x p_cur_service: 0x%08x",
btm_pair_state_descr(btm_cb.pairing_state), btm_cb.pairing_flags, p_dev_rec->p_cur_service);
if (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE)
@@ -3485,7 +3485,7 @@
btm_cb.devcb.loc_auth_req = evt_data.auth_req;
btm_cb.devcb.loc_io_caps = evt_data.io_cap;
- BTM_TRACE_EVENT4 ("btm_io_capabilities_req: State: %s IO_CAP:%d oob_data:%d auth_req:%d",
+ BTM_TRACE_EVENT ("btm_io_capabilities_req: State: %s IO_CAP:%d oob_data:%d auth_req:%d",
btm_pair_state_descr(btm_cb.pairing_state), evt_data.io_cap,
evt_data.oob_data, evt_data.auth_req);
@@ -3580,7 +3580,7 @@
/* All events start with bd_addr */
STREAM_TO_BDADDR (p_bda, p);
- BTM_TRACE_EVENT4 ("btm_proc_sp_req_evt() BDA: %08x%04x event: 0x%x, State: %s",
+ BTM_TRACE_EVENT ("btm_proc_sp_req_evt() BDA: %08x%04x event: 0x%x, State: %s",
(p_bda[0]<<24) + (p_bda[1]<<16) + (p_bda[2]<<8) + p_bda[3], (p_bda[4] << 8) + p_bda[5],
event, btm_pair_state_descr(btm_cb.pairing_state));
@@ -3615,7 +3615,7 @@
evt_data.cfm_req.just_works = FALSE;
}
#endif
- BTM_TRACE_DEBUG5 ("btm_proc_sp_req_evt() just_works:%d, io loc:%d, rmt:%d, auth loc:%d, rmt:%d",
+ BTM_TRACE_DEBUG ("btm_proc_sp_req_evt() just_works:%d, io loc:%d, rmt:%d, auth loc:%d, rmt:%d",
evt_data.cfm_req.just_works, btm_cb.devcb.loc_io_caps, p_dev_rec->rmt_io_caps,
btm_cb.devcb.loc_auth_req, p_dev_rec->rmt_auth_req);
@@ -3629,7 +3629,7 @@
/* Passkey notification (other side is a keyboard) */
STREAM_TO_UINT32 (evt_data.key_notif.passkey, p);
- BTM_TRACE_DEBUG1 ("BTM_SP_KEY_NOTIF_EVT: passkey: %u", evt_data.key_notif.passkey);
+ BTM_TRACE_DEBUG ("BTM_SP_KEY_NOTIF_EVT: passkey: %u", evt_data.key_notif.passkey);
btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE);
break;
@@ -3659,7 +3659,7 @@
if (event == BTM_SP_CFM_REQ_EVT)
{
- BTM_TRACE_DEBUG1 ("calling BTM_ConfirmReqReply with status: %d", status);
+ BTM_TRACE_DEBUG ("calling BTM_ConfirmReqReply with status: %d", status);
BTM_ConfirmReqReply (status, p_bda);
}
#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
@@ -3748,13 +3748,13 @@
if ((p_dev_rec = btm_find_dev (evt_data.bd_addr)) == NULL)
{
- BTM_TRACE_ERROR2 ("btm_simple_pair_complete() with unknown BDA: %08x%04x",
+ BTM_TRACE_ERROR ("btm_simple_pair_complete() with unknown BDA: %08x%04x",
(evt_data.bd_addr[0]<<24) + (evt_data.bd_addr[1]<<16) + (evt_data.bd_addr[2]<<8) + evt_data.bd_addr[3],
(evt_data.bd_addr[4] << 8) + evt_data.bd_addr[5]);
return;
}
- BTM_TRACE_EVENT3 ("btm_simple_pair_complete() Pair State: %s Status:%d sec_state: %u",
+ BTM_TRACE_EVENT ("btm_simple_pair_complete() Pair State: %s Status:%d sec_state: %u",
btm_pair_state_descr(btm_cb.pairing_state), status, p_dev_rec->sec_state);
evt_data.status = BTM_ERR_PROCESSING;
@@ -3829,7 +3829,7 @@
STREAM_TO_BDADDR (p_bda, p);
- BTM_TRACE_EVENT6 ("btm_rem_oob_req() BDA: %02x:%02x:%02x:%02x:%02x:%02x",
+ BTM_TRACE_EVENT ("btm_rem_oob_req() BDA: %02x:%02x:%02x:%02x:%02x:%02x",
p_bda[0], p_bda[1], p_bda[2], p_bda[3], p_bda[4], p_bda[5]);
if ( (NULL != (p_dev_rec = btm_find_dev (p_bda))) &&
@@ -3868,7 +3868,7 @@
tBTM_SP_LOC_OOB evt_data;
UINT8 status = *p++;
- BTM_TRACE_EVENT1 ("btm_read_local_oob_complete:%d", status);
+ BTM_TRACE_EVENT ("btm_read_local_oob_complete:%d", status);
if (status == HCI_SUCCESS)
{
evt_data.status = BTM_SUCCESS;
@@ -3912,7 +3912,7 @@
if (p_dev_rec != NULL)
{
- BTM_TRACE_DEBUG1 ("btm_sec_auth_collision: state %d (retrying in a moment...)", p_dev_rec->sec_state);
+ BTM_TRACE_DEBUG ("btm_sec_auth_collision: state %d (retrying in a moment...)", p_dev_rec->sec_state);
/* We will restart authentication after timeout */
if (p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING || p_dev_rec->sec_state == BTM_SEC_STATE_ENCRYPTING)
p_dev_rec->sec_state = 0;
@@ -3946,7 +3946,7 @@
#if (BT_USE_TRACES == TRUE)
if (p_dev_rec)
{
- BTM_TRACE_EVENT6 ("Security Manager: auth_complete PairState: %s handle:%u status:%d dev->sec_state: %u Bda:%08x, RName:%s",
+ BTM_TRACE_EVENT ("Security Manager: auth_complete PairState: %s handle:%u status:%d dev->sec_state: %u Bda:%08x, RName:%s",
btm_pair_state_descr (btm_cb.pairing_state),
handle, status,
p_dev_rec->sec_state,
@@ -3955,7 +3955,7 @@
}
else
{
- BTM_TRACE_EVENT3 ("Security Manager: auth_complete PairState: %s handle:%u status:%d",
+ BTM_TRACE_EVENT ("Security Manager: auth_complete PairState: %s handle:%u status:%d",
btm_pair_state_descr (btm_cb.pairing_state),
handle, status);
}
@@ -4061,7 +4061,7 @@
{
/* not retried yet. set the retry bit */
p_dev_rec->sm4 |= BTM_SM4_RETRY;
- BTM_TRACE_DEBUG2 ("Collision retry sm4:x%x sec_flags:0x%x", p_dev_rec->sm4, p_dev_rec->sec_flags);
+ BTM_TRACE_DEBUG ("Collision retry sm4:x%x sec_flags:0x%x", p_dev_rec->sm4, p_dev_rec->sec_flags);
}
/* this retry for missing key is for Lisbon or later only.
* Legacy device do not need this. the controller will drive the retry automatically */
@@ -4070,7 +4070,7 @@
/* not retried yet. set the retry bit */
p_dev_rec->sm4 |= BTM_SM4_RETRY;
p_dev_rec->sec_flags &= ~BTM_SEC_LINK_KEY_KNOWN;
- BTM_TRACE_DEBUG2 ("Retry for missing key sm4:x%x sec_flags:0x%x", p_dev_rec->sm4, p_dev_rec->sec_flags);
+ BTM_TRACE_DEBUG ("Retry for missing key sm4:x%x sec_flags:0x%x", p_dev_rec->sm4, p_dev_rec->sec_flags);
/* With BRCM controller, we do not need to delete the stored link key in controller.
If the stack may sit on top of other controller, we may need this
@@ -4118,7 +4118,7 @@
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle);
UINT8 bd_addr[BD_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} ;
- BTM_TRACE_EVENT2 ("Security Manager: mkey comp status:%d State:%d",
+ BTM_TRACE_EVENT ("Security Manager: mkey comp status:%d State:%d",
status, (p_dev_rec) ? p_dev_rec->sec_state : 0);
/* If encryption setup failed, notify the waiting layer */
@@ -4149,9 +4149,9 @@
tACL_CONN *p_acl = NULL;
UINT8 acl_idx = btm_handle_to_acl_index(handle);
#endif
- BTM_TRACE_EVENT3 ("Security Manager: encrypt_change status:%d State:%d, encr_enable = %d",
+ BTM_TRACE_EVENT ("Security Manager: encrypt_change status:%d State:%d, encr_enable = %d",
status, (p_dev_rec) ? p_dev_rec->sec_state : 0, encr_enable);
- BTM_TRACE_DEBUG1 ("before update p_dev_rec->sec_flags=0x%x", (p_dev_rec) ? p_dev_rec->sec_flags : 0 );
+ BTM_TRACE_DEBUG ("before update p_dev_rec->sec_flags=0x%x", (p_dev_rec) ? p_dev_rec->sec_flags : 0 );
/* For transaction collision we need to wait and repeat. There is no need */
/* for random timeout because only slave should receive the result */
@@ -4183,7 +4183,7 @@
p_dev_rec->sec_flags &= ~BTM_SEC_LE_ENCRYPTED;
}
- BTM_TRACE_DEBUG1 ("after update p_dev_rec->sec_flags=0x%x", p_dev_rec->sec_flags );
+ BTM_TRACE_DEBUG ("after update p_dev_rec->sec_flags=0x%x", p_dev_rec->sec_flags );
#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
if (acl_idx != MAX_L2CAP_LINKS )
@@ -4275,13 +4275,13 @@
tBTM_SEC_DEV_REC *p_dev_rec = btm_cb.p_collided_dev_rec;
UNUSED(p_tle);
- BTM_TRACE_EVENT0 ("btm_sec_connect_after_reject_timeout()");
+ BTM_TRACE_EVENT ("btm_sec_connect_after_reject_timeout()");
btm_cb.sec_collision_tle.param = 0;
btm_cb.p_collided_dev_rec = 0;
if (btm_sec_dd_create_conn(p_dev_rec) != BTM_CMD_STARTED)
{
- BTM_TRACE_WARNING0 ("Security Manager: btm_sec_connect_after_reject_timeout: failed to start connection");
+ BTM_TRACE_WARNING ("Security Manager: btm_sec_connect_after_reject_timeout: failed to start connection");
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
@@ -4316,14 +4316,14 @@
#if (BT_USE_TRACES == TRUE)
if (p_dev_rec)
{
- BTM_TRACE_EVENT6 ("Security Manager: btm_sec_connected in state: %s handle:%d status:%d enc_mode:%d bda:%x RName:%s",
+ BTM_TRACE_EVENT ("Security Manager: btm_sec_connected in state: %s handle:%d status:%d enc_mode:%d bda:%x RName:%s",
btm_pair_state_descr(btm_cb.pairing_state), handle, status, enc_mode,
(bda[2]<<24)+(bda[3]<<16)+(bda[4]<<8)+bda[5],
p_dev_rec->sec_bd_name);
}
else
{
- BTM_TRACE_EVENT5 ("Security Manager: btm_sec_connected in state: %s handle:%d status:%d enc_mode:%d bda:%x ",
+ BTM_TRACE_EVENT ("Security Manager: btm_sec_connected in state: %s handle:%d status:%d enc_mode:%d bda:%x ",
btm_pair_state_descr(btm_cb.pairing_state), handle, status, enc_mode,
(bda[2]<<24)+(bda[3]<<16)+(bda[4]<<8)+bda[5]);
}
@@ -4361,7 +4361,7 @@
/* Motorola S9 disconnects without asking pin code */
if ((status != HCI_SUCCESS)&&(btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_PIN_REQ))
{
- BTM_TRACE_WARNING0 ("Security Manager: btm_sec_connected: incoming connection failed without asking PIN");
+ BTM_TRACE_WARNING ("Security Manager: btm_sec_connected: incoming connection failed without asking PIN");
p_dev_rec->sm4 &= ~BTM_SM4_CONN_PEND;
if (p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN)
@@ -4409,7 +4409,7 @@
if ((status == HCI_ERR_HOST_REJECT_DEVICE)
&&(btm_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT))
{
- BTM_TRACE_WARNING2 ("Security Manager: btm_sec_connected: HCI_Conn_Comp Flags:0x%04x, sm4: 0x%x",
+ BTM_TRACE_WARNING ("Security Manager: btm_sec_connected: HCI_Conn_Comp Flags:0x%04x, sm4: 0x%x",
btm_cb.pairing_flags, p_dev_rec->sm4);
btm_cb.pairing_flags &= ~BTM_PAIR_FLAGS_REJECTED_CONNECT;
@@ -4436,7 +4436,7 @@
/* wait for incoming connection without resetting pairing state */
else if (status == HCI_ERR_CONNECTION_EXISTS)
{
- BTM_TRACE_WARNING0 ("Security Manager: btm_sec_connected: Wait for incoming connection");
+ BTM_TRACE_WARNING ("Security Manager: btm_sec_connected: Wait for incoming connection");
return;
}
@@ -4454,7 +4454,7 @@
{
p_dev_rec->security_required &= ~BTM_SEC_OUT_AUTHENTICATE;
p_dev_rec->sec_flags &= ~((BTM_SEC_LINK_KEY_KNOWN | BTM_SEC_LINK_KEY_AUTHED) << bit_shift);
- BTM_TRACE_DEBUG1 ("security_required:%x ", p_dev_rec->security_required );
+ BTM_TRACE_DEBUG ("security_required:%x ", p_dev_rec->security_required );
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
@@ -4585,7 +4585,7 @@
/* After connection is established we perform security if we do not know */
/* the name, or if we are originator because some procedure can have */
/* been scheduled while connection was down */
- BTM_TRACE_DEBUG1 ("is_originator:%d ", p_dev_rec->is_originator);
+ BTM_TRACE_DEBUG ("is_originator:%d ", p_dev_rec->is_originator);
if (!(p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN) || p_dev_rec->is_originator)
{
if ((res = btm_sec_execute_procedure (p_dev_rec)) != BTM_CMD_STARTED)
@@ -4609,7 +4609,7 @@
tBTM_SEC_DEV_REC *p_dev_rec = (tBTM_SEC_DEV_REC *)p_ref_data;
UINT8 res;
- BTM_TRACE_EVENT0 ("Security Manager: role changed");
+ BTM_TRACE_EVENT ("Security Manager: role changed");
/* If this role switch was started by peer do not need to do anything */
if (p_dev_rec->sec_state != BTM_SEC_STATE_SWITCHING_ROLE)
@@ -4700,18 +4700,18 @@
p_dev_rec->rs_disc_pending = BTM_SEC_RS_NOT_PENDING; /* reset flag */
#if BTM_DISC_DURING_RS == TRUE
- BTM_TRACE_ERROR0("btm_sec_disconnected - Clearing Pending flag");
+ BTM_TRACE_ERROR("btm_sec_disconnected - Clearing Pending flag");
p_dev_rec->rs_disc_pending = BTM_SEC_RS_NOT_PENDING; /* reset flag */
#endif
/* clear unused flags */
p_dev_rec->sm4 &= BTM_SM4_TRUE;
- BTM_TRACE_EVENT6("btm_sec_disconnected() sec_req:x%x State: %s reason:%d bda:%04x%08x RName:%s",
+ BTM_TRACE_EVENT("btm_sec_disconnected() sec_req:x%x State: %s reason:%d bda:%04x%08x RName:%s",
p_dev_rec->security_required, btm_pair_state_descr(btm_cb.pairing_state), reason, (p_dev_rec->bd_addr[0]<<8)+p_dev_rec->bd_addr[1],
(p_dev_rec->bd_addr[2]<<24)+(p_dev_rec->bd_addr[3]<<16)+(p_dev_rec->bd_addr[4]<<8)+p_dev_rec->bd_addr[5], p_dev_rec->sec_bd_name);
- BTM_TRACE_EVENT1("before Update sec_flags=0x%x", p_dev_rec->sec_flags);
+ BTM_TRACE_EVENT("before Update sec_flags=0x%x", p_dev_rec->sec_flags);
/* If we are in the process of bonding we need to tell client that auth failed */
if ( (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE)
@@ -4768,7 +4768,7 @@
(*p_callback) (p_dev_rec->bd_addr, transport, p_dev_rec->p_ref_data, BTM_ERR_PROCESSING);
}
- BTM_TRACE_EVENT1("after Update sec_flags=0x%x", p_dev_rec->sec_flags);
+ BTM_TRACE_EVENT("after Update sec_flags=0x%x", p_dev_rec->sec_flags);
}
/*******************************************************************************
@@ -4786,7 +4786,7 @@
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (p_bda);
BOOLEAN we_are_bonding = FALSE;
- BTM_TRACE_EVENT3 ("btm_sec_link_key_notification() BDA:%04x%08x, TYPE: %d",
+ BTM_TRACE_EVENT ("btm_sec_link_key_notification() BDA:%04x%08x, TYPE: %d",
(p_bda[0]<<8)+p_bda[1], (p_bda[2]<<24)+(p_bda[3]<<16)+(p_bda[4]<<8)+p_bda[5],
key_type);
@@ -4820,7 +4820,7 @@
if ((!(p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN)
&& ((p_dev_rec->dev_class[1] & BTM_COD_MAJOR_CLASS_MASK) != BTM_COD_MAJOR_PERIPHERAL)) )
{
- BTM_TRACE_EVENT3 ("btm_sec_link_key_notification() Delayed BDA: %08x%04x Type:%d",
+ BTM_TRACE_EVENT ("btm_sec_link_key_notification() Delayed BDA: %08x%04x Type:%d",
(p_bda[0]<<24) + (p_bda[1]<<16) + (p_bda[2]<<8) + p_bda[3], (p_bda[4] << 8) + p_bda[5], key_type);
p_dev_rec->link_key_not_sent = TRUE;
@@ -4832,7 +4832,7 @@
btm_inq_rmt_name_failed();
}
- BTM_TRACE_EVENT3 ("rmt_io_caps:%d, sec_flags:x%x, dev_class[1]:x%02x", p_dev_rec->rmt_io_caps, p_dev_rec->sec_flags, p_dev_rec->dev_class[1])
+ BTM_TRACE_EVENT ("rmt_io_caps:%d, sec_flags:x%x, dev_class[1]:x%02x", p_dev_rec->rmt_io_caps, p_dev_rec->sec_flags, p_dev_rec->dev_class[1])
return;
}
@@ -4872,7 +4872,7 @@
{
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (p_bda);
- BTM_TRACE_EVENT6 ("btm_sec_link_key_request() BDA: %02x:%02x:%02x:%02x:%02x:%02x",
+ BTM_TRACE_EVENT ("btm_sec_link_key_request() BDA: %02x:%02x:%02x:%02x:%02x:%02x",
p_bda[0], p_bda[1], p_bda[2], p_bda[3], p_bda[4], p_bda[5]);
if (p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_KNOWN)
@@ -4932,7 +4932,7 @@
*/
p_dev_rec = btm_find_dev (p_cb->pairing_bda);
- BTM_TRACE_EVENT2 ("btm_sec_pairing_timeout() State: %s Flags: %u",
+ BTM_TRACE_EVENT ("btm_sec_pairing_timeout() State: %s Flags: %u",
btm_pair_state_descr(p_cb->pairing_state), p_cb->pairing_flags);
switch (p_cb->pairing_state)
@@ -4995,7 +4995,7 @@
* now it's time to tear down the ACL link*/
if (p_dev_rec == NULL)
{
- BTM_TRACE_ERROR2 ("btm_sec_pairing_timeout() BTM_PAIR_STATE_WAIT_DISCONNECT unknown BDA: %08x%04x",
+ BTM_TRACE_ERROR ("btm_sec_pairing_timeout() BTM_PAIR_STATE_WAIT_DISCONNECT unknown BDA: %08x%04x",
(p_cb->pairing_bda[0]<<24) + (p_cb->pairing_bda[1]<<16) + (p_cb->pairing_bda[2]<<8) + p_cb->pairing_bda[3],
(p_cb->pairing_bda[4] << 8) + p_cb->pairing_bda[5]);
break;
@@ -5024,7 +5024,7 @@
break;
default:
- BTM_TRACE_WARNING1 ("btm_sec_pairing_timeout() not processed state: %s", btm_pair_state_descr(btm_cb.pairing_state));
+ BTM_TRACE_WARNING ("btm_sec_pairing_timeout() not processed state: %s", btm_pair_state_descr(btm_cb.pairing_state));
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
break;
}
@@ -5044,7 +5044,11 @@
tBTM_SEC_DEV_REC *p_dev_rec;
tBTM_CB *p_cb = &btm_cb;
- BTM_TRACE_EVENT3 ("btm_sec_pin_code_request() State: %s, BDA:%04x%08x",
+#ifdef PORCHE_PAIRING_CONFLICT
+ UINT8 default_pin_code_len = 4;
+ PIN_CODE default_pin_code = {0x30, 0x30, 0x30, 0x30};
+#endif
+ BTM_TRACE_EVENT ("btm_sec_pin_code_request() State: %s, BDA:%04x%08x",
btm_pair_state_descr(btm_cb.pairing_state),
(p_bda[0]<<8)+p_bda[1], (p_bda[2]<<24)+(p_bda[3]<<16)+(p_bda[4]<<8)+p_bda[5] );
@@ -5069,15 +5073,16 @@
else if ((btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_PIN_REQ)
|| memcmp (p_bda, btm_cb.pairing_bda, BD_ADDR_LEN) != 0)
{
- BTM_TRACE_WARNING1 ("btm_sec_pin_code_request() rejected - state: %s",
+ BTM_TRACE_WARNING ("btm_sec_pin_code_request() rejected - state: %s",
btm_pair_state_descr(btm_cb.pairing_state));
#ifdef PORCHE_PAIRING_CONFLICT
/* reply pin code again due to counter in_rand when local initiates pairing */
- BTM_TRACE_EVENT0 ("btm_sec_pin_code_request from remote dev. for local initiated pairing");
+ BTM_TRACE_EVENT ("btm_sec_pin_code_request from remote dev. for local initiated pairing");
if(! btm_cb.pin_code_len_saved)
{
- btsnd_hcic_pin_code_neg_reply (p_bda);
+ btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE);
+ btsnd_hcic_pin_code_req_reply (p_bda, default_pin_code_len, default_pin_code);
}
else
{
@@ -5106,7 +5111,7 @@
if (!p_cb->pairing_disabled && (p_cb->cfg.pin_type == HCI_PIN_TYPE_FIXED))
{
- BTM_TRACE_EVENT0 ("btm_sec_pin_code_request fixed pin replying");
+ BTM_TRACE_EVENT ("btm_sec_pin_code_request fixed pin replying");
btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE);
btsnd_hcic_pin_code_req_reply (p_bda, p_cb->cfg.pin_code_len, p_cb->cfg.pin_code);
return;
@@ -5120,7 +5125,7 @@
/* We could have started connection after asking user for the PIN code */
if (btm_cb.pin_code_len != 0)
{
- BTM_TRACE_EVENT0 ("btm_sec_pin_code_request bonding sending reply");
+ BTM_TRACE_EVENT ("btm_sec_pin_code_request bonding sending reply");
btsnd_hcic_pin_code_req_reply (p_bda, btm_cb.pin_code_len, p_cb->pin_code);
#ifdef PORCHE_PAIRING_CONFLICT
@@ -5149,7 +5154,7 @@
&& ((p_dev_rec->dev_class[1] & BTM_COD_MAJOR_CLASS_MASK) == BTM_COD_MAJOR_PERIPHERAL)
&& (p_dev_rec->dev_class[2] & BTM_COD_MINOR_KEYBOARD)) )
{
- BTM_TRACE_WARNING3("btm_sec_pin_code_request(): Pairing disabled:%d; PIN callback:%x, Dev Rec:%x!",
+ BTM_TRACE_WARNING("btm_sec_pin_code_request(): Pairing disabled:%d; PIN callback:%x, Dev Rec:%x!",
p_cb->pairing_disabled, p_cb->api.p_pin_callback, p_dev_rec);
btsnd_hcic_pin_code_neg_reply (p_bda);
@@ -5170,7 +5175,7 @@
/* Also cannot send remote name request while paging, i.e. connection is not completed */
if (p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN)
{
- BTM_TRACE_EVENT0 ("btm_sec_pin_code_request going for callback");
+ BTM_TRACE_EVENT ("btm_sec_pin_code_request going for callback");
btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD;
if (p_cb->api.p_pin_callback)
@@ -5178,7 +5183,7 @@
}
else
{
- BTM_TRACE_EVENT0 ("btm_sec_pin_code_request going for remote name");
+ BTM_TRACE_EVENT ("btm_sec_pin_code_request going for remote name");
/* We received PIN code request for the device with unknown name */
/* it is not user friendly just to ask for the PIN without name */
@@ -5190,7 +5195,7 @@
p_dev_rec->sec_flags |= BTM_SEC_NAME_KNOWN;
p_dev_rec->sec_bd_name[0] = 'f';
p_dev_rec->sec_bd_name[1] = '0';
- BTM_TRACE_ERROR0 ("can not send rmt_name_req?? fake a name and call callback");
+ BTM_TRACE_ERROR ("can not send rmt_name_req?? fake a name and call callback");
btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD;
if (p_cb->api.p_pin_callback)
@@ -5249,7 +5254,7 @@
*******************************************************************************/
static tBTM_STATUS btm_sec_execute_procedure (tBTM_SEC_DEV_REC *p_dev_rec)
{
- BTM_TRACE_EVENT3 ("btm_sec_execute_procedure: Required:0x%x Flags:0x%x State:%d",
+ BTM_TRACE_EVENT ("btm_sec_execute_procedure: Required:0x%x Flags:0x%x State:%d",
p_dev_rec->security_required, p_dev_rec->sec_flags, p_dev_rec->sec_state);
/* There is a chance that we are getting name. Wait until done. */
@@ -5260,7 +5265,7 @@
if (!(p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN)
&& (p_dev_rec->hci_handle != BTM_SEC_INVALID_HANDLE))
{
- BTM_TRACE_EVENT0 ("Security Manager: Start get name");
+ BTM_TRACE_EVENT ("Security Manager: Start get name");
if (!btm_sec_start_get_name (p_dev_rec))
{
return(BTM_NO_RESOURCES);
@@ -5281,7 +5286,7 @@
return(BTM_FAILED_ON_SECURITY);
#endif
- BTM_TRACE_EVENT0 ("Security Manager: Start authentication");
+ BTM_TRACE_EVENT ("Security Manager: Start authentication");
if (!btm_sec_start_authentication (p_dev_rec))
{
@@ -5303,7 +5308,7 @@
return(BTM_FAILED_ON_SECURITY);
#endif
- BTM_TRACE_EVENT0 ("Security Manager: Start encryption");
+ BTM_TRACE_EVENT ("Security Manager: Start encryption");
if (!btm_sec_start_encryption (p_dev_rec))
{
@@ -5318,7 +5323,7 @@
&& (( p_dev_rec->is_originator && (p_dev_rec->security_required & BTM_SEC_OUT_AUTHORIZE))
|| (!p_dev_rec->is_originator && (p_dev_rec->security_required & BTM_SEC_IN_AUTHORIZE))))
{
- BTM_TRACE_EVENT2 ("service id:%d, is trusted:%d",
+ BTM_TRACE_EVENT ("service id:%d, is trusted:%d",
p_dev_rec->p_cur_service->service_id,
(BTM_SEC_IS_SERVICE_TRUSTED(p_dev_rec->trusted_mask,
p_dev_rec->p_cur_service->service_id)));
@@ -5327,7 +5332,7 @@
(BTM_SEC_IS_SERVICE_TRUSTED(p_dev_rec->trusted_mask,
p_dev_rec->p_cur_service->service_id) == FALSE))
{
- BTM_TRACE_EVENT0 ("Security Manager: Start authorization");
+ BTM_TRACE_EVENT ("Security Manager: Start authorization");
return(btm_sec_start_authorization (p_dev_rec));
}
}
@@ -5339,8 +5344,8 @@
BTM_SEC_FORCE_MASTER | BTM_SEC_ATTEMPT_MASTER |
BTM_SEC_FORCE_SLAVE | BTM_SEC_ATTEMPT_SLAVE);
- BTM_TRACE_EVENT2 ("Security Manager: trusted:0x%04x%04x", p_dev_rec->trusted_mask[1], p_dev_rec->trusted_mask[0]);
- BTM_TRACE_EVENT0 ("Security Manager: access granted");
+ BTM_TRACE_EVENT ("Security Manager: trusted:0x%04x%04x", p_dev_rec->trusted_mask[1], p_dev_rec->trusted_mask[0]);
+ BTM_TRACE_EVENT ("Security Manager: access granted");
return(BTM_SUCCESS);
}
@@ -5457,7 +5462,7 @@
else /* Already authorized once for this L2CAP bringup */
{
- BTM_TRACE_DEBUG1 ("btm_sec_start_authorization: (Ignoring extra Authorization prompt for service %d)", service_id);
+ BTM_TRACE_DEBUG ("btm_sec_start_authorization: (Ignoring extra Authorization prompt for service %d)", service_id);
return (BTM_SUCCESS);
}
@@ -5588,7 +5593,7 @@
tBTM_SEC_SERV_REC *p_serv_rec = &btm_cb.sec_serv_rec[0];
int i;
- BTM_TRACE_DEBUG0 ("btm_sec_find_mx_serv");
+ BTM_TRACE_DEBUG ("btm_sec_find_mx_serv");
if (is_originator && p_out_serv && p_out_serv->psm == psm
&& p_out_serv->mx_proto_id == mx_proto_id
&& p_out_serv->orig_mx_chan_id == mx_chan_id)
@@ -5629,7 +5634,7 @@
tBTM_STATUS status;
UNUSED(p_tle);
- BTM_TRACE_EVENT0 ("btm_sec_collision_timeout()");
+ BTM_TRACE_EVENT ("btm_sec_collision_timeout()");
btm_cb.sec_collision_tle.param = 0;
status = btm_sec_execute_procedure (btm_cb.p_collided_dev_rec);
@@ -5701,7 +5706,7 @@
if (btm_cb.security_mode_changed)
{
btm_cb.security_mode_changed = FALSE;
- BTM_TRACE_DEBUG1("btm_restore_mode: Authen Enable -> %d", (btm_cb.security_mode == BTM_SEC_MODE_LINK));
+ BTM_TRACE_DEBUG("btm_restore_mode: Authen Enable -> %d", (btm_cb.security_mode == BTM_SEC_MODE_LINK));
btsnd_hcic_write_auth_enable ((UINT8)(btm_cb.security_mode == BTM_SEC_MODE_LINK));
}
@@ -5751,11 +5756,11 @@
{
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle);
- BTM_TRACE_EVENT2 ("BTM_snd_conn_encrypt Security Manager: encrypt_change p_dev_rec : 0x%x, enable = %s", p_dev_rec, (enable == TRUE) ? "TRUE" : "FALSE");
+ BTM_TRACE_EVENT ("BTM_snd_conn_encrypt Security Manager: encrypt_change p_dev_rec : 0x%x, enable = %s", p_dev_rec, (enable == TRUE) ? "TRUE" : "FALSE");
if (!p_dev_rec)
{
- BTM_TRACE_EVENT1 ("BTM_snd_conn_encrypt Error no p_dev_rec : 0x%x\n", p_dev_rec);
+ BTM_TRACE_EVENT ("BTM_snd_conn_encrypt Error no p_dev_rec : 0x%x\n", p_dev_rec);
return(FALSE);
}
@@ -5783,8 +5788,8 @@
{
tBTM_PAIRING_STATE old_state = btm_cb.pairing_state;
- BTM_TRACE_EVENT1 ("btm_sec_change_pairing_state Old: %s", btm_pair_state_descr(btm_cb.pairing_state));
- BTM_TRACE_EVENT2 ("btm_sec_change_pairing_state New: %s pairing_flags:0x%x",btm_pair_state_descr(new_state), btm_cb.pairing_flags);
+ BTM_TRACE_EVENT ("btm_sec_change_pairing_state Old: %s", btm_pair_state_descr(btm_cb.pairing_state));
+ BTM_TRACE_EVENT ("btm_sec_change_pairing_state New: %s pairing_flags:0x%x",btm_pair_state_descr(new_state), btm_cb.pairing_flags);
btm_cb.pairing_state = new_state;
@@ -5903,7 +5908,7 @@
memcpy (p_e->bd_addr, bd_addr, BD_ADDR_LEN);
- BTM_TRACE_EVENT4 ("btm_sec_queue_mx_request() PSM: 0x%04x Is_Orig: %u mx_proto_id: %u mx_chan_id: %u",
+ BTM_TRACE_EVENT ("btm_sec_queue_mx_request() PSM: 0x%04x Is_Orig: %u mx_proto_id: %u mx_chan_id: %u",
psm, is_orig, mx_proto_id, mx_chan_id);
GKI_enqueue (&btm_cb.sec_pending_q, p_e);
@@ -5923,7 +5928,7 @@
if ((major == BTM_COD_MAJOR_AUDIO)
&& ((minor == BTM_COD_MINOR_CONFM_HANDSFREE) || (minor == BTM_COD_MINOR_CAR_AUDIO)) )
{
- BTM_TRACE_EVENT2 ("btm_sec_check_prefetch_pin: Skipping pre-fetch PIN for carkit COD Major: 0x%02x Minor: 0x%02x", major, minor);
+ BTM_TRACE_EVENT ("btm_sec_check_prefetch_pin: Skipping pre-fetch PIN for carkit COD Major: 0x%02x Minor: 0x%02x", major, minor);
if (btm_cb.security_mode_changed == FALSE)
{
@@ -5948,7 +5953,7 @@
/* pin was not supplied - pre-fetch pin code now */
if (btm_cb.api.p_pin_callback && ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_PIN_REQD) == 0))
{
- BTM_TRACE_DEBUG0("btm_sec_check_prefetch_pin: PIN code callback called");
+ BTM_TRACE_DEBUG("btm_sec_check_prefetch_pin: PIN code callback called");
if (btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR) == NULL)
btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD;
(btm_cb.api.p_pin_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class, p_dev_rec->sec_bd_name);
@@ -5976,7 +5981,7 @@
void btm_sec_clear_ble_keys (tBTM_SEC_DEV_REC *p_dev_rec)
{
- BTM_TRACE_DEBUG0 ("btm_sec_clear_ble_keys: Clearing BLE Keys");
+ BTM_TRACE_DEBUG ("btm_sec_clear_ble_keys: Clearing BLE Keys");
#if (SMP_INCLUDED== TRUE)
p_dev_rec->ble.key_type = 0;
memset (&p_dev_rec->ble.keys, 0, sizeof(tBTM_SEC_BLE_KEYS));
@@ -6008,7 +6013,7 @@
{
is_bonded = TRUE;
}
- BTM_TRACE_DEBUG1 ("btm_sec_is_a_bonded_dev is_bonded=%d", is_bonded);
+ BTM_TRACE_DEBUG ("btm_sec_is_a_bonded_dev is_bonded=%d", is_bonded);
return(is_bonded);
}
@@ -6054,7 +6059,7 @@
int i;
if (start_idx >= BTM_SEC_MAX_DEVICE_RECORDS)
{
- BTM_TRACE_DEBUG0 ("LE bonded device not found");
+ BTM_TRACE_DEBUG ("LE bonded device not found");
return found;
}
@@ -6068,7 +6073,7 @@
break;
}
}
- BTM_TRACE_DEBUG1 ("btm_sec_find_bonded_dev=%d", found);
+ BTM_TRACE_DEBUG ("btm_sec_find_bonded_dev=%d", found);
#endif
return(found);
}
diff --git a/stack/btu/btu_hcif.c b/stack/btu/btu_hcif.c
index fa19515..23204a7 100644
--- a/stack/btu/btu_hcif.c
+++ b/stack/btu/btu_hcif.c
@@ -37,6 +37,8 @@
#include "btm_api.h"
#include "btm_int.h"
+extern void btm_process_cancel_complete(UINT8 status, UINT8 mode);
+extern void btm_ble_test_command_complete(UINT8 *p);
// btla-specific ++
#define LOG_TAG "BTLD"
@@ -192,11 +194,6 @@
#endif
)
{
-#if 0
- BT_TRACE_2 (TRACE_LAYER_HCI, TRACE_TYPE_DEBUG,
- "Storing VSC callback opcode=0x%04x, Callback function=0x%07x",
- opcode, *(UINT32 *)(p_buf + 1));
-#endif
memcpy ((UINT8 *)(p_cmd + 1), (UINT8 *)(p_buf + 1), sizeof(void *));
}
@@ -405,8 +402,7 @@
case HCI_BLE_EVENT:
STREAM_TO_UINT8 (ble_sub_code, p);
- BT_TRACE_2 (TRACE_LAYER_HCI, TRACE_TYPE_EVENT, "BLE HCI(id=%d) event = 0x%02x)",
- hci_evt_code, ble_sub_code);
+ HCI_TRACE_EVENT("BLE HCI(id=%d) event = 0x%02x)", hci_evt_code, ble_sub_code);
switch (ble_sub_code)
{
@@ -508,7 +504,7 @@
else
{
/* Unknown controller */
- BT_TRACE_1 (TRACE_LAYER_HCI, TRACE_TYPE_WARNING, "BTU HCI(ctrl id=%d) controller ID not recognized", controller_id);
+ HCI_TRACE_WARNING("BTU HCI(ctrl id=%d) controller ID not recognized", controller_id);
GKI_freebuf(p_buf);;
}
@@ -1518,8 +1514,7 @@
}
else
{
- BT_TRACE_1 (TRACE_LAYER_HCI, TRACE_TYPE_WARNING,
- "No command in queue matching opcode %d", opcode);
+ HCI_TRACE_WARNING("No command in queue matching opcode %d", opcode);
}
/* See if we can forward any more commands */
@@ -1547,7 +1542,7 @@
#if (defined(BTU_CMD_CMPL_TOUT_DOUBLE_CHECK) && BTU_CMD_CMPL_TOUT_DOUBLE_CHECK == TRUE)
if (!(p_hci_cmd_cb->checked_hcisu))
{
- BT_TRACE_1 (TRACE_LAYER_HCI, TRACE_TYPE_WARNING, "BTU HCI(id=%d) command timeout - double check HCISU", controller_id);
+ HCI_TRACE_WARNING("BTU HCI(id=%d) command timeout - double check HCISU", controller_id);
/* trigger HCISU to read any pending data in transport buffer */
GKI_send_event(HCISU_TASK, HCISU_EVT_MASK);
@@ -1569,7 +1564,7 @@
/* get queued command */
if ((p_cmd = (BT_HDR *) GKI_dequeue (&(p_hci_cmd_cb->cmd_cmpl_q))) == NULL)
{
- BT_TRACE_0 (TRACE_LAYER_HCI, TRACE_TYPE_WARNING, "Cmd timeout; no cmd in queue");
+ HCI_TRACE_WARNING("Cmd timeout; no cmd in queue");
return;
}
@@ -1592,7 +1587,7 @@
if (controller_id == NFC_CONTROLLER_ID)
{
//TODO call nfc_ncif_cmd_timeout
- BT_TRACE_2 (TRACE_LAYER_HCI, TRACE_TYPE_WARNING, "BTU NCI command timeout - header 0x%02x%02x", p[0], p[1]);
+ HCI_TRACE_WARNING("BTU NCI command timeout - header 0x%02x%02x", p[0], p[1]);
return;
}
#endif
@@ -1608,7 +1603,7 @@
ALOGE("#");
ALOGE("######################################################################");
#else
- BT_TRACE_2 (TRACE_LAYER_HCI, TRACE_TYPE_WARNING, "BTU HCI(id=%d) command timeout. opcode=0x%x", controller_id, opcode);
+ HCI_TRACE_WARNING("BTU HCI(id=%d) command timeout. opcode=0x%x", controller_id, opcode);
#endif
// btla-specific ++
@@ -1648,11 +1643,6 @@
)
{
p_cplt_cback = *((void **)(p_cmd + 1));
-#if 0
- BT_TRACE_2 (TRACE_LAYER_HCI, TRACE_TYPE_DEBUG,
- "Restoring VSC callback for opcode=0x%04x, Callback function=0x%07x",
- opcode, (UINT32)p_cplt_cback);
-#endif
}
/* fake a command complete; first create a fake event */
@@ -1669,8 +1659,7 @@
times, Bluetooth process will be killed and restarted */
if (num_hci_cmds_timed_out >= BTM_MAX_HCI_CMD_TOUT_BEFORE_RESTART)
{
- BT_TRACE_1(TRACE_LAYER_HCI, TRACE_TYPE_ERROR,
- "Num consecutive HCI Cmd tout =%d Restarting BT process",num_hci_cmds_timed_out);
+ HCI_TRACE_ERROR("Num consecutive HCI Cmd tout =%d Restarting BT process",num_hci_cmds_timed_out);
usleep(10000); /* 10 milliseconds */
/* Killing the process to force a restart as part of fault tolerance */
@@ -1678,8 +1667,7 @@
}
else
{
- BT_TRACE_1 (TRACE_LAYER_HCI, TRACE_TYPE_WARNING, "HCI Cmd timeout counter %d",
- num_hci_cmds_timed_out);
+ HCI_TRACE_WARNING("HCI Cmd timeout counter %d", num_hci_cmds_timed_out);
/* If anyone wants device status notifications, give him one */
btm_report_device_status (BTM_DEV_STATUS_CMD_TOUT);
@@ -1699,7 +1687,7 @@
*******************************************************************************/
static void btu_hcif_hardware_error_evt (UINT8 *p)
{
- BT_TRACE_1 (TRACE_LAYER_HCI, TRACE_TYPE_ERROR, "Ctlr H/w error event - code:0x%x", *p);
+ HCI_TRACE_ERROR("Ctlr H/w error event - code:0x%x", *p);
/* If anyone wants device status notifications, give him one. */
btm_report_device_status (BTM_DEV_STATUS_DOWN);
@@ -2268,7 +2256,7 @@
static void btu_ble_process_adv_pkt (UINT8 *p)
{
- BT_TRACE_0 (TRACE_LAYER_HCI, TRACE_TYPE_EVENT, "btu_ble_process_adv_pkt");
+ HCI_TRACE_EVENT("btu_ble_process_adv_pkt");
btm_ble_process_adv_pkt(p);
}
diff --git a/stack/btu/btu_init.c b/stack/btu/btu_init.c
index fe52361..c29d3e2 100644
--- a/stack/btu/btu_init.c
+++ b/stack/btu/btu_init.c
@@ -149,7 +149,7 @@
*******************************************************************************/
void btu_uipc_rx_cback(BT_HDR *p_msg)
{
- BT_TRACE_3 (TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, "btu_uipc_rx_cback event 0x%x, len %d, offset %d",
+ BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, "btu_uipc_rx_cback event 0x%x, len %d, offset %d",
p_msg->event, p_msg->len, p_msg->offset);
GKI_send_msg(BTU_TASK, BTU_HCI_RCV_MBOX, p_msg);
diff --git a/stack/btu/btu_task.c b/stack/btu/btu_task.c
index 5b5108a..a160c6e 100644
--- a/stack/btu/btu_task.c
+++ b/stack/btu/btu_task.c
@@ -170,7 +170,7 @@
#if (defined(HCISU_H4_INCLUDED) && HCISU_H4_INCLUDED == TRUE)
/* wait an event that HCISU is ready */
- BT_TRACE_0(TRACE_LAYER_BTU, TRACE_TYPE_API,
+ BT_TRACE(TRACE_LAYER_BTU, TRACE_TYPE_API,
"btu_task pending for preload complete event");
for (;;)
@@ -179,7 +179,7 @@
if (event & EVENT_MASK(GKI_SHUTDOWN_EVT))
{
/* indicates BT ENABLE abort */
- BT_TRACE_0(TRACE_LAYER_BTU, TRACE_TYPE_WARNING,
+ BT_TRACE(TRACE_LAYER_BTU, TRACE_TYPE_WARNING,
"btu_task start abort!");
return (0);
}
@@ -189,13 +189,13 @@
}
else
{
- BT_TRACE_1(TRACE_LAYER_BTU, TRACE_TYPE_WARNING,
+ BT_TRACE(TRACE_LAYER_BTU, TRACE_TYPE_WARNING,
"btu_task ignore evt %04x while pending for preload complete",
event);
}
}
- BT_TRACE_0(TRACE_LAYER_BTU, TRACE_TYPE_API,
+ BT_TRACE(TRACE_LAYER_BTU, TRACE_TYPE_API,
"btu_task received preload complete event");
#endif
diff --git a/stack/gap/gap_ble.c b/stack/gap/gap_ble.c
index d67bf5a..a9bed62 100644
--- a/stack/gap/gap_ble.c
+++ b/stack/gap/gap_ble.c
@@ -68,6 +68,7 @@
NULL,
NULL,
gap_ble_s_attr_request_cback,
+ NULL,
NULL
};
diff --git a/stack/gatt/att_protocol.c b/stack/gatt/att_protocol.c
index 51ea284..27c24a0 100644
--- a/stack/gatt/att_protocol.c
+++ b/stack/gatt/att_protocol.c
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright (C) 2008-2012 Broadcom Corporation
+ * Copyright (C) 2008-2014 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,7 +74,7 @@
BT_HDR *p_buf = NULL;
UINT8 *p;
- if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)(sizeof(BT_HDR) + 10 + L2CAP_MIN_OFFSET))) != NULL)
+ if ((p_buf = (BT_HDR *)GKI_getpoolbuf(GATT_BUF_POOL_ID)) != NULL)
{
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
@@ -347,12 +347,12 @@
/*******************************************************************************
**
-** Function attp_send_msg_to_L2CAP
+** Function attp_send_msg_to_l2cap
**
** Description Send message to L2CAP.
**
*******************************************************************************/
-BOOLEAN attp_send_msg_to_L2CAP(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP)
+tGATT_STATUS attp_send_msg_to_l2cap(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP)
{
UINT16 l2cap_ret;
@@ -366,13 +366,14 @@
{
GATT_TRACE_ERROR1("ATT failed to pass msg:0x%0x to L2CAP",
*((UINT8 *)(p_toL2CAP + 1) + p_toL2CAP->offset));
- GKI_freebuf(p_toL2CAP);
- return FALSE;
+ return GATT_INTERNAL_ERROR;
}
- else
+ else if (l2cap_ret == L2CAP_DW_CONGESTED)
{
- return TRUE;
+ GATT_TRACE_DEBUG0("ATT congested, message accepted");
+ return GATT_CONGESTED;
}
+ return GATT_SUCCESS;
}
/*******************************************************************************
@@ -459,11 +460,7 @@
if (p_msg != NULL)
{
p_msg->offset = L2CAP_MIN_OFFSET;
-
- if (attp_send_msg_to_L2CAP (p_tcb, p_msg))
- cmd_sent = GATT_SUCCESS;
- else
- cmd_sent = GATT_INTERNAL_ERROR;
+ cmd_sent = attp_send_msg_to_l2cap (p_tcb, p_msg);
}
}
return cmd_sent;
@@ -475,22 +472,26 @@
**
** Description Send a ATT command or enqueue it.
**
-** Returns TRUE if command sent, otherwise FALSE.
+** Returns GATT_SUCCESS if command sent
+** GATT_CONGESTED if command sent but channel congested
+** GATT_CMD_STARTED if command queue up in GATT
+** GATT_ERROR if command sending failure
**
*******************************************************************************/
-UINT8 attp_cl_send_cmd(tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 cmd_code, BT_HDR *p_cmd)
+tGATT_STATUS attp_cl_send_cmd(tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 cmd_code, BT_HDR *p_cmd)
{
- UINT8 att_ret = GATT_SUCCESS;
+ tGATT_STATUS att_ret = GATT_SUCCESS;
if (p_tcb != NULL)
{
cmd_code &= ~GATT_AUTH_SIGN_MASK;
+ /* no pending request or value confirmation */
if (p_tcb->pending_cl_req == p_tcb->next_slot_inq ||
cmd_code == GATT_HANDLE_VALUE_CONF)
{
- /* no penindg request or value confirmation */
- if (attp_send_msg_to_L2CAP(p_tcb, p_cmd))
+ att_ret = attp_send_msg_to_l2cap(p_tcb, p_cmd);
+ if (att_ret == GATT_CONGESTED || att_ret == GATT_SUCCESS)
{
/* do not enq cmd if handle value confirmation or set request */
if (cmd_code != GATT_HANDLE_VALUE_CONF && cmd_code != GATT_CMD_WRITE)
@@ -509,7 +510,7 @@
}
}
else
- att_ret = GATT_ILLEGAL_PARAMETER;
+ att_ret = GATT_ERROR;
return att_ret;
}
diff --git a/stack/gatt/gatt_api.c b/stack/gatt/gatt_api.c
index 0321fe8..e3c0475 100644
--- a/stack/gatt/gatt_api.c
+++ b/stack/gatt/gatt_api.c
@@ -595,7 +595,7 @@
*******************************************************************************/
tGATT_STATUS GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_handle, UINT16 val_len, UINT8 *p_val)
{
- tGATT_STATUS cmd_status = GATT_ILLEGAL_PARAMETER;
+ tGATT_STATUS cmd_status = GATT_NO_RESOURCES;
tGATT_VALUE indication;
BT_HDR *p_msg;
@@ -612,38 +612,39 @@
GATT_TRACE_ERROR1 ("GATTS_HandleValueIndication Unknown conn_id: %u ", conn_id);
return(tGATT_STATUS) GATT_INVALID_CONN_ID;
}
+
+ if (! GATT_HANDLE_IS_VALID (attr_handle))
+ return GATT_ILLEGAL_PARAMETER;
+
indication.conn_id = conn_id;
indication.handle = attr_handle;
indication.len = val_len;
memcpy (indication.value, p_val, val_len);
indication.auth_req = GATT_AUTH_REQ_NONE;
- if (GATT_HANDLE_IS_VALID (attr_handle) )
+ if (GATT_HANDLE_IS_VALID(p_tcb->indicate_handle))
{
- if (GATT_HANDLE_IS_VALID(p_tcb->indicate_handle))
+ GATT_TRACE_DEBUG0 ("Add a pending indication");
+ if ((p_buf = gatt_add_pending_ind(p_tcb, &indication)) !=NULL)
{
- GATT_TRACE_DEBUG0 ("Add a pending indication");
- if ((p_buf = gatt_add_pending_ind(p_tcb, &indication)) !=NULL)
- {
- cmd_status = GATT_SUCCESS;
- }
- else
- {
- cmd_status = GATT_NO_RESOURCES;
- }
+ cmd_status = GATT_SUCCESS;
}
else
{
+ cmd_status = GATT_NO_RESOURCES;
+ }
+ }
+ else
+ {
- if ( (p_msg = attp_build_sr_msg (p_tcb, GATT_HANDLE_VALUE_IND, (tGATT_SR_MSG *)&indication)) != NULL)
+ if ( (p_msg = attp_build_sr_msg (p_tcb, GATT_HANDLE_VALUE_IND, (tGATT_SR_MSG *)&indication)) != NULL)
+ {
+ cmd_status = attp_send_sr_msg (p_tcb, p_msg);
+
+ if (cmd_status == GATT_SUCCESS || cmd_status == GATT_CONGESTED)
{
- cmd_status = attp_send_sr_msg (p_tcb, p_msg);
-
- if (cmd_status == GATT_SUCCESS)
- {
- p_tcb->indicate_handle = indication.handle;
- gatt_start_conf_timer(p_tcb);
- }
+ p_tcb->indicate_handle = indication.handle;
+ gatt_start_conf_timer(p_tcb);
}
}
}
diff --git a/stack/gatt/gatt_attr.c b/stack/gatt/gatt_attr.c
index 60beaa7..30fae3c 100644
--- a/stack/gatt/gatt_attr.c
+++ b/stack/gatt/gatt_attr.c
@@ -51,6 +51,7 @@
NULL,
NULL,
gatt_profile_request_cback,
+ NULL,
NULL
} ;
diff --git a/stack/gatt/gatt_cl.c b/stack/gatt/gatt_cl.c
index 930cd35..9e1f640 100644
--- a/stack/gatt/gatt_cl.c
+++ b/stack/gatt/gatt_cl.c
@@ -275,7 +275,7 @@
else
rt = GATT_INTERNAL_ERROR;
- if ((rt != GATT_SUCCESS && rt != GATT_CMD_STARTED)
+ if ((rt != GATT_SUCCESS && rt != GATT_CMD_STARTED && rt != GATT_CONGESTED)
|| (rt != GATT_CMD_STARTED && p_clcb->op_subtype == GATT_WRITE_NO_RSP))
{
if (rt != GATT_SUCCESS)
@@ -1102,15 +1102,17 @@
BOOLEAN sent = FALSE;
UINT8 rsp_code;
tGATT_CLCB *p_clcb = NULL;
+ tGATT_STATUS att_ret = GATT_SUCCESS;
while (!sent &&
p_tcb->pending_cl_req != p_tcb->next_slot_inq &&
p_cmd->to_send && p_cmd->p_cmd != NULL)
{
- sent = attp_send_msg_to_L2CAP(p_tcb, p_cmd->p_cmd);
+ att_ret = attp_send_msg_to_l2cap(p_tcb, p_cmd->p_cmd);
- if (sent)
+ if (att_ret == GATT_SUCCESS || att_ret == GATT_CONGESTED)
{
+ sent = TRUE;
p_cmd->to_send = FALSE;
p_cmd->p_cmd = NULL;
@@ -1124,10 +1126,12 @@
p_clcb = gatt_cmd_dequeue(p_tcb, &rsp_code);
/* if no ack needed, keep sending */
- sent = FALSE;
+ if (att_ret == GATT_SUCCESS)
+ sent = FALSE;
+
p_cmd = &p_tcb->cl_cmd_q[p_tcb->pending_cl_req];
/* send command complete callback here */
- gatt_end_operation(p_clcb, GATT_SUCCESS, NULL);
+ gatt_end_operation(p_clcb, att_ret, NULL);
}
}
else
diff --git a/stack/gatt/gatt_db.c b/stack/gatt/gatt_db.c
index a1b0a8a..098208f 100644
--- a/stack/gatt/gatt_db.c
+++ b/stack/gatt/gatt_db.c
@@ -423,7 +423,7 @@
BTM_SEC_LINK_KEY_KNOWN)
{
tACL_CONN *p;
- p = btm_bda_to_acl(p_tcb->peer_bda);
+ p = btm_bda_to_acl(p_tcb->peer_bda, BT_TRANSPORT_LE);
if ((p != NULL) && (p->link_role == BTM_ROLE_MASTER))
{
tBTM_BLE_SEC_ACT sec_act = BTM_BLE_SEC_ENCRYPT;
diff --git a/stack/gatt/gatt_int.h b/stack/gatt/gatt_int.h
index b6bb95c..663aa7d 100644
--- a/stack/gatt/gatt_int.h
+++ b/stack/gatt/gatt_int.h
@@ -565,7 +565,7 @@
extern tGATT_STATUS attp_send_cl_msg (tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 op_code, tGATT_CL_MSG *p_msg);
extern BT_HDR *attp_build_sr_msg(tGATT_TCB *p_tcb, UINT8 op_code, tGATT_SR_MSG *p_msg);
extern tGATT_STATUS attp_send_sr_msg (tGATT_TCB *p_tcb, BT_HDR *p_msg);
-extern BOOLEAN attp_send_msg_to_L2CAP(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP);
+extern tGATT_STATUS attp_send_msg_to_l2cap(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP);
/* utility functions */
extern UINT8 * gatt_dbg_op_name(UINT8 op_code);
@@ -596,6 +596,7 @@
extern tGATTS_PENDING_NEW_SRV_START *gatt_add_pending_new_srv_start( tGATTS_HNDL_RANGE *p_new_srv_start);
extern void gatt_free_srvc_db_buffer_app_id(tBT_UUID *p_app_id);
extern BOOLEAN gatt_update_listen_mode(void);
+extern BOOLEAN gatt_cl_send_next_cmd_inq(tGATT_TCB *p_tcb);
/* reserved handle list */
extern tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_app_id (tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid, UINT16 svc_inst);
diff --git a/stack/gatt/gatt_main.c b/stack/gatt/gatt_main.c
index 59c6759..793be64 100644
--- a/stack/gatt/gatt_main.c
+++ b/stack/gatt/gatt_main.c
@@ -46,6 +46,7 @@
/********************************************************************************/
static void gatt_le_connect_cback (BD_ADDR bd_addr, BOOLEAN connected, UINT16 reason, tBT_TRANSPORT transport);
static void gatt_le_data_ind (BD_ADDR bd_addr, BT_HDR *p_buf);
+static void gatt_le_cong_cback(BD_ADDR remote_bda, BOOLEAN congest);
static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 l2cap_cid, UINT16 psm, UINT8 l2cap_id);
static void gatt_l2cif_connect_cfm_cback (UINT16 l2cap_cid, UINT16 result);
@@ -55,6 +56,7 @@
static void gatt_l2cif_disconnect_cfm_cback (UINT16 l2cap_cid, UINT16 result);
static void gatt_l2cif_data_ind_cback (UINT16 l2cap_cid, BT_HDR *p_msg);
static void gatt_send_conn_cback (tGATT_TCB *p_tcb);
+static void gatt_l2cif_congest_cback (UINT16 cid, BOOLEAN congested);
static const tL2CAP_APPL_INFO dyn_info =
{
@@ -67,7 +69,7 @@
gatt_l2cif_disconnect_cfm_cback,
NULL,
gatt_l2cif_data_ind_cback,
- NULL,
+ gatt_l2cif_congest_cback,
NULL
} ;
@@ -110,6 +112,7 @@
fixed_reg.pL2CA_FixedConn_Cb = gatt_le_connect_cback;
fixed_reg.pL2CA_FixedData_Cb = gatt_le_data_ind;
+ fixed_reg.pL2CA_FixedCong_Cb = gatt_le_cong_cback; /* congestion callback */
fixed_reg.default_idle_tout = 0xffff; /* 0xffff default idle timeout */
L2CA_RegisterFixedChannel (L2CAP_ATT_CID, &fixed_reg);
@@ -452,6 +455,62 @@
/*******************************************************************************
**
+** Function gatt_channel_congestion
+**
+** Description This function is called to process the congestion callback
+** from lcb
+**
+** Returns void
+**
+*******************************************************************************/
+static void gatt_channel_congestion(tGATT_TCB *p_tcb, BOOLEAN congested)
+{
+ UINT8 i = 0;
+ tGATT_REG *p_reg=NULL;
+ UINT16 conn_id;
+
+ /* if uncongested, check to see if there is any more pending data */
+ if (p_tcb != NULL && congested == FALSE)
+ {
+ gatt_cl_send_next_cmd_inq(p_tcb);
+ }
+ /* notifying all applications for the connection up event */
+ for (i = 0, p_reg = gatt_cb.cl_rcb ; i < GATT_MAX_APPS; i++, p_reg++)
+ {
+ if (p_reg->in_use)
+ {
+ if (p_reg->app_cb.p_congestion_cb)
+ {
+ conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, p_reg->gatt_if);
+ (*p_reg->app_cb.p_congestion_cb)(conn_id, congested);
+ }
+ }
+ }
+}
+
+/*******************************************************************************
+**
+** Function gatt_le_cong_cback
+**
+** Description This function is called when GATT fixed channel is congested
+** or uncongested.
+**
+** Returns void
+**
+*******************************************************************************/
+static void gatt_le_cong_cback(BD_ADDR remote_bda, BOOLEAN congested)
+{
+ tGATT_TCB *p_tcb = gatt_find_tcb_by_addr(remote_bda, BT_TRANSPORT_LE);
+
+ /* if uncongested, check to see if there is any more pending data */
+ if (p_tcb != NULL)
+ {
+ gatt_channel_congestion(p_tcb, congested);
+ }
+}
+
+/*******************************************************************************
+**
** Function gatt_le_data_ind
**
** Description This function is called when data is received from L2CAP.
@@ -553,7 +612,7 @@
** Returns void
**
*******************************************************************************/
-void gatt_l2cif_connect_cfm_cback(UINT16 lcid, UINT16 result)
+static void gatt_l2cif_connect_cfm_cback(UINT16 lcid, UINT16 result)
{
tGATT_TCB *p_tcb;
tL2CAP_CFG_INFO cfg;
@@ -754,7 +813,7 @@
** Returns void
**
*******************************************************************************/
-void gatt_l2cif_disconnect_cfm_cback(UINT16 lcid, UINT16 result)
+static void gatt_l2cif_disconnect_cfm_cback(UINT16 lcid, UINT16 result)
{
tGATT_TCB *p_tcb;
UINT16 reason;
@@ -789,7 +848,7 @@
** Returns void
**
*******************************************************************************/
-void gatt_l2cif_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
+static void gatt_l2cif_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
{
tGATT_TCB *p_tcb;
@@ -806,6 +865,25 @@
/*******************************************************************************
**
+** Function gatt_l2cif_congest_cback
+**
+** Description L2CAP congestion callback
+**
+** Returns void
+**
+*******************************************************************************/
+static void gatt_l2cif_congest_cback (UINT16 lcid, BOOLEAN congested)
+{
+ tGATT_TCB *p_tcb = gatt_find_tcb_by_cid(lcid);
+
+ if (p_tcb != NULL)
+ {
+ gatt_channel_congestion(p_tcb, congested);
+ }
+}
+
+/*******************************************************************************
+**
** Function gatt_send_conn_cback
**
** Description Callback used to notify layer above about a connection.
diff --git a/stack/include/avdt_api.h b/stack/include/avdt_api.h
index beaecf6..93ed6ae 100644
--- a/stack/include/avdt_api.h
+++ b/stack/include/avdt_api.h
@@ -454,6 +454,35 @@
*******************************************************************************/
AVDT_API extern void AVDT_Deregister(void);
+
+/*******************************************************************************
+**
+** Function AVDT_SINK_Activate
+**
+** Description Activate SEP of A2DP Sink. In Use parameter is adjusted.
+** In Use will be made false in case of activation. A2DP SRC
+** will receive in_use as false and can open A2DP Sink
+** connection
+**
+** Returns void
+**
+*******************************************************************************/
+AVDT_API extern void AVDT_SINK_Activate(void);
+
+/*******************************************************************************
+**
+** Function AVDT_SINK_Deactivate
+**
+** Description Deactivate SEP of A2DP Sink. In Use parameter is adjusted.
+** In Use will be made TRUE in case of activation. A2DP SRC
+** will receive in_use as true and will not open A2DP Sink
+** connection
+**
+** Returns void.
+**
+*******************************************************************************/
+AVDT_API extern void AVDT_SINK_Deactivate(void);
+
/*******************************************************************************
**
** Function AVDT_CreateStream
diff --git a/stack/include/btm_ble_api.h b/stack/include/btm_ble_api.h
index 0bfaea9..d38c417 100644
--- a/stack/include/btm_ble_api.h
+++ b/stack/include/btm_ble_api.h
@@ -26,6 +26,7 @@
#define BTM_BLE_API_H
#include "btm_api.h"
+#include "gki.h"
#define CHNL_MAP_LEN 5
typedef UINT8 tBTM_BLE_CHNL_MAP[CHNL_MAP_LEN];
@@ -98,7 +99,6 @@
#define BTM_BLE_CONN_SUP_TOUT_MIN 0x000A
#define BTM_BLE_CONN_SUP_TOUT_MAX 0x0C80
#define BTM_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */
-#define BTM_BLE_CONN_SUP_TOUT_DEF 700
/* default connection parameters if not configured, use GAP recommend value for auto/selective connection */
/* default scan interval */
@@ -162,6 +162,58 @@
#define BTM_BLE_SIMULTANEOUS_HOST 0x01
#endif
+/* Appearance Values Reported with BTM_BLE_AD_TYPE_APPEARANCE */
+#define BTM_BLE_APPEARANCE_UKNOWN 0x0000
+#define BTM_BLE_APPEARANCE_GENERIC_PHONE 0x0040
+#define BTM_BLE_APPEARANCE_GENERIC_COMPUTER 0x0080
+#define BTM_BLE_APPEARANCE_GENERIC_WATCH 0x00C0
+#define BTM_BLE_APPEARANCE_SPORTS_WATCH 0x00C1
+#define BTM_BLE_APPEARANCE_GENERIC_CLOCK 0x0100
+#define BTM_BLE_APPEARANCE_GENERIC_DISPLAY 0x0140
+#define BTM_BLE_APPEARANCE_GENERIC_REMOTE 0x0180
+#define BTM_BLE_APPEARANCE_GENERIC_EYEGLASSES 0x01C0
+#define BTM_BLE_APPEARANCE_GENERIC_TAG 0x0200
+#define BTM_BLE_APPEARANCE_GENERIC_KEYRING 0x0240
+#define BTM_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 0x0280
+#define BTM_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 0x02C0
+#define BTM_BLE_APPEARANCE_GENERIC_THERMOMETER 0x0300
+#define BTM_BLE_APPEARANCE_THERMOMETER_EAR 0x0301
+#define BTM_BLE_APPEARANCE_GENERIC_HEART_RATE 0x0340
+#define BTM_BLE_APPEARANCE_HEART_RATE_BELT 0x0341
+#define BTM_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 0x0380
+#define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_ARM 0x0381
+#define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 0x0382
+#define BTM_BLE_APPEARANCE_GENERIC_HID 0x03C0
+#define BTM_BLE_APPEARANCE_HID_KEYBOARD 0x03C1
+#define BTM_BLE_APPEARANCE_HID_MOUSE 0x03C2
+#define BTM_BLE_APPEARANCE_HID_JOYSTICK 0x03C3
+#define BTM_BLE_APPEARANCE_HID_GAMEPAD 0x03C4
+#define BTM_BLE_APPEARANCE_HID_DIGITIZER_TABLET 0x03C5
+#define BTM_BLE_APPEARANCE_HID_CARD_READER 0x03C6
+#define BTM_BLE_APPEARANCE_HID_DIGITAL_PEN 0x03C7
+#define BTM_BLE_APPEARANCE_HID_BARCODE_SCANNER 0x03C8
+#define BTM_BLE_APPEARANCE_GENERIC_GLUCOSE 0x0400
+#define BTM_BLE_APPEARANCE_GENERIC_WALKING 0x0440
+#define BTM_BLE_APPEARANCE_WALKING_IN_SHOE 0x0441
+#define BTM_BLE_APPEARANCE_WALKING_ON_SHOE 0x0442
+#define BTM_BLE_APPEARANCE_WALKING_ON_HIP 0x0443
+#define BTM_BLE_APPEARANCE_GENERIC_CYCLING 0x0480
+#define BTM_BLE_APPEARANCE_CYCLING_COMPUTER 0x0481
+#define BTM_BLE_APPEARANCE_CYCLING_SPEED 0x0482
+#define BTM_BLE_APPEARANCE_CYCLING_CADENCE 0x0483
+#define BTM_BLE_APPEARANCE_CYCLING_POWER 0x0484
+#define BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE 0x0485
+#define BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 0x0C40
+#define BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 0x0C41
+#define BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST 0x0C42
+#define BTM_BLE_APPEARANCE_GENERIC_WEIGHT 0x0C80
+#define BTM_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS 0x1440
+#define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION 0x1441
+#define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV 0x1442
+#define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD 0x1443
+#define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV 0x1444
+
+
/* Structure returned with Rand/Encrypt complete callback */
typedef struct
{
@@ -184,14 +236,6 @@
#define BTM_BLE_POLICY_ALLOW_CONN 0x02 /* relevant to advertiser */
#define BTM_BLE_POLICY_WHITE_ALL 0x03 /* relevant to both */
-typedef struct
-{
- UINT8 adv_int_min;
- UINT8 adv_int_max;
- tBTM_BLE_CHNL_MAP chnl_map;
-
-}tBTM_BLE_ADV_PARAMS;
-
/* ADV data flag bit definition used for BTM_BLE_AD_TYPE_FLAG */
#define BTM_BLE_LIMIT_DISC_FLAG (0x01 << 0)
#define BTM_BLE_GEN_DISC_FLAG (0x01 << 1)
@@ -199,7 +243,6 @@
/* 4.1 spec adv flag for simultaneous BR/EDR+LE connection support */
#define BTM_BLE_DMT_CONTROLLER_SPT (0x01 << 3)
#define BTM_BLE_DMT_HOST_SPT (0x01 << 4)
-
#define BTM_BLE_NON_LIMIT_DISC_FLAG (0x00 ) /* lowest bit unset */
#define BTM_BLE_ADV_FLAG_MASK (BTM_BLE_LIMIT_DISC_FLAG | BTM_BLE_BREDR_NOT_SPT | BTM_BLE_GEN_DISC_FLAG)
#define BTM_BLE_LIMIT_DISC_MASK (BTM_BLE_LIMIT_DISC_FLAG )
@@ -219,8 +262,8 @@
#define BTM_BLE_AD_BIT_RANDOM_ADDR (0x00000001 << 13)
#define BTM_BLE_AD_BIT_SERVICE_32 (0x00000001 << 4)
#define BTM_BLE_AD_BIT_SERVICE_32SOL (0x00000001 << 14)
-
#define BTM_BLE_AD_BIT_PROPRIETARY (0x00000001 << 15)
+#define BTM_BLE_AD_BIT_SERVICE_128 (0x00000001 << 16) /*128-bit Service UUIDs*/
typedef UINT32 tBTM_BLE_AD_MASK;
@@ -252,6 +295,25 @@
#define BTM_BLE_AD_TYPE_MANU HCI_EIR_MANUFACTURER_SPECIFIC_TYPE /* 0xff */
typedef UINT8 tBTM_BLE_AD_TYPE;
+/* adv tx power level */
+#define BTM_BLE_ADV_TX_POWER_MIN 0 /* minimum tx power */
+#define BTM_BLE_ADV_TX_POWER_LOW 1 /* low tx power */
+#define BTM_BLE_ADV_TX_POWER_MID 2 /* middle tx power */
+#define BTM_BLE_ADV_TX_POWER_UPPER 3 /* upper tx power */
+#define BTM_BLE_ADV_TX_POWER_MAX 4 /* maximum tx power */
+typedef UINT8 tBTM_BLE_ADV_TX_POWER;
+
+
+typedef struct
+{
+ UINT8 adv_inst_max; /* max adv instance supported in controller */
+ UINT8 rpa_offloading;
+ UINT16 tot_scan_results_strg;
+ UINT8 max_irk_list_sz;
+ UINT8 filter_support;
+ UINT8 max_filter;
+}tBTM_BLE_VSC_CB;
+
/* slave preferred connection interval range */
typedef struct
{
@@ -268,7 +330,7 @@
UINT16 *p_uuid;
}tBTM_BLE_SERVICE;
-/* Service tag supported in the device */
+/* 32 bits Service supported in the device */
typedef struct
{
UINT8 num_service;
@@ -276,6 +338,12 @@
UINT32 *p_uuid;
}tBTM_BLE_32SERVICE;
+/* 128 bits Service supported in the device */
+typedef struct
+{
+ BOOLEAN list_cmpl;
+ UINT8 uuid128[MAX_UUID_SIZE];
+}tBTM_BLE_128SERVICE;
typedef struct
{
@@ -291,7 +359,6 @@
UINT8 *p_val;
}tBTM_BLE_SERVICE_DATA;
-
typedef struct
{
UINT8 adv_type;
@@ -307,17 +374,75 @@
typedef struct
{
- tBTM_BLE_SERVICE_DATA *p_service_data;
- tBTM_BLE_MANU manu; /* manufactuer data */
tBTM_BLE_INT_RANGE int_range; /* slave prefered conn interval range */
- tBTM_BLE_SERVICE services; /* services */
- tBTM_BLE_32SERVICE service_32b; /* 32 bits Service UUID */
- tBTM_BLE_32SERVICE sol_service_32b; /* List of 32 bit Service Solicitation UUIDs */
+ tBTM_BLE_MANU *p_manu; /* manufactuer data */
+ tBTM_BLE_SERVICE *p_services; /* services */
+ tBTM_BLE_128SERVICE *p_services_128b; /* 128 bits service */
+ tBTM_BLE_32SERVICE *p_service_32b; /* 32 bits Service UUID */
+ tBTM_BLE_SERVICE *p_sol_services; /* 16 bits services Solicitation UUIDs */
+ tBTM_BLE_32SERVICE *p_sol_service_32b; /* List of 32 bit Service Solicitation UUIDs */
+ tBTM_BLE_128SERVICE *p_sol_service_128b; /* List of 128 bit Service Solicitation UUIDs */
+ tBTM_BLE_PROPRIETARY *p_proprietary;
+ tBTM_BLE_SERVICE_DATA *p_service_data; /* service data */
UINT16 appearance;
UINT8 flag;
- tBTM_BLE_PROPRIETARY *p_proprietary;
+ UINT8 tx_power;
}tBTM_BLE_ADV_DATA;
+#ifndef BTM_BLE_MULTI_ADV_MAX
+#define BTM_BLE_MULTI_ADV_MAX 4
+#endif
+
+#define BTM_BLE_MULTI_ADV_INVALID 0
+
+#define BTM_BLE_MULTI_ADV_ENB_EVT 1
+#define BTM_BLE_MULTI_ADV_DISABLE_EVT 2
+#define BTM_BLE_MULTI_ADV_PARAM_EVT 3
+#define BTM_BLE_MULTI_ADV_DATA_EVT 4
+typedef UINT8 tBTM_BLE_MULTI_ADV_EVT;
+
+#define BTM_BLE_MULTI_ADV_DEFAULT_STD 0
+
+typedef struct
+{
+ UINT16 adv_int_min;
+ UINT16 adv_int_max;
+ UINT8 adv_type;
+ tBTM_BLE_ADV_CHNL_MAP channel_map;
+ tBTM_BLE_AFP adv_filter_policy;
+ tBTM_BLE_ADV_TX_POWER tx_power;
+}tBTM_BLE_ADV_PARAMS;
+
+typedef struct
+{
+ UINT8 sub_code[BTM_BLE_MULTI_ADV_MAX];
+ UINT8 inst_id[BTM_BLE_MULTI_ADV_MAX];
+ UINT8 pending_idx;
+ UINT8 next_idx;
+}tBTM_BLE_MULTI_ADV_OPQ;
+
+typedef void (tBTM_BLE_MULTI_ADV_CBACK)(tBTM_BLE_MULTI_ADV_EVT evt, UINT8 inst_id,
+ void *p_ref, tBTM_STATUS status);
+
+typedef struct
+{
+ UINT8 inst_id;
+ UINT8 adv_evt;
+ BD_ADDR rpa;
+ TIMER_LIST_ENT raddr_timer_ent;
+ void *p_rpa_cback;
+ tBTM_BLE_MULTI_ADV_CBACK *p_cback;
+ void *p_ref;
+}tBTM_BLE_MULTI_ADV_INST;
+
+typedef struct
+{
+ tBTM_BLE_MULTI_ADV_INST adv_inst[BTM_BLE_MULTI_ADV_MAX];
+ tBTM_BLE_MULTI_ADV_OPQ op_q;
+ UINT8 adv_inst_max; /* max adv instance supported in controller */
+}tBTM_BLE_MULTI_ADV_CB;
+
+
/* These are the fields returned in each device adv packet. It
** is returned in the results callback if registered.
*/
@@ -341,6 +466,7 @@
typedef UINT8 tBTM_BLE_CONN_TYPE;
typedef BOOLEAN (tBTM_BLE_SEL_CBACK)(BD_ADDR random_bda, UINT8 *p_remote_name);
+typedef void (tBTM_BLE_CTRL_FEATURES_CBACK)(tBTM_STATUS status);
/* callback function for SMP signing algorithm, signed data in little endian order with tlen bits long */
typedef void (tBTM_BLE_SIGN_CBACK)(void *p_ref_data, UINT8 *p_signing_data);
@@ -454,7 +580,18 @@
*******************************************************************************/
BTM_API extern void BTM_BleSetScanParams(UINT16 scan_interval, UINT16 scan_window,
tBTM_BLE_SCAN_MODE scan_type);
-
+/*******************************************************************************
+**
+** Function BTM_BleGetVendorCapabilities
+**
+** Description This function reads local LE features
+**
+** Parameters p_cmn_vsc_cb : Locala LE capability structure
+**
+** Returns void
+**
+*******************************************************************************/
+BTM_API extern void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb);
/*******************************************************************************
**
** Function BTM_BleWriteScanRsp
@@ -722,6 +859,19 @@
*******************************************************************************/
BTM_API extern void BTM_BleSetConnScanParams (UINT16 scan_interval, UINT16 scan_window);
+/******************************************************************************
+**
+** Function BTM_BleReadControllerFeatures
+**
+** Description Reads BLE specific controller features
+**
+** Parameters: tBTM_BLE_CTRL_FEATURES_CBACK : Callback to notify when features are read
+**
+** Returns void
+**
+*******************************************************************************/
+BTM_API extern void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback);
+
/*******************************************************************************
**
** Function BTM_CheckAdvData
@@ -796,6 +946,19 @@
/*******************************************************************************
**
+** Function BTM_BleLocalPrivacyEnabled
+**
+** Description Checks if local device supports private address
+**
+** Returns Return TRUE if local privacy is enabled else FALSE
+**
+*******************************************************************************/
+BTM_API extern BOOLEAN BTM_BleLocalPrivacyEnabled();
+
+
+
+/*******************************************************************************
+**
** Function BTM_BleSetConnMode
**
** Description This function is called to set BLE connectable mode for a
@@ -913,6 +1076,74 @@
*******************************************************************************/
BTM_API extern tBTM_STATUS BTM_BleStackEnable (BOOLEAN enable);
+/*******************************************************************************/
+/* Multi ADV API */
+/*******************************************************************************
+**
+** Function BTM_BleEnableAdvInstance
+**
+** Description This function enable a Multi-ADV instance with the specified
+** adv parameters
+**
+** Parameters p_params: pointer to the adv parameter structure, set as default
+** adv parameter when the instance is enabled.
+** p_cback: callback function for the adv instance.
+** p_ref: reference data attach to the adv instance to be enabled.
+**
+** Returns status
+**
+*******************************************************************************/
+BTM_API extern tBTM_STATUS BTM_BleEnableAdvInstance (tBTM_BLE_ADV_PARAMS *p_params,
+ tBTM_BLE_MULTI_ADV_CBACK *p_cback,
+ void *p_ref);
+
+/*******************************************************************************
+**
+** Function BTM_BleUpdateAdvInstParam
+**
+** Description This function update a Multi-ADV instance with the specififed
+** adv parameters.
+**
+** Parameters inst_id: adv instance ID
+** p_params: pointer to the adv parameter structure.
+**
+** Returns status
+**
+*******************************************************************************/
+BTM_API extern tBTM_STATUS BTM_BleUpdateAdvInstParam (UINT8 inst_id, tBTM_BLE_ADV_PARAMS *p_params);
+
+/*******************************************************************************
+**
+** Function BTM_BleCfgAdvInstData
+**
+** Description This function configure a Multi-ADV instance with the specified
+** adv data or scan response data.
+**
+** Parameters inst_id: adv instance ID
+** is_scan_rsp: is this scacn response, if no set as adv data.
+** data_mask: adv data mask.
+** p_data: pointer to the adv data structure.
+**
+** Returns status
+**
+*******************************************************************************/
+BTM_API extern tBTM_STATUS BTM_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
+ tBTM_BLE_AD_MASK data_mask,
+ tBTM_BLE_ADV_DATA *p_data);
+
+/*******************************************************************************
+**
+** Function BTM_BleDisableAdvInstance
+**
+** Description This function disable a Multi-ADV instance.
+**
+** Parameters inst_id: adv instance ID
+**
+** Returns status
+**
+*******************************************************************************/
+BTM_API extern tBTM_STATUS BTM_BleDisableAdvInstance (UINT8 inst_id);
+
#ifdef __cplusplus
}
#endif
diff --git a/stack/include/gatt_api.h b/stack/include/gatt_api.h
index 9da7d9c..392b4b2 100644
--- a/stack/include/gatt_api.h
+++ b/stack/include/gatt_api.h
@@ -61,6 +61,7 @@
#define GATT_ENCRYPED_MITM GATT_SUCCESS
#define GATT_ENCRYPED_NO_MITM 0x8d
#define GATT_NOT_ENCRYPTED 0x8e
+#define GATT_CONGESTED 0x8f
/* 0xE0 ~ 0xFC reserved for future use */
#define GATT_CCC_CFG_ERR 0xFD /* Client Characteristic Configuration Descriptor Improperly Configured */
@@ -573,6 +574,9 @@
typedef void (tGATT_REQ_CBACK )(UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYPE type,
tGATTS_DATA *p_data);
+/* channel congestion/uncongestion callback */
+typedef void (tGATT_CONGESTION_CBACK )(UINT16 conn_id, BOOLEAN congested);
+
/* Define a callback function when encryption is established. */
typedef void (tGATT_ENC_CMPL_CB)(tGATT_IF gatt_if, BD_ADDR bda);
@@ -589,6 +593,7 @@
tGATT_DISC_CMPL_CB *p_disc_cmpl_cb;
tGATT_REQ_CBACK *p_req_cb;
tGATT_ENC_CMPL_CB *p_enc_cmpl_cb;
+ tGATT_CONGESTION_CBACK *p_congestion_cb;
} tGATT_CBACK;
/*********************** Start Handle Management Definitions **********************
diff --git a/stack/include/hcidefs.h b/stack/include/hcidefs.h
index 14ae893..4c0b604 100644
--- a/stack/include/hcidefs.h
+++ b/stack/include/hcidefs.h
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright (C) 1999-2012 Broadcom Corporation
+ * Copyright (C) 1999-2014 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -334,6 +334,22 @@
#define HCI_BLE_TRANSMITTER_TEST (0x001E | HCI_GRP_BLE_CMDS)
#define HCI_BLE_TEST_END (0x001F | HCI_GRP_BLE_CMDS)
+/* LE Get Vendor Capabilities Command OCF */
+#define HCI_BLE_VENDOR_CAP_OCF (0x0153 | HCI_GRP_VENDOR_SPECIFIC)
+
+/* Multi adv OCF */
+#define HCI_BLE_MULTI_ADV_OCF (0x0154 | HCI_GRP_VENDOR_SPECIFIC)
+
+/* subcode for multi adv feature */
+#define BTM_BLE_MULTI_ADV_SET_PARAM 0x01
+#define BTM_BLE_MULTI_ADV_WRITE_ADV_DATA 0x02
+#define BTM_BLE_MULTI_ADV_WRITE_SCAN_RSP_DATA 0x03
+#define BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR 0x04
+#define BTM_BLE_MULTI_ADV_ENB 0x05
+
+/* multi adv VSE subcode */
+#define HCI_VSE_SUBCODE_BLE_MULTI_ADV_ST_CHG 0x55 /* multi adv instance state change */
+
/* LE supported states definition */
#define HCI_LE_ADV_STATE 0x00000001
#define HCI_LE_SCAN_STATE 0x00000002
diff --git a/stack/include/l2c_api.h b/stack/include/l2c_api.h
index 54c7ddb..c85d76b 100644
--- a/stack/include/l2c_api.h
+++ b/stack/include/l2c_api.h
@@ -929,12 +929,21 @@
*/
typedef void (tL2CA_FIXED_DATA_CB) (BD_ADDR, BT_HDR *);
+/* Congestion status callback protype. This callback is optional. If
+** an application tries to send data when the transmit queue is full,
+** the data will anyways be dropped. The parameter is:
+** remote BD_ADDR
+** TRUE if congested, FALSE if uncongested
+*/
+typedef void (tL2CA_FIXED_CONGESTION_STATUS_CB) (BD_ADDR, BOOLEAN);
+
/* Fixed channel registration info (the callback addresses and channel config)
*/
typedef struct
{
tL2CA_FIXED_CHNL_CB *pL2CA_FixedConn_Cb;
tL2CA_FIXED_DATA_CB *pL2CA_FixedData_Cb;
+ tL2CA_FIXED_CONGESTION_STATUS_CB *pL2CA_FixedCong_Cb;
tL2CAP_FCR_OPTS fixed_chnl_opts;
UINT16 default_idle_tout;
diff --git a/stack/l2cap/l2c_api.c b/stack/l2cap/l2c_api.c
index 338a7cd..d79d3f2 100644
--- a/stack/l2cap/l2c_api.c
+++ b/stack/l2cap/l2c_api.c
@@ -1435,6 +1435,7 @@
|| (l2cb.fixed_reg[fixed_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb == NULL) )
{
L2CAP_TRACE_ERROR1 ("L2CA_SendFixedChnlData() Invalid CID: 0x%04x", fixed_cid);
+ GKI_freebuf (p_buf);
return (L2CAP_DW_FAILED);
}
@@ -1442,6 +1443,7 @@
if (!BTM_IsDeviceUp())
{
L2CAP_TRACE_WARNING1 ("L2CA_SendFixedChnlData(0x%04x) - BTU not ready", fixed_cid);
+ GKI_freebuf (p_buf);
return (L2CAP_DW_FAILED);
}
@@ -1451,12 +1453,14 @@
p_lcb->link_state == LST_DISCONNECTING)
{
L2CAP_TRACE_WARNING1 ("L2CA_SendFixedChnlData(0x%04x) - no LCB", fixed_cid);
+ GKI_freebuf (p_buf);
return (L2CAP_DW_FAILED);
}
if ((p_lcb->peer_chnl_mask[0] & (1 << fixed_cid)) == 0)
{
L2CAP_TRACE_WARNING1 ("L2CA_SendFixedChnlData() - peer does not support fixed chnl: 0x%04x", fixed_cid);
+ GKI_freebuf (p_buf);
return (L2CAP_DW_FAILED);
}
@@ -1468,10 +1472,22 @@
if (!l2cu_initialize_fixed_ccb (p_lcb, fixed_cid, &l2cb.fixed_reg[fixed_cid - L2CAP_FIRST_FIXED_CHNL].fixed_chnl_opts))
{
L2CAP_TRACE_WARNING1 ("L2CA_SendFixedChnlData() - no CCB for chnl: 0x%4x", fixed_cid);
+ GKI_freebuf (p_buf);
return (L2CAP_DW_FAILED);
}
}
+ /* If already congested, do not accept any more packets */
+ if (p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->cong_sent)
+ {
+ L2CAP_TRACE_ERROR3 ("L2CAP - CID: 0x%04x cannot send, already congested \
+ xmit_hold_q.count: %u buff_quota: %u", fixed_cid,
+ p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->xmit_hold_q.count,
+ p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->buff_quota);
+ GKI_freebuf (p_buf);
+ return (L2CAP_DW_FAILED);
+ }
+
l2c_enqueue_peer_data (p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL], p_buf);
l2c_link_check_send_pkts (p_lcb, NULL, NULL);
@@ -1482,6 +1498,9 @@
l2cu_no_dynamic_ccbs (p_lcb);
}
+ if (p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->cong_sent)
+ return (L2CAP_DW_CONGESTED);
+
return (L2CAP_DW_SUCCESS);
}
diff --git a/stack/l2cap/l2c_ble.c b/stack/l2cap/l2c_ble.c
index 0e6c73a..7a20250 100644
--- a/stack/l2cap/l2c_ble.c
+++ b/stack/l2cap/l2c_ble.c
@@ -36,6 +36,9 @@
#define L2CA_SET_UPD_ST(x, y) x = (((x) & ~UPD_ST_MASK) | (y))
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
+#include "vendor_ble.h"
+#endif
/*******************************************************************************
**
** Function L2CA_CancelBleConnectReq
@@ -627,7 +630,7 @@
if (p_dev_rec->ble.active_addr_type == BTM_BLE_ADDR_RRA)
{
init_addr_type = BLE_ADDR_RANDOM;
- memcpy(init_addr, p_dev_rec->ble.cur_rand_addr, BD_ADDR_LEN);
+ //memcpy(init_addr, p_dev_rec->ble.cur_rand_addr, BD_ADDR_LEN);
}
/* if privacy is on and current do not consider using reconnection address */
if (btm_cb.ble_ctr_cb.privacy ) /* && p_dev_rec->ble.use_reconn_addr */
@@ -640,6 +643,15 @@
L2CAP_TRACE_ERROR0("initate direct connection fail, topology limitation");
return FALSE;
}
+#if BLE_PRIVACY_SPT == TRUE
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
+ extern tBTM_STATUS BTM_BleEnableIRKFeature(BOOLEAN enable);
+ if (btm_ble_vendor_irk_list_load_dev(p_dev_rec))
+ BTM_BleEnableIRKFeature(TRUE);
+
+ btm_random_pseudo_to_public(init_addr, &init_addr_type);
+#endif
+#endif
if (!btsnd_hcic_ble_create_ll_conn (scan_int,/* UINT16 scan_int */
scan_win, /* UINT16 scan_win */
FALSE, /* UINT8 white_list */
@@ -651,9 +663,9 @@
(UINT16) ((p_dev_rec->conn_params.max_conn_int != BTM_BLE_CONN_PARAM_UNDEF) ?
p_dev_rec->conn_params.max_conn_int : BTM_BLE_CONN_INT_MAX_DEF), /* conn_int_max */
(UINT16) ((p_dev_rec->conn_params.slave_latency != BTM_BLE_CONN_PARAM_UNDEF) ?
- p_dev_rec->conn_params.slave_latency : 0), /* UINT16 conn_latency */
+ p_dev_rec->conn_params.slave_latency : BTM_BLE_CONN_SLAVE_LATENCY_DEF), /* UINT16 conn_latency */
(UINT16) ((p_dev_rec->conn_params.supervision_tout != BTM_BLE_CONN_PARAM_UNDEF) ?
- p_dev_rec->conn_params.supervision_tout : BTM_BLE_CONN_SUP_TOUT_DEF), /* conn_timeout */
+ p_dev_rec->conn_params.supervision_tout : BTM_BLE_CONN_TIMEOUT_DEF), /* conn_timeout */
0, /* UINT16 min_len */
0)) /* UINT16 max_len */
{
diff --git a/stack/l2cap/l2c_csm.c b/stack/l2cap/l2c_csm.c
index 4e24c23..d8c4ed3 100644
--- a/stack/l2cap/l2c_csm.c
+++ b/stack/l2cap/l2c_csm.c
@@ -1015,6 +1015,7 @@
#if BTM_PWR_MGR_INCLUDED == TRUE
{
tBTM_PM_PWR_MD settings;
+ memset((void*)&settings, 0, sizeof(settings));
settings.mode = BTM_PM_MD_ACTIVE;
BTM_SetPowerMode (BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr, &settings);
}
@@ -1038,6 +1039,7 @@
#if BTM_PWR_MGR_INCLUDED == TRUE
{
tBTM_PM_PWR_MD settings;
+ memset((void*)&settings, 0, sizeof(settings));
settings.mode = BTM_PM_MD_ACTIVE;
BTM_SetPowerMode (BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr, &settings);
}
diff --git a/stack/l2cap/l2c_fcr.c b/stack/l2cap/l2c_fcr.c
index f2e72ad..4447b5b 100644
--- a/stack/l2cap/l2c_fcr.c
+++ b/stack/l2cap/l2c_fcr.c
@@ -254,14 +254,14 @@
UINT32 throughput_avg, ack_delay_avg, ack_q_count_avg;
dur = GKI_OS_TICKS_TO_MS(dur);
- BT_TRACE_2(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC,
+ BT_TRACE(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC,
"--- L2CAP ERTM Stats for CID: 0x%04x Duration: %08ums", p_ccb->local_cid, dur);
- BT_TRACE_4(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC,
+ BT_TRACE(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC,
"Retransmissions:%08u Times Flow Controlled:%08u Retrans Touts:%08u Ack Touts:%08u",
p_ccb->fcrb.pkts_retransmitted, p_ccb->fcrb.xmit_window_closed, p_ccb->fcrb.retrans_touts, p_ccb->fcrb.xmit_ack_touts);
- BT_TRACE_1(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC,
+ BT_TRACE(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC,
"Times there is less than 2 packets in controller when flow controlled:%08u", p_ccb->fcrb.controller_idle);
- BT_TRACE_2(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC,
+ BT_TRACE(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC,
"max_held_acks:%08u, in_cfg.fcr.tx_win_sz:%08u", p_ccb->fcrb.max_held_acks, p_ccb->peer_cfg.fcr.tx_win_sz );
if (p_str)
{
@@ -270,14 +270,14 @@
(dur >= 10 ? (p_ccb->fcrb.ertm_byte_counts[0] * 100) / (dur / 10) : 0),
p_ccb->fcrb.s_frames_sent[0], p_ccb->fcrb.s_frames_sent[1], p_ccb->fcrb.s_frames_sent[2], p_ccb->fcrb.s_frames_sent[3]);
- BT_TRACE_1(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC, "%s", p_str);
+ BT_TRACE(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC, "%s", p_str);
sprintf(p_str, "Rcvd Pkts:%08u Bytes:%10u(%06u/sec) RR:%08u REJ:%08u RNR:%08u SREJ:%08u",
p_ccb->fcrb.ertm_pkt_counts[1], p_ccb->fcrb.ertm_byte_counts[1],
(dur >= 10 ? (p_ccb->fcrb.ertm_byte_counts[1] * 100) / (dur / 10) : 0),
p_ccb->fcrb.s_frames_rcvd[0], p_ccb->fcrb.s_frames_rcvd[1], p_ccb->fcrb.s_frames_rcvd[2], p_ccb->fcrb.s_frames_rcvd[3]);
- BT_TRACE_1(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC, "%s", p_str);
+ BT_TRACE(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC, "%s", p_str);
throughput_avg = 0;
ack_delay_avg = 0;
@@ -287,7 +287,7 @@
{
if (i == p_ccb->fcrb.ack_delay_avg_index )
{
- BT_TRACE_1(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC,
+ BT_TRACE(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC,
"[%02u] collecting data ...", i );
continue;
}
@@ -297,7 +297,7 @@
p_ccb->fcrb.ack_delay_avg[i], p_ccb->fcrb.ack_delay_min[i], p_ccb->fcrb.ack_delay_max[i],
p_ccb->fcrb.ack_q_count_avg[i], p_ccb->fcrb.ack_q_count_min[i], p_ccb->fcrb.ack_q_count_max[i] );
- BT_TRACE_1(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC, "%s", p_str);
+ BT_TRACE(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC, "%s", p_str);
throughput_avg += p_ccb->fcrb.throughput[i];
ack_delay_avg += p_ccb->fcrb.ack_delay_avg[i];
@@ -308,14 +308,14 @@
ack_delay_avg /= (L2CAP_ERTM_STATS_NUM_AVG - 1);
ack_q_count_avg /= (L2CAP_ERTM_STATS_NUM_AVG - 1);
- BT_TRACE_3(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC,
+ BT_TRACE(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC,
"throughput_avg: %8u (kbytes/sec), ack_delay_avg: %8u ms, ack_q_count_avg: %8u",
throughput_avg, ack_delay_avg, ack_q_count_avg );
GKI_freebuf(p_str);
}
- BT_TRACE_0(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC,
+ BT_TRACE(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC,
"---");
}
#endif
@@ -2690,7 +2690,7 @@
p_ccb->fcrb.ack_delay_avg[index], p_ccb->fcrb.ack_delay_min[index], p_ccb->fcrb.ack_delay_max[index],
p_ccb->fcrb.ack_q_count_avg[index], p_ccb->fcrb.ack_q_count_min[index], p_ccb->fcrb.ack_q_count_max[index] );
- BT_TRACE_1(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC, "%s", str);
+ BT_TRACE(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC, "%s", str);
index = (index + 1) % L2CAP_ERTM_STATS_NUM_AVG;
p_ccb->fcrb.ack_delay_avg_index = index;
diff --git a/stack/l2cap/l2c_utils.c b/stack/l2cap/l2c_utils.c
index 23b7584..1a0edc8 100644
--- a/stack/l2cap/l2c_utils.c
+++ b/stack/l2cap/l2c_utils.c
@@ -3250,6 +3250,7 @@
if ((p_buf = l2c_fcr_get_next_xmit_sdu_seg(p_ccb, 0)) != NULL)
{
+ l2cu_check_channel_congestion (p_ccb);
l2cu_set_acl_hci_header (p_buf, p_ccb);
return (p_buf);
}
@@ -3264,6 +3265,7 @@
L2CAP_TRACE_ERROR0("l2cu_get_buffer_to_send: No data to be sent");
return (NULL);
}
+ l2cu_check_channel_congestion (p_ccb);
l2cu_set_acl_hci_header (p_buf, p_ccb);
return (p_buf);
}
@@ -3391,7 +3393,7 @@
/* If the CCB queue limit is subject to a quota, check for congestion */
/* if this channel has outgoing traffic */
- if ((p_ccb->p_rcb)&&(p_ccb->buff_quota != 0))
+ if (p_ccb->buff_quota != 0)
{
/* If this channel was congested */
if ( p_ccb->cong_sent )
@@ -3400,7 +3402,7 @@
if (q_count <= (p_ccb->buff_quota / 2))
{
p_ccb->cong_sent = FALSE;
- if (p_ccb->p_rcb->api.pL2CA_CongestionStatus_Cb)
+ if (p_ccb->p_rcb && p_ccb->p_rcb->api.pL2CA_CongestionStatus_Cb)
{
L2CAP_TRACE_DEBUG3 ("L2CAP - Calling CongestionStatus_Cb (FALSE), CID: 0x%04x xmit_hold_q.count: %u buff_quota: %u",
p_ccb->local_cid, q_count, p_ccb->buff_quota);
@@ -3411,7 +3413,7 @@
l2cb.is_cong_cback_context = FALSE;
}
#if (L2CAP_UCD_INCLUDED == TRUE)
- else if ( p_ccb->local_cid == L2CAP_CONNECTIONLESS_CID )
+ else if ( p_ccb->p_rcb && p_ccb->local_cid == L2CAP_CONNECTIONLESS_CID )
{
if ( p_ccb->p_rcb->ucd.cb_info.pL2CA_UCD_Congestion_Status_Cb )
{
@@ -3422,6 +3424,21 @@
}
}
#endif
+#if (L2CAP_NUM_FIXED_CHNLS > 0)
+ else
+ {
+ UINT8 xx;
+ for (xx = 0; xx < L2CAP_NUM_FIXED_CHNLS; xx ++)
+ {
+ if (p_ccb->p_lcb->p_fixed_ccbs[xx] == p_ccb)
+ {
+ if (l2cb.fixed_reg[xx].pL2CA_FixedCong_Cb != NULL)
+ (* l2cb.fixed_reg[xx].pL2CA_FixedCong_Cb)(p_ccb->p_lcb->remote_bd_addr, FALSE);
+ break;
+ }
+ }
+ }
+#endif
}
}
else
@@ -3430,7 +3447,7 @@
if (q_count > p_ccb->buff_quota)
{
p_ccb->cong_sent = TRUE;
- if (p_ccb->p_rcb->api.pL2CA_CongestionStatus_Cb)
+ if (p_ccb->p_rcb && p_ccb->p_rcb->api.pL2CA_CongestionStatus_Cb)
{
L2CAP_TRACE_DEBUG3 ("L2CAP - Calling CongestionStatus_Cb (TRUE),CID:0x%04x,XmitQ:%u,Quota:%u",
p_ccb->local_cid, q_count, p_ccb->buff_quota);
@@ -3438,7 +3455,7 @@
(*p_ccb->p_rcb->api.pL2CA_CongestionStatus_Cb)(p_ccb->local_cid, TRUE);
}
#if (L2CAP_UCD_INCLUDED == TRUE)
- else if ( p_ccb->local_cid == L2CAP_CONNECTIONLESS_CID )
+ else if ( p_ccb->p_rcb && p_ccb->local_cid == L2CAP_CONNECTIONLESS_CID )
{
if ( p_ccb->p_rcb->ucd.cb_info.pL2CA_UCD_Congestion_Status_Cb )
{
@@ -3449,6 +3466,21 @@
}
}
#endif
+#if (L2CAP_NUM_FIXED_CHNLS > 0)
+ else
+ {
+ UINT8 xx;
+ for (xx = 0; xx < L2CAP_NUM_FIXED_CHNLS; xx ++)
+ {
+ if (p_ccb->p_lcb->p_fixed_ccbs[xx] == p_ccb)
+ {
+ if (l2cb.fixed_reg[xx].pL2CA_FixedCong_Cb != NULL)
+ (* l2cb.fixed_reg[xx].pL2CA_FixedCong_Cb)(p_ccb->p_lcb->remote_bd_addr, TRUE);
+ break;
+ }
+ }
+ }
+#endif
}
}
}
diff --git a/stack/pan/pan_api.c b/stack/pan/pan_api.c
index 29496f3..d08e527 100644
--- a/stack/pan/pan_api.c
+++ b/stack/pan/pan_api.c
@@ -466,7 +466,7 @@
}
result = BNEP_Disconnect (pcb->handle);
- if (pcb->con_state == PAN_STATE_CONNECTED)
+ if (pcb->con_state != PAN_STATE_IDLE)
pan_cb.num_conns--;
if (pan_cb.pan_bridge_req_cb && pcb->src_uuid == UUID_SERVCLASS_NAP)
diff --git a/stack/sdp/sdp_api.c b/stack/sdp/sdp_api.c
index 1471664..af35cc8 100644
--- a/stack/sdp/sdp_api.c
+++ b/stack/sdp/sdp_api.c
@@ -513,12 +513,12 @@
if ((SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE)
&& (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == 2) ) {
- printf("SDP_FindServiceInDb - p_sattr value = 0x%x serviceuuid = 0x%x\r\n", p_sattr->attr_value.v.u16, service_uuid);
+ SDP_TRACE_DEBUG2("SDP_FindServiceInDb - p_sattr value = 0x%x serviceuuid = 0x%x\r\n", p_sattr->attr_value.v.u16, service_uuid);
if(service_uuid == UUID_SERVCLASS_HDP_PROFILE)
{
if( (p_sattr->attr_value.v.u16==UUID_SERVCLASS_HDP_SOURCE) || ( p_sattr->attr_value.v.u16==UUID_SERVCLASS_HDP_SINK))
{
- printf("SDP_FindServiceInDb found HDP source or sink\n" );
+ SDP_TRACE_DEBUG0("SDP_FindServiceInDb found HDP source or sink\n" );
return (p_rec);
}
}
@@ -686,14 +686,14 @@
if (SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE)
{
- printf("uuid len=%d ", p_uuid->len);
+ SDP_TRACE_DEBUG1("uuid len=%d ", p_uuid->len);
if (p_uuid->len == 2)
{
- printf("uuid=0x%x \n", p_uuid->uu.uuid16);
+ SDP_TRACE_DEBUG1("uuid=0x%x \n", p_uuid->uu.uuid16);
}
else
{
- printf("\n");
+ SDP_TRACE_DEBUG0("\n");
}
if (sdpu_compare_uuid_with_attr (p_uuid, p_sattr))
diff --git a/stack/smp/smp_api.c b/stack/smp/smp_api.c
index 64644da..3149b09 100644
--- a/stack/smp/smp_api.c
+++ b/stack/smp/smp_api.c
@@ -131,7 +131,7 @@
tSMP_CB *p_cb = &smp_cb;
UINT8 status = SMP_PAIR_INTERNAL_ERR;
- BTM_TRACE_EVENT2 ("SMP_Pair state=%d flag=0x%x ", p_cb->state, p_cb->flags);
+ BTM_TRACE_EVENT ("SMP_Pair state=%d flag=0x%x ", p_cb->state, p_cb->flags);
if (p_cb->state != SMP_ST_IDLE || p_cb->flags & SMP_PAIR_FLAGS_WE_STARTED_DD)
{
/* pending security on going, reject this one */
@@ -172,7 +172,7 @@
UINT8 err_code = SMP_PAIR_FAIL_UNKNOWN;
BOOLEAN status = FALSE;
- BTM_TRACE_EVENT2 ("SMP_CancelPair state=%d flag=0x%x ", p_cb->state, p_cb->flags);
+ BTM_TRACE_EVENT ("SMP_CancelPair state=%d flag=0x%x ", p_cb->state, p_cb->flags);
if ( (p_cb->state != SMP_ST_IDLE) &&
(!memcmp (p_cb->pairing_bda, bd_addr, BD_ADDR_LEN)) )
{
diff --git a/stack/smp/smp_keys.c b/stack/smp/smp_keys.c
index 49612a5..5bf6c2e 100644
--- a/stack/smp/smp_keys.c
+++ b/stack/smp/smp_keys.c
@@ -110,13 +110,13 @@
SMP_TRACE_DEBUG0 ("smp_encrypt_data");
if ( (p_out == NULL ) || (key_len != SMP_ENCRYT_KEY_SIZE) )
{
- BTM_TRACE_ERROR0 ("smp_encrypt_data Failed");
+ BTM_TRACE_ERROR ("smp_encrypt_data Failed");
return(FALSE);
}
if ((p_start = (UINT8 *)GKI_getbuf((SMP_ENCRYT_DATA_SIZE*4))) == NULL)
{
- BTM_TRACE_ERROR0 ("smp_encrypt_data Failed unable to allocate buffer");
+ BTM_TRACE_ERROR ("smp_encrypt_data Failed unable to allocate buffer");
return(FALSE);
}
@@ -686,7 +686,7 @@
#if SMP_CONFORMANCE_TESTING == TRUE
if (p_cb->enable_test_confirm_val)
{
- BTM_TRACE_DEBUG0 ("Use confirm value from script");
+ BTM_TRACE_DEBUG ("Use confirm value from script");
memcpy(p_cb->confirm, p_cb->test_confirm, BT_OCTET16_LEN);
}
else
diff --git a/stack/smp/smp_l2c.c b/stack/smp/smp_l2c.c
index 02ec38e..3ba48ae 100644
--- a/stack/smp/smp_l2c.c
+++ b/stack/smp/smp_l2c.c
@@ -58,6 +58,7 @@
fixed_reg.pL2CA_FixedConn_Cb = smp_connect_cback;
fixed_reg.pL2CA_FixedData_Cb = smp_data_ind;
+ fixed_reg.pL2CA_FixedCong_Cb = NULL; /* do not handle congestion on this channel */
fixed_reg.default_idle_tout = 60; /* set 60 seconds timeout, 0xffff default idle timeout */
/* Now, register with L2CAP */
diff --git a/stack/srvc/srvc_dis.c b/stack/srvc/srvc_dis.c
index 7c4df0d..73be84b 100644
--- a/stack/srvc/srvc_dis.c
+++ b/stack/srvc/srvc_dis.c
@@ -427,6 +427,9 @@
{
UINT16 conn_id;
+ /* Initialize the DIS client if it hasn't been initialized already. */
+ srvc_eng_init();
+
/* For now we only handle one at a time */
if (dis_cb.dis_read_uuid_idx != 0xff)
return(FALSE);
diff --git a/stack/srvc/srvc_eng.c b/stack/srvc/srvc_eng.c
index bf730aa..ec1128c 100644
--- a/stack/srvc/srvc_eng.c
+++ b/stack/srvc/srvc_eng.c
@@ -41,6 +41,7 @@
NULL,
NULL,
srvc_eng_s_request_cback,
+ NULL,
NULL
} ;
/* type for action functions */
diff --git a/test/Android.mk b/test/Android.mk
index 3c3cb61..5053e7d 100644
--- a/test/Android.mk
+++ b/test/Android.mk
@@ -1,3 +1 @@
-ifneq ($(TARGET_SIMULATOR),true)
- include $(call all-subdir-makefiles)
-endif
+include $(call all-subdir-makefiles)
diff --git a/test/bluedroidtest/Android.mk b/test/bluedroidtest/Android.mk
index 864bff8..8196546 100644
--- a/test/bluedroidtest/Android.mk
+++ b/test/bluedroidtest/Android.mk
@@ -22,6 +22,9 @@
bluedroidtest.c
LOCAL_C_INCLUDES :=
+LOCAL_CFLAGS := -Wno-unused-parameter
+
+LOCAL_CFLAGS += -std=c99
LOCAL_CFLAGS += -std=c99
@@ -29,13 +32,11 @@
LOCAL_MODULE:= bdt
-LOCAL_LDLIBS += -lpthread -ldl -llog -lreadline
-LIBS_c += -lreadline
-
LOCAL_SHARED_LIBRARIES += libcutils \
libutils \
libhardware \
libhardware_legacy
-include $(BUILD_EXECUTABLE)
+LOCAL_MULTILIB := 32
+include $(BUILD_EXECUTABLE)
diff --git a/test/bluedroidtest/bluedroidtest.c b/test/bluedroidtest/bluedroidtest.c
index 8ec0e1e..4fc1559 100644
--- a/test/bluedroidtest/bluedroidtest.c
+++ b/test/bluedroidtest/bluedroidtest.c
@@ -201,7 +201,7 @@
if (n%16 == 1) {
/* store address for this line */
snprintf(addrstr, sizeof(addrstr), "%.4x",
- ((unsigned int)p-(unsigned int)data) );
+ (unsigned int)((uintptr_t)p-(uintptr_t)data) );
}
c = *p;
diff --git a/test/suite/Android.mk b/test/suite/Android.mk
index 0a66141..2f45180 100644
--- a/test/suite/Android.mk
+++ b/test/suite/Android.mk
@@ -38,4 +38,6 @@
LOCAL_CFLAGS += -std=c99 -Wall -Wno-unused-parameter -Wno-missing-field-initializers -Werror
+LOCAL_MULTILIB := 32
+
include $(BUILD_EXECUTABLE)
diff --git a/udrv/ulinux/uipc.c b/udrv/ulinux/uipc.c
index 3f8fd9b..32fbbf0 100644
--- a/udrv/ulinux/uipc.c
+++ b/udrv/ulinux/uipc.c
@@ -140,49 +140,6 @@
}
/*****************************************************************************
-**
-** Function
-**
-** Description
-**
-** Returns
-**
-*******************************************************************************/
-
-static void uipc_wait(tUIPC_CH_ID ch_id, tUIPC_EVENT wait_event_flags)
-{
- int ret;
- tUIPC_CHAN *p = &uipc_main.ch[ch_id];
-
- //BTIF_TRACE_EVENT2("WAIT UIPC CH %d EVT %x BEGIN", ch_id, wait_event_flags);
- pthread_mutex_lock(&p->cond_mutex);
- p->cond_flags |= wait_event_flags;
- ret = pthread_cond_wait(&p->cond, &p->cond_mutex);
- pthread_mutex_unlock(&p->cond_mutex);
- //BTIF_TRACE_EVENT2("WAIT UIPC CH %d EVT %x DONE", ch_id, wait_event_flags);
-}
-
-static void uipc_signal(tUIPC_CH_ID ch_id, tUIPC_EVENT event)
-{
- int ret;
- tUIPC_CHAN *p = &uipc_main.ch[ch_id];
-
- //BTIF_TRACE_EVENT2("SIGNAL UIPC CH %d EVT %x BEGIN", ch_id, dump_uipc_event(event));
- pthread_mutex_lock(&p->cond_mutex);
-
- if (event & p->cond_flags)
- {
- //BTIF_TRACE_EVENT0("UNBLOCK");
- ret = pthread_cond_signal(&p->cond);
- p->cond_flags = 0;
- }
-
- pthread_mutex_unlock(&p->cond_mutex);
-}
-
-
-
-/*****************************************************************************
** socket helper functions
*****************************************************************************/
@@ -891,7 +848,7 @@
break;
case UIPC_SET_READ_POLL_TMO:
- uipc_main.ch[ch_id].read_poll_tmo_ms = (int)param;
+ uipc_main.ch[ch_id].read_poll_tmo_ms = (intptr_t)param;
BTIF_TRACE_EVENT2("UIPC_SET_READ_POLL_TMO : CH %d, TMO %d ms", ch_id, uipc_main.ch[ch_id].read_poll_tmo_ms );
break;
diff --git a/vnd/ble/vendor_ble.c b/vnd/ble/vendor_ble.c
index 8f846ef..6229f75 100644
--- a/vnd/ble/vendor_ble.c
+++ b/vnd/ble/vendor_ble.c
@@ -101,11 +101,10 @@
if (evt_len < 1 )
{
- BTM_TRACE_ERROR1("can not interpret ADV PF filter setting callback. status = %d", status);
+ BTM_TRACE_ERROR("can not interpret ADV PF filter setting callback. status = %d", status);
return;
}
op_subcode = *p ++;
-
switch (op_subcode)
{
case BTM_BLE_META_PF_LOCAL_NAME:
@@ -133,11 +132,11 @@
case BTM_BLE_META_PF_ENABLE:
cond_type = BTM_BLE_META_PF_ENABLE;
- BTM_TRACE_DEBUG0("CS feature Enabled");
+ BTM_TRACE_DEBUG("CS feature Enabled");
break;
default:
- BTM_TRACE_ERROR1("unknow operation: %d", op_subcode);
+ BTM_TRACE_ERROR("unknow operation: %d", op_subcode);
break;
}
@@ -259,7 +258,7 @@
if (cond_type > BTM_BLE_PF_TYPE_ALL)
{
- BTM_TRACE_ERROR1("unknown PF filter condition type %d", cond_type);
+ BTM_TRACE_ERROR("unknown PF filter condition type %d", cond_type);
return BTM_BLE_INVALID_COUNTER;
}
/* for these three types of filter, always generic */
@@ -293,7 +292,7 @@
p_counter[cond_type] = btm_ble_cs_filter_max[cond_type] - num_available;
- BTM_TRACE_DEBUG1("current filter counter number = %d", p_counter[cond_type]);
+ BTM_TRACE_DEBUG("current filter counter number = %d", p_counter[cond_type]);
/* update corresponding feature mask */
if (p_counter[cond_type] > 0)
@@ -306,7 +305,7 @@
}
else
{
- BTM_TRACE_ERROR0("no matching filter counter found");
+ BTM_TRACE_ERROR("no matching filter counter found");
}
/* no matching filter located and updated */
return BTM_BLE_INVALID_COUNTER;
@@ -346,6 +345,9 @@
}
UINT8_TO_STREAM(p, action);
+ /* Filter index */
+ UINT8_TO_STREAM(p, 0);
+
if (action == BTM_BLE_SCAN_COND_ADD ||
action == BTM_BLE_SCAN_COND_DELETE)
{
@@ -398,7 +400,7 @@
}
else
{
- BTM_TRACE_ERROR0("manufacturer data PF filter update failed");
+ BTM_TRACE_ERROR("manufacturer data PF filter update failed");
}
return st;
@@ -429,6 +431,9 @@
UINT8_TO_STREAM(p, BTM_BLE_META_PF_LOCAL_NAME);
UINT8_TO_STREAM(p, action);
+ /* Filter index */
+ UINT8_TO_STREAM(p, 0);
+
if (action == BTM_BLE_SCAN_COND_ADD ||
action == BTM_BLE_SCAN_COND_DELETE)
{
@@ -452,7 +457,7 @@
}
else
{
- BTM_TRACE_ERROR0("Local Name PF filter update failed");
+ BTM_TRACE_ERROR("Local Name PF filter update failed");
}
return st;
@@ -481,6 +486,9 @@
UINT8_TO_STREAM(p, BTM_BLE_META_PF_ADDR);
UINT8_TO_STREAM(p, action);
+ /* Filter index */
+ UINT8_TO_STREAM(p, 0);
+
if (action == BTM_BLE_SCAN_COND_ADD ||
action == BTM_BLE_SCAN_COND_DELETE)
{
@@ -500,7 +508,7 @@
}
else
{
- BTM_TRACE_ERROR0("Broadcaster Address Filter Update failed");
+ BTM_TRACE_ERROR("Broadcaster Address Filter Update failed");
}
return st;
}
@@ -521,7 +529,7 @@
{
UINT8 param[BTM_BLE_META_UUID_LEN + BTM_BLE_META_HDR_LENGTH],
* p= param,
- len = BTM_BLE_META_HDR_LENGTH + 7;
+ len = BTM_BLE_META_HDR_LENGTH;
tBTM_STATUS st = BTM_ILLEGAL_VALUE;
tBTM_BLE_PF_UUID_COND *p_uuid_cond;
UINT8 evt_type;
@@ -541,7 +549,7 @@
if (p_uuid_cond == NULL && action != BTM_BLE_SCAN_COND_CLEAR)
{
- BTM_TRACE_ERROR0("Illegal param for add/delete UUID filter");
+ BTM_TRACE_ERROR("Illegal param for add/delete UUID filter");
return st;
}
@@ -553,6 +561,9 @@
UINT8_TO_STREAM(p, BTM_BLE_META_PF_ADDR);
UINT8_TO_STREAM(p, action);
+ /* Filter index */
+ UINT8_TO_STREAM(p, 0);
+
BDADDR_TO_STREAM(p, p_uuid_cond->p_target_addr->bda);
UINT8_TO_STREAM(p, p_uuid_cond->p_target_addr->type);
@@ -562,7 +573,7 @@
param,
btm_ble_vendor_scan_pf_cmpl_cback)) == BTM_NO_RESOURCES)
{
- BTM_TRACE_ERROR0("Update Address filter into controller failed.");
+ BTM_TRACE_ERROR("Update Address filter into controller failed.");
return st;
}
}
@@ -571,24 +582,12 @@
UINT8_TO_STREAM(p, evt_type);
UINT8_TO_STREAM(p, action);
- /* per BD ADDR UUID filter */
- if (p_uuid_cond && p_uuid_cond->p_target_addr)
- {
- BDADDR_TO_STREAM(p, p_uuid_cond->p_target_addr->bda);
- UINT8_TO_STREAM(p, p_uuid_cond->p_target_addr->type);
- }
- else /* generic UUID filter */
- {
- BDADDR_TO_STREAM(p, na_bda);
- UINT8_TO_STREAM(p, 0x02);
- }
+ /* Filter index */
+ UINT8_TO_STREAM(p, 0);
if (action == BTM_BLE_SCAN_COND_ADD ||
action == BTM_BLE_SCAN_COND_DELETE)
{
- UINT8_TO_STREAM(p, p_uuid_cond->cond_logic);
- len ++;
-
if (p_uuid_cond->uuid.len == LEN_UUID_16)
{
UINT16_TO_STREAM(p, p_uuid_cond->uuid.uu.uuid16);
@@ -606,7 +605,7 @@
}
else
{
- BTM_TRACE_ERROR1("illegal UUID length: %d", p_uuid_cond->uuid.len);
+ BTM_TRACE_ERROR("illegal UUID length: %d", p_uuid_cond->uuid.len);
return BTM_ILLEGAL_VALUE;
}
#if !(defined VENDOR_ADV_PCF_LEGACY && VENDOR_ADV_PCF_LEGACY == TRUE)
@@ -649,7 +648,7 @@
}
else
{
- BTM_TRACE_ERROR0("UUID filter udpating failed");
+ BTM_TRACE_ERROR("UUID filter udpating failed");
}
return st;
@@ -700,7 +699,7 @@
if (action != BTM_BLE_SCAN_COND_CLEAR)
{
- BTM_TRACE_ERROR1("unable to perform action:%d for generic adv filter type", action);
+ BTM_TRACE_ERROR("unable to perform action:%d for generic adv filter type", action);
return BTM_ILLEGAL_VALUE;
}
@@ -713,7 +712,7 @@
/* not a generic filter, and feature selection is empty */
(p_target != NULL && p_bda_filter && p_bda_filter->feat_mask == 0))
{
- BTM_TRACE_ERROR0("Error: Can not clear filter, No PF filter has been configured!");
+ BTM_TRACE_ERROR("Error: Can not clear filter, No PF filter has been configured!");
return st;
}
@@ -737,16 +736,8 @@
UINT8_TO_STREAM(p, BTM_BLE_META_PF_FEAT_SEL);
UINT8_TO_STREAM(p, BTM_BLE_SCAN_COND_CLEAR);
- if (p_target != NULL)
- {
- BDADDR_TO_STREAM(p, p_target->bda);
- UINT8_TO_STREAM(p, p_target->type);
- }
- else
- {
- BDADDR_TO_STREAM(p, na_bda);
- UINT8_TO_STREAM(p, 0x02);
- }
+ /* Filter index */
+ UINT8_TO_STREAM(p, 0);
/* set PCF selection */
UINT32_TO_STREAM(p, BTM_BLE_PF_SELECT_NONE);
@@ -796,7 +787,7 @@
if (btm_ble_vendor_cb.p_scan_pf_cback)
{
- BTM_TRACE_ERROR0("ADV PF Filter activity busy");
+ BTM_TRACE_ERROR("ADV PF Filter activity busy");
return BTM_BUSY;
}
@@ -807,7 +798,7 @@
if (p_bda_filter == NULL ||
(p_bda_filter && p_bda_filter->feat_mask == BTM_BLE_PF_SELECT_NONE))
{
- BTM_TRACE_ERROR0("No PF filter has been configured!");
+ BTM_TRACE_ERROR("No PF filter has been configured!");
return st;
}
@@ -815,16 +806,8 @@
UINT8_TO_STREAM(p, BTM_BLE_META_PF_FEAT_SEL);
UINT8_TO_STREAM(p, BTM_BLE_SCAN_COND_ADD);
- if (p_target != NULL)
- {
- BDADDR_TO_STREAM(p, p_target->bda);
- UINT8_TO_STREAM(p, p_target->type);
- }
- else
- {
- BDADDR_TO_STREAM(p, na_bda);
- UINT8_TO_STREAM(p, 0x02);
- }
+ /* Filter index */
+ UINT8_TO_STREAM(p, 0);
/* set PCF selection */
UINT32_TO_STREAM(p, p_bda_filter->feat_mask);
@@ -922,7 +905,7 @@
break;
default:
- BTM_TRACE_WARNING1("condition type [%d] not supported currently.", cond_type);
+ BTM_TRACE_WARNING("condition type [%d] not supported currently.", cond_type);
break;
}
if (st == BTM_CMD_STARTED
@@ -936,6 +919,602 @@
return st;
}
+/*******************************************************************************
+** Resolve Address Using IRK List functions
+*******************************************************************************/
+
+#if BLE_PRIVACY_SPT == TRUE
+/* Forward declaration */
+tBTM_STATUS BTM_BleEnableIRKFeature(BOOLEAN enable);
+
+/*******************************************************************************
+**
+** Function btm_ble_vendor_enq_irk_pending
+**
+** Description add target address into IRK pending operation queue
+**
+** Parameters target_bda: target device address
+** add_entry: TRUE for add entry, FALSE for remove entry
+**
+** Returns void
+**
+*******************************************************************************/
+void btm_ble_vendor_enq_irk_pending(BD_ADDR target_bda, BD_ADDR psuedo_bda, UINT8 to_add)
+{
+ tBTM_BLE_IRK_Q *p_q = &btm_ble_vendor_cb.irk_pend_q;
+
+ memcpy(p_q->irk_q[p_q->q_next], target_bda, BD_ADDR_LEN);
+ memcpy(p_q->irk_q_random_pseudo[p_q->q_next], psuedo_bda, BD_ADDR_LEN);
+ p_q->irk_q_action[p_q->q_next] = to_add;
+
+ p_q->q_next ++;
+ p_q->q_next %= BTM_CS_IRK_LIST_MAX;
+
+ return ;
+}
+/*******************************************************************************
+**
+** Function btm_ble_vendor_find_irk_pending_entry
+**
+** Description check to see if the action is in pending list
+**
+** Parameters TRUE: action pending;
+** FALSE: new action
+**
+** Returns void
+**
+*******************************************************************************/
+BOOLEAN btm_ble_vendor_find_irk_pending_entry(BD_ADDR psuedo_addr, UINT8 action)
+{
+ tBTM_BLE_IRK_Q *p_q = &btm_ble_vendor_cb.irk_pend_q;
+ UINT8 i;
+
+ for (i = p_q->q_pending; i != p_q->q_next; )
+ {
+ if (memcmp(p_q->irk_q_random_pseudo[i], psuedo_addr, BD_ADDR_LEN) == 0 &&
+ action == p_q->irk_q_action[i])
+ return TRUE;
+
+ i ++;
+ i %= BTM_CS_IRK_LIST_MAX;
+ }
+ return FALSE;
+}
+/*******************************************************************************
+**
+** Function btm_ble_vendor_deq_irk_pending
+**
+** Description add target address into IRK pending operation queue
+**
+** Parameters target_bda: target device address
+** add_entry: TRUE for add entry, FALSE for remove entry
+**
+** Returns void
+**
+*******************************************************************************/
+BOOLEAN btm_ble_vendor_deq_irk_pending(BD_ADDR target_bda, BD_ADDR psuedo_addr)
+{
+ tBTM_BLE_IRK_Q *p_q = &btm_ble_vendor_cb.irk_pend_q;
+
+ if (p_q->q_next != p_q->q_pending)
+ {
+ memcpy(target_bda, p_q->irk_q[p_q->q_pending], BD_ADDR_LEN);
+ memcpy(psuedo_addr, p_q->irk_q_random_pseudo[p_q->q_pending], BD_ADDR_LEN);
+
+ p_q->q_pending ++;
+ p_q->q_pending %= BTM_CS_IRK_LIST_MAX;
+
+ return TRUE;
+ }
+
+ return FALSE;
+
+}
+/*******************************************************************************
+**
+** Function btm_ble_vendor_find_irk_entry
+**
+** Description find IRK entry in local host IRK list by static address
+**
+** Returns IRK list entry pointer
+**
+*******************************************************************************/
+tBTM_BLE_IRK_ENTRY * btm_ble_vendor_find_irk_entry(BD_ADDR target_bda)
+{
+ tBTM_BLE_IRK_ENTRY *p_irk_entry = &btm_ble_vendor_cb.irk_list[0];
+ UINT8 i;
+
+ for (i = 0; i < BTM_CS_IRK_LIST_MAX; i ++, p_irk_entry++)
+ {
+ if (p_irk_entry->in_use && memcmp(p_irk_entry->bd_addr, target_bda, BD_ADDR_LEN) == 0)
+ {
+ return p_irk_entry ;
+ }
+ }
+ return NULL;
+}
+/*******************************************************************************
+**
+** Function btm_ble_vendor_find_irk_entry_by_psuedo_addr
+**
+** Description find IRK entry in local host IRK list by psuedo address
+**
+** Returns IRK list entry pointer
+**
+*******************************************************************************/
+tBTM_BLE_IRK_ENTRY * btm_ble_vendor_find_irk_entry_by_psuedo_addr (BD_ADDR psuedo_bda)
+{
+ tBTM_BLE_IRK_ENTRY *p_irk_entry = &btm_ble_vendor_cb.irk_list[0];
+ UINT8 i;
+
+ for (i = 0; i < BTM_CS_IRK_LIST_MAX; i ++, p_irk_entry++)
+ {
+ if (p_irk_entry->in_use && memcmp(p_irk_entry->psuedo_bda, psuedo_bda, BD_ADDR_LEN) == 0)
+ {
+ return p_irk_entry ;
+ }
+ }
+ return NULL;
+}
+/*******************************************************************************
+**
+** Function btm_ble_vendor_alloc_irk_entry
+**
+** Description allocate IRK entry in local host IRK list
+**
+** Returns IRK list index
+**
+*******************************************************************************/
+UINT8 btm_ble_vendor_alloc_irk_entry(BD_ADDR target_bda, BD_ADDR pseudo_bda)
+{
+ tBTM_BLE_IRK_ENTRY *p_irk_entry = &btm_ble_vendor_cb.irk_list[0];
+ UINT8 i;
+
+ for (i = 0; i < BTM_CS_IRK_LIST_MAX; i ++, p_irk_entry++)
+ {
+ if (!p_irk_entry->in_use)
+ {
+ memcpy(p_irk_entry->bd_addr, target_bda, BD_ADDR_LEN);
+ memcpy(p_irk_entry->psuedo_bda, pseudo_bda, BD_ADDR_LEN);
+
+ p_irk_entry->index = i;
+ p_irk_entry->in_use = TRUE;
+
+ return i;
+ }
+ }
+ return BTM_CS_IRK_LIST_INVALID;
+}
+
+/*******************************************************************************
+**
+** Function btm_ble_vendor_update_irk_list
+**
+** Description update IRK entry in local host IRK list
+**
+** Returns void
+**
+*******************************************************************************/
+void btm_ble_vendor_update_irk_list(BD_ADDR target_bda, BD_ADDR pseudo_bda, BOOLEAN add)
+{
+ tBTM_BLE_IRK_ENTRY *p_irk_entry = btm_ble_vendor_find_irk_entry(target_bda);
+ UINT8 i;
+
+ if (add)
+ {
+ if (p_irk_entry == NULL)
+ {
+ if ((i = btm_ble_vendor_alloc_irk_entry(target_bda, pseudo_bda)) == BTM_CS_IRK_LIST_INVALID)
+ {
+ BTM_TRACE_ERROR("max IRK capacity reached");
+ }
+ }
+ else
+ {
+ BTM_TRACE_WARNING(" IRK already in queue");
+ }
+ }
+ else
+ {
+ if (p_irk_entry != NULL)
+ {
+ memset(p_irk_entry, 0, sizeof(tBTM_BLE_IRK_ENTRY));
+ }
+ else
+ {
+ BTM_TRACE_ERROR("No IRK exist in list, can not remove");
+ }
+ }
+ return ;
+}
+/*******************************************************************************
+**
+** Function btm_ble_vendor_irk_vsc_op_cmpl
+**
+** Description IRK operation VSC complete handler
+**
+** Parameters
+**
+** Returns void
+**
+*******************************************************************************/
+void btm_ble_vendor_irk_vsc_op_cmpl (tBTM_VSC_CMPL *p_params)
+{
+ UINT8 status;
+ UINT8 *p = p_params->p_param_buf, op_subcode;
+ UINT16 evt_len = p_params->param_len;
+ UINT8 i;
+ tBTM_BLE_VENDOR_CB *p_cb = &btm_ble_vendor_cb;
+ BD_ADDR target_bda, pseudo_bda, rra;
+
+
+ STREAM_TO_UINT8(status, p);
+
+ evt_len--;
+
+ /*if (evt_len < 2 )
+ {
+ BTM_TRACE_ERROR("can not interpret IRK VSC cmpl callback");
+ return;
+ }*/
+ op_subcode = *p ++;
+ BTM_TRACE_DEBUG("btm_ble_vendor_irk_vsc_op_cmpl op_subcode = %d", op_subcode);
+ if (evt_len < 2 )
+ {
+ BTM_TRACE_ERROR("can not interpret IRK VSC cmpl callback");
+ return;
+ }
+
+
+ if (op_subcode == BTM_BLE_META_CLEAR_IRK_LIST)
+ {
+ if (status == HCI_SUCCESS)
+ {
+ STREAM_TO_UINT8(p_cb->irk_avail_size, p);
+ p_cb->irk_list_size = 0;
+
+ BTM_TRACE_DEBUG("p_cb->irk_list_size = %d", p_cb->irk_avail_size);
+
+ for (i = 0; i < BTM_CS_IRK_LIST_MAX; i ++)
+ memset(&p_cb->irk_list[i], 0, sizeof(tBTM_BLE_IRK_ENTRY));
+ }
+ }
+ else if (op_subcode == BTM_BLE_META_ADD_IRK_ENTRY)
+ {
+ if (!btm_ble_vendor_deq_irk_pending(target_bda, pseudo_bda))
+ {
+ BTM_TRACE_ERROR("no pending IRK operation");
+ return;
+ }
+
+ if (status == HCI_SUCCESS)
+ {
+ STREAM_TO_UINT8(p_cb->irk_avail_size, p);
+ btm_ble_vendor_update_irk_list(target_bda, pseudo_bda, TRUE);
+ }
+ else if (status == 0x07) /* BT_ERROR_CODE_MEMORY_CAPACITY_EXCEEDED */
+ {
+ p_cb->irk_avail_size = 0;
+ BTM_TRACE_ERROR("IRK Full ");
+ }
+ else
+ {
+ /* give the credit back if invalid parameter failed the operation */
+ p_cb->irk_list_size ++;
+ }
+ }
+ else if (op_subcode == BTM_BLE_META_REMOVE_IRK_ENTRY)
+ {
+ if (!btm_ble_vendor_deq_irk_pending(target_bda, pseudo_bda))
+ {
+ BTM_TRACE_ERROR("no pending IRK operation");
+ return;
+ }
+ if (status == HCI_SUCCESS)
+ {
+ STREAM_TO_UINT8(p_cb->irk_avail_size, p);
+ btm_ble_vendor_update_irk_list(target_bda, pseudo_bda, FALSE);
+ }
+ else
+ {
+ /* give the credit back if invalid parameter failed the operation */
+ if (p_cb->irk_avail_size > 0)
+ p_cb->irk_list_size --;
+ }
+
+ }
+ else if (op_subcode == BTM_BLE_META_READ_IRK_ENTRY)
+ {
+ if (status == HCI_SUCCESS)
+ {
+ //STREAM_TO_UINT8(index, p);
+ p += (1 + 16 + 1); /* skip index, IRK value, address type */
+ STREAM_TO_BDADDR(target_bda, p);
+ STREAM_TO_BDADDR(rra, p);
+
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
+ btm_ble_refresh_rra(target_bda, rra);
+#endif
+ }
+ }
+
+}
+/*******************************************************************************
+**
+** Function btm_ble_remove_irk_entry
+**
+** Description This function to remove an IRK entry from the list
+**
+** Parameters ble_addr_type: address type
+** ble_addr: LE adddress
+**
+** Returns status
+**
+*******************************************************************************/
+tBTM_STATUS btm_ble_remove_irk_entry(tBTM_SEC_DEV_REC *p_dev_rec)
+{
+ UINT8 param[20], *p;
+ tBTM_STATUS st;
+ tBTM_BLE_VENDOR_CB *p_cb = &btm_ble_vendor_cb;
+
+ p = param;
+ memset(param, 0, 20);
+
+ UINT8_TO_STREAM(p, BTM_BLE_META_REMOVE_IRK_ENTRY);
+ UINT8_TO_STREAM(p, p_dev_rec->ble.static_addr_type);
+ BDADDR_TO_STREAM(p, p_dev_rec->ble.static_addr);
+
+ if ((st = BTM_VendorSpecificCommand (HCI_VENDOR_BLE_RPA_VSC,
+ BTM_BLE_META_REMOVE_IRK_LEN,
+ param,
+ btm_ble_vendor_irk_vsc_op_cmpl))
+ != BTM_NO_RESOURCES)
+ {
+ btm_ble_vendor_enq_irk_pending(p_dev_rec->ble.static_addr, p_dev_rec->bd_addr, FALSE);
+ p_cb->irk_list_size --;
+ }
+
+ return st;
+
+}
+/*******************************************************************************
+**
+** Function btm_ble_vendor_clear_irk_list
+**
+** Description This function clears the IRK entry list
+**
+** Parameters None.
+**
+** Returns status
+**
+*******************************************************************************/
+tBTM_STATUS btm_ble_vendor_clear_irk_list(void)
+{
+ UINT8 param[20], *p;
+ tBTM_STATUS st;
+
+ p = param;
+ memset(param, 0, 20);
+
+ UINT8_TO_STREAM(p, BTM_BLE_META_CLEAR_IRK_LIST);
+
+ st = BTM_VendorSpecificCommand (HCI_VENDOR_BLE_RPA_VSC,
+ BTM_BLE_META_CLEAR_IRK_LEN,
+ param,
+ btm_ble_vendor_irk_vsc_op_cmpl);
+
+ return st;
+
+}
+/*******************************************************************************
+**
+** Function btm_ble_read_irk_entry
+**
+** Description This function read an IRK entry by index
+**
+** Parameters entry index.
+**
+** Returns status
+**
+*******************************************************************************/
+tBTM_STATUS btm_ble_read_irk_entry(BD_ADDR target_bda)
+{
+ UINT8 param[20], *p;
+ tBTM_STATUS st = BTM_UNKNOWN_ADDR;
+ tBTM_BLE_IRK_ENTRY *p_entry = btm_ble_vendor_find_irk_entry(target_bda);
+
+ if (p_entry == NULL)
+ return st;
+
+ p = param;
+ memset(param, 0, 20);
+
+ UINT8_TO_STREAM(p, BTM_BLE_META_READ_IRK_ENTRY);
+ UINT8_TO_STREAM(p, p_entry->index);
+
+ st = BTM_VendorSpecificCommand (HCI_VENDOR_BLE_RPA_VSC,
+ BTM_BLE_META_READ_IRK_LEN,
+ param,
+ btm_ble_vendor_irk_vsc_op_cmpl);
+
+ return st;
+
+}
+
+
+/*******************************************************************************
+**
+** Function btm_ble_vendor_enable_irk_list_known_dev
+**
+** Description This function add all known device with random address into
+** IRK list.
+**
+** Parameters enable: enable IRK list with known device, or disable it
+**
+** Returns status
+**
+*******************************************************************************/
+void btm_ble_vendor_irk_list_known_dev(BOOLEAN enable)
+{
+ UINT8 i;
+ UINT8 count = 0;
+ tBTM_SEC_DEV_REC *p_dev_rec = &btm_cb.sec_dev_rec[0];
+
+ /* add all known device with random address into IRK list */
+ for (i = 0; i < BTM_SEC_MAX_DEVICE_RECORDS; i ++, p_dev_rec ++)
+ {
+ if (p_dev_rec->sec_flags & BTM_SEC_IN_USE)
+ {
+ if (btm_ble_vendor_irk_list_load_dev(p_dev_rec))
+ count ++;
+ }
+ }
+
+ if ((count > 0 && enable) || !enable)
+ BTM_BleEnableIRKFeature(enable);
+
+ return ;
+}
+/*******************************************************************************
+**
+** Function btm_ble_vendor_irk_list_load_dev
+**
+** Description This function add a device which is using RPA into white list
+**
+** Parameters
+**
+** Returns status
+**
+*******************************************************************************/
+BOOLEAN btm_ble_vendor_irk_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec)
+{
+ UINT8 param[40], *p;
+ tBTM_BLE_VENDOR_CB *p_cb = &btm_ble_vendor_cb;
+ BOOLEAN rt = FALSE;
+ tBTM_BLE_IRK_ENTRY *p_irk_entry = NULL;
+ BTM_TRACE_DEBUG ("btm_ble_vendor_irk_list_load_dev:max_irk_size=%d", p_cb->irk_avail_size);
+ memset(param, 0, 40);
+
+ if (p_dev_rec != NULL && /* RPA is being used and PID is known */
+ (p_dev_rec->ble.key_type & BTM_LE_KEY_PID) != 0)
+ {
+
+ if ((p_irk_entry = btm_ble_vendor_find_irk_entry_by_psuedo_addr(p_dev_rec->bd_addr)) == NULL &&
+ btm_ble_vendor_find_irk_pending_entry(p_dev_rec->bd_addr, TRUE) == FALSE)
+ {
+
+ if (p_cb->irk_avail_size > 0)
+ {
+ p = param;
+
+ UINT8_TO_STREAM(p, BTM_BLE_META_ADD_IRK_ENTRY);
+ ARRAY_TO_STREAM(p, p_dev_rec->ble.keys.irk, BT_OCTET16_LEN);
+ UINT8_TO_STREAM(p, p_dev_rec->ble.static_addr_type);
+ BDADDR_TO_STREAM(p,p_dev_rec->ble.static_addr);
+
+ if (BTM_VendorSpecificCommand (HCI_VENDOR_BLE_RPA_VSC,
+ BTM_BLE_META_ADD_IRK_LEN,
+ param,
+ btm_ble_vendor_irk_vsc_op_cmpl)
+ != BTM_NO_RESOURCES)
+ {
+ btm_ble_vendor_enq_irk_pending(p_dev_rec->ble.static_addr, p_dev_rec->bd_addr, TRUE);
+ p_cb->irk_list_size ++;
+ rt = TRUE;
+ }
+ }
+ }
+ else
+ {
+ BTM_TRACE_ERROR("Device already in IRK list");
+ rt = TRUE;
+ }
+ }
+ else
+ {
+ BTM_TRACE_DEBUG("Device not a RPA enabled device");
+ }
+ return rt;
+}
+/*******************************************************************************
+**
+** Function btm_ble_vendor_irk_list_remove_dev
+**
+** Description This function remove the device from IRK list
+**
+** Parameters
+**
+** Returns status
+**
+*******************************************************************************/
+void btm_ble_vendor_irk_list_remove_dev(tBTM_SEC_DEV_REC *p_dev_rec)
+{
+ tBTM_BLE_VENDOR_CB *p_cs_cb = &btm_ble_vendor_cb;
+ tBTM_BLE_IRK_ENTRY *p_irk_entry;
+
+ if ((p_irk_entry = btm_ble_vendor_find_irk_entry_by_psuedo_addr(p_dev_rec->bd_addr)) != NULL &&
+ btm_ble_vendor_find_irk_pending_entry(p_dev_rec->bd_addr, FALSE) == FALSE)
+ {
+ btm_ble_remove_irk_entry(p_dev_rec);
+ }
+ else
+ {
+ BTM_TRACE_ERROR("Device not in IRK list");
+ }
+
+ if (p_cs_cb->irk_list_size == 0)
+ BTM_BleEnableIRKFeature(FALSE);
+}
+/*******************************************************************************
+**
+** Function btm_ble_vendor_disable_irk_list
+**
+** Description disable LE resolve address feature
+**
+** Parameters
+**
+** Returns status
+**
+*******************************************************************************/
+void btm_ble_vendor_disable_irk_list(void)
+{
+ BTM_BleEnableIRKFeature(FALSE);
+
+}
+
+/*******************************************************************************
+**
+** Function BTM_BleEnableIRKFeature
+**
+** Description This function is called to enable or disable the RRA
+** offloading feature.
+**
+** Parameters enable: enable or disable the RRA offloading feature
+**
+** Returns BTM_SUCCESS if successful
+**
+*******************************************************************************/
+tBTM_STATUS BTM_BleEnableIRKFeature(BOOLEAN enable)
+{
+ UINT8 param[20], *p;
+ tBTM_STATUS st = BTM_WRONG_MODE;
+ tBTM_BLE_PF_COUNT *p_bda_filter;
+
+ p = param;
+ memset(param, 0, 20);
+
+ /* select feature based on control block settings */
+ UINT8_TO_STREAM(p, BTM_BLE_META_IRK_ENABLE);
+ UINT8_TO_STREAM(p, enable ? 0x01 : 0x00);
+
+ st = BTM_VendorSpecificCommand (HCI_VENDOR_BLE_RPA_VSC, BTM_BLE_IRK_ENABLE_LEN,
+ param, btm_ble_vendor_irk_vsc_op_cmpl);
+
+ return st;
+}
+
+#endif
+
/*******************************************************************************
**
@@ -950,7 +1529,7 @@
*******************************************************************************/
void btm_ble_vendor_init(void)
{
- memset(&btm_ble_vendor_cb, 0, sizeof(tBTM_BLE_VENDOR_CB));
+ //memset(&btm_ble_vendor_cb, 0, sizeof(tBTM_BLE_VENDOR_CB));
if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
return;
diff --git a/vnd/ble/vendor_hcidefs.h b/vnd/ble/vendor_hcidefs.h
index dd2a1ca..f85e7fd 100644
--- a/vnd/ble/vendor_hcidefs.h
+++ b/vnd/ble/vendor_hcidefs.h
@@ -28,10 +28,29 @@
#ifndef VENDOR_HCIDEFS_H
#define VENDOR_HCIDEFS_H
-/* advertising data payload filter VSC */
-#define HCI_VENDOR_BLE_PCF_VSC (0x0138 | HCI_GRP_VENDOR_SPECIFIC)
+/*****************************************************************************
+** Private address resolution VSC
+******************************************************************************/
-/* BLE PCF VSC sub code */
+/* VSC */
+#define HCI_VENDOR_BLE_RPA_VSC (0x0155 | HCI_GRP_VENDOR_SPECIFIC)
+
+/* Sub codes */
+#define HCI_VENDOR_BLE_RPA_ENABLE 0x01
+#define HCI_VENDOR_BLE_RPA_ADD_IRK 0x02
+#define HCI_VENDOR_BLE_RPA_REMOVE_IRK 0x03
+#define HCI_VENDOR_BLE_RPA_CLEAR_IRK 0x04
+#define HCI_VENDOR_BLE_RPA_READ_IRK 0x05
+
+
+/*****************************************************************************
+** Advertising data payload filter VSC
+******************************************************************************/
+
+/* VSC */
+#define HCI_VENDOR_BLE_PCF_VSC (0x0157 | HCI_GRP_VENDOR_SPECIFIC)
+
+/* Sub codes */
#define BTM_BLE_META_PF_ENABLE 0x00
#define BTM_BLE_META_PF_FEAT_SEL 0x01
#define BTM_BLE_META_PF_ADDR 0x02
diff --git a/vnd/include/vendor_api.h b/vnd/include/vendor_api.h
index 3c65a35..c69c420 100644
--- a/vnd/include/vendor_api.h
+++ b/vnd/include/vendor_api.h
@@ -14,10 +14,21 @@
#include "bt_types.h"
#include "btm_api.h"
+/****************************************************************************
+** Resolvable private address offload VSC specific definitions
+******************************************************************************/
-/*************************************
-** VENDOR BLE specific definitions
-**************************************/
+enum
+{
+ BTM_BLE_PRIVACY_ENABLE,
+ BTM_BLE_PRIVACY_DISABLE
+};
+
+
+/****************************************************************************
+** Advertising packet filter VSC specific definitions
+******************************************************************************/
+
enum
{
BTM_BLE_SCAN_COND_ADD,
diff --git a/vnd/include/vendor_ble.h b/vnd/include/vendor_ble.h
index 432b55e..39c529e 100644
--- a/vnd/include/vendor_ble.h
+++ b/vnd/include/vendor_ble.h
@@ -30,9 +30,18 @@
#include "btm_ble_api.h"
#include "vendor_api.h"
+/* RPA offload VSC specifics */
+#define BTM_BLE_META_IRK_ENABLE 0x01
+#define BTM_BLE_META_ADD_IRK_ENTRY 0x02
+#define BTM_BLE_META_REMOVE_IRK_ENTRY 0x03
+#define BTM_BLE_META_CLEAR_IRK_LIST 0x04
+#define BTM_BLE_META_READ_IRK_ENTRY 0x05
+#define BTM_BLE_META_CS_RESOLVE_ADDR 0x00000001
+#define BTM_BLE_IRK_ENABLE_LEN 2
+
/* BLE meta vsc header: 1 bytes of sub_code, 1 byte of PCF action */
-#define BTM_BLE_META_HDR_LENGTH 2
-#define BTM_BLE_PF_FEAT_SEL_LEN 12
+#define BTM_BLE_META_HDR_LENGTH 3
+#define BTM_BLE_PF_FEAT_SEL_LEN 18
#define BTM_BLE_PCF_ENABLE_LEN 2
#define BTM_BLE_META_ADDR_LEN 7
#define BTM_BLE_META_UUID_LEN 40
@@ -64,6 +73,29 @@
UINT8 pf_counter[BTM_BLE_PF_TYPE_MAX]; /* number of filter indexed by tBTM_BLE_PF_COND_TYPE */
}tBTM_BLE_PF_COUNT;
+#ifndef BTM_CS_IRK_LIST_MAX
+#define BTM_CS_IRK_LIST_MAX 0x20
+#endif
+
+#define BTM_CS_IRK_LIST_INVALID 0xff
+
+typedef struct
+{
+ BOOLEAN in_use;
+ BD_ADDR bd_addr; /* must be the address used in controller */
+ BD_ADDR psuedo_bda; /* the random pseudo address */
+ UINT8 index;
+}tBTM_BLE_IRK_ENTRY;
+
+
+typedef struct
+{
+ BD_ADDR irk_q[BTM_CS_IRK_LIST_MAX];
+ BD_ADDR irk_q_random_pseudo[BTM_CS_IRK_LIST_MAX];
+ UINT8 irk_q_action[BTM_CS_IRK_LIST_MAX];
+ UINT8 q_next;
+ UINT8 q_pending;
+} tBTM_BLE_IRK_Q;
/* control block for BLE customer specific feature */
typedef struct
@@ -74,6 +106,11 @@
tBTM_BLE_PF_COUNT addr_filter_count[BTM_BLE_MAX_FILTER_COUNTER]; /* per BDA filter indexed by tBTM_BLE_PF_COND_TYPE */
tBLE_BD_ADDR cur_filter_target;
+ UINT8 irk_list_size;
+ UINT8 irk_avail_size;
+ tBTM_BLE_IRK_ENTRY irk_list[BTM_CS_IRK_LIST_MAX];
+ tBTM_BLE_IRK_Q irk_pend_q;
+
tBTM_BLE_PF_CMPL_CBACK *p_scan_pf_cback;
}tBTM_BLE_VENDOR_CB;
@@ -89,6 +126,12 @@
#define btm_ble_vendor_cb (*btm_ble_vendor_ptr)
#endif
+extern void btm_ble_vendor_irk_list_known_dev(BOOLEAN enable);
+extern tBTM_STATUS btm_ble_read_irk_entry(BD_ADDR target_bda);
+extern void btm_ble_vendor_disable_irk_list(void);
+extern BOOLEAN btm_ble_vendor_irk_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec);
+extern void btm_ble_vendor_irk_list_remove_dev(tBTM_SEC_DEV_REC *p_dev_rec);
+extern tBTM_STATUS btm_ble_enable_vendor_feature (BOOLEAN enable, UINT32 feature_bit);
extern void btm_ble_vendor_init(void);
extern BOOLEAN btm_ble_vendor_write_device_wl_attribute (tBLE_ADDR_TYPE addr_type, BD_ADDR bd_addr, UINT8 attribute);