Hello list,
I'm using IOBluetoothOBEXSession and OBEXFileTransferServices (method sendFile) to push a file to a device via OBEX. It works well in general, but some devices are not able to receive files for various reasons: 1.) User does not respond to the "Do you want to accept the file?" question 2.) Receiving device is too busy or out of reach 3.) etc.
Therefore I'd like to implement a timeout so that the thread which tries to send a file does not wait forever until the receiver is ready. Is the Bluetooth API capable of setting timeouts etc? I had a look at the documentation but couldn't find anything. I did some tests, in some cases (e.g. if I try to send a file to a Nokia N95 without responding to the "Do you want to accept the file?" question) the delegate method fileTransferServicesDisconnectionComplete gets called with error kOBEXSessionTransportDiedError ("The underlying transport connection (Bluetooth, etc.) died."). However, in many cases just nothing happens and I'd like to find a timeout solution for that.
Thanks, Thomas
PS: Here is the code that I currently use:
BluetoothDeviceAddress devAddress; IOBluetoothSDPServiceRecord *record; IOBluetoothDevice *device; OBEXFileTransferServices * mTransferServices; IOBluetoothOBEXSession * mOBEXSession;
IOBluetoothNSStringToDeviceAddress(@"00-17-b0-9f-a1-0c", &devAddress);
device = [IOBluetoothDevice withAddress:&devAddress];
// Get the service record of the service we want to use record = [device getServiceRecordForUUID:[IOBluetoothSDPUUID uuid16:kBluetoothSDPUUID16ServiceClassOBEXObjectPush]];
// Use the record to form an OBEX Session object mOBEXSession = [IOBluetoothOBEXSession withSDPServiceRecord: record]; [mOBEXSession retain];
// Send the OBEXSession off to FTS mTransferServices = [OBEXFileTransferServices withOBEXSession: mOBEXSession]; [mTransferServices retain]; [mTransferServices setDelegate: self]; [mTransferServices connectToObjectPushService];
- (void) fileTransferServicesConnectionComplete:(OBEXFileTransferServices*)inServices error:(OBEXError)inError { [mTransferServices sendFile: @"/Users/thomas/Documents/test.pdf"]; }
|