|
From: Mattias A. <mat...@us...> - 2001-04-17 12:09:11
|
The following file was modified in apps/bluetooth/btd:
Name Old version New version Comment
---- ----------- ----------- -------
btd.c 1.90 1.91=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* added setting event filter for CSR Hw too.
* added return code in start_sdp_server
* fixed correct args when starting sdp_server in usermode stack
* fixed shutting down sdp_server when quitting btd
* changed how test_disc works, now shut down all l2cap connections
* minor changes
The diff of the modified file(s):
--- btd.c 2001/04/11 12:23:45 1.90
+++ btd.c 2001/04/17 12:09:10 1.91
@@ -231,7 +231,7 @@
#define BT_DATA(fmt...)=20
#endif
=20
-#if BT_DATAFLOW_DEBUG
+#if BT_DATADUMP_DEBUG
#define PRINTPKT(str, data, len) print_data(str, data, len)
#else
#define PRINTPKT(str, data, len)
@@ -285,9 +285,7 @@
static int open_socket(char *name, int role);
=20
static int sdpsrv_pid =3D 0;
-#ifndef BTD_USERSTACK
-static void start_sdp_server(void);
-#endif
+static int start_sdp_server(void);
=20
/* misc */
#ifndef BTD_USERSTACK
@@ -732,12 +730,8 @@
physdev, btdev, speedstring);
#endif
=20
- /* FIXME -- add check for pppd */
-
-#ifndef BTD_USERSTACK
if (role =3D=3D SERVER)
- start_sdp_server();
-#endif
+ sdpsrv_pid =3D start_sdp_server();
=20=20=20
spd =3D atoi(speedstring);
=20
@@ -776,10 +770,6 @@
{
read_history(BTD_HISTORY_FILE);
=20
-#ifdef BTD_USERSTACK
- sleep(2); /* temp fix - wait for last command response to be returned =
*/
-#endif
-
printf("Now entering cmd line mode\n");
=20
show_menu();
@@ -917,21 +907,32 @@
}
#endif /* !HAVE_READLINE */
=20
-#ifndef BTD_USERSTACK
-static void start_sdp_server(void)
+#define SDPSRV_CONF "/etc/sdp.xml"
+
+#ifdef BTD_USERSTACK
+#define SDPSRV_PROC "/tmp/sdp_sock"
+#else
+#define SDPSRV_PROC "/proc/sdp_srv"
+#endif
+
+int start_sdp_server(void)
{
- syslog(LOG_INFO, "Starting SDP server\n");
+ int sdpsrv_pid;
+ char *args[] =3D { SDPSRV_CMD, SDPSRV_CONF, SDPSRV_PROC, NULL };
=20=20=20
+ syslog(LOG_INFO, "Starting SDP server [%s]\n", SDPSRV_CMD);=20=20
+
if (!(sdpsrv_pid =3D vfork()))
{
- execlp(SDPSRV_CMD, SDPSRV_CMD);
+ execvp(SDPSRV_CMD, args);
=20
fprintf(stderr, "%s: no such file or directory\n", SDPSRV_CMD);
+ syslog(LOG_INFO, "%s not found", SDPSRV_CMD);
=20
_exit(0);
}
+ return sdpsrv_pid;
}
-#endif
=20
static void start_pppd(void)
{
@@ -1546,12 +1547,25 @@
}
else if (strncmp(buf, "test_disc", 9) =3D=3D 0)
{
- printf("Disconnecting TEST layer\n");
+ l2cap_con *con =3D get_first_con();
+ printf("Disconnecting all l2cap cons\n");
+
+#if 1
+ con =3D get_first_con();
+ while (con!=3D NULL) {
+ l2ca_disconnect_req(con);
+ con =3D get_first_con();
+ sleep(1);
+ }
+#else
test_disconnect_req(testcon); /* extern l2cap_con set in test.c */
sleep(2);
test_disconnect_req(testcon2);
sleep(2);
test_disconnect_req(testcon3);
+#endif=20=20=20=20
+ /* shutdown baseband ? */
+
}
else if(sscanf(buf, "bb_conn %x:%x:%x:%x:%x:%x",
&bd[5], &bd[4], &bd[3], &bd[2], &bd[1], &bd[0]) =3D=3D 6)
@@ -1732,6 +1746,9 @@
bt_initdone =3D 0;
}
#endif
+
+ btd_killchilds();
+
}
=20
int open_device(char* dev, int flags, int role)
@@ -2168,7 +2185,7 @@
if (pthread_create(&read_thread, NULL,=20
(void*)hci_receive_thread, NULL)!=3D0)
perror("pthread_create");=20=20=20=20
- sleep(1); /* wait for thread to start */
+=20
return 0;
}
=20
@@ -2290,6 +2307,8 @@
int retval;
int bytes_sent =3D 0;
=20
+ printf("bt_write_top : try sending data on last connected ch\n");
+
BT_DATA(" |X|<-- %3d [%d]\n", count, line);
=20=20=20
while (bytes_sent!=3Dcount)
@@ -2300,13 +2319,12 @@
if (retval > 0)
bytes_sent+=3Dretval;
else if (retval=3D=3D0)
- usleep(1000); /* wait some ... */
+ usleep(100000); /* wait some ... */
else
{
printf("error\n");
return retval;
}
-=20=20=20
usleep(1000); /* wait some time ... */
};
=20
@@ -3153,7 +3171,7 @@
=20
/* set_event_filter must be called for m/s switch on IrmaC! */
sleep(1);
- evfilter[0] =3D 0x02; /* Conenction setup */
+ evfilter[0] =3D 0x02; /* Connection setup */
evfilter[1] =3D 0x00; /* All devices */
evfilter[2] =3D 0x01; /* No auto accept */
printf("Setting event filter in Ericsson module!\n");
@@ -3228,6 +3246,7 @@
{=20=20
#ifndef BTD_USERSTACK
unsigned int wrscan =3D (PAGE_SCAN_ENABLE | INQUIRY_SCAN_ENABLE);
+ unsigned char evfilter[3];=20
unsigned int tmp[2];
tmp[0]=3D0x50;
tmp[1]=3D0x20;
@@ -3248,6 +3267,19 @@
perror("HCIWRITESCANENABLE");
exit(1);
}
+
+ sleep(1);
+ evfilter[0] =3D 0x02; /* Connection setup */
+ evfilter[1] =3D 0x00; /* All devices */
+ evfilter[2] =3D 0x01; /* No auto accept */
+ printf("Setting event filter in CSR module!\n");
+ if (ioctl(bt_cfd, HCISET_EVENT_FILTER, &evfilter) < 0)
+ {=20
+ perror("HCISET_EVENT_FILTER");
+ exit(1);
+ }
+
+
#else
printf("Setting write_scan_enable in CSR module!\n");
hci_write_scan_enable(PAGE_SCAN_ENABLE|INQUIRY_SCAN_ENABLE);
|