From ea4cc8f50a27657568093fbcd30a18324506f096 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 9 Dec 2012 10:48:23 +0100 Subject: [PATCH] build: Remove unused hstest utility --- .gitignore | 1 - Makefile.tools | 7 +- test/hsmicro | 20 ---- test/hsplay | 22 ---- test/hstest.c | 310 ------------------------------------------------- 5 files changed, 2 insertions(+), 358 deletions(-) delete mode 100755 test/hsmicro delete mode 100755 test/hsplay delete mode 100644 test/hstest.c diff --git a/.gitignore b/.gitignore index 1f741c162..8a8216cf4 100644 --- a/.gitignore +++ b/.gitignore @@ -51,7 +51,6 @@ tools/sdptool test/agent test/bdaddr test/hciemu -test/hstest test/avtest test/l2test test/rctest diff --git a/Makefile.tools b/Makefile.tools index f207594bb..fe969144f 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -146,8 +146,7 @@ sbin_PROGRAMS += test/hciemu bin_PROGRAMS += test/l2test test/rctest -noinst_PROGRAMS += test/gaptest test/sdptest test/scotest \ - test/hstest test/avtest \ +noinst_PROGRAMS += test/gaptest test/sdptest test/scotest test/avtest \ test/lmptest test/bdaddr test/agent \ test/btiotest test/test-textfile \ test/uuidtest test/mpris-player @@ -164,8 +163,6 @@ test_sdptest_LDADD = lib/libbluetooth-private.la test_scotest_LDADD = lib/libbluetooth-private.la -test_hstest_LDADD = lib/libbluetooth-private.la - test_avtest_LDADD = lib/libbluetooth-private.la test_lmptest_LDADD = lib/libbluetooth-private.la @@ -193,7 +190,7 @@ else EXTRA_DIST += test/rctest.1 test/hciemu.1 test/bdaddr.8 endif -EXTRA_DIST += test/sap_client.py test/hsplay test/hsmicro test/bluezutils.py \ +EXTRA_DIST += test/sap_client.py test/bluezutils.py \ test/dbusdef.py test/monitor-bluetooth test/list-devices \ test/test-discovery test/test-manager test/test-adapter \ test/test-device test/test-service test/simple-agent \ diff --git a/test/hsmicro b/test/hsmicro deleted file mode 100755 index c254226b4..000000000 --- a/test/hsmicro +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -SOX=`which sox` -HSTEST=`which hstest` - -if [ -z "$HSTEST" ] -then - HSTEST="./hstest" -fi - -if [ -z "$1" ] -then - echo -e "Usage:\n\thsmicro [channel]" - exit -fi - -BDADDR=$1 -CHANNEL=$2 - -$HSTEST record - $BDADDR $CHANNEL | $SOX -t raw -r 8000 -c 1 -s -w - -t ossdsp -r 44100 -c 2 -s -w /dev/dsp polyphase vol 5.0 2> /dev/null diff --git a/test/hsplay b/test/hsplay deleted file mode 100755 index 8cecbffa4..000000000 --- a/test/hsplay +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -MPG123=`which mpg123` -SOX=`which sox` -HSTEST=`which hstest` - -if [ -z "$HSTEST" ] -then - HSTEST="./hstest" -fi - -if [ -z "$1" ] || [ -z "$2" ] -then - echo -e "Usage:\n\thsplay [channel]" - exit -fi - -FILE=$1 -BDADDR=$2 -CHANNEL=$3 - -$MPG123 -q -s "$FILE" | $SOX -t raw -r 44100 -c 2 -s -w - -t raw -r 8000 -c 1 -s -w - | $HSTEST play - $BDADDR $CHANNEL diff --git a/test/hstest.c b/test/hstest.c deleted file mode 100644 index ac68059ab..000000000 --- a/test/hstest.c +++ /dev/null @@ -1,310 +0,0 @@ -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - * Copyright (C) 2002-2010 Marcel Holtmann - * - * - * 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 -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -static volatile int terminate = 0; - -static void sig_term(int sig) { - terminate = 1; -} - -static int rfcomm_connect(bdaddr_t *src, bdaddr_t *dst, uint8_t channel) -{ - struct sockaddr_rc addr; - int s; - - if ((s = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0) { - return -1; - } - - memset(&addr, 0, sizeof(addr)); - addr.rc_family = AF_BLUETOOTH; - bacpy(&addr.rc_bdaddr, src); - addr.rc_channel = 0; - if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - close(s); - return -1; - } - - memset(&addr, 0, sizeof(addr)); - addr.rc_family = AF_BLUETOOTH; - bacpy(&addr.rc_bdaddr, dst); - addr.rc_channel = channel; - if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0 ){ - close(s); - return -1; - } - - return s; -} - -static int sco_connect(bdaddr_t *src, bdaddr_t *dst, uint16_t *handle, uint16_t *mtu) -{ - struct sockaddr_sco addr; - struct sco_conninfo conn; - struct sco_options opts; - socklen_t size; - int s; - - if ((s = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO)) < 0) { - return -1; - } - - memset(&addr, 0, sizeof(addr)); - addr.sco_family = AF_BLUETOOTH; - bacpy(&addr.sco_bdaddr, src); - - if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - close(s); - return -1; - } - - memset(&addr, 0, sizeof(addr)); - addr.sco_family = AF_BLUETOOTH; - bacpy(&addr.sco_bdaddr, dst); - - if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0 ){ - close(s); - return -1; - } - - memset(&conn, 0, sizeof(conn)); - size = sizeof(conn); - - if (getsockopt(s, SOL_SCO, SCO_CONNINFO, &conn, &size) < 0) { - close(s); - return -1; - } - - memset(&opts, 0, sizeof(opts)); - size = sizeof(opts); - - if (getsockopt(s, SOL_SCO, SCO_OPTIONS, &opts, &size) < 0) { - close(s); - return -1; - } - - if (handle) - *handle = conn.hci_handle; - - if (mtu) - *mtu = opts.mtu; - - return s; -} - -static void usage(void) -{ - printf("Usage:\n" - "\thstest play [channel]\n" - "\thstest record [channel]\n"); -} - -#define PLAY 1 -#define RECORD 2 - -int main(int argc, char *argv[]) -{ - struct sigaction sa; - - fd_set rfds; - struct timeval timeout; - unsigned char buf[2048], *p; - int maxfd, sel, rlen, wlen; - - bdaddr_t local; - bdaddr_t bdaddr; - uint8_t channel; - - char *filename; - mode_t filemode; - int mode = 0; - int dd, rd, sd, fd; - uint16_t sco_handle, sco_mtu, vs; - - switch (argc) { - case 4: - str2ba(argv[3], &bdaddr); - channel = 6; - break; - case 5: - str2ba(argv[3], &bdaddr); - channel = atoi(argv[4]); - break; - default: - usage(); - exit(-1); - } - - if (strncmp(argv[1], "play", 4) == 0) { - mode = PLAY; - filemode = O_RDONLY; - } else if (strncmp(argv[1], "rec", 3) == 0) { - mode = RECORD; - filemode = O_WRONLY | O_CREAT | O_TRUNC; - } else { - usage(); - exit(-1); - } - - filename = argv[2]; - - hci_devba(0, &local); - dd = hci_open_dev(0); - hci_read_voice_setting(dd, &vs, 1000); - vs = htobs(vs); - fprintf(stderr, "Voice setting: 0x%04x\n", vs); - close(dd); - if (vs != 0x0060) { - fprintf(stderr, "The voice setting must be 0x0060\n"); - return -1; - } - - if (strcmp(filename, "-") == 0) { - switch (mode) { - case PLAY: - fd = 0; - break; - case RECORD: - fd = 1; - break; - default: - return -1; - } - } else { - if ((fd = open(filename, filemode)) < 0) { - perror("Can't open input/output file"); - return -1; - } - } - - memset(&sa, 0, sizeof(sa)); - sa.sa_flags = SA_NOCLDSTOP; - sa.sa_handler = sig_term; - sigaction(SIGTERM, &sa, NULL); - sigaction(SIGINT, &sa, NULL); - - sa.sa_handler = SIG_IGN; - sigaction(SIGCHLD, &sa, NULL); - sigaction(SIGPIPE, &sa, NULL); - - if ((rd = rfcomm_connect(&local, &bdaddr, channel)) < 0) { - perror("Can't connect RFCOMM channel"); - return -1; - } - - fprintf(stderr, "RFCOMM channel connected\n"); - - if ((sd = sco_connect(&local, &bdaddr, &sco_handle, &sco_mtu)) < 0) { - perror("Can't connect SCO audio channel"); - close(rd); - return -1; - } - - fprintf(stderr, "SCO audio channel connected (handle %d, mtu %d)\n", sco_handle, sco_mtu); - - if (mode == RECORD) { - if (write(rd, "RING\r\n", 6) < 0) - return -errno; - } - - maxfd = (rd > sd) ? rd : sd; - - while (!terminate) { - - FD_ZERO(&rfds); - FD_SET(rd, &rfds); - FD_SET(sd, &rfds); - - timeout.tv_sec = 0; - timeout.tv_usec = 10000; - - if ((sel = select(maxfd + 1, &rfds, NULL, NULL, &timeout)) > 0) { - - if (FD_ISSET(rd, &rfds)) { - memset(buf, 0, sizeof(buf)); - rlen = read(rd, buf, sizeof(buf)); - if (rlen > 0) { - fprintf(stderr, "%s\n", buf); - wlen = write(rd, "OK\r\n", 4); - } - } - - if (FD_ISSET(sd, &rfds)) { - memset(buf, 0, sizeof(buf)); - rlen = read(sd, buf, sizeof(buf)); - if (rlen > 0) - switch (mode) { - case PLAY: - rlen = read(fd, buf, rlen); - - wlen = 0; - p = buf; - while (rlen > sco_mtu) { - wlen += write(sd, p, sco_mtu); - rlen -= sco_mtu; - p += sco_mtu; - } - wlen += write(sd, p, rlen); - break; - case RECORD: - wlen = write(fd, buf, rlen); - break; - default: - break; - } - } - - } - - } - - close(sd); - sleep(5); - close(rd); - - close(fd); - - return 0; -} -- 2.47.3