• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: OBEX question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OBEX question


  • Subject: Re: OBEX question
  • From: mat davidson <email@hidden>
  • Date: Fri, 27 May 2005 17:17:53 -0700

ahhhh, ok.

Yeah, this object (as well as most of the bluetooth stack objects) heavily rely on delegate driven IO.  The return value from  "connectToObjectPushService:" is only an initial value, not the final value.  It says that "sure, looks like Im ok to _try_ to connect...".  You've gotta look at the return value from the callback to know how the operation went.   It may seem overly complex but its a really powerful mechanism, and one that you're going to be using in most of the Bluetooth objects.   A lot can happen in the connection process: pairing, user interactions, etc, and it makes no sense to stall the caller while the connection takes place.  Let me know if you have any more problems once you get the delegate methods in place.

mat

PS- I've CC'd this to the list for future reference by other users.



On May 27, 2005, at 5:06 PM, Christian Klein wrote:


Am 28.05.2005 um 01:52 schrieb mat davidson:

Not to review the obvious, but I just wanted to make sure that you're receiving that return value from the connection delegate method and not from the call to connectToObjectPushService.  Is this the case?

You've set the FTS object delegate and are receiving a callback on the delegate method:

- (void) fileTransferServicesConnectionComplete: (OBEXFileTransferServices*)inServices
                                          error: (OBEXError)inError

with a kOBEXSuccess value?

I don't use a delegate object (is it a bad idea?), this is the code I use:
(it's more experimental code to get used to the framework)


    IOBluetoothDeviceInquiry *inquiry;
    id delegator;
    IOReturn result;

    delegator = [[DelegateObject alloc] init]; // delegator is just a dummy object with some NSLog calls

    inquiry = [IOBluetoothDeviceInquiry inquiryWithDelegate: delegator];
    [inquiry setInquiryLength: 10];
    [inquiry setUpdateNewDeviceNames: YES];


        [inquiry start];

      sleep(10);

      [inquiry stop];
     

        id device, deviceEnumerator;

        deviceEnumerator = [[inquiry foundDevices] objectEnumerator];

        while(device = [deviceEnumerator nextObject]) {
            NSLog(@"found device: %@", [device getNameOrAddress]);
            sendPic(device);
        }


void sendPic(id target)
{
//    BluetoothRFCOMMChannelID channelID = 5;
    BluetoothRFCOMMChannelID channelID = 4;

    OBEXError obxerr;

    id obexSession = [IOBluetoothOBEXSession withDevice: target channelID: channelID];
    id fileTransfer = [OBEXFileTransferServices withOBEXSession: obexSession];

    obxerr = [fileTransfer connectToObjectPushService];

    switch(obxerr) {

        case kOBEXSuccess:
                puts("success");
                break;

        case kOBEXSessionBusyError:
                puts("session busy");
                break;

        case kOBEXSessionAlreadyConnectedError:
                puts("already connected");
                break;

        case kOBEXNoResourcesError:
                puts("no resource");
                break;

        default:
                puts("unknown error");
    }

    NSLog(@"is connected: %s", [fileTransfer isConnected] == YES ? "YES" : "NO");

    [fileTransfer sendFile: @"/Users/chris/Pictures/me.jpg"];
}


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >OBEX question (From: Christian Klein <email@hidden>)
 >Re: OBEX question (From: mat davidson <email@hidden>)
 >Re: OBEX question (From: Christian Klein <email@hidden>)

  • Prev by Date: Re: OBEX question
  • Next by Date: Favorites serve what purpose?
  • Previous by thread: Re: OBEX question
  • Next by thread: Re: OBEX question
  • Index(es):
    • Date
    • Thread