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"];
}