|
From: Peter K. <pk...@us...> - 2001-09-06 16:16:28
|
The following files were modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
bt_vendor.c 1.27 1.28=20=20=20=20=20=20=20=20=20=20=20=20
bt_vendor.h 1.7 1.8=20=20=20=20=20=20=20=20=20=20=20=20=20
btd.c 1.25 1.26=20=20=20=20=20=20=20=20=20=20=20=20
btinit.c 1.13 1.14=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
csr_h4_to_bcsp() and csr_bcsp_to_h4() need the initial hardware speed.
The diff of the modified file(s):
--- bt_vendor.c 2001/09/06 16:02:37 1.27
+++ bt_vendor.c 2001/09/06 16:16:26 1.28
@@ -73,6 +73,8 @@
static void unknown_init_phys(int fd);
static void unknown_init_hw(int bt_cfd, int phys_fd, int spd);
=20
+static void csr_change_if(int bt_cfd, int phys_fd, int speed);
+
void
init_phys(int fd)
{
@@ -161,7 +163,7 @@
*/
=20
void
-init_failed(int bt_cfd, int phys_fd)
+init_failed(int bt_cfd, int phys_fd, int speed)
{
=20
static int did_restart =3D 0; /* only try once */=20=20
@@ -178,7 +180,7 @@
{
case HW_CSR:
/* Try changing interface BCSP<->H4 */
- csr_change_if(bt_cfd, phys_fd);
+ csr_change_if(bt_cfd, phys_fd, speed);
did_restart =3D 1;
=20
/* Restart btd */
@@ -312,21 +314,21 @@
* Switches host interface in CSR HW (H4<->BCSP)=20
*/
=20
-void csr_change_if(int bt_cfd, int phys_fd)
+void csr_change_if(int bt_cfd, int phys_fd, int speed)
{
/* This may seem reversed, but hw_vendor() returns what we want,
not what we have, in this situation... */
if (!bt_bcsp_mode(bt_cfd, -1))
{
- csr_bcsp_to_h4(bt_cfd, phys_fd);
+ csr_bcsp_to_h4(bt_cfd, phys_fd, speed);
}
else
{
- csr_h4_to_bcsp(bt_cfd, phys_fd);
+ csr_h4_to_bcsp(bt_cfd, phys_fd, speed);
}
}
=20
-void csr_bcsp_to_h4(int bt_cfd, int phys_fd)
+void csr_bcsp_to_h4(int bt_cfd, int phys_fd, int speed)
{
unsigned short ps_parbuf[10];
=20
@@ -335,8 +337,11 @@
/* Temporarily set stack to use BCSP framing */
bt_bcsp_mode(bt_cfd, 1);
=20
- /* Setup serial port for BCSP (default baudrate) */
- fd_setup(phys_fd, 115200, USE_FLOW_CTRL);
+ if (speed)
+ fd_setup(phys_fd, speed, USE_FLOW_CTRL);
+ else
+ init_phys(phys_fd);
+
reset_hw();
=20
if (ioctl(bt_cfd, BTINITBCSP) < 0)
@@ -391,7 +396,7 @@
shutdown_stack(bt_cfd);
}
=20
-void csr_h4_to_bcsp(int bt_cfd, int phys_fd)
+void csr_h4_to_bcsp(int bt_cfd, int phys_fd, int speed)
{
unsigned short ps_parbuf[10];
=20
@@ -400,8 +405,10 @@
/* Set stack to use H4 temporarily */=20=20=20=20=20=20=20=20
bt_bcsp_mode(bt_cfd, 0);
=20
- /* Setup serial port for H4 (default baudrate) */
- fd_setup(phys_fd, 115200, USE_FLOW_CTRL);
+ if (speed)
+ fd_setup(phys_fd, speed, USE_FLOW_CTRL);
+ else
+ init_phys(phys_fd);
=20
reset_hw();=20=20=20=20
=20
--- bt_vendor.h 2001/08/29 10:02:05 1.7
+++ bt_vendor.h 2001/09/06 16:16:26 1.8
@@ -66,12 +66,11 @@
=20
void init_hw(int bt_cfd, int phys_fd, int spd);
void init_phys(int fd);
-void init_failed(int bt_cfd, int phys_fd);
+void init_failed(int bt_cfd, int phys_fd, int speed);
=20
int hw_vendor(void);
=20
-void csr_change_if(int bt_cfd, int phys_fd);
-void csr_bcsp_to_h4(int bt_cfd, int phys_fd);
-void csr_h4_to_bcsp(int bt_cfd, int phys_fd);
+void csr_bcsp_to_h4(int bt_cfd, int phys_fd, int speed);
+void csr_h4_to_bcsp(int bt_cfd, int phys_fd, int speed);
=20
#endif /* __BT_VENDOR_H__*/
--- btd.c 2001/09/05 15:33:46 1.25
+++ btd.c 2001/09/06 16:16:26 1.26
@@ -301,7 +301,14 @@
reset_hw();
=20
if (init_stack(bt_cfd) < 0)
- init_failed(bt_cfd, phys_fd);
+ {
+ /* For some reason, the stack sometimes fails to initialize the first
+ time. So let us try an extra time, just to be sure... */
+ if (init_stack(bt_cfd) < 0)
+ {
+ init_failed(bt_cfd, phys_fd, init_hw_speed);
+ }
+ }
=20
if (do_hwinit)
init_hw(bt_cfd, phys_fd, atoi(speedstr));
--- btinit.c 2001/08/29 10:02:05 1.13
+++ btinit.c 2001/09/06 16:16:26 1.14
@@ -222,7 +222,14 @@
reset_hw();
=20=20=20
if (init_stack(bt_cfd) < 0)
- init_failed(bt_cfd, phys_fd);
+ {
+ /* For some reason, the stack sometimes fails to initialize the first
+ time. So let us try an extra time, just to be sure... */
+ if (init_stack(bt_cfd) < 0)
+ {
+ init_failed(bt_cfd, phys_fd, init_hw_speed);
+ }
+ }
=20=20=20
if (do_hwinit)
init_hw(bt_cfd, phys_fd, atoi(speedstr));
|
|
From: Peter K. <pk...@us...> - 2001-10-10 16:22:11
|
The following files were modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
Makefile 1.9 1.10=20=20=20=20=20=20=20=20=20=20=20=20
bt_vendor.c 1.29 1.30=20=20=20=20=20=20=20=20=20=20=20=20
bt_vendor.h 1.10 1.11=20=20=20=20=20=20=20=20=20=20=20=20
btconfig.c 1.7 1.8=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Made it possible to specify the maximum transmit power to use
(only supported for CSR).
The diff of the modified file(s):
--- Makefile 2001/09/26 14:24:26 1.9
+++ Makefile 2001/10/10 16:22:10 1.10
@@ -30,7 +30,7 @@
BTDISCOBJS =3D btdisc.o bt_if.o bt_misc.o
BTINQOBJS =3D btinq.o bt_if.o bt_misc.o
BTTESTOBJS =3D bttest.o bt_misc.o bt_vendor.o bt_if.o
-BTCONFIGOBJS =3D btconfig.o bt_if.o bt_misc.o
+BTCONFIGOBJS =3D btconfig.o bt_vendor.o bt_if.o bt_misc.o
=20
ifdef HAVE_READLINE_READLINE
LDLIBS +=3D -lreadline -ltermcap
--- bt_vendor.c 2001/10/03 17:46:13 1.29
+++ bt_vendor.c 2001/10/10 16:22:10 1.30
@@ -49,6 +49,8 @@
#include <signal.h>
#include <string.h>
#include <stdlib.h>
+#include <limits.h>
+#include <errno.h>
=20
#include "bt_misc.h"
#include "bt_vendor.h"
@@ -74,6 +76,7 @@
static void unknown_init_hw(int bt_cfd, int phys_fd, const char *speedstr);
=20
static void csr_change_if(int bt_cfd, int phys_fd, const char *speedstr);
+static int csr_set_max_power(int bt_cfd, short max_power);
=20
void
init_phys(int fd)
@@ -155,7 +158,20 @@
}
}
=20
+int
+bt_set_max_power(int bt_cfd, short max_power)
+{
+ switch (hw_vendor())
+ {
+ case HW_CSR:
+ return csr_set_max_power(bt_cfd, max_power);
=20
+ default:
+ errno =3D EPERM;
+ return -1;
+ }
+}
+
/*=20
* This function tries to recover stack if init failed=20
* For now all other vendors but CSR is left to restart=20
@@ -235,13 +251,14 @@
/* CSR specific commands */
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
=20
+#define PSKEY_LC_MAX_TX_POWER 0x0017
#define PSKEY_HOSTIO_UART_PS_BLOCK 0x0191
#define PSKEY_HOST_INTERFACE 0x01f9
#define PSKEY_UART_SLEEP_TIMEOUT 0x0222
+
#define CSR_PSKEY_GETREQ 0x0
#define CSR_PSKEY_SETREQ 0x2
=20
-
/* Set the phys device to CSR default, 115200 */=20
void
csr_init_phys(int fd)
@@ -505,6 +522,29 @@
syslog(LOG_INFO, "Did not set baudrate in CSR module as its firmware=
is too old (%d)", firmware);
}
}
+}
+
+int
+csr_set_max_power(int bt_cfd, short max_power)
+{
+ short old_max_power =3D SHRT_MAX;
+
+ /* We need to wait a little here for some reason, or the reading of the
+ current maximum power may fail and return 0 */
+ usleep(50000);
+
+ csr_pskey(bt_cfd, PSKEY_LC_MAX_TX_POWER, CSR_PSKEY_GETREQ, (unsigned sho=
rt *)&old_max_power, 1);
+
+ if (old_max_power !=3D max_power)
+ {
+ csr_pskey(bt_cfd, PSKEY_LC_MAX_TX_POWER, CSR_PSKEY_SETREQ, (unsigned s=
hort *)&max_power, 1);
+ if (restart_btd() < 0)
+ {
+ syslog(LOG_INFO, "Failed to restart btd");
+ }
+ }
+
+ return 0;
}
=20
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
--- bt_vendor.h 2001/10/03 17:46:40 1.10
+++ bt_vendor.h 2001/10/10 16:22:10 1.11
@@ -68,6 +68,8 @@
void init_phys(int fd);
void init_failed(int bt_cfd, int phys_fd, const char *speedstr);
=20
+int bt_set_max_power(int bt_cfd, short max_power);
+
int hw_vendor(void);
=20
void csr_bcsp_to_h4(int bt_cfd, int phys_fd, const char *speedstr);
--- btconfig.c 2001/09/10 12:01:18 1.7
+++ btconfig.c 2001/10/10 16:22:10 1.8
@@ -61,6 +61,7 @@
#include "bt_if.h"
#include "bt_conf.h"
#include "bt_misc.h"
+#include "bt_vendor.h"
=20=20=20=20=20
/****************** CONSTANT AND MACRO SECTION ***************************=
***/
=20
@@ -107,6 +108,7 @@
static int var_force_ms_switch =3D -1; /* not yet set */
static int var_set_local_name =3D 0;
static int var_max_connections =3D -1; /* not yet set */
+static short var_max_power =3D SHRT_MAX; /* not yet set */
=20
/* long option list */
static struct option long_options[] =3D
@@ -204,7 +206,8 @@
if (var_set_local_name ||
var_write_scan_enable >=3D 0 ||
var_force_ms_switch >=3D 0 ||
- var_max_connections >=3D 0)
+ var_max_connections >=3D 0 ||
+ var_max_power !=3D SHRT_MAX)
{
/* Open BT ctrl device */=20=20
if ((bt_cfd =3D bt_openctrl()) < 0)
@@ -233,6 +236,9 @@
if (var_max_connections >=3D 0)
bt_set_max_conections(bt_cfd, var_max_connections);
=20
+ if (var_max_power !=3D SHRT_MAX)
+ bt_set_max_power(bt_cfd, var_max_power);
+=20=20=20=20
close(bt_cfd);
}
=20
@@ -452,6 +458,11 @@
{=20
var_max_connections =3D atoi(value);
D(syslog(LOG_INFO, __FUNCTION__ ": Maximum BT connections: %s", value)=
);
+ }
+ else if (!strcasecmp(field, "MaxPower"))
+ {=20
+ var_max_power =3D atoi(value);
+ D(syslog(LOG_INFO, __FUNCTION__ ": Maximum power: %s", value));
}
=20=20=20
return TRUE;
|
|
From: Peter K. <pk...@us...> - 2002-02-26 17:50:57
|
The following files were modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
bt_if.c 1.41 1.42=20=20=20=20=20=20=20=20=20=20=20=20
bt_misc.c 1.23 1.24=20=20=20=20=20=20=20=20=20=20=20=20
bt_misc.h 1.12 1.13=20=20=20=20=20=20=20=20=20=20=20=20
btconfig.c 1.10 1.11=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added get_domain_name() which tries to get the domain name first
from /etc/resolv.conf, and if that fails using gethostname() or
getdomainname() (whichever succeeds).
The diff of the modified file(s):
--- bt_if.c 16 Oct 2001 16:15:34 -0000 1.41
+++ bt_if.c 26 Feb 2002 17:43:32 -0000 1.42
@@ -971,13 +971,11 @@
=20
void set_local_hostname(int bt_cfd, const char *local_name)
{
- unsigned char domainname[DOMAIN_NAME_LENGTH+1];
unsigned char buf[LOCAL_NAME_LENGTH + HOST_NAME_LENGTH +=20
DOMAIN_NAME_LENGTH + 5];
int len =3D 0;
=20
*buf =3D '\0';
- *domainname =3D '\0';
=20
if (*local_name)
{
@@ -1001,11 +999,12 @@
=20
if (!strchr(&buf[len], '.'))
{
- getdomainname(domainname, DOMAIN_NAME_LENGTH);
- if (*domainname)
+ char* domain_name =3D get_domain_name();
+
+ if (*domain_name)
{
strcat(buf, ".");
- strcat(buf, domainname);
+ strncat(buf, domain_name, DOMAIN_NAME_LENGTH);
}
}
=20
--- bt_misc.c 16 Oct 2001 15:02:19 -0000 1.23
+++ bt_misc.c 26 Feb 2002 17:43:32 -0000 1.24
@@ -44,7 +44,6 @@
#include <sys/wait.h>
#include <fcntl.h>
#include <stdio.h>
-#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <stdlib.h>
@@ -53,6 +52,7 @@
#include <errno.h>
#include <stdarg.h>
#include <signal.h>
+#include <ctype.h>
#include <linux/serial.h> /* struct serial_struct */
=20
/* The following includes are required to be able to determine the local
@@ -313,6 +313,73 @@
strcpy(ip, inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr));
=20
return ip;
+}
+
+char*
+get_domain_name(void)
+{
+ static char domain_name[256];
+ static char line[256];
+ FILE* file;
+
+ *domain_name =3D '\0';
+
+ /* Extract the domain name from the /etc/resolv.conf file */
+
+ if ((file =3D fopen("/etc/resolv.conf", "r")))
+ {
+ while (fgets(line, sizeof line, file))
+ {
+ char* s =3D line;
+
+ while (isspace(*s))
+ {
+ s++;
+ }
+
+ if (!strncasecmp(s, "domain", 6) && isspace(s[6]))
+ {
+ char* d =3D domain_name;
+
+ s +=3D 7;
+ while (isspace(*s))
+ {
+ s++;
+ }
+
+ while (*s && !isspace(*s))
+ {
+ *d++ =3D *s++;
+ }
+ *d =3D '\0';
+
+ if (*domain_name)
+ {
+ break;
+ }
+ }
+ else if (!strncasecmp(s, "search", 6) && isspace(s[6]))
+ {
+ char* d =3D domain_name;
+
+ s +=3D 7;
+ while (isspace(*s))
+ {
+ s++;
+ }
+
+ while (*s && !isspace(*s))
+ {
+ *d++ =3D *s++;
+ }
+ *d =3D '\0';
+ }
+ }
+
+ fclose(file);
+ }
+
+ return domain_name;
}
=20
int=20
--- bt_misc.h 16 Oct 2001 15:02:20 -0000 1.12
+++ bt_misc.h 26 Feb 2002 17:43:32 -0000 1.13
@@ -64,6 +64,9 @@
int restart_btd(void);
=20
char *get_local_ip_address(void);
+
+char* get_domain_name(void);
+
const char *bd2str(const unsigned char *bd);
#ifndef BT_USERSTACK
void print_data(const char *message, const unsigned char *buf, int len);
--- btconfig.c 12 Oct 2001 07:37:39 -0000 1.10
+++ btconfig.c 26 Feb 2002 17:43:32 -0000 1.11
@@ -428,19 +428,18 @@
=20
if (var_add_host_name =3D=3D TRUE)
{
- char tmp_str[DOMAIN_NAME_LENGTH];
-
D(syslog(LOG_INFO, __FUNCTION__": Add hostname and domain name"));
=20=20=20=20=20=20=20
gethostname(ip_name, HOST_NAME_LENGTH);
=20=20=20=20=20=20=20
if (!strchr(ip_name, '.'))
{
- getdomainname(tmp_str, DOMAIN_NAME_LENGTH);
- if (*tmp_str)
+ char* domain_name =3D get_domain_name();
+
+ if (*domain_name)
{
strcat(ip_name, ".");
- strcat(ip_name, tmp_str);
+ strncat(ip_name, domain_name, DOMAIN_NAME_LENGTH);
}
}
}
|