Progress with bluetooth

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Progress with bluetooth

Davide Varvello-2
Progress with bluetooth

Hi All,

Here is my first spike with squeak, bluetooth and osx, if you look at a previous thread you can see I use the ObjectiveC plugin by Avi.
So.. the code:

bundle := NSBundle bundleWithPath:'/System/Library/Frameworks/IOBluetoothUI.framework'.
bundle load.

selectorController := bundle classNamed:'IOBluetoothDeviceSelectorController'.
deviceSelector := selectorController deviceSelector.
deviceSelector runModal.
deviceSelector getResults.

If you paste it in a workspace you should see the selector window open itself and you can choose the bluetooth device you want to connect.

bye
 Davide



Reply | Threaded
Open this post in threaded view
|

Re: Progress with bluetooth

Davide Varvello-2
Hi All,
  Other progress with bluetooth.
As I don't like to use the GUI to interface my bluetooth devices, I  
explored more the IOBluetooth.framework to start a device discovery.  
Here the code:

bundle := NSBundle bundleWithPath:'/System/Library/Frameworks/
IOBluetooth.framework'.
bundle load.

inquiry := (bundle classNamed:'IOBluetoothDeviceInquiry') new.

inquiry start.
inquiry stop.

someDevices := inquiry foundDevices.
someDevices count.
bluetoothDevice := someDevices objectAtIndex:0.



It's simple and clean, isn't it?
Now, the next step is to start a communication. I'll update you next  
days.

bye
  Davide



Reply | Threaded
Open this post in threaded view
|

bluetooth - some problems

Davide Varvello-2
Hi All,
After a while here I'm with my experiments with squeak, bluetooth and  
my mac.
I've some problems to connect to a device and establish an OBEX  
connection (an ftp connection).
As you can see from the attached class there are 2 methods: firstStep  
and secondStep. In the firstStep I'm trying to connect to the ftp  
service of the device and then in the secondStep I'm going to send an  
image.
If you call these two methods in a row, you'll probably see some  
prints in the transcript like these ones:

firstStep:
bluetoothDevice isConnected - 0
obexSession hasOpenTransportConnection - 0
transfer isBusy - 1
transfer isConnected - 0

secondStep:
bluetoothDevice isConnected - 0
obexSession hasOpenTransportConnection - 0
transfer isBusy - 1
transfer isConnected - 0

As you can see transfer is always busy, and I can't understand why.
Instead the same objective-c code (this is also in attachment) shows  
other kinds of prints, and it really permits the connection to the  
device.
If you see the methods are: selectAndOpenFTPDevice and  
actionSelectImage, the first is like my firstStep method, the second  
is a method that shows a dialog to choose an image to send. When  
selectAndOpenFTPDevice is executed, the console shows:


2006-02-01 14:42:55.499 bluespam[777]  
selectAndOpenFTPDevice----------------------
2006-02-01 14:42:55.499 bluespam[777] mTransferServices isBusy

and when actionSelectImage is executed the console shows:

2006-02-01 14:43:01.690 bluespam[777] actionSelectImage before  
sending-------------------
2006-02-01 14:43:01.690 bluespam[777] mBluetoothDevice isConnected
2006-02-01 14:43:01.691 bluespam[777] mOBEXSession  
hasOpenTransportConnection
2006-02-01 14:43:01.691 bluespam[777] mTransferServices isConnected

than you can go on and succesfully sending the image

That's different from my prints on the transcript, and it seems to me  
the my squeak spike blocks somehow the connection, but I don't know why.
Can you help me, please?
TIA
Davide



p.s. a more elaborated example of the objc code is here: http://
lists.apple.com/archives/bluetooth-dev/2005/Jul/msg00005.html


BTSpike.st (2K) Download Attachment
SpamController.m (5K) Download Attachment