[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Bluetooth on OSX

varvello@yahoo.com

2/20/2006 8:39:00 PM

Hi,
I'm trying to connect, over bluetooth, to a mobile device and send a
picure.
That's my code:

require 'osx/cocoa'

OSX::NSBundle.bundleWithPath("/System/Library/Frameworks/IOBluetoothUI.framework").load

OSX.ns_import :IOBluetoothDeviceSelectorController

bluedevices = OSX::IOBluetoothDeviceSelectorController.deviceSelector
bluedevices.runModal;
result = bluedevices.getResults;

bluetoothDevice = result.objectAtIndex(0);

OSX::NSBundle.bundleWithPath("/System/Library/Frameworks/IOBluetooth.framework").load;
OSX.ns_import :IOBluetoothOBEXSession;
obexSession =
OSX::IOBluetoothOBEXSession.withDevice_channelID(bluetoothDevice, 9);

OSX.ns_import :OBEXFileTransferServices;
service = OSX::OBEXFileTransferServices.withOBEXSession(obexSession);

connectResult = service.connectToFTPService;
puts connectResult;
sleep 3;
sendResult=service.sendFile("/Users/davide/myPicture.jpeg");
puts sendResult;
sleep 3;
service.disconnect;

I know the channel id for ftp on my device is 9, puts connectResult
displays 0, but puts sendResult shows -21875 (i.e busy) and of course,
no picture is sent to the device.
Do you understand this behavior?
TIA
Davide

1 Answer

varvello@yahoo.com

2/21/2006 8:28:00 PM

0

Any hints?
Davide



varvello@yahoo.com wrote:
> Hi,
> I'm trying to connect, over bluetooth, to a mobile device and send a
> picure.
> That's my code:
>
> require 'osx/cocoa'
>
> OSX::NSBundle.bundleWithPath("/System/Library/Frameworks/IOBluetoothUI.framework").load
>
> OSX.ns_import :IOBluetoothDeviceSelectorController
>
> bluedevices = OSX::IOBluetoothDeviceSelectorController.deviceSelector
> bluedevices.runModal;
> result = bluedevices.getResults;
>
> bluetoothDevice = result.objectAtIndex(0);
>
> OSX::NSBundle.bundleWithPath("/System/Library/Frameworks/IOBluetooth.framework").load;
> OSX.ns_import :IOBluetoothOBEXSession;
> obexSession =
> OSX::IOBluetoothOBEXSession.withDevice_channelID(bluetoothDevice, 9);
>
> OSX.ns_import :OBEXFileTransferServices;
> service = OSX::OBEXFileTransferServices.withOBEXSession(obexSession);
>
> connectResult = service.connectToFTPService;
> puts connectResult;
> sleep 3;
> sendResult=service.sendFile("/Users/davide/myPicture.jpeg");
> puts sendResult;
> sleep 3;
> service.disconnect;
>
> I know the channel id for ftp on my device is 9, puts connectResult
> displays 0, but puts sendResult shows -21875 (i.e busy) and of course,
> no picture is sent to the device.
> Do you understand this behavior?
> TIA
> Davide