1 --- bluez-utils-3.1/tools/hciattach.c.orig 2006-07-23 14:02:14.000000000 +0200
2 +++ bluez-utils-3.1/tools/hciattach.c 2006-07-23 14:06:29.000000000 +0200
4 #define HCI_UART_3WIRE 2
5 #define HCI_UART_H4DS 3
15 int (*init) (int fd, struct uart_t *u, struct termios *ti);
16 + char *bts; /* bluetooth script */
19 #define FLOW_CTL 0x0001
24 +static int brf6150(int fd, struct uart_t *u, struct termios *ti)
29 + unsigned char actionbuf[256];
30 + unsigned char resp[128]; /* Response */
31 + unsigned long count;
32 + unsigned short atype;
34 + if (u->bts == NULL) /* no script, ignore */
37 + bfp = bts_load_script( u->bts, &vers );
41 + fprintf( stderr, "Loading BTS script version %lu\n", vers );
43 + while ((count = bts_next_action( bfp, actionbuf,
44 + sizeof actionbuf - 1, &atype )) != 0) {
45 + if (atype == ACTION_REMARKS) {
46 + if (actionbuf[0] != 0)
47 + fprintf( stderr, "%s\n", actionbuf );
49 + else if (atype == ACTION_SEND_COMMAND) {
51 + fprintf( stderr, "ACTION_SEND_COMMAND: ", (int)atype );
52 + for (i=0; i<count; i++) {
53 + fprintf( stderr, "0x%02x ", actionbuf[i] );
55 + fprintf( stderr, "\n" );
58 + n = write(fd, actionbuf, count);
59 + if (n < 0 || n < count) {
60 + perror("Failed to write TI action command");
64 + else if (atype == ACTION_WAIT_EVENT) {
65 + action_wait_t *wait = (action_wait_t *)actionbuf;
67 + fprintf( stderr, "ACTION_WAIT_EVENT: %u msec, %u size, data = ", wait->msec, wait->size );
68 + for (i=0; i<wait->size; i++) {
69 + fprintf( stderr, "0x%02x ", wait->data[i] );
71 + fprintf( stderr, "\n" );
73 + usleep(wait->msec); /* seems they give usec, not msec */
75 + if ((count = read_hci_event(fd, resp, sizeof resp)) < 0) {
76 + perror("Failed to read TI command response");
79 + if (count < wait->size) {
80 + fprintf( stderr, "TI command response is short.");
82 + for (i=0; i<wait->size; i++) {
83 + if (i == 3) continue; /* ignore */
84 + if (resp[i] != wait->data[i]) {
85 + fprintf( stderr, "TI command response does not match expected result.\n" );
89 + else if (atype == ACTION_SERIAL_PORT_PARAMETERS) {
90 + action_serial_t *sercmd = (action_serial_t *)actionbuf;
92 + /* Set actual baudrate */
94 + "BTS changing baud rate to %u, flow control to %u\n",
95 + sercmd->baud, sercmd->flow_control );
97 + tcflush(fd, TCIOFLUSH);
99 + if (sercmd->flow_control)
100 + ti->c_cflag |= CRTSCTS;
102 + ti->c_cflag &= ~CRTSCTS;
103 + if (tcsetattr(fd, TCSANOW, ti) < 0) {
104 + perror("Can't set port settings");
108 + u->speed = sercmd->baud;
110 + tcflush(fd, TCIOFLUSH);
111 + if (set_speed(fd, ti, sercmd->baud) < 0) {
112 + perror("Can't set baud rate");
116 + else if (atype == ACTION_DELAY) {
117 + action_delay_t *delay = (action_delay_t *)actionbuf;
118 + usleep(delay->msec); /* seems they give usec, not msec */
121 + fprintf( stderr, "BTS action type = %d: ", (int)atype );
122 + for (i=0; i<count; i++) {
123 + fprintf( stderr, "0x%02x ", actionbuf[i] );
125 + fprintf( stderr, "\n" );
128 + bts_unload_script( bfp );
132 static int texas(int fd, struct uart_t *u, struct termios *ti)
134 struct timespec tm = {0, 50000};
135 @@ -296,15 +407,26 @@
136 } while (resp[4] != cmd[1] && resp[5] != cmd[2]);
138 /* Verify manufacturer */
139 - if ((resp[11] & 0xFF) != 0x0d)
140 + if (resp[11] != 0x0d)
141 fprintf(stderr,"WARNING : module's manufacturer is not Texas Instrument\n");
143 /* Print LMP version */
144 - fprintf(stderr, "Texas module LMP version : 0x%02x\n", resp[10] & 0xFF);
145 + fprintf(stderr, "TI module LMP version : 0x%02x\n", resp[10]);
147 /* Print LMP subversion */
148 - fprintf(stderr, "Texas module LMP sub-version : 0x%02x%02x\n", resp[14] & 0xFF, resp[13] & 0xFF);
149 + fprintf(stderr, "TI module LMP sub-version : 0x%02x%02x\n", resp[14], resp[13]);
150 + if ((resp[14] >> 2) == 3) {
152 + nanosleep(&tm, NULL);
155 + if ((err=brf6150( fd, u, ti )) != 0) {
156 + fprintf( stderr, "TI script failed (err=%d)\n",
162 nanosleep(&tm, NULL);
165 @@ -1103,7 +1225,7 @@
167 printf("hciattach - HCI UART driver initialization utility\n");
169 - printf("\thciattach [-n] [-p] [-b] [-t timeout] [-s initial_speed] <tty> <type | id> [speed] [flow|noflow]\n");
170 + printf("\thciattach [-n] [-p] [-b] [-t timeout] [-s initial_speed] [-S bts-script] <tty> <type | id> [speed] [flow|noflow]\n");
171 printf("\thciattach -l\n");
174 @@ -1118,11 +1240,12 @@
183 - while ((opt=getopt(argc, argv, "bnpt:s:l")) != EOF) {
184 + while ((opt=getopt(argc, argv, "bnpt:s:S:l")) != EOF) {
188 @@ -1144,6 +1267,10 @@
189 init_speed = atoi(optarg);
197 for (i = 0; uart[i].type; i++) {
198 printf("%-10s0x%04x,0x%04x\n", uart[i].type,
199 @@ -1215,6 +1342,8 @@
201 u->init_speed = init_speed;
205 memset(&sa, 0, sizeof(sa));
206 sa.sa_flags = SA_NOCLDSTOP;
207 sa.sa_handler = sig_alarm;
208 --- bluez-utils-3.1/tools/Makefile.am.orig 2006-07-23 14:06:59.000000000 +0200
209 +++ bluez-utils-3.1/tools/Makefile.am 2006-07-23 14:07:18.000000000 +0200
212 noinst_PROGRAMS = hcisecfilter ppporc
214 -hciattach_SOURCES = hciattach.c hciattach_st.c
215 +hciattach_SOURCES = hciattach.c hciattach_st.c ti_bts.h ti_bts.c
217 hciconfig_SOURCES = hciconfig.c csr.h csr.c
218 hciconfig_LDADD = @BLUEZ_LIBS@ $(top_builddir)/common/libhelper.a
219 --- bluez-utils-3.1/tools/ti_bts.h.orig 2006-07-23 14:07:26.000000000 +0200
220 +++ bluez-utils-3.1/tools/ti_bts.h 2006-07-23 14:07:46.000000000 +0200
223 + * Copyright (c) 2005 Texas Instruments, Inc.
224 + * Ported by SDG Systems, LLC
226 + * This program is free software; you can redistribute it and/or modify
227 + * it under the terms of the GNU General Public License version 2 as
228 + * published by the Free Software Foundation;
230 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
231 + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
232 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
233 + * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
234 + * CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
235 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
236 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
237 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
239 + * ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
240 + * COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
241 + * SOFTWARE IS DISCLAIMED.
253 + * Define the interface of Bluetooth Script
259 +#define ACTION_SEND_COMMAND 1 /* Send out raw data (as is) */
260 +#define ACTION_WAIT_EVENT 2 /* Wait for data */
261 +#define ACTION_SERIAL_PORT_PARAMETERS 3
262 +#define ACTION_DELAY 4
263 +#define ACTION_RUN_SCRIPT 5
264 +#define ACTION_REMARKS 6
267 + * Structure for ACTION_SEND_COMMAND
269 +typedef struct tagCActionCommand
271 + unsigned char data[1]; /* Data to send */
275 + * Structure for ACTION_WAIT_EVENT
277 +typedef struct tagCActionWaitEvent
279 + unsigned long msec; /* in milliseconds */
280 + unsigned long size;
281 + unsigned char data[1]; /* Data to wait for */
286 + * Structure for ACTION_SERIAL_PORT_PARAMETERS
288 +typedef struct tagCActionSerialPortParameters
290 + unsigned long baud;
291 + unsigned long flow_control;
294 +/* Flow Control Type */
296 +#define FCT_HARDWARE 1
298 +#define DONT_CHANGE 0xFFFFFFFF /* For both baud rate and flow control */
302 + * Structure for ACTION_DELAY
304 +typedef struct tagCActionDelay
306 + unsigned long msec; /* in milliseconds */
310 + * Structure for ACTION_RUN_SCRIPT
312 +typedef struct tagCActionRunScript
318 + * Structure for ACTION_REMARKS
320 +typedef struct tagCActionRemarks
322 + char m_szRemarks[1];
326 +const char *cis_create_filename(const unsigned char* cmdparms);
327 +bts_t * bts_load_script(const char* fname, unsigned long* version);
328 +unsigned long bts_next_action(const bts_t* bts_fp, unsigned char* action_buf,
329 + unsigned long nMaxSize, unsigned short* ptype);
330 +void bts_unload_script(bts_t* bts_fp);
336 +#endif /* BT_SCRIPT_H */
338 --- bluez-utils-3.1/tools/ti_bts.c.orig 2006-07-23 14:07:28.000000000 +0200
339 +++ bluez-utils-3.1/tools/ti_bts.c 2006-07-23 14:07:46.000000000 +0200
342 + * Copyright (c) 2005 Texas Instruments, Inc.
343 + * Ported by SDG Systems, LLC
345 + * This program is free software; you can redistribute it and/or modify
346 + * it under the terms of the GNU General Public License version 2 as
347 + * published by the Free Software Foundation;
349 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
350 + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
351 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
352 + * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
353 + * CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
354 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
355 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
356 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
358 + * ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
359 + * COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
360 + * SOFTWARE IS DISCLAIMED.
370 +#define MAKEWORD(a, b) ((unsigned short)(((unsigned char)(a)) | ((unsigned short)((unsigned char)(b))) << 8))
373 +#define TI_MANUFACTURER_ID 13
376 + * Common Init Script specific
379 +cis_create_filename(const unsigned char* cmdparms)
381 + static char bts_file[50];
383 + /* Check for TI's id */
384 + unsigned short manfid = MAKEWORD(cmdparms[8], cmdparms[9]);
386 + if (TI_MANUFACTURER_ID == manfid) {
387 + unsigned short version = MAKEWORD(cmdparms[10], cmdparms[11]);
389 + unsigned short chip = (version & 0x7C00) >> 10;
390 + unsigned short min_ver = (version & 0x007F);
391 + unsigned short maj_ver = (version & 0x0380) >> 7;
393 + if (0 != (version & 0x8000)) {
397 + sprintf( bts_file, "TIInit_%d.%d.%d.bts",
398 + (int)chip, (int)maj_ver, (int)min_ver);
400 + return &bts_file[0];
405 +typedef struct tagCHeader
407 + unsigned long magic;
408 + unsigned long version;
409 + unsigned char future[24];
413 +/* The value 0x42535442 stands for (in ASCII) BTSB */
414 +/* which is Bluetooth Script Binary */
415 +#define FILE_HEADER_MAGIC 0x42535442
419 +bts_load_script(const char* fname, unsigned long* version)
422 + FILE* fp = fopen(fname, "rb");
429 + if (1 == fread(&header, sizeof(header), 1, fp)) {
430 + /* Check magic number for correctness */
431 + if (header.magic == FILE_HEADER_MAGIC) {
432 + /* If user wants the version number */
433 + if (NULL != version) {
434 + *version = header.version;
439 + /* If failed reading the file, close it */
448 +bts_next_action(const bts_t* bts_fp, unsigned char* action_buf,
449 + unsigned long nMaxSize, unsigned short* ptype)
451 + unsigned long bytes = 0;
452 + FILE* fp = (FILE*)bts_fp;
453 + unsigned char action_hdr[4];
455 + if (bts_fp == NULL)
458 + /* Each Action has the following: */
459 + /* UINT16 type of this action */
460 + /* UINT16 size of rest */
461 + /* BYTE[] action buffer (for HCI, includes the type byte e.g. 1 for hci command) */
463 + if (1 == fread(&action_hdr[0], sizeof(action_hdr), 1, fp)) {
464 + unsigned short type = *(unsigned short*)&action_hdr[0];
465 + unsigned short size = *(unsigned short*)&action_hdr[2];
467 + if (size <= nMaxSize) {
468 + int nread = fread(action_buf, sizeof(action_buf[0]), size, fp);
470 + if (nread == size) {
472 + bytes = (unsigned long)size;
481 +bts_unload_script(bts_t* bts_fp)
483 + FILE* fp = (FILE*)bts_fp;