Re: OBEX - getting a folder listing
site_archiver@lists.apple.com Delivered-To: bluetooth-dev@lists.apple.com User-agent: Thunderbird 1.5.0.10 (Macintosh/20070221) I've just started trying out the bluetooth sample projects. I played with "OBEXSample", which uses the OBEX File Transfer Profile (FTP). While the Put command works (I connect to a second Mac), Get and SetPath return errors. I can't figure out what's wrong there. Reading the OBEX FTP docs I found that the connection should be created using a particular UUID. The sample code does not seem to do this. I can't figure out how to add this UUID. I can't find docs about this, either, at least not using the plain C interfaces. Has someone dealt with this before and has a working version that you can send me, please? Thomas First of all I recommend to use Objective-C when working with Bluetooth. You can then get the channel id for a given device like this: } Now you can open the Obex session: and then the ObexFileTransferService Next is to open the connection: status = [mFileTransferService connectToFTPService]; if(inError == kOBEXSuccess) { NSLog(@"it is connected!"); } else { NSLog(@"Connection failed, I'm disappointed..."); } } status = [mFileTransferService retrieveFolderListing]; Again release control to CFRunLoop and provide a callback function: error:(OBEXError)inError listing:(NSArray*)inListing { NSLog ([inListing description]; // Here is you directory } Ralf Menssen _______________________________________________ Do not post admin requests to the list. They will be ignored. Bluetooth-dev mailing list (Bluetooth-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/bluetooth-dev/site_archiver%40lists.a... Thomas Tempelmann schrieb: Regarding the UUID, look into "BluetoothAssignedNumbers.h". You can create the UUID like this: IOBluetoothSDPUUIDRef ourUUID = IOBluetoothSDPUUIDCreateUUID16 ((UInt16) kBluetoothSDPUUID16ServiceClassOBEXFileTransfer); IOBluetoothDevice *btDevice; // comes from somewhere BluetoothRFCOMMChannelID channelID; dialupServiceRecord = [btDevice getServiceRecordForUUID:(IOBluetoothSDPUUID *)ourUUID]; if (dialupServiceRecord) { IOReturn status = [dialupServiceRecord getRFCOMMChannelID:&channelID]; if (status == noErr) { // You got it in channelID! } IOBluetoothOBEXSession *mOBEXSession; mOBEXSession = [IOBluetoothOBEXSession withDevice:btDevice channelID:channelID]; [mOBEXSession retain]; // MUST BE DONE mFileTransferService = [OBEXFileTransferServices withOBEXSession:mOBEXSession]; if( !mFileTransferService ) { return -1; } [mFileTransferService setDelegate: self]; // register for the callbacks [mFileTransferService retain]; and now your software must release control to CFRunLoop so that the callback function can be called when the connect was handled. So you have to provide a function in your delegate: - (void) fileTransferServicesConnectionComplete:(OBEXFileTransferServices *)inServices error:(OBEXError)inError { Now you can ask for the content for the current directory (after connection it is "/") - (void) fileTransferServicesRetrieveFolderListingComplete:(OBEXFileTransferServices*)inServices This email sent to site_archiver@lists.apple.com
participants (1)
-
Ralf Menssen