[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bluetooth-dev] some updates for btd/btduser
Hi,
I made some fixes in the btd's source:
1) turned of pty echo in open_pty; removed ready_for_ppp flag
2) introduced USE_READLINE option; readline lib is used if this is
defined in btd.c
Do not forget to remove the '-lreadline' option from the Makefile,
when building without readline lib.
Default is USE_READLINE enabled for all the others that use it !
I hope that someone can put this on the CVS !
A patch to btd.c (ver. 1.84) is attached ! It can be applied by typing
'patch -n 0 < brd_1_84_mfuchs.p' from the
cvs root !
Matthias
--
-------------------------------------------------
\ Matthias Fuchs \
\ esd electronic system design Gmbh \
\ Vahrenwalder Straße 205 \
\ D-30165 Hannover \
\ email: matthias.fuchs@xxxxxxx.com \
\ phone: +49-511-37298-0 \
\ fax: +49-511-37298-68 \
--------------------------------------------------
--- apps/bluetooth/btd/btd.c Mon Mar 5 12:15:55 2001
+++ ../current/apps/bluetooth/btd/btd.c Fri Mar 9 11:42:05 2001
@@ -150,8 +150,13 @@
#include <sys/un.h>
#include <arpa/inet.h>
-#include <readline/readline.h>
-#include <readline/history.h>
+/* comment out the next line if you do not have the readline lib - mfuchs */
+#define USE_READLINE
+
+#ifdef USE_READLINE
+# include <readline/readline.h>
+# include <readline/history.h>
+#endif
#define RESTART_ENABLED
@@ -202,7 +207,6 @@
extern int bt_read_proc(char *buf, int len);
bt_stat_struct bt_stat;
static int bt_initdone = 0;
-static int ready_for_ppp = 0;
rfcomm_con *test_rfcomm;
int test_dlci;
@@ -322,6 +326,13 @@
#define MANUFACTURER_SPEC 0x3f
#endif
+#ifndef USE_READLINE
+void read_history(char *hist_file_name);
+void write_history(char *hist_file_name);
+void add_history(char *command);
+char *readline(char *promt);
+#endif
+
/* Modem emulator stuff */
#define CONNECT 1
@@ -861,6 +872,28 @@
}
}
+/* readline replacement - mfuchs */
+#ifndef USE_READLINE
+#define MAXLINE 100
+
+void read_history(char *hist_file_name){}
+void write_history(char *hist_file_name){}
+void add_history(char *command){}
+
+char *readline(char *promt)
+{
+ int len;
+ char *line;
+
+ line = malloc(MAXLINE);
+ printf("%s",promt);
+ fflush(stdout);
+ len = read(STDIN_FILENO,line,MAXLINE-1);
+ line[len]=0;
+ return line;
+}
+#endif /* ifndef USE_READLINE */
+
#ifndef BTD_USERSTACK
static void start_sdp_server(void)
{
@@ -879,11 +912,6 @@
static void start_pppd(void)
{
-
-#ifdef BTD_USERSTACK
- ready_for_ppp = 1;
-#endif
-
/* run pppd in a child */
if (!(pppd_pid = vfork()))
{
@@ -922,11 +950,6 @@
syslog(LOG_ERR, "Failed to return IP address to IPA\n");
}
#endif
-
-#ifdef BTD_USERSTACK
- ready_for_ppp = 0;
-#endif
-
}
/* FIXME -- use separate options file 'pppd file <optionfile>' for
@@ -2156,8 +2179,35 @@
*/
int open_pty(void)
{
+ struct termios settings;
+ int result;
+
printf("Open pty.\n");
- return openpty(&pty_master_fd, &pty_slave_fd, ptydev, NULL, NULL);
+ result = openpty(&pty_master_fd, &pty_slave_fd, ptydev, NULL, NULL);
+ if (result < 0)
+ {
+ perror("openpty: ");
+ return result;
+ }
+
+ /* modify pty settinges -> turn off echo - mfuchs */
+ result = tcgetattr (pty_master_fd, &settings);
+ if (result < 0)
+ {
+ perror ("tcgetattr: ");
+ return result;
+ }
+
+ cfmakeraw(&settings);
+ settings.c_lflag &= ~ECHO;
+
+ result = tcsetattr (pty_master_fd, TCSANOW, &settings);
+ if (result < 0)
+ {
+ perror ("tcsetattr: ");
+ return result;
+ }
+ return 0;
}
/* Create a thread that reads data from the pty and
@@ -2252,11 +2302,6 @@
return len;
}
- /* FIXME -- why is data echoed back if no application is running on top
- of PTY ?? */
- if (!ready_for_ppp)
- return len;
-
/* feed this to PTY connected to pppd or whatever application
that may be running there... */
@@ -3114,6 +3159,7 @@
printf("Setting baudrate in Ericsson module!\n");
hci_set_baudrate(spd);
+
#endif
}