From: Peter K. <pk...@us...> - 2001-09-07 12:53:50
|
The following files were modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.32 1.33=20=20=20=20=20=20=20=20=20=20=20=20 bt_if.h 1.22 1.23=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added BCSP DFU support. The diff of the modified file(s): --- bt_if.c 2001/09/07 12:47:09 1.32 +++ bt_if.c 2001/09/07 12:53:50 1.33 @@ -86,12 +86,15 @@ init_userstack(); #endif =20 + if (!bt_dfu_mode(bt_cfd, -1)) + { /* fixme<3> -- read these parameters from config file ? */ bt_set_classofdevice(bt_cfd, 0x10, 0x3, 0x0, 0x0); =20 #ifndef __CRIS__ set_local_hostname(bt_cfd, "AXIS"); #endif + } =20=20=20 return ret; } @@ -195,6 +198,22 @@ #endif } =20 +int +bt_dfu_mode(int bt_cfd, int enable) +{ +#ifndef BT_USERSTACK + if (ioctl(bt_cfd, BT_SET_DFU_MODE, &enable) < 0) + { + perror(__FUNCTION__); + exit(1); + } + + return enable; +#else + return 0; +#endif +} + void reset_hw(void) { #ifdef __CRIS__ @@ -476,6 +495,59 @@ //hci_send_raw_data(data, 16); #endif return 0; +} + +int +bt_send_dfu_command(int bt_cfd, int len, unsigned char *data) +{ + static unsigned char buf[2048]; + + if (len > sizeof buf - sizeof(int)) + { + errno =3D EINVAL; + return -1; + } + + *(int *)buf =3D len; +=20=20 + memcpy((int *)buf+1, data, len); + +#ifndef BT_USERSTACK=20 + if (ioctl(bt_cfd, BT_SEND_DFU_COMMAND, buf) < 0) + { + perror(__FUNCTION__); + return -1; + } + + return 0; +#else + fprintf(stderr, __FUNCTION__ ": Not yet implemented...\n"); + errno =3D EPERM; + return -1; +#endif +} + +int +bt_retrieve_dfu_response(int bt_cfd, int len, unsigned char *data) +{ + *(int *)data =3D len - sizeof(int); + +#ifndef BT_USERSTACK=20 + if (ioctl(bt_cfd, BT_RETRIEVE_DFU_RESPONSE, data) < 0) + { + perror(__FUNCTION__); + return -1; + } + + len =3D *(int *)data; +=20=20 + memmove(data, (int *)data+1, len); + return len; +#else + fprintf(stderr, __FUNCTION__ ": Not yet implemented...\n"); + errno =3D EPERM; + return -1; +#endif } =20 int bt_ping(int bt_cfd, unsigned char bd[6],=20 --- bt_if.h 2001/09/07 12:47:09 1.22 +++ bt_if.h 2001/09/07 12:53:50 1.23 @@ -260,7 +260,11 @@ =20 #define BTINITBCSP _IO(BT_IOC_MAGIC, 0xf6) =20 -#define BTSETMAXCONNECTIONS _IOW(BT_IOC_MAGIC, 0xf7, unsigned char) +#define BT_SET_DFU_MODE _IOWR(BT_IOC_MAGIC, 0xf7, int) +#define BT_SEND_DFU_COMMAND _IOWR(BT_IOC_MAGIC, 0xf8, unsigned char[2048]) +#define BT_RETRIEVE_DFU_RESPONSE _IOWR(BT_IOC_MAGIC, 0xf9, unsigned char[2= 048]) + +#define BTSETMAXCONNECTIONS _IOW(BT_IOC_MAGIC, 0xfa, unsigned char) /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* Structs */ =20 @@ -301,6 +305,7 @@ #endif char* bt_firmware_info(void); int bt_bcsp_mode(int bt_cfd, int enable); +int bt_dfu_mode(int bt_cfd, int enable); void reset_hw(void); int bt_openctrl(void); void set_bt_line_disc(int phys_fd, int bt_disc, char* physdev); @@ -325,6 +330,8 @@ */ =20 int bt_send_raw_hci(int bt_cfd, unsigned char *data, char len); +int bt_send_dfu_command(int bt_cfd, int len, unsigned char *data); +int bt_retrieve_dfu_response(int bt_cfd, int len, unsigned char *data); int bt_ping(int bt_cfd, unsigned char bd[6],=20 unsigned char *data, unsigned short len); int bt_getinfo(int bt_cfd, unsigned char bd[6], unsigned short type); |