From: Mattias A. <mat...@us...> - 2001-03-21 17:26:46
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * added function to send raw hci data * added status message in bt_disconnect * added bt_showstatus * modified and added error codes for l2cap in error_msg() The diff of the modified file(s): --- bt_if.c 2001/03/13 22:21:17 1.2 +++ bt_if.c 2001/03/21 17:26:44 1.3 @@ -62,6 +62,29 @@ #include "bt_misc.h" #include "bt_conf.h" =20 + +int bt_send_raw_hci(int bt_cfd, unsigned char *data, char len) +{ + unsigned char buf[261]; + + buf[0] =3D len; +=20=20 + memcpy(buf+1, data, len); + + print_data("data :",(char*) buf,(int) len+1); + +#ifndef BT_USERSTACK=20 + if (ioctl(bt_cfd, HCISENDRAWDATA, buf) < 0) + { + perror("ecs_testctrl"); + } +#else + printf("not yet for usermode stack...\n"); + //hci_send_raw_data(data, 16); +#endif + return 0; +} + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=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 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 */ @@ -214,16 +237,16 @@ return result; } =20 -void +int bt_disconnect(int bt_fd, unsigned int con_id) { -#ifndef BT_USERSTACK + int ret_val; =20 - if (ioctl(bt_fd, BTDISCONNECT, &con_id) < 0) - { - perror("Disconnect"); - exit(1); - } +#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); + else + printf("Disconnected.\n"); #else /* fixme<3> -- only works for rfcomm */ u8 line;=09=09=09=09 @@ -236,9 +259,10 @@ return; } =20=20=20 - rfcomm_disconnect_req(GET_RFCOMMLINE(con_id)); + ret_val =3D rfcomm_disconnect_req(GET_RFCOMMLINE(con_id)); #endif - printf("Disconnected!\n"); + + return ret_val; } =20 /* Check whether this line is lower connected in stack (rfcomm ready) */ @@ -258,6 +282,21 @@ return ret; } =20 +void bt_showstatus(void) +{ +#ifdef BT_USERSTACK + + char tmp[4096]; + int len; + len =3D bt_read_internal(tmp); + tmp[len] =3D 0; + printf("%s", tmp); +#else + /*FIXME -- read /proc/bt_internal and print it on the console */ + printf("not yet...\n"); +#endif=20 +} + =20 /* fixme<1> -- add usermode stack version */ int @@ -319,6 +358,8 @@ return 0; } =20 + + void bt_waitline(int bt_fd, int line) { @@ -417,29 +458,20 @@ } =20 void -bt_set_bd_addr(int bt_cfd, int* bd) -{ - int i; - unsigned char new_bd[6]; -=20=20=20=20 - for (i =3D 0; i < 6; i++) +bt_set_bd_addr(int bt_cfd, unsigned char *bd) { - new_bd[i] =3D (unsigned char) *bd++; - } - printf("Setting BD address to: %02X:%02X:%02X:%02X:%02X:%02X\n", - new_bd[0], new_bd[1], new_bd[2], - new_bd[3], new_bd[4], new_bd[5]); + bd[0], bd[1], bd[2], + bd[3], bd[4], bd[5]); =20=20=20=20=20 #ifndef BT_USERSTACK - if (ioctl(bt_cfd, HCIWRITEBDADDR, new_bd) < 0) + if (ioctl(bt_cfd, HCIWRITEBDADDR, bd) < 0) { perror("Set bd addr"); } #else - hci_set_bd_addr(new_bd); + hci_set_bd_addr(bd); #endif=20=20=20=20 -=20 printf("Please reset HW to activate bd change\n"); } =20 @@ -449,7 +481,7 @@ int bt_set_baudrate(int bt_cfd, int spd) { int result; -=20=20 + syslog(LOG_INFO, "bt_set_baudrate %d baud", spd); #ifdef BT_USERSTACK tcflush(phys_fd, TCIOFLUSH); hci_set_baudrate(spd); @@ -473,15 +505,12 @@ } #else BD_ADDR rev_bd; - int i; -=20=20 hci_read_local_bd(rev_bd); =20 /* return as big endian */ for (i =3D 0; i < 6; i++) { bd_addr[i] =3D rev_bd[5-i]; } - #endif } =20 @@ -755,12 +784,15 @@ { switch(code) {=20 - case RES_PSMNEG: + case L2CAP_PSMNEG: return "L2CAP - PSM not valid"; - case RES_SECNEG: + case L2CAP_SECNEG: return "L2CAP - Security block"; - case RES_NOSRC: + case L2CAP_NOSRC: return "L2CAP - Remote side has no resources"; + case L2CAP_CON_UNRESPONSIVE: + return "L2CAP - Unresponsive link"; + default: return "L2CAP - unknown reason"; } @@ -768,7 +800,7 @@ break; =20=20=20=20=20 default: - return "Unknown layer - unknown reason"; + return "General failure"; } } =20 |
From: Mattias A. <mat...@us...> - 2001-03-30 12:31:47
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.4 1.5=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: ignore bt_openctrl calls when running usermode stack fixed usermode stack related problems moved around some functions added sleep after setting baudrate in usermode stack fixed some return values minor changes The diff of the modified file(s): --- bt_if.c 2001/03/26 15:33:13 1.4 +++ bt_if.c 2001/03/30 12:31:46 1.5 @@ -61,57 +61,7 @@ #include "bt_vendor.h" #include "bt_misc.h" #include "bt_conf.h" - -int bt_send_raw_hci(int bt_cfd, unsigned char *data, char len) -{ - unsigned char buf[261]; - - buf[0] =3D len; -=20=20 - memcpy(buf+1, data, len); - - print_data("data :",(char*) buf,(int) len+1); - -#ifndef BT_USERSTACK=20 - if (ioctl(bt_cfd, HCISENDRAWDATA, buf) < 0) - { - perror("bt_send_raw_hci"); - } -#else - printf("not yet for usermode stack...\n"); - //hci_send_raw_data(data, 16); -#endif - return 0; -} - -int bt_ping(int bt_cfd, unsigned char bd[6],=20 - unsigned char *data, unsigned short len) -{ - unsigned char buf[264]; - int ret_val; -=20=20 - printf("bt_ping\n"); - - memcpy(buf, bd, 6); - buf[6] =3D len>>8; - buf[7] =3D len&0xff; - memcpy(buf, data, len); - -#ifndef BT_USERSTACK=20 - if ((ret_val =3D ioctl(bt_cfd, BTPING, buf)) < 0) - { - printf("Error : %s\n", error_msg(ret_val)); - } - else - printf("Success!\n"); - -#else - printf("not yet for usermode stack...\n"); -#endif - return 0;=20=20 - -} - +#include "bt_user.h" =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 common for kernel and usermode stack */ @@ -213,11 +163,16 @@ { int bt_cfd; printf("Now opening BT Ctrl TTY [%s]\n", BT_CTRL_TTY); +#ifdef BT_USERSTACK + printf("bt_openctrl : ignored in userstack\n"); + return FD_BTUSERCTRL; +#else=20 if ((bt_cfd =3D open(BT_CTRL_TTY, O_RDWR | O_NOCTTY)) < 0) { printf("could not open %s\n", BT_CTRL_TTY); exit(1); } +#endif return bt_cfd; } =20 @@ -255,7 +210,7 @@ =20=20 if (line !=3D 0) { printf("Use line 0 instead ! (usermode only)\n"); - return; + return -1; } =20 printf("Connecting srv ch %d on line %d\n", srv_ch, line); @@ -268,7 +223,7 @@ int bt_disconnect(int bt_fd, unsigned int con_id) { - int ret_val; + int ret_val =3D 0; =20=20=20 #ifndef BT_USERSTACK=20=20 if ((ret_val =3D ioctl(bt_fd, BTDISCONNECT, &con_id))) @@ -284,10 +239,10 @@ =20=20=20 if (line !=3D 0) { printf("Use line 0 instead ! (usermode only)\n"); - return; + return -1; } =20=20=20 - ret_val =3D rfcomm_disconnect_req(GET_RFCOMMLINE(con_id)); + rfcomm_disconnect_req(GET_RFCOMMLINE(con_id)); #endif =20 return ret_val; @@ -408,11 +363,9 @@ void bt_waitnewconnections(int bt_fd) { - int result; -=20=20 syslog(LOG_INFO, "bt_waitnewconnections\n"); #ifndef BT_USERSTACK - if ((result =3D ioctl(bt_fd, BTWAITNEWCONNECTIONS)) < 0) + if (ioctl(bt_fd, BTWAITNEWCONNECTIONS) < 0) { perror("bt_waitnewconnections"); exit(1); @@ -443,6 +396,113 @@ #endif } =20 +int bt_send_raw_hci(int bt_cfd, unsigned char *data, char len) +{ + unsigned char buf[261]; + + buf[0] =3D len; +=20=20 + memcpy(buf+1, data, len); + + print_data("data :",(char*) buf,(int) len+1); + +#ifndef BT_USERSTACK=20 + if (ioctl(bt_cfd, HCISENDRAWDATA, buf) < 0) + { + perror("bt_send_raw_hci"); + } +#else + printf("not yet for usermode stack...\n"); + //hci_send_raw_data(data, 16); +#endif + return 0; +} + +int bt_ping(int bt_cfd, unsigned char bd[6],=20 + unsigned char *data, unsigned short len) +{ + int ret_val; + struct ping_struct ping; +=20=20 + print_data("bt_ping BD : ", bd, 6); + memcpy(ping.bd, bd, 6); + ping.len =3D len;=20=20 + memcpy(ping.data, data, len); +=20=20 +#ifndef BT_USERSTACK=20 + if ((ret_val =3D ioctl(bt_cfd, BTPING, &ping)) !=3D 0) + { + printf("Error : %s\n", error_msg(ret_val)); + } + else + printf("Success!\n"); + +#else + ret_val =3D l2ca_ping(bd, data, len); +#endif + return ret_val; +} + + +int=20 +bt_getinfo(int bt_cfd, unsigned char bd[6], unsigned short type) +{ + int ret_val; + unsigned char msg[8]; +=20=20 + memcpy(msg, bd, 6); + msg[6] =3D (unsigned char)(type>>8); + msg[7] =3D (unsigned char)(type&0xff); + +#ifndef BT_USERSTACK=20 + if ((ret_val =3D ioctl(bt_cfd, BTGETINFO, &msg)) !=3D 0) + { + printf("Error : %s\n", error_msg(ret_val)); + } + else + printf("Success!\n"); +#else + ret_val =3D l2ca_getinfo(bd, type); +#endif + return ret_val; +} + + +int bt_testcmd(int bt_cfd, unsigned char *cmd) +{ + int ret_val; +=20=20 + printf("bt_testcmd\n"); + print_data("cmd ", cmd, strlen(cmd)); + +#ifndef BT_USERSTACK=20 + if ((ret_val =3D ioctl(bt_cfd, BTTESTCOMMAND, cmd)) !=3D 0) + { + printf("Error : %s\n", error_msg(ret_val)); + } + else + printf("Success!\n"); +#else + printf("bt_testcmd mpt for usermode stack yet\n"); +#endif + return ret_val; +} + +int bt_force_msswitch_as_server(int bt_cfd, int enable) +{ + int ret_val; + syslog(LOG_INFO, "bt_force_msswitch_as_server : % d\n"), enable; +#ifndef BT_USERSTACK=20 + if ((ret_val =3D ioctl(bt_cfd, BTSETMSSWITCH, &enable)) !=3D 0) + { + printf("Error : %s\n", error_msg(ret_val)); + } +#else + hci_force_msswitch(enable); +#endif + return ret_val; +} + =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 */ /* HCI functions */ @@ -512,7 +572,8 @@ syslog(LOG_INFO, "bt_set_baudrate %d baud", spd); #ifdef BT_USERSTACK tcflush(phys_fd, TCIOFLUSH); - hci_set_baudrate(spd); + result =3D hci_set_baudrate(spd); + usleep(10000); #else if ((result =3D ioctl(bt_cfd, HCISETBAUDRATE, &spd)) < 0) { @@ -532,6 +593,7 @@ perror("Read bd addr"); } #else + int i; BD_ADDR rev_bd; hci_read_local_bd(rev_bd); =20 @@ -558,7 +620,6 @@ printf("done.\n"); } =20=20 - /* fixme<1> -- add "line" parameter to differentiate between the=20 remote devices */ void @@ -584,28 +645,53 @@ } =20 /* fixme<3> - get flags from somewhere */ -int bt_set_writescanenable(int bt_cfd, int flags) +int bt_write_scan_enable(int bt_cfd, unsigned int flags) { unsigned int wrscan =3D (PAGE_SCAN_ENABLE | INQUIRY_SCAN_ENABLE); int result; =20=20=20 - printf("Setting write_scan_enable [0x%x]\n", wrscan); + syslog(LOG_INFO, "Setting write_scan_enable [0x%x]\n", wrscan); =20 #ifdef BT_USERSTACK - hci_write_scan_enable(wrscan); + result =3D hci_write_scan_enable(wrscan); #else =20 if ((result =3D ioctl(bt_cfd, HCIWRITESCANENABLE, &wrscan)) < 0) {=20 - perror("HCIWRITESCANENABLE"); + perror("bt_set_writescanenable"); exit(1); } #endif=09 return result; } =20 -/* fixme<3> get filter from somwhere */ -int bt_set_event_filter(int bt_cfd, int filter) +void +bt_write_pagescan_activity(int bt_cfd, unsigned int interval,=20 + unsigned int wind) +{ + /* improves reliability when doing a connect */ + syslog(LOG_INFO, "Setting write_pagescan_activity in CSR module!\n"); + +#ifdef BT_USERSTACK + + hci_write_pagescan_activity(interval, wind); +#else + { + unsigned int tmp [2];=20=20 + tmp[0] =3D interval; + tmp[1] =3D wind; +=20=20=20=20 + if (ioctl(bt_cfd, HCIWRITEPAGESCANACTIVITY, &tmp) < 0) + {=20 + perror("bt_write_pagescan_activity"); + exit(1); + } + } +#endif +} + +/* fixme<3> get filter from somewhere */ +int bt_set_event_filter(int bt_cfd, unsigned int filter) { unsigned char evfilter[3]; int result; @@ -614,11 +700,11 @@ evfilter[1] =3D 0x00; /* All devices */ evfilter[2] =3D 0x01; /* No auto accept */=20=20 =20 - printf("Setting event filter [0x%1x 0x%1x 0x%1x]\n",=20 + syslog(LOG_INFO, "Setting event filter [0x%1x 0x%1x 0x%1x]\n",=20 evfilter[0], evfilter[1], evfilter[2]); =20 #ifdef BT_USERSTACK - result =3D hci_set_event_filter(&evfilter); + result =3D hci_set_event_filter((u8*)&evfilter); #else =20 if ((result =3D ioctl(bt_cfd, HCISET_EVENT_FILTER, &evfilter)) < 0) @@ -637,6 +723,7 @@ { unsigned char class_of_device[3];=20 =20=20=20 + syslog(LOG_INFO, "bt_set_classofdevice : srv class 0x%x, maj class 0x%x,= min class 0x%x, format 0x%x", service_class, major_class, minor_class, for= mat); switch (format) { case 0: @@ -655,13 +742,14 @@ #endif break; case 1: - printf("bt_set_classofdevice, Unsupported format 0x%02x\n", format); + syslog(LOG_INFO, "bt_set_classofdevice, Unsupported format 0x%02x\n",= =20 + format); break; case 2: - printf("bt_set_classofdevice, Unsupported format 0x%02x\n", format); + syslog(LOG_INFO, "bt_set_classofdevice, Unsupported format 0x%02x\n", = format); break; default: - printf("bt_set_classofdevice, Unsupported format 0x%02x\n", format); + syslog(LOG_INFO, "bt_set_classofdevice, Unsupported format 0x%02x\n", = format); break; } } @@ -672,7 +760,7 @@ int i; unsigned char tmp[7]; =20=09 - printf("Performing role switch to peer: %02X:%02X:%02X:%02X:%02X:%02X\n", + syslog(LOG_INFO, "Performing role switch to peer: %02X:%02X:%02X:%02X:%02= X:%02X\n", bd_addr[0], bd_addr[1], bd_addr[2], bd_addr[3], bd_addr[4], bd_addr[5]); =20=09 @@ -689,7 +777,7 @@ perror("role_switch"); } #else - role_switch(bd_addr, role); + hci_switch_role(bd_addr, role); #endif } =20 @@ -700,15 +788,14 @@ if (ioctl(phys_fd, TIOCSETD, &bt_disc) < 0) { perror("Set bt line disc"); - printf("Forgot to insmod bt.o ? [bt_disc %d]\n", bt_disc); + syslog(LOG_INFO, "Forgot to insmod bt.o ? [bt_disc %d]\n", bt_disc); exit(1); } -#else - printf("ERROR : No line disciplines in usermode stack\n"); - exit(1); -#endif syslog(LOG_INFO, "Registered bluetooth line discipline on %s\n", physdev= ); printf("Registered bluetooth line discipline on %s\n", physdev); +#else + printf("set_bt_line_disc, ignored in usermode stack\n"); +#endif } =20 void set_local_name(int bt_cfd, const char *local_name) @@ -771,7 +858,6 @@ /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* Misc functions */ =20 - /* See spec p 769 error codes for HCI */ const char *error_msg(int err) { @@ -853,14 +939,15 @@ =20 #ifdef BT_USERSTACK=20=20 /* if opening bt dev or control dev simply discard and return fake fd */ - if ((strcmp(dev, btdev) =3D=3D 0) || (strcmp(dev, BT_CTRL_TTY) =3D=3D 0)) + if ((strncmp(dev, "/dev/ttyBT", 11) =3D=3D 0) || (strcmp(dev, BT_CTRL_TT= Y) =3D=3D 0)) return 0xb055e; - +#if 0 /* fixme */ if (use_local_socket) return open_socket(dev, role); else if (use_tcp_socket) return open_tcpsocket(dev, role); #endif=20=20 +#endif=20=20 =20 syslog(LOG_INFO, "Opening dev %s\n", dev); if ((fd =3D open(dev, flags | O_NOCTTY)) < 0) @@ -892,13 +979,14 @@ int sdpsrv_pid; char *args[] =3D { SDPSRV_CMD, SDPSRV_CONF, SDPSRV_PROC, NULL }; =20=20=20 - syslog(LOG_INFO, "Starting SDP server\n"); + syslog(LOG_INFO, "Starting SDP server [%s]\n", SDPSRV_CMD);=20=20 =20=20=20 if (!(sdpsrv_pid =3D vfork())) { 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); } @@ -920,6 +1008,25 @@ =20 #ifdef BT_USERSTACK =20 + +#if BT_DATADUMP_DEBUG +#define BT_DATADUMP(str, data, len) print_data(str, data, len) +#else +#define BT_DATADUMP(str, data, len) +#endif + +#if BT_DATA_DEBUG +#if BT_USE_TIMESTAMPS +#define BT_DATA(fmt...) do {print_time(1);printk(BT_DBG_STR"DATA " fmt);} = while (0) +#else +#define BT_DATA(fmt...) printk(BT_DBG_STR"DATA " fmt) +#endif + +#else /* BT_DATA_DEBUG */ +#define BT_DATA(fmt...) +#endif /* BT_DATA_DEBUG */ + + int init_read_thread(void) { printf("Initiating read thread\n"); @@ -949,13 +1056,21 @@ if (len > 0) { BT_DATA("-->|X| %3d\n", len); - PRINTPKT("data rec : ", databuf, len); + BT_DATADUMP("-->|X|", databuf, len); hci_receive_data(databuf, len); } } } } =20 +void +init_upper_pty(void) +{ + printf("init_upper_pty"); + //open_pty(); + //init_pty_thread();=20=20 +} + =20 void init_userstack() {=20=20 @@ -969,7 +1084,7 @@ hci_init(); l2cap_init(); rfcomm_init(); - sdp_init(); + sdp_init(SERVER); tcs_init(); test_init(); btmem_init(); @@ -990,7 +1105,7 @@ =20 BT_DATA("<--|X| %3d\n", len); =20 - PRINTPKT("bt_write_lower_driver ", data, len); + BT_DATADUMP("<--|X|", data, len); i =3D write(phys_fd, data, len); return i; } @@ -1004,6 +1119,7 @@ int bytes_sent =3D 0; =20 BT_DATA(" |X|<-- %3d [%d]\n", count, line); + BT_DATADUMP("|X|<--", buf, count); =20=20=20 while (bytes_sent!=3Dcount) { @@ -1030,10 +1146,13 @@ =20 int bt_receive_top(rfcomm_con *rfcomm, unsigned char *data, int len) { - int n; + int n =3D 0; =20 BT_DATA(" |X|--> %3d [%d]\n", len, rfcomm->line); + BT_DATADUMP("|X|-->", data, len); =20 +#if 0 /* fixme */ + if (modem_emulation && !modem_connected) { modem_emulator(0xb055e, data, len); @@ -1054,6 +1173,7 @@ BT_DATA("bt_receive_top: tried to write %d bytes, wrote %d\n", len, n); } +#endif =20 bt_stat.bytes_received+=3Dn; =20 @@ -1063,7 +1183,11 @@ void bt_connect_ind(unsigned int con_id)=20 { - DSYS("Got connect indication on PSM %d\n", GET_PSM(con_id)); + if (GET_PSM(con_id) =3D=3D RFCOMM_LAYER) + printf("bt_connect_ind : RFCOMM dlci : %d\n",=20 + GET_RFCOMMDLCI(con_id)); + else + printf("bt_connect_ind : psm %d\n", GET_PSM(con_id)); } =20 void @@ -1112,16 +1236,30 @@ void bt_disconnect_ind(unsigned int con_id)=20 { - DSYS("Got disconnect indication on PSM %d\n", GET_PSM(con_id)); + if (GET_PSM(con_id) =3D=3D RFCOMM_LAYER) + printf("bt_disconnect_ind : RFCOMM dlci : %d\n",=20 + GET_RFCOMMDLCI(con_id)); + else + printf("bt_disconnect_ind : psm %d\n", GET_PSM(con_id)); } =20 - int bt_register_rfcomm(struct rfcomm_con *rfcomm, u8 dlci) { test_rfcomm =3D rfcomm; - test_dlci =3D dlci; + testdlci =3D dlci; return 0; +} + +s32 +bt_register_sdp(u8 line, u8 sdpID) +{ + printf("bt_register_sdp\n"); +} + +s32 bt_unregister_sdp(s32 line) +{ + printf("bt_unregister_sdp\n"); } =20 int bt_initiated(void) |
From: Peter K. <pk...@us...> - 2001-04-11 12:42:30
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.5 1.6=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Corrected indentation. The diff of the modified file(s): --- bt_if.c 2001/03/30 12:31:46 1.5 +++ bt_if.c 2001/04/11 12:42:30 1.6 @@ -268,9 +268,9 @@ void bt_showstatus(void) { #ifdef BT_USERSTACK - char tmp[4096]; int len; + len =3D bt_read_internal(tmp); tmp[len] =3D 0; printf("%s", tmp); @@ -280,7 +280,6 @@ #endif=20 } =20 - /* fixme<1> -- add usermode stack version */ int bt_send(int fd, int len, int repeat) @@ -325,8 +324,7 @@ } =20=20=20=20=20 repeat--; - printf("%6d kB left to send... \r", - ((repeat*len)/1000)); + printf("%6d kB left to send... \r", ((repeat*len)/1000)); fflush(stdout); } gettimeofday(&stop_t, NULL); @@ -342,7 +340,6 @@ } =20 =20 - void bt_waitline(int bt_fd, int line) { @@ -436,14 +433,12 @@ } else printf("Success!\n"); - #else ret_val =3D l2ca_ping(bd, data, len); #endif return ret_val; } =20 - int=20 bt_getinfo(int bt_cfd, unsigned char bd[6], unsigned short type) { @@ -467,7 +462,6 @@ return ret_val; } =20 - int bt_testcmd(int bt_cfd, unsigned char *cmd) { int ret_val; @@ -491,6 +485,7 @@ int bt_force_msswitch_as_server(int bt_cfd, int enable) { int ret_val; + syslog(LOG_INFO, "bt_force_msswitch_as_server : % d\n"), enable; #ifndef BT_USERSTACK=20 if ((ret_val =3D ioctl(bt_cfd, BTSETMSSWITCH, &enable)) !=3D 0) @@ -569,6 +564,7 @@ int bt_set_baudrate(int bt_cfd, int spd) { int result; + syslog(LOG_INFO, "bt_set_baudrate %d baud", spd); #ifdef BT_USERSTACK tcflush(phys_fd, TCIOFLUSH); @@ -595,16 +591,17 @@ #else int i; BD_ADDR rev_bd; + hci_read_local_bd(rev_bd); =20 /* return as big endian */ - for (i =3D 0; i < 6; i++) { + for (i =3D 0; i < 6; i++) + { bd_addr[i] =3D rev_bd[5-i]; } #endif } =20 - void enable_dut(int bt_cfd) { @@ -640,7 +637,6 @@ for (i =3D 0; i < 6; i++) { bd_addr[i] =3D rev_bd[5-i]; } - #endif } =20 @@ -678,6 +674,7 @@ #else { unsigned int tmp [2];=20=20 + tmp[0] =3D interval; tmp[1] =3D wind; =20=20=20=20=20 @@ -741,13 +738,16 @@ hci_write_class_of_device(class_of_device); #endif break; + case 1: syslog(LOG_INFO, "bt_set_classofdevice, Unsupported format 0x%02x\n",= =20 format); break; + case 2: syslog(LOG_INFO, "bt_set_classofdevice, Unsupported format 0x%02x\n", = format); break; + default: syslog(LOG_INFO, "bt_set_classofdevice, Unsupported format 0x%02x\n", = format); break; @@ -1020,7 +1020,7 @@ #define BT_DATA(fmt...) do {print_time(1);printk(BT_DBG_STR"DATA " fmt);} = while (0) #else #define BT_DATA(fmt...) printk(BT_DBG_STR"DATA " fmt) -#endif +#endif /* BT_USE_TIMESTAMPS */ =20 #else /* BT_DATA_DEBUG */ #define BT_DATA(fmt...) @@ -1030,8 +1030,7 @@ int init_read_thread(void) { printf("Initiating read thread\n"); - if (pthread_create(&read_thread, NULL,=20 - (void*)hci_receive_thread, NULL)!=3D0) + if (pthread_create(&read_thread, NULL, (void*)hci_receive_thread, NULL) = !=3D 0) perror("pthread_create");=20=20=20=20 sleep(1); /* wait for thread to start */ return 0; @@ -1152,7 +1151,6 @@ BT_DATADUMP("|X|-->", data, len); =20 #if 0 /* fixme */ - if (modem_emulation && !modem_connected) { modem_emulator(0xb055e, data, len); @@ -1214,10 +1212,8 @@ =20=09 switch (psm) { case RFCOMM_LAYER: - {=09 printf("bt_connect_cfm [%s]\n", psmname(psm)); break; - } =20=20=20=20=20=20=20=20=20=20=20 case SDP_LAYER: printf("bt_connect_cfm [%s]\n", psmname(psm)); @@ -1237,8 +1233,7 @@ bt_disconnect_ind(unsigned int con_id)=20 { if (GET_PSM(con_id) =3D=3D RFCOMM_LAYER) - printf("bt_disconnect_ind : RFCOMM dlci : %d\n",=20 - GET_RFCOMMDLCI(con_id)); + printf("bt_disconnect_ind : RFCOMM dlci : %d\n", GET_RFCOMMDLCI(con_id= )); else printf("bt_disconnect_ind : psm %d\n", GET_PSM(con_id)); } @@ -1266,4 +1261,4 @@ { return bt_initdone; } -#endif +#endif /* BT_USERSTACK */ |
From: Mattias A. <mat...@us...> - 2001-04-17 12:25:00
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.6 1.7=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: corrected wrong external variable name The diff of the modified file(s): --- bt_if.c 2001/04/11 12:42:30 1.6 +++ bt_if.c 2001/04/17 12:24:58 1.7 @@ -1241,20 +1241,30 @@ int bt_register_rfcomm(struct rfcomm_con *rfcomm, u8 dlci) { + printf("bt_register_rfcomm on dlci %d\n", dlci); test_rfcomm =3D rfcomm; - testdlci =3D dlci; + test_dlci =3D dlci; return 0; } =20 s32 +bt_unregister_rfcomm(s32 line) +{ + printf("bt_unregister_rfcomm on line %d\n", line); + /* fixme -- stub for now */ +} + +s32 bt_register_sdp(u8 line, u8 sdpID) { printf("bt_register_sdp\n"); + return 0; } =20 s32 bt_unregister_sdp(s32 line) { printf("bt_unregister_sdp\n"); + return 0; } =20 int bt_initiated(void) |
From: Mattias A. <mat...@us...> - 2001-04-17 15:45:28
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.7 1.8=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * added more error messages The diff of the modified file(s): --- bt_if.c 2001/04/17 12:24:58 1.7 +++ bt_if.c 2001/04/17 15:45:28 1.8 @@ -62,6 +62,7 @@ #include "bt_misc.h" #include "bt_conf.h" #include "bt_user.h" +#include "bt_errno.h" =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 common for kernel and usermode stack */ @@ -858,7 +859,7 @@ /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* Misc functions */ =20 -/* See spec p 769 error codes for HCI */ +/* See bt_errno.h for error codes */ const char *error_msg(int err) { int layer =3D (err >> 16) & 0xffff; @@ -868,6 +869,8 @@ { 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 @@ -913,6 +916,43 @@ } break; =20=20=20=20=20 + case MSG_LAYER_RFCOMM: + { + /* fixme */ + return "RFCOMM - unknown reason"; + } + break; + + case MSG_LAYER_SDP: + { + /* fixme */ + return "SDP - unknown reason"; + } + break; +=20=20=20=20 + case MSG_LAYER_TCS: + { + /* fixme */ + return "TCS - unknown reason"; + } + 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"; + } + } + break; + default: return "General failure"; } |
From: Peter K. <pk...@us...> - 2001-04-18 14:02:27
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.8 1.9=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Corrected a typo. The diff of the modified file(s): --- bt_if.c 2001/04/17 15:45:28 1.8 +++ bt_if.c 2001/04/18 14:01:34 1.9 @@ -487,7 +487,7 @@ { int ret_val; =20 - syslog(LOG_INFO, "bt_force_msswitch_as_server : % d\n"), enable; + syslog(LOG_INFO, "bt_force_msswitch_as_server: %d\n", enable); #ifndef BT_USERSTACK=20 if ((ret_val =3D ioctl(bt_cfd, BTSETMSSWITCH, &enable)) !=3D 0) { |
From: Mattias A. <mat...@us...> - 2001-04-25 18:05:52
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.10 1.11=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * use inpars when setting write scan enable The diff of the modified file(s): --- bt_if.c 2001/04/20 15:29:21 1.10 +++ bt_if.c 2001/04/25 18:05:52 1.11 @@ -502,7 +502,6 @@ 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) @@ -656,19 +655,16 @@ #endif } =20 -/* fixme<3> - get flags from somewhere */ int bt_write_scan_enable(int bt_cfd, unsigned int flags) { - unsigned int wrscan =3D (PAGE_SCAN_ENABLE | INQUIRY_SCAN_ENABLE); int result; -=20=20 - syslog(LOG_INFO, "Setting write_scan_enable [0x%x]", wrscan); + syslog(LOG_INFO, "Setting write_scan_enable [0x%x]\n", flags); =20 #ifdef BT_USERSTACK - result =3D hci_write_scan_enable(wrscan); + result =3D hci_write_scan_enable(flags); #else =20 - if ((result =3D ioctl(bt_cfd, HCIWRITESCANENABLE, &wrscan)) < 0) + if ((result =3D ioctl(bt_cfd, HCIWRITESCANENABLE, &flags)) < 0) {=20 perror(__FUNCTION__); exit(1); @@ -727,6 +723,8 @@ #endif return result; } + + =20 void bt_set_classofdevice(int bt_cfd, unsigned short service_class, |
From: Mattias A. <mat...@us...> - 2001-04-26 10:52:31
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.11 1.12=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * now use inparam in bt_set_event_filter The diff of the modified file(s): --- bt_if.c 2001/04/25 18:05:52 1.11 +++ bt_if.c 2001/04/26 10:52:30 1.12 @@ -698,24 +698,18 @@ #endif } =20 -/* fixme<3> get filter from somewhere */ -int bt_set_event_filter(int bt_cfd, unsigned int filter) +int bt_set_event_filter(int bt_cfd, unsigned char filter[3]) { - unsigned char evfilter[3]; int result; =20 - evfilter[0] =3D 0x02; /* Connection setup */ - evfilter[1] =3D 0x00; /* All devices */ - evfilter[2] =3D 0x01; /* No auto accept */=20=20 - syslog(LOG_INFO, "Setting event filter [0x%1x 0x%1x 0x%1x]\n",=20 - evfilter[0], evfilter[1], evfilter[2]); + filter[0], filter[1], filter[2]); =20 #ifdef BT_USERSTACK - result =3D hci_set_event_filter((u8*)&evfilter); + result =3D hci_set_event_filter((u8*)&filter); #else =20 - if ((result =3D ioctl(bt_cfd, HCISET_EVENT_FILTER, &evfilter)) < 0) + if ((result =3D ioctl(bt_cfd, HCISET_EVENT_FILTER, &filter)) < 0) {=20 perror(__FUNCTION__); exit(1); |
From: Peter K. <pk...@us...> - 2001-05-14 11:47:46
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.14 1.15=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Use bt_openctrl() to open the control device. The diff of the modified file(s): --- bt_if.c 2001/05/14 11:09:22 1.14 +++ bt_if.c 2001/05/14 11:47:45 1.15 @@ -138,7 +138,7 @@ #ifndef BT_USERSTACK char* bt_hw_vendor(void) { - int bt_cfd =3D open(BT_CTRL_TTY, O_RDWR | O_NOCTTY); + int bt_cfd =3D bt_openctrl(); static char buffer[20]; =20 if (bt_cfd < 0 || ioctl(bt_cfd, BTHWVENDOR, buffer) < 0) @@ -157,7 +157,7 @@ int devfd; =20 printf("Resetting HW board...\n"); - if ((devfd =3D open(BT_CTRL_TTY, O_RDWR | O_NOCTTY)) >=3D 0) + if ((devfd =3D bt_openctrl()) >=3D 0) { if (ioctl(devfd, BTRESETPHYSICALHW) < 0) { @@ -172,7 +172,7 @@ } else { - fprintf(stderr, "ERROR! Failed to open " BT_CTRL_TTY "\n"); + fprintf(stderr, "ERROR! Failed to open BT control device\n"); } #else printf("Please reset HW board within 5 seconds\n"); @@ -183,14 +183,14 @@ int bt_openctrl(void) { int bt_cfd; - D(syslog(LOG_INFO, "Now opening BT Ctrl TTY [%s]\n", BT_CTRL_TTY)); + D(syslog(LOG_INFO, "Now opening BT Ctrl TTY [" BT_CTRL_TTY "]")); #ifdef BT_USERSTACK printf(__FUNCTION__ ": ignored in userstack\n"); return FD_BTUSERCTRL; #else=20 if ((bt_cfd =3D open(BT_CTRL_TTY, O_RDWR | O_NOCTTY)) < 0) { - fprintf(stderr, "could not open %s\n", BT_CTRL_TTY); + fprintf(stderr, "Could not open " BT_CTRL_TTY "\n"); exit(1); } #endif |
From: Mattias A. <mat...@us...> - 2001-06-11 10:53:34
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.17 1.18=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * added debug The diff of the modified file(s): --- bt_if.c 2001/06/08 09:55:47 1.17 +++ bt_if.c 2001/06/11 10:53:32 1.18 @@ -686,6 +686,10 @@ { /* improves reliability when doing a connect */ =20 + syslog(LOG_INFO, "Setting write_pagescan_activity: int:0x%x wind:0x%x",= =20 + interval, wind); + + #ifdef BT_USERSTACK hci_write_pagescan_activity(interval, wind); #else |
From: Mattias A. <mat...@us...> - 2001-06-13 12:26:05
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.18 1.19=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * added return value in init_stack() The diff of the modified file(s): --- bt_if.c 2001/06/11 10:53:32 1.18 +++ bt_if.c 2001/06/13 12:26:05 1.19 @@ -70,19 +70,21 @@ /* 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 -void init_stack(int bt_cfd, int spd) +int init_stack(int bt_cfd, int spd) { + int ret; syslog(LOG_INFO, "Init stack"); =20 #ifdef BT_USERSTACK init_userstack(); #else /* Kernel mode stack */ =20=20=20 - if (ioctl(bt_cfd, BTINITSTACK) < 0) + if((ret =3D ioctl(bt_cfd, BTINITSTACK)) < 0) { - perror(__FUNCTION__); - exit(1); + shutdown_stack(bt_cfd); + return ret; } +=20=20 #endif =20 /* fixme<3> -- read these parameters from config file ? */ @@ -91,6 +93,8 @@ #ifndef __CRIS__ set_local_hostname(bt_cfd, "AXIS"); #endif +=20=20 + return ret; } =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 */ |
From: Peter K. <pk...@us...> - 2001-06-19 10:36:45
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.20 1.21=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added bt_firmware_info(). The diff of the modified file(s): --- bt_if.c 2001/06/15 12:36:25 1.20 +++ bt_if.c 2001/06/19 10:36:45 1.21 @@ -155,6 +155,24 @@ } #endif =20 +char* bt_firmware_info(void) +{ +#ifndef BT_USERSTACK + int bt_cfd =3D bt_openctrl(); + static char buffer[80]; + + if (bt_cfd < 0 || ioctl(bt_cfd, BTFIRMWAREINFO, buffer) < 0) + { + perror(__FUNCTION__); + return NULL; + } + close(bt_cfd); + return buffer; +#else + return bt_hw_firmware(); +#endif +} + void reset_hw(void) { #ifdef __CRIS__ |
From: Olov H. <ol...@us...> - 2001-07-10 13:01:02
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.21 1.22=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added support for max number of BT connections The diff of the modified file(s): --- bt_if.c 2001/06/19 10:36:45 1.21 +++ bt_if.c 2001/07/10 13:01:02 1.22 @@ -542,6 +542,22 @@ return ret_val; } =20 +int bt_set_max_conections(int bt_cfd, int connections) +{ + int ret_val; + + syslog(LOG_INFO, __FUNCTION__ ": %d", connections); +#ifndef BT_USERSTACK=20 + if ((ret_val =3D ioctl(bt_cfd, BTSETMAXCONNECTIONS, &connections)) < 0) + { + fprintf(stderr, __FUNCTION__ ": %s\n", error_msg(ret_val)); + } +#else + printf(__FUNCTION__": not implemented in userstack mode!\n" +#endif + return ret_val; +} + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=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 functions */ =20 |
From: Mattias A. <mat...@us...> - 2001-08-01 09:37:47
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.24 1.25=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * added bt_read_country_code * fixed bt_showstatus for non userstack The diff of the modified file(s): --- bt_if.c 2001/07/30 10:18:42 1.24 +++ bt_if.c 2001/08/01 09:37:46 1.25 @@ -319,8 +319,7 @@ tmp[len] =3D 0; printf(tmp); #else - /*FIXME -- read /proc/bt_internal and print it on the console */ - fprintf(stderr, __FUNCTION__ ": not yet implemented...\n"); + system("cat /proc/bt_internal"); #endif=20 } =20 @@ -939,6 +938,19 @@ } #else hci_change_local_name(buffer); +#endif +} + +int bt_read_country_code(int bt_cfd, unsigned char *result) +{ +#ifndef BT_USERSTACK=20=20 + if (ioctl(bt_cfd, HCIREADCOUNTRYCODE, result) < 0) + { + perror(__FUNCTION__); + exit(1); + } +#else + return hci_read_country_code(); #endif } =20 |
From: Anders J. <and...@us...> - 2001-08-01 10:26:18
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.25 1.26=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * Made bt_testcmd work with userstack. The diff of the modified file(s): --- bt_if.c 2001/08/01 09:37:46 1.25 +++ bt_if.c 2001/08/01 10:26:17 1.26 @@ -527,7 +527,7 @@ else printf("Success!\n"); #else - fprintf(stderr, __FUNCTION__ ": not yet implemented...\n"); + test_process_cmd(&tmp[1], tmp[0]); #endif return ret_val; } |
From: Mattias A. <mat...@us...> - 2001-08-02 13:03:01
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.26 1.27=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * removed some debug The diff of the modified file(s): --- bt_if.c 2001/08/01 10:26:17 1.26 +++ bt_if.c 2001/08/02 13:02:40 1.27 @@ -512,20 +512,17 @@ int ret_val =3D 0; unsigned char len =3D strlen(cmd); unsigned char tmp[261]; - syslog(LOG_INFO, "bt_testcmd : len %d", len); - syslog(LOG_INFO, "cmddata:_%s_", cmd); + tmp[0]=3D len; memcpy(tmp+1, cmd, len+1); /* don't forget nullterminate... */ =20=20=20=20=20 - print_data("usermode data :", tmp, len+2); + //printf("bt_testcmd : [%d] '%s'", len, cmd); =20 #ifndef BT_USERSTACK=20 if ((ret_val =3D ioctl(bt_cfd, BTTESTCOMMAND, tmp)) < 0) { printf("Error : %s\n", error_msg(ret_val)); } - else - printf("Success!\n"); #else test_process_cmd(&tmp[1], tmp[0]); #endif |
From: Mattias A. <mat...@us...> - 2001-08-22 17:49:57
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.28 1.29=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * added missing return The diff of the modified file(s): --- bt_if.c 2001/08/17 09:23:25 1.28 +++ bt_if.c 2001/08/22 17:49:56 1.29 @@ -517,8 +517,6 @@ tmp[0]=3D len; memcpy(tmp+1, cmd, len+1); /* don't forget nullterminate... */ =20 - //printf("bt_testcmd : [%d] '%s'", len, cmd); -=20=20=20=20 #ifndef BT_USERSTACK=20 if ((ret_val =3D ioctl(bt_cfd, BTTESTCOMMAND, tmp)) < 0) { @@ -947,6 +945,7 @@ perror(__FUNCTION__); exit(1); } + return result; #else return hci_read_country_code(); #endif |
From: Peter K. <pk...@us...> - 2001-09-10 11:59:55
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.33 1.34=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Made bt_set_max_conections() return -1 if it failed. The diff of the modified file(s): --- bt_if.c 2001/09/07 12:53:50 1.33 +++ bt_if.c 2001/09/10 11:59:54 1.34 @@ -621,36 +621,45 @@ =20 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)) < 0) + if (ioctl(bt_cfd, BTSETMSSWITCH, &enable) < 0) { - fprintf(stderr, __FUNCTION__ ": %s\n", error_msg(ret_val)); + perror(__FUNCTION__); + return -1; } #else hci_force_msswitch(enable); #endif - return ret_val; + return 0; } =20 int bt_set_max_conections(int bt_cfd, int connections) { - int ret_val; - syslog(LOG_INFO, __FUNCTION__ ": %d", connections); #ifndef BT_USERSTACK=20 - if ((ret_val =3D ioctl(bt_cfd, BTSETMAXCONNECTIONS, &connections)) < 0) + if (ioctl(bt_cfd, BTSETMAXCONNECTIONS, &connections) < 0) { - fprintf(stderr, __FUNCTION__ ": %s\n", error_msg(ret_val)); + perror(__FUNCTION__); + return -1; } + + return 0; #else - printf(__FUNCTION__": not implemented in userstack mode!\n" -#endif + { + int ret_val =3D hci_set_max_connections(connections); + + if (ret_val >=3D 0) + { return ret_val; } =20 + errno =3D -ret_val; + return -1; + } +#endif +} + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=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 functions */ =20 |
From: Peter K. <pk...@us...> - 2001-10-04 13:22:16
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.35 1.36=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: No need to shutdown the stack in init_stack() if it fails, since it is already shutdown. The diff of the modified file(s): --- bt_if.c 2001/10/03 17:34:17 1.35 +++ bt_if.c 2001/10/04 13:22:15 1.36 @@ -72,15 +72,12 @@ =20 int init_stack(int bt_cfd) { - int ret =3D 0; - syslog(LOG_INFO, "Init stack"); =20 #ifndef BT_USERSTACK - if ((ret =3D ioctl(bt_cfd, BTINITSTACK)) < 0) + if (ioctl(bt_cfd, BTINITSTACK) < 0) { - shutdown_stack(bt_cfd); - return ret; + return -1; } #else init_userstack(); @@ -96,7 +93,7 @@ #endif } =20=20=20 - return ret; + 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 */ @@ -727,7 +724,7 @@ int result; unsigned long spd =3D speedstrtoli(speedstr); =20 - syslog(LOG_INFO, __FUNCTION__ ": %d baud", spd); + syslog(LOG_INFO, __FUNCTION__ ": %lu baud", spd); #ifdef BT_USERSTACK tcflush(phys_fd, TCIOFLUSH); result =3D hci_set_baudrate(spd); |
From: Peter K. <pk...@us...> - 2001-10-12 14:56:43
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.38 1.39=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Free allocated memory in bt_inquiry() (thanks to Andreas Petralia). The diff of the modified file(s): --- bt_if.c 2001/10/12 12:01:16 1.38 +++ bt_if.c 2001/10/12 14:56:41 1.39 @@ -680,7 +680,11 @@ int i; inquiry_results *inq_res; =20 - inq_res =3D (inquiry_results*) malloc(sizeof(inquiry_results) + nbr_rsp = * 6); + if (!(inq_res =3D malloc(sizeof *inq_res + nbr_rsp * 6))) + { + fprintf(stderr, __FUNCTION__ ": Failed to allocate result structure!\n= "); + } + inq_res->nbr_of_units =3D nbr_rsp; inq_res->inq_time =3D t; =20 @@ -697,6 +701,8 @@ 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]); } + + free(inq_res); #endif } =20 |
From: Anders J. <and...@us...> - 2001-10-16 16:37:52
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.40 1.41=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * bt_testcmd should now return correct errorcodes. * bt_isconnected accepts -1 as filedescriptor and will then open the=20 controltty to allow the ioctl to be sent. The diff of the modified file(s): --- bt_if.c 2001/10/15 08:48:53 1.40 +++ bt_if.c 2001/10/16 16:15:34 1.41 @@ -328,11 +328,12 @@ } =20 /* Check whether this line is lower connected in stack (rfcomm ready) */ -int bt_isconnected(int bt_fd, int line) +int bt_isconnected(int bt_cfd, int line) { + int fd =3D (bt_cfd < 0 ? bt_openctrl() : bt_cfd); int ret; #ifndef BT_USERSTACK - if ((ret =3D ioctl(bt_fd, BTISLOWERCONNECTED, &line)) < 0) + if (fd < 0 || (ret =3D ioctl(fd, BTISLOWERCONNECTED, &line)) < 0) { perror(__FUNCTION__); exit(1); @@ -341,6 +342,10 @@ fprintf(stderr, __FUNCTION__ ": not yet implemented...\n"); ret =3D -1; #endif + if (bt_cfd < 0) + { + close(fd); + } return ret; } =20 @@ -613,7 +618,7 @@ else printf("Success!\n"); #else - test_process_cmd(&tmp[1], tmp[0]); + ret_val =3D test_process_cmd(&tmp[1], tmp[0]); #endif return ret_val; } |
From: Peter K. <pk...@us...> - 2002-02-26 18:09:00
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.42 1.43=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Removed a couple of extraneous & (address dereferences) which amongst others caused bt_set_event_filter() to not function properly (actually it did not work at all). The diff of the modified file(s): --- bt_if.c 26 Feb 2002 17:43:32 -0000 1.42 +++ bt_if.c 26 Feb 2002 18:08:59 -0000 1.43 @@ -587,7 +587,7 @@ msg[7] =3D (unsigned char)(type & 0xff); =20 #ifndef BT_USERSTACK=20 - if ((ret_val =3D ioctl(bt_cfd, BTGETINFO, &msg)) < 0) + if ((ret_val =3D ioctl(bt_cfd, BTGETINFO, msg)) < 0) { printf("Error : [%s (%d)]\n", error_msg(ret_val), MSG_GET_CODE(-ret_va= l)); } @@ -854,7 +854,7 @@ tmp[0] =3D interval; tmp[1] =3D wind; =20 - if (ioctl(bt_cfd, HCIWRITEPAGESCANACTIVITY, &tmp) < 0) + if (ioctl(bt_cfd, HCIWRITEPAGESCANACTIVITY, tmp) < 0) {=20 perror(__FUNCTION__); exit(1); @@ -871,10 +871,10 @@ filter[0], filter[1], filter[2]); =20 #ifdef BT_USERSTACK - result =3D hci_set_event_filter((u8*)&filter); + result =3D hci_set_event_filter((u8*)filter); #else =20 - if ((result =3D ioctl(bt_cfd, HCISET_EVENT_FILTER, &filter)) < 0) + if ((result =3D ioctl(bt_cfd, HCISET_EVENT_FILTER, filter)) < 0) {=20 perror(__FUNCTION__); exit(1); |
From: Willy S. <sag...@us...> - 2002-04-08 16:43:57
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- bt_if.c 1.44 1.45=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added new commands The diff of the modified file(s): --- bt_if.c 28 Feb 2002 20:08:31 -0000 1.44 +++ bt_if.c 8 Apr 2002 11:20:31 -0000 1.45 @@ -665,9 +665,313 @@ } =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 */ +/* BNEP functions */ + + +void +bnep_connect(int bt_fd, unsigned char *bd) +{ + unsigned int result; +=20=20=20=20=20=20=20=20=20=20 +#ifndef BTD_USERSTACK + result =3D ioctl(bt_fd, BNEPCONNECT, bd); + if (result&0x0ff) + printf("Connect failed [%s ((0x%X))]\n", error_msg(result&0x0ff), resu= lt); + else { + printf("Connected on con_hdl =3D %.2X:%.2X\n", bd[0], bd[1]); + printf("BNEP Interface =3D 0x%X\n", bd[2]); + } +#else + {=20=20 + printf("Unsupported in usermode\n"); + } +#endif +} +=20 +void +bnep_disconnect(int bt_fd, unsigned char *bd) +{ + int result; +=20=20=20=20=20=20=20=20 + #ifndef BTD_USERSTACK + result =3D ioctl(bt_fd, BNEPDISCONNECT, bd); + if (result)=20 + printf("Disconnect failed [%s ((0x%X))]\n", error_msg(resul= t&0x0ff), result&0x0ff); + else=20 + printf("Disconnect OK\n"); +#else + {=20=20 + printf("Unsupported in usermode\n"); + } +#endif +} + + + +/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=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 functions */ =20 =20 +void +bt_read_rssi(int bt_cfd, unsigned char* con_hdl) +{ + +#ifndef BTD_USERSTACK=20 + if (ioctl(bt_cfd, HCIREADRSSI, con_hdl) < 0) + { + perror("read_rssi"); + } + else + { + if (con_hdl[1] =3D=3D 2) + printf("RSSI level =3D 0x%X\n", con_hdl[0]); + else + printf("Not valid RSSI value !!!\n"); + } +#else + {=20=20 + printf("Unsupported in usermode\n"); + } +#endif +} + +void +bt_park_mode(int bt_cfd, unsigned char* park_params) +{ + +#ifndef BTD_USERSTACK=20 + if (ioctl(bt_cfd, HCIPARKMODE, park_params) < 0) + { + perror("park_mode"); + } +#else + {=20=20 + printf("Unsupported in usermode\n"); + } +#endif +} + +void +bt_exit_park_mode(int bt_cfd, unsigned char* con_hdl) +{ + +#ifndef BTD_USERSTACK=20 + if (ioctl(bt_cfd, HCIEXITPARKMODE, con_hdl) < 0) + { + perror("exit_park_mode"); + } +#else + {=20=20 + printf("Unsupported in usermode\n"); + } +#endif +} + +void +bt_sniff_mode(int bt_cfd, unsigned char* sniff_params) +{ + +#ifndef BTD_USERSTACK=20 + if (ioctl(bt_cfd, HCISNIFFMODE, sniff_params) < 0) + { + perror("sniff_mode"); + } +#else + {=20=20 + printf("Unsupported in usermode\n"); + } +#endif +} + +void +bt_exit_sniff_mode(int bt_cfd, unsigned char* con_hdl) +{ + +#ifndef BTD_USERSTACK=20 + if (ioctl(bt_cfd, HCIEXITSNIFFMODE, con_hdl) < 0) + { + perror("exit_sniff_mode"); + } +#else + {=20=20 + printf("Unsupported in usermode\n"); + } +#endif +} + +void=20 +bt_hold_mode(int bt_cfd, unsigned char* hold_params) +{ +#ifndef BTD_USERSTACK=20 + if (ioctl(bt_cfd, HCIHOLDMODE, hold_params) < 0) + { + perror("hold mode"); + } +#else + {=20=20 + printf("Unsupported in usermode\n"); + } +#endif +} + +void +bt_write_link_policy_settings(int bt_cfd, unsigned char* policy_params) +{ + +#ifndef BTD_USERSTACK=20 + if (ioctl(bt_cfd, HCIWRITELINKPOLICYSETTINGS, policy_params) < 0) + { + perror("write_link_policy_settings"); + } +#else + {=20=20 + printf("Unsupported in usermode\n"); + } +#endif +} + + +void +bt_read_clock_offset(int bt_cfd, unsigned char* con_hdl) +{ + +#ifndef BTD_USERSTACK=20 + if (ioctl(bt_cfd, HCIREADCLOCKOFFSET, con_hdl) < 0) + { + perror("read_rssi"); + } + else + { + if ((char)con_hdl[2] >=3D 0) + printf("CLOCK OFFSET =3D 0x%X%X\n", con_hdl[1], con_hdl[0]); + else + printf("Not valid CLOCK OFFSET value !!!\n"); + } +#else + {=20=20 + printf("Unsupported in usermode\n"); + } +#endif +} + +void +bt_read_num_broadcast_rtx(int bt_cfd) +{ + unsigned char num_rtx[2]; + +#ifndef BTD_USERSTACK=20 + if (ioctl(bt_cfd, HCIREADNUMBROADCASTRETRANSMISSIONS, num_rtx) < 0) + { + perror("read_num_broadcast_rtx"); + } + else + { + if ( (char)num_rtx[1] >=3D 0 ) + printf("read num broadcast rtx =3D 0x%X\n", num_rtx[0]); + else + printf("Not valid BROADCAST RTX value =3D 0x%X !!!\n",num_rtx[1]); + } +#else + {=20=20 + printf("Unsupported in usermode\n"); + } +#endif +} + +void +bt_write_num_broadcast_rtx(int bt_cfd, unsigned char* num_rtx) +{ + +#ifndef BTD_USERSTACK=20 + if (ioctl(bt_cfd, HCIWRITENUMBROADCASTRETRANSMISSIONS, num_rtx) < 0) + { + perror("write_num_broadcast_rtx"); + } +#else + {=20=20 + printf("Unsupported in usermode\n"); + } +#endif +} + +void +bt_write_page_to(int bt_cfd, unsigned char* page_to) +{ + +#ifndef BTD_USERSTACK=20 + if (ioctl(bt_cfd, HCIWRITEPAGETO, page_to) < 0) + { + perror("write_page_to"); + } +#else + {=20=20 + printf("Unsupported in usermode\n"); + } +#endif +} + +void +bt_read_tx_power_level(int bt_cfd, unsigned char* tx_power_level) +{ + +#ifndef BTD_USERSTACK=20 + if (ioctl(bt_cfd, HCIREADTRANSMITPOWERLEVEL, tx_power_level) < 0) + { + perror("read_tx_power_level"); + } + else + { + if ( (char)tx_power_level[1] =3D=3D 1 ) + printf("read tx power level =3D 0x%X\n", tx_power_level[0]); + else + printf("Not valid TX POWER LEVEL value !!!\n"); + } +#else + {=20=20 + printf("Unsupported in usermode\n"); + } +#endif +} + +void +bt_write_link_supervision_to(int bt_cfd, unsigned char* link_to) +{ + +#ifndef BTD_USERSTACK=20 + if (ioctl(bt_cfd, HCIWRITELINKSUPERVISIONTO, link_to) < 0) + { + perror("link_supervision_to"); + } +#else + {=20=20 + printf("Unsupported in usermode\n"); + } +#endif +} + + + + +void +bt_write_page_scan_activity(int bt_cfd, unsigned char* page_scan) +{ + +#ifndef BTD_USERSTACK=20 + printf("Setting write_pagescan_activity: p_s_int =3D 0x%X%X p_s_win= =3D 0x%X +%X\n",page_scan[0]&0x0FF, page_scan[1]&0x0FF, page_scan[4]&0x0FF, page_sca= n[5]&0x0FF); +=20=20 + if (ioctl(bt_cfd, HCIWRITEPAGESCANACTIVITY, page_scan) < 0) + {=20 + perror("write_page_scan_activity"); + } +#else + {=20=20 + printf("Unsupported in usermode\n"); + } +#endif +} + + int bt_inquiry(int bt_cfd, int nbr_rsp, int t) { @@ -756,6 +1060,10 @@ return result; } =20 + + + + void read_local_bd(int bt_cfd, unsigned char *bd_addr) { @@ -1529,3 +1837,8 @@ return bt_initdone; } #endif /* BT_USERSTACK */ + + + + + |
From: Alain P. <apa...@us...> - 2002-06-03 15:31:25
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- bt_if.c 1.47 1.48=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Juste correct an error making that with a custom name, the hostname was added at the end. The diff of the modified file(s): --- bt_if.c 3 Jun 2002 10:07:28 -0000 1.47 +++ bt_if.c 3 Jun 2002 15:31:22 -0000 1.48 @@ -1360,6 +1360,8 @@ } } =20 + if (add_host) + { gethostname(&buf[len], HOST_NAME_LENGTH); =20 if (!strchr(&buf[len], '.')) @@ -1372,7 +1374,7 @@ strncat(buf, domain_name, DOMAIN_NAME_LENGTH); } } - + } if (len && add_host) { strcat(buf, ")"); |
From: Peter K. <pk...@us...> - 2002-06-17 13:48:02
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- bt_if.c 1.48 1.49=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Corrected set_local_hostname() so it does not hang if unprintable characters are passed in local_name. The diff of the modified file(s): --- bt_if.c 3 Jun 2002 15:31:22 -0000 1.48 +++ bt_if.c 17 Jun 2002 13:47:58 -0000 1.49 @@ -51,6 +51,7 @@ #include <termios.h> #include <stdlib.h> #include <string.h> +#include <ctype.h> #include <syslog.h> #include <errno.h> #include <stdarg.h> @@ -1342,14 +1343,15 @@ =20 *buf =3D '\0'; =20 - if (*local_name) + if (local_name && *local_name) { while (*local_name && len < LOCAL_NAME_LENGTH) { - if (*local_name >=3D ' ' && *local_name <=3D 'z') + if (isprint(*local_name)) { - buf[len++] =3D *local_name++; + buf[len++] =3D *local_name; } + local_name++; } =20=20 if (len && add_host) @@ -1375,13 +1377,13 @@ } } } + if (len && add_host) { strcat(buf, ")"); } =20 bt_set_local_name(bt_cfd, buf); - } =20 void bt_set_local_name(int bt_cfd, const unsigned char *name) |