Changeset 146 for trunk

Show
Ignore:
Timestamp:
06/01/07 17:13:54 (18 months ago)
Author:
zany
Message:

adding hci selection support

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/apps/obexftp.c

    r143 r146  
    229229 
    230230/*@only@*/ /*@null@*/ static obexftp_client_t *cli = NULL; 
     231static const char *src_dev = NULL; 
    231232#ifdef HAVE_BLUETOOTH 
    232233static int transport = OBEX_TRANS_BLUETOOTH; 
     
    266267 
    267268                /* Connect */ 
    268                 if (obexftp_connect_uuid (cli, device, channel, uuid, uuid_len) >= 0) 
     269                if (obexftp_connect_src (cli, src_dev, device, channel, uuid, uuid_len) >= 0) 
    269270                        return TRUE; 
    270271                fprintf(stderr, "Still trying to connect\n"); 
     
    441442#ifdef HAVE_BLUETOOTH 
    442443                        {"bluetooth",   optional_argument, NULL, 'b'}, 
     444                        {"channel",     required_argument, NULL, 'B'}, 
     445                        {"hci",         required_argument, NULL, 'd'}, 
    443446#endif 
    444                         {"channel",     required_argument, NULL, 'B'}, 
    445447#ifdef HAVE_USB 
    446448                        {"usb",         optional_argument, NULL, 'u'}, 
     
    470472                }; 
    471473                 
    472                 c = getopt_long (argc, argv, "-ib::B:u::t:n:U::HSL::l::c:C:f:o:g:G:p:k:XYxm:VvhN:FP", 
     474                c = getopt_long (argc, argv, "-ib::B:d:u::t:n:U::HSL::l::c:C:f:o:g:G:p:k:XYxm:VvhN:FP", 
    473475                                 long_options, &option_index); 
    474476                if (c == -1) 
     
    499501                case 'B': 
    500502                        channel = atoi(optarg); 
     503                        break; 
     504                         
     505                case 'd': 
     506                        src_dev = optarg; 
    501507                        break; 
    502508#endif /* HAVE_BLUETOOTH */ 
     
    716722                                " -b, --bluetooth [<device>]  use or search a bluetooth device\n" 
    717723                                " [ -B, --channel <number> ]  use this bluetooth channel when connecting\n" 
     724                                " [ -d, --hci <no/address> ]  use source device with this address or number\n" 
    718725#endif 
    719726#ifdef HAVE_USB 
  • trunk/obexftp/client.c

    r142 r146  
    5353#include <bluetooth/bluetooth.h> 
    5454#include <bluetooth/rfcomm.h> 
     55#include <bluetooth/hci.h> 
     56#include <bluetooth/hci_lib.h> 
    5557#endif /* __FreeBSD__ */ 
    5658#endif 
     
    504506int obexftp_connect_uuid(obexftp_client_t *cli, const char *device, int port, const uint8_t uuid[], uint32_t uuid_len) 
    505507{ 
     508        return obexftp_connect_src(cli, NULL, device, port, uuid, uuid_len); 
     509} 
     510 
     511int obexftp_connect_src(obexftp_client_t *cli, const char *src, const char *device, int port, const uint8_t uuid[], uint32_t uuid_len) 
     512{ 
    506513        struct sockaddr_in peer; 
    507514#ifdef HAVE_BLUETOOTH 
    508515        char *devicedup, *devicep; 
    509         bdaddr_t bdaddr; 
     516        bdaddr_t bdaddr, src_addr; 
     517        int hci_id; 
    510518#endif 
    511519#ifdef HAVE_USB 
     
    558566#ifdef HAVE_BLUETOOTH 
    559567        case OBEX_TRANS_BLUETOOTH: 
     568                if (!src) { 
     569                        bacpy(&src_addr, BDADDR_ANY); 
     570                } else { 
     571                        str2ba(src, &src_addr); 
     572                        hci_id = atoi(src); 
     573                        if (hci_id > 0) { 
     574                                hci_devba(hci_id, &src_addr);    
     575                        } 
     576                } 
    560577                if (!device) { 
    561578                        ret = -EINVAL; 
     
    572589                        if (*devicep == '/') *devicep = ':'; 
    573590                } 
    574                 (void) str2ba(devicedup, &bdaddr); /* what is the meaning of the return code? */ 
     591                (void) str2ba(devicedup, &bdaddr); 
    575592                free(devicedup); 
    576                 ret = BtOBEX_TransportConnect(cli->obexhandle, BDADDR_ANY, &bdaddr, (uint8_t)port); 
     593                ret = BtOBEX_TransportConnect(cli->obexhandle, &src_addr, &bdaddr, (uint8_t)port); 
    577594                DEBUG(3, "%s() BT %d\n", __func__, ret); 
    578595                break; 
  • trunk/obexftp/client.h

    r145 r146  
    139139                                int port, /* INET(?), BLUETOOTH, USB*/ 
    140140                                /*@null@*/ const uint8_t uuid[], uint32_t uuid_len); 
     141int obexftp_connect_src(obexftp_client_t *cli, 
     142                                /*@null@*/ const char *src, /* HCI no. or address */ 
     143                                /*@null@*/ const char *device, /* for INET, BLUETOOTH */ 
     144                                int port, /* INET(?), BLUETOOTH, USB*/ 
     145                                /*@null@*/ const uint8_t uuid[], uint32_t uuid_len); 
    141146 
    142147//int obexftp_connect_service(obexftp_client_t *cli,