From: Peter K. <pk...@us...> - 2001-03-13 22:19:16
|
The following files were modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20 btd.c 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20 btinit.c 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20 btsend.c 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20 modememul.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added O_NOCTTY flag to all open() calls of any /dev/ttyBT* device to make sure we do not accidentally end up with one as controlling TTY. The diff of the modified file(s): --- bt_if.c 2001/03/02 10:59:57 1.1 +++ bt_if.c 2001/03/13 22:21:17 1.2 @@ -95,7 +95,7 @@ =20 int bt_isinitiated(void) { - int bt_cfd =3D open(BT_CTRL_TTY, O_RDWR); + int bt_cfd =3D open(BT_CTRL_TTY, O_RDWR | O_NOCTTY); int stack_initiated =3D -1; =20 if (ioctl(bt_cfd, BTISINITIATED, &stack_initiated) < 0) @@ -135,7 +135,7 @@ int devfd; =20 printf("Resetting HW board...\n"); - if ((devfd =3D open(BT_CTRL_TTY, O_RDWR)) >=3D 0) + if ((devfd =3D open(BT_CTRL_TTY, O_RDWR | O_NOCTTY)) >=3D 0) { if (ioctl(devfd, BTRESETPHYSICALHW) < 0) { @@ -162,7 +162,7 @@ { int bt_cfd; printf("Now opening BT Ctrl TTY [%s]\n", BT_CTRL_TTY); - if ((bt_cfd =3D open(BT_CTRL_TTY, O_RDWR)) < 0) + if ((bt_cfd =3D open(BT_CTRL_TTY, O_RDWR | O_NOCTTY)) < 0) { printf("could not open %s\n", BT_CTRL_TTY); exit(1); @@ -790,6 +790,7 @@ int open_device(char* dev, int flags, int role) { int fd; + #ifdef BT_USERSTACK=20=20 /* if opening bt dev or control dev simply discard and return fake fd */ if ((strcmp(dev, btdev)=3D=3D0) || (strcmp(dev, BT_CTRL_TTY)=3D=3D0) ) @@ -802,7 +803,7 @@ #endif=20=20 =20 syslog(LOG_INFO, "Opening dev %s\n", dev); - if ((fd =3D open(dev, flags)) < 0 ) + if ((fd =3D open(dev, flags | O_NOCTTY)) < 0) {=20 perror("open_device"); exit(1); @@ -821,6 +822,7 @@ if (fd !=3D 0xb055e) close(fd); #else + if (fd !=3D -1) close(fd); #endif } --- btd.c 2001/03/09 15:57:33 1.3 +++ btd.c 2001/03/13 22:21:17 1.4 @@ -264,7 +264,7 @@ if (do_reset) reset_hw(); =20=20=20 - if ((phys_fd =3D open(physdev, O_RDWR)) < 0) + if ((phys_fd =3D open(physdev, O_RDWR | O_NOCTTY)) < 0) { perror("could not open phys dev\n"); exit(1); @@ -275,7 +275,7 @@ /* Set the current tty to the bluetooth discpline */ set_bt_line_disc(phys_fd, bt_disc, physdev); =20=20=20 - bt_cfd =3D open(BT_CTRL_TTY, O_RDWR); + bt_cfd =3D open(BT_CTRL_TTY, O_RDWR | O_NOCTTY); =20=20=20 init_stack(bt_cfd, atoi(speedstr)); =20=20=20 --- btinit.c 2001/03/02 10:59:57 1.1 +++ btinit.c 2001/03/13 22:21:17 1.2 @@ -198,7 +198,7 @@ if (do_reset) reset_hw(); =20 - if ((phys_fd =3D open(physdev, O_RDWR)) < 0) + if ((phys_fd =3D open(physdev, O_RDWR | O_NOCTTY)) < 0) { perror("could not open phys dev\n"); exit(1); @@ -210,7 +210,7 @@ /* Set the current tty to the bluetooth discpline */ set_bt_line_disc(phys_fd, bt_disc, physdev); =20=20=20 - bt_cfd =3D open(BT_CTRL_TTY, O_RDWR); + bt_cfd =3D open(BT_CTRL_TTY, O_RDWR | O_NOCTTY); =20 init_stack(bt_cfd, atoi(speedstr)); =20 --- btsend.c 2001/03/02 10:59:57 1.1 +++ btsend.c 2001/03/13 22:21:17 1.2 @@ -119,7 +119,7 @@ /* Open BT device */=20=20 =20 printf("Opening %s\n", btdev); - if ((bt_fd =3D open(btdev, O_RDWR, CLIENT)) < 0) + if ((bt_fd =3D open(btdev, O_RDWR | O_NOCTTY, CLIENT)) < 0) { printf("could not open %s\n", btdev); exit(1); --- modememul.c 2001/03/05 11:17:24 1.2 +++ modememul.c 2001/03/13 22:21:17 1.3 @@ -119,7 +119,7 @@ while (done!=3DSTART_PPP) { syslog(LOG_INFO, "Open %s", argv[1]); - if ((btfd =3D open(argv[1], O_RDWR)) < 0) + if ((btfd =3D open(argv[1], O_RDWR | O_NOCTTY)) < 0) { perror("open"); exit(1); |
From: Peter K. <pk...@us...> - 2001-04-04 10:43:06
|
The following files were modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_misc.c 1.4 1.5=20=20=20=20=20=20=20=20=20=20=20=20=20 bt_misc.h 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20 btcon.c 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20 btd.c 1.6 1.7=20=20=20=20=20=20=20=20=20=20=20=20=20 bttest.c 1.5 1.6=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Use bd2str() instead of print_bd_addr(). The diff of the modified file(s): --- bt_misc.c 2001/04/04 10:31:19 1.4 +++ bt_misc.c 2001/04/04 10:43:04 1.5 @@ -331,10 +331,14 @@ return; } =20 -void print_bd_addr(char* str, unsigned char bd[6]) +const char* bd2str(const unsigned char *bd) { - printf("%s: %02X:%02X:%02X:%02X:%02X:%02X\n", - str, bd[0], bd[1], bd[2], bd[3], bd[4], bd[5]); + static char buf[20]; + + sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X", + bd[0], bd[1], bd[2], bd[3], bd[4], bd[5]); + + return buf; } =20 void=20 --- bt_misc.h 2001/03/30 12:34:54 1.3 +++ bt_misc.h 2001/04/04 10:43:04 1.4 @@ -59,7 +59,7 @@ =20 int write_pidfile(char *pidname); void get_local_addr(char *str); -void print_bd_addr(char* str, unsigned char *bd); +const char* bd2str(const unsigned char *bd); #ifndef BT_USERSTACK void print_data(const char *message, unsigned char *buf, int len); #endif --- btcon.c 2001/04/04 10:32:03 1.3 +++ btcon.c 2001/04/04 10:43:04 1.4 @@ -175,8 +175,7 @@ =20=20=20 /* Connect RFCOMM session on line */ =20=20 - print_bd_addr("Connecting to ", bd); - printf("on line %d\n", line); + printf("Connecting to %s on line %d\n", bd2str(bd), line); =20 con_id =3D CREATE_RFCOMM_ID(line, srvch << 1); =20 --- btd.c 2001/03/26 15:30:36 1.6 +++ btd.c 2001/04/04 10:43:04 1.7 @@ -268,8 +268,7 @@ physdev =3D optarg; break; =20=20=20=20=20=20=20 - case '?' : - printf("unknown option: %c\n", optopt); + default: break; } } @@ -294,7 +293,7 @@ =20 /* Sets initial HW baudrate */ if (init_hw_speed !=3D 0) - fd_setup(phys_fd, init_hw_speed, 1); + fd_setup(phys_fd, init_hw_speed, USE_FLOW_CTRL); else init_phys(phys_fd); =20 @@ -359,10 +358,10 @@ =20=20=20=20=20=20=20 default: { +#ifdef USE_IPASSIGN /* Got data on some fd */ int i, retval; =20 -#ifdef USE_IPASSIGN=20 for (i=3D0; i < result; i++)=20 { /* IPA response */ @@ -400,7 +399,7 @@ STATE(line) =3D CONNECTED; =20=20=20=20=20=20=20 read_remote_bd(bt_cfd, PEER(line).remote_bd); - print_bd_addr("remote bd ", PEER(line).remote_bd); + printf("Remote bd: %s\n", bd2str(PEER(line).remote_bd)); =20=20=20=20=20=20=20 #ifdef USE_IPASSIGN D(syslog(LOG_INFO, "Sending IPA request\n")); --- bttest.c 2001/03/30 12:46:32 1.5 +++ bttest.c 2001/04/04 10:43:04 1.6 @@ -249,7 +249,7 @@ { unsigned char my_bd_addr[6];=20=20 read_local_bd(bt_cfd, my_bd_addr); - print_bd_addr("Local BD ", my_bd_addr); + printf("Local BD: %s\n", bd2str(my_bd_addr)); } else if(sscanf(buf, "role_switch %x:%x:%x:%x:%x:%x %d ", &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4],=20 @@ -313,7 +313,7 @@ bd[i] =3D (unsigned char)tmp[i]; } =20=20 - print_bd_addr("Pinging ", bd); + printf("Pinging: %s\n", bd2str(bd)); =20 /* fill it with something */ memset(buf, 'A', count); @@ -332,7 +332,7 @@ bd[i] =3D (unsigned char)tmp[i]; } =20=20 - print_bd_addr("Get info from : ", bd); + printf("Get info from: %s\n", bd2str(bd)); =20 bt_getinfo(bt_cfd, bd, type); } |
From: Peter K. <pk...@us...> - 2001-06-08 09:55:48
|
The following files were modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.16 1.17=20=20=20=20=20=20=20=20=20=20=20=20 bt_ipa.c 1.4 1.5=20=20=20=20=20=20=20=20=20=20=20=20=20 bt_vendor.c 1.16 1.17=20=20=20=20=20=20=20=20=20=20=20=20 btd.c 1.18 1.19=20=20=20=20=20=20=20=20=20=20=20=20 modememul.c 1.8 1.9=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * Improved some log messages. * Marked debug messages as such. The diff of the modified file(s): --- bt_if.c 2001/05/29 10:04:12 1.16 +++ bt_if.c 2001/06/08 09:55:47 1.17 @@ -72,7 +72,7 @@ =20 void init_stack(int bt_cfd, int spd) { - syslog(LOG_INFO, "Init stack\n"); + syslog(LOG_INFO, "Init stack"); =20=20=20 #ifdef BT_USERSTACK init_userstack(); @@ -116,7 +116,7 @@ =20 void shutdown_stack(int bt_cfd) { - syslog(LOG_INFO, "Shutting down bluetooth stack\n"); + syslog(LOG_INFO, "Shutting down bluetooth stack"); #ifndef BT_USERSTACK if (bt_cfd !=3D -1 && (ioctl(bt_cfd, BTSHUTDOWN) < 0)) { @@ -183,6 +183,7 @@ int bt_openctrl(void) { int bt_cfd; + D(syslog(LOG_INFO, "Now opening BT Ctrl TTY [" BT_CTRL_TTY "]")); #ifdef BT_USERSTACK printf(__FUNCTION__ ": ignored in userstack\n"); @@ -448,7 +449,7 @@ memcpy(ping.data, data, len); =20=20=20 #ifndef BT_USERSTACK=20 - if ((ret_val =3D ioctl(bt_cfd, BTPING, &ping)) !=3D 0) + if ((ret_val =3D ioctl(bt_cfd, BTPING, &ping)) < 0) { printf("Error : %s\n", error_msg(ret_val)); } @@ -471,7 +472,7 @@ msg[7] =3D (unsigned char)(type & 0xff); =20 #ifndef BT_USERSTACK=20 - if ((ret_val =3D ioctl(bt_cfd, BTGETINFO, &msg)) !=3D 0) + if ((ret_val =3D ioctl(bt_cfd, BTGETINFO, &msg)) < 0) { printf("Error : %s\n", error_msg(ret_val)); } @@ -491,7 +492,7 @@ print_data("cmd ", cmd, strlen(cmd)); =20 #ifndef BT_USERSTACK=20 - if ((ret_val =3D ioctl(bt_cfd, BTTESTCOMMAND, cmd)) !=3D 0) + if ((ret_val =3D ioctl(bt_cfd, BTTESTCOMMAND, cmd)) < 0) { printf("Error : %s\n", error_msg(ret_val)); } @@ -506,9 +507,10 @@ int bt_force_msswitch_as_server(int bt_cfd, int enable) { int ret_val; + syslog(LOG_INFO, __FUNCTION__ ": %d", enable); #ifndef BT_USERSTACK=20 - if ((ret_val =3D ioctl(bt_cfd, BTSETMSSWITCH, &enable)) !=3D 0) + if ((ret_val =3D ioctl(bt_cfd, BTSETMSSWITCH, &enable)) < 0) { fprintf(stderr, __FUNCTION__ ": %s\n", error_msg(ret_val)); } @@ -662,7 +664,8 @@ int bt_write_scan_enable(int bt_cfd, unsigned int flags) { int result; - syslog(LOG_INFO, "Setting write_scan_enable [0x%x]\n", flags); + + syslog(LOG_INFO, "Setting write_scan_enable: 0x%x", flags); =20 #ifdef BT_USERSTACK result =3D hci_write_scan_enable(flags); @@ -682,7 +685,6 @@ unsigned int wind) { /* improves reliability when doing a connect */ - syslog(LOG_INFO, "Setting write_pagescan_activity in CSR module!"); =20 #ifdef BT_USERSTACK hci_write_pagescan_activity(interval, wind); @@ -706,7 +708,7 @@ { int result; =20 - syslog(LOG_INFO, "Setting event filter [0x%1x 0x%1x 0x%1x]\n",=20 + syslog(LOG_INFO, "Setting event filter [0x%x 0x%x 0x%x]",=20 filter[0], filter[1], filter[2]); =20 #ifdef BT_USERSTACK @@ -751,15 +753,15 @@ break; =20 case 1: - syslog(LOG_INFO, __FUNCTION__ ": Unsupported format 0x%02x\n", format); + syslog(LOG_INFO, __FUNCTION__ ": Unsupported format 0x%02x", format); break; =20 case 2: - syslog(LOG_INFO, __FUNCTION__ ": Unsupported format 0x%02x\n", format); + syslog(LOG_INFO, __FUNCTION__ ": Unsupported format 0x%02x", format); break; =20 default: - syslog(LOG_INFO, __FUNCTION__ ": Unsupported format 0x%02x\n", format); + syslog(LOG_INFO, __FUNCTION__ ": Unsupported format 0x%02x", format); break; } } @@ -770,7 +772,7 @@ int i; unsigned char tmp[7]; =20 - syslog(LOG_INFO, "Performing role switch to peer: %02X:%02X:%02X:%02X:%0= 2X:%02X\n", + syslog(LOG_INFO, "Performing role switch to peer: %02X:%02X:%02X:%02X:%0= 2X:%02X", bd_addr[0], bd_addr[1], bd_addr[2], bd_addr[3], bd_addr[4], bd_addr[5]); =20 @@ -798,10 +800,10 @@ if (ioctl(phys_fd, TIOCSETD, &bt_disc) < 0) { perror(__FUNCTION__); - syslog(LOG_INFO, "Forgot to insmod bt.o ? [bt_disc %d]\n", bt_disc); + syslog(LOG_INFO, "Forgot to insmod bt.o ? [bt_disc %d]", bt_disc); exit(1); } - syslog(LOG_INFO, "Registered bluetooth line discipline on %s\n", physdev= ); + syslog(LOG_INFO, "Registered bluetooth line discipline on %s", physdev); printf("Registered bluetooth line discipline on %s\n", physdev); #else fprintf(stderr, __FUNCTION__ ": ignored in usermode stack\n"); @@ -1024,7 +1026,7 @@ #endif #endif=20=20 =20 - syslog(LOG_INFO, "Opening dev %s\n", dev); + D(syslog(LOG_INFO, "Opening dev %s", dev)); if ((fd =3D open(dev, flags | O_NOCTTY)) < 0) { perror(__FUNCTION__); @@ -1037,7 +1039,7 @@ =20 void close_device(int fd) { - syslog(LOG_INFO, __FUNCTION__); + D(syslog(LOG_INFO, __FUNCTION__)); =20=20=20 #ifdef BT_USERSTACK /* if fake fd is used, ignore close since there are no open fd */ @@ -1054,7 +1056,7 @@ int sdpsrv_pid; char *args[] =3D { SDPSRV_CMD, SDPSRV_CONF, SDPSRV_PROC, NULL }; =20 - syslog(LOG_INFO, "Starting SDP server [%s]\n", SDPSRV_CMD);=20=20 + D(syslog(LOG_INFO, "Starting SDP server [%s]", SDPSRV_CMD)); =20 if (!(sdpsrv_pid =3D vfork())) { @@ -1068,12 +1070,9 @@ return sdpsrv_pid; } =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 */ /* Functions used in usermode stack only */ /* =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 /*=20 * --- bt_ipa.c 2001/05/15 12:13:04 1.4 +++ bt_ipa.c 2001/06/08 09:55:47 1.5 @@ -58,11 +58,13 @@ #include "bt_conf.h" #include "bt_misc.h" =20 +#define D(x) //x + int ipa_open(void) { int ipa_fd; =20=20=20 - syslog(LOG_INFO, "Opening socket to IP Assigner"); + D(syslog(LOG_INFO, "Opening socket to IP Assigner")); if ((ipa_fd =3D open_socket(IPASERVER, CLIENT)) < 0) {=20=20 perror("open_socket"); @@ -73,15 +75,15 @@ =20 void ipa_close(int ipa_fd) { - syslog(LOG_INFO, "Closing socket to IP Assigner");=20=20 + D(syslog(LOG_INFO, "Closing socket to IP Assigner")); close(ipa_fd); } =20 /* Sends msg to IPA socket */ int ipa_write(int ipa_fd, ipa_msg *msg) { - syslog(LOG_INFO, "ipa_send: sending ipa request (type: %d) len %d", - msg->type, msg->len); + D(syslog(LOG_INFO, __FUNCTION__ ": Sending ipa request (type: %d) len %d= ", + msg->type, msg->len)); =20=20=20 return write(ipa_fd, msg, msg->len + sizeof(struct ipa_msg)); } @@ -94,13 +96,13 @@ int offset =3D 0, all_read =3D 0, msg_len =3D -1, c; ipa_msg *tmp; =20 - syslog(LOG_INFO, "ipa_receive: reading response");=20=20 + D(syslog(LOG_INFO, __FUNCTION__ ": Reading response")); =20 while (!all_read) { c =3D read(ipa_fd, &ipa_buf+offset, 256-offset);=20=20 =20 - syslog(LOG_INFO, "ipa_receive: got %d bytes", c);=20=20 + D(syslog(LOG_INFO, __FUNCTION__ ": Got %d bytes", c)); =20 if (c < 0) return c; @@ -120,7 +122,7 @@ =20=20=20 memcpy(msg, ipa_buf, offset); =20 - syslog(LOG_INFO, "Got %d bytes", offset); + D(syslog(LOG_INFO, __FUNCTION__ ": Got %d bytes total", offset)); =20 return msg_len;=20=20 } --- bt_vendor.c 2001/06/06 15:02:54 1.16 +++ bt_vendor.c 2001/06/08 09:55:47 1.17 @@ -54,6 +54,8 @@ #include "bt_vendor.h" #include "bt_if.h" =20 +#define D(x) //x + static void csr_init_phys(int fd); static void csr_init_hw(int bt_cfd, int phys_fd, int spd); static void digianswer_init_phys(int fd); @@ -202,7 +204,7 @@ void csr_init_phys(int fd) { - syslog(LOG_INFO, "Setting default speed 115200"); + D(syslog(LOG_INFO, "Setting default speed 115200")); if (hw_vendor() =3D=3D HW_CSR_H4)=20 fd_setup(fd, 115200, USE_FLOW_CTRL, DONT_USE_BCSP); else @@ -231,7 +233,7 @@ { unsigned short msg[CSR_PSKEY_MAXPARAMS + CSR_PSKEY_MSGHDR_SIZE]; =20 - syslog(LOG_INFO ,": ps_key 0x%x rw_mode : %d\n", ps_key, rw_mode); + syslog(LOG_INFO, __FUNCTION__": ps_key 0x%x rw_mode : %d", ps_key, rw_mo= de); =20 msg[0] =3D ps_key; msg[1] =3D rw_mode; @@ -239,7 +241,7 @@ =20 if (n_pars > CSR_PSKEY_MAXPARAMS) { - syslog(LOG_INFO, "error : max nbr pskey params is %d [%d]\n",=20 + syslog(LOG_INFO, __FUNCTION__ ": Error: Max nbr pskey params is %d [%d= ]", CSR_PSKEY_MAXPARAMS, n_pars); return; } @@ -277,7 +279,7 @@ =20=20=20 if (hw_vendor() =3D=3D HW_CSR_H4) { - syslog(LOG_INFO, "Changing CSR host IF BCSP -> H4"); + syslog(LOG_INFO, "Changing CSR host IF: BCSP -> H4"); =20=20=20=20=20 /* Temporarily set stack to use BCSP framing */ csr_bcspmode(bt_cfd, 1); @@ -336,7 +338,7 @@ } else { - syslog(LOG_ERR, __FUNCTION__": PS key parameter unknown [%d]", ps_pa= rbuf[1]); + syslog(LOG_ERR, __FUNCTION__ ": Unknown PS key parameter: %d", ps_pa= rbuf[1]); }=20=20=20 =20=20=20=20=20 /* Set back stack to use H4 framing */ @@ -344,7 +346,7 @@ } else { - syslog(LOG_INFO, "Changing CSR host IF BCSP -> H4"); + syslog(LOG_INFO, "Changing CSR host IF: BCSP -> H4"); =20 /* Set stack to use H4 temporarily */=20=20=20=20=20=20=20=20 csr_bcspmode(bt_cfd, 0); @@ -382,7 +384,7 @@ }=20 else { - syslog(LOG_ERR, __FUNCTION__": PS key parameter unknown [%d]", ps_pa= rbuf[1]); + syslog(LOG_ERR, __FUNCTION__ ": Unknown PS key parameter: %d", ps_pa= rbuf[1]); } } =20 @@ -433,18 +435,18 @@ } } =20=20=20 - syslog(LOG_INFO, "Setting write_scan_enable in CSR module!\n"); + D(syslog(LOG_INFO, "Setting write_scan_enable in CSR module!")); =20 bt_write_scan_enable(bt_cfd, wrscan); =20=20=20 /* improves reliability when doing a connect */ - syslog(LOG_INFO, "Setting write_pagescan_activity in CSR module!\n"); + D(syslog(LOG_INFO, "Setting write_pagescan_activity in CSR module!")); =20 bt_write_pagescan_activity(bt_cfd, 0x0800, 0x12); =20 bt_set_event_filter(bt_cfd, filter); =20 - syslog(LOG_INFO, "Setting baudrate in CSR module!\n");=20=20 + D(syslog(LOG_INFO, "Setting baudrate in CSR module!")); =20 sleep(1); =20=20=20 @@ -458,7 +460,7 @@ =20 tcflush(phys_fd, TCIOFLUSH); =20 - syslog(LOG_INFO, "Baudrate set\n"); + D(syslog(LOG_INFO, "Baudrate set")); } =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*/ @@ -478,7 +480,7 @@ /* Connection setup, all devices, no auto accept */ unsigned char filter[3] =3D { 0x02, 0x00, 0x01 }; =20 - syslog(LOG_INFO, "Setting baudrate in Digianswer PC card\n"); + D(syslog(LOG_INFO, "Setting baudrate in Digianswer PC card")); =20 bt_set_baudrate(bt_cfd, spd); =20=20=20 @@ -521,7 +523,7 @@ =20 sleep(1); // wait for HW... =20 - syslog(LOG_INFO, "Setting baudrate in Ericsson module!\n");=20=20 + D(syslog(LOG_INFO, "Setting baudrate in Ericsson module!")); bt_set_baudrate(bt_cfd, spd); usleep(10000); =20 @@ -545,11 +547,11 @@ unsigned int wrscan =3D (PAGE_SCAN_ENABLE | INQUIRY_SCAN_ENABLE); =20=20=20 sleep(1); - syslog(LOG_INFO, "Setting write_scan_enable in Infineon module!\n"); + D(syslog(LOG_INFO, "Setting write_scan_enable in Infineon module!")); bt_write_scan_enable(bt_cfd, wrscan); =20 sleep(1); // wait for HW...=20 - syslog(LOG_INFO, "Setting baudrate in Infineon module!\n");=20=20 + D(syslog(LOG_INFO, "Setting baudrate in Infineon module!")); bt_set_baudrate(bt_cfd, spd); =20=20=20 /* Now set phys device speed to whatever HW was set to use */ @@ -574,12 +576,12 @@ unsigned char filter[3] =3D { 0x02, 0x00, 0x01 }; unsigned int wrscan =3D (PAGE_SCAN_ENABLE | INQUIRY_SCAN_ENABLE); =20 - syslog(LOG_INFO, "Setting write_scan_enable in USB module!\n"); + D(syslog(LOG_INFO, "Setting write_scan_enable in USB module!")); =20 bt_write_scan_enable(bt_cfd, wrscan); =20=20=20 /* improves reliability when doing a connect */ - syslog(LOG_INFO, "Setting write_pagescan_activity in USB module!\n"); + D(syslog(LOG_INFO, "Setting write_pagescan_activity in USB module!")); =20 bt_write_pagescan_activity(bt_cfd, 0x0800, 0x12); =20 @@ -605,7 +607,7 @@ unsigned char filter[3] =3D { 0x02, 0x00, 0x01 }; unsigned int wrscan =3D (PAGE_SCAN_ENABLE | INQUIRY_SCAN_ENABLE); =20 - syslog(LOG_INFO, "Setting write_scan_enable in generic module!\n"); + D(syslog(LOG_INFO, "Setting write_scan_enable in generic module!")); =20=20=20 bt_write_scan_enable(bt_cfd, wrscan); bt_set_event_filter(bt_cfd, filter); --- btd.c 2001/06/06 15:05:40 1.18 +++ btd.c 2001/06/08 09:55:47 1.19 @@ -50,10 +50,6 @@ =20=09=20=20=20=20=20 options:=20 =20 - -i, --hwinit=20 -=09 - default: ttyS0 -=20=20 -u, --physdev <uart device> Sets which uart device that will be used by the stack default: ttyS0 @@ -63,7 +59,7 @@ Can also be done from command line mode.=20 default: on =20=20=20 - -n, --local-name + -n, --local-name <prefix> prefix used for the local bluetooth device name default: nothing =20=20=20 @@ -71,6 +67,10 @@ reset bluetooth hardware before use default: no reset =20=20=20 + -i, --initial-speed <speed> + sets initial uart speed + default: 115200 baud + -s, --speed <speed> sets uart speed 9600, 19200, 38400, 57600, 115200, 230400, 460800 @@ -85,6 +85,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <errno.h> #include <fcntl.h> #include <signal.h> #include <syslog.h> @@ -184,11 +185,12 @@ /* long option list */ static struct option long_options[] =3D { + {"initial-speed", 1, NULL, 'i'}, /* initial uart speed */ {"physdev", 1, NULL, 'u'}, /* phys device used from stac= k */ - {"speed", 1, NULL, 's'}, /* uart speed towards hw */ + {"modem-emul", 1, NULL, 'm'}, {"local-name", 1, NULL, 'n'}, /* set local bluetooth name = */ {"reset", 1, NULL, 'R'}, /* reset BT HW */ - {"modem-emul", 1, NULL, 'm'}, + {"speed", 1, NULL, 's'}, /* uart speed towards hw */ {0, 0, 0, 0} }; =20 @@ -212,7 +214,7 @@ int result, opt; int bt_disc =3D N_BT; =20=20=20 - syslog(LOG_INFO, "Bluetooth daemon starting\n"); + syslog(LOG_INFO, "Bluetooth daemon starting"); =20=20=20 if (atexit(btd_cleanup) < 0) { @@ -229,7 +231,7 @@ case 'i': /* uart device */ init_hw_speed =3D atoi(optarg); - syslog(LOG_INFO, "init_hw_speed %d baud\n", init_hw_speed); + D(syslog(LOG_INFO, "init_hw_speed %d baud", init_hw_speed)); break; =20 case 'm': @@ -238,28 +240,29 @@ break; =20=20=20=20=20=20=20 case 'n': - syslog(LOG_INFO, "setting local name to %s\n", optarg); + D(syslog(LOG_INFO, "setting local name to %s", optarg)); strncpy(local_name, optarg, LOCAL_NAME_LENGTH); local_name[LOCAL_NAME_LENGTH] =3D '\0'; break; =20=20=20=20=20=20=20 case 'R': /* try to reset the hardware */ - syslog(LOG_INFO, "reset HW\n"); + D(syslog(LOG_INFO, "reset HW")); do_reset =3D 1; break; =20=20=20=20=20=20=20 case 's': /* speed */ - syslog(LOG_INFO, "phys dev running at %s\n", optarg); + D(syslog(LOG_INFO, "phys dev running at %s", optarg)); speedstr =3D optarg; break; =20=20=20=20=20=20=20 case 'u': /* uart device */ - syslog(LOG_INFO, "phys dev : %s\n", optarg); + D(syslog(LOG_INFO, "phys dev: %s", optarg)); physdev =3D optarg; break; + default: break; } @@ -268,7 +271,7 @@ /* Set restart point */ if (sigsetjmp(jmpbuffer, 1) !=3D 0) { - syslog(LOG_INFO, "restart...\n\n\n\n"); + syslog(LOG_INFO, "Restart..."); sleep(1); }=20=20=20=20 =20=20=20 @@ -276,14 +279,13 @@ =20 if ((phys_fd =3D open(physdev, O_RDWR | O_NOCTTY)) < 0) { - perror("could not open phys dev\n"); + perror("Could not open phys dev"); exit(1); } =20 /* Sets initial HW baudrate */ if (init_hw_speed !=3D 0) - fd_setup(phys_fd, init_hw_speed,=20 - USE_FLOW_CTRL, hw_vendor() =3D=3D HW_CSR_BCSP); + fd_setup(phys_fd, init_hw_speed, USE_FLOW_CTRL, hw_vendor() =3D=3D HW_= CSR_BCSP); else init_phys(phys_fd); =20=20 @@ -332,7 +334,7 @@ if ((STATE(i) =3D=3D WAITING_PPPCONF) || (STATE(i) =3D=3D WAITING_RETURN_PPPCONF)) { - D(syslog(LOG_INFO, "Waiting for IPA response\n")); + D(syslog(LOG_INFO, "Waiting for IPA response")); waiting_iparsp =3D 1; } i++; @@ -390,13 +392,13 @@ { int line; =20 - D(syslog(LOG_INFO, "discover_connections")); + D(syslog(LOG_INFO, __FUNCTION__)); for (line =3D 0; line < BT_NBR_DATAPORTS; line++) { if ((STATE(line) =3D=3D NOCONNECTION) &&=20 bt_isconnected(bt_cfd, line)) { - syslog(LOG_INFO, "Found connection on line : %d !\n", line); + syslog(LOG_INFO, "Found connection on line: %d", line); STATE(line) =3D CONNECTED; =20=20=20=20=20=20=20 read_remote_bd(bt_cfd, PEER(line).remote_bd); @@ -404,7 +406,7 @@ =20=20=20=20=20=20=20 if (ipa_available) {=20=20 - D(syslog(LOG_INFO, "Sending IPA request\n")); + D(syslog(LOG_INFO, "Sending IPA request")); =20=20=20=20=20=20=20=20=20 PEER(line).ipset =3D &IPSET(line); =20=20=20=20=20=20=20=20=20 @@ -442,7 +444,7 @@ if (ipa_available) show_ipset(ipset, line); =20=20=20 - D(syslog(LOG_INFO, "build_pppdopts\n")); + D(syslog(LOG_INFO, __FUNCTION__)); =20=20=20 sprintf(dev, "/dev/ttyBT%d",line); =20 @@ -579,7 +581,7 @@ options.ttyBT1 which contains the remote IP address,=20 dns, wins etc*/ =20=20=20=20=20 - syslog(LOG_INFO, "WARNING No remote ip addr set, only local %s",=20 + syslog(LOG_INFO, "WARNING: No remote ip addr set, only local %s",=20 ip_addresses); =20 opts[i++] =3D ip_addresses; @@ -613,7 +615,7 @@ /* check state */ if (STATE(line) !=3D PPPCONF_DONE) { - syslog(LOG_INFO, "Warning : ppp config not done (%d)\n", STATE(line)); + syslog(LOG_INFO, "Warning: PPP config not done (%d)", STATE(line)); return -1; } =20=20=20 @@ -624,8 +626,6 @@ /* run modem emulator in a child */ if (!(PEER(line).pppd_pid =3D vfork())) { - syslog(LOG_INFO, "Starting modem emulator on %s", dev);=20 -=20=20=20=20=20=20 /* replace first arg with MODEMEMULCMD (is handled by=20 modem emulator) */ =20=20=20=20=20=20=20 @@ -648,8 +648,6 @@ STATE(line) =3D PPPD_STARTED; if (!(PEER(line).pppd_pid =3D vfork())) { - syslog(LOG_INFO, "Starting pppd on %s", dev); -=20=20=20=20=20=20 /* FIXME -- use opts inparam and not static opts */ execvp(PPPDCMD, opts); =20=20=20=20=20=20=20 @@ -674,20 +672,20 @@ { struct sigaction act; =20=20=20 - syslog(LOG_INFO, "Initiating signal handler\n"); + D(syslog(LOG_INFO, "Initiating signal handler")); act.sa_handler =3D sighandler; sigemptyset(&act.sa_mask); act.sa_flags =3D 0; sigaction(SIGCHLD, &act, 0); /* Catches when pppd childs are done */ sigaction(SIGUSR1, &act, 0); /* Restart application */ sigaction(SIGUSR2, &act, 0); /* HW Upgrade ? */ - sigaction(SIGTERM, &act, 0); /* Received when kill cmd is used */ + sigaction(SIGTERM, &act, 0); /* Terminate application */ } =20 static void sighandler(int sig) { - syslog(LOG_INFO, "Sighandler got signal : %d\n", sig); + D(syslog(LOG_INFO, "Sighandler got signal: %d", sig)); =20=20=20 if (sig =3D=3D SIGUSR1) { @@ -703,30 +701,31 @@ /* FIXME -- execvp(hw_upgrade_prog) */ // siglongjmp(jmpbuffer, 1); } - else if (sig =3D=3D SIGTERM) /* ? */ + else if (sig =3D=3D SIGTERM) {=20 - syslog(LOG_INFO, "Got SIGTERM, now exiting"); + D(syslog(LOG_INFO, "Got SIGTERM, now exiting")); exit(0); } else if (sig =3D=3D SIGCHLD)=20=20 { int line =3D 0, pid, status; - syslog(LOG_INFO, "One of the childs terminated\n"); + + D(syslog(LOG_INFO, "One of the childs terminated")); /* Find pid for this child */ =20=20=20=20=20 if ((pid =3D waitpid(-1, &status, WNOHANG)) <=3D 0) return; =20=20=20=20=20 - syslog(LOG_INFO, "pid %d terminated with status %d\n", pid, status); + D(syslog(LOG_INFO, "pid %d terminated with status %d", pid, status)); =20=20=20=20=20 /* find corresponding line */ while (line < BT_NBR_DATAPORTS) {=20=20=20=20=20 - syslog(LOG_INFO, "line %d pid : %d\n", line, PEER(line).pppd_pid); + D(syslog(LOG_INFO, "line %d pid: %d", line, PEER(line).pppd_pid)); =20=20=20=20=20=20=20 if (PEER(line).pppd_pid =3D=3D pid) { - syslog(LOG_INFO, "line %d found\n", line); + D(syslog(LOG_INFO, "line %d found", line)); break; } line++; @@ -734,11 +733,11 @@ =20=20=20=20=20 if (line =3D=3D BT_NBR_DATAPORTS) { - syslog(LOG_INFO, "Not a pppd pid\n"); + D(syslog(LOG_INFO, "Not a pppd pid")); return; } =20=20=20=20=20 - syslog(LOG_INFO, "PPP line %d was shutdown\n", line); + D(syslog(LOG_INFO, "PPP line %d was shutdown", line)); =20=20=20=20=20 if (ipa_available)=20 {=20 @@ -800,7 +799,7 @@ ipa_fd =3D open_socket(IPASERVER, CLIENT); if (ipa_fd < 0) { - syslog(LOG_INFO, "Found no IPA server"); + D(syslog(LOG_INFO, "Found no IPA server")); =20 if (i > 8) {=20=20 @@ -808,35 +807,34 @@ } else { - syslog(LOG_INFO, "Retrying in %d sec", i); + D(syslog(LOG_INFO, "Retrying in %d sec", i)); sleep(i); i *=3D 2; }=20=20=20=20=20=20 } else=20 {=20=20=20=20=20=20 - syslog(LOG_INFO, "Found IPA server"); + D(syslog(LOG_INFO, "Found IPA server")); ipa_available =3D 1; } }=20 #endif =20 if (modem_emul =3D=3D 1) - syslog(LOG_INFO, "Using modem emulation"); + D(syslog(LOG_INFO, "Using modem emulation")); else - syslog(LOG_INFO, "Using NO modem emulation"); + D(syslog(LOG_INFO, "Using NO modem emulation")); } =20 static void btd_cleanup(void) { - syslog(LOG_INFO, "btd_cleanup\n"); + D(syslog(LOG_INFO, __FUNCTION__)); btd_killchilds(); =20=20=20 - printf("shutdown_stack\n"); + printf("Shutting down Bluetooth stack\n"); shutdown_stack(bt_cfd); -=20=20 - printf("shutdown_stack done\n"); + printf("Bluetooth stack shut down\n"); =20=20=20 if (bt_cfd !=3D -1) { @@ -854,7 +852,7 @@ =20 if (ipa_fd !=3D -1) { - syslog(LOG_INFO, "closing IPA"); + D(syslog(LOG_INFO, "Closing connection to IPA")); tcflush(ipa_fd, TCIOFLUSH); close(ipa_fd); ipa_fd =3D -1; @@ -871,10 +869,10 @@ btd_killchilds(void) { int line; - printf("btd_killchilds\n"); + if (sdpsrv_pid > 0) { - syslog(LOG_INFO, "Killing SDP server\n"); + D(syslog(LOG_INFO, "Killing SDP server")); kill(sdpsrv_pid, SIGTERM); =20=20=20=20=20 if (waitpid(sdpsrv_pid, NULL, 0) < 0) @@ -888,7 +886,7 @@ { if (STATE(line) =3D=3D PPPD_STARTED) { - syslog(LOG_INFO, "Killing pppd on line %d\n", line); + D(syslog(LOG_INFO, "Killing pppd on line %d", line)); kill(PEER(line).pppd_pid, SIGTERM); if (waitpid(PEER(line).pppd_pid, NULL, 0) < 0) perror("waitpid pppd"); @@ -906,7 +904,7 @@ struct ipa_msg *msg; struct ipa_request *req; =20=20=20 - D(syslog(LOG_INFO, "ipa_request : type %d\n", type)); + D(syslog(LOG_INFO, __FUNCTION__ ": Type %d", type)); =20 msg =3D (struct ipa_msg*)buf; msg->type =3D type; @@ -924,25 +922,25 @@ case IPARSP_STATUS: { ipa_status *rsp =3D (struct ipa_status*)(msg->msg); - D(syslog(LOG_INFO, "parse_ipa_response : got status %d on line %d\n"= ,=20 + D(syslog(LOG_INFO, __FUNCTION__ ": Got status %d on line %d",=20 rsp->status, rsp->id)); =20 /* Check state */ if (STATE(rsp->id) !=3D WAITING_RETURN_PPPCONF) { - syslog(LOG_INFO, "parse_ipa_response : wrong state"); + syslog(LOG_INFO, __FUNCTION__ ": Wrong state"); return -ERR_WRONGSTATE; } =20 /* Check status */ if (rsp->status =3D=3D IPA_STATUSFAILED) { - syslog(LOG_INFO, "parse_ipa_response : request failed [line:%d]\n"= ,=20 - rsp->id); + syslog(LOG_INFO, __FUNCTION__ ": Request failed [line:%d]", rsp->i= d); return -IPA_STATUSFAILED; }=20=20=20=20=20=20 else - D(syslog(LOG_INFO, "parse_ipa_response : request succeeded [line:%d]\n", = rsp->id)); + D(syslog(LOG_INFO, __FUNCTION__ ": Request succeeded [line:%d]", + rsp->id)); =20 /* put peer into NOCONNECTION, if still connected this will=20 be discovered from timeout */ @@ -955,12 +953,12 @@ case IPARSP_PEERSETTINGS: { ipa_response* rsp =3D (struct ipa_response*)(msg->msg); - D(syslog(LOG_INFO, "parse_ipa_response : got client settings\n")); + D(syslog(LOG_INFO, __FUNCTION__ ": Got client settings")); =20=20=20=20=20=20=20 /* Check state */ if (STATE(rsp->id) !=3D WAITING_PPPCONF) { - syslog(LOG_INFO, "parse_ipa_response : wrong state"); + syslog(LOG_INFO, __FUNCTION__ ": Wrong state"); return -ERR_WRONGSTATE; } =20 @@ -968,7 +966,7 @@ if (rsp->status =3D=3D IPA_STATUSFAILED) { /* error */ - printf("parse_ipa_response : failed to get client settings\n"); + syslog(LOG_INFO, __FUNCTION__ ": Failed to get client settings\n"); return -ERR_REQUESTFAILED; } =20 @@ -984,7 +982,7 @@ } =20=20=20=20=20 default : - syslog(LOG_INFO, "Error : Unknown message type"); + syslog(LOG_INFO, __FUNCTION__ ": Unknown message type"); break; } return 0; --- modememul.c 2001/06/06 15:06:00 1.8 +++ modememul.c 2001/06/08 09:55:47 1.9 @@ -83,10 +83,10 @@ void sighandler(int sig) { - syslog(LOG_INFO, "got signal %d", sig); + D(syslog(LOG_INFO, "Got signal %d", sig)); if ((sig =3D=3D SIGQUIT) || (sig =3D=3D SIGTERM || (sig =3D=3D SIGHUP))) { - syslog(LOG_INFO, "Modem emulator exiting\n"); + D(syslog(LOG_INFO, "Modem emulator exiting")); exit(0); } } @@ -96,13 +96,13 @@ { struct sigaction act; =20 - syslog(LOG_INFO, "Initiating signal handler\n"); + D(syslog(LOG_INFO, "Initiating signal handler")); act.sa_handler =3D sighandler; sigemptyset(&act.sa_mask); act.sa_flags =3D 0; sigaction(SIGHUP, &act, 0); sigaction(SIGQUIT, &act, 0); - sigaction(SIGTERM, &act, 0); /* Received when kill cmd is used */ + sigaction(SIGTERM, &act, 0); } =20 int @@ -119,7 +119,7 @@ =20 while (done !=3D START_PPP) { - syslog(LOG_INFO, "Starting modem emulator on %s\n", argv[1]); + syslog(LOG_INFO, "Starting modem emulator on %s", argv[1]); =20 if ((btfd =3D open(argv[1], O_RDWR, 0)) < 0) { @@ -131,7 +131,7 @@ fd_setup(btfd, speed, USE_NO_FLOW, DONT_USE_BCSP); done =3D modem_emulator(btfd); close(btfd); - syslog(LOG_INFO, "Closing %s", argv[1], speed);=20=20 + D(syslog(LOG_INFO, "Closing %s", argv[1])); } =20 /* replace first arg with pppd instead of modem emulator=20 @@ -154,7 +154,7 @@ int done =3D 0, i; fd_set rfd; =20 - syslog(LOG_INFO, "Modem emulator starting\n"); + D(syslog(LOG_INFO, "Modem emulator starting")); =20 while (!done) {=20=20 @@ -167,7 +167,7 @@ int len =3D read(bt_fd, &data, 128);=20=20=20=20=20=20 data[len] =3D 0; =20=20=20=20=20=20=20 - syslog(LOG_INFO, "Modem emulator got %d bytes\n", len); + D(syslog(LOG_INFO, "Modem emulator got %d bytes", len)); =20=20=20=20=20=20=20 if (len <=3D 0) return RESTART;=20=20=20=20=20=20 @@ -186,7 +186,7 @@ /* check for escaped chars */=20=20=20=20=20=20=20=20=20=20=20= =20 if (data[i+2] =3D=3D PPP_CONTROL_ESCAPE)=20 {=20 - D(syslog(LOG_INFO, "Found ctrl esc\n")); + D(syslog(LOG_INFO, "Found ctrl esc")); prot =3D ((data[i+4]<<8) | (data[i+5])); } else @@ -231,16 +231,16 @@ =20 if(!strncasecmp(data, "ATD", 3)) /* windows standard modem */ { - syslog(LOG_INFO, "got ATD");=09 + D(syslog(LOG_INFO, "Got ATD")); =20 - syslog(LOG_INFO, "Write : %s", connect); + D(syslog(LOG_INFO, "Write: %s", connect)); write(bt_fd, connect, strlen(connect));=20=20=20 syslog(LOG_INFO, "Modem connected !"); return START_PPP; } else if(!strncasecmp(data, "CLIENT", 6)) /* windows null modem */ { - syslog(LOG_INFO, "got CLIENT"); + D(syslog(LOG_INFO, "Got CLIENT")); write(bt_fd, client_server, strlen(client_server));=20=20=20 syslog(LOG_INFO, "Nullmodem connected !"); return START_PPP; |
From: Anders J. <and...@us...> - 2001-10-10 14:56:01
|
The following files were modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_errno.h 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20 bt_if.c 1.36 1.37=20=20=20=20=20=20=20=20=20=20=20=20 bt_if.h 1.26 1.27=20=20=20=20=20=20=20=20=20=20=20=20 bttest.c 1.21 1.22=20=20=20=20=20=20=20=20=20=20=20=20 bttest.h 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * Changed to use the new errorcodes from stack.=20 * Changed so that we doesn't return just a -1 on error. The diff of the modified file(s): --- bt_errno.h 2001/04/17 14:18:26 1.1 +++ bt_errno.h 2001/10/10 14:56:00 1.2 @@ -45,19 +45,21 @@ =20 /* Unique status codes 32 bits : | layer 16 bits | code 16 bits | */ #define MSGCODE(layer, msgcode) ((((layer)<<16)&0xffff0000) | ((msgcode)&0= xffff)) +#define MSG_GET_LAYER(msg) ((msg >> 16) & 0x0000ffff) +#define MSG_GET_CODE(msg) (msg & 0x0000ffff) =20 /* Layer ID */ -#define MSG_LAYER_HCI 0 -#define MSG_LAYER_L2CAP 1 -#define MSG_LAYER_RFCOMM 2 +#define MSG_LAYER_HCI 1 +#define MSG_LAYER_L2CAP 2 +#define MSG_LAYER_RFCOMM 3 #define MSG_LAYER_SDP 4 -#define MSG_LAYER_TCS 8 -#define MSG_BT_INTERFACE 16 +#define MSG_LAYER_TCS 5 +#define MSG_BT_INTERFACE 6 =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=3D=3D=3D*/ /* HCI */ =20 -/* fixme */ +/* Uses errorcodes as specified in the BT specification */ =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=3D=3D=3D*/ /* L2CAP */ @@ -73,6 +75,10 @@ /* General l2cap return codes */ #define L2CAP_FAILED 0xf0 #define L2CAP_CON_UNRESPONSIVE 0xf1 +#define L2CAP_INVALID_STATE 0xf2 +#define L2CAP_NO_CONNECTION 0xf3 +#define L2CAP_EXCEED_REMOTE_MTU 0xf4 +#define L2CAP_RTX_TIMEOUT 0xf5 =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=3D=3D=3D*/ /* RFCOMM */ @@ -95,3 +101,4 @@ #define BT_NOTCONNECTED 0x1 #define BT_ALREADYCONNECTED 0x2 #define BT_TIMEOUT 0x3 +#define BT_LINE_BUSY 0x4 --- bt_if.c 2001/10/04 13:22:15 1.36 +++ bt_if.c 2001/10/10 14:56:00 1.37 @@ -287,7 +287,7 @@ =20 #ifndef BT_USERSTACK if ((result =3D ioctl(bt_fd, BTCONNECT, &con))) - printf("Connect failed [%s (%d)]\n", error_msg(result), result); + printf("Connect failed [%s (%d)]\n", error_msg(result), MSG_GET_CODE(-= result)); else printf("Connected.\n");=20 #else @@ -312,7 +312,7 @@ =20=20=20 #ifndef BT_USERSTACK=20=20 if ((ret_val =3D ioctl(bt_fd, BTDISCONNECT, &con_id))) - printf("Disconnect failed, %s [%d]\n", error_msg(ret_val), ret_val); + printf("Disconnect failed [%s (%d)]\n", error_msg(ret_val), MSG_GET_CO= DE(-ret_val)); else printf("Disconnected.\n"); #else @@ -561,7 +561,7 @@ #ifndef BT_USERSTACK=20 if ((ret_val =3D ioctl(bt_cfd, BTPING, &ping)) < 0) { - printf("Error : %s\n", error_msg(ret_val)); + printf("Error : [%s (%d)]\n", error_msg(ret_val), MSG_GET_CODE(-ret_va= l)); } else printf("Success!\n"); @@ -584,7 +584,7 @@ #ifndef BT_USERSTACK=20 if ((ret_val =3D ioctl(bt_cfd, BTGETINFO, &msg)) < 0) { - printf("Error : %s\n", error_msg(ret_val)); + printf("Error : [%s (%d)]\n", error_msg(ret_val), MSG_GET_CODE(-ret_va= l)); } else printf("Success!\n"); @@ -608,8 +608,10 @@ #ifndef BT_USERSTACK=20 if ((ret_val =3D ioctl(bt_cfd, BTTESTCOMMAND, tmp)) < 0) { - printf("Error : %s\n", error_msg(ret_val)); + printf("Error : [%s (%d)]\n", error_msg(ret_val), MSG_GET_CODE(-ret_va= l)); } + else + printf("Success!\n"); #else test_process_cmd(&tmp[1], tmp[0]); #endif @@ -1056,99 +1058,101 @@ /* See bt_errno.h for error codes */ const char *error_msg(int err) { - int layer =3D (err >> 16) & 0xffff; - int code =3D err & 0xffff; + int layer, code, msg; + msg =3D -err; + layer =3D MSG_GET_LAYER(msg); + code =3D MSG_GET_CODE(msg); =20 switch (layer) { case MSG_LAYER_HCI: - { - - /* fixme -- add these as defines in bt_errno.h */ switch(code) {=20=20=20=20=20=20=20 - case 0x03:=20=20=20=20=20=20=20=20 - return "HCI - Hardware Failure"; - case 0x04:=20=20=20=20=20=20=20=20 - return "HCI - Page Timeout"; - case 0x05:=20=20=20=20=20=20=20=20 - return "HCI - Authentications Failure"; - case 0x06:=20=20=20=20=20=20=20=20 - return "HCI - Key missing"; - case 0x09:=20=20=20=20=20=20=20=20 - return "HCI - Max number of connections"; - case 0x0b:=20=20=20=20=20=20=20=20 - return "HCI - ACL connection already exists"; - case 0x0c:=20=20=20=20=20=20=20=20 - return "HCI - Command disallowed"; - case 0x10:=20=20=20=20=20=20=20=20 - return "HCI - Host Timeout"; - - default : - return "HCI - Unknown reason"; - break; - } + case 0x00: return "HCI: Success!"; + case 0x01: return "HCI: Unknown HCI Command"; + case 0x02: return "HCI: No Connection"; + case 0x03: return "HCI: Hardware Failure"; + case 0x04: return "HCI: Page Timeout"; + case 0x05: return "HCI: Authentication Failure"; + case 0x06: return "HCI: Key Missing"; + case 0x07: return "HCI: Memory Full"; + case 0x08: return "HCI: Connection Timeout"; + case 0x09: return "HCI: Max Number Of Connections"; + case 0x0A: return "HCI: Max Number Of SCO Connections To A Device"; + case 0x0B: return "HCI: ACL connection already exists"; + case 0x0C: return "HCI: Command Disallowed"; + case 0x0D: return "HCI: Host Rejected due to limited resources"; + case 0x0E: return "HCI: Host Rejected due to security reasons"; + case 0x0F: return "HCI: Host Rejected due to remote device is only a = personal device"; + case 0x10: return "HCI: Host Timeout"; + case 0x11: return "HCI: Unsupported Feature or Parameter Value"; + case 0x12: return "HCI: Invalid HCI Command Parameters"; + case 0x13: return "HCI: Other End Terminated Connection: User Ended C= onnection"; + case 0x14: return "HCI: Other End Terminated Connection: Low Resource= s"; + case 0x15: return "HCI: Other End Terminated Connection: About to Pow= er Off"; + case 0x16: return "HCI: Connection Terminated by Local Host"; + case 0x17: return "HCI: Repeated Attempts"; + case 0x18: return "HCI: Pairing Not Allowed"; + case 0x19: return "HCI: Unknown LMP PDU"; + case 0x1A: return "HCI: Unsupported Remote Feature"; + case 0x1B: return "HCI: SCO Offset Rejected"; + case 0x1C: return "HCI: SCO Interval Rejected"; + case 0x1D: return "HCI: SCO Air Mode Rejected"; + case 0x1E: return "HCI: Invalid LMP Parameters"; + case 0x1F: return "HCI: Unspecified Error"; + case 0x20: return "HCI: Unsupported LMP Parameter Value"; + case 0x21: return "HCI: Role Change Not Allowed"; + case 0x22: return "HCI: LMP Response Timeout"; + case 0x23: return "HCI: LMP Error Transaction Collision"; + case 0x24: return "HCI: LMP PDU Not Allowed"; + case 0x25: return "HCI: Encryption Mode Not Acceptable"; + case 0x26: return "HCI: Unit Key Used"; + case 0x27: return "HCI: QOS is Not Supported"; + case 0x28: return "HCI: Instant Passed"; + case 0x29: return "HCI: Pairing with Unit Key Not Supported"; + default: return "HCI: No debug msg defined"; } - break; - case MSG_LAYER_L2CAP: - { switch(code) {=20 - case L2CAP_PSMNEG: - return "L2CAP - PSM not valid"; - case L2CAP_SECNEG: - return "L2CAP - Security block"; - case L2CAP_NOSRC: - return "L2CAP - Remote side has no resources";=09 - case L2CAP_CON_UNRESPONSIVE: - return "L2CAP - Unresponsive link"; - - default: - return "L2CAP - unknown reason"; - } + case L2CAP_SUCCESS: return "L2CAP: Success"; + case L2CAP_CON_PENDING: return "L2CAP: Connection Pending"; + case L2CAP_PSMNEG: return "L2CAP: Connection Refused, PSM Not Accepte= d"; + case L2CAP_SECNEG: return "L2CAP: Connection Refused, Authentication = Failed"; + case L2CAP_NOSRC: return "L2CAP: Connection Refused, No Resources"; + case L2CAP_FAILED: return "L2CAP: General Error"; + case L2CAP_CON_UNRESPONSIVE: return "L2CAP: No Reply From Remote"; + case L2CAP_INVALID_STATE: return "L2CAP: Invalid State"; + case L2CAP_NO_CONNECTION: return "L2CAP: No Connection"; + case L2CAP_EXCEED_REMOTE_MTU: return "L2CAP: Trying to send a frame m= ore than remote MTU"; + case L2CAP_RTX_TIMEOUT: return "L2CAP: Timeout Waiting For Remote To = Reply"; + default: return "L2CAP: No debug msg defined"; } - break; -=20=20=20=20 case MSG_LAYER_RFCOMM: + switch(code) { - /* fixme */ - return "RFCOMM - unknown reason"; + default: return "RFCOMM: No debug msg defined"; } - break; - case MSG_LAYER_SDP: + switch(code) { - /* fixme */ - return "SDP - unknown reason"; + default: return "SDP: No debug msg defined"; } - break; -=20=20=20=20 case MSG_LAYER_TCS: + switch(code) { - /* fixme */ - return "TCS - unknown reason"; + default: return "TCS: No debug msg defined"; } - break; -=20=20=20=20 case MSG_BT_INTERFACE: - { switch(code) {=20 - case BT_NOTCONNECTED: - return "BT_INTERFACE - Not connected"; - case BT_ALREADYCONNECTED: - return "BT_INTERFACE - Already connected"; - case BT_TIMEOUT: - return "BT_INTERFACE - Timeout"; - default: - return "BT_INTERFACE - unknown reason"; - } + case BT_NOTCONNECTED: return "BT_INTERFACE: Line Not Connected"; + case BT_ALREADYCONNECTED: return "BT_INTERFACE: Line Already Connecte= d"; + case BT_TIMEOUT: return "BT_INTERFACE: Timeout When Processing Comman= d"; + case BT_LINE_BUSY: return "BT_INTERFACE: Line Busy"; + default: return "BT_INTERFACE: No debug msg defined"; } - break; - - default: - return "General failure"; + default: return "General Failure"; } } =20 @@ -1428,7 +1432,7 @@ =20 if (status) { /* fixme -- only works for rfcomm now */ - line =3D GET_RFCOMMLINE(con_id); + line =3D GET_LINE(con_id); =20 if ((line < 0) || (line > BT_NBR_DATAPORTS)) { =20 --- bt_if.h 2001/10/05 11:57:42 1.26 +++ bt_if.h 2001/10/10 14:56:00 1.27 @@ -93,27 +93,6 @@ =20 #define SDPSRV_CONF "/etc/sdp.xml" =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 */ -/* Return code defines (see bt_errno.h in kernel)*/ - -/* unique message status codes 32 bits : | layer 16 bits | code 16 bits | = */ - -#define MSG_LAYER_HCI 0 -#define MSG_LAYER_L2CAP 1 -#define MSG_LAYER_RFCOMM 2 -#define MSG_LAYER_SDP 4 -#define MSG_LAYER_TCS 8 - -#define L2CAP_SUCCESS 0x0 -#define L2CAP_CON_PENDING 0x1 - -/* Result in responses in L2CAP */ -#define L2CAP_PSMNEG 0x02 -#define L2CAP_SECNEG 0x03 -#define L2CAP_NOSRC 0x04 - -#define L2CAP_FAILED 0xf0 -#define L2CAP_CON_UNRESPONSIVE 0xf1 =20 #ifndef BT_USERSTACK =20 --- bttest.c 2001/10/03 17:48:31 1.21 +++ bttest.c 2001/10/10 14:56:00 1.22 @@ -70,7 +70,7 @@ #include "bt_misc.h" #include "bt_conf.h" #include "bt_vendor.h" - +#include "bt_errno.h" /* =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 BTD_HISTORY_FILE "/tmp/btd_history" @@ -240,6 +240,7 @@ process_cmd(char *buf, int bt_cfd) { unsigned int i, con_id, tmp[10], repeat, line =3D 0, profile, srv_ch; + int retval =3D 0; unsigned char bd[6]; =20 if (!strncmp(buf, "quit", 4)) @@ -263,7 +264,7 @@ srv_ch =3D (unsigned short)(tmp[6]); con_id =3D CREATE_RFCOMM_ID(line, srv_ch<<1); =20=20=20=20=20 - bt_connect(bt_cfd, bd, con_id); + retval =3D bt_connect(bt_cfd, bd, con_id); } else if (sscanf(buf, "bt_wrscan %d", &tmp[0]) =3D=3D 1) { @@ -274,7 +275,7 @@ { unsigned int con_id; con_id =3D CREATE_RFCOMM_ID(line, 0 /* fixme -- don't care */); - bt_disconnect(bt_cfd, con_id); + retval =3D bt_disconnect(bt_cfd, con_id); } else if (sscanf(buf, "rf_wait %d", &line) =3D=3D 1) { @@ -387,7 +388,7 @@ /* fill it with something */ memset(buf, 'A', count); =20 - bt_ping(bt_cfd, bd, (unsigned char*)&buf , (unsigned short)count);=20= =20 + retval =3D bt_ping(bt_cfd, bd, (unsigned char*)&buf , (unsigned short)= count);=20=20 } else if (sscanf(buf, "getinfo %x:%x:%x:%x:%x:%x %d", &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5],=20 @@ -407,7 +408,7 @@ #ifdef CONFIG_BLUETOOTH_UNPLUG_TEST else if (strncmp(buf, "upt", 3) =3D=3D 0) { - bt_testcmd(bt_cfd, buf+4); + retval =3D bt_testcmd(bt_cfd, buf+4); } #endif else if (sscanf(buf, "getinfo %x:%x:%x:%x:%x:%x %x", @@ -436,7 +437,7 @@ bd[0], bd[1], bd[2], bd[3], bd[4], bd[5]); =20 - bt_connect(bt_cfd, bd, (TCS_LAYER << 16) & 0xffff000); + retval =3D bt_connect(bt_cfd, bd, (TCS_LAYER << 16) & 0xffff000); } =20 /* FIXME so that we can specify which line to connect */ @@ -454,7 +455,7 @@ bd[3], bd[4], bd[5]); =20=20=20=20=20 printf("RFCOMM server channel is %d\n", srv_ch); - bt_connect(bt_cfd, bd, CREATE_RFCOMM_ID(0, srv_ch << 1)); + retval =3D bt_connect(bt_cfd, bd, CREATE_RFCOMM_ID(0, srv_ch << 1)); } else if(sscanf(buf, "sdp_conn %x:%x:%x:%x:%x:%x", &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]) =3D=3D 6) @@ -468,7 +469,7 @@ bd[0], bd[1], bd[2], bd[3], bd[4], bd[5]); =20 - bt_connect(bt_cfd, bd, (SDP_LAYER << 16) & 0xFFFF0000); + retval =3D bt_connect(bt_cfd, bd, (SDP_LAYER << 16) & 0xFFFF0000); } else if(sscanf(buf, "test_conn %x:%x:%x:%x:%x:%x %x %d", &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5], &tmp[6], &tmp[7])= =3D=3D 8) @@ -481,32 +482,32 @@ printf("Connecting test layer (psm 0x%x, line %d) to bd : %02X:%02X:%0= 2X:%02X:%02X:%02X\n",=20 tmp[6], tmp[7], bd[0], bd[1], bd[2], bd[3], bd[4], bd[5]); =20 - bt_connect(bt_cfd, bd, ((tmp[6] << 16) & 0xffff0000) | tmp[7]); + retval =3D bt_connect(bt_cfd, bd, ((tmp[6] << 16) & 0xffff0000) | tmp[= 7]); } else if (sscanf(buf, "test_case_reject %x:%x:%x:%x:%x:%x", &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]) = =3D=3D 6) { - bt_testcmd(bt_cfd, buf); + retval =3D bt_testcmd(bt_cfd, buf); } else if (sscanf(buf, "test_disc %x", &tmp[0]) =3D=3D 1) { printf("Disconnecting layer (PSM: %x)\n", tmp[0]); - bt_disconnect(bt_cfd, (tmp[0] << 16) & 0xffff0000); + retval =3D bt_disconnect(bt_cfd, (tmp[0] << 16) & 0xffff0000); } else if(sscanf(buf, "bb_conn %x:%x:%x:%x:%x:%x", &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]) =3D=3D 6) { - bt_testcmd(bt_cfd, buf); + retval =3D bt_testcmd(bt_cfd, buf); } else if(sscanf(buf, "bb_disc %d", &i) =3D=3D 1) { printf("Disconnecting hci handle %d\n", i); - bt_testcmd(bt_cfd, buf); + retval =3D bt_testcmd(bt_cfd, buf); } else if(sscanf(buf, "lcid_disconnect %d", &i) =3D=3D 1) { printf("Disconnecting lcid %d", i); - bt_testcmd(bt_cfd, buf); + retval =3D bt_testcmd(bt_cfd, buf); } else if(sscanf(buf, "hotlist_set %d %x:%x:%x:%x:%x:%x",=20 &tmp[6], &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tm= p[5])) @@ -562,7 +563,9 @@ { printf("> error: command not recognized or wrong syntax\n"); show_menu(); + return 0; } +=20=20=20=20=20=20 return 0; } =20 @@ -601,6 +604,8 @@ return line; } #endif /* !HAVE_READLINE */ + + =20 /* bttest.c */ /* =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 */ --- bttest.h 2001/03/02 10:59:57 1.1 +++ bttest.h 2001/10/10 14:56:00 1.2 @@ -45,6 +45,5 @@ #define START_PPP 1 #define QUIT_BTD 2 int process_cmd(char *buf, int bt_cfd); - #endif /* __BT_TEST_H__*/ =20 |
From: Alain P. <apa...@us...> - 2002-04-22 15:22:05
|
The following files were modified in apps/bluetooth/experimental: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- README.txt 1.5 1.6=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 bt_if.c 1.45 1.46=20=20=20=20=20=20=20=20=20=20=20=20=20=20 bt_if.h 1.33 1.34=20=20=20=20=20=20=20=20=20=20=20=20=20=20 btinq.c 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 bttest.c 1.26 1.27=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Add an option to btinq to get the names of the remote devices. The same option produce a formated output which contain BD addresses and names. The diff of the modified file(s): --- README.txt 22 Apr 2002 14:29:22 -0000 1.5 +++ README.txt 22 Apr 2002 15:22:03 -0000 1.6 @@ -121,9 +121,25 @@ btinq.c ------- Perform inquiry scan -Syntax : btinq -n <max # returned> -t <max inq time>=20 +Syntax : btinq -n <max # returned> -t <max inq time> [-r] e.g btinq -n 20 -t 15 =20 +If you want to get the names of the found remote devices and have a +standard formated output, use option "-r" (for remote name). + +If you use option -r, you will recieve next format on standard ouput : + +<n> +<name 1> +<BT address 1> +<name 2> +<BT address 2> +... + +where <n> will be the number of devices found + <name x> will be the name of the remote device x + <BT address x> will be the bluetooth hardware address of the + remote device x. =20 By using these small apps together with btinit it will be possible to=20 do whole test 'suites' using e.g expect scripts or similar. --- bt_if.c 8 Apr 2002 11:20:31 -0000 1.45 +++ bt_if.c 22 Apr 2002 15:22:03 -0000 1.46 @@ -973,7 +973,7 @@ =20 =20 int -bt_inquiry(int bt_cfd, int nbr_rsp, int t) +bt_inquiry(int bt_cfd, int nbr_rsp, int t, int get_name) { int retval =3D 0; #ifdef BTD_USERSTACK @@ -1001,11 +1001,60 @@ =20 if ((retval =3D ioctl(bt_cfd, HCIINQUIRY, inq_res)) < 0) { - printf("Inquiry failed [%s (%d)]\n", error_msg(retval), MSG_GET_CODE(-= retval)); + fprintf(stderr, "Inquiry failed [%s (%d)]\n", error_msg(retval), MSG_G= ET_CODE(-retval)); free(inq_res); return retval; } =20 +if (get_name) + { + unsigned char name_device[255]; + /* First print the number of units found */ + printf("%d", inq_res->nbr_of_units); +=09 + for (i =3D 0; i < inq_res->nbr_of_units; i++) { + /* Copy BD_ADDR to send in ioctl */ + memcpy(name_device,inq_res->bd_addr + 6*i, 6); +=20=20=20=20 + if ((retval =3D ioctl(bt_cfd, HCIREMOTENAME_REQUEST, name_device)) < 0= ) { + fprintf (stderr, "Remote name request failed [%s (%d)]\n", error_msg= (retval), MSG_GET_CODE(-retval)); + /* Test if the problem is that the IOCTL doesn't exist */ + if (errno =3D=3D EINVAL) + fprintf(stderr, "btinq : error : the ioctl HCIREMOTENAME_REQ= UEST doesn't exist in the driver"); + /* Print a default name */ + printf("\nDevice with unknown name"); + } + else { + switch (retval) + { + case 0x04: /* Page timeout */ + printf("\nDevice with unknown name"); + break; + case 0x00: + if (name_device[0] =3D=3D '\0') { + printf("Device with empty name\n"); + } + else { + printf("\n%s", name_device); + } + break; + default: + printf("\nDevice with unrecoverable name");; + } /* Switch */ + + } + + /* Print BD address */ + printf("\n%02x:%02x:%02x:%02x:%02x:%02x", + inq_res->bd_addr[0+6*i], inq_res->bd_addr[1+6*i], + inq_res->bd_addr[2+6*i], inq_res->bd_addr[3+6*i], + inq_res->bd_addr[4+6*i], inq_res->bd_addr[5+6*i]); +=09=20=20 + } /* End of loop on every addresses founded */ + } /* End of if get_name */ +else + { + /* Just write addresses as it was historically done */ for (i =3D 0; i < inq_res->nbr_of_units; i++) { printf("BD %d: %02x:%02x:%02x:%02x:%02x:%02x\n",i, @@ -1014,6 +1063,7 @@ inq_res->bd_addr[4+6*i], inq_res->bd_addr[5+6*i]); } =20 + } free(inq_res); #endif return retval; --- bt_if.h 8 Apr 2002 11:23:11 -0000 1.33 +++ bt_if.h 22 Apr 2002 15:22:03 -0000 1.34 @@ -349,7 +349,7 @@ int bt_getinfo(int bt_cfd, unsigned char bd[6], unsigned short type); int bt_testcmd(int bt_cfd, unsigned char *cmd); =20 -int bt_inquiry(int bt_cfd, int nbr_rsp, int t); +int bt_inquiry(int bt_cfd, int nbr_rsp, int t, int get_name); int bt_set_baudrate(int bt_cfd, const char *speedstr); void bt_set_bd_addr(int bt_cfd, unsigned char *bd); void read_local_bd(int bt_cfd, unsigned char *bd_addr); --- btinq.c 14 May 2001 11:29:36 -0000 1.3 +++ btinq.c 22 Apr 2002 15:22:03 -0000 1.4 @@ -62,15 +62,16 @@ #include "bt_conf.h" =20 /*=20 - * Syntax: btinq -n <max # returned> -t <max inq time>=20 + * Syntax: btinq -n <max # returned> -t <max inq time> [-r] */ =20 int main(int argc, char **argv) {=20 int bt_cfd, opt, t =3D 10, nbr =3D 10; + int get_name =3D 0; =20 - while ((opt =3D getopt(argc, argv, "n:t:")) !=3D -1) + while ((opt =3D getopt(argc, argv, "n:t:r")) !=3D -1) { switch(opt) { @@ -82,6 +83,11 @@ t =3D atoi(optarg); break; =20 + case 'r': + /* Get the name of remote found devices */ + get_name =3D 1; + break; +=09=09=20 default: break; } @@ -97,11 +103,11 @@ /* First of all check that stack is running */ if (!bt_isinitiated(bt_cfd)) { - printf("Stack not initiated, exit\n"); + fprintf(stderr, "Stack not initiated, exit\n"); exit(1); } =20 - bt_inquiry(bt_cfd, nbr, t); + bt_inquiry(bt_cfd, nbr, t, get_name); =20=20 close(bt_cfd); exit(0); --- bttest.c 8 Apr 2002 11:22:08 -0000 1.26 +++ bttest.c 22 Apr 2002 15:22:03 -0000 1.27 @@ -486,7 +486,7 @@ } else if (sscanf(buf, "inq %d %d", &tmp[0], &tmp[1]) =3D=3D 2) { - retval =3D bt_inquiry(bt_cfd, tmp[0], tmp[1]); + retval =3D bt_inquiry(bt_cfd, tmp[0], tmp[1], 0); } else if (sscanf(buf, "rf_send %d %d %d", &i, &repeat, &line) =3D=3D 3) { |
From: Alain P. <apa...@us...> - 2002-06-03 10:07:31
|
The following files were modified in apps/bluetooth/experimental: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- bt_if.c 1.46 1.47=20=20=20=20=20=20=20=20=20=20=20=20=20=20 bt_if.h 1.34 1.35=20=20=20=20=20=20=20=20=20=20=20=20=20=20 bt_vendor.c 1.34 1.35=20=20=20=20=20=20=20=20=20=20=20=20=20=20 btd.c 1.37 1.38=20=20=20=20=20=20=20=20=20=20=20=20=20=20 btinit.c 1.20 1.21=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Correct the option -n (for the custom local name). It was not completely implemented and it crashed the bti. The diff of the modified file(s): --- bt_if.c 22 Apr 2002 15:22:03 -0000 1.46 +++ bt_if.c 3 Jun 2002 10:07:28 -0000 1.47 @@ -70,7 +70,7 @@ /* Functions common for kernel and usermode stack */ /* =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 -int init_stack(int bt_cfd) +int init_stack(int bt_cfd, char * local_name) { syslog(LOG_INFO, "Init stack"); =20 @@ -89,7 +89,10 @@ bt_set_classofdevice(bt_cfd, 0x10, 0x3, 0x0, 0x0); =20 #ifndef __CRIS__ - set_local_hostname(bt_cfd, "AXIS"); + if (! local_name) + set_local_hostname(bt_cfd, "AXIS", 1); + else + set_local_hostname(bt_cfd, local_name, 0); #endif } =20=20=20 @@ -1331,7 +1334,7 @@ } =20 =20 -void set_local_hostname(int bt_cfd, const char *local_name) +void set_local_hostname(int bt_cfd, const char *local_name, int add_host) { unsigned char buf[LOCAL_NAME_LENGTH + HOST_NAME_LENGTH +=20 DOMAIN_NAME_LENGTH + 5]; @@ -1349,7 +1352,7 @@ } } =20=20 - if (len) + if (len && add_host) { buf[len++] =3D ' '; buf[len++] =3D '('; @@ -1370,7 +1373,7 @@ } } =20 - if (len) + if (len && add_host) { strcat(buf, ")"); } --- bt_if.h 22 Apr 2002 15:22:03 -0000 1.34 +++ bt_if.h 3 Jun 2002 10:07:28 -0000 1.35 @@ -300,7 +300,7 @@ * Init/shutdown and control of stack=20 */ =20 -int init_stack(int bt_cfd); +int init_stack(int bt_cfd, char * local_name); int bt_isinitiated(int bt_cfd); void shutdown_stack(int bt_cfd); #ifndef BT_USERSTACK @@ -385,7 +385,7 @@ =20 =20 /* Sets friendly name to local_name + hostname in HW */ -void set_local_hostname(int bt_cfd, const char *local_name); +void set_local_hostname(int bt_cfd, const char *local_name, int add_host); =20 /* Sets friendly name to name */ void bt_set_local_name(int bt_cfd, const unsigned char *name); --- bt_vendor.c 16 May 2002 15:12:45 -0000 1.34 +++ bt_vendor.c 3 Jun 2002 10:07:28 -0000 1.35 @@ -444,12 +444,12 @@ sleep(1); =20 /* Initialize stack */ - init_stack(bt_cfd); + init_stack(bt_cfd, NULL); =20 if (csr_disable_deep_sleep(bt_cfd)) { reset_hw(); - init_stack(bt_cfd); /* reinitialize */ + init_stack(bt_cfd, NULL); /* reinitialize */ } =20 /* Read params for ps key PSKEY_HOSTIO_UART_PS_BLOCK */ --- btd.c 20 Dec 2001 14:47:41 -0000 1.37 +++ btd.c 3 Jun 2002 10:07:28 -0000 1.38 @@ -192,7 +192,7 @@ =20 static char *physdev =3D DEFAULT_PHYS_DEV; static char *speedstr =3D DEFAULT_SPEED; -static char local_name[LOCAL_NAME_LENGTH+1]; /* 'friendly' name in HW modu= le */ +static char * local_name =3D NULL; /* not set */ =20 static int btd_pid =3D -1; static int sdpsrv_pid =3D 0; @@ -248,7 +248,7 @@ } =20=20=20 /* now parse options */ - while ((opt =3D getopt_long(argc, argv, "fi:m:nRs:u:IUB", + while ((opt =3D getopt_long(argc, argv, "fi:m:n:Rs:u:IUB", long_options, &option_index)) !=3D -1) { switch(opt) @@ -271,9 +271,8 @@ break; =20=20=20=20=20=20=20 case 'n': - D(syslog(LOG_INFO, "setting local name to %s", optarg)); - strncpy(local_name, optarg, LOCAL_NAME_LENGTH); - local_name[LOCAL_NAME_LENGTH] =3D '\0'; + local_name =3D optarg; + D(syslog(LOG_INFO, "setting local name to %s", local_name)); break; =20=20=20=20=20=20=20 case 'R': @@ -351,11 +350,11 @@ if (do_reset) reset_hw(); =20 - if (init_stack(bt_cfd) < 0) + if (init_stack(bt_cfd, local_name) < 0) { /* 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) + if (init_stack(bt_cfd, local_name) < 0) { init_failed(bt_cfd, phys_fd, init_hw_speedstr, flow_control); } --- btinit.c 15 May 2002 13:07:56 -0000 1.20 +++ btinit.c 3 Jun 2002 10:07:28 -0000 1.21 @@ -114,7 +114,7 @@ static int bt_cfd =3D -1; /* control tty for bt stack */ =20 static int btd_pid; -static char local_name[LOCAL_NAME_LENGTH+1]; /* 'friendly' name in HW modu= le */ +static char * local_name =3D NULL; /* not set */ static const char *init_hw_speedstr =3D NULL; /* not set */ static int do_hwinit =3D 1; /* do vendor specific initialization */ static int do_reset =3D 0; /* reset hw using I/O pins */ @@ -183,7 +183,7 @@ } =20 /* now parse options */ - while ((opt =3D getopt_long(argc, argv, "fi:nRs:u:D", + while ((opt =3D getopt_long(argc, argv, "fi:n:Rs:u:D", long_options, &option_index)) !=3D -1) { switch(opt) @@ -201,9 +201,8 @@ break; =20 case 'n': - D(syslog(LOG_INFO, "setting local name to %s", optarg)); - strncpy(local_name, optarg, LOCAL_NAME_LENGTH); - local_name[LOCAL_NAME_LENGTH] =3D '\0'; + local_name =3D optarg; + D(syslog(LOG_INFO, "setting local name to %s", local_name)); break; =20 case 'R': @@ -281,11 +280,11 @@ if (do_reset) reset_hw(); =20=20=20 - if (init_stack(bt_cfd) < 0) + if (init_stack(bt_cfd, local_name) < 0) { /* 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) + if (init_stack(bt_cfd, local_name) < 0) { init_failed(bt_cfd, phys_fd, init_hw_speedstr, flow_control); } |