autom4te.cache
ylwrap
-lexer.c
-parser.h
-parser.c
-
bluez.pc
include/bluetooth
src/bluetoothd
-plugins/builtin.h
audio/telephony.c
sbc/sbcdec
--- /dev/null
+#
+# Copyright (C) 2008 The Android Open Source Project
+#
+# 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.
+#
+ifneq ($(TARGET_SIMULATOR),true)
+ifeq ($(BOARD_HAVE_BLUETOOTH),true)
+ include $(all-subdir-makefiles)
+endif
+endif
--- /dev/null
+LOCAL_PATH:= $(call my-dir)
+
+# A2DP plugin
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ a2dp.c \
+ avdtp.c \
+ control.c \
+ device.c \
+ gateway.c \
+ headset.c \
+ ipc.c \
+ main.c \
+ manager.c \
+ module-bluetooth-sink.c \
+ sink.c \
+ telephony-dummy.c \
+ unix.c
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\" \
+ -DSTORAGEDIR=\"/data/misc/bluetoothd\" \
+ -DCONFIGDIR=\"/etc/bluez\" \
+ -DANDROID \
+ -D__S_IFREG=0100000 # missing from bionic stat.h
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common \
+ $(LOCAL_PATH)/../gdbus \
+ $(LOCAL_PATH)/../src \
+ $(call include-path-for, glib) \
+ $(call include-path-for, dbus)
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth \
+ libbluetoothd \
+ libdbus
+
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/bluez-plugin
+LOCAL_UNSTRIPPED_PATH := $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/bluez-plugin
+LOCAL_MODULE := audio
+
+include $(BUILD_SHARED_LIBRARY)
+
+#
+# liba2dp
+# This is linked to Audioflinger so **LGPL only**
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ liba2dp.c \
+ ipc.c \
+ ../sbc/sbc.c.arm \
+ ../sbc/sbc_primitives.c
+
+# to improve SBC performance
+LOCAL_CFLAGS:= -funroll-loops
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../sbc \
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils
+
+LOCAL_MODULE := liba2dp
+
+include $(BUILD_SHARED_LIBRARY)
# This section contains options which are not specific to any
# particular interface
[General]
+Enable=Source,Control,Sink
+Disable=Headset,Gateway
# Switch to master role for incoming connections (defaults to true)
#Master=true
# Headset interface specific options (i.e. options which affect how the audio
# service interacts with remote headset devices)
-[Headset]
+#[Headset]
-# Set to true to support HFP, false means only HSP is supported
-# Defaults to true
-HFP=true
+# Set to true to support HFP (in addition to HSP only which is the default)
+# Defaults to false
+#HFP=true
# Maximum number of connected HSP/HFP devices per adapter. Defaults to 1
-MaxConnections=1
+#MaxConnections=1
# Just an example of potential config options for the other interfaces
-#[A2DP]
-#SBCSources=1
-#MPEG12Sources=0
+[A2DP]
+SBCSources=1
+MPEG12Sources=0
+
+[AVRCP]
+InputDeviceName=AVRCP
#define BACKWARD_OP 0x4c
static DBusConnection *connection = NULL;
-
+static gchar *input_device_name = NULL;
static GSList *servers = NULL;
#if __BYTE_ORDER == __LITTLE_ENDIAN
static void init_uinput(struct control *control)
{
- char address[18];
+ char address[18], *name;
ba2str(&control->dev->dst, address);
- control->uinput = uinput_create(address);
+ /* Use device name from config file if specified */
+ name = input_device_name;
+ if (!name)
+ name = address;
+
+ control->uinput = uinput_create(name);
if (control->uinput < 0)
error("AVRCP: failed to init uinput for %s", address);
else
g_error_free(err);
} else
master = tmp;
+ err = NULL;
+ input_device_name = g_key_file_get_string(config,
+ "AVRCP", "InputDeviceName", &err);
+ if (err) {
+ debug("audio.conf: %s", err->message);
+ input_device_name = NULL;
+ g_error_free(err);
+ }
}
server = g_new0(struct avctp_server, 1);
--- /dev/null
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2006-2007 Nokia Corporation
+ * Copyright (C) 2004-2008 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdint.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <signal.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pthread.h>
+
+#include <netinet/in.h>
+#include <sys/poll.h>
+#include <sys/prctl.h>
+
+#include "ipc.h"
+#include "sbc.h"
+#include "rtp.h"
+#include "liba2dp.h"
+
+#define LOG_NDEBUG 0
+#define LOG_TAG "A2DP"
+#include <utils/Log.h>
+
+#define ENABLE_DEBUG
+/* #define ENABLE_VERBOSE */
+/* #define ENABLE_TIMING */
+
+#define BUFFER_SIZE 2048
+
+#ifdef ENABLE_DEBUG
+#define DBG LOGD
+#else
+#define DBG(fmt, arg...)
+#endif
+
+#ifdef ENABLE_VERBOSE
+#define VDBG LOGV
+#else
+#define VDBG(fmt, arg...)
+#endif
+
+#ifndef MIN
+# define MIN(x, y) ((x) < (y) ? (x) : (y))
+#endif
+
+#ifndef MAX
+# define MAX(x, y) ((x) > (y) ? (x) : (y))
+#endif
+
+#define MAX_BITPOOL 64
+#define MIN_BITPOOL 2
+
+#define ERR LOGE
+
+/* Number of packets to buffer in the stream socket */
+#define PACKET_BUFFER_COUNT 10
+
+/* timeout in milliseconds to prevent poll() from hanging indefinitely */
+#define POLL_TIMEOUT 1000
+
+/* timeout in milliseconds for a2dp_write */
+#define WRITE_TIMEOUT 100
+
+
+typedef enum {
+ A2DP_STATE_NONE = 0,
+ A2DP_STATE_INITIALIZED,
+ A2DP_STATE_CONFIGURING,
+ A2DP_STATE_CONFIGURED,
+ A2DP_STATE_STARTING,
+ A2DP_STATE_STARTED,
+ A2DP_STATE_STOPPING,
+} a2dp_state_t;
+
+typedef enum {
+ A2DP_CMD_NONE = 0,
+ A2DP_CMD_CONFIGURE,
+ A2DP_CMD_START,
+ A2DP_CMD_STOP,
+ A2DP_CMD_QUIT,
+} a2dp_command_t;
+
+struct bluetooth_data {
+ int link_mtu; /* MTU for transport channel */
+ struct pollfd stream; /* Audio stream filedescriptor */
+ struct pollfd server; /* Audio daemon filedescriptor */
+ a2dp_state_t state; /* Current A2DP state */
+ a2dp_command_t command; /* Current command for a2dp_thread */
+ pthread_t thread;
+ pthread_mutex_t mutex;
+ pthread_cond_t thread_wait;
+ pthread_cond_t client_wait;
+
+ sbc_capabilities_t sbc_capabilities;
+ sbc_t sbc; /* Codec data */
+ int frame_duration; /* length of an SBC frame in microseconds */
+ int codesize; /* SBC codesize */
+ int samples; /* Number of encoded samples */
+ uint8_t buffer[BUFFER_SIZE]; /* Codec transfer buffer */
+ int count; /* Codec transfer buffer counter */
+
+ int nsamples; /* Cumulative number of codec samples */
+ uint16_t seq_num; /* Cumulative packet sequence */
+ int frame_count; /* Current frames in buffer*/
+
+ char address[20];
+ int rate;
+ int channels;
+
+ /* used for pacing our writes to the output socket */
+ uint64_t next_write;
+};
+
+static uint64_t get_microseconds()
+{
+ struct timeval now;
+ gettimeofday(&now, NULL);
+ return (now.tv_sec * 1000000UL + now.tv_usec);
+}
+
+#ifdef ENABLE_TIMING
+static void print_time(const char* message, uint64_t then, uint64_t now)
+{
+ DBG("%s: %lld us", message, now - then);
+}
+#endif
+
+static int audioservice_send(struct bluetooth_data *data, const bt_audio_msg_header_t *msg);
+static int audioservice_expect(struct bluetooth_data *data, bt_audio_msg_header_t *outmsg,
+ int expected_type);
+static int bluetooth_a2dp_hw_params(struct bluetooth_data *data);
+static void set_state(struct bluetooth_data *data, a2dp_state_t state);
+
+
+static void bluetooth_close(struct bluetooth_data *data)
+{
+ DBG("bluetooth_close");
+ if (data->server.fd >= 0) {
+ bt_audio_service_close(data->server.fd);
+ data->server.fd = -1;
+ }
+
+ if (data->stream.fd >= 0) {
+ close(data->stream.fd);
+ data->stream.fd = -1;
+ }
+
+ data->state = A2DP_STATE_NONE;
+}
+
+static int bluetooth_start(struct bluetooth_data *data)
+{
+ char c = 'w';
+ char buf[BT_SUGGESTED_BUFFER_SIZE];
+ struct bt_start_stream_req *start_req = (void*) buf;
+ struct bt_start_stream_rsp *start_rsp = (void*) buf;
+ struct bt_new_stream_ind *streamfd_ind = (void*) buf;
+ int opt_name, err, bytes;
+
+ DBG("bluetooth_start");
+ data->state = A2DP_STATE_STARTING;
+ /* send start */
+ memset(start_req, 0, BT_SUGGESTED_BUFFER_SIZE);
+ start_req->h.type = BT_REQUEST;
+ start_req->h.name = BT_START_STREAM;
+ start_req->h.length = sizeof(*start_req);
+
+
+ err = audioservice_send(data, &start_req->h);
+ if (err < 0)
+ goto error;
+
+ start_rsp->h.length = sizeof(*start_rsp);
+ err = audioservice_expect(data, &start_rsp->h, BT_START_STREAM);
+ if (err < 0)
+ goto error;
+
+ streamfd_ind->h.length = sizeof(*streamfd_ind);
+ err = audioservice_expect(data, &streamfd_ind->h, BT_NEW_STREAM);
+ if (err < 0)
+ goto error;
+
+ data->stream.fd = bt_audio_service_get_data_fd(data->server.fd);
+ if (data->stream.fd < 0) {
+ ERR("bt_audio_service_get_data_fd failed, errno: %d", errno);
+ err = -errno;
+ goto error;
+ }
+ data->stream.events = POLLOUT;
+
+ /* set our socket buffer to the size of PACKET_BUFFER_COUNT packets */
+ bytes = data->link_mtu * PACKET_BUFFER_COUNT;
+ setsockopt(data->stream.fd, SOL_SOCKET, SO_SNDBUF, &bytes,
+ sizeof(bytes));
+
+ data->count = sizeof(struct rtp_header) + sizeof(struct rtp_payload);
+ data->frame_count = 0;
+ data->samples = 0;
+ data->nsamples = 0;
+ data->seq_num = 0;
+ data->frame_count = 0;
+ data->next_write = 0;
+
+ set_state(data, A2DP_STATE_STARTED);
+ return 0;
+
+error:
+ /* set state to A2DP_STATE_INITIALIZED to force reconfiguration */
+ if (data->state == A2DP_STATE_STARTING)
+ set_state(data, A2DP_STATE_INITIALIZED);
+ return err;
+}
+
+static int bluetooth_stop(struct bluetooth_data *data)
+{
+ char buf[BT_SUGGESTED_BUFFER_SIZE];
+ struct bt_stop_stream_req *stop_req = (void*) buf;
+ struct bt_stop_stream_rsp *stop_rsp = (void*) buf;
+ int err;
+
+ DBG("bluetooth_stop");
+
+ data->state = A2DP_STATE_STOPPING;
+ if (data->stream.fd >= 0) {
+ close(data->stream.fd);
+ data->stream.fd = -1;
+ }
+
+ /* send stop request */
+ memset(stop_req, 0, BT_SUGGESTED_BUFFER_SIZE);
+ stop_req->h.type = BT_REQUEST;
+ stop_req->h.name = BT_STOP_STREAM;
+ stop_req->h.length = sizeof(*stop_req);
+
+ err = audioservice_send(data, &stop_req->h);
+ if (err < 0)
+ goto error;
+
+ stop_rsp->h.length = sizeof(*stop_rsp);
+ err = audioservice_expect(data, &stop_rsp->h, BT_STOP_STREAM);
+ if (err < 0)
+ goto error;
+
+error:
+ if (data->state == A2DP_STATE_STOPPING)
+ set_state(data, A2DP_STATE_CONFIGURED);
+ return err;
+}
+
+static uint8_t default_bitpool(uint8_t freq, uint8_t mode)
+{
+ switch (freq) {
+ case BT_SBC_SAMPLING_FREQ_16000:
+ case BT_SBC_SAMPLING_FREQ_32000:
+ return 53;
+ case BT_SBC_SAMPLING_FREQ_44100:
+ switch (mode) {
+ case BT_A2DP_CHANNEL_MODE_MONO:
+ case BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL:
+ return 31;
+ case BT_A2DP_CHANNEL_MODE_STEREO:
+ case BT_A2DP_CHANNEL_MODE_JOINT_STEREO:
+ return 53;
+ default:
+ ERR("Invalid channel mode %u", mode);
+ return 53;
+ }
+ case BT_SBC_SAMPLING_FREQ_48000:
+ switch (mode) {
+ case BT_A2DP_CHANNEL_MODE_MONO:
+ case BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL:
+ return 29;
+ case BT_A2DP_CHANNEL_MODE_STEREO:
+ case BT_A2DP_CHANNEL_MODE_JOINT_STEREO:
+ return 51;
+ default:
+ ERR("Invalid channel mode %u", mode);
+ return 51;
+ }
+ default:
+ ERR("Invalid sampling freq %u", freq);
+ return 53;
+ }
+}
+
+static int bluetooth_a2dp_init(struct bluetooth_data *data)
+{
+ sbc_capabilities_t *cap = &data->sbc_capabilities;
+ unsigned int max_bitpool, min_bitpool;
+ int dir;
+
+ switch (data->rate) {
+ case 48000:
+ cap->frequency = BT_SBC_SAMPLING_FREQ_48000;
+ break;
+ case 44100:
+ cap->frequency = BT_SBC_SAMPLING_FREQ_44100;
+ break;
+ case 32000:
+ cap->frequency = BT_SBC_SAMPLING_FREQ_32000;
+ break;
+ case 16000:
+ cap->frequency = BT_SBC_SAMPLING_FREQ_16000;
+ break;
+ default:
+ ERR("Rate %d not supported", data->rate);
+ return -1;
+ }
+
+ if (data->channels == 2) {
+ if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_JOINT_STEREO)
+ cap->channel_mode = BT_A2DP_CHANNEL_MODE_JOINT_STEREO;
+ else if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_STEREO)
+ cap->channel_mode = BT_A2DP_CHANNEL_MODE_STEREO;
+ else if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL)
+ cap->channel_mode = BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL;
+ } else {
+ if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_MONO)
+ cap->channel_mode = BT_A2DP_CHANNEL_MODE_MONO;
+ }
+
+ if (!cap->channel_mode) {
+ ERR("No supported channel modes");
+ return -1;
+ }
+
+ if (cap->block_length & BT_A2DP_BLOCK_LENGTH_16)
+ cap->block_length = BT_A2DP_BLOCK_LENGTH_16;
+ else if (cap->block_length & BT_A2DP_BLOCK_LENGTH_12)
+ cap->block_length = BT_A2DP_BLOCK_LENGTH_12;
+ else if (cap->block_length & BT_A2DP_BLOCK_LENGTH_8)
+ cap->block_length = BT_A2DP_BLOCK_LENGTH_8;
+ else if (cap->block_length & BT_A2DP_BLOCK_LENGTH_4)
+ cap->block_length = BT_A2DP_BLOCK_LENGTH_4;
+ else {
+ ERR("No supported block lengths");
+ return -1;
+ }
+
+ if (cap->subbands & BT_A2DP_SUBBANDS_8)
+ cap->subbands = BT_A2DP_SUBBANDS_8;
+ else if (cap->subbands & BT_A2DP_SUBBANDS_4)
+ cap->subbands = BT_A2DP_SUBBANDS_4;
+ else {
+ ERR("No supported subbands");
+ return -1;
+ }
+
+ if (cap->allocation_method & BT_A2DP_ALLOCATION_LOUDNESS)
+ cap->allocation_method = BT_A2DP_ALLOCATION_LOUDNESS;
+ else if (cap->allocation_method & BT_A2DP_ALLOCATION_SNR)
+ cap->allocation_method = BT_A2DP_ALLOCATION_SNR;
+
+ min_bitpool = MAX(MIN_BITPOOL, cap->min_bitpool);
+ max_bitpool = MIN(default_bitpool(cap->frequency,
+ cap->channel_mode),
+ cap->max_bitpool);
+
+ cap->min_bitpool = min_bitpool;
+ cap->max_bitpool = max_bitpool;
+
+ return 0;
+}
+
+static void bluetooth_a2dp_setup(struct bluetooth_data *data)
+{
+ sbc_capabilities_t active_capabilities = data->sbc_capabilities;
+
+ sbc_reinit(&data->sbc, 0);
+
+ if (active_capabilities.frequency & BT_SBC_SAMPLING_FREQ_16000)
+ data->sbc.frequency = SBC_FREQ_16000;
+
+ if (active_capabilities.frequency & BT_SBC_SAMPLING_FREQ_32000)
+ data->sbc.frequency = SBC_FREQ_32000;
+
+ if (active_capabilities.frequency & BT_SBC_SAMPLING_FREQ_44100)
+ data->sbc.frequency = SBC_FREQ_44100;
+
+ if (active_capabilities.frequency & BT_SBC_SAMPLING_FREQ_48000)
+ data->sbc.frequency = SBC_FREQ_48000;
+
+ if (active_capabilities.channel_mode & BT_A2DP_CHANNEL_MODE_MONO)
+ data->sbc.mode = SBC_MODE_MONO;
+
+ if (active_capabilities.channel_mode & BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL)
+ data->sbc.mode = SBC_MODE_DUAL_CHANNEL;
+
+ if (active_capabilities.channel_mode & BT_A2DP_CHANNEL_MODE_STEREO)
+ data->sbc.mode = SBC_MODE_STEREO;
+
+ if (active_capabilities.channel_mode & BT_A2DP_CHANNEL_MODE_JOINT_STEREO)
+ data->sbc.mode = SBC_MODE_JOINT_STEREO;
+
+ data->sbc.allocation = active_capabilities.allocation_method
+ == BT_A2DP_ALLOCATION_SNR ? SBC_AM_SNR
+ : SBC_AM_LOUDNESS;
+
+ switch (active_capabilities.subbands) {
+ case BT_A2DP_SUBBANDS_4:
+ data->sbc.subbands = SBC_SB_4;
+ break;
+ case BT_A2DP_SUBBANDS_8:
+ data->sbc.subbands = SBC_SB_8;
+ break;
+ }
+
+ switch (active_capabilities.block_length) {
+ case BT_A2DP_BLOCK_LENGTH_4:
+ data->sbc.blocks = SBC_BLK_4;
+ break;
+ case BT_A2DP_BLOCK_LENGTH_8:
+ data->sbc.blocks = SBC_BLK_8;
+ break;
+ case BT_A2DP_BLOCK_LENGTH_12:
+ data->sbc.blocks = SBC_BLK_12;
+ break;
+ case BT_A2DP_BLOCK_LENGTH_16:
+ data->sbc.blocks = SBC_BLK_16;
+ break;
+ }
+
+ data->sbc.bitpool = active_capabilities.max_bitpool;
+ data->codesize = sbc_get_codesize(&data->sbc);
+ data->frame_duration = sbc_get_frame_duration(&data->sbc);
+ DBG("frame_duration: %d us", data->frame_duration);
+}
+
+static int bluetooth_a2dp_hw_params(struct bluetooth_data *data)
+{
+ char buf[BT_SUGGESTED_BUFFER_SIZE];
+ struct bt_open_req *open_req = (void *) buf;
+ struct bt_open_rsp *open_rsp = (void *) buf;
+ struct bt_set_configuration_req *setconf_req = (void*) buf;
+ struct bt_set_configuration_rsp *setconf_rsp = (void*) buf;
+ int err;
+
+ memset(open_req, 0, BT_SUGGESTED_BUFFER_SIZE);
+ open_req->h.type = BT_REQUEST;
+ open_req->h.name = BT_OPEN;
+ open_req->h.length = sizeof(*open_req);
+ strncpy(open_req->destination, data->address, 18);
+ open_req->seid = data->sbc_capabilities.capability.seid;
+ open_req->lock = BT_WRITE_LOCK;
+
+ err = audioservice_send(data, &open_req->h);
+ if (err < 0)
+ return err;
+
+ open_rsp->h.length = sizeof(*open_rsp);
+ err = audioservice_expect(data, &open_rsp->h, BT_OPEN);
+ if (err < 0)
+ return err;
+
+ err = bluetooth_a2dp_init(data);
+ if (err < 0)
+ return err;
+
+
+ memset(setconf_req, 0, BT_SUGGESTED_BUFFER_SIZE);
+ setconf_req->h.type = BT_REQUEST;
+ setconf_req->h.name = BT_SET_CONFIGURATION;
+ setconf_req->h.length = sizeof(*setconf_req);
+ memcpy(&setconf_req->codec, &data->sbc_capabilities,
+ sizeof(data->sbc_capabilities));
+
+ setconf_req->codec.transport = BT_CAPABILITIES_TRANSPORT_A2DP;
+ setconf_req->codec.length = sizeof(data->sbc_capabilities);
+ setconf_req->h.length += setconf_req->codec.length - sizeof(setconf_req->codec);
+
+ DBG("bluetooth_a2dp_hw_params sending configuration:\n");
+ switch (data->sbc_capabilities.channel_mode) {
+ case BT_A2DP_CHANNEL_MODE_MONO:
+ DBG("\tchannel_mode: MONO\n");
+ break;
+ case BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL:
+ DBG("\tchannel_mode: DUAL CHANNEL\n");
+ break;
+ case BT_A2DP_CHANNEL_MODE_STEREO:
+ DBG("\tchannel_mode: STEREO\n");
+ break;
+ case BT_A2DP_CHANNEL_MODE_JOINT_STEREO:
+ DBG("\tchannel_mode: JOINT STEREO\n");
+ break;
+ default:
+ DBG("\tchannel_mode: UNKNOWN (%d)\n",
+ data->sbc_capabilities.channel_mode);
+ }
+ switch (data->sbc_capabilities.frequency) {
+ case BT_SBC_SAMPLING_FREQ_16000:
+ DBG("\tfrequency: 16000\n");
+ break;
+ case BT_SBC_SAMPLING_FREQ_32000:
+ DBG("\tfrequency: 32000\n");
+ break;
+ case BT_SBC_SAMPLING_FREQ_44100:
+ DBG("\tfrequency: 44100\n");
+ break;
+ case BT_SBC_SAMPLING_FREQ_48000:
+ DBG("\tfrequency: 48000\n");
+ break;
+ default:
+ DBG("\tfrequency: UNKNOWN (%d)\n",
+ data->sbc_capabilities.frequency);
+ }
+ switch (data->sbc_capabilities.allocation_method) {
+ case BT_A2DP_ALLOCATION_SNR:
+ DBG("\tallocation_method: SNR\n");
+ break;
+ case BT_A2DP_ALLOCATION_LOUDNESS:
+ DBG("\tallocation_method: LOUDNESS\n");
+ break;
+ default:
+ DBG("\tallocation_method: UNKNOWN (%d)\n",
+ data->sbc_capabilities.allocation_method);
+ }
+ switch (data->sbc_capabilities.subbands) {
+ case BT_A2DP_SUBBANDS_4:
+ DBG("\tsubbands: 4\n");
+ break;
+ case BT_A2DP_SUBBANDS_8:
+ DBG("\tsubbands: 8\n");
+ break;
+ default:
+ DBG("\tsubbands: UNKNOWN (%d)\n",
+ data->sbc_capabilities.subbands);
+ }
+ switch (data->sbc_capabilities.block_length) {
+ case BT_A2DP_BLOCK_LENGTH_4:
+ DBG("\tblock_length: 4\n");
+ break;
+ case BT_A2DP_BLOCK_LENGTH_8:
+ DBG("\tblock_length: 8\n");
+ break;
+ case BT_A2DP_BLOCK_LENGTH_12:
+ DBG("\tblock_length: 12\n");
+ break;
+ case BT_A2DP_BLOCK_LENGTH_16:
+ DBG("\tblock_length: 16\n");
+ break;
+ default:
+ DBG("\tblock_length: UNKNOWN (%d)\n",
+ data->sbc_capabilities.block_length);
+ }
+ DBG("\tmin_bitpool: %d\n", data->sbc_capabilities.min_bitpool);
+ DBG("\tmax_bitpool: %d\n", data->sbc_capabilities.max_bitpool);
+
+ err = audioservice_send(data, &setconf_req->h);
+ if (err < 0)
+ return err;
+
+ err = audioservice_expect(data, &setconf_rsp->h, BT_SET_CONFIGURATION);
+ if (err < 0)
+ return err;
+
+ data->link_mtu = setconf_rsp->link_mtu;
+ DBG("MTU: %d", data->link_mtu);
+
+ /* Setup SBC encoder now we agree on parameters */
+ bluetooth_a2dp_setup(data);
+
+ DBG("\tallocation=%u\n\tsubbands=%u\n\tblocks=%u\n\tbitpool=%u\n",
+ data->sbc.allocation, data->sbc.subbands, data->sbc.blocks,
+ data->sbc.bitpool);
+
+ return 0;
+}
+
+static int avdtp_write(struct bluetooth_data *data)
+{
+ int ret = 0;
+ struct rtp_header *header;
+ struct rtp_payload *payload;
+
+ uint64_t now;
+ long duration = data->frame_duration * data->frame_count;
+#ifdef ENABLE_TIMING
+ uint64_t begin, end, begin2, end2;
+ begin = get_microseconds();
+#endif
+
+ header = (struct rtp_header *)data->buffer;
+ payload = (struct rtp_payload *)(data->buffer + sizeof(*header));
+
+ memset(data->buffer, 0, sizeof(*header) + sizeof(*payload));
+
+ payload->frame_count = data->frame_count;
+ header->v = 2;
+ header->pt = 1;
+ header->sequence_number = htons(data->seq_num);
+ header->timestamp = htonl(data->nsamples);
+ header->ssrc = htonl(1);
+
+ data->stream.revents = 0;
+#ifdef ENABLE_TIMING
+ begin2 = get_microseconds();
+#endif
+ ret = poll(&data->stream, 1, POLL_TIMEOUT);
+#ifdef ENABLE_TIMING
+ end2 = get_microseconds();
+ print_time("poll", begin2, end2);
+#endif
+ if (ret == 1 && data->stream.revents == POLLOUT) {
+ long ahead = 0;
+ now = get_microseconds();
+
+ if (data->next_write) {
+ ahead = data->next_write - now;
+#ifdef ENABLE_TIMING
+ DBG("duration: %ld, ahead: %ld", duration, ahead);
+#endif
+ if (ahead > 0) {
+ /* too fast, need to throttle */
+ usleep(ahead);
+ }
+ } else {
+ data->next_write = now;
+ }
+ if (ahead < 0) {
+ /* fallen too far behind, don't try to catch up */
+ VDBG("ahead < 0, resetting next_write");
+ data->next_write = 0;
+ } else {
+ /* advance next_write by duration */
+ data->next_write += duration;
+ }
+
+#ifdef ENABLE_TIMING
+ begin2 = get_microseconds();
+#endif
+ ret = send(data->stream.fd, data->buffer, data->count, MSG_NOSIGNAL);
+#ifdef ENABLE_TIMING
+ end2 = get_microseconds();
+ print_time("send", begin2, end2);
+#endif
+ if (ret < 0) {
+ /* can happen during normal remote disconnect */
+ VDBG("send() failed: %d (errno %s)", ret, strerror(errno));
+ }
+ if (ret == -EPIPE) {
+ bluetooth_close(data);
+ }
+ } else {
+ /* can happen during normal remote disconnect */
+ VDBG("poll() failed: %d (revents = %d, errno %s)",
+ ret, data->stream.revents, strerror(errno));
+ }
+
+ /* Reset buffer of data to send */
+ data->count = sizeof(struct rtp_header) + sizeof(struct rtp_payload);
+ data->frame_count = 0;
+ data->samples = 0;
+ data->seq_num++;
+
+#ifdef ENABLE_TIMING
+ end = get_microseconds();
+ print_time("avdtp_write", begin, end);
+#endif
+ return 0; /* always return success */
+}
+
+static int audioservice_send(struct bluetooth_data *data,
+ const bt_audio_msg_header_t *msg)
+{
+ int err;
+ uint16_t length;
+
+ length = msg->length ? msg->length : BT_SUGGESTED_BUFFER_SIZE;
+
+ VDBG("sending %s", bt_audio_strmsg(msg->msg_type));
+ if (send(data->server.fd, msg, length,
+ MSG_NOSIGNAL) > 0)
+ err = 0;
+ else {
+ err = -errno;
+ ERR("Error sending data to audio service: %s(%d)",
+ strerror(errno), errno);
+ if (err == -EPIPE)
+ bluetooth_close(data);
+ }
+
+ return err;
+}
+
+static int audioservice_recv(struct bluetooth_data *data,
+ bt_audio_msg_header_t *inmsg)
+{
+ int err, ret;
+ const char *type, *name;
+ uint16_t length;
+
+ length = inmsg->length ? inmsg->length : BT_SUGGESTED_BUFFER_SIZE;
+
+ ret = recv(data->server.fd, inmsg, length, 0);
+ if (ret < 0) {
+ err = -errno;
+ ERR("Error receiving IPC data from bluetoothd: %s (%d)",
+ strerror(errno), errno);
+ if (err == -EPIPE)
+ bluetooth_close(data);
+ } else if ((size_t) ret < sizeof(bt_audio_msg_header_t)) {
+ ERR("Too short (%d bytes) IPC packet from bluetoothd", ret);
+ err = -EINVAL;
+ } else {
+ type = bt_audio_strtype(inmsg->type);
+ name = bt_audio_strname(inmsg->name);
+ if (type && name) {
+ DBG("Received %s - %s", type, name);
+ err = 0;
+ } else {
+ err = -EINVAL;
+ ERR("Bogus message type %d - name %d"
+ " received from audio service",
+ inmsg->type, inmsg->name);
+ }
+
+ }
+ return err;
+}
+
+static int audioservice_expect(struct bluetooth_data *data,
+ bt_audio_msg_header_t *rsp_hdr, int expected_name)
+{
+ bt_audio_error_t *error;
+ int err = audioservice_recv(data, rsp_hdr);
+
+ if (err != 0)
+ return err;
+
+ if (rsp_hdr->name != expected_name) {
+ err = -EINVAL;
+ ERR("Bogus message %s received while %s was expected",
+ bt_audio_strname(rsp_hdr->name),
+ bt_audio_strname(expected_name));
+ }
+
+ if (rsp_hdr->type == BT_ERROR) {
+ error = (void *) rsp_hdr;
+ ERR("%s failed : %s(%d)",
+ bt_audio_strname(rsp_hdr->name),
+ strerror(error->posix_errno),
+ error->posix_errno);
+ return -error->posix_errno;
+ }
+
+ return err;
+
+}
+
+static int bluetooth_init(struct bluetooth_data *data)
+{
+ int sk, err;
+
+ DBG("bluetooth_init");
+
+ sk = bt_audio_service_open();
+ if (sk <= 0) {
+ ERR("bt_audio_service_open failed\n");
+ return -errno;
+ }
+
+ data->server.fd = sk;
+ data->server.events = POLLIN;
+ data->state = A2DP_STATE_INITIALIZED;
+
+ return 0;
+}
+
+static int bluetooth_parse_capabilities(struct bluetooth_data *data,
+ struct bt_get_capabilities_rsp *rsp)
+{
+ int bytes_left = rsp->h.length - sizeof(*rsp);
+ codec_capabilities_t *codec = (void *) rsp->data;
+
+ if (codec->transport != BT_CAPABILITIES_TRANSPORT_A2DP)
+ return 0;
+
+ while (bytes_left > 0) {
+ if ((codec->type == BT_A2DP_SBC_SINK) &&
+ !(codec->lock & BT_WRITE_LOCK))
+ break;
+
+ bytes_left -= codec->length;
+ codec = (void *) codec + codec->length;
+ }
+
+ if (bytes_left <= 0 ||
+ codec->length != sizeof(data->sbc_capabilities))
+ return -EINVAL;
+
+ memcpy(&data->sbc_capabilities, codec, codec->length);
+ return 0;
+}
+
+
+static int bluetooth_configure(struct bluetooth_data *data)
+{
+ char buf[BT_SUGGESTED_BUFFER_SIZE];
+ struct bt_get_capabilities_req *getcaps_req = (void*) buf;
+ struct bt_get_capabilities_rsp *getcaps_rsp = (void*) buf;
+ int err;
+
+ DBG("bluetooth_configure");
+
+ data->state = A2DP_STATE_CONFIGURING;
+ memset(getcaps_req, 0, BT_SUGGESTED_BUFFER_SIZE);
+ getcaps_req->h.type = BT_REQUEST;
+ getcaps_req->h.name = BT_GET_CAPABILITIES;
+
+ getcaps_req->flags = 0;
+ getcaps_req->flags |= BT_FLAG_AUTOCONNECT;
+ strncpy(getcaps_req->destination, data->address, 18);
+ getcaps_req->transport = BT_CAPABILITIES_TRANSPORT_A2DP;
+ getcaps_req->h.length = sizeof(*getcaps_req);
+
+ err = audioservice_send(data, &getcaps_req->h);
+ if (err < 0) {
+ ERR("audioservice_send failed for BT_GETCAPABILITIES_REQ\n");
+ goto error;
+ }
+
+ getcaps_rsp->h.length = 0;
+ err = audioservice_expect(data, &getcaps_rsp->h, BT_GET_CAPABILITIES);
+ if (err < 0) {
+ ERR("audioservice_expect failed for BT_GETCAPABILITIES_RSP\n");
+ goto error;
+ }
+
+ bluetooth_parse_capabilities(data, getcaps_rsp);
+ err = bluetooth_a2dp_hw_params(data);
+ if (err < 0) {
+ ERR("bluetooth_a2dp_hw_params failed err: %d", err);
+ goto error;
+ }
+
+ set_state(data, A2DP_STATE_CONFIGURED);
+ return 0;
+
+error:
+ if (data->state == A2DP_STATE_CONFIGURING)
+ set_state(data, A2DP_STATE_INITIALIZED);
+ return err;
+}
+
+static void set_state(struct bluetooth_data *data, a2dp_state_t state)
+{
+ pthread_mutex_lock(&data->mutex);
+ data->state = state;
+ pthread_cond_signal(&data->client_wait);
+ pthread_mutex_unlock(&data->mutex);
+}
+
+static void set_command(struct bluetooth_data *data, a2dp_command_t command)
+{
+ VDBG("set_command %d\n", command);
+ pthread_mutex_lock(&data->mutex);
+ data->command = command;
+ pthread_cond_signal(&data->thread_wait);
+ pthread_mutex_unlock(&data->mutex);
+}
+
+static int wait_for_start(struct bluetooth_data *data, int timeout)
+{
+ a2dp_state_t state = data->state;
+ struct timespec ts;
+ uint64_t begin, end;
+ int err = 0;
+
+ begin = get_microseconds();
+ end = begin + (timeout * 1000);
+ ts.tv_sec = end / (1000 * 1000);
+ ts.tv_nsec = (end % (1000 * 1000)) * 1000;
+
+ while (state != A2DP_STATE_STARTED && !err) {
+ if (state == A2DP_STATE_NONE)
+ return -ENODEV;
+ else if (state == A2DP_STATE_INITIALIZED)
+ set_command(data, A2DP_CMD_CONFIGURE);
+ else if (state == A2DP_STATE_CONFIGURED)
+ set_command(data, A2DP_CMD_START);
+
+ pthread_mutex_lock(&data->mutex);
+ while ((err = pthread_cond_timedwait(&data->client_wait, &data->mutex, &ts))
+ == EINTR) ;
+ state = data->state;
+ pthread_mutex_unlock(&data->mutex);
+ }
+
+#ifdef ENABLE_TIMING
+ end = get_microseconds();
+ print_time("wait_for_start", begin, end);
+#endif
+
+ /* pthread_cond_timedwait returns positive errors */
+ return -err;
+}
+
+static void* a2dp_thread(void *d)
+{
+ struct bluetooth_data* data = (struct bluetooth_data*)d;
+
+ DBG("a2dp_thread started");
+ prctl(PR_SET_NAME, "a2dp_thread", 0, 0, 0);
+
+ while (1)
+ {
+ a2dp_command_t command;
+
+ pthread_mutex_lock(&data->mutex);
+ pthread_cond_wait(&data->thread_wait, &data->mutex);
+ command = data->command;
+ pthread_mutex_unlock(&data->mutex);
+
+ if (data->state == A2DP_STATE_NONE && command != A2DP_CMD_QUIT)
+ bluetooth_init(data);
+
+ switch (command) {
+ case A2DP_CMD_CONFIGURE:
+ if (data->state != A2DP_STATE_INITIALIZED)
+ break;
+ bluetooth_configure(data);
+ break;
+
+ case A2DP_CMD_START:
+ if (data->state != A2DP_STATE_CONFIGURED)
+ break;
+ bluetooth_start(data);
+ break;
+
+ case A2DP_CMD_STOP:
+ if (data->state != A2DP_STATE_STARTED)
+ break;
+ bluetooth_stop(data);
+ break;
+
+ case A2DP_CMD_QUIT:
+ bluetooth_close(data);
+ sbc_finish(&data->sbc);
+ free(data);
+ goto done;
+
+ default:
+ break;
+ }
+ }
+
+done:
+ DBG("a2dp_thread finished");
+ return NULL;
+}
+
+int a2dp_init(int rate, int channels, a2dpData* dataPtr)
+{
+ struct bluetooth_data* data;
+ pthread_attr_t attr;
+ int err;
+
+ DBG("a2dp_init rate: %d channels: %d", rate, channels);
+ *dataPtr = NULL;
+ data = malloc(sizeof(struct bluetooth_data));
+ if (!data)
+ return -1;
+
+ memset(data, 0, sizeof(struct bluetooth_data));
+ data->server.fd = -1;
+ data->stream.fd = -1;
+ data->state = A2DP_STATE_NONE;
+
+ strncpy(data->address, "00:00:00:00:00:00", 18);
+ data->rate = rate;
+ data->channels = channels;
+
+ sbc_init(&data->sbc, 0);
+
+ pthread_mutex_init(&data->mutex, NULL);
+ pthread_cond_init(&data->thread_wait, NULL);
+ pthread_cond_init(&data->client_wait, NULL);
+
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ pthread_create(&data->thread, &attr, a2dp_thread, data);
+
+ *dataPtr = data;
+ return 0;
+error:
+ bluetooth_close(data);
+ free(data);
+
+ return err;
+}
+
+void a2dp_set_sink(a2dpData d, const char* address)
+{
+ struct bluetooth_data* data = (struct bluetooth_data*)d;
+ if (strncmp(data->address, address, 18)) {
+ strncpy(data->address, address, 18);
+ // force reconfiguration
+ set_command(data, A2DP_CMD_CONFIGURE);
+ }
+}
+
+int a2dp_write(a2dpData d, const void* buffer, int count)
+{
+ struct bluetooth_data* data = (struct bluetooth_data*)d;
+ uint8_t* src = (uint8_t *)buffer;
+ int codesize;
+ int err, ret = 0;
+ long frames_left = count;
+ int encoded, written;
+ const char *buff;
+ int did_configure = 0;
+#ifdef ENABLE_TIMING
+ uint64_t begin, end;
+ DBG("********** a2dp_write **********");
+ begin = get_microseconds();
+#endif
+
+ err = wait_for_start(data, WRITE_TIMEOUT);
+ if (err < 0)
+ return err;
+
+ codesize = data->codesize;
+
+ while (frames_left >= codesize) {
+ /* Enough data to encode (sbc wants 512 byte blocks) */
+ encoded = sbc_encode(&(data->sbc), src, codesize,
+ data->buffer + data->count,
+ sizeof(data->buffer) - data->count,
+ &written);
+ if (encoded <= 0) {
+ ERR("Encoding error %d", encoded);
+ goto done;
+ }
+ VDBG("sbc_encode returned %d, codesize: %d, written: %d\n",
+ encoded, codesize, written);
+
+ src += encoded;
+ data->count += written;
+ data->frame_count++;
+ data->samples += encoded;
+ data->nsamples += encoded;
+
+ /* No space left for another frame then send */
+ if (data->count + written >= data->link_mtu) {
+ VDBG("sending packet %d, count %d, link_mtu %u",
+ data->seq_num, data->count,
+ data->link_mtu);
+ err = avdtp_write(data);
+ if (err < 0)
+ return err;
+ }
+
+ ret += encoded;
+ frames_left -= encoded;
+ }
+
+ if (frames_left > 0)
+ ERR("%ld bytes left at end of a2dp_write\n", frames_left);
+
+done:
+#ifdef ENABLE_TIMING
+ end = get_microseconds();
+ print_time("a2dp_write total", begin, end);
+#endif
+ return ret;
+}
+
+int a2dp_stop(a2dpData d)
+{
+ struct bluetooth_data* data = (struct bluetooth_data*)d;
+ DBG("a2dp_stop\n");
+ if (!data)
+ return 0;
+
+ set_command(data, A2DP_CMD_STOP);
+ return 0;
+}
+
+void a2dp_cleanup(a2dpData d)
+{
+ struct bluetooth_data* data = (struct bluetooth_data*)d;
+ DBG("a2dp_cleanup\n");
+ set_command(data, A2DP_CMD_QUIT);
+}
--- /dev/null
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2006-2007 Nokia Corporation
+ * Copyright (C) 2004-2008 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void* a2dpData;
+
+int a2dp_init(int rate, int channels, a2dpData* dataPtr);
+void a2dp_set_sink(a2dpData data, const char* address);
+int a2dp_write(a2dpData data, const void* buffer, int count);
+int a2dp_stop(a2dpData data);
+void a2dp_cleanup(a2dpData data);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ btio.c \
+ glib-helper.c \
+ logging.c \
+ oui.c \
+ sdp-xml.c \
+ textfile.c \
+ test_textfile.c \
+
+LOCAL_CFLAGS+= \
+ -O3 \
+ -DNEED_DBUS_WATCH_GET_UNIX_FD
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(call include-path-for, glib) \
+ $(call include-path-for, glib)/glib \
+ $(call include-path-for, dbus)
+
+LOCAL_MODULE:=libbluez-common-static
+
+LOCAL_STATIC_LIBRARY:= \
+ libglib_static
+
+include $(BUILD_STATIC_LIBRARY)
#include "textfile.h"
+#ifndef HAVE_FDATASYNC
+#define fdatasync fsync
+#endif
+
int create_dirs(const char *filename, const mode_t mode)
{
struct stat st;
--- /dev/null
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ mainloop.c object.c watch.c
+
+LOCAL_CFLAGS+=-O3 -DNEED_DBUS_WATCH_GET_UNIX_FD
+
+LOCAL_C_INCLUDES:= \
+ $(call include-path-for, glib) \
+ $(call include-path-for, dbus)
+
+LOCAL_MODULE:=libgdbus_static
+
+include $(BUILD_STATIC_LIBRARY)
--- /dev/null
+LOCAL_PATH:= $(call my-dir)
+
+# HID plugin
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ device.c \
+ fakehid.c \
+ main.c \
+ manager.c \
+ server.c
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\" \
+ -DSTORAGEDIR=\"/data/misc/bluetoothd\" \
+ -DCONFIGDIR=\"/etc/bluez\"
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common \
+ $(LOCAL_PATH)/../src \
+ $(LOCAL_PATH)/../gdbus \
+ $(call include-path-for, glib) \
+ $(call include-path-for, dbus)
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetoothd \
+ libbluetooth \
+ libdbus \
+ libexpat \
+ libcutils
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/bluez-plugin
+LOCAL_UNSTRIPPED_PATH := $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/bluez-plugin
+LOCAL_MODULE := input
+
+include $(BUILD_SHARED_LIBRARY)
--- /dev/null
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ bluetooth.c \
+ sdp.c \
+ hci.c
+
+LOCAL_C_INCLUDES+= \
+ $(LOCAL_PATH)/../include/
+
+LOCAL_MODULE:=libbluetooth
+
+LOCAL_CFLAGS+=-O3
+
+include $(BUILD_SHARED_LIBRARY)
--- /dev/null
+LOCAL_PATH:= $(call my-dir)
+
+#
+# libplugin
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ hciops.c \
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\" \
+ -DBLUETOOTH_PLUGIN_BUILTIN \
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common \
+ $(LOCAL_PATH)/../gdbus \
+ $(LOCAL_PATH)/../src \
+ $(call include-path-for, glib) \
+ $(call include-path-for, dbus) \
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetoothd \
+ libbluetooth \
+ libcutils \
+ libdbus
+
+LOCAL_STATIC_LIBRARIES := \
+ libbluez-common-static \
+ libglib_static
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/bluez-plugin
+LOCAL_UNSTRIPPED_PATH := $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/bluez-plugin
+LOCAL_MODULE:=libbuiltinplugin
+
+include $(BUILD_STATIC_LIBRARY)
--- /dev/null
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2004-2009 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+extern struct bluetooth_plugin_desc __bluetooth_builtin_hciops;
+static struct bluetooth_plugin_desc *__bluetooth_builtin[] = {
+ &__bluetooth_builtin_hciops,
+ NULL };
--- /dev/null
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ kword.c \
+ main.c \
+ parser.c \
+ lexer.c
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\" \
+ -DCONFIGDIR=\"/etc/bluez\" \
+ -DNEED_PPOLL
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../common \
+ $(LOCAL_PATH)/../include
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth
+
+LOCAL_STATIC_LIBRARIES := \
+ libbluez-common-static
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=rfcomm
+
+include $(BUILD_EXECUTABLE)
--- /dev/null
+
+#line 3 "lex.yy.c"
+
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 31
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
+
+#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+#endif /* ! FLEXINT_H */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+#if __STDC__
+
+#define YY_USE_CONST
+
+#endif /* __STDC__ */
+#endif /* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index. If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN (yy_start) = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START (((yy_start) - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE yyrestart(yyin )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#define YY_BUF_SIZE 16384
+#endif
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+extern int yyleng;
+
+extern FILE *yyin, *yyout;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+ #define YY_LESS_LINENO(n)
+
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ *yy_cp = (yy_hold_char); \
+ YY_RESTORE_YY_MORE_OFFSET \
+ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+ } \
+ while ( 0 )
+
+#define unput(c) yyunput( c, (yytext_ptr) )
+
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ */
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef unsigned int yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via yyrestart()), so that the user can continue scanning by
+ * just pointing yyin at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* Stack of input buffers. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
+ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+ : NULL)
+
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
+
+/* yy_hold_char holds the character lost when yytext is formed. */
+static char yy_hold_char;
+static int yy_n_chars; /* number of characters read into yy_ch_buf */
+int yyleng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 1; /* whether we need to initialize */
+static int yy_start = 0; /* start state number */
+
+/* Flag which is used to allow yywrap()'s to do buffer switches
+ * instead of setting up a fresh yyin. A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void yyrestart (FILE *input_file );
+void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
+YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
+void yy_delete_buffer (YY_BUFFER_STATE b );
+void yy_flush_buffer (YY_BUFFER_STATE b );
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
+void yypop_buffer_state (void );
+
+static void yyensure_buffer_stack (void );
+static void yy_load_buffer_state (void );
+static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
+
+#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
+
+YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
+YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
+YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
+
+void *yyalloc (yy_size_t );
+void *yyrealloc (void *,yy_size_t );
+void yyfree (void * );
+
+#define yy_new_buffer yy_create_buffer
+
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){ \
+ yyensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ yy_create_buffer(yyin,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+ }
+
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){\
+ yyensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ yy_create_buffer(yyin,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+ }
+
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+/* Begin user sect3 */
+
+typedef unsigned char YY_CHAR;
+
+FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+
+typedef int yy_state_type;
+
+extern int yylineno;
+
+int yylineno = 1;
+
+extern char *yytext;
+#define yytext_ptr yytext
+
+static yy_state_type yy_get_previous_state (void );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
+static int yy_get_next_buffer (void );
+static void yy_fatal_error (yyconst char msg[] );
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+ (yytext_ptr) = yy_bp; \
+ yyleng = (size_t) (yy_cp - yy_bp); \
+ (yy_hold_char) = *yy_cp; \
+ *yy_cp = '\0'; \
+ (yy_c_buf_p) = yy_cp;
+
+#define YY_NUM_RULES 9
+#define YY_END_OF_BUFFER 10
+/* This struct is not used in this scanner,
+ but its presence is necessary. */
+struct yy_trans_info
+ {
+ flex_int32_t yy_verify;
+ flex_int32_t yy_nxt;
+ };
+static yyconst flex_int16_t yy_accept[36] =
+ { 0,
+ 0, 0, 10, 8, 1, 7, 8, 8, 6, 3,
+ 6, 0, 4, 0, 2, 6, 3, 6, 3, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 5, 0
+ } ;
+
+static yyconst flex_int32_t yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 1, 4, 5, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 6, 1, 1, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 8, 1, 1,
+ 1, 1, 1, 1, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 1, 1, 1, 1, 6, 1, 9, 9, 9, 9,
+
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1
+ } ;
+
+static yyconst flex_int32_t yy_meta[10] =
+ { 0,
+ 1, 1, 2, 1, 1, 3, 4, 1, 4
+ } ;
+
+static yyconst flex_int16_t yy_base[49] =
+ { 0,
+ 0, 0, 46, 47, 47, 47, 41, 41, 0, 4,
+ 36, 38, 37, 37, 47, 0, 7, 31, 31, 0,
+ 0, 29, 0, 0, 28, 0, 0, 27, 0, 0,
+ 26, 0, 0, 47, 47, 15, 19, 21, 29, 28,
+ 27, 26, 25, 24, 23, 22, 13, 8
+ } ;
+
+static yyconst flex_int16_t yy_def[49] =
+ { 0,
+ 35, 1, 35, 35, 35, 35, 36, 37, 38, 35,
+ 10, 36, 36, 37, 35, 38, 38, 38, 38, 39,
+ 40, 35, 41, 42, 35, 43, 44, 35, 45, 46,
+ 35, 47, 48, 35, 0, 35, 35, 35, 35, 35,
+ 35, 35, 35, 35, 35, 35, 35, 35
+ } ;
+
+static yyconst flex_int16_t yy_nxt[57] =
+ { 0,
+ 4, 5, 6, 7, 8, 9, 10, 4, 11, 16,
+ 17, 34, 18, 19, 20, 12, 33, 12, 12, 14,
+ 14, 14, 14, 16, 16, 31, 30, 28, 27, 25,
+ 24, 22, 21, 32, 29, 26, 23, 19, 20, 15,
+ 13, 13, 18, 15, 13, 35, 3, 35, 35, 35,
+ 35, 35, 35, 35, 35, 35
+ } ;
+
+static yyconst flex_int16_t yy_chk[57] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 10,
+ 10, 48, 10, 17, 17, 36, 47, 36, 36, 37,
+ 37, 37, 37, 38, 38, 46, 45, 44, 43, 42,
+ 41, 40, 39, 31, 28, 25, 22, 19, 18, 14,
+ 13, 12, 11, 8, 7, 3, 35, 35, 35, 35,
+ 35, 35, 35, 35, 35, 35
+ } ;
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+extern int yy_flex_debug;
+int yy_flex_debug = 0;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *yytext;
+#line 1 "lexer.l"
+#line 2 "lexer.l"
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2002-2008 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/* Nasty workaround, but flex defines isatty() twice */
+#define _UNISTD_H
+
+#include <stdio.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/rfcomm.h>
+
+#include "kword.h"
+#include "parser.h"
+
+int yylex(void);
+
+#define YY_NO_INPUT
+
+#define ECHO {;}
+#define YY_DECL int yylex(void)
+
+int yyerror(char *str);
+
+#line 512 "lex.yy.c"
+
+#define INITIAL 0
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+#include <unistd.h>
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap (void );
+#else
+extern int yywrap (void );
+#endif
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int );
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * );
+#endif
+
+#ifndef YY_NO_INPUT
+
+#ifdef __cplusplus
+static int yyinput (void );
+#else
+static int input (void );
+#endif
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+ { \
+ int c = '*'; \
+ size_t n; \
+ for ( n = 0; n < max_size && \
+ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( yyin ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ } \
+ else \
+ { \
+ errno=0; \
+ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(yyin); \
+ } \
+ }\
+\
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* end tables serialization structures and prototypes */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int yylex (void);
+
+#define YY_DECL int yylex (void)
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+ YY_USER_ACTION
+
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp, *yy_bp;
+ register int yy_act;
+
+#line 64 "lexer.l"
+
+
+#line 664 "lex.yy.c"
+
+ if ( (yy_init) )
+ {
+ (yy_init) = 0;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! (yy_start) )
+ (yy_start) = 1; /* first start state */
+
+ if ( ! yyin )
+ yyin = stdin;
+
+ if ( ! yyout )
+ yyout = stdout;
+
+ if ( ! YY_CURRENT_BUFFER ) {
+ yyensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ yy_create_buffer(yyin,YY_BUF_SIZE );
+ }
+
+ yy_load_buffer_state( );
+ }
+
+ while ( 1 ) /* loops until end-of-file is reached */
+ {
+ yy_cp = (yy_c_buf_p);
+
+ /* Support of yytext. */
+ *yy_cp = (yy_hold_char);
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+ yy_current_state = (yy_start);
+yy_match:
+ do
+ {
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 36 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ ++yy_cp;
+ }
+ while ( yy_base[yy_current_state] != 47 );
+
+yy_find_action:
+ yy_act = yy_accept[yy_current_state];
+ if ( yy_act == 0 )
+ { /* have to back up */
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ yy_act = yy_accept[yy_current_state];
+ }
+
+ YY_DO_BEFORE_ACTION;
+
+do_action: /* This label is used only to access EOF actions. */
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = (yy_hold_char);
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 66 "lexer.l"
+{
+ /* Skip spaces and tabs */
+ ;
+ }
+ YY_BREAK
+case 2:
+/* rule 2 can match eol */
+YY_RULE_SETUP
+#line 71 "lexer.l"
+{
+ /* Skip comments */
+ lineno++;
+ }
+ YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 76 "lexer.l"
+{
+ yylval.number = atoi(yytext);
+ return NUMBER;
+ }
+ YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 81 "lexer.l"
+{
+ yylval.string = yytext;
+ return STRING;
+ }
+ YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 86 "lexer.l"
+{
+ bdaddr_t *ba = malloc(sizeof(bdaddr_t));
+ str2ba(yytext, ba);
+ yylval.bdaddr = ba;
+ return BDADDR;
+ }
+ YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 93 "lexer.l"
+{
+ int keyword = rfcomm_find_keyword(rfcomm_keyword, yytext);
+ if (keyword != -1)
+ return keyword;
+
+ if (strncmp(yytext, "rfcomm", 6) == 0) {
+ yylval.number = atoi(yytext + 6);
+ return RFCOMM;
+ }
+
+ yylval.string = yytext;
+ return WORD;
+ }
+ YY_BREAK
+case 7:
+/* rule 7 can match eol */
+YY_RULE_SETUP
+#line 107 "lexer.l"
+{
+ lineno++;
+ }
+ YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 111 "lexer.l"
+{
+ return *yytext;
+ }
+ YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 115 "lexer.l"
+ECHO;
+ YY_BREAK
+#line 827 "lex.yy.c"
+case YY_STATE_EOF(INITIAL):
+ yyterminate();
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = (yy_hold_char);
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed yyin at a new source and called
+ * yylex(). If so, then we have to assure
+ * consistency between YY_CURRENT_BUFFER and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++(yy_c_buf_p);
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+ yy_cp = (yy_c_buf_p);
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ (yy_did_buffer_switch_on_eof) = 0;
+
+ if ( yywrap( ) )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * yytext, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) =
+ (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ (yy_c_buf_p) =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+} /* end of yylex */
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+static int yy_get_next_buffer (void)
+{
+ register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ register char *source = (yytext_ptr);
+ register int number_to_move, i;
+ int ret_val;
+
+ if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
+
+ else
+ {
+ int num_to_read =
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+
+ int yy_c_buf_p_offset =
+ (int) ((yy_c_buf_p) - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
+ }
+ else
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = 0;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+ number_to_move - 1;
+
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+ (yy_n_chars), num_to_read );
+
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ if ( (yy_n_chars) == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ yyrestart(yyin );
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ (yy_n_chars) += number_to_move;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
+
+ (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+ return ret_val;
+}
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+ static yy_state_type yy_get_previous_state (void)
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp;
+
+ yy_current_state = (yy_start);
+
+ for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
+ {
+ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 36 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ }
+
+ return yy_current_state;
+}
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
+{
+ register int yy_is_jam;
+ register char *yy_cp = (yy_c_buf_p);
+
+ register YY_CHAR yy_c = 1;
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 36 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_is_jam = (yy_current_state == 35);
+
+ return yy_is_jam ? 0 : yy_current_state;
+}
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+ static int yyinput (void)
+#else
+ static int input (void)
+#endif
+
+{
+ int c;
+
+ *(yy_c_buf_p) = (yy_hold_char);
+
+ if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ /* This was really a NUL. */
+ *(yy_c_buf_p) = '\0';
+
+ else
+ { /* need more input */
+ int offset = (yy_c_buf_p) - (yytext_ptr);
+ ++(yy_c_buf_p);
+
+ switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ yyrestart(yyin );
+
+ /*FALLTHROUGH*/
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( yywrap( ) )
+ return EOF;
+
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput();
+#else
+ return input();
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) = (yytext_ptr) + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
+ *(yy_c_buf_p) = '\0'; /* preserve yytext */
+ (yy_hold_char) = *++(yy_c_buf_p);
+
+ return c;
+}
+#endif /* ifndef YY_NO_INPUT */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ *
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+ void yyrestart (FILE * input_file )
+{
+
+ if ( ! YY_CURRENT_BUFFER ){
+ yyensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ yy_create_buffer(yyin,YY_BUF_SIZE );
+ }
+
+ yy_init_buffer(YY_CURRENT_BUFFER,input_file );
+ yy_load_buffer_state( );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ *
+ */
+ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
+{
+
+ /* TODO. We should be able to replace this entire function body
+ * with
+ * yypop_buffer_state();
+ * yypush_buffer_state(new_buffer);
+ */
+ yyensure_buffer_stack ();
+ if ( YY_CURRENT_BUFFER == new_buffer )
+ return;
+
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+ yy_load_buffer_state( );
+
+ /* We don't actually know whether we did this switch during
+ * EOF (yywrap()) processing, but the only time this flag
+ * is looked at is after yywrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+static void yy_load_buffer_state (void)
+{
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+ yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+ (yy_hold_char) = *(yy_c_buf_p);
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ *
+ * @return the allocated buffer state.
+ */
+ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
+{
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ yy_init_buffer(b,file );
+
+ return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with yy_create_buffer()
+ *
+ */
+ void yy_delete_buffer (YY_BUFFER_STATE b )
+{
+
+ if ( ! b )
+ return;
+
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ yyfree((void *) b->yy_ch_buf );
+
+ yyfree((void *) b );
+}
+
+#ifndef __cplusplus
+extern int isatty (int );
+#endif /* __cplusplus */
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a yyrestart() or at EOF.
+ */
+ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
+
+{
+ int oerrno = errno;
+
+ yy_flush_buffer(b );
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+ /* If b is the current buffer, then yy_init_buffer was _probably_
+ * called from yyrestart() or through yy_get_next_buffer.
+ * In that case, we don't want to reset the lineno or column.
+ */
+ if (b != YY_CURRENT_BUFFER){
+ b->yy_bs_lineno = 1;
+ b->yy_bs_column = 0;
+ }
+
+ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+
+ errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ *
+ */
+ void yy_flush_buffer (YY_BUFFER_STATE b )
+{
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == YY_CURRENT_BUFFER )
+ yy_load_buffer_state( );
+}
+
+/** Pushes the new state onto the stack. The new state becomes
+ * the current state. This function will allocate the stack
+ * if necessary.
+ * @param new_buffer The new state.
+ *
+ */
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
+{
+ if (new_buffer == NULL)
+ return;
+
+ yyensure_buffer_stack();
+
+ /* This block is copied from yy_switch_to_buffer. */
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ /* Only push if top exists. Otherwise, replace top. */
+ if (YY_CURRENT_BUFFER)
+ (yy_buffer_stack_top)++;
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+ /* copied from yy_switch_to_buffer. */
+ yy_load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ *
+ */
+void yypop_buffer_state (void)
+{
+ if (!YY_CURRENT_BUFFER)
+ return;
+
+ yy_delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ if ((yy_buffer_stack_top) > 0)
+ --(yy_buffer_stack_top);
+
+ if (YY_CURRENT_BUFFER) {
+ yy_load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+ }
+}
+
+/* Allocates the stack if it does not exist.
+ * Guarantees space for at least one push.
+ */
+static void yyensure_buffer_stack (void)
+{
+ int num_to_alloc;
+
+ if (!(yy_buffer_stack)) {
+
+ /* First allocation is just for 2 elements, since we don't know if this
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
+ * immediate realloc on the next call.
+ */
+ num_to_alloc = 1;
+ (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+
+ memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+
+ (yy_buffer_stack_max) = num_to_alloc;
+ (yy_buffer_stack_top) = 0;
+ return;
+ }
+
+ if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
+
+ /* Increase the buffer to prepare for a possible push. */
+ int grow_size = 8 /* arbitrary grow size */;
+
+ num_to_alloc = (yy_buffer_stack_max) + grow_size;
+ (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
+ ((yy_buffer_stack),
+ num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+
+ /* zero only the new slots.*/
+ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
+ (yy_buffer_stack_max) = num_to_alloc;
+ }
+}
+
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
+{
+ YY_BUFFER_STATE b;
+
+ if ( size < 2 ||
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
+ /* They forgot to leave room for the EOB's. */
+ return 0;
+
+ b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
+
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_pos = b->yy_ch_buf = base;
+ b->yy_is_our_buffer = 0;
+ b->yy_input_file = 0;
+ b->yy_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ yy_switch_to_buffer(b );
+
+ return b;
+}
+
+/** Setup the input buffer state to scan a string. The next call to yylex() will
+ * scan from a @e copy of @a str.
+ * @param str a NUL-terminated string to scan
+ *
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ * yy_scan_bytes() instead.
+ */
+YY_BUFFER_STATE yy_scan_string (yyconst char * yy_str )
+{
+
+ return yy_scan_bytes(yy_str,strlen(yy_str) );
+}
+
+/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
+ * scan from a @e copy of @a bytes.
+ * @param bytes the byte buffer to scan
+ * @param len the number of bytes in the buffer pointed to by @a bytes.
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE yy_scan_bytes (yyconst char * bytes, int len )
+{
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = len + 2;
+ buf = (char *) yyalloc(n );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
+
+ for ( i = 0; i < len; ++i )
+ buf[i] = bytes[i];
+
+ buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = yy_scan_buffer(buf,n );
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+}
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+static void yy_fatal_error (yyconst char* msg )
+{
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+}
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ yytext[yyleng] = (yy_hold_char); \
+ (yy_c_buf_p) = yytext + yyless_macro_arg; \
+ (yy_hold_char) = *(yy_c_buf_p); \
+ *(yy_c_buf_p) = '\0'; \
+ yyleng = yyless_macro_arg; \
+ } \
+ while ( 0 )
+
+/* Accessor methods (get/set functions) to struct members. */
+
+/** Get the current line number.
+ *
+ */
+int yyget_lineno (void)
+{
+
+ return yylineno;
+}
+
+/** Get the input stream.
+ *
+ */
+FILE *yyget_in (void)
+{
+ return yyin;
+}
+
+/** Get the output stream.
+ *
+ */
+FILE *yyget_out (void)
+{
+ return yyout;
+}
+
+/** Get the length of the current token.
+ *
+ */
+int yyget_leng (void)
+{
+ return yyleng;
+}
+
+/** Get the current token.
+ *
+ */
+
+char *yyget_text (void)
+{
+ return yytext;
+}
+
+/** Set the current line number.
+ * @param line_number
+ *
+ */
+void yyset_lineno (int line_number )
+{
+
+ yylineno = line_number;
+}
+
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ *
+ * @see yy_switch_to_buffer
+ */
+void yyset_in (FILE * in_str )
+{
+ yyin = in_str ;
+}
+
+void yyset_out (FILE * out_str )
+{
+ yyout = out_str ;
+}
+
+int yyget_debug (void)
+{
+ return yy_flex_debug;
+}
+
+void yyset_debug (int bdebug )
+{
+ yy_flex_debug = bdebug ;
+}
+
+/* yylex_destroy is for both reentrant and non-reentrant scanners. */
+int yylex_destroy (void)
+{
+
+ /* Pop the buffer stack, destroying each element. */
+ while(YY_CURRENT_BUFFER){
+ yy_delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ yypop_buffer_state();
+ }
+
+ /* Destroy the stack itself. */
+ yyfree((yy_buffer_stack) );
+ (yy_buffer_stack) = NULL;
+
+ return 0;
+}
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
+{
+ register int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+}
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * s )
+{
+ register int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+}
+#endif
+
+void *yyalloc (yy_size_t size )
+{
+ return (void *) malloc( size );
+}
+
+void *yyrealloc (void * ptr, yy_size_t size )
+{
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return (void *) realloc( (char *) ptr, size );
+}
+
+void yyfree (void * ptr )
+{
+ free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
+}
+
+#define YYTABLES_NAME "yytables"
+
+#undef YY_NEW_FILE
+#undef YY_FLUSH_BUFFER
+#undef yy_set_bol
+#undef yy_new_buffer
+#undef yy_set_interactive
+#undef yytext_ptr
+#undef YY_DO_BEFORE_ACTION
+
+#ifdef YY_DECL_IS_OURS
+#undef YY_DECL_IS_OURS
+#undef YY_DECL
+#endif
+#line 115 "lexer.l"
+
+
+
+int yywrap(void)
+{
+ return 1;
+}
+
--- /dev/null
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#include <stdlib.h>
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYPATCH 20050813
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING (yyerrflag != 0)
+
+extern int yyparse(void);
+
+static int yygrowstack(void);
+#define YYPREFIX "yy"
+#line 2 "parser.y"
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2002-2008 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/rfcomm.h>
+
+#include "kword.h"
+
+int yylex(void);
+int yyerror(char *s);
+
+struct rfcomm_opts *opts;
+
+#line 49 "parser.y"
+typedef union {
+ int number;
+ char *string;
+ bdaddr_t *bdaddr;
+} YYSTYPE;
+#line 74 "y.tab.c"
+#define K_BIND 257
+#define K_DEVICE 258
+#define K_CHANNEL 259
+#define K_COMMENT 260
+#define K_YES 261
+#define K_NO 262
+#define NUMBER 263
+#define RFCOMM 264
+#define STRING 265
+#define WORD 266
+#define BDADDR 267
+#define YYERRCODE 256
+short yylhs[] = { -1,
+ 0, 0, 0, 2, 2, 2, 2, 3, 5, 4,
+ 4, 4, 6, 6, 6, 6, 6, 1, 1,
+};
+short yylen[] = { 2,
+ 0, 1, 2, 4, 4, 1, 1, 1, 1, 2,
+ 2, 3, 2, 2, 2, 2, 1, 1, 1,
+};
+short yydefred[] = { 0,
+ 7, 9, 0, 0, 2, 0, 0, 3, 0, 0,
+ 0, 0, 0, 0, 0, 17, 0, 0, 0, 11,
+ 18, 19, 13, 14, 15, 16, 4, 0, 10, 5,
+ 12,
+};
+short yydgoto[] = { 4,
+ 23, 5, 6, 17, 7, 18,
+};
+short yysindex[] = { -254,
+ 0, 0, 0, -254, 0, -120, -109, 0, -251, -251,
+ -41, -245, -248, -243, -244, 0, -125, -37, -121, 0,
+ 0, 0, 0, 0, 0, 0, 0, -36, 0, 0,
+ 0,
+};
+short yyrindex[] = { 24,
+ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0,
+};
+short yygindex[] = { 0,
+ 0, 21, 0, 16, 0, -6,
+};
+#define YYTABLESIZE 267
+short yytable[] = { 27,
+ 6, 1, 9, 30, 11, 12, 13, 14, 15, 2,
+ 28, 3, 28, 10, 16, 21, 22, 20, 24, 25,
+ 26, 29, 31, 1, 8, 19, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 8, 0, 0, 0, 0, 0, 0,
+ 0, 12, 13, 14, 15, 12, 13, 14, 15, 0,
+ 16, 0, 0, 0, 16, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 6, 0, 0, 0,
+ 0, 0, 0, 0, 6, 0, 6,
+};
+short yycheck[] = { 125,
+ 0, 256, 123, 125, 256, 257, 258, 259, 260, 264,
+ 17, 266, 19, 123, 266, 261, 262, 59, 267, 263,
+ 265, 59, 59, 0, 4, 10, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 123, -1, -1, -1, -1, -1, -1,
+ -1, 257, 258, 259, 260, 257, 258, 259, 260, -1,
+ 266, -1, -1, -1, 266, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 256, -1, -1, -1,
+ -1, -1, -1, -1, 264, -1, 266,
+};
+#define YYFINAL 4
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 267
+#if YYDEBUG
+char *yyname[] = {
+"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"K_BIND","K_DEVICE",
+"K_CHANNEL","K_COMMENT","K_YES","K_NO","NUMBER","RFCOMM","STRING","WORD",
+"BDADDR",
+};
+char *yyrule[] = {
+"$accept : config",
+"config :",
+"config : statement",
+"config : config statement",
+"statement : section '{' rfcomm_options '}'",
+"statement : rfcomm '{' rfcomm_options '}'",
+"statement : WORD",
+"statement : error",
+"section : WORD",
+"rfcomm : RFCOMM",
+"rfcomm_options : rfcomm_option ';'",
+"rfcomm_options : error ';'",
+"rfcomm_options : rfcomm_options rfcomm_option ';'",
+"rfcomm_option : K_BIND bool",
+"rfcomm_option : K_DEVICE BDADDR",
+"rfcomm_option : K_CHANNEL NUMBER",
+"rfcomm_option : K_COMMENT STRING",
+"rfcomm_option : WORD",
+"bool : K_YES",
+"bool : K_NO",
+};
+#endif
+#if YYDEBUG
+#include <stdio.h>
+#endif
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+int yydebug;
+int yynerrs;
+int yyerrflag;
+int yychar;
+short *yyssp;
+YYSTYPE *yyvsp;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* variables for the parser stack */
+static short *yyss;
+static short *yysslim;
+static YYSTYPE *yyvs;
+static int yystacksize;
+#line 134 "parser.y"
+
+int yyerror(char *s)
+{
+ fprintf(stderr, "%s line %d\n", s, lineno);
+ return 0;
+}
+
+int rfcomm_read_config(char *filename)
+{
+ extern FILE *yyin;
+ char file[MAXPATHLEN + 1];
+ int i;
+
+ for (i = 0; i < RFCOMM_MAX_DEV; i++) {
+ rfcomm_opts[i].bind = 0;
+ bacpy(&rfcomm_opts[i].bdaddr, BDADDR_ANY);
+ rfcomm_opts[i].channel = 1;
+ }
+
+ if (filename) {
+ snprintf(file, MAXPATHLEN, "%s", filename);
+ } else {
+ snprintf(file, MAXPATHLEN, "%s/.bluetooth/rfcomm.conf", getenv("HOME"));
+
+ if ((getuid() == 0) || (access(file, R_OK) < 0))
+ snprintf(file, MAXPATHLEN, "%s/rfcomm.conf", CONFIGDIR);
+ }
+
+ if (!(yyin = fopen(file, "r")))
+ return -1;
+
+ lineno = 1;
+ yyparse();
+
+ fclose(yyin);
+
+ return 0;
+}
+#line 290 "y.tab.c"
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(void)
+{
+ int newsize, i;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = yystacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = yyssp - yyss;
+ newss = (yyss != 0)
+ ? (short *)realloc(yyss, newsize * sizeof(*newss))
+ : (short *)malloc(newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ yyss = newss;
+ yyssp = newss + i;
+ newvs = (yyvs != 0)
+ ? (YYSTYPE *)realloc(yyvs, newsize * sizeof(*newvs))
+ : (YYSTYPE *)malloc(newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ yyvs = newvs;
+ yyvsp = newvs + i;
+ yystacksize = newsize;
+ yysslim = yyss + newsize - 1;
+ return 0;
+}
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+int
+yyparse(void)
+{
+ register int yym, yyn, yystate;
+#if YYDEBUG
+ register const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+
+ if (yyss == NULL && yygrowstack()) goto yyoverflow;
+ yyssp = yyss;
+ yyvsp = yyvs;
+ *yyssp = yystate = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = yylex()) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yyssp >= yysslim && yygrowstack())
+ {
+ goto yyoverflow;
+ }
+ *++yyssp = yystate = yytable[yyn];
+ *++yyvsp = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+#ifdef lint
+ goto yyerrlab;
+#endif
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
+#endif
+ if (yyssp >= yysslim && yygrowstack())
+ {
+ goto yyoverflow;
+ }
+ *++yyssp = yystate = yytable[yyn];
+ *++yyvsp = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yyssp);
+#endif
+ if (yyssp <= yyss) goto yyabort;
+ --yyssp;
+ --yyvsp;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ yyval = yyvsp[1-yym];
+ switch (yyn)
+ {
+case 6:
+#line 74 "parser.y"
+{
+ }
+break;
+case 7:
+#line 77 "parser.y"
+{
+ yyclearin;
+ yyerrok;
+ }
+break;
+case 8:
+#line 84 "parser.y"
+{
+ opts = NULL;
+ }
+break;
+case 9:
+#line 90 "parser.y"
+{
+ if ((yyvsp[0].number >= 0) && (yyvsp[0].number < RFCOMM_MAX_DEV))
+ opts = &rfcomm_opts[yyvsp[0].number];
+ else
+ opts = NULL;
+ }
+break;
+case 13:
+#line 104 "parser.y"
+{
+ if (opts)
+ opts->bind = yyvsp[0].number;
+ }
+break;
+case 14:
+#line 109 "parser.y"
+{
+ if (opts)
+ bacpy(&opts->bdaddr, yyvsp[0].bdaddr);
+ }
+break;
+case 15:
+#line 114 "parser.y"
+{
+ if (opts)
+ opts->channel = yyvsp[0].number;
+ }
+break;
+case 16:
+#line 119 "parser.y"
+{
+ if (opts)
+ snprintf(opts->comment, MAXCOMMENTLEN, "%s", yyvsp[0].string);
+ }
+break;
+case 17:
+#line 124 "parser.y"
+{
+ /* Unknown option*/
+ }
+break;
+case 18:
+#line 129 "parser.y"
+{ yyval.number = 1; }
+break;
+case 19:
+#line 130 "parser.y"
+{ yyval.number = 0; }
+break;
+#line 537 "y.tab.c"
+ }
+ yyssp -= yym;
+ yystate = *yyssp;
+ yyvsp -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yyssp = YYFINAL;
+ *++yyvsp = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = yylex()) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yyssp, yystate);
+#endif
+ if (yyssp >= yysslim && yygrowstack())
+ {
+ goto yyoverflow;
+ }
+ *++yyssp = yystate;
+ *++yyvsp = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ return (1);
+
+yyaccept:
+ return (0);
+}
--- /dev/null
+/* A Bison parser, made by GNU Bison 2.3. */
+
+/* Skeleton interface for Bison's Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ K_BIND = 258,
+ K_DEVICE = 259,
+ K_CHANNEL = 260,
+ K_COMMENT = 261,
+ K_YES = 262,
+ K_NO = 263,
+ NUMBER = 264,
+ RFCOMM = 265,
+ STRING = 266,
+ WORD = 267,
+ BDADDR = 268
+ };
+#endif
+/* Tokens. */
+#define K_BIND 258
+#define K_DEVICE 259
+#define K_CHANNEL 260
+#define K_COMMENT 261
+#define K_YES 262
+#define K_NO 263
+#define NUMBER 264
+#define RFCOMM 265
+#define STRING 266
+#define WORD 267
+#define BDADDR 268
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+#line 50 "parser.y"
+{
+ int number;
+ char *string;
+ bdaddr_t *bdaddr;
+}
+/* Line 1489 of yacc.c. */
+#line 81 "parser.h"
+ YYSTYPE;
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+
+extern YYSTYPE yylval;
+
--- /dev/null
+LOCAL_PATH:= $(call my-dir)
+
+#
+# libbluetoothd
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ adapter.c \
+ agent.c \
+ dbus-common.c \
+ dbus-hci.c \
+ device.c \
+ error.c \
+ main.c \
+ manager.c \
+ plugin.c \
+ sdpd-request.c \
+ sdpd-service.c \
+ sdpd-server.c \
+ sdpd-database.c \
+ security.c \
+ storage.c
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\" \
+ -DSTORAGEDIR=\"/data/misc/bluetoothd\" \
+ -DCONFIGDIR=\"/etc/bluez\" \
+ -DSERVICEDIR=\"/system/bin\" \
+ -DPLUGINDIR=\"/system/lib/bluez-plugin\" \
+ -DANDROID_SET_AID_AND_CAP \
+ -DANDROID_EXPAND_NAME
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common \
+ $(LOCAL_PATH)/../gdbus \
+ $(LOCAL_PATH)/../plugins \
+ $(call include-path-for, glib) \
+ $(call include-path-for, glib)/glib \
+ $(call include-path-for, dbus)
+
+LOCAL_SHARED_LIBRARIES := \
+ libdl \
+ libbluetooth \
+ libdbus \
+ libcutils
+
+LOCAL_STATIC_LIBRARIES := \
+ libglib_static \
+ libbluez-common-static \
+ libbuiltinplugin \
+ libgdbus_static
+
+LOCAL_MODULE:=libbluetoothd
+
+include $(BUILD_SHARED_LIBRARY)
+
+#
+# bluetoothd
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetoothd
+
+LOCAL_MODULE:=bluetoothd
+
+include $(BUILD_EXECUTABLE)
return NULL;
}
+static DBusMessage *get_service_attribute_value_reply(DBusMessage *msg, DBusConnection *conn,
+ sdp_data_t *attr)
+{
+ DBusMessage *reply;
+ DBusMessageIter iter;
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return;
+ sdp_data_t *curr;
+ sdp_list_t *ap = 0;
+ for (; attr; attr = attr->next) {
+ sdp_list_t *pds = 0;
+ for (curr = attr->val.dataseq; curr; curr = curr->next)
+ pds = sdp_list_append(pds, curr->val.dataseq);
+ ap = sdp_list_append(ap, pds);
+ }
+
+ int ch = sdp_get_proto_port(ap, RFCOMM_UUID);
+ sdp_list_foreach(ap, (sdp_list_func_t) sdp_list_free, NULL);
+ sdp_list_free(ap, NULL);
+ ap = NULL;
+
+ dbus_message_append_args(reply, DBUS_TYPE_INT32, &ch, DBUS_TYPE_INVALID);
+
+ return reply;
+}
+
+static DBusMessage *get_service_attribute_value(DBusConnection *conn,
+ DBusMessage *msg,
+ void *user_data)
+{
+ struct btd_device *device = user_data;
+ sdp_record_t *rec;
+ sdp_data_t *attr_data;
+ const char *pattern;
+ uint16_t attrId;
+ int err;
+
+ if (device->browse)
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".InProgress",
+ "Discover in progress");
+ if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &pattern,
+ DBUS_TYPE_UINT16, &attrId,
+ DBUS_TYPE_INVALID) == FALSE)
+ goto fail;
+
+ if (strlen(pattern) == 0)
+ return invalid_args(msg);
+
+ rec = btd_device_get_record(device, pattern);
+ if (rec == NULL) {
+ error("rec is NULL");
+ goto fail;
+ }
+
+ attr_data = sdp_data_get(rec, attrId);
+
+ if (attr_data == NULL) {
+ error("attr in null");
+ goto fail;
+ }
+ return get_service_attribute_value_reply(msg, conn, attr_data);
+fail:
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
+ "GetServiceAttribute Failed");
+}
+
static GDBusMethodTable device_methods[] = {
{ "GetProperties", "", "a{sv}", get_properties },
{ "SetProperty", "sv", "", set_property },
{ "CancelDiscovery", "", "", cancel_discover },
{ "Disconnect", "", "", disconnect,
G_DBUS_METHOD_FLAG_ASYNC},
+ { "GetServiceAttributeValue", "sq", "i", get_service_attribute_value},
{ }
};
pairing multi;
# Default PIN code for incoming connections
- passkey "BlueZ";
+ passkey "Bluez";
}
# Default settings for HCI devices
# Default adaper name
# %h - substituted for hostname
# %d - substituted for adapter id
-Name = %h-%d
+Name = "Bluez"
# Default device class. Only the major and minor device class bits are
# considered.
# How long to stay in discoverable mode before going back to non-discoverable
# The value is in seconds. Default is 180, i.e. 3 minutes.
# 0 = disable timer, i.e. stay discoverable forever
-DiscoverableTimeout = 0
+DiscoverableTimeout = 120
# How long to stay in pairable mode before going back to non-discoverable
# The value is in seconds. Default is 0.
# Use vendor, product and version information for DID profile support.
# The values are separated by ":" and VID, PID and version.
-#DeviceID = 1234:5678:abcd
+DeviceID = android:generic:1.5
# Do reverse service discovery for previously unknown devices that connect to
# us. This option is really only needed for qualification since the BITE tester
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/socket.h>
+#include <cutils/sockets.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/l2cap.h>
unix_sock = -1;
return 0;
}
+#if 0
+ /* Create local Unix socket */
+ unix_sock = socket(PF_UNIX, SOCK_STREAM, 0);
+ if (unix_sock < 0) {
+ error("opening UNIX socket: %s", strerror(errno));
+ return -1;
+ }
+
+ memset(&unaddr, 0, sizeof(unaddr));
+ unaddr.sun_family = AF_UNIX;
+ strcpy(unaddr.sun_path, SDP_UNIX_PATH);
+
+ unlink(unaddr.sun_path);
+
+ if (bind(unix_sock, (struct sockaddr *) &unaddr, sizeof(unaddr)) < 0) {
+ error("binding UNIX socket: %s", strerror(errno));
+ return -1;
+ }
+
+ listen(unix_sock, 5);
+
+ chmod(SDP_UNIX_PATH, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
+#else
+ unix_sock = android_get_control_socket("bluetooth");
+ if (unix_sock < 0) {
+ error("Unable to get the control socket for 'bluetooth'");
+ return -1;
+ }
+
+ if (listen(unix_sock, 5)) {
+ error("Listening on local socket failed: %s", strerror(errno));
+ return -1;
+ }
+
+ info("Got Unix socket fd '%d' from environment", unix_sock);
+#endif
- /* Create local Unix socket */
- unix_sock = socket(PF_UNIX, SOCK_STREAM, 0);
- if (unix_sock < 0) {
- error("opening UNIX socket: %s", strerror(errno));
- return -1;
- }
-
- memset(&unaddr, 0, sizeof(unaddr));
- unaddr.sun_family = AF_UNIX;
- strcpy(unaddr.sun_path, SDP_UNIX_PATH);
-
- unlink(unaddr.sun_path);
-
- if (bind(unix_sock, (struct sockaddr *) &unaddr, sizeof(unaddr)) < 0) {
- error("binding UNIX socket: %s", strerror(errno));
- return -1;
- }
-
- listen(unix_sock, 5);
-
- chmod(SDP_UNIX_PATH, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
-
- return 0;
+ return 0;
}
static gboolean io_session_event(GIOChannel *chan, GIOCondition cond, gpointer data)
uint8_t get_service_classes(const bdaddr_t *bdaddr);
void set_service_classes_callback(service_classes_callback_t callback);
void create_ext_inquiry_response(const char *name, uint8_t *data);
+static inline int android_get_control_socket(const char *name);
--- /dev/null
+LOCAL_PATH:= $(call my-dir)
+
+#
+# hstest
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\"
+
+LOCAL_SRC_FILES:= \
+ hstest.c
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=hstest
+
+include $(BUILD_EXECUTABLE)
+
+#
+# l2test
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\"
+
+LOCAL_SRC_FILES:= \
+ l2test.c
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=l2test
+
+include $(BUILD_EXECUTABLE)
+
+#
+# rctest
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\"
+
+LOCAL_SRC_FILES:= \
+ rctest.c
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=rctest
+
+include $(BUILD_EXECUTABLE)
+
+
+#
+# scotest
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\"
+
+LOCAL_SRC_FILES:= \
+ scotest.c
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=scotest
+
+include $(BUILD_EXECUTABLE)
+
+#
+# agent
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\"
+
+LOCAL_SRC_FILES:= \
+ agent.c
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common \
+ $(call include-path-for, dbus)
+
+LOCAL_SHARED_LIBRARIES := \
+ libdbus
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=agent
+
+include $(BUILD_EXECUTABLE)
+
+#
+# attest
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\"
+
+LOCAL_SRC_FILES:= \
+ attest.c
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=attest
+
+include $(BUILD_EXECUTABLE)
+
+#
+# avtest
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\"
+
+LOCAL_SRC_FILES:= \
+ avtest.c
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=avtest
+
+include $(BUILD_EXECUTABLE)
+
+#
+# bdaddr
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\"
+
+LOCAL_SRC_FILES:= \
+ bdaddr.c
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth
+
+LOCAL_STATIC_LIBRARIES := \
+ libbluez-common-static
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=bdaddr
+
+include $(BUILD_EXECUTABLE)
+
+#
+# btiotest
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\"
+
+LOCAL_SRC_FILES:= \
+ btiotest.c
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common \
+ $(call include-path-for, glib) \
+ $(call include-path-for, glib)\glib
+
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth \
+
+LOCAL_STATIC_LIBRARIES := \
+ libbluez-common-static \
+ libglib_static \
+
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=btiotest
+
+include $(BUILD_EXECUTABLE)
+
+#
+# hciemu
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\"
+
+LOCAL_SRC_FILES:= \
+ hciemu.c
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common \
+ $(call include-path-for, glib) \
+ $(call include-path-for, glib)\glib
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth \
+ libc \
+ libcutils
+
+LOCAL_STATIC_LIBRARIES := \
+ libglib_static
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=hciemu
+
+include $(BUILD_EXECUTABLE)
+
+#
+# lmptest
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\"
+
+LOCAL_SRC_FILES:= \
+ lmptest.c
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=lmptest
+
+include $(BUILD_EXECUTABLE)
+
+#
+# sdptest
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\"
+
+LOCAL_SRC_FILES:= \
+ sdptest.c
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=sdptest
+
+include $(BUILD_EXECUTABLE)
#include <config.h>
#endif
+#include <netinet/in.h>
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
--- /dev/null
+LOCAL_PATH:= $(call my-dir)
+
+#
+# avinfo
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ avinfo.c
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\"
+
+LOCAL_C_INCLUDES:=\
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common \
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=avinfo
+
+include $(BUILD_EXECUTABLE)
+
+#
+# sdptool
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ sdptool.c
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\" -fpermissive
+
+LOCAL_C_INCLUDES:=\
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common \
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth
+
+LOCAL_STATIC_LIBRARIES := \
+ libbluez-common-static
+
+LOCAL_MODULE:=sdptool
+
+include $(BUILD_EXECUTABLE)
+
+#
+# hciconfig
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ csr.c \
+ csr_h4.c \
+ hciconfig.c
+
+LOCAL_CFLAGS:= \
+ -DSTORAGEDIR=\"/tmp\" \
+ -DVERSION=\"4.40\"
+
+LOCAL_C_INCLUDES:=\
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common \
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth
+
+LOCAL_STATIC_LIBRARIES := \
+ libbluez-common-static
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=hciconfig
+
+include $(BUILD_EXECUTABLE)
+
+#
+# hcitool
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ hcitool.c
+
+LOCAL_CFLAGS:= \
+ -DSTORAGEDIR=\"/tmp\" \
+ -DVERSION=\"4.40\"
+
+LOCAL_C_INCLUDES:=\
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common \
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth
+
+LOCAL_STATIC_LIBRARIES := \
+ libbluez-common-static
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=hcitool
+
+include $(BUILD_EXECUTABLE)
+
+#
+# l2ping
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ l2ping.c
+
+LOCAL_C_INCLUDES:=\
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common \
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE:=l2ping
+
+include $(BUILD_EXECUTABLE)
+
+#
+# hciattach
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ hciattach.c \
+ hciattach_st.c \
+ hciattach_ti.c \
+ hciattach_tialt.c
+
+LOCAL_CFLAGS:= \
+ -DVERSION=\"4.40\" \
+ -D__BSD_VISIBLE=1
+
+LOCAL_C_INCLUDES:=\
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/../common \
+
+LOCAL_SHARED_LIBRARIES := \
+ libbluetooth
+
+LOCAL_STATIC_LIBRARIES := \
+ libbluez-common-static
+
+LOCAL_MODULE:=hciattach
+
+include $(BUILD_EXECUTABLE)
#include "hciattach.h"
-#ifdef NEED_PPOLL
#include "ppoll.h"
-#endif
struct uart_t {
char *type;
uint32_t speed;
} __attribute__((packed)) texas_speed_change_cmd_t;
-static int texas_change_speed(int fd, uint32_t speed)
+static int texas_change_speed(int fd, struct termios *ti, uint32_t speed)
{
- return 0;
+ /* Send a speed-change request */
+ texas_speed_change_cmd_t cmd;
+ int n;
+
+ cmd.uart_prefix = HCI_COMMAND_PKT;
+ cmd.hci_hdr.opcode = 0xff36;
+ cmd.hci_hdr.plen = sizeof(uint32_t);
+ cmd.speed = speed;
+
+ fprintf(stderr, "Setting speed to %d\n", speed);
+ n = write(fd, &cmd, sizeof(cmd));
+ if (n < 0) {
+ perror("Failed to write speed-set command");
+ return -1;
+ }
+ if (n < (int)sizeof(cmd)) {
+ fprintf(stderr, "Wanted to write %d bytes, could only write %d. "
+ "Stop\n", (int)sizeof(cmd), n);
+ return -1;
+ }
+ /* Parse speed-change reply */
+ if (read_command_complete(fd, cmd.hci_hdr.opcode, cmd.hci_hdr.plen) < 0) {
+ return -1;
+ }
+ if (set_speed(fd, ti, speed) < 0) {
+ perror("Can't set baud rate");
+ return -1;
+ }
+ return 0;
}
static int texas_load_firmware(int fd, const char *firmware) {
sprintf(fw, "/etc/firmware/%s.bin", c_brf_chip[brf_chip]);
texas_load_firmware(fd, fw);
- texas_change_speed(fd, speed);
+ texas_change_speed(fd, ti, speed);
}
nanosleep(&tm, NULL);
return 0;