~ubuntu-branches/ubuntu/wily/bluez/wily

« back to all changes in this revision

Viewing changes to tools/bccmd.c

ImportĀ upstreamĀ versionĀ 4.81

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *
3
3
 *  BlueZ - Bluetooth protocol stack for Linux
4
4
 *
5
 
 *  Copyright (C) 2004-2009  Marcel Holtmann <marcel@holtmann.org>
 
5
 *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
6
6
 *
7
7
 *
8
8
 *  This program is free software; you can redistribute it and/or modify
59
59
#define CSR_TYPE_ARRAY          CSR_TYPE_COMPLEX
60
60
#define CSR_TYPE_BDADDR         CSR_TYPE_COMPLEX
61
61
 
62
 
static inline int transport_open(int transport, char *device)
 
62
static inline int transport_open(int transport, char *device, speed_t bcsp_rate)
63
63
{
64
64
        switch (transport) {
65
65
        case CSR_TRANSPORT_HCI:
69
69
                return csr_open_usb(device);
70
70
#endif
71
71
        case CSR_TRANSPORT_BCSP:
72
 
                return csr_open_bcsp(device);
 
72
                return csr_open_bcsp(device, bcsp_rate);
73
73
        case CSR_TRANSPORT_H4:
74
74
                return csr_open_h4(device);
75
75
        case CSR_TRANSPORT_3WIRE:
984
984
                        str = NULL;
985
985
                }
986
986
 
987
 
                printf("// %s%s\n&%04x =", str ? "PSKEY_" : "", 
 
987
                printf("// %s%s\n&%04x =", str ? "PSKEY_" : "",
988
988
                                                str ? str : val, pskey);
989
989
                for (i = 0; i < length; i++)
990
990
                        printf(" %02x%02x", array[(i * 2) + 7], array[(i * 2) + 6]);
1109
1109
        printf("Options:\n"
1110
1110
                "\t-t <transport>     Select the transport\n"
1111
1111
                "\t-d <device>        Select the device\n"
 
1112
                "\t-b <bcsp rate>     Select the bcsp transfer rate\n"
1112
1113
                "\t-h, --help         Display help\n"
1113
1114
                "\n");
1114
1115
 
1137
1138
static struct option main_options[] = {
1138
1139
        { "transport",  1, 0, 't' },
1139
1140
        { "device",     1, 0, 'd' },
 
1141
        { "bcsprate", 1, 0, 'b'},
1140
1142
        { "help",       0, 0, 'h' },
1141
1143
        { 0, 0, 0, 0 }
1142
1144
};
1145
1147
{
1146
1148
        char *device = NULL;
1147
1149
        int i, err, opt, transport = CSR_TRANSPORT_HCI;
 
1150
        speed_t bcsp_rate = B38400;
1148
1151
 
1149
 
        while ((opt=getopt_long(argc, argv, "+t:d:i:h", main_options, NULL)) != EOF) {
 
1152
        while ((opt=getopt_long(argc, argv, "+t:d:i:b:h", main_options, NULL)) != EOF) {
1150
1153
                switch (opt) {
1151
1154
                case 't':
1152
1155
                        if (!strcasecmp(optarg, "hci"))
1171
1174
                case 'i':
1172
1175
                        device = strdup(optarg);
1173
1176
                        break;
1174
 
 
 
1177
                case 'b':
 
1178
                        switch (atoi(optarg)) {
 
1179
                        case 9600: bcsp_rate = B9600; break;
 
1180
                        case 19200: bcsp_rate = B19200; break;
 
1181
                        case 38400: bcsp_rate = B38400; break;
 
1182
                        case 57600: bcsp_rate = B57600; break;
 
1183
                        case 115200: bcsp_rate = B115200; break;
 
1184
                        case 230400: bcsp_rate = B230400; break;
 
1185
                        case 460800: bcsp_rate = B460800; break;
 
1186
                        case 500000: bcsp_rate = B500000; break;
 
1187
                        case 576000: bcsp_rate = B576000; break;
 
1188
                        case 921600: bcsp_rate = B921600; break;
 
1189
                        case 1000000: bcsp_rate = B1000000; break;
 
1190
                        case 1152000: bcsp_rate = B1152000; break;
 
1191
                        case 1500000: bcsp_rate = B1500000; break;
 
1192
                        case 2000000: bcsp_rate = B2000000; break;
 
1193
#ifdef B2500000
 
1194
                        case 2500000: bcsp_rate = B2500000; break;
 
1195
#endif
 
1196
#ifdef B3000000
 
1197
                        case 3000000: bcsp_rate = B3000000; break;
 
1198
#endif
 
1199
#ifdef B3500000
 
1200
                        case 3500000: bcsp_rate = B3500000; break;
 
1201
#endif
 
1202
#ifdef B4000000
 
1203
                        case 4000000: bcsp_rate = B4000000; break;
 
1204
#endif
 
1205
                        default:
 
1206
                                printf("Unknown BCSP baud rate specified, defaulting to 38400bps\n");
 
1207
                                bcsp_rate = B38400;
 
1208
                        }
 
1209
                        break;
1175
1210
                case 'h':
1176
1211
                default:
1177
1212
                        usage();
1188
1223
                exit(1);
1189
1224
        }
1190
1225
 
1191
 
        if (transport_open(transport, device) < 0)
 
1226
        if (transport_open(transport, device, bcsp_rate) < 0)
1192
1227
                exit(1);
1193
1228
 
1194
1229
        if (device)