/* Sat Jun 11 02:27:36 EDT 2005 setbd-affix.c by kf_lists[at]digitalmunition[.]com Tool to Set Ericsson ROK 101 008 Bluetooth Address using Affix stack. frieza:/tmp# cc -o setbd-affix setbd-affix.c -laffix frieza:/tmp# ./setbd-affix 08:07:06:05:04:03 Using BD_ADDR from command line Setting BDA to 8:7:6:5:4:3 frieza:/tmp# btctl bt0 down frieza:/tmp# btctl bt0 up (sometimes this hangs) btctl: cmd_initdev: Unable to start device (bt0) frieza:/tmp# btctl bt0 up frieza:/tmp# btctl bt0 08:07:06:05:04:03 Flags: UP DISC CONN RX: acl:0 sco:0 event:46 bytes:363 errors:0 dropped:0 TX: acl:0 sco:0 cmd:48 bytes:1674 errors:0 dropped:0 Security: service pair [-auth, -encrypt] Packets: DM1 DH1 DM3 DH3 DM5 DH5 HV1 HV3 Role: deny switch, remain slave This was tested on PowerPC... the byte swapping my need to be fixed on intel */ #include #include #include int main(int argc, char *argv[]) { int devs[16], num, i, err, fd, val; char *bd_address; struct Command_Complete_Status ccs; HCI_Command_Packet_Header cmd; num = hci_get_devs(devs); if (num < 0) { printf("unable to get device list\n"); return -1; } if (num == 0) { printf("No Bluetooth Adapters found\n"); return 0; } fd = hci_open("bt0"); if (fd < 0) { printf("Unable to open device %s: %s\n", btdev); return -1; } if (argv[1] !=NULL) { printf("Using BD_ADDR from command line\n"); bd_address = argv[1]; } else { bd_address = "01:02:03:04:05:06"; } for (i = 5; i >= 0; i--) { err = sscanf(bd_address, "%2x", &val); if (err == 0) { return 0; } cmd.Data[i] = val; if (i == 0) { break; } bd_address = strchr(bd_address,':'); if (bd_address == 0) { return 0; } bd_address++; } printf("Setting BDA to %x:%x:%x:%x:%x:%x\n",cmd.Data[5],cmd.Data[4],cmd.Data[3],cmd.Data[2],cmd.Data[1],cmd.Data[0]); // Send new BD_ADDR to memory err = hci_exec_cmd(fd, 0xFC0D, &cmd, sizeof(cmd) + 6, COMMAND_COMPLETE_MASK, 0, &ccs, sizeof(ccs)); // Write new BD_ADDR to flash err = hci_exec_cmd0(fd, 0xFC22, COMMAND_COMPLETE_MASK, 0, &ccs, sizeof(ccs)); }