libdrm: drop older versions
[openembedded.git] / recipes / bluez / bcm2035-tool / addr-as-arg.patch
blob28618c5bbb3d3252e0e21ef5bcd42a5b5e8aae32
1 --- bcm2035-tool/bcm2035-tool.c 2007/05/07 12:48:06 2000
2 +++ bcm2035-tool/bcm2035-tool.c 2007/05/07 12:55:47 2001
3 @@ -1,6 +1,8 @@
4 -/* bcm2035-tool - bcm2035 tool for Motorola EZX phones
5 +/* bcm2035-tool
7 * (C) 2007 by Daniel Ribeiro <drwyrm@gmail.com>
8 + *
9 + * MAC address as argument extension by: Jan Herman <2hp@seznam.cz>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2
13 @@ -17,10 +19,10 @@
17 +/* Default MAC address */
18 +#define BDADDR "\x06\x05\x04\x03\x02\x01"
20 //#define PATCH_FIRMWARE
21 -#define BDADDR "\xab\x89\x67\x45\x23\x01"
24 #include <stdio.h>
25 #include <string.h>
26 @@ -33,6 +35,7 @@
27 #include <sys/ioctl.h>
28 #include <termios.h>
29 #include "bcm2035-tool.h"
30 +//#include "bluetooth.h"
32 #ifdef PATCH_FIRMWARE
33 #include "motorola_patches.h"
34 @@ -180,18 +183,51 @@
38 +void mac2hex(const char *mac, u_char *dst)
41 + int i;
42 + long l;
43 + char *pp;
45 + while (isspace(*mac))
46 + mac++;
48 + /* expect 6 hex octets separated by ':' or space/NUL if last octet */
49 + for (i = 0; i < 6; i++) {
50 + l = strtol(mac, &pp, 16);
51 + if (pp == mac || l > 0xFF || l < 0)
52 + return;
53 + if (!(*pp == ':' || (i == 5 && (isspace(*pp) || *pp == '\0'))))
54 + return;
55 + /* 5-i swaps hex chars */
56 + dst[5-i] = (u_char) l;
57 + mac = pp + 1;
58 + }
59 + }
61 +char bdaddr[6];
63 int main(int argc, char **argv)
65 int fd, i;
66 struct termios term;
67 char buf[1024];
68 - char bdaddr[6];
70 - if (argc < 2) {
71 - printf("use: %s <device>\n", argv[0]);
73 + if (argc < 3) {
74 + printf("BCM2035 Tool:\n");
75 + printf("Usage: %s <device> <bdaddr>\n", argv[0]);
76 exit(1);
79 + if (strlen(argv[2]) < 17) {
80 + printf("invalid argument %s!\n", argv[2]);
81 + exit(1);
82 + }
84 + /* Converts MAC address to swapped HEX */
85 + mac2hex(argv[2], bdaddr);
87 fd = open (argv[1], O_RDWR | O_NOCTTY );
89 if(fd < 0) exit(-1);
90 @@ -212,7 +248,7 @@
91 #endif
92 set_baud(fd, 460800);
94 - send_cmd(fd, CMD_SET_BDADDR, BDADDR, 6);
95 + send_cmd(fd, CMD_SET_BDADDR, bdaddr, 6);
97 i = N_HCI;
98 if (ioctl(fd, TIOCSETD, &i) < 0) {
99 @@ -228,5 +264,3 @@
100 while (1) sleep(999999999);
101 return 0;